Removed external bias as default from RF settings, and doxygen alignment

This commit is contained in:
Edvard Pettersen 2018-07-20 17:20:25 +02:00
parent dfc6ee611a
commit 824296cbc0
22 changed files with 334 additions and 231 deletions

View File

@ -54,6 +54,20 @@
#define GPIO_HAL_CONF_ARCH_HDR_PATH "dev/gpio-hal-arch.h"
/** @} */
/*---------------------------------------------------------------------------*/
/**
* \name Watchdog Configuration.
*
* @{
*/
#ifndef WATCHDOG_CONF_DISABLE
#define WATCHDOG_CONF_DISABLE 0
#endif
#ifndef WATCHDOG_CONF_TIMER_TOP
#define WATCHDOG_CONF_TIMER_TOP 0xFFFFF
#endif
/** @} */
/*---------------------------------------------------------------------------*/
/**
* \name RF configuration.
*

View File

@ -49,6 +49,7 @@
#endif
/*---------------------------------------------------------------------------*/
#include <stddef.h>
#include <stdint.h>
/*---------------------------------------------------------------------------*/
#define RTIMER_ARCH_SECOND 65536
/*---------------------------------------------------------------------------*/
@ -115,9 +116,9 @@
/*---------------------------------------------------------------------------*/
/* Path to CMSIS header */
#if (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X0_CC26X0)
# define CMSIS_CONF_HEADER_PATH "cc13x0-cc26x0-cm3.h"
# define CMSIS_CONF_HEADER_PATH "cc13x0-cc26x0-cm3.h"
#elif (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X2_CC26X2)
# define CMSIS_CONF_HEADER_PATH "cc13x2-cc26x2-cm4.h"
# define CMSIS_CONF_HEADER_PATH "cc13x2-cc26x2-cm4.h"
#endif
/*---------------------------------------------------------------------------*/
/* Path to headers with implementation of mutexes and memory barriers */

View File

@ -29,14 +29,20 @@
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* \addtogroup cc13xx-cc26xx-prng
* \addtogroup cc13xx-cc26xx-cpu
* @{
*
* \defgroup cc13xx-cc26xx-prng Pseudo Random Number Generator (PRNG) for CC13xx/CC26xx.
* @{
*
* Implementation based on Bob Jenkins' small noncryptographic PRNG.
* http://burtleburtle.net/bob/rand/smallprng.html
* - http://burtleburtle.net/bob/rand/smallprng.html
*
* This file overrides os/lib/random.c. Note that the file name must
* match the original file for the override to work.
*
* \file
* This file overrides os/lib/random.c.
* Implementation of Pseudo Random Number Generator for CC13xx/CC26xx.
* \author
* Edvard Pettersen <e.pettersen@ti.com>
*/
@ -75,8 +81,8 @@ random_rand(void)
}
/*---------------------------------------------------------------------------*/
/**
* \brief Function required by the API
* \param seed Ignored.
* \brief Initialize the PRNG.
* \param seed Seed for the PRNG.
*/
void
random_init(unsigned short seed)
@ -91,5 +97,6 @@ random_init(unsigned short seed)
}
/*---------------------------------------------------------------------------*/
/**
* @}
* @}
*/

View File

