Saved work
This commit is contained in:
@@ -12,23 +12,65 @@
|
||||
#include "hw/button.h"
|
||||
#include "hw/potentiometer.h"
|
||||
#include "hw/display_led.h"
|
||||
|
||||
#include "board/udccd_board.h"
|
||||
#include "hw/cv_output.h"
|
||||
|
||||
/**** 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 variables ****/
|
||||
/**** Private function declarations ****/
|
||||
static void board_setup(void);
|
||||
|
||||
/**** Public function definitions ****/
|
||||
int main(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);
|
||||
board_setup();
|
||||
|
||||
cvout.target = 0;
|
||||
cvout.min_out = 500;
|
||||
cvout.enable();
|
||||
|
||||
// Super loop
|
||||
while(1)
|
||||
@@ -41,3 +83,35 @@ int main(void)
|
||||
}
|
||||
|
||||
/**** 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);
|
||||
}
|
||||
Reference in New Issue
Block a user