/*
 * channel_control.h
 *
 *  Created on: Mar 10, 2025
 *      Author: janek
 */

#ifndef INC_CHANNEL_CONTROL_H_
#define INC_CHANNEL_CONTROL_H_

#include "stm32f3xx_hal.h"

typedef union {
	struct {
		uint8_t acc_cooling : 1;
		uint8_t ts_cooling : 1;
		uint8_t drs : 1;
		uint8_t acu : 1;
		uint8_t epsc : 1;
		uint8_t inverter : 1;
		uint8_t lidar : 1;
		uint8_t misc : 1;
	};
	uint8_t porta;
} gpio_port_a;

typedef union {
	struct {
		uint8_t alwayson : 1;
		uint8_t sdc : 1;
		uint8_t ebs1 : 1;
		uint8_t ebs2 : 1;
		uint8_t ebs3 : 1;
		uint8_t NC1 : 1;		// not used
		uint8_t NC2 : 1;		// not used
		uint8_t NC3 : 1;		// not used
	};
	uint8_t portb;
} gpio_port_b;

typedef union {
	struct {
		gpio_port_a porta;
		gpio_port_b portb;
	};
	uint16_t gpios_bitmask;
} enable_gpios;

void ChannelControl_init();

void ChannelControl_UpdateGPIOs(enable_gpios);

#endif /* INC_CHANNEL_CONTROL_H_ */