@ -10,6 +10,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
@ -32,38 +33,42 @@
* @{
*
* \file
* Implementation of the arch-specific rtimer functions for the CC13xx/CC26xx
* Implementation of the rtimer driver for CC13xx/CC26xx.
* \author
* Edvard Pettersen <e.pettersen@ti.com>
*/
/*---------------------------------------------------------------------------*/
#include "contiki.h"
/*---------------------------------------------------------------------------*/
#include <ti/devices/DeviceFamily.h>
#include DeviceFamily_constructPath(driverlib/aon_event.h)
#include DeviceFamily_constructPath(driverlib/aon_rtc.h)
#include DeviceFamily_constructPath(driverlib/interrupt.h)
#include <ti/drivers/dpl/ClockP.h>
#include <ti/drivers/dpl/HwiP.h>
/*---------------------------------------------------------------------------*/
#include "contiki.h"
/*---------------------------------------------------------------------------*/
#include <stddef.h>
#include <stdint.h>
/*---------------------------------------------------------------------------*/
#define HWIP_RTC_CH AON_RTC_CH0
#define RTIMER_RTC_CH AON_RTC_CH1
/*---------------------------------------------------------------------------*/
static ClockP_Struct gClk;
static ClockP_Handle hClk;
/*---------------------------------------------------------------------------*/
typedef void (*IsrFxn)(void);
typedef void (*HwiDispatchFxn)(void);
typedef void (*isr_fxn_t)(void);
typedef void (*hwi_dispatch_fxn_t)(void);
static volatile HwiDispatchFxn hwiDispatch = NULL;
static hwi_dispatch_fxn_t hwi_dispatch_fxn;
/*---------------------------------------------------------------------------*/
/**
* \brief TODO
* \brief Stub function used when creating the dummy clock object.
*/
static void rtimer_clock_stub(uintptr_t arg) { /* do nothing */ }
static void rtimer_clock_stub(uintptr_t unused) { (void)unused; /* do nothing */ }
/*---------------------------------------------------------------------------*/
/**
* \brief TODO
* \brief The Man-in-the-Middle ISR hook for the HWI dispatch ISR. This
* will be the ISR dispatched when INT_AON_RTC_COMB is triggered,
* and will either dispatch the interrupt to the rtimer driver or
* the HWI driver, depening on which event triggered the interrupt.
*/
static void
rtimer_isr_hook(void)
@ -75,9 +80,13 @@ rtimer_isr_hook(void)
rtimer_run_next();
}
if (hwiDispatch && AONRTCEventGet(HWIP_RTC_CH))
/*
* HWI Dispatch clears the interrupt. If HWI wasn't triggered, clear
* the interrupt manually.
*/
if (AONRTCEventGet(HWIP_RTC_CH))
{
hwiDispatch();
hwi_dispatch_fxn();
}
else
{
@ -91,50 +100,73 @@ rtimer_isr_hook(void)
void
rtimer_arch_init(void)
{
const bool intkey = IntMasterDisable();
uintptr_t key;
ClockP_Struct clk_object;
ClockP_Params clk_params;
volatile isr_fxn_t *ramvec_table;
// Create dummy clock to trigger init of the RAM vector table
ClockP_Params clkParams;
ClockP_Params_init(&clkParams);
hClk = ClockP_construct(&gClk, rtimer_clock_stub, 0, &clkParams);
key = HwiP_disable();
// Try to access the RAM vector table
volatile IsrFxn * const pfnRAMVectors = (volatile IsrFxn *)(HWREG(NVIC_VTABLE));
if (!pfnRAMVectors)
/*
* Create a dummy clock to guarantee the RAM vector table is initialized.
*
* Creating a dummy clock will trigger initialization of TimerP, which
* subsequently initializes the driverlib/interrupt.h module. It is the
* interrupt module that initializes the RAM vector table.
*
* It is safe to destruct the Clock object immediately afterwards.
*/
ClockP_Params_init(&clk_params);
ClockP_construct(&clk_object, rtimer_clock_stub, 0, &clk_params);
ClockP_destruct(&clk_object);
/* Try to access the RAM vector table. */
ramvec_table = (isr_fxn_t*)HWREG(NVIC_VTABLE);
if (!ramvec_table)
{
/*
* Unable to find the RAM vector table is a serious fault.
* Spin-lock forever.
*/
for (;;) { /* hang */ }
}
// The HWI Dispatch ISR should be located at int num INT_AON_RTC_COMB.
// Fetch and store it.
hwiDispatch = (HwiDispatchFxn)pfnRAMVectors[INT_AON_RTC_COMB];
if (!hwiDispatch)
/*
* The HWI Dispatch ISR is located at interrupt number INT_AON_RTC_COMB
* in the RAM vector table. Fetch and store it.
*/
hwi_dispatch_fxn = (hwi_dispatch_fxn_t)ramvec_table[INT_AON_RTC_COMB];
if (!hwi_dispatch_fxn)
{
/*
* Unable to find the HWI dispatch ISR in the RAM vector table is
* a serious fault. Spin-lock forever.
*/
for (;;) { /* hang */ }
}
// Override the INT_AON_RTC_COMB int num with own ISR hook
/*
* Override the INT_AON_RTC_COMB interrupt number with our own ISR hook,
* which will act as a man-in-the-middle ISR for the HWI dispatch.
*/
IntRegister(INT_AON_RTC_COMB, rtimer_isr_hook);
AONEventMcuWakeUpSet(AON_EVENT_MCU_WU1, AON_EVENT_RTC_CH1);
AONRTCCombinedEventConfig(HWIP_RTC_CH | RTIMER_RTC_CH);
if (!intkey)
{
IntMasterEnable();
}
HwiP_restore(key);
}
/*---------------------------------------------------------------------------*/
/**
* \brief Schedules an rtimer task to be triggered at time t
* \param t The time when the task will need executed.
* \brief Schedules an rtimer task to be triggered at time \p t.
* \param t The time when the task will need executed.
*
* \e t is an absolute time, in other words the task will be executed AT
* time \e t, not IN \e t rtimer ticks.
* \p t is an absolute time, in other words the task will be
* executed AT time \p t, not IN \p t rtimer ticks.
*
* This function schedules a one-shot event with the AON RTC.
* This function schedules a one-shot event with the AON RTC.
*
* This functions converts \e to a value suitable for the AON RTC.
* This functions converts \p t to a value suitable for the AON RTC.
*/
void
rtimer_arch_schedule(rtimer_clock_t t)
@ -145,17 +177,16 @@ rtimer_arch_schedule(rtimer_clock_t t)
}
/*---------------------------------------------------------------------------*/
/**
* \brief Returns the current real-time clock time
* \return The current rtimer time in ticks
*
* The value is read from the AON RTC counter and converted to a number of
* rtimer ticks
* \brief Returns the current real-time clock time.
* \return The current rtimer time in ticks.
*
* The value is read from the AON RTC counter and converted to a
* number of rtimer ticks.
*/
rtimer_clock_t
rtimer_arch_now()
{
return ((rtimer_clock_t)AONRTCCurrentCompareValueGet());
return (rtimer_clock_t)AONRTCCurrentCompareValueGet();
}
/*---------------------------------------------------------------------------*/
/** @} */

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Texas Instruments Incorporated - http://www.ti.com/
* Copyright (c) 2018, Texas Instruments Incorporated - http://www.ti.com/
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -10,6 +10,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
@ -27,19 +28,22 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
/**
* \addtogroup cc26xx-clocks
* \addtogroup cc13xx-cc26xx-cpu
* @{
*
* \defgroup cc26xx-rtimer CC13xx/CC26xx rtimer
* \defgroup cc13xx-cc26xx-rtimer The CC13xx/CC26xx rtimer
*
* Implementation of the rtimer module for the CC13xx/CC26xx
* Implementation of the rtimer module for CC13xx/CC26xx. This header
* is included by os/sys/rtimer.h.
*
* RTIMER_ARCH_SECOND is defined in cc13xx-cc26xx-def.h.
* @{
*/
/**
*
* \file
* Header file for the CC13xx/CC26xx rtimer driver
* Header file of the rtimer driver for CC13xx/CC26xx.
* \author
* Edvard Pettersen <e.pettersen@ti.com>
*/
/*---------------------------------------------------------------------------*/
#ifndef RTIMER_ARCH_H_
@ -47,22 +51,32 @@
/*---------------------------------------------------------------------------*/
#include "contiki.h"
/*---------------------------------------------------------------------------*/
extern rtimer_clock_t rtimer_arch_now(void);
/* HW oscillator frequency is 32 kHz, not 64 kHz and RTIMER_NOW() never returns
* an odd value; so US_TO_RTIMERTICKS always rounds to the nearest even number.
rtimer_clock_t rtimer_arch_now(void);
/*---------------------------------------------------------------------------*/
/*
* HW oscillator frequency is 32 kHz, not 64 kHz. And, RTIMER_NOW() never
* returns an odd value; US_TO_RTIMERTICKS always rounds to the nearest
* even number.
*/
#define US_TO_RTIMERTICKS(US) (2 * ((US) >= 0 ? \
(((int32_t)(US) * (RTIMER_ARCH_SECOND / 2) + 500000) / 1000000L) : \
((int32_t)(US) * (RTIMER_ARCH_SECOND / 2) - 500000) / 1000000L))
#define US_TO_RTIMERTICKS(us) (2 * ( \
((us) >= 0) \
? (((int32_t)(us) * (RTIMER_ARCH_SECOND / 2) + 500000) / 1000000L) \
: (((int32_t)(us) * (RTIMER_ARCH_SECOND / 2) - 500000) / 1000000L) \
))
#define RTIMERTICKS_TO_US(T) ((T) >= 0 ? \
(((int32_t)(T) * 1000000L + ((RTIMER_ARCH_SECOND) / 2)) / (RTIMER_ARCH_SECOND)) : \
((int32_t)(T) * 1000000L - ((RTIMER_ARCH_SECOND) / 2)) / (RTIMER_ARCH_SECOND))
#define RTIMERTICKS_TO_US(rt) ( \
((rt) >= 0) \
? (((int32_t)(rt) * 1000000L + (RTIMER_ARCH_SECOND / 2)) / RTIMER_ARCH_SECOND) \
: (((int32_t)(rt) * 1000000L - (RTIMER_ARCH_SECOND / 2)) / RTIMER_ARCH_SECOND) \
)
/* A 64-bit version because the 32-bit one cannot handle T >= 4295 ticks.
Intended only for positive values of T. */
#define RTIMERTICKS_TO_US_64(T) ((uint32_t)(((uint64_t)(T) * 1000000 + ((RTIMER_ARCH_SECOND) / 2)) / (RTIMER_ARCH_SECOND)))
/*
* A 64-bit version because the 32-bit one cannot handle T >= 4295 ticks.
* Intended only for positive values of T.
*/
#define RTIMERTICKS_TO_US_64(rt) ((uint32_t)( \
((uint64_t)(rt) * 1000000 + (RTIMER_ARCH_SECOND / 2)) / RTIMER_ARCH_SECOND \
))
/*---------------------------------------------------------------------------*/
#endif /* RTIMER_ARCH_H_ */
/*---------------------------------------------------------------------------*/

