parent
681bd375cc
commit
9984ab9fe9
@ -0,0 +1,26 @@
|
||||
#include "bsl_nucleo_f042k6.hpp"
|
||||
|
||||
|
||||
Nucleo_f042k6::Nucleo_f042k6(){}
|
||||
Nucleo_f042k6::~Nucleo_f042k6(){}
|
||||
|
||||
void Nucleo_f042k6::init()
|
||||
{
|
||||
ledPin.init();
|
||||
ledPin.setMode(Pin::mode::output);
|
||||
ledPin.setSpeed(Pin::speed::fast);
|
||||
|
||||
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);
|
||||
delay.ms(200);
|
||||
ledPin.write(false);
|
||||
delay.ms(200);
|
||||
}
|
||||
|
@ -1,42 +1,29 @@
|
||||
#include "bsl_nucleo_f042k6.hpp"
|
||||
int startBSL()
|
||||
|
||||
|
||||
Nucleo_f042k6::Nucleo_f042k6()
|
||||
{
|
||||
stmStart();
|
||||
Delay delay;
|
||||
|
||||
STM_Pin<Pin_no::pin_3, GPIO_Port::Port_B_base_address> led;
|
||||
STM_Pin<Pin_no::pin_0, GPIO_Port::Port_A_base_address> pin_a0;
|
||||
}
|
||||
Nucleo_f042k6::~Nucleo_f042k6(){}
|
||||
|
||||
led.init();
|
||||
led.setMode(Pin::mode::output);
|
||||
led.setSpeed(Pin::speed::fast);
|
||||
void Nucleo_f042k6::init()
|
||||
{
|
||||
ledPin.init();
|
||||
ledPin.setMode(Pin::mode::output);
|
||||
ledPin.setSpeed(Pin::speed::fast);
|
||||
|
||||
pin_a0.init();
|
||||
pin_a0.setMode(Pin::mode::input);
|
||||
pin_a0.setSpeed(Pin::speed::slow);
|
||||
pin_a0.setPullUpDonw(Pin::pullUpDown::pullDown);
|
||||
}
|
||||
|
||||
uint8_t i = 0;
|
||||
|
||||
for(i = 0 ; i < 10 ; i++)
|
||||
{
|
||||
delay.ms(100);
|
||||
led.write(true);
|
||||
delay.ms(100);
|
||||
led.write(false);
|
||||
}
|
||||
|
||||
while(1)
|
||||
{
|
||||
if(pin_a0.read())
|
||||
{
|
||||
led.write(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
led.write(false);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
void Nucleo_f042k6::running()
|
||||
{
|
||||
ledPin.write(true);
|
||||
delay.ms(200);
|
||||
ledPin.write(false);
|
||||
delay.ms(200);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,18 @@
|
||||
#include "led.hpp"
|
||||
|
||||
|
||||
void Pin::on()
|
||||
{
|
||||
pin.write(true);
|
||||
}
|
||||
|
||||
void Pin::off()
|
||||
{
|
||||
pin.write(false);
|
||||
}
|
||||
|
||||
void Pin::toggle()
|
||||
{
|
||||
pin.toggle();
|
||||
}
|
||||
|
@ -0,0 +1,22 @@
|
||||
#ifndef __LED_HPP
|
||||
#define __LED_HPP
|
||||
|
||||
// TODO : Change Cmake to include "pin.hpp"
|
||||
#include "../../bsl/csl/interfaces/pin.hpp"
|
||||
|
||||
class Led
|
||||
{
|
||||
public:
|
||||
Led(Pin& pin);
|
||||
~Led();
|
||||
|
||||
void on();
|
||||
void off();
|
||||
void toggle();
|
||||
|
||||
private:
|
||||
Pin& pin;
|
||||
};
|
||||
|
||||
|
||||
#endif /* __LED_HPP */
|
Loading…
Reference in new issue