Hier die Initialisierung des DMA + SPI
1 |
|
2 | DmaChannel dmaTxChn=DMA_CHANNEL1;
|
3 |
|
4 | SpiChannel spiTxChn=SPI_CHANNEL4;
|
5 |
|
6 | SpiChnOpen(spiTxChn, SPI_OPEN_MSTEN|SPI_OPEN_SMP_END|SPI_OPEN_MODE8, 100);
|
7 |
|
8 | DmaChnOpen(dmaTxChn, DMA_CHN_PRI2, DMA_OPEN_DEFAULT);
|
9 |
|
10 | DmaChnSetEventControl(dmaTxChn, DMA_EV_START_IRQ_EN|DMA_EV_START_IRQ(_SPI4_TX_IRQ));
|
11 |
|
12 | DmaChnSetTxfer(dmaTxChn, dmaBuffer, (void*)&SPI4BUF, sizeof(dmaBuffer), 1, 1);
|
13 |
|
14 | DmaChnSetEvEnableFlags(dmaTxChn, DMA_EV_BLOCK_DONE);
|
15 |
|
16 | INTConfigureSystem(INT_SYSTEM_CONFIG_MULT_VECTOR);
|
17 | INTEnableInterrupts();
|
18 |
|
19 | INTSetVectorPriority(INT_VECTOR_DMA(dmaTxChn), INT_PRIORITY_LEVEL_5);
|
20 | INTSetVectorSubPriority(INT_VECTOR_DMA(dmaTxChn), INT_SUB_PRIORITY_LEVEL_3);
|
21 |
|
22 | INTEnable(INT_SOURCE_DMA(dmaTxChn), INT_ENABLED);
|
23 |
|
24 | DmaTxIntFlag=0;
|
Und hier wird das Array gesendet,
1 | if(newPressed){
|
2 | dmaBuff[0] = 123;
|
3 | dmaBuff[1] = 0xff;
|
4 | dmaBuff[2] = pressedKeys;
|
5 | for(i=3;i<12;i++)
|
6 | dmaBuff[i] = 'U';
|
7 | DmaChnStartTxfer(DMA_CHANNEL1, DMA_WAIT_NOT, 0);
|
8 | newPressed = 0;
|
9 | pressedKeys = 0;
|
10 | }
|
und noch die ISR
1 |
|
2 | void __ISR(_DMA1_VECTOR, ipl5) IpcDmaHandler(void)
|
3 | {
|
4 | int evFlags; // event flags when getting the interrupt
|
5 |
|
6 | INTClearFlag(INT_SOURCE_DMA(DMA_CHANNEL1));
|
7 | evFlags=DmaChnGetEvFlags(DMA_CHANNEL1);
|
8 |
|
9 | if(evFlags&DMA_EV_BLOCK_DONE)
|
10 | {
|
11 | DmaTxIntFlag=1;
|
12 |
|
13 | DmaChnClrEvFlags(DMA_CHANNEL1, DMA_EV_BLOCK_DONE);
|
14 | }
|
15 | }
|
dmaBuff[0] = 123;
dmaBuff[1] = 0xff; <-----NICHT AUF DEM OSZI ZU SEHEN
dmaBuff[2] = pressedKeys;