View File

@ -28,23 +28,27 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
/**
* \addtogroup cc26xx-char-io
* \addtogroup cc13xx-cc26xx-cpu
* @{
*
* \defgroup cc13xx-cc26xx-slip-arch SLIP for CC13xx/CC26xx.
* @{
*
* \file
* Arch-specific SLIP functions for the CC13xx/CC26xx
* Implementation of SLIP driver for CC13xx/CC26xx.
* \author
* Edvard Pettersen <e.pettersen@ti.com>
*/
/*---------------------------------------------------------------------------*/
#include <contiki.h>
#include <dev/slip.h>
#include "contiki.h"
#include "dev/slip.h"
/*---------------------------------------------------------------------------*/
#include "dev/uart0-arch.h"
#include "uart0-arch.h"
/*---------------------------------------------------------------------------*/
/**
* \brief Write a byte over SLIP
* \param c the byte
* \brief Write a single byte over SLIP.
* \param c The byte to write.
*/
void
slip_arch_writeb(unsigned char c)
@ -53,16 +57,20 @@ slip_arch_writeb(unsigned char c)
}
/*---------------------------------------------------------------------------*/
/**
* \brief Initialise the arch-specific SLIP driver
* \brief Initialize the SLIP driver.
*/
void
slip_arch_init()
slip_arch_init(void)
{
// Enable an input handler. In doing so, the driver will make sure that UART
// RX stays operational during deep sleep
/*
* Set an input handler. In doing so, the driver will make sure that UART
* RX stays operational during deep sleep.
*/
uart0_init();
uart0_set_callback(slip_input_byte);
}
/*---------------------------------------------------------------------------*/
/** @} */
/**
* @}
* @}
*/

