temporarily implement light gate input latching

This commit is contained in:
Leonard Gies 2025-07-08 17:59:53 +02:00
parent 22e24b38b5
commit 866d0642fb
Signed by: l.gies
GPG Key ID: 6F6FB9338EE44F71
2 changed files with 16 additions and 1 deletions

View File

@ -136,6 +136,10 @@ static can_pkt_t CAN_SIGNAL_MAP[NUM_TX_PKT] = {
}
};
static uint8_t DIO_LATCHING[NUM_DIO_PINS] = {
1, 1, 0, 0, 0, 0,
};
#define CAN_PWM_DC_ID 0x0DA // UNUSED
#define CAN_PWM_CONF_ID 0x0DB // UNUSED
#define CAN_PWM_BASE_ID CAN_PWM_DC_ID
@ -183,6 +187,10 @@ static can_pkt_t CAN_SIGNAL_MAP[NUM_TX_PKT] = {
}
};
static uint8_t DIO_LATCHING[NUM_DIO_PINS] = {
0, 0, 0, 0, 0, 0,
};
#define CAN_PWM_DC_ID 0x0DC
#define CAN_PWM_CONF_ID 0x0DD
#define CAN_PWM_BASE_ID CAN_PWM_DC_ID

View File

@ -90,10 +90,16 @@ void loop_1kHz() {
mscounter++;
for (int di = 0; di < NUM_DIO_PINS; di++) {
dio_values[di] = HAL_GPIO_ReadPin(
uint8_t value = HAL_GPIO_ReadPin(
DIO_PIN_MAP[di].port,
DIO_PIN_MAP[di].pin
);
if (DIO_LATCHING[di]) {
dio_values[di] |= value;
} else {
dio_values[di] = value;
}
}
for (int pi = 0; pi < NUM_TX_PKT; pi++) {
@ -116,6 +122,7 @@ void loop_1kHz() {
switch (signal->type) {
case DIN:
value = dio_values[signal->channel];
dio_values[signal->channel] = 0; // will be overwritten with real value at start of 1kHz loop
break;
case AIN: