42 #include "contiki-net.h" 43 #include "sys/clock.h" 52 #include "lib/random.h" 53 #include "lib/sensors.h" 58 #include <ti/devices/DeviceFamily.h> 59 #include DeviceFamily_constructPath(driverlib/driverlib_release.h) 60 #include DeviceFamily_constructPath(driverlib/chipinfo.h) 61 #include DeviceFamily_constructPath(driverlib/vims.h) 63 #include <ti/drivers/dpl/HwiP.h> 64 #include <ti/drivers/I2C.h> 65 #include <ti/drivers/NVS.h> 66 #include <ti/drivers/PIN.h> 67 #include <ti/drivers/pin/PINCC26XX.h> 68 #include <ti/drivers/Power.h> 69 #include <ti/drivers/SPI.h> 70 #include <ti/drivers/TRNG.h> 71 #include <ti/drivers/UART.h> 73 #include "board-peripherals.h" 86 #define LOG_MODULE "CC13xx/CC26xx" 87 #define LOG_LEVEL LOG_LEVEL_MAIN 93 extern void Board_initHook(
void);
104 uint32_t pivot = 800;
105 uint32_t pivot_half = pivot / 2;
107 for(k = 0; k < pivot; ++k) {
108 j = (k > pivot_half) ? pivot - k : k;
110 PINCC26XX_setOutputValue(pin, 1);
111 for(i = 0; i < j; ++i) {
112 __asm__ __volatile__ (
"nop");
114 PINCC26XX_setOutputValue(pin, 0);
115 for(i = 0; i < pivot_half - j; ++i) {
116 __asm__ __volatile__ (
"nop");
130 memset(ext_addr, 0x0,
sizeof(ext_addr));
135 short_addr = (((uint16_t)ext_addr[7] << 0) |
136 ((uint16_t)ext_addr[6] << 8));
138 NETSTACK_RADIO.set_value(RADIO_PARAM_PAN_ID, IEEE802154_PANID);
139 NETSTACK_RADIO.set_value(RADIO_PARAM_16BIT_ADDR, short_addr);
140 NETSTACK_RADIO.set_object(RADIO_PARAM_64BIT_ADDR, ext_addr,
sizeof(ext_addr));
146 DRIVERLIB_ASSERT_CURR_RELEASE();
149 VIMSModeSet(VIMS_BASE, VIMS_MODE_ENABLED);
151 VIMSConfigure(VIMS_BASE,
true,
true);
156 if(PIN_init(BoardGpioInitTable) != PIN_SUCCESS) {
171 fade(Board_PIN_LED0);
174 #if TI_UART_CONF_ENABLE 177 #if TI_I2C_CONF_ENABLE 180 #if TI_SPI_CONF_ENABLE 183 #if TI_NVS_CONF_ENABLE 189 fade(Board_PIN_LED1);
200 #if TI_UART_CONF_UART0_ENABLE 209 unsigned short seed = 0;
210 if(!
trng_rand((uint8_t *)&seed,
sizeof(seed), TRNG_WAIT_FOREVER)) {
221 fade(Board_PIN_LED0);
227 #if RF_CONF_BLE_BEACON_ENABLE 236 LOG_DBG(
"With DriverLib v%u.%u\n", DRIVERLIB_RELEASE_GROUP,
237 DRIVERLIB_RELEASE_BUILD);
238 LOG_DBG(
"IEEE 802.15.4: %s, Sub-1 GHz: %s, BLE: %s\n",
239 ChipInfo_SupportsIEEE_802_15_4() ?
"Yes" :
"No",
240 ChipInfo_SupportsPROPRIETARY() ?
"Yes" :
"No",
241 ChipInfo_SupportsBLE() ?
"Yes" :
"No");
243 #if (RF_MODE == RF_MODE_SUB_1_GHZ) 244 LOG_INFO(
"Operating frequency on Sub-1 GHz\n");
245 #elif (RF_MODE == RF_MODE_2_4_GHZ) 246 LOG_INFO(
"Operating frequency on 2.4 GHz\n");
249 NETSTACK_RADIO.get_value(RADIO_PARAM_CHANNEL, &chan);
250 LOG_INFO(
"RF: Channel %d", chan);
252 if(NETSTACK_RADIO.get_value(RADIO_PARAM_PAN_ID, &pan) == RADIO_RESULT_OK) {
253 LOG_INFO(
", PANID 0x%04X", pan);
257 LOG_INFO(
"Node ID: %d\n", node_id);
259 #if BOARD_CONF_SENSORS_ENABLE 263 fade(Board_PIN_LED1);
Header file for the CC13xx/CC26xx BLE Beacon Daemon.
void platform_init_stage_two()
Stage 2 of platform driver initialisation.
void platform_idle()
The platform's idle/sleep function.
Header file of UART driver for CC13xx/CC26xx.
void leds_init(void)
Initialise the LED HAL.
int_fast32_t uart0_set_callback(uart0_input_fxn_t input_cb)
Set the callback function for when bytes are received on UART0.
Node-id (simple 16-bit identifiers) handling.
int radio_value_t
Each radio has a set of parameters that designate the current configuration and state of the radio...
void gpio_hal_init()
Initialise the GPIO HAL.
linkaddr_t linkaddr_node_addr
The link-layer address of the node.
void ieee_addr_cpy_to(uint8_t *dst, uint8_t len)
Copy the node's IEEE address to a destination memory area.
int serial_line_input_byte(unsigned char c)
Get one byte of input from the serial driver.
Header file for the CC13xx/CC26xx IEEE address driver.
void uart0_init(unsigned long ubr)
Initalize the RS232 port.
Header file for the real-time timer module.
802.15.4 frame creation and parsing functions
rf_ble_beacond_result_t rf_ble_beacond_init(void)
Initialize the BLE advertisement/beacon daemon.
void platform_init_stage_three()
Final stage of platform driver initialisation.
bool trng_rand(uint8_t *entropy_buf, size_t entropy_len, uint32_t timeout_us)
Generates a stream of entropy from which you can create a true random number from.
void random_init(unsigned short seed)
Seed the cc2538 random number generator.
Header file of common CC13xx/CC26xx RF functionality.
Generic serial I/O process header filer.
Header file for the GPIO HAL.
Header file for the logging system
Header file for the LED HAL.
void platform_init_stage_one(void)
Basic (Stage 1) platform driver initialisation.
Header file of True Random Number Generator for CC13xx/CC26xx.
void process_start(struct process *p, process_data_t data)
Start a process.