Added a very simple delay.cpp interface

interrupts
key 4 years ago
parent 2530ee3804
commit 93dae2698b

@ -0,0 +1,16 @@
#ifndef _DELAY_H_
#define _DELAY_H_
#include <stdint.h>
class Delay
{
public:
Delay();
~Delay();
void us(uint16_t delay);
private:
};
#endif

@ -3,7 +3,6 @@
#include <unistd.h>
#include <stdint.h>
#include <memory>
class Pin
{

@ -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)

@ -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);
}

@ -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 */

@ -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)

@ -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);
}

Loading…
Cancel
Save