[LSM9DS1] fix warnings, fix wrong macro usage

This commit is contained in:
ІО-23 Шмуляр Олег 2025-04-14 18:18:08 +03:00
parent c74299dc0d
commit ac75969758
1 changed files with 6 additions and 4 deletions

View File

@ -3,8 +3,8 @@
#include "lcd.h" #include "lcd.h"
#define FAILSAFE_PRE_OP for (size_t t = 0; t < 5; t++) { #define FAILSAFE_PRE_OP for (size_t t = 0; t < 5; t++) {
#define FAILSAFE_POST_OP_ACCEL(prefix) if (op_result) print_error_accel(op_result, err_count, t, prefix); else break; } #define FAILSAFE_POST_OP_ACCEL(prefix) if (op_result) print_error_accel(op_result, &err_count, t, prefix); else break; }
#define FAILSAFE_POST_OP_MAGNET(prefix) if (op_result) print_error_magnet(op_result, err_count, t, prefix); else break; } #define FAILSAFE_POST_OP_MAGNET(prefix) if (op_result) print_error_magnet(op_result, &err_count, t, prefix); else break; }
extern I2C_HandleTypeDef hi2c1; extern I2C_HandleTypeDef hi2c1;
@ -20,6 +20,8 @@ static void print_error_message(HAL_StatusTypeDef result, size_t *err_count, siz
display_write_data_seq("/5 "); display_write_data_seq("/5 ");
switch (result) { switch (result) {
case HAL_OK:
break;
case HAL_ERROR: case HAL_ERROR:
display_write_data_seq("ERROR"); display_write_data_seq("ERROR");
break; break;
@ -110,12 +112,12 @@ void LSM9DS1_test_magnet(void)
buffer[0] = 0x28; buffer[0] = 0x28;
FAILSAFE_PRE_OP; FAILSAFE_PRE_OP;
op_result = HAL_I2C_Master_Transmit(&hi2c1, 0x3C, buffer, 1, 1000); op_result = HAL_I2C_Master_Transmit(&hi2c1, 0x3C, buffer, 1, 1000);
FAILSAFE_POST_OP_ACCEL("A"); FAILSAFE_POST_OP_MAGNET("A");
// read from registers sequentially // read from registers sequentially
FAILSAFE_PRE_OP; FAILSAFE_PRE_OP;
op_result = HAL_I2C_Master_Receive(&hi2c1, 0x3D, buffer, 6, 1000); op_result = HAL_I2C_Master_Receive(&hi2c1, 0x3D, buffer, 6, 1000);
FAILSAFE_POST_OP_ACCEL("R"); FAILSAFE_POST_OP_MAGNET("R");
if (!err_count) { if (!err_count) {
DISPLAY_SET_CURSOR(1, 1); DISPLAY_SET_CURSOR(1, 1);