Changeset 278


Ignore:
Timestamp:
10/06/2007 05:51:37 PM (4 years ago)
Author:
agr
Message:

rt-link, time sync signal fix

Location:
nano-RK
Files:
8 edited

Legend:

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

    r256 r278  
    102102  nrk_kprintf( PSTR("start done\r\n") ); 
    103103  while(!rtl_ready())  nrk_wait_until_next_period();  
    104   //nrk_led_set(0);   
    105104  while(1) { 
    106105          
    107106          if( rtl_rx_pkt_check()!=0 ) 
    108107               { 
    109                    //nrk_led_set(1); 
     108                   nrk_led_set(BLUE_LED); 
    110109                   local_rx_buf=rtl_rx_pkt_get(&length, &rssi, &slot); 
    111110                   printf( "Got Packet on slot %d %d: ",slot,length ); 
     
    116115                   nrk_kprintf( PSTR("\r\n") ); 
    117116                   rtl_rx_pkt_release(); 
    118                    //nrk_led_clr(1); 
     117                   nrk_led_clr(BLUE_LED); 
    119118               } 
    120119  
     
    124123               } 
    125124          else { 
    126                 //nrk_led_set(2); 
     125                nrk_led_set(RED_LED); 
    127126                cnt++; 
    128127                sprintf( &tx_buf[PKT_DATA_START], "Hello World %d", cnt );  
     
    130129                rtl_tx_pkt( tx_buf, length, MY_TX_SLOT ); 
    131130                printf( "Sending Packet on slot %d\r\n",MY_TX_SLOT ); 
    132                 //nrk_led_clr(2); 
     131                nrk_led_clr(RED_LED); 
    133132               } 
    134133          
  • nano-RK/projects/basic_rtl/rtl_coord/nrk_cfg.h

    r263 r278  
    1919// Leave NRK_NO_POWER_DOWN define in if the target can not wake up from sleep  
    2020// because it has no asynchronously clocked 
    21 // #define NRK_NO_POWER_DOWN 
     21//  #define NRK_NO_POWER_DOWN 
    2222 
    2323#define NRK_MAX_TASKS                   4    // Max number of tasks in your application 
  • nano-RK/projects/basic_rtl/rtl_fixed/main.c

    r263 r278  
    112112          if( rtl_rx_pkt_check()!=0 ) 
    113113               { 
    114                    //nrk_led_set(1); 
     114                   nrk_led_set(BLUE_LED); 
    115115                   local_rx_buf=rtl_rx_pkt_get(&length, &rssi, &slot); 
    116116                   printf( "Got Packet on slot %d %d: ",slot,length ); 
     
    121121                   nrk_kprintf( PSTR("\r\n") ); 
    122122                   rtl_rx_pkt_release(); 
    123                    //nrk_led_clr(1); 
     123                   nrk_led_clr(BLUE_LED); 
    124124               } 
    125125 
     
    129129               } 
    130130          else { 
    131                 //nrk_led_set(2); 
     131                nrk_led_set(GREEN_LED); 
    132132                cnt++; 
    133133                sprintf( &tx_buf[PKT_DATA_START], "Hello World %d", cnt ); 
     
    135135                rtl_tx_pkt( tx_buf, length, MY_TX_SLOT ); 
    136136                printf( "Sending Packet on slot %d\r\n",MY_TX_SLOT ); 
    137                 //nrk_led_clr(2); 
     137                nrk_led_clr(GREEN_LED); 
    138138               } 
    139139 
  • nano-RK/projects/fun/laundry_monitor/main.c

    r269 r278  
    3737#include <ff_basic_sensor.h> 
    3838 
    39 //#define LED_NOTIFY 
    40 #define COORDINATOR  
    41 #define NODE_ID     1 
     39#define LED_NOTIFY 
     40//#define COORDINATOR  
     41#define NODE_ID     4 
    4242 
    4343#if NODE_ID == 1 
     
    186186                                //prev_light=light; 
    187187 
     188                                nrk_led_set(2); 
    188189                                tx_buf[PKT_DATA_START]=NODE_ID; 
    189190                                tx_buf[PKT_DATA_START+1]=vibrate; 
  • nano-RK/projects/fun/laundry_monitor/nrk_cfg.h

    r269 r278  
    1919// Leave NRK_NO_POWER_DOWN define in if the target can not wake up from sleep  
    2020// because it has no asynchronously clocked 
    21 //#define NRK_NO_POWER_DOWN 
     21// #define NRK_NO_POWER_DOWN 
    2222 
    2323// We have at most NRK_DRIVER_CNT drivers to register 
  • nano-RK/src/net/rt_link/platform/firefly2_2/rtl_defs.h

    r240 r278  
    5656#define OS_TICK_TO_TASK_START  800  
    5757//#define SFD_TO_NEXT_SLOT_TIME   (SLOT_TIME-TX_GUARD_TIME-TX_TO_SFD-OS_TICK_TO_TASK_START-OS_TICK_TO_TASK_START) 
    58 #define SFD_TO_NEXT_SLOT_TIME   (41100) 
     58//#define SFD_TO_NEXT_SLOT_TIME   (41100) 
     59#define SFD_TO_NEXT_SLOT_TIME   (27750) 
    5960 
    6061 
  • nano-RK/src/net/rt_link/rt_link.c

    r263 r278  
    8787} 
    8888 
    89 int8_t rtl_wait_until_rx_packet () 
     89int8_t rtl_wait_until_rx_pkt () 
    9090{ 
    9191    nrk_signal_register(rtl_rx_pkt_signal); 
     
    239239        slot = (TDMA_FRAME_SLOTS - slot - 1); 
    240240        _rtl_contention_pending = 1; 
    241         //printf( "CONTENTION %d\r\n",slot ); 
    242241    } 
    243242    rtl_tx_info[slot].pPayload = tx_buf;    // pass le pointer 
     
    403402            if (_nrk_os_timer_get () > timeout) 
    404403                { 
    405                 nrk_kprintf( PSTR("Pkt timed out\r\n") ); 
     404                //nrk_kprintf( PSTR("Pkt timed out\r\n") ); 
    406405                break;          // huge timeout as failsafe 
    407406                } 
     
    431430        if(tmp_token>_rtl_time_token || (_rtl_time_token>110 && tmp_token<10)) 
    432431                { 
     432                rtl_rx_slot = (global_slot ) % 32; 
    433433                // only acccept sync if the token is greater than yours 
    434                 if((rtl_rfRxInfo.pPayload[TIME_SYNC_TOKEN]&0x80)==0) 
     434                if((rtl_rfRxInfo.pPayload[TIME_SYNC_TOKEN]&0x80)==0 ) 
    435435                        { 
     436                        // Got normal packet  
    436437                        // if we got a good packet, send the signal to 
    437438                        // the application 
    438                         //nrk_kprintf( PSTR("app\r\n") ); 
    439                         nrk_event_signal (rtl_rx_pkt_signal); 
     439 
     440                        // Check if we are supposed to RX on this slot, or if it was an overheard sync slot with data 
     441                        // If it had data but not for me, ignore it 
     442                        if((((uint32_t)1<<rtl_rx_slot) & rtl_tdma_rx_mask)==(uint32_t)0) 
     443                                rtl_rx_pkt_release();  
     444                        else 
     445                                nrk_event_signal (rtl_rx_pkt_signal); 
    440446                        } 
    441447                // If it is a time sync packet, then release it 
    442448                // so it doesn't block a buffer... 
    443449                else {  
    444                 //      nrk_kprintf( PSTR("explicit\r\n") );  
     450                        // Explicit Sync 
    445451                        rtl_rx_pkt_release();  
    446452                //      nrk_event_signal (SIG(RTL_RX_PKT_EVENT)); 
     
    463469#endif 
    464470          
    465     rtl_rx_slot = (global_slot - 1) % 32; 
     471    rtl_rx_slot = (global_slot) % 32; 
    466472    current_global_slot = global_slot-1; 
    467473    //printf( "Got sync token %d\r\n",tmp_token );  
     
    600606        while ((n = rf_polling_rx_packet ()) == 0) { 
    601607            if (_nrk_os_timer_get () > timeout) { 
    602                 nrk_kprintf( PSTR("pkt timed out\r\n") ); 
     608                //nrk_kprintf( PSTR("pkt timed out\r\n") ); 
    603609                break;          // huge timeout as failsafe 
    604610            } 
     
    636642                        { 
    637643                        // if we got a good packet, send the signal to 
    638                         // the application 
     644                        // the application.  Shouldn't need to check rx 
     645                        // mask here since this should only get called by real 
     646                        // rx slot. 
    639647                        nrk_event_signal (rtl_rx_pkt_signal); 
    640648                        } 
    641                 // If it is a time sync packet, then release it 
     649                // If it is an explicit time sync packet, then release it 
    642650                // so it doesn't block a buffer... 
    643                 else { rtl_rx_pkt_release(); } 
     651                else {  
     652                //nrk_kprintf( PSTR("got explicit sync\r\n") ); 
     653                rtl_rx_pkt_release();  
     654                } 
    644655    } // else printf( "Error = %d\r\n",(int8_t)n );            
    645656    #ifdef RTL_DEBUG 
     
    668679void _rtl_tx (uint8_t slot) 
    669680{ 
     681int8_t explicit_tsync; 
    670682     
    671683    if (rtl_sync_status () == 0) 
     
    682694    // or in so that you don't kill  
    683695    //rtl_rfTxInfo.pPayload[TIME_SYNC_TOKEN]|= _rtl_time_token;   
    684     rtl_rfTxInfo.pPayload[TIME_SYNC_TOKEN]= _rtl_time_token;   
     696 
     697    // This clears the explicit sync bit 
     698    rtl_rfTxInfo.pPayload[TIME_SYNC_TOKEN]= _rtl_time_token;  
     699    explicit_tsync=0; 
     700    // If it is an empty packet set explicit sync bit 
     701    if(rtl_rfTxInfo.length==PKT_DATA_START ) 
     702        { 
     703        explicit_tsync=1; 
     704        rtl_rfTxInfo.pPayload[TIME_SYNC_TOKEN]|= 0x80; 
     705        }  
     706          
    685707                                                                        // MSB (explicit time slot flag) 
    686708 
     
    697719        _rtl_contention_pending = 0; 
    698720    // clear time sync token so that explicit time slot flag is cleared  
    699     rtl_rfTxInfo.pPayload[TIME_SYNC_TOKEN]=0;   
    700     nrk_event_signal (rtl_tx_done_signal); 
     721    //rtl_rfTxInfo.pPayload[TIME_SYNC_TOKEN]=0;   
     722    if(explicit_tsync==0) 
     723        nrk_event_signal (rtl_tx_done_signal); 
    701724 
    702725#ifdef LED_DEBUG 
     
    10071030                                // and does not signal applications 
    10081031                                rtl_tsync_tx.pPayload=rtl_tsync_buf; 
    1009                                 rtl_tsync_buf[TIME_SYNC_TOKEN]|=0x80;  // set explicit time sync flag  
     1032                                // set explicit time sync flag  
     1033                                rtl_tsync_buf[TIME_SYNC_TOKEN]|=0x80;   
    10101034                                rtl_tsync_tx.length=PKT_DATA_START; 
    10111035                                if(slot>(TDMA_FRAME_SLOTS-_rtl_contention_slots)) 
  • nano-RK/src/net/rt_link/rt_link.h

    r263 r278  
    108108int8_t rtl_tx_pkt (uint8_t *buf, uint8_t len, uint8_t slot); 
    109109int8_t rtl_tx_abs_pkt (uint8_t *buf, uint8_t len, uint16_t abs_slot); 
     110int8_t rtl_wait_until_tx_done(uint8_t slot); 
    110111 
    111112 
Note: See TracChangeset for help on using the changeset viewer.