DevGuide/USB-Serial

From PaparazziUAV
Revision as of 11:42, 4 February 2009 by Martinmm (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

USB serial telemetry

Warning

This feature is EXPERIMENTAL. Please do not fly it until it is extensively tested. The USB stack adds some complex software and numerous interrupts to the system. To use USB with the LPC2148 the peripheral clock (PCLK) has to be higher than 18MHz (thanks for the info, Andre). Until now PCLK has been running with 15MHz so it has to be increased. Please make sure all LPC2148 peripheral modules you are using do operate correctly at the higher PCLK. It is planned to increase PCLK as default. Almost all I/O operations (e.g. also the speed of a GPIO pin toggle) are affected by this. Make your peripheral initialization to be independent of PCLK. The Paparazzi software drivers have been checked to run properly at a different PCLK but it is a good idea to check before you fly.

Application

Until now you will need an external FTDI cable/chip or a pair of modems if you want to test and debug a Paparazzi system in your lab. This serial USB removes the need for this. It is possible to get telemetry through the same USB interface that you use for download. This USB serial might also be used to connect to an on-board payload processor (e.g. BeagleBoard).

Usage

The PCLK is increased to (at least) 30MHz to make the USB work properly. There is conf/autopilot/tiny_2_1_1_usb.h for the Tiny board that does that for you. In conf/airframes/usb_test.xml it is shown how to use the USB as telemetry link. It is connected instead of Uart0 or Uart1 and uses the transparent PPRZ format.

ap.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport -DUSE_USB_SERIAL
ap.CFLAGS += -DDOWNLINK_FBW_DEVICE=UsbS -DDOWNLINK_AP_DEVICE=UsbS -DPPRZ_UART=UsbS -DDATALINK=PPRZ
ap.srcs += downlink.c $(SRC_ARCH)/uart_hw.c $(SRC_ARCH)/usb_ser_hw.c datalink.c pprz_transport.c
ap.srcs += $(SRC_ARCH)/lpcusb/usbhw_lpc.c $(SRC_ARCH)/lpcusb/usbcontrol.c
ap.srcs += $(SRC_ARCH)/lpcusb/usbstdreq.c $(SRC_ARCH)/lpcusb/usbinit.c

The USB serial will connect as a modem through /dev/ttyACM0 on a Linux system. Use this as device for the Paparazzi link application. The baudrate can be set to any value as it is fully virtual.

/paparazzi3/sw/ground_segment/tmtc/link -d /dev/ttyACM0