From a2d33c7cabd3d03b314252843df3dae3a564a814 Mon Sep 17 00:00:00 2001 From: Felix Ruess Date: Thu, 22 Aug 2013 13:38:10 +0200 Subject: [PATCH] [omap] rename/move FmsSerialPort to SerialPort in arch/omap --- conf/firmwares/rotorcraft.makefile | 17 +++----------- sw/airborne/arch/omap/mcu_periph/uart_arch.c | 10 ++++----- .../omap/serial_port.c} | 18 +++++++-------- .../omap/serial_port.h} | 22 +++++++++---------- sw/airborne/firmwares/beth/overo_test_uart.c | 4 ++-- sw/airborne/firmwares/beth/uart_hw.c | 6 ++--- 6 files changed, 33 insertions(+), 44 deletions(-) rename sw/airborne/{fms/fms_serial_port.c => arch/omap/serial_port.c} (87%) rename sw/airborne/{fms/fms_serial_port.h => arch/omap/serial_port.h} (66%) diff --git a/conf/firmwares/rotorcraft.makefile b/conf/firmwares/rotorcraft.makefile index bb42616a4b..58b2b6187e 100644 --- a/conf/firmwares/rotorcraft.makefile +++ b/conf/firmwares/rotorcraft.makefile @@ -108,6 +108,9 @@ ap.srcs += $(SRC_ARCH)/subsystems/settings_arch.c ap.srcs += mcu_periph/uart.c ap.srcs += $(SRC_ARCH)/mcu_periph/uart_arch.c +ifeq ($(ARCH), omap) +ap.srcs += $(SRC_ARCH)/serial_port.c +endif # I2C is needed for speed controllers and barometers on lisa ifeq ($(TARGET), ap) @@ -291,17 +294,3 @@ ap.srcs += $(SRC_FIRMWARE)/guidance/guidance_v_adapt.c ap.srcs += $(SRC_FIRMWARE)/navigation.c ap.srcs += subsystems/navigation/common_flight_plan.c -# -# FMS choice -# -# include booz2_fms_test_signal.makefile -# or -# include booz2_fms_datalink.makefile -# or -# nothing -# -ifeq ($(ARCH), omap) -SRC_FMS=fms -ap.CFLAGS += -I. -I$(SRC_FMS) -ap.srcs += $(SRC_FMS)/fms_serial_port.c -endif diff --git a/sw/airborne/arch/omap/mcu_periph/uart_arch.c b/sw/airborne/arch/omap/mcu_periph/uart_arch.c index 2e8b9b4964..0d4cd02bd1 100644 --- a/sw/airborne/arch/omap/mcu_periph/uart_arch.c +++ b/sw/airborne/arch/omap/mcu_periph/uart_arch.c @@ -34,7 +34,7 @@ // FIXME: fms_serial_port includes termios.h that with omap defines B9600 as 12 // Include termios.h AFTER uart.h. This OVERWRITES (without warning) the paparazzi uart.h B9600 -#include "fms/fms_serial_port.h" +#include "serial_port.h" // #define TRACE(fmt,args...) fprintf(stderr, fmt, args) #define TRACE(fmt,args...) @@ -59,10 +59,10 @@ speed_t baudconvert_drone(uint32_t baud) void uart_periph_set_baudrate(struct uart_periph* p, uint32_t baud) { - struct FmsSerialPort* fmssp; + struct SerialPort* fmssp; // close serial port if already open if (p->reg_addr != NULL) { - fmssp = (struct FmsSerialPort*)(p->reg_addr); + fmssp = (struct SerialPort*)(p->reg_addr); serial_port_close(fmssp); serial_port_free(fmssp); } @@ -94,7 +94,7 @@ void uart_transmit(struct uart_periph* p, uint8_t data ) { } else { // no, set running flag and write to output register p->tx_running = TRUE; - struct FmsSerialPort* fmssp = (struct FmsSerialPort*)(p->reg_addr); + struct SerialPort* fmssp = (struct SerialPort*)(p->reg_addr); int ret = write((int)(fmssp->fd),&data,1); if (ret < 1) { @@ -110,7 +110,7 @@ static inline void uart_handler(struct uart_periph* p) { if (p->reg_addr == NULL) return; // device not initialized ? - struct FmsSerialPort* fmssp = (struct FmsSerialPort*)(p->reg_addr); + struct SerialPort* fmssp = (struct SerialPort*)(p->reg_addr); int fd = fmssp->fd; // check if more data to send diff --git a/sw/airborne/fms/fms_serial_port.c b/sw/airborne/arch/omap/serial_port.c similarity index 87% rename from sw/airborne/fms/fms_serial_port.c rename to sw/airborne/arch/omap/serial_port.c index 4e20792050..13441f77b0 100644 --- a/sw/airborne/fms/fms_serial_port.c +++ b/sw/airborne/arch/omap/serial_port.c @@ -1,4 +1,4 @@ -#include "fms_serial_port.h" +#include "serial_port.h" #include #include @@ -13,17 +13,17 @@ #define TRACE(type,fmt,args...) #define TRACE_ERROR 1 -struct FmsSerialPort* serial_port_new(void) { - struct FmsSerialPort* me = malloc(sizeof(struct FmsSerialPort)); +struct SerialPort* serial_port_new(void) { + struct SerialPort* me = malloc(sizeof(struct SerialPort)); return me; } -void serial_port_free(struct FmsSerialPort* me) { +void serial_port_free(struct SerialPort* me) { free(me); } -void serial_port_flush(struct FmsSerialPort* me) { +void serial_port_flush(struct SerialPort* me) { /* * flush any input that might be on the port so we start fresh. */ @@ -33,7 +33,7 @@ void serial_port_flush(struct FmsSerialPort* me) { } } -void serial_port_flush_output(struct FmsSerialPort* me) { +void serial_port_flush_output(struct SerialPort* me) { /* * flush any input that might be on the port so we start fresh. */ @@ -43,7 +43,7 @@ void serial_port_flush_output(struct FmsSerialPort* me) { } } -int serial_port_open_raw(struct FmsSerialPort* me, const char* device, speed_t speed) { +int serial_port_open_raw(struct SerialPort* me, const char* device, speed_t speed) { if ((me->fd = open(device, O_RDWR | O_NONBLOCK | O_NOCTTY)) < 0) { TRACE(TRACE_ERROR,"%s, open failed: %s (%d)\n", device, strerror(errno), errno); return -1; @@ -78,7 +78,7 @@ int serial_port_open_raw(struct FmsSerialPort* me, const char* device, speed_t return 0; } -int serial_port_open(struct FmsSerialPort* me, const char* device, +int serial_port_open(struct SerialPort* me, const char* device, void(*term_conf_callback)(struct termios*, speed_t*)) { speed_t speed; @@ -108,7 +108,7 @@ int serial_port_open(struct FmsSerialPort* me, const char* device, } -void serial_port_close(struct FmsSerialPort* me) { +void serial_port_close(struct SerialPort* me) { /* if null pointer or file descriptor indicates error just bail */ if (!me || me->fd < 0) diff --git a/sw/airborne/fms/fms_serial_port.h b/sw/airborne/arch/omap/serial_port.h similarity index 66% rename from sw/airborne/fms/fms_serial_port.h rename to sw/airborne/arch/omap/serial_port.h index 44a120c73c..f259114975 100644 --- a/sw/airborne/fms/fms_serial_port.h +++ b/sw/airborne/arch/omap/serial_port.h @@ -20,24 +20,24 @@ * */ -#ifndef FMS_SERIAL_PORT_H -#define FMS_SERIAL_PORT_H +#ifndef SERIAL_PORT_H +#define SERIAL_PORT_H #include -struct FmsSerialPort { +struct SerialPort { int fd; /* serial device fd */ struct termios orig_termios; /* saved tty state structure */ struct termios cur_termios; /* tty state structure */ }; -extern struct FmsSerialPort* serial_port_new(void); -extern void serial_port_free(struct FmsSerialPort* me); -extern void serial_port_flush(struct FmsSerialPort* me); -extern void serial_port_flush_output(struct FmsSerialPort* me); -extern int serial_port_open_raw(struct FmsSerialPort* me, const char* device, speed_t speed); -extern int serial_port_open(struct FmsSerialPort* me, const char* device, +extern struct SerialPort* serial_port_new(void); +extern void serial_port_free(struct SerialPort* me); +extern void serial_port_flush(struct SerialPort* me); +extern void serial_port_flush_output(struct SerialPort* me); +extern int serial_port_open_raw(struct SerialPort* me, const char* device, speed_t speed); +extern int serial_port_open(struct SerialPort* me, const char* device, void(*term_conf_callback)(struct termios*, speed_t*)); -extern void serial_port_close(struct FmsSerialPort* me); +extern void serial_port_close(struct SerialPort* me); -#endif /* FMS_SERIAL_PORT_H */ +#endif /* SERIAL_PORT_H */ diff --git a/sw/airborne/firmwares/beth/overo_test_uart.c b/sw/airborne/firmwares/beth/overo_test_uart.c index add7fb9055..572696f762 100644 --- a/sw/airborne/firmwares/beth/overo_test_uart.c +++ b/sw/airborne/firmwares/beth/overo_test_uart.c @@ -37,7 +37,7 @@ #include "fms_periodic.h" #include "fms_debug.h" -#include "fms_serial_port.h" +#include "serial_port.h" #include "overo_gcs_com.h" #include "uart_hw.h" @@ -57,7 +57,7 @@ void check_gps(void); uint8_t nav_utm_zone0 = 31; static uint16_t foo = 0; -//struct FmsSerialPort* fmssp; +//struct SerialPort* fmssp; //int spfd; uint8_t portnum; #ifdef GPS_CONFIGURE diff --git a/sw/airborne/firmwares/beth/uart_hw.c b/sw/airborne/firmwares/beth/uart_hw.c index 558747b871..2d05231221 100644 --- a/sw/airborne/firmwares/beth/uart_hw.c +++ b/sw/airborne/firmwares/beth/uart_hw.c @@ -27,7 +27,7 @@ #include #include -#include "fms_serial_port.h" +#include "serial_port.h" #ifdef USE_UART0 @@ -39,7 +39,7 @@ volatile uint16_t uart0_tx_insert_idx, uart0_tx_extract_idx; volatile bool_t uart0_tx_running; uint8_t uart0_tx_buffer[UART0_TX_BUFFER_SIZE]; -struct FmsSerialPort* fmssp0; +struct SerialPort* fmssp0; int uart0_fd; extern uint8_t portnum; @@ -165,7 +165,7 @@ volatile uint16_t uart1_tx_insert_idx, uart1_tx_extract_idx; volatile bool_t uart1_tx_running; uint8_t uart1_tx_buffer[UART1_TX_BUFFER_SIZE]; -struct FmsSerialPort* fmssp1; +struct SerialPort* fmssp1; int uart1_fd; void uart1_init( void ) {