Skip to content

Commit

Permalink
chore(hal): remove StdPeriph (#5023)
Browse files Browse the repository at this point in the history
Co-authored-by: raphaelcoeffic <1050031+raphaelcoeffic@users.noreply.github.com>
Co-authored-by: Malte Langermann <malte@langermann.net>
Co-authored-by: 3djc <3djc@gh.com>
Co-authored-by: Richard Li <richard.li@ces.hk>
  • Loading branch information
5 people authored Jun 1, 2024
1 parent fea402a commit 6579905
Show file tree
Hide file tree
Showing 247 changed files with 2,188 additions and 145,250 deletions.
11 changes: 6 additions & 5 deletions radio/src/boards/generic_stm32/analog_inputs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,14 @@ const etx_hal_adc_driver_t _adc_driver = {
};

#if defined(PWM_STICKS)
#include "stm32_gpio.h"

static const stick_pwm_timer_t _sticks_timer = {
PWM_GPIO,
PWM_GPIOA_PINS,
PWM_GPIO_AF,
PWM_TIMER,
PWM_IRQn,
.GPIOx = PWM_GPIO,
.GPIO_Pin = PWM_GPIOA_PINS,
.GPIO_Alternate = PWM_GPIO_AF,
.TIMx = PWM_TIMER,
.TIM_IRQn = PWM_IRQn,
};

#if !defined(PWM_IRQHandler)
Expand Down
49 changes: 20 additions & 29 deletions radio/src/boards/generic_stm32/aux_ports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@
*/

#include "hal/serial_port.h"
#include "hal/gpio.h"

#include "stm32_serial_driver.h"
#include "stm32_gpio_driver.h"
#include "stm32_gpio.h"

#include "board.h"
#include "dataconstants.h"
Expand All @@ -34,53 +37,41 @@
#endif

#if defined(AUX_SERIAL_PWR_GPIO) || defined(AUX2_SERIAL_PWR_GPIO)
static void _aux_pwr(GPIO_TypeDef *GPIOx, uint32_t pin, uint8_t on)
static void _aux_pwr(gpio_t pin, uint8_t on)
{
stm32_gpio_enable_clock(GPIOx);
LL_GPIO_InitTypeDef pinInit;
LL_GPIO_StructInit(&pinInit);
pinInit.Pin = pin;
pinInit.Mode = LL_GPIO_MODE_OUTPUT;
pinInit.Pull = LL_GPIO_PULL_UP;
LL_GPIO_Init(GPIOx, &pinInit);

if (on) {
LL_GPIO_SetOutputPin(GPIOx, pin);
} else {
LL_GPIO_ResetOutputPin(GPIOx, pin);
}
gpio_init(pin, GPIO_OUT, GPIO_PIN_SPEED_LOW);
gpio_write(pin, on);
}
#endif

#if defined(AUX_SERIAL)

#if !defined(AUX_SERIAL_DMA_TX)
#define AUX_SERIAL_DMA_TX nullptr
#define AUX_SERIAL_DMA_Stream_TX nullptr
#define AUX_SERIAL_DMA_Stream_TX_LL 0
#define AUX_SERIAL_DMA_Channel_TX 0
#define AUX_SERIAL_DMA_TX_STREAM 0
#define AUX_SERIAL_DMA_TX_CHANNEL 0
#endif

static const stm32_usart_t auxUSART = {
.USARTx = AUX_SERIAL_USART,
.GPIOx = AUX_SERIAL_GPIO,
.GPIO_Pin = AUX_SERIAL_GPIO_PIN_TX | AUX_SERIAL_GPIO_PIN_RX,
.txGPIO = AUX_SERIAL_TX_GPIO,
.rxGPIO = AUX_SERIAL_RX_GPIO,
.IRQn = AUX_SERIAL_USART_IRQn,
.IRQ_Prio = 7, // TODO: define constant
.txDMA = AUX_SERIAL_DMA_TX,
.txDMA_Stream = AUX_SERIAL_DMA_Stream_TX_LL,
.txDMA_Channel = AUX_SERIAL_DMA_Channel_TX,
.txDMA_Stream = AUX_SERIAL_DMA_TX_STREAM,
.txDMA_Channel = AUX_SERIAL_DMA_TX_CHANNEL,
.rxDMA = AUX_SERIAL_DMA_RX,
.rxDMA_Stream = AUX_SERIAL_DMA_Stream_RX_LL,
.rxDMA_Channel = AUX_SERIAL_DMA_Channel_RX,
.rxDMA_Stream = AUX_SERIAL_DMA_RX_STREAM,
.rxDMA_Channel = AUX_SERIAL_DMA_RX_CHANNEL,
};

DEFINE_STM32_SERIAL_PORT(Aux, auxUSART, AUX_SERIAL_RX_BUFFER, AUX_SERIAL_TX_BUFFER);

#if defined(AUX_SERIAL_PWR_GPIO)
void set_aux_pwr(uint8_t on)
{
_aux_pwr(AUX_SERIAL_PWR_GPIO, AUX_SERIAL_PWR_GPIO_PIN, on);
_aux_pwr(AUX_SERIAL_PWR_GPIO, on);
}
#define AUX_PWR_FCT set_aux_pwr
#else
Expand All @@ -102,24 +93,24 @@ const etx_serial_port_t auxSerialPort = {

static const stm32_usart_t aux2USART = {
.USARTx = AUX2_SERIAL_USART,
.GPIOx = AUX2_SERIAL_GPIO,
.GPIO_Pin = AUX2_SERIAL_GPIO_PIN_TX | AUX2_SERIAL_GPIO_PIN_RX,
.txGPIO = AUX2_SERIAL_TX_GPIO,
.rxGPIO = AUX2_SERIAL_RX_GPIO,
.IRQn = AUX2_SERIAL_USART_IRQn,
.IRQ_Prio = 7, // TODO: define constant
.txDMA = nullptr,
.txDMA_Stream = 0,
.txDMA_Channel = 0,
.rxDMA = AUX2_SERIAL_DMA_RX,
.rxDMA_Stream = AUX2_SERIAL_DMA_Stream_RX_LL,
.rxDMA_Channel = AUX2_SERIAL_DMA_Channel_RX,
.rxDMA_Stream = AUX2_SERIAL_DMA_RX_STREAM,
.rxDMA_Channel = AUX2_SERIAL_DMA_RX_CHANNEL,
};

DEFINE_STM32_SERIAL_PORT(Aux2, aux2USART, AUX_SERIAL_RX_BUFFER, AUX_SERIAL_TX_BUFFER);

#if defined(AUX2_SERIAL_PWR_GPIO)
void set_aux2_pwr(uint8_t on)
{
_aux_pwr(AUX2_SERIAL_PWR_GPIO, AUX2_SERIAL_PWR_GPIO_PIN, on);
_aux_pwr(AUX2_SERIAL_PWR_GPIO, on);
}
#define AUX2_PWR_FCT set_aux2_pwr
#else
Expand Down
29 changes: 23 additions & 6 deletions radio/src/boards/generic_stm32/bor_level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,33 @@
*/

#if defined(STM32F4)
#include "stm32f4xx_flash.h"
#include "stm32_hal.h"

void board_set_bor_level()
{
if (FLASH_OB_GetBOR() != OB_BOR_LEVEL3)
FLASH_OBProgramInitTypeDef OB;
HAL_FLASHEx_OBGetConfig(&OB);

if (OB.BORLevel != OB_BOR_LEVEL3)
{
FLASH_OB_Unlock();
FLASH_OB_BORConfig(OB_BOR_LEVEL3);
FLASH_OB_Launch();
FLASH_OB_Lock();

HAL_FLASH_Unlock();
HAL_FLASH_OB_Unlock();

OB.OptionType = OPTIONBYTE_BOR;
OB.BORLevel = OB_BOR_LEVEL3;

if ( HAL_FLASHEx_OBProgram(&OB) != HAL_OK )
{
HAL_FLASH_OB_Lock();
HAL_FLASH_Lock();
}

HAL_FLASH_OB_Launch();

HAL_FLASH_OB_Lock();
HAL_FLASH_Lock();
}

}
#endif
Loading

0 comments on commit 6579905

Please sign in to comment.