diff --git a/bsl/csl/interfaces/delay.hpp b/bsl/csl/interfaces/delay.hpp new file mode 100644 index 0000000..6e81ac1 --- /dev/null +++ b/bsl/csl/interfaces/delay.hpp @@ -0,0 +1,16 @@ +#ifndef _DELAY_H_ +#define _DELAY_H_ + +#include + +class Delay +{ + public: + Delay(); + ~Delay(); + void us(uint16_t delay); + private: +}; + +#endif + diff --git a/bsl/csl/interfaces/pin.hpp b/bsl/csl/interfaces/pin.hpp index 3d0e48d..d53381b 100644 --- a/bsl/csl/interfaces/pin.hpp +++ b/bsl/csl/interfaces/pin.hpp @@ -3,7 +3,6 @@ #include #include -#include class Pin { diff --git a/bsl/csl/stm32f042/Src/CMakeLists.txt b/bsl/csl/stm32f042/Src/CMakeLists.txt index 82b5f71..563e4a6 100644 --- a/bsl/csl/stm32f042/Src/CMakeLists.txt +++ b/bsl/csl/stm32f042/Src/CMakeLists.txt @@ -22,3 +22,10 @@ target_compile_options(stmGpio PRIVATE ${C_FLAGS}) target_compile_definitions(stmGpio PRIVATE ${C_DEFS}) target_include_directories(stmGpio PUBLIC ${INTERFACES_DIR} ${CSL_INCLUDES}) add_library(sub::gpio ALIAS stmGpio) + +add_library(stmDelay delay.cpp) + +target_compile_options(stmDelay PRIVATE ${C_FLAGS}) +target_compile_definitions(stmDelay PRIVATE ${C_DEFS}) +target_include_directories(stmDelay PUBLIC ${INTERFACES_DIR} ${CSL_INCLUDES}) +add_library(sub::delay ALIAS stmDelay) diff --git a/bsl/csl/stm32f042/Src/delay.cpp b/bsl/csl/stm32f042/Src/delay.cpp new file mode 100644 index 0000000..aabf707 --- /dev/null +++ b/bsl/csl/stm32f042/Src/delay.cpp @@ -0,0 +1,19 @@ +#include "delay.hpp" +#include "../Inc/stm32f0xx_csl.h" + + + +Delay::Delay() +{ + +} + +Delay::~Delay() +{ + +} + +void Delay::us(uint16_t delay) +{ + LL_mDelay(delay); +} diff --git a/bsl/csl/stm32f042/Src/stm32f0xx_csl.c b/bsl/csl/stm32f042/Src/stm32f0xx_csl.c index 245476a..5029e8b 100644 --- a/bsl/csl/stm32f042/Src/stm32f0xx_csl.c +++ b/bsl/csl/stm32f042/Src/stm32f0xx_csl.c @@ -141,17 +141,15 @@ void SystemClock_Config(void) * @param None * @retval None */ +/* static void MX_GPIO_Init(void) { LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - /* GPIO Ports Clock Enable */ LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOB); - /**/ LL_GPIO_ResetOutputPin(LED_G_GPIO_Port, LED_G_Pin); - /**/ GPIO_InitStruct.Pin = LED_G_Pin; GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; @@ -160,7 +158,7 @@ static void MX_GPIO_Init(void) LL_GPIO_Init(LED_G_GPIO_Port, &GPIO_InitStruct); } - +*/ /* USER CODE BEGIN 4 */ /* USER CODE END 4 */ diff --git a/bsl/nucleo_f042k6/bslConfig.cmake b/bsl/nucleo_f042k6/bslConfig.cmake index f7dfb43..9406819 100644 --- a/bsl/nucleo_f042k6/bslConfig.cmake +++ b/bsl/nucleo_f042k6/bslConfig.cmake @@ -75,3 +75,4 @@ list(APPEND EXTRA_LIBS sub::startup) list(APPEND EXTRA_LIBS sub::translator) list(APPEND EXTRA_LIBS sub::sources) list(APPEND EXTRA_LIBS sub::gpio) +list(APPEND EXTRA_LIBS sub::delay) diff --git a/bsl/nucleo_f042k6/bsl_nucleo_f042k6.cpp b/bsl/nucleo_f042k6/bsl_nucleo_f042k6.cpp index 337fa18..0a41826 100644 --- a/bsl/nucleo_f042k6/bsl_nucleo_f042k6.cpp +++ b/bsl/nucleo_f042k6/bsl_nucleo_f042k6.cpp @@ -1,17 +1,19 @@ #include "bsl_nucleo_f042k6.hpp" #include "../csl/interfaces/pin.hpp" +#include "../csl/interfaces/delay.hpp" int startBSL() { stmStart(); Pin pin; - + Delay delay; + while(1) { - LL_mDelay(50); + delay.us(500); pin.write(true); - LL_mDelay(50); + delay.us(500); pin.write(false); }