Skip to content

File Bsp.hpp

FileList > fw > rbcx-coprocessor > include > Bsp.hpp

Go to the source code of this file.

  • #include "FreeRTOSConfig.h"
  • #include "stm32f1xx_hal.h"
  • #include "stm32f1xx_hal_cortex.h"
  • #include "stm32f1xx_hal_gpio.h"
  • #include "stm32f1xx_ll_adc.h"
  • #include "stm32f1xx_ll_dma.h"
  • #include "stm32f1xx_ll_utils.h"
  • #include <algorithm>
  • #include <array>
  • #include <cassert>

Public Types

Type Name
typedef uint32_t ADC_channel_t
typedef uint32_t ADC_rank_t
typedef uint32_t DMA_channel_t
typedef std::pair< GPIO_TypeDef *, uint16_t > PinDef

Public Attributes

Type Name
ADC_TypeDef *const auxiliaryAdc = = ADC1
const IRQn_Type auxiliaryAndMotorAdcIRQn = = ADC1_2_IRQn
const unsigned auxiliaryAndMotorAdcIrqPrio = = 9
const ADC_channel_t batteryMiddleVoltageAdcChannel = = LL_ADC_CHANNEL_3
const ADC_rank_t batteryMiddleVoltageAdcRank = = LL_ADC_INJ_RANK_3
const PinDef batteryMiddleVoltagePin = = std::make_pair(GPIOA, GPIO_PIN_3)
const ADC_channel_t batteryVoltageAdcChannel = = LL_ADC_CHANNEL_6
const ADC_rank_t batteryVoltageAdcRank = = LL_ADC_INJ_RANK_1
const PinDef batteryVoltagePin = = std::make_pair(GPIOA, GPIO_PIN_6)
const PinDef button1Pin = = std::make_pair(GPIOE, GPIO_PIN_0)
const PinDef button2Pin = = std::make_pair(GPIOD, GPIO_PIN_10)
const PinDef button3Pin = = std::make_pair(GPIOB, GPIO_PIN_2)
const PinDef button4Pin = = std::make_pair(GPIOD, GPIO_PIN_11)
const PinDef buttonOffPin = = std::make_pair(GPIOE, GPIO_PIN_15)
const PinDef buttonOnPin = = std::make_pair(GPIOD, GPIO_PIN_14)
const std::array< PinDef, 6 > buttonPin = = { buttonOffPin, button1Pin,
button2Pin, button3Pin, button4Pin, buttonOnPin }
const PinDef buzzerPin = = std::make_pair(GPIOD, GPIO_PIN_3)
USART_TypeDef *const controlUart = = USART3
DMA_Channel_TypeDef *const controlUartRxDmaChannel = = DMA1_Channel3
const PinDef controlUartRxPin = = std::make_pair(GPIOB, GPIO_PIN_11)
DMA_Channel_TypeDef *const controlUartTxDmaChannel = = DMA1_Channel2
const IRQn_Type controlUartTxDmaIRQn = = DMA1_Channel2_IRQn
const unsigned controlUartTxDmaIRQnPrio = = 8
const PinDef controlUartTxPin = = std::make_pair(GPIOB, GPIO_PIN_10)
USART_TypeDef *const debugUart = = UART4
const IRQn_Type debugUartIRQn = = UART4_IRQn
const unsigned debugUartIrqPrio = = 10
DMA_Channel_TypeDef *const debugUartRxDmaChannel = = DMA2_Channel3
const PinDef debugUartRxPin = = std::make_pair(GPIOC, GPIO_PIN_11)
DMA_Channel_TypeDef *const debugUartTxDmaChannel = = DMA2_Channel5
const IRQn_Type debugUartTxDmaIRQn = = DMA2_Channel4_5_IRQn
const unsigned debugUartTxDmaIrqPrio = = 9
const PinDef debugUartTxPin = = std::make_pair(GPIOC, GPIO_PIN_10)
const PinDef encoder1aPin = = std::make_pair(GPIOD, GPIO_PIN_12)
const PinDef encoder1bPin = = std::make_pair(GPIOD, GPIO_PIN_13)
const PinDef encoder2aPin = = std::make_pair(GPIOA, GPIO_PIN_0)
const PinDef encoder2bPin = = std::make_pair(GPIOA, GPIO_PIN_1)
const PinDef encoder3aPin = = std::make_pair(GPIOA, GPIO_PIN_15)
const PinDef encoder3bPin = = std::make_pair(GPIOB, GPIO_PIN_3)
const PinDef encoder4aPin = = std::make_pair(GPIOB, GPIO_PIN_4)
const PinDef encoder4bPin = = std::make_pair(GPIOB, GPIO_PIN_5)
TIM_TypeDef *const encoderTimer = = { TIM4, TIM5, TIM2, TIM3 }
const PinDef esp0Pin = = std::make_pair(GPIOB, GPIO_PIN_10)
const PinDef esp12Pin = = std::make_pair(GPIOB, GPIO_PIN_15)
const PinDef esp15Pin = = std::make_pair(GPIOB, GPIO_PIN_14)
const PinDef esp2Pin = = std::make_pair(GPIOB, GPIO_PIN_11)
const PinDef espEnPin = = std::make_pair(GPIOD, GPIO_PIN_4)
const IRQn_Type i2cErIRQn = = I2C1_ER_IRQn
const IRQn_Type i2cEvIRQn = = I2C1_EV_IRQn
const unsigned i2cIRQnPrio = = 8
const int i2cPrio = = 2
const PinDef i2cScl = = std::make_pair(GPIOB, GPIO_PIN_8)
const PinDef i2cSda = = std::make_pair(GPIOB, GPIO_PIN_9)
const PinDef in4aPin = = std::make_pair(IN4PORT, IN4AMASK)
const PinDef in4bPin = = std::make_pair(IN4PORT, IN4BMASK)
const ADC_rank_t internalReferenceVoltageAdcRank = = LL_ADC_INJ_RANK_2
const PinDef led1Pin = = std::make_pair(GPIOA, GPIO_PIN_7)
const PinDef led2Pin = = std::make_pair(GPIOA, GPIO_PIN_8)
const PinDef led3Pin = = std::make_pair(GPIOA, GPIO_PIN_9)
const PinDef led4Pin = = std::make_pair(GPIOA, GPIO_PIN_10)
const std::array< PinDef, 4 > ledPin = = { led1Pin, led2Pin, led3Pin, led4Pin }
const PinDef ledPins = = std::make_pair(
GPIOA, led1Pin.second | led2Pin.second | led3Pin.second | led4Pin.second)
const int mainTaskPrio = = 4
const int motorTaskPrio = = 2
const PinDef powerPin = = std::make_pair(GPIOC, GPIO_PIN_13)
const PinDef pwm1aPin = = std::make_pair(GPIOE, GPIO_PIN_9)
const PinDef pwm1bPin = = std::make_pair(GPIOE, GPIO_PIN_8)
const PinDef pwm2aPin = = std::make_pair(GPIOE, GPIO_PIN_11)
const PinDef pwm2bPin = = std::make_pair(GPIOE, GPIO_PIN_10)
const PinDef pwm3aPin = = std::make_pair(GPIOE, GPIO_PIN_13)
const PinDef pwm3bPin = = std::make_pair(GPIOE, GPIO_PIN_12)
const PinDef pwm4Pin = = std::make_pair(GPIOE, GPIO_PIN_14)
TIM_TypeDef *const pwmTimer = = TIM1
const PinDef servo1Pin = = std::make_pair(GPIOC, GPIO_PIN_6)
const PinDef servo2Pin = = std::make_pair(GPIOC, GPIO_PIN_7)
const PinDef servo3Pin = = std::make_pair(GPIOC, GPIO_PIN_8)
const PinDef servo4Pin = = std::make_pair(GPIOC, GPIO_PIN_9)
const PinDef servoPins = = std::make_pair(GPIOC,
servo1Pin.second | servo2Pin.second | servo3Pin.second | servo4Pin.second)
TIM_TypeDef *const servoTimer = = TIM8
USART_TypeDef *const servoUart = = UART5
const IRQn_Type servoUartIRQn = = UART5_IRQn
const unsigned servoUartIrqPrio = = 9
const PinDef servoUartTxRxPin = = std::make_pair(GPIOC, GPIO_PIN_12)
const int softResetTaskPrio = = configMAX_PRIORITIES - 1
const ADC_rank_t temperatureAdcRank = = LL_ADC_INJ_RANK_4
USART_TypeDef *const tunnelUart = = USART2
DMA_Channel_TypeDef *const tunnelUartRxDmaChannel = = DMA1_Channel6
const PinDef tunnelUartRxPin = = std::make_pair(GPIOD, GPIO_PIN_6)
DMA_Channel_TypeDef *const tunnelUartTxDmaChannel = = DMA1_Channel7
const PinDef tunnelUartTxPin = = std::make_pair(GPIOD, GPIO_PIN_5)
const int ultrasoundTaskPrio = = 2
const PinDef usbBusDetectionPin = = std::make_pair(GPIOA, GPIO_PIN_2)
const PinDef usbDnPin = = std::make_pair(GPIOA, GPIO_PIN_11)
const PinDef usbDpPin = = std::make_pair(GPIOA, GPIO_PIN_12)
const PinDef usbDpPullUpPin = = std::make_pair(USBD_DP_PORT, 1 << USBD_DP_PIN)
const IRQn_Type usbLpIRQn = = USB_LP_CAN1_RX0_IRQn
constexpr unsigned usbLpIRQnPrio = = 8
USART_TypeDef *const userUart = = USART1
const PinDef userUartRxPin = = std::make_pair(GPIOB, GPIO_PIN_7)
const PinDef userUartTxPin = = std::make_pair(GPIOB, GPIO_PIN_6)
const PinDef uts1EchoPin = = std::make_pair(GPIOE, GPIO_PIN_6)
const PinDef uts1TrigPin = = std::make_pair(GPIOE, GPIO_PIN_1)
const PinDef uts2EchoPin = = std::make_pair(GPIOD, GPIO_PIN_7)
const PinDef uts2TrigPin = = std::make_pair(GPIOE, GPIO_PIN_2)
const PinDef uts3EchoPin = = std::make_pair(GPIOD, GPIO_PIN_8)
const PinDef uts3TrigPin = = std::make_pair(GPIOE, GPIO_PIN_3)
const PinDef uts4EchoPin = = std::make_pair(GPIOD, GPIO_PIN_9)
const PinDef uts4TrigPin = = std::make_pair(GPIOE, GPIO_PIN_4)
const std::array< PinDef, 4 > utsEchoPin = = { uts1EchoPin, uts2EchoPin, uts3EchoPin, uts4EchoPin }
const uint32_t utsIRQPrio = = 7
TIM_TypeDef *const utsTimer = = TIM7
const std::array< PinDef, 4 > utsTrigPin = = { uts1TrigPin, uts2TrigPin, uts3TrigPin, uts4TrigPin }

