Skip to content

Commit

Permalink
renamed some digital pins, to be in sync with the schematic, for bett…
Browse files Browse the repository at this point in the history
…er maintainability
  • Loading branch information
uhi22 committed Oct 9, 2024
1 parent 25a20f8 commit f96ff21
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 20 deletions.
24 changes: 12 additions & 12 deletions ccs/hardwareInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,43 +551,43 @@ void hardwareInterface_WakeupOtherPeripherals()
bool ppValid = Param::GetInt(Param::ResistanceProxPilot) < 2000;
int wakeupPinFunc = Param::GetInt(Param::WakeupPinFunc);

if (!DigIo::supply_out.Get()) {
if (!DigIo::keep_power_on.Get()) {
//Make sure we don't wake ourself up
//Unless we monitor PP
DigIo::wakeup_out.Clear();
DigIo::trigger_wakeup.Clear();
return;
}

switch (wakeupPinFunc) {
case WAKEUP_LEVEL:
DigIo::wakeup_out.Set(); //Wake up other peripherals
DigIo::trigger_wakeup.Set(); //Wake up other peripherals
break;
case WAKEUP_PULSE:
if (wakeUpPulseLength > 0) {
wakeUpPulseLength--;
DigIo::wakeup_out.Set();
DigIo::trigger_wakeup.Set();
}
else DigIo::wakeup_out.Clear();
else DigIo::trigger_wakeup.Clear();
break;
case WAKEUP_LEVEL | WAKEUP_ONVALIDCP:
if (dutyValid) DigIo::wakeup_out.Set();
else DigIo::wakeup_out.Clear();
if (dutyValid) DigIo::trigger_wakeup.Set();
else DigIo::trigger_wakeup.Clear();
break;
case WAKEUP_LEVEL | WAKEUP_ONVALIDPP:
if (ppValid || dutyValid) DigIo::wakeup_out.Set();
else DigIo::wakeup_out.Clear();
if (ppValid || dutyValid) DigIo::trigger_wakeup.Set();
else DigIo::trigger_wakeup.Clear();
break;
case WAKEUP_PULSE | WAKEUP_ONVALIDCP:
if (dutyValid && wakeUpPulseLength > 0) {
wakeUpPulseLength--;
DigIo::wakeup_out.Set();
DigIo::trigger_wakeup.Set();
}
else if (!dutyValid) {
wakeUpPulseLength = 10; //allow pulsing again when PWM returns
DigIo::wakeup_out.Clear();
DigIo::trigger_wakeup.Clear();
}
else {
DigIo::wakeup_out.Clear();
DigIo::trigger_wakeup.Clear();
}
break;
}
Expand Down
6 changes: 3 additions & 3 deletions include/digio_prj.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@

#define DIG_IO_LIST \
DIG_IO_ENTRY(spics, GPIOA, GPIO4, PinMode::OUTPUT) \
DIG_IO_ENTRY(led_out, GPIOB, GPIO7, PinMode::OUTPUT) \
DIG_IO_ENTRY(led_alive, GPIOB, GPIO7, PinMode::OUTPUT) \
DIG_IO_ENTRY(statec_out, GPIOB, GPIO4, PinMode::OUTPUT) \
DIG_IO_ENTRY(red_out, GPIOB, GPIO2, PinMode::OUTPUT) \
DIG_IO_ENTRY(green_out, GPIOB, GPIO10, PinMode::OUTPUT) \
DIG_IO_ENTRY(blue_out, GPIOB, GPIO11, PinMode::OUTPUT) \
DIG_IO_ENTRY(contact_out, GPIOA, GPIO1, PinMode::OUTPUT) \
DIG_IO_ENTRY(wakeup_out, GPIOB, GPIO0, PinMode::OUTPUT) \
DIG_IO_ENTRY(supply_out, GPIOB, GPIO1, PinMode::OUTPUT) \
DIG_IO_ENTRY(trigger_wakeup, GPIOB, GPIO0, PinMode::OUTPUT) \
DIG_IO_ENTRY(keep_power_on, GPIOB, GPIO1, PinMode::OUTPUT) \

#endif // PinMode_PRJ_H_INCLUDED
2 changes: 0 additions & 2 deletions include/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ void Error_Handler(void);
#define OUT_CONTACTOR_CONTROL1_GPIO_Port GPIOB
#define OUT_CONTACTOR_CONTROL2_Pin GPIO_PIN_6
#define OUT_CONTACTOR_CONTROL2_GPIO_Port GPIOB
#define OUT_LED_ALIVE_Pin GPIO_PIN_7
#define OUT_LED_ALIVE_GPIO_Port GPIOB

/* USER CODE BEGIN Private defines */

Expand Down
6 changes: 3 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ static void Ms100Task(void)
{
static uint32_t lastValidCp = 0;

DigIo::led_out.Toggle();
DigIo::led_alive.Toggle();
//The boot loader enables the watchdog, we have to reset it
//at least every 2s or otherwise the controller is hard reset.
iwdg_reset();
Expand Down Expand Up @@ -159,7 +159,7 @@ static void Ms100Task(void)
{
if ((Param::GetInt(Param::WakeupPinFunc) & WAKEUP_ONVALIDPP) == 0 || !ppValid)
{
DigIo::supply_out.Clear();
DigIo::keep_power_on.Clear();
}
}
}
Expand Down Expand Up @@ -261,7 +261,7 @@ extern "C" int main(void)
write_bootloader_pininit(); //Instructs boot loader to initialize certain pins
gpio_primary_remap(AFIO_MAPR_SWJ_CFG_JTAG_OFF_SW_ON, AFIO_MAPR_TIM3_REMAP_FULL_REMAP | AFIO_MAPR_TIM2_REMAP_FULL_REMAP);

DigIo::supply_out.Set(); //Make sure board stays awake
DigIo::keep_power_on.Set(); //Make sure board stays awake

hardwareInterface_setStateB();
hw_evaluateHardwareVariants();
Expand Down

0 comments on commit f96ff21

Please sign in to comment.