diff --git a/conf/airframes/example.xml b/conf/airframes/example.xml new file mode 100644 index 0000000000..4ea1239ea8 --- /dev/null +++ b/conf/airframes/example.xml @@ -0,0 +1,43 @@ + + + + +ARCHI=arm7 + +FLASH_MODE = IAP + + + +# +# GPS : +# +# +example_gps.ARCHDIR = $(ARCHI) +example_gps.ARCH = arm7tdmi +example_gps.TARGET = example_gps +example_gps.TARGETDIR = example_gps + +example_gps.CFLAGS += -DCONFIG=\"conf_demo.h\" +example_gps.srcs = example/example_gps.c + +example_gps.CFLAGS += -DPERIODIC_TASK_PERIOD='SYS_TICS_OF_SEC(10e-2)' +example_gps.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c + +example_gps.CFLAGS += -DLED + +example_gps.srcs += $(SRC_ARCH)/armVIC.c + +example_gps.CFLAGS += -DUSE_UART0 -DUART0_BAUD=B38400 +example_gps.srcs += $(SRC_ARCH)/uart_hw.c + +example_gps.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_DEVICE=Uart0 +example_gps.srcs += downlink.c pprz_transport.c + +example_gps.CFLAGS += -DUSE_UART1 -DUART1_BAUD=B38400 +example_gps.CFLAGS += -DGPS -DUBX -DGPS_LINK=Uart0 -DDOWNLINK_GPS_DEVICE=Uart0 -DGPS_BAUD=38400 +example_gps.srcs += gps_ubx.c gps.c latlong.c + + + + + diff --git a/sw/airborne/example/example_gps.c b/sw/airborne/example/example_gps.c new file mode 100644 index 0000000000..fe929d6566 --- /dev/null +++ b/sw/airborne/example/example_gps.c @@ -0,0 +1,51 @@ +#include "std.h" +#include "init_hw.h" +#include "sys_time.h" +#include "led.h" +#include "interrupt_hw.h" +#include "uart.h" + +#include "messages.h" +#include "downlink.h" + +#include "gps.h" + +static inline void main_init( void ); +static inline void main_periodic_task( void ); +static inline void main_event_task( void ); +static inline void on_gps( void ); + +int main( void ) { + main_init(); + while(1) { + if (sys_time_periodic()) + main_periodic_task(); + main_event_task(); + } + return 0; +} + +static inline void main_init( void ) { + hw_init(); + sys_time_init(); + led_init(); + uart0_init_tx(); + uart1_init_tx(); + gps_init(); + int_enable(); +} + +static inline void main_periodic_task( void ) { + LED_TOGGLE(1); + DOWNLINK_SEND_TAKEOFF(&cpu_time_sec); +} + +static inline void main_event_task( void ) { + + GpsEventCheckAndHandle(on_gps, FALSE); + +} + +static inline void on_gps( void ) { + // do something clever +}