diff --git a/include/sta/gpio_pin.hpp b/include/sta/gpio_pin.hpp index 9a26f4c..3ab32be 100644 --- a/include/sta/gpio_pin.hpp +++ b/include/sta/gpio_pin.hpp @@ -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. * diff --git a/src/devices/stm32/can.cpp b/src/devices/stm32/can.cpp index 7a5cd59..47e9c97 100644 --- a/src/devices/stm32/can.cpp +++ b/src/devices/stm32/can.cpp @@ -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 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); } } } diff --git a/src/gpio_pin.cpp b/src/gpio_pin.cpp new file mode 100644 index 0000000..aafd52e --- /dev/null +++ b/src/gpio_pin.cpp @@ -0,0 +1,20 @@ +#include + + +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