Send button state to CAN

This commit is contained in:
2022-08-17 08:48:09 +02:00
committed by jazzpi
parent 2a824f1662
commit ceb9602c3c
5 changed files with 93 additions and 13 deletions

View File

@ -4,6 +4,20 @@
#include "events.h"
#include "stm32g4xx_hal.h"
#include "stm32g4xx_hal_gpio.h"
typedef struct {
GPIO_PinState left;
GPIO_PinState right;
GPIO_PinState r2d;
GPIO_PinState enter;
GPIO_PinState enc0a;
GPIO_PinState enc0b;
GPIO_PinState enc1a;
GPIO_PinState enc1b;
} ButtonsState;
ButtonsState get_buttons_state();
void handle_button_press(const ButtonPressEvent* ev);

View File

@ -4,13 +4,21 @@
#include "state.h"
#include "stm32g4xx_hal.h"
#include "stm32g4xx_hal_def.h"
#include "stm32g4xx_hal_fdcan.h"
#define CAN_ID_MISSION_SELECT 0x400
#define CAN_ID_BUTTONS 0x401
#define CAN_ID_AS_MISSION_FB 0x410
#define CAN_BUTTONS_LEFT (1 << 0)
#define CAN_BUTTONS_RIGHT (1 << 1)
#define CAN_BUTTONS_R2D (1 << 2)
#define CAN_BUTTONS_ENTER (1 << 3)
void vehicle_init(FDCAN_HandleTypeDef* handle);
void vehicle_send_mission_select(Mission mission);
HAL_StatusTypeDef vehicle_send_mission_select(Mission mission);
HAL_StatusTypeDef vehicle_send_buttons();
#endif // __VEHICLE_H