53 lines
1.1 KiB
C++
53 lines
1.1 KiB
C++
/**** Includes ****/
|
|
#include "../utils/utils.h"
|
|
#include "mcu/mcu_hal.h"
|
|
#include "dout.h"
|
|
|
|
using namespace bsp;
|
|
|
|
/**** Private definitions ****/
|
|
/**** Private constants ****/
|
|
/**** Private variables ****/
|
|
/**** Private function declarations ****/
|
|
|
|
/**** Public function definitions ****/
|
|
bsp::DigitalOut::DigitalOut(uint8_t gpio_ch, uint8_t inverted)
|
|
{
|
|
this->gpio_ch = gpio_ch;
|
|
this->invert = inverted;
|
|
this->write(DOUT_HIZ);
|
|
}
|
|
|
|
bsp::DigitalOut::~DigitalOut(void)
|
|
{
|
|
this->write(DOUT_HIZ);
|
|
}
|
|
|
|
void bsp::DigitalOut::write(int8_t level)
|
|
{
|
|
if(level > 0)
|
|
{
|
|
this->last_set = DOUT_HIGH;
|
|
if(this->invert) mcu::gpio_write(this->gpio_ch, mcu::LEVEL_LOW);
|
|
else mcu::gpio_write(this->gpio_ch, mcu::LEVEL_HIGH);
|
|
}
|
|
else if(level == 0)
|
|
{
|
|
this->last_set = DOUT_LOW;
|
|
if(this->invert) mcu::gpio_write(this->gpio_ch, mcu::LEVEL_HIGH);
|
|
else mcu::gpio_write(this->gpio_ch, mcu::LEVEL_LOW);
|
|
}
|
|
else
|
|
{
|
|
this->last_set = DOUT_HIZ;
|
|
mcu::gpio_write(this->gpio_ch, mcu::LEVEL_HIZ);
|
|
}
|
|
}
|
|
|
|
int8_t bsp::DigitalOut::get_set_level(void)
|
|
{
|
|
return this->last_set;
|
|
}
|
|
|
|
/**** Private function definitions ****/
|