View File

@ -46,8 +46,8 @@
#include <ti/drivers/cryptoutils/cryptokey/CryptoKeyPlaintext.h>
/*---------------------------------------------------------------------------*/
/*
* Very dirty workaround because of the pre-compiled TI drivers library for
* CC13xx/CC26x0 is missing the CryptoKey object file.
* Very dirty workaround because the pre-compiled TI drivers library for
* CC13x0/CC26x0 is missing the CryptoKey object file.
*/
#include <ti/devices/DeviceFamily.h>
#if (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X0_CC26X0)
@ -57,18 +57,12 @@
#include <stdint.h>
#include <stdbool.h>
/*---------------------------------------------------------------------------*/
void
trng_init(void)
{
TRNG_init();
}
/*---------------------------------------------------------------------------*/
bool
trng_rand(uint8_t *entropy_buf, size_t entropy_len, uint32_t timeout_us)
{
TRNG_Params trng_params;
TRNG_Handle trng_handle;
CryptoKey entropy_key;
TRNG_Params trng_params;
TRNG_Handle trng_handle;
CryptoKey entropy_key;
int_fast16_t result;
TRNG_Params_init(&trng_params);
@ -78,7 +72,7 @@ trng_rand(uint8_t *entropy_buf, size_t entropy_len, uint32_t timeout_us)
}
trng_handle = TRNG_open(0, &trng_params);
if (!trng_handle) {
if(!trng_handle) {
return false;
}

View File

@ -52,13 +52,9 @@
#define TRNG_WAIT_FOREVER (~(uint32_t)0)
/*---------------------------------------------------------------------------*/
/**
* \breif Initialize the TRNG module.
*/
void trng_init(void);
/**
* \brief Generates a stream of true random numbers. This is
* a blocking function call with a specified timeout.
* \brief Generates a stream of entropy from which you can create
* a true random number from. This is a blocking function
* call with a specified timeout.
* \param entropy_buf Buffer to store a stream of entropy.
* \param entropy_len Length of the entropy buffer.
* \param timeout_us How long to wait until timing out the operation. A

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Texas Instruments Incorporated - http://www.ti.com/
* Copyright (c) 2018, Texas Instruments Incorporated - http://www.ti.com/
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -10,6 +10,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
@ -27,99 +28,102 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
/**
* \addtogroup cc26xx-uart
* \addtogroup cc13xx-cc26xx-uart
* @{
*
* \file
* Implementation of the CC13xx/CC26xx UART driver.
* Implementation of UART driver for CC13xx/CC26xx.
* \author
* Edvard Pettersen <e.pettersen@ti.com>
*/
/*---------------------------------------------------------------------------*/
#include "contiki.h"
/*---------------------------------------------------------------------------*/
#include "uart0-arch.h"
/*---------------------------------------------------------------------------*/
#include <Board.h>
#include <ti/drivers/UART.h>
/*---------------------------------------------------------------------------*/
#include <contiki.h>
/*---------------------------------------------------------------------------*/
#include <stdint.h>
#include <stdbool.h>
/*---------------------------------------------------------------------------*/
#include "uart0-arch.h"
/*---------------------------------------------------------------------------*/
static UART_Handle gh_uart;
static UART_Handle uart_handle;
static volatile uart0_input_cb curr_input_cb;
static volatile uart0_input_fxn_t curr_input_cb;
static unsigned char char_buf;
static bool is_init;
static bool initialized;
/*---------------------------------------------------------------------------*/
static void
uart0_cb(UART_Handle handle, void *buf, size_t count)
{
if (!curr_input_cb) { return; }
/* Simply return if the current callback is NULL. */
if(!curr_input_cb) { return; }
/*
* Save the current callback function, as this might be overwritten after
* the callback is called.
* Save the current callback function locally, as it might be overwritten
* after calling the callback.
*/
const uart0_input_cb currCb = curr_input_cb;
/* Call the callback. Note this might reset curr_input_cb */
currCb(char_buf);
const uart0_input_fxn_t curr_cb = curr_input_cb;
curr_cb(char_buf);
/*
* If curr_input_cb didn't change after the call, do another read.
* Else, the uart0_set_callback was called with a different callback pointer
* and triggered an another read.
*/
if (currCb == curr_input_cb) {
UART_read(gh_uart, &char_buf, 1);
if(curr_cb == curr_input_cb) {
UART_read(uart_handle, &char_buf, 1);
}
}
/*---------------------------------------------------------------------------*/
void
uart0_init(void)
{
if (is_init) { return; }
is_init = true;
if(initialized) { return; }
UART_Params params;
UART_Params_init(&params);
UART_Params uart_params;
UART_Params_init(&uart_params);
params.baudRate = TI_UART_CONF_BAUD_RATE;
params.readMode = UART_MODE_CALLBACK;
params.writeMode = UART_MODE_BLOCKING;
params.readCallback = uart0_cb;
params.readDataMode = UART_DATA_TEXT;
params.readReturnMode = UART_RETURN_NEWLINE;
uart_params.baudRate = TI_UART_CONF_BAUD_RATE;
uart_params.readMode = UART_MODE_CALLBACK;
uart_params.writeMode = UART_MODE_BLOCKING;
uart_params.readCallback = uart0_cb;
uart_params.readDataMode = UART_DATA_TEXT;
uart_params.readReturnMode = UART_RETURN_NEWLINE;
gh_uart = UART_open(Board_UART0, &params);
/* No error handling. */
uart_handle = UART_open(Board_UART0, &uart_params);
initialized = true;
}
/*---------------------------------------------------------------------------*/
int_fast32_t
uart0_write(const void *buffer, size_t size)
uart0_write(const void *buf, size_t buf_size)
{
if (!is_init) {
if(!initialized) {
return UART_STATUS_ERROR;
}
return UART_write(gh_uart, buffer, size);
return UART_write(uart_handle, buf, buf_size);
}
/*---------------------------------------------------------------------------*/
int_fast32_t
uart0_set_callback(uart0_input_cb input_cb)
uart0_set_callback(uart0_input_fxn_t input_cb)
{
if (!is_init) {
if(!initialized) {
return UART_STATUS_ERROR;
}
if (curr_input_cb == input_cb) {
if(curr_input_cb == input_cb) {
return UART_STATUS_SUCCESS;
}
curr_input_cb = input_cb;
if (input_cb) {
return UART_read(gh_uart, &char_buf, 1);
if(input_cb) {
return UART_read(uart_handle, &char_buf, 1);
} else {
UART_readCancel(gh_uart);
UART_readCancel(uart_handle);
return UART_STATUS_SUCCESS;
}
}

View File

@ -28,16 +28,20 @@
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* \addtogroup cc26xx
* \addtogroup cc13xx-cc26xx-cpu
* @{
*
* \defgroup cc26xx-uart CC13xx/CC26xx UARTs
* \defgroup cc13xx-cc26xx-uart UART for CC13xx/CC26xx.
*
* Driver for the CC13xx/CC26xx UART controller
* This particular driver utilizes the UART0 peripheral specifically.
*
* Driver for the CC13xx/CC26xx UART controller.
* @{
*
* \file
* Header file for the CC13xx/CC26xx UART driver
* Header file of UART driver for CC13xx/CC26xx.
* \author
* Edvard Pettersen <e.pettersen@ti.com>
*/
#ifndef UART0_ARCH_H_
#define UART0_ARCH_H_
@ -45,37 +49,31 @@
#include <stddef.h>
#include <stdint.h>
/*---------------------------------------------------------------------------*/
typedef int (*uart0_input_cb)(unsigned char);
typedef int (*uart0_input_fxn_t)(unsigned char);
/*---------------------------------------------------------------------------*/
/** \name UART functions
* @{
*/
/**
* \brief Initializes the UART driver
* \brief Initializes the UART driver.
*/
void uart0_init(void);
/**
* \brief Writes data from a memory buffer to the UART interface.
* \param buffer A pointer to the data buffer.
* \param size Size of the data buffer.
* \return Number of bytes that has been written to the UART. If an
* error occurs, a negative value is returned.
* \brief Writes data from a memory buffer to the UART interface.
* \param buf A pointer to the data buffer.
* \param buf_size Size of the data buffer.
* \return Number of bytes that has been written to the UART. If an
* error occurs, a negative value is returned.
*/
int_fast32_t uart0_write(const void *buffer, size_t size);
int_fast32_t uart0_write(const void *buf, size_t buf_size);
/**
* \brief Sets the callback function for when bytes are received
* on UART0.
* \param input_cb Pointer to the callback function. A valid pointer subscribes
* for UART0 callbacks when bytes are received, while a NULL pointer
* unsubscribes.
* \return 0 for success, negative value for errors.
* \brief Set the callback function for when bytes are received
* on UART0.
* \param input_cb Pointer to the callback function. A valid pointer
* subscribes for UART0 callbacks when bytes are received,
* while a NULL pointer unsubscribes.
* \return 0 for success, negative value for errors.
*/
int_fast32_t uart0_set_callback(uart0_input_cb input_cb);
/** @} */
int_fast32_t uart0_set_callback(uart0_input_fxn_t input_cb);
/*---------------------------------------------------------------------------*/
#endif /* UART0_ARCH_H_ */
/**

View File

@ -28,10 +28,10 @@
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* \addtogroup cc26xx-clocks
* \addtogroup cc13xx-cc26xx-cpu
* @{
*
* \defgroup cc26xx-wdt CC13xx/CC26xx watchdog timer driver
* \defgroup cc13xx-cc26xx-watchdog CC13xx/CC26xx watchdog timer driver
*
* Driver for the CC13xx/CC26xx Watchdog Timer
*
@ -53,66 +53,85 @@
#include <stdbool.h>
#include <stdint.h>
/*---------------------------------------------------------------------------*/
#ifdef CONTIKI_WATCHDOG_CONF_TIMER_TOP
#define CONTIKI_WATCHDOG_TIMER_TOP CONTIKI_WATCHDOG_CONF_TIMER_TOP
#else
#define CONTIKI_WATCHDOG_TIMER_TOP 0xFFFFF
#endif
#define WATCHDOG_DISABLE WATCHDOG_CONF_DISABLE
#define WATCHDOG_TIMER_TOP WATCHDOG_CONF_TIMER_TOP
/*---------------------------------------------------------------------------*/
static Watchdog_Handle wd_handle;
static Watchdog_Handle wdt_handle;
/*---------------------------------------------------------------------------*/
/**
* \brief Initialises the CC26xx WDT
* \brief Initialises the Watchdog module.
*
* Simply sets the reload counter to a default value. The WDT is not started
* yet. To start it, watchdog_start() must be called.
* Simply sets the reload counter to a default value. The WDT is not
* started yet. To start it, watchdog_start() must be called.
*/
void
watchdog_init(void)
{
if(WATCHDOG_DISABLE) {
return;
}
Watchdog_init();
Watchdog_Params params;
Watchdog_Params_init(&params);
params.resetMode = Watchdog_RESET_ON;
params.debugStallMode = Watchdog_DEBUG_STALL_ON;
Watchdog_Params wdt_params;
Watchdog_Params_init(&wdt_params);
wd_handle = Watchdog_open(Board_WATCHDOG0, &params);
wdt_params.resetMode = Watchdog_RESET_ON;
wdt_params.debugStallMode = Watchdog_DEBUG_STALL_ON;
wdt_handle = Watchdog_open(Board_WATCHDOG0, &wdt_params);
}
/*---------------------------------------------------------------------------*/
/**
* \brief Starts the CC26xx WDT
* \brief Start the Watchdog.
*/
void
watchdog_start(void)
{
if(WATCHDOG_DISABLE) {
return;
}
watchdog_periodic();
}
/*---------------------------------------------------------------------------*/
/**
* \brief Refreshes the CC26xx WDT
* \brief Refresh (feed) the Watchdog.
*/
void
watchdog_periodic(void)
{
Watchdog_setReload(wd_handle, CONTIKI_WATCHDOG_TIMER_TOP);
if(WATCHDOG_DISABLE) {
return;
}
Watchdog_setReload(wdt_handle, WATCHDOG_TIMER_TOP);
}
/*---------------------------------------------------------------------------*/
/**
* \brief Stops the WDT such that it won't timeout and cause MCU reset
* \brief Stop the Watchdog such that it won't timeout and cause a
* system reset.
*/
void
watchdog_stop(void)
{
Watchdog_clear(wd_handle);
if(WATCHDOG_DISABLE) {
return;
}
Watchdog_clear(wdt_handle);
}
/*---------------------------------------------------------------------------*/
/**
* \brief Manually trigger a WDT reboot
* \brief Manually trigger a Watchdog timeout.
*/
void
watchdog_reboot(void)
{
if(WATCHDOG_DISABLE) {
return;
}
watchdog_start();
while(1);
}

View File

@ -141,7 +141,7 @@ rfc_CMD_RADIO_SETUP_t rf_ble_cmd_radio_setup =
.mode = 0x00,
.loDivider = 0x00,
.config.frontEndMode = 0x0,
.config.biasMode = 0x1,
.config.biasMode = 0x0,
.config.analogCfgMode = 0x0,
.config.bNoFsPowerUp = 0x0,
.txPower = 0x3D3F,

View File

@ -144,7 +144,7 @@ rfc_CMD_RADIO_SETUP_t rf_cmd_ieee_radio_setup =
.condition.nSkip = 0x0,
.mode = 0x01,
.config.frontEndMode = 0x0,
.config.biasMode = 0x1,
.config.biasMode = 0x0,
.config.analogCfgMode = 0x0,
.config.bNoFsPowerUp = 0x0,
.txPower = DEFAULT_TX_POWER, /* 5 dBm default */
@ -210,7 +210,7 @@ rfc_CMD_IEEE_RX_t rf_cmd_ieee_rx =
.condition.nSkip = 0x0,
.channel = 0x00, /* set by driver */
.rxConfig.bAutoFlushCrc = 0x1,
.rxConfig.bAutoFlushIgn = 0x0,
.rxConfig.bAutoFlushIgn = 0x1,
.rxConfig.bIncludePhyHdr = 0x0,
.rxConfig.bIncludeCrc = 0x1,
.rxConfig.bAppendRssi = 0x1,

View File

@ -307,7 +307,7 @@ rfc_CMD_PROP_RADIO_DIV_SETUP_t rf_cmd_prop_radio_div_setup =
.formatConf.fecMode = 0x0,
.formatConf.whitenMode = 0x7,
.config.frontEndMode = 0x0, /* set by driver */
.config.biasMode = 0x1, /* set by driver */
.config.biasMode = 0x0, /* set by driver */
.config.analogCfgMode = 0x0,
.config.bNoFsPowerUp = 0x0,
.txPower = DEFAULT_TX_POWER,

View File

@ -283,7 +283,7 @@ rfc_CMD_RADIO_SETUP_t rf_cmd_ieee_radio_setup =
.mode = 0x01,
.loDivider = 0x00,
.config.frontEndMode = 0x0,
.config.biasMode = 0x1,
.config.biasMode = 0x0,
.config.analogCfgMode = 0x0,
.config.bNoFsPowerUp = 0x0,
.txPower = DEFAULT_TX_POWER, /* 5 dBm default */
@ -349,7 +349,7 @@ rfc_CMD_IEEE_RX_t rf_cmd_ieee_rx =
.condition.nSkip = 0x0,
.channel = 0x00, /* set by driver */
.rxConfig.bAutoFlushCrc = 0x1,
.rxConfig.bAutoFlushIgn = 0x0,
.rxConfig.bAutoFlushIgn = 0x1,
.rxConfig.bIncludePhyHdr = 0x0,
.rxConfig.bIncludeCrc = 0x1,
.rxConfig.bAppendRssi = 0x1,

View File

@ -402,7 +402,7 @@ rfc_CMD_PROP_RADIO_DIV_SETUP_t rf_cmd_prop_radio_div_setup =
.formatConf.fecMode = 0x0,
.formatConf.whitenMode = 0x7,
.config.frontEndMode = 0x0, /* set by driver */
.config.biasMode = 0x1, /* set by driver */
.config.biasMode = 0x0, /* set by driver */
.config.analogCfgMode = 0x0,
.config.bNoFsPowerUp = 0x0,
.txPower = DEFAULT_TX_POWER,

View File

@ -140,7 +140,7 @@ rfc_CMD_RADIO_SETUP_t rf_cmd_ieee_radio_setup =
.mode = 0x01,
.__dummy0 = 0x00,
.config.frontEndMode = 0x0,
.config.biasMode = 0x1,
.config.biasMode = 0x0,
.config.analogCfgMode = 0x0,
.config.bNoFsPowerUp = 0x0,
.txPower = DEFAULT_TX_POWER, /* 5 dBm default */
@ -206,7 +206,7 @@ rfc_CMD_IEEE_RX_t rf_cmd_ieee_rx =
.condition.nSkip = 0x0,
.channel = 0x00, /* set by driver */
.rxConfig.bAutoFlushCrc = 0x1,
.rxConfig.bAutoFlushIgn = 0x0,
.rxConfig.bAutoFlushIgn = 0x1,
.rxConfig.bIncludePhyHdr = 0x0,
.rxConfig.bIncludeCrc = 0x1,
.rxConfig.bAppendRssi = 0x1,

View File

@ -139,10 +139,10 @@ rfc_CMD_RADIO_SETUP_t rf_cmd_ieee_radio_setup =
.mode = 0x01,
.loDivider = 0x00,
.config.frontEndMode = 0x0,
.config.biasMode = 0x1,
.config.biasMode = 0x0,
.config.analogCfgMode = 0x0,
.config.bNoFsPowerUp = 0x0,
.txPower = DEFAULT_TX_POWER, /* 5 dBm default */
.txPower = DEFAULT_TX_POWER,
.pRegOverride = rf_ieee_overrides,
};
/*---------------------------------------------------------------------------*/
@ -205,7 +205,7 @@ rfc_CMD_IEEE_RX_t rf_cmd_ieee_rx =
.condition.nSkip = 0x0,
.channel = 0x00, /* set by driver */
.rxConfig.bAutoFlushCrc = 0x1,
.rxConfig.bAutoFlushIgn = 0x0,
.rxConfig.bAutoFlushIgn = 0x1,
.rxConfig.bIncludePhyHdr = 0x0,
.rxConfig.bIncludeCrc = 0x1,
.rxConfig.bAppendRssi = 0x1,

View File

@ -79,9 +79,9 @@
#include <stdbool.h>
/*---------------------------------------------------------------------------*/
#if 1
# define PRINTF(...)
#else
# define PRINTF(...) printf(__VA_ARGS__)
#else
# define PRINTF(...)
#endif
/*---------------------------------------------------------------------------*/
/* Configuration parameters */
@ -420,6 +420,8 @@ init(void)
set_channel(DOT_15_4G_DEFAULT_CHAN);
rf_set_tx_power(ieee_radio.rf_handle, TX_POWER_TABLE, TX_POWER_MAX);
ENERGEST_ON(ENERGEST_TYPE_LISTEN);
/* Start RAT overflow upkeep */

View File

@ -56,11 +56,10 @@
#include <ti/drivers/rf/RF.h>
/*---------------------------------------------------------------------------*/
/* Platform RF dev */
#include "dot-15-4g.h"
#include "rf-core.h"
#include "rf-data-queue.h"
#include "netstack-settings.h"
#include RF_PROP_SETTINGS
#include "rf/dot-15-4g.h"
#include "rf/sched.h"
#include "rf/data-queue.h"
#include "prop-settings.h"
/*---------------------------------------------------------------------------*/
#include <stdint.h>
#include <string.h>
@ -495,7 +494,7 @@ pending_packet(void)
} while (curr_entry != read_entry);
if (num_pending > 0) {
process_poll(&rf_core_process);
process_poll(&rf_sched_process);
}
/* If we didn't find an entry at status finished, no frames are pending */
@ -691,7 +690,7 @@ init(void)
ENERGEST_ON(ENERGEST_TYPE_LISTEN);
/* Start RF process */
process_start(&rf_core_process, NULL);
process_start(&rf_sched_process, NULL);
return RF_RESULT_OK;
}

View File

@ -44,7 +44,7 @@
#include "net/netstack.h"
#include "net/packetbuf.h"
#include "net/mac/mac.h"
#include "lib/random.h"
/*---------------------------------------------------------------------------*/
#include <ti/devices/DeviceFamily.h>
#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h)
@ -81,6 +81,8 @@
/*---------------------------------------------------------------------------*/
/* Synth re-calibration every 3 minutes */
#define SYNTH_RECAL_INTERVAL (CLOCK_SECOND * 60 * 3)
/* Set re-calibration interval with a jitter of 10 seconds */
#define SYNTH_RECAL_JITTER (CLOCK_SECOND * 10)
static struct etimer synth_recal_timer;
/*---------------------------------------------------------------------------*/
@ -105,11 +107,20 @@ cmd_rx_cb(RF_Handle client, RF_CmdHandle command, RF_EventMask events)
if (events & RF_EventRxBufFull) {
rx_buf_full = true;
process_poll(&rf_sched_process);
}
}
/*---------------------------------------------------------------------------*/
static inline clock_time_t
synth_recal_interval(void)
{
/*
* Add jitter centered around SYNTH_RECAL_INTERVAL,
* giving a +- jitter halved.
*/
return SYNTH_RECAL_INTERVAL + (random_rand() % SYNTH_RECAL_JITTER) - (SYNTH_RECAL_JITTER / 2);
}
/*---------------------------------------------------------------------------*/
static inline bool
cmd_rx_is_active(void)
{
@ -241,12 +252,12 @@ netstack_sched_fs(void)
*
* For Prop-mode, the synth is always manually calibrated with CMD_FS.
*/
#if (RF_CORE_CONF_MODE == RF_CORE_MODE_2_4_GHZ)
#if (RF_MODE == RF_CORE_MODE_2_4_GHZ)
if (rx_key) {
cmd_rx_restore(rx_key);
return RF_RESULT_OK;
}
#endif /* RF_CORE_CONF_MODE == RF_CORE_MODE_2_4_GHZ */
#endif /* RF_MODE == RF_CORE_MODE_2_4_GHZ */
RF_EventMask events;
bool synth_error = false;
@ -518,11 +529,18 @@ PROCESS_THREAD(rf_sched_process, ev, data)
while(1) {
PROCESS_YIELD_UNTIL((ev == PROCESS_EVENT_POLL) ||
etimer_expired(&synth_recal_timer));
(ev == PROCESS_EVENT_TIMER));
/* start the synth re-calibration timer once. */
if (rf_is_on) {
rf_is_on = false;
etimer_set(&synth_recal_timer, synth_recal_interval());
}
if (ev == PROCESS_EVENT_POLL) {
do {
watchdog_periodic();
packetbuf_clear();
len = NETSTACK_RADIO.read(packetbuf_dataptr(), PACKETBUF_SIZE);
@ -531,7 +549,7 @@ PROCESS_THREAD(rf_sched_process, ev, data)
* RX after we've freed at least on packet.
*/
if (rx_buf_full) {
PRINTF("rf_core: RX buf full, restart RX\n");
PRINTF("rf_core: RX buf full, restart RX status=0x%04x\n", CMD_STATUS(netstack_cmd_rx));
rx_buf_full = false;
/* Restart RX. */
@ -547,16 +565,13 @@ PROCESS_THREAD(rf_sched_process, ev, data)
} while(len > 0);
}
/* start the synth re-calibration timer once. */
if (rf_is_on) {
rf_is_on = false;
etimer_set(&synth_recal_timer, SYNTH_RECAL_INTERVAL);
}
/* Scheduling CMD_FS will re-calibrate the synth. */
if (etimer_expired(&synth_recal_timer)) {
if ((ev == PROCESS_EVENT_TIMER) &&
etimer_expired(&synth_recal_timer)) {
PRINTF("rf_core: Re-calibrate synth\n");
netstack_sched_fs();
etimer_reset(&synth_recal_timer);
etimer_set(&synth_recal_timer, synth_recal_interval());
}
}
PROCESS_END();

View File

@ -67,6 +67,7 @@
#include <ti/drivers/PIN.h>
#include <ti/drivers/Power.h>
#include <ti/drivers/SPI.h>
#include <ti/drivers/TRNG.h>
#include <ti/drivers/UART.h>
/*---------------------------------------------------------------------------*/
#include "board-peripherals.h"
@ -152,7 +153,7 @@ platform_init_stage_one(void)
* Something is seriously wrong if PIN initialization of the Board GPIO
* table fails.
*/
while (1);
for (;;);
}
/* Perform board-specific initialization */
@ -178,6 +179,8 @@ platform_init_stage_one(void)
NVS_init();
#endif
TRNG_init();
fade(LEDS_GREEN);
/* NoRTOS must be called last */
@ -198,14 +201,12 @@ platform_init_stage_two(void)
#endif
/* Use TRNG to seed PRNG. If TRNG fails, use a hard-coded seed. */
unsigned short trn = 0;
trng_init();
bool result = trng_rand((uint8_t*)&trn, sizeof(trn), TRNG_WAIT_FOREVER);
if (!result) {
unsigned short seed = 0;
if (!trng_rand((uint8_t*)&seed, sizeof(seed), TRNG_WAIT_FOREVER)) {
/* Default to some hard-coded seed. */
trn = 0x1234;
seed = 0x1234;
}
random_init(trn);
random_init(seed);
/* Populate linkaddr_node_addr */
ieee_addr_cpy_to(linkaddr_node_addr.u8, LINKADDR_SIZE);