예제 #1
0
파일: wixelNode.c 프로젝트: kshn/Wixel_599
void perTestTxInit()
{
    uint8 i;

    radioRegistersInit();

    CHANNR = param_radio_channel_1;

    PKTLEN = RADIO_PACKET_SIZE;
    
    MCSM0 = 0x14;    // Auto-calibrate when going from idle to RX or TX.
    MCSM1 = 0x00;    // Disable CCA.  After RX, go to IDLE.  After TX, go to IDLE.
    // We leave MCSM2 at its default value.

    IOCFG2 = 0b011011; // put out a PA_PD signal on P1_7 (active low when the radio is in TX mode)

    dmaConfig.radio.DC6 = 19; // WORDSIZE = 0, TMODE = 0, TRIG = 19

    dmaConfig.radio.SRCADDRH = (unsigned int)packet >> 8;
    dmaConfig.radio.SRCADDRL = (unsigned int)packet;
    dmaConfig.radio.DESTADDRH = XDATA_SFR_ADDRESS(RFD) >> 8;
    dmaConfig.radio.DESTADDRL = XDATA_SFR_ADDRESS(RFD);
    dmaConfig.radio.LENL = 1 + RADIO_PACKET_SIZE;
    dmaConfig.radio.VLEN_LENH = 0b00100000; // Transfer length is FirstByte+1
    dmaConfig.radio.DC7 = 0x40; // SRCINC = 1, DESTINC = 0, IRQMASK = 0, M8 = 0, PRIORITY = 0
    
    for(i = 1; i < sizeof(packet); i++)
    {
        packet[i] = 'A' + i;
    }
    packet[0] = RADIO_PACKET_SIZE;

    RFST = 4;  // Switch radio to Idle mode.
}
예제 #2
0
/* dma_init:  	A function to initialise the DMA channel for use in erasing and storing data in flash.
Parameters:		none.
Returns :		void.
Uses :			writeBuffer - A global variable we can address as the write buffer for writing data.
*/
 void dma_Init(){
	// Configure the flash write timer.  See section 12.3.5 of the datasheet.
	FWT = 32;

	// Set up the DMA configuration block we use for writing to flash (See Figure 21 of the datasheet).
	// LENL and LENH are sent later when we know how much data to write.
	flashWriteDmaConfig.SRCADDRH = (unsigned short)&writeBuffer >> 8;
	flashWriteDmaConfig.SRCADDRL = (unsigned char)&writeBuffer;
	flashWriteDmaConfig.DESTADDRH = XDATA_SFR_ADDRESS(FWDATA) >> 8;
	flashWriteDmaConfig.DESTADDRL = XDATA_SFR_ADDRESS(FWDATA);

	// WORDSIZE = 0     : byte
	// TMODE = 0        : single mode
	// TRIG = 0d18      : flash
	flashWriteDmaConfig.DC6 = 18;

	// SRCINC = 01      : yes
	// DESTINC = 00     : no
	// IRQMASK = 0      : no   *datasheet said this bit should be 1
	// M8 = 0           : 8-bit transfer
	// PRIORITY = 0b10  : high
	flashWriteDmaConfig.DC7 = 0b01000010;

	DMA0CFG = (uint16)&flashWriteDmaConfig;
}