#pragma once

#include "main.h"
#include <stdint.h>

#define DUTY_INVERT 0

typedef enum {
    EV_STATE_A_IDLE = 0,
    EV_STATE_B_CONN_PREP = 1,
    EV_STATE_C_CONN_ACTIVE = 2,
    EV_STATE_D_CONN_ACT_VENT = 3,
    EV_STATE_E_NO_POWER = 4,
    EV_STATE_F_ERROR = 5,
    EV_STATE_ACQUIRING = 6,
} CP_State_t;

extern CP_State_t cp_state_buffer;

void CP_Init(void);
void CP_SetDuty(uint8_t percentage);
uint8_t CP_GetDuty(void);
int32_t CP_GetVoltage(void);
CP_State_t CP_GetState(void);
CP_State_t CP_GetFilteredState(void);
void CP_FilterState(void);
void CP_Loop(void);

