feat-hal-2 #4
@@ -8,33 +8,6 @@ namespace mcu {
|
|||||||
|
|
||||||
/**** Public definitions ****/
|
/**** Public definitions ****/
|
||||||
/*
|
/*
|
||||||
GPIO0 Down
|
|
||||||
GPIO1 Up
|
|
||||||
GPIO2 Mode
|
|
||||||
GPIO3 Handbrake
|
|
||||||
GPIO4 Brakes
|
|
||||||
GPIO5 Dimm
|
|
||||||
GPIO6 LED0
|
|
||||||
GPIO7 LED1
|
|
||||||
GPIO8 LED2
|
|
||||||
GPIO9 LED3
|
|
||||||
GPIO10 LED4
|
|
||||||
GPIO11 LED5
|
|
||||||
GPIO12 DCCD Enable
|
|
||||||
GPIO13 Handbrake pull
|
|
||||||
GPIO14 Speed pull
|
|
||||||
GPIO15 DCCD PWM
|
|
||||||
GPIO16 LED PWM
|
|
||||||
|
|
||||||
ADC0 Output current
|
|
||||||
ADC1 Output voltage
|
|
||||||
ADC2 Battery current
|
|
||||||
ADC3 Battery voltage
|
|
||||||
ADC4 Potentiometer
|
|
||||||
ADC5 Mode
|
|
||||||
ADC8 MCU temperature
|
|
||||||
ADC14 MCU internal reference
|
|
||||||
ADC15 MCU ground
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const uint8_t GPIO0 = 0; //PC5 Mode
|
const uint8_t GPIO0 = 0; //PC5 Mode
|
||||||
|
|||||||
@@ -1,44 +0,0 @@
|
|||||||
#ifndef UDCCD_BOARD_H_
|
|
||||||
#define UDCCD_BOARD_H_
|
|
||||||
|
|
||||||
/**** Includes ****/
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
using namespace board;
|
|
||||||
|
|
||||||
/**** Public definitions ****/
|
|
||||||
static AnalogIn dccd_i(mcu::ADC0);
|
|
||||||
static AnalogIn dccd_u(mcu::ADC1);
|
|
||||||
static AnalogIn bat_u(mcu::ADC2);
|
|
||||||
static AnalogIn bat_i(mcu::ADC3);
|
|
||||||
|
|
||||||
static Hafbridge hbridge(mcu::PWM0, mcu::GPIO15, 95);
|
|
||||||
|
|
||||||
static AnalogIn ain1(mcu::ADC5);
|
|
||||||
static AnalogIn ain2(mcu::ADC4);
|
|
||||||
|
|
||||||
static DigitalIn din1(mcu::GPIO0, 0, board::DIN_HIGH);
|
|
||||||
static DigitalIn din2(mcu::GPIO1, 0, board::DIN_HIGH);
|
|
||||||
static DigitalIn din3(mcu::GPIO2, 0, board::DIN_HIGH);
|
|
||||||
static DigitalIn din4(mcu::GPIO3, 0, board::DIN_HIGH);
|
|
||||||
|
|
||||||
static DigitalIn hvdin1(mcu::GPIO4, 1, board::DIN_LOW);
|
|
||||||
static DigitalIn hvdin2(mcu::GPIO5, 1, board::DIN_LOW);
|
|
||||||
static DigitalIn hvdin3(mcu::GPIO6, 1, board::DIN_LOW);
|
|
||||||
static DigitalIO hvdin3_pull(mcu::GPIO3, board::DIN_HIGH);
|
|
||||||
|
|
||||||
static DigitalOut odout1(mcu::GPIO9, 1);
|
|
||||||
static DigitalOut odout2(mcu::GPIO10, 1);
|
|
||||||
static DigitalOut odout3(mcu::GPIO11, 1);
|
|
||||||
static DigitalOut odout4(mcu::GPIO12, 1);
|
|
||||||
static DigitalOut odout5(mcu::GPIO13, 1);
|
|
||||||
static DigitalOut odout6(mcu::GPIO14, 1);
|
|
||||||
|
|
||||||
static PWMout od_pwm(mcu::PWM1);
|
|
||||||
|
|
||||||
/**** Public function declarations ****/
|
|
||||||
|
|
||||||
#ifdef TESTING
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* UDCCD_BOARD_H_ */
|
|
||||||
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
/**** Includes ****/
|
/**** Includes ****/
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "../board/ain.h"
|
|
||||||
#include "../board/halfbridge.h"
|
#include "../board/halfbridge.h"
|
||||||
|
|
||||||
namespace hw {
|
namespace hw {
|
||||||
|
|||||||
@@ -12,23 +12,65 @@
|
|||||||
#include "hw/button.h"
|
#include "hw/button.h"
|
||||||
#include "hw/potentiometer.h"
|
#include "hw/potentiometer.h"
|
||||||
#include "hw/display_led.h"
|
#include "hw/display_led.h"
|
||||||
|
#include "hw/cv_output.h"
|
||||||
#include "board/udccd_board.h"
|
|
||||||
|
|
||||||
/**** Private definitions ****/
|
/**** Private definitions ****/
|
||||||
|
static board::AnalogIn dccd_i(mcu::ADC0);
|
||||||
|
static board::AnalogIn dccd_u(mcu::ADC1);
|
||||||
|
static board::AnalogIn bat_u(mcu::ADC2);
|
||||||
|
static board::AnalogIn bat_i(mcu::ADC3);
|
||||||
|
|
||||||
|
static board::Hafbridge hbridge(mcu::PWM0, mcu::GPIO15, 95);
|
||||||
|
|
||||||
|
static board::AnalogIn ain1(mcu::ADC5); // mode
|
||||||
|
static board::AnalogIn ain2(mcu::ADC4); // pot
|
||||||
|
|
||||||
|
static board::DigitalIn din1(mcu::GPIO0, 0, board::DIN_HIGH); //mode
|
||||||
|
static board::DigitalIn din2(mcu::GPIO1, 0, board::DIN_HIGH); //pot
|
||||||
|
static board::DigitalIn din3(mcu::GPIO2, 0, board::DIN_HIGH); //down
|
||||||
|
static board::DigitalIn din4(mcu::GPIO3, 0, board::DIN_HIGH); //up
|
||||||
|
|
||||||
|
static board::DigitalIn hvdin1(mcu::GPIO4, 1, board::DIN_LOW); //dimm
|
||||||
|
static board::DigitalIn hvdin2(mcu::GPIO5, 1, board::DIN_LOW); //brakes
|
||||||
|
static board::DigitalIn hvdin3(mcu::GPIO6, 1, board::DIN_LOW); //hbrake
|
||||||
|
static board::DigitalIO hvdin3_pull(mcu::GPIO7, board::DIN_HIGH); //hbrake pull
|
||||||
|
|
||||||
|
static board::DigitalOut odout1(mcu::GPIO9, 1);
|
||||||
|
static board::DigitalOut odout2(mcu::GPIO10, 1);
|
||||||
|
static board::DigitalOut odout3(mcu::GPIO11, 1);
|
||||||
|
static board::DigitalOut odout4(mcu::GPIO12, 1);
|
||||||
|
static board::DigitalOut odout5(mcu::GPIO13, 1);
|
||||||
|
static board::DigitalOut odout6(mcu::GPIO14, 1);
|
||||||
|
|
||||||
|
static board::PWMout od_pwm(mcu::PWM1);
|
||||||
|
|
||||||
|
static hw::Button btn_mode(&din1, board::DIN_LOW, 10, hw::BUTTON_OFF);
|
||||||
|
static hw::Button btn_up(&din4, board::DIN_LOW, 10, hw::BUTTON_OFF);
|
||||||
|
static hw::Button btn_down(&din3, board::DIN_LOW, 10, hw::BUTTON_OFF);
|
||||||
|
|
||||||
|
static hw::Button sw_dimm(&hvdin1, board::DIN_HIGH, 10, hw::BUTTON_OFF);
|
||||||
|
static hw::Button sw_brakes(&hvdin2, board::DIN_HIGH, 10, hw::BUTTON_OFF);
|
||||||
|
static hw::Button sw_hbrake(&hvdin3, board::DIN_LOW, 10, hw::BUTTON_OFF);
|
||||||
|
|
||||||
|
static hw::Potentiometer pot(&ain2, 500, 4500);
|
||||||
|
|
||||||
|
static hw::DisplayLed display(&odout1, &odout2, &odout3, &odout4, &odout5, &odout6, &od_pwm);
|
||||||
|
|
||||||
|
static hw::CVoutput cvout(&hbridge);
|
||||||
|
|
||||||
/**** Private constants ****/
|
/**** Private constants ****/
|
||||||
/**** Private variables ****/
|
/**** Private variables ****/
|
||||||
/**** Private function declarations ****/
|
/**** Private function declarations ****/
|
||||||
|
static void board_setup(void);
|
||||||
|
|
||||||
/**** Public function definitions ****/
|
/**** Public function definitions ****/
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
mcu::startupCfg_t mcu_cfg;
|
board_setup();
|
||||||
mcu_cfg.adc_clk = mcu::ADC_DIV2;
|
|
||||||
mcu_cfg.pwm_clk = mcu::TIM_DIV1;
|
cvout.target = 0;
|
||||||
mcu_cfg.pwm_top = 200;
|
cvout.min_out = 500;
|
||||||
mcu_cfg.pwm_ch1_en = 1;
|
cvout.enable();
|
||||||
|
|
||||||
mcu::startup(&mcu_cfg);
|
|
||||||
|
|
||||||
// Super loop
|
// Super loop
|
||||||
while(1)
|
while(1)
|
||||||
@@ -41,3 +83,35 @@ int main(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**** Private function definitions ***/
|
/**** Private function definitions ***/
|
||||||
|
static void board_setup(void)
|
||||||
|
{
|
||||||
|
mcu::startupCfg_t mcu_cfg;
|
||||||
|
mcu_cfg.adc_clk = mcu::ADC_DIV2;
|
||||||
|
mcu_cfg.pwm_clk = mcu::TIM_DIV1;
|
||||||
|
mcu_cfg.pwm_top = 200;
|
||||||
|
mcu_cfg.pwm_ch1_en = 1;
|
||||||
|
|
||||||
|
mcu::startup(&mcu_cfg);
|
||||||
|
|
||||||
|
dccd_i.mul = 215;
|
||||||
|
dccd_i.div = 22;
|
||||||
|
dccd_i.offset = 0;
|
||||||
|
dccd_i.last_read = 0;
|
||||||
|
|
||||||
|
dccd_u.mul = 20;
|
||||||
|
dccd_u.div = 1;
|
||||||
|
dccd_u.offset = 0;
|
||||||
|
dccd_u.last_read = 0;
|
||||||
|
|
||||||
|
bat_u.mul = 20;
|
||||||
|
bat_u.div = 1;
|
||||||
|
bat_u.offset = 0;
|
||||||
|
bat_u.last_read = 12000;
|
||||||
|
|
||||||
|
bat_i.mul = 235;
|
||||||
|
bat_i.div = 6;
|
||||||
|
bat_i.offset = 0;
|
||||||
|
bat_i.last_read = 0;
|
||||||
|
|
||||||
|
od_pwm.write(100);
|
||||||
|
}
|
||||||
@@ -195,9 +195,6 @@
|
|||||||
<Compile Include="board\pwm.h">
|
<Compile Include="board\pwm.h">
|
||||||
<SubType>compile</SubType>
|
<SubType>compile</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="board\udccd_board.h">
|
|
||||||
<SubType>compile</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="hw\button.cpp">
|
<Compile Include="hw\button.cpp">
|
||||||
<SubType>compile</SubType>
|
<SubType>compile</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|||||||
Reference in New Issue
Block a user