Merge pull request #4824 from mikeller/move_max7456_pg

Moved max7456 parameter group into `pg/` directory.
This commit is contained in:
Michael Keller 2017-12-24 09:40:13 +13:00 committed by GitHub
commit bf3dd1991d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 82 additions and 31 deletions

View File

@ -63,6 +63,7 @@ COMMON_SRC = \
pg/adc.c \
pg/bus_i2c.c \
pg/flash.c \
pg/max7456.c \
pg/pg.c \
scheduler/scheduler.c \
sensors/battery.c \

View File

@ -25,6 +25,7 @@
#include "build/debug.h"
#include "pg/max7456.h"
#include "pg/pg.h"
#include "pg/pg_ids.h"
@ -220,13 +221,6 @@ static IO_t max7456CsPin = IO_NONE;
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)
{
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.
// 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();
@ -441,7 +435,7 @@ void max7456Init(const vcdProfile_t *pVcdProfile, bool cpuOverclock)
#if defined(STM32F4) && !defined(DISABLE_OVERCLOCK)
// Determine SPI clock divisor based on config and the device type.
switch (max7456Config()->clockConfig) {
switch (max7456Config->clockConfig) {
case MAX7456_CLOCK_CONFIG_HALF:
max7456SpiClock = MAX7456_SPI_CLK * 2;
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_DIVISOR, max7456SpiClock);
#else
UNUSED(max7456Config);
UNUSED(cpuOverclock);
#endif

View File

@ -27,7 +27,8 @@ extern uint16_t maxScreenSize;
struct vcdProfile_s;
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 max7456Brightness(uint8_t black, uint8_t white);
void max7456DrawScreen(void);
@ -39,13 +40,3 @@ void max7456ClearScreen(void);
void max7456RefreshAll(void);
uint8_t* max7456GetScreenBuffer(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);

View File

@ -28,15 +28,11 @@
#include "common/utils.h"
#include "pg/pg.h"
#include "pg/pg_ids.h"
#include "drivers/adc.h"
#include "drivers/bus_i2c.h"
#include "drivers/bus_spi.h"
#include "drivers/light_led.h"
#include "drivers/camera_control.h"
#include "drivers/max7456.h"
#include "drivers/vtx_common.h"
#include "fc/config.h"
@ -66,6 +62,9 @@
#include "io/vtx_rtc6705.h"
#include "pg/adc.h"
#include "pg/max7456.h"
#include "pg/pg.h"
#include "pg/pg_ids.h"
#include "rx/rx.h"
#include "rx/cc2500_frsky_common.h"

View File

@ -24,9 +24,6 @@
#include "common/utils.h"
#include "pg/pg.h"
#include "pg/pg_ids.h"
#include "drivers/display.h"
#include "drivers/max7456.h"
#include "drivers/vcd.h"
@ -37,6 +34,10 @@
#include "io/osd.h"
#include "io/osd_slave.h"
#include "pg/max7456.h"
#include "pg/pg.h"
#include "pg/pg_ids.h"
displayPort_t max7456DisplayPort;
PG_REGISTER_WITH_RESET_FN(displayPortProfile_t, displayPortProfileMax7456, PG_DISPLAY_PORT_MAX7456_CONFIG, 0);
@ -157,9 +158,9 @@ displayPort_t *max7456DisplayPortInit(const vcdProfile_t *vcdProfile)
{
displayInit(&max7456DisplayPort, &max7456VTable);
#ifdef USE_OSD_SLAVE
max7456Init(vcdProfile, false);
max7456Init(max7456Config(), vcdProfile, false);
#else
max7456Init(vcdProfile, systemConfig()->cpu_overclock);
max7456Init(max7456Config(), vcdProfile, systemConfig()->cpu_overclock);
#endif
resync(&max7456DisplayPort);
return &max7456DisplayPort;

33
src/main/pg/max7456.c Normal file
View 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
View 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);

View File

@ -22,10 +22,11 @@
#ifdef USE_TARGET_CONFIG
#include "pg/pg.h"
#include "drivers/max7456.h"
#include "io/serial.h"
#include "pg/max7456.h"
#include "pg/pg.h"
void targetConfiguration(void)
{
#ifdef OMNIBUSF4BASE