35 lines
807 B
C
35 lines
807 B
C
#ifndef __RPI_H
|
|
#define __RPI_H
|
|
|
|
#include "stm32g4xx_hal.h"
|
|
|
|
#include <stddef.h>
|
|
|
|
// 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;
|
|
|
|
extern size_t rpi_num_polls;
|
|
|
|
void rpi_init(I2C_HandleTypeDef* handle);
|
|
|
|
void rpi_update_tx_buffer();
|
|
void rpi_update_tx_buffer_mission_select();
|
|
void rpi_update_tx_buffer_ami();
|
|
|
|
#endif // __RPI_H
|