steering-wheel-stm/Core/Inc/rpi.h

33 lines
730 B
C
Raw Normal View History

2022-05-27 00:11:56 +02:00
#ifndef __RPI_H
#define __RPI_H
#include "stm32g4xx_hal.h"
2022-05-27 17:20:16 +02:00
#include <stddef.h>
2022-05-27 00:11:56 +02:00
// We only need to receive one byte (command ID)
#define I2C_RX_BUF_SIZE 1
extern uint8_t i2c_rx_buf[I2C_RX_BUF_SIZE];
// We always send the maximum 32 byes supported by an SMBus block read
#define I2C_TX_BUF_MAX_SIZE 32
extern uint8_t i2c_tx_buf[I2C_TX_BUF_MAX_SIZE];
extern uint8_t i2c_tx_len;
#define COMM_SEND_DATA 0x00
typedef enum {
RPI_I2C_IDLE,
RPI_I2C_WAITING_FOR_COMMAND,
RPI_I2C_WAITING_FOR_MASTER_RECEIVE,
RPI_I2C_SENDING_DATA_SIZE,
RPI_I2C_SENDING_DATA
} RPiI2CState;
extern RPiI2CState rpi_i2c_state;
2022-05-27 17:20:16 +02:00
extern size_t rpi_num_polls;
2022-05-27 00:11:56 +02:00
void rpi_init(I2C_HandleTypeDef *handle);
2022-05-27 17:20:16 +02:00
void rpi_update_tx_buffer();
2022-05-27 00:11:56 +02:00
#endif // __RPI_H