Changeset 1459
- Timestamp:
- 02/25/12 18:57:16 (15 months ago)
- Location:
- trunk/firmware/openos
- Files:
-
- 5 edited
-
bsp/radio.h (modified) (2 diffs)
-
bsp/radiotimer.h (modified) (2 diffs)
-
bsp/telosb/radio.c (modified) (1 diff)
-
bsp/telosb/radiotimer.c (modified) (3 diffs)
-
projects/telosb/01-bsp/01bsp_radio.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/firmware/openos/bsp/radio.h
r1457 r1459 7 7 #ifndef __RADIO_H 8 8 #define __RADIO_H 9 10 #include "radiotimer.h" 9 11 10 12 //=========================== define ========================================== … … 19 21 void radio_reset(); 20 22 void radio_startTimer(uint16_t period); 23 void radio_setOverflowCb(radiotimer_compare_cbt cb); 24 void radio_setCompareCb(radiotimer_compare_cbt cb); 25 void radio_setStartFrameCb(radiotimer_capture_cbt cb); 26 void radio_setEndFrameCb(radiotimer_capture_cbt cb); 21 27 void radio_setFrequency(uint8_t frequency); 22 28 void radio_rfOn(); -
trunk/firmware/openos/bsp/radiotimer.h
r1457 r1459 14 14 //=========================== typedef ========================================= 15 15 16 typedef void (*radiotimer_ overflow_cbt)();17 typedef void (*radiotimer_ frame_cbt)(uint16_t timestamp);16 typedef void (*radiotimer_compare_cbt)(); 17 typedef void (*radiotimer_capture_cbt)(uint16_t timestamp); 18 18 19 19 //=========================== variables ======================================= … … 22 22 23 23 void radiotimer_init(); 24 void radiotimer_setOverflowCb(radiotimer_compare_cbt cb); 25 void radiotimer_setCompareCb(radiotimer_compare_cbt cb); 26 void radiotimer_setStartFrameCb(radiotimer_capture_cbt cb); 27 void radiotimer_setEndFrameCb(radiotimer_capture_cbt cb); 24 28 void radiotimer_start(uint16_t period); 25 29 void radiotimer_schedule(uint16_t offset); -
trunk/firmware/openos/bsp/telosb/radio.c
r1457 r1459 50 50 void radio_startTimer(uint16_t period) { 51 51 radiotimer_start(period); 52 } 53 54 void radio_setOverflowCb(radiotimer_compare_cbt cb) { 55 radiotimer_setOverflowCb(cb); 56 } 57 58 void radio_setCompareCb(radiotimer_compare_cbt cb) { 59 radiotimer_setCompareCb(cb); 60 } 61 62 void radio_setStartFrameCb(radiotimer_capture_cbt cb) { 63 radiotimer_setStartFrameCb(cb); 64 } 65 66 void radio_setEndFrameCb(radiotimer_capture_cbt cb) { 67 radiotimer_setEndFrameCb(cb); 52 68 } 53 69 -
trunk/firmware/openos/bsp/telosb/radiotimer.c
r1457 r1459 13 13 14 14 typedef struct { 15 radiotimer_overflow_cbt overflowCb; 16 radiotimer_frame_cbt startOfFrameCb; 17 radiotimer_frame_cbt endOfFrameCb; 15 radiotimer_compare_cbt overflowCb; 16 radiotimer_compare_cbt compareCb; 17 radiotimer_capture_cbt startFrameCb; 18 radiotimer_capture_cbt endFrameCb; 18 19 } radiotimer_vars_t; 19 20 … … 29 30 } 30 31 31 void radiotimer_setOverflowCb(radiotimer_ overflow_cbt cb) {32 radiotimer_vars.overflowCb = cb;32 void radiotimer_setOverflowCb(radiotimer_compare_cbt cb) { 33 radiotimer_vars.overflowCb = cb; 33 34 } 34 35 35 void radiotimer_set StartOfFrameCb(radiotimer_frame_cbt cb) {36 radiotimer_vars. startOfFrameCb= cb;36 void radiotimer_setCompareCb(radiotimer_compare_cbt cb) { 37 radiotimer_vars.compareCb = cb; 37 38 } 38 39 39 void radiotimer_setEndOfFrameCb(radiotimer_frame_cbt cb) { 40 radiotimer_vars.endOfFrameCb = cb; 40 void radiotimer_setStartFrameCb(radiotimer_capture_cbt cb) { 41 radiotimer_vars.startFrameCb = cb; 42 } 43 44 void radiotimer_setEndFrameCb(radiotimer_capture_cbt cb) { 45 radiotimer_vars.endFrameCb = cb; 41 46 } 42 47 … … 105 110 if (TBCCR1 & CCI) { 106 111 // SFD pin is high: this was the start of a frame 107 if (radiotimer_vars.start OfFrameCb!=NULL) {108 radiotimer_vars.start OfFrameCb(TBCCR1);112 if (radiotimer_vars.startFrameCb!=NULL) { 113 radiotimer_vars.startFrameCb(TBCCR1); 109 114 } 110 115 } else { 111 116 // SFD pin is low: this was the end of a frame 112 if (radiotimer_vars.end OfFrameCb!=NULL) {113 radiotimer_vars.end OfFrameCb(TBCCR1);117 if (radiotimer_vars.endFrameCb!=NULL) { 118 radiotimer_vars.endFrameCb(TBCCR1); 114 119 } 115 120 } 116 121 break; 117 122 case 0x0004: // CCR2 fires 123 if (radiotimer_vars.compareCb!=NULL) { 124 radiotimer_vars.compareCb(); 125 } 118 126 break; 119 127 case 0x0006: // CCR3 fires -
trunk/firmware/openos/projects/telosb/01-bsp/01bsp_radio.c
r1453 r1459 6 6 7 7 #include "stdint.h" 8 #include "string.h" 8 9 #include "board.h" 9 10 #include "radio.h" 10 11 #include "leds.h" 11 12 13 //=========================== defines ========================================= 14 12 15 #define LENGTH_PACKET 100 13 16 #define CHANNEL 11 17 18 //=========================== variables ======================================= 19 20 void cb_radioTimerOverflows(); 21 void cb_radioTimerCompare(); 22 void cb_startFrame(uint16_t timestamp); 23 void cb_endFrame(uint16_t timestamp); 24 25 typedef struct { 26 uint8_t radio_busy; 27 uint8_t num_overflow; 28 uint8_t num_compare; 29 uint8_t num_startFrame; 30 uint8_t num_endFrame; 31 } app_vars_t; 32 33 app_vars_t app_vars; 34 35 //=========================== main ============================================ 14 36 15 37 /** … … 21 43 uint8_t i; 22 44 23 // initialize 45 // clear local variables 46 memset(&app_vars,0,sizeof(app_vars_t)); 47 48 // initialize board 24 49 board_init(); 50 51 // add callback functions from radio 52 radio_setOverflowCb(cb_radioTimerOverflows); 53 radio_setCompareCb(cb_radioTimerCompare); 54 radio_setStartFrameCb(cb_startFrame); 55 radio_setEndFrameCb(cb_endFrame); 25 56 26 57 // prepare packet … … 35 66 radio_txEnable(); 36 67 radio_txNow(); 37 radio_waitTxDone(); 68 app_vars.radio_busy = 1; 69 while (app_vars.radio_busy==1); 38 70 radio_rfOff(); 39 71 led_radio_toggle(); … … 42 74 board_sleep(); 43 75 } 76 77 //=========================== callbacks ======================================= 78 79 void cb_radioTimerOverflows() { 80 app_vars.num_overflow++; 81 } 82 83 void cb_radioTimerCompare() { 84 app_vars.num_compare++; 85 } 86 87 void cb_startFrame(uint16_t timestamp) { 88 app_vars.num_startFrame++; 89 } 90 91 void cb_endFrame(uint16_t timestamp) { 92 app_vars.radio_busy = 0; 93 app_vars.num_endFrame++; 94 }
Note: See TracChangeset
for help on using the changeset viewer.