Public Functions

Type Name
void LL_ADC_SetChannelSamplingTimeFix (ADC_TypeDef * ADCx, uint32_t Channel, uint32_t SamplingTime)
void LL_GPIO_AF_Remap (uint32_t mask, uint32_t value)
void clocksInit ()
uint32_t getButtons ()
bool isPressed (PinDef button)
void pinInit (GPIO_TypeDef * port, uint32_t pinMask, uint32_t mode, uint32_t pull, uint32_t speed, bool deInitFirst=false)
void pinInit (PinDef pin, uint32_t mode, uint32_t pull, uint32_t speed, bool deInitFirst=false)
bool pinRead (PinDef pin)
void pinToggle (PinDef pin)
void pinWrite (PinDef pin, bool value)
void pinsInit ()
void reinitEspStrappingPins ()
void setLeds (uint32_t ledsOn)
void softReset ()
void softResetInit ()

Macros

Type Name
define AFIO_MAPR_RESERVED 0xF8E00000
define AUXILIARY_AND_MOTOR_ADC_IRQ_HANDLER ADC1_2_IRQHandler
define CONTROLUART_TX_DMA_HANDLER DMA1_Channel2_IRQHandler
define DEBUGUART_HANDLER UART4_IRQHandler
define DEBUGUART_TX_DMA_HANDLER DMA2_Channel4_5_IRQHandler
define IN4AMASK GPIO_PIN_5
define IN4BMASK GPIO_PIN_7
define IN4PORT GPIOE
define SERVOUART_HANDLER UART5_IRQHandler
define USB_LP_IRQ_HANDLER USB_LP_CAN1_RX0_IRQHandler

