Implement TMP144 timeout
This commit is contained in:
@ -11,18 +11,22 @@
|
||||
#include "common_defs.h"
|
||||
|
||||
#include "stm32f4xx_hal.h"
|
||||
#include "stm32f4xx_hal_def.h"
|
||||
#include "stm32f4xx_hal_uart.h"
|
||||
|
||||
#define N_SENSORS 32
|
||||
#define N_TEMP_SENSORS 32
|
||||
#define TMP144_RESPONSE_TIMEOUT 100 /* ms */
|
||||
|
||||
extern volatile uint16_t temperatures[N_SENSORS];
|
||||
extern volatile uint16_t max_temp;
|
||||
extern volatile uint16_t temperatures[N_TEMP_SENSORS];
|
||||
extern volatile uint16_t min_temperature;
|
||||
extern volatile uint16_t max_temperature;
|
||||
|
||||
typedef enum {
|
||||
TMP144_IDLE,
|
||||
TMP144_RESETTING,
|
||||
TMP144_INITIALIZING,
|
||||
TMP144_READING_TEMP
|
||||
TMP144_READING_TEMP,
|
||||
TMP144_ERROR
|
||||
} TMP144State;
|
||||
|
||||
typedef struct {
|
||||
@ -32,11 +36,18 @@ typedef struct {
|
||||
uint8_t rxbuf[34];
|
||||
|
||||
size_t n_sensors;
|
||||
|
||||
uint32_t expected_response_time;
|
||||
} TMP144Bus;
|
||||
|
||||
extern volatile TMP144Bus tmp144_bus_busbar;
|
||||
extern volatile TMP144Bus tmp144_bus_other;
|
||||
|
||||
HAL_StatusTypeDef tmp144_init(UART_HandleTypeDef* busbar_side,
|
||||
UART_HandleTypeDef* other_side);
|
||||
|
||||
HAL_StatusTypeDef tmp144_check_timeouts();
|
||||
|
||||
HAL_StatusTypeDef tmp144_init_reset(TMP144Bus* bus);
|
||||
HAL_StatusTypeDef tmp144_init_post_reset(TMP144Bus* bus);
|
||||
HAL_StatusTypeDef tmp144_init_post_addr(TMP144Bus* bus);
|
||||
|
||||
Reference in New Issue
Block a user