89 static U16 VCP_Ctrl (uint32_t Cmd, uint8_t* Buf, uint32_t Len);
318 if (state == ENABLE) {
320 RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_GPIOA , ENABLE);
323 GPIO_InitTypeDef GPIO_InitStructure;
324 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 | GPIO_Pin_12;
325 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
326 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
327 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
328 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
329 GPIO_Init(GPIOA, &GPIO_InitStructure);
335 RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
336 RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_OTG_FS, ENABLE) ;
343 RCC_AHB2PeriphClockCmd(
USB_CLOCK, state);
390 NVIC_DisableIRQ(OTG_FS_IRQn);
468 linecoding.
bitrate = (uint32_t)(Buf[0] | (Buf[1] << 8) | (Buf[2] << 16) | (Buf[3] << 24));
469 linecoding.
format = Buf[4];
476 Buf[0] = (uint8_t)(linecoding.
bitrate);
477 Buf[1] = (uint8_t)(linecoding.
bitrate >> 8);
478 Buf[2] = (uint8_t)(linecoding.
bitrate >> 16);
479 Buf[3] = (uint8_t)(linecoding.
bitrate >> 24);
480 Buf[4] = linecoding.
format;
486 #define USB_CDCACM_CONTROL_LINE_DTR (0x01) 487 #define USB_CDCACM_CONTROL_LINE_RTS (0x02) 491 linecoding.
bitrate = (uint32_t)(Buf[0] | (Buf[1] << 8));
567 unsigned sz =
MIN_(avail, len);
587 if (sz && (nbytes -= sz))
628 unsigned sz =
MIN_(avail, max_len);
651 if(buffer[0] ==
'1' && buffer[1] ==
'E' && buffer[2] ==
'A' && buffer[3] ==
'F') {
663 if (sz && (nbytes -= sz))
756 int usb_write(
const uint8_t *buf,
unsigned int nbytes) {
void usb_mass_mal_USBdisconnect()
uint16_t usb_tx_pending(void)
uint16_t usb_tx_space(void)
U8 * USBD_USR_DeviceDescriptor(U8 speed, U16 *length)
static INLINE void noInterrupts()
#define USB_LEN_DEV_QUALIFIER_DESC
int usb_configure(usb_attr_t *attr)
#define USBD_MANUFACTURER_STRING
void USB_OTG_StopDevice(USB_OTG_CORE_HANDLE *pdev)
Stop the device and clean up fifo's.
#define GET_ENCAPSULATED_RESPONSE
#define USB_DESC_TYPE_DEVICE_QUALIFIER
uint32_t USBD_OTG_ISR_Handler(const USB_OTG_CORE_HANDLE *pdev)
void USBD_USR_DeviceConfigured(void)
static volatile U8 VCP_RTSHIGH
static INLINE void interrupts()
int usb_ioctl(int request, void *ctl)
static uint8_t buffer[SRXL_FRAMELEN_MAX]
void VCP_MarkWritten(unsigned sz)
U8 * USBD_USR_InterfaceStrDescriptor(U8 speed, U16 *length)
static unsigned ring_space_contig(unsigned size, unsigned head, unsigned tail)
static const USBD_DEVICE USR_CDC_desc
static U16 VCP_Init(void)
#define USBD_SERIALNUMBER_FS_STRING
USBD_Class_cb_TypeDef const USBD_CDC_cb
void USB_OTG_BSP_Init(USB_OTG_CORE_HANDLE *pdev)
void USB_OTG_BSP_DisableInterrupt()
void USB_OTG_BSP_uDelay(const uint32_t usec)
void DCD_DevDisconnect(USB_OTG_CORE_HANDLE *pdev)
Disconnect device (disable internal pull-up)
unsigned VCP_PutContig(void const *buff, unsigned len)
void OTG_FS_IRQHandler(void)
static unsigned ring_wrap(unsigned size, unsigned idx)
#define USBD_IDX_PRODUCT_STR
#define USBD_IDX_SERIAL_STR
uint32_t USB_Rx_buff_size
#define USB_OTG_SPEED_FULL
U8 * USBD_USR_ConfigStrDescriptor(U8 speed, U16 *length)
#define USB_OTG_MAX_EP0_SIZE
void hal_delay_microseconds(uint16_t t)
void gpio_set_mode(const gpio_dev *const dev, uint8_t pin, gpio_pin_mode mode)
static U16 VCP_DataTx(const uint8_t *Buf, uint32_t Len)
uint8_t is_usb_connected(usb_attr_t *attr)
#define USB_OTG_SPEED_HIGH
static U16 VCP_Ctrl(uint32_t Cmd, uint8_t *Buf, uint32_t Len)
#define USB_CDCACM_CONTROL_LINE_RTS
static const U16 rxfifo_size
static uint8_t * VCP_SpacePtr(void)
const USBD_Usr_cb_TypeDef USR_cb
__ALIGN_BEGIN USB_OTG_CORE_HANDLE USB_OTG_dev __ALIGN_END
U8 * USBD_USR_LangIDStrDescriptor(U8 speed, U16 *length)
#define SEND_ENCAPSULATED_COMMAND
uint8_t USBD_StrDesc[USB_MAX_STR_DESC_SIZ]
void USBD_USR_DeviceReset(uint8_t speed)
#define USBD_PRODUCT_FS_STRING
static uint8_t rx_buf[USB_RXFIFO_SIZE]
static void rb_init(ring_buffer *rb, uint16_t size, uint8_t *buf)
void USBD_Init(USB_OTG_CORE_HANDLE *pdev, const USB_OTG_CORE_ID_TypeDef coreID, const USBD_DEVICE *pDevice, const USBD_Class_cb_TypeDef *class_cb, const USBD_Usr_cb_TypeDef *usr_cb)
USBD_Init Initailizes the device stack and load the class driver.
const CDC_IF_Prop_TypeDef VCP_fops
static usb_attr_t * usb_attr
USBD_Status USBD_DeInit(USB_OTG_CORE_HANDLE *pdev)
USBD_DeInit Re-Initialize th device library.
#define USB_SIZ_DEVICE_DESC
static unsigned ring_data_avail(unsigned size, unsigned head, unsigned tail)
void USB_OTG_BSP_mDelay(const uint32_t msec)
void enable_nvic_irq(uint8_t irq, uint8_t prio)
void VCP_SetUSBTxBlocking(uint8_t Mode)
static ring_buffer _rxfifo IN_CCM
static ring_buffer * rxfifo
#define USBD_LANGID_STRING
const uint8_t USBD_LangIDDesc[USB_SIZ_STRING_LANGID]
static volatile U8 VCP_DTRHIGH
static enum reset_state_t reset_state
USB_OTG_CORE_HANDLE USB_OTG_dev
void USBD_USR_DeviceSuspended(void)
static unsigned ring_space_avail(unsigned size, unsigned head, unsigned tail)
uint32_t USB_Rx_buff_tail
#define CLEAR_COMM_FEATURE
const uint8_t USBD_DeviceDesc[USB_SIZ_DEVICE_DESC]
uint32_t usb_data_available(void)
unsigned VCP_GetContig(void *buff, unsigned max_len)
uint32_t USB_Tx_buff_tail
void VCP_MarkRead(unsigned sz)
Board-specific pin information.
static uint8_t const * VCP_DataPtr(void)
void USB_OTG_BSP_EnableInterrupt(USB_OTG_CORE_HANDLE *pdev)
unsigned VCP_SpaceAvailContig(void)
unsigned VCP_SpaceAvail(void)
#define USBD_CONFIGURATION_FS_STRING
U8 * USBD_USR_ProductStrDescriptor(U8 speed, U16 *length)
const gpio_dev * present_port
static INLINE uint8_t gpio_read_bit(const gpio_dev *const dev, uint8_t pin)
#define USBD_INTERFACE_FS_STRING
#define SET_CONTROL_LINE_STATE
const uint8_t USBD_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC]
void board_set_rtc_register(uint32_t sig, uint16_t reg)
static U16 VCP_DataRx(uint8_t *Buf, uint32_t Len)
static void gpio_set_af_mode(const gpio_dev *const dev, uint8_t pin, uint8_t mode)
#define DFU_RTC_SIGNATURE
#define USB_DEVICE_DESCRIPTOR_TYPE
void USBD_USR_DeviceConnected(void)
const gpio_dev *const _GPIOA
#define USB_SIZ_STRING_LANGID
unsigned VCP_DataAvail(void)
U8 * USBD_USR_SerialStrDescriptor(U8 speed, U16 *length)
void USBD_GetString(const uint8_t *desc, uint8_t *unicode, uint16_t *len)
USBD_GetString Convert Ascii string into unicode one.
static void rb_reset(ring_buffer *rb)
Discard all items from a ring buffer.
static U16 VCP_DeInit(void)
unsigned VCP_DataAvailContig(void)
uint32_t USB_Rx_buff_head
#define RTC_SIGNATURE_REG
static unsigned ring_data_contig(unsigned size, unsigned head, unsigned tail)
int usb_periphcfg(FunctionalState state)
void usb_default_attr(usb_attr_t *attr)
void USBD_USR_DeviceDisconnected(void)
#define USB_DESC_TYPE_STRING
#define USB_CDCACM_CONTROL_LINE_DTR
static bool is_bare_metal()
void USBD_USR_DeviceResumed(void)
U8 * USBD_USR_ManufacturerStrDescriptor(U8 speed, U16 *length)
int usb_read(void *buf, unsigned int nbytes)
int usb_write(const uint8_t *buf, unsigned int nbytes)
uint32_t USB_Tx_buff_head
void usb_setParams(usb_attr_t *attr)