on 2022-06-30 12:37 AM
#define SPI_FLASH_PAGESIZE 256 void WriteData(void) { uint32_t sizeOfBitmaps = (uint32_t)(&__MY_AUDIOFILES_END)- (uint32_t) (&__MY_AUDIOFILES_START); //erase sections required uint32_t address = 0x000000; do { sendWriteEnable(); sendSectorErase(address); //wait until WIP is cleared uint32_t status; do { status = readStatusRegister(); } while (status & STATUS_WIP); address += 0x001000; } while (address < sizeOfBitmaps); constuint8_t* bitmapStart = &__MY_AUDIOFILES_START; //page program required pages address = 0x00000000; do { sendWriteEnable(); sendPageProgram(address, bitmapStart + address, SPI_FLASH_PAGESIZE); //wait until WIP is cleared uint32_t status; do { status = readStatusRegister(); } while (status & STATUS_WIP); address += 256; } while (address < sizeOfBitmaps); }readData(uint32_t address24, uint8_t* buffer, uint32_t length)
#define CMD_READ 0x03 void readData(uint32_t address24, uint8_t* buffer, uint32_t length) { FLASH_CS_LOW(); uint8_t bufferOut[4]; bufferOut[0] = CMD_READ; bufferOut[1] = (address24 >> 16) & 0xFF; bufferOut[2] = (address24 >> 8) & 0xFF; bufferOut[3] = address24 & 0xFF; if (HAL_SPI_Transmit(&flashSPIh, bufferOut, sizeof(bufferOut), 1000) !=HAL_OK) { /* Transfer error in transmission process */ Error_Handler(); } if (HAL_SPI_Receive(&flashSPIh, bufferIn, sizeof(bufferIn), 1000) != HAL_OK) { /* Transfer error in transmission process */ Error_Handler(); } FLASH_CS_HIGH(); }SPIFlash_RunTest(void)
uint32_t SPIFlash_RunTest(void) { //RDSR test statusReg = readStatusRegister(); /*Unprotect if protected*/ sendWriteEnable(); while(statusReg & 0x38) { statusReg &= ~0x38; writeStatusRegister(0x01, statusReg); statusReg = readStatusRegister(); } sendWriteEnable(); statusReg = readStatusRegister(); //wait until WIP is cleared uint32_t status; do { status = readStatusRegister(); } while (status & STATUS_WIP); //WREN sendWriteEnable(); return 0; }
Good morning,
I tried to recreate this example with STMCUBEIDE v.1.19.0 for the STM32G030F6P6, but I also get errors like:
../Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_rcc.h:3119:1: error: unknown type name 'HAL_StatusTypeDef'.
Do you have a complete project, even for another CPU, that can compile correctly?
I'd like to try: Final Demo of how to play audio files from external memory using STM32G0
Thanks
Luigi Fiorini
We’re moving the ST Community to a new platform to give you a better and more reliable community experience.