Skip to content

Commit

Permalink
Apply astyle config
Browse files Browse the repository at this point in the history
  • Loading branch information
MaJerle committed Jul 2, 2020
1 parent ca1a8e5 commit 4cc7653
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 31 deletions.
34 changes: 25 additions & 9 deletions onewire_uart/src/devices/ow_device_ds18x20.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,20 @@ ow_ds18x20_read_raw(ow_t* const ow, const ow_rom_t* const rom_id, float* const t
}
digit = (temp >> 0x04) | (((temp >> 0x08) & 0x07) << 0x04);
switch (resolution) { /* Check for resolution settings */
case 9: dec = ((temp >> 0x03) & 0x01) * 0.5f; break;
case 10: dec = ((temp >> 0x02) & 0x03) * 0.25f; break;
case 11: dec = ((temp >> 0x01) & 0x07) * 0.125f; break;
case 12: dec = (temp & 0x0F) * 0.0625f; break;
default: dec = 0xFF, digit = 0;
case 9:
dec = ((temp >> 0x03) & 0x01) * 0.5f;
break;
case 10:
dec = ((temp >> 0x02) & 0x03) * 0.25f;
break;
case 11:
dec = ((temp >> 0x01) & 0x07) * 0.125f;
break;
case 12:
dec = (temp & 0x0F) * 0.0625f;
break;
default:
dec = 0xFF, digit = 0;
}
dec += digit;
if (m) {
Expand Down Expand Up @@ -239,10 +248,17 @@ ow_ds18x20_set_resolution_raw(ow_t* const ow, const ow_rom_t* const rom_id, cons

conf &= ~0x60; /* Remove configuration bits for temperature resolution */
switch (bits) { /* Check bits configuration */
case 12: conf |= 0x60; break; /* 12-bits configuration */
case 11: conf |= 0x40; break; /* 11-bits configuration */
case 10: conf |= 0x20; break; /* 10-bits configuration */
default: break; /* 9-bits configuration */
case 12:
conf |= 0x60;
break; /* 12-bits configuration */
case 11:
conf |= 0x40;
break; /* 11-bits configuration */
case 10:
conf |= 0x20;
break; /* 10-bits configuration */
default:
break; /* 9-bits configuration */
}

/* Write data back to device */
Expand Down
18 changes: 9 additions & 9 deletions onewire_uart/src/include/ow/ow.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ typedef enum {
owERRNODEV, /*!< No device connected, maybe device removed during scan? */
owERRTXRX, /*!< Error while exchanging data */
owERRBAUD, /*!< Error setting baudrate */
owPARERR , /*!< Parameter error */
owPARERR, /*!< Parameter error */
owERR, /*!< General-Purpose error */
} owr_t;

Expand Down Expand Up @@ -180,10 +180,10 @@ typedef owr_t (*ow_search_cb_fn) (ow_t* const ow, const ow_rom_t* const rom_id,
* \hideinitializer
*/
#define OW_ASSERT(msg, c) do { \
if (!(c)) { \
return owPARERR; \
} \
} while (0)
if (!(c)) { \
return owPARERR; \
} \
} while (0)

/**
* \brief Assert check function with return `0`
Expand All @@ -195,10 +195,10 @@ typedef owr_t (*ow_search_cb_fn) (ow_t* const ow, const ow_rom_t* const rom_id,
* \hideinitializer
*/
#define OW_ASSERT0(msg, c) do { \
if (!(c)) { \
return 0; \
} \
} while (0)
if (!(c)) { \
return 0; \
} \
} while (0)

/**
* \brief Get size of statically declared array
Expand Down
8 changes: 4 additions & 4 deletions onewire_uart/src/ow/ow.c
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ ow_crc(const void* in, const size_t len) {
*/
owr_t
ow_search_with_command_callback(ow_t* const ow, const uint8_t cmd, size_t* const roms_found,
const ow_search_cb_fn func, void* arg) {
const ow_search_cb_fn func, void* arg) {
owr_t res;
ow_rom_t rom_id;
size_t i;
Expand All @@ -642,7 +642,7 @@ ow_search_with_command_callback(ow_t* const ow, const uint8_t cmd, size_t* const
ow_protect(ow, 1);
/* Search device-by-device until all found */
for (i = 0, res = ow_search_reset_raw(ow);
res == owOK && (res = ow_search_with_command_raw(ow, cmd, &rom_id)) == owOK; ++i) {
res == owOK && (res = ow_search_with_command_raw(ow, cmd, &rom_id)) == owOK; ++i) {
if ((res = func(ow, &rom_id, i, arg)) != owOK) {
break;
}
Expand Down Expand Up @@ -687,7 +687,7 @@ ow_search_with_callback(ow_t* const ow, size_t* const roms_found, const ow_searc
*/
owr_t
ow_search_devices_with_command_raw(ow_t* const ow, const uint8_t cmd, ow_rom_t* const rom_id_arr,
const size_t rom_len, size_t* const roms_found) {
const size_t rom_len, size_t* const roms_found) {
owr_t res;
size_t cnt = 0;

Expand Down Expand Up @@ -715,7 +715,7 @@ ow_search_devices_with_command_raw(ow_t* const ow, const uint8_t cmd, ow_rom_t*
*/
owr_t
ow_search_devices_with_command(ow_t* const ow, const uint8_t cmd, ow_rom_t* const rom_id_arr,
const size_t rom_len, size_t* const roms_found) {
const size_t rom_len, size_t* const roms_found) {
owr_t res;

OW_ASSERT("ow != NULL", ow != NULL);
Expand Down
2 changes: 1 addition & 1 deletion onewire_uart/src/system/ow_ll_stm32_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ transmit_receive(const uint8_t* tx, uint8_t* rx, size_t len, void* arg) {
HAL_UART_Receive_IT(huart, rx, len);

/* Process TX in polling mode */
HAL_UART_Transmit(huart, (void *)tx, len, 100);
HAL_UART_Transmit(huart, (void*)tx, len, 100);

/* Wait RX to finish */
while (huart->RxState != HAL_UART_STATE_READY) {
Expand Down
14 changes: 7 additions & 7 deletions onewire_uart/src/system/ow_ll_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ init(void* arg) {

/* Open virtual file as read/write */
com_port = CreateFile(L"\\\\.\\COM4",
GENERIC_READ | GENERIC_WRITE,
0,
0,
OPEN_EXISTING,
0,
NULL
);
GENERIC_READ | GENERIC_WRITE,
0,
0,
OPEN_EXISTING,
0,
NULL
);

/* First read current values */
if (GetCommState(com_port, &dcb)) {
Expand Down
2 changes: 1 addition & 1 deletion snippets/include/scan_devices.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
extern "C" {
#endif /* __cplusplus */

owr_t scan_onewire_devices(ow_t* ow, ow_rom_t* rom_ids, size_t rtf, size_t* rf);
owr_t scan_onewire_devices(ow_t* ow, ow_rom_t* rom_ids, size_t rtf, size_t* rf);

#ifdef __cplusplus
}
Expand Down

0 comments on commit 4cc7653

Please sign in to comment.