1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-26 17:55:28 +03:00

Allow different M25P16 chips; Fix BJF4 revision detection

This commit is contained in:
Konstantin Sharlaimov (DigitalEntity) 2017-12-15 22:08:25 +10:00
parent 77c5bd1170
commit 37de7009c4
4 changed files with 11 additions and 10 deletions

View file

@ -211,13 +211,13 @@ static bool m25p16_readIdentification(void)
* Attempts to detect a connected m25p16. If found, true is returned and device capacity can be fetched with
* m25p16_getGeometry().
*/
bool m25p16_init(void)
bool m25p16_init(int flashNumToUse)
{
if (busDev) {
return true;
}
busDev = busDeviceInit(BUSTYPE_SPI, DEVHW_M25P16, 0, OWNER_FLASH);
busDev = busDeviceInit(BUSTYPE_SPI, DEVHW_M25P16, flashNumToUse, OWNER_FLASH);
if (busDev == NULL) {
return false;
}

View file

@ -23,7 +23,7 @@
#define M25P16_PAGESIZE 256
bool m25p16_init(void);
bool m25p16_init(int flashNumToUse);
void m25p16_eraseSector(uint32_t address);
void m25p16_eraseCompletely(void);

View file

@ -612,10 +612,10 @@ void init(void)
#ifdef USE_FLASHFS
#ifdef NAZE
if (hardwareRevision == NAZE32_REV5) {
m25p16_init();
m25p16_init(0);
}
#elif defined(USE_FLASH_M25P16)
m25p16_init();
m25p16_init(0);
#endif
flashfsInit();

View file

@ -23,8 +23,8 @@
#include "build/build_config.h"
#include "drivers/bus.h"
#include "drivers/time.h"
#include "drivers/bus_spi.h"
#include "drivers/io.h"
#include "drivers/flash_m25p16.h"
#include "hardware_revision.h"
@ -83,16 +83,17 @@ void detectHardwareRevision(void)
IOLo(uart1invert);
}
/* BJF4_REV1 has different connection of memory chip */
BUSDEV_REGISTER_SPI_TAG(m25p16_bjf3_rev1, DEVHW_M25P16, M25P16_SPI_BUS, PB3, NONE, 1, DEVFLAGS_NONE);
void updateHardwareRevision(void)
{
if (hardwareRevision != BJF4_REV2) {
return;
}
/*
if flash exists on PB3 then Rev1
*/
if (m25p16_init(IO_TAG(PB3))) {
/* if flash exists on PB3 (busDevice m25p16_bjf3_rev1) then Rev1 */
if (m25p16_init(1)) {
hardwareRevision = BJF4_REV1;
} else {
IOInit(IOGetByTag(IO_TAG(PB3)), OWNER_FREE, RESOURCE_NONE, 0);