void set_address(char *address, int address_size) { spi_csl(); spi_send(NRF_WRITE | NRF_TX_ADDR); spi_send_buffer(address, address_size); spi_csh(); spi_csl(); spi_send(NRF_WRITE | NRF_RX_ADDR_P0); spi_send_buffer(address, address_size); spi_csh(); }
char nrf_rx() { char tmp; spi_csl(); spi_send(NRF_R_PAYLOAD); tmp = spi_send(NRF_NOOP); spi_csh(); return tmp; }
char nrf_read( char address ) { char tmp; spi_csl(); spi_send(NRF_READ | address); tmp = spi_send(NRF_NOOP); spi_csh(); return tmp; }
void nrf_tx(char data) { char tmp = nrf_read(NRF_FIFO_STATUS); if(tmp & NRF_STAT_TX_FULL) { return; } radio_on(); spi_csl(); spi_send(NRF_TX); spi_send(data); spi_csh(); nrf_ceh(); //start transmission (pulse CE > 10us) __delay_cycles(20); nrf_cel(); __delay_cycles(1000); radio_off(); }
void draw_square() { int count = 0; if(change_duty) { square_wave_init(); change_duty = 0; } while(count < NUM_DIVISIONS) { if (timeCount > oldTimeCount) { oldTimeCount = timeCount; spi_csl(); spi_xfer_byte((squareVals[count] | 0x1000) >> 8); spi_xfer_byte(squareVals[count++] & 0xFF); spi_csh(); } }
void send_command(char command) { spi_csl(); spi_send(command); spi_csh(); }
void nrf_write(char address, char data) { spi_csl(); spi_send(NRF_WRITE | address); spi_send(data); spi_csh(); }