// send data extern bool phy_tx_data(phy_tx_cfg_t* cfg) { //TODO Return error if fec not enabled but requested #ifdef D7_PHY_USE_FEC if (fec) { //Initialize fec encoding fec_init_encode(cfg->data); //Configure length settings set_length_infinite(true); fec_set_length(cfg->length); remainingBytes = ((cfg->length & 0xFE) + 2) << 1; WriteSingleReg(PKTLEN, (uint8_t)(remainingBytes & 0x00FF)); } else { #endif //Set buffer position bufferPosition = cfg->data; //Configure length settings set_length_infinite(false); remainingBytes = cfg->length; WriteSingleReg(PKTLEN, (uint8_t)remainingBytes); #ifdef D7_PHY_USE_FEC } #endif //Write initial data to txfifo tx_data_isr(); //Configure txfifo threshold WriteSingleReg(FIFOTHR, RADIO_FIFOTHR_FIFO_THR_17_48); //Enable interrupts radioClearInterruptPendingLines(); phy_set_gdo_values(GDOLine2, GDO_EDGE_TXBelowThresh, GDO_SETTING_TXBelowThresh); // phy_set_gdo_values(GDOLine2, GDO_EDGE_TXUnderflow, GDO_SETTING_TXUnderflow); phy_set_gdo_values(GDOLine0, GDO_EDGE_EndOfPacket, GDO_SETTING_EndOfPacket); radioEnableGDO2Interrupt(); radioEnableGDO0Interrupt(); //Start transmitting Strobe(RF_STX); return true; }
unsigned int test_fec_decoding(void) { uint8_t input[15] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E}; uint8_t output[32]; TimerA_configureContinuousMode(__MSP430_BASEADDRESS_T0A5__, TIMERA_CLOCKSOURCE_SMCLK, TIMERA_CLOCKSOURCE_DIVIDER_1, TIMERA_TAIE_INTERRUPT_DISABLE, TIMERA_DO_CLEAR); fec_init_encode(input); fec_set_length(15); fec_encode(&output[0]); fec_encode(&output[4]); fec_encode(&output[8]); fec_encode(&output[12]); fec_encode(&output[16]); fec_encode(&output[20]); fec_encode(&output[24]); fec_encode(&output[28]); memset(input, 0, 15); fec_init_decode(input); fec_set_length(15); TimerA_clear(__MSP430_BASEADDRESS_T0A5__); fec_decode(&output[0]); fec_decode(&output[4]); fec_decode(&output[8]); fec_decode(&output[12]); fec_decode(&output[16]); fec_decode(&output[20]); fec_decode(&output[24]); fec_decode(&output[28]); TimerA_stop(__MSP430_BASEADDRESS_T0A5__); return TA0R - TIMER_OFFSET; }