Skip to content

Commit

Permalink
fix compilation warnings and errors
Browse files Browse the repository at this point in the history
  • Loading branch information
gautierhattenberger committed Apr 10, 2018
1 parent 191db67 commit 3b0aa82
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 101 deletions.
11 changes: 7 additions & 4 deletions conf/modules/radio_control_spektrum.xml
Expand Up @@ -11,18 +11,17 @@
<configure name="RADIO_CONTROL_SPEKTRUM_PRIMARY_PORT" value="uartX" description="UART for primary spektrum receiver"/>
<configure name="RADIO_CONTROL_SPEKTRUM_SECONDARY_PORT" value="uartX" description="UART for optional secondary spektrum receiver"/>
<configure name="USE_SECONDARY_SPEKTRUM_RECEIVER" value="0|1" description="enable secondary receiver (default: disabled)"/>
<define name="USE_DSMX" value="FALSE|TRUE" description="Set to true to use DSMX instead of DSM2"/>
</doc>
<header>
<file name="spektrum.h" dir="subsystems/radio_control"/>
</header>
<makefile target="ap|fbw|sim|nps|hitl|test_radio_control">
<makefile target="ap|fbw|sim|nps|test_radio_control">
<configure name="RADIO_CONTROL_LED" default="none"/>
<define name="RADIO_CONTROL_LED" value="$(RADIO_CONTROL_LED)" cond="ifneq ($(RADIO_CONTROL_LED),none)"/>
<define name="RADIO_CONTROL_TYPE_H" value="subsystems/radio_control/spektrum.h" type="string"/>
</makefile>
<makefile target="fbw|hitl|test_radio_control">
<define name="RADIO_CONTROL"/>
<define name="RADIO_CONTROL_TYPE_H" value="subsystems/radio_control/spektrum.h" type="string"/>
<define name="RADIO_CONTROL_BIND_IMPL_FUNC" value="spektrum_try_bind"/>

<configure name="SPEKTRUM_PRIMARY_UART" value="$(RADIO_CONTROL_SPEKTRUM_PRIMARY_PORT)" case="upper|lower"/>
Expand All @@ -43,6 +42,9 @@
<file name="radio_control.c" dir="subsystems"/>
<file name="spektrum.c" dir="subsystems/radio_control"/>
</makefile>
<makefile target="ap">
<define name="RADIO_CONTROL_TYPE_H" value="subsystems/radio_control/spektrum.h" type="string"/>
</makefile>
<makefile target="ap" cond="ifeq (,$(findstring $(SEPARATE_FBW),1 TRUE))">
<define name="RADIO_CONTROL"/>
<define name="RADIO_CONTROL_BIND_IMPL_FUNC" value="spektrum_try_bind"/>
Expand All @@ -65,8 +67,9 @@
<file name="radio_control.c" dir="subsystems"/>
<file name="spektrum.c" dir="subsystems/radio_control"/>
</makefile>
<makefile target="sim|nps">
<makefile target="sim|nps|hitl">
<define name="RADIO_CONTROL"/>
<define name="RADIO_CONTROL_TYPE_H" value="subsystems/radio_control/spektrum_arch.h" type="string"/>
<file name="radio_control.c" dir="subsystems"/>
<file_arch name="spektrum_arch.c" dir="subsystems/radio_control"/>
</makefile>
Expand Down
6 changes: 3 additions & 3 deletions sw/airborne/arch/sim/subsystems/radio_control/spektrum_arch.c
Expand Up @@ -27,7 +27,7 @@
*/

#include "subsystems/radio_control.h"
#include "subsystems/radio_control/spektrum.h"
#include "subsystems/radio_control/spektrum_arch.h"
#include "std.h"
#include <inttypes.h>

Expand All @@ -39,8 +39,6 @@

static bool spektrum_available;

void radio_control_spektrum_try_bind(void) {}

void radio_control_impl_init(void)
{
spektrum_available = false;
Expand All @@ -56,6 +54,8 @@ void spektrum_event(void (*frame_handler)(void))
spektrum_available = false;
}

void spektrum_try_bind(void) {}

#if USE_NPS
#ifdef RADIO_CONTROL
void radio_control_feed(void)
Expand Down
37 changes: 2 additions & 35 deletions sw/airborne/arch/sim/subsystems/radio_control/spektrum_arch.h
Expand Up @@ -23,44 +23,11 @@
#ifndef RADIO_CONTROL_SPEKTRUM_ARCH_H
#define RADIO_CONTROL_SPEKTRUM_ARCH_H


