Uncrustify
This commit is contained in:
parent
08bda8bed7
commit
7cf843f601
@ -150,7 +150,7 @@
|
||||
#define RF_CONF_BLE_BEACON_ENABLE 0
|
||||
#endif
|
||||
|
||||
#if (RF_BLE_BEACON_ENABLE) && !(SUPPORTS_BLE_BEACON)
|
||||
#if (RF_CONF_BLE_BEACON_ENABLE) && !(SUPPORTS_BLE_BEACON)
|
||||
#error "Device does not support BLE for BLE beacon"
|
||||
#endif
|
||||
|
||||
|
@ -67,8 +67,8 @@
|
||||
|
||||
/* Timer conversion; radio is running at 4 MHz */
|
||||
#define RAT_SECOND 4000000u
|
||||
#define RAT_TO_RTIMER(X) ((uint32_t)(((uint64_t)(X) * (RTIMER_SECOND / 256)) / (RAT_SECOND / 256)))
|
||||
#define USEC_TO_RAT(X) ((X) * 4)
|
||||
#define RAT_TO_RTIMER(x) ((uint32_t)(((uint64_t)(x)*(RTIMER_SECOND / 256)) / (RAT_SECOND / 256)))
|
||||
#define USEC_TO_RAT(x) ((x) * 4)
|
||||
|
||||
#if (RTIMER_SECOND % 256) || (RAT_SECOND % 256)
|
||||
#error RAT_TO_RTIMER macro must be fixed!
|
||||
|
@ -27,7 +27,7 @@
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/**
|
||||
/**
|
||||
* \addtogroup cc13xx-cc26xx-cpu
|
||||
* @{
|
||||
*
|
||||
|
@ -97,7 +97,7 @@ clock_init(void)
|
||||
params.period = clockp_ticks_second;
|
||||
params.startFlag = true;
|
||||
|
||||
ClockP_construct(&etimer_clock, (ClockP_Fxn)&clock_update_cb,
|
||||
ClockP_construct(&etimer_clock, (ClockP_Fxn)clock_update_cb,
|
||||
clockp_ticks_second, ¶ms);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -10,7 +10,6 @@
|
||||
* 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.
|
||||
@ -28,7 +27,7 @@
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/**
|
||||
/**
|
||||
* \addtogroup cc13xx-cc26xx-cpu
|
||||
* @{
|
||||
*
|
||||
|
@ -10,7 +10,6 @@
|
||||
* 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.
|
||||
@ -62,7 +61,12 @@ static hwi_dispatch_fxn_t hwi_dispatch_fxn;
|
||||
/**
|
||||
* \brief Stub function used when creating the dummy clock object.
|
||||
*/
|
||||
static void rtimer_clock_stub(uintptr_t unused) { (void)unused; /* do nothing */ }
|
||||
static void
|
||||
rtimer_clock_stub(uintptr_t unused)
|
||||
{
|
||||
(void)unused;
|
||||
/* do nothing */
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief The Man-in-the-Middle ISR hook for the HWI dispatch ISR. This
|
||||
|
@ -10,7 +10,6 @@
|
||||
* 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.
|
||||
@ -58,11 +57,11 @@ rtimer_clock_t rtimer_arch_now(void);
|
||||
* returns an odd value; US_TO_RTIMERTICKS always rounds to the nearest
|
||||
* even number.
|
||||
*/
|
||||
#define US_TO_RTIMERTICKS(us) (2 * ( \
|
||||
((us) >= 0) \
|
||||
#define US_TO_RTIMERTICKS(us) ( \
|
||||
(((us) >= 0) \
|
||||
? (((int32_t)(us) * (RTIMER_ARCH_SECOND / 2) + 500000) / 1000000L) \
|
||||
: (((int32_t)(us) * (RTIMER_ARCH_SECOND / 2) - 500000) / 1000000L) \
|
||||
))
|
||||
) * 2)
|
||||
|
||||
#define RTIMERTICKS_TO_US(rt) ( \
|
||||
((rt) >= 0) \
|
||||
@ -74,7 +73,8 @@ rtimer_clock_t rtimer_arch_now(void);
|
||||
* 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)( \
|
||||
#define RTIMERTICKS_TO_US_64(rt) ( \
|
||||
(uint32_t)( \
|
||||
((uint64_t)(rt) * 1000000 + (RTIMER_ARCH_SECOND / 2)) / RTIMER_ARCH_SECOND \
|
||||
))
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -10,7 +10,6 @@
|
||||
* 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.
|
||||
|
@ -63,7 +63,7 @@ static spi_arch_t spi_arches[SPI_CONTROLLER_COUNT];
|
||||
static spi_arch_t *spi_arches = NULL;
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static inline spi_arch_t*
|
||||
static inline spi_arch_t *
|
||||
get_handle(uint8_t spi_controller)
|
||||
{
|
||||
if(spi_controller < SPI_CONTROLLER_COUNT) {
|
||||
|
@ -73,7 +73,7 @@ extern unsigned long _stack_end;
|
||||
__attribute__((section(".resetVecs"))) __attribute__((used))
|
||||
static void(*const resetVectors[16])(void) =
|
||||
{
|
||||
(void (*)(void))((uint32_t)&_stack_end),
|
||||
(void(*)(void))((uint32_t)&_stack_end),
|
||||
/* The initial stack pointer */
|
||||
resetISR, /* The reset handler */
|
||||
nmiISR, /* The NMI handler */
|
||||
|
@ -49,10 +49,10 @@
|
||||
#include DeviceFamily_constructPath(driverlib/interrupt.h)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Forward declaration of the reset ISR and the default fault handlers. */
|
||||
static void nmiISR( void );
|
||||
static void faultISR( void );
|
||||
static void intDefaultHandler( void );
|
||||
extern int main( void );
|
||||
static void nmiISR(void);
|
||||
static void faultISR(void);
|
||||
static void intDefaultHandler(void);
|
||||
extern int main(void);
|
||||
|
||||
extern void MPUFaultIntHandler(void);
|
||||
extern void BusFaultIntHandler(void);
|
||||
@ -141,22 +141,22 @@ extern void TRNGIntHandler(void);
|
||||
extern void __iar_program_start(void);
|
||||
|
||||
/* Get stack start (highest address) symbol from linker file. */
|
||||
extern const void* STACK_TOP;
|
||||
extern const void *STACK_TOP;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* It is required to place something in the CSTACK segment to get the stack
|
||||
* check feature in IAR to work as expected
|
||||
*/
|
||||
__root static void* dummy_stack @ ".stack";
|
||||
__root static void *dummy_stack @ ".stack";
|
||||
|
||||
/*
|
||||
* The vector table. Note that the proper constructs must be placed on this to
|
||||
* ensure that it ends up at physical address 0x0000.0000 or at the start of
|
||||
* the program if located at a start address other than 0.
|
||||
*/
|
||||
__root void (* const __vector_table[])(void) @ ".intvec" =
|
||||
__root void(*const __vector_table[])(void) @ ".intvec" =
|
||||
{
|
||||
(void (*)(void))&STACK_TOP, /* 0 The initial stack pointer */
|
||||
(void (*)(void)) & STACK_TOP, /* 0 The initial stack pointer */
|
||||
__iar_program_start, /* 1 The reset handler */
|
||||
nmiISR, /* 2 The NMI handler */
|
||||
faultISR, /* 3 The hard fault handler */
|
||||
@ -209,7 +209,7 @@ __root void (* const __vector_table[])(void) @ ".intvec" =
|
||||
AUXADCIntHandler, /* 48 AUX ADC new sample or ADC DMA */
|
||||
/* done, ADC underflow, ADC overflow */
|
||||
TRNGIntHandler /* 49 TRNG event */
|
||||
};
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* \brief Setup trim device.
|
||||
|
@ -10,7 +10,6 @@
|
||||
* 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.
|
||||
|
@ -10,7 +10,6 @@
|
||||
* 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.
|
||||
|
@ -10,7 +10,6 @@
|
||||
* 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.
|
||||
@ -60,7 +59,9 @@ static void
|
||||
uart0_cb(UART_Handle handle, void *buf, size_t count)
|
||||
{
|
||||
/* Simply return if the current callback is NULL. */
|
||||
if(!curr_input_cb) { return; }
|
||||
if(!curr_input_cb) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Save the current callback function locally, as it might be overwritten
|
||||
@ -81,7 +82,9 @@ uart0_cb(UART_Handle handle, void *buf, size_t count)
|
||||
void
|
||||
uart0_init(void)
|
||||
{
|
||||
if(initialized) { return; }
|
||||
if(initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
UART_Params uart_params;
|
||||
UART_Params_init(&uart_params);
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
@ -27,7 +27,7 @@
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/**
|
||||
/**
|
||||
* \addtogroup cc13xx-cc26xx-cpu
|
||||
* @{
|
||||
*
|
||||
@ -133,7 +133,9 @@ watchdog_reboot(void)
|
||||
}
|
||||
|
||||
watchdog_start();
|
||||
while(1);
|
||||
|
||||
/* Busy loop until watchdog times out */
|
||||
for (;;) { /* hang */ }
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
|
@ -54,11 +54,11 @@
|
||||
#define BLE_MAC_PRIMARY_ADDRESS (FCFG1_BASE + FCFG1_O_MAC_BLE_0)
|
||||
#define BLE_MAC_SECONDARY_ADDRESS (CCFG_BASE + CCFG_O_IEEE_BLE_0)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
uint8_t*
|
||||
uint8_t *
|
||||
ble_addr_ptr(void)
|
||||
{
|
||||
volatile const uint8_t * const primary = (uint8_t *)BLE_MAC_PRIMARY_ADDRESS;
|
||||
volatile const uint8_t * const secondary = (uint8_t *)BLE_MAC_SECONDARY_ADDRESS;
|
||||
volatile const uint8_t *const primary = (uint8_t *)BLE_MAC_PRIMARY_ADDRESS;
|
||||
volatile const uint8_t *const secondary = (uint8_t *)BLE_MAC_SECONDARY_ADDRESS;
|
||||
|
||||
/*
|
||||
* Reading from primary location...
|
||||
@ -72,12 +72,12 @@ ble_addr_ptr(void)
|
||||
for(i = 0; i < BLE_ADDR_SIZE; i++) {
|
||||
if(secondary[i] != 0xFF) {
|
||||
/* A byte in secondary is not 0xFF. Use secondary address. */
|
||||
return (uint8_t*)secondary;
|
||||
return (uint8_t *)secondary;
|
||||
}
|
||||
}
|
||||
|
||||
/* All bytes in secondary is 0xFF. Use primary address. */
|
||||
return (uint8_t*)primary;
|
||||
return (uint8_t *)primary;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
|
@ -55,7 +55,7 @@
|
||||
* This function will return the primary address from info page, unless a
|
||||
* valid address is found in the secondary address from CCFG.
|
||||
*/
|
||||
uint8_t* ble_addr_ptr(void);
|
||||
uint8_t *ble_addr_ptr(void);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Copy the node's factory BLE address to a destination memory area
|
||||
|
@ -67,7 +67,7 @@
|
||||
#define LOG_MODULE "Radio"
|
||||
#define LOG_LEVEL LOG_LEVEL_NONE
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if RF_BLE_BEACON_ENABLE
|
||||
#if RF_CONF_BLE_BEACON_ENABLE
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* BLE Advertisement channels. Not to be changed by the user. */
|
||||
typedef enum {
|
||||
@ -75,9 +75,9 @@ typedef enum {
|
||||
BLE_ADV_CHANNEL_38 = (1 << 1),
|
||||
BLE_ADV_CHANNEL_39 = (1 << 2),
|
||||
|
||||
BLE_ADV_CHANNEL_MASK = BLE_ADV_CHANNEL_37
|
||||
| BLE_ADV_CHANNEL_38
|
||||
| BLE_ADV_CHANNEL_39,
|
||||
BLE_ADV_CHANNEL_MASK = (BLE_ADV_CHANNEL_37 |
|
||||
BLE_ADV_CHANNEL_38 |
|
||||
BLE_ADV_CHANNEL_39),
|
||||
} ble_adv_channel_t;
|
||||
|
||||
#define BLE_ADV_CHANNEL_MIN 37
|
||||
@ -210,7 +210,7 @@ rf_ble_get_tx_power(void)
|
||||
rf_result_t res;
|
||||
|
||||
int8_t dbm;
|
||||
res = rf_get_tx_power(ble_beacond.rf_handle, TX_POWER_TABLE, &dbm)
|
||||
res = rf_get_tx_power(ble_beacond.rf_handle, TX_POWER_TABLE, &dbm);
|
||||
|
||||
if(res != RF_RESULT_OK) {
|
||||
return RF_TxPowerTable_INVALID_DBM;
|
||||
@ -290,26 +290,44 @@ PROCESS_THREAD(ble_beacond_process, ev, data)
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#else /* RF_BLE_BEACON_ENABLE */
|
||||
#else /* RF_CONF_BLE_BEACON_ENABLE */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
rf_ble_beacond_result_t
|
||||
rf_ble_beacond_init(void) { return RF_BLE_BEACOND_DISABLED; }
|
||||
rf_ble_beacond_init(void)
|
||||
{
|
||||
return RF_BLE_BEACOND_DISABLED;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
rf_ble_beacond_result_t
|
||||
rf_ble_beacond_start(clock_time_t interval, const char *name) { return RF_BLE_BEACOND_DISABLED; }
|
||||
rf_ble_beacond_start(clock_time_t interval, const char *name)
|
||||
{
|
||||
return RF_BLE_BEACOND_DISABLED;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
rf_ble_beacond_result_t
|
||||
rf_ble_beacond_stop(void) { return RF_BLE_BEACOND_DISABLED; }
|
||||
rf_ble_beacond_stop(void)
|
||||
{
|
||||
return RF_BLE_BEACOND_DISABLED;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int8_t
|
||||
rf_ble_is_active(void) { return -1; }
|
||||
rf_ble_is_active(void)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
rf_ble_beacond_result_t
|
||||
rf_ble_set_tx_power(int8_t power) { return RF_BLE_BEACOND_DISABLED; }
|
||||
rf_ble_set_tx_power(int8_t power)
|
||||
{
|
||||
return RF_BLE_BEACOND_DISABLED;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int8_t
|
||||
rf_ble_get_tx_power(void) { return ~(int8_t)(0); }
|
||||
rf_ble_get_tx_power(void)
|
||||
{
|
||||
return ~(int8_t)(0);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* RF_BLE_BEACON_ENABLE */
|
||||
#endif /* RF_CONF_BLE_BEACON_ENABLE */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
||||
|
@ -39,13 +39,13 @@
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "sys/cc.h"
|
||||
|
||||
#include "rf/data-queue.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <ti/devices/DeviceFamily.h>
|
||||
#include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
|
||||
#include DeviceFamily_constructPath(driverlib/rf_data_entry.h)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "rf/data-queue.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
@ -58,7 +58,7 @@
|
||||
typedef union {
|
||||
data_entry_t data_entry;
|
||||
uint8_t buf[RX_BUF_SIZE];
|
||||
} rx_buf_t CC_ALIGN(4);
|
||||
} rx_buf_t CC_ALIGN (4);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
typedef struct {
|
||||
/* RX bufs */
|
||||
@ -66,7 +66,7 @@ typedef struct {
|
||||
/* RFC data queue object */
|
||||
data_queue_t data_queue;
|
||||
/* Current data entry in use by RF */
|
||||
data_entry_t* curr_entry;
|
||||
data_entry_t *curr_entry;
|
||||
/* Size in bytes of length field in data entry */
|
||||
size_t lensz;
|
||||
} rx_data_queue_t;
|
||||
@ -85,11 +85,11 @@ rx_bufs_init(void)
|
||||
data_entry->status = DATA_ENTRY_PENDING;
|
||||
data_entry->config.type = DATA_ENTRY_TYPE_GEN;
|
||||
data_entry->config.lenSz = rx_data_queue.lensz;
|
||||
data_entry->length = RX_BUF_SIZE - sizeof(data_entry_t); /* TODO: is this sizeof sound? */
|
||||
data_entry->length = RX_BUF_SIZE - sizeof(data_entry_t);
|
||||
/* Point to fist entry if this is last entry, else point to next entry */
|
||||
data_entry->pNextEntry = ((i + 1) == RX_BUF_CNT)
|
||||
? rx_data_queue.bufs[0].buf
|
||||
: rx_data_queue.bufs[i+1].buf;
|
||||
: rx_data_queue.bufs[i + 1].buf;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
@ -107,7 +107,7 @@ rx_bufs_reset(void)
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
data_queue_t*
|
||||
data_queue_t *
|
||||
data_queue_init(size_t lensz)
|
||||
{
|
||||
rx_data_queue.lensz = lensz;
|
||||
@ -137,7 +137,7 @@ data_queue_reset(void)
|
||||
rx_data_queue.curr_entry = &(rx_data_queue.bufs[0].data_entry);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
data_entry_t*
|
||||
data_entry_t *
|
||||
data_queue_current_entry(void)
|
||||
{
|
||||
return rx_data_queue.curr_entry;
|
||||
@ -147,7 +147,7 @@ void
|
||||
data_queue_release_entry(void)
|
||||
{
|
||||
data_entry_t *const curr_entry = rx_data_queue.curr_entry;
|
||||
uint8_t *const frame_ptr = (uint8_t*)&(curr_entry->data);
|
||||
uint8_t *const frame_ptr = (uint8_t *)&(curr_entry->data);
|
||||
|
||||
/* Clear length bytes */
|
||||
memset(frame_ptr, 0x0, rx_data_queue.lensz);
|
||||
@ -155,7 +155,7 @@ data_queue_release_entry(void)
|
||||
curr_entry->status = DATA_ENTRY_PENDING;
|
||||
|
||||
/* Move current entry to the next entry */
|
||||
rx_data_queue.curr_entry = (data_entry_t*)(curr_entry->pNextEntry);
|
||||
rx_data_queue.curr_entry = (data_entry_t *)(curr_entry->pNextEntry);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
||||
|
@ -55,9 +55,9 @@
|
||||
typedef dataQueue_t data_queue_t;
|
||||
typedef rfc_dataEntryGeneral_t data_entry_t;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
data_queue_t* data_queue_init(size_t lensz);
|
||||
data_queue_t *data_queue_init(size_t lensz);
|
||||
void data_queue_reset(void);
|
||||
data_entry_t* data_queue_current_entry(void);
|
||||
data_entry_t *data_queue_current_entry(void);
|
||||
void data_queue_release_entry(void);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* RF_DATA_QUEUE_H_ */
|
||||
|
@ -70,8 +70,8 @@ ieee_addr_cpy_to(uint8_t *dst, uint8_t len)
|
||||
} else {
|
||||
int i;
|
||||
|
||||
volatile const uint8_t * const primary = (uint8_t *)IEEE_MAC_PRIMARY_ADDRESS;
|
||||
volatile const uint8_t * const secondary = (uint8_t *)IEEE_MAC_SECONDARY_ADDRESS;
|
||||
volatile const uint8_t *const primary = (uint8_t *)IEEE_MAC_PRIMARY_ADDRESS;
|
||||
volatile const uint8_t *const secondary = (uint8_t *)IEEE_MAC_SECONDARY_ADDRESS;
|
||||
|
||||
/* Reading from primary location... */
|
||||
volatile const uint8_t *ieee_addr = primary;
|
||||
|
@ -173,11 +173,11 @@ static ieee_radio_t ieee_radio;
|
||||
static cmd_mod_filt_t cmd_mod_filt;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* RF Command volatile objects */
|
||||
#define cmd_radio_setup (*(volatile rfc_CMD_RADIO_SETUP_t*)&rf_cmd_ieee_radio_setup)
|
||||
#define cmd_fs (*(volatile rfc_CMD_FS_t*) &rf_cmd_ieee_fs)
|
||||
#define cmd_tx (*(volatile rfc_CMD_IEEE_TX_t*) &rf_cmd_ieee_tx)
|
||||
#define cmd_rx (*(volatile rfc_CMD_IEEE_RX_t*) &rf_cmd_ieee_rx)
|
||||
#define cmd_rx_ack (*(volatile rfc_CMD_IEEE_RX_ACK_t*)&rf_cmd_ieee_rx_ack)
|
||||
#define cmd_radio_setup (*(volatile rfc_CMD_RADIO_SETUP_t *)&rf_cmd_ieee_radio_setup)
|
||||
#define cmd_fs (*(volatile rfc_CMD_FS_t *) &rf_cmd_ieee_fs)
|
||||
#define cmd_tx (*(volatile rfc_CMD_IEEE_TX_t *) &rf_cmd_ieee_tx)
|
||||
#define cmd_rx (*(volatile rfc_CMD_IEEE_RX_t *) &rf_cmd_ieee_rx)
|
||||
#define cmd_rx_ack (*(volatile rfc_CMD_IEEE_RX_ACK_t *)&rf_cmd_ieee_rx_ack)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static inline bool
|
||||
rx_is_active(void)
|
||||
@ -191,19 +191,19 @@ static uint32_t rat_to_timestamp(const uint32_t);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Forward declarations of Radio driver functions */
|
||||
static int init(void);
|
||||
static int prepare(const void*, unsigned short);
|
||||
static int prepare(const void *, unsigned short);
|
||||
static int transmit(unsigned short);
|
||||
static int send(const void*, unsigned short);
|
||||
static int read(void*, unsigned short);
|
||||
static int send(const void *, unsigned short);
|
||||
static int read(void *, unsigned short);
|
||||
static int channel_clear(void);
|
||||
static int receiving_packet(void);
|
||||
static int pending_packet(void);
|
||||
static int on(void);
|
||||
static int off(void);
|
||||
static radio_result_t get_value(radio_param_t, radio_value_t*);
|
||||
static radio_result_t get_value(radio_param_t, radio_value_t *);
|
||||
static radio_result_t set_value(radio_param_t, radio_value_t);
|
||||
static radio_result_t get_object(radio_param_t, void*, size_t);
|
||||
static radio_result_t set_object(radio_param_t, const void*, size_t);
|
||||
static radio_result_t get_object(radio_param_t, void *, size_t);
|
||||
static radio_result_t set_object(radio_param_t, const void *, size_t);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
rat_overflow_cb(void *arg)
|
||||
@ -236,7 +236,7 @@ init_rf_params(void)
|
||||
|
||||
cmd_rx.ccaRssiThr = IEEE_MODE_CCA_RSSI_THRESHOLD;
|
||||
|
||||
cmd_tx.pNextOp = (RF_Op*)&cmd_rx_ack;
|
||||
cmd_tx.pNextOp = (RF_Op *)&cmd_rx_ack;
|
||||
cmd_tx.condition.rule = COND_NEVER; /* Initially ACK turned off */
|
||||
|
||||
/*
|
||||
@ -502,8 +502,8 @@ read(void *buf, unsigned short buf_len)
|
||||
* Length = N + 8
|
||||
* N = Length - 8
|
||||
*/
|
||||
uint8_t *const frame_ptr = (uint8_t*)&data_entry->data;
|
||||
const lensz_t frame_len = *(lensz_t*)frame_ptr;
|
||||
uint8_t *const frame_ptr = (uint8_t *)&data_entry->data;
|
||||
const lensz_t frame_len = *(lensz_t *)frame_ptr;
|
||||
|
||||
/* Sanity check that Frame is at least Frame Shave bytes long */
|
||||
if(frame_len < FRAME_SHAVE) {
|
||||
@ -532,7 +532,7 @@ read(void *buf, unsigned short buf_len)
|
||||
/* LQI retrieved from Status byte, FCS (2) + RSSI (1) bytes after payload. */
|
||||
ieee_radio.last.corr_lqi = (uint8_t)(payload_ptr[payload_len + 3] & STATUS_CORRELATION);
|
||||
/* Timestamp stored FCS (2) + RSSI (1) + Status (1) bytes after payload. */
|
||||
const uint32_t rat_ticks = *(uint32_t*)(payload_ptr + payload_len + 4);
|
||||
const uint32_t rat_ticks = *(uint32_t *)(payload_ptr + payload_len + 4);
|
||||
ieee_radio.last.timestamp = rat_to_timestamp(rat_ticks);
|
||||
|
||||
if(!ieee_radio.poll_mode) {
|
||||
@ -567,7 +567,7 @@ cca_request(cmd_cca_req_t *cmd_cca_req)
|
||||
|
||||
RF_Stat stat = RF_StatRadioInactiveError;
|
||||
if(rx_is_active()) {
|
||||
stat = RF_runImmediateCmd(ieee_radio.rf_handle, (uint32_t*)&cmd_cca_req);
|
||||
stat = RF_runImmediateCmd(ieee_radio.rf_handle, (uint32_t *)&cmd_cca_req);
|
||||
}
|
||||
|
||||
if(rx_is_idle) {
|
||||
@ -738,7 +738,7 @@ get_value(radio_param_t param, radio_value_t *value)
|
||||
|
||||
/* TX power */
|
||||
case RADIO_PARAM_TXPOWER:
|
||||
res = rf_get_tx_power(ieee_radio.rf_handle, rf_tx_power_table, (int8_t*)&value);
|
||||
res = rf_get_tx_power(ieee_radio.rf_handle, rf_tx_power_table, (int8_t *)&value);
|
||||
return ((res == RF_RESULT_OK) &&
|
||||
(*value != RF_TxPowerTable_INVALID_DBM))
|
||||
? RADIO_RESULT_OK
|
||||
@ -848,7 +848,8 @@ set_value(radio_param_t param, radio_value_t value)
|
||||
/* RX Mode */
|
||||
case RADIO_PARAM_RX_MODE: {
|
||||
if(value & ~(RADIO_RX_MODE_ADDRESS_FILTER |
|
||||
RADIO_RX_MODE_AUTOACK | RADIO_RX_MODE_POLL_MODE)) {
|
||||
RADIO_RX_MODE_AUTOACK |
|
||||
RADIO_RX_MODE_POLL_MODE)) {
|
||||
return RADIO_RESULT_INVALID_VALUE;
|
||||
}
|
||||
|
||||
@ -867,7 +868,7 @@ set_value(radio_param_t param, radio_value_t value)
|
||||
if(old_poll_mode == ieee_radio.poll_mode) {
|
||||
/* Do not turn the radio off and on, just send an update command */
|
||||
memcpy(&cmd_mod_filt.newFrameFiltOpt, &(rf_cmd_ieee_rx.frameFiltOpt), sizeof(rf_cmd_ieee_rx.frameFiltOpt));
|
||||
const RF_Stat stat = RF_runImmediateCmd(ieee_radio.rf_handle, (uint32_t*)&cmd_mod_filt);
|
||||
const RF_Stat stat = RF_runImmediateCmd(ieee_radio.rf_handle, (uint32_t *)&cmd_mod_filt);
|
||||
if(stat != RF_StatCmdDoneSuccess) {
|
||||
LOG_ERR("Setting address filter failed, stat=0x%02X\n", stat);
|
||||
return RADIO_RESULT_ERROR;
|
||||
|
@ -79,8 +79,10 @@
|
||||
#define LOG_LEVEL LOG_LEVEL_NONE
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Configuration parameters */
|
||||
#define PROP_MODE_DW PROP_MODE_CONF_DW
|
||||
#define PROP_MODE_DYN_WHITENER PROP_MODE_CONF_DW
|
||||
#define PROP_MODE_USE_CRC16 PROP_MODE_CONF_USE_CRC16
|
||||
#define PROP_MODE_CENTER_FREQ PROP_MODE_CONF_CENTER_FREQ
|
||||
#define PROP_MODE_LO_DIVIDER PROP_MODE_CONF_LO_DIVIDER
|
||||
#define PROP_MODE_CCA_RSSI_THRESHOLD PROP_MODE_CONF_CCA_RSSI_THRESHOLD
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Used for checking result of CCA_REQ command */
|
||||
@ -108,7 +110,7 @@ typedef enum {
|
||||
#define CRC_LEN 4
|
||||
#endif /* PROP_MODE_USE_CRC16 */
|
||||
|
||||
#if PROP_MODE_DW
|
||||
#if PROP_MODE_DYN_WHITENER
|
||||
#define DOT_4G_PHR_DW_BIT DOT_4G_PHR_DW
|
||||
#else
|
||||
#define DOT_4G_PHR_DW_BIT 0
|
||||
@ -188,8 +190,8 @@ static int off(void);
|
||||
static void
|
||||
init_rf_params(void)
|
||||
{
|
||||
cmd_radio_setup.centerFreq = PROP_MODE_CONF_CENTER_FREQ;
|
||||
cmd_radio_setup.loDivider = PROP_MODE_CONF_LO_DIVIDER;
|
||||
cmd_radio_setup.centerFreq = PROP_MODE_CENTER_FREQ;
|
||||
cmd_radio_setup.loDivider = PROP_MODE_LO_DIVIDER;
|
||||
|
||||
data_queue_t *data_queue = data_queue_init(sizeof(lensz_t));
|
||||
|
||||
@ -387,8 +389,8 @@ read(void *buf, unsigned short buf_len)
|
||||
* = N + 2
|
||||
* N = Length - 2
|
||||
*/
|
||||
uint8_t *const frame_ptr = (uint8_t*)&data_entry->data;
|
||||
const lensz_t frame_len = *(lensz_t*)frame_ptr;
|
||||
uint8_t *const frame_ptr = (uint8_t *)&data_entry->data;
|
||||
const lensz_t frame_len = *(lensz_t *)frame_ptr;
|
||||
|
||||
/* Sanity check that Frame is at least Frame Shave bytes long */
|
||||
if(frame_len < FRAME_SHAVE) {
|
||||
@ -551,7 +553,7 @@ get_value(radio_param_t param, radio_value_t *value)
|
||||
return RADIO_RESULT_OK;
|
||||
|
||||
case RADIO_PARAM_TXPOWER:
|
||||
res = rf_get_tx_power(prop_radio.rf_handle, rf_tx_power_table, (int8_t*)&value);
|
||||
res = rf_get_tx_power(prop_radio.rf_handle, rf_tx_power_table, (int8_t *)&value);
|
||||
return ((res == RF_RESULT_OK) &&
|
||||
(*value != RF_TxPowerTable_INVALID_DBM))
|
||||
? RADIO_RESULT_OK
|
||||
|
@ -56,9 +56,8 @@
|
||||
#define RF_MODE_2_4_GHZ (1 << 1)
|
||||
|
||||
/* Bitmask of supported RF modes */
|
||||
#define RF_MODE_BM ( RF_MODE_SUB_1_GHZ \
|
||||
| RF_MODE_2_4_GHZ \
|
||||
)
|
||||
#define RF_MODE_BM (RF_MODE_SUB_1_GHZ | \
|
||||
RF_MODE_2_4_GHZ)
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* RF_CORE_H_ */
|
||||
|
@ -91,7 +91,7 @@ static struct etimer synth_recal_timer;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static RF_Object rf_netstack;
|
||||
|
||||
#if RF_BLE_BEACON_ENABLE
|
||||
#if RF_CONF_BLE_BEACON_ENABLE
|
||||
static RF_Object rf_ble;
|
||||
#endif
|
||||
|
||||
@ -171,12 +171,12 @@ cmd_rx_restore(uint_fast8_t rx_key)
|
||||
|
||||
CMD_STATUS(netstack_cmd_rx) = PENDING;
|
||||
|
||||
cmd_rx_handle = RF_scheduleCmd(&rf_netstack,
|
||||
(RF_Op*)&netstack_cmd_rx,
|
||||
cmd_rx_handle = RF_scheduleCmd(
|
||||
&rf_netstack,
|
||||
(RF_Op *)&netstack_cmd_rx,
|
||||
&sched_params,
|
||||
cmd_rx_cb,
|
||||
RF_EventRxEntryDone | RF_EventRxBufFull
|
||||
);
|
||||
RF_EventRxEntryDone | RF_EventRxBufFull);
|
||||
|
||||
if(!CMD_HANDLE_OK(cmd_rx_handle)) {
|
||||
LOG_ERR("Unable to restore RX command, handle=%d status=0x%04x",
|
||||
@ -192,13 +192,13 @@ rf_yield(void)
|
||||
{
|
||||
/* Force abort of any ongoing RF operation */
|
||||
RF_flushCmd(&rf_netstack, RF_CMDHANDLE_FLUSH_ALL, RF_ABORT_GRACEFULLY);
|
||||
#if RF_BLE_BEACON_ENABLE
|
||||
#if RF_CONF_BLE_BEACON_ENABLE
|
||||
RF_flushCmd(&rf_ble, RF_CMDHANDLE_FLUSH_ALL, RF_ABORT_GRACEFULLY);
|
||||
#endif
|
||||
|
||||
/* Trigger a manual power-down */
|
||||
RF_yield(&rf_netstack);
|
||||
#if RF_BLE_BEACON_ENABLE
|
||||
#if RF_CONF_BLE_BEACON_ENABLE
|
||||
RF_yield(&rf_ble);
|
||||
#endif
|
||||
|
||||
@ -213,9 +213,7 @@ rf_yield(void)
|
||||
rf_result_t
|
||||
rf_set_tx_power(RF_Handle handle, RF_TxPowerTable_Entry *table, int8_t dbm)
|
||||
{
|
||||
const RF_Stat stat = RF_setTxPower(handle,
|
||||
RF_TxPowerTable_findValue(table, dbm)
|
||||
);
|
||||
const RF_Stat stat = RF_setTxPower(handle, RF_TxPowerTable_findValue(table, dbm));
|
||||
|
||||
return (stat == RF_StatSuccess)
|
||||
? RF_RESULT_OK
|
||||
@ -225,9 +223,7 @@ rf_set_tx_power(RF_Handle handle, RF_TxPowerTable_Entry *table, int8_t dbm)
|
||||
rf_result_t
|
||||
rf_get_tx_power(RF_Handle handle, RF_TxPowerTable_Entry *table, int8_t *dbm)
|
||||
{
|
||||
*dbm = RF_TxPowerTable_findPowerLevel(table,
|
||||
RF_getTxPower(handle)
|
||||
);
|
||||
*dbm = RF_TxPowerTable_findPowerLevel(table, RF_getTxPower(handle));
|
||||
|
||||
return (*dbm != RF_TxPowerTable_INVALID_DBM)
|
||||
? RF_RESULT_OK
|
||||
@ -237,11 +233,7 @@ rf_get_tx_power(RF_Handle handle, RF_TxPowerTable_Entry *table, int8_t *dbm)
|
||||
RF_Handle
|
||||
netstack_open(RF_Params *params)
|
||||
{
|
||||
return RF_open(&rf_netstack,
|
||||
&netstack_mode,
|
||||
(RF_RadioSetup*)&netstack_cmd_radio_setup,
|
||||
params
|
||||
);
|
||||
return RF_open(&rf_netstack, &netstack_mode, (RF_RadioSetup *)&netstack_cmd_radio_setup, params);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
rf_result_t
|
||||
@ -271,15 +263,15 @@ netstack_sched_fs(void)
|
||||
do {
|
||||
CMD_STATUS(netstack_cmd_fs) = PENDING;
|
||||
|
||||
events = RF_runCmd(&rf_netstack,
|
||||
(RF_Op*)&netstack_cmd_fs,
|
||||
events = RF_runCmd(
|
||||
&rf_netstack,
|
||||
(RF_Op *)&netstack_cmd_fs,
|
||||
RF_PriorityNormal,
|
||||
NULL,
|
||||
0
|
||||
);
|
||||
0);
|
||||
|
||||
synth_error = (EVENTS_CMD_DONE(events)) && (CMD_STATUS(netstack_cmd_fs) == ERROR_SYNTH_PROG);
|
||||
|
||||
synth_error = (EVENTS_CMD_DONE(events))
|
||||
&& (CMD_STATUS(netstack_cmd_fs) == ERROR_SYNTH_PROG);
|
||||
} while(synth_error && (num_tries++ < CMD_FS_RETRIES));
|
||||
|
||||
cmd_rx_restore(rx_key);
|
||||
@ -318,12 +310,12 @@ netstack_sched_ieee_tx(bool ack_request)
|
||||
|
||||
CMD_STATUS(netstack_cmd_tx) = PENDING;
|
||||
|
||||
RF_CmdHandle tx_handle = RF_scheduleCmd(&rf_netstack,
|
||||
(RF_Op*)&netstack_cmd_tx,
|
||||
RF_CmdHandle tx_handle = RF_scheduleCmd(
|
||||
&rf_netstack,
|
||||
(RF_Op *)&netstack_cmd_tx,
|
||||
&sched_params,
|
||||
NULL,
|
||||
0
|
||||
);
|
||||
0);
|
||||
|
||||
if(!CMD_HANDLE_OK(tx_handle)) {
|
||||
LOG_ERR("Unable to schedule TX command, handle=%d status=0x%04x\n",
|
||||
@ -372,12 +364,12 @@ netstack_sched_prop_tx(void)
|
||||
|
||||
CMD_STATUS(netstack_cmd_tx) = PENDING;
|
||||
|
||||
RF_CmdHandle tx_handle = RF_scheduleCmd(&rf_netstack,
|
||||
(RF_Op*)&netstack_cmd_tx,
|
||||
RF_CmdHandle tx_handle = RF_scheduleCmd(
|
||||
&rf_netstack,
|
||||
(RF_Op *)&netstack_cmd_tx,
|
||||
&sched_params,
|
||||
NULL,
|
||||
0
|
||||
);
|
||||
0);
|
||||
|
||||
if(!CMD_HANDLE_OK(tx_handle)) {
|
||||
LOG_ERR("Unable to schedule TX command, handle=%d status=0x%04x\n",
|
||||
@ -434,12 +426,12 @@ netstack_sched_rx(bool start)
|
||||
|
||||
CMD_STATUS(netstack_cmd_rx) = PENDING;
|
||||
|
||||
cmd_rx_handle = RF_scheduleCmd(&rf_netstack,
|
||||
(RF_Op*)&netstack_cmd_rx,
|
||||
cmd_rx_handle = RF_scheduleCmd(
|
||||
&rf_netstack,
|
||||
(RF_Op *)&netstack_cmd_rx,
|
||||
&sched_params,
|
||||
cmd_rx_cb,
|
||||
RF_EventRxEntryDone | RF_EventRxBufFull
|
||||
);
|
||||
RF_EventRxEntryDone | RF_EventRxBufFull);
|
||||
|
||||
if(!CMD_HANDLE_OK(cmd_rx_handle)) {
|
||||
LOG_ERR("Unable to schedule RX command, handle=%d status=0x%04x\n",
|
||||
@ -479,8 +471,8 @@ netstack_stop_rx(void)
|
||||
RF_Handle
|
||||
ble_open(RF_Params *params)
|
||||
{
|
||||
#if RF_BLE_BEACON_ENABLE
|
||||
return RF_open(&rf_ble, &ble_mode, (RF_RadioSetup*)&ble_cmd_radio_setup, params);
|
||||
#if RF_CONF_BLE_BEACON_ENABLE
|
||||
return RF_open(&rf_ble, &ble_mode, (RF_RadioSetup *)&ble_cmd_radio_setup, params);
|
||||
|
||||
#else
|
||||
return (RF_Handle)NULL;
|
||||
@ -490,7 +482,7 @@ ble_open(RF_Params *params)
|
||||
rf_result_t
|
||||
ble_sched_beacon(RF_Callback cb, RF_EventMask bm_event)
|
||||
{
|
||||
#if RF_BLE_BEACON_ENABLE
|
||||
#if RF_CONF_BLE_BEACON_ENABLE
|
||||
RF_ScheduleCmdParams sched_params;
|
||||
RF_ScheduleCmdParams_init(&sched_params);
|
||||
|
||||
@ -500,12 +492,12 @@ ble_sched_beacon(RF_Callback cb, RF_EventMask bm_event)
|
||||
|
||||
CMD_STATUS(ble_cmd_beacon) = PENDING;
|
||||
|
||||
RF_CmdHandle beacon_handle = RF_scheduleCmd(&rf_ble,
|
||||
(RF_Op*)&ble_cmd_beacon,
|
||||
RF_CmdHandle beacon_handle = RF_scheduleCmd(
|
||||
&rf_ble,
|
||||
(RF_Op *)&ble_cmd_beacon,
|
||||
&sched_params,
|
||||
cb,
|
||||
bm_event
|
||||
);
|
||||
bm_event);
|
||||
|
||||
if(!CMD_HANDLE_OK(beacon_handle)) {
|
||||
LOG_ERR("Unable to schedule BLE Beacon command, handle=%d status=0x%04x\n",
|
||||
|
@ -27,7 +27,7 @@
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/**
|
||||
/**
|
||||
* \addtogroup cc13xx-cc26xx-cpu
|
||||
* @{
|
||||
*
|
||||
|
@ -83,13 +83,11 @@ tx_power_min(tx_power_table_t *table)
|
||||
{
|
||||
return table[0].power;
|
||||
}
|
||||
|
||||
static inline int8_t
|
||||
tx_power_max(tx_power_table_t *table, size_t size)
|
||||
{
|
||||
return table[size - 1].power;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
tx_power_in_range(int8_t dbm, tx_power_table_t *table, size_t size)
|
||||
{
|
||||
|
@ -108,9 +108,13 @@ fade(PIN_Id pin)
|
||||
j = (k > pivot_half) ? pivot - k : k;
|
||||
|
||||
PINCC26XX_setOutputValue(pin, 1);
|
||||
for(i = 0; i < j; ++i) { __asm__ __volatile__ ("nop"); }
|
||||
for(i = 0; i < j; ++i) {
|
||||
__asm__ __volatile__ ("nop");
|
||||
}
|
||||
PINCC26XX_setOutputValue(pin, 0);
|
||||
for(i = 0; i < pivot_half - j; ++i) { __asm__ __volatile__ ("nop"); }
|
||||
for(i = 0; i < pivot_half - j; ++i) {
|
||||
__asm__ __volatile__ ("nop");
|
||||
}
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
@ -128,8 +132,8 @@ set_rf_params(void)
|
||||
ieee_addr_cpy_to(ext_addr, sizeof(ext_addr));
|
||||
|
||||
/* Short address is the last two bytes of the MAC address */
|
||||
short_addr = ((uint16_t)ext_addr[7] << 0)
|
||||
| ((uint16_t)ext_addr[6] << 8);
|
||||
short_addr = (((uint16_t)ext_addr[7] << 0) |
|
||||
((uint16_t)ext_addr[6] << 8));
|
||||
|
||||
NETSTACK_RADIO.set_value(RADIO_PARAM_PAN_ID, IEEE802154_PANID);
|
||||
NETSTACK_RADIO.set_value(RADIO_PARAM_16BIT_ADDR, short_addr);
|
||||
@ -203,7 +207,7 @@ platform_init_stage_two(void)
|
||||
|
||||
/* Use TRNG to seed PRNG. If TRNG fails, use a hard-coded seed. */
|
||||
unsigned short seed = 0;
|
||||
if(!trng_rand((uint8_t*)&seed, sizeof(seed), TRNG_WAIT_FOREVER)) {
|
||||
if(!trng_rand((uint8_t *)&seed, sizeof(seed), TRNG_WAIT_FOREVER)) {
|
||||
/* Default to some hard-coded seed. */
|
||||
seed = 0x1234;
|
||||
}
|
||||
@ -220,7 +224,7 @@ platform_init_stage_two(void)
|
||||
void
|
||||
platform_init_stage_three(void)
|
||||
{
|
||||
#if RF_BLE_BEACON_ENABLE
|
||||
#if RF_CONF_BLE_BEACON_ENABLE
|
||||
rf_ble_beacond_init();
|
||||
#endif
|
||||
|
||||
@ -239,9 +243,9 @@ platform_init_stage_three(void)
|
||||
ChipInfo_SupportsPROPRIETARY() ? "Yes" : "No",
|
||||
ChipInfo_SupportsBLE() ? "Yes" : "No");
|
||||
|
||||
#if(RF_MODE == RF_MODE_SUB_1_GHZ)
|
||||
#if (RF_MODE == RF_MODE_SUB_1_GHZ)
|
||||
LOG_INFO("Operating frequency on Sub-1 GHz\n");
|
||||
#elif(RF_MODE == RF_MODE_2_4_GHZ)
|
||||
#elif (RF_MODE == RF_MODE_2_4_GHZ)
|
||||
LOG_INFO("Operating frequency on 2.4 GHz\n");
|
||||
#endif
|
||||
LOG_INFO("RF: Channel %d, PANID 0x%04X\n", chan, pan);
|
||||
|
@ -67,7 +67,7 @@
|
||||
#if BOARD_SENSORS_ENABLE
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef Board_BMP280_ADDR
|
||||
# error "Board file doesn't define I2C address Board_BMP280_ADDR"
|
||||
#error "Board file doesn't define I2C address Board_BMP280_ADDR"
|
||||
#endif
|
||||
/* Sensor I2C address */
|
||||
#define BMP280_I2C_ADDRESS Board_BMP280_ADDR
|
||||
@ -175,7 +175,6 @@ i2c_write_read(void *writeBuf, size_t writeCount, void *readBuf, size_t readCoun
|
||||
|
||||
return I2C_transfer(i2c_handle, &i2cTransaction);
|
||||
}
|
||||
|
||||
#define i2c_write(writeBuf, writeCount) i2c_write_read(writeBuf, writeCount, NULL, 0)
|
||||
#define i2c_read(readBuf, readCount) i2c_write_read(NULL, 0, readBuf, readCount)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
@ -276,18 +275,8 @@ convert(uint8_t *data, int32_t *temp, uint32_t *press)
|
||||
);
|
||||
|
||||
/* Compensate temperature */
|
||||
int32_t v_x1_u32r = ( (
|
||||
(utemp >> 3) - ((int32_t)p->dig_t1 << 1)
|
||||
) * (int32_t)p->dig_t2
|
||||
) >> 11;
|
||||
int32_t v_x2_u32r = ( ( ( (
|
||||
(utemp >> 4) - (int32_t)p->dig_t1
|
||||
) * (
|
||||
(utemp >> 4) - (int32_t)p->dig_t1
|
||||
)
|
||||
) >> 12
|
||||
) * (int32_t)p->dig_t3
|
||||
) >> 14;
|
||||
int32_t v_x1_u32r = (((utemp >> 3) - ((int32_t)p->dig_t1 << 1)) * (int32_t)p->dig_t2) >> 11;
|
||||
int32_t v_x2_u32r = (((((utemp >> 4) - (int32_t)p->dig_t1) * ((utemp >> 4) - (int32_t)p->dig_t1)) >> 12) * (int32_t)p->dig_t3) >> 14;
|
||||
|
||||
const uint32_t t_fine = v_x1_u32r + v_x2_u32r;
|
||||
const int32_t temperature = (t_fine * 5 + 128) >> 8;
|
||||
@ -295,28 +284,11 @@ convert(uint8_t *data, int32_t *temp, uint32_t *press)
|
||||
|
||||
/* Compensate pressure */
|
||||
v_x1_u32r = ((int32_t)t_fine >> 1) - (int32_t)64000;
|
||||
v_x2_u32r = ( (
|
||||
(v_x1_u32r >> 2) * (v_x1_u32r >> 2)
|
||||
) >> 11
|
||||
) * (int32_t)p->dig_p6;
|
||||
v_x2_u32r = ( (
|
||||
v_x1_u32r * (int32_t)p->dig_p5
|
||||
) << 1
|
||||
) + v_x2_u32r;
|
||||
v_x2_u32r = (((v_x1_u32r >> 2) * (v_x1_u32r >> 2)) >> 11) * (int32_t)p->dig_p6;
|
||||
v_x2_u32r = ((v_x1_u32r * (int32_t)p->dig_p5) << 1) + v_x2_u32r;
|
||||
v_x2_u32r = (v_x2_u32r >> 2) + ((int32_t)p->dig_p4 << 16);
|
||||
v_x1_u32r = ( ( ( ( (
|
||||
(v_x1_u32r >> 2) * (v_x1_u32r >> 2)
|
||||
) >> 13
|
||||
) * p->dig_p3
|
||||
) >> 3
|
||||
) + ( (
|
||||
(int32_t)p->dig_p2 * v_x1_u32r
|
||||
) >> 1
|
||||
)
|
||||
) >> 18;
|
||||
v_x1_u32r = (
|
||||
(32768 + v_x1_u32r) * (int32_t)p->dig_p1
|
||||
) >> 15;
|
||||
v_x1_u32r = ((((((v_x1_u32r >> 2) * (v_x1_u32r >> 2)) >> 13) * p->dig_p3) >> 3) + (((int32_t)p->dig_p2 * v_x1_u32r) >> 1)) >> 18;
|
||||
v_x1_u32r = ((32768 + v_x1_u32r) * (int32_t)p->dig_p1) >> 15;
|
||||
|
||||
if(v_x1_u32r == 0) {
|
||||
/* Avoid exception caused by division by zero */
|
||||
@ -324,33 +296,16 @@ convert(uint8_t *data, int32_t *temp, uint32_t *press)
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t pressure = ( (
|
||||
(uint32_t)((int32_t)1048576 - upress)
|
||||
) - (
|
||||
v_x2_u32r >> 12
|
||||
)
|
||||
) * 3125;
|
||||
uint32_t pressure = (((uint32_t)((int32_t)1048576 - upress)) - (v_x2_u32r >> 12)) * 3125;
|
||||
if((int32_t)pressure < 0) {
|
||||
pressure = (pressure << 1) / (uint32_t)v_x1_u32r;
|
||||
} else {
|
||||
pressure = (pressure / (uint32_t)v_x1_u32r) * 2;
|
||||
}
|
||||
|
||||
v_x1_u32r = ( (
|
||||
(int32_t)( (
|
||||
(pressure >> 3) * (pressure >> 3)
|
||||
) >> 13
|
||||
)
|
||||
) * (int32_t)p->dig_p9
|
||||
) >> 12;
|
||||
v_x2_u32r = (
|
||||
(int32_t)(pressure >> 2) * (int32_t)p->dig_p8
|
||||
) >> 13;
|
||||
pressure = (uint32_t)( ( (
|
||||
v_x1_u32r + v_x2_u32r + p->dig_p7
|
||||
) >> 4
|
||||
) + (int32_t)pressure
|
||||
);
|
||||
v_x1_u32r = (((int32_t)(((pressure >> 3) * (pressure >> 3)) >> 13)) * (int32_t)p->dig_p9) >> 12;
|
||||
v_x2_u32r = ((int32_t)(pressure >> 2) * (int32_t)p->dig_p8) >> 13;
|
||||
pressure = (uint32_t)(((v_x1_u32r + v_x2_u32r + p->dig_p7) >> 4) + (int32_t)pressure);
|
||||
|
||||
*press = pressure;
|
||||
}
|
||||
|
@ -64,7 +64,7 @@
|
||||
/* The BMP-280 driver uses the I2C0 peripheral to access the senssor */
|
||||
#if BOARD_SENSORS_ENABLE
|
||||
#if (TI_I2C_CONF_ENABLE == 0) || (TI_I2C_CONF_I2C0_ENABLE == 0)
|
||||
# error "The BMP280 requires the I2C driver (TI_I2C_CONF_ENABLE = 1)"
|
||||
#error "The BMP280 requires the I2C driver (TI_I2C_CONF_ENABLE = 1)"
|
||||
#endif
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -54,7 +54,7 @@
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Configure BUZZER pin */
|
||||
#ifndef Board_BUZZER
|
||||
# error "Board file doesn't define pin Board_BUZZER"
|
||||
#error "Board file doesn't define pin Board_BUZZER"
|
||||
#endif
|
||||
#define BUZZER_PIN Board_BUZZER
|
||||
/*---------------------------------------------------------------------------*/
|
||||
@ -126,8 +126,8 @@ buzzer_start(uint32_t freq)
|
||||
|
||||
PINCC26XX_setMux(pin_handle, BUZZER_PIN, GPT_PIN_0A);
|
||||
|
||||
// MCU runs at 48 MHz
|
||||
GPTimerCC26XX_Value load_value = 48000000 / freq;
|
||||
/* MCU runs at 48 MHz */
|
||||
GPTimerCC26XX_Value load_value = (48 * 1000 * 1000) / freq;
|
||||
|
||||
GPTimerCC26XX_setLoadValue(gpt_handle, load_value);
|
||||
GPTimerCC26XX_start(gpt_handle);
|
||||
|
@ -68,7 +68,7 @@
|
||||
#if BOARD_SENSORS_ENABLE
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef Board_HDC1000_ADDR
|
||||
# error "Board file doesn't define the I2C address Board_HDC1000_ADDR"
|
||||
#error "Board file doesn't define the I2C address Board_HDC1000_ADDR"
|
||||
#endif
|
||||
/* Sensor I2C address */
|
||||
#define HDC1000_I2C_ADDRESS Board_HDC1000_ADDR
|
||||
@ -145,7 +145,6 @@ i2c_write_read(void *wbuf, size_t wcount, void *rbuf, size_t rcount)
|
||||
|
||||
return I2C_transfer(i2c_handle, &i2c_transaction);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Peform a write only I2C transaction.
|
||||
* \param wbuf Output buffer during the I2C transation.
|
||||
@ -158,7 +157,6 @@ i2c_write(void *wbuf, size_t wcount)
|
||||
{
|
||||
return i2c_write_read(wbuf, wcount, NULL, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Peform a read only I2C transaction.
|
||||
* \param rbuf Input buffer during the I2C transation.
|
||||
@ -194,7 +192,7 @@ sensor_init(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Enable reading data in one operation
|
||||
/* Enable reading data in one operation */
|
||||
uint8_t config_data[] = { HDC1000_REG_CONFIG, LSB16(HDC1000_VAL_CONFIG) };
|
||||
|
||||
return i2c_write(config_data, sizeof(config_data));
|
||||
|
@ -71,7 +71,7 @@
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if BOARD_SENSORS_ENABLE
|
||||
#if (TI_I2C_CONF_ENABLE == 0) || (TI_I2C_CONF_I2C0_ENABLE == 0)
|
||||
# error "The HDC-1000 requires the I2C driver (TI_I2C_CONF_ENABLE = 1)"
|
||||
#error "The HDC-1000 requires the I2C driver (TI_I2C_CONF_ENABLE = 1)"
|
||||
#endif
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -47,7 +47,7 @@
|
||||
#include <Board.h>
|
||||
|
||||
#include <ti/devices/DeviceFamily.h>
|
||||
#include DeviceFamily_constructPath(driverlib/cpu.h)
|
||||
#include DeviceFamily_constructPath(driverlib / cpu.h)
|
||||
|
||||
#include <ti/drivers/PIN.h>
|
||||
#include <ti/drivers/I2C.h>
|
||||
@ -72,10 +72,10 @@
|
||||
#if BOARD_SENSORS_ENABLE
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef Board_MPU9250_ADDR
|
||||
# error "Board file doesn't define I2C address Board_MPU9250_ADDR"
|
||||
#error "Board file doesn't define I2C address Board_MPU9250_ADDR"
|
||||
#endif
|
||||
#ifndef Board_MPU9250_MAG_ADDR
|
||||
# error "Board file doesn't define I2C address Board_MPU9250_MAG_ADDR"
|
||||
#error "Board file doesn't define I2C address Board_MPU9250_MAG_ADDR"
|
||||
#endif
|
||||
|
||||
/* Sensor I2C address */
|
||||
@ -256,7 +256,6 @@ i2c_write_read(void *wbuf, size_t wcount, void *rbuf, size_t rcount)
|
||||
|
||||
return I2C_transfer(i2c_handle, &i2c_transaction);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Peform a write only I2C transaction.
|
||||
* \param wbuf Output buffer during the I2C transation.
|
||||
@ -269,7 +268,6 @@ i2c_write(void *wbuf, size_t wcount)
|
||||
{
|
||||
return i2c_write_read(wbuf, wcount, NULL, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Peform a read only I2C transaction.
|
||||
* \param rbuf Input buffer during the I2C transation.
|
||||
@ -392,7 +390,7 @@ convert_to_le(uint8_t *data, uint8_t len)
|
||||
* us to determine whether a new sensor reading is available.
|
||||
*/
|
||||
static bool
|
||||
sensor_data_ready(uint8_t* int_status)
|
||||
sensor_data_ready(uint8_t *int_status)
|
||||
{
|
||||
uint8_t int_status_data[] = { REG_INT_STATUS };
|
||||
const bool spi_ok = i2c_write_read(int_status_data, sizeof(int_status_data), int_status, 1);
|
||||
@ -418,7 +416,7 @@ acc_read(uint8_t int_status, uint16_t *data)
|
||||
return false;
|
||||
}
|
||||
|
||||
convert_to_le((uint8_t*)data, DATA_SIZE);
|
||||
convert_to_le((uint8_t *)data, DATA_SIZE);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -441,7 +439,7 @@ gyro_read(uint8_t int_status, uint16_t *data)
|
||||
return false;
|
||||
}
|
||||
|
||||
convert_to_le((uint8_t*)data, DATA_SIZE);
|
||||
convert_to_le((uint8_t *)data, DATA_SIZE);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -591,7 +589,7 @@ value(int type)
|
||||
static int
|
||||
configure(int type, int enable)
|
||||
{
|
||||
// Mask enable
|
||||
/* Mask enable */
|
||||
const MPU_9250_SENSOR_TYPE enable_type = enable & MPU_9250_SENSOR_TYPE_ALL;
|
||||
|
||||
switch(type) {
|
||||
|
@ -79,7 +79,7 @@
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if BOARD_SENSORS_ENABLE
|
||||
#if (TI_I2C_CONF_ENABLE == 0) || (TI_I2C_CONF_I2C0_ENABLE == 0)
|
||||
# error "The MPU-9250 requires the I2C driver (TI_I2C_CONF_ENABLE = 1)"
|
||||
#error "The MPU-9250 requires the I2C driver (TI_I2C_CONF_ENABLE = 1)"
|
||||
#endif
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
@ -125,9 +125,9 @@ typedef enum {
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Accelerometer range configuration, type MPU_9250_SENSOR_ACC_RANGE */
|
||||
#ifdef MPU_9250_SENSOR_CONF_ACC_RANGE_ARG
|
||||
# define MPU_9250_SENSOR_ACC_RANGE_ARG MPU_9250_SENSOR_CONF_ACC_RANGE
|
||||
#define MPU_9250_SENSOR_ACC_RANGE_ARG MPU_9250_SENSOR_CONF_ACC_RANGE
|
||||
#else
|
||||
# define MPU_9250_SENSOR_ACC_RANGE_ARG MPU_9250_SENSOR_ACC_RANGE_2G
|
||||
#define MPU_9250_SENSOR_ACC_RANGE_ARG MPU_9250_SENSOR_ACC_RANGE_2G
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
extern const struct sensors_sensor mpu_9250_sensor;
|
||||
|
@ -68,7 +68,7 @@
|
||||
#if BOARD_SENSORS_ENABLE
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef Board_OPT3001_ADDR
|
||||
# error "Board file doesn't define I2C address Board_OPT3001_ADDR"
|
||||
#error "Board file doesn't define I2C address Board_OPT3001_ADDR"
|
||||
#endif
|
||||
/* Slave address */
|
||||
#define OPT_3001_I2C_ADDRESS Board_OPT3001_ADDR
|
||||
@ -169,7 +169,6 @@ i2c_write_read(void *wbuf, size_t wcount, void *rbuf, size_t rcount)
|
||||
|
||||
return I2C_transfer(i2c_handle, &i2c_transaction);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Peform a write only I2C transaction.
|
||||
* \param wbuf Output buffer during the I2C transation.
|
||||
@ -182,7 +181,6 @@ i2c_write(void *wbuf, size_t wcount)
|
||||
{
|
||||
return i2c_write_read(wbuf, wcount, NULL, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Peform a read only I2C transaction.
|
||||
* \param rbuf Input buffer during the I2C transation.
|
||||
|
@ -67,7 +67,7 @@
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if BOARD_SENSORS_ENABLE
|
||||
#if (TI_I2C_CONF_ENABLE == 0) || (TI_I2C_CONF_I2C0_ENABLE == 0)
|
||||
# error "The OPT-3001 requires the I2C driver (TI_I2C_CONF_ENABLE = 1)"
|
||||
#error "The OPT-3001 requires the I2C driver (TI_I2C_CONF_ENABLE = 1)"
|
||||
#endif
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -69,13 +69,13 @@
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Slave address */
|
||||
#ifndef Board_TMP_ADDR
|
||||
# error "Board file doesn't define I2C address Board_TMP_ADDR"
|
||||
#error "Board file doesn't define I2C address Board_TMP_ADDR"
|
||||
#endif
|
||||
#define TMP_007_I2C_ADDRESS Board_TMP_ADDR
|
||||
|
||||
/* Sensor Interrupt pin */
|
||||
#ifndef Board_TMP_RDY
|
||||
# error "Board file doesn't define interrupt pin Board_TMP_RDY"
|
||||
#error "Board file doesn't define interrupt pin Board_TMP_RDY"
|
||||
#endif
|
||||
#define TMP_007_TMP_RDY Board_TMP_RDY
|
||||
/*---------------------------------------------------------------------------*/
|
||||
@ -157,7 +157,6 @@ i2c_write_read(void *wbuf, size_t wcount, void *rbuf, size_t rcount)
|
||||
|
||||
return I2C_transfer(i2c_handle, &i2c_transaction);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Peform a write only I2C transaction.
|
||||
* \param wbuf Output buffer during the I2C transation.
|
||||
@ -170,7 +169,6 @@ i2c_write(void *wbuf, size_t wcount)
|
||||
{
|
||||
return i2c_write_read(wbuf, wcount, NULL, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Peform a read only I2C transaction.
|
||||
* \param rbuf Input buffer during the I2C transation.
|
||||
@ -301,7 +299,7 @@ read_data(uint16_t *local_tmp, uint16_t *obj_tmp)
|
||||
* from sensor.
|
||||
*/
|
||||
static void
|
||||
convert(uint16_t* local_tmp, uint16_t* obj_tmp)
|
||||
convert(uint16_t *local_tmp, uint16_t *obj_tmp)
|
||||
{
|
||||
uint32_t local = (uint32_t)*local_tmp;
|
||||
uint32_t obj = (uint32_t)*obj_tmp;
|
||||
|
@ -72,15 +72,16 @@
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if BOARD_SENSORS_ENABLE
|
||||
#if (TI_I2C_CONF_ENABLE == 0) || (TI_I2C_CONF_I2C0_ENABLE == 0)
|
||||
# error "The BMP280 requires the I2C driver to be enabled (TI_I2C_CONF_ENABLE = 1)"
|
||||
#error "The BMP280 requires the I2C driver to be enabled (TI_I2C_CONF_ENABLE = 1)"
|
||||
#endif
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
typedef enum {
|
||||
TMP_007_TYPE_OBJECT = (1 << 0),
|
||||
TMP_007_TYPE_AMBIENT = (1 << 1),
|
||||
TMP_007_TYPE_ALL = TMP_007_TYPE_OBJECT
|
||||
| TMP_007_TYPE_AMBIENT,
|
||||
|
||||
TMP_007_TYPE_ALL = (TMP_007_TYPE_OBJECT |
|
||||
TMP_007_TYPE_AMBIENT),
|
||||
} TMP_007_TYPE;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
typedef enum {
|
||||
|
Loading…
Reference in New Issue
Block a user