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:
parent
77c5bd1170
commit
37de7009c4
4 changed files with 11 additions and 10 deletions
|
@ -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
|
* 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(void)
|
bool m25p16_init(int flashNumToUse)
|
||||||
{
|
{
|
||||||
if (busDev) {
|
if (busDev) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
busDev = busDeviceInit(BUSTYPE_SPI, DEVHW_M25P16, 0, OWNER_FLASH);
|
busDev = busDeviceInit(BUSTYPE_SPI, DEVHW_M25P16, flashNumToUse, OWNER_FLASH);
|
||||||
if (busDev == NULL) {
|
if (busDev == NULL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
#define M25P16_PAGESIZE 256
|
#define M25P16_PAGESIZE 256
|
||||||
|
|
||||||
bool m25p16_init(void);
|
bool m25p16_init(int flashNumToUse);
|
||||||
|
|
||||||
void m25p16_eraseSector(uint32_t address);
|
void m25p16_eraseSector(uint32_t address);
|
||||||
void m25p16_eraseCompletely(void);
|
void m25p16_eraseCompletely(void);
|
||||||
|
|
|
@ -612,10 +612,10 @@ void init(void)
|
||||||
#ifdef USE_FLASHFS
|
#ifdef USE_FLASHFS
|
||||||
#ifdef NAZE
|
#ifdef NAZE
|
||||||
if (hardwareRevision == NAZE32_REV5) {
|
if (hardwareRevision == NAZE32_REV5) {
|
||||||
m25p16_init();
|
m25p16_init(0);
|
||||||
}
|
}
|
||||||
#elif defined(USE_FLASH_M25P16)
|
#elif defined(USE_FLASH_M25P16)
|
||||||
m25p16_init();
|
m25p16_init(0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
flashfsInit();
|
flashfsInit();
|
||||||
|
|
|
@ -23,8 +23,8 @@
|
||||||
|
|
||||||
#include "build/build_config.h"
|
#include "build/build_config.h"
|
||||||
|
|
||||||
|
#include "drivers/bus.h"
|
||||||
#include "drivers/time.h"
|
#include "drivers/time.h"
|
||||||
#include "drivers/bus_spi.h"
|
|
||||||
#include "drivers/io.h"
|
#include "drivers/io.h"
|
||||||
#include "drivers/flash_m25p16.h"
|
#include "drivers/flash_m25p16.h"
|
||||||
#include "hardware_revision.h"
|
#include "hardware_revision.h"
|
||||||
|
@ -83,16 +83,17 @@ void detectHardwareRevision(void)
|
||||||
IOLo(uart1invert);
|
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)
|
void updateHardwareRevision(void)
|
||||||
{
|
{
|
||||||
if (hardwareRevision != BJF4_REV2) {
|
if (hardwareRevision != BJF4_REV2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* if flash exists on PB3 (busDevice m25p16_bjf3_rev1) then Rev1 */
|
||||||
if flash exists on PB3 then Rev1
|
if (m25p16_init(1)) {
|
||||||
*/
|
|
||||||
if (m25p16_init(IO_TAG(PB3))) {
|
|
||||||
hardwareRevision = BJF4_REV1;
|
hardwareRevision = BJF4_REV1;
|
||||||
} else {
|
} else {
|
||||||
IOInit(IOGetByTag(IO_TAG(PB3)), OWNER_FREE, RESOURCE_NONE, 0);
|
IOInit(IOGetByTag(IO_TAG(PB3)), OWNER_FREE, RESOURCE_NONE, 0);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue