1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-24 00:35:39 +03:00

Moved USB detection to IO

Fixed CHEBUZZF3, SPRACINGF3 (EVO, MINI) and F3Discovery targets
This commit is contained in:
blckmn 2016-06-04 09:41:00 +10:00
parent 9c1c4fef33
commit 78da0fad65
12 changed files with 80 additions and 155 deletions

View file

@ -47,8 +47,8 @@
#define JEDEC_ID_MICRON_N25Q128 0x20ba18
#define JEDEC_ID_WINBOND_W25Q128 0xEF4018
#define DISABLE_M25P16 GPIO_SetBits(M25P16_CS_GPIO, M25P16_CS_PIN)
#define ENABLE_M25P16 GPIO_ResetBits(M25P16_CS_GPIO, M25P16_CS_PIN)
#define DISABLE_M25P16 IOHi(m25p16CsPin)
#define ENABLE_M25P16 IOLo(m25p16CsPin)
// The timeout we expect between being able to issue page program instructions
#define DEFAULT_TIMEOUT_MILLIS 6
@ -59,6 +59,8 @@
static flashGeometry_t geometry = {.pageSize = M25P16_PAGESIZE};
static IO_t m25p16CsPin = IO_NONE;
/*
* Whether we've performed an action that could have made the device busy for writes.
*
@ -195,6 +197,13 @@ static bool m25p16_readIdentification()
*/
bool m25p16_init()
{
#ifdef M25P16_CS_PIN
m25p16CsPin = IOGetByTag(IO_TAG(M25P16_CS_PIN));
#endif
IOInit(m25p16CsPin, OWNER_FLASH, RESOURCE_SPI);
IOConfigGPIO(m25p16CsPin, SPI_IO_CS_CFG);
//Maximum speed for standard READ command is 20mHz, other commands tolerate 25mHz
spiSetDivisor(M25P16_SPI_INSTANCE, SPI_18MHZ_CLOCK_DIVIDER);