/*
* All Spektrum and JR 2.4 GHz transmitters
* have the same channel assignments.
*/


#ifndef RADIO_CONTROL_NB_CHANNEL
#define RADIO_CONTROL_NB_CHANNEL 12
#endif

#if RADIO_CONTROL_NB_CHANNEL > 12
#error "RADIO_CONTROL_NB_CHANNEL mustn't be higher than 12."
#endif

/* channel assignments */
#define RADIO_THROTTLE 0
#define RADIO_ROLL 1
#define RADIO_PITCH 2
#define RADIO_YAW 3
#define RADIO_GEAR 4
#define RADIO_FLAP 5
#define RADIO_AUX1 5
#define RADIO_AUX2 6
#define RADIO_AUX3 7
#define RADIO_AUX4 8
#define RADIO_AUX5 9
#define RADIO_AUX6 10
#define RADIO_AUX7 11

/* really for a 9 channel transmitter
we would swap the order of these */
#ifndef RADIO_MODE
#define RADIO_MODE RADIO_GEAR
#endif
#include "subsystems/radio_control/spektrum_radio.h"

extern void spektrum_event(void (*_received_frame_handler)(void));
#define RadioControlEventImp spektrum_event
extern void spektrum_try_bind(void);

#if USE_NPS
extern void radio_control_feed(void);
Expand Down
49 changes: 0 additions & 49 deletions sw/airborne/subsystems/radio_control/joby_9ch.h

This file was deleted.

17 changes: 8 additions & 9 deletions sw/airborne/subsystems/radio_control/spektrum.c
Expand Up @@ -44,14 +44,6 @@
/* Changed radio control order Notice */
INFO("Radio-Control now follows PPRZ sign convention: this means you might need to reverese some channels in your transmitter: RollRight / PitchUp / YawRight / FullThrottle / Auto2 are positive deflections")

/* Print maximum frame time for debugging */
PRINT_CONFIG_VAR(SPEKTRUM_MAX_FRAME_TIME)

/* Check if sys time is fast enough */
#if (2000 / SPEKTRUM_MAX_FRAME_TIME) > SYS_TIME_FREQUENCY
#error "The system timer frequency is too low for Spektrum, please define a higher SYS_TIME_FREQUENCY"
#endif

/* Number of low pulses sent during binding to the satellite receivers
* As recommended, master and slave receivers are in DSMX 11ms mode,
* other modes (DSM2, 22ms) will be automatically supported
Expand All @@ -71,10 +63,12 @@ PRINT_CONFIG_VAR(SPEKTRUM_MAX_FRAME_TIME)
#define SPEKTRUM_BIND_WAIT 60000
#endif

// in case the number of channel is less than maximum
const int8_t spektrum_signs[] = RADIO_CONTROL_SPEKTRUM_SIGNS;

/* Default spektrum values */
static struct spektrum_t spektrum = {
.valid = false,
.signs = RADIO_CONTROL_SPEKTRUM_SIGNS,
.tx_type = 0, // unknown type
};

Expand Down Expand Up @@ -153,6 +147,11 @@ void spektrum_try_bind(void)
/** Main Radio initialization */
void radio_control_impl_init(void)
{

for (uint8_t i = 0; i < RADIO_CONTROL_NB_CHANNEL; i++) {
spektrum.signs[i] = spektrum_signs[i];
}

// Set polarity to normal on boards that can change this
#ifdef RC_POLARITY_GPIO_PORT
gpio_setup_output(RC_POLARITY_GPIO_PORT, RC_POLARITY_GPIO_PIN);
Expand Down
1 change: 0 additions & 1 deletion sw/airborne/subsystems/radio_control/spektrum.h
Expand Up @@ -43,7 +43,6 @@
#define SPEKTRUM_MAX_FRAMES 2 ///< Maximum amount of RC frames containing different channels
#define SPEKTRUM_MAX_CHANNELS (SPEKTRUM_CHANNELS_PER_FRAME * SPEKTRUM_MAX_FRAMES)
#define SPEKTRUM_MIN_FRAME_SPACE 7 ///< Minum amount of time between frames (7ms), in fact either 11 or 22 ms
#define SPEKTRUM_MAX_FRAME_TIME 4 ///< Maximum amount a frame takes to receive (4ms)

/* Set the event function to the correct */
#define RadioControlEvent(_received_frame_handler) spektrum_event(_received_frame_handler)
Expand Down

0 comments on commit 3b0aa82

Please sign in to comment.