/** * Initialize the driver, must be called before any other routines. * * Attempts to detect a connected m25p16. If found, true is returned and device capacity can be fetched with * m25p16_getGeometry(). */ bool m25p16_init(ioTag_t csTag) { /* if we have already detected a flash device we can simply exit TODO: change the init param in favour of flash CFG when ParamGroups work is done then cs pin can be specified in hardware_revision.c or config.c (dependent on revision). */ if (geometry.sectors) { return true; } if (csTag) { m25p16CsPin = IOGetByTag(csTag); } else { #ifdef M25P16_CS_PIN m25p16CsPin = IOGetByTag(IO_TAG(M25P16_CS_PIN)); #else return false; #endif } IOInit(m25p16CsPin, OWNER_FLASH_CS, 0); IOConfigGPIO(m25p16CsPin, SPI_IO_CS_CFG); DISABLE_M25P16; #ifndef M25P16_SPI_SHARED //Maximum speed for standard READ command is 20mHz, other commands tolerate 25mHz spiSetDivisor(M25P16_SPI_INSTANCE, SPI_CLOCK_FAST); #endif return m25p16_readIdentification(); }
/** * Initialize the driver, must be called before any other routines. * * Attempts to detect a connected m25p16. If found, true is returned and device capacity can be fetched with * m25p16_getGeometry(). */ bool m25p16_init() { //Maximum speed for standard READ command is 20mHz, other commands tolerate 25mHz spiSetDivisor(M25P16_SPI_INSTANCE, HIGH_SPEED_SPI); return m25p16_readIdentification(); }
/** * Initialize the driver, must be called before any other routines. * * Attempts to detect a connected m25p16. If found, true is returned and device capacity can be fetched with * m25p16_getGeometry(). */ bool m25p16_init() { //Maximum speed for standard READ command is 20mHz, other commands tolerate 25mHz #ifdef STM32F40_41xxx spiSetDivisor(M25P16_SPI_INSTANCE, SPI_21MHZ_CLOCK_DIVIDER); #else spiSetDivisor(M25P16_SPI_INSTANCE, SPI_18MHZ_CLOCK_DIVIDER); #endif return m25p16_readIdentification(); }
/** * Initialize the driver, must be called before any other routines. * * Attempts to detect a connected m25p16. If found, true is returned and device capacity can be fetched with * m25p16_getGeometry(). */ bool m25p16_init() { #ifdef M25P16_CS_PIN m25p16CsPin = IOGetByTag(IO_TAG(M25P16_CS_PIN)); #endif IOInit(m25p16CsPin, OWNER_FLASH, RESOURCE_SPI_CS, 0); IOConfigGPIO(m25p16CsPin, SPI_IO_CS_CFG); DISABLE_M25P16; #ifndef M25P16_SPI_SHARED //Maximum speed for standard READ command is 20mHz, other commands tolerate 25mHz spiSetDivisor(M25P16_SPI_INSTANCE, SPI_CLOCK_FAST); #endif return m25p16_readIdentification(); }