#include #include #include #include // Just to make it easier: // DMA14_CONFIG is a structure which has four DMA_CONFIG // DMA_CONFIG is the hardware configuration registers // In wixel, the first channel was used for radio so lets keep it that way // for now. If we encounter problems later on, will change that accordingly // _2, _3 and _4 were unassigned. For ADXL377, which is a 3 axes device, // it will be assigned to x, y and z // And finally lets use DMA to receive packets by radio // DMA14_CONFIG XDATA dmaConfig; DMA_CONFIG XDATA radioRxConfig; void dmaInit(void) { DMA1CFG = (uint16)&dmaConfig; } /******************************************************************************* * @fn initDma * * @brief This function clears all interrupt flags and disarms all DMA channels 1 to 4. * This function is written specifically for a different application * * @parm none * * @return void * * DMA is used by the following functions * buffers to radio * port 0_0 ADC * port 0_1 ADC * port 0_2 ADC * All DMA related registers should be initialized for the above four functions * */ void initDma(void) { // ARM channels 0, 1 and 2 DMAARM &= (DMA_CHANNEL_0 | DMA_CHANNEL_1 | DMA_CHANNEL_2); DMAARM |= (DMA_CHANNEL_0 | DMA_CHANNEL_1 | DMA_CHANNEL_2); DMAREQ &= (DMA_CHANNEL_0 | DMA_CHANNEL_1 | DMA_CHANNEL_2); DMAREQ |= (DMA_CHANNEL_0 | DMA_CHANNEL_1 | DMA_CHANNEL_2); DMAIE = 1; // Enable DMA Interrupt DMA0CFG = (uint16)&radioRxConfig; //Initialize the structure to Rx Pkts DMA1CFG = (uint16)&dmaConfig; //Initialize all 4 channels as done in // original code // Clearing the interrupt flag of the DMA and enabling DMA interrupt. // INT_SETFLAG(INUM_DMA, INT_CLR); // INT_ENABLE(INUM_DMA, INT_ON); // DMA_SET_ADDR_DESC1234(&dmaConfig); Not required to do this as // with the current compiler, the above statements will take care of // high and low bytes }