Public Types Documentation

typedef ADC_channel_t

typedef uint32_t ADC_channel_t;

typedef ADC_rank_t

typedef uint32_t ADC_rank_t;

typedef DMA_channel_t

typedef uint32_t DMA_channel_t;

typedef PinDef

using PinDef =  std::pair<GPIO_TypeDef*, uint16_t>;

Public Attributes Documentation

variable auxiliaryAdc

ADC_TypeDef* const auxiliaryAdc;

variable auxiliaryAndMotorAdcIRQn

const IRQn_Type auxiliaryAndMotorAdcIRQn;

variable auxiliaryAndMotorAdcIrqPrio

const unsigned auxiliaryAndMotorAdcIrqPrio;

variable batteryMiddleVoltageAdcChannel

const ADC_channel_t batteryMiddleVoltageAdcChannel;

variable batteryMiddleVoltageAdcRank

const ADC_rank_t batteryMiddleVoltageAdcRank;

variable batteryMiddleVoltagePin

const PinDef batteryMiddleVoltagePin;

variable batteryVoltageAdcChannel

const ADC_channel_t batteryVoltageAdcChannel;

variable batteryVoltageAdcRank

const ADC_rank_t batteryVoltageAdcRank;

variable batteryVoltagePin

const PinDef batteryVoltagePin;

