From e1a6914b022533e26b7b9c356601a7bd24f81a21 Mon Sep 17 00:00:00 2001 From: Andreas Brauchli Date: Sun, 12 May 2019 22:00:20 +0200 Subject: [PATCH] Automated type conversion This patch includes the changes from the following commands: find . -type f \ \( -name '*\.[ch]' -o -name '*\.cpp' -o -name '*\.ino' \) -print0 \ | xargs -0 sed -i \ -e 's/\bu\([0-9]\{1,2\}\)\b/uint\1_t/g' \ -e 's/\bs\([0-9]\{1,2\}\)\b/int\1_t/g' \ -e 's/\bf32\b/float32_t/g' make style-fix This commit also updates embedded-common --- embedded-common | 2 +- sts-common/example_usage.c | 4 +-- sts-common/sts.h | 16 ++++++------ sts-common/sts_common.c | 12 ++++----- sts-common/sts_common.h | 4 +-- sts3x/sts3x.c | 50 +++++++++++++++++++------------------- 6 files changed, 44 insertions(+), 44 deletions(-) diff --git a/embedded-common b/embedded-common index da2e3c2..d7389df 160000 --- a/embedded-common +++ b/embedded-common @@ -1 +1 @@ -Subproject commit da2e3c21a7f24f3f331ad10ace80ce0fce83d0cb +Subproject commit d7389dff12a7eafad952246b6577c65f6d30786b diff --git a/sts-common/example_usage.c b/sts-common/example_usage.c index 9b468cd..16a7ea4 100644 --- a/sts-common/example_usage.c +++ b/sts-common/example_usage.c @@ -51,12 +51,12 @@ int main(void) { /* printf("STS sensor probing successful\n"); */ while (1) { - s32 temperature; + int32_t temperature; float temperature_degree; /* Measure temperature and store into variable temperature * (output is multiplied by 1000). */ - s8 ret = sts_measure_blocking_read(&temperature); + int8_t ret = sts_measure_blocking_read(&temperature); if (ret == STATUS_OK) { temperature_degree = temperature / 1000.0f; /* printf("measured temperature: %0.2f degreeCelsius\n", diff --git a/sts-common/sts.h b/sts-common/sts.h index 851b21d..92730fd 100644 --- a/sts-common/sts.h +++ b/sts-common/sts.h @@ -60,7 +60,7 @@ extern "C" { * * @return 0 if a sensor was detected */ -s8 sts_probe(void); +int8_t sts_probe(void); /** * Starts a measurement and then reads out the results. This function blocks @@ -72,7 +72,7 @@ s8 sts_probe(void); * measurement * @return 0 if the command was successful, else an error code. */ -s8 sts_measure_blocking_read(s32 *temperature); +int8_t sts_measure_blocking_read(int32_t *temperature); /** * Starts a measurement in high precision mode. Use sts_read() to read out the @@ -81,7 +81,7 @@ s8 sts_measure_blocking_read(s32 *temperature); * * @return 0 if the command was successful, else an error code. */ -s8 sts_measure(void); +int8_t sts_measure(void); /** * Reads out the results of a measurement that was previously started by @@ -93,7 +93,7 @@ s8 sts_measure(void); * measurement * @return 0 if the command was successful, else an error code. */ -s8 sts_read(s32 *temperature); +int8_t sts_read(int32_t *temperature); /** * Set repeatability of the STS @@ -102,7 +102,7 @@ s8 sts_read(s32 *temperature); * 1 for medium repeatability mode * 2 for low repeatability mode */ -void sts_set_repeatability(u8 repeatability); +void sts_set_repeatability(uint8_t repeatability); /** * Enable internal heater. The heater is meant for plausibility check only. @@ -110,7 +110,7 @@ void sts_set_repeatability(u8 repeatability); * @return 0 if the command was successful, * 1 if an error occured */ -s8 sts_heater_on(void); +int8_t sts_heater_on(void); /** * Disable internal heater @@ -118,7 +118,7 @@ s8 sts_heater_on(void); * @return 0 if the command was successful, * 1 if an error occured */ -s8 sts_heater_off(void); +int8_t sts_heater_off(void); /** * sts_get_driver_version() - Return the driver version @@ -132,7 +132,7 @@ const char *sts_get_driver_version(void); * * @return STSxx_ADDRESS */ -u8 sts_get_configured_sts_address(void); +uint8_t sts_get_configured_sts_address(void); #ifdef __cplusplus } diff --git a/sts-common/sts_common.c b/sts-common/sts_common.c index c9dd02c..44980b7 100644 --- a/sts-common/sts_common.c +++ b/sts-common/sts_common.c @@ -41,22 +41,22 @@ #include "sensirion_i2c.h" #include "sts.h" -s8 sts_common_read_ticks(u8 address, s32 *temperature_ticks) { - u8 data[3]; - s8 ret = sensirion_i2c_read(address, data, sizeof(data)); +int8_t sts_common_read_ticks(uint8_t address, int32_t *temperature_ticks) { + uint8_t data[3]; + int8_t ret = sensirion_i2c_read(address, data, sizeof(data)); if (ret) return ret; if (sensirion_common_check_crc(data, 2, data[2])) { return STATUS_CRC_FAIL; } - *temperature_ticks = (data[1] & 0xff) | ((s32)data[0] << 8); + *temperature_ticks = (data[1] & 0xff) | ((int32_t)data[0] << 8); return STATUS_OK; } -s8 sts_common_read_measurement(u8 address, s32 *temperature) { - s8 ret = sts_common_read_ticks(address, temperature); +int8_t sts_common_read_measurement(uint8_t address, int32_t *temperature) { + int8_t ret = sts_common_read_ticks(address, temperature); /** * formulas for conversion of the sensor signals, optimized for fixed point * algebra: Temperature = 175 * S_T / 2^16 - 45 diff --git a/sts-common/sts_common.h b/sts-common/sts_common.h index a45d26a..cdd52d4 100644 --- a/sts-common/sts_common.h +++ b/sts-common/sts_common.h @@ -38,9 +38,9 @@ extern "C" { #endif -s8 sts_common_read_ticks(u8 address, s32 *temperature_ticks); +int8_t sts_common_read_ticks(uint8_t address, int32_t *temperature_ticks); -s8 sts_common_read_measurement(u8 address, s32 *temperature); +int8_t sts_common_read_measurement(uint8_t address, int32_t *temperature); #ifdef __cplusplus } diff --git a/sts3x/sts3x.c b/sts3x/sts3x.c index 29a9c12..f7a8640 100644 --- a/sts3x/sts3x.c +++ b/sts3x/sts3x.c @@ -46,30 +46,30 @@ /* all measurement commands return T (CRC) RH (CRC) */ #if USE_SENSIRION_CLOCK_STRETCHING -static const u8 CMD_MEASURE_HPM[] = {0x2C, 0x06}; -static const u8 CMD_MEASURE_MPM[] = {0x2C, 0x0D}; -static const u8 CMD_MEASURE_LPM[] = {0x2C, 0x10}; +static const uint8_t CMD_MEASURE_HPM[] = {0x2C, 0x06}; +static const uint8_t CMD_MEASURE_MPM[] = {0x2C, 0x0D}; +static const uint8_t CMD_MEASURE_LPM[] = {0x2C, 0x10}; #else -static const u8 CMD_MEASURE_HPM[] = {0x24, 0x00}; -static const u8 CMD_MEASURE_MPM[] = {0x24, 0x0B}; -static const u8 CMD_MEASURE_LPM[] = {0x24, 0x16}; +static const uint8_t CMD_MEASURE_HPM[] = {0x24, 0x00}; +static const uint8_t CMD_MEASURE_MPM[] = {0x24, 0x0B}; +static const uint8_t CMD_MEASURE_LPM[] = {0x24, 0x16}; #endif /* USE_SENSIRION_CLOCK_STRETCHING */ -static const u8 CMD_READ_STATUS_REG[] = {0xF3, 0x2D}; -static const u8 CMD_HEATER_ON[] = {0x30, 0x6D}; -static const u8 CMD_HEATER_OFF[] = {0x30, 0x66}; -static const u8 COMMAND_SIZE = sizeof(CMD_MEASURE_HPM); +static const uint8_t CMD_READ_STATUS_REG[] = {0xF3, 0x2D}; +static const uint8_t CMD_HEATER_ON[] = {0x30, 0x6D}; +static const uint8_t CMD_HEATER_OFF[] = {0x30, 0x66}; +static const uint8_t COMMAND_SIZE = sizeof(CMD_MEASURE_HPM); #ifdef STS_ADDRESS -static const u8 STS3X_ADDRESS = STS_ADDRESS; +static const uint8_t STS3X_ADDRESS = STS_ADDRESS; #else -static const u8 STS3X_ADDRESS = 0x4A; +static const uint8_t STS3X_ADDRESS = 0x4A; #endif -static const u16 MEASUREMENT_DURATION_USEC = 15000; +static const uint16_t MEASUREMENT_DURATION_USEC = 15000; -static const u8 *cmd_measure = CMD_MEASURE_HPM; +static const uint8_t *cmd_measure = CMD_MEASURE_HPM; -s8 sts_measure_blocking_read(s32 *temperature) { - s8 ret = sts_measure(); +int8_t sts_measure_blocking_read(int32_t *temperature) { + int8_t ret = sts_measure(); if (ret == STATUS_OK) { sensirion_sleep_usec(MEASUREMENT_DURATION_USEC); ret = sts_read(temperature); @@ -77,18 +77,18 @@ s8 sts_measure_blocking_read(s32 *temperature) { return ret; } -s8 sts_measure() { +int8_t sts_measure() { return sensirion_i2c_write(STS3X_ADDRESS, CMD_MEASURE_HPM, COMMAND_SIZE); } -s8 sts_read(s32 *temperature) { +int8_t sts_read(int32_t *temperature) { return sts_common_read_measurement(STS3X_ADDRESS, temperature); } -s8 sts_probe() { - u8 data[3]; +int8_t sts_probe() { + uint8_t data[3]; sensirion_i2c_init(); - s8 ret = + int8_t ret = sensirion_i2c_write(STS3X_ADDRESS, CMD_READ_STATUS_REG, COMMAND_SIZE); if (ret) return ret; @@ -103,7 +103,7 @@ s8 sts_probe() { return STATUS_OK; } -void sts_set_repeatability(u8 repeatability) { +void sts_set_repeatability(uint8_t repeatability) { switch (repeatability) { case 2: cmd_measure = CMD_MEASURE_LPM; @@ -118,11 +118,11 @@ void sts_set_repeatability(u8 repeatability) { } } -s8 sts_heater_on(void) { +int8_t sts_heater_on(void) { return sensirion_i2c_write(STS3X_ADDRESS, CMD_HEATER_ON, COMMAND_SIZE); } -s8 sts_heater_off(void) { +int8_t sts_heater_off(void) { return sensirion_i2c_write(STS3X_ADDRESS, CMD_HEATER_OFF, COMMAND_SIZE); } @@ -130,6 +130,6 @@ const char *sts_get_driver_version() { return STS_DRV_VERSION_STR; } -u8 sts_get_configured_sts_address() { +uint8_t sts_get_configured_sts_address() { return STS3X_ADDRESS; }