Skip to content

Commit 6759bf3

Browse files
committed
update for v1.12.1
1 parent 4b53920 commit 6759bf3

8 files changed

Lines changed: 110 additions & 14 deletions

File tree

Firmware/FFBoard/Src/flash_helpers.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@ bool Flash_Write(uint16_t adr,uint16_t dat){
2525
bool res = false;
2626
if(readRes == 1 || (readRes == 0 && buf != dat) ){ // Only write if var updated
2727
HAL_FLASH_Unlock();
28+
#ifndef HW_ESP32SX
2829
// Clear all the error flags
2930
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP);
3031
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_OPERR);
3132
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_WRPERR);
3233
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_PGAERR);
3334
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_PGPERR);
3435
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_PGSERR);
36+
#endif
3537
if(EE_WriteVariable(adr, dat) == HAL_OK){
3638
res = true;
3739
}
@@ -60,13 +62,15 @@ bool Flash_ReadWriteDefault(uint16_t adr,uint16_t *buf,uint16_t def){
6062
if(EE_ReadVariable(adr, buf) != 0){
6163
*buf = def;
6264
HAL_FLASH_Unlock();
65+
#ifndef HW_ESP32SX
6366
// Clear all the error flags
6467
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP);
6568
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_OPERR);
6669
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_WRPERR);
6770
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_PGAERR);
6871
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_PGPERR);
6972
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_PGSERR);
73+
#endif
7074
EE_WriteVariable(adr, def);
7175
HAL_FLASH_Lock();
7276
return false;
-57.5 KB
Binary file not shown.
-57.5 KB
Binary file not shown.
-59.7 KB
Binary file not shown.

Firmware/Targets/ESP32SX/main/cpp_target_config.cpp

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,25 @@ CANPort canport{CANPORT};
4242

4343
#ifdef PWMDRIVER
4444
// CCR and channels must match!
45-
const PWMConfig pwmTimerConfig = {
46-
.channel_1 = TIM_CHANNEL_1,
47-
.channel_2 = TIM_CHANNEL_2,
48-
.channel_3 = TIM_CHANNEL_3,
49-
.channel_4 = TIM_CHANNEL_4,
50-
51-
.ccr_1 = 1,
52-
.ccr_2 = 2,
53-
.ccr_3 = 3,
54-
.ccr_4 = 4,
55-
56-
.timer = &TIM_PWM,
57-
.timerFreq = APB_CLK_FREQ
58-
};
45+
const PWMConfig pwmTimerConfig =
46+
{
47+
.channel_1 = TIM_CHANNEL_1,
48+
.channel_2 = TIM_CHANNEL_2,
49+
.channel_3 = TIM_CHANNEL_3,
50+
.channel_4 = TIM_CHANNEL_4,
51+
52+
.pwm_chan = 1,
53+
.dir_chan = 3,
54+
.dir_chan_n = 4,
55+
56+
.centerpwm_chan = 1,
57+
58+
.rcpwm_chan = 1,
59+
60+
.dualpwm1 = 1,
61+
.dualpwm2 = 2,
62+
63+
.timer = &TIM_PWM,
64+
.timerFreq = APB_CLK_FREQ
65+
};
5966
#endif

Firmware/Targets/ESP32SX/main/glue.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,20 @@ CAN_HandleTypeDef hcan1;
2525
TIM_HandleTypeDef htim1;
2626
I2C_HandleTypeDef hi2c1;
2727

28+
29+
void HAL_GPIO_Init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_Init)
30+
{
31+
gpio_config_t io_conf = {0};
32+
io_conf.intr_type = GPIO_INTR_DISABLE;
33+
io_conf.mode = GPIO_Init->Mode;
34+
io_conf.pin_bit_mask = (BIT64(LED_CLIP_Pin) | BIT64(LED_ERR_Pin) \
35+
| BIT64(LED_SYS_Pin) | BIT64(DRV_ENABLE_Pin) \
36+
| BIT64(DRV_BRAKE_Pin) | BIT64(CAN_S_Pin));
37+
io_conf.pull_down_en = 0;
38+
io_conf.pull_up_en = 0;
39+
gpio_config(&io_conf);
40+
}
41+
2842
GPIO_PinState HAL_GPIO_ReadPin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
2943
{
3044
return gpio_ll_get_level(&GPIO, GPIO_Pin);
@@ -216,6 +230,21 @@ HAL_StatusTypeDef HAL_UART_Receive(UART_HandleTypeDef *huart, uint8_t *pData, ui
216230
ESP_LOGW(TAG, "%s: Unsupported", __FUNCTION__);
217231
return HAL_OK;
218232
}
233+
HAL_StatusTypeDef HAL_UART_Receive_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)
234+
{
235+
ESP_LOGW(TAG, "%s: Unsupported", __FUNCTION__);
236+
return HAL_OK;
237+
}
238+
HAL_StatusTypeDef HAL_UART_AbortReceive(UART_HandleTypeDef *huart)
239+
{
240+
ESP_LOGW(TAG, "%s: Unsupported", __FUNCTION__);
241+
return;
242+
}
243+
HAL_StatusTypeDef HAL_UART_AbortTransmit(UART_HandleTypeDef *huart)
244+
{
245+
ESP_LOGW(TAG, "%s: Unsupported", __FUNCTION__);
246+
return;
247+
}
219248

