7 #ifdef PIOS_INCLUDE_4WAY
14 #include <mixersettings.h>
16 #define USE_SERIAL_4WAY_BLHELI_INTERFACE
18 #define MAX_SUPPORTED_MOTORS 10
22 typedef struct serialPort_s serialPort_t;
23 typedef int ioConfig_t;
26 #define IO_NONE ((IO_t)0)
38 #define IOCFG_OUT_PP 1
44 static inline bool IORead(IO_t io)
49 static inline void IOLo(IO_t io)
54 static inline void IOHi(IO_t io)
59 static inline void IOConfigGPIO(IO_t io, ioConfig_t
cfg)
69 static inline void pwmDisableMotors(
void)
73 static inline void pwmEnableMotors(
void)
77 static inline bool should_be_enabled(
int type)
80 case MIXERSETTINGS_MIXER1TYPE_DISABLED:
81 case MIXERSETTINGS_MIXER1TYPE_MOTOR:
89 #define set_disabled_token_paste(b) \
91 int saved_idx = (b) - 1; \
92 if (saved_idx < MAX_SUPPORTED_MOTORS) { \
93 pwm_val[saved_idx].enabled = pwm_val[saved_idx].enabled && \
94 should_be_enabled(mixerSettings.Mixer ## b ## Type); \
98 static inline pwmOutputPort_t *pwmGetMotors(
void)
100 static pwmOutputPort_t pwm_val[MAX_SUPPORTED_MOTORS];
101 dio_tag_t dios_tmp[MAX_SUPPORTED_MOTORS];
104 MixerSettingsData mixerSettings;
105 MixerSettingsGet(&mixerSettings);
109 for (i = 0; i < num_mot; i++) {
111 pwm_val[
i].enabled =
true;
112 pwm_val[
i].io = dios_tmp[
i];
114 pwm_val[
i].enabled =
false;
115 pwm_val[
i].io = dios_tmp[
i];
119 for (; i < MAX_SUPPORTED_MOTORS; i++) {
120 pwm_val[
i].enabled =
false;
121 pwm_val[
i].io = IO_NONE;
124 set_disabled_token_paste(1);
125 set_disabled_token_paste(2);
126 set_disabled_token_paste(3);
127 set_disabled_token_paste(4);
128 set_disabled_token_paste(5);
129 set_disabled_token_paste(6);
130 set_disabled_token_paste(7);
131 set_disabled_token_paste(8);
132 set_disabled_token_paste(9);
133 set_disabled_token_paste(10);
139 static inline void delayMicroseconds(uint32_t us)
146 static inline uint32_t micros(
void)
151 static inline uint32_t millis(
void)
154 return micros() / 1000;
158 static inline uint8_t serialRead(serialPort_t *
instance)
167 static inline void serialWrite(serialPort_t *instance, uint8_t ch)
173 static inline uint32_t serialRxBytesWaiting(
const serialPort_t *instance)
178 static inline uint32_t serialTxBytesFree(
const serialPort_t *instance)
185 static inline void serialBeginWrite(serialPort_t *instance)
189 static inline void serialEndWrite(serialPort_t *instance)
static void dio_low(dio_tag_t t)
Sets an output GPIO low.
uint32_t PIOS_DELAY_GetuS()
Query the Delay timer for the current uS.
Main PiOS header to include all the compiled in PiOS options.
static void dio_set_input(dio_tag_t t, enum dio_pull pull)
Configures a GPIO as an input.
void PIOS_WDG_Clear(void)
Clear the watchdog timer.
static struct flyingpicmd_cfg_fa cfg
int PIOS_Servo_GetPins(dio_tag_t *dios, int max_dio)
uint16_t PIOS_COM_ReceiveBuffer(uintptr_t com_id, uint8_t *buf, uint16_t buf_len, uint32_t timeout_ms)
static void dio_high(dio_tag_t t)
Sets an output GPIO high.
static void dio_set_output(dio_tag_t t, bool open_collector, enum dio_drive_strength strength, bool first_value)
Configures a GPIO as an output.
PIOS_COM_SendBuffer(shub_global->frsky_port, shub_global->serial_buf, msg_length)
Includes PiOS and core architecture components.
static bool dio_read(dio_tag_t t)
Reads a GPIO logical value.
int32_t PIOS_DELAY_WaituS(uint32_t uS)