From 7cf843f601883808d4c5b572b577bcf0d1344606 Mon Sep 17 00:00:00 2001 From: Edvard Pettersen Date: Wed, 25 Jul 2018 18:16:27 +0200 Subject: [PATCH] Uncrustify --- arch/cpu/cc13xx-cc26xx/cc13xx-cc26xx-conf.h | 2 +- arch/cpu/cc13xx-cc26xx/cc13xx-cc26xx-def.h | 4 +- arch/cpu/cc13xx-cc26xx/ccfg-conf.c | 2 +- arch/cpu/cc13xx-cc26xx/dev/clock-arch.c | 4 +- arch/cpu/cc13xx-cc26xx/dev/gpio-hal-arch.c | 2 +- arch/cpu/cc13xx-cc26xx/dev/random.c | 3 +- arch/cpu/cc13xx-cc26xx/dev/rtimer-arch.c | 8 +- arch/cpu/cc13xx-cc26xx/dev/rtimer-arch.h | 24 ++-- arch/cpu/cc13xx-cc26xx/dev/slip-arch.c | 1 - arch/cpu/cc13xx-cc26xx/dev/spi-arch.c | 10 +- .../dev/startup_cc13xx_cc26xx_gcc.c | 6 +- .../dev/startup_cc13xx_cc26xx_iar.c | 18 +-- arch/cpu/cc13xx-cc26xx/dev/trng-arch.c | 7 +- arch/cpu/cc13xx-cc26xx/dev/trng-arch.h | 1 - arch/cpu/cc13xx-cc26xx/dev/uart0-arch.c | 19 +-- arch/cpu/cc13xx-cc26xx/dev/uart0-arch.h | 2 +- arch/cpu/cc13xx-cc26xx/dev/watchdog-arch.c | 10 +- arch/cpu/cc13xx-cc26xx/rf/ble-addr.c | 12 +- arch/cpu/cc13xx-cc26xx/rf/ble-addr.h | 2 +- arch/cpu/cc13xx-cc26xx/rf/ble-beacond.c | 44 ++++-- arch/cpu/cc13xx-cc26xx/rf/data-queue.c | 34 ++--- arch/cpu/cc13xx-cc26xx/rf/data-queue.h | 6 +- arch/cpu/cc13xx-cc26xx/rf/ieee-addr.c | 6 +- arch/cpu/cc13xx-cc26xx/rf/ieee-mode.c | 99 ++++++------- arch/cpu/cc13xx-cc26xx/rf/prop-mode.c | 44 +++--- arch/cpu/cc13xx-cc26xx/rf/rf.h | 5 +- arch/cpu/cc13xx-cc26xx/rf/sched.c | 132 ++++++++---------- arch/cpu/cc13xx-cc26xx/rf/settings.h | 2 +- arch/cpu/cc13xx-cc26xx/rf/tx-power.h | 10 +- .../simplelink/cc13xx-cc26xx/platform.c | 24 ++-- .../cc13xx-cc26xx/sensortag/bmp-280-sensor.c | 107 ++++---------- .../cc13xx-cc26xx/sensortag/bmp-280-sensor.h | 6 +- .../cc13xx-cc26xx/sensortag/buzzer.c | 6 +- .../cc13xx-cc26xx/sensortag/hdc-1000-sensor.c | 14 +- .../cc13xx-cc26xx/sensortag/hdc-1000-sensor.h | 2 +- .../cc13xx-cc26xx/sensortag/mpu-9250-sensor.c | 44 +++--- .../cc13xx-cc26xx/sensortag/mpu-9250-sensor.h | 42 +++--- .../cc13xx-cc26xx/sensortag/opt-3001-sensor.c | 14 +- .../cc13xx-cc26xx/sensortag/opt-3001-sensor.h | 2 +- .../cc13xx-cc26xx/sensortag/tmp-007-sensor.c | 38 +++-- .../cc13xx-cc26xx/sensortag/tmp-007-sensor.h | 9 +- 41 files changed, 397 insertions(+), 430 deletions(-) diff --git a/arch/cpu/cc13xx-cc26xx/cc13xx-cc26xx-conf.h b/arch/cpu/cc13xx-cc26xx/cc13xx-cc26xx-conf.h index 09790cebc..256032d2d 100644 --- a/arch/cpu/cc13xx-cc26xx/cc13xx-cc26xx-conf.h +++ b/arch/cpu/cc13xx-cc26xx/cc13xx-cc26xx-conf.h @@ -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 diff --git a/arch/cpu/cc13xx-cc26xx/cc13xx-cc26xx-def.h b/arch/cpu/cc13xx-cc26xx/cc13xx-cc26xx-def.h index f51ee3c2b..44ac92cf7 100644 --- a/arch/cpu/cc13xx-cc26xx/cc13xx-cc26xx-def.h +++ b/arch/cpu/cc13xx-cc26xx/cc13xx-cc26xx-def.h @@ -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! diff --git a/arch/cpu/cc13xx-cc26xx/ccfg-conf.c b/arch/cpu/cc13xx-cc26xx/ccfg-conf.c index fecdca7c1..be6c1ed9b 100644 --- a/arch/cpu/cc13xx-cc26xx/ccfg-conf.c +++ b/arch/cpu/cc13xx-cc26xx/ccfg-conf.c @@ -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 * @{ * diff --git a/arch/cpu/cc13xx-cc26xx/dev/clock-arch.c b/arch/cpu/cc13xx-cc26xx/dev/clock-arch.c index 516d51cdb..ef2d4e1c9 100644 --- a/arch/cpu/cc13xx-cc26xx/dev/clock-arch.c +++ b/arch/cpu/cc13xx-cc26xx/dev/clock-arch.c @@ -94,10 +94,10 @@ clock_init(void) ClockP_Params params; ClockP_Params_init(¶ms); - params.period = clockp_ticks_second; + 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); } /*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/cc13xx-cc26xx/dev/gpio-hal-arch.c b/arch/cpu/cc13xx-cc26xx/dev/gpio-hal-arch.c index 9da458899..841627ec4 100644 --- a/arch/cpu/cc13xx-cc26xx/dev/gpio-hal-arch.c +++ b/arch/cpu/cc13xx-cc26xx/dev/gpio-hal-arch.c @@ -51,7 +51,7 @@ #include /*---------------------------------------------------------------------------*/ static PIN_Config pin_config[] = { PIN_TERMINATE }; -static PIN_State pin_state; +static PIN_State pin_state; static PIN_Handle pin_handle; /*---------------------------------------------------------------------------*/ static void diff --git a/arch/cpu/cc13xx-cc26xx/dev/random.c b/arch/cpu/cc13xx-cc26xx/dev/random.c index 1a244742b..4286bfe89 100644 --- a/arch/cpu/cc13xx-cc26xx/dev/random.c +++ b/arch/cpu/cc13xx-cc26xx/dev/random.c @@ -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 * @{ * diff --git a/arch/cpu/cc13xx-cc26xx/dev/rtimer-arch.c b/arch/cpu/cc13xx-cc26xx/dev/rtimer-arch.c index d63adc36c..7fd768008 100644 --- a/arch/cpu/cc13xx-cc26xx/dev/rtimer-arch.c +++ b/arch/cpu/cc13xx-cc26xx/dev/rtimer-arch.c @@ -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 diff --git a/arch/cpu/cc13xx-cc26xx/dev/rtimer-arch.h b/arch/cpu/cc13xx-cc26xx/dev/rtimer-arch.h index 341f09393..c42fcbd41 100644 --- a/arch/cpu/cc13xx-cc26xx/dev/rtimer-arch.h +++ b/arch/cpu/cc13xx-cc26xx/dev/rtimer-arch.h @@ -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,24 +57,25 @@ 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) \ - ? (((int32_t)(us) * (RTIMER_ARCH_SECOND / 2) + 500000) / 1000000L) \ - : (((int32_t)(us) * (RTIMER_ARCH_SECOND / 2) - 500000) / 1000000L) \ - )) +#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) \ - ? (((int32_t)(rt) * 1000000L + (RTIMER_ARCH_SECOND / 2)) / RTIMER_ARCH_SECOND) \ - : (((int32_t)(rt) * 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(rt) ((uint32_t)( \ - ((uint64_t)(rt) * 1000000 + (RTIMER_ARCH_SECOND / 2)) / RTIMER_ARCH_SECOND \ +#define RTIMERTICKS_TO_US_64(rt) ( \ + (uint32_t)( \ + ((uint64_t)(rt) * 1000000 + (RTIMER_ARCH_SECOND / 2)) / RTIMER_ARCH_SECOND \ )) /*---------------------------------------------------------------------------*/ #endif /* RTIMER_ARCH_H_ */ diff --git a/arch/cpu/cc13xx-cc26xx/dev/slip-arch.c b/arch/cpu/cc13xx-cc26xx/dev/slip-arch.c index f1f877e98..d15148428 100644 --- a/arch/cpu/cc13xx-cc26xx/dev/slip-arch.c +++ b/arch/cpu/cc13xx-cc26xx/dev/slip-arch.c @@ -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. diff --git a/arch/cpu/cc13xx-cc26xx/dev/spi-arch.c b/arch/cpu/cc13xx-cc26xx/dev/spi-arch.c index 7fe41762b..6950b7baf 100644 --- a/arch/cpu/cc13xx-cc26xx/dev/spi-arch.c +++ b/arch/cpu/cc13xx-cc26xx/dev/spi-arch.c @@ -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) { @@ -144,10 +144,10 @@ spi_arch_lock_and_open(spi_device_t *dev) SPI_Params_init(&spi_params); spi_params.transferMode = SPI_MODE_BLOCKING; - spi_params.mode = SPI_MASTER; - spi_params.bitRate = dev->spi_bit_rate; - spi_params.dataSize = 8; - spi_params.frameFormat = convert_frame_format(dev->spi_pol, dev->spi_pha); + spi_params.mode = SPI_MASTER; + spi_params.bitRate = dev->spi_bit_rate; + spi_params.dataSize = 8; + spi_params.frameFormat = convert_frame_format(dev->spi_pol, dev->spi_pha); /* * Try to open the SPI driver. Accessing the SPI driver also ensures diff --git a/arch/cpu/cc13xx-cc26xx/dev/startup_cc13xx_cc26xx_gcc.c b/arch/cpu/cc13xx-cc26xx/dev/startup_cc13xx_cc26xx_gcc.c index b5bb2c13c..4c47a9ad6 100644 --- a/arch/cpu/cc13xx-cc26xx/dev/startup_cc13xx_cc26xx_gcc.c +++ b/arch/cpu/cc13xx-cc26xx/dev/startup_cc13xx_cc26xx_gcc.c @@ -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 */ @@ -126,8 +126,8 @@ localProgramStart(void) uint32_t *dl; uint32_t *ds; uint32_t *de; - uint32_t count; - uint32_t i; + uint32_t count; + uint32_t i; #if defined(__ARM_ARCH_7EM__) && defined(__VFP_FP__) && !defined(__SOFTFP__) volatile uint32_t *pui32Cpacr = (uint32_t *)0xE000ED88; diff --git a/arch/cpu/cc13xx-cc26xx/dev/startup_cc13xx_cc26xx_iar.c b/arch/cpu/cc13xx-cc26xx/dev/startup_cc13xx_cc26xx_iar.c index 3624c20ac..84b17ac76 100644 --- a/arch/cpu/cc13xx-cc26xx/dev/startup_cc13xx_cc26xx_iar.c +++ b/arch/cpu/cc13xx-cc26xx/dev/startup_cc13xx_cc26xx_iar.c @@ -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. diff --git a/arch/cpu/cc13xx-cc26xx/dev/trng-arch.c b/arch/cpu/cc13xx-cc26xx/dev/trng-arch.c index 8f7cb2627..5196c5c6e 100644 --- a/arch/cpu/cc13xx-cc26xx/dev/trng-arch.c +++ b/arch/cpu/cc13xx-cc26xx/dev/trng-arch.c @@ -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,9 +59,9 @@ 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); diff --git a/arch/cpu/cc13xx-cc26xx/dev/trng-arch.h b/arch/cpu/cc13xx-cc26xx/dev/trng-arch.h index ac220bd25..fc25b9169 100644 --- a/arch/cpu/cc13xx-cc26xx/dev/trng-arch.h +++ b/arch/cpu/cc13xx-cc26xx/dev/trng-arch.h @@ -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. diff --git a/arch/cpu/cc13xx-cc26xx/dev/uart0-arch.c b/arch/cpu/cc13xx-cc26xx/dev/uart0-arch.c index ec1f85265..4bf529ddd 100644 --- a/arch/cpu/cc13xx-cc26xx/dev/uart0-arch.c +++ b/arch/cpu/cc13xx-cc26xx/dev/uart0-arch.c @@ -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,16 +82,18 @@ 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); - 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.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; /* No error handling. */ diff --git a/arch/cpu/cc13xx-cc26xx/dev/uart0-arch.h b/arch/cpu/cc13xx-cc26xx/dev/uart0-arch.h index 68b7a18c5..17a93519a 100644 --- a/arch/cpu/cc13xx-cc26xx/dev/uart0-arch.h +++ b/arch/cpu/cc13xx-cc26xx/dev/uart0-arch.h @@ -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 diff --git a/arch/cpu/cc13xx-cc26xx/dev/watchdog-arch.c b/arch/cpu/cc13xx-cc26xx/dev/watchdog-arch.c index 825b835bf..6cba086b4 100644 --- a/arch/cpu/cc13xx-cc26xx/dev/watchdog-arch.c +++ b/arch/cpu/cc13xx-cc26xx/dev/watchdog-arch.c @@ -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 * @{ * @@ -76,7 +76,7 @@ watchdog_init(void) Watchdog_Params wdt_params; Watchdog_Params_init(&wdt_params); - wdt_params.resetMode = Watchdog_RESET_ON; + wdt_params.resetMode = Watchdog_RESET_ON; wdt_params.debugStallMode = Watchdog_DEBUG_STALL_ON; wdt_handle = Watchdog_open(Board_WATCHDOG0, &wdt_params); @@ -133,7 +133,9 @@ watchdog_reboot(void) } watchdog_start(); - while(1); + + /* Busy loop until watchdog times out */ + for (;;) { /* hang */ } } /*---------------------------------------------------------------------------*/ /** diff --git a/arch/cpu/cc13xx-cc26xx/rf/ble-addr.c b/arch/cpu/cc13xx-cc26xx/rf/ble-addr.c index d4753e1a5..357e7e7c5 100644 --- a/arch/cpu/cc13xx-cc26xx/rf/ble-addr.c +++ b/arch/cpu/cc13xx-cc26xx/rf/ble-addr.c @@ -52,13 +52,13 @@ #include /*---------------------------------------------------------------------------*/ #define BLE_MAC_PRIMARY_ADDRESS (FCFG1_BASE + FCFG1_O_MAC_BLE_0) -#define BLE_MAC_SECONDARY_ADDRESS (CCFG_BASE + CCFG_O_IEEE_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 diff --git a/arch/cpu/cc13xx-cc26xx/rf/ble-addr.h b/arch/cpu/cc13xx-cc26xx/rf/ble-addr.h index 0b4028269..7fb45b1f2 100644 --- a/arch/cpu/cc13xx-cc26xx/rf/ble-addr.h +++ b/arch/cpu/cc13xx-cc26xx/rf/ble-addr.h @@ -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 diff --git a/arch/cpu/cc13xx-cc26xx/rf/ble-beacond.c b/arch/cpu/cc13xx-cc26xx/rf/ble-beacond.c index 22b1a9658..79c0f4e62 100644 --- a/arch/cpu/cc13xx-cc26xx/rf/ble-beacond.c +++ b/arch/cpu/cc13xx-cc26xx/rf/ble-beacond.c @@ -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 */ /*---------------------------------------------------------------------------*/ /** @} */ diff --git a/arch/cpu/cc13xx-cc26xx/rf/data-queue.c b/arch/cpu/cc13xx-cc26xx/rf/data-queue.c index 27e383557..a5f03a8d7 100644 --- a/arch/cpu/cc13xx-cc26xx/rf/data-queue.c +++ b/arch/cpu/cc13xx-cc26xx/rf/data-queue.c @@ -39,13 +39,13 @@ /*---------------------------------------------------------------------------*/ #include "contiki.h" #include "sys/cc.h" - -#include "rf/data-queue.h" /*---------------------------------------------------------------------------*/ #include #include DeviceFamily_constructPath(driverlib/rf_mailbox.h) #include DeviceFamily_constructPath(driverlib/rf_data_entry.h) /*---------------------------------------------------------------------------*/ +#include "rf/data-queue.h" +/*---------------------------------------------------------------------------*/ #include #include #include @@ -57,18 +57,18 @@ /* Receive buffer entries with room for 1 IEEE 802.15.4 frame in each */ typedef union { data_entry_t data_entry; - uint8_t buf[RX_BUF_SIZE]; -} rx_buf_t CC_ALIGN(4); + uint8_t buf[RX_BUF_SIZE]; +} rx_buf_t CC_ALIGN (4); /*---------------------------------------------------------------------------*/ typedef struct { /* RX bufs */ - rx_buf_t bufs[RX_BUF_CNT]; + rx_buf_t bufs[RX_BUF_CNT]; /* RFC data queue object */ - data_queue_t data_queue; + 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; + size_t lensz; } rx_data_queue_t; static rx_data_queue_t rx_data_queue; @@ -82,14 +82,14 @@ rx_bufs_init(void) for(i = 0; i < RX_BUF_CNT; ++i) { data_entry = &(rx_data_queue.bufs[i].data_entry); - data_entry->status = DATA_ENTRY_PENDING; - data_entry->config.type = DATA_ENTRY_TYPE_GEN; + 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) + 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); } /*---------------------------------------------------------------------------*/ /** @} */ diff --git a/arch/cpu/cc13xx-cc26xx/rf/data-queue.h b/arch/cpu/cc13xx-cc26xx/rf/data-queue.h index c0b6913a8..049cf78d1 100644 --- a/arch/cpu/cc13xx-cc26xx/rf/data-queue.h +++ b/arch/cpu/cc13xx-cc26xx/rf/data-queue.h @@ -52,12 +52,12 @@ /*---------------------------------------------------------------------------*/ #include /*---------------------------------------------------------------------------*/ -typedef dataQueue_t data_queue_t; +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_ */ diff --git a/arch/cpu/cc13xx-cc26xx/rf/ieee-addr.c b/arch/cpu/cc13xx-cc26xx/rf/ieee-addr.c index bdea2782e..4ce39a241 100644 --- a/arch/cpu/cc13xx-cc26xx/rf/ieee-addr.c +++ b/arch/cpu/cc13xx-cc26xx/rf/ieee-addr.c @@ -54,7 +54,7 @@ #define IEEE_ADDR_ADDRESS IEEE_ADDR_CONF_ADDRESS /*---------------------------------------------------------------------------*/ #define IEEE_MAC_PRIMARY_ADDRESS (FCFG1_BASE + FCFG1_O_MAC_15_4_0) -#define IEEE_MAC_SECONDARY_ADDRESS (CCFG_BASE + CCFG_O_IEEE_MAC_0) +#define IEEE_MAC_SECONDARY_ADDRESS (CCFG_BASE + CCFG_O_IEEE_MAC_0) /*---------------------------------------------------------------------------*/ int ieee_addr_cpy_to(uint8_t *dst, uint8_t len) @@ -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; diff --git a/arch/cpu/cc13xx-cc26xx/rf/ieee-mode.c b/arch/cpu/cc13xx-cc26xx/rf/ieee-mode.c index ef7408b21..5f4a54982 100644 --- a/arch/cpu/cc13xx-cc26xx/rf/ieee-mode.c +++ b/arch/cpu/cc13xx-cc26xx/rf/ieee-mode.c @@ -118,53 +118,53 @@ #define TX_BUF_SIZE 180 /*---------------------------------------------------------------------------*/ /* Size of the Length representation in Data Entry, one byte in this case */ -typedef uint8_t lensz_t; +typedef uint8_t lensz_t; #define FRAME_OFFSET sizeof(lensz_t) #define FRAME_SHAVE 8 /* FCS (2) + RSSI (1) + Status (1) + Timestamp (4) */ /*---------------------------------------------------------------------------*/ /* Used for checking result of CCA_REQ command */ typedef enum { - CCA_STATE_IDLE = 0, - CCA_STATE_BUSY = 1, + CCA_STATE_IDLE = 0, + CCA_STATE_BUSY = 1, CCA_STATE_INVALID = 2 } cca_state_t; /*---------------------------------------------------------------------------*/ /* RF Core typedefs */ -typedef rfc_ieeeRxOutput_t rx_output_t; +typedef rfc_ieeeRxOutput_t rx_output_t; typedef rfc_CMD_IEEE_MOD_FILT_t cmd_mod_filt_t; -typedef rfc_CMD_IEEE_CCA_REQ_t cmd_cca_req_t; +typedef rfc_CMD_IEEE_CCA_REQ_t cmd_cca_req_t; typedef struct { /* Outgoing frame buffer */ - uint8_t tx_buf[TX_BUF_SIZE] CC_ALIGN(4); + uint8_t tx_buf[TX_BUF_SIZE] CC_ALIGN(4); /* RF Statistics struct */ - rx_output_t rx_stats; + rx_output_t rx_stats; /* Indicates RF is supposed to be on or off */ - bool rf_is_on; + bool rf_is_on; /* Enable/disable CCA before sending */ - bool send_on_cca; + bool send_on_cca; /* Are we currently in poll mode? */ - bool poll_mode; + bool poll_mode; /* Last RX operation stats */ struct { - int8_t rssi; - uint8_t corr_lqi; - uint32_t timestamp; + int8_t rssi; + uint8_t corr_lqi; + uint32_t timestamp; } last; /* RAT Overflow Upkeep */ struct { - struct ctimer overflow_timer; - rtimer_clock_t last_overflow; + struct ctimer overflow_timer; + rtimer_clock_t last_overflow; volatile uint32_t overflow_count; } rat; /* RF driver */ - RF_Handle rf_handle; + RF_Handle rf_handle; } ieee_radio_t; static ieee_radio_t ieee_radio; @@ -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) @@ -219,7 +219,7 @@ init_rf_params(void) { data_queue_t *rx_q = data_queue_init(sizeof(lensz_t)); - cmd_rx.pRxQ = rx_q; + cmd_rx.pRxQ = rx_q; cmd_rx.pOutput = &ieee_radio.rx_stats; #if IEEE_MODE_PROMISCOUS @@ -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 */ /* @@ -248,13 +248,13 @@ init_rf_params(void) * of 11 bytes. 11 bytes x 32 us/byte equals 352 us of ACK transmission time. */ cmd_rx_ack.startTrigger.triggerType = TRIG_NOW; - cmd_rx_ack.endTrigger.triggerType = TRIG_REL_START; + cmd_rx_ack.endTrigger.triggerType = TRIG_REL_START; cmd_rx_ack.endTime = RF_convertUsToRatTicks(700); /* Initialize address filter command */ cmd_mod_filt.commandNo = CMD_IEEE_MOD_FILT; memcpy(&(cmd_mod_filt.newFrameFiltOpt), &(rf_cmd_ieee_rx.frameFiltOpt), sizeof(rf_cmd_ieee_rx.frameFiltOpt)); - memcpy(&(cmd_mod_filt.newFrameTypes), &(rf_cmd_ieee_rx.frameTypes), sizeof(rf_cmd_ieee_rx.frameTypes)); + memcpy(&(cmd_mod_filt.newFrameTypes), &(rf_cmd_ieee_rx.frameTypes), sizeof(rf_cmd_ieee_rx.frameTypes)); } /*---------------------------------------------------------------------------*/ static rf_result_t @@ -279,11 +279,11 @@ set_channel(uint8_t channel) cmd_rx.channel = channel; const uint32_t new_freq = dot_15_4g_freq(channel); - const uint16_t freq = (uint16_t)(new_freq / 1000); - const uint16_t frac = (uint16_t)(((new_freq - (freq * 1000)) * 0x10000) / 1000); + const uint16_t freq = (uint16_t)(new_freq / 1000); + const uint16_t frac = (uint16_t)(((new_freq - (freq * 1000)) * 0x10000) / 1000); LOG_DBG("Set channel to %d, frequency 0x%04X.0x%04X (%lu)\n", - (int)channel, freq, frac, new_freq); + (int)channel, freq, frac, new_freq); cmd_fs.frequency = freq; cmd_fs.fractFreq = frac; @@ -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,14 +532,14 @@ 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) { /* Not in poll mode: packetbuf should not be accessed in interrupt context. */ /* In poll mode, the last packet RSSI and link quality can be obtained through */ /* RADIO_PARAM_LAST_RSSI and RADIO_PARAM_LAST_LINK_QUALITY */ - packetbuf_set_attr(PACKETBUF_ATTR_RSSI, (packetbuf_attr_t)ieee_radio.last.rssi); + packetbuf_set_attr(PACKETBUF_ATTR_RSSI, (packetbuf_attr_t)ieee_radio.last.rssi); packetbuf_set_attr(PACKETBUF_ATTR_LINK_QUALITY, (packetbuf_attr_t)ieee_radio.last.corr_lqi); } @@ -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,18 +848,19 @@ 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; } - cmd_rx.frameFiltOpt.frameFiltEn = (value & RADIO_RX_MODE_ADDRESS_FILTER) != 0; - cmd_rx.frameFiltOpt.frameFiltStop = 1; - cmd_rx.frameFiltOpt.autoAckEn = (value & RADIO_RX_MODE_AUTOACK) != 0; - cmd_rx.frameFiltOpt.slottedAckEn = 0; - cmd_rx.frameFiltOpt.autoPendEn = 0; - cmd_rx.frameFiltOpt.defaultPend = 0; + cmd_rx.frameFiltOpt.frameFiltEn = (value & RADIO_RX_MODE_ADDRESS_FILTER) != 0; + cmd_rx.frameFiltOpt.frameFiltStop = 1; + cmd_rx.frameFiltOpt.autoAckEn = (value & RADIO_RX_MODE_AUTOACK) != 0; + cmd_rx.frameFiltOpt.slottedAckEn = 0; + cmd_rx.frameFiltOpt.autoPendEn = 0; + cmd_rx.frameFiltOpt.defaultPend = 0; cmd_rx.frameFiltOpt.bPendDataReqOnly = 0; - cmd_rx.frameFiltOpt.bPanCoord = 0; + cmd_rx.frameFiltOpt.bPanCoord = 0; cmd_rx.frameFiltOpt.bStrictLenFilter = 0; const bool old_poll_mode = ieee_radio.poll_mode; @@ -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; diff --git a/arch/cpu/cc13xx-cc26xx/rf/prop-mode.c b/arch/cpu/cc13xx-cc26xx/rf/prop-mode.c index 7aa906a3a..76475d154 100644 --- a/arch/cpu/cc13xx-cc26xx/rf/prop-mode.c +++ b/arch/cpu/cc13xx-cc26xx/rf/prop-mode.c @@ -79,14 +79,16 @@ #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 */ typedef enum { - CCA_STATE_IDLE = 0, - CCA_STATE_BUSY = 1, + CCA_STATE_IDLE = 0, + CCA_STATE_BUSY = 1, CCA_STATE_INVALID = 2 } cca_state_t; /*---------------------------------------------------------------------------*/ @@ -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 @@ -127,7 +129,7 @@ typedef enum { #define TX_BUF_SIZE (TX_BUF_HDR_LEN + TX_BUF_PAYLOAD_LEN) /*---------------------------------------------------------------------------*/ /* Size of the Length field in Data Entry, two bytes in this case */ -typedef uint16_t lensz_t; +typedef uint16_t lensz_t; #define FRAME_OFFSET sizeof(lensz_t) #define FRAME_SHAVE 2 /**< RSSI (1) + Status (1) */ @@ -142,24 +144,24 @@ typedef uint16_t lensz_t; #define ED_RF_POWER_MAX_DBM RX_SATURATION_DBM /*---------------------------------------------------------------------------*/ /* RF Core typedefs */ -typedef rfc_propRxOutput_t rx_output_t; +typedef rfc_propRxOutput_t rx_output_t; typedef struct { /* Outgoing frame buffer */ - uint8_t tx_buf[TX_BUF_SIZE] CC_ALIGN(4); + uint8_t tx_buf[TX_BUF_SIZE] CC_ALIGN(4); /* RX Statistics struct */ rx_output_t rx_stats; /* RSSI Threshold */ - int8_t rssi_threshold; - uint16_t channel; + int8_t rssi_threshold; + uint16_t channel; /* Indicates RF is supposed to be on or off */ - uint8_t rf_is_on; + uint8_t rf_is_on; /* RF driver */ - RF_Handle rf_handle; + RF_Handle rf_handle; } prop_radio_t; static prop_radio_t prop_radio; @@ -188,14 +190,14 @@ 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)); cmd_rx.maxPktLen = DOT_4G_MAX_FRAME_LEN - cmd_rx.lenOffset; - cmd_rx.pQueue = data_queue; - cmd_rx.pOutput = (uint8_t *)&prop_radio.rx_stats; + cmd_rx.pQueue = data_queue; + cmd_rx.pOutput = (uint8_t *)&prop_radio.rx_stats; } /*---------------------------------------------------------------------------*/ static int8_t @@ -265,7 +267,7 @@ set_channel(uint16_t channel) const uint16_t frac = (uint16_t)(((new_freq - (freq * 1000)) * 0x10000) / 1000); LOG_DBG("Set channel to %d, frequency 0x%04X.0x%04X (%lu)\n", - (int)channel, freq, frac, new_freq); + (int)channel, freq, frac, new_freq); cmd_fs.frequency = freq; cmd_fs.fractFreq = frac; @@ -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) { @@ -417,7 +419,7 @@ read(void *buf, unsigned short buf_len) /* LQI calculated from RSSI */ const uint8_t lqi = calculate_lqi(rssi); - packetbuf_set_attr(PACKETBUF_ATTR_RSSI, (packetbuf_attr_t)rssi); + packetbuf_set_attr(PACKETBUF_ATTR_RSSI, (packetbuf_attr_t)rssi); packetbuf_set_attr(PACKETBUF_ATTR_LINK_QUALITY, (packetbuf_attr_t)lqi); data_queue_release_entry(); @@ -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 @@ -663,7 +665,7 @@ init(void) init_rf_params(); /* Init RF params and specify non-default params */ - RF_Params rf_params; + RF_Params rf_params; RF_Params_init(&rf_params); rf_params.nInactivityTimeout = 2000; /* 2 ms */ diff --git a/arch/cpu/cc13xx-cc26xx/rf/rf.h b/arch/cpu/cc13xx-cc26xx/rf/rf.h index a0c38513f..cfc6b2277 100644 --- a/arch/cpu/cc13xx-cc26xx/rf/rf.h +++ b/arch/cpu/cc13xx-cc26xx/rf/rf.h @@ -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_ */ diff --git a/arch/cpu/cc13xx-cc26xx/rf/sched.c b/arch/cpu/cc13xx-cc26xx/rf/sched.c index 73957e33b..44387c138 100644 --- a/arch/cpu/cc13xx-cc26xx/rf/sched.c +++ b/arch/cpu/cc13xx-cc26xx/rf/sched.c @@ -72,7 +72,7 @@ /*---------------------------------------------------------------------------*/ #define CMD_FS_RETRIES 3 -#define RF_EVENTS_CMD_DONE (RF_EventCmdDone | RF_EventLastCmdDone | \ +#define RF_EVENTS_CMD_DONE (RF_EventCmdDone | RF_EventLastCmdDone | \ RF_EventFGCmdDone | RF_EventLastFGCmdDone) #define CMD_STATUS(cmd) (CC_ACCESS_NOW(RF_Op, cmd).status) @@ -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 @@ -165,22 +165,22 @@ cmd_rx_restore(uint_fast8_t rx_key) RF_ScheduleCmdParams sched_params; RF_ScheduleCmdParams_init(&sched_params); - sched_params.priority = RF_PriorityNormal; - sched_params.endTime = 0; + sched_params.priority = RF_PriorityNormal; + sched_params.endTime = 0; sched_params.allowDelay = RF_AllowDelayAny; CMD_STATUS(netstack_cmd_rx) = PENDING; - cmd_rx_handle = RF_scheduleCmd(&rf_netstack, - (RF_Op*)&netstack_cmd_rx, - &sched_params, - cmd_rx_cb, - RF_EventRxEntryDone | RF_EventRxBufFull - ); + cmd_rx_handle = RF_scheduleCmd( + &rf_netstack, + (RF_Op *)&netstack_cmd_rx, + &sched_params, + cmd_rx_cb, + RF_EventRxEntryDone | RF_EventRxBufFull); if(!CMD_HANDLE_OK(cmd_rx_handle)) { LOG_ERR("Unable to restore RX command, handle=%d status=0x%04x", - cmd_rx_handle, CMD_STATUS(netstack_cmd_rx)); + cmd_rx_handle, CMD_STATUS(netstack_cmd_rx)); return RF_RESULT_ERROR; } @@ -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 - RF_flushCmd(&rf_ble, RF_CMDHANDLE_FLUSH_ALL, RF_ABORT_GRACEFULLY); +#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, - RF_PriorityNormal, - NULL, - 0 - ); + events = RF_runCmd( + &rf_netstack, + (RF_Op *)&netstack_cmd_fs, + RF_PriorityNormal, + NULL, + 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); @@ -297,8 +289,8 @@ netstack_sched_ieee_tx(bool ack_request) RF_ScheduleCmdParams sched_params; RF_ScheduleCmdParams_init(&sched_params); - sched_params.priority = RF_PriorityNormal; - sched_params.endTime = 0; + sched_params.priority = RF_PriorityNormal; + sched_params.endTime = 0; sched_params.allowDelay = RF_AllowDelayAny; const bool rx_is_active = cmd_rx_is_active(); @@ -318,16 +310,16 @@ 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, - &sched_params, - NULL, - 0 - ); + RF_CmdHandle tx_handle = RF_scheduleCmd( + &rf_netstack, + (RF_Op *)&netstack_cmd_tx, + &sched_params, + NULL, + 0); if(!CMD_HANDLE_OK(tx_handle)) { LOG_ERR("Unable to schedule TX command, handle=%d status=0x%04x\n", - tx_handle, CMD_STATUS(netstack_cmd_tx)); + tx_handle, CMD_STATUS(netstack_cmd_tx)); return RF_RESULT_ERROR; } @@ -353,7 +345,7 @@ netstack_sched_ieee_tx(bool ack_request) if(!EVENTS_CMD_DONE(tx_events)) { LOG_ERR("Pending on TX comand generated error, events=0x%08llx status=0x%04x\n", - tx_events, CMD_STATUS(netstack_cmd_tx)); + tx_events, CMD_STATUS(netstack_cmd_tx)); return RF_RESULT_ERROR; } @@ -366,18 +358,18 @@ netstack_sched_prop_tx(void) RF_ScheduleCmdParams sched_params; RF_ScheduleCmdParams_init(&sched_params); - sched_params.priority = RF_PriorityNormal; - sched_params.endTime = 0; + sched_params.priority = RF_PriorityNormal; + sched_params.endTime = 0; sched_params.allowDelay = RF_AllowDelayAny; CMD_STATUS(netstack_cmd_tx) = PENDING; - RF_CmdHandle tx_handle = RF_scheduleCmd(&rf_netstack, - (RF_Op*)&netstack_cmd_tx, - &sched_params, - NULL, - 0 - ); + RF_CmdHandle tx_handle = RF_scheduleCmd( + &rf_netstack, + (RF_Op *)&netstack_cmd_tx, + &sched_params, + NULL, + 0); if(!CMD_HANDLE_OK(tx_handle)) { LOG_ERR("Unable to schedule TX command, handle=%d status=0x%04x\n", @@ -428,18 +420,18 @@ netstack_sched_rx(bool start) RF_ScheduleCmdParams sched_params; RF_ScheduleCmdParams_init(&sched_params); - sched_params.priority = RF_PriorityNormal; - sched_params.endTime = 0; + sched_params.priority = RF_PriorityNormal; + sched_params.endTime = 0; sched_params.allowDelay = RF_AllowDelayAny; CMD_STATUS(netstack_cmd_rx) = PENDING; - cmd_rx_handle = RF_scheduleCmd(&rf_netstack, - (RF_Op*)&netstack_cmd_rx, - &sched_params, - cmd_rx_cb, - RF_EventRxEntryDone | RF_EventRxBufFull - ); + cmd_rx_handle = RF_scheduleCmd( + &rf_netstack, + (RF_Op *)&netstack_cmd_rx, + &sched_params, + cmd_rx_cb, + 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,22 +482,22 @@ 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); - sched_params.priority = RF_PriorityNormal; - sched_params.endTime = 0; + sched_params.priority = RF_PriorityNormal; + sched_params.endTime = 0; sched_params.allowDelay = RF_AllowDelayAny; CMD_STATUS(ble_cmd_beacon) = PENDING; - RF_CmdHandle beacon_handle = RF_scheduleCmd(&rf_ble, - (RF_Op*)&ble_cmd_beacon, - &sched_params, - cb, - bm_event - ); + RF_CmdHandle beacon_handle = RF_scheduleCmd( + &rf_ble, + (RF_Op *)&ble_cmd_beacon, + &sched_params, + cb, + bm_event); if(!CMD_HANDLE_OK(beacon_handle)) { LOG_ERR("Unable to schedule BLE Beacon command, handle=%d status=0x%04x\n", diff --git a/arch/cpu/cc13xx-cc26xx/rf/settings.h b/arch/cpu/cc13xx-cc26xx/rf/settings.h index 4d8df6d23..0f4da3376 100644 --- a/arch/cpu/cc13xx-cc26xx/rf/settings.h +++ b/arch/cpu/cc13xx-cc26xx/rf/settings.h @@ -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 * @{ * diff --git a/arch/cpu/cc13xx-cc26xx/rf/tx-power.h b/arch/cpu/cc13xx-cc26xx/rf/tx-power.h index a6104275e..91bab7d6b 100644 --- a/arch/cpu/cc13xx-cc26xx/rf/tx-power.h +++ b/arch/cpu/cc13xx-cc26xx/rf/tx-power.h @@ -81,20 +81,18 @@ extern const size_t ble_tx_power_table_size; static inline int8_t tx_power_min(tx_power_table_t *table) { - return table[0].power; + return table[0].power; } - static inline int8_t tx_power_max(tx_power_table_t *table, size_t size) { - return table[size - 1].power; + return table[size - 1].power; } - static inline bool tx_power_in_range(int8_t dbm, tx_power_table_t *table, size_t size) { - return (dbm >= tx_power_min(table)) && - (dbm <= tx_power_max(table, size)); + return (dbm >= tx_power_min(table)) && + (dbm <= tx_power_max(table, size)); } /** @} */ /*---------------------------------------------------------------------------*/ diff --git a/arch/platform/simplelink/cc13xx-cc26xx/platform.c b/arch/platform/simplelink/cc13xx-cc26xx/platform.c index bf295e762..50b8ad2c8 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/platform.c +++ b/arch/platform/simplelink/cc13xx-cc26xx/platform.c @@ -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 @@ -236,12 +240,12 @@ platform_init_stage_three(void) DRIVERLIB_RELEASE_BUILD); LOG_DBG("IEEE 802.15.4: %s, Sub-1 GHz: %s, BLE: %s\n", ChipInfo_SupportsIEEE_802_15_4() ? "Yes" : "No", - ChipInfo_SupportsPROPRIETARY() ? "Yes" : "No", - ChipInfo_SupportsBLE() ? "Yes" : "No"); + 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); diff --git a/arch/platform/simplelink/cc13xx-cc26xx/sensortag/bmp-280-sensor.c b/arch/platform/simplelink/cc13xx-cc26xx/sensortag/bmp-280-sensor.c index 830506fac..7c6b0f2f1 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/sensortag/bmp-280-sensor.c +++ b/arch/platform/simplelink/cc13xx-cc26xx/sensortag/bmp-280-sensor.c @@ -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 @@ -122,17 +122,17 @@ /*---------------------------------------------------------------------------*/ typedef struct { uint16_t dig_t1; - int16_t dig_t2; - int16_t dig_t3; + int16_t dig_t2; + int16_t dig_t3; uint16_t dig_p1; - int16_t dig_p2; - int16_t dig_p3; - int16_t dig_p4; - int16_t dig_p5; - int16_t dig_p6; - int16_t dig_p7; - int16_t dig_p8; - int16_t dig_p9; + int16_t dig_p2; + int16_t dig_p3; + int16_t dig_p4; + int16_t dig_p5; + int16_t dig_p6; + int16_t dig_p7; + int16_t dig_p8; + int16_t dig_p9; } BMP_280_Calibration; /*---------------------------------------------------------------------------*/ static BMP_280_Calibration calib_data; @@ -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) /*---------------------------------------------------------------------------*/ @@ -209,8 +208,8 @@ init(void) uint8_t calib_reg = ADDR_CALIB; /* Read and store calibration data */ return i2c_write_read(&calib_reg, sizeof(calib_reg), &calib_data, sizeof(calib_data)) - /* then reset the sensor */ - && i2c_write(reset_data, sizeof(reset_data)); + /* then reset the sensor */ + && i2c_write(reset_data, sizeof(reset_data)); } /*---------------------------------------------------------------------------*/ /** @@ -264,30 +263,20 @@ convert(uint8_t *data, int32_t *temp, uint32_t *press) /* Pressure */ const int32_t upress = (int32_t)( - (((uint32_t)data[0]) << 12) | - (((uint32_t)data[1]) << 4) | - (((uint32_t)data[2]) >> 4) - ); + (((uint32_t)data[0]) << 12) | + (((uint32_t)data[1]) << 4) | + (((uint32_t)data[2]) >> 4) + ); /* Temperature */ const int32_t utemp = (int32_t)( - (((uint32_t)data[3]) << 12) | - (((uint32_t)data[4]) << 4) | - (((uint32_t)data[5]) >> 4) - ); + (((uint32_t)data[3]) << 12) | + (((uint32_t)data[4]) << 4) | + (((uint32_t)data[5]) >> 4) + ); /* 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; } diff --git a/arch/platform/simplelink/cc13xx-cc26xx/sensortag/bmp-280-sensor.h b/arch/platform/simplelink/cc13xx-cc26xx/sensortag/bmp-280-sensor.h index f2c160947..02b2034b1 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/sensortag/bmp-280-sensor.h +++ b/arch/platform/simplelink/cc13xx-cc26xx/sensortag/bmp-280-sensor.h @@ -64,13 +64,13 @@ /* 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 /*---------------------------------------------------------------------------*/ typedef enum { - BMP_280_SENSOR_TYPE_TEMP, - BMP_280_SENSOR_TYPE_PRESS + BMP_280_SENSOR_TYPE_TEMP, + BMP_280_SENSOR_TYPE_PRESS } BMP_280_SENSOR_TYPE; /*---------------------------------------------------------------------------*/ #define BMP_280_READING_ERROR -1 diff --git a/arch/platform/simplelink/cc13xx-cc26xx/sensortag/buzzer.c b/arch/platform/simplelink/cc13xx-cc26xx/sensortag/buzzer.c index 84d760278..1815a370d 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/sensortag/buzzer.c +++ b/arch/platform/simplelink/cc13xx-cc26xx/sensortag/buzzer.c @@ -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); diff --git a/arch/platform/simplelink/cc13xx-cc26xx/sensortag/hdc-1000-sensor.c b/arch/platform/simplelink/cc13xx-cc26xx/sensortag/hdc-1000-sensor.c index 2f3e6fa6e..85840605d 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/sensortag/hdc-1000-sensor.c +++ b/arch/platform/simplelink/cc13xx-cc26xx/sensortag/hdc-1000-sensor.c @@ -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 @@ -136,16 +136,15 @@ static bool i2c_write_read(void *wbuf, size_t wcount, void *rbuf, size_t rcount) { I2C_Transaction i2c_transaction = { - .writeBuf = wbuf, - .writeCount = wcount, - .readBuf = rbuf, - .readCount = rcount, + .writeBuf = wbuf, + .writeCount = wcount, + .readBuf = rbuf, + .readCount = rcount, .slaveAddress = HDC1000_I2C_ADDRESS, }; 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)); diff --git a/arch/platform/simplelink/cc13xx-cc26xx/sensortag/hdc-1000-sensor.h b/arch/platform/simplelink/cc13xx-cc26xx/sensortag/hdc-1000-sensor.h index b6bd7ca4f..4dcab02c2 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/sensortag/hdc-1000-sensor.h +++ b/arch/platform/simplelink/cc13xx-cc26xx/sensortag/hdc-1000-sensor.h @@ -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 /*---------------------------------------------------------------------------*/ diff --git a/arch/platform/simplelink/cc13xx-cc26xx/sensortag/mpu-9250-sensor.c b/arch/platform/simplelink/cc13xx-cc26xx/sensortag/mpu-9250-sensor.c index f849c6735..825a4043c 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/sensortag/mpu-9250-sensor.c +++ b/arch/platform/simplelink/cc13xx-cc26xx/sensortag/mpu-9250-sensor.c @@ -47,7 +47,7 @@ #include #include -#include DeviceFamily_constructPath(driverlib/cpu.h) +#include DeviceFamily_constructPath(driverlib / cpu.h) #include #include @@ -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 */ @@ -190,20 +190,20 @@ #define BIT_STBY_XYZG (BIT_STBY_XG | BIT_STBY_YG | BIT_STBY_ZG) /*---------------------------------------------------------------------------*/ static PIN_Config mpu_9250_pin_table[] = { - Board_MPU_INT | PIN_INPUT_EN | PIN_PULLDOWN | PIN_HYSTERESIS, + Board_MPU_INT | PIN_INPUT_EN | PIN_PULLDOWN | PIN_HYSTERESIS, Board_MPU_POWER | PIN_GPIO_OUTPUT_EN | PIN_DRVSTR_MAX | PIN_GPIO_LOW, PIN_TERMINATE }; -static PIN_State pin_state; +static PIN_State pin_state; static PIN_Handle pin_handle; static I2C_Handle i2c_handle; /*---------------------------------------------------------------------------*/ typedef struct { - volatile MPU_9250_SENSOR_STATUS status; - volatile MPU_9250_SENSOR_TYPE type; - MPU_9250_SENSOR_ACC_RANGE acc_range; + volatile MPU_9250_SENSOR_STATUS status; + volatile MPU_9250_SENSOR_TYPE type; + MPU_9250_SENSOR_ACC_RANGE acc_range; } MPU_9250_Object; static MPU_9250_Object mpu_9250; @@ -247,16 +247,15 @@ static bool i2c_write_read(void *wbuf, size_t wcount, void *rbuf, size_t rcount) { I2C_Transaction i2c_transaction = { - .writeBuf = wbuf, - .writeCount = wcount, - .readBuf = rbuf, - .readCount = rcount, + .writeBuf = wbuf, + .writeCount = wcount, + .readBuf = rbuf, + .readCount = rcount, .slaveAddress = MPU_9250_I2C_ADDRESS, }; 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; } @@ -455,9 +453,9 @@ static int32_t acc_convert(int32_t raw_data) { switch(mpu_9250.acc_range) { - case MPU_9250_SENSOR_ACC_RANGE_2G: return raw_data * 100 * 2 / 32768; - case MPU_9250_SENSOR_ACC_RANGE_4G: return raw_data * 100 * 4 / 32768; - case MPU_9250_SENSOR_ACC_RANGE_8G: return raw_data * 100 * 8 / 32768; + case MPU_9250_SENSOR_ACC_RANGE_2G: return raw_data * 100 * 2 / 32768; + case MPU_9250_SENSOR_ACC_RANGE_4G: return raw_data * 100 * 4 / 32768; + case MPU_9250_SENSOR_ACC_RANGE_8G: return raw_data * 100 * 8 / 32768; case MPU_9250_SENSOR_ACC_RANGE_16G: return raw_data * 100 * 16 / 32768; } return 0; @@ -555,7 +553,7 @@ value(int type) default: return MPU_9250_READING_ERROR; } - /* Read gyro data */ + /* Read gyro data */ } else if((type & MPU_9250_SENSOR_TYPE_GYRO) != 0) { if(!gyro_read(int_status, sensor_value)) { @@ -573,7 +571,7 @@ value(int type) default: return MPU_9250_READING_ERROR; } - /* Invalid sensor type */ + /* Invalid sensor type */ } else { PRINTF("MPU: Invalid type\n"); return MPU_9250_READING_ERROR; @@ -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) { diff --git a/arch/platform/simplelink/cc13xx-cc26xx/sensortag/mpu-9250-sensor.h b/arch/platform/simplelink/cc13xx-cc26xx/sensortag/mpu-9250-sensor.h index 846e6beb2..d66e91977 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/sensortag/mpu-9250-sensor.h +++ b/arch/platform/simplelink/cc13xx-cc26xx/sensortag/mpu-9250-sensor.h @@ -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 /*---------------------------------------------------------------------------*/ @@ -87,31 +87,31 @@ /*---------------------------------------------------------------------------*/ /* Accelerometer / Gyro Axes */ typedef enum { - MPU_9250_SENSOR_TYPE_NONE = (0), /**< 0b000000 = 0x00 */ + MPU_9250_SENSOR_TYPE_NONE = (0), /**< 0b000000 = 0x00 */ MPU_9250_SENSOR_TYPE_GYRO_X = (1 << 0), /**< 0b000001 = 0x01 */ MPU_9250_SENSOR_TYPE_GYRO_Y = (1 << 1), /**< 0b000010 = 0x02 */ MPU_9250_SENSOR_TYPE_GYRO_Z = (1 << 2), /**< 0b000100 = 0x04 */ - MPU_9250_SENSOR_TYPE_ACC_X = (1 << 3), /**< 0b001000 = 0x08 */ - MPU_9250_SENSOR_TYPE_ACC_Y = (1 << 4), /**< 0b010000 = 0x10 */ - MPU_9250_SENSOR_TYPE_ACC_Z = (1 << 5), /**< 0b100000 = 0x20 */ - MPU_9250_SENSOR_TYPE_GYRO = MPU_9250_SENSOR_TYPE_GYRO_X - | MPU_9250_SENSOR_TYPE_GYRO_Y - | MPU_9250_SENSOR_TYPE_GYRO_Z, - /**< 0b000111 = 0x07 */ - MPU_9250_SENSOR_TYPE_ACC = MPU_9250_SENSOR_TYPE_ACC_X - | MPU_9250_SENSOR_TYPE_ACC_Y - | MPU_9250_SENSOR_TYPE_ACC_Z, - /**< 0b111000 = 0x38 */ - MPU_9250_SENSOR_TYPE_ALL = MPU_9250_SENSOR_TYPE_GYRO - | MPU_9250_SENSOR_TYPE_ACC - /**< 0b111111 = 0x3F */ + MPU_9250_SENSOR_TYPE_ACC_X = (1 << 3), /**< 0b001000 = 0x08 */ + MPU_9250_SENSOR_TYPE_ACC_Y = (1 << 4), /**< 0b010000 = 0x10 */ + MPU_9250_SENSOR_TYPE_ACC_Z = (1 << 5), /**< 0b100000 = 0x20 */ + MPU_9250_SENSOR_TYPE_GYRO = MPU_9250_SENSOR_TYPE_GYRO_X + | MPU_9250_SENSOR_TYPE_GYRO_Y + | MPU_9250_SENSOR_TYPE_GYRO_Z, + /**< 0b000111 = 0x07 */ + MPU_9250_SENSOR_TYPE_ACC = MPU_9250_SENSOR_TYPE_ACC_X + | MPU_9250_SENSOR_TYPE_ACC_Y + | MPU_9250_SENSOR_TYPE_ACC_Z, + /**< 0b111000 = 0x38 */ + MPU_9250_SENSOR_TYPE_ALL = MPU_9250_SENSOR_TYPE_GYRO + | MPU_9250_SENSOR_TYPE_ACC + /**< 0b111111 = 0x3F */ } MPU_9250_SENSOR_TYPE; /*---------------------------------------------------------------------------*/ /* Accelerometer range */ typedef enum { - MPU_9250_SENSOR_ACC_RANGE_2G = 0, - MPU_9250_SENSOR_ACC_RANGE_4G = 1, - MPU_9250_SENSOR_ACC_RANGE_8G = 2, + MPU_9250_SENSOR_ACC_RANGE_2G = 0, + MPU_9250_SENSOR_ACC_RANGE_4G = 1, + MPU_9250_SENSOR_ACC_RANGE_8G = 2, MPU_9250_SENSOR_ACC_RANGE_16G = 3 } MPU_9250_SENSOR_ACC_RANGE; /*---------------------------------------------------------------------------*/ @@ -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; diff --git a/arch/platform/simplelink/cc13xx-cc26xx/sensortag/opt-3001-sensor.c b/arch/platform/simplelink/cc13xx-cc26xx/sensortag/opt-3001-sensor.c index 086c61165..885fefe88 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/sensortag/opt-3001-sensor.c +++ b/arch/platform/simplelink/cc13xx-cc26xx/sensortag/opt-3001-sensor.c @@ -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 @@ -160,16 +160,15 @@ static bool i2c_write_read(void *wbuf, size_t wcount, void *rbuf, size_t rcount) { I2C_Transaction i2c_transaction = { - .writeBuf = wbuf, - .writeCount = wcount, - .readBuf = rbuf, - .readCount = rcount, + .writeBuf = wbuf, + .writeCount = wcount, + .readBuf = rbuf, + .readCount = rcount, .slaveAddress = OPT_3001_I2C_ADDRESS, }; 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. @@ -305,7 +303,7 @@ value(int type) result_value = SWAP16(result_value); - uint32_t e = (result_value & 0x0FFF) >> 0; + uint32_t e = (result_value & 0x0FFF) >> 0; uint32_t m = (result_value & 0xF000) >> 12; uint32_t converted = m * 100 * (1 << e); diff --git a/arch/platform/simplelink/cc13xx-cc26xx/sensortag/opt-3001-sensor.h b/arch/platform/simplelink/cc13xx-cc26xx/sensortag/opt-3001-sensor.h index 7f4e132c5..221ea041f 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/sensortag/opt-3001-sensor.h +++ b/arch/platform/simplelink/cc13xx-cc26xx/sensortag/opt-3001-sensor.h @@ -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 /*---------------------------------------------------------------------------*/ diff --git a/arch/platform/simplelink/cc13xx-cc26xx/sensortag/tmp-007-sensor.c b/arch/platform/simplelink/cc13xx-cc26xx/sensortag/tmp-007-sensor.c index 92033c5a8..68bd4669a 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/sensortag/tmp-007-sensor.c +++ b/arch/platform/simplelink/cc13xx-cc26xx/sensortag/tmp-007-sensor.c @@ -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 /*---------------------------------------------------------------------------*/ @@ -116,16 +116,16 @@ static const PIN_Config pin_table[] = { PIN_TERMINATE }; -static PIN_State pin_state; +static PIN_State pin_state; static PIN_Handle pin_handle; static I2C_Handle i2c_handle; /*---------------------------------------------------------------------------*/ typedef struct { - TMP_007_TYPE type; + TMP_007_TYPE type; volatile TMP_007_STATUS status; - uint16_t local_tmp_latched; - uint16_t obj_tmp_latched; + uint16_t local_tmp_latched; + uint16_t obj_tmp_latched; } TMP_007_Object; static TMP_007_Object tmp_007; @@ -148,16 +148,15 @@ static bool i2c_write_read(void *wbuf, size_t wcount, void *rbuf, size_t rcount) { I2C_Transaction i2c_transaction = { - .writeBuf = wbuf, - .writeCount = wcount, - .readBuf = rbuf, - .readCount = rcount, + .writeBuf = wbuf, + .writeCount = wcount, + .readBuf = rbuf, + .readCount = rcount, .slaveAddress = TMP_007_I2C_ADDRESS, }; 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,16 +299,16 @@ 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; + uint32_t obj = (uint32_t)*obj_tmp; local = (local >> 2) * 3125 / 100; - obj = (obj >> 2) * 3125 / 100; + obj = (obj >> 2) * 3125 / 100; *local_tmp = (uint16_t)local; - *obj_tmp = (uint16_t)obj; + *obj_tmp = (uint16_t)obj; } /*---------------------------------------------------------------------------*/ /** @@ -322,7 +320,7 @@ static int value(int type) { uint16_t raw_local_tmp = 0, local_tmp = 0; - uint16_t raw_obj_tmp = 0, obj_tmp = 0; + uint16_t raw_obj_tmp = 0, obj_tmp = 0; if(tmp_007.status != TMP_007_STATUS_READY) { PRINTF("Sensor disabled or starting up (%d)\n", tmp_007.status); @@ -339,14 +337,14 @@ value(int type) } local_tmp = raw_local_tmp; - obj_tmp = raw_obj_tmp; + obj_tmp = raw_obj_tmp; convert(&local_tmp, &obj_tmp); PRINTF("TMP: %04X %04X o=%d a=%d\n", raw_local_tmp, raw_obj_tmp, - (int)(local_tmp), (int)(obj_tmp)); + (int)(local_tmp), (int)(obj_tmp)); tmp_007.local_tmp_latched = (int)(local_tmp); - tmp_007.obj_tmp_latched = (int)(obj_tmp); + tmp_007.obj_tmp_latched = (int)(obj_tmp); return 0; diff --git a/arch/platform/simplelink/cc13xx-cc26xx/sensortag/tmp-007-sensor.h b/arch/platform/simplelink/cc13xx-cc26xx/sensortag/tmp-007-sensor.h index cb810e703..1c806abe8 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/sensortag/tmp-007-sensor.h +++ b/arch/platform/simplelink/cc13xx-cc26xx/sensortag/tmp-007-sensor.h @@ -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_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 {