1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-19 06:15:16 +03:00

Moved parameter group for flash into pg/.

This commit is contained in:
mikeller 2017-12-23 23:46:10 +13:00
parent 060c4d3e9a
commit 429c6cecda
10 changed files with 87 additions and 23 deletions

View file

@ -62,6 +62,7 @@ COMMON_SRC = \
msp/msp_serial.c \ msp/msp_serial.c \
pg/adc.c \ pg/adc.c \
pg/bus_i2c.c \ pg/bus_i2c.c \
pg/flash.c \
pg/pg.c \ pg/pg.c \
scheduler/scheduler.c \ scheduler/scheduler.c \
sensors/battery.c \ sensors/battery.c \

View file

@ -27,8 +27,3 @@ typedef struct flashGeometry_s {
uint32_t totalSize; // This is just sectorSize * sectors uint32_t totalSize; // This is just sectorSize * sectors
uint16_t pagesPerSector; uint16_t pagesPerSector;
} flashGeometry_t; } flashGeometry_t;
typedef struct flashConfig_s {
ioTag_t csTag;
uint8_t spiDevice;
} flashConfig_t;

View file

@ -22,12 +22,15 @@
#ifdef USE_FLASH_M25P16 #ifdef USE_FLASH_M25P16
#include "flash.h"
#include "flash_m25p16.h"
#include "drivers/bus_spi.h" #include "drivers/bus_spi.h"
#include "drivers/flash.h"
#include "drivers/io.h" #include "drivers/io.h"
#include "drivers/time.h" #include "drivers/time.h"
#include "pg/flash.h"
#include "flash_m25p16.h"
#define M25P16_INSTRUCTION_RDID 0x9F #define M25P16_INSTRUCTION_RDID 0x9F
#define M25P16_INSTRUCTION_READ_BYTES 0x03 #define M25P16_INSTRUCTION_READ_BYTES 0x03
#define M25P16_INSTRUCTION_READ_STATUS_REG 0x05 #define M25P16_INSTRUCTION_READ_STATUS_REG 0x05
@ -229,6 +232,7 @@ static bool m25p16_readIdentification(void)
* Attempts to detect a connected m25p16. If found, true is returned and device capacity can be fetched with * Attempts to detect a connected m25p16. If found, true is returned and device capacity can be fetched with
* m25p16_getGeometry(). * m25p16_getGeometry().
*/ */
bool m25p16_init(const flashConfig_t *flashConfig) bool m25p16_init(const flashConfig_t *flashConfig)
{ {
/* /*

View file

@ -22,7 +22,8 @@
#define M25P16_PAGESIZE 256 #define M25P16_PAGESIZE 256
bool m25p16_init(const flashConfig_t *flashConfig); struct flashConfig_s;
bool m25p16_init(const struct flashConfig_s *flashConfig);
void m25p16_eraseSector(uint32_t address); void m25p16_eraseSector(uint32_t address);
void m25p16_eraseCompletely(void); void m25p16_eraseCompletely(void);

View file

@ -151,20 +151,6 @@ PG_REGISTER_WITH_RESET_FN(pwmConfig_t, pwmConfig, PG_PWM_CONFIG, 0);
PG_REGISTER_WITH_RESET_FN(ppmConfig_t, ppmConfig, PG_PPM_CONFIG, 0); PG_REGISTER_WITH_RESET_FN(ppmConfig_t, ppmConfig, PG_PPM_CONFIG, 0);
#endif #endif
#ifdef USE_FLASHFS
PG_REGISTER_WITH_RESET_FN(flashConfig_t, flashConfig, PG_FLASH_CONFIG, 0);
void pgResetFn_flashConfig(flashConfig_t *flashConfig)
{
#ifdef M25P16_CS_PIN
flashConfig->csTag = IO_TAG(M25P16_CS_PIN);
#else
flashConfig->csTag = IO_TAG_NONE;
#endif
flashConfig->spiDevice = SPI_DEV_TO_CFG(spiDeviceByInstance(M25P16_SPI_INSTANCE));
}
#endif // USE_FLASH_FS
#ifdef USE_SDCARD #ifdef USE_SDCARD
PG_REGISTER_WITH_RESET_TEMPLATE(sdcardConfig_t, sdcardConfig, PG_SDCARD_CONFIG, 0); PG_REGISTER_WITH_RESET_TEMPLATE(sdcardConfig_t, sdcardConfig, PG_SDCARD_CONFIG, 0);

View file

@ -84,7 +84,6 @@ typedef struct systemConfig_s {
PG_DECLARE(pilotConfig_t, pilotConfig); PG_DECLARE(pilotConfig_t, pilotConfig);
PG_DECLARE(systemConfig_t, systemConfig); PG_DECLARE(systemConfig_t, systemConfig);
PG_DECLARE(beeperDevConfig_t, beeperDevConfig); PG_DECLARE(beeperDevConfig_t, beeperDevConfig);
PG_DECLARE(flashConfig_t, flashConfig);
PG_DECLARE(ppmConfig_t, ppmConfig); PG_DECLARE(ppmConfig_t, ppmConfig);
PG_DECLARE(pwmConfig_t, pwmConfig); PG_DECLARE(pwmConfig_t, pwmConfig);
PG_DECLARE(vcdProfile_t, vcdProfile); PG_DECLARE(vcdProfile_t, vcdProfile);

View file

@ -81,6 +81,7 @@
#include "pg/adc.h" #include "pg/adc.h"
#include "pg/bus_i2c.h" #include "pg/bus_i2c.h"
#include "pg/flash.h"
#include "rx/rx.h" #include "rx/rx.h"
#include "rx/rx_spi.h" #include "rx/rx_spi.h"

44
src/main/pg/flash.c Normal file
View file

@ -0,0 +1,44 @@
/*
* 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 <stdbool.h>
#include <stdint.h>
#include "platform.h"
#ifdef USE_FLASHFS
#include "drivers/bus_spi.h"
#include "drivers/io.h"
#include "pg/pg.h"
#include "pg/pg_ids.h"
#include "flash.h"
PG_REGISTER_WITH_RESET_FN(flashConfig_t, flashConfig, PG_FLASH_CONFIG, 0);
void pgResetFn_flashConfig(flashConfig_t *flashConfig)
{
#ifdef M25P16_CS_PIN
flashConfig->csTag = IO_TAG(M25P16_CS_PIN);
#else
flashConfig->csTag = IO_TAG_NONE;
#endif
flashConfig->spiDevice = SPI_DEV_TO_CFG(spiDeviceByInstance(M25P16_SPI_INSTANCE));
}
#endif

31
src/main/pg/flash.h Normal file
View file

@ -0,0 +1,31 @@
/*
* 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 <stdint.h>
#include "drivers/io_types.h"
#include "pg/pg.h"
typedef struct flashConfig_s {
ioTag_t csTag;
uint8_t spiDevice;
} flashConfig_t;
PG_DECLARE(flashConfig_t, flashConfig);

View file

@ -28,6 +28,8 @@
#include "drivers/io.h" #include "drivers/io.h"
#include "drivers/time.h" #include "drivers/time.h"
#include "pg/flash.h"
#include "hardware_revision.h" #include "hardware_revision.h"
uint8_t hardwareRevision = UNKNOWN; uint8_t hardwareRevision = UNKNOWN;