uint16_t hal_nrf_read_multibyte_reg(uint8_t reg, uint8_t *buf) { uint8_t ctr, length; uint8_t memtype; uint8_t read_byte, dummy = 0U; /*lint -esym(530,read_byte) symbol not initialized*/ bool first_round; first_round = true; switch(reg) { case HAL_NRF_PIPE0: case HAL_NRF_PIPE1: case HAL_NRF_TX: length = ctr = hal_nrf_get_address_width(); CSN_LOW(); hal_nrf_rw(RX_ADDR_P0 + reg); break; case HAL_NRF_RX_PLOAD: reg = hal_nrf_get_rx_data_source(); if (reg < 7U) { length = ctr = hal_nrf_read_rx_payload_width(); CSN_LOW(); hal_nrf_rw(R_RX_PAYLOAD); } else { ctr = length = 0U; } break; default: ctr = length = 0U; break; } while( ctr-- ){ HAL_SPI_TransmitReceive(&SpiHandle, (uint8_t*)&dummy, (uint8_t *)buf++, 1, 5000); /*if (!first_round) \ { \ *buf = read_byte; \ buf++; \ } \ else \ { \ first_round = false; \ } \*/ /* wait for byte transfer finished */ \ } //*buf = read_byte; CSN_HIGH(); return (((uint16_t) reg << 8) | length); }
static uint8_t hal_nrf_read_reg(uint8_t data reg) { uint8_t temp; CSN_LOW(); hal_nrf_rw(reg); temp = hal_nrf_rw(0); CSN_HIGH(); return temp; }
uint16_t hal_nrf_read_multibyte_reg(uint8_t reg, uint8_t *pbuf) { uint8_t ctr, length; uint8_t memtype; uint8_t read_byte = 0; /*lint -esym(530,read_byte) symbol not initialized*/ bool first_round; first_round = true; memtype = *(uint8_t*)(&pbuf); switch(reg) { case HAL_NRF_PIPE0: case HAL_NRF_PIPE1: case HAL_NRF_TX: length = ctr = hal_nrf_get_address_width(); CSN_LOW(); hal_nrf_rw(RX_ADDR_P0 + reg); break; case HAL_NRF_RX_PLOAD: reg = hal_nrf_get_rx_data_source(); if (reg < 7U) { length = ctr = hal_nrf_read_rx_payload_width(); CSN_LOW(); hal_nrf_rw(R_RX_PAYLOAD); } else { ctr = length = 0U; } break; default: ctr = length = 0U; break; } if (memtype == 0x00U) { uint8_t data *buf = (uint8_t data *)pbuf; NRF_READ_MULTIBYTE_REG_COMMON_BODY }
uint8_t hal_nrf_nop(void) { uint8_t retval; CSN_LOW(); retval = hal_nrf_rw(NOP); CSN_HIGH(); return retval; }
uint16_t hal_nrf_read_multibyte_reg(uint8_t data reg, uint8_t data *pbuf) { uint8_t data ctr, length; switch(reg) { case HAL_NRF_PIPE0: case HAL_NRF_PIPE1: case HAL_NRF_TX: length = ctr = hal_nrf_get_address_width(); CSN_LOW(); hal_nrf_rw(RX_ADDR_P0 + reg); break; case HAL_NRF_RX_PLOAD: if( (reg = hal_nrf_get_rx_data_source()) < 7) { length = ctr = hal_nrf_read_rx_payload_width(); CSN_LOW(); hal_nrf_rw(R_RX_PAYLOAD); } else { ctr = length = 0; } break; default: ctr = length = 0; break; } while(ctr--) { *pbuf++ = hal_nrf_rw(0); } CSN_HIGH(); return (((uint16_t) reg << 8) | length); }
void hal_nrf_read_payload(u8 *buf, u8 length) { u8 i; CSN_LOW(); hal_nrf_rw(R_RX_PAYLOAD); for(i=0; i<length; i++){ HAL_NRF_HW_SPI_WRITE(0U); while(HAL_NRF_HW_SPI_BUSY){} buf[i] = HAL_NRF_HW_SPI_READ(); } CSN_HIGH(); }
void hal_nrf_flush_tx(void) { CSN_LOW(); hal_nrf_rw(FLUSH_TX); CSN_HIGH(); }
void hal_nrf_reuse_tx(void) { CSN_LOW(); hal_nrf_rw(REUSE_TX_PL); CSN_HIGH(); }