51 lines
1.1 KiB
C
51 lines
1.1 KiB
C
/*
|
|
* TMP144.h
|
|
*
|
|
* Created on: Mar 22, 2022
|
|
* Author: Jasper
|
|
*/
|
|
|
|
#ifndef INC_TMP144_H_
|
|
#define INC_TMP144_H_
|
|
|
|
#include "common_defs.h"
|
|
|
|
#include "stm32f4xx_hal.h"
|
|
#include "stm32f4xx_hal_uart.h"
|
|
|
|
#define N_SENSORS 32
|
|
|
|
extern volatile uint16_t temperatures[N_SENSORS];
|
|
extern volatile uint16_t max_temp;
|
|
|
|
typedef enum {
|
|
TMP144_IDLE,
|
|
TMP144_RESETTING,
|
|
TMP144_INITIALIZING,
|
|
TMP144_READING_TEMP
|
|
} TMP144State;
|
|
|
|
typedef struct {
|
|
UART_HandleTypeDef* handle;
|
|
TMP144State state;
|
|
|
|
uint8_t rxbuf[34];
|
|
|
|
size_t n_sensors;
|
|
} TMP144Bus;
|
|
|
|
HAL_StatusTypeDef tmp144_init(UART_HandleTypeDef* busbar_side,
|
|
UART_HandleTypeDef* other_side);
|
|
|
|
HAL_StatusTypeDef tmp144_init_reset(TMP144Bus* bus);
|
|
HAL_StatusTypeDef tmp144_init_post_reset(TMP144Bus* bus);
|
|
HAL_StatusTypeDef tmp144_init_post_addr(TMP144Bus* bus);
|
|
|
|
HAL_StatusTypeDef tmp144_read_temps();
|
|
HAL_StatusTypeDef tmp144_send_read_temps(TMP144Bus* bus);
|
|
HAL_StatusTypeDef tmp144_recv_temps(TMP144Bus* bus);
|
|
|
|
void tmp144_handle_rx_cplt(UART_HandleTypeDef* handle);
|
|
|
|
#endif /* INC_TMP144_H_ */
|