variable button1Pin

const PinDef button1Pin;

variable button2Pin

const PinDef button2Pin;

variable button3Pin

const PinDef button3Pin;

variable button4Pin

const PinDef button4Pin;

variable buttonOffPin

const PinDef buttonOffPin;

variable buttonOnPin

const PinDef buttonOnPin;

variable buttonPin

const std::array<PinDef, 6> buttonPin;

variable buzzerPin

const PinDef buzzerPin;

variable controlUart

USART_TypeDef* const controlUart;

variable controlUartRxDmaChannel

DMA_Channel_TypeDef* const controlUartRxDmaChannel;

variable controlUartRxPin

const PinDef controlUartRxPin;

variable controlUartTxDmaChannel

DMA_Channel_TypeDef* const controlUartTxDmaChannel;

variable controlUartTxDmaIRQn

const IRQn_Type controlUartTxDmaIRQn;

variable controlUartTxDmaIRQnPrio

const unsigned controlUartTxDmaIRQnPrio;

variable controlUartTxPin

const PinDef controlUartTxPin;

variable debugUart

USART_TypeDef* const debugUart;

variable debugUartIRQn

const IRQn_Type debugUartIRQn;

variable debugUartIrqPrio

const unsigned debugUartIrqPrio;

variable debugUartRxDmaChannel

DMA_Channel_TypeDef* const debugUartRxDmaChannel;

variable debugUartRxPin

const PinDef debugUartRxPin;

variable debugUartTxDmaChannel

DMA_Channel_TypeDef* const debugUartTxDmaChannel;

variable debugUartTxDmaIRQn

const IRQn_Type debugUartTxDmaIRQn;

variable debugUartTxDmaIrqPrio

const unsigned debugUartTxDmaIrqPrio;

