Changeset 102


Ignore:
Timestamp:
06/19/2007 09:57:41 PM (5 years ago)
Author:
agr
Message:

bmac update

Location:
nano-RK
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • nano-RK/projects/basic_bmac/main.c

    r83 r102  
    5555  int8_t rssi, val; 
    5656  uint8_t *local_rx_buf; 
     57  nrk_time_t check_period; 
    5758  printf ("rx_task PID=%d\r\n", nrk_get_pid ()); 
    5859 
    5960  // init bmac on channel 25  
    6061  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" )); 
    6178  // This sets the next RX buffer. 
    6279  // This can be called at anytime before releaseing the packet 
  • nano-RK/projects/basic_bmac/makefile

    r95 r102  
    11# Platform name  cc2420DK, firefly, micaZ 
    2 PLATFORM = firefly2_2 
     2PLATFORM = firefly2 
    33 
    44 
  • nano-RK/src/kernel/source/nrk.c

    r101 r102  
    107107    nrk_high_ready_prio = 0;  
    108108 
    109      
     109    #ifdef NRK_MAX_RESERVES  
    110110    // Setup the reserve structures 
    111111    _nrk_reserve_init(); 
     112    #endif 
    112113 
    113114    _nrk_resource_cnt=0; //NRK_MAX_RESOURCE_CNT; 
  • nano-RK/src/net/bmac/bmac.c

    r83 r102  
    5151uint8_t g_chan; 
    5252 
     53nrk_time_t _bmac_check_period; 
     54 
    5355/** 
    5456 *  This is a callback if you require immediate response to a packet 
     
    6769} 
    6870 
     71int8_t bmac_set_cca_thresh(int8_t thresh) 
     72{ 
     73  rf_set_cca_thresh(thresh);  
     74return NRK_OK; 
     75} 
     76 
    6977int8_t bmac_set_channel(uint8_t chan) 
    7078{ 
     
    7381rf_init (&bmac_rfRxInfo, chan, 0x2420, 0); 
    7482return NRK_OK; 
     83} 
     84 
     85int8_t bmac_set_cca_threshold(uint8_t thresh) 
     86{ 
     87 
     88return NRK_ERROR; 
    7589} 
    7690 
     
    101115    uint16_t a,b; 
    102116 
    103  
     117    _bmac_check_period.secs=0; 
     118    _bmac_check_period.nano_secs=BMAC_DEFAULT_CHECK_RATE_MS*NANOS_PER_MS; 
    104119    bmac_rx_pkt_signal=nrk_signal_create(); 
    105120    bmac_tx_pkt_done_signal=nrk_signal_create(); 
     
    193208                _bmac_tx(); 
    194209                } 
    195          
    196         nrk_wait_until_next_period(); 
     210        
     211        nrk_wait(_bmac_check_period);  
     212        //nrk_wait_until_next_period(); 
    197213        } 
    198214 
     
    200216 
    201217 
    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; 
     218int8_t bmac_set_rx_check_rate(nrk_time_t period) 
     219{ 
     220if(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; 
     224return NRK_OK; 
    208225} 
    209226 
     
    235252        { 
    236253        cnt++; 
    237         nrk_wait_until_next_period(); 
     254        nrk_wait(_bmac_check_period); 
     255        //nrk_wait_until_next_period(); 
    238256        if(cnt>3) {  
    239257                        #ifdef DEBUG 
     
    302320        rf_test_mode(); 
    303321        rf_carrier_on();  
    304         nrk_wait_until_next_period(); 
     322        nrk_wait(_bmac_check_period); 
     323        //nrk_wait_until_next_period(); 
    305324        rf_carrier_off();  
    306325        rf_data_mode(); 
     
    332351    bmac_task.Ptos = (void *) &bmac_task_stack[BMAC_STACK_SIZE-1]; 
    333352    bmac_task.Pbos = (void *) &bmac_task_stack[0]; 
    334     bmac_task.prio = 20; 
     353    bmac_task.prio = BMAC_TASK_PRIORITY; 
    335354    bmac_task.FirstActivation = TRUE; 
    336355    bmac_task.Type = BASIC_TASK; 
    337356    bmac_task.SchType = PREEMPTIVE; 
    338357    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 period 
     358    bmac_task.period.nano_secs = BMAC_MIN_CHECK_RATE_MS * NANOS_PER_MS; 
     359    bmac_task.cpu_reserve.secs = 0;      // Disable bmac reserve  
    341360    bmac_task.cpu_reserve.nano_secs = 0; 
    342361    bmac_task.offset.secs = 0; 
  • nano-RK/src/net/bmac/bmac.h

    r83 r102  
    6363 
    6464 
    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 
    6670nrk_task_type bmac_task; 
    6771NRK_STK bmac_task_stack[BMAC_STACK_SIZE]; 
     
    7478RF_TX_INFO bmac_rfTxInfo; // Extra slot at end for abs slot buffer pointer   
    7579 
    76 int8_t bmac_set_rx_check_rate(uint16_t ms); 
     80int8_t bmac_set_rx_check_rate(nrk_time_t period); 
    7781void bmac_task_config (); 
    7882int8_t bmac_set_channel(uint8_t chan); 
     
    8387int8_t bmac_tx_packet_enqueue(uint8_t *buf, uint8_t len); 
    8488 
     89int8_t bmac_set_cca_thresh(int8_t thresh); 
    8590uint8_t *bmac_rx_pkt_get(uint8_t *len, uint8_t *rssi); 
    8691int8_t bmac_rx_pkt_ready(void); 
  • nano-RK/src/radio/cc2420/include/basic_rf.h

    r15 r102  
    102102void rf_carrier_on(); 
    103103void rf_carrier_off(); 
     104void rf_set_cca_thresh(int8_t t); 
    104105 
    105106 
  • nano-RK/src/radio/cc2420/source/basic_rf.c

    r38 r102  
    667667} 
    668668 
     669void rf_set_cca_thresh(int8_t t) 
     670{ 
     671// default is -32 
     672// Higher number is less sensitive 
     673uint16_t val; 
     674val=(t<<8) | 0x80; 
     675FASTSPI_SETREG(CC2420_RSSI, val);  
     676 
     677} 
    669678 
    670679void rf_test_mode() 
Note: See TracChangeset for help on using the changeset viewer.