mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 08:15:30 +03:00
add pull_up to names, change pg config to array of elements, use correct DEFs
This commit is contained in:
parent
cc9687a2bf
commit
6a713a0340
8 changed files with 54 additions and 65 deletions
|
@ -31,7 +31,7 @@ COMMON_SRC = \
|
|||
drivers/mco.c \
|
||||
drivers/motor.c \
|
||||
drivers/pinio.c \
|
||||
drivers/pin_up_down.c \
|
||||
drivers/pin_pull_up_down.c \
|
||||
drivers/resource.c \
|
||||
drivers/rcc.c \
|
||||
drivers/serial.c \
|
||||
|
|
|
@ -137,6 +137,7 @@ bool cliMode = false;
|
|||
#include "pg/mco.h"
|
||||
#include "pg/motor.h"
|
||||
#include "pg/pinio.h"
|
||||
#include "pg/pin_pull_up_down.h"
|
||||
#include "pg/pg.h"
|
||||
#include "pg/pg_ids.h"
|
||||
#include "pg/rx.h"
|
||||
|
@ -149,7 +150,6 @@ bool cliMode = false;
|
|||
#include "pg/timerup.h"
|
||||
#include "pg/usb.h"
|
||||
#include "pg/vtx_table.h"
|
||||
#include "pg/pin_up_down.h"
|
||||
|
||||
#include "rx/rx.h"
|
||||
#include "rx/spektrum.h"
|
||||
|
@ -4914,9 +4914,9 @@ const cliResourceValue_t resourceTable[] = {
|
|||
DEFS( OWNER_VTX_DATA, PG_VTX_IO_CONFIG, vtxIOConfig_t, dataTag ),
|
||||
DEFS( OWNER_VTX_CLK, PG_VTX_IO_CONFIG, vtxIOConfig_t, clockTag ),
|
||||
#endif
|
||||
#ifdef USE_PIN_UP_DOWN
|
||||
DEFA( OWNER_PULLUP, PG_PULLUP_CONFIG, pinUpDownConfig_t, ioTag, PIN_UP_DOWN_COUNT ),
|
||||
DEFA( OWNER_PULLDOWN, PG_PULLDOWN_CONFIG, pinUpDownConfig_t, ioTag, PIN_UP_DOWN_COUNT ),
|
||||
#ifdef USE_PIN_PULL_UP_DOWN
|
||||
DEFA( OWNER_PULLUP, PG_PULLUP_CONFIG, pinPullUpDownConfig_t, ioTag, PIN_PULL_UP_DOWN_COUNT ),
|
||||
DEFA( OWNER_PULLDOWN, PG_PULLDOWN_CONFIG, pinPullUpDownConfig_t, ioTag, PIN_PULL_UP_DOWN_COUNT ),
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -22,24 +22,22 @@
|
|||
|
||||
#include "platform.h"
|
||||
|
||||
#ifdef USE_PIN_UP_DOWN
|
||||
#ifdef USE_PIN_PULL_UP_DOWN
|
||||
|
||||
#include "build/debug.h"
|
||||
|
||||
#include "pg/pin_up_down.h"
|
||||
|
||||
#include "drivers/io.h"
|
||||
#include "pg/pin_pull_up_down.h"
|
||||
#include "pin_pull_up_down.h"
|
||||
|
||||
static void initPins(const pinUpDownConfig_t * config, resourceOwner_e owner)
|
||||
|
||||
static void initPin(const pinPullUpDownConfig_t* config, resourceOwner_e owner, uint8_t index)
|
||||
{
|
||||
for (int i = 0; i < PIN_UP_DOWN_COUNT; i++) {
|
||||
IO_t io = IOGetByTag(config->ioTag[i]);
|
||||
|
||||
IO_t io = IOGetByTag(config->ioTag);
|
||||
if (!io) {
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
|
||||
IOInit(io, OWNER_PINIO, RESOURCE_INDEX(i));
|
||||
IOInit(io, owner, RESOURCE_INDEX(index));
|
||||
|
||||
if (owner == OWNER_PULLUP) {
|
||||
IOConfigGPIO(io, IOCFG_IPU);
|
||||
|
@ -47,16 +45,13 @@ static void initPins(const pinUpDownConfig_t * config, resourceOwner_e owner)
|
|||
IOConfigGPIO(io, IOCFG_IPD);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void pinPullupInit(const pinUpDownConfig_t * pullupConfig)
|
||||
void pinPullupPulldownInit()
|
||||
{
|
||||
initPins(pullupConfig, OWNER_PULLUP);
|
||||
for (uint8_t i = 0; i < PIN_PULL_UP_DOWN_COUNT; i++) {
|
||||
initPin(pinPullupConfig(i), OWNER_PULLUP, i);
|
||||
initPin(pinPulldownConfig(i), OWNER_PULLDOWN, i);
|
||||
}
|
||||
|
||||
void pinPulldownInit(const pinUpDownConfig_t * pulldownConfig)
|
||||
{
|
||||
initPins(pulldownConfig, OWNER_PULLDOWN);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -22,11 +22,10 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifndef PIN_UP_DOWN_COUNT
|
||||
#define PIN_UP_DOWN_COUNT 2
|
||||
#ifndef PIN_PULL_UP_DOWN_COUNT
|
||||
#define PIN_PULL_UP_DOWN_COUNT 4
|
||||
#endif
|
||||
|
||||
struct pinUpDownConfig_s;
|
||||
struct pinPullUpDownConfig_s;
|
||||
|
||||
void pinPullupInit(const struct pinUpDownConfig_s *pinUpDownConfig);
|
||||
void pinPulldownInit(const struct pinUpDownConfig_s *pinUpDownConfig);
|
||||
void pinPullupPulldownInit();
|
|
@ -59,6 +59,7 @@
|
|||
#include "drivers/mco.h"
|
||||
#include "drivers/nvic.h"
|
||||
#include "drivers/persistent.h"
|
||||
#include "drivers/pin_pull_up_down.h"
|
||||
#include "drivers/pwm_esc_detect.h"
|
||||
#include "drivers/pwm_output.h"
|
||||
#include "drivers/rx/rx_pwm.h"
|
||||
|
@ -80,7 +81,6 @@
|
|||
#include "drivers/vtx_common.h"
|
||||
#include "drivers/vtx_rtc6705.h"
|
||||
#include "drivers/vtx_table.h"
|
||||
#include "drivers/pin_up_down.h"
|
||||
|
||||
#include "fc/board_info.h"
|
||||
#include "fc/config.h"
|
||||
|
@ -141,6 +141,7 @@
|
|||
#include "pg/motor.h"
|
||||
#include "pg/pinio.h"
|
||||
#include "pg/piniobox.h"
|
||||
#include "pg/pin_pull_up_down.h"
|
||||
#include "pg/pg.h"
|
||||
#include "pg/rx.h"
|
||||
#include "pg/rx_spi.h"
|
||||
|
@ -148,7 +149,6 @@
|
|||
#include "pg/sdcard.h"
|
||||
#include "pg/vcd.h"
|
||||
#include "pg/vtx_io.h"
|
||||
#include "pg/pin_up_down.h"
|
||||
|
||||
#include "rx/rx.h"
|
||||
#include "rx/rx_spi.h"
|
||||
|
@ -696,9 +696,8 @@ void init(void)
|
|||
pinioInit(pinioConfig());
|
||||
#endif
|
||||
|
||||
#ifdef USE_PIN_UP_DOWN
|
||||
pinPullupInit(pinPullupConfig());
|
||||
pinPulldownInit(pinPulldownConfig());
|
||||
#ifdef USE_PIN_PULL_UP_DOWN
|
||||
pinPullupPulldownInit();
|
||||
#endif
|
||||
|
||||
#ifdef USE_PINIOBOX
|
||||
|
|
|
@ -20,26 +20,23 @@
|
|||
|
||||
#include "platform.h"
|
||||
|
||||
#ifdef USE_PINIO
|
||||
#ifdef USE_PIN_PULL_UP_DOWN
|
||||
|
||||
#include "pg/pg_ids.h"
|
||||
#include "pin_up_down.h"
|
||||
#include "drivers/io.h"
|
||||
#include "pg/pg_ids.h"
|
||||
#include "pin_pull_up_down.h"
|
||||
|
||||
PG_REGISTER_WITH_RESET_TEMPLATE(pinUpDownConfig_t, pinPullupConfig, PG_PULLUP_CONFIG, 0);
|
||||
PG_REGISTER_WITH_RESET_TEMPLATE(pinUpDownConfig_t, pinPulldownConfig, PG_PULLDOWN_CONFIG, 0);
|
||||
PG_REGISTER_ARRAY_WITH_RESET_FN(pinPullUpDownConfig_t, PIN_PULL_UP_DOWN_COUNT, pinPullupConfig, PG_PULLUP_CONFIG, 0);
|
||||
|
||||
PG_RESET_TEMPLATE(pinUpDownConfig_t, pinPullupConfig,
|
||||
.ioTag = {
|
||||
IO_TAG(NONE),
|
||||
IO_TAG(NONE),
|
||||
void pgResetFn_pinPullupConfig(pinPullUpDownConfig_t *config)
|
||||
{
|
||||
config->ioTag = IO_TAG(NONE);
|
||||
}
|
||||
);
|
||||
|
||||
PG_RESET_TEMPLATE(pinUpDownConfig_t, pinPulldownConfig,
|
||||
.ioTag = {
|
||||
IO_TAG(NONE),
|
||||
IO_TAG(NONE),
|
||||
PG_REGISTER_ARRAY_WITH_RESET_FN(pinPullUpDownConfig_t, PIN_PULL_UP_DOWN_COUNT, pinPulldownConfig, PG_PULLDOWN_CONFIG, 0);
|
||||
|
||||
void pgResetFn_pinPulldownConfig(pinPullUpDownConfig_t *config)
|
||||
{
|
||||
config->ioTag = IO_TAG(NONE);
|
||||
}
|
||||
);
|
||||
#endif
|
|
@ -20,14 +20,13 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "../drivers/pin_up_down.h"
|
||||
|
||||
#include "pg/pg.h"
|
||||
#include "drivers/io_types.h"
|
||||
#include "drivers/pin_pull_up_down.h"
|
||||
#include "pg/pg.h"
|
||||
|
||||
typedef struct pinUpDownConfig_s {
|
||||
ioTag_t ioTag[PIN_UP_DOWN_COUNT];
|
||||
} pinUpDownConfig_t;
|
||||
typedef struct pinPullUpDownConfig_s {
|
||||
ioTag_t ioTag;
|
||||
} pinPullUpDownConfig_t;
|
||||
|
||||
PG_DECLARE(pinUpDownConfig_t, pinPullupConfig);
|
||||
PG_DECLARE(pinUpDownConfig_t, pinPulldownConfig);
|
||||
PG_DECLARE_ARRAY(pinPullUpDownConfig_t, PIN_PULL_UP_DOWN_COUNT, pinPullupConfig);
|
||||
PG_DECLARE_ARRAY(pinPullUpDownConfig_t, PIN_PULL_UP_DOWN_COUNT, pinPulldownConfig);
|
|
@ -264,7 +264,6 @@
|
|||
#define USE_HUFFMAN
|
||||
#define USE_PINIO
|
||||
#define USE_PINIOBOX
|
||||
#define USE_PIN_UP_DOWN
|
||||
#endif
|
||||
|
||||
#if ((FLASH_SIZE > 256) || (FEATURE_CUT_LEVEL < 3))
|
||||
|
@ -277,6 +276,7 @@
|
|||
#define USE_SPEKTRUM_VTX_CONTROL
|
||||
#define USE_SPEKTRUM_VTX_TELEMETRY
|
||||
#define USE_SPEKTRUM_CMS_TELEMETRY
|
||||
#define USE_PIN_PULL_UP_DOWN
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue