diff --git a/.gitignore b/.gitignore index 7b0464eeff..551398b967 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ Debug settings *.dep +*.ewd +*.ewt +*.bak *.sfr *.o *.exe @@ -24,3 +27,5 @@ settings /projects/telosb/01bsp_uart/path.txt /projects/telosb/03oos_macpong/path.txt /projects/telosb/02drv_opentimers/path.txt +/projects/openmote-b/01bsp_openradio_rx/log.txt +/projects/openmote-b/01bsp_radio_tx/asm.s diff --git a/SConstruct b/SConstruct index 258a998a14..459aa23afc 100644 --- a/SConstruct +++ b/SConstruct @@ -3,7 +3,7 @@ import sys import platform import SCons -#============================ banner ========================================== +#============================ banner ========================================= banner = [] banner += [""] diff --git a/bootloader/openmote-cc2538/ot_program.py b/bootloader/openmote-cc2538/ot_program.py index 5f66b7481f..63e024967c 100644 --- a/bootloader/openmote-cc2538/ot_program.py +++ b/bootloader/openmote-cc2538/ot_program.py @@ -10,6 +10,105 @@ #============================ defines ========================================= BROKER_ADDRESS = "argus.paris.inria.fr" NUMBER_OF_MOTES = 80 - 4 # 4 motes are used for local test +BOOT_MODE = "default" #"default" or "subset" + +# subset used for 10% disturbance experiments +mote_subset1 = [ +"00-12-4b-00-14-b5-b5-95" +] + +# subset used for 10% disturbance experiments +#mote_subset = [ +#"00-12-4b-00-14-b5-b5-8c", +#"00-12-4b-00-14-b5-b6-02", +#"00-12-4b-00-14-b5-b5-7e", +#"00-12-4b-00-14-b5-b6-1c" +#] +temp_subset=[ +"00-12-4b-00-14-b5-b6-46", +"00-12-4b-00-14-b5-b6-1c", +"00-12-4b-00-14-b5-b5-57", +"00-12-4b-00-14-b5-b5-58", +"00-12-4b-00-14-b5-b5-a3", +"00-12-4b-00-14-b5-b6-3a", +"00-12-4b-00-14-b5-b6-18", +"00-12-4b-00-14-b5-b5-8c", +"00-12-4b-00-14-b5-b5-71", +"00-12-4b-00-14-b5-b6-12" + +] +# subset used for 50% density experiments +#mote_subset = [ +#"00-12-4b-00-14-b5-b4-8d", +#"00-12-4b-00-14-b5-b5-71", +#"00-12-4b-00-14-b5-b5-b5", +#"00-12-4b-00-14-b5-b5-93", +#"00-12-4b-00-14-b5-b5-a3", +#"00-12-4b-00-14-b5-b6-02", +#"00-12-4b-00-14-b5-b6-05", +#"00-12-4b-00-14-b5-b6-1c", +#"00-12-4b-00-14-b5-b5-a9", +#"00-12-4b-00-14-b5-b5-88", +#"00-12-4b-00-14-b5-b4-62", +#"00-12-4b-00-14-b5-b6-22", +#"00-12-4b-00-14-b5-b5-63", +#"00-12-4b-00-14-b5-b6-0b", +#"00-12-4b-00-14-b5-b6-40", +#"00-12-4b-00-14-b5-b5-d8", +#"00-12-4b-00-14-b5-b6-12", +#"00-12-4b-00-14-b5-b6-18", +#"00-12-4b-00-14-b5-b6-3a", +#"00-12-4b-00-14-b5-b5-57", +#"00-12-4b-00-14-b5-b6-48" +#] + +# motes in building a +mote_subset2 = [ +"00-12-4b-00-14-b5-b5-95", +"00-12-4b-00-14-b5-b5-d8", +"00-12-4b-00-14-b5-b4-8d", +"00-12-4b-00-14-b5-b6-22", +"00-12-4b-00-14-b5-b6-40", +"00-12-4b-00-14-b5-b6-29", +"00-12-4b-00-14-b5-b6-46", +"00-12-4b-00-14-b5-b6-47", +"00-12-4b-00-14-b5-b6-02", +"00-12-4b-00-14-b5-b6-1c", +"00-12-4b-00-14-b5-b6-1a", +"00-12-4b-00-14-b5-b5-e7", +"00-12-4b-00-14-b5-b4-62", +"00-12-4b-00-14-b5-b4-98", +"00-12-4b-00-14-b5-b5-a9", +"00-12-4b-00-14-b5-b5-57", +"00-12-4b-00-14-b5-b5-58", +"00-12-4b-00-14-b5-b5-88", +"00-12-4b-00-14-b5-b5-3d", +"00-12-4b-00-14-b5-b5-a3", +"00-12-4b-00-14-b5-b4-aa", +"00-12-4b-00-14-b5-b5-5b", +"00-12-4b-00-14-b5-b6-48", +"00-12-4b-00-14-b5-b5-7e", +"00-12-4b-00-14-b5-b6-3a", +"00-12-4b-00-14-b5-b6-38", +"00-12-4b-00-14-b5-b5-93", +"00-12-4b-00-14-b5-b6-18", +"00-12-4b-00-14-b5-b5-b5", +"00-12-4b-00-14-b5-b5-f8", +"00-12-4b-00-14-b5-b5-b7", +"00-12-4b-00-14-b5-b5-8c", +"00-12-4b-00-14-b5-b6-0b", +"00-12-4b-00-14-b5-b5-f1", +"00-12-4b-00-14-b5-b5-f3", +"00-12-4b-00-14-b5-b5-f2", +"00-12-4b-00-14-b5-b5-bf", +"00-12-4b-00-14-b5-b6-05", +"00-12-4b-00-14-b5-b5-63", +"00-12-4b-00-14-b5-b5-71", +"00-12-4b-00-14-b5-b5-65", +"00-12-4b-00-14-b5-b6-12" +] + +mote_subset = temp_subset #============================ classes ========================================= class program_over_testbed(object): @@ -18,14 +117,14 @@ class program_over_testbed(object): CMD = 'program' # in seconds, should be larger than the time starting from publishing message until receiving the response - MESSAGE_RESP_TIMEOUT = 30 + MESSAGE_RESP_TIMEOUT = 60 def __init__(self, mote, image_path): # initialize parameters self.mote = mote self.image = None - + print "\tprogramming: {0}".format(mote) # check bootload backdoor is configured correctly bootloader_backdoor_enabled = False @@ -66,10 +165,6 @@ def __init__(self, mote, image_path): 'failed_messages_topic': [] } - # mqtt topic string format - self.mqtttopic_mote_cmd = 'opentestbed/deviceType/mote/deviceId/{0}/cmd/{1}'.format(self.mote,self.CMD) - self.mqtttopic_mote_resp = 'opentestbed/deviceType/mote/deviceId/{0}/resp/{1}'.format(self.mote,self.CMD) - # connect to MQTT self.mqttclient = mqtt.Client(self.CLIENT_ID) self.mqttclient.on_connect = self._on_mqtt_connect @@ -85,12 +180,33 @@ def __init__(self, mote, image_path): 'description': self.image_name, 'hex': self.image, } - # publish the cmd message - self.mqttclient.publish( - topic = self.mqtttopic_mote_cmd, - payload = json.dumps(payload_program_image), - ) - + if BOOT_MODE == 'default': + # mqtt topic string format + self.mqtttopic_mote_cmd = 'opentestbed/deviceType/mote/deviceId/{0}/cmd/{1}'.format(self.mote,self.CMD) + self.mqtttopic_mote_resp = 'opentestbed/deviceType/mote/deviceId/{0}/resp/{1}'.format(self.mote,self.CMD) + print "\tcmd: {}".format(self.mqtttopic_mote_cmd) + # publish the cmd message + self.mqttclient.publish( + topic = self.mqtttopic_mote_cmd, + payload = json.dumps(payload_program_image), + ) + elif BOOT_MODE == "subset": + i = 0 + for m in mote_subset: + # mqtt topic string format + self.mqtttopic_mote_cmd = 'opentestbed/deviceType/mote/deviceId/{0}/cmd/{1}'.format(m,self.CMD) + self.mqtttopic_mote_resp = 'opentestbed/deviceType/mote/deviceId/{0}/resp/{1}'.format(m,self.CMD) + print "\tcmd: {}".format(self.mqtttopic_mote_cmd) + self.mqttclient.publish( + topic = self.mqtttopic_mote_cmd, + payload = json.dumps(payload_program_image), + ) + # wait = random.randrange(60, 360, 1) # a random value beween 1 and 3 minutes + wait = 5 + time.sleep(wait) + i+=1 + if i%10==0: + time.sleep(5) try: # wait maxmium MESSAGE_RESP_TIMEOUT seconds before return self.cmd_response_success_queue.get(timeout=self.MESSAGE_RESP_TIMEOUT) @@ -118,7 +234,8 @@ def _on_mqtt_message(self, client, userdata, message): ''' Record the number of message received and success status ''' - + print userdata + print message self.response_success['message_counter'] += 1 if json.loads(message.payload)['success']: self.response_success['success_counter'] += 1 @@ -187,4 +304,4 @@ def usage(): raise Exception('No file path given.') #==== program_over_testbed - program_over_testbed(configure['mote_address'], configure['image_name_path']) \ No newline at end of file + program_over_testbed(configure['mote_address'], configure['image_name_path']) diff --git a/bsp/boards/board.h b/bsp/boards/board.h index a46a95ae17..29cd52e51d 100644 --- a/bsp/boards/board.h +++ b/bsp/boards/board.h @@ -16,25 +16,55 @@ #include "toolchain_defs.h" //=========================== define ========================================== +#define SLOTDURATION_MS board_getSlotDuration()/PORT_TICS_PER_MS typedef enum { DO_NOT_KICK_SCHEDULER = 0, KICK_SCHEDULER = 1, } kick_scheduler_t; + + //=========================== typedef ========================================= +typedef struct { + uint16_t slotDuration; + + // execution speed related + // also implementation related (e.g. SoC radio or spi-connected radio because of the time to load a packet to/from radio) + uint16_t maxTxDataPrepare; + uint16_t maxRxAckPrepare; + uint16_t maxRxDataPrepare; + uint16_t maxTxAckPrepare; + + // radio speed related + // also implementation related (because the time to execute the Tx/Rx command is highly dependent on the radio AND the configuration) + uint16_t delayTx; + uint16_t delayRx; +} slot_board_vars_t; //board specific slot vars + +// available slot templates +typedef enum{ + SLOT_10ms, + SLOT_20ms_24GHZ, + SLOT_40ms_24GHZ, + SLOT_40ms_FSK_SUBGHZ, + SLOT_40ms_OFDM1MCS0_3_SUBGHZ, + MAX_SLOT_TYPES, +} slotType_t; //=========================== variables ======================================= //=========================== prototypes ====================================== -void board_init(void); -void board_sleep(void); -void board_reset(void); - +void board_init(void); +void board_sleep(void); +void board_reset(void); +uint16_t board_getSlotDuration (void); +slot_board_vars_t board_selectSlotTemplate(slotType_t slot_type); /** \} \} */ - +//=========================== private ========================================= +void board_init_slot_vars(void); #endif diff --git a/bsp/boards/iot-lab_A8-M3/board.c b/bsp/boards/iot-lab_A8-M3/board.c index 29b8a060f9..2f1b7ae1b2 100644 --- a/bsp/boards/iot-lab_A8-M3/board.c +++ b/bsp/boards/iot-lab_A8-M3/board.c @@ -16,7 +16,10 @@ #include "nvic.h" #include "debugpins.h" -//=========================== variable ======================================== +//=========================== variables ======================================= + +slot_board_vars_t slot_board_vars [MAX_SLOT_TYPES]; +slotType_t selected_slot_type; //=========================== private ========================================= @@ -25,6 +28,8 @@ void GPIO_Config_ALL_AIN(void); // configure the hard fault exception void board_enableHardFaultExceptionHandler(void); + + //=========================== main ============================================ extern int mote_main(void); @@ -96,6 +101,35 @@ void board_init(void){ debugpins_init(); //enable nvic for the radio NVIC_radio(); + board_init_slot_vars(); +} + + +//==== bootstrapping slot info lookup table +void board_init_slot_vars(void){ + + // 20ms slot + slot_board_vars [SLOT_20ms_24GHZ].slotDuration = 655 ; // ms + slot_board_vars [SLOT_20ms_24GHZ].maxTxDataPrepare = 110 ; // 3355us (not measured) + slot_board_vars [SLOT_20ms_24GHZ].maxRxAckPrepare = 20 ; // 610us (not measured) + slot_board_vars [SLOT_20ms_24GHZ].maxRxDataPrepare = 33 ; // 1000us (not measured) + slot_board_vars [SLOT_20ms_24GHZ].maxTxAckPrepare = 50 ; // 1525us (not measured) + slot_board_vars [SLOT_20ms_24GHZ].delayTx = 18 ; // 549us (not measured) + slot_board_vars [SLOT_20ms_24GHZ].delayRx = 0 ; // 0us (can not measure) +} + +// To get the current slotDuration at any time +// used during initialization by sixtop to fire the first sixtop EB +uint16_t board_getSlotDuration (void) +{ + return slot_board_vars [selected_slot_type].slotDuration; +} + +// Setter/Getter function for slot_board_vars +slot_board_vars_t board_selectSlotTemplate (slotType_t slot_type) +{ + selected_slot_type = slot_type; + return slot_board_vars [selected_slot_type]; } void board_sleep(void) { diff --git a/bsp/boards/iot-lab_A8-M3/board_info.h b/bsp/boards/iot-lab_A8-M3/board_info.h index 46b9db4c12..379933fc72 100644 --- a/bsp/boards/iot-lab_A8-M3/board_info.h +++ b/bsp/boards/iot-lab_A8-M3/board_info.h @@ -50,23 +50,6 @@ to return the board's description. #define PORT_PIN_RADIO_RESET_HIGH() //GPIOC->ODR |= 0X0040;// nothing #define PORT_PIN_RADIO_RESET_LOW() //GPIOC->ODR &= ~0X0040;// nothing -//===== IEEE802154E timing - -#define SLOTDURATION 20 // in miliseconds - -// time-slot related -#define PORT_TsSlotDuration 655 // 20ms - -// execution speed related -#define PORT_maxTxDataPrepare 110 // 3355us (not measured) -#define PORT_maxRxAckPrepare 20 // 610us (not measured) -#define PORT_maxRxDataPrepare 33 // 1000us (not measured) -#define PORT_maxTxAckPrepare 50 // 1525us (not measured) - -// radio speed related -#define PORT_delayTx 18 // 549us (not measured) -#define PORT_delayRx 0 // 0us (can not measure) -// radio watchdog //===== adaptive_sync accuracy diff --git a/bsp/boards/iot-lab_M3/board.c b/bsp/boards/iot-lab_M3/board.c index 1603716ef0..5c2b7e7d65 100644 --- a/bsp/boards/iot-lab_M3/board.c +++ b/bsp/boards/iot-lab_M3/board.c @@ -19,6 +19,11 @@ #include "gpio.h" #include "cryptoengine.h" + +//=========================== variables ======================================= +slot_board_vars_t slot_board_vars [MAX_SLOT_TYPES]; +slotType_t selected_slot_type; + //=========================== main ============================================ extern int mote_main(void); @@ -93,6 +98,35 @@ void board_init(void) //enable nvic for the radio NVIC_radio(); cryptoengine_init(); + board_init_slot_vars(); +} + + +//==== bootstrapping slot info lookup table +void board_init_slot_vars(void){ + + // 20ms slot + slot_board_vars [SLOT_20ms_24GHZ].slotDuration = 655 ; // ms + slot_board_vars [SLOT_20ms_24GHZ].maxTxDataPrepare = 110 ; // 3355us (not measured) + slot_board_vars [SLOT_20ms_24GHZ].maxRxAckPrepare = 20 ; // 610us (not measured) + slot_board_vars [SLOT_20ms_24GHZ].maxRxDataPrepare = 33 ; // 1000us (not measured) + slot_board_vars [SLOT_20ms_24GHZ].maxTxAckPrepare = 50 ; // 1525us (not measured) + slot_board_vars [SLOT_20ms_24GHZ].delayTx = 18 ; // 549us (not measured) + slot_board_vars [SLOT_20ms_24GHZ].delayRx = 0 ; // 0us (can not measure) +} + +// To get the current slotDuration at any time +// used during initialization by sixtop to fire the first sixtop EB +uint16_t board_getSlotDuration (void) +{ + return slot_board_vars [selected_slot_type].slotDuration; +} + +// Setter/Getter function for slot_board_vars +slot_board_vars_t board_selectSlotTemplate (slotType_t slot_type) +{ + selected_slot_type = slot_type; + return slot_board_vars [selected_slot_type]; } void board_sleep(void) { diff --git a/bsp/boards/iot-lab_M3/board_info.h b/bsp/boards/iot-lab_M3/board_info.h index babbc4a216..36d3109adb 100644 --- a/bsp/boards/iot-lab_M3/board_info.h +++ b/bsp/boards/iot-lab_M3/board_info.h @@ -49,23 +49,6 @@ to return the board's description. #define PORT_PIN_RADIO_RESET_LOW() //GPIOC->ODR &= ~0X0040;// nothing //#define PORT_PIN_RADIO_RESET_LOW() GPIOC->ODR &= ~(1<<1); -//===== IEEE802154E timing - -#define SLOTDURATION 20 // in miliseconds - -// time-slot related -#define PORT_TsSlotDuration 655 // 20ms - -// execution speed related -#define PORT_maxTxDataPrepare 110 // 3355us (not measured) -#define PORT_maxRxAckPrepare 20 // 610us (not measured) -#define PORT_maxRxDataPrepare 33 // 1000us (not measured) -#define PORT_maxTxAckPrepare 50 // 1525us (not measured) - -// radio speed related -#define PORT_delayTx 18 // 549us (not measured) -#define PORT_delayRx 0 // 0us (can not measure) -// radio watchdog //===== adaptive_sync accuracy diff --git a/bsp/boards/openmote-b-24ghz/board.c b/bsp/boards/openmote-b-24ghz/board.c index 3ba1e7eafb..b9fc4cfee6 100644 --- a/bsp/boards/openmote-b-24ghz/board.c +++ b/bsp/boards/openmote-b-24ghz/board.c @@ -34,6 +34,11 @@ #define BSP_BUTTON_BASE ( GPIO_D_BASE ) #define BSP_BUTTON_USER ( GPIO_PIN_5 ) +//=========================== variables ============================================ +slot_board_vars_t slot_board_vars [MAX_SLOT_TYPES]; +slotType_t selected_slot_type; + + //=========================== prototypes ====================================== void board_timer_init(void); @@ -73,11 +78,50 @@ void board_init(void) { uart_init(); radio_init(); i2c_init(); - + board_init_slot_vars(); // sensors_init(); cryptoengine_init(); } +//==== bootstrapping slot info lookup table +void board_init_slot_vars(void){ + //10ms slot + slot_board_vars [SLOT_10ms].slotDuration = 328 ; // 10ms + slot_board_vars [SLOT_10ms].maxTxDataPrepare = 10 ; // 305us (measured 82us) + slot_board_vars [SLOT_10ms].maxRxAckPrepare = 10 ; // 305us (measured 83us) + slot_board_vars [SLOT_10ms].maxRxDataPrepare = 4 ; // 122us (measured 22us) + slot_board_vars [SLOT_10ms].maxTxAckPrepare = 10 ; // 122us (measured 94us) + #ifdef L2_SECURITY_ACTIVE + slot_board_vars [SLOT_10ms].delayTx = 14 ; // 366us (measured xxxus) + #else + slot_board_vars [SLOT_10ms].delayTx = 12 ; // 366us (measured xxxus) + #endif + slot_board_vars [SLOT_10ms].delayRx = 0 ; // 0us (can not measure) + + // 20ms slot + slot_board_vars [SLOT_20ms_24GHZ].slotDuration = 655 ; // 20ms + slot_board_vars [SLOT_20ms_24GHZ].maxTxDataPrepare = 15 ; // 457us (based on measurement) + slot_board_vars [SLOT_20ms_24GHZ].maxRxAckPrepare = 10 ; // 305us (based on measurement) + slot_board_vars [SLOT_20ms_24GHZ].maxRxDataPrepare = 10 ; // 305us (based on measurement) + slot_board_vars [SLOT_20ms_24GHZ].maxTxAckPrepare = 15 ; // 457us (based on measurement) + slot_board_vars [SLOT_20ms_24GHZ].delayTx = 13 ; // 396us (based on measurement) + slot_board_vars [SLOT_20ms_24GHZ].delayRx = 0 ; // 0us (can not measure) +} + +// To get the current slotDuration at any time +// used during initialization by sixtop to fire the first sixtop EB +uint16_t board_getSlotDuration (void) +{ + return slot_board_vars [selected_slot_type].slotDuration; +} + +// Setter/Getter function for slot_board_vars +slot_board_vars_t board_selectSlotTemplate (slotType_t slot_type) +{ + selected_slot_type = slot_type; + return slot_board_vars [selected_slot_type]; +} + void antenna_init(void) { /* Configure GPIO as output */ GPIOPinTypeGPIOOutput(BSP_ANTENNA_BASE, BSP_ANTENNA_CC2538_24GHZ); diff --git a/bsp/boards/openmote-b-24ghz/board_info.h b/bsp/boards/openmote-b-24ghz/board_info.h index c0dc0d92b7..29024cb011 100644 --- a/bsp/boards/openmote-b-24ghz/board_info.h +++ b/bsp/boards/openmote-b-24ghz/board_info.h @@ -58,42 +58,6 @@ #define PORT_PIN_RADIO_RESET_HIGH() // nothing #define PORT_PIN_RADIO_RESET_LOW() // nothing -#define SLOTDURATION 20 // in miliseconds - -//===== IEEE802154E timing - -#if SLOTDURATION==10 - // time-slot related - #define PORT_TsSlotDuration 328 // counter counts one extra count, see datasheet - // execution speed related - #define PORT_maxTxDataPrepare 10 // 305us (measured 82us) - #define PORT_maxRxAckPrepare 10 // 305us (measured 83us) - #define PORT_maxRxDataPrepare 4 // 122us (measured 22us) - #define PORT_maxTxAckPrepare 10 // 122us (measured 94us) - // radio speed related - #ifdef L2_SECURITY_ACTIVE - #define PORT_delayTx 14 // 366us (measured xxxus) - #else - #define PORT_delayTx 12 // 366us (measured xxxus) - #endif - #define PORT_delayRx 0 // 0us (can not measure) - // radio watchdog -#endif - -#if SLOTDURATION==20 - #define PORT_TsSlotDuration 655 // 20ms - - // execution speed related - #define PORT_maxTxDataPrepare 15 // 458us (measured 213us) - #define PORT_maxRxAckPrepare 10 // 305us (measured 86us) - #define PORT_maxRxDataPrepare 10 // 305us (measured 88us) - #define PORT_maxTxAckPrepare 15 // 458us (measured 211us) - - // radio speed related - #define PORT_delayTx 13 // 397us (measured 388us) - #define PORT_delayRx 0 // 0us (can not measure) -#endif - //===== adaptive_sync accuracy #define SYNC_ACCURACY 1 // ticks diff --git a/bsp/boards/openmote-b-24ghz/radio.c b/bsp/boards/openmote-b-24ghz/radio.c index 08fe64c205..96ae4987c9 100644 --- a/bsp/boards/openmote-b-24ghz/radio.c +++ b/bsp/boards/openmote-b-24ghz/radio.c @@ -45,6 +45,8 @@ typedef struct { radio_vars_t radio_vars; +// global radio selection, will use RADIOSETTING_24GHZ by default at initialization. +uint8_t selected_radioSetting = RADIOSETTING_24GHZ; //=========================== prototypes ====================================== void enable_radio_interrupts(void); @@ -181,7 +183,13 @@ void radio_reset(void) { //===== RF admin -void radio_setFrequency(uint8_t frequency, radio_freq_t tx_or_rx) { +void radio_setConfig (radioSetting_t radioSetting){ + selected_radioSetting = radioSetting; + //do nothing +} + + +void radio_setFrequency(uint16_t frequency, radio_freq_t tx_or_rx) { // change state radio_vars.state = RADIOSTATE_SETTING_FREQUENCY; diff --git a/bsp/boards/openmote-b-subghz/board_info.h b/bsp/boards/openmote-b-subghz/board_info.h index b86a537ae7..431d6d3ce9 100644 --- a/bsp/boards/openmote-b-subghz/board_info.h +++ b/bsp/boards/openmote-b-subghz/board_info.h @@ -114,10 +114,12 @@ #define NUMSENSORS 7 -//====== Antenna options ==== + +//=========================== Antenna options ================================ + #define BSP_ANTENNA_BASE GPIO_D_BASE #define BSP_ANTENNA_CC2538_24GHZ GPIO_PIN_4 //!< PD4 -- 2.4ghz -#define BSP_ANTENNA_AT215_24GHZ GPIO_PIN_3 //!< PD3 -- subghz +#define BSP_ANTENNA_AT215_24GHZ GPIO_PIN_3 //!< PD3 -- subghz //#define DAGROOT //=========================== typedef ======================================== diff --git a/bsp/boards/openmote-b/SConscript b/bsp/boards/openmote-b/SConscript index 71941a8ed4..570b55d7c9 100644 --- a/bsp/boards/openmote-b/SConscript +++ b/bsp/boards/openmote-b/SConscript @@ -10,6 +10,17 @@ si70x = localEnv.SConscript( exports = {'env': env}, ) +cc2538rf = localEnv.SConscript( + os.path.join('#','bsp','chips','cc2538rf','SConscript'), + variant_dir = 'cc2538rf', + exports = {'env': env}, +) +rf215 = localEnv.SConscript( + os.path.join('#','bsp','chips','at86rf215','SConscript'), + variant_dir = 'rf215', + exports = {'env': env}, +) + source = \ [file for file in Glob('*.c') if file.name.find('iar')==-1] + \ Glob('source/*.c') @@ -19,10 +30,12 @@ localEnv.Append( os.path.join('#','bsp','boards','openmote-b'), os.path.join('#','bsp','boards','openmote-b','headers'), os.path.join('#','bsp','boards','openmote-b','source'), + os.path.join('#','bsp','chips','cc2538rf'), os.path.join('#','bsp','chips','si70x'), + os.path.join('#','bsp','chips','at86rf215'), ], ) -board = localEnv.Object(source=source) + si70x +board = localEnv.Object(source=source) + si70x + rf215 + cc2538rf Return('board') diff --git a/bsp/boards/openmote-b/board.c b/bsp/boards/openmote-b/board.c index df5dbadd63..2c5a309108 100644 --- a/bsp/boards/openmote-b/board.c +++ b/bsp/boards/openmote-b/board.c @@ -1,9 +1,9 @@ -/** - * Author: Xavier Vilajosana (xvilajosana@eecs.berkeley.edu) - * Pere Tuset (peretuset@openmote.com) - * Date: July 2013 - * Description: CC2538-specific definition of the "board" bsp module. - */ + + // Author: Xavier Vilajosana (xvilajosana@eecs.berkeley.edu) + // Pere Tuset (peretuset@openmote.com) + // Date: July 2013 + // Description: CC2538-specific definition of the "board" bsp module. + #include #include @@ -19,6 +19,7 @@ #include #include "board.h" +#include "board_info.h" #include "debugpins.h" #include "i2c.h" #include "leds.h" @@ -28,16 +29,13 @@ #include "uart.h" #include "cryptoengine.h" -//=========================== variables ======================================= +//=========================== defines ======================================= -#define BSP_BUTTON_BASE ( GPIO_C_BASE ) -#define BSP_BUTTON_USER ( GPIO_PIN_3 ) +#define BSP_BUTTON_BASE ( GPIO_D_BASE ) +#define BSP_BUTTON_USER ( GPIO_PIN_5 ) + +//=========================== variables ====================================== -#ifdef REVA1 //Rev.A1 uses SF23 cc2538 which start at diffferent location - #define CC2538_FLASH_ADDRESS ( 0x0023F800 ) -#else - #define CC2538_FLASH_ADDRESS ( 0x0027F800 ) -#endif //=========================== prototypes ====================================== void board_timer_init(void); @@ -47,20 +45,22 @@ bool board_timer_expired(uint32_t future); static void clock_init(void); static void gpio_init(void); static void button_init(void); -static void antenna_init(void); +static void antenna_init(void); +void antenna_cc2538(void); +void antenna_at86rf215(void); static void SysCtrlDeepSleepSetting(void); static void SysCtrlSleepSetting(void); static void SysCtrlRunSetting(void); static void SysCtrlWakeupSetting(void); -static void GPIO_C_Handler(void); - -bool user_button_initialized; +//=========================== variables ======================================= +slot_board_vars_t slot_board_vars [MAX_SLOT_TYPES]; +slotType_t selected_slot_type; //=========================== main ============================================ - + extern int mote_main(void); int main(void) { @@ -70,73 +70,96 @@ int main(void) { //=========================== public ========================================== void board_init(void) { - user_button_initialized = FALSE; - - gpio_init(); - clock_init(); - antenna_init(); - board_timer_init(); - leds_init(); - debugpins_init(); - button_init(); - sctimer_init(); - uart_init(); - radio_init(); - i2c_init(); - sensors_init(); - cryptoengine_init(); + + + gpio_init(); + clock_init(); + antenna_init(); + board_timer_init(); + leds_init(); + debugpins_init(); + button_init(); + sctimer_init(); + uart_init(); + radio_init(); + i2c_init(); + board_init_slot_vars(); + // sensors_init(); + cryptoengine_init(); } void antenna_init(void) { - //use cc2538 2.4ghz radio - GPIOPinWrite(BSP_ANTENNA_BASE, BSP_ANTENNA_CC2538_24GHZ, BSP_ANTENNA_CC2538_24GHZ); - GPIOPinWrite(BSP_ANTENNA_BASE, BSP_ANTENNA_AT215_24GHZ, 0); + // Configure GPIO as output + GPIOPinTypeGPIOOutput(BSP_ANTENNA_BASE, BSP_ANTENNA_CC2538_24GHZ); + GPIOPinTypeGPIOOutput(BSP_ANTENNA_BASE, BSP_ANTENNA_AT215_24GHZ); + +#ifdef ATMEL_24GHZ + // atmel is using 2.4ghz, connect antenna to atrf215 + antenna_at86rf215(); +#else + // atmel is not using 2.4ghz, connect antenna to cc2538 + antenna_cc2538(); +#endif +} + +void antenna_cc2538(void) { + GPIOPinWrite(BSP_ANTENNA_BASE, BSP_ANTENNA_CC2538_24GHZ, 0); + GPIOPinWrite(BSP_ANTENNA_BASE, BSP_ANTENNA_AT215_24GHZ, BSP_ANTENNA_AT215_24GHZ); +} + +void antenna_at86rf215(void) { + GPIOPinWrite(BSP_ANTENNA_BASE, BSP_ANTENNA_AT215_24GHZ, 0); + GPIOPinWrite(BSP_ANTENNA_BASE, BSP_ANTENNA_CC2538_24GHZ, BSP_ANTENNA_CC2538_24GHZ); } -/** - * Puts the board to sleep - */ + + // Puts the board to sleep + void board_sleep(void) { SysCtrlPowerModeSet(SYS_CTRL_PM_NOACTION); SysCtrlSleep(); } -/** - * Timer runs at 32 MHz and is 32-bit wide - * The timer is divided by 32, whichs gives a 1 microsecond ticks - */ + + // Timer runs at 32 MHz and is 32-bit wide + // The timer is divided by 32, whichs gives a 1 microsecond ticks + void board_timer_init(void) { - // Configure the timer + //Configure the timer TimerConfigure(GPTIMER2_BASE, GPTIMER_CFG_PERIODIC_UP); - + // Enable the timer TimerEnable(GPTIMER2_BASE, GPTIMER_BOTH); } -/** - * Returns the current value of the timer - * The timer is divided by 32, whichs gives a 1 microsecond ticks - */ + + // Returns the current value of the timer + // The timer is divided by 32, whichs gives a 1 microsecond ticks + uint32_t board_timer_get(void) { uint32_t current; - + + //Get the current timer value current = TimerValueGet(GPTIMER2_BASE, GPTIMER_A) >> 5; - + return current; } -/** - * Returns true if the timer has expired - * The timer is divided by 32, whichs gives a 1 microsecond ticks - */ + + // Returns true if the timer has expired + // The timer is divided by 32, whichs gives a 1 microsecond ticks + bool board_timer_expired(uint32_t future) { uint32_t current; int32_t remaining; + //Get current time current = TimerValueGet(GPTIMER2_BASE, GPTIMER_A) >> 5; + //Calculate remaining time remaining = (int32_t) (future - current); - + + //Return if timer has expired if (remaining > 0) { return false; } else { @@ -144,9 +167,76 @@ bool board_timer_expired(uint32_t future) { } } -/** - * Resets the board - */ +//==== bootstrapping slot info lookup table +void board_init_slot_vars(void){ + //10ms slot + slot_board_vars [SLOT_10ms].slotDuration = 328 ; // ms + slot_board_vars [SLOT_10ms].maxTxDataPrepare = 10 ; // 305us (measured 82us) + slot_board_vars [SLOT_10ms].maxRxAckPrepare = 10 ; // 305us (measured 83us) + slot_board_vars [SLOT_10ms].maxRxDataPrepare = 4 ; // 122us (measured 22us) + slot_board_vars [SLOT_10ms].maxTxAckPrepare = 10 ; // 122us (measured 94us) + #ifdef L2_SECURITY_ACTIVE + slot_board_vars [SLOT_10ms].delayTx = 14 ; // 366us (measured xxxus) + #else + slot_board_vars [SLOT_10ms].delayTx = 12 ; // 366us (measured xxxus) + #endif + slot_board_vars [SLOT_10ms].delayRx = 0 ; // 0us (can not measure) + + // 20ms slot + slot_board_vars [SLOT_20ms_24GHZ].slotDuration = 328*2 ; // tics + slot_board_vars [SLOT_20ms_24GHZ].maxTxDataPrepare = 15 ; // 457us (based on measurement) + slot_board_vars [SLOT_20ms_24GHZ].maxRxAckPrepare = 10 ; // 305us (based on measurement) + slot_board_vars [SLOT_20ms_24GHZ].maxRxDataPrepare = 10 ; // 305us (based on measurement) + slot_board_vars [SLOT_20ms_24GHZ].maxTxAckPrepare = 15 ; // 457us (based on measurement) + slot_board_vars [SLOT_20ms_24GHZ].delayTx = 6 ; // 183us (based on measurement) + slot_board_vars [SLOT_20ms_24GHZ].delayRx = 0 ; // 0us (can not measure) + + //40ms slot for 24ghz cc2538 + slot_board_vars [SLOT_40ms_24GHZ].slotDuration = 328*2 ; // tics + slot_board_vars [SLOT_40ms_24GHZ].maxTxDataPrepare = 30 ; // 457us (based on measurement) + slot_board_vars [SLOT_40ms_24GHZ].maxRxAckPrepare = 20 ; // 305us (based on measurement) + slot_board_vars [SLOT_40ms_24GHZ].maxRxDataPrepare = 20 ; // 305us (based on measurement) + slot_board_vars [SLOT_40ms_24GHZ].maxTxAckPrepare = 30 ; // 457us (based on measurement) + slot_board_vars [SLOT_40ms_24GHZ].delayTx = 13 ; // 183us (measured xxxus) + slot_board_vars [SLOT_40ms_24GHZ].delayRx = 0 ; // 0us (can not measure) + + //40ms slot for FSK + slot_board_vars [SLOT_40ms_FSK_SUBGHZ].slotDuration = 328*5 ; // tics + slot_board_vars [SLOT_40ms_FSK_SUBGHZ].maxTxDataPrepare = 65 ; // 2000us (based on measurement) + slot_board_vars [SLOT_40ms_FSK_SUBGHZ].maxRxAckPrepare = 42;//10 ; // 305µs (based on measurement) + slot_board_vars [SLOT_40ms_FSK_SUBGHZ].maxRxDataPrepare = 42;//10 ; // 305µs (based on measurement) + slot_board_vars [SLOT_40ms_FSK_SUBGHZ].maxTxAckPrepare = 65 ; // 1525µs (based on measurement) + slot_board_vars [SLOT_40ms_FSK_SUBGHZ].delayTx = 67;//69, 66 ; // 2000µs (based on measurement) + slot_board_vars [SLOT_40ms_FSK_SUBGHZ].delayRx = 19;//16 ; // 488µs. This parameter is usually set to 0, however for Atmel on openmote-b, it takes at least 1ms for the transmission to occure because of spi delay (or other implementation specific overhead), so reciver is expected to wait a little more before turning on the radio. + + //40ms slot for OFDM1 MCS3 + slot_board_vars [SLOT_40ms_OFDM1MCS0_3_SUBGHZ].slotDuration = 328*2 ; // tics + slot_board_vars [SLOT_40ms_OFDM1MCS0_3_SUBGHZ].maxTxDataPrepare = 65 ; // 1525us (based on measurement) + slot_board_vars [SLOT_40ms_OFDM1MCS0_3_SUBGHZ].maxRxAckPrepare = 42;//10 ; // 305us (based on measurement) + slot_board_vars [SLOT_40ms_OFDM1MCS0_3_SUBGHZ].maxRxDataPrepare = 42;//10 ; // 305us (based on measurement) + slot_board_vars [SLOT_40ms_OFDM1MCS0_3_SUBGHZ].maxTxAckPrepare = 50 ; // 1000us (based on measurement) + slot_board_vars [SLOT_40ms_OFDM1MCS0_3_SUBGHZ].delayTx = 41 ; // 1251us (based on measurement) + slot_board_vars [SLOT_40ms_OFDM1MCS0_3_SUBGHZ].delayRx = 16 ; // 488µs. This parameter is usually set to 0, however for Atmel on openmote-b, it takes at least 1ms for the transmission to occure because of spi delay (or other implementation specific overhead), so reciver is expected to wait a little more before turning on the radio. +} + +// To get the current slotDuration at any time (in tics) +// if you need the value in MS, divide by PORT_TICS_PER_MS (which varies by board and clock frequency and defined in board_info.h) +uint16_t board_getSlotDuration (void) +{ + //return slot_board_vars [selected_slot_type].slotDuration; + return MICROSLOTDURATION; +} + +// Setter/Getter function for slot_board_vars +slot_board_vars_t board_selectSlotTemplate (slotType_t slot_type) +{ + selected_slot_type = slot_type; + return slot_board_vars [selected_slot_type]; +} + + + // Resets the board + void board_reset(void) { SysCtrlReset(); } @@ -154,143 +244,128 @@ void board_reset(void) { //=========================== private ========================================= static void gpio_init(void) { - /* Set GPIOs as output */ - GPIOPinTypeGPIOOutput(GPIO_A_BASE, 0xFF); - GPIOPinTypeGPIOOutput(GPIO_B_BASE, 0xFF); - GPIOPinTypeGPIOOutput(GPIO_C_BASE, 0xFF); - GPIOPinTypeGPIOOutput(GPIO_D_BASE, 0xFF); - - /* Initialize GPIOs to low */ - GPIOPinWrite(GPIO_A_BASE, 0xFF, 0x00); - GPIOPinWrite(GPIO_B_BASE, 0xFF, 0x00); - GPIOPinWrite(GPIO_C_BASE, 0xFF, 0x00); - GPIOPinWrite(GPIO_D_BASE, 0xFF, 0x00); + // Configure all GPIO as input + GPIOPinTypeGPIOInput(GPIO_A_BASE, 0xFF); + GPIOPinTypeGPIOInput(GPIO_B_BASE, 0xFF); + GPIOPinTypeGPIOInput(GPIO_C_BASE, 0xFF); + GPIOPinTypeGPIOInput(GPIO_D_BASE, 0xFF); } static void clock_init(void) { - /* Disable global interrupts */ + // Disable global interrupts bool bIntDisabled = IntMasterDisable(); - /* Configure the 32 kHz pins, PD6 and PD7, for crystal operation */ - /* By default they are configured as GPIOs */ + // Configure the 32 kHz pins, PD6 and PD7, for crystal operation + // By default they are configured as GPIOs GPIODirModeSet(GPIO_D_BASE, 0x40, GPIO_DIR_MODE_IN); GPIODirModeSet(GPIO_D_BASE, 0x80, GPIO_DIR_MODE_IN); IOCPadConfigSet(GPIO_D_BASE, 0x40, IOC_OVERRIDE_ANA); IOCPadConfigSet(GPIO_D_BASE, 0x80, IOC_OVERRIDE_ANA); - /* Set the real-time clock to use the 32 kHz external crystal */ - /* Set the system clock to use the external 32 MHz crystal */ - /* Set the system clock to 32 MHz */ + // Set the real-time clock to use the 32 kHz external crystal + // Set the system clock to use the external 32 MHz crystal + // Set the system clock to 32 MHz SysCtrlClockSet(true, false, SYS_CTRL_SYSDIV_32MHZ); - /* Set the IO clock to operate at 16 MHz */ - /* This way peripherals can run while the system clock is gated */ - SysCtrlIOClockSet(SYS_CTRL_SYSDIV_16MHZ); + // Set the IO clock to operate at 32 MHz + // This way peripherals can run while the system clock is gated + SysCtrlIOClockSet(SYS_CTRL_SYSDIV_32MHZ); - /* Wait until the selected clock configuration is stable */ + // Wait until the selected clock configuration is stable while (!((HWREG(SYS_CTRL_CLOCK_STA)) & (SYS_CTRL_CLOCK_STA_XOSC_STB))); - /* Define what peripherals run in each mode */ + // Define what peripherals run in each mode SysCtrlRunSetting(); SysCtrlSleepSetting(); SysCtrlDeepSleepSetting(); SysCtrlWakeupSetting(); - /* Re-enable interrupt if initially enabled */ + // Re-enable interrupt if initially enabled if (!bIntDisabled) { IntMasterEnable(); } } -/** - * Configures the user button as input source - */ -static void button_init(void) { - volatile uint32_t i; - - /* Delay to avoid pin floating problems */ - for (i = 0xFFFF; i != 0; i--); - GPIOPinIntDisable(BSP_BUTTON_BASE, BSP_BUTTON_USER); - GPIOPinIntClear(BSP_BUTTON_BASE, BSP_BUTTON_USER); + // Configures the user button as input source - /* The button is an input GPIO on falling edge */ +static void button_init(void) { + // The button is an input GPIO on falling edge GPIOPinTypeGPIOInput(BSP_BUTTON_BASE, BSP_BUTTON_USER); GPIOIntTypeSet(BSP_BUTTON_BASE, BSP_BUTTON_USER, GPIO_FALLING_EDGE); - /* Register the interrupt */ - GPIOPortIntRegister(BSP_BUTTON_BASE, GPIO_C_Handler); + // Enable wake-up capability + GPIOIntWakeupEnable(GPIO_IWE_PORT_D); - /* Clear and enable the interrupt */ + // Clear and enable the interrupt GPIOPinIntClear(BSP_BUTTON_BASE, BSP_BUTTON_USER); GPIOPinIntEnable(BSP_BUTTON_BASE, BSP_BUTTON_USER); - user_button_initialized = TRUE; } static void SysCtrlRunSetting(void) { - /* Disable General Purpose Timers 0, 1, 2, 3 when running */ + // Disable General Purpose Timers 0, 1, 2, 3 when running SysCtrlPeripheralDisable(SYS_CTRL_PERIPH_GPT0); SysCtrlPeripheralDisable(SYS_CTRL_PERIPH_GPT1); SysCtrlPeripheralDisable(SYS_CTRL_PERIPH_GPT3); - /* Disable SSI 0, 1 when running */ + // Disable SSI 0, 1 when running SysCtrlPeripheralDisable(SYS_CTRL_PERIPH_SSI0); SysCtrlPeripheralDisable(SYS_CTRL_PERIPH_SSI1); - /* Disable UART1 when running */ + // Disable UART1 when running SysCtrlPeripheralDisable(SYS_CTRL_PERIPH_UART1); - /* Disable I2C, AES and PKA when running */ + // Disable I2C, AES and PKA when running SysCtrlPeripheralDisable(SYS_CTRL_PERIPH_I2C); SysCtrlPeripheralDisable(SYS_CTRL_PERIPH_PKA); SysCtrlPeripheralDisable(SYS_CTRL_PERIPH_AES); - /* Enable UART0 and RFC when running */ + // Enable UART0 and RFC when running SysCtrlPeripheralEnable(SYS_CTRL_PERIPH_GPT2); SysCtrlPeripheralEnable(SYS_CTRL_PERIPH_UART0); SysCtrlPeripheralEnable(SYS_CTRL_PERIPH_RFC); } static void SysCtrlSleepSetting(void) { - /* Disable General Purpose Timers 0, 1, 2, 3 during sleep */ + // Disable General Purpose Timers 0, 1, 2, 3 during sleep SysCtrlPeripheralSleepDisable(SYS_CTRL_PERIPH_GPT0); SysCtrlPeripheralSleepDisable(SYS_CTRL_PERIPH_GPT1); SysCtrlPeripheralSleepDisable(SYS_CTRL_PERIPH_GPT3); - /* Disable SSI 0, 1 during sleep */ + // Disable SSI 0, 1 during sleep SysCtrlPeripheralSleepDisable(SYS_CTRL_PERIPH_SSI0); SysCtrlPeripheralSleepDisable(SYS_CTRL_PERIPH_SSI1); - /* Disable UART 0, 1 during sleep */ + // Disable UART 0, 1 during sleep SysCtrlPeripheralSleepDisable(SYS_CTRL_PERIPH_UART1); - /* Disable I2C, PKA, AES during sleep */ + // Disable I2C, PKA, AES during sleep SysCtrlPeripheralSleepDisable(SYS_CTRL_PERIPH_I2C); SysCtrlPeripheralSleepDisable(SYS_CTRL_PERIPH_PKA); SysCtrlPeripheralSleepDisable(SYS_CTRL_PERIPH_AES); - /* Enable UART and RFC during sleep */ + // Enable UART and RFC during sleep SysCtrlPeripheralSleepEnable(SYS_CTRL_PERIPH_GPT2); SysCtrlPeripheralSleepEnable(SYS_CTRL_PERIPH_UART0); SysCtrlPeripheralSleepEnable(SYS_CTRL_PERIPH_RFC); } static void SysCtrlDeepSleepSetting(void) { - /* Disable General Purpose Timers 0, 1, 2, 3 during deep sleep */ + // Disable General Purpose Timers 0, 1, 2, 3 during deep sleep SysCtrlPeripheralDeepSleepDisable(SYS_CTRL_PERIPH_GPT0); SysCtrlPeripheralDeepSleepDisable(SYS_CTRL_PERIPH_GPT1); SysCtrlPeripheralDeepSleepDisable(SYS_CTRL_PERIPH_GPT2); SysCtrlPeripheralDeepSleepDisable(SYS_CTRL_PERIPH_GPT3); - /* Disable SSI 0, 1 during deep sleep */ + // Disable SSI 0, 1 during deep sleep SysCtrlPeripheralDeepSleepDisable(SYS_CTRL_PERIPH_SSI0); SysCtrlPeripheralDeepSleepDisable(SYS_CTRL_PERIPH_SSI1); - /* Disable UART 0, 1 during deep sleep */ + // Disable UART 0, 1 during deep sleep SysCtrlPeripheralDeepSleepDisable(SYS_CTRL_PERIPH_UART0); SysCtrlPeripheralDeepSleepDisable(SYS_CTRL_PERIPH_UART1); - /* Disable I2C, PKA, AES during deep sleep */ + // Disable I2C, PKA, AES during deep sleep SysCtrlPeripheralDeepSleepDisable(SYS_CTRL_PERIPH_I2C); SysCtrlPeripheralDeepSleepDisable(SYS_CTRL_PERIPH_PKA); SysCtrlPeripheralDeepSleepDisable(SYS_CTRL_PERIPH_AES); @@ -298,27 +373,8 @@ static void SysCtrlDeepSleepSetting(void) { } static void SysCtrlWakeupSetting(void) { - /* Allow the SMTimer to wake up the processor */ + // Allow the SMTimer to wake up the processor GPIOIntWakeupEnable(GPIO_IWE_SM_TIMER); } //=========================== interrupt handlers ============================== - -/** - * GPIO_C interrupt handler. User button is GPIO_C_3 - * Erases a Flash sector to trigger the bootloader backdoor - */ -static void GPIO_C_Handler(void) { - if (!user_button_initialized) return; - /* Disable the interrupts */ - IntMasterDisable(); - leds_all_off(); - - /* Eras the CCA flash page */ - FlashMainPageErase(CC2538_FLASH_ADDRESS); - - leds_circular_shift(); - - /* Reset the board */ - SysCtrlReset(); -} diff --git a/bsp/boards/openmote-b/board_info.h b/bsp/boards/openmote-b/board_info.h index 86a26647e3..ec923c196b 100644 --- a/bsp/boards/openmote-b/board_info.h +++ b/bsp/boards/openmote-b/board_info.h @@ -57,41 +57,9 @@ #define PORT_PIN_RADIO_RESET_HIGH() // nothing #define PORT_PIN_RADIO_RESET_LOW() // nothing -#define SLOTDURATION 10 // in miliseconds - -//===== IEEE802154E timing - -#if SLOTDURATION==10 - // time-slot related - #define PORT_TsSlotDuration 328 // counter counts one extra count, see datasheet - // execution speed related - #define PORT_maxTxDataPrepare 10 // 305us (measured 82us) - #define PORT_maxRxAckPrepare 10 // 305us (measured 83us) - #define PORT_maxRxDataPrepare 4 // 122us (measured 22us) - #define PORT_maxTxAckPrepare 10 // 122us (measured 94us) - // radio speed related - #ifdef L2_SECURITY_ACTIVE - #define PORT_delayTx 14 // 366us (measured xxxus) - #else - #define PORT_delayTx 12 // 366us (measured xxxus) - #endif - #define PORT_delayRx 0 // 0us (can not measure) - // radio watchdog -#endif -#if SLOTDURATION==15 - // time-slot related - #define PORT_TsSlotDuration 492 // counter counts one extra count, see datasheet - // execution speed related - #define PORT_maxTxDataPrepare 66 // 2014us (measured 746us) - #define PORT_maxRxAckPrepare 10 // 305us (measured 83us) - #define PORT_maxRxDataPrepare 33 // 1007us (measured 84us) - #define PORT_maxTxAckPrepare 22 // 305us (measured 219us) - // radio speed related - #define PORT_delayTx 12 // 214us (measured 219us) - #define PORT_delayRx 0 // 0us (can not measure) - // radio watchdog -#endif +// Number of available radio settings +#define MAX_RADIOS 7 //===== adaptive_sync accuracy @@ -101,25 +69,25 @@ #define NUMSENSORS 7 -//====== Antenna options ==== +//=========================== Antenna options ================================= + #define BSP_ANTENNA_BASE GPIO_D_BASE #define BSP_ANTENNA_CC2538_24GHZ GPIO_PIN_4 //!< PD4 -- 2.4ghz #define BSP_ANTENNA_AT215_24GHZ GPIO_PIN_3 //!< PD3 -- subghz - //=========================== typedef ======================================== //=========================== variables ======================================= static const uint8_t rreg_uriquery[] = "h=ucb"; -static const uint8_t infoBoardname[] = "CC2538"; +static const uint8_t infoBoardname[] = "Openmote B"; static const uint8_t infouCName[] = "CC2538"; static const uint8_t infoRadioName[] = "CC2538 SoC"; //=========================== prototypes ====================================== //=========================== public ========================================== - +void eraseFlash(void); //=========================== private ========================================= #endif diff --git a/bsp/boards/openmote-b/cx2538xf53.icf b/bsp/boards/openmote-b/cx2538xf53.icf new file mode 100644 index 0000000000..4585a623ad --- /dev/null +++ b/bsp/boards/openmote-b/cx2538xf53.icf @@ -0,0 +1,109 @@ +/*###ICF### Section handled by ICF editor, don't touch! ****/ +/*-Editor annotation file-*/ +/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */ +/*-Specials-*/ +define symbol __ICFEDIT_intvec_start__ = 0x00200000; +/*-Memory Regions-*/ +define symbol __ICFEDIT_region_ROM_start__ = 0x00200000; +define symbol __ICFEDIT_region_ROM_end__ = 0x0027ffd3; +define symbol __ICFEDIT_region_RAM_start__ = 0x20000000; +define symbol __ICFEDIT_region_RAM_end__ = 0x20007FFF; +/*-Sizes-*/ +define symbol __ICFEDIT_size_cstack__ = 0x800; +define symbol __ICFEDIT_size_heap__ = 0x1000; +/**** End of ICF editor section. ###ICF###*/ + +// +// Define a memory region that covers the entire 4 GB addressible space of the +// processor. +// +define memory mem with size = 4G; + +// +// Define a region for the on-chip flash. +// This device has 512KB Flash size +// +define region FLASH = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__]; + +// +// Define a region for Customer Configuration Area in flash. +// +define region FLASH_CCA = mem:[from 0x0027ffd4 to 0x0027ffdf]; + +// +// Define a region for the on-chip SRAM. +// This device has 32KB RAM size +// +define region SRAM = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__]; + +// +// Define regions of retention and non-retention RAM. The stack and other +// variables that require retention through PM2/3 should be placed in the +// retention RAM region +// +define region SRAM_NON_RETENTION = mem:[from __ICFEDIT_region_RAM_start__ to 0x20003fff]; +define region SRAM_RETENTION = mem:[from 0x20004000 to __ICFEDIT_region_RAM_end__]; +define region SRAM_TOTAL = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__]; + +// +// Define a block for the heap. The size should be set to something other +// than zero if things in the C library that require the heap are used. +// +define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { }; + +// +// Indicate that the read/write values should be initialized by copying from +// flash. +// +initialize by copy { readwrite }; + +// +// Indicate that the noinit values should be left alone. +// +do not initialize { section .noinit }; + +// +// Place the interrupt vectors at the start of flash. +// +place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec }; + +// +// Place the cca area at the end of flash (start of FLASH_CCA). +// +place at start of FLASH_CCA { readonly section .flashcca }; + +// +// Place the remainder of the read-only items into flash. +// +place in FLASH { readonly }; + +// +// Place the RAM vector table at the start of retention ram. +// +place at start of SRAM_TOTAL { section VTABLE }; + +// +// Place all read/write items into retention SRAM. +// +place in SRAM_TOTAL { readwrite, block HEAP }; + +// +// Define CSTACK block to contain .stack section. This enables the IAR IDE +// to properly show the stack content during debug. Place stack at end of +// retention RAM, do not initialize (initializing the stack will destroy the +// return address from the initialization code, causing the processor to branch +// to zero and fault) +// +define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { section .stack }; +do not initialize { section .stack }; +place at end of SRAM_TOTAL { block CSTACK }; + +// +// Export stack top symbol. Used by startup file. +// +define exported symbol STACK_TOP = __ICFEDIT_region_RAM_end__ + 1; + +// +// Variables that do not need retention should be defined here +// +place in SRAM_TOTAL { section .nonretenvar }; diff --git a/bsp/boards/openmote-b/i2c.c b/bsp/boards/openmote-b/i2c.c index d9028f5dd5..e5c1764a09 100644 --- a/bsp/boards/openmote-b/i2c.c +++ b/bsp/boards/openmote-b/i2c.c @@ -21,10 +21,10 @@ #define I2C_PERIPHERAL ( SYS_CTRL_PERIPH_I2C ) #define I2C_BASE ( GPIO_B_BASE ) -#define I2C_SCL ( GPIO_PIN_3 ) +#define I2C_SCL ( GPIO_PIN_5 ) #define I2C_SDA ( GPIO_PIN_4 ) -#define I2C_BAUDRATE ( 100000 ) -#define I2C_MAX_DELAY_US ( 100000 ) +#define I2C_BAUDRATE ( 400000 ) +#define I2C_MAX_DELAY_US ( 400000 ) //=========================== variables ======================================= diff --git a/bsp/boards/openmote-b/leds.c b/bsp/boards/openmote-b/leds.c index 248b6ed64a..aaf3c5bde4 100644 --- a/bsp/boards/openmote-b/leds.c +++ b/bsp/boards/openmote-b/leds.c @@ -59,34 +59,34 @@ uint8_t leds_error_isOn(void) { return (uint8_t)(ui32Toggle & BSP_LED_1)>>4; } -// orange +// green void leds_sync_on(void) { - bspLedSet(BSP_LED_2); + bspLedSet(BSP_LED_4); } void leds_sync_off(void) { - bspLedClear(BSP_LED_2); + bspLedClear(BSP_LED_4); } void leds_sync_toggle(void) { - bspLedToggle(BSP_LED_2); + bspLedToggle(BSP_LED_4); } uint8_t leds_sync_isOn(void) { - uint32_t ui32Toggle = GPIOPinRead(BSP_LED_BASE, BSP_LED_2); - return (uint8_t)(ui32Toggle & BSP_LED_2)>>5; + uint32_t ui32Toggle = GPIOPinRead(BSP_LED_BASE, BSP_LED_4); + return (uint8_t)(ui32Toggle & BSP_LED_4)>>5; } -// green +// orange void leds_radio_on(void) { - bspLedSet(BSP_LED_4); + bspLedSet(BSP_LED_2); } void leds_radio_off(void) { - bspLedClear(BSP_LED_4); + bspLedClear(BSP_LED_2); } void leds_radio_toggle(void) { - bspLedToggle(BSP_LED_4); + bspLedToggle(BSP_LED_2); } uint8_t leds_radio_isOn(void) { - uint32_t ui32Toggle = GPIOPinRead(BSP_LED_BASE, BSP_LED_4); - return (uint8_t)(ui32Toggle & BSP_LED_4)>>7; + uint32_t ui32Toggle = GPIOPinRead(BSP_LED_BASE, BSP_LED_2); + return (uint8_t)(ui32Toggle & BSP_LED_2)>>7; } // yellow @@ -140,7 +140,7 @@ void leds_circular_shift(void) { // incrementally turn LED on for (i=0;i<10;i++) { bspLedSet(BSP_LED_1); - for (delay=0xffff;delay>0;delay--); + for (delay=0xffff;delay>0;delay--) bspLedClear(BSP_LED_1); bspLedSet(BSP_LED_2); for (delay=0xffff;delay>0;delay--); diff --git a/bsp/boards/openmote-b/radio.c b/bsp/boards/openmote-b/radio.c index 2d4281a5cf..a6bb9e8b51 100644 --- a/bsp/boards/openmote-b/radio.c +++ b/bsp/boards/openmote-b/radio.c @@ -1,531 +1,352 @@ /** - * Author: Xavier Vilajosana (xvilajosana@eecs.berkeley.edu) - * Pere Tuset (peretuset@openmote.com) - * Date: July 2013 - * Description: CC2538-specific definition of the "radio" bsp module. - */ - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include - + \brief Definition of the Open Radio interface for openmote-b + \author Mina Rady , March 2020. +*/ #include "board.h" -#include "cc2538rf.h" + +#include "spi.h" #include "debugpins.h" #include "leds.h" -#include "radio.h" #include "sctimer.h" -//=========================== defines ========================================= -/* Bit Masks for the last byte in the RX FIFO */ -#define CRC_BIT_MASK 0x80 -#define LQI_BIT_MASK 0x7F +#include +#include +#include +#include +#include + +#include +#include +#include +#include -/* RSSI Offset */ -#define RSSI_OFFSET 73 -#define CHECKSUM_LEN 2 +// Drivers of radios attached to openmote-b +#include "radio_at86rf215.h" +#include "radio_cc2538rf.h" -//=========================== variables ======================================= +// The generic radio driver header file +#include "radio.h" -typedef struct { - radio_capture_cbt startFrame_cb; - radio_capture_cbt endFrame_cb; - radio_state_t state; -} radio_vars_t; +//=========================== defines ========================================= -radio_vars_t radio_vars; -//=========================== prototypes ====================================== +// open radio functions callback types declaration + +typedef void (*radio_reset_cb_t)(void); +typedef void (*radio_init_cb_t)(void); +typedef void (*radio_setConfig_cb_t)(radioSetting_t radioSetting); +typedef void (*radio_setStartFrameCb_cb_t)(radio_capture_cbt cb); +typedef void (*radio_setEndFrameCb_cb_t)(radio_capture_cbt cb); +typedef void (*radio_setFrequency_cb_t)(uint16_t channel, radio_freq_t tx_or_rx); +typedef void (*radio_rfOn_cb_t)(void); +typedef void (*radio_rfOff_cb_t)(void); +typedef int8_t (*radio_getFrequencyOffset_cb_t)(void); +typedef void (*radio_loadPacket_cb_t)(uint8_t* packet, uint16_t len); +typedef radio_state_t (*radio_getState_cb_t)(void); +typedef void (*radio_txEnable_cb_t)(void); +typedef void (*radio_txNow_cb_t)(void); +typedef void (*radio_rxEnable_cb_t)(void); +typedef void (*radio_rxNow_cb_t)(void); +typedef void (*radio_getReceivedFrame_cb_t)( + uint8_t* bufRead, + uint8_t* lenRead, + uint8_t maxBufLen, + int8_t* rssi, + uint8_t* lqi, + bool* crc + ); +typedef kick_scheduler_t (*radio_isr_cb_t)(void); + + +// the template for radio function callbacks +typedef struct { + radio_reset_cb_t radio_reset; + radio_init_cb_t radio_init; + radio_setConfig_cb_t radio_setConfig; + radio_setStartFrameCb_cb_t radio_setStartFrameCb; + radio_setEndFrameCb_cb_t radio_setEndFrameCb; + radio_setFrequency_cb_t radio_setFrequency; + radio_rfOn_cb_t radio_rfOn; + radio_rfOff_cb_t radio_rfOff; + radio_getFrequencyOffset_cb_t radio_getFrequencyOffset; + radio_loadPacket_cb_t radio_loadPacket; + radio_txEnable_cb_t radio_txEnable; + radio_txNow_cb_t radio_txNow; + radio_rxEnable_cb_t radio_rxEnable; + radio_rxNow_cb_t radio_rxNow; + radio_getReceivedFrame_cb_t radio_getReceivedFrame; + radio_isr_cb_t radio_isr; +} radio_functions_t; + + +// global radio selection, will use the slowest by default at initialization. +uint8_t selected_radioSetting = RADIOSETTING_FSK_OPTION1_FEC; -void enable_radio_interrupts(void); -void disable_radio_interrupts(void); +//=========================== variables ======================================= -void radio_on(void); -void radio_off(void); +//function call back matrix +radio_functions_t dyn_funcs [MAX_RADIOS]; + +//=========================== Bootstrapping =================================== + +// initializing the lookup table for radio function callbacks +void radio_bootstrap (void) +{ + // RADIOSETTING_FSK_OPTION1_FEC + dyn_funcs [RADIOSETTING_FSK_OPTION1_FEC].radio_reset = radio_reset_at86rf215; + dyn_funcs [RADIOSETTING_FSK_OPTION1_FEC].radio_init = radio_init_at86rf215; + dyn_funcs [RADIOSETTING_FSK_OPTION1_FEC].radio_setConfig = radio_setConfig_at86rf215; + dyn_funcs [RADIOSETTING_FSK_OPTION1_FEC].radio_setStartFrameCb = radio_setStartFrameCb_at86rf215; + dyn_funcs [RADIOSETTING_FSK_OPTION1_FEC].radio_setEndFrameCb = radio_setEndFrameCb_at86rf215; + dyn_funcs [RADIOSETTING_FSK_OPTION1_FEC].radio_setFrequency = radio_setFrequency_at86rf215; + dyn_funcs [RADIOSETTING_FSK_OPTION1_FEC].radio_rfOn = radio_rfOn_at86rf215; + dyn_funcs [RADIOSETTING_FSK_OPTION1_FEC].radio_rfOff = radio_rfOff_at86rf215; + dyn_funcs [RADIOSETTING_FSK_OPTION1_FEC].radio_getFrequencyOffset = radio_getFrequencyOffset_at86rf215; + dyn_funcs [RADIOSETTING_FSK_OPTION1_FEC].radio_loadPacket = radio_loadPacket_at86rf215; + dyn_funcs [RADIOSETTING_FSK_OPTION1_FEC].radio_txEnable = radio_txEnable_at86rf215; + dyn_funcs [RADIOSETTING_FSK_OPTION1_FEC].radio_txNow = radio_txNow_at86rf215; + dyn_funcs [RADIOSETTING_FSK_OPTION1_FEC].radio_rxEnable = radio_rxEnable_at86rf215; + dyn_funcs [RADIOSETTING_FSK_OPTION1_FEC].radio_rxNow = radio_rxNow_at86rf215; + dyn_funcs [RADIOSETTING_FSK_OPTION1_FEC].radio_getReceivedFrame = radio_getReceivedFrame_at86rf215; + dyn_funcs [RADIOSETTING_FSK_OPTION1_FEC].radio_isr = radio_isr_at86rf215; + + + //RADIOSETTING_OQPSK_RATE3 + dyn_funcs [RADIOSETTING_OQPSK_RATE3].radio_reset = radio_reset_at86rf215; + dyn_funcs [RADIOSETTING_OQPSK_RATE3].radio_init = radio_init_at86rf215; + dyn_funcs [RADIOSETTING_OQPSK_RATE3].radio_setConfig = radio_setConfig_at86rf215; + dyn_funcs [RADIOSETTING_OQPSK_RATE3].radio_setStartFrameCb = radio_setStartFrameCb_at86rf215; + dyn_funcs [RADIOSETTING_OQPSK_RATE3].radio_setEndFrameCb = radio_setEndFrameCb_at86rf215; + dyn_funcs [RADIOSETTING_OQPSK_RATE3].radio_setFrequency = radio_setFrequency_at86rf215; + dyn_funcs [RADIOSETTING_OQPSK_RATE3].radio_rfOn = radio_rfOn_at86rf215; + dyn_funcs [RADIOSETTING_OQPSK_RATE3].radio_rfOff = radio_rfOff_at86rf215; + dyn_funcs [RADIOSETTING_OQPSK_RATE3].radio_getFrequencyOffset = radio_getFrequencyOffset_at86rf215; + dyn_funcs [RADIOSETTING_OQPSK_RATE3].radio_loadPacket = radio_loadPacket_at86rf215; + dyn_funcs [RADIOSETTING_OQPSK_RATE3].radio_txEnable = radio_txEnable_at86rf215; + dyn_funcs [RADIOSETTING_OQPSK_RATE3].radio_txNow = radio_txNow_at86rf215; + dyn_funcs [RADIOSETTING_OQPSK_RATE3].radio_rxEnable = radio_rxEnable_at86rf215; + dyn_funcs [RADIOSETTING_OQPSK_RATE3].radio_rxNow = radio_rxNow_at86rf215; + dyn_funcs [RADIOSETTING_OQPSK_RATE3].radio_getReceivedFrame = radio_getReceivedFrame_at86rf215; + dyn_funcs [RADIOSETTING_OQPSK_RATE3].radio_isr = radio_isr_at86rf215; + + //RADIOSETTING_OFDM_OPTION_1_MCS0 + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS0].radio_reset = radio_reset_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS0].radio_init = radio_init_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS0].radio_setConfig = radio_setConfig_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS0].radio_setStartFrameCb = radio_setStartFrameCb_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS0].radio_setEndFrameCb = radio_setEndFrameCb_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS0].radio_setFrequency = radio_setFrequency_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS0].radio_rfOn = radio_rfOn_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS0].radio_rfOff = radio_rfOff_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS0].radio_getFrequencyOffset = radio_getFrequencyOffset_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS0].radio_loadPacket = radio_loadPacket_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS0].radio_txEnable = radio_txEnable_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS0].radio_txNow = radio_txNow_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS0].radio_rxEnable = radio_rxEnable_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS0].radio_rxNow = radio_rxNow_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS0].radio_getReceivedFrame = radio_getReceivedFrame_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS0].radio_isr = radio_isr_at86rf215; + + //RADIOSETTING_OFDM_OPTION_1_MCS1 + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS1].radio_reset = radio_reset_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS1].radio_init = radio_init_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS1].radio_setConfig = radio_setConfig_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS1].radio_setStartFrameCb = radio_setStartFrameCb_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS1].radio_setEndFrameCb = radio_setEndFrameCb_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS1].radio_setFrequency = radio_setFrequency_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS1].radio_rfOn = radio_rfOn_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS1].radio_rfOff = radio_rfOff_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS1].radio_getFrequencyOffset = radio_getFrequencyOffset_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS1].radio_loadPacket = radio_loadPacket_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS1].radio_txEnable = radio_txEnable_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS1].radio_txNow = radio_txNow_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS1].radio_rxEnable = radio_rxEnable_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS1].radio_rxNow = radio_rxNow_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS1].radio_getReceivedFrame = radio_getReceivedFrame_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS1].radio_isr = radio_isr_at86rf215; + + //RADIOSETTING_OFDM_OPTION_1_MCS2 + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS2].radio_reset = radio_reset_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS2].radio_init = radio_init_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS2].radio_setConfig = radio_setConfig_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS2].radio_setStartFrameCb = radio_setStartFrameCb_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS2].radio_setEndFrameCb = radio_setEndFrameCb_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS2].radio_setFrequency = radio_setFrequency_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS2].radio_rfOn = radio_rfOn_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS2].radio_rfOff = radio_rfOff_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS2].radio_getFrequencyOffset = radio_getFrequencyOffset_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS2].radio_loadPacket = radio_loadPacket_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS2].radio_txEnable = radio_txEnable_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS2].radio_txNow = radio_txNow_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS2].radio_rxEnable = radio_rxEnable_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS2].radio_rxNow = radio_rxNow_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS2].radio_getReceivedFrame = radio_getReceivedFrame_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS2].radio_isr = radio_isr_at86rf215; + + //RADIOSETTING_OFDM_OPTION_1_MCS3 + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS3].radio_reset = radio_reset_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS3].radio_init = radio_init_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS3].radio_setConfig = radio_setConfig_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS3].radio_setStartFrameCb = radio_setStartFrameCb_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS3].radio_setEndFrameCb = radio_setEndFrameCb_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS3].radio_setFrequency = radio_setFrequency_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS3].radio_rfOn = radio_rfOn_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS3].radio_rfOff = radio_rfOff_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS3].radio_getFrequencyOffset = radio_getFrequencyOffset_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS3].radio_loadPacket = radio_loadPacket_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS3].radio_txEnable = radio_txEnable_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS3].radio_txNow = radio_txNow_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS3].radio_rxEnable = radio_rxEnable_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS3].radio_rxNow = radio_rxNow_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS3].radio_getReceivedFrame = radio_getReceivedFrame_at86rf215; + dyn_funcs [RADIOSETTING_OFDM_OPTION_1_MCS3].radio_isr = radio_isr_at86rf215; + + + //RADIOSETTING_24GHZ + dyn_funcs [RADIOSETTING_24GHZ].radio_reset = radio_reset_cc2538rf; + dyn_funcs [RADIOSETTING_24GHZ].radio_init = radio_init_cc2538rf; + dyn_funcs [RADIOSETTING_24GHZ].radio_setConfig = radio_setConfig_cc2538rf; + dyn_funcs [RADIOSETTING_24GHZ].radio_setStartFrameCb = radio_setStartFrameCb_cc2538rf; + dyn_funcs [RADIOSETTING_24GHZ].radio_setEndFrameCb = radio_setEndFrameCb_cc2538rf; + dyn_funcs [RADIOSETTING_24GHZ].radio_setFrequency = radio_setFrequency_cc2538rf; + dyn_funcs [RADIOSETTING_24GHZ].radio_rfOn = radio_rfOn_cc2538rf; + dyn_funcs [RADIOSETTING_24GHZ].radio_rfOff = radio_rfOff_cc2538rf; + dyn_funcs [RADIOSETTING_24GHZ].radio_getFrequencyOffset = radio_getFrequencyOffset_cc2538rf; + dyn_funcs [RADIOSETTING_24GHZ].radio_loadPacket = radio_loadPacket_cc2538rf; + dyn_funcs [RADIOSETTING_24GHZ].radio_txEnable = radio_txEnable_cc2538rf; + dyn_funcs [RADIOSETTING_24GHZ].radio_txNow = radio_txNow_cc2538rf; + dyn_funcs [RADIOSETTING_24GHZ].radio_rxEnable = radio_rxEnable_cc2538rf; + dyn_funcs [RADIOSETTING_24GHZ].radio_rxNow = radio_rxNow_cc2538rf; + dyn_funcs [RADIOSETTING_24GHZ].radio_getReceivedFrame = radio_getReceivedFrame_cc2538rf; + dyn_funcs [RADIOSETTING_24GHZ].radio_isr = radio_isr_cc2538rf; +} -void radio_error_isr(void); -void radio_isr_internal(void); //=========================== public ========================================== //===== admin - -void radio_init(void) { - - // clear variables - memset(&radio_vars,0,sizeof(radio_vars_t)); - - // change state - radio_vars.state = RADIOSTATE_STOPPED; - //flush fifos - CC2538_RF_CSP_ISFLUSHRX(); - CC2538_RF_CSP_ISFLUSHTX(); - - radio_off(); - - //disable radio interrupts - disable_radio_interrupts(); - - /* - This CORR_THR value should be changed to 0x14 before attempting RX. Testing has shown that - too many false frames are received if the reset value is used. Make it more likely to detect - sync by removing the requirement that both symbols in the SFD must have a correlation value - above the correlation threshold, and make sync word detection less likely by raising the - correlation threshold. - */ - HWREG(RFCORE_XREG_MDMCTRL1) = 0x14; - /* tuning adjustments for optimal radio performance; details available in datasheet */ - - HWREG(RFCORE_XREG_RXCTRL) = 0x3F; - /* Adjust current in synthesizer; details available in datasheet. */ - HWREG(RFCORE_XREG_FSCTRL) = 0x55; - - /* Makes sync word detection less likely by requiring two zero symbols before the sync word. - * details available in datasheet. - */ - HWREG(RFCORE_XREG_MDMCTRL0) = 0x85; - - /* Adjust current in VCO; details available in datasheet. */ - HWREG(RFCORE_XREG_FSCAL1) = 0x01; - /* Adjust target value for AGC control loop; details available in datasheet. */ - HWREG(RFCORE_XREG_AGCCTRL1) = 0x15; - - /* Tune ADC performance, details available in datasheet. */ - HWREG(RFCORE_XREG_ADCTEST0) = 0x10; - HWREG(RFCORE_XREG_ADCTEST1) = 0x0E; - HWREG(RFCORE_XREG_ADCTEST2) = 0x03; - - //update CCA register to -81db as indicated by manual.. won't be used.. - HWREG(RFCORE_XREG_CCACTRL0) = 0xF8; - /* - * Changes from default values - * See User Guide, section "Register Settings Update" - */ - HWREG(RFCORE_XREG_TXFILTCFG) = 0x09; /** TX anti-aliasing filter bandwidth */ - HWREG(RFCORE_XREG_AGCCTRL1) = 0x15; /** AGC target value */ - HWREG(ANA_REGS_O_IVCTRL) = 0x0B; /** Bias currents */ - - /* disable the CSPT register compare function */ - HWREG(RFCORE_XREG_CSPT) = 0xFFUL; - /* - * Defaults: - * Auto CRC; Append RSSI, CRC-OK and Corr. Val.; CRC calculation; - * RX and TX modes with FIFOs - */ - HWREG(RFCORE_XREG_FRMCTRL0) = RFCORE_XREG_FRMCTRL0_AUTOCRC; - - //poipoi disable frame filtering by now.. sniffer mode. - HWREG(RFCORE_XREG_FRMFILT0) &= ~RFCORE_XREG_FRMFILT0_FRAME_FILTER_EN; - - /* Disable source address matching and autopend */ - HWREG(RFCORE_XREG_SRCMATCH) = 0; - - /* MAX FIFOP threshold */ - HWREG(RFCORE_XREG_FIFOPCTRL) = CC2538_RF_MAX_PACKET_LEN; - - HWREG(RFCORE_XREG_TXPOWER) = CC2538_RF_TX_POWER; - HWREG(RFCORE_XREG_FREQCTRL) = CC2538_RF_CHANNEL_MIN; - - /* Enable RF interrupts see page 751 */ - // enable_radio_interrupts(); - - //register interrupt - IntRegister(INT_RFCORERTX, radio_isr_internal); - IntRegister(INT_RFCOREERR, radio_error_isr); - - IntEnable(INT_RFCORERTX); - - /* Enable all RF Error interrupts */ - HWREG(RFCORE_XREG_RFERRM) = RFCORE_XREG_RFERRM_RFERRM_M; //all errors - IntEnable(INT_RFCOREERR); - //radio_on(); - - // change state - radio_vars.state = RADIOSTATE_RFOFF; +void radio_init (void) { + //bootstrapping the radio look-up matrix + radio_bootstrap(); + + // Initializing the atmel radio + dyn_funcs [RADIOSETTING_FSK_OPTION1_FEC].radio_init(); + + // Initializing the ti radio + dyn_funcs [RADIOSETTING_24GHZ].radio_init(); } -void radio_setStartFrameCb(radio_capture_cbt cb) { - radio_vars.startFrame_cb = cb; -} - -void radio_setEndFrameCb(radio_capture_cbt cb) { - radio_vars.endFrame_cb = cb; -} - -//===== reset void radio_reset(void) { - /* Wait for ongoing TX to complete (e.g. this could be an outgoing ACK) */ - while(HWREG(RFCORE_XREG_FSMSTAT1) & RFCORE_XREG_FSMSTAT1_TX_ACTIVE); - - //flush fifos - CC2538_RF_CSP_ISFLUSHRX(); - CC2538_RF_CSP_ISFLUSHTX(); - - /* Don't turn off if we are off as this will trigger a Strobe Error */ - if(HWREG(RFCORE_XREG_RXENABLE) != 0) { - CC2538_RF_CSP_ISRFOFF(); - } - radio_init(); + dyn_funcs [selected_radioSetting].radio_reset(); } -//===== RF admin -void radio_setFrequency(uint8_t frequency, radio_freq_t tx_or_rx) { - - // change state - radio_vars.state = RADIOSTATE_SETTING_FREQUENCY; - - radio_off(); - // configure the radio to the right frequency - if((frequency < CC2538_RF_CHANNEL_MIN) || (frequency > CC2538_RF_CHANNEL_MAX)) { - while(1); - } - - /* Changes to FREQCTRL take effect after the next recalibration */ - HWREG(RFCORE_XREG_FREQCTRL) = (CC2538_RF_CHANNEL_MIN - + (frequency - CC2538_RF_CHANNEL_MIN) * CC2538_RF_CHANNEL_SPACING); - - //radio_on(); - - // change state - radio_vars.state = RADIOSTATE_FREQUENCY_SET; +void radio_setConfig (radioSetting_t radioSetting){ + selected_radioSetting = radioSetting; + dyn_funcs [selected_radioSetting].radio_setConfig(selected_radioSetting); } -void radio_rfOn(void) { - //radio_on(); + +void radio_setStartFrameCb (radio_capture_cbt cb) { + // setting the callback for the at86rf215 radio driver + dyn_funcs [RADIOSETTING_FSK_OPTION1_FEC].radio_setStartFrameCb(cb); + + // setting the callback for the cc2538 radio driver + dyn_funcs [RADIOSETTING_24GHZ].radio_setStartFrameCb(cb); } -void radio_rfOff(void) { - - // change state - radio_vars.state = RADIOSTATE_TURNING_OFF; - radio_off(); - // wiggle debug pin - debugpins_radio_clr(); - leds_radio_off(); - //enable radio interrupts - disable_radio_interrupts(); - - // change state - radio_vars.state = RADIOSTATE_RFOFF; +void radio_setEndFrameCb (radio_capture_cbt cb) { + // setting the callback for the at86rf215 radio driver + dyn_funcs [RADIOSETTING_FSK_OPTION1_FEC].radio_setEndFrameCb(cb); + + // setting the callback for the cc2538 radio driver + dyn_funcs [RADIOSETTING_24GHZ].radio_setEndFrameCb(cb); } -//===== TX +//===== RF admin -void radio_loadPacket(uint8_t* packet, uint16_t len) { - uint8_t i=0; - - // change state - radio_vars.state = RADIOSTATE_LOADING_PACKET; - - // load packet in TXFIFO - /* - When we transmit in very quick bursts, make sure previous transmission - is not still in progress before re-writing to the TX FIFO - */ - while(HWREG(RFCORE_XREG_FSMSTAT1) & RFCORE_XREG_FSMSTAT1_TX_ACTIVE); - - CC2538_RF_CSP_ISFLUSHTX(); - - /* Send the phy length byte first */ - HWREG(RFCORE_SFR_RFDATA) = len; //crc len is included - - for(i = 0; i < len; i++) { - HWREG(RFCORE_SFR_RFDATA) = packet[i]; - } - - // change state - radio_vars.state = RADIOSTATE_PACKET_LOADED; +void radio_setFrequency (uint16_t channel, radio_freq_t tx_or_rx) { + dyn_funcs [selected_radioSetting].radio_setFrequency(channel, tx_or_rx); } -void radio_txEnable(void) { - - // change state - radio_vars.state = RADIOSTATE_ENABLING_TX; - - // wiggle debug pin - debugpins_radio_set(); - leds_radio_on(); - - //do nothing -- radio is activated by the strobe on rx or tx - //radio_rfOn(); - - // change state - radio_vars.state = RADIOSTATE_TX_ENABLED; +void radio_rfOn (void) { + dyn_funcs [selected_radioSetting].radio_rfOn(); } -void radio_txNow(void) { - PORT_TIMER_WIDTH count; - - // change state - radio_vars.state = RADIOSTATE_TRANSMITTING; - - //enable radio interrupts - enable_radio_interrupts(); - - //make sure we are not transmitting already - while(HWREG(RFCORE_XREG_FSMSTAT1) & RFCORE_XREG_FSMSTAT1_TX_ACTIVE); - - // send packet by STON strobe see pag 669 +void radio_rfOff (void) { + dyn_funcs [selected_radioSetting].radio_rfOff(); +} - CC2538_RF_CSP_ISTXON(); - //wait 192uS - count=0; - while(!((HWREG(RFCORE_XREG_FSMSTAT1) & RFCORE_XREG_FSMSTAT1_TX_ACTIVE))){ - count++; //debug - } +int8_t radio_getFrequencyOffset (void){ + return dyn_funcs [selected_radioSetting].radio_getFrequencyOffset(); } -//===== RX +//===== TX -void radio_rxEnable(void) { - - // change state - radio_vars.state = RADIOSTATE_ENABLING_RX; - - //enable radio interrupts - - // do nothing as we do not want to receive anything yet. - // wiggle debug pin - debugpins_radio_set(); - leds_radio_on(); - - // change state - radio_vars.state = RADIOSTATE_LISTENING; +void radio_loadPacket (uint8_t* packet, uint16_t len) { + dyn_funcs [selected_radioSetting].radio_loadPacket(packet, len); } -void radio_rxNow(void) { - //empty buffer before receiving - //CC2538_RF_CSP_ISFLUSHRX(); - - //enable radio interrupts - CC2538_RF_CSP_ISFLUSHRX(); - enable_radio_interrupts(); - - CC2538_RF_CSP_ISRXON(); - // busy wait until radio really listening - while(!((HWREG(RFCORE_XREG_FSMSTAT1) & RFCORE_XREG_FSMSTAT1_RX_ACTIVE))); -} -void radio_getReceivedFrame(uint8_t* pBufRead, - uint8_t* pLenRead, - uint8_t maxBufLen, - int8_t* pRssi, - uint8_t* pLqi, - bool* pCrc) { - uint8_t crc_corr,i; - - uint8_t len=0; - - /* Check the length */ - len = HWREG(RFCORE_SFR_RFDATA); //first byte is len - - - /* Check for validity */ - if(len > CC2538_RF_MAX_PACKET_LEN) { - /* wrong len */ - CC2538_RF_CSP_ISFLUSHRX(); - return; - } - - - if(len <= CC2538_RF_MIN_PACKET_LEN) { - //too short - CC2538_RF_CSP_ISFLUSHRX(); - return; - } - - //check if this fits to the buffer - if(len > maxBufLen) { - CC2538_RF_CSP_ISFLUSHRX(); - return; - } - - // when reading the packet from the RX buffer, you get the following: - // - *[1B] length byte - // - [0-125B] packet (excluding CRC) - // - [1B] RSSI - // - *[2B] CRC - - //skip first byte is len - for(i = 0; i < len - 2; i++) { - pBufRead[i] = HWREG(RFCORE_SFR_RFDATA); - } - - *pRssi = ((int8_t)(HWREG(RFCORE_SFR_RFDATA)) - RSSI_OFFSET); - crc_corr = HWREG(RFCORE_SFR_RFDATA); - *pCrc = crc_corr & CRC_BIT_MASK; - *pLenRead = len; - - //flush it - CC2538_RF_CSP_ISFLUSHRX(); +void radio_txEnable (void) { + dyn_funcs [selected_radioSetting].radio_txEnable(); } -//=========================== private ========================================= +void radio_txNow (void) { + switch (selected_radioSetting){ + case (RADIOSETTING_FSK_OPTION1_FEC): + debugpins_radio_toggle(); + debugpins_radio_toggle(); + break; + case (RADIOSETTING_24GHZ): + debugpins_radio_toggle(); + debugpins_radio_toggle(); + debugpins_radio_toggle(); + debugpins_radio_toggle(); + break; + case (RADIOSETTING_OFDM_OPTION_1_MCS3): + debugpins_radio_toggle(); + debugpins_radio_toggle(); + debugpins_radio_toggle(); + debugpins_radio_toggle(); + debugpins_radio_toggle(); + debugpins_radio_toggle(); + break; + } + dyn_funcs [selected_radioSetting].radio_txNow(); +} -void enable_radio_interrupts(void){ - /* Enable RF interrupts 0, RXPKTDONE,SFD,FIFOP only -- see page 751 */ - HWREG(RFCORE_XREG_RFIRQM0) |= ((0x06|0x02|0x01) << RFCORE_XREG_RFIRQM0_RFIRQM_S) & RFCORE_XREG_RFIRQM0_RFIRQM_M; +//===== RX - /* Enable RF interrupts 1, TXDONE only */ - HWREG(RFCORE_XREG_RFIRQM1) |= ((0x02) << RFCORE_XREG_RFIRQM1_RFIRQM_S) & RFCORE_XREG_RFIRQM1_RFIRQM_M; +void radio_rxEnable (void) { + dyn_funcs [selected_radioSetting].radio_rxEnable(); } -void disable_radio_interrupts(void){ - /* Enable RF interrupts 0, RXPKTDONE,SFD,FIFOP only -- see page 751 */ - HWREG(RFCORE_XREG_RFIRQM0) = 0; - /* Enable RF interrupts 1, TXDONE only */ - HWREG(RFCORE_XREG_RFIRQM1) = 0; +void radio_rxNow (void) { + dyn_funcs [selected_radioSetting].radio_rxNow(); } -void radio_on(void){ - // CC2538_RF_CSP_ISFLUSHRX(); - CC2538_RF_CSP_ISRXON(); -} +void radio_getReceivedFrame ( + uint8_t* bufRead, + uint8_t* lenRead, + uint8_t maxBufLen, + int8_t* rssi, + uint8_t* lqi, + bool* crc +) { -void radio_off(void){ - /* Wait for ongoing TX to complete (e.g. this could be an outgoing ACK) */ - while(HWREG(RFCORE_XREG_FSMSTAT1) & RFCORE_XREG_FSMSTAT1_TX_ACTIVE); - //CC2538_RF_CSP_ISFLUSHRX(); - - /* Don't turn off if we are off as this will trigger a Strobe Error */ - if(HWREG(RFCORE_XREG_RXENABLE) != 0) { - CC2538_RF_CSP_ISRFOFF(); - //clear fifo isr flag - HWREG(RFCORE_SFR_RFIRQF0) = ~(RFCORE_SFR_RFIRQF0_FIFOP|RFCORE_SFR_RFIRQF0_RXPKTDONE); - } + dyn_funcs [selected_radioSetting].radio_getReceivedFrame (bufRead, lenRead, maxBufLen, rssi, lqi, crc ); } +//=========================== private ========================================= + //=========================== callbacks ======================================= //=========================== interrupt handlers ============================== - -/** -\brief Stub function for the CC2538. - -In MSP430 platforms the CPU status after servicing an interrupt can be managed -toggling some bits in a special register, e.g. CPUOFF, LPM1, etc, within the -interrupt context itself. By default, after servicing an interrupt the CPU will -be off so it makes sense to return a value and enable it if something has -happened that needs the scheduler to run (a packet has been received that needs -to be processed). Otherwise, the CPU is kept in sleep mode without even -reaching the main loop. - -In the CC2538, however, the default behaviour is the contrary. After servicing -an interrupt the CPU will be on by default and it is the responsability of the -main thread to put it back to sleep (which is already done). This means that -the scheduler will always be kicked in after servicing an interrupt. This -behaviour can be changed by modifying the SLEEPEXIT field in the SYSCTRL -regiser (see page 131 of the CC2538 manual). -*/ kick_scheduler_t radio_isr(void) { - return DO_NOT_KICK_SCHEDULER; + return dyn_funcs [selected_radioSetting].radio_isr(); } -void radio_isr_internal(void) { - volatile PORT_TIMER_WIDTH capturedTime; - uint8_t irq_status0,irq_status1; - - debugpins_isr_set(); - - // capture the time - capturedTime = sctimer_readCounter(); - - // reading IRQ_STATUS - irq_status0 = HWREG(RFCORE_SFR_RFIRQF0); - irq_status1 = HWREG(RFCORE_SFR_RFIRQF1); - - IntPendClear(INT_RFCORERTX); - - //clear interrupt - HWREG(RFCORE_SFR_RFIRQF0) = 0; - HWREG(RFCORE_SFR_RFIRQF1) = 0; - - //STATUS0 Register - // start of frame event - if ((irq_status0 & RFCORE_SFR_RFIRQF0_SFD) == RFCORE_SFR_RFIRQF0_SFD) { - // change state - radio_vars.state = RADIOSTATE_RECEIVING; - if (radio_vars.startFrame_cb!=NULL) { - // call the callback - radio_vars.startFrame_cb(capturedTime); - debugpins_isr_clr(); - // kick the OS - return; - } else { - while(1); - } - } - - //or RXDONE is full -- we have a packet. - if (((irq_status0 & RFCORE_SFR_RFIRQF0_RXPKTDONE) == RFCORE_SFR_RFIRQF0_RXPKTDONE)) { - // change state - radio_vars.state = RADIOSTATE_TXRX_DONE; - if (radio_vars.endFrame_cb!=NULL) { - // call the callback - radio_vars.endFrame_cb(capturedTime); - debugpins_isr_clr(); - // kick the OS - return; - } else { - while(1); - } - } - - // or FIFOP is full -- we have a packet. - if (((irq_status0 & RFCORE_SFR_RFIRQF0_FIFOP) == RFCORE_SFR_RFIRQF0_FIFOP)) { - // change state - radio_vars.state = RADIOSTATE_TXRX_DONE; - if (radio_vars.endFrame_cb!=NULL) { - // call the callback - radio_vars.endFrame_cb(capturedTime); - debugpins_isr_clr(); - // kick the OS - return; - } else { - while(1); - } - } - - //STATUS1 Register - // end of frame event --either end of tx . - if (((irq_status1 & RFCORE_SFR_RFIRQF1_TXDONE) == RFCORE_SFR_RFIRQF1_TXDONE)) { - // change state - radio_vars.state = RADIOSTATE_TXRX_DONE; - if (radio_vars.endFrame_cb!=NULL) { - // call the callback - radio_vars.endFrame_cb(capturedTime); - debugpins_isr_clr(); - // kick the OS - return; - } else { - while(1); - } - } - debugpins_isr_clr(); - - return; -} -void radio_error_isr(void){ - uint8_t rferrm; - - rferrm = (uint8_t)HWREG(RFCORE_XREG_RFERRM); - - if ((HWREG(RFCORE_XREG_RFERRM) & (((0x02)<, September 2017. +*/ +#include "board.h" +#include "board_info.h" +#include "ssi.h" +#include "spi.h" +#include "gpio.h" +#include "ioc.h" +#include "sys_ctrl.h" + +#include +#include +#include +#include +#include +#include + + +//=========================== defines ========================================= + +#define SPI_PIN_SSI_CLK GPIO_PIN_2 // CLK +#define SPI_PIN_SSI_FSS GPIO_PIN_3 // CSn +#define SPI_PIN_SSI_RX GPIO_PIN_4 // MISO +#define SPI_PIN_SSI_TX GPIO_PIN_5 // MOSI +#define SPI_GPIO_SSI_BASE GPIO_A_BASE + +//=========================== variables ======================================= + +typedef struct { + // information about the current transaction + uint8_t* pNextTxByte; + uint16_t numTxedBytes; + uint16_t txBytesLeft; + spi_return_t returnType; + uint8_t* pNextRxByte; + uint16_t maxRxBytes; + spi_first_t isFirst; + spi_last_t isLast; + // state of the module + uint8_t busy; +#ifdef SPI_IN_INTERRUPT_MODE + // callback when module done + spi_cbt callback; +#endif +} spi_vars_t; + +spi_vars_t spi_vars; + +//=========================== prototypes ====================================== + +static void disableInterrupts(void); +static void enableInterrupts(void); + +//=========================== public ========================================== + +void spi_init() { + // clear variables + memset(&spi_vars,0,sizeof(spi_vars_t)); + + // set the clk miso and cs pins as output + GPIOPinTypeGPIOOutput(SPI_GPIO_SSI_BASE, SPI_PIN_SSI_CLK); + GPIOPinTypeGPIOOutput(SPI_GPIO_SSI_BASE, SPI_PIN_SSI_TX); + GPIOPinTypeGPIOOutput(SPI_GPIO_SSI_BASE, SPI_PIN_SSI_FSS); + + //set cs to high + GPIOPinWrite(SPI_GPIO_SSI_BASE, SPI_PIN_SSI_FSS, SPI_PIN_SSI_FSS); + //set pins to low + GPIOPinWrite(SPI_GPIO_SSI_BASE, SPI_PIN_SSI_TX, 0); + GPIOPinWrite(SPI_GPIO_SSI_BASE, SPI_PIN_SSI_CLK, 0); + + SysCtrlPeripheralEnable(SYS_CTRL_PERIPH_SSI0); + SysCtrlPeripheralSleepEnable(SYS_CTRL_PERIPH_SSI0); + SysCtrlPeripheralDeepSleepDisable(SYS_CTRL_PERIPH_SSI0); + + SSIDisable(SSI0_BASE); + SSIClockSourceSet(SSI0_BASE, SSI_CLOCK_PIOSC); + + IOCPinConfigPeriphOutput(SPI_GPIO_SSI_BASE, SPI_PIN_SSI_CLK, IOC_MUX_OUT_SEL_SSI0_CLKOUT); + IOCPinConfigPeriphOutput(SPI_GPIO_SSI_BASE, SPI_PIN_SSI_TX, IOC_MUX_OUT_SEL_SSI0_TXD); + IOCPinConfigPeriphInput(SPI_GPIO_SSI_BASE, SPI_PIN_SSI_RX, IOC_SSIRXD_SSI0); + + GPIOPinTypeSSI(SPI_GPIO_SSI_BASE, SPI_PIN_SSI_CLK ); + GPIOPinTypeSSI(SPI_GPIO_SSI_BASE, SPI_PIN_SSI_RX ); + GPIOPinTypeSSI(SPI_GPIO_SSI_BASE, SPI_PIN_SSI_TX ); + + SSIConfigSetExpClk(SSI0_BASE, SysCtrlIOClockGet(), SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, /*SysCtrlIOClockGet()/2*/16000000, 8); + + // Enable the SSI0 module. + SSIEnable(SSI0_BASE); +} + +#ifdef SPI_IN_INTERRUPT_MODE +void spi_setCb(spi_cbt cb) { + spi_vars.spi_cb = cb; +} +#endif + +void spi_txrx(uint8_t* bufTx, + uint16_t lenbufTx, + spi_return_t returnType, + uint8_t* bufRx, + uint16_t maxLenBufRx, + spi_first_t isFirst, + spi_last_t isLast) { + + uint32_t data,i; + GPIOPinWrite(GPIO_B_BASE, GPIO_PIN_1, GPIO_PIN_1); + // register spi frame to send + spi_vars.pNextTxByte = bufTx; + spi_vars.numTxedBytes = 0; + spi_vars.txBytesLeft = lenbufTx; + spi_vars.returnType = returnType; + spi_vars.pNextRxByte = bufRx; + spi_vars.maxRxBytes = maxLenBufRx; + spi_vars.isFirst = isFirst; + spi_vars.isLast = isLast; + + // SPI is now busy + spi_vars.busy = 1; + + // lower CS signal to have slave listening + if (spi_vars.isFirst==SPI_FIRST) { + GPIOPinWrite(SPI_GPIO_SSI_BASE, SPI_PIN_SSI_FSS, 0); + } + + for ( i = 0; i < lenbufTx; i++) + { + // Push a byte + SSIDataPut(SSI0_BASE, spi_vars.pNextTxByte[i]); + + // Wait until it is complete + while(SSIBusy(SSI0_BASE)); + + // Read a byte + SSIDataGet(SSI0_BASE, &data); + + // Store the result + spi_vars.pNextRxByte[i] = (uint8_t)(data & 0xFF); + // one byte less to go + } + + if (spi_vars.isLast==SPI_LAST) { + GPIOPinWrite(SPI_GPIO_SSI_BASE, SPI_PIN_SSI_FSS, SPI_PIN_SSI_FSS); + } + + // SPI is not busy anymore + spi_vars.busy = 0; + GPIOPinWrite(GPIO_B_BASE, GPIO_PIN_1, 0); +} + +//=========================== private ========================================= + +port_INLINE void enableInterrupts(void) +{ + // Enable the SPI interrupt + SSIIntEnable(SSI0_BASE, (SSI_TXFF | SSI_RXFF | SSI_RXTO | SSI_RXOR)); + + // Enable the SPI interrupt + IntEnable(INT_SSI0); +} + +port_INLINE void disableInterrupts(void) +{ + // Disable the SPI interrupt + SSIIntDisable(SSI0_BASE, (SSI_TXFF | SSI_RXFF | SSI_RXTO | SSI_RXOR)); + + // Disable the SPI interrupt + IntDisable(INT_SSI0); +} + +//=========================== interrupt handlers ============================== + +kick_scheduler_t spi_isr() { +#ifdef SPI_IN_INTERRUPT_MODE + uint32_t data; + // save the byte just received in the RX buffer + status = SSIIntStatus(SSI0_BASE, true); + + // Clear SPI interrupt in the NVIC + IntPendClear(INT_SSI0); + + SSIDataGet(SSI0_BASE, &data); + + // Store the result + spi_vars.pNextRxByte = (uint8_t)(data & 0xFF); + + // one byte less to go + spi_vars.pNextTxByte++; + spi_vars.pNextRxByte++; + spi_vars.txBytesLeft--; + + if (spi_vars.txBytesLeft>0) { + // write next byte to TX buffer + SSIDataPut(SSI0_BASE, *spi_vars.pNextTxByte); + + } else { + // SPI is not busy anymore + spi_vars.busy = 0; + + // SPI is done! + if (spi_vars.callback!=NULL) { + // call the callback + spi_vars.spi_cb(); + // kick the OS + return KICK_SCHEDULER; + } + } + +#endif + return DO_NOT_KICK_SCHEDULER; +} diff --git a/bsp/boards/openmote-b/startup_iar.c b/bsp/boards/openmote-b/startup_iar.c index e63d7bc74b..4b7c2ad585 100644 --- a/bsp/boards/openmote-b/startup_iar.c +++ b/bsp/boards/openmote-b/startup_iar.c @@ -39,8 +39,8 @@ #include #define FLASH_START_ADDR 0x00200000 -#define BOOTLOADER_BACKDOOR_ENABLE 0xF7FFFFFF // ENABLED: PORT A, PIN 6, LOW #define BOOTLOADER_BACKDOOR_DISABLE 0xEFFFFFFF +#define BOOTLOADER_BACKDOOR_ENABLE 0xF6FFFFFF // ENABLED: PORT A, PIN 6, LOW #define SYS_CTRL_EMUOVR 0x400D20B4 #define SYS_CTRL_I_MAP 0x400D2098 @@ -191,7 +191,7 @@ lockPageCCA_t; __root const lockPageCCA_t __cca @ ".flashcca" = { - BOOTLOADER_BACKDOOR_ENABLE, // Bootloader backdoor disabled + BOOTLOADER_BACKDOOR_ENABLE, // Bootloader backdoor enabled 0, // Image valid bytes FLASH_START_ADDR // Vector table located at flash start address }; diff --git a/bsp/boards/openmote-cc2538/board.c b/bsp/boards/openmote-cc2538/board.c index 9195d655a5..cb738b8533 100644 --- a/bsp/boards/openmote-cc2538/board.c +++ b/bsp/boards/openmote-cc2538/board.c @@ -3,7 +3,7 @@ * Pere Tuset (peretuset@openmote.com) * Date: July 2013 * Description: CC2538-specific definition of the "board" bsp module. - */ + **/ #include #include @@ -39,6 +39,10 @@ #else #define CC2538_FLASH_ADDRESS ( 0x0027F800 ) #endif + +slot_board_vars_t slot_board_vars [MAX_SLOT_TYPES]; +slotType_t selected_slot_type; + //=========================== prototypes ====================================== void board_timer_init(void); @@ -84,11 +88,50 @@ void board_init(void) { sensors_init(); cryptoengine_init(); pwm_init(); + board_init_slot_vars(); +} + +//==== bootstrapping slot info lookup table +void board_init_slot_vars(void){ + //10ms slot + slot_board_vars [SLOT_10ms].slotDuration = 328 ; // ms + slot_board_vars [SLOT_10ms].maxTxDataPrepare = 10 ; // 305us (measured 82us) + slot_board_vars [SLOT_10ms].maxRxAckPrepare = 10 ; // 305us (measured 83us) + slot_board_vars [SLOT_10ms].maxRxDataPrepare = 4 ; // 122us (measured 22us) + slot_board_vars [SLOT_10ms].maxTxAckPrepare = 10 ; // 122us (measured 94us) + #ifdef L2_SECURITY_ACTIVE + slot_board_vars [SLOT_10ms].delayTx = 14 ; // 366us (measured xxxus) + #else + slot_board_vars [SLOT_10ms].delayTx = 12 ; // 366us (measured xxxus) + #endif + slot_board_vars [SLOT_10ms].delayRx = 0 ; // 0us (can not measure) + + // 20ms slot + slot_board_vars [SLOT_20ms_24GHZ].slotDuration = 655 ; // ms + slot_board_vars [SLOT_20ms_24GHZ].maxTxDataPrepare = 15 ; // 457us (based on measurement) + slot_board_vars [SLOT_20ms_24GHZ].maxRxAckPrepare = 10 ; // 305us (based on measurement) + slot_board_vars [SLOT_20ms_24GHZ].maxRxDataPrepare = 10 ; // 305us (based on measurement) + slot_board_vars [SLOT_20ms_24GHZ].maxTxAckPrepare = 15 ; // 457us (based on measurement) + slot_board_vars [SLOT_20ms_24GHZ].delayTx = 13 ; // 396us (based on measurement) + slot_board_vars [SLOT_20ms_24GHZ].delayRx = 0 ; // 0us (can not measure) } +// To get the current slotDuration at any time +// used during initialization by sixtop to fire the first sixtop EB +uint16_t board_getSlotDuration (void) +{ + return slot_board_vars [selected_slot_type].slotDuration; +} + +// Setter/Getter function for slot_board_vars +slot_board_vars_t board_selectSlotTemplate (slotType_t slot_type) +{ + selected_slot_type = slot_type; + return slot_board_vars [selected_slot_type]; +} /** * Puts the board to sleep - */ + **/ void board_sleep(void) { SysCtrlPowerModeSet(SYS_CTRL_PM_NOACTION); SysCtrlSleep(); @@ -97,7 +140,7 @@ void board_sleep(void) { /** * Timer runs at 32 MHz and is 32-bit wide * The timer is divided by 32, whichs gives a 1 microsecond ticks - */ + **/ void board_timer_init(void) { // Configure the timer TimerConfigure(GPTIMER2_BASE, GPTIMER_CFG_PERIODIC_UP); @@ -109,7 +152,7 @@ void board_timer_init(void) { /** * Returns the current value of the timer * The timer is divided by 32, whichs gives a 1 microsecond ticks - */ + **/ uint32_t board_timer_get(void) { uint32_t current; @@ -121,7 +164,7 @@ uint32_t board_timer_get(void) { /** * Returns true if the timer has expired * The timer is divided by 32, whichs gives a 1 microsecond ticks - */ + **/ bool board_timer_expired(uint32_t future) { uint32_t current; int32_t remaining; @@ -139,7 +182,7 @@ bool board_timer_expired(uint32_t future) { /** * Resets the board - */ + **/ void board_reset(void) { SysCtrlReset(); } @@ -147,13 +190,13 @@ void board_reset(void) { //=========================== private ========================================= static void gpio_init(void) { - /* Set GPIOs as output */ + //Set GPIOs as output GPIOPinTypeGPIOOutput(GPIO_A_BASE, 0xFF); GPIOPinTypeGPIOOutput(GPIO_B_BASE, 0xFF); GPIOPinTypeGPIOOutput(GPIO_C_BASE, 0xFF); GPIOPinTypeGPIOOutput(GPIO_D_BASE, 0xFF); - /* Initialize GPIOs to low */ + //Initialize GPIOs to low GPIOPinWrite(GPIO_A_BASE, 0xFF, 0x00); GPIOPinWrite(GPIO_B_BASE, 0xFF, 0x00); GPIOPinWrite(GPIO_C_BASE, 0xFF, 0x00); @@ -161,35 +204,35 @@ static void gpio_init(void) { } static void clock_init(void) { - /* Disable global interrupts */ + //Disable global interrupts bool bIntDisabled = IntMasterDisable(); - /* Configure the 32 kHz pins, PD6 and PD7, for crystal operation */ - /* By default they are configured as GPIOs */ + //Configure the 32 kHz pins, PD6 and PD7, for crystal operation + //By default they are configured as GPIOs GPIODirModeSet(GPIO_D_BASE, 0x40, GPIO_DIR_MODE_IN); GPIODirModeSet(GPIO_D_BASE, 0x80, GPIO_DIR_MODE_IN); IOCPadConfigSet(GPIO_D_BASE, 0x40, IOC_OVERRIDE_ANA); IOCPadConfigSet(GPIO_D_BASE, 0x80, IOC_OVERRIDE_ANA); - /* Set the real-time clock to use the 32 kHz external crystal */ - /* Set the system clock to use the external 32 MHz crystal */ - /* Set the system clock to 32 MHz */ + //Set the real-time clock to use the 32 kHz external crystal + //Set the system clock to use the external 32 MHz crystal + //Set the system clock to 32 MHz SysCtrlClockSet(true, false, SYS_CTRL_SYSDIV_32MHZ); - /* Set the IO clock to operate at 16 MHz */ - /* This way peripherals can run while the system clock is gated */ + //Set the IO clock to operate at 16 MHz + //This way peripherals can run while the system clock is gated SysCtrlIOClockSet(SYS_CTRL_SYSDIV_16MHZ); - /* Wait until the selected clock configuration is stable */ + //Wait until the selected clock configuration is stable while (!((HWREG(SYS_CTRL_CLOCK_STA)) & (SYS_CTRL_CLOCK_STA_XOSC_STB))); - /* Define what peripherals run in each mode */ + //Define what peripherals run in each mode SysCtrlRunSetting(); SysCtrlSleepSetting(); SysCtrlDeepSleepSetting(); SysCtrlWakeupSetting(); - /* Re-enable interrupt if initially enabled */ + //Re-enable interrupt if initially enabled if (!bIntDisabled) { IntMasterEnable(); } @@ -197,48 +240,48 @@ static void clock_init(void) { /** * Configures the user button as input source - */ + **/ static void button_init(void) { volatile uint32_t i; - /* Delay to avoid pin floating problems */ + //Delay to avoid pin floating problems for (i = 0xFFFF; i != 0; i--); GPIOPinIntDisable(BSP_BUTTON_BASE, BSP_BUTTON_USER); GPIOPinIntClear(BSP_BUTTON_BASE, BSP_BUTTON_USER); - /* The button is an input GPIO on falling edge */ + //The button is an input GPIO on falling edge GPIOPinTypeGPIOInput(BSP_BUTTON_BASE, BSP_BUTTON_USER); GPIOIntTypeSet(BSP_BUTTON_BASE, BSP_BUTTON_USER, GPIO_FALLING_EDGE); - /* Register the interrupt */ + //Register the interrupt GPIOPortIntRegister(BSP_BUTTON_BASE, GPIO_C_Handler); - /* Clear and enable the interrupt */ + //Clear and enable the interrupt GPIOPinIntClear(BSP_BUTTON_BASE, BSP_BUTTON_USER); GPIOPinIntEnable(BSP_BUTTON_BASE, BSP_BUTTON_USER); user_button_initialized = TRUE; } static void SysCtrlRunSetting(void) { - /* Disable General Purpose Timers 0, 1, 2, 3 when running */ + //Disable General Purpose Timers 0, 1, 2, 3 when running SysCtrlPeripheralDisable(SYS_CTRL_PERIPH_GPT0); SysCtrlPeripheralDisable(SYS_CTRL_PERIPH_GPT1); SysCtrlPeripheralDisable(SYS_CTRL_PERIPH_GPT3); - /* Disable SSI 0, 1 when running */ + //Disable SSI 0, 1 when running SysCtrlPeripheralDisable(SYS_CTRL_PERIPH_SSI0); SysCtrlPeripheralDisable(SYS_CTRL_PERIPH_SSI1); - /* Disable UART1 when running */ + //Disable UART1 when running SysCtrlPeripheralDisable(SYS_CTRL_PERIPH_UART1); - /* Disable I2C, AES and PKA when running */ + //Disable I2C, AES and PKA when running SysCtrlPeripheralDisable(SYS_CTRL_PERIPH_I2C); SysCtrlPeripheralDisable(SYS_CTRL_PERIPH_PKA); SysCtrlPeripheralDisable(SYS_CTRL_PERIPH_AES); - /* Enable UART0 and RFC when running */ + //Enable UART0 and RFC when running SysCtrlPeripheralEnable(SYS_CTRL_PERIPH_GPT2); SysCtrlPeripheralEnable(SYS_CTRL_PERIPH_GPT3); SysCtrlPeripheralEnable(SYS_CTRL_PERIPH_UART0); @@ -246,24 +289,24 @@ static void SysCtrlRunSetting(void) { } static void SysCtrlSleepSetting(void) { - /* Disable General Purpose Timers 0, 1, 2, 3 during sleep */ + //Disable General Purpose Timers 0, 1, 2, 3 during sleep SysCtrlPeripheralSleepDisable(SYS_CTRL_PERIPH_GPT0); SysCtrlPeripheralSleepDisable(SYS_CTRL_PERIPH_GPT1); SysCtrlPeripheralSleepDisable(SYS_CTRL_PERIPH_GPT3); - /* Disable SSI 0, 1 during sleep */ + //Disable SSI 0, 1 during sleep SysCtrlPeripheralSleepDisable(SYS_CTRL_PERIPH_SSI0); SysCtrlPeripheralSleepDisable(SYS_CTRL_PERIPH_SSI1); - /* Disable UART 0, 1 during sleep */ + //Disable UART 0, 1 during sleep SysCtrlPeripheralSleepDisable(SYS_CTRL_PERIPH_UART1); - /* Disable I2C, PKA, AES during sleep */ + //Disable I2C, PKA, AES during sleep SysCtrlPeripheralSleepDisable(SYS_CTRL_PERIPH_I2C); SysCtrlPeripheralSleepDisable(SYS_CTRL_PERIPH_PKA); SysCtrlPeripheralSleepDisable(SYS_CTRL_PERIPH_AES); - /* Enable UART and RFC during sleep */ + //Enable UART and RFC during sleep SysCtrlPeripheralSleepEnable(SYS_CTRL_PERIPH_GPT2); SysCtrlPeripheralSleepEnable(SYS_CTRL_PERIPH_GPT3); SysCtrlPeripheralSleepEnable(SYS_CTRL_PERIPH_UART0); @@ -271,21 +314,21 @@ static void SysCtrlSleepSetting(void) { } static void SysCtrlDeepSleepSetting(void) { - /* Disable General Purpose Timers 0, 1, 2, 3 during deep sleep */ + //Disable General Purpose Timers 0, 1, 2, 3 during deep sleep SysCtrlPeripheralDeepSleepDisable(SYS_CTRL_PERIPH_GPT0); SysCtrlPeripheralDeepSleepDisable(SYS_CTRL_PERIPH_GPT1); SysCtrlPeripheralDeepSleepDisable(SYS_CTRL_PERIPH_GPT2); SysCtrlPeripheralDeepSleepDisable(SYS_CTRL_PERIPH_GPT3); - /* Disable SSI 0, 1 during deep sleep */ + //Disable SSI 0, 1 during deep sleep SysCtrlPeripheralDeepSleepDisable(SYS_CTRL_PERIPH_SSI0); SysCtrlPeripheralDeepSleepDisable(SYS_CTRL_PERIPH_SSI1); - /* Disable UART 0, 1 during deep sleep */ + //Disable UART 0, 1 during deep sleep SysCtrlPeripheralDeepSleepDisable(SYS_CTRL_PERIPH_UART0); SysCtrlPeripheralDeepSleepDisable(SYS_CTRL_PERIPH_UART1); - /* Disable I2C, PKA, AES during deep sleep */ + //Disable I2C, PKA, AES during deep sleep SysCtrlPeripheralDeepSleepDisable(SYS_CTRL_PERIPH_I2C); SysCtrlPeripheralDeepSleepDisable(SYS_CTRL_PERIPH_PKA); SysCtrlPeripheralDeepSleepDisable(SYS_CTRL_PERIPH_AES); @@ -293,7 +336,7 @@ static void SysCtrlDeepSleepSetting(void) { } static void SysCtrlWakeupSetting(void) { - /* Allow the SMTimer to wake up the processor */ + //Allow the SMTimer to wake up the processor GPIOIntWakeupEnable(GPIO_IWE_SM_TIMER); } @@ -302,18 +345,18 @@ static void SysCtrlWakeupSetting(void) { /** * GPIO_C interrupt handler. User button is GPIO_C_3 * Erases a Flash sector to trigger the bootloader backdoor - */ + **/ static void GPIO_C_Handler(void) { if (!user_button_initialized) return; - /* Disable the interrupts */ + //Disable the interrupts IntMasterDisable(); leds_all_off(); - /* Eras the CCA flash page */ + //Eras the CCA flash page FlashMainPageErase(CC2538_FLASH_ADDRESS); leds_circular_shift(); - /* Reset the board */ + //Reset the board SysCtrlReset(); } diff --git a/bsp/boards/openmote-cc2538/board_info.h b/bsp/boards/openmote-cc2538/board_info.h index 721f6e03fa..417f8845d2 100644 --- a/bsp/boards/openmote-cc2538/board_info.h +++ b/bsp/boards/openmote-cc2538/board_info.h @@ -58,44 +58,6 @@ #define PORT_PIN_RADIO_RESET_HIGH() // nothing #define PORT_PIN_RADIO_RESET_LOW() // nothing -//===== IEEE802154E timing - -#define SLOTDURATION 20 // in miliseconds - -//===== IEEE802154E timing - -#if SLOTDURATION==10 - // time-slot related - #define PORT_TsSlotDuration 328 // counter counts one extra count, see datasheet - // execution speed related - #define PORT_maxTxDataPrepare 10 // 305us (measured 82us) - #define PORT_maxRxAckPrepare 10 // 305us (measured 83us) - #define PORT_maxRxDataPrepare 4 // 122us (measured 22us) - #define PORT_maxTxAckPrepare 10 // 122us (measured 94us) - // radio speed related - #ifdef L2_SECURITY_ACTIVE - #define PORT_delayTx 14 // 366us (measured xxxus) - #else - #define PORT_delayTx 12 // 366us (measured xxxus) - #endif - #define PORT_delayRx 0 // 0us (can not measure) - // radio watchdog -#endif - -#if SLOTDURATION==20 - #define PORT_TsSlotDuration 655 // 20ms - - // execution speed related - #define PORT_maxTxDataPrepare 15 // 458us (measured 213us) - #define PORT_maxRxAckPrepare 10 // 305us (measured 86us) - #define PORT_maxRxDataPrepare 10 // 305us (measured 88us) - #define PORT_maxTxAckPrepare 15 // 458us (measured 211us) - - // radio speed related - #define PORT_delayTx 13 // 397us (measured 388us) - #define PORT_delayRx 0 // 0us (can not measure) -#endif - //===== adaptive_sync accuracy #define SYNC_ACCURACY 1 // ticks diff --git a/bsp/boards/openmote-cc2538/radio.c b/bsp/boards/openmote-cc2538/radio.c index b81dafeaa1..312e835884 100644 --- a/bsp/boards/openmote-cc2538/radio.c +++ b/bsp/boards/openmote-cc2538/radio.c @@ -45,6 +45,9 @@ typedef struct { radio_vars_t radio_vars; +// global radio selection, will use the slowest by default at initialization. +uint8_t selected_radioSetting = RADIOSETTING_24GHZ; + //=========================== prototypes ====================================== void enable_radio_interrupts(void); @@ -181,7 +184,12 @@ void radio_reset(void) { //===== RF admin -void radio_setFrequency(uint8_t frequency, radio_freq_t tx_or_rx) { +void radio_setConfig (radioSetting_t radioSetting){ + selected_radioSetting = radioSetting; + //do nothing +} + +void radio_setFrequency(uint16_t frequency, radio_freq_t tx_or_rx) { // change state radio_vars.state = RADIOSTATE_SETTING_FREQUENCY; diff --git a/bsp/boards/openmotestm/board.c b/bsp/boards/openmotestm/board.c index a0420b8a9a..4f9509e7fb 100644 --- a/bsp/boards/openmotestm/board.c +++ b/bsp/boards/openmotestm/board.c @@ -32,7 +32,9 @@ extern int mote_main(void); int main(void) { return mote_main(); } - +//=========================== variables ======================================= +slot_board_vars_t slot_board_vars [MAX_SLOT_TYPES]; +slotType_t selected_slot_type; //=========================== public ========================================== void board_init(void){ @@ -95,6 +97,37 @@ void board_init(void){ debugpins_init(); //enable nvic for the radio NVIC_radio(); + + board_init_slot_vars(); +} + +//==== bootstrapping slot info lookup table + +//===== IEEE802154E timing +void board_init_slot_vars(void){ + // 20ms slot + slot_board_vars [SLOT_20ms_24GHZ].slotDuration = 655 ; // ms + slot_board_vars [SLOT_20ms_24GHZ].maxTxDataPrepare = 66 ; // 2014us (not measured) + slot_board_vars [SLOT_20ms_24GHZ].maxRxAckPrepare = 20 ; // 610us (not measured) + slot_board_vars [SLOT_20ms_24GHZ].maxRxDataPrepare = 33 ; // 1007us (not measured) + slot_board_vars [SLOT_20ms_24GHZ].maxTxAckPrepare = 30 ; // 915us (not measured) + slot_board_vars [SLOT_20ms_24GHZ].delayTx = 10 ; // 305us (not measured) + slot_board_vars [SLOT_20ms_24GHZ].delayRx = 0 ; // 0us (can not measure) + +} + +// To get the current slotDuration at any time +// used during initialization by sixtop to fire the first sixtop EB +uint16_t board_getSlotDuration (void) +{ + return slot_board_vars [selected_slot_type].slotDuration; +} + +// Setter/Getter function for slot_board_vars +slot_board_vars_t board_selectSlotTemplate (slotType_t slot_type) +{ + selected_slot_type = slot_type; + return slot_board_vars [selected_slot_type]; } void board_sleep(void) { @@ -123,24 +156,24 @@ void board_reset(void){ void GPIO_Config_ALL_AIN(void){ GPIO_InitTypeDef GPIO_InitStructure; - /* Enable GPIOD and GPIOE clock */ + //Enable GPIOD and GPIOE clock RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | RCC_APB2Periph_AFIO, ENABLE); - /* PA */ + //PA GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; GPIO_Init(GPIOA, &GPIO_InitStructure); - /* PB */ + //PB GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; GPIO_Init(GPIOB, &GPIO_InitStructure); - /* PC */ + //PC GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; GPIO_Init(GPIOC, &GPIO_InitStructure); - /* PD */ + //PD GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; GPIO_Init(GPIOD, &GPIO_InitStructure); diff --git a/bsp/boards/openmotestm/board_info.h b/bsp/boards/openmotestm/board_info.h index 0cfe4f67c0..43add1fb89 100644 --- a/bsp/boards/openmotestm/board_info.h +++ b/bsp/boards/openmotestm/board_info.h @@ -53,21 +53,6 @@ to return the board's description. #define PORT_PIN_RADIO_RESET_HIGH() //GPIOC->ODR |= 0X0040; #define PORT_PIN_RADIO_RESET_LOW() //GPIOC->ODR &= ~0X0040; -//===== IEEE802154E timing - -#define SLOTDURATION 20 // in miliseconds - -// time-slot related -#define PORT_TsSlotDuration 655 // counter counts one extra count, see datasheet -// execution speed related -#define PORT_maxTxDataPrepare 66 // 2014us (measured 746us) -#define PORT_maxRxAckPrepare 20 // 305us (measured 83us) -#define PORT_maxRxDataPrepare 33 // 1007us (measured 84us) -#define PORT_maxTxAckPrepare 30 // 305us (measured 219us) -// radio speed related -#define PORT_delayTx 10 // 214us (measured 219us) -#define PORT_delayRx 0 // 0us (can not measure) -// radio watchdog //===== adaptive_sync accuracy diff --git a/bsp/boards/python/board_info.h b/bsp/boards/python/board_info.h index bd753a556f..8bdab16286 100644 --- a/bsp/boards/python/board_info.h +++ b/bsp/boards/python/board_info.h @@ -29,20 +29,6 @@ #define SCHEDULER_WAKEUP() #define SCHEDULER_ENABLE_INTERRUPT() -#define SLOTDURATION 10 // in miliseconds - -//===== IEEE802154E timing -// time-slot related -#define PORT_TsSlotDuration 328 // counter counts one extra count, see datasheet -// execution speed related -#define PORT_maxTxDataPrepare 10 // 305us (measured 82us) -#define PORT_maxRxAckPrepare 10 // 305us (measured 83us) -#define PORT_maxRxDataPrepare 4 // 122us (measured 22us) -#define PORT_maxTxAckPrepare 4 // 122us (measured 94us) -// radio speed related -#define PORT_delayTx 7 // 366us (measured xxxus) -#define PORT_delayRx 0 // 0us (can not measure) - //===== adaptive_sync accuracy #define SYNC_ACCURACY 1 // when using openmoteSTM, change to 2 diff --git a/bsp/boards/python/board_obj.c b/bsp/boards/python/board_obj.c index 583a06b331..79dabe44a6 100644 --- a/bsp/boards/python/board_obj.c +++ b/bsp/boards/python/board_obj.c @@ -15,6 +15,8 @@ #include "sctimer_obj.h" //=========================== variables ======================================= +slot_board_vars_t slot_board_vars [MAX_SLOT_TYPES]; +slotType_t selected_slot_type; //=========================== prototypes ====================================== @@ -34,6 +36,8 @@ void board_init(OpenMote* self) { uart_init(self); radio_init(self); + board_init_slot_vars(); + // forward to Python result = PyObject_CallObject(self->callback[MOTE_NOTIF_board_init],NULL); if (result == NULL) { @@ -47,6 +51,33 @@ void board_init(OpenMote* self) { #endif } + +//==== bootstrapping slot info lookup table +void board_init_slot_vars(void){ + //10ms slot + slot_board_vars [SLOT_10ms].slotDuration = 328 ; // ms + slot_board_vars [SLOT_10ms].maxTxDataPrepare = 10 ; // 305us (measured 82us) + slot_board_vars [SLOT_10ms].maxRxAckPrepare = 10 ; // 305us (measured 83us) + slot_board_vars [SLOT_10ms].maxRxDataPrepare = 4 ; // 122us (measured 22us) + slot_board_vars [SLOT_10ms].maxTxAckPrepare = 4 ; // 122us (measured 94us) + slot_board_vars [SLOT_10ms].delayTx = 7 ; // 213us (measured xxxus) + slot_board_vars [SLOT_10ms].delayRx = 0 ; // 0us (can not measure) +} + +// To get the current slotDuration at any time +// used during initialization by sixtop to fire the first sixtop EB +uint16_t board_getSlotDuration (void) +{ + return slot_board_vars [selected_slot_type].slotDuration; +} + +// Setter/Getter function for slot_board_vars +slot_board_vars_t board_selectSlotTemplate (slotType_t slot_type) +{ + selected_slot_type = slot_type; + return slot_board_vars [selected_slot_type]; +} + void board_sleep(OpenMote* self) { PyObject* result; diff --git a/bsp/boards/python/radio_obj.c b/bsp/boards/python/radio_obj.c index d227f027f7..c24ab11db7 100644 --- a/bsp/boards/python/radio_obj.c +++ b/bsp/boards/python/radio_obj.c @@ -9,7 +9,8 @@ //=========================== defines ========================================= //=========================== variables ======================================= - +// global radio selection +uint8_t selected_radioSetting = RADIOSETTING_24GHZ; //=========================== prototypes ====================================== @@ -87,7 +88,13 @@ void radio_reset(OpenMote* self) { //===== RF admin -void radio_setFrequency(OpenMote* self, uint8_t frequency, radio_freq_t tx_or_rx) { +void radio_setConfig ( radioSetting_t radioSetting){ + selected_radioSetting = radioSetting; + //do nothing +} + + +void radio_setFrequency(OpenMote* self, uint16_t frequency, radio_freq_t tx_or_rx) { PyObject* result; PyObject* arglist; diff --git a/bsp/boards/radio.h b/bsp/boards/radio.h index df4333e870..510c6d9c5c 100644 --- a/bsp/boards/radio.h +++ b/bsp/boards/radio.h @@ -13,7 +13,7 @@ */ #include "board.h" - +#include "opendefs.h" //=========================== define ========================================== #define LENGTH_CRC 2 @@ -56,29 +56,49 @@ typedef void (*radio_capture_cbt)(PORT_TIMER_WIDTH timestamp); //=========================== prototypes ====================================== // admin +// used in MAC init void radio_init(void); +// referred to only inside projects. Never inside MAC or even drivers +void radio_powerOn(void); +// referred to in init and change of settings void radio_setStartFrameCb(radio_capture_cbt cb); void radio_setEndFrameCb(radio_capture_cbt cb); // reset +// I don't see it referenced anywhere in cource code. there are some references in pbi and pbd files void radio_reset(void); // RF admin -void radio_setFrequency(uint8_t frequency, radio_freq_t tx_or_rx); -//void radio_setFrequency(uint8_t frequency); +// This function never sets frequency in fact. It sets a "channel". It shoud change accordingly. +// Should be claculateChannel and it can take an 8 bit channel index. +void radio_setFrequency(uint16_t frequency, radio_freq_t tx_or_rx); + +void radio_setConfig(radioSetting_t radioSetting); + +//referred to in MAC init and in some projects void radio_rfOn(void); +//referenced at end of each rf activity in the MAC void radio_rfOff(void); +// not referenced in MAC but referenced in some projects int8_t radio_getFrequencyOffset(void); // TX #ifdef SLOT_FSM_IMPLEMENTATION_MULTIPLE_TIMER_INTERRUPT +// why not put it under the scum implementation of loadpacket? void radio_loadPacket_prepare(uint8_t* packet, uint16_t len); #endif + + void radio_loadPacket(uint8_t* packet, uint16_t len); void radio_txEnable(void); void radio_txNow(void); // RX +//referenced in the MAC in scum context only. +// why not put it under the scum implementation of rxEnable? void radio_rxPacket_prepare(void); + void radio_rxEnable(void); +//referenced in the MAC in scum context only: why not have an implementation of rxEnable void radio_rxEnable_scum(void); void radio_rxNow(void); +// some older implementations support only 8bit lenRead and maxBufLen. They need to be generalized to 16bit because of big packets and to keep a flexible radio interface for non-openwsn applications where lengh can be up to 16bit) void radio_getReceivedFrame(uint8_t* bufRead, uint8_t* lenRead, uint8_t maxBufLen, @@ -87,6 +107,7 @@ void radio_getReceivedFrame(uint8_t* bufRead, bool* crc); // interrupt handlers +// kick_scheduler_t: a generalized version of this will need to maintain void return.? kick_scheduler_t radio_isr(void); /** diff --git a/bsp/boards/samr21_xpro/board.c b/bsp/boards/samr21_xpro/board.c index 25ed3b6e5b..46425b07a0 100644 --- a/bsp/boards/samr21_xpro/board.c +++ b/bsp/boards/samr21_xpro/board.c @@ -32,7 +32,7 @@ * */ -/* === INCLUDES ============================================================ */ +//=== INCLUDES ============================================================ #include "sam.h" #include "samr21_extint.h" #include "samr21_flash.h" @@ -55,19 +55,22 @@ #include "leds.h" #include "delay.h" +//=========================== variables ======================================= +slot_board_vars_t slot_board_vars [MAX_SLOT_TYPES]; +slotType_t selected_slot_type; -/* === MACROS ============================================================== */ +//=== MACROS ============================================================== -/* TRX Parameter: t10 */ +//TRX Parameter: t10 #define RST_PULSE_WIDTH_US (10) -/* TRX Parameter: tTR1 typical value */ +//TRX Parameter: tTR1 typical value #define P_ON_TO_CLKM_AVAILABLE_TYP_US (330) #define TRX_EXT_INT_CH (0) -/* === GLOBALS ============================================================= */ +//=== GLOBALS ============================================================= extern int mote_main(); @@ -98,43 +101,46 @@ int main(void) */ void board_init(void) { - /* Disable the irq before initialization */ + //Disable the irq before initialization cpu_irq_disable(); - /* Initialize the Clock and event system and more */ + // Initialize the Clock and event system and more sys_clock_init(); - /* Configure the Debug Pins */ + //Configure the Debug Pins debugpins_init(); - /* Configure the Radio Interrupt */ + //Configure the Radio Interrupt at86rfx_intc_init(); - /* Clear the Radio Interrupt */ + //Clear the Radio Interrupt extint_flag_clear(TRX_EXT_INT_CH); -/* Initialize board hardware - SPI Init Configure the Radio Pins and Like RST, SLP_TR, EXTI(IRQ on Rising Edge) - */ +// Initialize board hardware +// SPI Init Configure the Radio Pins and Like RST, SLP_TR, EXTI(IRQ on Rising Edge) + rf_interface_init(); - /* Initialize the LED Output */ + //Initialize the LED Output leds_init(); - /* Initialize the Button Input */ + //Initialize the Button Input button_init(); - /* Radio Init */ + //Radio Init radio_init(); - /* UART Init */ + //UART Init uart_init(); - /* BSP Timer Init*/ + //BSP Timer Init sctimer_init(); - /* Clear the Radio Interrupt */ + //Initialize slot vars + board_init_slot_vars(); + + //Clear the Radio Interrupt extint_enable_irq(TRX_EXT_INT_CH); - /* Enable the IRQ */ + //Enable the IRQ cpu_irq_enable(); } @@ -149,7 +155,7 @@ void board_init(void) void rf_interface_init(void) { pinmux_t pinmux; - /* Configure the RF233 SPI Interface */ + //Configure the RF233 SPI Interface pinmux.dir = PORT_PIN_DIR_OUTPUT; pinmux.mux_loc = SYSTEM_PINMUX_GPIO; pinmux.pull = PORT_PIN_PULLUP; @@ -169,7 +175,7 @@ void rf_interface_init(void) port_pin_set_level(AT86RFX_RST_PIN, SET_HIGH); port_pin_set_level(AT86RFX_SLP_PIN, SET_HIGH); - /* Enable the RF Block */ + //Enable the RF Block PM->APBCMASK.reg |= (1<>. 0x64 = txPwr=>0x04, max: 0x1F. - {RG_BBC0_IRQM, 0x1F},// TXFE, RXEM, RXAM, RXFE, RXFS interrupts enabled + {RG_RF09_PAC, 0x7F}, // Tx Power 5 bits >>. 0x64 = txPwr=>0x04, max: 0x1F. + {RG_BBC0_IRQM, 0x1F}, // TXFE, RXEM, RXAM, RXFE, RXFS interrupts enabled {RG_BBC1_IRQM, 0x00}, - {RG_BBC0_PC, 0x1D},// No FCS filter, 32 bits FCS, FSK. >Mina: used to be 15. Set to 1D to use 16 bit FCS - {RG_BBC0_FSKDM, 0x01},//Direct modulation and preemphasis enabled. + {RG_BBC0_PC, 0x1D}, // No FCS filter, 16 bits FCS, FSK. + {RG_BBC0_FSKDM, 0x01}, //Direct modulation and preemphasis enabled. {RG_BBC0_FSKC0, 0xD6}, {RG_BBC0_FSKC1, 0x00}, // {RG_BBC0_FSKC2, 0x00}, @@ -4071,8 +4071,8 @@ static const registerSetting_t basic_settings_fsk_option3 []={ //DO NOT USE {RG_BBC0_FSKPHRTX, 0x00},// No data whitening SFD0 used. }; //------------------------------------ OQPSK -----------------------------------// -static const registerSetting_t basic_settings_oqpsk_rate1[] = { - {RG_BBC0_PC, 0x17}, +static const registerSetting_t basic_settings_oqpsk_rate0[] = { + {RG_BBC0_PC, 0x1F}, // 16bit FCS {RG_BBC0_OQPSKPHRTX, 0x00}, // MR-OQPSK, rate mode 0 {RG_BBC0_OQPSKC0, 0x10}, // 100kchips/s, RC-0.8 shaping, direct-modulation enabled // {RG_BBC0_OQPSKC1, 0x3F}, // MINIMUM preamble-detection sensitivities, rx-override disabled @@ -4092,7 +4092,7 @@ static const registerSetting_t basic_settings_oqpsk_rate1[] = { {RG_RF09_PAC, 0x7F},// Tx Power 5 bits >>. 0x64 = txPwr=>0x04, max: 0x1F. }; -static const registerSetting_t basic_settings_oqpsk_rate2[] = { +static const registerSetting_t basic_settings_oqpsk_rate1[] = { {RG_BBC0_PC, 0x17}, {RG_BBC0_OQPSKPHRTX, 0x02}, // MR-OQPSK, rate mode 0 {RG_BBC0_OQPSKC0, 0x10}, // 100kchips/s, RC-0.8 shaping, direct-modulation enabled @@ -4113,9 +4113,9 @@ static const registerSetting_t basic_settings_oqpsk_rate2[] = { {RG_RF09_PAC, 0x7F},// Tx Power 5 bits >>. 0x64 = txPwr=>0x04, max: 0x1F. }; -static const registerSetting_t basic_settings_oqpsk_rate3[] = { +static const registerSetting_t basic_settings_oqpsk_rate2[] = { {RG_BBC0_PC, 0x1F}, // Mina: used to be 17 but change to 1F make 2B FCS - {RG_BBC0_OQPSKPHRTX, 0x04}, // MR-OQPSK, rate mode 0 + {RG_BBC0_OQPSKPHRTX, 0x04}, // MR-OQPSK, rate mode 3 {RG_BBC0_OQPSKC0, 0x10}, // 100kchips/s, RC-0.8 shaping, direct-modulation enabled // {RG_BBC0_OQPSKC1, 0x3F}, // MINIMUM preamble-detection sensitivities, rx-override disabled // {RG_BBC0_OQPSKC2, 0x00}, // listen for MR-OQPSK frames only @@ -4134,9 +4134,9 @@ static const registerSetting_t basic_settings_oqpsk_rate3[] = { {RG_RF09_PAC, 0x7F},// Tx Power 5 bits >>. 0x64 = txPwr=>0x04, max: 0x1F. }; -static const registerSetting_t basic_settings_oqpsk_rate4[] = { - {RG_BBC0_PC, 0x17}, - {RG_BBC0_OQPSKPHRTX, 0x06}, // MR-OQPSK, rate mode 0 +static registerSetting_t basic_settings_oqpsk_rate3[] = { + {RG_BBC0_PC, 0x1F}, // 16 bit FCS + {RG_BBC0_OQPSKPHRTX, 0x06}, // MR-OQPSK, rate mode 0//ERORR {RG_BBC0_OQPSKC0, 0x10}, // 100kchips/s, RC-0.8 shaping, direct-modulation enabled // {RG_BBC0_OQPSKC1, 0x3F}, // MINIMUM preamble-detection sensitivities, rx-override disabled // {RG_BBC0_OQPSKC2, 0x00}, // listen for MR-OQPSK frames only @@ -4178,7 +4178,7 @@ static const registerSetting_t basic_settings_oqpsk_250kbps[] = { //------------------------------------ OFDM -----------------------------------// /** Preferred settings for OFDM */ -static const registerSetting_t basic_settings_ofdm_1_mcs0[] = { +static registerSetting_t basic_settings_ofdm_1_mcs0[] = { {RG_RF09_CMD, 0x02}, {RG_RF09_IRQM, 0x1F}, {RG_RF24_IRQM, 0x00}, @@ -4196,7 +4196,7 @@ static const registerSetting_t basic_settings_ofdm_1_mcs0[] = { {RG_BBC0_OFDMPHRTX, 0x00}, }; -static const registerSetting_t basic_settings_ofdm_1_mcs1[] = { +static registerSetting_t basic_settings_ofdm_1_mcs1[] = { {RG_RF09_CMD, 0x02}, {RG_RF09_IRQM, 0x1F}, {RG_RF24_IRQM, 0x00}, @@ -4214,7 +4214,7 @@ static const registerSetting_t basic_settings_ofdm_1_mcs1[] = { {RG_BBC0_OFDMPHRTX, 0x01}, }; -static const registerSetting_t basic_settings_ofdm_1_mcs2[] = { +static registerSetting_t basic_settings_ofdm_1_mcs2[] = { {RG_RF09_CMD, 0x02}, {RG_RF09_IRQM, 0x1F}, {RG_RF24_IRQM, 0x00}, @@ -4232,7 +4232,7 @@ static const registerSetting_t basic_settings_ofdm_1_mcs2[] = { {RG_BBC0_OFDMPHRTX, 0x02}, }; -static const registerSetting_t basic_settings_ofdm_1_mcs3[] = { //TODO +static registerSetting_t basic_settings_ofdm_1_mcs3[] = { //TODO {RG_RF09_CMD, 0x02}, {RG_RF09_IRQM, 0x1F}, {RG_RF24_IRQM, 0x00}, diff --git a/bsp/chips/at86rf215/radio.h b/bsp/chips/at86rf215/radio.h deleted file mode 100644 index b8b810db38..0000000000 --- a/bsp/chips/at86rf215/radio.h +++ /dev/null @@ -1,98 +0,0 @@ -#ifndef __RADIO_H -#define __RADIO_H - -/** -\addtogroup BSP -\{ -\addtogroup radio -\{ - -\brief Cross-platform declaration "radio" bsp module. - -\author Thomas Watteyne , February 2012. -*/ - -/* -\modifications to implement the IEEE 802.15.4-SUN -\done by Jonathan Munoz -*/ - -#include "at86rf215.h" - -//=========================== define ========================================== - -#define LENGTH_CRC 2 - -//=========================== typedef ========================================= - -/** -\brief Current state of the radio. - -\note This radio driver is very minimal in that it does not follow a state machine. - It is up to the MAC layer to ensure that the different radio operations - are called in the righr order. The radio keeps a state for debugging purposes only. -*/ -typedef enum { - RADIOSTATE_STOPPED = 0x00, ///< Completely stopped. - RADIOSTATE_RFOFF = 0x01, ///< Listening for commands, but RF chain is off. - RADIOSTATE_SETTING_FREQUENCY = 0x02, ///< Configuring the frequency. - RADIOSTATE_FREQUENCY_SET = 0x03, ///< Done configuring the frequency. - RADIOSTATE_LOADING_PACKET = 0x04, ///< Loading packet into the radio's TX buffer. - RADIOSTATE_PACKET_LOADED = 0x05, ///< Packet is fully loaded in the radio's TX buffer. - RADIOSTATE_ENABLING_TX = 0x06, ///< The RF TX chaing is being enabled (includes locking the PLL). - RADIOSTATE_TX_ENABLED = 0x07, ///< Radio ready to transmit. - RADIOSTATE_TRANSMITTING = 0x08, ///< Busy transmitting bytes. - RADIOSTATE_ENABLING_RX = 0x09, ///< The RF RX chain is being enabled (includes locking the PLL). - RADIOSTATE_LISTENING = 0x0a, ///< RF chain is on, listening, but no packet received yet. - RADIOSTATE_RECEIVING = 0x0b, ///< Busy receiving bytes. - RADIOSTATE_TXRX_DONE = 0x0c, ///< Frame has been sent/received completely. - RADIOSTATE_TURNING_OFF = 0x0d, ///< Turning the RF chain off. -} radio_state_t; - -typedef enum { - FREQ_TX = 0x01, - FREQ_RX = 0x02, -} radio_freq_t; - -typedef void (*radio_capture_cbt)(PORT_TIMER_WIDTH timestamp); - -//=========================== variables ======================================= - -//=========================== prototypes ====================================== - -// admin -void radio_powerOn(void); -void radio_init(void); -void radio_setStartFrameCb(radio_capture_cbt cb); -void radio_setEndFrameCb(radio_capture_cbt cb); -// reset -void radio_reset(void); -// RF admin -void radio_setFrequency(uint16_t channel, radio_freq_t tx_or_rx); -void radio_rfOn(void); -void radio_rfOff(void); -void radio_change_modulation(registerSetting_t * mod); -void radio_change_size(uint16_t* size); -// TX -void radio_loadPacket(uint8_t* packet, uint16_t len); -void radio_txEnable(void); -void radio_txNow(void); -// RX -void radio_rxEnable(void); -void radio_rxNow(void); -void radio_getReceivedFrame(uint8_t* bufRead, - uint16_t* lenRead, - uint16_t maxBufLen, - int8_t* rssi, - uint8_t* lqi, - bool* crc); - -// interrupt handlers -void radio_isr(void); - -/** -\} -\} -*/ - -#endif diff --git a/bsp/chips/at86rf215/radio.c b/bsp/chips/at86rf215/radio_at86rf215.c similarity index 53% rename from bsp/chips/at86rf215/radio.c rename to bsp/chips/at86rf215/radio_at86rf215.c index 1171388777..7fe319fee6 100644 --- a/bsp/chips/at86rf215/radio.c +++ b/bsp/chips/at86rf215/radio_at86rf215.c @@ -2,16 +2,17 @@ \brief at86rf215-specific definition of the "radio" bsp module. \author Jonathan Munoz , July 2016. -*/ +Modified by Mina Rady +*/ #include "board.h" -#include "radio.h" #include "spi.h" #include "debugpins.h" #include "leds.h" #include "sctimer.h" + #include #include #include @@ -23,6 +24,11 @@ #include #include +#include "radio.h" +#include "radio_at86rf215.h" +#include "at86rf215.h" + + #define AT86RF215_IRQ_BASE ( GPIO_D_BASE ) #define AT86RF215_IRQ_PIN ( GPIO_PIN_0 ) #define AT86RF215_IRQ_IOC ( IOC_OVERRIDE_DIS ) @@ -43,28 +49,20 @@ #define ATMEL_FREQUENCY_TYPE FREQ_SUGHZ #endif -//=========================== variables ======================================= +//=========================== variables ========================================== +radio_vars_at86rf215_t radio_vars_at86rf215; -typedef struct { - radio_capture_cbt startFrame_cb; - radio_capture_cbt endFrame_cb; - radio_state_t state; - uint8_t rf09_isr; - uint8_t rf24_isr; - uint8_t bb0_isr; - uint8_t bb1_isr; -} radio_vars_t; - -radio_vars_t radio_vars; +// open radio register mapping: an array of pointers to registersettings arrays +radio_config_t radio_api; //=========================== public ========================================== -static void radio_read_isr(void); -static void radio_clear_isr(void); +static void radio_read_isr_at86rf215(void); +static void radio_clear_isr_at86rf215(void); //===== admin -void radio_powerOn(void) { +void radio_powerOn_at86rf215(void) { volatile uint32_t delay; GPIOPinTypeGPIOOutput(GPIO_C_BASE, GPIO_PIN_0); @@ -84,32 +82,31 @@ void radio_powerOn(void) { } -void radio_reset(void) { +void radio_reset_at86rf215(void) { at86rf215_spiWriteReg( RG_RF_RST, CMD_RF_RESET); } -void radio_init(void) { - - uint16_t i; +void radio_init_at86rf215(void) { + //power it on and configure pins - radio_powerOn(); + radio_powerOn_at86rf215(); spi_init(); // clear variables - memset(&radio_vars,0,sizeof(radio_vars_t)); + memset(&radio_vars_at86rf215,0,sizeof(radio_vars_at86rf215_t)); // change state - radio_vars.state = RADIOSTATE_STOPPED; + radio_vars_at86rf215.state = RADIOSTATE_STOPPED; // reset radio - radio_reset(); + radio_reset_at86rf215(); at86rf215_spiStrobe(CMD_RF_TRXOFF, ATMEL_FREQUENCY_TYPE); while(at86rf215_status(ATMEL_FREQUENCY_TYPE) != RF_STATE_TRXOFF); // change state - radio_vars.state = RADIOSTATE_RFOFF; + radio_vars_at86rf215.state = RADIOSTATE_RFOFF; //configure external radio interrupt in pin D0 GPIOPinIntDisable(AT86RF215_IRQ_BASE, AT86RF215_IRQ_PIN); @@ -121,7 +118,7 @@ void radio_init(void) { GPIOPinIntClear(AT86RF215_IRQ_BASE, AT86RF215_IRQ_PIN); /* Register the interrupt */ - GPIOPortIntRegister(AT86RF215_IRQ_BASE, radio_isr); + GPIOPortIntRegister(AT86RF215_IRQ_BASE, radio_isr_internal_at86rf215); /* Clear and enable the interrupt */ GPIOPinIntEnable(AT86RF215_IRQ_BASE, AT86RF215_IRQ_PIN); @@ -130,28 +127,37 @@ void radio_init(void) { if ((at86rf215_spiReadReg(RG_RF_PN) != 0x34) | (at86rf215_spiReadReg(RG_RF_VN) != 0x03)) { while(1); //UNKNOWN DEVICE, FINISH } - // Write registers to radio -- configuration 2-FSK-50kbps - if (ATMEL_FREQUENCY_TYPE==FREQ_SUGHZ){ - for( i = 0; i < (sizeof(basic_settings_fsk_option1)/sizeof(registerSetting_t)); i++) { - at86rf215_spiWriteReg( basic_settings_fsk_option1[i].addr, basic_settings_fsk_option1[i].data); - }; - } else { - for( i = 0; i < (sizeof(basic_settings_oqpsk_250kbps)/sizeof(registerSetting_t)); i++) { - at86rf215_spiWriteReg( basic_settings_oqpsk_250kbps[i].addr, basic_settings_oqpsk_250kbps[i].data); - }; - } - - - radio_read_isr(); + + //Initialize the lookup table for register configurations + + radio_local_bootstrap_at86rf215(); + + // select the radio configuration to use -- configuration 2-FSK-50kbps + radio_setConfig_at86rf215 (RADIOSETTING_FSK_OPTION1_FEC); + radio_read_isr_at86rf215(); } -void radio_change_size(uint16_t* size){ +void radio_change_size_at86rf215(uint16_t* size){ static int i = 0; *size = sizes[i%4]; i++; } -void radio_change_modulation(registerSetting_t * mod){ +// This function accepts one of the existing radio presets and writes them to the radio chip. +void radio_setConfig_at86rf215(radioSetting_t radioSetting){ + uint16_t _register; + + at86rf215_spiStrobe(CMD_RF_TRXOFF, ATMEL_FREQUENCY_TYPE); + while(at86rf215_status(ATMEL_FREQUENCY_TYPE) != RF_STATE_TRXOFF); + + for( _register = 0; _register < radio_api.size[radioSetting]; _register++) { + at86rf215_spiWriteReg(radio_api.radios[radioSetting][_register].addr, radio_api.radios[radioSetting][_register].data); + }; + radio_read_isr_at86rf215(); +} + +// This function writes a specific set of register values to customize the configuration of the radio chip +void radio_change_modulation_at86rf215(registerSetting_t * mod){ static int mod_list = 1; uint16_t i; @@ -161,23 +167,23 @@ void radio_change_modulation(registerSetting_t * mod){ for( i = 0; i < (sizeof(*mod)/sizeof(registerSetting_t)); i++) { at86rf215_spiWriteReg( mod[i].addr, mod[i].data); }; - radio_read_isr(); + radio_read_isr_at86rf215(); mod_list++; } -void radio_setStartFrameCb(radio_capture_cbt cb) { - radio_vars.startFrame_cb = cb; +void radio_setStartFrameCb_at86rf215(radio_capture_cbt cb) { + radio_vars_at86rf215.startFrame_cb = cb; } -void radio_setEndFrameCb(radio_capture_cbt cb) { - radio_vars.endFrame_cb = cb; +void radio_setEndFrameCb_at86rf215(radio_capture_cbt cb) { + radio_vars_at86rf215.endFrame_cb = cb; } //===== RF admin //channel spacing in KHz //frequency_0 in kHz //frequency_nb integer -void radio_setFrequency(uint16_t channel, radio_freq_t tx_or_rx) { +void radio_setFrequency_at86rf215(uint16_t channel, radio_freq_t tx_or_rx) { uint16_t frequency_0; @@ -203,19 +209,19 @@ void radio_setFrequency(uint16_t channel, radio_freq_t tx_or_rx) { } // change state - radio_vars.state = RADIOSTATE_FREQUENCY_SET; + radio_vars_at86rf215.state = RADIOSTATE_FREQUENCY_SET; } -void radio_rfOn(void) { +void radio_rfOn_at86rf215(void) { //put the radio in the TRXPREP state at86rf215_spiStrobe(CMD_RF_TRXOFF, ATMEL_FREQUENCY_TYPE); while(at86rf215_status(ATMEL_FREQUENCY_TYPE) != RF_STATE_TRXOFF); } -void radio_rfOff(void) { +void radio_rfOff_at86rf215(void) { // change state - radio_vars.state = RADIOSTATE_TURNING_OFF; + radio_vars_at86rf215.state = RADIOSTATE_TURNING_OFF; at86rf215_spiStrobe(CMD_RF_TRXOFF, ATMEL_FREQUENCY_TYPE); while(at86rf215_status(ATMEL_FREQUENCY_TYPE) != RF_STATE_TRXOFF); @@ -224,10 +230,10 @@ void radio_rfOff(void) { leds_radio_off(); // change state - radio_vars.state = RADIOSTATE_RFOFF; + radio_vars_at86rf215.state = RADIOSTATE_RFOFF; } -int8_t radio_getFrequencyOffset(void){ +int8_t radio_getFrequencyOffset_at86rf215(void){ // not available return 0; @@ -235,23 +241,23 @@ int8_t radio_getFrequencyOffset(void){ //===== TX -void radio_loadPacket(uint8_t* packet, uint16_t len) { +void radio_loadPacket_at86rf215(uint8_t* packet, uint16_t len) { - radio_vars.state = RADIOSTATE_LOADING_PACKET; + radio_vars_at86rf215.state = RADIOSTATE_LOADING_PACKET; at86rf215_spiWriteFifo(packet, len, ATMEL_FREQUENCY_TYPE); // change state - radio_vars.state = RADIOSTATE_PACKET_LOADED; + radio_vars_at86rf215.state = RADIOSTATE_PACKET_LOADED; //at86rf215_readBurst(0x0306, packet, len); } -radio_state_t radio_getState(void){ - return radio_vars.state; +radio_state_t radio_getState_at86rf215(void){ + return radio_vars_at86rf215.state; } -void radio_txEnable(void) { +void radio_txEnable_at86rf215(void) { // change state - radio_vars.state = RADIOSTATE_ENABLING_TX; + radio_vars_at86rf215.state = RADIOSTATE_ENABLING_TX; at86rf215_spiStrobe(CMD_RF_TXPREP, ATMEL_FREQUENCY_TYPE); while(at86rf215_status(ATMEL_FREQUENCY_TYPE) != RF_STATE_TXPREP); @@ -260,41 +266,41 @@ void radio_txEnable(void) { debugpins_radio_set(); leds_radio_on(); - radio_vars.state = RADIOSTATE_TX_ENABLED; + radio_vars_at86rf215.state = RADIOSTATE_TX_ENABLED; } -void radio_txNow(void) { +void radio_txNow_at86rf215(void) { PORT_TIMER_WIDTH capturedTime; // change state - radio_vars.state = RADIOSTATE_TRANSMITTING; + radio_vars_at86rf215.state = RADIOSTATE_TRANSMITTING; at86rf215_spiStrobe(CMD_RF_TX, ATMEL_FREQUENCY_TYPE); - if (radio_vars.startFrame_cb!=NULL) { + if (radio_vars_at86rf215.startFrame_cb!=NULL) { // capture the time capturedTime = sctimer_readCounter(); // call the callback - radio_vars.startFrame_cb(capturedTime); + radio_vars_at86rf215.startFrame_cb(capturedTime); } } //===== RX -void radio_rxEnable(void) { +void radio_rxEnable_at86rf215(void) { // change state - radio_vars.state = RADIOSTATE_ENABLING_RX; + radio_vars_at86rf215.state = RADIOSTATE_ENABLING_RX; // wiggle debug pin debugpins_radio_set(); leds_radio_on(); at86rf215_spiStrobe(CMD_RF_RX, ATMEL_FREQUENCY_TYPE); // change state - radio_vars.state = RADIOSTATE_LISTENING; + radio_vars_at86rf215.state = RADIOSTATE_LISTENING; } -void radio_rxNow(void) { +void radio_rxNow_at86rf215(void) { //nothing to do if(at86rf215_status(ATMEL_FREQUENCY_TYPE) != RF_STATE_RX){ leds_error_toggle(); @@ -302,10 +308,10 @@ void radio_rxNow(void) { } } -void radio_getReceivedFrame( +void radio_getReceivedFrame_at86rf215( uint8_t* bufRead, - uint16_t* lenRead, - uint16_t maxBufLen, + uint8_t* lenRead, + uint8_t maxBufLen, int8_t* rssi, uint8_t* lqi, bool* crc @@ -324,7 +330,7 @@ void radio_getReceivedFrame( } // read the received packet from the RXFIFO - at86rf215_spiReadRxFifo(bufRead, lenRead, ATMEL_FREQUENCY_TYPE, maxBufLen); + at86rf215_spiReadRxFifo(bufRead, (uint16_t*)lenRead, ATMEL_FREQUENCY_TYPE, maxBufLen); *rssi = at86rf215_spiReadReg(register_edv); *crc = (at86rf215_spiReadReg(register_bbc_pc)>>5); @@ -332,23 +338,48 @@ void radio_getReceivedFrame( //=========================== private ========================================= -void radio_read_isr(void){ +//This function creates a matrix of register configurations of each modulation supported by the readio chip. It is used for dynamic modulation change inside the chip. +void radio_local_bootstrap_at86rf215(void){ + + radio_api.radios [RADIOSETTING_FSK_OPTION1_FEC] = basic_settings_fsk_option1; + radio_api.radios [RADIOSETTING_OQPSK_RATE3] = basic_settings_oqpsk_rate3; + radio_api.radios [RADIOSETTING_OFDM_OPTION_1_MCS0] = basic_settings_ofdm_1_mcs0; + radio_api.radios [RADIOSETTING_OFDM_OPTION_1_MCS1] = basic_settings_ofdm_1_mcs1; + radio_api.radios [RADIOSETTING_OFDM_OPTION_1_MCS2] = basic_settings_ofdm_1_mcs2; + radio_api.radios [RADIOSETTING_OFDM_OPTION_1_MCS3] = basic_settings_ofdm_1_mcs3; + + radio_api.size [RADIOSETTING_FSK_OPTION1_FEC] = sizeof(basic_settings_fsk_option1)/sizeof(registerSetting_t); + radio_api.size [RADIOSETTING_OQPSK_RATE3] = sizeof(basic_settings_oqpsk_rate3)/sizeof(registerSetting_t); + radio_api.size [RADIOSETTING_OFDM_OPTION_1_MCS0] = sizeof(basic_settings_ofdm_1_mcs0)/sizeof(registerSetting_t); + radio_api.size [RADIOSETTING_OFDM_OPTION_1_MCS1] = sizeof(basic_settings_ofdm_1_mcs1)/sizeof(registerSetting_t); + radio_api.size [RADIOSETTING_OFDM_OPTION_1_MCS2] = sizeof(basic_settings_ofdm_1_mcs2)/sizeof(registerSetting_t); + radio_api.size [RADIOSETTING_OFDM_OPTION_1_MCS3] = sizeof(basic_settings_ofdm_1_mcs3)/sizeof(registerSetting_t); +} +void radio_read_isr_at86rf215(void){ uint8_t flags[4]; at86rf215_read_isr(flags, ATMEL_FREQUENCY_TYPE); - radio_vars.rf09_isr = flags[0]; - radio_vars.rf24_isr = flags[1]; - radio_vars.bb0_isr = flags[2]; - radio_vars.bb1_isr = flags[3]; + radio_vars_at86rf215.rf09_isr = flags[0]; + radio_vars_at86rf215.rf24_isr = flags[1]; + radio_vars_at86rf215.bb0_isr = flags[2]; + radio_vars_at86rf215.bb1_isr = flags[3]; } + //=========================== callbacks ======================================= //=========================== interrupt handlers ============================== -void radio_isr(void) { + +// Wrapper function for radio_isr_at86rf215 to be called by the radio interrupt +void radio_isr_internal_at86rf215(void) { + + kick_scheduler_t ks = radio_isr_at86rf215(); + +} +kick_scheduler_t radio_isr_at86rf215(void) { PORT_TIMER_WIDTH capturedTime; - // kick_scheduler_t result = DO_NOT_KICK_SCHEDULER; + kick_scheduler_t result = DO_NOT_KICK_SCHEDULER; debugpins_isr_set(); @@ -357,50 +388,52 @@ void radio_isr(void) { // capture the time capturedTime = sctimer_readCounter(); //get isr that happened from radio - radio_read_isr(); + radio_read_isr_at86rf215(); - if (radio_vars.bb0_isr & IRQS_RXFS_MASK){ - radio_vars.state = RADIOSTATE_RECEIVING; - if (radio_vars.startFrame_cb!=NULL) { + if (radio_vars_at86rf215.bb0_isr & IRQS_RXFS_MASK){ + radio_vars_at86rf215.state = RADIOSTATE_RECEIVING; + if (radio_vars_at86rf215.startFrame_cb!=NULL) { // call the callback - radio_vars.startFrame_cb(capturedTime); + radio_vars_at86rf215.startFrame_cb(capturedTime); // kick the OS - // result = KICK_SCHEDULER; + result = KICK_SCHEDULER; } else { //while(1); } } else { - if ((radio_vars.bb0_isr & IRQS_TXFE_MASK)){ - radio_vars.state = RADIOSTATE_TXRX_DONE; - if (radio_vars.endFrame_cb!=NULL) { + if ((radio_vars_at86rf215.bb0_isr & IRQS_TXFE_MASK)){ + radio_vars_at86rf215.state = RADIOSTATE_TXRX_DONE; + if (radio_vars_at86rf215.endFrame_cb!=NULL) { // call the callback - radio_vars.endFrame_cb(capturedTime); + radio_vars_at86rf215.endFrame_cb(capturedTime); // kick the OS - // result = KICK_SCHEDULER; + result = KICK_SCHEDULER; } else { //while(1); } } else { - if ((radio_vars.bb0_isr & IRQS_RXFE_MASK)){ - radio_vars.state = RADIOSTATE_TXRX_DONE; - if (radio_vars.endFrame_cb!=NULL) { + if ((radio_vars_at86rf215.bb0_isr & IRQS_RXFE_MASK)){ + radio_vars_at86rf215.state = RADIOSTATE_TXRX_DONE; + if (radio_vars_at86rf215.endFrame_cb!=NULL) { // call the callback - radio_vars.endFrame_cb(capturedTime); + radio_vars_at86rf215.endFrame_cb(capturedTime); + // kick the OS - //result = KICK_SCHEDULER; + result = KICK_SCHEDULER; } else { // while(1); } } } } - radio_clear_isr(); + radio_clear_isr_at86rf215(); debugpins_isr_clr(); + return result; } -port_INLINE void radio_clear_isr(){ - radio_vars.rf09_isr = 0; - radio_vars.rf24_isr = 0; - radio_vars.bb0_isr = 0; - radio_vars.bb1_isr = 0; +port_INLINE void radio_clear_isr_at86rf215(){ + radio_vars_at86rf215.rf09_isr = 0; + radio_vars_at86rf215.rf24_isr = 0; + radio_vars_at86rf215.bb0_isr = 0; + radio_vars_at86rf215.bb1_isr = 0; } diff --git a/bsp/chips/at86rf215/radio_at86rf215.h b/bsp/chips/at86rf215/radio_at86rf215.h new file mode 100644 index 0000000000..96e462f788 --- /dev/null +++ b/bsp/chips/at86rf215/radio_at86rf215.h @@ -0,0 +1,96 @@ +#ifndef __RADIO_AT86RF215_H +#define __RADIO_AT86RF215_H + +/** +\addtogroup BSP +\{ +\addtogroup radio +\{ + +\brief Cross-platform declaration "radio" bsp module. + +\author Thomas Watteyne , February 2012. +*/ + +/* +\modifications to implement the IEEE 802.15.4-SUN +\done by Jonathan Munoz +*/ + +#include "radio.h" +#include "at86rf215.h" + +//=========================== define ========================================== + +// Number of modulations available on this radio chip. This is different from MAC_RADIOS which is for all the board and defined in board_info.h +#define MAX_MODULATIONS 6 + +//=========================== typedef ========================================= + + +typedef struct { + radio_capture_cbt startFrame_cb; + radio_capture_cbt endFrame_cb; + radio_state_t state; + uint8_t rf09_isr; + uint8_t rf24_isr; + uint8_t bb0_isr; + uint8_t bb1_isr; +} radio_vars_at86rf215_t; + + + + +// open radio register mapping: an array of pointers to registersettings arrays + +typedef struct { + registerSetting_t * radios [MAX_MODULATIONS]; + size_t size [MAX_MODULATIONS]; +} radio_config_t; + + +//=========================== variables ======================================= + +//=========================== prototypes ====================================== + +// admin +void radio_powerOn_at86rf215(void); +void radio_init_at86rf215(void); +void radio_setStartFrameCb_at86rf215(radio_capture_cbt cb); +void radio_setEndFrameCb_at86rf215(radio_capture_cbt cb); +// reset +void radio_reset_at86rf215(void); +// RF admin +void radio_setFrequency_at86rf215(uint16_t channel, radio_freq_t tx_or_rx); +int8_t radio_getFrequencyOffset_at86rf215(void); +void radio_rfOn_at86rf215(void); +void radio_rfOff_at86rf215(void); +void radio_setConfig_at86rf215 (radioSetting_t radioSetting); +void radio_change_modulation_at86rf215(registerSetting_t * mod); +void radio_change_size_at86rf215(uint16_t* size); +// TX +void radio_loadPacket_at86rf215(uint8_t* packet, uint16_t len); +radio_state_t radio_getState_at86rf215(void); +void radio_txEnable_at86rf215(void); +void radio_txNow_at86rf215(void); +// RX +void radio_rxEnable_at86rf215(void); +void radio_rxNow_at86rf215(void); +void radio_getReceivedFrame_at86rf215(uint8_t* bufRead, + uint8_t* lenRead, + uint8_t maxBufLen, + int8_t* rssi, + uint8_t* lqi, + bool* crc); + +// interrupt handlers +kick_scheduler_t radio_isr_at86rf215(void); +// private +void radio_isr_internal_at86rf215(void); +void radio_local_bootstrap_at86rf215(void); +/** +\} +\} +*/ + +#endif diff --git a/bsp/chips/at86rf231/radio.c b/bsp/chips/at86rf231/radio.c index a5792ab6f6..e7428b37a7 100644 --- a/bsp/chips/at86rf231/radio.c +++ b/bsp/chips/at86rf231/radio.c @@ -25,6 +25,9 @@ typedef struct { radio_vars_t radio_vars; +// global radio selection. +uint8_t selected_radioSetting = RADIOSETTING_24GHZ; + //=========================== prototypes ====================================== void radio_spiWriteReg(uint8_t reg_addr, uint8_t reg_setting); @@ -86,12 +89,16 @@ void radio_reset(void) { //===== RF admin -void radio_setFrequency(uint8_t frequency, radio_freq_t tx_or_rx) { +void radio_setConfig (radioSetting_t radioSetting){ + selected_radioSetting = radioSetting; + //do nothing +} +void radio_setFrequency(uint16_t frequency, radio_freq_t tx_or_rx) { // change state radio_vars.state = RADIOSTATE_SETTING_FREQUENCY; // configure the radio to the right frequecy - radio_spiWriteReg(RG_PHY_CC_CCA,0x20+frequency); + radio_spiWriteReg(RG_PHY_CC_CCA,0x20+ frequency); // change state radio_vars.state = RADIOSTATE_FREQUENCY_SET; diff --git a/bsp/chips/cc2538rf/SConscript b/bsp/chips/cc2538rf/SConscript new file mode 100644 index 0000000000..cfbcf68cfb --- /dev/null +++ b/bsp/chips/cc2538rf/SConscript @@ -0,0 +1,13 @@ +# chip support sconscripts are expected to return a list of objects, so +# that they can be included in a board bsp library. This allows the board +# to include the chip support without knowing exactly what the filenames +# are or where they live. + +Import('env') + +localEnv = env.Clone() + +source = ['radio_cc2538rf.c'] +cc2538rf = localEnv.Object(source=source) + +Return('cc2538rf') \ No newline at end of file diff --git a/bsp/chips/cc2538rf/radio_cc2538rf.c b/bsp/chips/cc2538rf/radio_cc2538rf.c new file mode 100644 index 0000000000..fa113c2680 --- /dev/null +++ b/bsp/chips/cc2538rf/radio_cc2538rf.c @@ -0,0 +1,539 @@ +/** + * Author: Xavier Vilajosana (xvilajosana@eecs.berkeley.edu) + * Pere Tuset (peretuset@openmote.com) + * Date: July 2013 + * Description: CC2538-specific definition of the "radio" bsp module. + */ + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "board.h" +#include "debugpins.h" +#include "leds.h" +#include "radio_cc2538rf.h" +#include "radio.h" +#include "sctimer.h" + +//=========================== defines ========================================= + +/* Bit Masks for the last byte in the RX FIFO */ +#define CRC_BIT_MASK 0x80 +#define LQI_BIT_MASK 0x7F + +/* RSSI Offset */ +#define RSSI_OFFSET 73 +#define CHECKSUM_LEN 2 + +//=========================== variables ======================================= + + +radio_vars_cc2538rf_t radio_vars_cc2538rf; + +//=========================== prototypes ====================================== + +void enable_radio_interrupts(void); +void disable_radio_interrupts(void); + +void radio_on(void); +void radio_off(void); + +void radio_error_isr_cc2538rf(void); +void radio_isr_internal_cc2538rf(void); + +//=========================== public ========================================== + +//===== admin + +void radio_init_cc2538rf(void) { + + // clear variables + memset(&radio_vars_cc2538rf,0,sizeof(radio_vars_cc2538rf_t)); + + // change state + radio_vars_cc2538rf.state = RADIOSTATE_STOPPED; + //flush fifos + CC2538_RF_CSP_ISFLUSHRX(); + CC2538_RF_CSP_ISFLUSHTX(); + + radio_off(); + + //disable radio interrupts + disable_radio_interrupts(); + + /* + This CORR_THR value should be changed to 0x14 before attempting RX. Testing has shown that + too many false frames are received if the reset value is used. Make it more likely to detect + sync by removing the requirement that both symbols in the SFD must have a correlation value + above the correlation threshold, and make sync word detection less likely by raising the + correlation threshold. + */ + HWREG(RFCORE_XREG_MDMCTRL1) = 0x14; + /* tuning adjustments for optimal radio performance; details available in datasheet */ + + HWREG(RFCORE_XREG_RXCTRL) = 0x3F; + /* Adjust current in synthesizer; details available in datasheet. */ + HWREG(RFCORE_XREG_FSCTRL) = 0x55; + + /* Makes sync word detection less likely by requiring two zero symbols before the sync word. + * details available in datasheet. + */ + HWREG(RFCORE_XREG_MDMCTRL0) = 0x85; + + /* Adjust current in VCO; details available in datasheet. */ + HWREG(RFCORE_XREG_FSCAL1) = 0x01; + /* Adjust target value for AGC control loop; details available in datasheet. */ + HWREG(RFCORE_XREG_AGCCTRL1) = 0x15; + + /* Tune ADC performance, details available in datasheet. */ + HWREG(RFCORE_XREG_ADCTEST0) = 0x10; + HWREG(RFCORE_XREG_ADCTEST1) = 0x0E; + HWREG(RFCORE_XREG_ADCTEST2) = 0x03; + + //update CCA register to -81db as indicated by manual.. won't be used.. + HWREG(RFCORE_XREG_CCACTRL0) = 0xF8; + /* + * Changes from default values + * See User Guide, section "Register Settings Update" + */ + HWREG(RFCORE_XREG_TXFILTCFG) = 0x09; /** TX anti-aliasing filter bandwidth */ + HWREG(RFCORE_XREG_AGCCTRL1) = 0x15; /** AGC target value */ + HWREG(ANA_REGS_O_IVCTRL) = 0x0B; /** Bias currents */ + + /* disable the CSPT register compare function */ + HWREG(RFCORE_XREG_CSPT) = 0xFFUL; + /* + * Defaults: + * Auto CRC; Append RSSI, CRC-OK and Corr. Val.; CRC calculation; + * RX and TX modes with FIFOs + */ + HWREG(RFCORE_XREG_FRMCTRL0) = RFCORE_XREG_FRMCTRL0_AUTOCRC; + + //poipoi disable frame filtering by now.. sniffer mode. + HWREG(RFCORE_XREG_FRMFILT0) &= ~RFCORE_XREG_FRMFILT0_FRAME_FILTER_EN; + + /* Disable source address matching and autopend */ + HWREG(RFCORE_XREG_SRCMATCH) = 0; + + /* MAX FIFOP threshold */ + HWREG(RFCORE_XREG_FIFOPCTRL) = CC2538_RF_MAX_PACKET_LEN; + + HWREG(RFCORE_XREG_TXPOWER) = CC2538_RF_TX_POWER; + HWREG(RFCORE_XREG_FREQCTRL) = CC2538_RF_CHANNEL_MIN; + + /* Enable RF interrupts see page 751 */ + // enable_radio_interrupts(); + + //register interrupt + IntRegister(INT_RFCORERTX, radio_isr_internal_cc2538rf); + IntRegister(INT_RFCOREERR, radio_error_isr_cc2538rf); + + IntEnable(INT_RFCORERTX); + + /* Enable all RF Error interrupts */ + HWREG(RFCORE_XREG_RFERRM) = RFCORE_XREG_RFERRM_RFERRM_M; //all errors + IntEnable(INT_RFCOREERR); + //radio_on(); + + // change state + radio_vars_cc2538rf.state = RADIOSTATE_RFOFF; +} + +void radio_setStartFrameCb_cc2538rf(radio_capture_cbt cb) { + radio_vars_cc2538rf.startFrame_cb = cb; +} + +void radio_setEndFrameCb_cc2538rf(radio_capture_cbt cb) { + radio_vars_cc2538rf.endFrame_cb = cb; +} + +//===== reset + +void radio_reset_cc2538rf(void) { + /* Wait for ongoing TX to complete (e.g. this could be an outgoing ACK) */ + while(HWREG(RFCORE_XREG_FSMSTAT1) & RFCORE_XREG_FSMSTAT1_TX_ACTIVE); + + //flush fifos + CC2538_RF_CSP_ISFLUSHRX(); + CC2538_RF_CSP_ISFLUSHTX(); + + /* Don't turn off if we are off as this will trigger a Strobe Error */ + if(HWREG(RFCORE_XREG_RXENABLE) != 0) { + CC2538_RF_CSP_ISRFOFF(); + } + radio_init(); +} + +//===== RF admin + +void radio_setFrequency_cc2538rf(uint16_t frequency, radio_freq_t tx_or_rx) { + + // change state + radio_vars_cc2538rf.state = RADIOSTATE_SETTING_FREQUENCY; + + radio_off(); + // configure the radio to the right frequecy + if((frequency < CC2538_RF_CHANNEL_MIN) || (frequency > CC2538_RF_CHANNEL_MAX)) { + while(1); + } + + /* Changes to FREQCTRL take effect after the next recalibration */ + HWREG(RFCORE_XREG_FREQCTRL) = (CC2538_RF_CHANNEL_MIN + + (frequency - CC2538_RF_CHANNEL_MIN) * CC2538_RF_CHANNEL_SPACING); + + //radio_on(); + + // change state + radio_vars_cc2538rf.state = RADIOSTATE_FREQUENCY_SET; +} + +void radio_setConfig_cc2538rf(radioSetting_t radioSetting){ + // do nothing +} + +void radio_rfOn_cc2538rf(void) { + //radio_on(); +} + +void radio_rfOff_cc2538rf(void) { + + // change state + radio_vars_cc2538rf.state = RADIOSTATE_TURNING_OFF; + radio_off(); + // wiggle debug pin + debugpins_radio_clr(); + leds_radio_off(); + //enable radio interrupts + disable_radio_interrupts(); + + // change state + radio_vars_cc2538rf.state = RADIOSTATE_RFOFF; +} + +int8_t radio_getFrequencyOffset_cc2538rf(void){ + + int8_t freq_offset; + + freq_offset = HWREG(RFCORE_XREG_FREQEST); + + return freq_offset; +} + +//===== TX + +void radio_loadPacket_cc2538rf(uint8_t* packet, uint16_t len) { + uint8_t i=0; + + // change state + radio_vars_cc2538rf.state = RADIOSTATE_LOADING_PACKET; + + // load packet in TXFIFO + /* + When we transmit in very quick bursts, make sure previous transmission + is not still in progress before re-writing to the TX FIFO + */ + while(HWREG(RFCORE_XREG_FSMSTAT1) & RFCORE_XREG_FSMSTAT1_TX_ACTIVE); + + CC2538_RF_CSP_ISFLUSHTX(); + + /* Send the phy length byte first */ + HWREG(RFCORE_SFR_RFDATA) = len; //crc len is included + + for(i = 0; i < len; i++) { + HWREG(RFCORE_SFR_RFDATA) = packet[i]; + } + + // change state + radio_vars_cc2538rf.state = RADIOSTATE_PACKET_LOADED; +} + +void radio_txEnable_cc2538rf(void) { + + // change state + radio_vars_cc2538rf.state = RADIOSTATE_ENABLING_TX; + + // wiggle debug pin + debugpins_radio_set(); + leds_radio_on(); + + //do nothing -- radio is activated by the strobe on rx or tx + //radio_rfOn(); + + // change state + radio_vars_cc2538rf.state = RADIOSTATE_TX_ENABLED; +} + +void radio_txNow_cc2538rf(void) { + PORT_TIMER_WIDTH count; + + // change state + radio_vars_cc2538rf.state = RADIOSTATE_TRANSMITTING; + + //enable radio interrupts + enable_radio_interrupts(); + + //make sure we are not transmitting already + while(HWREG(RFCORE_XREG_FSMSTAT1) & RFCORE_XREG_FSMSTAT1_TX_ACTIVE); + + // send packet by STON strobe see pag 669 + + CC2538_RF_CSP_ISTXON(); + //wait 192uS + count=0; + while(!((HWREG(RFCORE_XREG_FSMSTAT1) & RFCORE_XREG_FSMSTAT1_TX_ACTIVE))){ + count++; //debug + } +} + +//===== RX + +void radio_rxEnable_cc2538rf(void) { + + // change state + radio_vars_cc2538rf.state = RADIOSTATE_ENABLING_RX; + + //enable radio interrupts + + // do nothing as we do not want to receive anything yet. + // wiggle debug pin + debugpins_radio_set(); + leds_radio_on(); + + // change state + radio_vars_cc2538rf.state = RADIOSTATE_LISTENING; +} + +void radio_rxNow_cc2538rf(void) { + //empty buffer before receiving + //CC2538_RF_CSP_ISFLUSHRX(); + + //enable radio interrupts + CC2538_RF_CSP_ISFLUSHRX(); + enable_radio_interrupts(); + + CC2538_RF_CSP_ISRXON(); + // busy wait until radio really listening + while(!((HWREG(RFCORE_XREG_FSMSTAT1) & RFCORE_XREG_FSMSTAT1_RX_ACTIVE))); +} + +void radio_getReceivedFrame_cc2538rf(uint8_t* pBufRead, + uint8_t* pLenRead, + uint8_t maxBufLen, + int8_t* pRssi, + uint8_t* pLqi, + bool* pCrc) { + uint8_t crc_corr,i; + + uint8_t len=0; + + /* Check the length */ + len = HWREG(RFCORE_SFR_RFDATA); //first byte is len + + + /* Check for validity */ + if(len > CC2538_RF_MAX_PACKET_LEN) { + /* wrong len */ + CC2538_RF_CSP_ISFLUSHRX(); + return; + } + + + if(len < CC2538_RF_MIN_PACKET_LEN) { + //too short + CC2538_RF_CSP_ISFLUSHRX(); + return; + } + + //check if this fits to the buffer + if(len > maxBufLen) { + CC2538_RF_CSP_ISFLUSHRX(); + return; + } + + // when reading the packet from the RX buffer, you get the following: + // - *[1B] length byte + // - [0-125B] packet (excluding CRC) + // - [1B] RSSI + // - *[2B] CRC + + //skip first byte is len + for(i = 0; i < len - 2; i++) { + pBufRead[i] = HWREG(RFCORE_SFR_RFDATA); + } + + *pRssi = ((int8_t)(HWREG(RFCORE_SFR_RFDATA)) - RSSI_OFFSET); + crc_corr = HWREG(RFCORE_SFR_RFDATA); + *pCrc = crc_corr & CRC_BIT_MASK; + *pLenRead = len; + + //flush it + CC2538_RF_CSP_ISFLUSHRX(); +} + +//=========================== private ========================================= + +void enable_radio_interrupts(void){ + /* Enable RF interrupts 0, RXPKTDONE,SFD,FIFOP only -- see page 751 */ + HWREG(RFCORE_XREG_RFIRQM0) |= ((0x06|0x02|0x01) << RFCORE_XREG_RFIRQM0_RFIRQM_S) & RFCORE_XREG_RFIRQM0_RFIRQM_M; + + /* Enable RF interrupts 1, TXDONE only */ + HWREG(RFCORE_XREG_RFIRQM1) |= ((0x02) << RFCORE_XREG_RFIRQM1_RFIRQM_S) & RFCORE_XREG_RFIRQM1_RFIRQM_M; +} + +void disable_radio_interrupts(void){ + /* Enable RF interrupts 0, RXPKTDONE,SFD,FIFOP only -- see page 751 */ + HWREG(RFCORE_XREG_RFIRQM0) = 0; + /* Enable RF interrupts 1, TXDONE only */ + HWREG(RFCORE_XREG_RFIRQM1) = 0; +} + +void radio_on(void){ + // CC2538_RF_CSP_ISFLUSHRX(); + CC2538_RF_CSP_ISRXON(); +} + +void radio_off(void){ + /* Wait for ongoing TX to complete (e.g. this could be an outgoing ACK) */ + while(HWREG(RFCORE_XREG_FSMSTAT1) & RFCORE_XREG_FSMSTAT1_TX_ACTIVE); + //CC2538_RF_CSP_ISFLUSHRX(); + + /* Don't turn off if we are off as this will trigger a Strobe Error */ + if(HWREG(RFCORE_XREG_RXENABLE) != 0) { + CC2538_RF_CSP_ISRFOFF(); + //clear fifo isr flag + HWREG(RFCORE_SFR_RFIRQF0) = ~(RFCORE_SFR_RFIRQF0_FIFOP|RFCORE_SFR_RFIRQF0_RXPKTDONE); + } +} + +//=========================== callbacks ======================================= + +//=========================== interrupt handlers ============================== + +/** +\brief Stub function for the CC2538. + +In MSP430 platforms the CPU status after servicing an interrupt can be managed +toggling some bits in a special register, e.g. CPUOFF, LPM1, etc, within the +interrupt context itself. By default, after servicing an interrupt the CPU will +be off so it makes sense to return a value and enable it if something has +happened that needs the scheduler to run (a packet has been received that needs +to be processed). Otherwise, the CPU is kept in sleep mode without even +reaching the main loop. + +In the CC2538, however, the default behaviour is the contrary. After servicing +an interrupt the CPU will be on by default and it is the responsability of the +main thread to put it back to sleep (which is already done). This means that +the scheduler will always be kicked in after servicing an interrupt. This +behaviour can be changed by modifying the SLEEPEXIT field in the SYSCTRL +regiser (see page 131 of the CC2538 manual). +*/ +kick_scheduler_t radio_isr_cc2538rf(void) { + return DO_NOT_KICK_SCHEDULER; +} + +void radio_isr_internal_cc2538rf(void) { + volatile PORT_TIMER_WIDTH capturedTime; + uint8_t irq_status0,irq_status1; + + debugpins_isr_set(); + + // capture the time + capturedTime = sctimer_readCounter(); + + // reading IRQ_STATUS + irq_status0 = HWREG(RFCORE_SFR_RFIRQF0); + irq_status1 = HWREG(RFCORE_SFR_RFIRQF1); + + IntPendClear(INT_RFCORERTX); + + //clear interrupt + HWREG(RFCORE_SFR_RFIRQF0) = 0; + HWREG(RFCORE_SFR_RFIRQF1) = 0; + + //STATUS0 Register + // start of frame event + if ((irq_status0 & RFCORE_SFR_RFIRQF0_SFD) == RFCORE_SFR_RFIRQF0_SFD) { + // change state + radio_vars_cc2538rf.state = RADIOSTATE_RECEIVING; + if (radio_vars_cc2538rf.startFrame_cb!=NULL) { + // call the callback + radio_vars_cc2538rf.startFrame_cb(capturedTime); + debugpins_isr_clr(); + // kick the OS + return; + } else { + while(1); + } + } + + //or RXDONE is full -- we have a packet. + if (((irq_status0 & RFCORE_SFR_RFIRQF0_RXPKTDONE) == RFCORE_SFR_RFIRQF0_RXPKTDONE)) { + // change state + radio_vars_cc2538rf.state = RADIOSTATE_TXRX_DONE; + if (radio_vars_cc2538rf.endFrame_cb!=NULL) { + // call the callback + radio_vars_cc2538rf.endFrame_cb(capturedTime); + debugpins_isr_clr(); + // kick the OS + return; + } else { + while(1); + } + } + + // or FIFOP is full -- we have a packet. + if (((irq_status0 & RFCORE_SFR_RFIRQF0_FIFOP) == RFCORE_SFR_RFIRQF0_FIFOP)) { + // change state + radio_vars_cc2538rf.state = RADIOSTATE_TXRX_DONE; + if (radio_vars_cc2538rf.endFrame_cb!=NULL) { + // call the callback + radio_vars_cc2538rf.endFrame_cb(capturedTime); + debugpins_isr_clr(); + // kick the OS + return; + } else { + while(1); + } + } + + //STATUS1 Register + // end of frame event --either end of tx . + if (((irq_status1 & RFCORE_SFR_RFIRQF1_TXDONE) == RFCORE_SFR_RFIRQF1_TXDONE)) { + // change state + radio_vars_cc2538rf.state = RADIOSTATE_TXRX_DONE; + if (radio_vars_cc2538rf.endFrame_cb!=NULL) { + // call the callback + radio_vars_cc2538rf.endFrame_cb(capturedTime); + debugpins_isr_clr(); + // kick the OS + return; + } else { + while(1); + } + } + debugpins_isr_clr(); + + return; +} + +void radio_error_isr_cc2538rf(void){ + uint8_t rferrm; + + rferrm = (uint8_t)HWREG(RFCORE_XREG_RFERRM); + + if ((HWREG(RFCORE_XREG_RFERRM) & (((0x02)< #include - +#include "radio.h" /*--------------------------------------------------------------------------- * RF Config *---------------------------------------------------------------------------*/ /* Constants */ #define CC2538_RF_CCA_THRES_USER_GUIDE 0xF8 -#define CC2538_RF_TX_POWER_RECOMMENDED 0xD5 /* TODO: Check value */ -#define CC2538_RF_CHANNEL_MIN 11 //poipoi -- in fact is sending on 0x17 check that. +/** Tx Power register + dbm - value +{ 7, 0xFF }, +{ 5, 0xED }, +{ 3, 0xD5 }, +{ 1, 0xC5 }, +{ 0, 0xB6 }, +{ -1, 0xB0 }, +{ -3, 0xA1 }, +{ -5, 0x91 }, +{ -7, 0x88 }, +{ -9, 0x72 }, +{-11, 0x62 }, +{-13, 0x58 }, +{-15, 0x42 }, +{-24, 0x00 }, +*/ +#define CC2538_RF_TX_POWER_RECOMMENDED 0xFF // use 7dbm maxmium txpower +#define CC2538_RF_CHANNEL_MIN 11 // poipoi -- in fact is sending on 0x17 check that. #define CC2538_RF_CHANNEL_MAX 26 #define CC2538_RF_CHANNEL_SPACING 5 #define CC2538_RF_MAX_PACKET_LEN 127 #define CC2538_RF_MIN_PACKET_LEN 4 #define CC2538_RF_CCA_CLEAR 1 #define CC2538_RF_CCA_BUSY 0 + + + /*---------------------------------------------------------------------------*/ #ifdef CC2538_RF_CONF_TX_POWER #define CC2538_RF_TX_POWER CC2538_RF_CONF_TX_POWER @@ -88,6 +108,50 @@ HWREG(RFCORE_SFR_RFST) = CC2538_RF_CSP_OP_ISFLUSHTX; \ } while(0) /*---------------------------------------------------------------------------*/ +typedef struct { + radio_capture_cbt startFrame_cb; + radio_capture_cbt endFrame_cb; + radio_state_t state; +} radio_vars_cc2538rf_t; + +//=========================== variables ======================================= + +//=========================== prototypes ====================================== + +// admin +void radio_init_cc2538rf(void); +void radio_setStartFrameCb_cc2538rf(radio_capture_cbt cb); +void radio_setEndFrameCb_cc2538rf(radio_capture_cbt cb); +// reset +void radio_reset_cc2538rf(void); +// RF admin +void radio_setFrequency_cc2538rf(uint16_t channel, radio_freq_t tx_or_rx); +int8_t radio_getFrequencyOffset_cc2538rf(void); +void radio_rfOn_cc2538rf(void); +void radio_rfOff_cc2538rf(void); +void radio_setConfig_cc2538rf (radioSetting_t radioSetting); + +// TX +void radio_loadPacket_cc2538rf(uint8_t* packet, uint16_t len); +void radio_txEnable_cc2538rf(void); +void radio_txNow_cc2538rf(void); +// RX +void radio_rxEnable_cc2538rf(void); +void radio_rxNow_cc2538rf(void); +void radio_getReceivedFrame_cc2538rf(uint8_t* bufRead, + uint8_t* lenRead, + uint8_t maxBufLen, + int8_t* rssi, + uint8_t* lqi, + bool* crc); + +// interrupt handlers +kick_scheduler_t radio_isr_cc2538rf(void); + +/** +\} +\} +*/ -#endif /* CC2538RF_H_ */ +#endif /* RADIO_CC2538RF_H_ */ diff --git a/drivers/common/opentimers.c b/drivers/common/opentimers.c index 718b39a3a4..f502f21cd5 100644 --- a/drivers/common/opentimers.c +++ b/drivers/common/opentimers.c @@ -8,6 +8,7 @@ at most MAX_NUM_TIMERS timers. */ #include "opendefs.h" +#include "board.h" #include "opentimers.h" // some dsp modules are required #include "sctimer.h" diff --git a/drivers/common/opentimers.h b/drivers/common/opentimers.h index 763035e420..fdffaa6c32 100644 --- a/drivers/common/opentimers.h +++ b/drivers/common/opentimers.h @@ -8,7 +8,7 @@ #define __OPENTIMERS_H #include "opendefs.h" - +#include "board.h" /** \addtogroup drivers \{ @@ -32,7 +32,8 @@ #define TIMER_NUMBER_NON_GENERAL 2 #define SPLITE_TIMER_DURATION 15 // in ticks -#define PRE_CALL_TIMER_WINDOW PORT_TsSlotDuration + +#define PRE_CALL_TIMER_WINDOW board_getSlotDuration() typedef void (*opentimers_cbt)(opentimers_id_t id); diff --git a/inc/opendefs.h b/inc/opendefs.h index fbc0692da6..450a9368a0 100644 --- a/inc/opendefs.h +++ b/inc/opendefs.h @@ -36,7 +36,60 @@ static const uint8_t infoStackName[] = "OpenWSN "; #define LENGTH_ADDR64b 8 #define LENGTH_ADDR128b 16 -#define MAXNUMNEIGHBORS 30 +#define MAXNUMNEIGHBORS 130 + +// radio settings available for the MAC layer and supported by openmote-b +typedef enum +{ + + // different "modulations" (AT86RF215-specific) + // At83rf215 settings start at index 0 because they are used directly in a sub-array in the atmel driver. + RADIOSETTING_FSK_OPTION1_FEC, + RADIOSETTING_OQPSK_RATE3, + RADIOSETTING_OFDM_OPTION_1_MCS0, + RADIOSETTING_OFDM_OPTION_1_MCS1, + RADIOSETTING_OFDM_OPTION_1_MCS2, + RADIOSETTING_OFDM_OPTION_1_MCS3, + + // default + RADIOSETTING_24GHZ, + + // can be useful for switching receiver between OFDMx MCS modes. + RADIOSETTING_NONE, + + RADIOSETTING_MAX + +} radioSetting_t; + +// radio settings indexes for cell options. +// these settings will be mapped to any subset of the available settings +// in the Open Radio interface + +typedef enum{ + CELLRADIOSETTING_1, + CELLRADIOSETTING_2 , + CELLRADIOSETTING_3 , + MAX_CELLRADIOSETTINGS +} cellRadioSetting_t; + +// the radiosetting used for fallback (autonoumous cells) +#define CELLRADIOSETTING_FALLBACK CELLRADIOSETTING_2 + +// mapping of MAC-level cellRadioSetting_t (in schedule.h) to Open Radio +// radioSetting_t (in opendefs.h) +static const radioSetting_t cellRadioSettingMap[MAX_CELLRADIOSETTINGS]= { + RADIOSETTING_24GHZ, + RADIOSETTING_FSK_OPTION1_FEC, + RADIOSETTING_OFDM_OPTION_1_MCS3, +}; +// mapping of MAC-level cellRadioSetting_t (in schedule.h) to DAGRank increases +// ordered by range from shortest to longest +static const uint8_t radioMinHopRankIncreaseFactor [MAX_CELLRADIOSETTINGS]= { + 2, //24GHZ 2 + 5, //FSK 7 + 1 //OFDM 1 +}; + // maximum celllist length #define CELLLIST_MAX_LEN 5 @@ -302,6 +355,7 @@ typedef struct { bool isUsed; uint16_t slotoffset; uint16_t channeloffset; + cellRadioSetting_t cellRadioSetting; } cellInfo_ht; typedef struct { // always written big endian, i.e. MSB in addr[0] @@ -316,6 +370,7 @@ typedef struct { // always written big endian, i } open_addr_t; END_PACK + typedef struct { //admin uint8_t creator; // the component which called getFreePacketBuffer() @@ -343,6 +398,7 @@ typedef struct { //l2 owerror_t l2_sendDoneError; // outcome of trying to send this packet open_addr_t l2_nextORpreviousHop; // 64b IEEE802.15.4 next (down stack) or previous (up) hop address + cellRadioSetting_t l2_cellRadioSetting; // radio setting for this packet uint8_t l2_frameType; // beacon, data, ack, cmd uint8_t l2_dsn; // sequence number of the received frame uint8_t l2_retriesLeft; // number Tx retries left before packet dropped (dropped when hits 0) @@ -398,6 +454,7 @@ typedef struct { uint8_t switchStabilityCounter; open_addr_t addr_64b; dagrank_t DAGrank; + cellRadioSetting_t cellRadioSetting; int8_t rssi; uint8_t numRx; uint8_t numTx; @@ -412,6 +469,11 @@ typedef struct { } neighborRow_t; END_PACK +//ideally this struct should be in the neighbor table as an ID. +typedef struct { + open_addr_t open_addr; + cellRadioSetting_t cellRadioSetting; +} neighborKey_t; //=========================== variables ======================================= diff --git a/openapps/c6t/c6t.c b/openapps/c6t/c6t.c index f9002f3043..8e47822f05 100644 --- a/openapps/c6t/c6t.c +++ b/openapps/c6t/c6t.c @@ -72,8 +72,9 @@ owerror_t c6t_receive(OpenQueueEntry_t* msg, uint8_t* coap_outgoingOptionsLen ) { owerror_t outcome; - open_addr_t neighbor; - bool foundNeighbor; + open_addr_t neighbor; + cellRadioSetting_t neighborRadio; + bool foundNeighbor; cellInfo_ht celllist_add[CELLLIST_MAX_LEN]; cellInfo_ht celllist_delete[CELLLIST_MAX_LEN]; @@ -87,14 +88,14 @@ owerror_t c6t_receive(OpenQueueEntry_t* msg, msg->length = 0; // get preferred parent - foundNeighbor = icmpv6rpl_getPreferredParentEui64(&neighbor); + foundNeighbor = icmpv6rpl_getPreferredParentKey(&neighbor,&neighborRadio); if (foundNeighbor==FALSE) { outcome = E_FAIL; coap_header->Code = COAP_CODE_RESP_PRECONDFAILED; break; } - if (msf_candidateAddCellList(celllist_add,1)==FALSE){ + if (msf_candidateAddCellList(celllist_add,1,neighborRadio)==FALSE){ // set the CoAP header outcome = E_FAIL; coap_header->Code = COAP_CODE_RESP_CHANGED; diff --git a/openapps/cjoin/cjoin.c b/openapps/cjoin/cjoin.c index 2d87372fdb..7444565c44 100644 --- a/openapps/cjoin/cjoin.c +++ b/openapps/cjoin/cjoin.c @@ -48,7 +48,7 @@ void cjoin_timer_cb(opentimers_id_t id); void cjoin_task_cb(void); void cjoin_sendDone(OpenQueueEntry_t* msg, owerror_t error); -owerror_t cjoin_sendJoinRequest(open_addr_t *joinProxy); +owerror_t cjoin_sendJoinRequest(open_addr_t *joinProxy, cellRadioSetting_t *joinProxyRadio); void cjoin_retransmission_cb(opentimers_id_t id); void cjoin_retransmission_task_cb(void); bool cjoin_getIsJoined(void); @@ -175,14 +175,17 @@ void cjoin_retransmission_cb(opentimers_id_t id) { } void cjoin_retransmission_task_cb(void) { - open_addr_t* joinProxy; + open_addr_t *joinProxy; + cellRadioSetting_t *joinProxyRadio; if (ieee154e_isSynch() == FALSE){ // keep the retransmission timer, in case it synchronized at next time return; } - joinProxy = neighbors_getJoinProxy(); + joinProxy= neighbors_getJoinProxy(); + joinProxyRadio = neighbors_getJoinProxyRadio(); + if(joinProxy == NULL) { // keep the retransmission timer, in case it synchronized at next time openserial_printError( @@ -194,12 +197,13 @@ void cjoin_retransmission_task_cb(void) { return; } - cjoin_sendJoinRequest(joinProxy); + cjoin_sendJoinRequest(joinProxy,joinProxyRadio); } void cjoin_task_cb(void) { open_addr_t *joinProxy; - + cellRadioSetting_t *joinProxyRadio; + // don't run if not synch if (ieee154e_isSynch() == FALSE){ return; @@ -211,7 +215,9 @@ void cjoin_task_cb(void) { return; } - joinProxy = neighbors_getJoinProxy(); + joinProxy= neighbors_getJoinProxy(); + joinProxyRadio = neighbors_getJoinProxyRadio(); + if(joinProxy == NULL) { return; } @@ -229,7 +235,7 @@ void cjoin_task_cb(void) { // that may be set over the serial cjoin_init_security_context(); - cjoin_sendJoinRequest(joinProxy); + cjoin_sendJoinRequest(joinProxy,joinProxyRadio); } void cjoin_sendDone(OpenQueueEntry_t* msg, owerror_t error) { @@ -237,7 +243,7 @@ void cjoin_sendDone(OpenQueueEntry_t* msg, owerror_t error) { openqueue_freePacketBuffer(msg); } -owerror_t cjoin_sendJoinRequest(open_addr_t* joinProxy) { +owerror_t cjoin_sendJoinRequest(open_addr_t *joinProxy, cellRadioSetting_t *joinProxyRadio) { OpenQueueEntry_t* pkt; owerror_t outcome; coap_option_iht options[5]; @@ -290,6 +296,7 @@ owerror_t cjoin_sendJoinRequest(open_addr_t* joinProxy) { pkt->l3_destinationAdd.type = ADDR_128B; pkt->l3_destinationAdd.addr_128b[0] = 0xfe; pkt->l3_destinationAdd.addr_128b[1] = 0x80; + pkt->l2_cellRadioSetting = *joinProxyRadio; memset(&pkt->l3_destinationAdd.addr_128b[2], 0x00, 6); memcpy(&pkt->l3_destinationAdd.addr_128b[8],joinProxy->addr_64b,8); // set host to eui-64 of the join proxy diff --git a/openapps/uinject/uinject.c b/openapps/uinject/uinject.c index 475545ab67..64e756537b 100644 --- a/openapps/uinject/uinject.c +++ b/openapps/uinject/uinject.c @@ -6,6 +6,7 @@ #include "scheduler.h" #include "IEEE802154E.h" #include "schedule.h" +#include "neighbors.h" #include "icmpv6rpl.h" #include "idmanager.h" #include "openrandom.h" @@ -14,7 +15,7 @@ //=========================== defines ========================================= -#define UINJECT_TRAFFIC_RATE 2 ///> the value X indicates 1 packet/X minutes +#define UINJECT_TRAFFIC_RATE 1 ///> the value X indicates 1 packet/X minutes //=========================== variables ======================================= @@ -93,10 +94,19 @@ void uinject_task_cb(void) { OpenQueueEntry_t* pkt; uint8_t asnArray[5]; uint8_t numCellsUsed; + uint8_t numNeighbors; + uint16_t DAGRank; open_addr_t parentNeighbor; bool foundNeighbor; - + + uint32_t ticksTx; uint32_t ticksOn; + uint32_t ticksTx_0; + uint32_t ticksOn_0; + uint32_t ticksTx_1; + uint32_t ticksOn_1; + uint32_t ticksTx_2; + uint32_t ticksOn_2; uint32_t ticksInTotal; // don't run if not synch @@ -163,31 +173,109 @@ void uinject_task_cb(void) { pkt->payload[3] = asnArray[3]; pkt->payload[4] = asnArray[4]; + // number of cells +// packetfunctions_reserveHeaderSize(pkt,sizeof(uint8_t)); +// numCellsUsed = msf_getPreviousNumCellsUsed(CELLTYPE_TX); +// pkt->payload[0] = numCellsUsed; + +// packetfunctions_reserveHeaderSize(pkt,sizeof(uint8_t)); +// numCellsUsed = msf_getPreviousNumCellsUsed(CELLTYPE_RX); +// pkt->payload[0] = numCellsUsed; + + // number of neighbors packetfunctions_reserveHeaderSize(pkt,sizeof(uint8_t)); - numCellsUsed = msf_getPreviousNumCellsUsed(CELLTYPE_TX); - pkt->payload[0] = numCellsUsed; + numNeighbors = neighbors_getNumNeighbors(); + pkt->payload[0] = numNeighbors; + + // queue stats + openqueue_stats_t oqs = openqueue_get_stats(); + openqueue_reset_stats(); packetfunctions_reserveHeaderSize(pkt,sizeof(uint8_t)); - numCellsUsed = msf_getPreviousNumCellsUsed(CELLTYPE_RX); - pkt->payload[0] = numCellsUsed; + pkt->payload[0] = oqs.maxBuffSize; +// packetfunctions_reserveHeaderSize(pkt,sizeof(uint8_t)); +// pkt->payload[0] = oqs.minBuffSize; + + // address packetfunctions_reserveHeaderSize(pkt,sizeof(uint16_t)); pkt->payload[1] = (uint8_t)(idmanager_getMyID(ADDR_16B)->addr_16b[0]); pkt->payload[0] = (uint8_t)(idmanager_getMyID(ADDR_16B)->addr_16b[1]); - - ieee154e_getTicsInfo(&ticksOn, &ticksInTotal); + + // DAG Rank + DAGRank = icmpv6rpl_getMyDAGrank(); + packetfunctions_reserveHeaderSize(pkt,sizeof(uint16_t)); + pkt->payload[1] = (uint8_t)((DAGRank & 0x0000ff00) >> 8); + pkt->payload[0] = (uint8_t)( DAGRank & 0x000000ff); + + // duty cycle info + ieee154e_getRadioTicsInfo( + &ticksTx, + &ticksOn, + &ticksTx_0, + &ticksOn_0, + &ticksTx_1, + &ticksOn_1, + &ticksTx_2, + &ticksOn_2, + &ticksInTotal + ); packetfunctions_reserveHeaderSize(pkt,sizeof(uint32_t)); pkt->payload[3] = (uint8_t)((ticksOn & 0xff000000) >> 24); pkt->payload[2] = (uint8_t)((ticksOn & 0x00ff0000) >> 16); pkt->payload[1] = (uint8_t)((ticksOn & 0x0000ff00) >> 8); pkt->payload[0] = (uint8_t)( ticksOn & 0x000000ff); + packetfunctions_reserveHeaderSize(pkt,sizeof(uint32_t)); + pkt->payload[3] = (uint8_t)((ticksTx & 0xff000000) >> 24); + pkt->payload[2] = (uint8_t)((ticksTx & 0x00ff0000) >> 16); + pkt->payload[1] = (uint8_t)((ticksTx & 0x0000ff00) >> 8); + pkt->payload[0] = (uint8_t)( ticksTx & 0x000000ff); + + packetfunctions_reserveHeaderSize(pkt,sizeof(uint32_t)); + pkt->payload[3] = (uint8_t)((ticksOn_0 & 0xff000000) >> 24); + pkt->payload[2] = (uint8_t)((ticksOn_0 & 0x00ff0000) >> 16); + pkt->payload[1] = (uint8_t)((ticksOn_0 & 0x0000ff00) >> 8); + pkt->payload[0] = (uint8_t)( ticksOn_0 & 0x000000ff); + + packetfunctions_reserveHeaderSize(pkt,sizeof(uint32_t)); + pkt->payload[3] = (uint8_t)((ticksTx_0 & 0xff000000) >> 24); + pkt->payload[2] = (uint8_t)((ticksTx_0 & 0x00ff0000) >> 16); + pkt->payload[1] = (uint8_t)((ticksTx_0 & 0x0000ff00) >> 8); + pkt->payload[0] = (uint8_t)( ticksTx_0 & 0x000000ff); + + packetfunctions_reserveHeaderSize(pkt,sizeof(uint32_t)); + pkt->payload[3] = (uint8_t)((ticksOn_1 & 0xff000000) >> 24); + pkt->payload[2] = (uint8_t)((ticksOn_1 & 0x00ff0000) >> 16); + pkt->payload[1] = (uint8_t)((ticksOn_1 & 0x0000ff00) >> 8); + pkt->payload[0] = (uint8_t)( ticksOn_1 & 0x000000ff); + + packetfunctions_reserveHeaderSize(pkt,sizeof(uint32_t)); + pkt->payload[3] = (uint8_t)((ticksTx_1 & 0xff000000) >> 24); + pkt->payload[2] = (uint8_t)((ticksTx_1 & 0x00ff0000) >> 16); + pkt->payload[1] = (uint8_t)((ticksTx_1 & 0x0000ff00) >> 8); + pkt->payload[0] = (uint8_t)( ticksTx_1 & 0x000000ff); + + packetfunctions_reserveHeaderSize(pkt,sizeof(uint32_t)); + pkt->payload[3] = (uint8_t)((ticksOn_2 & 0xff000000) >> 24); + pkt->payload[2] = (uint8_t)((ticksOn_2 & 0x00ff0000) >> 16); + pkt->payload[1] = (uint8_t)((ticksOn_2 & 0x0000ff00) >> 8); + pkt->payload[0] = (uint8_t)( ticksOn_2 & 0x000000ff); + + packetfunctions_reserveHeaderSize(pkt,sizeof(uint32_t)); + pkt->payload[3] = (uint8_t)((ticksTx_2 & 0xff000000) >> 24); + pkt->payload[2] = (uint8_t)((ticksTx_2 & 0x00ff0000) >> 16); + pkt->payload[1] = (uint8_t)((ticksTx_2 & 0x0000ff00) >> 8); + pkt->payload[0] = (uint8_t)( ticksTx_2 & 0x000000ff); + packetfunctions_reserveHeaderSize(pkt,sizeof(uint32_t)); pkt->payload[3] = (uint8_t)((ticksInTotal & 0xff000000) >> 24); pkt->payload[2] = (uint8_t)((ticksInTotal & 0x00ff0000) >> 16); pkt->payload[1] = (uint8_t)((ticksInTotal & 0x0000ff00) >> 8); pkt->payload[0] = (uint8_t)( ticksInTotal & 0x000000ff); - + // resettin mac stats + ieee154e_resetStats(); + if ((openudp_send(pkt))==E_FAIL) { openqueue_freePacketBuffer(pkt); } else { diff --git a/openstack/02a-MAClow/IEEE802154E.c b/openstack/02a-MAClow/IEEE802154E.c index 07921ae300..36c8d002c7 100644 --- a/openstack/02a-MAClow/IEEE802154E.c +++ b/openstack/02a-MAClow/IEEE802154E.c @@ -17,15 +17,21 @@ #include "sctimer.h" #include "openrandom.h" #include "msf.h" - +#include "board.h" +#include "board_info.h" //=========================== definition ====================================== - +//#define IEEE802154E_SINGLE_CHANNEL 11 //=========================== variables ======================================= -ieee154e_vars_t ieee154e_vars; -ieee154e_stats_t ieee154e_stats; -ieee154e_dbg_t ieee154e_dbg; +ieee154e_vars_t ieee154e_vars; +ieee154e_stats_t ieee154e_stats; +ieee154e_dbg_t ieee154e_dbg; + +slotTemplate_t slotTemplate; +slot_154e_vars_t slot_154e_vars [MAX_SLOT_TYPES]; +uint32_t Tics1; +uint32_t Tics2; //=========================== prototypes ====================================== // SYNCHRONIZING @@ -75,6 +81,8 @@ bool ieee154e_processIEs(OpenQueueEntry_t* pkt, uint16_t* lenIE); void timeslotTemplateIDStoreFromEB(uint8_t id); void channelhoppingTemplateIDStoreFromEB(uint8_t id); // ASN handling +void storeStartASN(void); +void getStartAsn(uint8_t* array); void incrementAsnOffset(void); void ieee154e_resetAsn(void); void ieee154e_syncSlotOffset(void); @@ -88,7 +96,6 @@ void changeIsSync(bool newIsSync); void notif_sendDone(OpenQueueEntry_t* packetSent, owerror_t error); void notif_receive(OpenQueueEntry_t* packetReceived); // statistics -void resetStats(void); void updateStats(PORT_SIGNED_INT_WIDTH timeCorrection); // misc uint8_t calculateFrequency(uint8_t channelOffset); @@ -116,14 +123,14 @@ void ieee154e_init(void) { memset(&ieee154e_dbg,0,sizeof(ieee154e_dbg_t)); // set singleChannel to 0 to enable channel hopping. -#if IEEE802154E_SINGLE_CHANNEL +#if IEEE802154E_SINGLE_CHANNEL ieee154e_vars.singleChannel = IEEE802154E_SINGLE_CHANNEL; #else ieee154e_vars.singleChannel = 0; // 0 means channel hopping #endif ieee154e_vars.isAckEnabled = TRUE; ieee154e_vars.isSecurityEnabled = FALSE; - ieee154e_vars.slotDuration = TsSlotDuration; + ieee154e_vars.numOfSleepSlots = 1; // default hopping template @@ -139,9 +146,31 @@ void ieee154e_init(void) { changeIsSync(FALSE); } - resetStats(); + ieee154e_resetStats(); ieee154e_stats.numDeSync = 0; + // initialize slot template lookup table + ieee154e_slot_template_init(); + + /* select the desired slot template to use, default is SLOT_20ms_24GHZ + currently, the following slot template/radio setting combinations are supported: + + SLOT_20ms_24GHZ , RADIOSETTING_24GHZ --> Default + SLOT_40ms_24GHZ , RADIOSETTING_24GHZ + SLOT_40ms_FSK_SUBGHZ , RADIOSETTING_FSK_OPTION1_FEC + SLOT_40ms_OFDM1MCS0_3_SUBGHZ , RADIOSETTING_OFDM_OPTION_1_MCS0 + SLOT_40ms_OFDM1MCS0_3_SUBGHZ , RADIOSETTING_OFDM_OPTION_1_MCS1 + SLOT_40ms_OFDM1MCS0_3_SUBGHZ , RADIOSETTING_OFDM_OPTION_1_MCS2 + SLOT_40ms_OFDM1MCS0_3_SUBGHZ , RADIOSETTING_OFDM_OPTION_1_MCS3 + */ + + // TODO: convert the 3 lines to one function + ieee154e_select_slot_template (SLOT_40ms_FSK_SUBGHZ); + //set the radio setting to use for scanning, default is RADIOSETTING_24GHZ + ieee154e_vars.cellRadioSetting = CELLRADIOSETTING_FALLBACK; + radio_setConfig (cellRadioSettingMap[CELLRADIOSETTING_FALLBACK]); + + // switch radio on radio_rfOn(); @@ -167,6 +196,91 @@ void ieee154e_init(void) { ieee154e_vars.serialInhibitTimerId = opentimers_create(TIMER_INHIBIT, TASKPRIO_NONE); } +/** +\brief This function initializes the lookup table for the slot templates. + +Call this function once, preferrably at end of the ieee154e_init function +*/ +void ieee154e_slot_template_init(void) +{ + //10ms slot + slot_154e_vars [SLOT_10ms].TsTxOffset = ( 2120 /PORT_US_PER_TICK ) ; // 2120us + slot_154e_vars [SLOT_10ms].TsLongGT = ( 1100 /PORT_US_PER_TICK ) ; // 1100us + slot_154e_vars [SLOT_10ms].TsTxAckDelay = ( 1000 /PORT_US_PER_TICK ) ; // 1000us + slot_154e_vars [SLOT_10ms].TsShortGT = ( 500 /PORT_US_PER_TICK ) ; // 500us; The standardlized value for this is 400/2=200us(7ticks). Currectly 7 doesn't work for short packet; change it back to 7 when found the problem. + slot_154e_vars [SLOT_10ms].wdRadioTx = ( 1342 /PORT_US_PER_TICK ) ; // 1000us (needs to be >delayTx) (SCuM need a larger value; 45 is tested and works) + slot_154e_vars [SLOT_10ms].wdDataDuration = ( 5000 /PORT_US_PER_TICK ) ; // 5000us (measured 4280us with max payload) + slot_154e_vars [SLOT_10ms].wdAckDuration = ( 3000 /PORT_US_PER_TICK ) ; // 3000us (measured 1000us) + + // 20ms slot for 24ghz cc2538 + slot_154e_vars [SLOT_20ms_24GHZ].TsTxOffset = ( 5215 /PORT_US_PER_TICK ) ; // 5215us + slot_154e_vars [SLOT_20ms_24GHZ].TsLongGT = ( 1311 /PORT_US_PER_TICK ) ; // 1311us + slot_154e_vars [SLOT_20ms_24GHZ].TsTxAckDelay = ( 5521 /PORT_US_PER_TICK ) ; // 5521us + slot_154e_vars [SLOT_20ms_24GHZ].TsShortGT = ( 700 /PORT_US_PER_TICK ) ; // 700us + slot_154e_vars [SLOT_20ms_24GHZ].wdRadioTx = ( 1342 /PORT_US_PER_TICK ) ; // 1000us (needs to be >delayTx) (SCuM need a larger value; 45 is tested and works) + slot_154e_vars [SLOT_20ms_24GHZ].wdDataDuration = ( 5000 /PORT_US_PER_TICK ) ; // 5000us (measured 4280us with max payload) + slot_154e_vars [SLOT_20ms_24GHZ].wdAckDuration = ( 3000 /PORT_US_PER_TICK ) ; // 3000us (measured 1000us) + + //40ms slot for 24ghz cc2538 + slot_154e_vars [SLOT_40ms_24GHZ].TsTxOffset = ( 5215 /PORT_US_PER_TICK ) ; // 5215us + slot_154e_vars [SLOT_40ms_24GHZ].TsLongGT = ( 1311 /PORT_US_PER_TICK ) ; // 1311us + slot_154e_vars [SLOT_40ms_24GHZ].TsTxAckDelay = ( 5521 /PORT_US_PER_TICK ) ; // 5521us + slot_154e_vars [SLOT_40ms_24GHZ].TsShortGT = ( 700 /PORT_US_PER_TICK ) ; // 700us + slot_154e_vars [SLOT_40ms_24GHZ].wdRadioTx = ( 1342 /PORT_US_PER_TICK ) ; // 1000us (needs to be >delayTx) (SCuM need a larger value; 45 is tested and works) + slot_154e_vars [SLOT_40ms_24GHZ].wdDataDuration = ( 5000 /PORT_US_PER_TICK ) ; // 5000us (measured 4280us with max payload) + slot_154e_vars [SLOT_40ms_24GHZ].wdAckDuration = ( 3000 /PORT_US_PER_TICK ) ; // 3000us (measured 1000us) + + //40ms slot for FSK + slot_154e_vars [SLOT_40ms_FSK_SUBGHZ].TsTxOffset = ( 6500 /PORT_US_PER_TICK ); //5500 measured: 131 ticks + slot_154e_vars [SLOT_40ms_FSK_SUBGHZ].TsLongGT = ( 2000 /PORT_US_PER_TICK ); // measured: 66 ticks + slot_154e_vars [SLOT_40ms_FSK_SUBGHZ].TsTxAckDelay = ( 6500 /PORT_US_PER_TICK ); //5000 measured: 121 ticks + slot_154e_vars [SLOT_40ms_FSK_SUBGHZ].TsShortGT = ( 1831 /PORT_US_PER_TICK ); // measured: 60 ticks + slot_154e_vars [SLOT_40ms_FSK_SUBGHZ].wdRadioTx = ( 3800 /PORT_US_PER_TICK ); //7000 230 ticks 7019us delayTx+Tx time for 10 bytes( (needs to be >delayTx) (SCuM need a larger value; 45 is tested and works) + slot_154e_vars [SLOT_40ms_FSK_SUBGHZ].wdDataDuration = ( 25000 /PORT_US_PER_TICK ); // 983 ticks ; estimated based on max payload + slot_154e_vars [SLOT_40ms_FSK_SUBGHZ].wdAckDuration = ( 10000 /PORT_US_PER_TICK ); // 655 ticks; estimated + + //40ms slot for OFDM1 MCS0-3 + slot_154e_vars [SLOT_40ms_OFDM1MCS0_3_SUBGHZ].TsTxOffset = ( 5000 /PORT_US_PER_TICK ); // 3500 measured: 115 ticks; + slot_154e_vars [SLOT_40ms_OFDM1MCS0_3_SUBGHZ].TsLongGT = ( 2000 /PORT_US_PER_TICK ); // measured: 66 ticks; + slot_154e_vars [SLOT_40ms_OFDM1MCS0_3_SUBGHZ].TsTxAckDelay = ( 5000 /PORT_US_PER_TICK ); // measured: 121 ticks + slot_154e_vars [SLOT_40ms_OFDM1MCS0_3_SUBGHZ].TsShortGT = ( 1500 /PORT_US_PER_TICK ); // measured: 60 ticks + slot_154e_vars [SLOT_40ms_OFDM1MCS0_3_SUBGHZ].wdRadioTx = ( 3800 /PORT_US_PER_TICK ); // 230 ticks 7019us delayTx+Tx time for 10 bytes( (needs to be >delayTx) (SCuM need a larger value; 45 is tested and works) + slot_154e_vars [SLOT_40ms_OFDM1MCS0_3_SUBGHZ].wdDataDuration = ( 5000 /PORT_US_PER_TICK ); // 983 ticks; estimated based on max payload + slot_154e_vars [SLOT_40ms_OFDM1MCS0_3_SUBGHZ].wdAckDuration = ( 3000 /PORT_US_PER_TICK ); // 655 ticks; estimated +} + +/** +\brief This function copies the variables of a selected tamplate from board vars and 154e vars in one variable. + +This is called at init function and at the beginning of the slot after the radio setting is selected +*/ +void ieee154e_select_slot_template(slotType_t slotType) +{ + slot_board_vars_t slot_board_vars= board_selectSlotTemplate(slotType); + + // board-specific template details + slotTemplate.slotDuration = slot_board_vars.slotDuration; + slotTemplate.maxTxDataPrepare = slot_board_vars.maxTxDataPrepare; + slotTemplate.maxRxAckPrepare = slot_board_vars.maxRxAckPrepare; + slotTemplate.maxRxDataPrepare = slot_board_vars.maxRxDataPrepare; + slotTemplate.maxTxAckPrepare = slot_board_vars.maxTxAckPrepare; + slotTemplate.delayTx = slot_board_vars.delayTx; + slotTemplate.delayRx = slot_board_vars.delayRx; + + //154e general slot template + slotTemplate.TsTxOffset = slot_154e_vars [slotType].TsTxOffset; + slotTemplate.TsLongGT = slot_154e_vars [slotType].TsLongGT; + slotTemplate.TsTxAckDelay = slot_154e_vars [slotType].TsTxAckDelay; + slotTemplate.TsShortGT = slot_154e_vars [slotType].TsShortGT; + slotTemplate.wdRadioTx = slot_154e_vars [slotType].wdRadioTx; + slotTemplate.wdDataDuration = slot_154e_vars [slotType].wdDataDuration; + slotTemplate.wdAckDuration = slot_154e_vars [slotType].wdAckDuration; + + ieee154e_vars.slotDuration = slotTemplate.slotDuration; + +} + + //=========================== public ========================================== /** @@ -282,15 +396,18 @@ This function executes in ISR mode, when the new slot timer fires. void isr_ieee154e_newSlot(opentimers_id_t id) { ieee154e_vars.startOfSlotReference = opentimers_getCurrentCompareValue(); - + ieee154e_vars.slotDuration = MICROSLOTDURATION; opentimers_scheduleAbsolute( ieee154e_vars.timerId, // timerId - TsSlotDuration, // duration + // this should be which duration? + slotTemplate.slotDuration, // duration ieee154e_vars.startOfSlotReference, // reference TIME_TICS, // timetype isr_ieee154e_newSlot // callback ); - ieee154e_vars.slotDuration = TsSlotDuration; + + + // radiotimer_setPeriod(ieee154e_vars.slotDuration); if (ieee154e_vars.isSync==FALSE) { @@ -554,6 +671,7 @@ port_INLINE void activity_synchronize_newSlot(void) { } ieee154e_vars.radioOnInit=sctimer_readCounter(); + ieee154e_vars.radioTxRxInit = ieee154e_vars.radioOnInit; ieee154e_vars.radioOnThisSlot=TRUE; // if this is the first time I call this function while not synchronized, @@ -584,10 +702,23 @@ port_INLINE void activity_synchronize_newSlot(void) { radio_rxEnable(); radio_rxNow(); } else { - // I'm listening last slot + // I was listening last slot ieee154e_stats.numTicsOn += ieee154e_vars.slotDuration; + ieee154e_stats.numRxTics += ieee154e_vars.slotDuration; ieee154e_stats.numTicsTotal += ieee154e_vars.slotDuration; - + + // update radio-specific DC stats + switch (ieee154e_vars.cellRadioSetting){ + case CELLRADIOSETTING_1: + ieee154e_stats.numTicsOn_0 += ieee154e_vars.slotDuration; + break; + case CELLRADIOSETTING_2: + ieee154e_stats.numTicsOn_1 += ieee154e_vars.slotDuration; + break; + case CELLRADIOSETTING_3: + ieee154e_stats.numTicsOn_2 += ieee154e_vars.slotDuration; + break; + } #ifdef SLOT_FSM_IMPLEMENTATION_MULTIPLE_TIMER_INTERRUPT sctimer_setCapture(ACTION_RX_SFD_DONE); sctimer_setCapture(ACTION_RX_DONE); @@ -719,8 +850,8 @@ port_INLINE void activity_synchronize_endOfFrame(PORT_TIMER_WIDTH capturedTime) // retrieve the received data frame from the radio's Rx buffer ieee154e_vars.dataReceived->payload = &(ieee154e_vars.dataReceived->packet[FIRST_FRAME_BYTE]); - radio_getReceivedFrame( ieee154e_vars.dataReceived->payload, - (uint8_t*)&ieee154e_vars.dataReceived->length, + radio_getReceivedFrame( ieee154e_vars.dataReceived->payload, + (uint8_t*)&ieee154e_vars.dataReceived->length, sizeof(ieee154e_vars.dataReceived->packet), &ieee154e_vars.dataReceived->l1_rssi, &ieee154e_vars.dataReceived->l1_lqi, @@ -752,7 +883,10 @@ port_INLINE void activity_synchronize_endOfFrame(PORT_TIMER_WIDTH capturedTime) // break from the do-while loop and execute the clean-up code below break; } - + + // store the cellRadioSetting used while receiving this packet + ieee154e_vars.dataReceived->l2_cellRadioSetting =schedule_getCellRadioSetting (); + // store header details in packet buffer ieee154e_vars.dataReceived->l2_frameType = ieee802514_header.frameType; ieee154e_vars.dataReceived->l2_dsn = ieee802514_header.dsn; @@ -798,6 +932,7 @@ port_INLINE void activity_synchronize_endOfFrame(PORT_TIMER_WIDTH capturedTime) // compute radio duty cycle ieee154e_vars.radioOnTics += (sctimer_readCounter()-ieee154e_vars.radioOnInit); + ieee154e_vars.radioRxTics += (sctimer_readCounter()-ieee154e_vars.radioTxRxInit); // toss the IEs packetfunctions_tossHeader(ieee154e_vars.dataReceived,lenIE); @@ -842,18 +977,22 @@ port_INLINE bool ieee154e_processIEs(OpenQueueEntry_t* pkt, uint16_t* lenIE) { // at this point, ASN and frame length are known // the current slotoffset can be inferred ieee154e_syncSlotOffset(); - schedule_syncSlotOffset(ieee154e_vars.slotOffset); + + // Issue?: this is called inside ieee154e_syncSlotOffset as well. + // will comment it out + //schedule_syncSlotOffset(ieee154e_vars.slotOffset); + ieee154e_vars.nextActiveSlotOffset = schedule_getNextActiveSlotOffset(); /* infer the asnOffset based on the fact that ieee154e_vars.freq = 11 + (asnOffset + channelOffset)%16 */ - for (i=0;i ieee154e_vars.numOfSleepSlots){ ieee154e_vars.deSyncTimeout -= ieee154e_vars.numOfSleepSlots; } else { - // Reset sleep slots - ieee154e_vars.numOfSleepSlots = 1; - // declare myself desynchronized - changeIsSync(FALSE); // log the error openserial_printError(COMPONENT_IEEE802154E,ERR_DESYNCHRONIZED, (errorparameter_t)ieee154e_vars.slotOffset, (errorparameter_t)0); + //poipoi: for debugging + openserial_printError(COMPONENT_IEEE802154E,ERR_SECURITY, + (errorparameter_t)ieee154e_vars.deSyncTimeout, + (errorparameter_t)ieee154e_vars.numOfSleepSlots); + + // Reset sleep slots + ieee154e_vars.numOfSleepSlots = 1; + // declare myself desynchronized + changeIsSync(FALSE); + // update the statistics ieee154e_stats.numDeSync++; @@ -923,37 +1071,91 @@ port_INLINE void activity_ti1ORri1(void) { // update nextActiveSlotOffset before using ieee154e_vars.nextActiveSlotOffset = schedule_getNextActiveSlotOffset(); if (ieee154e_vars.slotOffset==ieee154e_vars.nextActiveSlotOffset) { + // this is the next active slot - // advance the schedule + // advance the schedule : update current slot entry to this active slot schedule_advanceSlot(); + // Perhaps this is also where th radiosetting will be selected // calculate the frequency to transmit on ieee154e_vars.freq = calculateFrequency(schedule_getChannelOffset()); + // retrieve the radio setting to be used in this cell + ieee154e_vars.cellRadioSetting = schedule_getCellRadioSetting(); //l2 radio setting + ieee154e_vars.radioSetting = cellRadioSettingMap[ieee154e_vars.cellRadioSetting]; //l1 radioSetting + + // configure the radio setting + radio_setConfig (ieee154e_vars.radioSetting); + + /* select the desired slot template to use, default is SLOT_20ms_24GHZ + currently, the following slot template/radio setting combinations are supported: + + SLOT_20ms_24GHZ , RADIOSETTING_24GHZ --> Default + SLOT_40ms_24GHZ , RADIOSETTING_24GHZ + SLOT_40ms_FSK_SUBGHZ , RADIOSETTING_FSK_OPTION1_FEC + SLOT_40ms_OFDM1MCS0_3_SUBGHZ , RADIOSETTING_OFDM_OPTION_1_MCS0 + SLOT_40ms_OFDM1MCS0_3_SUBGHZ , RADIOSETTING_OFDM_OPTION_1_MCS1 + SLOT_40ms_OFDM1MCS0_3_SUBGHZ , RADIOSETTING_OFDM_OPTION_1_MCS2 + SLOT_40ms_OFDM1MCS0_3_SUBGHZ , RADIOSETTING_OFDM_OPTION_1_MCS3 + */ + switch (ieee154e_vars.radioSetting) { + case RADIOSETTING_24GHZ: + ieee154e_select_slot_template (SLOT_40ms_24GHZ); + break; + case RADIOSETTING_FSK_OPTION1_FEC: + ieee154e_select_slot_template (SLOT_40ms_FSK_SUBGHZ); + break; + case RADIOSETTING_OFDM_OPTION_1_MCS3: + case RADIOSETTING_OFDM_OPTION_1_MCS2: + case RADIOSETTING_OFDM_OPTION_1_MCS1: + case RADIOSETTING_OFDM_OPTION_1_MCS0: + ieee154e_select_slot_template (SLOT_40ms_OFDM1MCS0_3_SUBGHZ); + break; + default: + // log the error + // >> add error notification here + // abort + endSlot(); + break; + + } + // increment AsnOffset for superslots + ieee154e_vars.superSlotLength = schedule_getCurrentSuperSlotLength(); + + // store start ASN before incremeneting, to use in EBs + storeStartASN(); + + for (i=0;iieee154e_vars.slotOffset) { - ieee154e_vars.numOfSleepSlots = ieee154e_vars.nextActiveSlotOffset-ieee154e_vars.slotOffset; + if (ieee154e_vars.nextActiveSlotOffset>ieee154e_vars.slotOffset) { + + ieee154e_vars.numOfSleepSlots = ieee154e_vars.nextActiveSlotOffset-ieee154e_vars.slotOffset-ieee154e_vars.superSlotLength; } else { - ieee154e_vars.numOfSleepSlots = schedule_getFrameLength()+ieee154e_vars.nextActiveSlotOffset-ieee154e_vars.slotOffset; + ieee154e_vars.numOfSleepSlots = schedule_getFrameLength()+ieee154e_vars.nextActiveSlotOffset-ieee154e_vars.slotOffset-ieee154e_vars.superSlotLength; } - + + // this is really weird, don't get it opentimers_scheduleAbsolute( ieee154e_vars.timerId, // timerId - TsSlotDuration*(ieee154e_vars.numOfSleepSlots), // duration + MICROSLOTDURATION*(ieee154e_vars.numOfSleepSlots), // duration ieee154e_vars.startOfSlotReference, // reference TIME_TICS, // timetype isr_ieee154e_newSlot // callback ); - ieee154e_vars.slotDuration = TsSlotDuration*(ieee154e_vars.numOfSleepSlots); - // radiotimer_setPeriod(TsSlotDuration*(ieee154e_vars.numOfSleepSlots)); - + + ieee154e_vars.slotDuration = MICROSLOTDURATION*(ieee154e_vars.numOfSleepSlots); + //increase ASN by numOfSleepSlots-1 slots as at this slot is already incremented by 1 - for (i=0;il2_sendOnTxCell = TRUE; msf_updateCellsUsed(&neighbor, CELLTYPE_TX); } - msf_updateCellsElapsed(&neighbor, CELLTYPE_TX); + msf_updateCellsElapsed(&neighbor,ieee154e_vars.cellRadioSetting, CELLTYPE_TX); } } else { // this is minimal cell + isMinimalCell = TRUE; + // add a condition here, if the this cell has the default radio setting for DIO + //if (ieee154e_vars.cellRadioSetting == CELLRADIOSETTING_FALLBACK){ ieee154e_vars.dataToSend = openqueue_macGetDIOPacket(); + //} if (ieee154e_vars.dataToSend==NULL){ couldSendEB=TRUE; // look for an EB packet in the queue @@ -1004,7 +1218,7 @@ port_INLINE void activity_ti1ORri1(void) { } if (ieee154e_vars.dataToSend==NULL) { - if (cellType==CELLTYPE_TX) { + if (cellType==CELLTYPE_TX) { // abort endSlot(); break; @@ -1017,13 +1231,18 @@ port_INLINE void activity_ti1ORri1(void) { if (couldSendEB==TRUE) { // I will be sending an EB //copy synch IE -- should be Little endian??? // fill in the ASN field of the EB - ieee154e_getAsn(asn); - join_priority = (icmpv6rpl_getMyDAGrank()/MINHOPRANKINCREASE)-1; //poipoi -- use dagrank(rank)-1 + getStartAsn(asn); + join_priority = ((radioMinHopRankIncreaseFactor[schedule_getCellRadioSetting()]*icmpv6rpl_getMyDAGrank())/MINHOPRANKINCREASE)-1; //poipoi -- use dagrank(rank)-1 + // This is where the ASN of the slot is added to the EB. memcpy(ieee154e_vars.dataToSend->l2_ASNpayload,&asn[0],sizeof(asn_t)); memcpy(ieee154e_vars.dataToSend->l2_ASNpayload+sizeof(asn_t),&join_priority,sizeof(uint8_t)); } + // record that I attempt to transmit this packet ieee154e_vars.dataToSend->l2_numTxAttempts++; + + //poipoi debug + Tics2 = sctimer_readCounter(); #ifdef SLOT_FSM_IMPLEMENTATION_MULTIPLE_TIMER_INTERRUPT // 1. schedule timer for loading packet sctimer_scheduleActionIn(ACTION_LOAD_PACKET, ieee154e_vars.startOfSlotReference+DURATION_tt1); @@ -1065,13 +1284,28 @@ port_INLINE void activity_ti1ORri1(void) { TIME_TICS, // timetype isr_ieee154e_timer // callback ); + // radiotimer_schedule(DURATION_tt1); #endif break; } case CELLTYPE_RX: + if(isMinimalCell){ + if( openrandom_get16b()< (0xffff/MIN_RX_PORTION)){ + // do nothing + }else{ + endSlot(); + break; + } + } // change state changeState(S_RXDATAOFFSET); + // poipoi: debugging, print asnOffset in rx auto cell +// openserial_printError(COMPONENT_IEEE802154E,ERR_BUSY_RECEIVING, +// (errorparameter_t)ieee154e_vars.asnOffset, +// (errorparameter_t)ieee154e_vars.slotOffset); + //poipoi debug + Tics2 = sctimer_readCounter(); #ifdef SLOT_FSM_IMPLEMENTATION_MULTIPLE_TIMER_INTERRUPT // arm rt1 sctimer_scheduleActionIn(ACTION_RADIORX_ENABLE,ieee154e_vars.startOfSlotReference+DURATION_rt1); @@ -1093,6 +1327,7 @@ port_INLINE void activity_ti1ORri1(void) { TIME_TICS, // timetype isr_ieee154e_timer // callback ); + // radiotimer_schedule(DURATION_rt1); #endif @@ -1113,7 +1348,8 @@ port_INLINE void activity_ti2(void) { // change state changeState(S_TXDATAPREPARE); - + //debugpins_slot_toggle(); + //debugpins_slot_toggle(); #ifdef SLOT_FSM_IMPLEMENTATION_MULTIPLE_TIMER_INTERRUPT #else // arm tt2 @@ -1141,10 +1377,10 @@ port_INLINE void activity_ti2(void) { // add 2 CRC bytes only to the local copy as we end up here for each retransmission packetfunctions_reserveFooterSize(&ieee154e_vars.localCopyForTransmission, 2); - + // configure the radio to listen to the default synchronizing channel radio_setFrequency(ieee154e_vars.freq, FREQ_TX); - + // load the packet in the radio's Tx buffer radio_loadPacket(ieee154e_vars.localCopyForTransmission.payload, ieee154e_vars.localCopyForTransmission.length); @@ -1202,6 +1438,10 @@ port_INLINE void activity_tie2(void) { port_INLINE void activity_ti4(PORT_TIMER_WIDTH capturedTime) { // change state changeState(S_TXDATA); + + // capture time for radio tx duy cycle calculation + ieee154e_vars.radioTxRxInit = sctimer_readCounter(); + #ifdef SLOT_FSM_IMPLEMENTATION_MULTIPLE_TIMER_INTERRUPT // cancel tt3 sctimer_actionCancel(ACTION_SET_TIMEOUT); @@ -1239,7 +1479,8 @@ port_INLINE void activity_tie3(void) { openserial_printError(COMPONENT_IEEE802154E,ERR_WDDATADURATION_OVERFLOWS, (errorparameter_t)ieee154e_vars.state, (errorparameter_t)ieee154e_vars.slotOffset); - + debugpins_frame_toggle(); + debugpins_frame_toggle(); // abort endSlot(); } @@ -1266,6 +1507,7 @@ port_INLINE void activity_ti5(PORT_TIMER_WIDTH capturedTime) { // turn off the radio radio_rfOff(); ieee154e_vars.radioOnTics+=(sctimer_readCounter()-ieee154e_vars.radioOnInit); + ieee154e_vars.radioTxTics+=(sctimer_readCounter()-ieee154e_vars.radioTxRxInit); // record the captured time ieee154e_vars.lastCapturedTime = capturedTime; @@ -1302,6 +1544,8 @@ port_INLINE void activity_ti5(PORT_TIMER_WIDTH capturedTime) { isr_ieee154e_timer // callback ); // radiotimer_schedule(DURATION_tt5); + + #endif } else { // indicate succesful Tx to schedule to keep statistics @@ -1403,6 +1647,10 @@ port_INLINE void activity_tie5(void) { port_INLINE void activity_ti8(PORT_TIMER_WIDTH capturedTime) { // change state changeState(S_RXACK); + + // capture time for radio rx duy cycle calculation + ieee154e_vars.radioTxRxInit = sctimer_readCounter(); + #ifdef SLOT_FSM_IMPLEMENTATION_MULTIPLE_TIMER_INTERRUPT // cancel tt7 sctimer_actionCancel(ACTION_SET_TIMEOUT); @@ -1466,8 +1714,9 @@ port_INLINE void activity_ti9(PORT_TIMER_WIDTH capturedTime) { // turn off the radio radio_rfOff(); //compute tics radio on. - ieee154e_vars.radioOnTics+=(sctimer_readCounter()-ieee154e_vars.radioOnInit); - + //ieee154e_vars.radioOnTics+=(sctimer_readCounter()-ieee154e_vars.radioOnInit); + ieee154e_vars.radioRxTics += (sctimer_readCounter()-ieee154e_vars.radioTxRxInit); + // record the captured time ieee154e_vars.lastCapturedTime = capturedTime; @@ -1502,7 +1751,7 @@ port_INLINE void activity_ti9(PORT_TIMER_WIDTH capturedTime) { ieee154e_vars.ackReceived->payload = &(ieee154e_vars.ackReceived->packet[FIRST_FRAME_BYTE]); radio_getReceivedFrame( ieee154e_vars.ackReceived->payload, - (uint8_t*)&ieee154e_vars.ackReceived->length, + (uint8_t*)&ieee154e_vars.ackReceived->length, sizeof(ieee154e_vars.ackReceived->packet), &ieee154e_vars.ackReceived->l1_rssi, &ieee154e_vars.ackReceived->l1_lqi, @@ -1608,7 +1857,7 @@ port_INLINE void activity_ri2(void) { isr_ieee154e_timer // callback ); // radiotimer_schedule(DURATION_rt2); - + // configure the radio to listen to the default synchronizing channel radio_setFrequency(ieee154e_vars.freq, FREQ_RX); @@ -1662,6 +1911,11 @@ port_INLINE void activity_ri4(PORT_TIMER_WIDTH capturedTime) { // change state changeState(S_RXDATA); + + // capture time for radio rx duy cycle calculation + ieee154e_vars.radioTxRxInit = sctimer_readCounter(); + + //indicate on LA that a frame reception has actually started #ifdef SLOT_FSM_IMPLEMENTATION_MULTIPLE_TIMER_INTERRUPT // cancel rt3 @@ -1702,12 +1956,15 @@ port_INLINE void activity_rie3(void) { openserial_printError(COMPONENT_IEEE802154E,ERR_WDDATADURATION_OVERFLOWS, (errorparameter_t)ieee154e_vars.state, (errorparameter_t)ieee154e_vars.slotOffset); - + debugpins_slot_toggle(); + debugpins_slot_toggle(); // abort endSlot(); } port_INLINE void activity_ri5(PORT_TIMER_WIDTH capturedTime) { + //indicate on LA that a frame reception has ended + ieee802154_header_iht ieee802514_header; uint16_t lenIE=0; open_addr_t addressToWrite; @@ -1732,6 +1989,8 @@ port_INLINE void activity_ri5(PORT_TIMER_WIDTH capturedTime) { // turn off the radio radio_rfOff(); ieee154e_vars.radioOnTics+=sctimer_readCounter()-ieee154e_vars.radioOnInit; + ieee154e_vars.radioRxTics+=sctimer_readCounter()-ieee154e_vars.radioTxRxInit; + // get a buffer to put the (received) data in ieee154e_vars.dataReceived = openqueue_getFreePacketBuffer(COMPONENT_IEEE802154E); if (ieee154e_vars.dataReceived==NULL) { @@ -1764,7 +2023,7 @@ port_INLINE void activity_ri5(PORT_TIMER_WIDTH capturedTime) { ieee154e_vars.dataReceived->payload = &(ieee154e_vars.dataReceived->packet[FIRST_FRAME_BYTE]); radio_getReceivedFrame( ieee154e_vars.dataReceived->payload, - (uint8_t*)&ieee154e_vars.dataReceived->length, + (uint8_t*)&ieee154e_vars.dataReceived->length, sizeof(ieee154e_vars.dataReceived->packet), &ieee154e_vars.dataReceived->l1_rssi, &ieee154e_vars.dataReceived->l1_lqi, @@ -1779,7 +2038,10 @@ port_INLINE void activity_ri5(PORT_TIMER_WIDTH capturedTime) { ieee154e_vars.dataReceived->length); break; } - + + // store the cellRadioSetting used while receiving this packet + ieee154e_vars.dataReceived-> l2_cellRadioSetting =schedule_getCellRadioSetting (); + // toss CRC (2 last bytes) packetfunctions_tossFooter( ieee154e_vars.dataReceived, LENGTH_CRC); @@ -1788,7 +2050,7 @@ port_INLINE void activity_ri5(PORT_TIMER_WIDTH capturedTime) { // jump to the error code below this do-while loop break; } - + // parse the IEEE802.15.4 header (RX DATA) ieee802154_retrieveHeader(ieee154e_vars.dataReceived,&ieee802514_header); @@ -1857,7 +2119,7 @@ port_INLINE void activity_ri5(PORT_TIMER_WIDTH capturedTime) { } // record the timeCorrection and print out at end of slot - ieee154e_vars.dataReceived->l2_timeCorrection = (PORT_SIGNED_INT_WIDTH)((PORT_SIGNED_INT_WIDTH)TsTxOffset-(PORT_SIGNED_INT_WIDTH)ieee154e_vars.syncCapturedTime); + ieee154e_vars.dataReceived->l2_timeCorrection = (PORT_SIGNED_INT_WIDTH)((PORT_SIGNED_INT_WIDTH)slotTemplate.TsTxOffset-(PORT_SIGNED_INT_WIDTH)ieee154e_vars.syncCapturedTime); // check if ack requested if (ieee802514_header.ackRequested==1 && ieee154e_vars.isAckEnabled == TRUE) { @@ -1885,7 +2147,7 @@ port_INLINE void activity_ri5(PORT_TIMER_WIDTH capturedTime) { // calculate the time timeCorrection (this is the time the sender is off w.r.t to this node. A negative number means // the sender is too late. - ieee154e_vars.timeCorrection = (PORT_SIGNED_INT_WIDTH)((PORT_SIGNED_INT_WIDTH)TsTxOffset-(PORT_SIGNED_INT_WIDTH)ieee154e_vars.syncCapturedTime); + ieee154e_vars.timeCorrection = (PORT_SIGNED_INT_WIDTH)((PORT_SIGNED_INT_WIDTH) slotTemplate.TsTxOffset-(PORT_SIGNED_INT_WIDTH)ieee154e_vars.syncCapturedTime); // prepend the IEEE802.15.4 header to the ACK ieee154e_vars.ackToSend->l2_frameType = IEEE154_TYPE_ACK; @@ -1941,6 +2203,7 @@ port_INLINE void activity_ri5(PORT_TIMER_WIDTH capturedTime) { ); // radiotimer_schedule(DURATION_rt5); #endif + } else { // synchronize to the received packet if I'm not a DAGroot and this is my preferred parent // or in case I'm in the middle of the join process when parent is not yet selected @@ -2006,6 +2269,7 @@ port_INLINE void activity_ri6(void) { openserial_printError(COMPONENT_IEEE802154E,ERR_NO_FREE_PACKET_BUFFER, (errorparameter_t)0, (errorparameter_t)0); + // indicate we received a packet anyway (we don't want to loose any) notif_receive(ieee154e_vars.dataReceived); // free local variable @@ -2021,7 +2285,7 @@ port_INLINE void activity_ri6(void) { // calculate the time timeCorrection (this is the time the sender is off w.r.t to this node. A negative number means // the sender is too late. - ieee154e_vars.timeCorrection = (PORT_SIGNED_INT_WIDTH)((PORT_SIGNED_INT_WIDTH)TsTxOffset-(PORT_SIGNED_INT_WIDTH)ieee154e_vars.syncCapturedTime); + ieee154e_vars.timeCorrection = (PORT_SIGNED_INT_WIDTH)((PORT_SIGNED_INT_WIDTH)slotTemplate.TsTxOffset-(PORT_SIGNED_INT_WIDTH)ieee154e_vars.syncCapturedTime); // prepend the IEEE802.15.4 header to the ACK ieee154e_vars.ackToSend->l2_frameType = IEEE154_TYPE_ACK; @@ -2111,6 +2375,10 @@ port_INLINE void activity_rie5(void) { port_INLINE void activity_ri8(PORT_TIMER_WIDTH capturedTime) { // change state changeState(S_TXACK); + + // capture time for radio tx duy cycle calculation + ieee154e_vars.radioTxRxInit = sctimer_readCounter(); + #ifdef SLOT_FSM_IMPLEMENTATION_MULTIPLE_TIMER_INTERRUPT // cancel rt7 sctimer_actionCancel(ACTION_SET_TIMEOUT); @@ -2156,6 +2424,14 @@ port_INLINE void activity_rie6(void) { port_INLINE void activity_ri9(PORT_TIMER_WIDTH capturedTime) { // change state changeState(S_RXPROC); + // turn off the radio + radio_rfOff(); + + // compute radio duty cycle + //ieee154e_vars.radioOnTics += (sctimer_readCounter()-ieee154e_vars.radioOnInit); + // calculate radio tics for tx duty cycle calculations + ieee154e_vars.radioTxTics += (sctimer_readCounter()-ieee154e_vars.radioTxRxInit); + #ifdef SLOT_FSM_IMPLEMENTATION_MULTIPLE_TIMER_INTERRUPT // cancel rt8 sctimer_actionCancel(ACTION_SET_TIMEOUT); @@ -2260,15 +2536,17 @@ port_INLINE bool isValidAck(ieee802154_header_iht* ieee802514_header, OpenQueueE port_INLINE void incrementAsnOffset(void) { frameLength_t frameLength; - + uint8_t i; // increment the asn - ieee154e_vars.asn.bytes0and1++; - if (ieee154e_vars.asn.bytes0and1==0) { - ieee154e_vars.asn.bytes2and3++; - if (ieee154e_vars.asn.bytes2and3==0) { - ieee154e_vars.asn.byte4++; - } - } + + ieee154e_vars.asn.bytes0and1++; + if (ieee154e_vars.asn.bytes0and1==0) { + ieee154e_vars.asn.bytes2and3++; + if (ieee154e_vars.asn.bytes2and3==0) { + ieee154e_vars.asn.byte4++; + } + } + // increment the offsets frameLength = schedule_getFrameLength(); @@ -2292,11 +2570,19 @@ port_INLINE void ieee154e_resetAsn(void) { //from upper layer that want to send the ASN to compute timing or latency port_INLINE void ieee154e_getAsn(uint8_t* array) { - array[0] = (ieee154e_vars.asn.bytes0and1 & 0xff); - array[1] = (ieee154e_vars.asn.bytes0and1/256 & 0xff); - array[2] = (ieee154e_vars.asn.bytes2and3 & 0xff); - array[3] = (ieee154e_vars.asn.bytes2and3/256 & 0xff); - array[4] = ieee154e_vars.asn.byte4; + array[0] = (ieee154e_vars.startAsn.bytes0and1 & 0xff); + array[1] = (ieee154e_vars.startAsn.bytes0and1/256 & 0xff); + array[2] = (ieee154e_vars.startAsn.bytes2and3 & 0xff); + array[3] = (ieee154e_vars.startAsn.bytes2and3/256 & 0xff); + array[4] = ieee154e_vars.startAsn.byte4; +} + +port_INLINE void getStartAsn(uint8_t* array) { + array[0] = (ieee154e_vars.startAsn.bytes0and1 & 0xff); + array[1] = (ieee154e_vars.startAsn.bytes0and1/256 & 0xff); + array[2] = (ieee154e_vars.startAsn.bytes2and3 & 0xff); + array[3] = (ieee154e_vars.startAsn.bytes2and3/256 & 0xff); + array[4] = ieee154e_vars.startAsn.byte4; } port_INLINE uint16_t ieee154e_getTimeCorrection(void) { @@ -2313,6 +2599,29 @@ void ieee154e_getTicsInfo(uint32_t* numTicsOn, uint32_t* numTicsTotal){ *numTicsTotal = (uint32_t)(ieee154e_stats.numTicsTotal); } +void ieee154e_getRadioTicsInfo( + uint32_t* numTxTics, + uint32_t* numTicsOn, + uint32_t* numTxTics_0, + uint32_t* numTicsOn_0, + uint32_t* numTxTics_1, + uint32_t* numTicsOn_1, + uint32_t* numTxTics_2, + uint32_t* numTicsOn_2, + uint32_t* numTicsTotal + ){ + + *numTxTics = (uint32_t)(ieee154e_stats.numTxTics); + *numTicsOn = (uint32_t)(ieee154e_stats.numTicsOn); + *numTxTics_0 = (uint32_t)(ieee154e_stats.numTxTics_0); + *numTicsOn_0 = (uint32_t)(ieee154e_stats.numTicsOn_0); + *numTxTics_1 = (uint32_t)(ieee154e_stats.numTxTics_1); + *numTicsOn_1 = (uint32_t)(ieee154e_stats.numTicsOn_1); + *numTxTics_2 = (uint32_t)(ieee154e_stats.numTxTics_2); + *numTicsOn_2 = (uint32_t)(ieee154e_stats.numTicsOn_2); + *numTicsTotal = (uint32_t)(ieee154e_stats.numTicsTotal); +} + port_INLINE void joinPriorityStoreFromEB(uint8_t jp){ ieee154e_vars.dataReceived->l2_joinPriority = jp; ieee154e_vars.dataReceived->l2_joinPriorityPresent = TRUE; @@ -2383,7 +2692,9 @@ bool isValidEbFormat(OpenQueueEntry_t* pkt, uint16_t* lenIE){ open_addr_t temp_neighbor; uint16_t slotoffset; uint16_t channeloffset; - + uint16_t linkoptions; + cellRadioSetting_t cellRadioSetting; + chTemplate_checkPass = FALSE; tsTemplate_checkpass = FALSE; sync_ie_checkPass = FALSE; @@ -2453,6 +2764,7 @@ bool isValidEbFormat(OpenQueueEntry_t* pkt, uint16_t* lenIE){ sublen = (temp16b & IEEE802154E_DESC_LEN_SHORT_MLME_IE_MASK); switch(subid){ case IEEE802154E_MLME_SYNC_IE_SUBID: + // this is where the ASN is stored asnStoreFromEB((uint8_t*)(pkt->payload+ptr)); joinPriorityStoreFromEB(*((uint8_t*)(pkt->payload)+ptr+5)); sync_ie_checkPass = TRUE; @@ -2474,21 +2786,26 @@ bool isValidEbFormat(OpenQueueEntry_t* pkt, uint16_t* lenIE){ // shared TXRX anycast slot(s) memset(&temp_neighbor,0,sizeof(temp_neighbor)); temp_neighbor.type = ADDR_ANYCAST; - for (i=0;ipayload+ptr+5+5*i)); // slotframes length - slotoffset |= *((uint8_t*)(pkt->payload+ptr+5+5*i+1))<<8; + slotoffset = *((uint8_t*)(pkt->payload+ptr+5+5*i)); // slot offset + slotoffset |= *((uint8_t*)(pkt->payload+ptr+5+5*i+1))<<8; - channeloffset = *((uint8_t*)(pkt->payload+ptr+5+5*i+2)); // slotframes length + channeloffset = *((uint8_t*)(pkt->payload+ptr+5+5*i+2)); // channel offset channeloffset |= *((uint8_t*)(pkt->payload+ptr+5+5*i+3))<<8; + linkoptions = *((uint8_t*)(pkt->payload+ptr+5+5*i+4)); // link options + //linkoptions |= *((uint8_t*)(pkt->payload+ptr+5+5*i+6))<<8; + + //extract cell radiosetting with bitmask 0x60 + cellRadioSetting = (cellRadioSetting_t)(linkoptions & 0x60)>>5; schedule_addActiveSlot( - slotoffset, // slot offset - CELLTYPE_TXRX, // type of slot - TRUE, // shared? - FALSE, // auto cell - channeloffset, // channel offset - &temp_neighbor // neighbor + slotoffset, // slot offset + CELLTYPE_TXRX, // type of slot + TRUE, // shared? + FALSE, // auto cell + cellRadioSetting, // cell radiosetting + channeloffset, // channel offset + &temp_neighbor // neighbor ); } } @@ -2525,14 +2842,23 @@ port_INLINE void asnStoreFromEB(uint8_t* asn) { ieee154e_vars.asn.byte4 = asn[4]; } +port_INLINE void storeStartASN(void) { + + // store the ASN + ieee154e_vars.startAsn.bytes0and1 = ieee154e_vars.asn.bytes0and1; + ieee154e_vars.startAsn.bytes2and3 = ieee154e_vars.asn.bytes2and3; + ieee154e_vars.startAsn.byte4 = ieee154e_vars.asn.byte4; +} + port_INLINE void ieee154e_syncSlotOffset(void) { frameLength_t frameLength; uint32_t slotOffset; uint8_t i; + uint8_t superSlotLength; frameLength = schedule_getFrameLength(); - // determine the current slotOffset + // determine the current slotOffset (of the ASN from EB?) slotOffset = ieee154e_vars.asn.byte4; slotOffset = slotOffset % frameLength; slotOffset = slotOffset << 16; @@ -2541,12 +2867,20 @@ port_INLINE void ieee154e_syncSlotOffset(void) { slotOffset = slotOffset << 16; slotOffset = slotOffset + ieee154e_vars.asn.bytes0and1; slotOffset = slotOffset % frameLength; - + + // this is the offset sent from EB (at end of the superSLot of a minimal cell) ieee154e_vars.slotOffset = (slotOffset_t) slotOffset; - + + // get the superSlot length of this PHY + superSlotLength = superSlotLengthMap[ieee154e_vars.cellRadioSetting]; + + // update the current offset to the initial Microslot + //ieee154e_vars.slotOffset = ieee154e_vars.slotOffset; - superSlotLength +1; + + // change the current slot to this entry schedule_syncSlotOffset(ieee154e_vars.slotOffset); - ieee154e_vars.nextActiveSlotOffset = schedule_getNextActiveSlotOffset(); - /* + + /* infer the asnOffset based on the fact that ieee154e_vars.freq = 11 + (asnOffset + channelOffset)%16 */ @@ -2555,7 +2889,20 @@ port_INLINE void ieee154e_syncSlotOffset(void) { break; } } + // what is going on here? ieee154e_vars.asnOffset = i - schedule_getChannelOffset(); + + // get the next active slot. + ieee154e_vars.nextActiveSlotOffset = schedule_getNextActiveSlotOffset(); + + // then fast-forward the offset to the end of the superSlot + // otherwise, the frame length will be extended + + for (i=0;i= 11 && ieee154e_vars.singleChannel <= 26 ) { return ieee154e_vars.singleChannel; // single channel @@ -2874,7 +3240,7 @@ function should already have been done. If this is not the case, this function will do that for you, but assume that something went wrong. */ void endSlot(void) { - + open_addr_t slotNeighbor; open_addr_t parentAddress; slotinfo_element_t info; @@ -2903,17 +3269,43 @@ void endSlot(void) { ieee154e_vars.lastCapturedTime = 0; ieee154e_vars.syncCapturedTime = 0; - // compute duty cycle. + // compute duty cycle for radio on time. ieee154e_stats.numTicsOn+=ieee154e_vars.radioOnTics;//accumulate and tics the radio is on for that window ieee154e_stats.numTicsTotal+=ieee154e_vars.slotDuration;//increment total tics by timer period. + + // compute duty cycle for raio tx time. + ieee154e_stats.numTxTics+=ieee154e_vars.radioTxTics;//accumulate and tics the radio is transmitting for that window + + // compute duty cycle for raio rx time. + ieee154e_stats.numRxTics+=ieee154e_vars.radioRxTics;//accumulate and tics the radio is receiving for that window if (ieee154e_stats.numTicsTotal>DUTY_CYCLE_WINDOW_LIMIT){ ieee154e_stats.numTicsTotal = ieee154e_stats.numTicsTotal>>1; ieee154e_stats.numTicsOn = ieee154e_stats.numTicsOn>>1; + ieee154e_stats.numTicsOn_0 = ieee154e_stats.numTicsOn_0>>1; + ieee154e_stats.numTicsOn_1 = ieee154e_stats.numTicsOn_1>>1; + ieee154e_stats.numTicsOn_2 = ieee154e_stats.numTicsOn_2>>1; } - + // updating radio-specific DC stats + switch (ieee154e_vars.cellRadioSetting){ + case CELLRADIOSETTING_1: + ieee154e_stats.numTxTics_0+=ieee154e_vars.radioTxTics;//accumulate and tics the radio is transmitting for that window + ieee154e_stats.numTicsOn_0+=ieee154e_vars.radioOnTics;//accumulate and tics the radio is on for that window + break; + case CELLRADIOSETTING_2: + ieee154e_stats.numTxTics_1+=ieee154e_vars.radioTxTics;//accumulate and tics the radio is transmitting for that window + ieee154e_stats.numTicsOn_1+=ieee154e_vars.radioOnTics;//accumulate and tics the radio is on for that window + break; + case CELLRADIOSETTING_3: + ieee154e_stats.numTxTics_2+=ieee154e_vars.radioTxTics;//accumulate and tics the radio is transmitting for that window + ieee154e_stats.numTicsOn_2+=ieee154e_vars.radioOnTics;//accumulate and tics the radio is on for that window + break; + } + // clear vars for duty cycle on this slot ieee154e_vars.radioOnTics=0; + ieee154e_vars.radioTxTics=0; + ieee154e_vars.radioRxTics=0; ieee154e_vars.radioOnThisSlot=FALSE; // clean up dataToSend @@ -2958,13 +3350,13 @@ void endSlot(void) { if (icmpv6rpl_getPreferredParentEui64(&parentAddress)){ if (schedule_hasNegotiatedCellToNeighbor(&parentAddress, CELLTYPE_RX) == FALSE) { // adapt traffic on auto rx for downstream traffic - msf_updateCellsElapsed(&parentAddress, CELLTYPE_RX); + msf_updateCellsElapsed(&parentAddress, ieee154e_vars.cellRadioSetting, CELLTYPE_RX); } } } else { // update numelapsed on rx cell (msf will check whether it // is to parent or not) - msf_updateCellsElapsed(&info.address, CELLTYPE_RX); + msf_updateCellsElapsed(&info.address, ieee154e_vars.cellRadioSetting, CELLTYPE_RX); } } ieee154e_vars.receivedFrameFromParent = FALSE; @@ -2998,9 +3390,10 @@ void endSlot(void) { // check if this is auto tx cell if ( - schedule_getSlottOffset() == ieee154e_vars.slotOffset && + schedule_getSlottOffset() == (ieee154e_vars.slotOffset- ieee154e_vars.superSlotLength+1) && schedule_getIsAutoCell() && - schedule_getType() == CELLTYPE_TX + schedule_getType() == CELLTYPE_TX + ){ // check if there are unicast packets to the neighbor of this slot // if no, remove the cell @@ -3008,12 +3401,13 @@ void endSlot(void) { schedule_getNeighbor(&slotNeighbor); if (openqueue_macGetUnicastPakcet(&slotNeighbor)==NULL) { schedule_removeActiveSlot( - ieee154e_vars.slotOffset, + ieee154e_vars.slotOffset- ieee154e_vars.superSlotLength+1, CELLTYPE_TX, TRUE, &slotNeighbor ); } + } // change state diff --git a/openstack/02a-MAClow/IEEE802154E.h b/openstack/02a-MAClow/IEEE802154E.h index 117aa7f3e6..015575b8c6 100644 --- a/openstack/02a-MAClow/IEEE802154E.h +++ b/openstack/02a-MAClow/IEEE802154E.h @@ -1,347 +1,391 @@ -#ifndef __IEEE802154E_H -#define __IEEE802154E_H - -/** -\addtogroup MAClow -\{ -\addtogroup IEEE802154E -\{ -*/ - -#include "opendefs.h" -#include "board.h" -#include "opentimers.h" -#include "schedule.h" - -//=========================== debug define ==================================== - -//=========================== static ========================================== -static const uint8_t chTemplate_default[] = { - 5,6,12,7,15,4,14,11,8,0,1,2,13,3,9,10 -}; - -// refer to RFC8180: https://tools.ietf.org/html/rfc8180#appendix-A.1 -// ASN and join Metric are replaced later when sending an EB -static const uint8_t ebIEsBytestream[] = { - 0x1A,0x88,0x06,0x1A,0x00,0x00, 0x00,0x00, 0x00,0x00,0x01,0x1C,0x00,0x01, - 0xC8,0x00,0x0A,0x1B,0x01,0x00,SLOTFRAME_LENGTH,0x00,SCHEDULE_MINIMAL_6TISCH_ACTIVE_CELLS,0x00,0x00,0x00,0x00,0x0F -}; -//=========================== define ========================================== - -#define EB_ASN0_OFFSET 4 -#define EB_JP_OFFSET 9 -#define EB_SLOTFRAME_TS_ID_OFFSET 12 -#define EB_SLOTFRAME_CH_ID_OFFSET 15 -#define EB_SLOTFRAME_LEN_OFFSET 20 -#define EB_SLOTFRAME_NUMLINK_OFFSET 22 - -#define EB_IE_LEN 28 - -#define NUM_CHANNELS 16 // number of channels to channel hop on -#define TXRETRIES 15 // number of MAC retries before declaring failed -#define TX_POWER 31 // 1=-25dBm, 31=0dBm (max value) -#define RESYNCHRONIZATIONGUARD 5 // in 32kHz ticks. min distance to the end of the slot to successfully synchronize -#define EB_PORTION 10 // set EB on minimal cell for 1/EB_PORTION portion -#define MAXKAPERIOD 1000 // in slots: 1500@20ms per slot -> ~30 seconds. Max value used by adaptive synchronization. -#define DESYNCTIMEOUT 1750 // in slots: 1750@20ms per slot -> ~35 seconds. A larger DESYNCTIMEOUT is needed if using a larger KATIMEOUT. -#define LIMITLARGETIMECORRECTION 5 // threshold number of ticks to declare a timeCorrection "large" -#define LENGTH_IEEE154_MAX 128 // max length of a valid radio packet -#define DUTY_CYCLE_WINDOW_LIMIT (0xFFFFFFFF>>1) // limit of the dutycycle window -#define SERIALINHIBITGUARD (1000/PORT_US_PER_TICK) // 32@32kHz ~ 1ms - -//15.4e information elements related -#define IEEE802154E_PAYLOAD_DESC_LEN_SHIFT 0x04 -#define IEEE802154E_PAYLOAD_DESC_GROUP_ID_MLME (1<<11) -#define IEEE802154E_PAYLOAD_DESC_TYPE_MLME (1<<15) -#define IEEE802154E_DESC_TYPE_LONG ((uint16_t)(1<<15)) -#define IEEE802154E_DESC_TYPE_SHORT ((uint16_t)(0<<15)) - -// GROUP_ID changed to 5 (IETF IE) https://openwsn.atlassian.net/browse/FW-569 -#define IANA_IETF_IE_GROUP_ID (5<<11) -#define IANA_IETF_IE_TYPE (1<<15) -#define IEEE802154E_DESC_LEN_PAYLOAD_ID_TYPE_MASK 0xF800 - -#define IEEE802154E_DESC_TYPE_HEADER_IE 0x0000 -#define IEEE802154E_DESC_TYPE_PAYLOAD_IE 0x8000 -//len field on PAYLOAD/HEADER DESC -#define IEEE802154E_DESC_LEN_HEADER_IE_MASK 0x007F -#define IEEE802154E_DESC_LEN_PAYLOAD_IE_MASK 0x07FF - -//groupID/elementID field on PAYLOAD/HEADER DESC -#define IEEE802154E_DESC_ELEMENTID_HEADER_IE_MASK 0x7F80 -#define IEEE802154E_DESC_GROUPID_PAYLOAD_IE_MASK 0x7800 - -#define IEEE802154E_DESC_ELEMENTID_HEADER_IE_SHIFT 7 -#define IEEE802154E_DESC_GROUPID_PAYLOAD_IE_SHIFT 11 - -//type field on PAYLOAD/HEADER DESC -#define IEEE802154E_DESC_TYPE_IE_MASK 0x8000 - -#define IEEE802154E_DESC_TYPE_IE_SHIFT 15 - -//MLME Sub IE LONG page 83 -#define IEEE802154E_DESC_LEN_LONG_MLME_IE_MASK 0x07FF -#define IEEE802154E_DESC_SUBID_LONG_MLME_IE_MASK 0x7800 - -#define IEEE802154E_DESC_SUBID_LONG_MLME_IE_SHIFT 11 - -//MLME Sub IE SHORT page 82 -#define IEEE802154E_DESC_LEN_SHORT_MLME_IE_MASK 0x00FF -#define IEEE802154E_DESC_SUBID_SHORT_MLME_IE_MASK 0x7F00 - -#define IEEE802154E_DESC_SUBID_SHORT_MLME_IE_SHIFT 8 - -#define IEEE802154E_MLME_SYNC_IE_SUBID 0x1A -#define IEEE802154E_MLME_SYNC_IE_SUBID_SHIFT 8 -#define IEEE802154E_MLME_SLOTFRAME_LINK_IE_SUBID 0x1B -#define IEEE802154E_MLME_SLOTFRAME_LINK_IE_SUBID_SHIFT 8 -#define IEEE802154E_MLME_TIMESLOT_IE_SUBID 0x1c -#define IEEE802154E_MLME_TIMESLOT_IE_SUBID_SHIFT 8 -#define IEEE802154E_MLME_CHANNELHOPPING_IE_SUBID 0x09 -#define IEEE802154E_MLME_CHANNELHOPPING_IE_SUBID_SHIFT 11 - -#define IEEE802154E_MLME_IE_GROUPID 0x01 -#define IEEE802154E_ACK_NACK_TIMECORRECTION_ELEMENTID 0x1E - -/** -When a packet is received, it is written inside the OpenQueueEntry_t->packet -buffer, starting at the byte defined below. When a packet is relayed, it -traverses the stack in which the MAC and IPHC headers are parsed and stripped -off, then put on again. During that process, the IPv6 hop limit field is -decremented. Depending on the new value of the hop limit, the IPHC header -compression algorithm might not be able to compress it, and hence has to carry -it inline, adding a byte to the header. To avoid having to move bytes around -inside OpenQueueEntry_t->packet buffer, we start writing the received packet a -bit after the start of the packet. -*/ -#define FIRST_FRAME_BYTE 1 - -// the different states of the IEEE802.15.4e state machine -typedef enum { - S_SLEEP = 0x00, // ready for next slot - // synchronizing - S_SYNCLISTEN = 0x01, // listened for packet to synchronize to network - S_SYNCRX = 0x02, // receiving packet to synchronize to network - S_SYNCPROC = 0x03, // processing packet just received - // TX - S_TXDATAOFFSET = 0x04, // waiting to prepare for Tx data - S_TXDATAPREPARE = 0x05, // preparing for Tx data - S_TXDATAREADY = 0x06, // ready to Tx data, waiting for 'go' - S_TXDATADELAY = 0x07, // 'go' signal given, waiting for SFD Tx data - S_TXDATA = 0x08, // Tx data SFD received, sending bytes - S_RXACKOFFSET = 0x09, // Tx data done, waiting to prepare for Rx ACK - S_RXACKPREPARE = 0x0a, // preparing for Rx ACK - S_RXACKREADY = 0x0b, // ready to Rx ACK, waiting for 'go' - S_RXACKLISTEN = 0x0c, // idle listening for ACK - S_RXACK = 0x0d, // Rx ACK SFD received, receiving bytes - S_TXPROC = 0x0e, // processing sent data - // RX - S_RXDATAOFFSET = 0x0f, // waiting to prepare for Rx data - S_RXDATAPREPARE = 0x10, // preparing for Rx data - S_RXDATAREADY = 0x11, // ready to Rx data, waiting for 'go' - S_RXDATALISTEN = 0x12, // idle listening for data - S_RXDATA = 0x13, // data SFD received, receiving more bytes - S_TXACKOFFSET = 0x14, // waiting to prepare for Tx ACK - S_TXACKPREPARE = 0x15, // preparing for Tx ACK - S_TXACKREADY = 0x16, // Tx ACK ready, waiting for 'go' - S_TXACKDELAY = 0x17, // 'go' signal given, waiting for SFD Tx ACK - S_TXACK = 0x18, // Tx ACK SFD received, sending bytes - S_RXPROC = 0x19, // processing received data -} ieee154e_state_t; - -#define TIMESLOT_TEMPLATE_ID 0x00 -#define CHANNELHOPPING_TEMPLATE_ID 0x00 - -// Atomic durations -// expressed in 32kHz ticks: -// - ticks = duration_in_seconds * 32768 -// - duration_in_seconds = ticks / 32768 -enum ieee154e_atomicdurations_enum { - -// time-slot related -#if SLOTDURATION==10 - TsTxOffset = (2120/PORT_US_PER_TICK), // 2120us - TsLongGT = (1100/PORT_US_PER_TICK), // 1100us - TsTxAckDelay = (1000/PORT_US_PER_TICK), // 1000us - TsShortGT = (500/PORT_US_PER_TICK), // 500us, The standardlized value for this is 400/2=200us(7ticks). Currectly 7 doesn't work for short packet, change it back to 7 when found the problem. - wdRadioTx = (1342/PORT_US_PER_TICK), // 1000us (needs to be >delayTx) (SCuM need a larger value, 45 is tested and works) - wdDataDuration = (5000/PORT_US_PER_TICK), // 5000us (measured 4280us with max payload) - wdAckDuration = (3000/PORT_US_PER_TICK), // 3000us (measured 1000us) -#endif - -#if SLOTDURATION==20 - TsTxOffset = (5215/PORT_US_PER_TICK), // 5215us - TsLongGT = (1311/PORT_US_PER_TICK), // 1311us - TsTxAckDelay = (5521/PORT_US_PER_TICK), // 5521us - TsShortGT = (700/PORT_US_PER_TICK), // 700us - wdRadioTx = (1342/PORT_US_PER_TICK), // 1000us (needs to be >delayTx) (SCuM need a larger value, 45 is tested and works) - wdDataDuration = (5000/PORT_US_PER_TICK), // 5000us (measured 4280us with max payload) - wdAckDuration = (3000/PORT_US_PER_TICK), // 3000us (measured 1000us) -#endif - -#if SLOTDURATION==160 - TsTxOffset = (10986/PORT_US_PER_TICK), // 360 ticks, 10986us - TsLongGT = (7324/PORT_US_PER_TICK), // 240 ticks, 7324us - TsTxAckDelay = (11047/PORT_US_PER_TICK), // 362 ticks, 11047us - TsShortGT = (1831/PORT_US_PER_TICK), // 60 ticksz 1831us - // radio watchdog - wdRadioTx = (7019/PORT_US_PER_TICK), // 230 ticks 7019us delayTx+Tx time for 10 bytes( (needs to be >delayTx) (SCuM need a larger value, 45 is tested and works) - wdDataDuration = (81238/PORT_US_PER_TICK), // 2662 ticks 81238us (measured with max payload) - wdAckDuration = (18310/PORT_US_PER_TICK), // 600 ticks 18310us (measured) - -#endif - TsSlotDuration = PORT_TsSlotDuration, - // execution speed related - maxTxDataPrepare = PORT_maxTxDataPrepare, - maxRxAckPrepare = PORT_maxRxAckPrepare, - maxRxDataPrepare = PORT_maxRxDataPrepare, - maxTxAckPrepare = PORT_maxTxAckPrepare, - // radio speed related - delayTx = PORT_delayTx, // between GO signal and SFD - delayRx = PORT_delayRx, // between GO signal and start listening - // radio watchdog - -}; - -//shift of bytes in the linkOption bitmap: draft-ietf-6tisch-minimal-10.txt: page 6 -enum ieee154e_linkOption_enum { - FLAG_TX_S = 0, - FLAG_RX_S = 1, - FLAG_SHARED_S = 2, - FLAG_TIMEKEEPING_S = 3, -}; - -// FSM timer durations (combinations of atomic durations) -// TX -#define DURATION_tt1 ieee154e_vars.lastCapturedTime+TsTxOffset-delayTx-maxTxDataPrepare -#define DURATION_tt2 ieee154e_vars.lastCapturedTime+TsTxOffset-delayTx -#define DURATION_tt3 ieee154e_vars.lastCapturedTime+TsTxOffset-delayTx+wdRadioTx -#define DURATION_tt4 ieee154e_vars.lastCapturedTime+wdDataDuration -#define DURATION_tt5 ieee154e_vars.lastCapturedTime+TsTxAckDelay-TsShortGT-delayRx-maxRxAckPrepare -#define DURATION_tt6 ieee154e_vars.lastCapturedTime+TsTxAckDelay-TsShortGT-delayRx -#define DURATION_tt7 ieee154e_vars.lastCapturedTime+TsTxAckDelay+TsShortGT -#define DURATION_tt8 ieee154e_vars.lastCapturedTime+wdAckDuration -// RX -#define DURATION_rt1 ieee154e_vars.lastCapturedTime+TsTxOffset-TsLongGT-delayRx-maxRxDataPrepare -#define DURATION_rt2 ieee154e_vars.lastCapturedTime+TsTxOffset-TsLongGT-delayRx -#define DURATION_rt3 ieee154e_vars.lastCapturedTime+TsTxOffset+TsLongGT -#define DURATION_rt4 ieee154e_vars.lastCapturedTime+wdDataDuration -#define DURATION_rt5 ieee154e_vars.lastCapturedTime+TsTxAckDelay-delayTx-maxTxAckPrepare -#define DURATION_rt6 ieee154e_vars.lastCapturedTime+TsTxAckDelay-delayTx -#define DURATION_rt7 ieee154e_vars.lastCapturedTime+TsTxAckDelay-delayTx+wdRadioTx -#define DURATION_rt8 ieee154e_vars.lastCapturedTime+wdAckDuration -// serialInhibit -#define DURATION_si ieee154e_vars.slotDuration-SERIALINHIBITGUARD - -//=========================== typedef ========================================= - -// IEEE802.15.4E acknowledgement (ACK) -typedef struct { - PORT_SIGNED_INT_WIDTH timeCorrection; -} IEEE802154E_ACK_ht; - -//=========================== module variables ================================ - -typedef struct { - // misc - asn_t asn; // current absolute slot number - slotOffset_t slotOffset; // current slot offset - slotOffset_t nextActiveSlotOffset; // next active slot offset - PORT_TIMER_WIDTH deSyncTimeout; // how many slots left before looses sync - bool isSync; // TRUE iff mote is synchronized to network - OpenQueueEntry_t localCopyForTransmission;// copy of the frame used for current TX - PORT_TIMER_WIDTH numOfSleepSlots; // number of slots to sleep between active slots - // as shown on the chronogram - ieee154e_state_t state; // state of the FSM - OpenQueueEntry_t* dataToSend; // pointer to the data to send - OpenQueueEntry_t* dataReceived; // pointer to the data received - OpenQueueEntry_t* ackToSend; // pointer to the ack to send - OpenQueueEntry_t* ackReceived; // pointer to the ack received - PORT_TIMER_WIDTH lastCapturedTime; // last captured time - PORT_TIMER_WIDTH syncCapturedTime; // captured time used to sync - // channel hopping - uint8_t freq; // frequency of the current slot - uint8_t asnOffset; // offset inside the frame - uint8_t singleChannel; // the single channel used for transmission - bool singleChannelChanged; // detect id singleChannelChanged - uint8_t chTemplate[NUM_CHANNELS];// storing the template of hopping sequence - // template ID - uint8_t tsTemplateId; // timeslot template id - uint8_t chTemplateId; // channel hopping tempalte id - - PORT_TIMER_WIDTH radioOnInit; // when within the slot the radio turns on - PORT_TIMER_WIDTH radioOnTics; // how many tics within the slot the radio is on - bool radioOnThisSlot; // to control if the radio has been turned on in a slot. - - // control - bool isAckEnabled; // whether reply for ack, used for synchronization test - bool isSecurityEnabled; // whether security is applied - // time correction - int16_t timeCorrection; // store the timeCorrection, prepend and retrieve it inside of frame header - - uint16_t slotDuration; // duration of slot - opentimers_id_t timerId; // id of timer used for implementing TSCH slot FSM - uint32_t startOfSlotReference; // the time refer to the beginning of slot - opentimers_id_t serialInhibitTimerId; // id of serial inhibit timer used for scheduling serial output - - // for msf downstream traffic adaptation - uint32_t receivedFrameFromParent; // True when received a frame from parent - - uint16_t compensatingCounter; -} ieee154e_vars_t; - -BEGIN_PACK -typedef struct { - uint8_t numSyncPkt; // how many times synchronized on a non-ACK packet - uint8_t numSyncAck; // how many times synchronized on an ACK - int16_t minCorrection; // minimum time correction - int16_t maxCorrection; // maximum time correction - uint8_t numDeSync; // number of times a desync happened - uint32_t numTicsOn; // mac dutyCycle - uint32_t numTicsTotal; // total tics for which the dutycycle is computed -} ieee154e_stats_t; -END_PACK - -typedef struct { - PORT_TIMER_WIDTH num_newSlot; - PORT_TIMER_WIDTH num_timer; - PORT_TIMER_WIDTH num_startOfFrame; - PORT_TIMER_WIDTH num_endOfFrame; -} ieee154e_dbg_t; - -//=========================== prototypes ====================================== - -// admin -void ieee154e_init(void); -// public -PORT_TIMER_WIDTH ieee154e_asnDiff(asn_t* someASN); -#ifdef DEADLINE_OPTION_ENABLED -int16_t ieee154e_computeAsnDiff(asn_t* h_asn, asn_t* l_asn); -void ieee154e_calculateExpTime(uint16_t max_delay, uint8_t* et_asn); -void ieee154e_orderToASNStructure(uint8_t* in,asn_t* val_asn); -#endif -bool ieee154e_isSynch(void); -void ieee154e_getAsn(uint8_t* array); -void ieee154e_setIsAckEnabled(bool isEnabled); -void ieee154e_setSingleChannel(uint8_t channel); -void ieee154e_setIsSecurityEnabled(bool isEnabled); -void ieee154e_setSlotDuration(uint16_t duration); -uint16_t ieee154e_getSlotDuration(void); - -uint16_t ieee154e_getTimeCorrection(void); -void ieee154e_getTicsInfo(uint32_t* numTicsOn, uint32_t* numTicsTotal); -// events -void ieee154e_startOfFrame(PORT_TIMER_WIDTH capturedTime); -void ieee154e_endOfFrame(PORT_TIMER_WIDTH capturedTime); -// misc -bool debugPrint_asn(void); -bool debugPrint_isSync(void); -bool debugPrint_macStats(void); - -/** -\} -\} -*/ - -#endif - +#ifndef __IEEE802154E_H +#define __IEEE802154E_H + +/** +\addtogroup MAClow +\{ +\addtogroup IEEE802154E +\{ +*/ + +#include "opendefs.h" +#include "board.h" +#include "opentimers.h" +#include "schedule.h" +#include "radio.h" + +//=========================== debug define ==================================== + +//=========================== static ========================================== +static const uint8_t chTemplate_default[] = { + 5,6,12,7,15,4,14,11,8,0,1,2,13,3,9,10 +}; + +// refer to RFC8180: https://tools.ietf.org/html/rfc8180#appendix-A.1 +// ASN and join Metric are replaced later when sending an EB +static const uint8_t ebIEsBytestream[] = { + 0x1A,0x88,0x06,0x1A,0x00,0x00, 0x00,0x00, 0x00,0x00,0x01,0x1C,0x00,0x01, + 0xC8,0x00,0x0A,0x1B,0x01,0x00,SLOTFRAME_LENGTH,0x00,SCHEDULE_MINIMAL_6TISCH_ACTIVE_CELLS,SCHEDULE_MINIMAL_6TISCH_SLOTOFFSET,0x00,0x00,0x00,0x0F +}; + +// Defining link options for each minimal active cell + +static const uint8_t cellLinkOptions [SCHEDULE_MINIMAL_6TISCH_ACTIVE_CELLS] = { + CELLOPTIONS_TX|CELLOPTIONS_RX|CELLOPTIONS_SHARED|CELLOPTIONS_TIMEKEPPING| CELLRADIOSETTING_1<<5 , + CELLOPTIONS_TX|CELLOPTIONS_RX|CELLOPTIONS_SHARED|CELLOPTIONS_TIMEKEPPING| CELLRADIOSETTING_2<<5 , + CELLOPTIONS_TX|CELLOPTIONS_RX|CELLOPTIONS_SHARED|CELLOPTIONS_TIMEKEPPING| CELLRADIOSETTING_3<<5 +}; +//=========================== define ========================================== + + +#define EB_ASN0_OFFSET 4 +#define EB_JP_OFFSET 9 +#define EB_SLOTFRAME_TS_ID_OFFSET 12 +#define EB_SLOTFRAME_CH_ID_OFFSET 15 +#define EB_SLOTFRAME_LEN_OFFSET 20 +#define EB_SLOTFRAME_NUMLINK_OFFSET 22 + +#define EB_IE_LEN 28 + +#define NUM_CHANNELS 16 // number of channels to channel hop on +#define TXRETRIES 15 // number of MAC retries before declaring failed // original 15 +#define TX_POWER 31 // 1=-25dBm, 31=0dBm (max value) +#define RESYNCHRONIZATIONGUARD 5 // in 32kHz ticks. min distance to the end of the slot to successfully synchronize +#define EB_PORTION 10 // set EB on minimal cell for 1/EB_PORTION portion +#define MIN_RX_PORTION 1 // Turn On receiver at min cell +#define MAXKAPERIOD 2000 // in slots: 1500@20ms per slot -> ~30 seconds. Max value used by adaptive synchronization (30000 ms / slot duration). Keep alives sent over auto cells or dedicated cells. +#define DESYNCTIMEOUT 3500 // in slots: 1750@20ms per slot -> ~35 seconds. A larger DESYNCTIMEOUT is needed if using a larger KATIMEOUT. (35000 ms / slot duration) +#define LIMITLARGETIMECORRECTION 5 // threshold number of ticks to declare a timeCorrection "large" +#define LENGTH_IEEE154_MAX 128 // max length of a valid radio packet +#define DUTY_CYCLE_WINDOW_LIMIT (0xFFFFFFFF>>1) // limit of the dutycycle window +#define SERIALINHIBITGUARD (1000/PORT_US_PER_TICK) // 32@32kHz ~ 1ms + +//15.4e information elements related +#define IEEE802154E_PAYLOAD_DESC_LEN_SHIFT 0x04 +#define IEEE802154E_PAYLOAD_DESC_GROUP_ID_MLME (1<<11) +#define IEEE802154E_PAYLOAD_DESC_TYPE_MLME (1<<15) +#define IEEE802154E_DESC_TYPE_LONG ((uint16_t)(1<<15)) +#define IEEE802154E_DESC_TYPE_SHORT ((uint16_t)(0<<15)) + +// GROUP_ID changed to 5 (IETF IE) https://openwsn.atlassian.net/browse/FW-569 +#define IANA_IETF_IE_GROUP_ID (5<<11) +#define IANA_IETF_IE_TYPE (1<<15) +#define IEEE802154E_DESC_LEN_PAYLOAD_ID_TYPE_MASK 0xF800 + +#define IEEE802154E_DESC_TYPE_HEADER_IE 0x0000 +#define IEEE802154E_DESC_TYPE_PAYLOAD_IE 0x8000 +//len field on PAYLOAD/HEADER DESC +#define IEEE802154E_DESC_LEN_HEADER_IE_MASK 0x007F +#define IEEE802154E_DESC_LEN_PAYLOAD_IE_MASK 0x07FF + +//groupID/elementID field on PAYLOAD/HEADER DESC +#define IEEE802154E_DESC_ELEMENTID_HEADER_IE_MASK 0x7F80 +#define IEEE802154E_DESC_GROUPID_PAYLOAD_IE_MASK 0x7800 + +#define IEEE802154E_DESC_ELEMENTID_HEADER_IE_SHIFT 7 +#define IEEE802154E_DESC_GROUPID_PAYLOAD_IE_SHIFT 11 + +//type field on PAYLOAD/HEADER DESC +#define IEEE802154E_DESC_TYPE_IE_MASK 0x8000 + +#define IEEE802154E_DESC_TYPE_IE_SHIFT 15 + +//MLME Sub IE LONG page 83 +#define IEEE802154E_DESC_LEN_LONG_MLME_IE_MASK 0x07FF +#define IEEE802154E_DESC_SUBID_LONG_MLME_IE_MASK 0x7800 + +#define IEEE802154E_DESC_SUBID_LONG_MLME_IE_SHIFT 11 + +//MLME Sub IE SHORT page 82 +#define IEEE802154E_DESC_LEN_SHORT_MLME_IE_MASK 0x00FF +#define IEEE802154E_DESC_SUBID_SHORT_MLME_IE_MASK 0x7F00 + +#define IEEE802154E_DESC_SUBID_SHORT_MLME_IE_SHIFT 8 + +#define IEEE802154E_MLME_SYNC_IE_SUBID 0x1A +#define IEEE802154E_MLME_SYNC_IE_SUBID_SHIFT 8 +#define IEEE802154E_MLME_SLOTFRAME_LINK_IE_SUBID 0x1B +#define IEEE802154E_MLME_SLOTFRAME_LINK_IE_SUBID_SHIFT 8 +#define IEEE802154E_MLME_TIMESLOT_IE_SUBID 0x1c +#define IEEE802154E_MLME_TIMESLOT_IE_SUBID_SHIFT 8 +#define IEEE802154E_MLME_CHANNELHOPPING_IE_SUBID 0x09 +#define IEEE802154E_MLME_CHANNELHOPPING_IE_SUBID_SHIFT 11 + +#define IEEE802154E_MLME_IE_GROUPID 0x01 +#define IEEE802154E_ACK_NACK_TIMECORRECTION_ELEMENTID 0x1E + +/** +When a packet is received, it is written inside the OpenQueueEntry_t->packet +buffer, starting at the byte defined below. When a packet is relayed, it +traverses the stack in which the MAC and IPHC headers are parsed and stripped +off, then put on again. During that process, the IPv6 hop limit field is +decremented. Depending on the new value of the hop limit, the IPHC header +compression algorithm might not be able to compress it, and hence has to carry +it inline, adding a byte to the header. To avoid having to move bytes around +inside OpenQueueEntry_t->packet buffer, we start writing the received packet a +bit after the start of the packet. +*/ +#define FIRST_FRAME_BYTE 1 + +// the different states of the IEEE802.15.4e state machine +typedef enum { + S_SLEEP = 0x00, // ready for next slot + // synchronizing + S_SYNCLISTEN = 0x01, // listened for packet to synchronize to network + S_SYNCRX = 0x02, // receiving packet to synchronize to network + S_SYNCPROC = 0x03, // processing packet just received + // TX + S_TXDATAOFFSET = 0x04, // waiting to prepare for Tx data + S_TXDATAPREPARE = 0x05, // preparing for Tx data + S_TXDATAREADY = 0x06, // ready to Tx data, waiting for 'go' + S_TXDATADELAY = 0x07, // 'go' signal given, waiting for SFD Tx data + S_TXDATA = 0x08, // Tx data SFD received, sending bytes + S_RXACKOFFSET = 0x09, // Tx data done, waiting to prepare for Rx ACK + S_RXACKPREPARE = 0x0a, // preparing for Rx ACK + S_RXACKREADY = 0x0b, // ready to Rx ACK, waiting for 'go' + S_RXACKLISTEN = 0x0c, // idle listening for ACK + S_RXACK = 0x0d, // Rx ACK SFD received, receiving bytes + S_TXPROC = 0x0e, // processing sent data + // RX + S_RXDATAOFFSET = 0x0f, // waiting to prepare for Rx data + S_RXDATAPREPARE = 0x10, // preparing for Rx data + S_RXDATAREADY = 0x11, // ready to Rx data, waiting for 'go' + S_RXDATALISTEN = 0x12, // idle listening for data + S_RXDATA = 0x13, // data SFD received, receiving more bytes + S_TXACKOFFSET = 0x14, // waiting to prepare for Tx ACK + S_TXACKPREPARE = 0x15, // preparing for Tx ACK + S_TXACKREADY = 0x16, // Tx ACK ready, waiting for 'go' + S_TXACKDELAY = 0x17, // 'go' signal given, waiting for SFD Tx ACK + S_TXACK = 0x18, // Tx ACK SFD received, sending bytes + S_RXPROC = 0x19, // processing received data +} ieee154e_state_t; + +#define TIMESLOT_TEMPLATE_ID 0x00 +#define CHANNELHOPPING_TEMPLATE_ID 0x00 + +//===== Slot Template Configurations + +//general MAC slot template +typedef struct { + uint16_t TsTxOffset; + uint16_t TsLongGT; + uint16_t TsTxAckDelay; + uint16_t TsShortGT; + uint16_t wdRadioTx; + uint16_t wdDataDuration; + uint16_t wdAckDuration; +} slot_154e_vars_t; + +//======== global 802154e atomic duration variables + +// - ticks = duration_in_seconds * 32768 +// - duration_in_seconds = ticks / 32768 + +// This slotTemplate should be instantiated only once for the currently used slotTemplate +typedef struct { + +// 1. slot template variables +// data transmission template +uint16_t TsTxOffset; //tx +uint16_t TsLongGT; //rx + +// ack transmission template +uint16_t TsTxAckDelay; //tx +uint16_t TsShortGT; //rx + +// watchdog (safety check) template +uint16_t wdRadioTx; +uint16_t wdDataDuration; +uint16_t wdAckDuration; + +// 2. board/implementation specific durations +// note that these variables MUST respect (i.e. fit) the slot template section 1 in order for the scedule to maintain its integrity. + +uint16_t slotDuration; +uint16_t maxTxDataPrepare; +uint16_t maxRxAckPrepare; +uint16_t maxRxDataPrepare; +uint16_t maxTxAckPrepare; + +//3. radio setting specific durations + +// this parameter is specifically helpful in tuning the radio transmission timing to meet the TsTxOffset for accurate synchronization +uint16_t delayTx; // between GO signal and SFD + +// this parameter is helpful to have the radio listen later or earlier to save energy in listening state. +uint16_t delayRx; // between GO signal and start listening +} slotTemplate_t; + +//shift of bytes in the linkOption bitmap: draft-ietf-6tisch-minimal-10.txt: page 6 +enum ieee154e_linkOption_enum { + FLAG_TX_S = 0, + FLAG_RX_S = 1, + FLAG_SHARED_S = 2, + FLAG_TIMEKEEPING_S = 3, +}; + +// FSM timer durations (combinations of atomic durations) +// TX +#define DURATION_tt1 ieee154e_vars.lastCapturedTime+slotTemplate.TsTxOffset-slotTemplate.delayTx-slotTemplate.maxTxDataPrepare +#define DURATION_tt2 ieee154e_vars.lastCapturedTime+slotTemplate.TsTxOffset-slotTemplate.delayTx +#define DURATION_tt3 ieee154e_vars.lastCapturedTime+slotTemplate.TsTxOffset-slotTemplate.delayTx+slotTemplate.wdRadioTx +#define DURATION_tt4 ieee154e_vars.lastCapturedTime+slotTemplate.wdDataDuration +#define DURATION_tt5 ieee154e_vars.lastCapturedTime+slotTemplate.TsTxAckDelay-slotTemplate.TsShortGT-slotTemplate.delayRx-slotTemplate.maxRxAckPrepare +#define DURATION_tt6 ieee154e_vars.lastCapturedTime+slotTemplate.TsTxAckDelay-slotTemplate.TsShortGT-slotTemplate.delayRx +#define DURATION_tt7 ieee154e_vars.lastCapturedTime+slotTemplate.TsTxAckDelay+slotTemplate.TsShortGT +#define DURATION_tt8 ieee154e_vars.lastCapturedTime+slotTemplate.wdAckDuration +// RX +#define DURATION_rt1 ieee154e_vars.lastCapturedTime+slotTemplate.TsTxOffset-slotTemplate.TsLongGT-slotTemplate.delayRx-slotTemplate.maxRxDataPrepare +#define DURATION_rt2 ieee154e_vars.lastCapturedTime+slotTemplate.TsTxOffset-slotTemplate.TsLongGT-slotTemplate.delayRx +#define DURATION_rt3 ieee154e_vars.lastCapturedTime+slotTemplate.TsTxOffset+slotTemplate.TsLongGT +#define DURATION_rt4 ieee154e_vars.lastCapturedTime+slotTemplate.wdDataDuration +#define DURATION_rt5 ieee154e_vars.lastCapturedTime+slotTemplate.TsTxAckDelay-slotTemplate.delayTx-slotTemplate.maxTxAckPrepare +#define DURATION_rt6 ieee154e_vars.lastCapturedTime+slotTemplate.TsTxAckDelay-slotTemplate.delayTx +#define DURATION_rt7 ieee154e_vars.lastCapturedTime+slotTemplate.TsTxAckDelay-slotTemplate.delayTx+slotTemplate.wdRadioTx +#define DURATION_rt8 ieee154e_vars.lastCapturedTime+slotTemplate.wdAckDuration +// serialInhibit +#define DURATION_si ieee154e_vars.slotDuration-SERIALINHIBITGUARD + +//=========================== typedef ========================================= + +// IEEE802.15.4E acknowledgement (ACK) +typedef struct { + PORT_SIGNED_INT_WIDTH timeCorrection; +} IEEE802154E_ACK_ht; + +//=========================== module variables ================================ + +typedef struct { + // misc + asn_t asn; // current absolute slot number (end of superSlot) + asn_t startAsn; // current absolute slot number (beginning of superSlot) + slotOffset_t slotOffset; // current slot offset + uint8_t superSlotLength; // current superSlot length + radioSetting_t radioSetting; // current slot layer 1 radio setting + cellRadioSetting_t cellRadioSetting; // current slot layer 2 radio setting + slotOffset_t nextActiveSlotOffset; // next active slot offset + PORT_TIMER_WIDTH deSyncTimeout; // how many slots left before looses sync + bool isSync; // TRUE iff mote is synchronized to network + OpenQueueEntry_t localCopyForTransmission;// copy of the frame used for current TX + PORT_TIMER_WIDTH numOfSleepSlots; // number of slots to sleep between active slots + // as shown on the chronogram + ieee154e_state_t state; // state of the FSM + OpenQueueEntry_t* dataToSend; // pointer to the data to send + OpenQueueEntry_t* dataReceived; // pointer to the data received + OpenQueueEntry_t* ackToSend; // pointer to the ack to send + OpenQueueEntry_t* ackReceived; // pointer to the ack received + PORT_TIMER_WIDTH lastCapturedTime; // last captured time + PORT_TIMER_WIDTH syncCapturedTime; // captured time used to sync + // channel hopping + uint8_t freq; // frequency of the current slot + uint8_t asnOffset; // offset inside the frame + uint8_t singleChannel; // the single channel used for transmission + bool singleChannelChanged; // detect id singleChannelChanged + uint8_t chTemplate[NUM_CHANNELS];// storing the template of hopping sequence + // template ID + uint8_t tsTemplateId; // timeslot template id + uint8_t chTemplateId; // channel hopping tempalte id + + PORT_TIMER_WIDTH radioOnInit; // when within the slot the radio turns on + PORT_TIMER_WIDTH radioOnTics; // how many tics within the slot the radio is on + PORT_TIMER_WIDTH radioTxRxInit; // when within the slot the radio tx/rx activity begins + PORT_TIMER_WIDTH radioTxTics; // how many tics within the slot the radio is transmitting + PORT_TIMER_WIDTH radioRxTics; // how many tics within the slot the radio is receiving + bool radioOnThisSlot; // to control if the radio has been turned on in a slot. + + // control + bool isAckEnabled; // whether reply for ack, used for synchronization test + bool isSecurityEnabled; // whether security is applied + // time correction + int16_t timeCorrection; // store the timeCorrection, prepend and retrieve it inside of frame header + + uint16_t slotDuration; // duration of slot + opentimers_id_t timerId; // id of timer used for implementing TSCH slot FSM + uint32_t startOfSlotReference; // the time refer to the beginning of slot + opentimers_id_t serialInhibitTimerId; // id of serial inhibit timer used for scheduling serial output + + // for msf downstream traffic adaptation + uint32_t receivedFrameFromParent; // True when received a frame from parent + + uint16_t compensatingCounter; + +} ieee154e_vars_t; + +BEGIN_PACK +typedef struct { + uint8_t numSyncPkt; // how many times synchronized on a non-ACK packet + uint8_t numSyncAck; // how many times synchronized on an ACK + int16_t minCorrection; // minimum time correction + int16_t maxCorrection; // maximum time correction + uint8_t numDeSync; // number of times a desync happened + uint32_t numTicsOn; // mac dutyCycle + uint32_t numTicsTotal; // total tics for which the dutycycle is computed + uint32_t numTxTics; // mac tx dutyCycle + uint32_t numRxTics; // mac rx dutyCycle + uint32_t numTxTics_0; // mac tx dutyCycle PHY0 + uint32_t numTicsOn_0; // mac dutyCycle PHY0 + uint32_t numTxTics_1; // mac tx dutyCycle PHY1 + uint32_t numTicsOn_1; // mac dutyCycle PHY1 + uint32_t numTxTics_2; // mac tx dutyCycle PHY2 + uint32_t numTicsOn_2; // mac dutyCycle PHY2 +} ieee154e_stats_t; +END_PACK + +typedef struct { + PORT_TIMER_WIDTH num_newSlot; + PORT_TIMER_WIDTH num_timer; + PORT_TIMER_WIDTH num_startOfFrame; + PORT_TIMER_WIDTH num_endOfFrame; +} ieee154e_dbg_t; + +//=========================== prototypes ====================================== + +// admin +void ieee154e_init(void); +void ieee154e_slot_template_init(void); +void ieee154e_select_slot_template(slotType_t slotType); +slotTemplate_t ieee154e_getSlotTemplate (void); +// public +PORT_TIMER_WIDTH ieee154e_asnDiff(asn_t* someASN); +#ifdef DEADLINE_OPTION_ENABLED +int16_t ieee154e_computeAsnDiff(asn_t* h_asn, asn_t* l_asn); +void ieee154e_calculateExpTime(uint16_t max_delay, uint8_t* et_asn); +void ieee154e_orderToASNStructure(uint8_t* in,asn_t* val_asn); +#endif +bool ieee154e_isSynch(void); +void ieee154e_getAsn(uint8_t* array); +void ieee154e_setIsAckEnabled(bool isEnabled); +void ieee154e_setSingleChannel(uint8_t channel); +void ieee154e_setIsSecurityEnabled(bool isEnabled); +void ieee154e_setSlotDuration(uint16_t duration); +uint16_t ieee154e_getSlotDuration(void); + +uint16_t ieee154e_getTimeCorrection(void); +void ieee154e_getTicsInfo(uint32_t* numTicsOn, uint32_t* numTicsTotal); +void ieee154e_getRadioTicsInfo( + uint32_t* numTxTics, + uint32_t* numTicsOn, + uint32_t* numTxTics_0, + uint32_t* numTicsOn_0, + uint32_t* numTxTics_1, + uint32_t* numTicsOn_1, + uint32_t* numTxTics_2, + uint32_t* numTicsOn_2, + uint32_t* numTicsTotal + ); +// events +void ieee154e_startOfFrame(PORT_TIMER_WIDTH capturedTime); +void ieee154e_endOfFrame(PORT_TIMER_WIDTH capturedTime); +// misc +bool debugPrint_asn(void); +bool debugPrint_isSync(void); +bool debugPrint_macStats(void); +void ieee154e_resetStats(void); + +/** +\} +\} +*/ + +#endif + diff --git a/openstack/02a-MAClow/IEEE802154_security.c b/openstack/02a-MAClow/IEEE802154_security.c index fbdf5f2baa..ed1f8c010b 100755 --- a/openstack/02a-MAClow/IEEE802154_security.c +++ b/openstack/02a-MAClow/IEEE802154_security.c @@ -487,7 +487,7 @@ uint8_t IEEE802154_security_getSecurityLevel(OpenQueueEntry_t *msg) { return IEEE802154_SECURITY_LEVEL; } - if(neighbors_isInsecureNeighbor(&msg->l2_nextORpreviousHop) && + if(neighbors_isInsecureNeighbor(&msg->l2_nextORpreviousHop, &msg-> l2_cellRadioSetting) && ieee802154_security_vars.joinPermitted == TRUE) { return IEEE154_ASH_SLF_TYPE_NOSEC; } @@ -512,7 +512,7 @@ bool IEEE802154_security_acceptableLevel(OpenQueueEntry_t* msg, ieee802154_heade if (IEEE802154_security_isConfigured() == TRUE && msg->l2_securityLevel == IEEE154_ASH_SLF_TYPE_NOSEC && ieee802154_security_vars.joinPermitted == TRUE && - neighbors_isInsecureNeighbor(&parsedHeader->src) == TRUE) { + neighbors_isInsecureNeighbor(&parsedHeader->src, &msg->l2_cellRadioSetting) == TRUE) { return TRUE; } diff --git a/openstack/02b-MAChigh/msf.c b/openstack/02b-MAChigh/msf.c index 07e6a5c2d5..4bddada9a4 100644 --- a/openstack/02b-MAChigh/msf.c +++ b/openstack/02b-MAChigh/msf.c @@ -16,13 +16,13 @@ //=========================== variables ======================================= msf_vars_t msf_vars; - +open_addr_t myaddr; //=========================== prototypes ====================================== // sixtop callback uint16_t msf_getMetadata(void); metadata_t msf_translateMetadata(void); -void msf_handleRCError(uint8_t code, open_addr_t* address); +void msf_handleRCError(uint8_t code, open_addr_t* address, cellRadioSetting_t cellRadioSetting); void msf_timer_housekeeping_cb(opentimers_id_t id); void msf_timer_housekeeping_task(void); @@ -38,7 +38,6 @@ void msf_housekeeping(void); //=========================== public ========================================== void msf_init(void) { - open_addr_t temp_neighbor; memset(&msf_vars,0,sizeof(msf_vars_t)); @@ -57,6 +56,7 @@ void msf_init(void) { CELLTYPE_RX, // type of slot FALSE, // shared? TRUE, // auto cell? + CELLRADIOSETTING_FALLBACK, // default radio setting msf_hashFunction_getChanneloffset(idmanager_getMyID(ADDR_64B)), // channel offset &temp_neighbor // neighbor ); @@ -74,7 +74,7 @@ void msf_init(void) { } // called by schedule -void msf_updateCellsElapsed(open_addr_t* neighbor, cellType_t type){ +void msf_updateCellsElapsed(open_addr_t* neighbor, cellRadioSetting_t cellRadioSetting, cellType_t type){ #ifdef MSF_ADAPTING_TO_TRAFFIC if (icmpv6rpl_isPreferredParent(neighbor)==FALSE){ @@ -118,7 +118,7 @@ void msf_updateCellsElapsed(open_addr_t* neighbor, cellType_t type){ // adapt to downward traffic when there are negotiated Tx cells in schedule - if (schedule_getNumberOfNegotiatedCells(neighbor, CELLTYPE_TX)==0){ + if (schedule_getNumberOfNegotiatedCells(neighbor, cellRadioSetting, CELLTYPE_TX)==0){ return; } @@ -178,7 +178,7 @@ metadata_t msf_translateMetadata(void){ return METADATA_TYPE_FRAMEID; } -void msf_handleRCError(uint8_t code, open_addr_t* address){ +void msf_handleRCError(uint8_t code, open_addr_t* address, cellRadioSetting_t cellRadioSetting){ uint16_t waitDuration; if ( @@ -215,10 +215,10 @@ void msf_handleRCError(uint8_t code, open_addr_t* address){ if (code==IANA_6TOP_RC_BUSY){ // mark neighbor f6NORES - neighbors_setNeighborNoResource(address); + neighbors_setNeighborNoResource(address,cellRadioSetting); } - neighbors_updateSequenceNumber(address); + neighbors_updateSequenceNumber(address,cellRadioSetting); } void msf_timer_waitretry_cb(opentimers_id_t id){ @@ -246,19 +246,20 @@ void msf_timer_housekeeping_task(void){ void msf_timer_clear_task(void){ open_addr_t neighbor; + cellRadioSetting_t neighborRadio; bool foundNeighbor; // get preferred parent - foundNeighbor = icmpv6rpl_getPreferredParentEui64(&neighbor); + foundNeighbor = icmpv6rpl_getPreferredParentKey(&neighbor, &neighborRadio); if (foundNeighbor==FALSE) { return; } - + uint8_t cellOptions = CELLOPTIONS_MSF | (neighborRadio << 5); sixtop_request( IANA_6TOP_CMD_CLEAR, // code &neighbor, // neighbor NUMCELLS_MSF, // number cells - CELLOPTIONS_MSF, // cellOptions (not used) + cellOptions, // cellOptions (not used) NULL, // celllist to add (not used) NULL, // celllist to delete (not used) IANA_6TISCH_SFID_MSF, // sfid @@ -271,6 +272,7 @@ void msf_timer_clear_task(void){ void msf_trigger6pAdd(void){ open_addr_t neighbor; + cellRadioSetting_t neighborRadio; bool foundNeighbor; cellInfo_ht celllist_add[CELLLIST_MAX_LEN]; @@ -286,7 +288,8 @@ void msf_trigger6pAdd(void){ // get preferred parent - foundNeighbor = icmpv6rpl_getPreferredParentEui64(&neighbor); + foundNeighbor = icmpv6rpl_getPreferredParentKey(&neighbor,&neighborRadio); + if (foundNeighbor==FALSE) { return; } @@ -303,12 +306,14 @@ void msf_trigger6pAdd(void){ return; } } - - if (msf_candidateAddCellList(celllist_add,NUMCELLS_MSF)==FALSE){ + + //define the neighbor radio in the linkOptions byte. + cellOptions |= neighborRadio <<5; + + if (msf_candidateAddCellList(celllist_add,NUMCELLS_MSF,neighborRadio)==FALSE){ // failed to get cell list to add return; } - sixtop_request( IANA_6TOP_CMD_ADD, // code &neighbor, // neighbor @@ -324,6 +329,7 @@ void msf_trigger6pAdd(void){ void msf_trigger6pDelete(void){ open_addr_t neighbor; + cellRadioSetting_t neighborRadio; bool foundNeighbor; cellInfo_ht celllist_delete[CELLLIST_MAX_LEN]; @@ -338,13 +344,13 @@ void msf_trigger6pDelete(void){ } // get preferred parent - foundNeighbor = icmpv6rpl_getPreferredParentEui64(&neighbor); + foundNeighbor = icmpv6rpl_getPreferredParentKey(&neighbor,&neighborRadio); if (foundNeighbor==FALSE) { return; } if (msf_vars.needDeleteTx) { - if (schedule_getNumberOfNegotiatedCells(&neighbor, CELLTYPE_TX)<=1){ + if (schedule_getNumberOfNegotiatedCells(&(neighbor), neighborRadio, CELLTYPE_TX)<=1){ // at least one negotiated Tx cell presents msf_vars.needDeleteTx = FALSE; } @@ -363,14 +369,14 @@ void msf_trigger6pDelete(void){ } } - if (msf_candidateRemoveCellList(celllist_delete,&neighbor,NUMCELLS_MSF, cellOptions)==FALSE){ + if (msf_candidateRemoveCellList(celllist_delete,&(neighbor),NUMCELLS_MSF, cellOptions)==FALSE){ // failed to get cell list to delete return; } sixtop_request( IANA_6TOP_CMD_DELETE, // code - &neighbor, // neighbor + &neighbor, // neighbor NUMCELLS_MSF, // number cells cellOptions, // cellOptions NULL, // celllist to add (not used) @@ -387,7 +393,8 @@ void msf_appPktPeriod(uint8_t numAppPacketsPerSlotFrame){ bool msf_candidateAddCellList( cellInfo_ht* cellList, - uint8_t requiredCells + uint8_t requiredCells, + cellRadioSetting_t cellRadioSetting ){ uint8_t i; frameLength_t slotoffset; @@ -400,6 +407,7 @@ bool msf_candidateAddCellList( if(schedule_isSlotOffsetAvailable(slotoffset)==TRUE){ cellList[numCandCells].slotoffset = slotoffset; cellList[numCandCells].channeloffset = openrandom_get16b()&0x0F; + cellList[numCandCells].cellRadioSetting = cellRadioSetting; cellList[numCandCells].isUsed = TRUE; numCandCells++; } @@ -451,7 +459,9 @@ bool msf_candidateRemoveCellList( void msf_housekeeping(void){ open_addr_t parentNeighbor; + cellRadioSetting_t parentNeighborRadio; open_addr_t nonParentNeighbor; + cellRadioSetting_t nonParentNeighborRadio; bool foundNeighbor; cellInfo_ht celllist_add[CELLLIST_MAX_LEN]; cellInfo_ht celllist_delete[CELLLIST_MAX_LEN]; @@ -460,30 +470,37 @@ void msf_housekeeping(void){ return; } - foundNeighbor = icmpv6rpl_getPreferredParentEui64(&parentNeighbor); + foundNeighbor = icmpv6rpl_getPreferredParentKey(&parentNeighbor,&parentNeighborRadio); if (foundNeighbor==FALSE) { return; } - - if (schedule_hasNegotiatedTxCellToNonParent(&parentNeighbor, &nonParentNeighbor)==TRUE){ - - // send a clear request to the non-parent neighbor - - sixtop_request( - IANA_6TOP_CMD_CLEAR, // code - &nonParentNeighbor, // neighbor - NUMCELLS_MSF, // number cells - CELLOPTIONS_MSF, // cellOptions - NULL, // celllist to add (not used) - NULL, // celllist to delete (not used) - IANA_6TISCH_SFID_MSF, // sfid - 0, // list command offset (not used) - 0 // list command maximum celllist (not used) - ); - return; - } - - if (schedule_getNumberOfNegotiatedCells(&parentNeighbor, CELLTYPE_TX)==0){ + // WRONG: this needs to be done the opposite way: it clears nonParent when and only when cells are negotiated with the new parent + if (schedule_hasNegotiatedTxCellToNonParent( + &parentNeighbor, + &parentNeighborRadio, + &nonParentNeighbor, + &nonParentNeighborRadio)==TRUE + ){ + // send a clear request to the non-parent neighbor + + uint8_t cellOptions = CELLOPTIONS_MSF | (nonParentNeighborRadio<<5); + + sixtop_request( + IANA_6TOP_CMD_CLEAR, // code + &nonParentNeighbor, // neighbor + NUMCELLS_MSF, // number cells + cellOptions, // cellOptions + NULL, // celllist to add (not used) + NULL, // celllist to delete (not used) + IANA_6TISCH_SFID_MSF, // sfid + 0, // list command offset (not used) + 0 // list command maximum celllist (not used) + ); + // will remove this for now to have the node proceed with cell addition even if cell clearing is not successful. + //return; + } + + if (schedule_getNumberOfNegotiatedCells(&parentNeighbor, parentNeighborRadio, CELLTYPE_TX)==0){ msf_vars.needAddTx = TRUE; msf_trigger6pAdd(); return; @@ -493,21 +510,23 @@ void msf_housekeeping(void){ return; } - if (schedule_isNumTxWrapped(&parentNeighbor)==FALSE){ + if (schedule_isNumTxWrapped(&parentNeighbor, parentNeighborRadio)==FALSE){ return; } memset(celllist_delete, 0, CELLLIST_MAX_LEN*sizeof(cellInfo_ht)); - if (schedule_getCellsToBeRelocated(&parentNeighbor, celllist_delete)){ - if (msf_candidateAddCellList(celllist_add,NUMCELLS_MSF)==FALSE){ + + if (schedule_getCellsToBeRelocated(&parentNeighbor, parentNeighborRadio, celllist_delete)){ + if (msf_candidateAddCellList(celllist_add, NUMCELLS_MSF, parentNeighborRadio)==FALSE){ // failed to get cell list to add return; } + uint8_t cellOptions = CELLOPTIONS_MSF | (parentNeighborRadio << 5); sixtop_request( IANA_6TOP_CMD_RELOCATE, // code &parentNeighbor, // neighbor NUMCELLS_MSF, // number cells - CELLOPTIONS_MSF, // cellOptions + cellOptions, // cellOptions celllist_add, // celllist to add celllist_delete, // celllist to delete IANA_6TISCH_SFID_MSF, // sfid diff --git a/openstack/02b-MAChigh/msf.h b/openstack/02b-MAChigh/msf.h index 78c945fa34..4be3e39f1c 100644 --- a/openstack/02b-MAChigh/msf.h +++ b/openstack/02b-MAChigh/msf.h @@ -59,7 +59,8 @@ void msf_appPktPeriod(uint8_t numAppPacketsPerSlotFrame); uint8_t msf_getsfid(void); bool msf_candidateAddCellList( cellInfo_ht* cellList, - uint8_t requiredCells + uint8_t requiredCells, + cellRadioSetting_t cellRadioSetting ); bool msf_candidateRemoveCellList( cellInfo_ht* cellList, @@ -68,7 +69,7 @@ bool msf_candidateRemoveCellList( uint8_t cellOptions ); // called by schedule -void msf_updateCellsElapsed(open_addr_t* neighbor, cellType_t cellType); +void msf_updateCellsElapsed(open_addr_t* neighbor, cellRadioSetting_t cellRadioSetting, cellType_t cellType); void msf_updateCellsUsed(open_addr_t* neighbor, cellType_t cellType); uint16_t msf_hashFunction_getSlotoffset(open_addr_t* address); diff --git a/openstack/02b-MAChigh/neighbors.c b/openstack/02b-MAChigh/neighbors.c index a7de3394be..7d282f9095 100644 --- a/openstack/02b-MAChigh/neighbors.c +++ b/openstack/02b-MAChigh/neighbors.c @@ -16,16 +16,18 @@ static neighbors_vars_t neighbors_vars; void registerNewNeighbor( open_addr_t* neighborID, + cellRadioSetting_t cellRadioSetting, int8_t rssi, asn_t* asnTimestamp, bool joinPrioPresent, uint8_t joinPrio, bool insecure ); -bool isNeighbor(open_addr_t* neighbor); +bool isNeighbor(open_addr_t* neighbor,cellRadioSetting_t cellRadioSetting); void removeNeighbor(uint8_t neighborIndex); bool isThisRowMatching( open_addr_t* address, + cellRadioSetting_t cellRadioSetting, uint8_t rowNumber ); @@ -114,25 +116,49 @@ with lowest join priority metric to send join traffic through. */ open_addr_t* neighbors_getJoinProxy(void) { uint8_t i; + uint8_t proxyIndex; uint8_t joinPrioMinimum; - open_addr_t* joinProxy; + open_addr_t *joinProxy; joinPrioMinimum = 0xff; + proxyIndex = 0 ; joinProxy = NULL; - for (i=0;iaddr_64b), &(neighbors_vars.neighbors[index].addr_64b.addr_64b), LENGTH_ADDR64b); + address->type = ADDR_64B; + //memcpy(&(cellRadioSetting), &(neighbors_vars.neighbors[index].cellRadioSetting), 1); + *cellRadioSetting = neighbors_vars.neighbors[index].cellRadioSetting; + ReturnVal = neighbors_vars.neighbors[index].used; + break; + default: + openserial_printCritical(COMPONENT_NEIGHBORS,ERR_WRONG_ADDR_TYPE, + (errorparameter_t)addr_type, + (errorparameter_t)2); + break; + } + return ReturnVal; +} + // ==== update backoff void neighbors_updateBackoff(open_addr_t* address){ uint8_t i; @@ -538,12 +598,12 @@ void neighbors_setNeighborRank(uint8_t index, dagrank_t rank) { } -void neighbors_setNeighborNoResource(open_addr_t* address){ +void neighbors_setNeighborNoResource(open_addr_t* address, cellRadioSetting_t cellRadioSetting){ uint8_t i; // loop through neighbor table for (i=0;i DEFAULTLINKCOST){ if (neighbors_vars.neighbors[index].numTx < MINIMAL_NUM_TX){ - rankIncrease = (3*neighbors_vars.neighbors[index].numTx-2)*MINHOPRANKINCREASE; + rankIncrease = (3*neighbors_vars.neighbors[index].numTx-2) + * MINHOPRANKINCREASE + * radioMinHopRankIncreaseFactor [neighborRadio]; } else { rankIncrease = 65535; } } else { - rankIncrease = (3*DEFAULTLINKCOST-2)*MINHOPRANKINCREASE; + rankIncrease = (3*DEFAULTLINKCOST-2) + * MINHOPRANKINCREASE + * radioMinHopRankIncreaseFactor [neighborRadio]; } } else { //6TiSCH minimal draft using OF0 for rank computation: ((3*numTx/numTxAck)-2)*minHopRankIncrease // numTx is on 8 bits, so scaling up 10 bits won't lead to saturation // but this <<10 followed by >>10 does not provide any benefit either. Result is the same. rankIncreaseIntermediary = (((uint32_t)neighbors_vars.neighbors[index].numTx) << 10); - rankIncreaseIntermediary = (3*rankIncreaseIntermediary * MINHOPRANKINCREASE) / ((uint32_t)neighbors_vars.neighbors[index].numTxACK); - rankIncreaseIntermediary = rankIncreaseIntermediary - ((uint32_t)(2 * MINHOPRANKINCREASE)<<10); + rankIncreaseIntermediary = (3*rankIncreaseIntermediary * MINHOPRANKINCREASE * radioMinHopRankIncreaseFactor [neighborRadio]) / ((uint32_t)neighbors_vars.neighbors[index].numTxACK); + rankIncreaseIntermediary = rankIncreaseIntermediary - ((uint32_t)(2 * MINHOPRANKINCREASE * radioMinHopRankIncreaseFactor [neighborRadio])<<10); // this could still overflow for numTx large and numTxAck small, Casting to 16 bits will yiel the least significant bits if (rankIncreaseIntermediary >= (65536<<10)) { rankIncrease = 65535; @@ -668,6 +733,7 @@ bool debugPrint_neighbors(void) { //=========================== private ========================================= void registerNewNeighbor(open_addr_t* address, + cellRadioSetting_t cellRadioSetting, int8_t rssi, asn_t* asnTimestamp, bool joinPrioPresent, @@ -683,7 +749,7 @@ void registerNewNeighbor(open_addr_t* address, return; } // add this neighbor - if (isNeighbor(address)==FALSE) { + if (isNeighbor(address,cellRadioSetting)==FALSE) { i=0; while(itype) { case ADDR_64B: return neighbors_vars.neighbors[rowNumber].used && - packetfunctions_sameAddress(address,&neighbors_vars.neighbors[rowNumber].addr_64b); + packetfunctions_sameAddress(address,&neighbors_vars.neighbors[rowNumber].addr_64b) && + neighbors_vars.neighbors[rowNumber].cellRadioSetting == cellRadioSetting ; default: openserial_printCritical(COMPONENT_NEIGHBORS,ERR_WRONG_ADDR_TYPE, (errorparameter_t)address->type, diff --git a/openstack/02b-MAChigh/neighbors.h b/openstack/02b-MAChigh/neighbors.h index acc99b45b7..4f9dd43c01 100644 --- a/openstack/02b-MAChigh/neighbors.h +++ b/openstack/02b-MAChigh/neighbors.h @@ -63,24 +63,29 @@ uint8_t neighbors_getNumNeighbors(void); uint16_t neighbors_getLinkMetric(uint8_t index); open_addr_t* neighbors_getKANeighbor(uint16_t kaPeriod); open_addr_t* neighbors_getJoinProxy(void); +cellRadioSetting_t* neighbors_getJoinProxyRadio(void); + bool neighbors_getNeighborNoResource(uint8_t index); int8_t neighbors_getRssi(uint8_t index); uint8_t neighbors_getNumTx(uint8_t index); +// be careful this no longer works, it would need to be updated to include radio uint8_t neighbors_getSequenceNumber(open_addr_t* address); + // setters void neighbors_setNeighborRank(uint8_t index, dagrank_t rank); -void neighbors_setNeighborNoResource(open_addr_t* address); +void neighbors_setNeighborNoResource(open_addr_t* address, cellRadioSetting_t cellRadioSetting); void neighbors_setPreferredParent(uint8_t index, bool isPreferred); // interrogators -bool neighbors_isStableNeighbor(open_addr_t* address); +bool neighbors_isStableNeighbor(open_addr_t* address, cellRadioSetting_t cellRadioSetting); bool neighbors_isStableNeighborByIndex(uint8_t index); -bool neighbors_isInsecureNeighbor(open_addr_t* address); +bool neighbors_isInsecureNeighbor(open_addr_t* address, cellRadioSetting_t cellRadioSetting); bool neighbors_isNeighborWithHigherDAGrank(uint8_t index); bool neighbors_reachedMinimalTransmission(uint8_t index); // updating neighbor information void neighbors_indicateRx( open_addr_t* l2_src, + cellRadioSetting_t cellRadioSetting, int8_t rssi, asn_t* asnTimestamp, bool joinPrioPresent, @@ -89,16 +94,19 @@ void neighbors_indicateRx( ); void neighbors_indicateTx( open_addr_t* dest, + cellRadioSetting_t cellRadioSetting, uint8_t numTxAttempts, bool sentOnTxCell, bool was_finally_acked, asn_t* asnTimestamp ); -void neighbors_updateSequenceNumber(open_addr_t* address); -void neighbors_resetSequenceNumber(open_addr_t* address); +void neighbors_updateSequenceNumber(open_addr_t* address, cellRadioSetting_t cellRadioSetting); +void neighbors_resetSequenceNumber(open_addr_t* address, cellRadioSetting_t cellRadioSetting); // get addresses bool neighbors_getNeighborEui64(open_addr_t* address,uint8_t addr_type,uint8_t index); +bool neighbors_getNeighborKey(open_addr_t* address, uint8_t addr_type, cellRadioSetting_t* cellRadioSetting, uint8_t index); + // update backoff field void neighbors_updateBackoff(open_addr_t* address); void neighbors_decreaseBackoff(open_addr_t* address); diff --git a/openstack/02b-MAChigh/schedule.c b/openstack/02b-MAChigh/schedule.c index 7638bf869c..dde845a4b1 100644 --- a/openstack/02b-MAChigh/schedule.c +++ b/openstack/02b-MAChigh/schedule.c @@ -80,6 +80,8 @@ void schedule_startDAGroot(void) { CELLTYPE_TXRX, // type of slot TRUE, // shared? FALSE, // auto cell? + CELLRADIOSETTING_1 // cell radio setting + + (running_slotOffset-start_slotOffset), SCHEDULE_MINIMAL_6TISCH_CHANNELOFFSET, // channel offset &temp_neighbor // neighbor ); @@ -95,6 +97,7 @@ status information about several modules in the OpenWSN stack. \returns TRUE if this function printed something, FALSE otherwise. */ bool debugPrint_schedule(void) { + debugScheduleEntry_t temp; // increment the row just printed @@ -110,6 +113,8 @@ bool debugPrint_schedule(void) { schedule_vars.scheduleBuf[schedule_vars.debugPrintRow].shared; temp.channelOffset = \ schedule_vars.scheduleBuf[schedule_vars.debugPrintRow].channelOffset; + temp.cellRadioSetting = \ + schedule_vars.scheduleBuf[schedule_vars.debugPrintRow].cellRadioSetting; memcpy( &temp.neighbor, &schedule_vars.scheduleBuf[schedule_vars.debugPrintRow].neighbor, @@ -233,6 +238,7 @@ void schedule_getSlotInfo( info->link_type = slotContainer->type; info->shared = slotContainer->shared; info->slotOffset = slotOffset; + info->cellRadioSetting = slotContainer->cellRadioSetting; info->channelOffset = slotContainer->channelOffset; info->isAutoCell = slotContainer->isAutoCell; memcpy(&(info->address), &(slotContainer->neighbor), sizeof(open_addr_t)); @@ -244,6 +250,7 @@ void schedule_getSlotInfo( info->link_type = CELLTYPE_OFF; info->shared = FALSE; info->channelOffset = 0; //set to zero if not set. + info->cellRadioSetting = 0; info->isAutoCell = FALSE; memset(&(info->address), 0, sizeof(open_addr_t)); } @@ -263,6 +270,7 @@ owerror_t schedule_addActiveSlot( cellType_t type, bool shared, bool isAutoCell, + cellRadioSetting_t cellRadioSetting, channelOffset_t channelOffset, open_addr_t* neighbor ) { @@ -351,10 +359,11 @@ owerror_t schedule_addActiveSlot( if (needSwapEntries) { // backup current entries - backupEntry->type = slotContainer->type; - backupEntry->shared = slotContainer->shared; - backupEntry->channelOffset = slotContainer->channelOffset; - backupEntry->isAutoCell = slotContainer->isAutoCell; + backupEntry->type = slotContainer->type; + backupEntry->shared = slotContainer->shared; + backupEntry->channelOffset = slotContainer->channelOffset; + backupEntry->cellRadioSetting = slotContainer->cellRadioSetting; + backupEntry->isAutoCell = slotContainer->isAutoCell; memcpy(&(backupEntry->neighbor), &(slotContainer->neighbor), sizeof(open_addr_t)); @@ -371,6 +380,7 @@ owerror_t schedule_addActiveSlot( slotContainer->shared = shared; slotContainer->channelOffset = channelOffset; slotContainer->isAutoCell = isAutoCell; + slotContainer->cellRadioSetting = cellRadioSetting; memcpy(&(slotContainer->neighbor),neighbor,sizeof(open_addr_t)); // fill that schedule entry with current asn @@ -385,6 +395,7 @@ owerror_t schedule_addActiveSlot( backupEntry->shared = shared; backupEntry->channelOffset = channelOffset; backupEntry->isAutoCell = isAutoCell; + backupEntry->cellRadioSetting = cellRadioSetting; memcpy(&backupEntry->neighbor,neighbor,sizeof(open_addr_t)); // fill that schedule entry with current asn @@ -406,6 +417,7 @@ owerror_t schedule_addActiveSlot( slotContainer->shared = shared; slotContainer->channelOffset = channelOffset; slotContainer->isAutoCell = isAutoCell; + slotContainer->cellRadioSetting = cellRadioSetting; memcpy(&(slotContainer->neighbor),neighbor,sizeof(open_addr_t)); // fill that schedule entry with current asn @@ -460,6 +472,7 @@ owerror_t schedule_addActiveSlot( slotContainer->type = CELLTYPE_OFF; slotContainer->shared = FALSE; slotContainer->channelOffset = 0; + slotContainer->cellRadioSetting = 0; memset(&slotContainer->neighbor,0,sizeof(open_addr_t)); ENABLE_INTERRUPTS(); return E_FAIL; @@ -549,7 +562,7 @@ owerror_t schedule_removeActiveSlot( backupEntry->type = CELLTYPE_OFF; backupEntry->shared = FALSE; backupEntry->channelOffset = 0; - + backupEntry->cellRadioSetting = 0; backupEntry->neighbor.type = ADDR_NONE; memset(&backupEntry->neighbor.addr_64b[0], 0x00, sizeof(backupEntry->neighbor.addr_64b)); @@ -579,6 +592,7 @@ owerror_t schedule_removeActiveSlot( // move the backup entry to the schedule slotContainer->type = slotContainer->backupEntries[candidate_index].type; slotContainer->shared = slotContainer->backupEntries[candidate_index].shared; + slotContainer->cellRadioSetting = slotContainer->backupEntries[candidate_index].cellRadioSetting; slotContainer->channelOffset = slotContainer->backupEntries[candidate_index].channelOffset; slotContainer->isAutoCell = slotContainer->backupEntries[candidate_index].isAutoCell; memcpy(&slotContainer->neighbor,&(slotContainer->backupEntries[candidate_index].neighbor),sizeof(open_addr_t)); @@ -679,7 +693,8 @@ bool schedule_isSlotOffsetAvailable(uint16_t slotOffset){ void schedule_removeAllNegotiatedCellsToNeighbor( uint8_t slotframeID, - open_addr_t* neighbor + open_addr_t* neighbor, + cellRadioSetting_t neighborRadio ){ uint8_t i; @@ -687,6 +702,7 @@ void schedule_removeAllNegotiatedCellsToNeighbor( for(i=0;i0xFF/2){ returnVal = TRUE; @@ -782,7 +801,7 @@ bool schedule_isNumTxWrapped(open_addr_t* neighbor){ } -bool schedule_getCellsToBeRelocated(open_addr_t* neighbor, cellInfo_ht* celllist){ +bool schedule_getCellsToBeRelocated(open_addr_t* neighbor, cellRadioSetting_t cellRadioSetting, cellInfo_ht* celllist){ uint8_t i; uint16_t cellPDR; @@ -793,7 +812,8 @@ bool schedule_getCellsToBeRelocated(open_addr_t* neighbor, cellInfo_ht* celllist // found the cell with higest PDR for(i=0;iMINIMAL_NUM_TX){ cellPDR = 100*schedule_vars.scheduleBuf[i].numTxACK/schedule_vars.scheduleBuf[i].numTx; @@ -902,16 +922,44 @@ bool schedule_hasNegotiatedCellToNeighbor(open_addr_t* neighbor, cellType_t cell return FALSE; } +bool schedule_hasNegotiatedCellToNeighborKey(open_addr_t* neighbor, cellRadioSetting_t cellRadioSetting, cellType_t cell_type){ + uint8_t i; + + INTERRUPT_DECLARATION(); + DISABLE_INTERRUPTS(); + + for(i=0;icellRadioSetting; + + ENABLE_INTERRUPTS(); + + return returnVal; +} + /** \brief Get the channel offset of the current schedule entry. @@ -1265,13 +1336,13 @@ bool schedule_getOneCellAfterOffset(uint8_t metadata,uint8_t offset,open_addr_t* DISABLE_INTERRUPTS(); // translate cellOptions to cell type - if (cellOptions == CELLOPTIONS_TX){ + if ((cellOptions & SIXTOP_CELLREQUEST_LINKOPTIONS_MASK) == CELLOPTIONS_TX){ type = CELLTYPE_TX; } - if (cellOptions == CELLOPTIONS_RX){ + if ((cellOptions & SIXTOP_CELLREQUEST_LINKOPTIONS_MASK) == CELLOPTIONS_RX){ type = CELLTYPE_RX; } - if (cellOptions == (CELLOPTIONS_TX | CELLOPTIONS_RX | CELLOPTIONS_SHARED)){ + if ((cellOptions & SIXTOP_CELLREQUEST_LINKOPTIONS_MASK) == (CELLOPTIONS_TX | CELLOPTIONS_RX | CELLOPTIONS_SHARED)){ type = CELLTYPE_TXRX; } @@ -1303,7 +1374,7 @@ void schedule_resetEntry(scheduleEntry_t* e) { e->shared = FALSE; e->isAutoCell = FALSE; e->channelOffset = 0; - + e->cellRadioSetting = 0; e->neighbor.type = ADDR_NONE; memset(&e->neighbor.addr_64b[0], 0x00, sizeof(e->neighbor.addr_64b)); diff --git a/openstack/02b-MAChigh/schedule.h b/openstack/02b-MAChigh/schedule.h index dc3b9f50e1..ddd1cbe28a 100644 --- a/openstack/02b-MAChigh/schedule.h +++ b/openstack/02b-MAChigh/schedule.h @@ -17,10 +17,10 @@ The superframe reappears over time and can be arbitrarily long. */ -#define SLOTFRAME_LENGTH 101 //should be 101 +#define SLOTFRAME_LENGTH 41 //should be 101 //draft-ietf-6tisch-minimal-06 -#define SCHEDULE_MINIMAL_6TISCH_ACTIVE_CELLS 1 +#define SCHEDULE_MINIMAL_6TISCH_ACTIVE_CELLS 3 #define SCHEDULE_MINIMAL_6TISCH_SLOTOFFSET 0 #define SCHEDULE_MINIMAL_6TISCH_CHANNELOFFSET 0 #define SCHEDULE_MINIMAL_6TISCH_DEFAULT_SLOTFRAME_HANDLE 0 //id of slotframe @@ -88,9 +88,11 @@ typedef enum{ CELLOPTIONS_RX = 1<<1, CELLOPTIONS_SHARED = 1<<2, CELLOPTIONS_TIMEKEPPING = 1<<3, - CELLOPTIONS_PRIORITY = 1<<4 + CELLOPTIONS_PRIORITY = 1<<4, }linkOptions_t; + + //=========================== typedef ========================================= typedef uint8_t channelOffset_t; @@ -105,31 +107,33 @@ typedef enum { } cellType_t; typedef struct { - cellType_t type; - bool shared; - bool isAutoCell; - uint8_t channelOffset; - open_addr_t neighbor; - uint8_t numRx; - uint8_t numTx; - uint8_t numTxACK; - asn_t lastUsedAsn; - void* next; + cellType_t type; + bool shared; + bool isAutoCell; + cellRadioSetting_t cellRadioSetting; + uint8_t channelOffset; + open_addr_t neighbor; + uint8_t numRx; + uint8_t numTx; + uint8_t numTxACK; + asn_t lastUsedAsn; + void* next; } backupEntry_t; typedef struct { - slotOffset_t slotOffset; - cellType_t type; - bool shared; - bool isAutoCell; - uint8_t channelOffset; - open_addr_t neighbor; - uint8_t numRx; - uint8_t numTx; - uint8_t numTxACK; - asn_t lastUsedAsn; - backupEntry_t backupEntries[MAXBACKUPSLOTS]; - void* next; + slotOffset_t slotOffset; + cellType_t type; + bool shared; + bool isAutoCell; + cellRadioSetting_t cellRadioSetting; + uint8_t channelOffset; + open_addr_t neighbor; + uint8_t numRx; + uint8_t numTx; + uint8_t numTxACK; + asn_t lastUsedAsn; + backupEntry_t backupEntries[MAXBACKUPSLOTS]; + void* next; } scheduleEntry_t; BEGIN_PACK @@ -138,6 +142,7 @@ typedef struct { slotOffset_t slotOffset; uint8_t type; bool shared; + cellRadioSetting_t cellRadioSetting; uint8_t channelOffset; open_addr_t neighbor; uint8_t numRx; @@ -153,6 +158,7 @@ typedef struct { bool shared; slotOffset_t slotOffset; channelOffset_t channelOffset; + cellRadioSetting_t cellRadioSetting; bool isAutoCell; }slotinfo_element_t; @@ -187,6 +193,7 @@ owerror_t schedule_addActiveSlot( cellType_t type, bool shared, bool isAutoCell, + cellRadioSetting_t cellRadioSetting, uint8_t channelOffset, open_addr_t* neighbor ); @@ -205,23 +212,29 @@ void schedule_removeAllAutonomousTxRxCellUnicast(void); bool schedule_isSlotOffsetAvailable(uint16_t slotOffset); void schedule_removeAllNegotiatedCellsToNeighbor( uint8_t slotframeID, - open_addr_t* neighbor + open_addr_t* neighbor, + cellRadioSetting_t neighborRadio ); uint8_t schedule_getNumberOfFreeEntries(void); -uint8_t schedule_getNumberOfNegotiatedCells(open_addr_t* neighbor, cellType_t cell_type); -bool schedule_isNumTxWrapped(open_addr_t* neighbor); -bool schedule_getCellsToBeRelocated(open_addr_t* neighbor, cellInfo_ht* celllist); +uint8_t schedule_getNumberOfNegotiatedCells(open_addr_t* neighbor, cellRadioSetting_t cellRadioSetting, cellType_t cell_type); +bool schedule_isNumTxWrapped(open_addr_t* neighbor, cellRadioSetting_t cellRadioSetting); + +bool schedule_getCellsToBeRelocated(open_addr_t* neighbor,cellRadioSetting_t cellRadioSetting, cellInfo_ht* celllist); bool schedule_hasAutonomousTxRxCellUnicast(open_addr_t* neighbor); bool schedule_getAutonomousTxRxCellUnicastNeighbor(open_addr_t* neighbor); bool schedule_hasAutoTxCellToNeighbor(open_addr_t* neighbor); bool schedule_hasNegotiatedCellToNeighbor(open_addr_t* neighbor, cellType_t cell_type); +bool schedule_hasNegotiatedCellToNeighborKey(open_addr_t* neighbor, cellRadioSetting_t cellRadioSetting, cellType_t cell_type); + bool schedule_getAutonomousTxRxCellAnycast(uint16_t* slotoffset); bool schedule_hasNonParentManagedTxCell(open_addr_t* neighbor); void schedule_hasNegotiatedTxCell(open_addr_t* address); bool schedule_hasNegotiatedTxCellToNonParent( - open_addr_t* parentNeighbor, - open_addr_t* nonParentNeighbor + open_addr_t* parentNeighbor, + cellRadioSetting_t* parentNeighborRadio, + open_addr_t* nonParentNeighbor, + cellRadioSetting_t* nonParentNeighborRadio ); // from IEEE802154E @@ -234,6 +247,7 @@ bool schedule_getShared(void); bool schedule_getIsAutoCell(void); void schedule_getNeighbor(open_addr_t* addrToWrite); slotOffset_t schedule_getSlottOffset(void); +cellRadioSetting_t schedule_getCellRadioSetting(void); channelOffset_t schedule_getChannelOffset(void); bool schedule_getOkToSend(void); void schedule_resetBackoff(void); diff --git a/openstack/02b-MAChigh/sixtop.c b/openstack/02b-MAChigh/sixtop.c index b42926b194..d373dd7a8b 100644 --- a/openstack/02b-MAChigh/sixtop.c +++ b/openstack/02b-MAChigh/sixtop.c @@ -31,7 +31,6 @@ //=========================== variables ======================================= sixtop_vars_t sixtop_vars; - //=========================== prototypes ====================================== // send internal @@ -108,6 +107,7 @@ void sixtop_init(void) { sixtop_vars.periodMaintenance = 872 +(openrandom_get16b()&0xff); sixtop_vars.busySendingKA = FALSE; sixtop_vars.busySendingEB = FALSE; + sixtop_vars.ebCounter = 0; sixtop_vars.dsn = 0; sixtop_vars.mgtTaskCounter = 0; sixtop_vars.kaPeriod = MAXKAPERIOD; @@ -117,7 +117,7 @@ void sixtop_init(void) { sixtop_vars.ebSendingTimerId = opentimers_create(TIMER_GENERAL_PURPOSE, TASKPRIO_SIXTOP); opentimers_scheduleIn( sixtop_vars.ebSendingTimerId, - SLOTFRAME_LENGTH*SLOTDURATION, + SLOTFRAME_LENGTH*(SLOTDURATION_MS), TIME_MS, TIMER_PERIODIC, sixtop_sendingEb_timer_cb @@ -280,6 +280,7 @@ owerror_t sixtop_request( } else { // record the neighbor in case no response for clear memcpy(&sixtop_vars.neighborToClearCells,neighbor,sizeof(open_addr_t)); + sixtop_vars.neighborRadioToClearCells = (cellOptions & SIXTOP_CELLREQUEST_RADIOSETTING_MASK)>>5; } // append 6p metadata @@ -409,6 +410,7 @@ void task_sixtopNotifSendDone(void) { if (msg->l2_sendDoneError==E_SUCCESS) { neighbors_indicateTx( &(msg->l2_nextORpreviousHop), + msg->l2_cellRadioSetting, msg->l2_numTxAttempts, msg->l2_sendOnTxCell, TRUE, @@ -417,6 +419,7 @@ void task_sixtopNotifSendDone(void) { } else { neighbors_indicateTx( &(msg->l2_nextORpreviousHop), + msg->l2_cellRadioSetting, msg->l2_numTxAttempts, msg->l2_sendOnTxCell, FALSE, @@ -428,8 +431,11 @@ void task_sixtopNotifSendDone(void) { switch (msg->creator) { case COMPONENT_SIXTOP: if (msg->l2_frameType==IEEE154_TYPE_BEACON) { - // this is a EB - + + // this is an EB + // this decrement should never end up less than 0 if protocol is running correctly. + sixtop_vars.ebCounter --; + // not busy sending EB anymore sixtop_vars.busySendingEB = FALSE; } else { @@ -472,6 +478,7 @@ void task_sixtopNotifReceive(void) { // update neighbor statistics neighbors_indicateRx( &(msg->l2_nextORpreviousHop), + msg->l2_cellRadioSetting, msg->l1_rssi, &msg->l2_asn, msg->l2_joinPriorityPresent, @@ -608,6 +615,7 @@ owerror_t sixtop_send_internal( // this is a new packet which I never attempted to send msg->l2_numTxAttempts = 0; // transmit with the default TX power + msg->l1_txPower = TX_POWER; // add a IEEE802.15.4 header ieee802154_prependHeader( @@ -622,18 +630,19 @@ owerror_t sixtop_send_internal( if ( packetfunctions_isBroadcastMulticast(&(msg->l2_nextORpreviousHop)) == FALSE && - schedule_hasNegotiatedCellToNeighbor(&(msg->l2_nextORpreviousHop), CELLTYPE_TX) == FALSE && + schedule_hasNegotiatedCellToNeighborKey(&(msg->l2_nextORpreviousHop), msg->l2_cellRadioSetting , CELLTYPE_TX) == FALSE && schedule_hasAutoTxCellToNeighbor(&(msg->l2_nextORpreviousHop)) == FALSE ){ // the frame source address is not broadcast/multicast // no negotiated tx cell to that neighbor // no auto tx cell to that neighbor - + msg->l2_cellRadioSetting = CELLRADIOSETTING_FALLBACK; schedule_addActiveSlot( msf_hashFunction_getSlotoffset(&(msg->l2_nextORpreviousHop)), // slot offset CELLTYPE_TX, // type of slot TRUE, // shared? TRUE, // auto cell? + CELLRADIOSETTING_FALLBACK, // msg radio setting msf_hashFunction_getChanneloffset(&(msg->l2_nextORpreviousHop)), // channel offset &(msg->l2_nextORpreviousHop) // neighbor ); @@ -648,8 +657,11 @@ owerror_t sixtop_send_internal( already. No need to push a task again. */ void sixtop_sendingEb_timer_cb(opentimers_id_t id){ - + // if multiple minimal cells are allocated, call the EB firing mechanism for + // each cell + for (uint8_t i =0;icreator = COMPONENT_SIXTOP; eb->owner = COMPONENT_SIXTOP; + +//=========================== Compose eb payload ============================== // in case we none default number of shared cells defined in minimal configuration if (ebIEsBytestream[EB_SLOTFRAME_NUMLINK_OFFSET]>1){ @@ -773,7 +800,7 @@ port_INLINE void sixtop_sendEB(void) { eb->payload[1] = 0x00; eb->payload[2] = 0x00; // channel offset eb->payload[3] = 0x00; - eb->payload[4] = 0x0F; // link options + eb->payload[4] = cellLinkOptions[i]; // link options } } @@ -793,7 +820,9 @@ port_INLINE void sixtop_sendEB(void) { eb->payload[EB_SLOTFRAME_LEN_OFFSET] = (uint8_t)(0x00FF & (schedule_getFrameLength())); eb->payload[EB_SLOTFRAME_LEN_OFFSET+1] = (uint8_t)(0x00FF & (schedule_getFrameLength()>>8)); - + +//=========================== Compose l2 attributes =========================== + // Keep a pointer to where the ASN will be // Note: the actual value of the current ASN and JP will be written by the // IEEE802.15.4e when transmitting @@ -812,12 +841,21 @@ port_INLINE void sixtop_sendEB(void) { eb->l2_securityLevel = IEEE802154_SECURITY_LEVEL_BEACON; eb->l2_keyIdMode = IEEE802154_SECURITY_KEYIDMODE; eb->l2_keyIndex = IEEE802154_security_getBeaconKeyIndex(); - + +//=========================== Send ============================================ + // put in queue for MAC to handle sixtop_send_internal(eb,eb->l2_payloadIEpresent); - // I'm now busy sending an EB - sixtop_vars.busySendingEB = TRUE; + //update ebCounter + sixtop_vars.ebCounter++; + + if (sixtop_vars.ebCounter >= SCHEDULE_MINIMAL_6TISCH_ACTIVE_CELLS){ + // I have created enough EB packets for all minimal cells. + // I'm now busy sending an EB + sixtop_vars.busySendingEB = TRUE; + } + } /** @@ -838,6 +876,7 @@ port_INLINE void sixtop_sendKA(void) { openqueue_removeAllCreatedBy(COMPONENT_SIXTOP); // I'm not busy sending an EB or KA + sixtop_vars.ebCounter = 0; sixtop_vars.busySendingEB = FALSE; sixtop_vars.busySendingKA = FALSE; @@ -861,6 +900,7 @@ port_INLINE void sixtop_sendKA(void) { openqueue_removeAllCreatedBy(COMPONENT_SIXTOP); // I'm not busy sending an EB or KA + sixtop_vars.ebCounter = 0; sixtop_vars.busySendingEB = FALSE; sixtop_vars.busySendingKA = FALSE; @@ -914,9 +954,10 @@ void timer_sixtop_six2six_timeout_fired(void) { // no response for the 6p clear, just clear locally schedule_removeAllNegotiatedCellsToNeighbor( sixtop_vars.cb_sf_getMetadata(), - &sixtop_vars.neighborToClearCells + &sixtop_vars.neighborToClearCells, + sixtop_vars.neighborRadioToClearCells ); - neighbors_resetSequenceNumber(&sixtop_vars.neighborToClearCells); + neighbors_resetSequenceNumber(&sixtop_vars.neighborToClearCells, sixtop_vars.neighborRadioToClearCells); memset(&sixtop_vars.neighborToClearCells,0,sizeof(open_addr_t)); } // timeout timer fired, reset the state of sixtop to idle @@ -982,7 +1023,7 @@ void sixtop_six2six_sendDone(OpenQueueEntry_t* msg, owerror_t error){ // if this is a response send done if (msg->l2_sixtop_messageType == SIXTOP_CELL_RESPONSE){ if(error == E_SUCCESS) { - neighbors_updateSequenceNumber(&(msg->l2_nextORpreviousHop)); + neighbors_updateSequenceNumber(&(msg->l2_nextORpreviousHop), msg->l2_cellRadioSetting ); // in case a response is sent out, check the return code if (msg->l2_sixtop_returnCode == IANA_6TOP_RC_SUCCESS){ if (msg->l2_sixtop_command == IANA_6TOP_CMD_ADD){ @@ -1021,9 +1062,10 @@ void sixtop_six2six_sendDone(OpenQueueEntry_t* msg, owerror_t error){ if ( msg->l2_sixtop_command == IANA_6TOP_CMD_CLEAR){ schedule_removeAllNegotiatedCellsToNeighbor( msg->l2_sixtop_frameID, - &(msg->l2_nextORpreviousHop) + &(msg->l2_nextORpreviousHop), + msg->l2_cellRadioSetting ); - neighbors_resetSequenceNumber(&(msg->l2_nextORpreviousHop)); + neighbors_resetSequenceNumber(&(msg->l2_nextORpreviousHop),msg->l2_cellRadioSetting); } } else { // the return code doesn't end up with SUCCESS @@ -1036,9 +1078,10 @@ void sixtop_six2six_sendDone(OpenQueueEntry_t* msg, owerror_t error){ if ( msg->l2_sixtop_command == IANA_6TOP_CMD_CLEAR){ schedule_removeAllNegotiatedCellsToNeighbor( msg->l2_sixtop_frameID, - &(msg->l2_nextORpreviousHop) + &(msg->l2_nextORpreviousHop), + msg->l2_cellRadioSetting ); - neighbors_resetSequenceNumber(&(msg->l2_nextORpreviousHop)); + neighbors_resetSequenceNumber(&(msg->l2_nextORpreviousHop),msg->l2_cellRadioSetting); } } } @@ -1125,6 +1168,7 @@ void sixtop_six2six_notifyReceive( uint8_t returnCode = -1; uint16_t metadata = -1; uint8_t cellOptions = -1; + cellRadioSetting_t cellRadioSetting; uint8_t cellOptions_transformed; uint16_t offset; uint16_t length_groupid_type; @@ -1220,6 +1264,13 @@ void sixtop_six2six_notifyReceive( } cellOptions = *((uint8_t*)(pkt->payload)+ptr); + + // extract radio setting + cellRadioSetting = (cellRadioSetting_t)((cellOptions & SIXTOP_CELLREQUEST_RADIOSETTING_MASK)>>5); + + // keep only link options bits + // cellOptions = cellOptions & SIXTOP_CELLREQUEST_LINKOPTIONS_MASK; + ptr += 1; pktLen -= 1; @@ -1325,11 +1376,12 @@ void sixtop_six2six_notifyReceive( i = 0; memset(response_pkt->l2_sixtop_celllist_add,0,sizeof(response_pkt->l2_sixtop_celllist_add)); while(pktLen>0){ - response_pkt->l2_sixtop_celllist_add[i].slotoffset = *((uint8_t*)(pkt->payload)+ptr); - response_pkt->l2_sixtop_celllist_add[i].slotoffset |= (*((uint8_t*)(pkt->payload)+ptr+1))<<8; - response_pkt->l2_sixtop_celllist_add[i].channeloffset = *((uint8_t*)(pkt->payload)+ptr+2); - response_pkt->l2_sixtop_celllist_add[i].channeloffset |= (*((uint8_t*)(pkt->payload)+ptr+3))<<8; - response_pkt->l2_sixtop_celllist_add[i].isUsed = TRUE; + response_pkt->l2_sixtop_celllist_add[i].slotoffset = *((uint8_t*)(pkt->payload)+ptr); + response_pkt->l2_sixtop_celllist_add[i].slotoffset |= (*((uint8_t*)(pkt->payload)+ptr+1))<<8; + response_pkt->l2_sixtop_celllist_add[i].channeloffset = *((uint8_t*)(pkt->payload)+ptr+2); + response_pkt->l2_sixtop_celllist_add[i].channeloffset |= (*((uint8_t*)(pkt->payload)+ptr+3))<<8; + response_pkt->l2_sixtop_celllist_add[i].cellRadioSetting = cellRadioSetting; + response_pkt->l2_sixtop_celllist_add[i].isUsed = TRUE; ptr += 4; pktLen -= 4; i++; @@ -1394,10 +1446,11 @@ void sixtop_six2six_notifyReceive( memset(response_pkt->l2_sixtop_celllist_delete,0,sizeof(response_pkt->l2_sixtop_celllist_delete)); temp16 = numCells; while(temp16>0){ - response_pkt->l2_sixtop_celllist_delete[i].slotoffset = *((uint8_t*)(pkt->payload)+ptr); - response_pkt->l2_sixtop_celllist_delete[i].slotoffset |= (*((uint8_t*)(pkt->payload)+ptr+1))<<8; - response_pkt->l2_sixtop_celllist_delete[i].channeloffset = *((uint8_t*)(pkt->payload)+ptr+2); - response_pkt->l2_sixtop_celllist_delete[i].channeloffset |= (*((uint8_t*)(pkt->payload)+ptr+3))<<8; + response_pkt->l2_sixtop_celllist_delete[i].slotoffset = *((uint8_t*)(pkt->payload)+ptr); + response_pkt->l2_sixtop_celllist_delete[i].slotoffset |= (*((uint8_t*)(pkt->payload)+ptr+1))<<8; + response_pkt->l2_sixtop_celllist_delete[i].channeloffset = *((uint8_t*)(pkt->payload)+ptr+2); + response_pkt->l2_sixtop_celllist_delete[i].channeloffset |= (*((uint8_t*)(pkt->payload)+ptr+3))<<8; + response_pkt->l2_sixtop_celllist_delete[i].cellRadioSetting = cellRadioSetting; response_pkt->l2_sixtop_celllist_delete[i].isUsed = TRUE; ptr += 4; pktLen -= 4; @@ -1417,11 +1470,12 @@ void sixtop_six2six_notifyReceive( i = 0; memset(response_pkt->l2_sixtop_celllist_add,0,sizeof(response_pkt->l2_sixtop_celllist_add)); while(pktLen>0){ - response_pkt->l2_sixtop_celllist_add[i].slotoffset = *((uint8_t*)(pkt->payload)+ptr); - response_pkt->l2_sixtop_celllist_add[i].slotoffset |= (*((uint8_t*)(pkt->payload)+ptr+1))<<8; - response_pkt->l2_sixtop_celllist_add[i].channeloffset = *((uint8_t*)(pkt->payload)+ptr+2); - response_pkt->l2_sixtop_celllist_add[i].channeloffset |= (*((uint8_t*)(pkt->payload)+ptr+3))<<8; - response_pkt->l2_sixtop_celllist_add[i].isUsed = TRUE; + response_pkt->l2_sixtop_celllist_add[i].slotoffset = *((uint8_t*)(pkt->payload)+ptr); + response_pkt->l2_sixtop_celllist_add[i].slotoffset |= (*((uint8_t*)(pkt->payload)+ptr+1))<<8; + response_pkt->l2_sixtop_celllist_add[i].channeloffset = *((uint8_t*)(pkt->payload)+ptr+2); + response_pkt->l2_sixtop_celllist_add[i].channeloffset |= (*((uint8_t*)(pkt->payload)+ptr+3))<<8; + response_pkt->l2_sixtop_celllist_add[i].cellRadioSetting = cellRadioSetting; + response_pkt->l2_sixtop_celllist_add[i].isUsed = TRUE; ptr += 4; pktLen -= 4; i++; @@ -1447,7 +1501,11 @@ void sixtop_six2six_notifyReceive( response_pkt->l2_sixtop_command = code; response_pkt->l2_sixtop_returnCode = returnCode; response_pkt->l2_sixtop_frameID = metadata; - // revert tx and rx link option bits + + // fill the radio setting back into the cellOptions. + response_pkt->l2_sixtop_cellOptions = cellOptions | cellRadioSetting; + + // revert tx and rx link option bits if ((cellOptions & (CELLOPTIONS_TX | CELLOPTIONS_RX)) != (CELLOPTIONS_TX | CELLOPTIONS_RX)){ response_pkt->l2_sixtop_cellOptions = cellOptions ^ (CELLOPTIONS_TX | CELLOPTIONS_RX); } else { @@ -1500,19 +1558,24 @@ void sixtop_six2six_notifyReceive( } if (type == SIXTOP_CELL_RESPONSE) { - // this is a 6p response message - - // if the code is SUCCESS + // this is a 6p response message + + // if the code is SUCCESS if (code == IANA_6TOP_RC_SUCCESS || code == IANA_6TOP_RC_EOL){ + + // extract radio setting + cellRadioSetting = (cellRadioSetting_t)(sixtop_vars.cellOptions & SIXTOP_CELLREQUEST_RADIOSETTING_MASK)>>5; + switch(sixtop_vars.six2six_state){ case SIX_STATE_WAIT_ADDRESPONSE: i = 0; memset(pkt->l2_sixtop_celllist_add,0,sizeof(pkt->l2_sixtop_celllist_add)); while(pktLen>0){ - pkt->l2_sixtop_celllist_add[i].slotoffset = *((uint8_t*)(pkt->payload)+ptr); - pkt->l2_sixtop_celllist_add[i].slotoffset |= (*((uint8_t*)(pkt->payload)+ptr+1))<<8; - pkt->l2_sixtop_celllist_add[i].channeloffset = *((uint8_t*)(pkt->payload)+ptr+2); - pkt->l2_sixtop_celllist_add[i].channeloffset |= (*((uint8_t*)(pkt->payload)+ptr+3))<<8; + pkt->l2_sixtop_celllist_add[i].slotoffset = *((uint8_t*)(pkt->payload)+ptr); + pkt->l2_sixtop_celllist_add[i].slotoffset |= (*((uint8_t*)(pkt->payload)+ptr+1))<<8; + pkt->l2_sixtop_celllist_add[i].channeloffset = *((uint8_t*)(pkt->payload)+ptr+2); + pkt->l2_sixtop_celllist_add[i].channeloffset |= (*((uint8_t*)(pkt->payload)+ptr+3))<<8; + pkt->l2_sixtop_celllist_add[i].cellRadioSetting = cellRadioSetting ; pkt->l2_sixtop_celllist_add[i].isUsed = TRUE; ptr += 4; pktLen -= 4; @@ -1524,7 +1587,7 @@ void sixtop_six2six_notifyReceive( &(pkt->l2_nextORpreviousHop), // neighbor that cells to be added to sixtop_vars.cellOptions // cell options ); - neighbors_updateSequenceNumber(&(pkt->l2_nextORpreviousHop)); + neighbors_updateSequenceNumber(&(pkt->l2_nextORpreviousHop),pkt->l2_cellRadioSetting); break; case SIX_STATE_WAIT_DELETERESPONSE: i = 0; @@ -1534,6 +1597,7 @@ void sixtop_six2six_notifyReceive( pkt->l2_sixtop_celllist_delete[i].slotoffset |= (*((uint8_t*)(pkt->payload)+ptr+1))<<8; pkt->l2_sixtop_celllist_delete[i].channeloffset = *((uint8_t*)(pkt->payload)+ptr+2); pkt->l2_sixtop_celllist_delete[i].channeloffset |= (*((uint8_t*)(pkt->payload)+ptr+3))<<8; + pkt->l2_sixtop_celllist_delete[i].cellRadioSetting = cellRadioSetting; pkt->l2_sixtop_celllist_delete[i].isUsed = TRUE; ptr += 4; pktLen -= 4; @@ -1545,17 +1609,18 @@ void sixtop_six2six_notifyReceive( &(pkt->l2_nextORpreviousHop), sixtop_vars.cellOptions ); - neighbors_updateSequenceNumber(&(pkt->l2_nextORpreviousHop)); + neighbors_updateSequenceNumber(&(pkt->l2_nextORpreviousHop),pkt->l2_cellRadioSetting); break; case SIX_STATE_WAIT_RELOCATERESPONSE: i = 0; memset(pkt->l2_sixtop_celllist_add,0,sizeof(pkt->l2_sixtop_celllist_add)); while(pktLen>0){ - pkt->l2_sixtop_celllist_add[i].slotoffset = *((uint8_t*)(pkt->payload)+ptr); - pkt->l2_sixtop_celllist_add[i].slotoffset |= (*((uint8_t*)(pkt->payload)+ptr+1))<<8; - pkt->l2_sixtop_celllist_add[i].channeloffset = *((uint8_t*)(pkt->payload)+ptr+2); - pkt->l2_sixtop_celllist_add[i].channeloffset |= (*((uint8_t*)(pkt->payload)+ptr+3))<<8; - pkt->l2_sixtop_celllist_add[i].isUsed = TRUE; + pkt->l2_sixtop_celllist_add[i].slotoffset = *((uint8_t*)(pkt->payload)+ptr); + pkt->l2_sixtop_celllist_add[i].slotoffset |= (*((uint8_t*)(pkt->payload)+ptr+1))<<8; + pkt->l2_sixtop_celllist_add[i].channeloffset = *((uint8_t*)(pkt->payload)+ptr+2); + pkt->l2_sixtop_celllist_add[i].channeloffset |= (*((uint8_t*)(pkt->payload)+ptr+3))<<8; + pkt->l2_sixtop_celllist_add[i].cellRadioSetting = cellRadioSetting; + pkt->l2_sixtop_celllist_add[i].isUsed = TRUE; ptr += 4; pktLen -= 4; i++; @@ -1572,7 +1637,7 @@ void sixtop_six2six_notifyReceive( &(pkt->l2_nextORpreviousHop), // neighbor that cells to be added to sixtop_vars.cellOptions // cell options ); - neighbors_updateSequenceNumber(&(pkt->l2_nextORpreviousHop)); + neighbors_updateSequenceNumber(&(pkt->l2_nextORpreviousHop),pkt->l2_cellRadioSetting); break; case SIX_STATE_WAIT_COUNTRESPONSE: numCells = *((uint8_t*)(pkt->payload)+ptr); @@ -1584,7 +1649,7 @@ void sixtop_six2six_notifyReceive( (errorparameter_t)numCells, (errorparameter_t)sixtop_vars.six2six_state ); - neighbors_updateSequenceNumber(&(pkt->l2_nextORpreviousHop)); + neighbors_updateSequenceNumber(&(pkt->l2_nextORpreviousHop),pkt->l2_cellRadioSetting); break; case SIX_STATE_WAIT_LISTRESPONSE: i = 0; @@ -1606,14 +1671,15 @@ void sixtop_six2six_notifyReceive( (errorparameter_t)celllist_list[0].slotoffset, (errorparameter_t)celllist_list[1].slotoffset ); - neighbors_updateSequenceNumber(&(pkt->l2_nextORpreviousHop)); + neighbors_updateSequenceNumber(&(pkt->l2_nextORpreviousHop),pkt->l2_cellRadioSetting); break; case SIX_STATE_WAIT_CLEARRESPONSE: schedule_removeAllNegotiatedCellsToNeighbor( sixtop_vars.cb_sf_getMetadata(), - &(pkt->l2_nextORpreviousHop) + &(pkt->l2_nextORpreviousHop), + cellRadioSetting ); - neighbors_resetSequenceNumber(&(pkt->l2_nextORpreviousHop)); + neighbors_resetSequenceNumber(&(pkt->l2_nextORpreviousHop),pkt->l2_cellRadioSetting); break; default: // The sixtop response arrived after 6P TIMEOUT, or @@ -1624,7 +1690,7 @@ void sixtop_six2six_notifyReceive( break; } } else { - sixtop_vars.cb_sf_handleRCError(code, &(pkt->l2_nextORpreviousHop)); + sixtop_vars.cb_sf_handleRCError(code, &(pkt->l2_nextORpreviousHop), pkt->l2_cellRadioSetting); } openserial_printInfo( COMPONENT_SIXTOP, @@ -1653,15 +1719,16 @@ bool sixtop_addCells( bool hasCellsAdded; // translate cellOptions to cell type - if (cellOptions == CELLOPTIONS_TX){ + + if ((cellOptions & SIXTOP_CELLREQUEST_LINKOPTIONS_MASK) == CELLOPTIONS_TX){ type = CELLTYPE_TX; isShared = FALSE; } - if (cellOptions == CELLOPTIONS_RX){ + if ((cellOptions & SIXTOP_CELLREQUEST_LINKOPTIONS_MASK) == CELLOPTIONS_RX){ type = CELLTYPE_RX; isShared = FALSE; } - if (cellOptions == (CELLOPTIONS_TX | CELLOPTIONS_RX | CELLOPTIONS_SHARED)){ + if ((cellOptions & SIXTOP_CELLREQUEST_LINKOPTIONS_MASK) == (CELLOPTIONS_TX | CELLOPTIONS_RX | CELLOPTIONS_SHARED)){ type = CELLTYPE_TXRX; isShared = TRUE; } @@ -1678,6 +1745,7 @@ bool sixtop_addCells( type, isShared, FALSE, + cellList[i].cellRadioSetting, cellList[i].channeloffset, &temp_neighbor ); @@ -1700,15 +1768,15 @@ bool sixtop_removeCells( bool hasCellsRemoved; // translate cellOptions to cell type - if (cellOptions == CELLOPTIONS_TX){ + if ((cellOptions & SIXTOP_CELLREQUEST_LINKOPTIONS_MASK) == CELLOPTIONS_TX){ type = CELLTYPE_TX; isShared = FALSE; } - if (cellOptions == CELLOPTIONS_RX){ + if ((cellOptions & SIXTOP_CELLREQUEST_LINKOPTIONS_MASK) == CELLOPTIONS_RX){ type = CELLTYPE_RX; isShared = FALSE; } - if (cellOptions == (CELLOPTIONS_TX | CELLOPTIONS_RX | CELLOPTIONS_SHARED)){ + if ((cellOptions & SIXTOP_CELLREQUEST_LINKOPTIONS_MASK) == (CELLOPTIONS_TX | CELLOPTIONS_RX | CELLOPTIONS_SHARED)){ type = CELLTYPE_TXRX; isShared = TRUE; } @@ -1795,13 +1863,13 @@ bool sixtop_areAvailableCellsToBeRemoved( available = TRUE; // translate cellOptions to cell type - if (cellOptions == CELLOPTIONS_TX){ + if ((cellOptions & SIXTOP_CELLREQUEST_LINKOPTIONS_MASK) == CELLOPTIONS_TX){ type = CELLTYPE_TX; } - if (cellOptions == CELLOPTIONS_RX){ + if ((cellOptions & SIXTOP_CELLREQUEST_LINKOPTIONS_MASK) == CELLOPTIONS_RX){ type = CELLTYPE_RX; } - if (cellOptions == (CELLOPTIONS_TX | CELLOPTIONS_RX | CELLOPTIONS_SHARED)){ + if ((cellOptions & SIXTOP_CELLREQUEST_LINKOPTIONS_MASK) == (CELLOPTIONS_TX | CELLOPTIONS_RX | CELLOPTIONS_SHARED)){ type = CELLTYPE_TXRX; memset(&anycastAddr,0,sizeof(open_addr_t)); anycastAddr.type = ADDR_ANYCAST; diff --git a/openstack/02b-MAChigh/sixtop.h b/openstack/02b-MAChigh/sixtop.h index 08c18da054..6763f05167 100644 --- a/openstack/02b-MAChigh/sixtop.h +++ b/openstack/02b-MAChigh/sixtop.h @@ -47,12 +47,18 @@ // SF ID #define SFID_SF0 0 +// cellRadioSetting mask in the linkOptions byte of the sixtop request +#define SIXTOP_CELLREQUEST_RADIOSETTING_MASK 0x60 + +// linkOptions mask in the linkOptions byte of the sixtop request +#define SIXTOP_CELLREQUEST_LINKOPTIONS_MASK 0x1F typedef enum { SIXTOP_CELL_REQUEST = 0x00, SIXTOP_CELL_RESPONSE = 0x01, SIXTOP_CELL_CONFIRMATION = 0x02, }sixtop_message_t; + // states of the sixtop-to-sixtop state machine typedef enum { // ready for next event @@ -85,7 +91,7 @@ typedef enum { typedef uint8_t (*sixtop_sf_getsfid_cbt)(void); typedef uint16_t (*sixtop_sf_getmetadata_cbt)(void); typedef metadata_t (*sixtop_sf_translatemetadata_cbt)(void); -typedef void (*sixtop_sf_handle_callback_cbt)(uint8_t arg, open_addr_t* address); +typedef void (*sixtop_sf_handle_callback_cbt)(uint8_t arg, open_addr_t* address, cellRadioSetting_t cellRadioSetting); #define SIXTOP_MINIMAL_EBPERIOD 5 // minist period of sending EB @@ -113,6 +119,7 @@ typedef struct { sixtop_sf_translatemetadata_cbt cb_sf_translateMetadata; sixtop_sf_handle_callback_cbt cb_sf_handleRCError; open_addr_t neighborToClearCells; + cellRadioSetting_t neighborRadioToClearCells; } sixtop_vars_t; //=========================== prototypes ====================================== diff --git a/openstack/03a-IPHC/frag.c b/openstack/03a-IPHC/frag.c index 2ac796146c..abceed5195 100644 --- a/openstack/03a-IPHC/frag.c +++ b/openstack/03a-IPHC/frag.c @@ -324,7 +324,6 @@ void frag_receive(OpenQueueEntry_t *msg) { if (idmanager_getIsDAGroot() == TRUE) { openbridge_receive(msg); - return; } else { // recover ip address from first fragment packetfunctions_tossHeader(msg, FRAG1_HEADER_SIZE); @@ -337,7 +336,7 @@ void frag_receive(OpenQueueEntry_t *msg) { // fast forwarding / source routing msg->creator = COMPONENT_FRAG; allocate_vrb(msg, size, tag); - return iphc_receive(msg); + iphc_receive(msg); } } } else if (dispatch == DISPATCH_FRAG_SUBSEQ) { @@ -436,7 +435,6 @@ static void store_fragment(OpenQueueEntry_t *msg, uint16_t size, uint16_t tag, u for (i = 0; i < FRAGMENT_BUFFER_SIZE; i++) { if (frag_vars.fragmentBuf[i].datagram_tag == tag && frag_vars.fragmentBuf[i].datagram_offset == offset) { openqueue_freePacketBuffer(msg); - return; } if (frag_vars.fragmentBuf[i].datagram_tag == tag && frag_vars.fragmentBuf[i].reassembly_timer != 0) { diff --git a/openstack/03a-IPHC/frag.h b/openstack/03a-IPHC/frag.h index 54b3998b52..7c778c6bbe 100644 --- a/openstack/03a-IPHC/frag.h +++ b/openstack/03a-IPHC/frag.h @@ -27,7 +27,7 @@ * If L2 security is not active MAX_FRAGMENT_SIZE can be set to 96 bytes, but the corresponding variable in * openvisualizer must then also be updated to the same value. */ -#define MAX_FRAGMENT_SIZE 80 +#define MAX_FRAGMENT_SIZE 96 #define FRAGMENT_BUFFER_SIZE (((IPV6_PACKET_SIZE / MAX_FRAGMENT_SIZE) + 1) * BIGQUEUELENGTH) #define NUM_OF_VRBS 2 diff --git a/openstack/03b-IPv6/forwarding.c b/openstack/03b-IPv6/forwarding.c index bec8d76415..ebf908cb48 100644 --- a/openstack/03b-IPv6/forwarding.c +++ b/openstack/03b-IPv6/forwarding.c @@ -16,7 +16,7 @@ //=========================== prototypes ====================================== -void forwarding_getNextHop(open_addr_t *destination, open_addr_t *addressToWrite); +void forwarding_getNextHop(open_addr_t *destination128b, open_addr_t *addressToWrite64b, cellRadioSetting_t *radioSettingToWrite); owerror_t forwarding_send_internal_RoutingTable( OpenQueueEntry_t *msg, @@ -369,7 +369,7 @@ void forwarding_receive( openqueue_freePacketBuffer(msg); return; } - + // going upstream if (ipv6_outer_header->next_header != IANA_IPv6ROUTE) { flags = rpl_option->flags; senderRank = rpl_option->senderRank; @@ -383,6 +383,8 @@ void forwarding_receive( (errorparameter_t) senderRank ); } + // because this part is executed in upstream direction only + // previous rank must be higher. if (senderRank < icmpv6rpl_getMyDAGrank()) { // loop detected // set flag @@ -420,6 +422,7 @@ void forwarding_receive( } } else { // source routing header present + // going downstream if ( forwarding_send_internal_SourceRouting( msg, @@ -451,7 +454,7 @@ void forwarding_receive( \param[in] destination128b Final IPv6 destination address. \param[out] addressToWrite64b Location to write the EUI64 of next hop to. */ -void forwarding_getNextHop(open_addr_t *destination128b, open_addr_t *addressToWrite64b) { +void forwarding_getNextHop(open_addr_t *destination128b, open_addr_t *addressToWrite64b, cellRadioSetting_t *radioSettingToWrite) { uint8_t i; if (packetfunctions_isBroadcastMulticast(destination128b)) { @@ -462,7 +465,7 @@ void forwarding_getNextHop(open_addr_t *destination128b, open_addr_t *addressToW } } else { // destination is remote, send to preferred parent - icmpv6rpl_getPreferredParentEui64(addressToWrite64b); + icmpv6rpl_getPreferredParentKey(addressToWrite64b,radioSettingToWrite); } } @@ -496,13 +499,14 @@ owerror_t forwarding_send_internal_RoutingTable( msg->is_cjoin_response || msg->creator == COMPONENT_CJOIN ) { - if (neighbors_isStableNeighbor(&(msg->l3_destinationAdd)) || msg->is_cjoin_response) { + if (neighbors_isStableNeighbor(&(msg->l3_destinationAdd), msg->l2_cellRadioSetting) || msg->is_cjoin_response) { // IP destination is 1-hop neighbor, send directly packetfunctions_ip128bToMac64b(&(msg->l3_destinationAdd), &temp_prefix64btoWrite, &(msg->l2_nextORpreviousHop)); } } else { - forwarding_getNextHop(&(msg->l3_destinationAdd), &(msg->l2_nextORpreviousHop)); + + forwarding_getNextHop(&(msg->l3_destinationAdd), &(msg->l2_nextORpreviousHop),&(msg->l2_cellRadioSetting)); } if (msg->l2_nextORpreviousHop.type == ADDR_NONE) { @@ -822,6 +826,8 @@ owerror_t forwarding_send_internal_SourceRouting( (errorparameter_t) senderRank ); } + // because this part is executed in downstream direction only + // previous rank must be smaller. if (senderRank > icmpv6rpl_getMyDAGrank()) { // loop detected // set flag diff --git a/openstack/03b-IPv6/icmpv6rpl.c b/openstack/03b-IPv6/icmpv6rpl.c index 86e1c7d3f9..0040330969 100644 --- a/openstack/03b-IPv6/icmpv6rpl.c +++ b/openstack/03b-IPv6/icmpv6rpl.c @@ -16,8 +16,8 @@ //=========================== definition ====================================== -#define DIO_PORTION 10 -#define DAO_PORTION 60 +#define DIO_PORTION 10 //10 +#define DAO_PORTION 60 //60 //=========================== variables ======================================= @@ -92,6 +92,7 @@ void icmpv6rpl_init(void) { memcpy(&icmpv6rpl_vars.dioDestination.addr_128b[0],all_routers_multicast,sizeof(all_routers_multicast)); icmpv6rpl_vars.dioPeriod = DIO_PERIOD; + icmpv6rpl_vars.dioCounter = 0; icmpv6rpl_vars.timerIdDIO = opentimers_create(TIMER_GENERAL_PURPOSE, TASKPRIO_RPL); //initialize PIO -> move this to dagroot code @@ -131,7 +132,7 @@ void icmpv6rpl_init(void) { opentimers_scheduleIn( icmpv6rpl_vars.timerIdDIO, - SLOTFRAME_LENGTH*SLOTDURATION, + SLOTFRAME_LENGTH*(SLOTDURATION_MS), TIME_MS, TIMER_PERIODIC, icmpv6rpl_timer_DIO_cb @@ -180,7 +181,7 @@ void icmpv6rpl_init(void) { icmpv6rpl_vars.timerIdDAO = opentimers_create(TIMER_GENERAL_PURPOSE, TASKPRIO_RPL); opentimers_scheduleIn( icmpv6rpl_vars.timerIdDAO, - SLOTFRAME_LENGTH*SLOTDURATION, + SLOTFRAME_LENGTH*(SLOTDURATION_MS), TIME_MS, TIMER_PERIODIC, icmpv6rpl_timer_DAO_cb @@ -238,6 +239,9 @@ void icmpv6rpl_sendDone(OpenQueueEntry_t* msg, owerror_t error) { // I'm not busy sending DIO/DAO anymore if (packetfunctions_isBroadcastMulticast(&(msg->l2_nextORpreviousHop))){ icmpv6rpl_vars.busySendingDIO = FALSE; + // this is a DIO + // this decrement should never end up less than 0 if protocol is running correctly. + icmpv6rpl_vars.dioCounter --; } else { icmpv6rpl_vars.busySendingDAO = FALSE; } @@ -266,6 +270,8 @@ void icmpv6rpl_receive(OpenQueueEntry_t* msg) { // handle message switch (icmpv6code) { case IANA_ICMPv6_RPL_DIS: + // This is a current hack: the DIO is sent as a broadcast in response to DIS + // but it is supposed to be sent as a unicast to DIS source. icmpv6rpl_timer_DIO_task(); break; case IANA_ICMPv6_RPL_DIO: @@ -312,6 +318,7 @@ bool icmpv6rpl_getPreferredParentIndex(uint8_t* indexptr) { return icmpv6rpl_vars.haveParent; } + /** \brief Retrieve my preferred parent's EUI64 address. \param[out] addressToWrite Where to copy the preferred parent's address to. @@ -327,6 +334,21 @@ bool icmpv6rpl_getPreferredParentEui64(open_addr_t* addressToWrite) { } } +/** +\brief Retrieve my preferred parent's neighborKey (addr and radio setting) +\param[out] neighborKey Where to copy the preferred parent's address to. +*/ +bool icmpv6rpl_getPreferredParentKey(open_addr_t* addressToWrite, cellRadioSetting_t* radioToWrite) { + if ( + icmpv6rpl_vars.haveParent && + neighbors_getNeighborNoResource(icmpv6rpl_vars.ParentIndex) == FALSE + ){ + return neighbors_getNeighborKey(addressToWrite,ADDR_64B, radioToWrite, icmpv6rpl_vars.ParentIndex); + } else { + return FALSE; + } +} + /** \brief Indicate whether some neighbor is the routing parent. @@ -389,6 +411,7 @@ void icmpv6rpl_updateMyDAGrankAndParentSelection(void) { uint32_t tentativeDAGrank; open_addr_t newParent; + cellRadioSetting_t newParentRadioSetting; // if I'm a DAGroot, my DAGrank is always MINHOPRANKINCREASE if ((idmanager_getIsDAGroot())==TRUE) { @@ -485,8 +508,8 @@ void icmpv6rpl_updateMyDAGrankAndParentSelection(void) { neighbors_setPreferredParent(icmpv6rpl_vars.ParentIndex, TRUE); // update the upstream traffic nexthop address to new parent - neighbors_getNeighborEui64(&newParent,ADDR_64B,icmpv6rpl_vars.ParentIndex); - icmpv6rpl_updateNexthopAddress(&newParent); + neighbors_getNeighborKey(&newParent,ADDR_64B,&newParentRadioSetting,icmpv6rpl_vars.ParentIndex); + icmpv6rpl_updateNexthopAddressAndRadio(&newParent,&newParentRadioSetting); } else { @@ -503,8 +526,8 @@ void icmpv6rpl_updateMyDAGrankAndParentSelection(void) { neighbors_setPreferredParent(icmpv6rpl_vars.ParentIndex, TRUE); // update the upstream traffic nexthop address to new parent - neighbors_getNeighborEui64(&newParent,ADDR_64B,icmpv6rpl_vars.ParentIndex); - icmpv6rpl_updateNexthopAddress(&newParent); + neighbors_getNeighborKey(&newParent,ADDR_64B,&newParentRadioSetting,icmpv6rpl_vars.ParentIndex); + icmpv6rpl_updateNexthopAddressAndRadio(&newParent,&newParentRadioSetting); } } } else { @@ -526,10 +549,11 @@ void icmpv6rpl_updateMyDAGrankAndParentSelection(void) { \brief In case of parent changed, update the nexthop of the IPv6 packet in the queue \param newParent. the new parent address +\param newParentRadio. the new parent radio */ -void icmpv6rpl_updateNexthopAddress(open_addr_t* newParent){ +void icmpv6rpl_updateNexthopAddressAndRadio (open_addr_t* newParent, cellRadioSetting_t* newParentRadioSetting){ - openqueue_updateNextHopPayload(newParent); + openqueue_updateNextHopPayload(newParent, newParentRadioSetting); } /** @@ -549,6 +573,7 @@ void icmpv6rpl_indicateRxDIO(OpenQueueEntry_t* msg) { uint8_t temp_8b; dagrank_t neighborRank; open_addr_t NeighborAddress; + cellRadioSetting_t NeighborRadioSetting; open_addr_t myPrefix; uint8_t* current; uint8_t optionsLen; @@ -621,20 +646,24 @@ void icmpv6rpl_indicateRxDIO(OpenQueueEntry_t* msg) { // update rank of that neighbor in table for (i=0;il2_nextORpreviousHop),&NeighborAddress)) { // matching address + + if (neighbors_getNeighborKey(&NeighborAddress, ADDR_64B, &NeighborRadioSetting, i)) { // this neighbor entry is in use + if (packetfunctions_sameAddress(&(msg->l2_nextORpreviousHop),&NeighborAddress) + && (msg->l2_cellRadioSetting == NeighborRadioSetting)) { // matching address and radio setting neighborRank=neighbors_getNeighborRank(i); if ( (icmpv6rpl_vars.incomingDio->rank > neighborRank) && (icmpv6rpl_vars.incomingDio->rank - neighborRank) > ((3*DEFAULTLINKCOST-2)*MINHOPRANKINCREASE) ) { // the new DAGrank looks suspiciously high, only increment a bit - neighbors_setNeighborRank(i,neighborRank + ((3*DEFAULTLINKCOST-2)*2*MINHOPRANKINCREASE)); + + neighbors_setNeighborRank(i,neighborRank + ((3*DEFAULTLINKCOST-2)*2*MINHOPRANKINCREASE + * ((uint8_t) msg->l2_cellRadioSetting +1))); // temp hack for testing openserial_printError(COMPONENT_ICMPv6RPL,ERR_LARGE_DAGRANK, (errorparameter_t)icmpv6rpl_vars.incomingDio->rank, (errorparameter_t)neighborRank); } else { - neighbors_setNeighborRank(i,icmpv6rpl_vars.incomingDio->rank); + neighbors_setNeighborRank(i,icmpv6rpl_vars.incomingDio->rank ); } // since changes were made to neighbors DAG rank, run the routing algorithm again icmpv6rpl_updateMyDAGrankAndParentSelection(); @@ -664,7 +693,11 @@ void icmpv6rpl_killPreferredParent(void) { already. No need to push a task again. */ void icmpv6rpl_timer_DIO_cb(opentimers_id_t id) { + // if multiple minimal cells are allocated, call the DIO firing mechanism for + // each cell + for (uint8_t i =0;i= SCHEDULE_MINIMAL_6TISCH_ACTIVE_CELLS){ + // I have created enough DIO packets for all minimal cells. + // I'm now busy sending a DIO + icmpv6rpl_vars.busySendingDIO = TRUE; + } } else { openqueue_freePacketBuffer(msg); } @@ -854,6 +895,7 @@ void sendDAO(void) { uint8_t nbrIdx; // running neighbor index uint8_t numTransitParents,numTargetParents; // the number of parents indicated in transit option open_addr_t address; + cellRadioSetting_t parentCellRadioSetting; open_addr_t* prefix; memset(&address,0,sizeof(open_addr_t)); @@ -867,7 +909,7 @@ void sendDAO(void) { // I'm not busy sending a DIO/DAO icmpv6rpl_vars.busySendingDAO = FALSE; icmpv6rpl_vars.busySendingDIO = FALSE; - + icmpv6rpl_vars.dioCounter = 0; // stop here return; } @@ -883,10 +925,10 @@ void sendDAO(void) { } if ( - icmpv6rpl_getPreferredParentEui64(&address) == FALSE || + icmpv6rpl_getPreferredParentKey(&address,&parentCellRadioSetting) == FALSE || ( - icmpv6rpl_getPreferredParentEui64(&address) && - schedule_hasNegotiatedCellToNeighbor(&address, CELLTYPE_TX) == FALSE + icmpv6rpl_getPreferredParentKey(&address,&parentCellRadioSetting) && + schedule_hasNegotiatedCellToNeighborKey(&address, parentCellRadioSetting, CELLTYPE_TX) == FALSE ) ){ // delete packets genereted by this module (EB and KA) from openqueue @@ -895,6 +937,7 @@ void sendDAO(void) { // I'm not busy sending a DIO/DAO icmpv6rpl_vars.busySendingDIO = FALSE; icmpv6rpl_vars.busySendingDAO = FALSE; + icmpv6rpl_vars.dioCounter = 0; return; } @@ -936,7 +979,7 @@ void sendDAO(void) { //=== transit option -- from RFC 6550, page 55 - 1 transit information header per parent is required. //getting only preferred parent as transit numTransitParents=0; - icmpv6rpl_getPreferredParentEui64(&address); + icmpv6rpl_getPreferredParentKey(&address,&parentCellRadioSetting); packetfunctions_writeAddress(msg,&address,OW_BIG_ENDIAN); prefix=idmanager_getMyID(ADDR_PREFIX); packetfunctions_writeAddress(msg,prefix,OW_BIG_ENDIAN); @@ -1011,6 +1054,8 @@ void sendDAO(void) { //=== DAO header packetfunctions_reserveHeaderSize(msg,sizeof(icmpv6rpl_dao_ht)); + // hack: using the radio setting in the DAO. + icmpv6rpl_vars.dao.reserved = parentCellRadioSetting; icmpv6rpl_vars.dao.DAOSequence++; memcpy( ((icmpv6rpl_dao_ht*)(msg->payload)), diff --git a/openstack/03b-IPv6/icmpv6rpl.h b/openstack/03b-IPv6/icmpv6rpl.h index f98f5d753b..3aef8432c6 100644 --- a/openstack/03b-IPv6/icmpv6rpl.h +++ b/openstack/03b-IPv6/icmpv6rpl.h @@ -187,6 +187,7 @@ typedef struct { uint16_t dioTimerCounter; ///< counter to determine when to send DIO. opentimers_id_t timerIdDIO; ///< ID of the timer used to send DIOs. uint16_t dioPeriod; ///< dio period in seconds. + uint8_t dioCounter; ///< dio transmit counter for multiple minimal cells. // DAO-related icmpv6rpl_dao_ht dao; ///< pre-populated DAO packet. icmpv6rpl_dao_transit_ht dao_transit; ///< pre-populated DAO "Transit Info" option header. @@ -221,7 +222,8 @@ void icmpv6rpl_setDIOPeriod(uint16_t dioPeriod); void icmpv6rpl_setDAOPeriod(uint16_t daoPeriod); bool icmpv6rpl_getPreferredParentIndex(uint8_t* indexptr); bool icmpv6rpl_getPreferredParentEui64(open_addr_t* addressToWrite); -void icmpv6rpl_updateNexthopAddress(open_addr_t* addressToWrite); +bool icmpv6rpl_getPreferredParentKey(open_addr_t* addressToWrite, cellRadioSetting_t* radioToWrite); +void icmpv6rpl_updateNexthopAddressAndRadio (open_addr_t* addressToWrite,cellRadioSetting_t* radioToWrite); bool icmpv6rpl_isPreferredParent(open_addr_t* address); dagrank_t icmpv6rpl_getMyDAGrank(void); void icmpv6rpl_setMyDAGrank(dagrank_t rank); diff --git a/openstack/cross-layers/openqueue.c b/openstack/cross-layers/openqueue.c index 1bc569dd5a..e1c31406e6 100644 --- a/openstack/cross-layers/openqueue.c +++ b/openstack/cross-layers/openqueue.c @@ -15,6 +15,7 @@ //=========================== variables ======================================= openqueue_vars_t openqueue_vars; +openqueue_stats_t openqueue_stats; //=========================== prototypes ====================================== @@ -22,6 +23,10 @@ void openqueue_reset_entry(OpenQueueEntry_t *entry); void openqueue_reset_big_entry(OpenQueueBigEntry_t *entry); +void openqueue_update_stats(void); + +uint8_t openqueue_getBusyPacketBufferSize(void); + //=========================== public ========================================== //======= admin @@ -38,6 +43,8 @@ void openqueue_init(void) { for (i = 0; i < BIGQUEUELENGTH; i++) { openqueue_reset_big_entry(&(openqueue_vars.big_queue[i])); } + + openqueue_reset_stats(); } /** @@ -97,6 +104,7 @@ OpenQueueEntry_t* openqueue_getFreePacketBuffer(uint8_t creator) { if (openqueue_vars.queue[i].owner == COMPONENT_NULL) { openqueue_vars.queue[i].creator = creator; openqueue_vars.queue[i].owner = COMPONENT_OPENQUEUE; + openqueue_update_stats(); ENABLE_INTERRUPTS(); return &openqueue_vars.queue[i]; } @@ -123,7 +131,6 @@ OpenQueueEntry_t* openqueue_getFreeBigPacketBuffer(uint8_t creator) { openqueue_vars.big_queue[i].standard_entry.creator = creator; openqueue_vars.big_queue[i].standard_entry.owner = COMPONENT_OPENQUEUE; openqueue_vars.big_queue[i].standard_entry.is_big_packet = TRUE; - ENABLE_INTERRUPTS(); return &openqueue_vars.big_queue[i].standard_entry; @@ -134,6 +141,7 @@ OpenQueueEntry_t* openqueue_getFreeBigPacketBuffer(uint8_t creator) { return NULL; } + /** \brief Free a previously-allocated packet buffer. @@ -157,7 +165,6 @@ owerror_t openqueue_freePacketBuffer(OpenQueueEntry_t *pkt) { (errorparameter_t) 0, (errorparameter_t) 0); } - openqueue_reset_big_entry((OpenQueueBigEntry_t *) pkt); ENABLE_INTERRUPTS(); return E_SUCCESS; @@ -174,6 +181,7 @@ owerror_t openqueue_freePacketBuffer(OpenQueueEntry_t *pkt) { (errorparameter_t) 0); } openqueue_reset_entry(&(openqueue_vars.queue[i])); + openqueue_update_stats(); ENABLE_INTERRUPTS(); return E_SUCCESS; } @@ -189,6 +197,7 @@ owerror_t openqueue_freePacketBuffer(OpenQueueEntry_t *pkt) { return E_FAIL; } + /** \brief Free all the packet buffers created by a specific module. @@ -212,7 +221,7 @@ void openqueue_removeAllCreatedBy(uint8_t creator) { openqueue_reset_big_entry(&(openqueue_vars.big_queue[i])); } } - + openqueue_update_stats(); ENABLE_INTERRUPTS(); } @@ -397,10 +406,11 @@ OpenQueueEntry_t* openqueue_macGetDIOPacket(){ } /** -\Brief replace the upstream packet nexthop payload by given newNextHop address +\Brief replace the upstream packet nexthop payload by given newNextHop address and RadioSetting \param newNextHop. +\param newNextHopRadio. */ -void openqueue_updateNextHopPayload(open_addr_t *newNextHop) { +void openqueue_updateNextHopPayload(open_addr_t *newNextHop, cellRadioSetting_t* newNextHopRadio) { uint8_t i, j; INTERRUPT_DECLARATION(); @@ -422,6 +432,7 @@ void openqueue_updateNextHopPayload(open_addr_t *newNextHop) { for (j = 0; j < 8; j++) { *((uint8_t *) openqueue_vars.queue[i].l2_nextHop_payload + j) = newNextHop->addr_64b[j]; } + openqueue_vars.queue[i].l2_cellRadioSetting = *newNextHopRadio; } } } @@ -481,9 +492,56 @@ OpenQueueEntry_t* openqueue_macGetUnicastPakcet(open_addr_t* toNeighbor){ } +openqueue_stats_t openqueue_get_stats(void) +{ + return openqueue_stats; +} //=========================== private ========================================= +/** +\brief Get the size of the busy packet buffer + +This is used at the moment for statistical measurements purposes to see the +impact of different configurations on the average buffer size. + +\returns an uint with the number of waiting packets in the buffer +*/ +uint8_t openqueue_getBusyPacketBufferSize() { + uint8_t i; + uint8_t busy_buffer_size = 0; + + INTERRUPT_DECLARATION(); + DISABLE_INTERRUPTS(); + // walk through queue and find free entry + for (i = 0; i < QUEUELENGTH; i++) { + if (openqueue_vars.queue[i].owner != COMPONENT_NULL) { + busy_buffer_size++; + } + } + ENABLE_INTERRUPTS(); + return busy_buffer_size; +} + + +void openqueue_update_stats(void){ + // update the stats + uint8_t buffSize = openqueue_getBusyPacketBufferSize(); + if (buffSize>openqueue_stats.maxBuffSize){ + openqueue_stats.maxBuffSize = buffSize; + } + + if (buffSize< openqueue_stats.minBuffSize){ + openqueue_stats.minBuffSize=buffSize; + } + +} +void openqueue_reset_stats(void){ + uint8_t size = openqueue_getBusyPacketBufferSize(); + openqueue_stats.maxBuffSize=size; + openqueue_stats.minBuffSize=size; +} + void openqueue_reset_entry(OpenQueueEntry_t *entry) { //admin entry->creator = COMPONENT_NULL; diff --git a/openstack/cross-layers/openqueue.h b/openstack/cross-layers/openqueue.h index a37f8c5688..24a1374bae 100644 --- a/openstack/cross-layers/openqueue.h +++ b/openstack/cross-layers/openqueue.h @@ -30,6 +30,11 @@ typedef struct { OpenQueueBigEntry_t big_queue[BIGQUEUELENGTH]; } openqueue_vars_t; +typedef struct +{ + uint8_t maxBuffSize; // max packets in the buffer + uint8_t minBuffSize; // min packets in the buffer +} openqueue_stats_t; //=========================== prototypes ====================================== // admin @@ -41,8 +46,11 @@ OpenQueueEntry_t* openqueue_getFreeBigPacketBuffer(uint8_t creator); owerror_t openqueue_freePacketBuffer(OpenQueueEntry_t* pkt); void openqueue_removeAllCreatedBy(uint8_t creator); bool openqueue_isHighPriorityEntryEnough(void); +openqueue_stats_t openqueue_get_stats(void); +void openqueue_reset_stats(void); + // called by ICMPv6 -void openqueue_updateNextHopPayload(open_addr_t* newNextHop); +void openqueue_updateNextHopPayload(open_addr_t* newNextHop, cellRadioSetting_t* newNextHopRadio); // called by res OpenQueueEntry_t* openqueue_sixtopGetSentPacket(void); OpenQueueEntry_t* openqueue_sixtopGetReceivedPacket(void); diff --git a/projects/common/01bsp_radio_jammer/01bsp_radio_jammer.c b/projects/common/01bsp_radio_jammer/01bsp_radio_jammer.c index 2418715f34..e321f088d9 100644 --- a/projects/common/01bsp_radio_jammer/01bsp_radio_jammer.c +++ b/projects/common/01bsp_radio_jammer/01bsp_radio_jammer.c @@ -15,7 +15,7 @@ The packet contains LENGTH_PACKET bytes. The send bytes are random. #include "board.h" #include "radio.h" #include "leds.h" -#include "bsp_timer.h" +//#include "bsp_timer.h" //=========================== defines ========================================= diff --git a/projects/common/01bsp_radio_tx/01bsp_radio_tx.c b/projects/common/01bsp_radio_tx/01bsp_radio_tx.c index 243032d5fb..964f162d80 100644 --- a/projects/common/01bsp_radio_tx/01bsp_radio_tx.c +++ b/projects/common/01bsp_radio_tx/01bsp_radio_tx.c @@ -133,4 +133,4 @@ void cb_endFrame(PORT_TIMER_WIDTH timestamp) { // led leds_sync_off(); -} +} \ No newline at end of file diff --git a/projects/common/03oos_macpong/03oos_macpong.c b/projects/common/03oos_macpong/03oos_macpong.c index a9da815044..ade35cedcb 100644 --- a/projects/common/03oos_macpong/03oos_macpong.c +++ b/projects/common/03oos_macpong/03oos_macpong.c @@ -200,4 +200,3 @@ void opencoap_init(void) { return; } //===== L7 void openapps_init(void) { return; } - diff --git a/projects/openmote-b-24ghz/03oos_macpong/03oos_macpong.ewp b/projects/openmote-b-24ghz/03oos_macpong/03oos_macpong.ewp index 8210554df4..00ad42c162 100644 --- a/projects/openmote-b-24ghz/03oos_macpong/03oos_macpong.ewp +++ b/projects/openmote-b-24ghz/03oos_macpong/03oos_macpong.ewp @@ -11,7 +11,7 @@ General 3 - 28 + 31 1 1 + + + ICCARM 2 - 34 + 35 1 1 + @@ -701,7 +718,7 @@ ILINK 0 - 20 + 23 1 1 + + + + + + @@ -1052,7 +1093,7 @@ General 3 - 28 + 31 1 0 + + + ICCARM 2 - 34 + 35 1 0 + @@ -1711,7 +1769,7 @@ ILINK 0 - 20 + 23 1 0 + + + + + + diff --git a/projects/openmote-b-subghz/03oos_macpong/03oos_macpong.ewp b/projects/openmote-b-subghz/03oos_macpong/03oos_macpong.ewp index 746e1669de..ee66e84e33 100644 --- a/projects/openmote-b-subghz/03oos_macpong/03oos_macpong.ewp +++ b/projects/openmote-b-subghz/03oos_macpong/03oos_macpong.ewp @@ -11,7 +11,7 @@ General 3 - 28 + 31 1 1 + + + ICCARM 2 - 34 + 35 1 1 + @@ -701,7 +718,7 @@ ILINK 0 - 20 + 23 1 1 + + + + + + @@ -1052,7 +1093,7 @@ General 3 - 28 + 31 1 0 + + + ICCARM 2 - 34 + 35 1 0 + @@ -1711,7 +1769,7 @@ ILINK 0 - 20 + 23 1 0 + + + + + + @@ -2394,6 +2476,12 @@ $PROJ_DIR$\..\..\..\bsp\chips\at86rf215\radio.h + + $PROJ_DIR$\..\..\..\bsp\chips\at86rf215\radio_at86rf215.c + + + $PROJ_DIR$\..\..\..\bsp\chips\at86rf215\radio_at86rf215.h + max44009 diff --git a/projects/openmote-b-subghz/03oos_macpong/03oos_macpong.ewt b/projects/openmote-b-subghz/03oos_macpong/03oos_macpong.ewt new file mode 100644 index 0000000000..55a4d87fa9 --- /dev/null +++ b/projects/openmote-b-subghz/03oos_macpong/03oos_macpong.ewt @@ -0,0 +1,2891 @@ + + + 3 + + Debug + + ARM + + 1 + + C-STAT + 261 + + 261 + + 0 + + 1 + 600 + 1 + 2 + 0 + 1 + 100 + + + 1.5.5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + RuntimeChecking + 0 + + 2 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + Release + + ARM + + 0 + + C-STAT + 261 + + 261 + + 0 + + 1 + 600 + 1 + 2 + 0 + 1 + 100 + + + 1.5.5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + RuntimeChecking + 0 + + 2 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + application + + $PROJ_DIR$\..\..\common\03oos_macpong\03oos_macpong.c + + + $PROJ_DIR$\..\..\common\03oos_macpong\03oos_macpong.h + + + + bsp + + boards + + openmote-b-subghz + + headers + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\headers\hw_aes.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\headers\hw_ana_regs.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\headers\hw_cctest.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\headers\hw_flash_ctrl.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\headers\hw_gpio.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\headers\hw_gptimer.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\headers\hw_i2cm.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\headers\hw_i2cs.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\headers\hw_ints.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\headers\hw_ioc.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\headers\hw_memmap.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\headers\hw_nvic.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\headers\hw_pka.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\headers\hw_rfcore_ffsm.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\headers\hw_rfcore_sfr.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\headers\hw_rfcore_xreg.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\headers\hw_smwdthrosc.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\headers\hw_soc_adc.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\headers\hw_ssi.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\headers\hw_sys_ctrl.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\headers\hw_types.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\headers\hw_uart.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\headers\hw_udma.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\headers\hw_udmachctl.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\headers\hw_usb.h + + + + source + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\adc.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\adc.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\aes.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\aes.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\bl_commands.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\ccm.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\ccm.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\cpu.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\cpu.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\debug.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\debug.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\ecc_curveinfo.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\flash.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\flash.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\gpio.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\gpio.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\gptimer.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\gptimer.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\i2c_lib.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\i2c_lib.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\interrupt.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\interrupt.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\ioc.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\ioc.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\pka.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\pka.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\rom.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\sha256.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\sha256.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\sleepmode.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\sleepmode.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\ssi.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\ssi.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\sys_ctrl.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\sys_ctrl.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\systick.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\systick.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\uarthal.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\uarthal.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\udma.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\udma.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\watchdog.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\source\watchdog.h + + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\adc_sensor.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\adc_sensor.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\board.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\board_info.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\cc2538rf.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\cryptoengine.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\debugpins.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\eui64.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\i2c.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\leds.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\sctimer.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\sensors.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\spi.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\startup_gcc.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\startup_iar.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\uart.c + + + + $PROJ_DIR$\..\..\..\bsp\boards\board.h + + + $PROJ_DIR$\..\..\..\bsp\boards\bsp_timer.h + + + $PROJ_DIR$\..\..\..\bsp\boards\debugpins.h + + + $PROJ_DIR$\..\..\..\bsp\boards\eui64.h + + + $PROJ_DIR$\..\..\..\bsp\boards\i2c.h + + + $PROJ_DIR$\..\..\..\bsp\boards\leds.h + + + $PROJ_DIR$\..\..\..\bsp\boards\radio.h + + + $PROJ_DIR$\..\..\..\bsp\boards\radiotimer.h + + + $PROJ_DIR$\..\..\..\bsp\boards\sctimer.h + + + $PROJ_DIR$\..\..\..\bsp\boards\sensors.h + + + $PROJ_DIR$\..\..\..\bsp\boards\spi.h + + + $PROJ_DIR$\..\..\..\bsp\boards\toolchain_defs.h + + + $PROJ_DIR$\..\..\..\bsp\boards\uart.h + + + + chips + + adxl346 + + $PROJ_DIR$\..\..\..\bsp\chips\adxl346\adxl346.c + + + $PROJ_DIR$\..\..\..\bsp\chips\adxl346\adxl346.h + + + + at86rf215 + + $PROJ_DIR$\..\..\..\bsp\chips\at86rf215\at86rf215.c + + + $PROJ_DIR$\..\..\..\bsp\chips\at86rf215\at86rf215.h + + + $PROJ_DIR$\..\..\..\bsp\chips\at86rf215\radio.c + + + $PROJ_DIR$\..\..\..\bsp\chips\at86rf215\radio.h + + + $PROJ_DIR$\..\..\..\bsp\chips\at86rf215\radio_at86rf215.c + + + $PROJ_DIR$\..\..\..\bsp\chips\at86rf215\radio_at86rf215.h + + + + max44009 + + $PROJ_DIR$\..\..\..\bsp\chips\max44009\max44009.c + + + $PROJ_DIR$\..\..\..\bsp\chips\max44009\max44009.h + + + + sht21 + + $PROJ_DIR$\..\..\..\bsp\chips\sht21\sht21.c + + + $PROJ_DIR$\..\..\..\bsp\chips\sht21\sht21.h + + + + si70x + + $PROJ_DIR$\..\..\..\bsp\chips\si70x\si70x.c + + + $PROJ_DIR$\..\..\..\bsp\chips\si70x\si70x.h + + + + + + drivers + + common + + $PROJ_DIR$\..\..\..\drivers\common\openhdlc.c + + + $PROJ_DIR$\..\..\..\drivers\common\openhdlc.h + + + $PROJ_DIR$\..\..\..\drivers\common\opensensors.c + + + $PROJ_DIR$\..\..\..\drivers\common\opensensors.h + + + $PROJ_DIR$\..\..\..\drivers\common\openserial.c + + + $PROJ_DIR$\..\..\..\drivers\common\openserial.h + + + $PROJ_DIR$\..\..\..\drivers\common\opentimers.c + + + $PROJ_DIR$\..\..\..\drivers\common\opentimers.h + + + + + inc + + $PROJ_DIR$\..\..\..\inc\opendefs.h + + + + kernel + + $PROJ_DIR$\..\..\..\kernel\openos\scheduler.c + + + $PROJ_DIR$\..\..\..\kernel\scheduler.h + + + + openstack + + 02a-MAClow + + $PROJ_DIR$\..\..\..\openstack\02a-MAClow\adaptive_sync.c + + + $PROJ_DIR$\..\..\..\openstack\02a-MAClow\adaptive_sync.h + + + $PROJ_DIR$\..\..\..\openstack\02a-MAClow\IEEE802154.c + + + $PROJ_DIR$\..\..\..\openstack\02a-MAClow\IEEE802154.h + + + $PROJ_DIR$\..\..\..\openstack\02a-MAClow\IEEE802154_security.c + + + $PROJ_DIR$\..\..\..\openstack\02a-MAClow\IEEE802154_security.h + + + $PROJ_DIR$\..\..\..\openstack\02a-MAClow\IEEE802154E.c + + + $PROJ_DIR$\..\..\..\openstack\02a-MAClow\IEEE802154E.h + + + $PROJ_DIR$\..\..\..\openstack\02a-MAClow\topology.c + + + $PROJ_DIR$\..\..\..\openstack\02a-MAClow\topology.h + + + + 02b-MAChigh + + $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\msf.c + + + $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\msf.h + + + $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\neighbors.c + + + $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\neighbors.h + + + $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\processIE.h + + + $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\schedule.c + + + $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\schedule.h + + + $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\sixtop.c + + + $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\sixtop.h + + + + cross-layers + + $PROJ_DIR$\..\..\..\openstack\cross-layers\idmanager.c + + + $PROJ_DIR$\..\..\..\openstack\cross-layers\idmanager.h + + + $PROJ_DIR$\..\..\..\openstack\cross-layers\openqueue.c + + + $PROJ_DIR$\..\..\..\openstack\cross-layers\openqueue.h + + + $PROJ_DIR$\..\..\..\openstack\cross-layers\openrandom.c + + + $PROJ_DIR$\..\..\..\openstack\cross-layers\openrandom.h + + + $PROJ_DIR$\..\..\..\openstack\cross-layers\packetfunctions.c + + + $PROJ_DIR$\..\..\..\openstack\cross-layers\packetfunctions.h + + + + $PROJ_DIR$\..\..\..\openstack\openstack.c + + + $PROJ_DIR$\..\..\..\openstack\openstack.h + + + diff --git a/projects/openmote-b/01bsp_openradio_rx/01bsp_openradio_rx.c b/projects/openmote-b/01bsp_openradio_rx/01bsp_openradio_rx.c new file mode 100644 index 0000000000..807fabf49f --- /dev/null +++ b/projects/openmote-b/01bsp_openradio_rx/01bsp_openradio_rx.c @@ -0,0 +1,284 @@ +/** +\brief This program shows the use of the "radio" bsp module. + +Since the bsp modules for different platforms have the same declaration, you +can use this project with any platform. + +This application places the mote in receive mode, and prints, over the serial +port, all information about the received packet. The frame printed over the +serial port for each received packet is formatted as follows: +- [1B] the length of the packet, an unsigned integer +- [1B] the first byte of the packet, an unsigned integer +- [1B] the receive signal strength of tehe packet, an signed integer +- [1B] the link quality indicator, an unsigned integer +- [1B] whether the receive packet passed CRC (1) or not (0) +- [3B] closing flags, each of value 0xff + +You can run the 01bsp_radio_rx.py script to listen to your mote and parse those +serial frames. The application can connect directly to the mote's serial port, +or to its TCP port when running on the IoT-LAB platform. + +Example when running locally: +---------------------------- + + ___ _ _ _ ___ _ _ +| . | ___ ___ ._ _ | | | |/ __>| \ | +| | || . \/ ._>| ' || | | |\__ \| | +`___'| _/\___.|_|_||__/_/ <___/|_\_| + |_| openwsn.org + +running IoT-lAB? (Y|N): N +name of serial port (e.g. COM10): COM25 +len=127 num=176 rssi=-43 lqi=107 crc=1 +len=127 num=177 rssi=-43 lqi=107 crc=1 +len=127 num=178 rssi=-43 lqi=106 crc=1 +len=127 num=179 rssi=-43 lqi=107 crc=1 +len=127 num=180 rssi=-43 lqi=108 crc=1 +len=127 num=181 rssi=-43 lqi=107 crc=1 +len=127 num=182 rssi=-43 lqi=107 crc=1 +len=127 num=183 rssi=-43 lqi=107 crc=1 + + +Example when running on the IoT-LAB platform: +-------------------------------------------- + + ___ _ _ _ ___ _ _ +| . | ___ ___ ._ _ | | | |/ __>| \ | +| | || . \/ ._>| ' || | | |\__ \| | +`___'| _/\___.|_|_||__/_/ <___/|_\_| + |_| openwsn.org + +running IoT-lAB? (Y|N): Y +motename? (e.g. wsn430-35): wsn430-35 +len=17 num=84 rssi=-80 lqi=107 crc=1 +len=17 num=84 rssi=-81 lqi=107 crc=1 +len=17 num=84 rssi=-80 lqi=107 crc=1 +len=17 num=84 rssi=-81 lqi=105 crc=1 +len=17 num=84 rssi=-80 lqi=108 crc=1 +len=17 num=84 rssi=-81 lqi=108 crc=1 + + +\author Xavi Vilajosana xvilajosana@eecs.berkeley.edu>, June 2012. +\author Thomas Watteyne , August 2014. +*/ + +#include "stdint.h" +#include "string.h" +#include "board.h" +#include "radio.h" +#include "leds.h" +#include "debugpins.h" +#include "uart.h" +//#include "sctimer.h" + +//=========================== defines ========================================= + +#define LENGTH_PACKET 125+LENGTH_CRC // maximum length is 127 bytes +#define CHANNEL 11 // 24ghz: 11 = 2.405GHz, subghz: 11 = 865.325 in FSK operating mode #1 +#define LENGTH_SERIAL_FRAME 9 // length of the serial frame + +//=========================== variables ======================================= + +typedef struct { + uint8_t num_radioTimerCompare; + uint8_t num_startFrame; + uint8_t num_endFrame; +} app_dbg_t; + +app_dbg_t app_dbg; + +typedef struct { + // rx packet + volatile uint8_t rxpk_done; + uint8_t rxpk_buf[LENGTH_PACKET]; + uint16_t rxpk_len; + uint8_t rxpk_num; + int8_t rxpk_rssi; + uint8_t rxpk_lqi; + bool rxpk_crc; + uint8_t rxpk_freq_offset; + // uart + uint8_t uart_txFrame[LENGTH_SERIAL_FRAME]; + uint8_t uart_lastTxByte; + volatile uint8_t uart_done; +} app_vars_t; + +app_vars_t app_vars; + +//=========================== prototypes ====================================== + +// radiotimer +void cb_radioTimerOverflows(void); +// radio +void cb_startFrame(PORT_TIMER_WIDTH timestamp); +void cb_endFrame(PORT_TIMER_WIDTH timestamp); +// uart +void cb_uartTxDone(void); +uint8_t cb_uartRxCb(void); + +//=========================== main ============================================ + +/** +\brief The program starts executing here. +*/ +int mote_main(void) { + + uint8_t i; + + // clear local variables + memset(&app_vars,0,sizeof(app_vars_t)); + + // initialize board + board_init(); + + + + // setup UART + uart_setCallbacks(cb_uartTxDone,cb_uartRxCb); + + // prepare radio + radio_setConfig (RADIOSETTING_OQPSK_RATE3); + radio_rfOn(); + // freq type only effects on scum port + radio_setFrequency(CHANNEL, FREQ_RX); + // add callback functions radio + radio_setStartFrameCb(cb_startFrame); + radio_setEndFrameCb(cb_endFrame); + // switch in RX + radio_rxEnable(); + radio_rxNow(); + debugpins_radio_clr(); + while (1) { + + // sleep while waiting for at least one of the rxpk_done to be set + + app_vars.rxpk_done = 0; + while (app_vars.rxpk_done==0) { + board_sleep(); + } + + // if I get here, I just received a packet + + //===== send notification over serial port + + // led + leds_error_on(); + + // format frame to send over serial port + i = 0; + app_vars.uart_txFrame[i++] = app_vars.rxpk_len; // packet length + app_vars.uart_txFrame[i++] = app_vars.rxpk_num; // packet number + app_vars.uart_txFrame[i++] = app_vars.rxpk_rssi; // RSSI + app_vars.uart_txFrame[i++] = app_vars.rxpk_lqi; // LQI + app_vars.uart_txFrame[i++] = app_vars.rxpk_crc; // CRC + app_vars.uart_txFrame[i++] = app_vars.rxpk_freq_offset; // freq_offset + app_vars.uart_txFrame[i++] = 0xff; // closing flag + app_vars.uart_txFrame[i++] = 0xff; // closing flag + app_vars.uart_txFrame[i++] = 0xff; // closing flag + + app_vars.uart_done = 0; + app_vars.uart_lastTxByte = 0; + + // send app_vars.uart_txFrame over UART + uart_clearTxInterrupts(); + uart_clearRxInterrupts(); + uart_enableInterrupts(); + uart_writeByte(app_vars.uart_txFrame[app_vars.uart_lastTxByte]); + while (app_vars.uart_done==0); // busy wait to finish + uart_disableInterrupts(); + + // led + leds_error_off(); + } +} + +//=========================== callbacks ======================================= + +//===== radio + +void cb_startFrame(PORT_TIMER_WIDTH timestamp) { + debugpins_radio_toggle(); + debugpins_fsm_set(); + leds_sync_on(); + // update debug stats + app_dbg.num_startFrame++; +} + +void cb_endFrame(PORT_TIMER_WIDTH timestamp) { + debugpins_radio_toggle(); + debugpins_fsm_clr(); + uint8_t i; + bool expectedFrame; + + // update debug stats + app_dbg.num_endFrame++; + + memset(&app_vars.rxpk_buf[0],0,LENGTH_PACKET); + + app_vars.rxpk_freq_offset = radio_getFrequencyOffset(); + + // get packet from radio + radio_getReceivedFrame( + app_vars.rxpk_buf, + &app_vars.rxpk_len, + sizeof(app_vars.rxpk_buf), + &app_vars.rxpk_rssi, + &app_vars.rxpk_lqi, + &app_vars.rxpk_crc + ); + + // check the frame is sent by radio_tx project + expectedFrame = TRUE; + + if (app_vars.rxpk_len>LENGTH_PACKET){ + expectedFrame = FALSE; + } else { + for(i=1;i<10;i++){ + if(app_vars.rxpk_buf[i]!=i){ + expectedFrame = FALSE; + break; + } + } + } + + // read the packet number + app_vars.rxpk_num = app_vars.rxpk_buf[0]; + + // toggle led if the frame is expected + if (expectedFrame){ + // indicate I just received a packet from bsp_radio_tx mote + app_vars.rxpk_done = 1; + + leds_debug_toggle(); + } + + // keep listening (needed for at86rf215 radio) + radio_rxEnable(); + radio_rxNow(); + + // led + leds_sync_off(); +} + +//===== uart + +void cb_uartTxDone(void) { + + uart_clearTxInterrupts(); + + // prepare to send the next byte + app_vars.uart_lastTxByte++; + + if (app_vars.uart_lastTxByte| \ |"] +banner += ["| | || . \/ ._>| ' || | | |\__ \| |"] +banner += ["`___'| _/\___.|_|_||__/_/ <___/|_\_|"] +banner += [" |_| openwsn.org"] +banner += [""] +banner = '\n'.join(banner) +print banner + +XOFF = 0x13 +XON = 0x11 +XONXOFF_ESCAPE = 0x12 +XONXOFF_MASK = 0x10 + +MAX_NUM_PACKET = 256 + +def mote_connect(motename=None , serialport= None, baudrate='115200'): + try: + if (motename): + mote = socket.socket(socket.AF_INET,socket.SOCK_STREAM) + mote.connect((motename,20000)) + else: + mote = serial.Serial(serialport, baudrate) + return mote + except Exception as err: + print "{0}".format(err) + raw_input('Press Enter to close.') + sys.exit(1) + + +#============================ configuration and connection =================================== + +iotlab_serialport = False +motename = 'wsn430-35' +serialport = 'COM10' +mote = None + +t = raw_input('Are you running on IoT-LAB nodes ? (Y|N): ') +if (not t.strip() or t.strip() in ['1','yes','y','Y']): + t = raw_input('Enter mote name ? (e.g. {0}): '.format(motename)) + if t.strip(): + motename = t.strip() + archi = motename.split('-') + assert len(archi) == 2 + assert archi[0] in ['wsn430', 'a8', 'm3'] + if (archi[0] != 'a8'): + iotlab_serialport = True + mote = mote_connect(motename=motename) + else: + mote = mote_connect(serialport='/dev/ttyA8_M3', baudrate='500000') + +else: + t = raw_input('Enter serial port name (e.g. {0}): '.format(serialport)) + if t.strip(): + serialport = t.strip() + mote = mote_connect(serialport=serialport) + +#============================ read ============================================ + +rawFrame = [] +rawFrame_decoded = [] +previousFrame = 0 +frameCounter = 0 +xonxoffEscaping = False + +while True: + + if iotlab_serialport: + bytes = mote.recv(1024) + rawFrame += [ord(b) for b in bytes] + else: + byte = mote.read(1) + rawFrame += [ord(byte)] + + if rawFrame[-3:]==[0xff]*3 and len(rawFrame)>=9: + + for byte in rawFrame: + if byte==XONXOFF_ESCAPE: + xonxoffEscaping = True + else: + if xonxoffEscaping==True: + rawFrame_decoded += [byte^XONXOFF_MASK] + xonxoffEscaping=False + elif byte!=XON and byte!=XOFF: + rawFrame_decoded += [byte] + + (rxpk_len,rxpk_num,rxpk_rssi,rxpk_lqi,rxpk_crc, rxpk_freq_offset) = \ + struct.unpack('>BBbBBb', ''.join([chr(b) for b in rawFrame_decoded[-9:-3]])) + + # debug info + output = 'len={0:<3} num={1:<3} rssi={2:<4} lqi={3:<3} crc={4} freq_offset={5:<4}'.format( + rxpk_len, + rxpk_num, + rxpk_rssi, + rxpk_lqi, + rxpk_crc, + rxpk_freq_offset + ) + + print output + + with open('log.txt','a') as f: + f.write(output+'\n') + + if rxpk_len>127: + print "ERROR: frame too long.\a" + else: + if previousFrame>rxpk_num: + output = "frameCounter={0:<3}, PDR={1}%".format(frameCounter, frameCounter*100/MAX_NUM_PACKET) + print output + frameCounter = 0 + with open('log.txt','a') as f: + f.write(output+'\n') + + frameCounter += 1 + previousFrame = rxpk_num + + rawFrame = [] + rawFrame_decoded = [] diff --git a/projects/openmote-b/01bsp_openradio_tx/01bsp_openradio_tx.c b/projects/openmote-b/01bsp_openradio_tx/01bsp_openradio_tx.c new file mode 100644 index 0000000000..9e68177ab5 --- /dev/null +++ b/projects/openmote-b/01bsp_openradio_tx/01bsp_openradio_tx.c @@ -0,0 +1,177 @@ +/** +\brief This program shows the use of the "open radio" bsp module. + +Since the bsp modules for different platforms have the same declaration, you +can use this project with any platform. + +The board running this program will send a packet on channel CHANNEL every +TIMER_PERIOD ticks. The packet contains LENGTH_PACKET bytes. The first byte +is the packet number, which increments for each transmitted packet. The +remainder of the packet contains an incrementing bytes. + +\author Thomas Watteyne , August 2014. +\updated Mina Rady +*/ + +#include "stdint.h" +#include "string.h" +#include "board.h" +#include "board.h" +#include "radio.h" +#include "leds.h" +#include "sctimer.h" + +//=========================== defines ========================================= + +#define LENGTH_PACKET 125+LENGTH_CRC // maximum length is 127 bytes +#define CHANNEL 11 // 24ghz: 11 = 2.405GHz, subghz: 11 = 865.325 in FSK operating mode #1 +#define TIMER_PERIOD (32768>>4) // (32768>>1) = 500ms @ 32kHz + +//=========================== variables ======================================= + +typedef struct { + uint8_t num_scTimerCompare; + uint8_t num_startFrame; + uint8_t num_endFrame; +} app_dbg_t; + +app_dbg_t app_dbg; + +typedef struct { + uint8_t txpk_txNow; + uint8_t txpk_buf[LENGTH_PACKET]; + uint8_t txpk_len; + uint8_t txpk_num; +} app_vars_t; + +app_vars_t app_vars; + +//=========================== prototypes ====================================== + +void cb_scTimerCompare(void); +void cb_startFrame(PORT_TIMER_WIDTH timestamp); +void cb_endFrame(PORT_TIMER_WIDTH timestamp); + +//=========================== main ============================================ + +/** +\brief The program starts executing here. +*/ +int mote_main(void) { + uint8_t i; + // bool to switch betweeb radios + + uint8_t radio_switch = 0; + // clear local variables + memset(&app_vars,0,sizeof(app_vars_t)); + + // initialize board + board_init(); + + // add radio callback functions + sctimer_set_callback(cb_scTimerCompare); + + radio_setConfig (RADIOSETTING_FSK_OPTION1_FEC); + radio_setStartFrameCb(cb_startFrame); + radio_setEndFrameCb(cb_endFrame); + + radio_setConfig (RADIOSETTING_24GHZ); + radio_setStartFrameCb(cb_startFrame); + radio_setEndFrameCb(cb_startFrame); + + + // start periodic overflow + sctimer_setCompare(sctimer_readCounter()+ TIMER_PERIOD); + sctimer_enable(); + while(1) { + + // wait for timer to elapse + app_vars.txpk_txNow = 0; + while (app_vars.txpk_txNow==0) { + board_sleep(); + } + + switch (radio_switch%7){ + case 0: + // freq type only effects on scum port + // looping on radio settings from slowest to fastest. + radio_setFrequency(CHANNEL, FREQ_TX); + radio_setConfig (RADIOSETTING_FSK_OPTION1_FEC); + break; + case 1: + radio_setFrequency(CHANNEL, FREQ_TX); + radio_setConfig (RADIOSETTING_OQPSK_RATE3); + break; + case 2: + radio_setFrequency(CHANNEL, FREQ_TX); + radio_setConfig (RADIOSETTING_OFDM_OPTION_1_MCS0); + break; + case 3: + radio_setFrequency(CHANNEL, FREQ_TX); + radio_setConfig (RADIOSETTING_OFDM_OPTION_1_MCS1); + break; + case 4: + radio_setFrequency(CHANNEL, FREQ_TX); + radio_setConfig (RADIOSETTING_OFDM_OPTION_1_MCS2); + break; + case 5: + radio_setFrequency(CHANNEL, FREQ_TX); + radio_setConfig (RADIOSETTING_OFDM_OPTION_1_MCS3); + break; + case 6: + radio_setFrequency(CHANNEL, FREQ_TX); + radio_setConfig (RADIOSETTING_24GHZ); + break; + } + + //Toggle the switch + radio_switch ++; + // led + leds_error_toggle(); + + // prepare packet + app_vars.txpk_num++; + app_vars.txpk_len = sizeof(app_vars.txpk_buf); + app_vars.txpk_buf[0] = app_vars.txpk_num; + for (i=1;i + + 3 + + Debug + + ARM + + 1 + + General + 3 + + 31 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ICCARM + 2 + + 35 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AARM + 2 + + 10 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OBJCOPY + 0 + + 1 + 1 + 1 + + + + + + + + + CUSTOM + 3 + + + + 0 + + + + BICOMP + 0 + + + + BUILDACTION + 1 + + + + + + + ILINK + 0 + + 23 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IARCHIVE + 0 + + 0 + 1 + 1 + + + + + + + BILINK + 0 + + + + + Release + + ARM + + 0 + + General + 3 + + 31 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ICCARM + 2 + + 35 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AARM + 2 + + 10 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OBJCOPY + 0 + + 1 + 1 + 0 + + + + + + + + + CUSTOM + 3 + + + + 0 + + + + BICOMP + 0 + + + + BUILDACTION + 1 + + + + + + + ILINK + 0 + + 23 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IARCHIVE + 0 + + 0 + 1 + 0 + + + + + + + BILINK + 0 + + + + + bsp + + boards + + openmote-b + + headers + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_aes.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_ana_regs.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_cctest.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_flash_ctrl.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_gpio.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_gptimer.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_i2cm.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_i2cs.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_ints.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_ioc.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_memmap.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_nvic.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_pka.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_rfcore_ffsm.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_rfcore_sfr.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_rfcore_xreg.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_smwdthrosc.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_soc_adc.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_ssi.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_sys_ctrl.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_types.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_uart.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_udma.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_udmachctl.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_usb.h + + + + source + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\adc.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\adc.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\aes.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\aes.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\bl_commands.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\ccm.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\ccm.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\cpu.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\cpu.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\debug.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\debug.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\ecc_curveinfo.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\flash.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\flash.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\gpio.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\gpio.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\gptimer.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\gptimer.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\i2c_lib.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\i2c_lib.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\interrupt.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\interrupt.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\ioc.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\ioc.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\pka.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\pka.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\rom.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\sha256.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\sha256.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\sleepmode.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\sleepmode.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\ssi.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\ssi.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\sys_ctrl.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\sys_ctrl.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\systick.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\systick.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\uarthal.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\uarthal.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\udma.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\udma.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\watchdog.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\watchdog.h + + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\adc_sensor.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\adc_sensor.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\board.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\board_info.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\bsp_timer.c + + Debug + + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\cc2538rf.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\cryptoengine.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\debugpins.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\eui64.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\i2c.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\leds.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\radiotimer.c + + Debug + + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\sctimer.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\sensors.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\spi.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\startup_iar.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\uart.c + + + + $PROJ_DIR$\..\..\..\bsp\boards\board.h + + + $PROJ_DIR$\..\..\..\bsp\boards\bsp_timer.h + + Debug + + + + $PROJ_DIR$\..\..\..\bsp\boards\crypto_engine.h + + + $PROJ_DIR$\..\..\..\bsp\boards\debugpins.h + + + $PROJ_DIR$\..\..\..\bsp\boards\eui64.h + + + $PROJ_DIR$\..\..\..\bsp\boards\i2c.h + + + $PROJ_DIR$\..\..\..\bsp\boards\leds.h + + + $PROJ_DIR$\..\..\..\bsp\boards\radiotimer.h + + Debug + + + + $PROJ_DIR$\..\..\..\bsp\boards\sctimer.h + + + $PROJ_DIR$\..\..\..\bsp\boards\sensors.h + + + $PROJ_DIR$\..\..\..\bsp\boards\spi.h + + + $PROJ_DIR$\..\..\..\bsp\boards\toolchain_defs.h + + + $PROJ_DIR$\..\..\..\bsp\boards\uart.h + + + + chips + + at86rf215 + + $PROJ_DIR$\..\..\..\bsp\chips\at86rf215\at86rf215.c + + + $PROJ_DIR$\..\..\..\bsp\chips\at86rf215\at86rf215.h + + + $PROJ_DIR$\..\..\..\bsp\chips\at86rf215\radio.c + + + $PROJ_DIR$\..\..\..\bsp\chips\at86rf215\radio.h + + + $PROJ_DIR$\..\..\..\bsp\chips\at86rf215\radio_at86rf215.c + + + $PROJ_DIR$\..\..\..\bsp\chips\at86rf215\radio_at86rf215.h + + + + si70x + + $PROJ_DIR$\..\..\..\bsp\chips\si70x\si70x.c + + + $PROJ_DIR$\..\..\..\bsp\chips\si70x\si70x.h + + + + + + inc + + $PROJ_DIR$\..\..\..\inc\opendefs.h + + + + projects + + common + + 01bsp_radio_jammer + + $PROJ_DIR$\..\..\common\01bsp_radio_jammer\01bsp_radio_jammer.c + + + + + diff --git a/projects/openmote-b/01bsp_radio_jammer/01bsp_radio_jammer.ewt b/projects/openmote-b/01bsp_radio_jammer/01bsp_radio_jammer.ewt new file mode 100644 index 0000000000..b0d27d68cd --- /dev/null +++ b/projects/openmote-b/01bsp_radio_jammer/01bsp_radio_jammer.ewt @@ -0,0 +1,2732 @@ + + + 3 + + Debug + + ARM + + 1 + + C-STAT + 261 + + 261 + + 0 + + 1 + 600 + 1 + 2 + 0 + 1 + 100 + + + 1.5.5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + RuntimeChecking + 0 + + 2 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + Release + + ARM + + 0 + + C-STAT + 261 + + 261 + + 0 + + 1 + 600 + 1 + 2 + 0 + 1 + 100 + + + 1.5.5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + RuntimeChecking + 0 + + 2 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + bsp + + boards + + openmote-b + + headers + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_aes.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_ana_regs.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_cctest.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_flash_ctrl.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_gpio.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_gptimer.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_i2cm.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_i2cs.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_ints.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_ioc.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_memmap.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_nvic.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_pka.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_rfcore_ffsm.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_rfcore_sfr.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_rfcore_xreg.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_smwdthrosc.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_soc_adc.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_ssi.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_sys_ctrl.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_types.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_uart.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_udma.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_udmachctl.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_usb.h + + + + source + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\adc.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\adc.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\aes.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\aes.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\bl_commands.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\ccm.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\ccm.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\cpu.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\cpu.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\debug.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\debug.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\ecc_curveinfo.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\flash.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\flash.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\gpio.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\gpio.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\gptimer.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\gptimer.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\i2c_lib.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\i2c_lib.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\interrupt.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\interrupt.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\ioc.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\ioc.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\pka.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\pka.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\rom.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\sha256.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\sha256.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\sleepmode.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\sleepmode.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\ssi.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\ssi.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\sys_ctrl.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\sys_ctrl.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\systick.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\systick.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\uarthal.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\uarthal.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\udma.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\udma.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\watchdog.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\watchdog.h + + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\adc_sensor.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\adc_sensor.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\board.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\board_info.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\bsp_timer.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\cc2538rf.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\cryptoengine.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\debugpins.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\eui64.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\i2c.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\leds.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\radiotimer.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\sctimer.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\sensors.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b-subghz\spi.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\startup_iar.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\uart.c + + + + $PROJ_DIR$\..\..\..\bsp\boards\board.h + + + $PROJ_DIR$\..\..\..\bsp\boards\bsp_timer.h + + + $PROJ_DIR$\..\..\..\bsp\boards\crypto_engine.h + + + $PROJ_DIR$\..\..\..\bsp\boards\debugpins.h + + + $PROJ_DIR$\..\..\..\bsp\boards\eui64.h + + + $PROJ_DIR$\..\..\..\bsp\boards\i2c.h + + + $PROJ_DIR$\..\..\..\bsp\boards\leds.h + + + $PROJ_DIR$\..\..\..\bsp\boards\radiotimer.h + + + $PROJ_DIR$\..\..\..\bsp\boards\sctimer.h + + + $PROJ_DIR$\..\..\..\bsp\boards\sensors.h + + + $PROJ_DIR$\..\..\..\bsp\boards\spi.h + + + $PROJ_DIR$\..\..\..\bsp\boards\toolchain_defs.h + + + $PROJ_DIR$\..\..\..\bsp\boards\uart.h + + + + chips + + at86rf215 + + $PROJ_DIR$\..\..\..\bsp\chips\at86rf215\at86rf215.c + + + $PROJ_DIR$\..\..\..\bsp\chips\at86rf215\at86rf215.h + + + $PROJ_DIR$\..\..\..\bsp\chips\at86rf215\radio.c + + + $PROJ_DIR$\..\..\..\bsp\chips\at86rf215\radio.h + + + $PROJ_DIR$\..\..\..\bsp\chips\at86rf215\radio_at86rf215.c + + + $PROJ_DIR$\..\..\..\bsp\chips\at86rf215\radio_at86rf215.h + + + + si70x + + $PROJ_DIR$\..\..\..\bsp\chips\si70x\si70x.c + + + $PROJ_DIR$\..\..\..\bsp\chips\si70x\si70x.h + + + + + + inc + + $PROJ_DIR$\..\..\..\inc\opendefs.h + + + + projects + + common + + 01bsp_radio_jammer + + $PROJ_DIR$\..\..\common\01bsp_radio_jammer\01bsp_radio_jammer.c + + + + + diff --git a/projects/openmote-b/01bsp_radio_tx/01bsp_radio_tx.ewp b/projects/openmote-b/01bsp_radio_tx/01bsp_radio_tx.ewp new file mode 100644 index 0000000000..e81c8c2a46 --- /dev/null +++ b/projects/openmote-b/01bsp_radio_tx/01bsp_radio_tx.ewp @@ -0,0 +1,2637 @@ + + + 3 + + Debug + + ARM + + 1 + + General + 3 + + 31 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ICCARM + 2 + + 35 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AARM + 2 + + 10 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OBJCOPY + 0 + + 1 + 1 + 1 + + + + + + + + + CUSTOM + 3 + + + + 0 + + + + BICOMP + 0 + + + + BUILDACTION + 1 + + + + + + + ILINK + 0 + + 23 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IARCHIVE + 0 + + 0 + 1 + 1 + + + + + + + BILINK + 0 + + + + + Release + + ARM + + 0 + + General + 3 + + 31 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ICCARM + 2 + + 35 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AARM + 2 + + 10 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OBJCOPY + 0 + + 1 + 1 + 0 + + + + + + + + + CUSTOM + 3 + + + + 0 + + + + BICOMP + 0 + + + + BUILDACTION + 1 + + + + + + + ILINK + 0 + + 23 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IARCHIVE + 0 + + 0 + 1 + 0 + + + + + + + BILINK + 0 + + + + + application + + $PROJ_DIR$\..\..\common\01bsp_radio_tx\01bsp_radio_tx.c + + + + bsp + + boards + + openmote-b + + headers + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_aes.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_ana_regs.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_cctest.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_flash_ctrl.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_gpio.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_gptimer.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_i2cm.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_i2cs.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_ints.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_ioc.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_memmap.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_nvic.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_pka.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_rfcore_ffsm.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_rfcore_sfr.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_rfcore_xreg.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_smwdthrosc.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_soc_adc.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_ssi.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_sys_ctrl.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_types.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_uart.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_udma.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_udmachctl.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_usb.h + + + + source + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\adc.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\adc.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\aes.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\aes.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\bl_commands.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\ccm.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\ccm.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\cpu.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\cpu.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\debug.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\debug.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\ecc_curveinfo.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\flash.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\flash.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\gpio.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\gpio.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\gptimer.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\gptimer.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\i2c_lib.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\i2c_lib.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\interrupt.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\interrupt.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\ioc.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\ioc.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\pka.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\pka.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\rom.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\sha256.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\sha256.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\sleepmode.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\sleepmode.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\ssi.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\ssi.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\sys_ctrl.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\sys_ctrl.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\systick.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\systick.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\uarthal.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\uarthal.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\udma.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\udma.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\watchdog.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\watchdog.h + + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\adc_sensor.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\adc_sensor.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\board.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\board_info.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\cc2538rf.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\cryptoengine.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\debugpins.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\eui64.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\i2c.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\leds.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\radio.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\sctimer.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\sensors.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\spi.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\startup_iar.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\uart.c + + + + $PROJ_DIR$\..\..\..\bsp\boards\board.h + + + $PROJ_DIR$\..\..\..\bsp\boards\cryptoengine.h + + + $PROJ_DIR$\..\..\..\bsp\boards\debugpins.h + + + $PROJ_DIR$\..\..\..\bsp\boards\eui64.h + + + $PROJ_DIR$\..\..\..\bsp\boards\i2c.h + + + $PROJ_DIR$\..\..\..\bsp\boards\leds.h + + + $PROJ_DIR$\..\..\..\bsp\boards\radio.h + + + $PROJ_DIR$\..\..\..\bsp\boards\sctimer.h + + + $PROJ_DIR$\..\..\..\bsp\boards\sensors.h + + + $PROJ_DIR$\..\..\..\bsp\boards\spi.h + + + $PROJ_DIR$\..\..\..\bsp\boards\toolchain_defs.h + + + $PROJ_DIR$\..\..\..\bsp\boards\uart.h + + + + chips + + at86rf215 + + $PROJ_DIR$\..\..\..\bsp\chips\at86rf215\at86rf215.c + + + $PROJ_DIR$\..\..\..\bsp\chips\at86rf215\at86rf215.h + + + $PROJ_DIR$\..\..\..\bsp\chips\at86rf215\radio_at86rf215.c + + + $PROJ_DIR$\..\..\..\bsp\chips\at86rf215\radio_at86rf215.h + + + + cc2538rf + + $PROJ_DIR$\..\..\..\bsp\chips\cc2538rf\radio_cc2538rf.c + + + $PROJ_DIR$\..\..\..\bsp\chips\cc2538rf\radio_cc2538rf.h + + + + s70x + + $PROJ_DIR$\..\..\..\bsp\chips\si70x\si70x.c + + + $PROJ_DIR$\..\..\..\bsp\chips\si70x\si70x.h + + + + sht21 + + $PROJ_DIR$\..\..\..\bsp\chips\sht21\sht21.c + + + $PROJ_DIR$\..\..\..\bsp\chips\sht21\sht21.h + + + + + + drivers + + common + + $PROJ_DIR$\..\..\..\drivers\common\openhdlc.c + + + $PROJ_DIR$\..\..\..\drivers\common\openhdlc.h + + + $PROJ_DIR$\..\..\..\drivers\common\opensensors.c + + + $PROJ_DIR$\..\..\..\drivers\common\opensensors.h + + + $PROJ_DIR$\..\..\..\drivers\common\openserial.c + + + $PROJ_DIR$\..\..\..\drivers\common\openserial.h + + + $PROJ_DIR$\..\..\..\drivers\common\opentimers.c + + + $PROJ_DIR$\..\..\..\drivers\common\opentimers.h + + + + + inc + + $PROJ_DIR$\..\..\..\inc\opendefs.h + + + + kernel + + $PROJ_DIR$\..\..\..\kernel\openos\scheduler.c + + + $PROJ_DIR$\..\..\..\kernel\scheduler.h + + + + openstack + + 02a-MAClow + + $PROJ_DIR$\..\..\..\openstack\02a-MAClow\adaptive_sync.c + + + $PROJ_DIR$\..\..\..\openstack\02a-MAClow\adaptive_sync.h + + + $PROJ_DIR$\..\..\..\openstack\02a-MAClow\IEEE802154.c + + + $PROJ_DIR$\..\..\..\openstack\02a-MAClow\IEEE802154.h + + + $PROJ_DIR$\..\..\..\openstack\02a-MAClow\IEEE802154_security.c + + + $PROJ_DIR$\..\..\..\openstack\02a-MAClow\IEEE802154_security.h + + + $PROJ_DIR$\..\..\..\openstack\02a-MAClow\IEEE802154E.c + + + $PROJ_DIR$\..\..\..\openstack\02a-MAClow\IEEE802154E.h + + + $PROJ_DIR$\..\..\..\openstack\02a-MAClow\topology.c + + + $PROJ_DIR$\..\..\..\openstack\02a-MAClow\topology.h + + + + 02b-MAChigh + + $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\msf.c + + + $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\msf.h + + + $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\neighbors.c + + + $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\neighbors.h + + + $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\processIE.h + + + $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\schedule.c + + + $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\schedule.h + + + $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\sixtop.c + + + $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\sixtop.h + + + + cross-layers + + $PROJ_DIR$\..\..\..\openstack\cross-layers\idmanager.c + + + $PROJ_DIR$\..\..\..\openstack\cross-layers\idmanager.h + + + $PROJ_DIR$\..\..\..\openstack\cross-layers\openqueue.c + + + $PROJ_DIR$\..\..\..\openstack\cross-layers\openqueue.h + + + $PROJ_DIR$\..\..\..\openstack\cross-layers\openrandom.c + + + $PROJ_DIR$\..\..\..\openstack\cross-layers\openrandom.h + + + $PROJ_DIR$\..\..\..\openstack\cross-layers\packetfunctions.c + + + $PROJ_DIR$\..\..\..\openstack\cross-layers\packetfunctions.h + + + + $PROJ_DIR$\..\..\..\openstack\openstack.c + + + $PROJ_DIR$\..\..\..\openstack\openstack.h + + + diff --git a/projects/openmote-b/02drv_relay/02drv_relay.c b/projects/openmote-b/02drv_relay/02drv_relay.c new file mode 100644 index 0000000000..80cafec92d --- /dev/null +++ b/projects/openmote-b/02drv_relay/02drv_relay.c @@ -0,0 +1,365 @@ +/** +\brief This is a program which runs a simple relay. If it recives an input from UART, it turns the mote into a periodic transmitter for that payload. + +\author Mina Rady , October 2021 +*/ + +#include "stdint.h" +#include "stdio.h" +#include "string.h" +// bsp modules required +#include "board.h" +#include "uart.h" +#include "sctimer.h" +#include "leds.h" +#include "radio.h" + +//=========================== defines ========================================= +#define CPU_CLOCK_FREQ 32768 // 32kHz = 1s +#define VAR_NOT_SET 0xFF + +// Serial input + +#define SCTIMER_PERIOD CPU_CLOCK_FREQ*5 +#define MAX_STRING_SIZE 100 + +// Protocol stack + +#define LENGTH_PACKET 125+LENGTH_CRC // maximum length is 127 bytes +#define CHANNEL 11 // 24ghz: 11 = 2.405GHz, subghz: 11 = 865.325 in FSK operating mode #1 +#define TIMER_PERIOD (32768>>1) // (32768>>1) = 500ms @ 32kHz +#define NETID 38000 // Grenoble postal code +#define NETID_SIZE 2 // 2 bytes + +uint8_t stringReceived[MAX_STRING_SIZE]; +uint8_t writeIndex; +bool IAmTransmitter; + +uint16_t net_id; +uint8_t payloadString[MAX_STRING_SIZE]; +uint8_t payloadSize; + + +//=========================== variables ======================================= + +typedef struct { + + // UART TX related + uint8_t uart_lastTxByteIndex; + volatile uint8_t uartDone; + volatile uint8_t uartSendNow; + + // MAC related + + // tx + uint8_t txpk_txNow; + uint8_t txpk_buf[LENGTH_PACKET]; + uint8_t txpk_len; + uint8_t txpk_num; + + //rx + volatile uint8_t rxpk_done; + uint8_t rxpk_buf[LENGTH_PACKET]; + uint8_t rxpk_len; + uint8_t rxpk_num; + uint8_t rxpk_src; + int8_t rxpk_rssi; + uint8_t rxpk_lqi; + bool rxpk_crc; + uint8_t rxpk_freq_offset; + + // routing + uint8_t rank; +} app_vars_t; + +app_vars_t app_vars; + + +typedef struct { + uint8_t num_scTimerCompare; + uint8_t num_startFrame; + uint8_t num_endFrame; + uint8_t counter; +} app_dbg_t; + +app_dbg_t app_dbg; + +//=========================== prototypes ====================================== + +// timer callback +void cb_compare(void); + +// UART callbacks +void cb_uartTxDone(void); +uint8_t cb_uartRxCb(void); + +// radio callbacks +void cb_startFrame(PORT_TIMER_WIDTH timestamp); +void cb_endFrame(PORT_TIMER_WIDTH timestamp); + +// frame validity check +bool checkFrame (void); + +//=========================== main ============================================ + +/** +\brief The program starts executing here. +*/ +int mote_main(void) { + + // clear local variable + memset(&app_vars,0,sizeof(app_vars_t)); + memset(&stringReceived,0,MAX_STRING_SIZE); + memset(&payloadString,0,MAX_STRING_SIZE); + writeIndex= 0; + IAmTransmitter = false; + app_dbg.counter = 0; + app_vars.uartSendNow = 1; + app_vars.rank = VAR_NOT_SET; + + // initialize the board + board_init(); + + // setup UART + uart_setCallbacks(cb_uartTxDone,cb_uartRxCb); + uart_enableInterrupts(); + + // setup sctimer + sctimer_set_callback(cb_compare); + sctimer_setCompare(sctimer_readCounter()+SCTIMER_PERIOD); + + // setup the radios + + + + // cc2538 callbacks + radio_setConfig (RADIOSETTING_24GHZ); + radio_setStartFrameCb(cb_startFrame); + radio_setEndFrameCb(cb_startFrame); + + // atmel callbacks + radio_setConfig (RADIOSETTING_FSK_OPTION1_FEC); + radio_setStartFrameCb(cb_startFrame); + radio_setEndFrameCb(cb_endFrame); + + // radio frequency + radio_setFrequency(CHANNEL, FREQ_TX); + radio_rfOn(); + + while(1) { + + // if I am a designated transmitter, transmit. + while (IAmTransmitter == true){ + + uint8_t i = 0; + + // prepare packet + + /* + 1B packet number + 1B hop number + 2B NET ID + 1B payload size + 100B payload + */ + app_vars.txpk_num++; + app_vars.txpk_len = sizeof(app_vars.txpk_buf); + app_vars.txpk_buf[i++] = app_vars.txpk_num; + app_vars.txpk_buf[i++] = 0; // hop number + app_vars.txpk_buf[i++] = NETID >>8; + app_vars.txpk_buf[i++] = NETID & 0xFF; + app_vars.txpk_buf[i++] = payloadSize; + + + for (uint8_t j = 0; j< payloadSize; j++) + { + app_vars.txpk_buf[i++] = payloadString[j]; + } + + // now packet is ready + + while (app_vars.txpk_txNow==0) { + board_sleep(); + } + app_vars.txpk_txNow = 0; + app_dbg.counter++; + + // transmit + leds_error_toggle(); + radio_rfOff(); + radio_loadPacket(app_vars.txpk_buf,app_vars.txpk_len); + radio_txEnable(); + radio_txNow(); + + + } + + // otherwise, listen and relay + radio_setFrequency(CHANNEL, FREQ_RX); + radio_rxEnable(); + radio_rxNow(); + + app_vars.rxpk_done = 0; + while (app_vars.rxpk_done==0 && IAmTransmitter == 0) { + board_sleep(); + } + // if I get here, I just received a packet + + + //while (app_vars.uartSendNow==0); + //app_vars.uartSendNow = 0; + + // send string over UART + // app_vars.uartDone = 0; + // app_vars.uart_lastTxByteIndex = 0; + // uart_writeByte(payloadString[app_vars.uart_lastTxByteIndex]); + // while(app_vars.uartDone==0); + } +} + +//=========================== callbacks ======================================= + +void cb_compare(void) { + + // send packet + app_vars.txpk_txNow = 1; + + // app_vars.uartSendNow = 1; + + // schedule again + sctimer_setCompare(sctimer_readCounter()+SCTIMER_PERIOD); +} + +void cb_uartTxDone(void) { + app_vars.uart_lastTxByteIndex++; + if (app_vars.uart_lastTxByteIndexLENGTH_PACKET){ + return false; + } + + uint8_t* frame = &app_vars.rxpk_buf[0]; + uint8_t frame_no = *frame++; + uint8_t hop_no = *frame++; + uint16_t netid = *frame++; + netid = netid<<8 | *frame; + + // check net id + if (netid != NETID){ + return false; + } + + // check routing + if (app_vars.rank == VAR_NOT_SET){ + app_vars.rank = hop_no+1; + }else{ + + if (hop_no| \ |"] +banner += ["| | || . \/ ._>| ' || | | |\__ \| |"] +banner += ["`___'| _/\___.|_|_||__/_/ <___/|_\_|"] +banner += [" |_| openwsn.org"] +banner += [""] +banner = '\n'.join(banner) +print banner + +XOFF = 0x13 +XON = 0x11 +XONXOFF_ESCAPE = 0x12 +XONXOFF_MASK = 0x10 + +MAX_NUM_PACKET = 256 + +def mote_connect(motename=None , serialport= None, baudrate='115200'): + try: + if (motename): + mote = socket.socket(socket.AF_INET,socket.SOCK_STREAM) + mote.connect((motename,20000)) + else: + mote = serial.Serial(serialport, baudrate) + return mote + except Exception as err: + print "{0}".format(err) + raw_input('Press Enter to close.') + sys.exit(1) + + +#============================ configuration and connection =================================== + +iotlab_serialport = False +motename = 'wsn430-35' +serialport = 'COM10' +mote = None + +t = raw_input('Are you running on IoT-LAB nodes ? (Y|N): ') +if (not t.strip() or t.strip() in ['1','yes','y','Y']): + t = raw_input('Enter mote name ? (e.g. {0}): '.format(motename)) + if t.strip(): + motename = t.strip() + archi = motename.split('-') + assert len(archi) == 2 + assert archi[0] in ['wsn430', 'a8', 'm3'] + if (archi[0] != 'a8'): + iotlab_serialport = True + mote = mote_connect(motename=motename) + else: + mote = mote_connect(serialport='/dev/ttyA8_M3', baudrate='500000') + +else: + t = raw_input('Enter serial port name (e.g. {0}): '.format(serialport)) + if t.strip(): + serialport = t.strip() + mote = mote_connect(serialport=serialport) + +#============================ read ============================================ + +rawFrame = [] +rawFrame_decoded = [] +previousFrame = 0 +frameCounter = 0 +xonxoffEscaping = False + +while True: + + if iotlab_serialport: + bytes = mote.recv(1024) + rawFrame += [ord(b) for b in bytes] + else: + byte = mote.read(1) + rawFrame += [ord(byte)] + + if rawFrame[-3:]==[0xff]*3 and len(rawFrame)>=9: + + for byte in rawFrame: + if byte==XONXOFF_ESCAPE: + xonxoffEscaping = True + else: + if xonxoffEscaping==True: + rawFrame_decoded += [byte^XONXOFF_MASK] + xonxoffEscaping=False + elif byte!=XON and byte!=XOFF: + rawFrame_decoded += [byte] + (rxpk_len,rxpk_num,rxpk_src,rxpk_rssi,rxpk_lqi,rxpk_crc, rxpk_freq_offset) = \ + struct.unpack('>BBBbBBb', ''.join([chr(b) for b in rawFrame_decoded[-10:-3]])) + + # debug info + output = 'src={0:<3} len={1:<3} num={2:<3} rssi={3:<4} lqi={4:<3} crc={5} freq_offset={6:<4}'.format( + rxpk_src, + rxpk_len, + rxpk_num, + rxpk_rssi, + rxpk_lqi, + rxpk_crc, + rxpk_freq_offset + ) + + print output + + with open('log.txt','a') as f: + f.write(output+'\n') + + if rxpk_len>127: + print "ERROR: frame too long.\a" + else: + if previousFrame>rxpk_num: + output = "frameCounter={0:<3}, PDR={1}%".format(frameCounter, frameCounter*100/MAX_NUM_PACKET) + print output + frameCounter = 0 + with open('log.txt','a') as f: + f.write(output+'\n') + + frameCounter += 1 + previousFrame = rxpk_num + + rawFrame = [] + rawFrame_decoded = [] diff --git a/projects/openmote-b/03oos_macpong/03oos_macpong.ewp b/projects/openmote-b/03oos_macpong/03oos_macpong.ewp index 5fcd035c22..95c5452fdb 100644 --- a/projects/openmote-b/03oos_macpong/03oos_macpong.ewp +++ b/projects/openmote-b/03oos_macpong/03oos_macpong.ewp @@ -11,7 +11,7 @@ General 3 - 28 + 31 1 1 + + + ICCARM 2 - 34 + 35 1 1 + @@ -612,7 +632,7 @@ @@ -1051,7 +1095,7 @@ General 3 - 28 + 31 1 0 + + + ICCARM 2 - 34 + 35 1 0 + @@ -1710,7 +1771,7 @@ ILINK 0 - 20 + 23 1 0 + + + + + + @@ -2316,10 +2401,7 @@ $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\sensors.c - $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\startup_gcc.c - - Debug - + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\spi.c $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\startup_iar.c @@ -2332,7 +2414,7 @@ $PROJ_DIR$\..\..\..\bsp\boards\board.h - $PROJ_DIR$\..\..\..\bsp\boards\bsp_timer.h + $PROJ_DIR$\..\..\..\bsp\boards\cryptoengine.h $PROJ_DIR$\..\..\..\bsp\boards\debugpins.h @@ -2349,9 +2431,6 @@ $PROJ_DIR$\..\..\..\bsp\boards\radio.h - - $PROJ_DIR$\..\..\..\bsp\boards\radiotimer.h - $PROJ_DIR$\..\..\..\bsp\boards\sctimer.h @@ -2371,21 +2450,36 @@ chips - adxl346 + at86rf215 - $PROJ_DIR$\..\..\..\bsp\chips\adxl346\adxl346.c + $PROJ_DIR$\..\..\..\bsp\chips\at86rf215\at86rf215.c - $PROJ_DIR$\..\..\..\bsp\chips\adxl346\adxl346.h + $PROJ_DIR$\..\..\..\bsp\chips\at86rf215\at86rf215.h + + + $PROJ_DIR$\..\..\..\bsp\chips\at86rf215\radio_at86rf215.c + + + $PROJ_DIR$\..\..\..\bsp\chips\at86rf215\radio_at86rf215.h - max44009 + cc2538rf - $PROJ_DIR$\..\..\..\bsp\chips\max44009\max44009.c + $PROJ_DIR$\..\..\..\bsp\chips\cc2538rf\radio_cc2538rf.c - $PROJ_DIR$\..\..\..\bsp\chips\max44009\max44009.h + $PROJ_DIR$\..\..\..\bsp\chips\cc2538rf\radio_cc2538rf.h + + + + s70x + + $PROJ_DIR$\..\..\..\bsp\chips\si70x\si70x.c + + + $PROJ_DIR$\..\..\..\bsp\chips\si70x\si70x.h @@ -2481,6 +2575,12 @@ 02b-MAChigh + + $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\msf.c + + + $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\msf.h + $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\neighbors.c @@ -2496,12 +2596,6 @@ $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\schedule.h - - $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\msf.c - - - $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\msf.h - $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\sixtop.c diff --git a/projects/openmote-b/03oos_macpong/03oos_macpong.ewt b/projects/openmote-b/03oos_macpong/03oos_macpong.ewt new file mode 100644 index 0000000000..ba57a28b68 --- /dev/null +++ b/projects/openmote-b/03oos_macpong/03oos_macpong.ewt @@ -0,0 +1,2873 @@ + + + 3 + + Debug + + ARM + + 1 + + C-STAT + 261 + + 261 + + 0 + + 1 + 600 + 1 + 2 + 0 + 1 + 100 + + + 1.5.5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + RuntimeChecking + 0 + + 2 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + Release + + ARM + + 0 + + C-STAT + 261 + + 261 + + 0 + + 1 + 600 + 1 + 2 + 0 + 1 + 100 + + + 1.5.5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + RuntimeChecking + 0 + + 2 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + application + + $PROJ_DIR$\..\..\common\03oos_macpong\03oos_macpong.c + + + $PROJ_DIR$\..\..\common\03oos_macpong\03oos_macpong.h + + + + bsp + + boards + + openmote-b + + headers + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_aes.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_ana_regs.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_cctest.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_flash_ctrl.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_gpio.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_gptimer.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_i2cm.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_i2cs.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_ints.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_ioc.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_memmap.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_nvic.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_pka.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_rfcore_ffsm.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_rfcore_sfr.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_rfcore_xreg.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_smwdthrosc.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_soc_adc.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_ssi.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_sys_ctrl.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_types.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_uart.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_udma.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_udmachctl.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_usb.h + + + + source + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\adc.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\adc.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\aes.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\aes.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\bl_commands.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\ccm.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\ccm.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\cpu.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\cpu.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\debug.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\debug.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\ecc_curveinfo.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\flash.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\flash.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\gpio.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\gpio.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\gptimer.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\gptimer.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\i2c_lib.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\i2c_lib.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\interrupt.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\interrupt.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\ioc.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\ioc.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\pka.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\pka.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\rom.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\sha256.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\sha256.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\sleepmode.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\sleepmode.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\ssi.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\ssi.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\sys_ctrl.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\sys_ctrl.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\systick.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\systick.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\uarthal.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\uarthal.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\udma.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\udma.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\watchdog.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\watchdog.h + + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\adc_sensor.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\adc_sensor.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\board.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\board_info.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\cc2538rf.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\cryptoengine.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\debugpins.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\eui64.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\i2c.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\leds.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\radio.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\sctimer.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\sensors.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\spi.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\startup_iar.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\uart.c + + + + $PROJ_DIR$\..\..\..\bsp\boards\board.h + + + $PROJ_DIR$\..\..\..\bsp\boards\cryptoengine.h + + + $PROJ_DIR$\..\..\..\bsp\boards\debugpins.h + + + $PROJ_DIR$\..\..\..\bsp\boards\eui64.h + + + $PROJ_DIR$\..\..\..\bsp\boards\i2c.h + + + $PROJ_DIR$\..\..\..\bsp\boards\leds.h + + + $PROJ_DIR$\..\..\..\bsp\boards\radio.h + + + $PROJ_DIR$\..\..\..\bsp\boards\sctimer.h + + + $PROJ_DIR$\..\..\..\bsp\boards\sensors.h + + + $PROJ_DIR$\..\..\..\bsp\boards\spi.h + + + $PROJ_DIR$\..\..\..\bsp\boards\toolchain_defs.h + + + $PROJ_DIR$\..\..\..\bsp\boards\uart.h + + + + chips + + at86rf215 + + $PROJ_DIR$\..\..\..\bsp\chips\at86rf215\at86rf215.c + + + $PROJ_DIR$\..\..\..\bsp\chips\at86rf215\at86rf215.h + + + $PROJ_DIR$\..\..\..\bsp\chips\at86rf215\radio_at86rf215.c + + + $PROJ_DIR$\..\..\..\bsp\chips\at86rf215\radio_at86rf215.h + + + + cc2538rf + + $PROJ_DIR$\..\..\..\bsp\chips\cc2538rf\radio_cc2538rf.c + + + $PROJ_DIR$\..\..\..\bsp\chips\cc2538rf\radio_cc2538rf.h + + + + s70x + + $PROJ_DIR$\..\..\..\bsp\chips\si70x\si70x.c + + + $PROJ_DIR$\..\..\..\bsp\chips\si70x\si70x.h + + + + sht21 + + $PROJ_DIR$\..\..\..\bsp\chips\sht21\sht21.c + + + $PROJ_DIR$\..\..\..\bsp\chips\sht21\sht21.h + + + + + + drivers + + common + + $PROJ_DIR$\..\..\..\drivers\common\openhdlc.c + + + $PROJ_DIR$\..\..\..\drivers\common\openhdlc.h + + + $PROJ_DIR$\..\..\..\drivers\common\opensensors.c + + + $PROJ_DIR$\..\..\..\drivers\common\opensensors.h + + + $PROJ_DIR$\..\..\..\drivers\common\openserial.c + + + $PROJ_DIR$\..\..\..\drivers\common\openserial.h + + + $PROJ_DIR$\..\..\..\drivers\common\opentimers.c + + + $PROJ_DIR$\..\..\..\drivers\common\opentimers.h + + + + + inc + + $PROJ_DIR$\..\..\..\inc\opendefs.h + + + + kernel + + $PROJ_DIR$\..\..\..\kernel\openos\scheduler.c + + + $PROJ_DIR$\..\..\..\kernel\scheduler.h + + + + openstack + + 02a-MAClow + + $PROJ_DIR$\..\..\..\openstack\02a-MAClow\adaptive_sync.c + + + $PROJ_DIR$\..\..\..\openstack\02a-MAClow\adaptive_sync.h + + + $PROJ_DIR$\..\..\..\openstack\02a-MAClow\IEEE802154.c + + + $PROJ_DIR$\..\..\..\openstack\02a-MAClow\IEEE802154.h + + + $PROJ_DIR$\..\..\..\openstack\02a-MAClow\IEEE802154_security.c + + + $PROJ_DIR$\..\..\..\openstack\02a-MAClow\IEEE802154_security.h + + + $PROJ_DIR$\..\..\..\openstack\02a-MAClow\IEEE802154E.c + + + $PROJ_DIR$\..\..\..\openstack\02a-MAClow\IEEE802154E.h + + + $PROJ_DIR$\..\..\..\openstack\02a-MAClow\topology.c + + + $PROJ_DIR$\..\..\..\openstack\02a-MAClow\topology.h + + + + 02b-MAChigh + + $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\msf.c + + + $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\msf.h + + + $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\neighbors.c + + + $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\neighbors.h + + + $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\processIE.h + + + $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\schedule.c + + + $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\schedule.h + + + $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\sixtop.c + + + $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\sixtop.h + + + + cross-layers + + $PROJ_DIR$\..\..\..\openstack\cross-layers\idmanager.c + + + $PROJ_DIR$\..\..\..\openstack\cross-layers\idmanager.h + + + $PROJ_DIR$\..\..\..\openstack\cross-layers\openqueue.c + + + $PROJ_DIR$\..\..\..\openstack\cross-layers\openqueue.h + + + $PROJ_DIR$\..\..\..\openstack\cross-layers\openrandom.c + + + $PROJ_DIR$\..\..\..\openstack\cross-layers\openrandom.h + + + $PROJ_DIR$\..\..\..\openstack\cross-layers\packetfunctions.c + + + $PROJ_DIR$\..\..\..\openstack\cross-layers\packetfunctions.h + + + + $PROJ_DIR$\..\..\..\openstack\openstack.c + + + $PROJ_DIR$\..\..\..\openstack\openstack.h + + + diff --git a/projects/openmote-b/03oos_openwsn/03oos_openwsn.ewp b/projects/openmote-b/03oos_openwsn/03oos_openwsn.ewp index fe6a0586a6..17f51a93c7 100644 --- a/projects/openmote-b/03oos_openwsn/03oos_openwsn.ewp +++ b/projects/openmote-b/03oos_openwsn/03oos_openwsn.ewp @@ -11,7 +11,7 @@ General 3 - 28 + 31 1 1 + + + ICCARM 2 - 34 + 35 1 1 + @@ -705,7 +724,7 @@ ILINK 0 - 20 + 23 1 1 + + + + + + @@ -1056,7 +1099,7 @@ General 3 - 28 + 31 1 0 + + + ICCARM 2 - 34 + 35 1 0 + @@ -1715,7 +1775,7 @@ ILINK 0 - 20 + 23 1 0 + + + + + + @@ -2320,6 +2404,9 @@ $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\sensors.c + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\spi.c + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\startup_iar.c @@ -2363,6 +2450,30 @@ chips + + at86rf215 + + $PROJ_DIR$\..\..\..\bsp\chips\at86rf215\at86rf215.c + + + $PROJ_DIR$\..\..\..\bsp\chips\at86rf215\at86rf215.h + + + $PROJ_DIR$\..\..\..\bsp\chips\at86rf215\radio_at86rf215.c + + + $PROJ_DIR$\..\..\..\bsp\chips\at86rf215\radio_at86rf215.h + + + + cc2538rf + + $PROJ_DIR$\..\..\..\bsp\chips\cc2538rf\radio_cc2538rf.c + + + $PROJ_DIR$\..\..\..\bsp\chips\cc2538rf\radio_cc2538rf.h + + si70x @@ -2672,6 +2783,12 @@ 03a-IPHC + + $PROJ_DIR$\..\..\..\openstack\03a-IPHC\frag.c + + + $PROJ_DIR$\..\..\..\openstack\03a-IPHC\frag.h + $PROJ_DIR$\..\..\..\openstack\03a-IPHC\iphc.c diff --git a/projects/openmote-b/03oos_openwsn/03oos_openwsn.ewt b/projects/openmote-b/03oos_openwsn/03oos_openwsn.ewt new file mode 100644 index 0000000000..87c234dc2b --- /dev/null +++ b/projects/openmote-b/03oos_openwsn/03oos_openwsn.ewt @@ -0,0 +1,3098 @@ + + + 3 + + Debug + + ARM + + 1 + + C-STAT + 261 + + 261 + + 0 + + 1 + 600 + 1 + 2 + 0 + 1 + 100 + + + 1.5.5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + RuntimeChecking + 0 + + 2 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + Release + + ARM + + 0 + + C-STAT + 261 + + 261 + + 0 + + 1 + 600 + 1 + 2 + 0 + 1 + 100 + + + 1.5.5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + RuntimeChecking + 0 + + 2 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + application + + $PROJ_DIR$\..\..\common\03oos_openwsn\03oos_openwsn.c + + + $PROJ_DIR$\..\..\common\03oos_openwsn\03oos_openwsn.h + + + + bsp + + boards + + openmote-b + + headers + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_aes.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_ana_regs.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_cctest.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_flash_ctrl.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_gpio.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_gptimer.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_i2cm.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_i2cs.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_ints.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_ioc.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_memmap.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_nvic.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_pka.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_rfcore_ffsm.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_rfcore_sfr.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_rfcore_xreg.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_smwdthrosc.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_soc_adc.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_ssi.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_sys_ctrl.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_types.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_uart.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_udma.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_udmachctl.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\headers\hw_usb.h + + + + source + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\adc.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\adc.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\aes.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\aes.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\bl_commands.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\ccm.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\ccm.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\cpu.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\cpu.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\debug.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\debug.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\ecc_curveinfo.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\flash.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\flash.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\gpio.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\gpio.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\gptimer.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\gptimer.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\i2c_lib.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\i2c_lib.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\interrupt.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\interrupt.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\ioc.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\ioc.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\pka.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\pka.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\rom.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\sha256.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\sha256.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\sleepmode.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\sleepmode.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\ssi.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\ssi.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\sys_ctrl.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\sys_ctrl.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\systick.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\systick.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\uarthal.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\uarthal.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\udma.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\udma.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\watchdog.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\source\watchdog.h + + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\adc_sensor.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\adc_sensor.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\board.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\board_info.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\cc2538rf.h + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\cryptoengine.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\debugpins.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\eui64.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\i2c.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\leds.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\radio.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\sctimer.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\sensors.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\spi.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\startup_iar.c + + + $PROJ_DIR$\..\..\..\bsp\boards\openmote-b\uart.c + + + + $PROJ_DIR$\..\..\..\bsp\boards\board.h + + + $PROJ_DIR$\..\..\..\bsp\boards\cryptoengine.h + + + $PROJ_DIR$\..\..\..\bsp\boards\debugpins.h + + + $PROJ_DIR$\..\..\..\bsp\boards\eui64.h + + + $PROJ_DIR$\..\..\..\bsp\boards\i2c.h + + + $PROJ_DIR$\..\..\..\bsp\boards\leds.h + + + $PROJ_DIR$\..\..\..\bsp\boards\radio.h + + + $PROJ_DIR$\..\..\..\bsp\boards\sctimer.h + + + $PROJ_DIR$\..\..\..\bsp\boards\spi.h + + + $PROJ_DIR$\..\..\..\bsp\boards\toolchain_defs.h + + + $PROJ_DIR$\..\..\..\bsp\boards\uart.h + + + + chips + + at86rf215 + + $PROJ_DIR$\..\..\..\bsp\chips\at86rf215\at86rf215.c + + + $PROJ_DIR$\..\..\..\bsp\chips\at86rf215\at86rf215.h + + + $PROJ_DIR$\..\..\..\bsp\chips\at86rf215\radio_at86rf215.c + + + $PROJ_DIR$\..\..\..\bsp\chips\at86rf215\radio_at86rf215.h + + + + cc2538rf + + $PROJ_DIR$\..\..\..\bsp\chips\cc2538rf\radio_cc2538rf.c + + + $PROJ_DIR$\..\..\..\bsp\chips\cc2538rf\radio_cc2538rf.h + + + + si70x + + $PROJ_DIR$\..\..\..\bsp\chips\si70x\si70x.c + + + $PROJ_DIR$\..\..\..\bsp\chips\si70x\si70x.h + + + + + + drivers + + common + + $PROJ_DIR$\..\..\..\drivers\common\openhdlc.c + + + $PROJ_DIR$\..\..\..\drivers\common\openhdlc.h + + + $PROJ_DIR$\..\..\..\drivers\common\opensensors.c + + + $PROJ_DIR$\..\..\..\drivers\common\opensensors.h + + + $PROJ_DIR$\..\..\..\drivers\common\openserial.c + + + $PROJ_DIR$\..\..\..\drivers\common\openserial.h + + + $PROJ_DIR$\..\..\..\drivers\common\opentimers.c + + + $PROJ_DIR$\..\..\..\drivers\common\opentimers.h + + + + + inc + + $PROJ_DIR$\..\..\..\inc\opendefs.h + + + + kernel + + $PROJ_DIR$\..\..\..\kernel\openos\scheduler.c + + + $PROJ_DIR$\..\..\..\kernel\scheduler.h + + + + openapps + + c6t + + $PROJ_DIR$\..\..\..\openapps\c6t\c6t.c + + + $PROJ_DIR$\..\..\..\openapps\c6t\c6t.h + + + + cexample + + $PROJ_DIR$\..\..\..\openapps\cexample\cexample.c + + + $PROJ_DIR$\..\..\..\openapps\cexample\cexample.h + + + + cinfo + + $PROJ_DIR$\..\..\..\openapps\cinfo\cinfo.c + + + $PROJ_DIR$\..\..\..\openapps\cinfo\cinfo.h + + + + cjoin + + $PROJ_DIR$\..\..\..\openapps\cjoin\cjoin.c + + + $PROJ_DIR$\..\..\..\openapps\cjoin\cjoin.h + + + $PROJ_DIR$\..\..\..\openapps\cjoin\cojp_cbor.c + + + $PROJ_DIR$\..\..\..\openapps\cjoin\cojp_cbor.h + + + + cleds + + $PROJ_DIR$\..\..\..\openapps\cleds\cleds.c + + + $PROJ_DIR$\..\..\..\openapps\cleds\cleds.h + + + + csensors + + $PROJ_DIR$\..\..\..\openapps\csensors\csensors.c + + + $PROJ_DIR$\..\..\..\openapps\csensors\csensors.h + + + + cstorm + + $PROJ_DIR$\..\..\..\openapps\cstorm\cstorm.c + + + $PROJ_DIR$\..\..\..\openapps\cstorm\cstorm.h + + + + cwellknow + + $PROJ_DIR$\..\..\..\openapps\cwellknown\cwellknown.c + + + $PROJ_DIR$\..\..\..\openapps\cwellknown\cwellknown.h + + + + opencoap + + $PROJ_DIR$\..\..\..\openapps\opencoap\cborencoder.c + + + $PROJ_DIR$\..\..\..\openapps\opencoap\cborencoder.h + + + $PROJ_DIR$\..\..\..\openapps\opencoap\hkdf.c + + + $PROJ_DIR$\..\..\..\openapps\opencoap\hmac.c + + + $PROJ_DIR$\..\..\..\openapps\opencoap\opencoap.c + + + $PROJ_DIR$\..\..\..\openapps\opencoap\opencoap.h + + + $PROJ_DIR$\..\..\..\openapps\opencoap\openoscoap.c + + + $PROJ_DIR$\..\..\..\openapps\opencoap\openoscoap.h + + + $PROJ_DIR$\..\..\..\openapps\opencoap\sha-private.h + + + $PROJ_DIR$\..\..\..\openapps\opencoap\sha.h + + + $PROJ_DIR$\..\..\..\openapps\opencoap\sha224-256.c + + + $PROJ_DIR$\..\..\..\openapps\opencoap\usha.c + + + + rrt + + $PROJ_DIR$\..\..\..\openapps\rrt\rrt.c + + + $PROJ_DIR$\..\..\..\openapps\rrt\rrt.h + + + + uecho + + $PROJ_DIR$\..\..\..\openapps\uecho\uecho.c + + + $PROJ_DIR$\..\..\..\openapps\uecho\uecho.h + + + + uexpiration + + $PROJ_DIR$\..\..\..\openapps\uexpiration\uexpiration.c + + + $PROJ_DIR$\..\..\..\openapps\uexpiration\uexpiration.h + + + + uexpiration_monitor + + $PROJ_DIR$\..\..\..\openapps\uexpiration_monitor\uexpiration_monitor.c + + + $PROJ_DIR$\..\..\..\openapps\uexpiration_monitor\uexpiration_monitor.h + + + + uinject + + $PROJ_DIR$\..\..\..\openapps\uinject\uinject.c + + + $PROJ_DIR$\..\..\..\openapps\uinject\uinject.h + + + + userialbridge + + $PROJ_DIR$\..\..\..\openapps\userialbridge\userialbridge.c + + + $PROJ_DIR$\..\..\..\openapps\userialbridge\userialbridge.h + + + + $PROJ_DIR$\..\..\..\openapps\openapps.c + + + $PROJ_DIR$\..\..\..\openapps\openapps.h + + + + openstack + + 02a-MAClow + + $PROJ_DIR$\..\..\..\openstack\02a-MAClow\adaptive_sync.c + + + $PROJ_DIR$\..\..\..\openstack\02a-MAClow\adaptive_sync.h + + + $PROJ_DIR$\..\..\..\openstack\02a-MAClow\IEEE802154.c + + + $PROJ_DIR$\..\..\..\openstack\02a-MAClow\IEEE802154.h + + + $PROJ_DIR$\..\..\..\openstack\02a-MAClow\IEEE802154_security.c + + + $PROJ_DIR$\..\..\..\openstack\02a-MAClow\IEEE802154_security.h + + + $PROJ_DIR$\..\..\..\openstack\02a-MAClow\ieee802154_security_driver.h + + + $PROJ_DIR$\..\..\..\openstack\02a-MAClow\IEEE802154E.c + + + $PROJ_DIR$\..\..\..\openstack\02a-MAClow\IEEE802154E.h + + + $PROJ_DIR$\..\..\..\openstack\02a-MAClow\topology.c + + + $PROJ_DIR$\..\..\..\openstack\02a-MAClow\topology.h + + + + 02b-MAChigh + + $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\msf.c + + + $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\msf.h + + + $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\neighbors.c + + + $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\neighbors.h + + + $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\schedule.c + + + $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\schedule.h + + + $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\sixtop.c + + + $PROJ_DIR$\..\..\..\openstack\02b-MAChigh\sixtop.h + + + + 03a-IPHC + + $PROJ_DIR$\..\..\..\openstack\03a-IPHC\frag.c + + + $PROJ_DIR$\..\..\..\openstack\03a-IPHC\frag.h + + + $PROJ_DIR$\..\..\..\openstack\03a-IPHC\iphc.c + + + $PROJ_DIR$\..\..\..\openstack\03a-IPHC\iphc.h + + + $PROJ_DIR$\..\..\..\openstack\03a-IPHC\openbridge.c + + + $PROJ_DIR$\..\..\..\openstack\03a-IPHC\openbridge.h + + + + 03b-IPv6 + + $PROJ_DIR$\..\..\..\openstack\03b-IPv6\forwarding.c + + + $PROJ_DIR$\..\..\..\openstack\03b-IPv6\forwarding.h + + + $PROJ_DIR$\..\..\..\openstack\03b-IPv6\icmpv6.c + + + $PROJ_DIR$\..\..\..\openstack\03b-IPv6\icmpv6.h + + + $PROJ_DIR$\..\..\..\openstack\03b-IPv6\icmpv6echo.c + + + $PROJ_DIR$\..\..\..\openstack\03b-IPv6\icmpv6echo.h + + + $PROJ_DIR$\..\..\..\openstack\03b-IPv6\icmpv6rpl.c + + + $PROJ_DIR$\..\..\..\openstack\03b-IPv6\icmpv6rpl.h + + + + 04-TRAN + + $PROJ_DIR$\..\..\..\openstack\04-TRAN\openudp.c + + + $PROJ_DIR$\..\..\..\openstack\04-TRAN\openudp.h + + + + cross-layers + + $PROJ_DIR$\..\..\..\openstack\cross-layers\idmanager.c + + + $PROJ_DIR$\..\..\..\openstack\cross-layers\idmanager.h + + + $PROJ_DIR$\..\..\..\openstack\cross-layers\openqueue.c + + + $PROJ_DIR$\..\..\..\openstack\cross-layers\openqueue.h + + + $PROJ_DIR$\..\..\..\openstack\cross-layers\openrandom.c + + + $PROJ_DIR$\..\..\..\openstack\cross-layers\openrandom.h + + + $PROJ_DIR$\..\..\..\openstack\cross-layers\packetfunctions.c + + + $PROJ_DIR$\..\..\..\openstack\cross-layers\packetfunctions.h + + + + $PROJ_DIR$\..\..\..\openstack\openstack.c + + + $PROJ_DIR$\..\..\..\openstack\openstack.h + + + diff --git a/projects/openmote-b/openmote_b.eww b/projects/openmote-b/openmote_b.eww index 62dc3f76a7..3ddf5a6714 100644 --- a/projects/openmote-b/openmote_b.eww +++ b/projects/openmote-b/openmote_b.eww @@ -1,46 +1,50 @@ - - + - - $WS_DIR$\01bsp_sctimer\01bsp_sctimer.ewp - - - $WS_DIR$\02drv_opentimers\02drv_opentimers.ewp - - - $WS_DIR$\03oos_macpong\03oos_macpong.ewp - - - $WS_DIR$\03oos_openwsn\03oos_openwsn.ewp - - - $WS_DIR$\03oos_sniffer\03oos_sniffer.ewp - - - - all_debug - - 01bsp_sctimer - Debug - - - 02drv_opentimers - Debug - - - 03oos_macpong - Debug - - - 03oos_openwsn - Debug - - - 03oos_sniffer - Debug - - - + + $WS_DIR$\01bsp_radio_jammer\01bsp_radio_jammer.ewp + + + $WS_DIR$\01bsp_sctimer\01bsp_sctimer.ewp + + + $WS_DIR$\02drv_opentimers\02drv_opentimers.ewp + + + $WS_DIR$\03oos_macpong\03oos_macpong.ewp + + + $WS_DIR$\03oos_openwsn\03oos_openwsn.ewp + + + $WS_DIR$\03oos_sniffer\03oos_sniffer.ewp + + + + all_debug + + 01bsp_radio_jammer + Debug + + + 01bsp_sctimer + Debug + + + 02drv_opentimers + Debug + + + 03oos_macpong + Debug + + + 03oos_openwsn + Debug + + + 03oos_sniffer + Debug + + + - -