diff options
| author | Sadeep Madurange <sadeep@asciimx.com> | 2024-12-08 17:21:23 +0800 |
|---|---|---|
| committer | Sadeep Madurange <sadeep@asciimx.com> | 2024-12-08 17:21:23 +0800 |
| commit | 92ba8bbb42cca4eca7a1a7a2d27701204c2e8a56 (patch) | |
| tree | 6b5a0241fa41f9a0b68fbdbdfc6bcd9690ec25fb /rf_test | |
| parent | 393e97515ac3aa66d78627cd7a7b60f1cf50f76b (diff) | |
| download | smart-home-92ba8bbb42cca4eca7a1a7a2d27701204c2e8a56.tar.gz | |
wip: tx issues.
Diffstat (limited to 'rf_test')
| -rw-r--r-- | rf_test/radio.c | 21 | ||||
| -rw-r--r-- | rf_test/radio.h | 4 | ||||
| -rw-r--r-- | rf_test/send.c | 9 |
3 files changed, 19 insertions, 15 deletions
diff --git a/rf_test/radio.c b/rf_test/radio.c index 6a11b42..fe3ce08 100644 --- a/rf_test/radio.c +++ b/rf_test/radio.c @@ -41,10 +41,11 @@ static inline void write_reg(uint8_t reg, uint8_t val) void radio_send(const char *data, uint8_t n) { + char s[3]; uint8_t i; write_reg(0x01, 0x04); - while (!(read_reg(0x27) & 80)) + while ((read_reg(0x27) & 80)) ; SPI_PORT &= ~(1 << SPI_SS); @@ -58,7 +59,15 @@ void radio_send(const char *data, uint8_t n) } SPI_PORT |= (1 << SPI_SS); - // todo: wait for tx complete + write_reg(0x01, 0x0C); + while (!(read_reg(0x28) & 0x08)) + ; + + serial_write_line("sending data"); + + write_reg(0x01, 0x04); + while ((read_reg(0x27) & 80)) + ; } uint8_t radio_recv(char *buf, uint8_t n) @@ -111,14 +120,14 @@ void radio_init(const struct radio_cfg *cfg) write_reg(0x2F, cfg->netid); // packet config - write_config(0x37, 0x30); - write_config(0x38, cfg->payload_len); + write_reg(0x37, 0x30); + write_reg(0x38, cfg->payload_len); - write_config(0x39, cfg->nodeid); + write_reg(0x39, cfg->nodeid); // fifo config write_reg(0x0F, 0x8F); // DAGC config - write_config(0x6F, 0x30); + write_reg(0x6F, 0x30); } diff --git a/rf_test/radio.h b/rf_test/radio.h index f016659..71e3e8b 100644 --- a/rf_test/radio.h +++ b/rf_test/radio.h @@ -4,8 +4,8 @@ #include <stdint.h> struct radio_cfg { - uint8_t node_id; - uint8_t network_id; + uint8_t netid; + uint8_t nodeid; uint8_t payload_len; }; diff --git a/rf_test/send.c b/rf_test/send.c index 4934534..08340ba 100644 --- a/rf_test/send.c +++ b/rf_test/send.c @@ -12,8 +12,6 @@ #define LED_DDR DDRB #define LED_PORT PORTB -#define NODE_ID 2 - int main(void) { uint8_t n; @@ -21,7 +19,8 @@ int main(void) const char *s = "hello, world!"; n = strlen(s); - cfg.node_id = NODE_ID; + cfg.netid = 0x01; + cfg.nodeid = 0x02; cfg.payload_len = n; LED_DDR |= (1 << LED_PIN); @@ -29,12 +28,8 @@ int main(void) serial_init(); radio_init(&cfg); - sei(); - for (;;) { radio_send(s, n); - serial_write_line("sent data"); - LED_PORT |= (1 << LED_PIN); _delay_ms(100); LED_PORT &= ~(1 << LED_PIN); |
