void gzll_get_address(uint8_t pipe, uint8_t* address) { ASSERT((pipe <= 5)); ASSERT(address != NULL); gzll_interupts_disable_rfck_enable(); hal_nrf_get_address(pipe, address); //lint !e534 "return value ignored" gzll_interupts_enable_rfck_disable(); }
void gzll_get_address(uint8_t pipe, uint8_t* address) { uint32_t flag; ASSERT((pipe <= 5)); ASSERT(address != NULL); flag = gzll_interupts_save(); hal_nrf_get_address(pipe, address); //lint !e534 "return value ignored" gzll_interupts_restore(flag); }
bool gzll_tx_data(const uint8_t *src, uint8_t length, uint8_t pipe) { uint8_t temp_address[GZLL_ADDRESS_WIDTH]; uint16_t temp; uint32_t flag; ASSERT(length <= GZLL_MAX_FW_PAYLOAD_LENGTH && length > 0); ASSERT(pipe <= 5); /* Length check to prevent memory corruption. (Note, assertion will capture this as well). */ if(length == 0 || length > GZLL_MAX_FW_PAYLOAD_LENGTH) { return false; } gzll_current_tx_payload_length = length; if(gzll_state_var == GZLL_HOST_ACTIVE) { gzll_goto_idle(); } flag = gzll_interupts_save(); /* If the specified pipe is different from the previous TX pipe, the TX setup must be updated */ if(pipe != gzll_current_tx_pipe) { gzll_current_tx_pipe = pipe; gzll_tx_setup_modified = true; } /* Here, state can be GZLL_IDLE or GZLL_DEVICE_ACTIVE */ if(gzll_state_var == GZLL_IDLE) { if(gzll_tx_setup_modified) // TX setup has to be restored? { gzll_tx_setup_modified = false; gzll_rx_setup_modified = true; hal_nrf_set_operation_mode(HAL_NRF_PTX); hal_nrf_open_pipe(HAL_NRF_PIPE0, EN_AA); //Read out the full RX address for pipe number "pipe" if(pipe == HAL_NRF_PIPE0) { hal_nrf_set_address(HAL_NRF_TX, gzll_p0_adr); hal_nrf_set_address(HAL_NRF_PIPE0, gzll_p0_adr); } else { //lint -esym(550,bytes_in_buffer) "variable not accessed" //lint -esym(438,bytes_in_buffer) "last assigned value not used" uint8_t bytes_in_buffer; bytes_in_buffer = hal_nrf_get_address(HAL_NRF_PIPE1, temp_address); if(pipe != HAL_NRF_PIPE1) { switch(pipe) { default: case HAL_NRF_PIPE2: bytes_in_buffer = hal_nrf_get_address(HAL_NRF_PIPE2, temp_address); break; case HAL_NRF_PIPE3: bytes_in_buffer = hal_nrf_get_address(HAL_NRF_PIPE3, temp_address); break; case HAL_NRF_PIPE4: bytes_in_buffer = hal_nrf_get_address(HAL_NRF_PIPE4, temp_address); break; case HAL_NRF_PIPE5: bytes_in_buffer = hal_nrf_get_address(HAL_NRF_PIPE5, temp_address); break; } bytes_in_buffer = bytes_in_buffer; } //Here, temp_address will contain the full TX address hal_nrf_set_address(HAL_NRF_PIPE0, temp_address); hal_nrf_set_address(HAL_NRF_TX, temp_address); /* Change seed for random generator. Will prevent different devices transmitting to the same host from using the same channel hopping sequence. */ //lint -esym(534, gzll_lfsr_get) "return value ignored" gzll_lfsr_get(pipe, 1); } } // Prepare for new transmission gzll_timeout_counter = 0; gzll_channel_switch_counter = 0; gzll_try_counter = 0; hal_nrf_flush_tx(); GZLL_UPLOAD_PAYLOAD_TO_RADIO(); gzll_tx_success_f = false; // Transmission by default "failure" temp = gzll_dyn_params[GZLL_PARAM_DEVICE_MODE]; gzll_set_radio_power_on(true); if(gzll_sync_on) { switch(temp) { case GZLL_DEVICE_MODE_2: default: gzll_start_new_tx(GZLL_CHANNEL_PREVIOUS_SUCCESS); break; case GZLL_DEVICE_MODE_3: gzll_start_new_tx(GZLL_CHANNEL_RANDOM); break; case GZLL_DEVICE_MODE_4: gzll_start_new_tx(GZLL_CHANNEL_ESTIMATED); break; } } else { switch(temp) { case GZLL_DEVICE_MODE_0: case GZLL_DEVICE_MODE_2: gzll_start_new_tx(GZLL_CHANNEL_PREVIOUS_SUCCESS); break; default: gzll_start_new_tx(GZLL_CHANNEL_RANDOM); break; } } gzll_state_var = GZLL_DEVICE_ACTIVE; gzll_interupts_restore(flag); return true; // Payload successfully written to TX FIFO } else // Else TRANSMIT state { /* Check if criteria for starting new transmission when already transmitting is fulfilled */ if(!gzll_tx_setup_modified && !hal_nrf_tx_fifo_full() ) { GZLL_UPLOAD_PAYLOAD_TO_RADIO(); gzll_interupts_restore(flag); return true; // Payload successfully written to TX FIFO } else { gzll_interupts_restore(flag); return false; // Payload not written to TX FIFO } } }