Changeset 278
- Timestamp:
- 10/06/2007 05:51:37 PM (4 years ago)
- Location:
- nano-RK
- Files:
-
- 8 edited
-
projects/basic_rtl/rtl_coord/main.c (modified) (4 diffs)
-
projects/basic_rtl/rtl_coord/nrk_cfg.h (modified) (1 diff)
-
projects/basic_rtl/rtl_fixed/main.c (modified) (4 diffs)
-
projects/fun/laundry_monitor/main.c (modified) (2 diffs)
-
projects/fun/laundry_monitor/nrk_cfg.h (modified) (1 diff)
-
src/net/rt_link/platform/firefly2_2/rtl_defs.h (modified) (1 diff)
-
src/net/rt_link/rt_link.c (modified) (11 diffs)
-
src/net/rt_link/rt_link.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
nano-RK/projects/basic_rtl/rtl_coord/main.c
r256 r278 102 102 nrk_kprintf( PSTR("start done\r\n") ); 103 103 while(!rtl_ready()) nrk_wait_until_next_period(); 104 //nrk_led_set(0);105 104 while(1) { 106 105 107 106 if( rtl_rx_pkt_check()!=0 ) 108 107 { 109 //nrk_led_set(1);108 nrk_led_set(BLUE_LED); 110 109 local_rx_buf=rtl_rx_pkt_get(&length, &rssi, &slot); 111 110 printf( "Got Packet on slot %d %d: ",slot,length ); … … 116 115 nrk_kprintf( PSTR("\r\n") ); 117 116 rtl_rx_pkt_release(); 118 //nrk_led_clr(1);117 nrk_led_clr(BLUE_LED); 119 118 } 120 119 … … 124 123 } 125 124 else { 126 //nrk_led_set(2);125 nrk_led_set(RED_LED); 127 126 cnt++; 128 127 sprintf( &tx_buf[PKT_DATA_START], "Hello World %d", cnt ); … … 130 129 rtl_tx_pkt( tx_buf, length, MY_TX_SLOT ); 131 130 printf( "Sending Packet on slot %d\r\n",MY_TX_SLOT ); 132 //nrk_led_clr(2);131 nrk_led_clr(RED_LED); 133 132 } 134 133 -
nano-RK/projects/basic_rtl/rtl_coord/nrk_cfg.h
r263 r278 19 19 // Leave NRK_NO_POWER_DOWN define in if the target can not wake up from sleep 20 20 // because it has no asynchronously clocked 21 // #define NRK_NO_POWER_DOWN21 // #define NRK_NO_POWER_DOWN 22 22 23 23 #define NRK_MAX_TASKS 4 // Max number of tasks in your application -
nano-RK/projects/basic_rtl/rtl_fixed/main.c
r263 r278 112 112 if( rtl_rx_pkt_check()!=0 ) 113 113 { 114 //nrk_led_set(1);114 nrk_led_set(BLUE_LED); 115 115 local_rx_buf=rtl_rx_pkt_get(&length, &rssi, &slot); 116 116 printf( "Got Packet on slot %d %d: ",slot,length ); … … 121 121 nrk_kprintf( PSTR("\r\n") ); 122 122 rtl_rx_pkt_release(); 123 //nrk_led_clr(1);123 nrk_led_clr(BLUE_LED); 124 124 } 125 125 … … 129 129 } 130 130 else { 131 //nrk_led_set(2);131 nrk_led_set(GREEN_LED); 132 132 cnt++; 133 133 sprintf( &tx_buf[PKT_DATA_START], "Hello World %d", cnt ); … … 135 135 rtl_tx_pkt( tx_buf, length, MY_TX_SLOT ); 136 136 printf( "Sending Packet on slot %d\r\n",MY_TX_SLOT ); 137 //nrk_led_clr(2);137 nrk_led_clr(GREEN_LED); 138 138 } 139 139 -
nano-RK/projects/fun/laundry_monitor/main.c
r269 r278 37 37 #include <ff_basic_sensor.h> 38 38 39 //#define LED_NOTIFY40 #define COORDINATOR41 #define NODE_ID 139 #define LED_NOTIFY 40 //#define COORDINATOR 41 #define NODE_ID 4 42 42 43 43 #if NODE_ID == 1 … … 186 186 //prev_light=light; 187 187 188 nrk_led_set(2); 188 189 tx_buf[PKT_DATA_START]=NODE_ID; 189 190 tx_buf[PKT_DATA_START+1]=vibrate; -
nano-RK/projects/fun/laundry_monitor/nrk_cfg.h
r269 r278 19 19 // Leave NRK_NO_POWER_DOWN define in if the target can not wake up from sleep 20 20 // because it has no asynchronously clocked 21 // #define NRK_NO_POWER_DOWN21 // #define NRK_NO_POWER_DOWN 22 22 23 23 // We have at most NRK_DRIVER_CNT drivers to register -
nano-RK/src/net/rt_link/platform/firefly2_2/rtl_defs.h
r240 r278 56 56 #define OS_TICK_TO_TASK_START 800 57 57 //#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) 59 60 60 61 -
nano-RK/src/net/rt_link/rt_link.c
r263 r278 87 87 } 88 88 89 int8_t rtl_wait_until_rx_p acket ()89 int8_t rtl_wait_until_rx_pkt () 90 90 { 91 91 nrk_signal_register(rtl_rx_pkt_signal); … … 239 239 slot = (TDMA_FRAME_SLOTS - slot - 1); 240 240 _rtl_contention_pending = 1; 241 //printf( "CONTENTION %d\r\n",slot );242 241 } 243 242 rtl_tx_info[slot].pPayload = tx_buf; // pass le pointer … … 403 402 if (_nrk_os_timer_get () > timeout) 404 403 { 405 nrk_kprintf( PSTR("Pkt timed out\r\n") );404 //nrk_kprintf( PSTR("Pkt timed out\r\n") ); 406 405 break; // huge timeout as failsafe 407 406 } … … 431 430 if(tmp_token>_rtl_time_token || (_rtl_time_token>110 && tmp_token<10)) 432 431 { 432 rtl_rx_slot = (global_slot ) % 32; 433 433 // 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 ) 435 435 { 436 // Got normal packet 436 437 // if we got a good packet, send the signal to 437 438 // 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); 440 446 } 441 447 // If it is a time sync packet, then release it 442 448 // so it doesn't block a buffer... 443 449 else { 444 // nrk_kprintf( PSTR("explicit\r\n") );450 // Explicit Sync 445 451 rtl_rx_pkt_release(); 446 452 // nrk_event_signal (SIG(RTL_RX_PKT_EVENT)); … … 463 469 #endif 464 470 465 rtl_rx_slot = (global_slot - 1) % 32;471 rtl_rx_slot = (global_slot) % 32; 466 472 current_global_slot = global_slot-1; 467 473 //printf( "Got sync token %d\r\n",tmp_token ); … … 600 606 while ((n = rf_polling_rx_packet ()) == 0) { 601 607 if (_nrk_os_timer_get () > timeout) { 602 nrk_kprintf( PSTR("pkt timed out\r\n") );608 //nrk_kprintf( PSTR("pkt timed out\r\n") ); 603 609 break; // huge timeout as failsafe 604 610 } … … 636 642 { 637 643 // 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. 639 647 nrk_event_signal (rtl_rx_pkt_signal); 640 648 } 641 // If it is a time sync packet, then release it649 // If it is an explicit time sync packet, then release it 642 650 // 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 } 644 655 } // else printf( "Error = %d\r\n",(int8_t)n ); 645 656 #ifdef RTL_DEBUG … … 668 679 void _rtl_tx (uint8_t slot) 669 680 { 681 int8_t explicit_tsync; 670 682 671 683 if (rtl_sync_status () == 0) … … 682 694 // or in so that you don't kill 683 695 //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 685 707 // MSB (explicit time slot flag) 686 708 … … 697 719 _rtl_contention_pending = 0; 698 720 // 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); 701 724 702 725 #ifdef LED_DEBUG … … 1007 1030 // and does not signal applications 1008 1031 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; 1010 1034 rtl_tsync_tx.length=PKT_DATA_START; 1011 1035 if(slot>(TDMA_FRAME_SLOTS-_rtl_contention_slots)) -
nano-RK/src/net/rt_link/rt_link.h
r263 r278 108 108 int8_t rtl_tx_pkt (uint8_t *buf, uint8_t len, uint8_t slot); 109 109 int8_t rtl_tx_abs_pkt (uint8_t *buf, uint8_t len, uint16_t abs_slot); 110 int8_t rtl_wait_until_tx_done(uint8_t slot); 110 111 111 112
Note: See TracChangeset
for help on using the changeset viewer.
