usbuart: Moved some important definitions to the header temporarily
This commit is contained in:
parent
2da8b44c1d
commit
62adb8a7d2
|
@ -23,10 +23,30 @@
|
||||||
#include <libopencm3/usb/usbd.h>
|
#include <libopencm3/usb/usbd.h>
|
||||||
#include <libopencm3/usb/cdc.h>
|
#include <libopencm3/usb/cdc.h>
|
||||||
|
|
||||||
|
#include "general.h"
|
||||||
|
|
||||||
void aux_serial_init(void);
|
void aux_serial_init(void);
|
||||||
|
|
||||||
void aux_serial_set_encoding(struct usb_cdc_line_coding *coding);
|
void aux_serial_set_encoding(struct usb_cdc_line_coding *coding);
|
||||||
void usbuart_usb_out_cb(usbd_device *dev, uint8_t ep);
|
void usbuart_usb_out_cb(usbd_device *dev, uint8_t ep);
|
||||||
void usbuart_usb_in_cb(usbd_device *dev, uint8_t ep);
|
void usbuart_usb_in_cb(usbd_device *dev, uint8_t ep);
|
||||||
|
|
||||||
|
void usbuart_run(void);
|
||||||
|
|
||||||
|
/* F072 with st_usbfs_v2_usb_drive drops characters at the 64 byte boundary!*/
|
||||||
|
#if !defined(USART_DMA_BUF_SIZE)
|
||||||
|
# define USART_DMA_BUF_SIZE 128
|
||||||
|
#endif
|
||||||
|
#define RX_FIFO_SIZE (USART_DMA_BUF_SIZE)
|
||||||
|
#define TX_BUF_SIZE (USART_DMA_BUF_SIZE)
|
||||||
|
|
||||||
|
#ifdef ENABLE_DEBUG
|
||||||
|
/* Debug Fifo buffer with space for copy fn overrun */
|
||||||
|
extern char usb_dbg_buf[RX_FIFO_SIZE + sizeof(uint64_t)];
|
||||||
|
/* Debug Fifo in pointer */
|
||||||
|
extern uint8_t usb_dbg_in;
|
||||||
|
/* Debug Fifo out pointer */
|
||||||
|
extern uint8_t usb_dbg_out;
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include <libopencm3/usb/cdc.h>
|
#include <libopencm3/usb/cdc.h>
|
||||||
|
|
||||||
#include "general.h"
|
#include "general.h"
|
||||||
|
#include "usbuart.h"
|
||||||
#include "usb.h"
|
#include "usb.h"
|
||||||
|
|
||||||
#ifdef DMA_STREAM0
|
#ifdef DMA_STREAM0
|
||||||
|
@ -50,13 +51,6 @@
|
||||||
#define TX_LED_ACT (1 << 0)
|
#define TX_LED_ACT (1 << 0)
|
||||||
#define RX_LED_ACT (1 << 1)
|
#define RX_LED_ACT (1 << 1)
|
||||||
|
|
||||||
/* F072 with st_usbfs_v2_usb_drive drops characters at the 64 byte boundary!*/
|
|
||||||
#if !defined(USART_DMA_BUF_SIZE)
|
|
||||||
# define USART_DMA_BUF_SIZE 128
|
|
||||||
#endif
|
|
||||||
#define RX_FIFO_SIZE (USART_DMA_BUF_SIZE)
|
|
||||||
#define TX_BUF_SIZE (USART_DMA_BUF_SIZE)
|
|
||||||
|
|
||||||
/* TX double buffer */
|
/* TX double buffer */
|
||||||
static uint8_t buf_tx[TX_BUF_SIZE * 2];
|
static uint8_t buf_tx[TX_BUF_SIZE * 2];
|
||||||
/* Active buffer part idx */
|
/* Active buffer part idx */
|
||||||
|
@ -72,17 +66,15 @@ static uint8_t buf_rx_out;
|
||||||
/* RX usb transfer complete */
|
/* RX usb transfer complete */
|
||||||
static bool rx_usb_trfr_cplt = true;
|
static bool rx_usb_trfr_cplt = true;
|
||||||
|
|
||||||
#ifdef USBUART_DEBUG
|
#ifdef ENABLE_DEBUG
|
||||||
/* Debug Fifo buffer with space for copy fn overrun */
|
/* Debug Fifo buffer with space for copy fn overrun */
|
||||||
static uint8_t usb_dbg_buf[RX_FIFO_SIZE + sizeof(uint64_t)];
|
char usb_dbg_buf[RX_FIFO_SIZE + sizeof(uint64_t)];
|
||||||
/* Debug Fifo in pointer */
|
/* Debug Fifo in pointer */
|
||||||
static uint8_t usb_dbg_in;
|
uint8_t usb_dbg_in;
|
||||||
/* Debug Fifo out pointer */
|
/* Debug Fifo out pointer */
|
||||||
static uint8_t usb_dbg_out;
|
uint8_t usb_dbg_out;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void usbuart_run(void);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Update led state atomically respecting RX anb TX states.
|
* Update led state atomically respecting RX anb TX states.
|
||||||
*/
|
*/
|
||||||
|
@ -309,12 +301,12 @@ static void usbuart_send_rx_packet(void)
|
||||||
/* Forcibly empty fifo if no USB endpoint.
|
/* Forcibly empty fifo if no USB endpoint.
|
||||||
* If fifo empty, nothing further to do. */
|
* If fifo empty, nothing further to do. */
|
||||||
if (usb_get_config() != 1 || (buf_rx_in == buf_rx_out
|
if (usb_get_config() != 1 || (buf_rx_in == buf_rx_out
|
||||||
#ifdef USBUART_DEBUG
|
#ifdef ENABLE_DEBUG
|
||||||
&& usb_dbg_in == usb_dbg_out
|
&& usb_dbg_in == usb_dbg_out
|
||||||
#endif
|
#endif
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
#ifdef USBUART_DEBUG
|
#ifdef ENABLE_DEBUG
|
||||||
usb_dbg_out = usb_dbg_in;
|
usb_dbg_out = usb_dbg_in;
|
||||||
#endif
|
#endif
|
||||||
buf_rx_out = buf_rx_in;
|
buf_rx_out = buf_rx_in;
|
||||||
|
@ -330,9 +322,9 @@ static void usbuart_send_rx_packet(void)
|
||||||
uint8_t packet_buf[CDCACM_PACKET_SIZE - 1 + sizeof(uint64_t)];
|
uint8_t packet_buf[CDCACM_PACKET_SIZE - 1 + sizeof(uint64_t)];
|
||||||
uint32_t packet_size;
|
uint32_t packet_size;
|
||||||
|
|
||||||
#ifdef USBUART_DEBUG
|
#ifdef ENABLE_DEBUG
|
||||||
/* Copy data from DEBUG FIFO into local usb packet buffer */
|
/* Copy data from DEBUG FIFO into local usb packet buffer */
|
||||||
packet_size = copy_from_fifo(packet_buf, usb_dbg_buf, usb_dbg_out, usb_dbg_in, CDCACM_PACKET_SIZE - 1, RX_FIFO_SIZE);
|
packet_size = copy_from_fifo(packet_buf, (uint8_t *)usb_dbg_buf, usb_dbg_out, usb_dbg_in, CDCACM_PACKET_SIZE - 1, RX_FIFO_SIZE);
|
||||||
/* Send if buffer not empty */
|
/* Send if buffer not empty */
|
||||||
if (packet_size)
|
if (packet_size)
|
||||||
{
|
{
|
||||||
|
@ -359,7 +351,7 @@ void usbuart_usb_in_cb(usbd_device *dev, uint8_t ep)
|
||||||
usbuart_send_rx_packet();
|
usbuart_send_rx_packet();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void usbuart_run(void)
|
void usbuart_run(void)
|
||||||
{
|
{
|
||||||
nvic_disable_irq(USB_IRQ);
|
nvic_disable_irq(USB_IRQ);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue