#ifndef AD_USB_CDC_H
#define AD_USB_CDC_H

#include <stdint.h>

typedef enum
{
    AD_USB_CDC_STATUS_INITIALIZED = (1UL << 0),
    AD_USB_CDC_STATUS_CONFIGURED = (1UL << 1),
    AD_USB_CDC_STATUS_TX_BUSY = (1UL << 2),
    AD_USB_CDC_STATUS_ENUM_ERROR = (1UL << 3),
    AD_USB_CDC_STATUS_TX_DROPPED = (1UL << 4)
} AD_USB_CDC_StatusFlag_t;

typedef struct
{
    uint8_t initialized;
    uint8_t configured;
    uint8_t tx_busy;
    uint8_t reserved;
    uint32_t status_flags;
    uint32_t tx_packets;
    uint32_t tx_bytes;
    uint32_t dropped_packets;
    uint32_t setup_packets;
    uint32_t rx_bytes;
    uint32_t last_error;
} AD_USB_CDC_State_t;

void AD_USB_CDC_Init(void);
void AD_USB_CDC_Loop(void);
uint8_t AD_USB_CDC_WritePacket(const uint8_t *data, uint16_t size);
uint8_t AD_USB_CDC_IsConfigured(void);
uint8_t AD_USB_CDC_IsTxBusy(void);
const AD_USB_CDC_State_t* AD_USB_CDC_GetState(void);
void AD_USB_CDC_IRQHandler(void);

#endif
