diff options
| author | Sadeep Madurange <sadeep@asciimx.com> | 2024-12-10 19:47:36 +0800 |
|---|---|---|
| committer | Sadeep Madurange <sadeep@asciimx.com> | 2024-12-10 19:47:36 +0800 |
| commit | e0021c1579ae329e8a78eda6979616fa7ceb456e (patch) | |
| tree | ee3e502bbd1c9aa59ba2c76a8f526ee8e90f9a75 /rf_test | |
| parent | b8103d0b0624ca7fbbccfc7d7b2bef560efd3198 (diff) | |
| download | smart-home-e0021c1579ae329e8a78eda6979616fa7ceb456e.tar.gz | |
wip: rx.
Diffstat (limited to 'rf_test')
| -rw-r--r-- | rf_test/radio.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/rf_test/radio.c b/rf_test/radio.c index 83bd7c2..9dc3528 100644 --- a/rf_test/radio.c +++ b/rf_test/radio.c @@ -75,24 +75,21 @@ uint8_t radio_recv(char *buf, uint8_t n) read_len = 0; - if ((read_reg(0x28) & 0x04)) - { - write_reg(0x01, 0x04); - while ((read_reg(0x27) >> 7) != 1) - ; + write_reg(0x01, 0x04); + while ((read_reg(0x27) & 0x80)) + ; - SPI_PORT &= ~(1 << SPI_SS); - SPDR = 0x00 | 0x7F; + SPI_PORT &= ~(1 << SPI_SS); + SPDR = 0x00 | 0x7F; + while (!(SPSR & (1 << SPIF))) + ; + while (read_len < n) { + SPDR = 0; while (!(SPSR & (1 << SPIF))) ; - while (read_len < n) { - SPDR = 0; - while (!(SPSR & (1 << SPIF))) - ; - buf[read_len++] = SPDR; - } - SPI_PORT |= (1 << SPI_SS); - } + buf[read_len++] = SPDR; + } + SPI_PORT |= (1 << SPI_SS); return read_len; } |
