[joyos] r288 committed - Made rf polling a realtime thread.

0 views
Skip to first unread message

jo...@googlecode.com

unread,
Jan 18, 2011, 12:25:59 AM1/18/11
to joyos...@googlegroups.com
Revision: 288
Author: vaumnou
Date: Mon Jan 17 21:17:07 2011
Log: Made rf polling a realtime thread.
http://code.google.com/p/joyos/source/detail?r=288

Modified:
/trunk/src/drivers/rf.c

=======================================
--- /trunk/src/drivers/rf.c Mon Jan 17 21:16:52 2011
+++ /trunk/src/drivers/rf.c Mon Jan 17 21:17:07 2011
@@ -388,19 +388,22 @@

#ifndef SIMULATE

- for (;;) {
- //if (PINE & _BV(PD7)) {
- uint8_t status = nrf_read_status();
- if (status & _BV(NRF_BIT_RX_DR)) {
- nrf_write_reg(NRF_REG_STATUS, _BV(NRF_BIT_RX_DR)); //reset int
-
- packet_buffer rx;
- uint8_t size;
- uint8_t pipe;
- while ((pipe = rf_get_packet((uint8_t*)&rx, &size)) !=
NRF_RX_P_NO_EMPTY)
- rf_process_packet(&rx, size, pipe);
- }
- //}
+ for(;;) {
+ if (spi_try_acquire()) {
+ if (!(PINE & _BV(PE7))) {
+ uint8_t status = nrf_read_status();
+ if (status & _BV(NRF_BIT_RX_DR)) {
+ nrf_write_reg(NRF_REG_STATUS, _BV(NRF_BIT_RX_DR));
//reset int
+
+ packet_buffer rx;
+ uint8_t size;
+ uint8_t pipe;
+ while ((pipe = rf_get_packet((uint8_t*)&rx, &size)) !=
NRF_RX_P_NO_EMPTY)
+ rf_process_packet(&rx, size, pipe);
+ }
+ }
+ spi_release();
+ }
yield();
}
return 0;
@@ -456,5 +459,5 @@

#endif

- create_thread (&rf_receive, STACK_DEFAULT,
THREAD_PRIORITY_NORMAL, "rf");
-}
+ create_thread (&rf_receive, STACK_DEFAULT,
THREAD_PRIORITY_REALTIME, "rf");
+}

Reply all
Reply to author
Forward
0 new messages