feat-hal-2 #4

Merged
andis merged 35 commits from feat-hal-2 into develop 2024-07-31 16:15:36 +00:00
4 changed files with 40 additions and 25 deletions
Showing only changes of commit 82838c25cb - Show all commits

View File

@@ -20,6 +20,7 @@ void board_init(void)
mcu::startup(&mcu_cfg); mcu::startup(&mcu_cfg);
// Board setup // Board setup
// Fixed function AIN mV and mA scale
dccd_i.mul = 215; dccd_i.mul = 215;
dccd_i.div = 22; dccd_i.div = 22;
dccd_i.offset = 0; dccd_i.offset = 0;

View File

@@ -4,27 +4,32 @@
/**** Private definitions ****/ /**** Private definitions ****/
/**** Private constants ****/ /**** Private constants ****/
static const uint16_t def_button_hold_time = 1000;
static const uint16_t def_min_current = 100;
static const uint16_t def_fuse_treshold = 6000;
static const uint16_t def_fuse_hold_cycles = 50;
static const uint16_t def_fuse_cooldown_cycles = 1000;
/**** Private variables ****/ /**** Private variables ****/
/**** Private function declarations ****/ /**** Private function declarations ****/
/**** Public function definitions ****/ /**** Public function definitions ****/
void devices_init(void) void devices_init(void)
{ {
board_init(); board_init();
btn_up.hold_time = 1000; btn_up.hold_time = def_button_hold_time;
btn_down.hold_time = 1000; btn_down.hold_time = def_button_hold_time;
ccout.target = 0; ccout.target = 0;
ccout.min_out = 100; ccout.min_out = def_min_current;
sup_fuse.hold_current = 6000; sup_fuse.hold_current = def_fuse_treshold;
sup_fuse.trip_cycles = 50; sup_fuse.trip_cycles = def_fuse_hold_cycles;
sup_fuse.cooldown_cycles = 1000; sup_fuse.cooldown_cycles = def_fuse_cooldown_cycles;
out_fuse.hold_current = 6000; out_fuse.hold_current = def_fuse_treshold;
out_fuse.trip_cycles = 100; out_fuse.trip_cycles = def_fuse_hold_cycles;
out_fuse.cooldown_cycles = 1000; out_fuse.cooldown_cycles = def_fuse_cooldown_cycles;
hvdin3_pull.write(bsp::DOUT_HIGH); hvdin3_pull.write(bsp::DOUT_HIGH);
@@ -33,7 +38,6 @@ void devices_init(void)
display.write(0x00); display.write(0x00);
display.set_brigthness(100); display.set_brigthness(100);
ccout.target = 0;
ccout.update(); ccout.update();
ccout.enable(); ccout.enable();
} }

View File

@@ -6,12 +6,19 @@ using namespace logic;
/**** Private definitions ****/ /**** Private definitions ****/
/**** Private constants ****/ /**** Private constants ****/
const uint16_t addr_btn_force = 0x0000; static const uint16_t addr_btn_force = 0x0000;
const uint16_t addr_bmode = 0x0001; static const uint16_t addr_bmode = 0x0001;
const uint16_t addr_pot_mode = 0x0002; static const uint16_t addr_pot_mode = 0x0002;
const uint16_t addr_dsp_brigth = 0x0003; static const uint16_t addr_dsp_brigth = 0x0003;
const uint16_t addr_dsp_dimm = 0x0004; static const uint16_t addr_dsp_dimm = 0x0004;
const uint16_t addr_lock_current = 0x0005; static const uint16_t addr_lock_current = 0x0005;
static const uint8_t def_btn_force = 0;
static const uint8_t def_pot_mode = 0;
static const uint8_t def_bmode = 0;
static const uint8_t def_dimm = 50;
static const uint8_t def_brigth = 100;
static const uint16_t def_lock_current = 4500;
/**** Private variables ****/ /**** Private variables ****/
/**** Private function declarations ****/ /**** Private function declarations ****/
@@ -44,37 +51,37 @@ void logic::CfgMemory::init(void)
if(this->mem_btn_force > 100) if(this->mem_btn_force > 100)
{ {
this->mem_btn_force = 0; this->mem_btn_force = def_btn_force;
mcu::eeprom_write8b(addr_btn_force, this->mem_btn_force); mcu::eeprom_write8b(addr_btn_force, this->mem_btn_force);
}; };
if(this->mem_bmode > 2) if(this->mem_bmode > 2)
{ {
this->mem_bmode = 0; this->mem_bmode = def_bmode;
mcu::eeprom_write8b(addr_bmode, this->mem_bmode); mcu::eeprom_write8b(addr_bmode, this->mem_bmode);
}; };
if(this->mem_pot_mode > 1) if(this->mem_pot_mode > 1)
{ {
this->mem_pot_mode = 0; this->mem_pot_mode = def_pot_mode;
mcu::eeprom_write8b(addr_pot_mode, this->mem_pot_mode); mcu::eeprom_write8b(addr_pot_mode, this->mem_pot_mode);
}; };
if(this->mem_dsp_brigth > 100) if(this->mem_dsp_brigth > 100)
{ {
this->mem_dsp_brigth = 100; this->mem_dsp_brigth = def_brigth;
mcu::eeprom_write8b(addr_dsp_brigth, this->mem_dsp_brigth); mcu::eeprom_write8b(addr_dsp_brigth, this->mem_dsp_brigth);
}; };
if(this->mem_dsp_dimm > 100) if(this->mem_dsp_dimm > 100)
{ {
this->mem_dsp_dimm = 50; this->mem_dsp_dimm = def_dimm;
mcu::eeprom_write8b(addr_dsp_dimm, this->mem_dsp_dimm); mcu::eeprom_write8b(addr_dsp_dimm, this->mem_dsp_dimm);
}; };
if(this->mem_lock_current > 6000) if(this->mem_lock_current > 6000)
{ {
this->mem_lock_current = 4500; this->mem_lock_current = def_lock_current;
mcu::eeprom_write16b(addr_lock_current, this->mem_lock_current); mcu::eeprom_write16b(addr_lock_current, this->mem_lock_current);
}; };

View File

@@ -11,6 +11,9 @@
/**** Private definitions ****/ /**** Private definitions ****/
/**** Private constants ****/ /**** Private constants ****/
static const uint16_t dsp_lock_bmode = 1000;
static const uint16_t dsp_lock_force = 50;
/**** Private variables ****/ /**** Private variables ****/
static logic::CfgMemory cfg_mem = logic::CfgMemory(); static logic::CfgMemory cfg_mem = logic::CfgMemory();
@@ -77,13 +80,13 @@ int main(void)
break; break;
} }
display.write(bmode_img); display.write(bmode_img);
dsp_lock = 1000; dsp_lock = dsp_lock_bmode;
dccd_force.is_new_bmode = 0; dccd_force.is_new_bmode = 0;
} }
else if((button_force.is_new)&&(cfg_mem.pot_mode==0)) else if((button_force.is_new)&&(cfg_mem.pot_mode==0))
{ {
display.show_percent(dccd_force.force, hw::DisplayLed::LED_DSP_DOT10); display.show_percent(dccd_force.force, hw::DisplayLed::LED_DSP_DOT10);
dsp_lock = 500; dsp_lock = dsp_lock_force;
button_force.is_new = 0; button_force.is_new = 0;
} }
else else