diff --git a/conf/Makefile.arm7 b/conf/Makefile.arm7 index ba4c5d2f1b..2ccf326a60 100644 --- a/conf/Makefile.arm7 +++ b/conf/Makefile.arm7 @@ -120,8 +120,8 @@ ADEFS = -D$(RUN_MODE) #CFLAGS = -g0 CFLAGS = $(CDEFS) $(CINCS) CFLAGS += -O$(OPT) -CFLAGS += -Wall -Wcast-qual -Wimplicit -# -Wcast-align # Incompatible with GPS message parsing +# CFLAGS += -malignment-traps +CFLAGS += -Wall -Wcast-qual -Wimplicit -Wcast-align CFLAGS += -Wpointer-arith -Wswitch CFLAGS += -Wredundant-decls -Wreturn-type -Wshadow -Wunused CFLAGS += -Wa,-adhlns=$(OBJDIR)/$(notdir $(subst $(suffix $<),.lst,$<)) diff --git a/conf/airframes/microjet4.xml b/conf/airframes/microjet4.xml index 2a35f44aaa..1acbd2ae04 100644 --- a/conf/airframes/microjet4.xml +++ b/conf/airframes/microjet4.xml @@ -33,25 +33,112 @@ +
+ + +
+ +
+ + + + + +
+ +
+ + + + + + + + + + +
+ +
+ + + + + +
+ +
+ + +
+ +
+ + + + + + + +
+ +
+ + + + + + + + +
+ +
+ + + +
+ +
+ + + +
+ include $(PAPARAZZI_SRC)/conf/autopilot/tiny.makefile +ap.CFLAGS += -DFBW -DAP -DCONFIG=\"tiny.h\" -DLED -DTIME_LED=1 +ap.srcs = sys_time.c $(SRC_ARCH)/sys_time_hw.c $(SRC_ARCH)/armVIC.c main_fbw.c main_ap.c main.c + ap.srcs += commands.c ap.CFLAGS += -DACTUATORS=\"servos_4015_hw.h\" -DSERVOS_4015 ap.srcs += $(SRC_ARCH)/servos_4015_hw.c -ap.CFLAGS += -DRADIO_CONTROL +ap.CFLAGS += -DRADIO_CONTROL -DRADIO_CONTROL_TYPE=RC_FUTABA ap.srcs += radio_control.c $(SRC_ARCH)/ppm_hw.c -ap.CFLAGS += -DDOWNLINK -DUSE_UART0 -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_FBW_DEVICE=Uart0 -DDOWNLINK_AP_DEVICE=Uart0 -ap.srcs += downlink.c pprz_transport.c $(SRC_ARCH)/uart_hw.c +ap.CFLAGS += -DDOWNLINK -DUSE_UART0 -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_FBW_DEVICE=Uart0 -DDOWNLINK_AP_DEVICE=Uart0 -DPPRZ_UART=Uart0 -DDATALINK=PPRZ -DUART0_BAUD=B9600 +ap.srcs += downlink.c pprz_transport.c $(SRC_ARCH)/uart_hw.c datalink.c ap.CFLAGS += -DINTER_MCU ap.srcs += inter_mcu.c -ap.CFLAGS += -DGPS -DUBX -DUSE_UART1 -DGPS_LINK=Uart1 +ap.CFLAGS += -DADC -DUSE_AD0_1 -DUSE_AD0_2 -DUSE_AD0_3 +ap.srcs += $(SRC_ARCH)/adc_hw.c + +ap.CFLAGS += -DGPS -DUBX -DUSE_UART1 -DGPS_LINK=Uart1 -DUART1_BAUD=B19200 -DGPS_CONFIGURE ap.srcs += gps_ubx.c gps.c +ap.CFLAGS += -DINFRARED +ap.srcs += infrared.c estimator.c + +ap.srcs += nav.c pid.c + +# Harware In The Loop +ap.CFLAGS += -DHITL + + diff --git a/conf/airframes/twinjet1.xml b/conf/airframes/twinjet1.xml index bc90baa62e..a7a568955f 100644 --- a/conf/airframes/twinjet1.xml +++ b/conf/airframes/twinjet1.xml @@ -138,13 +138,13 @@ fbw.srcs += $(SRC_ARCH)/adc_hw.c ap.CFLAGS += -DAP -DCONFIG=\"classix.h\" -DLED -DTIME_LED=2 ap.srcs = sys_time.c $(SRC_ARCH)/sys_time_hw.c $(SRC_ARCH)/armVIC.c main_ap.c main.c -ap.CFLAGS += -DDOWNLINK -DUSE_UART0 -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_AP_DEVICE=Uart0 -DPPRZ_INPUT -DPPRZ_UART=Uart0 -DDATALINK +ap.CFLAGS += -DDOWNLINK -DUSE_UART0 -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_AP_DEVICE=Uart0 -DPPRZ_UART=Uart0 -DDATALINK=PPRZ -DUART0_BAUD=B9600 ap.srcs += downlink.c pprz_transport.c $(SRC_ARCH)/uart_hw.c datalink.c traffic_info.c ap.CFLAGS += -DINTER_MCU -DMCU_SPI_LINK ap.srcs += inter_mcu.c link_mcu.c spi.c $(SRC_ARCH)/spi_hw.c -ap.CFLAGS += -DGPS -DUBX -DUSE_UART1 -DGPS_LINK=Uart1 +ap.CFLAGS += -DGPS -DUBX -DUSE_UART1 -DGPS_LINK=Uart1 -DUART1_BAUD=B38400 ap.srcs += gps_ubx.c gps.c ap.CFLAGS += -DADC -DUSE_AD0_1 -DUSE_AD0_2 -DUSE_AD0_3 @@ -155,8 +155,6 @@ ap.srcs += infrared.c estimator.c ap.srcs += nav.c pid.c - - test.CFLAGS += -DFBW -DCONFIG=\"classix.h\" -DLED -DTIME_LED=1 -DACTUATORS=\"servos_4017_hw.h\" -DSERVOS_4017 -DSERVOS_4017_CLOCK_FALLING -DUSE_UART0 -DDATALINK -DPPRZ_INPUT -DPPRZ_UART=Uart0 test.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c $(SRC_ARCH)/armVIC.c pprz_transport.c setup_actuators.c $(SRC_ARCH)/uart_hw.c $(SRC_ARCH)/servos_4017_hw.c main.c diff --git a/conf/airframes/twinstar4.xml b/conf/airframes/twinstar4.xml index fedcad9c82..8e7d532d70 100755 --- a/conf/airframes/twinstar4.xml +++ b/conf/airframes/twinstar4.xml @@ -131,7 +131,7 @@ ap.srcs += $(SRC_ARCH)/modem_hw.c ap.CFLAGS += -DRADIO_CONTROL_CALIB ap.srcs += if_calib.c -ap.CFLAGS += -DDATALINK +ap.CFLAGS += -DDATALINK=WAVECARD ap.srcs += traffic_info.c datalink.c ap.CFLAGS += -DWAVECARD -DWAVECARD_UART=Uart0 -DUSE_UART0 ap.srcs += wavecard.c diff --git a/conf/autopilot/tiny.h b/conf/autopilot/tiny.h index 1c7628a11d..2128ff15df 100644 --- a/conf/autopilot/tiny.h +++ b/conf/autopilot/tiny.h @@ -6,14 +6,19 @@ /* Master oscillator freq. */ #define FOSC (14745600) + /* PLL multiplier */ #define PLL_MUL (4) + /* CPU clock freq. */ #define CCLK (FOSC * PLL_MUL) -/* Peripheral bus speed divider */ -#define PBSD 2 + +/* Peripheral bus speed mask 0x00->4, 0x01-> 1, 0x02 -> 2 */ +#define PBSD_BITS 0x00 +#define PBSD_VAL 4 + /* Peripheral bus clock freq. */ -#define PCLK (CCLK / PBSD) +#define PCLK (CCLK / PBSD_VAL) #define LED_1_BANK 1 #define LED_1_PIN 28 diff --git a/conf/autopilot/tiny.makefile b/conf/autopilot/tiny.makefile index 688229b015..661889bd8c 100644 --- a/conf/autopilot/tiny.makefile +++ b/conf/autopilot/tiny.makefile @@ -6,8 +6,6 @@ ap.ARCHDIR = $(ARCHI) ap.ARCH = arm7tdmi ap.TARGET = autopilot ap.TARGETDIR = autopilot -ap.CFLAGS += -DFBW -DAP -DCONFIG=\"tiny.h\" -ap.srcs = sys_time.c $(SRC_ARCH)/sys_time_hw.c $(SRC_ARCH)/armVIC.c main_fbw.c main_ap_2.c main.c LPC21ISP_BAUD = 115200 -LPC21ISP_XTAL = 14746 \ No newline at end of file +LPC21ISP_XTAL = 14746 diff --git a/conf/flight_plans/muret4.xml b/conf/flight_plans/muret4.xml index e93cbc1bf6..6601f05c2b 100644 --- a/conf/flight_plans/muret4.xml +++ b/conf/flight_plans/muret4.xml @@ -15,6 +15,17 @@ + + + + + + + + + + + diff --git a/conf/messages.xml b/conf/messages.xml index 1ae5a27dec..65744d5058 100644 --- a/conf/messages.xml +++ b/conf/messages.xml @@ -262,18 +262,19 @@ - + - + - + + @@ -285,6 +286,7 @@ + @@ -304,8 +306,8 @@ - + diff --git a/sw/airborne/arm7/uart_hw.c b/sw/airborne/arm7/uart_hw.c index 4df23c54bf..57d40f87c8 100644 --- a/sw/airborne/arm7/uart_hw.c +++ b/sw/airborne/arm7/uart_hw.c @@ -29,7 +29,7 @@ static void uart0_init_param( uint16_t baud, uint8_t mode, uint8_t fmode); void uart0_init_tx( void ) { /** uart0_init_param(UART_BAUD(38400), UART_8N1, UART_FIFO_8); **/ - uart0_init_param(UART_BAUD(9600), UART_8N1, UART_FIFO_8); + uart0_init_param(UART0_BAUD, UART_8N1, UART_FIFO_8); } void uart0_init_rx( void ) {} @@ -224,7 +224,7 @@ uint8_t uart1_tx_running; static void uart1_init_param( uint16_t baud, uint8_t mode, uint8_t fmode); void uart1_init_tx( void ) { - uart1_init_param(UART_BAUD(38400), UART_8N1, UART_FIFO_8); + uart1_init_param(UART1_BAUD, UART_8N1, UART_FIFO_8); } void uart1_init_rx( void ) {} diff --git a/sw/airborne/datalink.c b/sw/airborne/datalink.c index a37adf696e..1f0dbe244c 100644 --- a/sw/airborne/datalink.c +++ b/sw/airborne/datalink.c @@ -28,6 +28,7 @@ #define DATALINK_C #include +#include #include "traffic_info.h" #include "nav.h" #include "datalink.h" @@ -78,6 +79,7 @@ void dl_parse_msg(void) { /** Infrared and GPS sensors are replaced by messages on the datalink */ else if (msg_id == DL_HITL_INFRARED) { /** This code simulates infrared.c:ir_update() */ + DOWNLINK_SEND_DEBUG1(10, dl_buffer); ir_roll = DL_HITL_INFRARED_roll(dl_buffer); ir_pitch = DL_HITL_INFRARED_pitch(dl_buffer); } else if (msg_id == DL_HITL_UBX) { @@ -99,7 +101,10 @@ void dl_parse_msg(void) { #endif #ifdef DlSetting else if (msg_id == DL_SETTING) { - DlSetting(DL_SETTING_index(dl_buffer), DL_SETTING_value(dl_buffer)); + uint8_t i = DL_SETTING_index(dl_buffer); + float var = DL_SETTING_value(dl_buffer); + DlSetting(i, var); + DOWNLINK_SEND_DL_VALUE(&i, &var); } #endif /** Else there is no dl_settings section in the flight plan */ } diff --git a/sw/airborne/datalink.h b/sw/airborne/datalink.h index 4ab65da38c..cc3d55693e 100644 --- a/sw/airborne/datalink.h +++ b/sw/airborne/datalink.h @@ -41,7 +41,7 @@ EXTERN bool_t dl_msg_available; /** Flag provided to control calls to ::dl_parse_msg. NOT used in this module*/ #define MSG_SIZE 128 -EXTERN char dl_buffer[MSG_SIZE]; +EXTERN uint8_t dl_buffer[MSG_SIZE] __attribute__ ((aligned)); void dl_parse_msg(void); /** Should be called when chars are available in dl_buffer */ diff --git a/sw/airborne/gps_ubx.c b/sw/airborne/gps_ubx.c index 1899d02f6a..ae9fe85888 100644 --- a/sw/airborne/gps_ubx.c +++ b/sw/airborne/gps_ubx.c @@ -49,7 +49,8 @@ bool_t gps_pos_available; uint8_t ubx_id, ubx_class; #define UBX_MAX_PAYLOAD 255 -uint8_t ubx_msg_buf[UBX_MAX_PAYLOAD]; + +uint8_t ubx_msg_buf[UBX_MAX_PAYLOAD] __attribute__ ((aligned)); #define RadianOfDeg(d) ((d)/180.*3.1415927) diff --git a/sw/airborne/main_ap.c b/sw/airborne/main_ap.c index 5f6e700c1b..ad936f84a8 100644 --- a/sw/airborne/main_ap.c +++ b/sw/airborne/main_ap.c @@ -508,6 +508,9 @@ void init_ap( void ) { /** Reset the wavecard during the init pause */ wc_reset(); #endif +#if defined GPS && defined GPS_CONFIGURE + gps_configure(); +#endif /************ Internal status ***************/ estimator_init(); @@ -539,9 +542,11 @@ void init_ap( void ) { /*********** EVENT ***********************************************************/ void event_task_ap( void ) { #ifdef GPS +#ifndef HITL /** else comes through the datalink */ if (GpsBuffer()) { ReadGpsBuffer(); } +#endif if (gps_msg_received) { /* parse and use GPS messages */ parse_gps_msg(); @@ -553,7 +558,18 @@ void event_task_ap( void ) { } #endif /** GPS */ -#ifdef WAVECARD +#if defined DATALINK + + +#if DATALINK == PPRZ + if (PprzBuffer()) { + ReadPprzBuffer(); + if (pprz_msg_received) { + pprz_parse_payload(); + pprz_msg_received = FALSE; + } + } +#elif DATALINK == WAVECARD if (WavecardBuffer()) { ReadWavecardBuffer(); if (wc_msg_received) { @@ -562,24 +578,13 @@ void event_task_ap( void ) { wc_msg_received = FALSE; } } -#endif /** WAVECARD */ +#endif -#ifdef PPRZ_INPUT - if (PprzBuffer()) { - ReadPprzBuffer(); - if (pprz_msg_received) { - pprz_msg_received = FALSE; - pprz_parse_payload(); - } - } -#endif /** PPRZ_INPUT */ - -#ifdef DATALINK if (dl_msg_available) { dl_parse_msg(); dl_msg_available = FALSE; } -#endif +#endif /** DATALINK */ #ifdef TELEMETER /** Handling of data sent by the device (initiated by srf08_receive() */ diff --git a/sw/ground_segment/tmtc/link.ml b/sw/ground_segment/tmtc/link.ml index 64189bf319..30e4888e26 100644 --- a/sw/ground_segment/tmtc/link.ml +++ b/sw/ground_segment/tmtc/link.ml @@ -87,7 +87,7 @@ exception NotSendingToThis let airborne_device = fun ac_id airframes device -> let ac_device = try Some (List.assoc ac_id airframes) with Not_found -> None in match ac_device, device with - _, Pprz -> Uart + None, Pprz -> Uart | (Some (WavecardDevice _ as ac_device), Wavecard) | (Some (MaxstreamDevice _ as ac_device), Maxstream) -> ac_device diff --git a/sw/lib/ocaml/convert.c b/sw/lib/ocaml/convert.c index 8885346ad8..cbc4c31ee4 100644 --- a/sw/lib/ocaml/convert.c +++ b/sw/lib/ocaml/convert.c @@ -46,6 +46,13 @@ c_sprint_float(value s, value index, value f) { return Val_unit; } +value +c_sprint_int16(value s, value index, value f) { + int16_t *p = (int16_t*) (String_val(s) + Int_val(index)); + *p = (int16_t)Int_val(f); + return Val_unit; +} + value c_sprint_int32(value s, value index, value x) { char *p = String_val(s) + Int_val(index); diff --git a/sw/lib/ocaml/pprz.ml b/sw/lib/ocaml/pprz.ml index c24ad40cc5..4ad84c7e65 100644 --- a/sw/lib/ocaml/pprz.ml +++ b/sw/lib/ocaml/pprz.ml @@ -74,6 +74,7 @@ external int8_of_bytes : string -> int -> int = "c_int8_of_indexed_bytes" external int16_of_bytes : string -> int -> int = "c_int16_of_indexed_bytes" external sprint_float : string -> int -> float -> unit = "c_sprint_float" external sprint_int32 : string -> int -> int32 -> unit = "c_sprint_int32" +external sprint_int16 : string -> int -> int -> unit = "c_sprint_int16" let types = [ ("uint8", { format = "%u"; glib_type = "guint8"; inttype = "uint8_t"; size = 1; value=Int 42 }); @@ -237,6 +238,7 @@ let rec sprint_value = fun buf i _type v -> Scalar ("int8"|"uint8"), Int x -> buf.[i] <- Char.chr x; sizeof _type | Scalar "float", Float f -> sprint_float buf i f; sizeof _type | Scalar "int32", Int32 x -> sprint_int32 buf i x; sizeof _type + | Scalar "int16", Int x -> sprint_int16 buf i x; sizeof _type | Scalar ("int32" | "uint32"), Int value -> assert (_type <> Scalar "uint32" || value >= 0); buf.[i+3] <- byte (value asr 24);