variable debugUartTxPin

const PinDef debugUartTxPin;

variable encoder1aPin

const PinDef encoder1aPin;

variable encoder1bPin

const PinDef encoder1bPin;

variable encoder2aPin

const PinDef encoder2aPin;

variable encoder2bPin

const PinDef encoder2bPin;

variable encoder3aPin

const PinDef encoder3aPin;

variable encoder3bPin

const PinDef encoder3bPin;

variable encoder4aPin

const PinDef encoder4aPin;

variable encoder4bPin

const PinDef encoder4bPin;

variable encoderTimer

TIM_TypeDef* const encoderTimer[4];

variable esp0Pin

const PinDef esp0Pin;

variable esp12Pin

const PinDef esp12Pin;

variable esp15Pin

const PinDef esp15Pin;

variable esp2Pin

const PinDef esp2Pin;

variable espEnPin

const PinDef espEnPin;

variable i2cErIRQn

const IRQn_Type i2cErIRQn;

variable i2cEvIRQn

const IRQn_Type i2cEvIRQn;

variable i2cIRQnPrio

const unsigned i2cIRQnPrio;

variable i2cPrio

const int i2cPrio;

variable i2cScl

const PinDef i2cScl;

variable i2cSda

const PinDef i2cSda;

variable in4aPin

const PinDef in4aPin;

variable in4bPin

const PinDef in4bPin;

variable internalReferenceVoltageAdcRank

const ADC_rank_t internalReferenceVoltageAdcRank;

variable led1Pin

const PinDef led1Pin;

variable led2Pin

const PinDef led2Pin;

variable led3Pin

const PinDef led3Pin;

variable led4Pin

const PinDef led4Pin;

variable ledPin

const std::array<PinDef, 4> ledPin;

variable ledPins

const PinDef ledPins;

variable mainTaskPrio

const int mainTaskPrio;

variable motorTaskPrio

const int motorTaskPrio;

variable powerPin

const PinDef powerPin;

variable pwm1aPin

const PinDef pwm1aPin;

variable pwm1bPin

const PinDef pwm1bPin;

variable pwm2aPin

const PinDef pwm2aPin;

variable pwm2bPin

const PinDef pwm2bPin;

variable pwm3aPin

const PinDef pwm3aPin;

variable pwm3bPin

const PinDef pwm3bPin;

variable pwm4Pin

const PinDef pwm4Pin;

variable pwmTimer

TIM_TypeDef* const pwmTimer;

variable servo1Pin

const PinDef servo1Pin;

variable servo2Pin

const PinDef servo2Pin;

variable servo3Pin

const PinDef servo3Pin;

variable servo4Pin

const PinDef servo4Pin;

variable servoPins

const PinDef servoPins;

variable servoTimer

TIM_TypeDef* const servoTimer;

variable servoUart

USART_TypeDef* const servoUart;

variable servoUartIRQn

const IRQn_Type servoUartIRQn;

variable servoUartIrqPrio

const unsigned servoUartIrqPrio;

variable servoUartTxRxPin

const PinDef servoUartTxRxPin;

variable softResetTaskPrio

const int softResetTaskPrio;

variable temperatureAdcRank

const ADC_rank_t temperatureAdcRank;

variable tunnelUart

USART_TypeDef* const tunnelUart;

variable tunnelUartRxDmaChannel

DMA_Channel_TypeDef* const tunnelUartRxDmaChannel;

variable tunnelUartRxPin

const PinDef tunnelUartRxPin;

variable tunnelUartTxDmaChannel

DMA_Channel_TypeDef* const tunnelUartTxDmaChannel;

variable tunnelUartTxPin

const PinDef tunnelUartTxPin;

variable ultrasoundTaskPrio

const int ultrasoundTaskPrio;

variable usbBusDetectionPin

const PinDef usbBusDetectionPin;

variable usbDnPin

const PinDef usbDnPin;

variable usbDpPin

const PinDef usbDpPin;

