Compare commits
3 Commits
5fb5d271b1
...
2024
| Author | SHA1 | Date | |
|---|---|---|---|
| 59262443c9 | |||
| 25da5cde32 | |||
| 10aa474124 |
7
.stm32env
Normal file
7
.stm32env
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# environment variable file used by stm32-for-vscode and the STM32Make.make makefile
|
||||||
|
# Other environment variables can be added here. If wanting to use the generated makefile in CI/CD context please
|
||||||
|
# configure the following variables: GCC_PATH, OPENOCD
|
||||||
|
|
||||||
|
ARM_GCC_PATH = /Applications/ArmGNUToolchain/13.2.Rel1/arm-none-eabi/bin
|
||||||
|
OPENOCD = /opt/homebrew/bin/openocd
|
||||||
|
|
||||||
@ -5,8 +5,10 @@
|
|||||||
/**
|
/**
|
||||||
* Decrements the given value if it is above the minimum allowed value
|
* Decrements the given value if it is above the minimum allowed value
|
||||||
*/
|
*/
|
||||||
#define DEC_IF_ABOVE(param_val, min_val, decr_amt) ((param_val) = ((param_val) - (decr_amt) ) > (min_val) ? ((param_val) - (decr_amt)) : (min_val))
|
// TODO these functions take into account that the parameters are unsigned, it's definitely better to have them
|
||||||
#define INC_IF_BELOW(param_val, max_val, incr_amt) ((param_val) = ((param_val) + (incr_amt)) < (max_val) ? ((param_val) + (incr_amt)) : (max_val))
|
// signed but would need to be tested with the autobox
|
||||||
|
#define DEC_IF_ABOVE(param_val, min_val, decr_amt) ((param_val) = (((int)(param_val) - (int)(decr_amt)) > (int)(min_val)) ? ((param_val) - (decr_amt)) : (min_val))
|
||||||
|
#define INC_IF_BELOW(param_val, max_val, incr_amt) ((param_val) = (((param_val) + (incr_amt)) < (max_val)) ? ((param_val) + (incr_amt)) : (max_val))
|
||||||
|
|
||||||
Params params = {0};
|
Params params = {0};
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
#include "leds.h"
|
#include "leds.h"
|
||||||
|
|
||||||
#define DRS_BUTTON_IDX (6)
|
#define DRS_BUTTON_IDX (6)
|
||||||
#define DRS_PRESS_WAIT_CYCLES (10)
|
#define DRS_PRESS_WAIT_CYCLES (1000)
|
||||||
static int drs_press_buf_cycles = 0;
|
static int drs_press_buf_cycles = 0;
|
||||||
|
|
||||||
void ui_thread_entry(ULONG _) {
|
void ui_thread_entry(ULONG _) {
|
||||||
|
|||||||
@ -1,16 +1,14 @@
|
|||||||
#include "vehicle.h"
|
#include "vehicle.h"
|
||||||
|
|
||||||
#include "main.h"
|
|
||||||
#include "ui.h"
|
|
||||||
#include "vehicle_state.h"
|
|
||||||
|
|
||||||
#include "can-halal.h"
|
#include "can-halal.h"
|
||||||
|
#include "main.h"
|
||||||
#include "stm32h7xx.h"
|
#include "stm32h7xx.h"
|
||||||
#include "stm32h7xx_hal.h"
|
#include "stm32h7xx_hal.h"
|
||||||
#include "stm32h7xx_hal_fdcan.h"
|
#include "stm32h7xx_hal_fdcan.h"
|
||||||
#include "stm32h7xx_hal_gpio.h"
|
#include "stm32h7xx_hal_gpio.h"
|
||||||
#include "tx_api.h"
|
#include "tx_api.h"
|
||||||
|
#include "ui.h"
|
||||||
|
#include "vehicle_state.h"
|
||||||
|
|
||||||
#define CAN_ID_AMS_SLAVE_PANIC 0x9
|
#define CAN_ID_AMS_SLAVE_PANIC 0x9
|
||||||
#define CAN_ID_AMS_STATUS 0xA
|
#define CAN_ID_AMS_STATUS 0xA
|
||||||
@ -98,7 +96,8 @@ void vehicle_broadcast_param(ParamType param, int32_t value) {
|
|||||||
|
|
||||||
void vehicle_broadcast_buttons(GPIO_PinState *button_states) {
|
void vehicle_broadcast_buttons(GPIO_PinState *button_states) {
|
||||||
uint8_t data = (button_states[0] << 2) | (button_states[1] << 0) |
|
uint8_t data = (button_states[0] << 2) | (button_states[1] << 0) |
|
||||||
(button_states[2] << 1) | (button_states[3] << 3);
|
(button_states[2] << 1) | (button_states[3] << 3) |
|
||||||
|
(button_states[6] << 4);
|
||||||
ftcan_transmit(CAN_ID_STW_BUTTONS, &data, 1);
|
ftcan_transmit(CAN_ID_STW_BUTTONS, &data, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,12 +227,14 @@ void ftcan_msg_received_cb(uint16_t id, size_t datalen, const uint8_t *data) {
|
|||||||
break;
|
break;
|
||||||
case CAN_ID_ABX_PARAM_CONFIRMED:
|
case CAN_ID_ABX_PARAM_CONFIRMED:
|
||||||
vehicle_state.last_param_confirmed = data[0];
|
vehicle_state.last_param_confirmed = data[0];
|
||||||
tx_event_flags_set(&gui_update_events, GUI_UPDATE_PARAM_CONFIRMED, TX_OR);
|
tx_event_flags_set(&gui_update_events, GUI_UPDATE_PARAM_CONFIRMED,
|
||||||
|
TX_OR);
|
||||||
break;
|
break;
|
||||||
case CAN_ID_SHUNT_CURRENT: {
|
case CAN_ID_SHUNT_CURRENT: {
|
||||||
// The first two bytes of shunt result messages are metadata
|
// The first two bytes of shunt result messages are metadata
|
||||||
const uint8_t *result_ptr = &data[2];
|
const uint8_t *result_ptr = &data[2];
|
||||||
vehicle_state.ts_current = ftcan_unmarshal_signed(&result_ptr, 4) * 1e-3;
|
vehicle_state.ts_current =
|
||||||
|
ftcan_unmarshal_signed(&result_ptr, 4) * 1e-3;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CAN_ID_SHUNT_VOLTAGE1: {
|
case CAN_ID_SHUNT_VOLTAGE1: {
|
||||||
|
|||||||
@ -336,7 +336,7 @@ static_assert(sizeof(dataFieldDescs) / sizeof(dataFieldDescs[0]) ==
|
|||||||
|
|
||||||
NamedFieldDescription paramFieldDescs[] = {
|
NamedFieldDescription paramFieldDescs[] = {
|
||||||
[PF_PLIM] = {NamedFieldKind::Int, "PLIM", 2, 0, PARAM_FIELD(plim)},
|
[PF_PLIM] = {NamedFieldKind::Int, "PLIM", 2, 0, PARAM_FIELD(plim)},
|
||||||
[PF_TLIM] = {NamedFieldKind::Int, "TLIM", 4, 1, PARAM_FIELD(plim)},
|
[PF_TLIM] = {NamedFieldKind::Int, "TLIM", 4, 1, PARAM_FIELD(tlim)},
|
||||||
[PF_SLIM] = {NamedFieldKind::Int, "SLIM", 2, 2, PARAM_FIELD(slim)},
|
[PF_SLIM] = {NamedFieldKind::Int, "SLIM", 2, 2, PARAM_FIELD(slim)},
|
||||||
[PF_TVEC] = {NamedFieldKind::Int, "TVEC", 2, 1, PARAM_FIELD(tvec)},
|
[PF_TVEC] = {NamedFieldKind::Int, "TVEC", 2, 1, PARAM_FIELD(tvec)},
|
||||||
[PF_PG] = {NamedFieldKind::Int, "PG", 2, 0, PARAM_FIELD(pg)},
|
[PF_PG] = {NamedFieldKind::Int, "PG", 2, 0, PARAM_FIELD(pg)},
|
||||||
|
|||||||
Reference in New Issue
Block a user