mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-30 03:27:33 +08:00
[usb_serial] convert usb_serial to generic device API
This commit is contained in:
@@ -4,8 +4,8 @@
|
|||||||
#serial USB (e.g. /dev/ttyACM0)
|
#serial USB (e.g. /dev/ttyACM0)
|
||||||
|
|
||||||
ifeq ($(ARCH), lpc21)
|
ifeq ($(ARCH), lpc21)
|
||||||
ap.CFLAGS += -DDOWNLINK -DPERIODIC_TELEMETRY -DDOWNLINK_DEVICE=UsbS -DPPRZ_UART=UsbS
|
ap.CFLAGS += -DDOWNLINK -DPERIODIC_TELEMETRY -DDOWNLINK_DEVICE=usb_serial -DPPRZ_UART=UsbS
|
||||||
ap.CFLAGS += -DDOWNLINK_TRANSPORT=PprzTransport -DDATALINK=PPRZ -DUSE_USB_SERIAL -DUSE_USB_HIGH_PCLK
|
ap.CFLAGS += -DDOWNLINK_TRANSPORT=pprz_tp -DDATALINK=PPRZ -DUSE_USB_SERIAL -DUSE_USB_HIGH_PCLK
|
||||||
ap.srcs += subsystems/datalink/downlink.c subsystems/datalink/pprz_transport.c
|
ap.srcs += subsystems/datalink/downlink.c subsystems/datalink/pprz_transport.c
|
||||||
ap.srcs += $(SRC_FIRMWARE)/datalink.c
|
ap.srcs += $(SRC_FIRMWARE)/datalink.c
|
||||||
ap.srcs += $(SRC_ARCH)/usb_ser_hw.c $(SRC_ARCH)/lpcusb/usbhw_lpc.c $(SRC_ARCH)/lpcusb/usbcontrol.c
|
ap.srcs += $(SRC_ARCH)/usb_ser_hw.c $(SRC_ARCH)/lpcusb/usbhw_lpc.c $(SRC_ARCH)/lpcusb/usbcontrol.c
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
#serial USB (e.g. /dev/ttyACM0)
|
#serial USB (e.g. /dev/ttyACM0)
|
||||||
|
|
||||||
ifeq ($(ARCH), lpc21)
|
ifeq ($(ARCH), lpc21)
|
||||||
ap.CFLAGS += -DDOWNLINK -DPERIODIC_TELEMETRY -DDOWNLINK_DEVICE=UsbS -DPPRZ_UART=UsbS
|
ap.CFLAGS += -DDOWNLINK -DPERIODIC_TELEMETRY -DDOWNLINK_DEVICE=usb_serial -DPPRZ_UART=UsbS
|
||||||
ap.CFLAGS += -DDOWNLINK_TRANSPORT=PprzTransport -DDATALINK=PPRZ -DUSE_USB_SERIAL -DDefaultPeriodic='&telemetry_Main'
|
ap.CFLAGS += -DDOWNLINK_TRANSPORT=pprz_tp -DDATALINK=PPRZ -DUSE_USB_SERIAL -DDefaultPeriodic='&telemetry_Main'
|
||||||
ap.srcs += subsystems/datalink/downlink.c subsystems/datalink/pprz_transport.c subsystems/datalink/telemetry.c
|
ap.srcs += subsystems/datalink/downlink.c subsystems/datalink/pprz_transport.c subsystems/datalink/telemetry.c
|
||||||
ap.srcs += $(SRC_FIRMWARE)/datalink.c $(SRC_FIRMWARE)/rotorcraft_telemetry.c
|
ap.srcs += $(SRC_FIRMWARE)/datalink.c $(SRC_FIRMWARE)/rotorcraft_telemetry.c
|
||||||
ap.srcs += $(SRC_ARCH)/usb_ser_hw.c $(SRC_ARCH)/lpcusb/usbhw_lpc.c $(SRC_ARCH)/lpcusb/usbcontrol.c
|
ap.srcs += $(SRC_ARCH)/usb_ser_hw.c $(SRC_ARCH)/lpcusb/usbhw_lpc.c $(SRC_ARCH)/lpcusb/usbcontrol.c
|
||||||
|
|||||||
@@ -434,7 +434,7 @@ int VCOM_check_available(void)
|
|||||||
@param [in] bEP
|
@param [in] bEP
|
||||||
@param [in] bEPStatus
|
@param [in] bEPStatus
|
||||||
*/
|
*/
|
||||||
static void BulkOut(U8 bEP, U8 bEPStatus)
|
static void BulkOut(U8 bEP, U8 bEPStatus __attribute__((unused)))
|
||||||
{
|
{
|
||||||
int i, iLen;
|
int i, iLen;
|
||||||
|
|
||||||
@@ -463,7 +463,7 @@ static void BulkOut(U8 bEP, U8 bEPStatus)
|
|||||||
@param [in] bEP
|
@param [in] bEP
|
||||||
@param [in] bEPStatus
|
@param [in] bEPStatus
|
||||||
*/
|
*/
|
||||||
static void BulkIn(U8 bEP, U8 bEPStatus)
|
static void BulkIn(U8 bEP, U8 bEPStatus __attribute__((unused)))
|
||||||
{
|
{
|
||||||
int i, iLen;
|
int i, iLen;
|
||||||
|
|
||||||
@@ -541,7 +541,7 @@ static void USBIntHandler(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void USBFrameHandler(U16 wFrame)
|
static void USBFrameHandler(U16 wFrame __attribute__((unused)))
|
||||||
{
|
{
|
||||||
if (fifo_avail(&txfifo) > 0) {
|
if (fifo_avail(&txfifo) > 0) {
|
||||||
// data available, enable NAK interrupt on bulk in
|
// data available, enable NAK interrupt on bulk in
|
||||||
@@ -549,6 +549,21 @@ static void USBFrameHandler(U16 wFrame)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Periph with generic device API
|
||||||
|
struct usb_serial_periph usb_serial;
|
||||||
|
|
||||||
|
// Functions for the generic device API
|
||||||
|
static int usb_serial_check_free_space(struct usb_serial_periph* p __attribute__((unused)), uint8_t len)
|
||||||
|
{
|
||||||
|
return (int)VCOM_check_free_space(len);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void usb_serial_transmit(struct usb_serial_periph* p __attribute__((unused)), uint8_t byte)
|
||||||
|
{
|
||||||
|
VCOM_putchar(byte);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void usb_serial_send(struct usb_serial_periph* p __attribute__((unused))) { }
|
||||||
|
|
||||||
void VCOM_init(void) {
|
void VCOM_init(void) {
|
||||||
// initialise stack
|
// initialise stack
|
||||||
@@ -588,6 +603,12 @@ void VCOM_init(void) {
|
|||||||
|
|
||||||
// connect to bus
|
// connect to bus
|
||||||
USBHwConnect(TRUE);
|
USBHwConnect(TRUE);
|
||||||
|
|
||||||
|
// Configure generic device
|
||||||
|
usb_serial.device.periph = (void *)(&usb_serial);
|
||||||
|
usb_serial.device.check_free_space = (check_free_space_t) usb_serial_check_free_space;
|
||||||
|
usb_serial.device.transmit = (transmit_t) usb_serial_transmit;
|
||||||
|
usb_serial.device.send_message = (send_message_t) usb_serial_send;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -30,8 +30,16 @@
|
|||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include "std.h"
|
#include "std.h"
|
||||||
|
#include "mcu_periph/device.h"
|
||||||
//#include "usb_serial_hw.h"
|
//#include "usb_serial_hw.h"
|
||||||
|
|
||||||
|
struct usb_serial_periph {
|
||||||
|
/** Generic device interface */
|
||||||
|
struct device device;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern struct usb_serial_periph usb_serial;
|
||||||
|
|
||||||
void VCOM_init(void);
|
void VCOM_init(void);
|
||||||
int VCOM_putchar(int c);
|
int VCOM_putchar(int c);
|
||||||
int VCOM_getchar(void);
|
int VCOM_getchar(void);
|
||||||
|
|||||||
Reference in New Issue
Block a user