Changeset 102
- Timestamp:
- 06/19/2007 09:57:41 PM (5 years ago)
- Location:
- nano-RK
- Files:
-
- 7 edited
-
projects/basic_bmac/main.c (modified) (1 diff)
-
projects/basic_bmac/makefile (modified) (1 diff)
-
src/kernel/source/nrk.c (modified) (1 diff)
-
src/net/bmac/bmac.c (modified) (9 diffs)
-
src/net/bmac/bmac.h (modified) (3 diffs)
-
src/radio/cc2420/include/basic_rf.h (modified) (1 diff)
-
src/radio/cc2420/source/basic_rf.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
nano-RK/projects/basic_bmac/main.c
r83 r102 55 55 int8_t rssi, val; 56 56 uint8_t *local_rx_buf; 57 nrk_time_t check_period; 57 58 printf ("rx_task PID=%d\r\n", nrk_get_pid ()); 58 59 59 60 // init bmac on channel 25 60 61 bmac_init (25); 62 63 // By default the RX check rate is 100ms 64 // below shows how to change that 65 //check_period.secs=0; 66 //check_period.nano_secs=200*NANOS_PER_MS; 67 //val=bmac_set_rx_check_rate(check_period); 68 69 // The default Clear Channel Assement RSSI threshold is -32 70 // Setting this value higher means that you will only trigger 71 // receive with a very strong signal. Setting this lower means 72 // bmac will try to receive fainter packets. If the value is set 73 // too high or too low performance will suffer greatly. 74 // bmac_set_cca_thresh(-32); 75 76 77 if(val==NRK_ERROR) nrk_kprintf( PSTR("ERROR setting bmac rate\r\n" )); 61 78 // This sets the next RX buffer. 62 79 // This can be called at anytime before releaseing the packet -
nano-RK/projects/basic_bmac/makefile
r95 r102 1 1 # Platform name cc2420DK, firefly, micaZ 2 PLATFORM = firefly2 _22 PLATFORM = firefly2 3 3 4 4 -
nano-RK/src/kernel/source/nrk.c
r101 r102 107 107 nrk_high_ready_prio = 0; 108 108 109 109 #ifdef NRK_MAX_RESERVES 110 110 // Setup the reserve structures 111 111 _nrk_reserve_init(); 112 #endif 112 113 113 114 _nrk_resource_cnt=0; //NRK_MAX_RESOURCE_CNT; -
nano-RK/src/net/bmac/bmac.c
r83 r102 51 51 uint8_t g_chan; 52 52 53 nrk_time_t _bmac_check_period; 54 53 55 /** 54 56 * This is a callback if you require immediate response to a packet … … 67 69 } 68 70 71 int8_t bmac_set_cca_thresh(int8_t thresh) 72 { 73 rf_set_cca_thresh(thresh); 74 return NRK_OK; 75 } 76 69 77 int8_t bmac_set_channel(uint8_t chan) 70 78 { … … 73 81 rf_init (&bmac_rfRxInfo, chan, 0x2420, 0); 74 82 return NRK_OK; 83 } 84 85 int8_t bmac_set_cca_threshold(uint8_t thresh) 86 { 87 88 return NRK_ERROR; 75 89 } 76 90 … … 101 115 uint16_t a,b; 102 116 103 117 _bmac_check_period.secs=0; 118 _bmac_check_period.nano_secs=BMAC_DEFAULT_CHECK_RATE_MS*NANOS_PER_MS; 104 119 bmac_rx_pkt_signal=nrk_signal_create(); 105 120 bmac_tx_pkt_done_signal=nrk_signal_create(); … … 193 208 _bmac_tx(); 194 209 } 195 196 nrk_wait_until_next_period(); 210 211 nrk_wait(_bmac_check_period); 212 //nrk_wait_until_next_period(); 197 213 } 198 214 … … 200 216 201 217 202 int8_t bmac_set_rx_check_rate(uint16_t ms) 203 { 204 // Not YET implemented! 205 // This function needs to check the wait_until_next_period 206 // timeouts for the main checking task. 207 return NRK_ERROR; 218 int8_t bmac_set_rx_check_rate(nrk_time_t period) 219 { 220 if(period.secs==0 && period.nano_secs < BMAC_MIN_CHECK_RATE_MS*NANOS_PER_MS) 221 return NRK_ERROR; 222 _bmac_check_period.secs=period.secs; 223 _bmac_check_period.nano_secs=period.nano_secs; 224 return NRK_OK; 208 225 } 209 226 … … 235 252 { 236 253 cnt++; 237 nrk_wait_until_next_period(); 254 nrk_wait(_bmac_check_period); 255 //nrk_wait_until_next_period(); 238 256 if(cnt>3) { 239 257 #ifdef DEBUG … … 302 320 rf_test_mode(); 303 321 rf_carrier_on(); 304 nrk_wait_until_next_period(); 322 nrk_wait(_bmac_check_period); 323 //nrk_wait_until_next_period(); 305 324 rf_carrier_off(); 306 325 rf_data_mode(); … … 332 351 bmac_task.Ptos = (void *) &bmac_task_stack[BMAC_STACK_SIZE-1]; 333 352 bmac_task.Pbos = (void *) &bmac_task_stack[0]; 334 bmac_task.prio = 20;353 bmac_task.prio = BMAC_TASK_PRIORITY; 335 354 bmac_task.FirstActivation = TRUE; 336 355 bmac_task.Type = BASIC_TASK; 337 356 bmac_task.SchType = PREEMPTIVE; 338 357 bmac_task.period.secs = 0; 339 bmac_task.period.nano_secs = 100* NANOS_PER_MS;340 bmac_task.cpu_reserve.secs = 15; // Way larger than period358 bmac_task.period.nano_secs = BMAC_MIN_CHECK_RATE_MS * NANOS_PER_MS; 359 bmac_task.cpu_reserve.secs = 0; // Disable bmac reserve 341 360 bmac_task.cpu_reserve.nano_secs = 0; 342 361 bmac_task.offset.secs = 0; -
nano-RK/src/net/bmac/bmac.h
r83 r102 63 63 64 64 65 #define BMAC_STACK_SIZE 128 65 #define BMAC_STACK_SIZE 128 66 #define BMAC_MIN_CHECK_RATE_MS 50 67 #define BMAC_DEFAULT_CHECK_RATE_MS 100 68 #define BMAC_TASK_PRIORITY 20 69 66 70 nrk_task_type bmac_task; 67 71 NRK_STK bmac_task_stack[BMAC_STACK_SIZE]; … … 74 78 RF_TX_INFO bmac_rfTxInfo; // Extra slot at end for abs slot buffer pointer 75 79 76 int8_t bmac_set_rx_check_rate( uint16_t ms);80 int8_t bmac_set_rx_check_rate(nrk_time_t period); 77 81 void bmac_task_config (); 78 82 int8_t bmac_set_channel(uint8_t chan); … … 83 87 int8_t bmac_tx_packet_enqueue(uint8_t *buf, uint8_t len); 84 88 89 int8_t bmac_set_cca_thresh(int8_t thresh); 85 90 uint8_t *bmac_rx_pkt_get(uint8_t *len, uint8_t *rssi); 86 91 int8_t bmac_rx_pkt_ready(void); -
nano-RK/src/radio/cc2420/include/basic_rf.h
r15 r102 102 102 void rf_carrier_on(); 103 103 void rf_carrier_off(); 104 void rf_set_cca_thresh(int8_t t); 104 105 105 106 -
nano-RK/src/radio/cc2420/source/basic_rf.c
r38 r102 667 667 } 668 668 669 void rf_set_cca_thresh(int8_t t) 670 { 671 // default is -32 672 // Higher number is less sensitive 673 uint16_t val; 674 val=(t<<8) | 0x80; 675 FASTSPI_SETREG(CC2420_RSSI, val); 676 677 } 669 678 670 679 void rf_test_mode()
Note: See TracChangeset
for help on using the changeset viewer.
