Changeset 1031


Ignore:
Timestamp:
01/13/2010 02:32:46 AM (2 years ago)
Author:
jcy
Message:

Added CCA mode func to basic_rf.c
Support for modulated CCA checks in tdma-asap

Location:
nano-RK
Files:
4 edited

Legend:

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

    r1028 r1031  
    4444#define EVENT_PERIOD_SECS 10 
    4545 
    46 #define TDMA_MODE TDMA_SLAVE 
     46#define TDMA_MODE TDMA_MASTER 
    4747#define SMALL_STACK 256 
    4848 
  • nano-RK/src/net/tdma_asap/tdma_asap.c

    r1030 r1031  
    912912        { 
    913913            rf_tx_set_serial(); 
    914             rf_set_preamble_length(4); // send 2 more bytes to make it equal to minipacket size 
     914            //rf_set_preamble_length(4); // send 2 more bytes to make it equal to minipacket size 
    915915 
    916916            nrk_gpio_raw_direction(DDRC, FIFO, NRK_PIN_OUTPUT); 
    917917            // keep sending preambles repeatedly 
    918918 
     919            // MOD_CCA 13 jan 2010 : Just throw on the radio and let it roll 
     920            rf_carrier_on(); 
    919921 
    920922            // this timing needs perfected 
    921923            //while (_nrk_high_speed_timer_get() < (DATA_SLOT_START_TICKS-TDMA_DELTA_SLOT_TICKS+500)) 
    922             DISABLE_GLOBAL_INT(); 
    923924            while (_nrk_high_speed_timer_get() < (DATA_SLOT_START_TICKS+DELTA_SLOT_OFFSET)) 
    924925            { 
     
    928929    #endif 
    929930 
     931                /* 
    930932                rf_carrier_on(); 
    931933                while (!SFD_IS_1 || !FIFOP_IS_1); 
     
    936938                rf_carrier_off(); 
    937939                cnt++; 
     940                */ 
    938941 
    939942    #ifdef TDMA_STATS_COLLECT 
     
    942945 
    943946            }  
    944             ENABLE_GLOBAL_INT(); 
    945             rf_set_preamble_length(2); // 3 bytes, 802.15.4 compliant 
     947 
     948            // MOD_CCA 13 Jan 2010 
     949            rf_carrier_off(); 
     950 
     951            //rf_set_preamble_length(2); // 3 bytes, 802.15.4 compliant 
    946952 
    947953            nrk_gpio_raw_direction(DDRC,FIFO,NRK_PIN_INPUT); 
     
    13331339#ifdef TDMA_PREAMBLE_HANDSHAKE 
    13341340    #ifdef TDMA_STATS_COLLECT 
    1335         stats_start_rdo(); 
    1336     #endif 
    1337         rf_rx_on(); 
     1341        //stats_start_rdo(); 
     1342    #endif 
     1343        //rf_rx_on(); 
     1344        // MOD_CCA 13 Jan 2010:  
     1345        rf_set_cca_mode(1); 
    13381346#endif 
    13391347 
     
    13441352            //nrk_kprintf(PSTR("Checking Channel\r\n")); 
    13451353#ifdef TDMA_PREAMBLE_HANDSHAKE 
    1346             if (SFD_IS_1) 
     1354            //if (SFD_IS_1) 
     1355            // MOD_CCA 13 Jan 2010: use CCA (modified method) 
     1356            if (!_tdma_channel_check()) 
    13471357#else 
    13481358            if (!_tdma_channel_check()) // if channel activity 
     
    13761386#endif 
    13771387    // done checking channel 
     1388#ifdef TDMA_PREAMBLE_HANDSHAKE 
     1389    // MOD_CCA 13 Jan 2010 
     1390    rf_set_cca_mode(2); 
     1391#endif 
     1392 
    13781393    rf_rx_off(); 
    13791394 
     
    15661581        stats_start_rdo(); 
    15671582    #endif 
    1568         rf_rx_set_serial(); 
    1569         rf_rx_on(); 
     1583        // MOD_CCA 13 Jan 2010 
     1584        //rf_rx_set_serial(); 
     1585        //rf_rx_on(); 
     1586        rf_set_cca_mode(2); 
    15701587        while (_nrk_high_speed_timer_get() < (DATA_SLOT_START_TICKS + DELTA_SLOT_OFFSET) && 
    1571             (v = !(SFD_IS_1))); 
     1588            (v = _tdma_channel_check())); 
     1589            //(v = !(SFD_IS_1))); 
    15721590#else 
    15731591        // wait while we are still before the data slot start time and the channel is free 
     
    15851603    //#endif 
    15861604            nrk_led_set(GREEN_LED); 
     1605    #ifdef TDMA_PREAMBLE_HANDSHAKE 
     1606        // MOD_CCA 13 Jan 2010 
     1607        rf_set_cca_mode(1); 
     1608    #endif 
    15871609    #if defined(TDMA_PREAMBLE_HANDSHAKE) && defined(TDMA_STATS_COLLECT) 
    15881610        stats_stop_rdo(); 
  • nano-RK/src/net/tdma_asap/tdma_asap_tree.c

    r1029 r1031  
    146146    sensorsInfo[2 ].isDead = 0; 
    147147        sensorsInfo[2 ].parent = 1; 
    148     sensorsInfo[3 ].isDead = 1; 
     148    sensorsInfo[3 ].isDead = 0; 
    149149        sensorsInfo[3 ].parent = 15; 
    150150    sensorsInfo[4 ].isDead = 0; 
    151151        sensorsInfo[4 ].parent = 1; 
    152     sensorsInfo[5 ].isDead = 1; 
     152    sensorsInfo[5 ].isDead = 0; 
    153153        sensorsInfo[5 ].parent = 14; 
    154     sensorsInfo[6 ].isDead = 1; 
     154    sensorsInfo[6 ].isDead = 0; 
    155155        sensorsInfo[6 ].parent = 5; 
    156     sensorsInfo[7 ].isDead = 1; 
     156    sensorsInfo[7 ].isDead = 0; 
    157157        sensorsInfo[7 ].parent = 11; 
    158     sensorsInfo[8 ].isDead = 1; 
     158    sensorsInfo[8 ].isDead = 0; 
    159159        sensorsInfo[8 ].parent = 1; 
    160     sensorsInfo[9 ].isDead = 1; 
     160    sensorsInfo[9 ].isDead = 0; 
    161161        sensorsInfo[9 ].parent = 12; 
    162     sensorsInfo[10].isDead = 1; 
     162    sensorsInfo[10].isDead = 0; 
    163163        sensorsInfo[10].parent = 8; 
    164     sensorsInfo[11].isDead = 1; 
     164    sensorsInfo[11].isDead = 0; 
    165165        sensorsInfo[11].parent = 1; 
    166     sensorsInfo[12].isDead = 1; 
     166    sensorsInfo[12].isDead = 0; 
    167167        sensorsInfo[12].parent = 16; 
    168     sensorsInfo[13].isDead = 1; 
     168    sensorsInfo[13].isDead = 0; 
    169169        sensorsInfo[13].parent = 10; 
    170     sensorsInfo[14].isDead = 1; 
     170    sensorsInfo[14].isDead = 0; 
    171171        sensorsInfo[14].parent = 1; 
    172     sensorsInfo[15].isDead = 1; 
     172    sensorsInfo[15].isDead = 0; 
    173173        sensorsInfo[15].parent = 9; 
    174     sensorsInfo[16].isDead = 1; 
     174    sensorsInfo[16].isDead = 0; 
    175175        sensorsInfo[16].parent = 6; 
    176176 
  • nano-RK/src/radio/cc2420/source/basic_rf.c

    r1030 r1031  
    11141114    FASTSPI_SETREG(CC2420_MDMCTRL0, mdmctrl0); 
    11151115} 
     1116 
     1117/********************************************************** 
     1118 * Set the CCA mode 
     1119 * Accept 1-3 as argument 
     1120 */ 
     1121void rf_set_cca_mode(uint8_t mode) 
     1122{ 
     1123    mdmctrl0 &= (0xFF3F); 
     1124    mdmctrl0 |= ((mode & 0x3) << 6); 
     1125    FASTSPI_SETREG(CC2420_MDMCTRL0, mdmctrl0); 
     1126} 
     1127 
    11161128/********************************************************** 
    11171129 * start sending a carrier pulse 
Note: See TracChangeset for help on using the changeset viewer.