Will redo this
This commit is contained in:
@@ -1,37 +0,0 @@
|
||||
/**** Includes ****/
|
||||
#include "../utils/utils.h"
|
||||
#include "mcu/mcu_hal.h"
|
||||
#include "hvdin.h"
|
||||
|
||||
using namespace board;
|
||||
|
||||
/**** Private definitions ****/
|
||||
/**** Private constants ****/
|
||||
/**** Private variables ****/
|
||||
/**** Private function declarations ****/
|
||||
|
||||
/**** Public function definitions ****/
|
||||
board::HVDigitalIn::HVDigitalIn(uint8_t gpio_ch, uint8_t init_read)
|
||||
{
|
||||
this->gpio_ch = gpio_ch;
|
||||
|
||||
if(init_read) this->last_read = HVDIN_HIGH;
|
||||
else this->last_read = HVDIN_LOW;
|
||||
}
|
||||
|
||||
board::HVDigitalIn::~HVDigitalIn(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t board::HVDigitalIn::read(void)
|
||||
{
|
||||
// Auto inverts level to match board external connectors
|
||||
uint8_t lvl = mcu::gpio_read(this->gpio_ch);
|
||||
if(lvl>0) this->last_read = HVDIN_LOW;
|
||||
else this->last_read = HVDIN_HIGH;
|
||||
|
||||
return this->last_read;
|
||||
}
|
||||
|
||||
/**** Private function definitions ****/
|
||||
@@ -1,34 +0,0 @@
|
||||
#ifndef HV_DIN_H_
|
||||
#define HV_DIN_H_
|
||||
|
||||
/**** Includes ****/
|
||||
#include <stdint.h>
|
||||
|
||||
namespace board {
|
||||
|
||||
/**** Public definitions ****/
|
||||
const uint8_t HVDIN_LOW = 0;
|
||||
const uint8_t HVDIN_HIGH = 1;
|
||||
|
||||
class HVDigitalIn
|
||||
{
|
||||
protected:
|
||||
uint8_t gpio_ch;
|
||||
|
||||
public:
|
||||
HVDigitalIn(uint8_t gpio_ch, uint8_t init_read);
|
||||
~HVDigitalIn(void);
|
||||
|
||||
uint8_t last_read;
|
||||
|
||||
uint8_t read(void);
|
||||
};
|
||||
|
||||
/**** Public function declarations ****/
|
||||
|
||||
#ifdef TESTING
|
||||
#endif
|
||||
|
||||
} //namespace
|
||||
|
||||
#endif /* HV_DIN_H_ */
|
||||
@@ -1,40 +0,0 @@
|
||||
/**** Includes ****/
|
||||
#include "../utils/utils.h"
|
||||
#include "mcu/mcu_hal.h"
|
||||
#include "od_com.h"
|
||||
|
||||
using namespace board;
|
||||
|
||||
/**** Private definitions ****/
|
||||
/**** Private constants ****/
|
||||
/**** Private variables ****/
|
||||
/**** Private function declarations ****/
|
||||
|
||||
/**** Public function definitions ****/
|
||||
board::ODCommon::ODCommon(uint8_t pwm_ch)
|
||||
{
|
||||
this->pwm_ch = pwm_ch;
|
||||
this->write(0);
|
||||
}
|
||||
|
||||
board::ODCommon::~ODCommon(void)
|
||||
{
|
||||
this->write(0);
|
||||
}
|
||||
|
||||
void board::ODCommon::write(uint8_t duty)
|
||||
{
|
||||
// Convert percent to 16b duty cycle
|
||||
uint16_t dc = util::percent_to_16b(duty);
|
||||
|
||||
// Set PWM
|
||||
mcu::pwm_write(this->pwm_ch, dc);
|
||||
this->last_duty = duty;
|
||||
}
|
||||
|
||||
uint8_t board::ODCommon::get_set_duty(void)
|
||||
{
|
||||
return this->last_duty;
|
||||
}
|
||||
|
||||
/**** Private function definitions ****/
|
||||
@@ -1,31 +0,0 @@
|
||||
#ifndef OD_COMMON_H_
|
||||
#define OD_COMMON_H_
|
||||
|
||||
/**** Includes ****/
|
||||
#include <stdint.h>
|
||||
|
||||
namespace board {
|
||||
|
||||
/**** Public definitions ****/
|
||||
class ODCommon
|
||||
{
|
||||
protected:
|
||||
uint8_t pwm_ch;
|
||||
uint8_t last_duty;
|
||||
|
||||
public:
|
||||
ODCommon(uint8_t pwm_ch);
|
||||
~ODCommon(void);
|
||||
|
||||
void write(uint8_t duty);
|
||||
uint8_t get_set_duty(void);
|
||||
};
|
||||
|
||||
/**** Public function declarations ****/
|
||||
|
||||
#ifdef TESTING
|
||||
#endif
|
||||
|
||||
} //namespace
|
||||
|
||||
#endif /* OD_COMMON_H_ */
|
||||
@@ -1,44 +0,0 @@
|
||||
/**** Includes ****/
|
||||
#include "../utils/utils.h"
|
||||
#include "mcu/mcu_hal.h"
|
||||
#include "odout.h"
|
||||
|
||||
using namespace board;
|
||||
|
||||
/**** Private definitions ****/
|
||||
/**** Private constants ****/
|
||||
/**** Private variables ****/
|
||||
/**** Private function declarations ****/
|
||||
|
||||
/**** Public function definitions ****/
|
||||
board::OpenDrainOut::OpenDrainOut(uint8_t gpio_ch)
|
||||
{
|
||||
this->gpio_ch = gpio_ch;
|
||||
this->write(OD_OFF);
|
||||
}
|
||||
|
||||
board::OpenDrainOut::~OpenDrainOut(void)
|
||||
{
|
||||
this->write(OD_OFF);
|
||||
}
|
||||
|
||||
void board::OpenDrainOut::write(uint8_t state)
|
||||
{
|
||||
if(state)
|
||||
{
|
||||
mcu::gpio_write(this->gpio_ch, mcu::LEVEL_HIGH);
|
||||
this->last_set = OD_ON;
|
||||
}
|
||||
else
|
||||
{
|
||||
mcu::gpio_write(this->gpio_ch, mcu::LEVEL_LOW);
|
||||
this->last_set = OD_OFF;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t board::OpenDrainOut::get_set_state(void)
|
||||
{
|
||||
return this->last_set;
|
||||
}
|
||||
|
||||
/**** Private function definitions ****/
|
||||
@@ -1,34 +0,0 @@
|
||||
#ifndef OD_OUT_H_
|
||||
#define OD_OUT_H_
|
||||
|
||||
/**** Includes ****/
|
||||
#include <stdint.h>
|
||||
|
||||
namespace board {
|
||||
|
||||
/**** Public definitions ****/
|
||||
const uint8_t OD_OFF = 0;
|
||||
const uint8_t OD_ON = 1;
|
||||
|
||||
class OpenDrainOut
|
||||
{
|
||||
protected:
|
||||
uint8_t gpio_ch;
|
||||
uint8_t last_set;
|
||||
|
||||
public:
|
||||
OpenDrainOut(uint8_t gpio_ch);
|
||||
~OpenDrainOut(void);
|
||||
|
||||
void write(uint8_t state);
|
||||
uint8_t get_set_state(void);
|
||||
};
|
||||
|
||||
/**** Public function declarations ****/
|
||||
|
||||
#ifdef TESTING
|
||||
#endif
|
||||
|
||||
} //namespace
|
||||
|
||||
#endif /* OD_OUT_H_ */
|
||||
Reference in New Issue
Block a user