mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-09 22:49:53 +08:00
[test] more tests updates for linux arch
This commit is contained in:
@@ -82,6 +82,9 @@ COMMON_TELEMETRY_CFLAGS += -DPPRZ_UART=$(MODEM_DEV)
|
||||
COMMON_TELEMETRY_CFLAGS += -DDOWNLINK_DEVICE=$(UDP_MODEM_PORT_LOWER)
|
||||
else
|
||||
# via UART
|
||||
#ifeq ($(MODEM_PORT),)
|
||||
#$(error MODEM_PORT not defined)
|
||||
#endif
|
||||
COMMON_TELEMETRY_MODEM_PORT_LOWER=$(shell echo $(MODEM_PORT) | tr A-Z a-z)
|
||||
COMMON_TELEMETRY_CFLAGS += -DUSE_$(MODEM_PORT) -D$(MODEM_PORT)_BAUD=$(MODEM_BAUD)
|
||||
COMMON_TELEMETRY_CFLAGS += -DPPRZ_UART=$(MODEM_PORT)
|
||||
@@ -138,7 +141,6 @@ test_uart.ARCHDIR = $(ARCH)
|
||||
test_uart.CFLAGS += $(COMMON_TEST_CFLAGS)
|
||||
test_uart.srcs += $(COMMON_TEST_SRCS)
|
||||
|
||||
test_uart.CFLAGS += -I$(SRC_LISA) -DUSE_UART
|
||||
#test_uart.CFLAGS += -DUSE_UART1 -DUART1_BAUD=B57600
|
||||
#test_uart.CFLAGS += -DUSE_UART2 -DUART2_BAUD=B57600
|
||||
#test_uart.CFLAGS += -DUSE_UART3 -DUART3_BAUD=B57600
|
||||
@@ -146,6 +148,27 @@ test_uart.CFLAGS += -I$(SRC_LISA) -DUSE_UART
|
||||
test_uart.srcs += mcu_periph/uart.c
|
||||
test_uart.srcs += $(SRC_ARCH)/mcu_periph/uart_arch.c
|
||||
test_uart.srcs += test/mcu_periph/test_uart.c
|
||||
ifeq ($(ARCH), linux)
|
||||
test_uart.srcs += $(SRC_ARCH)/serial_port.c
|
||||
endif
|
||||
|
||||
|
||||
#
|
||||
# test uart_echo
|
||||
#
|
||||
# required configuration:
|
||||
# -DUSE_UARTx
|
||||
# -DUARTx_BAUD=B57600
|
||||
#
|
||||
test_uart_echo.ARCHDIR = $(ARCH)
|
||||
test_uart_echo.CFLAGS += $(COMMON_TEST_CFLAGS)
|
||||
test_uart_echo.srcs += $(COMMON_TEST_SRCS)
|
||||
test_uart_echo.srcs += mcu_periph/uart.c
|
||||
test_uart_echo.srcs += $(SRC_ARCH)/mcu_periph/uart_arch.c
|
||||
test_uart_echo.srcs += test/mcu_periph/test_uart_echo.c
|
||||
ifeq ($(ARCH), linux)
|
||||
test_uart_echo.srcs += $(SRC_ARCH)/serial_port.c
|
||||
endif
|
||||
|
||||
|
||||
#
|
||||
|
||||
@@ -37,6 +37,7 @@ int main(void)
|
||||
if (sys_time_check_and_ack_timer(0)) {
|
||||
main_periodic();
|
||||
}
|
||||
uart_event();
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -61,8 +62,11 @@ static inline void main_periodic(void)
|
||||
#if USE_UART3
|
||||
uart_transmit(&uart3, 'c');
|
||||
#endif
|
||||
#if USE_UART4
|
||||
uart_transmit(&uart4, 'd');
|
||||
#endif
|
||||
#if USE_UART5
|
||||
uart_transmit(&uart5, 'd');
|
||||
uart_transmit(&uart5, 'e');
|
||||
#endif
|
||||
|
||||
LED_OFF(1);
|
||||
@@ -101,9 +105,9 @@ static inline void main_periodic(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if USE_UART5
|
||||
if (uart_char_available(&uart5)) {
|
||||
ch = uart_getch(&uart5);
|
||||
#if USE_UART4
|
||||
if (uart_char_available(&uart4)) {
|
||||
ch = uart_getch(&uart4);
|
||||
if (ch == 'd') {
|
||||
LED_ON(1);
|
||||
} else {
|
||||
@@ -111,4 +115,15 @@ static inline void main_periodic(void)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if USE_UART5
|
||||
if (uart_char_available(&uart5)) {
|
||||
ch = uart_getch(&uart5);
|
||||
if (ch == 'e') {
|
||||
LED_ON(1);
|
||||
} else {
|
||||
LED_ON(2);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Felix Ruess <felix.ruess@gmail.com>
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
*
|
||||
* paparazzi is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* paparazzi is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include BOARD_CONFIG
|
||||
#include "mcu.h"
|
||||
#include "mcu_periph/uart.h"
|
||||
#include "mcu_periph/sys_time.h"
|
||||
#include "std.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef TEST_UART
|
||||
#if USE_UART1
|
||||
#define TEST_UART uart1
|
||||
#endif
|
||||
#if USE_UART4
|
||||
#define TEST_UART uart4
|
||||
#endif
|
||||
#endif
|
||||
PRINT_CONFIG_VAR(TEST_UART)
|
||||
|
||||
static inline void main_init(void);
|
||||
static inline void main_periodic(void);
|
||||
static inline void main_event(void);
|
||||
|
||||
int main(void)
|
||||
{
|
||||
main_init();
|
||||
|
||||
while (1) {
|
||||
if (sys_time_check_and_ack_timer(0)) {
|
||||
main_periodic();
|
||||
}
|
||||
main_event();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void main_init(void)
|
||||
{
|
||||
mcu_init();
|
||||
sys_time_register_timer((1. / PERIODIC_FREQUENCY), NULL);
|
||||
}
|
||||
|
||||
static inline void main_periodic(void)
|
||||
{
|
||||
const char *foo = "FooBarBaz";
|
||||
static int i = 0;
|
||||
|
||||
if (i == strlen(foo)) {
|
||||
i = 0;
|
||||
}
|
||||
|
||||
uart_transmit(&TEST_UART, foo[i]);
|
||||
printf("%f, transmit: '%c'\n", get_sys_time_float(), foo[i]);
|
||||
|
||||
if (uart_char_available(&TEST_UART)) {
|
||||
char c = uart_getch(&TEST_UART);
|
||||
printf("%f, received: '%c'\n", get_sys_time_float(), c);
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
static inline void main_event(void)
|
||||
{
|
||||
uart_event();
|
||||
}
|
||||
@@ -82,6 +82,8 @@ static inline void main_event_task(void)
|
||||
{
|
||||
#if USE_UDP
|
||||
udp_event();
|
||||
#else
|
||||
uart_event();
|
||||
#endif
|
||||
ImuEvent(on_gyro_event, on_accel_event, on_mag_event);
|
||||
}
|
||||
|
||||
@@ -118,6 +118,8 @@ static inline void main_event_task(void)
|
||||
{
|
||||
#if USE_UDP
|
||||
udp_event();
|
||||
#else
|
||||
uart_event();
|
||||
#endif
|
||||
ImuEvent(on_gyro_event, on_accel_event, on_mag_event);
|
||||
}
|
||||
|
||||
@@ -88,6 +88,8 @@ static inline void main_event_task(void)
|
||||
{
|
||||
#if USE_UDP
|
||||
udp_event();
|
||||
#else
|
||||
uart_event();
|
||||
#endif
|
||||
RadioControlEvent(main_on_radio_control_frame);
|
||||
}
|
||||
|
||||
@@ -90,6 +90,8 @@ static inline void main_event(void)
|
||||
{
|
||||
#if USE_UDP
|
||||
udp_event();
|
||||
#else
|
||||
uart_event();
|
||||
#endif
|
||||
DatalinkEvent();
|
||||
}
|
||||
|
||||
@@ -67,5 +67,7 @@ static inline void main_event(void)
|
||||
{
|
||||
#if USE_UDP
|
||||
udp_event();
|
||||
#else
|
||||
uart_event();
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user