For robots and stuff
Diff: Radio/Radio.cpp
- Revision:
- 2:c42a035d71ed
- Parent:
- 1:05a48c038381
diff -r 05a48c038381 -r c42a035d71ed Radio/Radio.cpp --- a/Radio/Radio.cpp Sun Dec 28 06:28:42 2014 +0000 +++ b/Radio/Radio.cpp Wed Dec 31 22:16:01 2014 +0000 @@ -3,6 +3,7 @@ Radio::Radio() : _tx_led(NC), _rx_led(NC), + _err_led(NC), _receive_thread(&Radio::receive_thread, this, osPriorityLow, 0), _transmit_thread(&Radio::transmit_thread, this, osPriorityLow, 0), _tx_led_thread(&Radio::led_tick, &_tx_led, osPriorityLow, 0), @@ -12,11 +13,14 @@ _addr = 0; _freq = 0; _need_ack = false; + _p_count = 0; + _has_error = false; } Radio::Radio(PinName tx_led, PinName rx_led) : _tx_led(tx_led), _rx_led(rx_led), + _err_led(p29), _receive_thread(&Radio::receive_thread, this, osPriorityRealtime, 2048), _transmit_thread(&Radio::transmit_thread, this, osPriorityNormal, 1024), _tx_led_thread(&Radio::led_tick, &_tx_led, osPriorityLow, 128), @@ -26,6 +30,14 @@ _addr = 0; _freq = 0; _need_ack = false; + _p_count = 0; + _tx_led = 1; + _rx_led = 1; + + // always off initially + _err_led = 1; + + _has_error = false; } bool Radio::send(const RTP_t& packet) @@ -37,11 +49,6 @@ } -void Radio::mailbox(const Mail<RTP_t, 6>& mail_ptr) -{ - _rx_data = mail_ptr; -} - // INTERRUPT ROUTINES void Radio::isr_receive(void) { @@ -51,15 +58,22 @@ void Radio::led_tick(void const *arg) { DigitalOut *led = (DigitalOut*)arg; + + // initial LED state to OFF + *led = 1; while(1) { // wait for signal to be set before doing anything osSignalWait(SET_LED_TICK, osWaitForever); // blink the led once - *led = 1; + *led = !*led; Thread::wait(10); // ms - *led = 0; + *led = !*led; Thread::wait(60); } -} \ No newline at end of file +} + +bool Radio::hasError(void){ + return _has_error; + } \ No newline at end of file