mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-18 13:55:18 +03:00
Moved max7456 parameter group into pg/
directory.
This commit is contained in:
parent
9dda8c4f18
commit
200167aaf7
7 changed files with 78 additions and 28 deletions
|
@ -63,6 +63,7 @@ COMMON_SRC = \
|
||||||
pg/adc.c \
|
pg/adc.c \
|
||||||
pg/bus_i2c.c \
|
pg/bus_i2c.c \
|
||||||
pg/flash.c \
|
pg/flash.c \
|
||||||
|
pg/max7456.c \
|
||||||
pg/pg.c \
|
pg/pg.c \
|
||||||
scheduler/scheduler.c \
|
scheduler/scheduler.c \
|
||||||
sensors/battery.c \
|
sensors/battery.c \
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
#include "build/debug.h"
|
#include "build/debug.h"
|
||||||
|
|
||||||
|
#include "pg/max7456.h"
|
||||||
#include "pg/pg.h"
|
#include "pg/pg.h"
|
||||||
#include "pg/pg_ids.h"
|
#include "pg/pg_ids.h"
|
||||||
|
|
||||||
|
@ -220,13 +221,6 @@ static IO_t max7456CsPin = IO_NONE;
|
||||||
static uint8_t max7456DeviceType;
|
static uint8_t max7456DeviceType;
|
||||||
|
|
||||||
|
|
||||||
PG_REGISTER_WITH_RESET_TEMPLATE(max7456Config_t, max7456Config, PG_MAX7456_CONFIG, 0);
|
|
||||||
|
|
||||||
PG_RESET_TEMPLATE(max7456Config_t, max7456Config,
|
|
||||||
.clockConfig = MAX7456_CLOCK_CONFIG_OC, // SPI clock based on device type and overclock state
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
static uint8_t max7456Send(uint8_t add, uint8_t data)
|
static uint8_t max7456Send(uint8_t add, uint8_t data)
|
||||||
{
|
{
|
||||||
spiTransferByte(MAX7456_SPI_INSTANCE, add);
|
spiTransferByte(MAX7456_SPI_INSTANCE, add);
|
||||||
|
@ -415,7 +409,7 @@ void max7456ReInit(void)
|
||||||
// Here we init only CS and try to init MAX for first time.
|
// Here we init only CS and try to init MAX for first time.
|
||||||
// Also detect device type (MAX v.s. AT)
|
// Also detect device type (MAX v.s. AT)
|
||||||
|
|
||||||
void max7456Init(const vcdProfile_t *pVcdProfile, bool cpuOverclock)
|
void max7456Init(const max7456Config_t *max7456Config, const vcdProfile_t *pVcdProfile, bool cpuOverclock)
|
||||||
{
|
{
|
||||||
max7456HardwareReset();
|
max7456HardwareReset();
|
||||||
|
|
||||||
|
@ -441,7 +435,7 @@ void max7456Init(const vcdProfile_t *pVcdProfile, bool cpuOverclock)
|
||||||
#if defined(STM32F4) && !defined(DISABLE_OVERCLOCK)
|
#if defined(STM32F4) && !defined(DISABLE_OVERCLOCK)
|
||||||
// Determine SPI clock divisor based on config and the device type.
|
// Determine SPI clock divisor based on config and the device type.
|
||||||
|
|
||||||
switch (max7456Config()->clockConfig) {
|
switch (max7456Config->clockConfig) {
|
||||||
case MAX7456_CLOCK_CONFIG_HALF:
|
case MAX7456_CLOCK_CONFIG_HALF:
|
||||||
max7456SpiClock = MAX7456_SPI_CLK * 2;
|
max7456SpiClock = MAX7456_SPI_CLK * 2;
|
||||||
break;
|
break;
|
||||||
|
@ -459,6 +453,7 @@ void max7456Init(const vcdProfile_t *pVcdProfile, bool cpuOverclock)
|
||||||
DEBUG_SET(DEBUG_MAX7456_SPICLOCK, DEBUG_MAX7456_SPICLOCK_DEVTYPE, max7456DeviceType);
|
DEBUG_SET(DEBUG_MAX7456_SPICLOCK, DEBUG_MAX7456_SPICLOCK_DEVTYPE, max7456DeviceType);
|
||||||
DEBUG_SET(DEBUG_MAX7456_SPICLOCK, DEBUG_MAX7456_SPICLOCK_DIVISOR, max7456SpiClock);
|
DEBUG_SET(DEBUG_MAX7456_SPICLOCK, DEBUG_MAX7456_SPICLOCK_DIVISOR, max7456SpiClock);
|
||||||
#else
|
#else
|
||||||
|
UNUSED(max7456Config);
|
||||||
UNUSED(cpuOverclock);
|
UNUSED(cpuOverclock);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,8 @@ extern uint16_t maxScreenSize;
|
||||||
|
|
||||||
struct vcdProfile_s;
|
struct vcdProfile_s;
|
||||||
void max7456HardwareReset(void);
|
void max7456HardwareReset(void);
|
||||||
void max7456Init(const struct vcdProfile_s *vcdProfile, bool cpuOverclock);
|
struct max7456Config_s;
|
||||||
|
void max7456Init(const struct max7456Config_s *max7456Config, const struct vcdProfile_s *vcdProfile, bool cpuOverclock);
|
||||||
void max7456Invert(bool invert);
|
void max7456Invert(bool invert);
|
||||||
void max7456Brightness(uint8_t black, uint8_t white);
|
void max7456Brightness(uint8_t black, uint8_t white);
|
||||||
void max7456DrawScreen(void);
|
void max7456DrawScreen(void);
|
||||||
|
@ -39,13 +40,3 @@ void max7456ClearScreen(void);
|
||||||
void max7456RefreshAll(void);
|
void max7456RefreshAll(void);
|
||||||
uint8_t* max7456GetScreenBuffer(void);
|
uint8_t* max7456GetScreenBuffer(void);
|
||||||
bool max7456DmaInProgress(void);
|
bool max7456DmaInProgress(void);
|
||||||
|
|
||||||
typedef struct max7456Config_s {
|
|
||||||
uint8_t clockConfig; // 0 = force half clock, 1 = half if OC, 2 = force full
|
|
||||||
} max7456Config_t;
|
|
||||||
|
|
||||||
#define MAX7456_CLOCK_CONFIG_HALF 0
|
|
||||||
#define MAX7456_CLOCK_CONFIG_OC 1
|
|
||||||
#define MAX7456_CLOCK_CONFIG_FULL 2
|
|
||||||
|
|
||||||
PG_DECLARE(max7456Config_t, max7456Config);
|
|
||||||
|
|
|
@ -28,15 +28,11 @@
|
||||||
|
|
||||||
#include "common/utils.h"
|
#include "common/utils.h"
|
||||||
|
|
||||||
#include "pg/pg.h"
|
|
||||||
#include "pg/pg_ids.h"
|
|
||||||
|
|
||||||
#include "drivers/adc.h"
|
#include "drivers/adc.h"
|
||||||
#include "drivers/bus_i2c.h"
|
#include "drivers/bus_i2c.h"
|
||||||
#include "drivers/bus_spi.h"
|
#include "drivers/bus_spi.h"
|
||||||
#include "drivers/light_led.h"
|
#include "drivers/light_led.h"
|
||||||
#include "drivers/camera_control.h"
|
#include "drivers/camera_control.h"
|
||||||
#include "drivers/max7456.h"
|
|
||||||
#include "drivers/vtx_common.h"
|
#include "drivers/vtx_common.h"
|
||||||
|
|
||||||
#include "fc/config.h"
|
#include "fc/config.h"
|
||||||
|
@ -66,6 +62,9 @@
|
||||||
#include "io/vtx_rtc6705.h"
|
#include "io/vtx_rtc6705.h"
|
||||||
|
|
||||||
#include "pg/adc.h"
|
#include "pg/adc.h"
|
||||||
|
#include "pg/max7456.h"
|
||||||
|
#include "pg/pg.h"
|
||||||
|
#include "pg/pg_ids.h"
|
||||||
|
|
||||||
#include "rx/rx.h"
|
#include "rx/rx.h"
|
||||||
#include "rx/cc2500_frsky_common.h"
|
#include "rx/cc2500_frsky_common.h"
|
||||||
|
|
|
@ -24,9 +24,6 @@
|
||||||
|
|
||||||
#include "common/utils.h"
|
#include "common/utils.h"
|
||||||
|
|
||||||
#include "pg/pg.h"
|
|
||||||
#include "pg/pg_ids.h"
|
|
||||||
|
|
||||||
#include "drivers/display.h"
|
#include "drivers/display.h"
|
||||||
#include "drivers/max7456.h"
|
#include "drivers/max7456.h"
|
||||||
#include "drivers/vcd.h"
|
#include "drivers/vcd.h"
|
||||||
|
@ -37,6 +34,10 @@
|
||||||
#include "io/osd.h"
|
#include "io/osd.h"
|
||||||
#include "io/osd_slave.h"
|
#include "io/osd_slave.h"
|
||||||
|
|
||||||
|
#include "pg/max7456.h"
|
||||||
|
#include "pg/pg.h"
|
||||||
|
#include "pg/pg_ids.h"
|
||||||
|
|
||||||
displayPort_t max7456DisplayPort;
|
displayPort_t max7456DisplayPort;
|
||||||
|
|
||||||
PG_REGISTER_WITH_RESET_FN(displayPortProfile_t, displayPortProfileMax7456, PG_DISPLAY_PORT_MAX7456_CONFIG, 0);
|
PG_REGISTER_WITH_RESET_FN(displayPortProfile_t, displayPortProfileMax7456, PG_DISPLAY_PORT_MAX7456_CONFIG, 0);
|
||||||
|
@ -159,7 +160,7 @@ displayPort_t *max7456DisplayPortInit(const vcdProfile_t *vcdProfile)
|
||||||
#ifdef USE_OSD_SLAVE
|
#ifdef USE_OSD_SLAVE
|
||||||
max7456Init(vcdProfile, false);
|
max7456Init(vcdProfile, false);
|
||||||
#else
|
#else
|
||||||
max7456Init(vcdProfile, systemConfig()->cpu_overclock);
|
max7456Init(max7456Config(), vcdProfile, systemConfig()->cpu_overclock);
|
||||||
#endif
|
#endif
|
||||||
resync(&max7456DisplayPort);
|
resync(&max7456DisplayPort);
|
||||||
return &max7456DisplayPort;
|
return &max7456DisplayPort;
|
||||||
|
|
33
src/main/pg/max7456.c
Normal file
33
src/main/pg/max7456.c
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* This file is part of Cleanflight.
|
||||||
|
*
|
||||||
|
* Cleanflight is free software: you can redistribute it 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.
|
||||||
|
*
|
||||||
|
* Cleanflight 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 Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "platform.h"
|
||||||
|
|
||||||
|
#ifdef USE_MAX7456
|
||||||
|
|
||||||
|
#include "pg/pg.h"
|
||||||
|
#include "pg/pg_ids.h"
|
||||||
|
|
||||||
|
#include "max7456.h"
|
||||||
|
|
||||||
|
PG_REGISTER_WITH_RESET_TEMPLATE(max7456Config_t, max7456Config, PG_MAX7456_CONFIG, 0);
|
||||||
|
|
||||||
|
PG_RESET_TEMPLATE(max7456Config_t, max7456Config,
|
||||||
|
.clockConfig = MAX7456_CLOCK_CONFIG_OC, // SPI clock based on device type and overclock state
|
||||||
|
);
|
||||||
|
|
||||||
|
#endif // USE_MAX7456
|
30
src/main/pg/max7456.h
Normal file
30
src/main/pg/max7456.h
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
* This file is part of Cleanflight.
|
||||||
|
*
|
||||||
|
* Cleanflight is free software: you can redistribute it 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.
|
||||||
|
*
|
||||||
|
* Cleanflight 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 Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "pg/pg.h"
|
||||||
|
|
||||||
|
#define MAX7456_CLOCK_CONFIG_HALF 0
|
||||||
|
#define MAX7456_CLOCK_CONFIG_OC 1
|
||||||
|
#define MAX7456_CLOCK_CONFIG_FULL 2
|
||||||
|
|
||||||
|
typedef struct max7456Config_s {
|
||||||
|
uint8_t clockConfig; // 0 = force half clock, 1 = half if OC, 2 = force full
|
||||||
|
} max7456Config_t;
|
||||||
|
|
||||||
|
PG_DECLARE(max7456Config_t, max7456Config);
|
Loading…
Add table
Add a link
Reference in a new issue