Merge branch 'main' into delay_fixup

This commit is contained in:
ivetagench 2024-05-01 12:04:21 +00:00
commit 7aac2badc5
3 changed files with 46 additions and 7 deletions

View File

@ -38,6 +38,24 @@ namespace sta
*/
virtual void setState(GpioPinState state) = 0;
/**
* @brief Set the GPIO pin to high.
*
*/
void setHigh();
/**
* @brief Set the GPIO pin to low.
*
*/
void setLow();
/**
* @brief Set the GPIO pin to the opposite of the current state.
*
*/
void toggle();
/**
* @brief Get pin input state.
*

View File

@ -166,6 +166,7 @@ namespace sta
config->FilterScale = CAN_FILTERSCALE_32BIT;
config->FilterActivation = CAN_FILTER_DISABLE;
config->SlaveStartFilterBank = MAX_FILTER_COUNT;
HAL_CAN_ConfigFilter(handle_, config);
}
}
@ -203,16 +204,16 @@ namespace sta
} // namespace sta
#ifdef STA_STM32_CAN_GLOBAL
#ifdef STA_STM32_CAN_HANDLE
#include <can.h>
namespace sta
{
STM32CanController CanBus(&STA_STM32_CAN_GLOBAL);
STM32CanController CanBus(&STA_STM32_CAN_HANDLE);
STA_WEAK
void CanBus_RxPendingCallback()
void CanBus_RxPendingCallback(uint32_t fifo)
{}
} // namespace sta
@ -221,17 +222,17 @@ extern "C"
{
void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan)
{
if (hcan == &STA_STM32_CAN_GLOBAL)
if (hcan == &STA_STM32_CAN_HANDLE)
{
sta::CanBus_RxPendingCallback();
sta::CanBus_RxPendingCallback(CAN_RX_FIFO0);
}
}
void HAL_CAN_RxFifo1MsgPendingCallback(CAN_HandleTypeDef *hcan)
{
if (hcan == &STA_STM32_CAN_GLOBAL)
if (hcan == &STA_STM32_CAN_HANDLE)
{
sta::CanBus_RxPendingCallback();
sta::CanBus_RxPendingCallback(CAN_RX_FIFO1);
}
}
}

20
src/gpio_pin.cpp Normal file
View File

@ -0,0 +1,20 @@
#include <sta/gpio_pin.hpp>
namespace sta
{
void GpioPin::setHigh()
{
setState(GpioPinState::GPIO_HIGH);
}
void GpioPin::setLow()
{
setState(GpioPinState::GPIO_LOW);
}
void GpioPin::toggle()
{
setState(getState() == GpioPinState::GPIO_HIGH ? GpioPinState::GPIO_LOW : GpioPinState::GPIO_HIGH);
}
} // namespace sta