Paparazzi UAS
v5.15_devel-230-gc96ce27
Paparazzi is a free software Unmanned Aircraft System.
|
CDC USB device driver for STM32 architecture (STM32F1, STM32F4) More...
#include <stdlib.h>
#include <libopencm3/stm32/rcc.h>
#include <libopencm3/stm32/gpio.h>
#include <libopencm3/cm3/nvic.h>
#include <libopencm3/cm3/systick.h>
#include <libopencm3/usb/usbd.h>
#include <libopencm3/usb/cdc.h>
#include <libopencm3/cm3/scb.h>
#include <libopencm3/stm32/desig.h>
#include <libopencm3/stm32/otg_fs.h>
#include "mcu_periph/usb_serial.h"
#include "mcu_periph/sys_time_arch.h"
Go to the source code of this file.
Data Structures | |
struct | fifo_t |
Macros | |
#define | MAX_PACKET_SIZE 64 |
#define | VCOM_FIFO_SIZE 256 |
#define | TX_TIMEOUT_CNT 20 |
Functions | |
void | fifo_init (fifo_t *fifo, uint8_t *buf) |
bool | fifo_put (fifo_t *fifo, uint8_t c) |
bool | fifo_get (fifo_t *fifo, uint8_t *pc) |
int | fifo_avail (fifo_t *fifo) |
int | fifo_free (fifo_t *fifo) |
static int | cdcacm_control_request (usbd_device *usbd_dev, struct usb_setup_data *req, uint8_t **buf, uint16_t *len, void(**complete)(usbd_device *usbd_dev, struct usb_setup_data *req)) |
CDC device control request (from libopencm3 examples) More... | |
static void | cdcacm_data_rx_cb (usbd_device *usbd_dev, uint8_t ep) |
RX callback for CDC device (from libopencm3 examples) More... | |
static void | suspend_cb (void) |
static void | cdcacm_set_config (usbd_device *usbd_dev, uint16_t wValue) |
Set configuration and control callbacks for CDC device (from libopencm3 examples) More... | |
int | VCOM_putchar (int c) |
Writes one character to VCOM port fifo. More... | |
int | VCOM_getchar (void) |
Reads one character from VCOM port. More... | |
bool | VCOM_check_free_space (uint16_t len) |
Checks if buffer free in VCOM buffer. More... | |
int | VCOM_check_available (void) |
Checks if data available in VCOM buffer. More... | |
void | VCOM_event (void) |
Poll usb (required by libopencm3). More... | |
void | VCOM_send_message (void) |
Send data from fifo right now. More... | |
static int | usb_serial_check_free_space (struct usb_serial_periph *p, long *fd, uint16_t len) |
static void | usb_serial_transmit (struct usb_serial_periph *p, long fd, uint8_t byte) |
static void | usb_serial_transmit_buffer (struct usb_serial_periph *p, long fd, uint8_t *data, uint16_t len) |
static void | usb_serial_send (struct usb_serial_periph *p, long fd) |
static int | usb_serial_char_available (struct usb_serial_periph *p) |
static uint8_t | usb_serial_getch (struct usb_serial_periph *p) |
void | VCOM_init (void) |
Variables | |
static uint8_t | txdata [VCOM_FIFO_SIZE] |
static uint8_t | rxdata [VCOM_FIFO_SIZE] |
static fifo_t | txfifo |
static fifo_t | rxfifo |
int | tx_timeout |
usbd_device * | my_usbd_dev |
static const struct usb_device_descriptor | dev |
static const struct usb_endpoint_descriptor | comm_endp [] |
static const struct usb_endpoint_descriptor | data_endp [] |
struct { | |
struct usb_cdc_header_descriptor | header |
struct usb_cdc_call_management_descriptor | call_mgmt |
struct usb_cdc_acm_descriptor | acm |
struct usb_cdc_union_descriptor | cdc_union |
} | cdcacm_functional_descriptors |
static const struct usb_interface_descriptor | comm_iface [] |
static const struct usb_interface_descriptor | data_iface [] |
static const struct usb_interface | ifaces [] |
static const struct usb_config_descriptor | config |
static char | serial_no [25] |
static const char * | usb_strings [] |
uint8_t | usbd_control_buffer [128] |
static bool | usb_connected |
struct usb_serial_periph | usb_serial |
CDC USB device driver for STM32 architecture (STM32F1, STM32F4)
Definition in file usb_ser_hw.c.
struct fifo_t |
Definition at line 90 of file usb_ser_hw.c.
Data Fields | ||
---|---|---|
uint8_t * | buf | |
int | head | |
int | tail |
#define MAX_PACKET_SIZE 64 |
Definition at line 46 of file usb_ser_hw.c.
Referenced by cdcacm_data_rx_cb(), cdcacm_set_config(), and VCOM_send_message().
#define TX_TIMEOUT_CNT 20 |
Definition at line 50 of file usb_ser_hw.c.
Referenced by VCOM_putchar().
#define VCOM_FIFO_SIZE 256 |
Definition at line 48 of file usb_ser_hw.c.
Referenced by fifo_avail(), fifo_free(), fifo_get(), and fifo_put().
|
static |
CDC device control request (from libopencm3 examples)
Definition at line 232 of file usb_ser_hw.c.
Referenced by cdcacm_set_config().
|
static |
RX callback for CDC device (from libopencm3 examples)
Definition at line 275 of file usb_ser_hw.c.
References fifo_put(), and MAX_PACKET_SIZE.
Referenced by cdcacm_set_config().
|
static |
Set configuration and control callbacks for CDC device (from libopencm3 examples)
Definition at line 302 of file usb_ser_hw.c.
References cdcacm_control_request(), cdcacm_data_rx_cb(), MAX_PACKET_SIZE, and suspend_cb().
Referenced by VCOM_init().
int fifo_avail | ( | fifo_t * | fifo | ) |
Definition at line 366 of file usb_ser_hw.c.
References fifo_t::head, fifo_t::tail, and VCOM_FIFO_SIZE.
int fifo_free | ( | fifo_t * | fifo | ) |
Definition at line 372 of file usb_ser_hw.c.
References fifo_avail(), and VCOM_FIFO_SIZE.
Definition at line 348 of file usb_ser_hw.c.
References fifo_t::buf, fifo_t::head, fifo_t::tail, and VCOM_FIFO_SIZE.
Definition at line 321 of file usb_ser_hw.c.
References fifo_t::buf, fifo_t::head, and fifo_t::tail.
Definition at line 330 of file usb_ser_hw.c.
References fifo_t::buf, fifo_t::head, fifo_t::tail, and VCOM_FIFO_SIZE.
|
static |
Definition at line 293 of file usb_ser_hw.c.
Referenced by cdcacm_set_config().
|
static |
Definition at line 532 of file usb_ser_hw.c.
References VCOM_check_available().
Referenced by VCOM_init().
|
static |
Definition at line 503 of file usb_ser_hw.c.
References VCOM_check_free_space().
Referenced by VCOM_init().
|
static |
Definition at line 537 of file usb_ser_hw.c.
References VCOM_getchar().
Referenced by VCOM_init().
|
static |
Definition at line 527 of file usb_ser_hw.c.
References VCOM_send_message().
Referenced by VCOM_init().
|
static |
Definition at line 510 of file usb_ser_hw.c.
References VCOM_putchar().
Referenced by VCOM_init().
|
static |
Definition at line 517 of file usb_ser_hw.c.
References VCOM_putchar().
Referenced by VCOM_init().
int VCOM_check_available | ( | void | ) |
Checks if data available in VCOM buffer.
Definition at line 436 of file usb_ser_hw.c.
References fifo_avail().
bool VCOM_check_free_space | ( | uint16_t | len | ) |
Checks if buffer free in VCOM buffer.
Definition at line 427 of file usb_ser_hw.c.
References FALSE, fifo_free(), and TRUE.
void VCOM_event | ( | void | ) |
Poll usb (required by libopencm3).
VCOM_event() should be called from main/module event function
Definition at line 445 of file usb_ser_hw.c.
References fifo_avail(), my_usbd_dev, tx_timeout, and VCOM_send_message().
int VCOM_getchar | ( | void | ) |
Reads one character from VCOM port.
Definition at line 415 of file usb_ser_hw.c.
References BULK_OUT_EP, BulkOut(), BulkOut_is_blocked, disableIRQ(), enableIRQ(), EOF, fifo_free(), fifo_get(), and MAX_PACKET_SIZE.
void VCOM_init | ( | void | ) |
Definition at line 542 of file usb_ser_hw.c.
References _VIC_ADDR, _VIC_CNTL, abClassReqData, BULK_IN_EP, BULK_OUT_EP, BulkIn(), BulkOut(), cdcacm_set_config(), dev, usb_serial_periph::device, fifo_init(), GPIO11, GPIO12, GPIO_AF10, GPIOA, HandleClassRequest(), INT_IN_EP, my_usbd_dev, rxdata, TRUE, tx_timeout, txdata, usb_serial, usb_serial_char_available(), usb_serial_check_free_space(), usb_serial_getch(), usb_serial_send(), usb_serial_transmit(), usb_serial_transmit_buffer(), USB_VIC_SLOT, USBFrameHandler(), USBIntHandler(), VIC_BIT, VIC_ENABLE, VIC_USB, VICIntEnable, and VICIntSelect.
int VCOM_putchar | ( | int | c | ) |
Writes one character to VCOM port fifo.
Writes one character to VCOM port.
Since we don't really have an instant feeedback from USB driver if the character was written, we always return c if we are connected.
[in] | c | character to write |
Definition at line 387 of file usb_ser_hw.c.
References EOF, fifo_put(), sys_time_usleep(), tx_timeout, TX_TIMEOUT_CNT, VCOM_check_free_space(), and VCOM_send_message().
void VCOM_send_message | ( | void | ) |
Send data from fifo right now.
Only if usb is connected.
Definition at line 464 of file usb_ser_hw.c.
References fifo_get(), MAX_PACKET_SIZE, and my_usbd_dev.
const { ... } cdcacm_functional_descriptors |
|
static |
Definition at line 95 of file usb_ser_hw.c.
|
static |
Definition at line 157 of file usb_ser_hw.c.
|
static |
Definition at line 199 of file usb_ser_hw.c.
Referenced by dshotStart(), and msdStart().
|
static |
Definition at line 105 of file usb_ser_hw.c.
|
static |
Definition at line 175 of file usb_ser_hw.c.
|
static |
Definition at line 73 of file usb_ser_hw.c.
Referenced by dl_parse_msg(), firmware_parse_msg(), gps_mtk_event(), gps_nmea_event(), gps_sirf_event(), gps_skytraq_event(), gps_ubx_event(), ins_event_check_and_handle(), multi_ranger_boot_device(), parse_ins_msg(), send_airspeed(), send_gps(), send_gps_int(), send_gps_lla(), send_i2c_err(), send_uart_err(), telemetry_intermcu_repack(), v4l2_capture_thread(), v4l2_init(), VCOM_init(), and xsens_parser_event().
|
static |
Definition at line 190 of file usb_ser_hw.c.
usbd_device* my_usbd_dev |
Definition at line 71 of file usb_ser_hw.c.
Referenced by VCOM_event(), VCOM_init(), and VCOM_send_message().
|
static |
Definition at line 59 of file usb_ser_hw.c.
Referenced by VCOM_init().
|
static |
Definition at line 62 of file usb_ser_hw.c.
|
static |
Definition at line 212 of file usb_ser_hw.c.
int tx_timeout |
Definition at line 69 of file usb_ser_hw.c.
Referenced by VCOM_event(), VCOM_init(), and VCOM_putchar().
|
static |
Definition at line 58 of file usb_ser_hw.c.
Referenced by VCOM_init().
|
static |
Definition at line 61 of file usb_ser_hw.c.
|
static |
Definition at line 290 of file usb_ser_hw.c.
struct usb_serial_periph usb_serial |
Definition at line 500 of file usb_ser_hw.c.
|
static |
Definition at line 215 of file usb_ser_hw.c.
uint8_t usbd_control_buffer[128] |
Definition at line 226 of file usb_ser_hw.c.