diff --git a/prime-tx/main.c b/prime-tx/main.c index 512688f..68ea4c1 100644 --- a/prime-tx/main.c +++ b/prime-tx/main.c @@ -43,7 +43,6 @@ int main(void) { int clock = 0; uint8_t primes[] = { 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 0 }; - /* display_t display = { .reg = { .output = { .ddr = &DDRB, .port = &PORTB, .pin = &PINB, .addr = 7 }, @@ -51,7 +50,6 @@ int main(void) { .latch_clock = { .ddr = &DDRB, .port = &PORTB, .pin = &PINB, .addr = 5 }, }, }; - */ rfm_t radio = (rfm_t){ .spi = { @@ -64,23 +62,23 @@ int main(void) { .reset = { .ddr = &DDRD, .port = &PORTD, .pin = &PIND, .addr = 4 }, }; - // _delay_ms(15); - // display_init(&display); + _delay_ms(15); + display_init(&display); rfm_error_e error; rfm_init(&radio, (uint8_t [4]){ 0xde, 0xca, 0xfb, 0xad }, 4, &error); - // status(&display, &radio, clock); + status(&display, &radio, clock); int next_transmit = 0; int prime = 0; while (1) { if (clock >= next_transmit) { - // display_clear(&display); + display_clear(&display); char msg[16]; sprintf(msg, "sending %d", primes[prime]); - // display_write_message(&display, msg); + display_write_message(&display, msg); rfm_transmit(&radio, &primes[prime], 1); if (primes[prime] == 0) { prime = 0; @@ -90,7 +88,7 @@ int main(void) { next_transmit = clock + 10; _delay_ms(1000); } - // status(&display, &radio, clock); + status(&display, &radio, clock); interrupt_flags_t flags = rfm_interrupts(&radio); if (flags.packet_sent) { diff --git a/rfm69hcw/rfm.c b/rfm69hcw/rfm.c index 2d9ffe8..622ffca 100644 --- a/rfm69hcw/rfm.c +++ b/rfm69hcw/rfm.c @@ -122,8 +122,9 @@ void rfm_standby(rfm_t *rfm) { rfm_set_mode(rfm, (op_mode_t){ .listen_on = false, .mode = standby }); } -void rfm_transmit(rfm_t *rfm, uint8_t *data, size_t length) { +void rfm_transmit(rfm_t *rfm, uint8_t *data, uint8_t length) { rfm_set_mode(rfm, (op_mode_t){ .listen_on = false, .mode = standby }); + _rfm_write(rfm, REG_FIFO, &length, 1); _rfm_write(rfm, REG_FIFO, data, length); _rfm_write(rfm, REG_DIO_MAPPING1, (uint8_t [1]){ 0x00 }, 1); rfm_set_mode(rfm, (op_mode_t){ .listen_on = false, .mode = tx }); diff --git a/rfm69hcw/rfm.h b/rfm69hcw/rfm.h index d3153d1..0c4e661 100644 --- a/rfm69hcw/rfm.h +++ b/rfm69hcw/rfm.h @@ -75,7 +75,7 @@ void rfm_packet_format(rfm_t *rfm, packet_format_e format, size_t length); void rfm_sleep(rfm_t *); void rfm_standby(rfm_t *); void rfm_receive_mode(rfm_t *); -void rfm_transmit(rfm_t *rfm, uint8_t *data, size_t length); +void rfm_transmit(rfm_t *rfm, uint8_t *data, uint8_t length); void rfm_receive(rfm_t *rfm, uint8_t *data, size_t length); op_mode_t rfm_mode(rfm_t *rfm);