diff options
| author | Sadeep Madurange <sadeep@asciimx.com> | 2025-03-09 15:31:45 +0800 |
|---|---|---|
| committer | Sadeep Madurange <sadeep@asciimx.com> | 2025-03-09 15:31:45 +0800 |
| commit | 39cceb3a9f1fd309a6960bcb95ce85dbac25748b (patch) | |
| tree | a69021a9a85e07912a9d4e2a7b26b680906a5f3a | |
| parent | 99daec98af8b8b506bb847ddf3a945ead970dc13 (diff) | |
| download | avr-nrf24l01-driver-39cceb3a9f1fd309a6960bcb95ce85dbac25748b.tar.gz | |
2-byte CRC code.
| -rw-r--r-- | main.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -33,6 +33,18 @@ static inline uint8_t read_reg(uint8_t reg) return SPDR; } +static inline void write_reg(uint8_t reg, uint8_t val) +{ + SPI_PORT &= ~(1 << SPI_SS); + SPDR = (reg & 0x1F) | 0x20; + while (!(SPSR & (1 << SPIF))) + ; + SPDR = val; + while (!(SPSR & (1 << SPIF))) + ; + SPI_PORT |= (1 << SPI_SS); +} + void radio_init(void) { SPI_DDR |= (1 << SPI_SS) | (1 << SPI_SCK) | (1 << SPI_MOSI); @@ -43,6 +55,9 @@ void radio_init(void) NRF_CE_PORT &= ~(1 << NRF_CE); _delay_ms(NRF_RST_DELAY_MS); + + // Change the default 1-byte CRC code to 2-byte CRC code + write_reg(0x00, 0b00001100); } int main(void) |
