bool ieee802_15_4_reset(bool set_default_pib) {
    
    /* Reset the MAC's internal state. */
    IEEE802_15_4_SET_STATE(IEEE_MAC_IDLE);
    
    uint8_t reset_status = false;
    if (true != tat_init()) {
        tat_deinit();
    } else{
        
        /* Reset the PIBs if requested. */
        if (true == set_default_pib) {
            ieee802_15_4_pib_init();
        }
        
        /* Reset callback TAT callback handlers. */
        tat_set_tx_callback_handler(ieee802_15_4_send_ack_event_handler);
        tat_set_rx_callback_handler(ieee802_15_4_pd_data_indication);
        
        /* Configure the radio transceiver; CMSA and frame filer. */
        rf230_subregister_write(SR_MIN_BE, macMinBE_def);
        rf230_subregister_write(SR_MAX_CSMA_RETRIES, macMaxCSMABackoffs_def);
        rf230_subregister_write(SR_MAX_FRAME_RETRIES, aMaxFrameRetries);
        
        tat_set_ieee_address((uint8_t *)(&IEEE802_15_4_GET_EXTENDED_ADDRESS()));
        tat_set_short_address(IEEE802_15_4_GET_SHORT_ADDRESS());
        tat_set_pan_id(IEEE802_15_4_GET_PAN_ID());
        
        /* Go to sleep if configured to do so. Otherwise the radio transceiver will
         * stay in TRX_OFF state.
         */
        if (false == IEEE802_15_4_GET_RX_ON_WHEN_IDLE()) {
            tat_go_to_sleep();
        }
        
        reset_status = true;
    }
    
    return reset_status;
}
Пример #2
0
/** @brief IRIS: This function is used to initialize the TRX.
 *
 *  @return true if the TRX was successfully configured.
 *  @return false if the TRX was not configured properly.
 */
inline bool2 trx_init( void ){
    
    static bool2 status;
    
    if (tat_init( ) != TAT_SUCCESS) {
        //Leds_yellowToggle();  //Debug--Redtoggle Upon
        status = false;
    } else if (tat_set_operating_channel( 21 ) != TAT_SUCCESS) {
        status = false;
    } else if (tat_set_clock_speed( true, CLKM_DISABLED ) != TAT_SUCCESS) {
        status = false; 
    } else{
        tat_use_auto_tx_crc( true ); //Automatic CRC must be enabled.
        status = true;
    } // end: if (tat_init( ) != TAT_SUCCESS) ...

    rf230radiom_currentDSN = 0;
    
    if (tat_set_trx_state( RX_ON )==TAT_SUCCESS) {}
	   else
     {}
    return status;
}