Uncrustify

This commit is contained in:
Edvard Pettersen 2018-07-25 18:16:27 +02:00
parent 08bda8bed7
commit 7cf843f601
41 changed files with 397 additions and 430 deletions

View File

@ -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

View File

@ -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!

View File

@ -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, &params);
}
/*---------------------------------------------------------------------------*/

View File

@ -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.

View File

@ -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

View File

@ -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 \
))
/*---------------------------------------------------------------------------*/

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Texas Instruments Incorporated - http://www.ti.com/
* Copyright (c) 2018, Texas Instruments Incorporated - http://www.ti.com/
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Texas Instruments Incorporated - http://www.ti.com/
* Copyright (c) 2018, Texas Instruments Incorporated - http://www.ti.com/
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -133,7 +133,9 @@ watchdog_reboot(void)
}
watchdog_start();
while(1);
/* Busy loop until watchdog times out */
for (;;) { /* hang */ }
}
/*---------------------------------------------------------------------------*/
/**

View File

@ -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 */
/*---------------------------------------------------------------------------*/
/** @} */

View File

@ -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>
@ -85,7 +85,7 @@ 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

View File

@ -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;
}

View File

@ -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));

View File

@ -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_ */

View File

@ -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,
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,
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_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_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,
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,7 +471,7 @@ netstack_stop_rx(void)
RF_Handle
ble_open(RF_Params *params)
{
#if RF_BLE_BEACON_ENABLE
#if RF_CONF_BLE_BEACON_ENABLE
return RF_open(&rf_ble, &ble_mode, (RF_RadioSetup *)&ble_cmd_radio_setup, params);
#else
@ -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_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",

View File

@ -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)
{

View File

@ -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);
@ -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

View File

@ -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;
}

View File

@ -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);

View File

@ -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));

View File

@ -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.
@ -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) {

View File

@ -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.

View File

@ -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.

View File

@ -79,8 +79,9 @@
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 {