In my project using w25q32 with stm32 and i want to store the pressure sensor data and calibration data to flash and i got code from github but it's working for only uint8_t data store like only 0-255 number of data can store so i tried uint16_t , uint32_t data to store but no luck so i attached code please help me to resolve this.
void W25qxx_WritePage(uint8_t *pBuffer, uint32_t Page_Address, uint32_t OffsetInByte, uint32_t NumByteToWrite_up_to_PageSize)
{
if (((NumByteToWrite_up_to_PageSize + OffsetInByte) > w25q32.PageSize) || (NumByteToWrite_up_to_PageSize == 0))
NumByteToWrite_up_to_PageSize = w25q32.PageSize - OffsetInByte;
if ((OffsetInByte + NumByteToWrite_up_to_PageSize) > w25q32.PageSize)
NumByteToWrite_up_to_PageSize = w25q32.PageSize - OffsetInByte;
W25q32_WaitForWriteEnd();
W25q32_WriteEnable();
HAL_GPIO_WritePin(GPIOB,GPIO_PIN_6,GPIO_PIN_RESET);
Page_Address = (Page_Address * w25q32.PageSize) + OffsetInByte;
W25q32_Spi(0x02);
W25q32_Spi((Page_Address & 0xFF0000) >> 16);
W25q32_Spi((Page_Address & 0xFF00) >> 8);
W25q32_Spi(Page_Address & 0xFF);
HAL_SPI_Transmit(&hspi1, pBuffer, NumByteToWrite_up_to_PageSize, 100);
HAL_GPIO_WritePin(GPIOB,GPIO_PIN_6,GPIO_PIN_SET);
W25q32_WaitForWriteEnd();
printf("wrote data's are:\r\n");
for (uint32_t i = 0; i < NumByteToWrite_up_to_PageSize; i++)
{
if ((i % 32 == 0) && (i > 2))
{
HAL_Delay(10);
}
printf("%d,", pBuffer[i]);
}
printf("\r\n");
HAL_Delay(100);
}
void W25qxx_ReadPage(uint8_t *pBuffer, uint32_t Page_Address, uint32_t OffsetInByte, uint32_t NumByteToRead_up_to_PageSize)
{
if ((NumByteToRead_up_to_PageSize > w25q32.PageSize) || (NumByteToRead_up_to_PageSize == 0))
NumByteToRead_up_to_PageSize = w25q32.PageSize;
if ((OffsetInByte + NumByteToRead_up_to_PageSize) > w25q32.PageSize)
NumByteToRead_up_to_PageSize = w25q32.PageSize - OffsetInByte;
Page_Address = Page_Address * w25q32.PageSize + OffsetInByte;
HAL_GPIO_WritePin(GPIOB,GPIO_PIN_6,GPIO_PIN_RESET);
W25q32_Spi(0x0B);
W25q32_Spi((Page_Address & 0xFF0000) >> 16);
W25q32_Spi((Page_Address & 0xFF00) >> 8);
W25q32_Spi(Page_Address & 0xFF);
W25q32_Spi(0);
HAL_SPI_Receive(&hspi1, pBuffer, NumByteToRead_up_to_PageSize, 100);
HAL_GPIO_WritePin(GPIOB,GPIO_PIN_6,GPIO_PIN_SET);
printf("read data's are\r\n:");
for (uint32_t i = 0; i < NumByteToRead_up_to_PageSize; i++)
{
if ((i % 32 == 0) && (i > 2))
{
HAL_Delay(10);
}
printf("%d,",pBuffer[i]);
}
printf("\r\n");
HAL_Delay(100);
}