mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-17 05:15:23 +03:00
Merge branch 'master' into dzikuvx-logic-condition-global-function-unification
This commit is contained in:
commit
893e532f8b
19 changed files with 585 additions and 35 deletions
|
@ -39,6 +39,14 @@ Logic conditions can be edited using INAV Configurator user interface, of via CL
|
|||
| 11 | NOR | |
|
||||
| 12 | NOT | |
|
||||
| 13 | STICKY | `Operand A` is activation operator, `Operand B` is deactivation operator. After activation, operator will return `true` until Operand B is evaluated as `true`|
|
||||
| 14 | ADD | Add `Operand A` to `Operand B` and returns the result |
|
||||
| 15 | SUB | Substract `Operand B` from `Operand A` and returns the result |
|
||||
| 16 | MUL | Multiply `Operand A` by `Operand B` and returns the result |
|
||||
| 17 | DIV | Divide `Operand A` by `Operand B` and returns the result |
|
||||
| 18 | GVAR SET | Store value from `Operand B` into the Global Variable addressed by `Operand B`. Bear in mind, that operand `Global Variable` means: Value stored in Global Variable of an index! To store in GVAR 1 use `Value 1` not `Global Variable 1` |
|
||||
| 19 | GVAR INC | Increase the GVAR indexed by `Operand A` with value from `Operand B` |
|
||||
| 20 | GVAR DEC | Decrease the GVAR indexed by `Operand A` with value from `Operand B` |
|
||||
| 128 | IO PORT SET | Set I2C IO Expander pin `Operand A` to value of `Operand B`. `Operand A` accepts values `0-7` and `Operand B` accepts `0` and `1` |
|
||||
|
||||
### Operands
|
||||
|
||||
|
@ -49,6 +57,7 @@ Logic conditions can be edited using INAV Configurator user interface, of via CL
|
|||
| 2 | FLIGHT | `value` points to flight parameter table |
|
||||
| 3 | FLIGHT_MODE | `value` points to flight modes table |
|
||||
| 4 | LC | `value` points to other logic condition ID |
|
||||
| 5 | GVAR | Value stored in Global Variable indexed by `value`. `GVAR 1` means: value in GVAR 1 |
|
||||
|
||||
#### FLIGHT
|
||||
|
||||
|
|
|
@ -34,4 +34,4 @@ RELEASE_TARGETS += IFLIGHTF7_TWING IFLIGHTF4_TWING IFLIGHTF4_SUCCEXD
|
|||
|
||||
RELEASE_TARGETS += AIKONF4
|
||||
|
||||
RELEASE_TARGETS += ZEEZF7
|
||||
RELEASE_TARGETS += ZEEZF7 HGLRCF722
|
||||
|
|
|
@ -53,6 +53,8 @@ MAIN_SRC = \
|
|||
drivers/display_font_metadata.c \
|
||||
drivers/exti.c \
|
||||
drivers/io_pca9685.c \
|
||||
drivers/io_pcf8574.c \
|
||||
drivers/io_port_expander.c \
|
||||
drivers/osd.c \
|
||||
drivers/resource.c \
|
||||
drivers/rx_nrf24l01.c \
|
||||
|
|
|
@ -76,5 +76,6 @@ typedef enum {
|
|||
DEBUG_SPM_CELLS, // Smartport master FLVSS
|
||||
DEBUG_SPM_VS600, // Smartport master VS600 VTX
|
||||
DEBUG_SPM_VARIO, // Smartport master variometer
|
||||
DEBUG_PCF8574,
|
||||
DEBUG_COUNT
|
||||
} debugType_e;
|
||||
|
|
|
@ -145,6 +145,7 @@ typedef enum {
|
|||
DEVHW_UG2864, // I2C OLED display
|
||||
DEVHW_SDCARD, // Generic SD-Card
|
||||
DEVHW_IRLOCK, // IR-Lock visual positioning hardware
|
||||
DEVHW_PCF8574, // 8-bit I/O expander
|
||||
} devHardwareType_e;
|
||||
|
||||
typedef enum {
|
||||
|
|
84
src/main/drivers/io_pcf8574.c
Normal file
84
src/main/drivers/io_pcf8574.c
Normal file
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* This file is part of INAV.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms
|
||||
* of the GNU General Public License Version 3, as described below:
|
||||
*
|
||||
* This file is free software: you may copy, redistribute and/or modify
|
||||
* it under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This file 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 this program. If not, see http://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "drivers/bus.h"
|
||||
#include "drivers/io_pcf8574.h"
|
||||
#include "drivers/time.h"
|
||||
#include "build/debug.h"
|
||||
|
||||
#define PCF8574_WRITE_ADDRESS 0x40
|
||||
#define PCF8574_READ_ADDRESS 0x41
|
||||
|
||||
static busDevice_t *busDev;
|
||||
|
||||
static bool deviceDetect(busDevice_t *busDev)
|
||||
{
|
||||
for (int retry = 0; retry < 5; retry++)
|
||||
{
|
||||
uint8_t sig;
|
||||
|
||||
delay(150);
|
||||
|
||||
bool ack = busRead(busDev, 0x00, &sig);
|
||||
if (ack)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool pcf8574Init(void)
|
||||
{
|
||||
busDev = busDeviceInit(BUSTYPE_I2C, DEVHW_PCF8574, 0, 0);
|
||||
if (busDev == NULL)
|
||||
{
|
||||
DEBUG_SET(DEBUG_PCF8574, 0, 1);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!deviceDetect(busDev))
|
||||
{
|
||||
DEBUG_SET(DEBUG_PCF8574, 0, 2);
|
||||
busDeviceDeInit(busDev);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void pcf8574Write(uint8_t data)
|
||||
{
|
||||
busWrite(busDev, PCF8574_WRITE_ADDRESS, data);
|
||||
}
|
||||
|
||||
uint8_t pcf8574Read(void)
|
||||
{
|
||||
uint8_t data;
|
||||
busRead(busDev, PCF8574_READ_ADDRESS, &data);
|
||||
return data;
|
||||
}
|
29
src/main/drivers/io_pcf8574.h
Normal file
29
src/main/drivers/io_pcf8574.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* This file is part of INAV.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms
|
||||
* of the GNU General Public License Version 3, as described below:
|
||||
*
|
||||
* This file is free software: you may copy, redistribute and/or modify
|
||||
* it under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This file 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 this program. If not, see http://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
bool pcf8574Init(void);
|
||||
void pcf8574Write(uint8_t data);
|
||||
uint8_t pcf8574Read(void);
|
67
src/main/drivers/io_port_expander.c
Normal file
67
src/main/drivers/io_port_expander.c
Normal file
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* This file is part of INAV.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms
|
||||
* of the GNU General Public License Version 3, as described below:
|
||||
*
|
||||
* This file is free software: you may copy, redistribute and/or modify
|
||||
* it under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This file 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 this program. If not, see http://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "platform.h"
|
||||
#include "drivers/io_port_expander.h"
|
||||
#include "drivers/io_pcf8574.h"
|
||||
|
||||
#ifdef USE_I2C_IO_EXPANDER
|
||||
|
||||
static ioPortExpanderState_t ioPortExpanderState;
|
||||
|
||||
void ioPortExpanderInit(void)
|
||||
{
|
||||
|
||||
ioPortExpanderState.active = pcf8574Init();
|
||||
|
||||
if (ioPortExpanderState.active) {
|
||||
ioPortExpanderState.state = 0x00;
|
||||
pcf8574Write(ioPortExpanderState.state); //Set all ports to OFF
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ioPortExpanderSet(uint8_t pin, uint8_t value)
|
||||
{
|
||||
if (pin > 7) {
|
||||
return;
|
||||
}
|
||||
|
||||
//Cast to 0/1
|
||||
value = (bool) value;
|
||||
|
||||
ioPortExpanderState.state ^= (-value ^ ioPortExpanderState.state) & (1UL << pin);
|
||||
ioPortExpanderState.shouldSync = true;
|
||||
}
|
||||
|
||||
void ioPortExpanderSync(void)
|
||||
{
|
||||
if (ioPortExpanderState.active && ioPortExpanderState.shouldSync) {
|
||||
pcf8574Write(ioPortExpanderState.state);
|
||||
ioPortExpanderState.shouldSync = false;;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
37
src/main/drivers/io_port_expander.h
Normal file
37
src/main/drivers/io_port_expander.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* This file is part of INAV.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms
|
||||
* of the GNU General Public License Version 3, as described below:
|
||||
*
|
||||
* This file is free software: you may copy, redistribute and/or modify
|
||||
* it under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This file 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 this program. If not, see http://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
typedef struct ioPortExpanderState_s {
|
||||
uint8_t active;
|
||||
uint8_t state;
|
||||
uint8_t shouldSync;
|
||||
} ioPortExpanderState_t;
|
||||
|
||||
void ioPortExpanderInit(void);
|
||||
void ioPortExpanderSync(void);
|
||||
void ioPortExpanderSet(uint8_t pin, uint8_t value);
|
|
@ -83,6 +83,7 @@
|
|||
#include "msc/emfat_file.h"
|
||||
#endif
|
||||
#include "drivers/sdcard/sdcard.h"
|
||||
#include "drivers/io_port_expander.h"
|
||||
|
||||
#include "fc/cli.h"
|
||||
#include "fc/config.h"
|
||||
|
@ -682,6 +683,10 @@ void init(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_I2C_IO_EXPANDER
|
||||
ioPortExpanderInit();
|
||||
#endif
|
||||
|
||||
// Considering that the persistent reset reason is only used during init
|
||||
persistentObjectWrite(PERSISTENT_OBJECT_RESET_REASON, RESET_NONE);
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ tables:
|
|||
"FLOW", "SBUS", "FPORT", "ALWAYS", "SAG_COMP_VOLTAGE",
|
||||
"VIBE", "CRUISE", "REM_FLIGHT_TIME", "SMARTAUDIO", "ACC", "ITERM_RELAX",
|
||||
"ERPM", "RPM_FILTER", "RPM_FREQ", "NAV_YAW", "DYNAMIC_FILTER", "DYNAMIC_FILTER_FREQUENCY",
|
||||
"IRLOCK", "CD", "KALMAN", "SPM_CELLS", "SPM_VS600", "SPM_VARIO"]
|
||||
"IRLOCK", "CD", "KALMAN", "SPM_CELLS", "SPM_VS600", "SPM_VARIO", "PCF8574"]
|
||||
- name: async_mode
|
||||
values: ["NONE", "GYRO", "ALL"]
|
||||
- name: aux_operator
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "sensors/pitotmeter.h"
|
||||
#include "flight/imu.h"
|
||||
#include "flight/pid.h"
|
||||
#include "drivers/io_port_expander.h"
|
||||
|
||||
#include "navigation/navigation.h"
|
||||
#include "navigation/navigation_private.h"
|
||||
|
@ -270,6 +271,12 @@ static int logicConditionCompute(
|
|||
return operandA;
|
||||
break;
|
||||
|
||||
#ifdef USE_I2C_IO_EXPANDER
|
||||
case LOGIC_CONDITION_PORT_SET:
|
||||
ioPortExpanderSet((uint8_t)operandA, (uint8_t)operandB);
|
||||
return operandB;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
return false;
|
||||
break;
|
||||
|
@ -549,6 +556,9 @@ void logicConditionUpdateTask(timeUs_t currentTimeUs) {
|
|||
for (uint8_t i = 0; i < MAX_LOGIC_CONDITIONS; i++) {
|
||||
logicConditionProcess(i);
|
||||
}
|
||||
#ifdef USE_I2C_IO_EXPANDER
|
||||
ioPortExpanderSync();
|
||||
#endif
|
||||
}
|
||||
|
||||
void logicConditionReset(void) {
|
||||
|
|
|
@ -29,39 +29,40 @@
|
|||
#define MAX_LOGIC_CONDITIONS 16
|
||||
|
||||
typedef enum {
|
||||
LOGIC_CONDITION_TRUE = 0, // 0
|
||||
LOGIC_CONDITION_EQUAL, // 1
|
||||
LOGIC_CONDITION_GREATER_THAN, // 2
|
||||
LOGIC_CONDITION_LOWER_THAN, // 3
|
||||
LOGIC_CONDITION_LOW, // 4
|
||||
LOGIC_CONDITION_MID, // 5
|
||||
LOGIC_CONDITION_HIGH, // 6
|
||||
LOGIC_CONDITION_AND, // 7
|
||||
LOGIC_CONDITION_OR, // 8
|
||||
LOGIC_CONDITION_XOR, // 9
|
||||
LOGIC_CONDITION_NAND, // 10
|
||||
LOGIC_CONDITION_NOR, // 11
|
||||
LOGIC_CONDITION_NOT, // 12
|
||||
LOGIC_CONDITION_STICKY, // 13
|
||||
LOGIC_CONDITION_ADD, // 14
|
||||
LOGIC_CONDITION_SUB, // 15
|
||||
LOGIC_CONDITION_MUL, // 16
|
||||
LOGIC_CONDITION_DIV, // 17
|
||||
LOGIC_CONDITION_GVAR_SET, // 18
|
||||
LOGIC_CONDITION_GVAR_INC, // 19
|
||||
LOGIC_CONDITION_GVAR_DEC, // 20
|
||||
LOGIC_CONDITION_OVERRIDE_ARMING_SAFETY = 129,
|
||||
LOGIC_CONDITION_OVERRIDE_THROTTLE_SCALE = 130,
|
||||
LOGIC_CONDITION_SWAP_ROLL_YAW = 131,
|
||||
LOGIC_CONDITION_SET_VTX_POWER_LEVEL = 132,
|
||||
LOGIC_CONDITION_INVERT_ROLL = 133,
|
||||
LOGIC_CONDITION_INVERT_PITCH = 134,
|
||||
LOGIC_CONDITION_INVERT_YAW = 135,
|
||||
LOGIC_CONDITION_OVERRIDE_THROTTLE = 136,
|
||||
LOGIC_CONDITION_SET_VTX_BAND = 137,
|
||||
LOGIC_CONDITION_SET_VTX_CHANNEL = 138,
|
||||
LOGIC_CONDITION_SET_OSD_LAYOUT = 139,
|
||||
LOGIC_CONDITION_LAST
|
||||
LOGIC_CONDITION_TRUE = 0,
|
||||
LOGIC_CONDITION_EQUAL = 1,
|
||||
LOGIC_CONDITION_GREATER_THAN = 2,
|
||||
LOGIC_CONDITION_LOWER_THAN = 3,
|
||||
LOGIC_CONDITION_LOW = 4,
|
||||
LOGIC_CONDITION_MID = 5,
|
||||
LOGIC_CONDITION_HIGH = 6,
|
||||
LOGIC_CONDITION_AND = 7,
|
||||
LOGIC_CONDITION_OR = 8,
|
||||
LOGIC_CONDITION_XOR = 9,
|
||||
LOGIC_CONDITION_NAND = 10,
|
||||
LOGIC_CONDITION_NOR = 11,
|
||||
LOGIC_CONDITION_NOT = 12,
|
||||
LOGIC_CONDITION_STICKY = 13,
|
||||
LOGIC_CONDITION_ADD = 14,
|
||||
LOGIC_CONDITION_SUB = 15,
|
||||
LOGIC_CONDITION_MUL = 16,
|
||||
LOGIC_CONDITION_DIV = 17,
|
||||
LOGIC_CONDITION_GVAR_SET = 18,
|
||||
LOGIC_CONDITION_GVAR_INC = 19,
|
||||
LOGIC_CONDITION_GVAR_DEC = 20,
|
||||
LOGIC_CONDITION_PORT_SET = 21,
|
||||
LOGIC_CONDITION_OVERRIDE_ARMING_SAFETY = 22,
|
||||
LOGIC_CONDITION_OVERRIDE_THROTTLE_SCALE = 23,
|
||||
LOGIC_CONDITION_SWAP_ROLL_YAW = 24,
|
||||
LOGIC_CONDITION_SET_VTX_POWER_LEVEL = 25,
|
||||
LOGIC_CONDITION_INVERT_ROLL = 26,
|
||||
LOGIC_CONDITION_INVERT_PITCH = 27,
|
||||
LOGIC_CONDITION_INVERT_YAW = 28,
|
||||
LOGIC_CONDITION_OVERRIDE_THROTTLE = 29,
|
||||
LOGIC_CONDITION_SET_VTX_BAND = 30,
|
||||
LOGIC_CONDITION_SET_VTX_CHANNEL = 31,
|
||||
LOGIC_CONDITION_SET_OSD_LAYOUT = 32,
|
||||
LOGIC_CONDITION_LAST = 33,
|
||||
} logicOperation_e;
|
||||
|
||||
typedef enum logicOperandType_s {
|
||||
|
|
33
src/main/target/HGLRCF722/config.c
Normal file
33
src/main/target/HGLRCF722/config.c
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* This file is part of INAV Project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms
|
||||
* of the GNU General Public License Version 3, as described below:
|
||||
*
|
||||
* This file is free software: you may copy, redistribute and/or modify
|
||||
* it under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This file 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 this program. If not, see http://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "io/piniobox.h"
|
||||
|
||||
void targetConfiguration(void)
|
||||
{
|
||||
pinioBoxConfigMutable()->permanentId[0] = 47;
|
||||
pinioBoxConfigMutable()->permanentId[1] = 48;
|
||||
}
|
53
src/main/target/HGLRCF722/target.c
Normal file
53
src/main/target/HGLRCF722/target.c
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* This file is part of INAV Project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms
|
||||
* of the GNU General Public License Version 3, as described below:
|
||||
*
|
||||
* This file is free software: you may copy, redistribute and/or modify
|
||||
* it under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This file 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 this program. If not, see http://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
#include "drivers/bus.h"
|
||||
#include "drivers/io.h"
|
||||
#include "drivers/pwm_mapping.h"
|
||||
#include "drivers/timer.h"
|
||||
#include "drivers/pinio.h"
|
||||
#include "drivers/sensor.h"
|
||||
|
||||
BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, MPU6000_SPI_BUS, MPU6000_CS_PIN, MPU6000_EXTI_PIN, 0, DEVFLAGS_NONE, IMU_MPU6000_ALIGN);
|
||||
|
||||
const timerHardware_t timerHardware[] = {
|
||||
DEF_TIM(TIM3, CH1, PB4, TIM_USE_MC_MOTOR | TIM_USE_FW_SERVO, 0, 0), // S1 UP1-2 D(1, 4, 5)
|
||||
DEF_TIM(TIM3, CH2, PB5, TIM_USE_MC_MOTOR | TIM_USE_FW_SERVO, 0, 0), // S2 UP1-2 D(1, 5, 5)
|
||||
DEF_TIM(TIM3, CH3, PB0, TIM_USE_MC_MOTOR | TIM_USE_FW_SERVO, 0, 0), // S3 UP1-2 D(1, 7, 5)
|
||||
DEF_TIM(TIM3, CH4, PB1, TIM_USE_MC_MOTOR | TIM_USE_FW_SERVO, 0, 0), // S4 UP1-2 D(1, 2, 5)
|
||||
DEF_TIM(TIM2, CH1, PA15, TIM_USE_MC_MOTOR | TIM_USE_FW_SERVO, 0, 0), // S5 UP1-7 D(1, 5, 3) - clash with S2
|
||||
DEF_TIM(TIM2, CH2, PB3, TIM_USE_MC_MOTOR | TIM_USE_FW_SERVO, 0, 0), // S6 UP1-7 D(1, 6, 3)
|
||||
DEF_TIM(TIM4, CH1, PB6, TIM_USE_MC_SERVO | TIM_USE_FW_MOTOR, 0, 0), // S7 UP1-6 D(1, 0, 2)
|
||||
DEF_TIM(TIM4, CH2, PB7, TIM_USE_MC_SERVO | TIM_USE_FW_MOTOR, 0, 0), // S8 UP1-6 D(1, 3, 2)
|
||||
|
||||
DEF_TIM(TIM1, CH1, PA8, TIM_USE_LED, 0, 2), // LED D(2, 6, 0)
|
||||
DEF_TIM(TIM9, CH2, PA3, TIM_USE_PPM, 0, 0), // PPM, RX2
|
||||
DEF_TIM(TIM5, CH3, PA2, TIM_USE_PWM, 0, 0), // TX2 & softserial1
|
||||
};
|
||||
|
||||
const int timerHardwareCount = sizeof(timerHardware) / sizeof(timerHardware[0]);
|
180
src/main/target/HGLRCF722/target.h
Normal file
180
src/main/target/HGLRCF722/target.h
Normal file
|
@ -0,0 +1,180 @@
|
|||
/*
|
||||
* This file is part of INAV Project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms
|
||||
* of the GNU General Public License Version 3, as described below:
|
||||
*
|
||||
* This file is free software: you may copy, redistribute and/or modify
|
||||
* it under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This file 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 this program. If not, see http://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#define TARGET_BOARD_IDENTIFIER "HGF7"
|
||||
#define USBD_PRODUCT_STRING "HGLRCF722"
|
||||
|
||||
#define LED0 PA14
|
||||
#define LED1 PA13
|
||||
|
||||
#define BEEPER PC13
|
||||
#define BEEPER_INVERTED
|
||||
|
||||
// *************** SPI1 Gyro & ACC *******************
|
||||
#define USE_TARGET_IMU_HARDWARE_DESCRIPTORS
|
||||
|
||||
#define USE_SPI
|
||||
#define USE_SPI_DEVICE_1
|
||||
#define SPI1_SCK_PIN PA5
|
||||
#define SPI1_MISO_PIN PA6
|
||||
#define SPI1_MOSI_PIN PA7
|
||||
|
||||
#define USE_DUAL_GYRO
|
||||
|
||||
#define USE_IMU_MPU6000
|
||||
#define IMU_MPU6000_ALIGN CW180_DEG_FLIP
|
||||
#define MPU6000_CS_PIN PB2
|
||||
#define MPU6000_SPI_BUS BUS_SPI1
|
||||
#define MPU6000_EXTI_PIN PC4
|
||||
|
||||
#define USE_EXTI
|
||||
#define USE_MPU_DATA_READY_SIGNAL
|
||||
|
||||
// *************** I2C /Baro/Mag *********************
|
||||
#define USE_I2C
|
||||
#define USE_I2C_DEVICE_1
|
||||
#define I2C1_SCL PB8
|
||||
#define I2C1_SDA PB9
|
||||
|
||||
#define USE_BARO
|
||||
#define USE_BARO_BMP280
|
||||
#define USE_BARO_SPI_BMP280
|
||||
#define BMP280_SPI_BUS BUS_SPI1
|
||||
#define BMP280_CS_PIN PA4
|
||||
#define BARO_I2C_BUS BUS_I2C1
|
||||
#define USE_BARO_MS5611
|
||||
#define USE_BARO_DPS310
|
||||
|
||||
#define USE_MAG
|
||||
#define MAG_I2C_BUS BUS_I2C1
|
||||
#define USE_MAG_AK8975
|
||||
#define USE_MAG_HMC5883
|
||||
#define USE_MAG_QMC5883
|
||||
#define USE_MAG_IST8310
|
||||
#define USE_MAG_IST8308
|
||||
#define USE_MAG_MAG3110
|
||||
#define USE_MAG_LIS3MDL
|
||||
|
||||
#define TEMPERATURE_I2C_BUS BUS_I2C1
|
||||
|
||||
#define PITOT_I2C_BUS BUS_I2C1
|
||||
|
||||
#define USE_RANGEFINDER
|
||||
#define RANGEFINDER_I2C_BUS BUS_I2C1
|
||||
|
||||
// *************** SPI2 OSD ***********************
|
||||
#define USE_SPI_DEVICE_2
|
||||
#define SPI2_SCK_PIN PB13
|
||||
#define SPI2_MISO_PIN PB14
|
||||
#define SPI2_MOSI_PIN PB15
|
||||
|
||||
#define USE_OSD
|
||||
#define USE_MAX7456
|
||||
#define MAX7456_SPI_BUS BUS_SPI2
|
||||
#define MAX7456_CS_PIN PB12
|
||||
|
||||
// *************** SPI3 SD BLACKBOX*******************
|
||||
#define USE_SPI_DEVICE_3
|
||||
#define SPI3_SCK_PIN PC10
|
||||
#define SPI3_MISO_PIN PC11
|
||||
#define SPI3_MOSI_PIN PC12
|
||||
|
||||
#define USE_FLASHFS
|
||||
#define USE_FLASH_M25P16
|
||||
#define M25P16_SPI_BUS BUS_SPI3
|
||||
#define M25P16_CS_PIN PD2
|
||||
#define ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT
|
||||
|
||||
|
||||
// *************** UART *****************************
|
||||
#define USE_VCP
|
||||
#define USB_DETECT_PIN PC14
|
||||
#define USE_USB_DETECT
|
||||
|
||||
#define USE_UART1
|
||||
#define UART1_TX_PIN PA9
|
||||
#define UART1_RX_PIN PA10
|
||||
|
||||
#define USE_UART2
|
||||
#define UART2_TX_PIN PA2
|
||||
#define UART2_RX_PIN PA3
|
||||
|
||||
#define USE_UART3
|
||||
#define UART3_TX_PIN PB10
|
||||
#define UART3_RX_PIN PB11
|
||||
|
||||
#define USE_UART4
|
||||
#define UART4_TX_PIN PA0
|
||||
#define UART4_RX_PIN PA1
|
||||
|
||||
#define USE_UART6
|
||||
#define UART6_TX_PIN PC6
|
||||
#define UART6_RX_PIN PC7
|
||||
|
||||
#define SERIAL_PORT_COUNT 6
|
||||
|
||||
#define DEFAULT_RX_TYPE RX_TYPE_SERIAL
|
||||
#define SERIALRX_PROVIDER SERIALRX_SBUS
|
||||
#define SERIALRX_UART SERIAL_PORT_USART1
|
||||
|
||||
// *************** ADC *****************************
|
||||
#define USE_ADC
|
||||
#define ADC_INSTANCE ADC1
|
||||
#define ADC1_DMA_STREAM DMA2_Stream0
|
||||
|
||||
#define ADC_CHANNEL_1_PIN PC2
|
||||
#define ADC_CHANNEL_2_PIN PC1
|
||||
#define ADC_CHANNEL_3_PIN PC0
|
||||
|
||||
#define VBAT_ADC_CHANNEL ADC_CHN_1
|
||||
#define CURRENT_METER_ADC_CHANNEL ADC_CHN_2
|
||||
#define RSSI_ADC_CHANNEL ADC_CHN_3
|
||||
|
||||
// *************** PINIO ***************************
|
||||
#define USE_PINIO
|
||||
#define USE_PINIOBOX
|
||||
#define PINIO1_PIN PC8 // VTX power switcher
|
||||
#define PINIO2_PIN PC9 // 2xCamera switcher
|
||||
|
||||
// *************** LEDSTRIP ************************
|
||||
#define USE_LED_STRIP
|
||||
#define WS2811_PIN PA8
|
||||
|
||||
#define DEFAULT_FEATURES (FEATURE_OSD | FEATURE_TELEMETRY | FEATURE_CURRENT_METER | FEATURE_VBAT | FEATURE_TX_PROF_SEL | FEATURE_BLACKBOX)
|
||||
#define CURRENT_METER_SCALE 179
|
||||
|
||||
#define USE_SERIAL_4WAY_BLHELI_INTERFACE
|
||||
|
||||
#define TARGET_IO_PORTA 0xffff
|
||||
#define TARGET_IO_PORTB 0xffff
|
||||
#define TARGET_IO_PORTC 0xffff
|
||||
#define TARGET_IO_PORTD 0xffff
|
||||
|
||||
#define MAX_PWM_OUTPUT_PORTS 8
|
||||
#define USE_DSHOT
|
||||
#define USE_SERIALSHOT
|
||||
#define USE_ESC_SENSOR
|
19
src/main/target/HGLRCF722/target.mk
Normal file
19
src/main/target/HGLRCF722/target.mk
Normal file
|
@ -0,0 +1,19 @@
|
|||
F7X2RE_TARGETS += $(TARGET)
|
||||
FEATURES += VCP ONBOARDFLASH MSC
|
||||
|
||||
TARGET_SRC = \
|
||||
drivers/accgyro/accgyro_mpu6000.c \
|
||||
drivers/barometer/barometer_bmp085.c \
|
||||
drivers/barometer/barometer_bmp280.c \
|
||||
drivers/barometer/barometer_ms56xx.c \
|
||||
drivers/barometer/barometer_dps310.c \
|
||||
drivers/compass/compass_ak8975.c \
|
||||
drivers/compass/compass_hmc5883l.c \
|
||||
drivers/compass/compass_qmc5883l.c \
|
||||
drivers/compass/compass_ist8310.c \
|
||||
drivers/compass/compass_ist8308.c \
|
||||
drivers/compass/compass_mag3110.c \
|
||||
drivers/compass/compass_lis3mdl.c \
|
||||
drivers/light_ws2811strip.c \
|
||||
drivers/max7456.c \
|
||||
drivers/pitotmeter_adc.c \
|
|
@ -121,6 +121,8 @@
|
|||
#define USE_D_BOOST
|
||||
#define USE_ANTIGRAVITY
|
||||
|
||||
#define USE_I2C_IO_EXPANDER
|
||||
|
||||
#else // FLASH_SIZE < 256
|
||||
#define LOG_LEVEL_MAXIMUM LOG_LEVEL_ERROR
|
||||
#endif
|
||||
|
|
|
@ -353,4 +353,21 @@
|
|||
BUSDEV_REGISTER_I2C(busdev_irlock, DEVHW_IRLOCK, IRLOCK_I2C_BUS, 0x54, NONE, DEVFLAGS_USE_RAW_REGISTERS);
|
||||
#endif
|
||||
|
||||
#if defined(USE_I2C) && defined(USE_I2C_IO_EXPANDER)
|
||||
|
||||
#if !defined(PCF8574_I2C_BUS) && defined(EXTERNAL_I2C_BUS)
|
||||
#define PCF8574_I2C_BUS EXTERNAL_I2C_BUS
|
||||
#endif
|
||||
|
||||
#if !defined(PCF8574_I2C_BUS) && defined(DEFAULT_I2C_BUS)
|
||||
#define PCF8574_I2C_BUS DEFAULT_I2C_BUS
|
||||
#endif
|
||||
|
||||
#if !defined(PCF8574_I2C_BUS)
|
||||
#define PCF8574_I2C_BUS BUS_I2C1
|
||||
#endif
|
||||
|
||||
BUSDEV_REGISTER_I2C(busdev_pcf8574, DEVHW_PCF8574, PCF8574_I2C_BUS, 0x20, NONE, DEVFLAGS_NONE, 0);
|
||||
#endif
|
||||
|
||||
#endif // USE_TARGET_HARDWARE_DESCRIPTORS
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue