Made the LED class and it's worting at it is now wrotten but wehn i pass &ledPin i get : 'Pin' is an inaccessible base of STM_Pin<(Pin_no)3, (GPIO_Port)1207960576>

interrupts
key 4 years ago
parent 9984ab9fe9
commit 7b65c95242

@ -29,6 +29,7 @@ set(INTERFACES_DIR ${CMAKE_SOURCE_DIR}/bsl/csl/interfaces)
####################################################################################################
include(${PROJECT_DEFS})
add_subdirectory(bsl)
add_subdirectory(drivers/led)
set(BSL_HEADER_FILE ${CMAKE_SOURCE_DIR}/bsl/raspberry/bsl_raspberry.hpp)

@ -76,3 +76,4 @@ list(APPEND EXTRA_LIBS sub::translator)
list(APPEND EXTRA_LIBS sub::sources)
#list(APPEND EXTRA_LIBS sub::gpio) # TODO : PLease add this again.
list(APPEND EXTRA_LIBS sub::delay)
list(APPEND EXTRA_LIBS sub::led)

@ -5,6 +5,7 @@ Nucleo_f042k6::Nucleo_f042k6()
{
stmStart();
}
Nucleo_f042k6::~Nucleo_f042k6(){}
void Nucleo_f042k6::init()
@ -12,18 +13,24 @@ void Nucleo_f042k6::init()
ledPin.init();
ledPin.setMode(Pin::mode::output);
ledPin.setSpeed(Pin::speed::fast);
//Led ledGreen;
/*
pin_a0.init();
pin_a0.setMode(Pin::mode::input);
pin_a0.setSpeed(Pin::speed::slow);
pin_a0.setPullUpDonw(Pin::pullUpDown::pullDown);
*/
}
void Nucleo_f042k6::running()
{
ledPin.write(true);
STM_Pin<Pin_no::pin_3, GPIO_Port::Port_B_base_address> ledPin;
Led ledGreen(&ledPin);
ledGreen.on();
delay.ms(200);
ledPin.write(false);
ledGreen.off();
delay.ms(200);
}

@ -4,6 +4,7 @@
#include "../csl/interfaces/pin.hpp"
#include "../csl/interfaces/delay.hpp"
#include "../csl/stm32f042/Inc/stm_pin.hpp"
#include "../../drivers/led/led.hpp"
#include "stm32f0xx_csl.h"
class Nucleo_f042k6
@ -16,12 +17,12 @@ class Nucleo_f042k6
void init();
void running();
private :
Delay delay;
//STM_Pin<Pin_no::pin_0, GPIO_Port::Port_A_base_address> pin_a0;
STM_Pin<Pin_no::pin_3, GPIO_Port::Port_B_base_address> ledPin;
STM_Pin<Pin_no::pin_0, GPIO_Port::Port_A_base_address> pin_a0;
//Led ledGreen(&STM_Pin<Pin_no::pin_3, GPIO_Port::Port_B_base_address>);
};
#endif /* BSL_NUCLEO_F042K6_H */

@ -0,0 +1,7 @@
add_library(ledDriver led.cpp)
target_compile_options(ledDriver PRIVATE ${C_FLAGS})
target_compile_definitions(ledDriver PRIVATE ${C_DEFS})
target_include_directories(ledDriver PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
add_library(sub::led ALIAS ledDriver)

@ -1,18 +1,30 @@
#include "led.hpp"
Led::Led(Pin* pin_ptr)
{
pin = pin_ptr;
pin->init();
pin->setMode(Pin::mode::output);
pin->setSpeed(Pin::speed::fast);
}
Led::~Led()
{
}
void Pin::on()
void Led::on()
{
pin.write(true);
pin->write(true);
}
void Pin::off()
void Led::off()
{
pin.write(false);
pin->write(false);
}
void Pin::toggle()
void Led::toggle()
{
pin.toggle();
pin->toggle();
}

@ -1,13 +1,14 @@
#ifndef __LED_HPP
#define __LED_HPP
#ifndef _LED_HPP
#define _LED_HPP
// TODO : Change Cmake to include "pin.hpp"
#include "../../bsl/csl/interfaces/pin.hpp"
#include "../../bsl/csl/interfaces/delay.hpp"
class Led
{
public:
Led(Pin& pin);
Led(Pin *pin_ptr);
~Led();
void on();
@ -15,7 +16,7 @@ class Led
void toggle();
private:
Pin& pin;
Pin *pin;
};

@ -1,10 +1,10 @@
#include"main.hpp"
#include"drivers/led/led.hpp"
int main(int argc, char *argv[])
{
Nucleo_f042k6 bsl;
bsl.init();
while(1)
{

Loading…
Cancel
Save