variable usbDpPullUpPin

const PinDef usbDpPullUpPin;

variable usbLpIRQn

const IRQn_Type usbLpIRQn;

variable usbLpIRQnPrio

constexpr unsigned usbLpIRQnPrio;

variable userUart

USART_TypeDef* const userUart;

variable userUartRxPin

const PinDef userUartRxPin;

variable userUartTxPin

const PinDef userUartTxPin;

variable uts1EchoPin

const PinDef uts1EchoPin;

variable uts1TrigPin

const PinDef uts1TrigPin;

variable uts2EchoPin

const PinDef uts2EchoPin;

variable uts2TrigPin

const PinDef uts2TrigPin;

variable uts3EchoPin

const PinDef uts3EchoPin;

variable uts3TrigPin

const PinDef uts3TrigPin;

variable uts4EchoPin

const PinDef uts4EchoPin;

variable uts4TrigPin

const PinDef uts4TrigPin;

variable utsEchoPin

const std::array<PinDef, 4> utsEchoPin;

variable utsIRQPrio

const uint32_t utsIRQPrio;

variable utsTimer

TIM_TypeDef* const utsTimer;

variable utsTrigPin

const std::array<PinDef, 4> utsTrigPin;

Public Functions Documentation

function LL_ADC_SetChannelSamplingTimeFix

inline void LL_ADC_SetChannelSamplingTimeFix (
    ADC_TypeDef * ADCx,
    uint32_t Channel,
    uint32_t SamplingTime
) 

function LL_GPIO_AF_Remap

inline void LL_GPIO_AF_Remap (
    uint32_t mask,
    uint32_t value
) 

function clocksInit

inline void clocksInit () 

function getButtons

inline uint32_t getButtons () 

function isPressed

inline bool isPressed (
    PinDef button
) 

function pinInit

inline void pinInit (
    GPIO_TypeDef * port,
    uint32_t pinMask,
    uint32_t mode,
    uint32_t pull,
    uint32_t speed,
    bool deInitFirst=false
) 

function pinInit

inline void pinInit (
    PinDef pin,
    uint32_t mode,
    uint32_t pull,
    uint32_t speed,
    bool deInitFirst=false
) 

function pinRead

inline bool pinRead (
    PinDef pin
) 

function pinToggle

inline void pinToggle (
    PinDef pin
) 

function pinWrite

inline void pinWrite (
    PinDef pin,
    bool value
) 

function pinsInit

inline void pinsInit () 

function reinitEspStrappingPins

inline void reinitEspStrappingPins () 

function setLeds

inline void setLeds (
    uint32_t ledsOn
) 

function softReset

void softReset () 

function softResetInit

void softResetInit () 

Macro Definition Documentation

define AFIO_MAPR_RESERVED

#define AFIO_MAPR_RESERVED 0xF8E00000

define AUXILIARY_AND_MOTOR_ADC_IRQ_HANDLER

#define AUXILIARY_AND_MOTOR_ADC_IRQ_HANDLER ADC1_2_IRQHandler

define CONTROLUART_TX_DMA_HANDLER

#define CONTROLUART_TX_DMA_HANDLER DMA1_Channel2_IRQHandler

define DEBUGUART_HANDLER

#define DEBUGUART_HANDLER UART4_IRQHandler

define DEBUGUART_TX_DMA_HANDLER

#define DEBUGUART_TX_DMA_HANDLER DMA2_Channel4_5_IRQHandler

define IN4AMASK

#define IN4AMASK GPIO_PIN_5

define IN4BMASK

#define IN4BMASK GPIO_PIN_7

define IN4PORT

#define IN4PORT GPIOE

define SERVOUART_HANDLER

#define SERVOUART_HANDLER UART5_IRQHandler

define USB_LP_IRQ_HANDLER

#define USB_LP_IRQ_HANDLER USB_LP_CAN1_RX0_IRQHandler

The documentation for this class was generated from the following file fw/rbcx-coprocessor/include/Bsp.hpp