ihsm-strain-gage-controller-fw/include/usb_if.h
2023-06-05 18:12:01 +02:00

32 lines
706 B
C

#ifndef __USB_IF_H__
#define __USB_IF_H__
#include <global.h>
#include <usb_cdc.h>
#include <usb.h>
#include <cobs.h>
#define USB_CDC_DATA_SIZE 0x40
struct usb_state {
struct usb_cdc_line_coding line;
usbd_device usb_dev;
uint32_t usb_buf[0x20];
uint8_t usb_pkbuf[USB_CDC_DATA_SIZE];
struct cobs_decode_state cobs_state;
bool cobs_synchronized;
bool connected;
ErrorCode error;
uint64_t last_error;
uint8_t txbuf[256];
size_t txbuf_wrpos;
size_t txbuf_rdpos;
};
extern struct usb_state st_usb;
void usb_init(void);
extern void handle_usb_packet(void *packet, size_t len);
ErrorCode usb_write_response(void *data, size_t len);
#endif /* __USB_IF_H__ */