Implement I2C communication with RPi

This commit is contained in:
2022-05-27 17:20:16 +02:00
committed by jazzpi
parent 5f1ae3955d
commit d7f9d0df9a
6 changed files with 130 additions and 94 deletions

View File

@ -3,6 +3,8 @@
#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];
@ -21,6 +23,10 @@ typedef enum {
} RPiI2CState;
extern RPiI2CState rpi_i2c_state;
extern size_t rpi_num_polls;
void rpi_init(I2C_HandleTypeDef *handle);
void rpi_update_tx_buffer();
#endif // __RPI_H

19
Core/Inc/state.h Normal file
View File

@ -0,0 +1,19 @@
#ifndef __STATE_H
#define __STATE_H
typedef enum {
VIEW_MISSION_SELECT = 0,
VIEW_AMI = 1,
VIEW_DRIVER = 2,
VIEW_TESTING = 3
} STWView;
typedef struct {
STWView view;
} STWState;
extern STWState stw_state;
void state_init();
#endif // __STATE_H