220249
HAL_StatusTypeDef HAL_I2C_Init(I2C_HandleTypeDef *hi2c)
221250
{

Firmware/Targets/ESP32SX/main/glue.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,23 @@ extern "C" {
2929
#define HAL_FLASH_Unlock()
3030
#define HAL_FLASH_Lock()
3131

32+
/**
33+
\brief Reverse byte order (16 bit)
34+
\details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000.
35+
\param [in] value Value to reverse
36+
\return Reversed value
37+
*/
38+
static inline int16_t __REVSH(int16_t value)
39+
{
40+
#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
41+
return (int16_t)__builtin_bswap16(value);
42+
#else
43+
int16_t result;
44+
45+
__ASM volatile ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
46+
return result;
47+
#endif
48+
}
3249

3350
#define TIM_CHANNEL_1 LEDC_CHANNEL_0
3451
#define TIM_CHANNEL_2 LEDC_CHANNEL_1
@@ -46,6 +63,7 @@ extern "C" {
4663
#endif
4764
#endif
4865

66+
void HAL_GPIO_Init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_Init);
4967
GPIO_PinState HAL_GPIO_ReadPin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin);
5068
void HAL_GPIO_WritePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState);
5169
void HAL_GPIO_TogglePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin);
@@ -89,6 +107,9 @@ HAL_StatusTypeDef HAL_UART_Transmit_DMA(UART_HandleTypeDef *huart, uint8_t *pDat
89107
HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout);
90108
HAL_StatusTypeDef HAL_UART_Transmit_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
91109
HAL_StatusTypeDef HAL_UART_Receive(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout);
110+
HAL_StatusTypeDef HAL_UART_Receive_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
111+
HAL_StatusTypeDef HAL_UART_AbortReceive(UART_HandleTypeDef *huart);
112+
HAL_StatusTypeDef HAL_UART_AbortTransmit(UART_HandleTypeDef *huart);
92113

93114
HAL_StatusTypeDef HAL_ADC_Start_DMA(ADC_HandleTypeDef *hadc, uint32_t *pData, uint32_t Length);
94115

Firmware/Targets/ESP32SX/main/stm32f4xx_hal.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,40 @@ typedef enum
120120
#define GPIO_PIN_47 (47)
121121
#define GPIO_PIN_48 (48)
122122

123+
/**
124+
* @brief GPIO Init structure definition
125+
*/
126+
typedef struct
127+
{
128+
uint32_t Pin; /*!< Specifies the GPIO pins to be configured.
129+
This parameter can be any value of @ref GPIO_pins_define */
130+
131+
uint32_t Mode; /*!< Specifies the operating mode for the selected pins.
132+
This parameter can be a value of @ref GPIO_mode_define */
133+
134+
uint32_t Pull; /*!< Specifies the Pull-up or Pull-Down activation for the selected pins.
135+
This parameter can be a value of @ref GPIO_pull_define */
136+
137+
uint32_t Speed; /*!< Specifies the speed for the selected pins.
138+
This parameter can be a value of @ref GPIO_speed_define */
139+
140+
uint32_t Alternate; /*!< Peripheral to be connected to the selected pins.
141+
This parameter can be a value of @ref GPIO_Alternate_function_selection */
142+
}GPIO_InitTypeDef;
143+
144+
#define GPIO_MODE_INPUT GPIO_MODE_INPUT /*!< Input Floating Mode */
145+
#define GPIO_MODE_OUTPUT_PP GPIO_MODE_OUTPUT /*!< Output Push Pull Mode */
146+
#define GPIO_MODE_OUTPUT_OD GPIO_MODE_OUTPUT_OD /*!< Output Open Drain Mode */
147+
148+
#define GPIO_NOPULL GPIO_PULLUP_DISABLE /*!< No Pull-up or Pull-down activation */
149+
#define GPIO_PULLUP GPIO_PULLUP_ENABLE /*!< Pull-up activation */
150+
#define GPIO_PULLDOWN GPIO_PULLDOWN_ENABLE /*!< Pull-down activation */
151+
152+
#define GPIO_SPEED_FREQ_LOW 0x00000000U /*!< IO works at 2 MHz, please refer to the product datasheet */
153+
#define GPIO_SPEED_FREQ_MEDIUM 0x00000001U /*!< range 12,5 MHz to 50 MHz, please refer to the product datasheet */
154+
#define GPIO_SPEED_FREQ_HIGH 0x00000002U /*!< range 25 MHz to 100 MHz, please refer to the product datasheet */
155+
#define GPIO_SPEED_FREQ_VERY_HIGH 0x00000003U /*!< range 50 MHz to 200 MHz, please refer to the product datasheet */
156+
123157
typedef struct {
124158
twai_timing_config_t t_config;
125159
TaskHandle_t task;
@@ -431,6 +465,7 @@ typedef struct
431465
typedef struct {
432466
UART_InitTypeDef Init;
433467
uint32_t a;
468+
uint32_t ErrorCode;
434469
} UART_HandleTypeDef;
435470

436471

0 commit comments

Comments
 (0)