2018-06-06 05:23 AM
Hello,
I implemented some functions to read and write the QSPI memory by using functions HAL_QSPI_Transmit() and HAL_QSPI_Receive() provided by the libraries.
Everything works fine. I just wonder how I can write and read strings using these functions.
I want to write:
char myString[100][50];
but the above functions have a uint8_t as an input!
Is there any way to do so, other than passing a single character at a time?
Thanks,
#read #strings #write #qspiSolved! Go to Solution.
2018-06-06 10:21 AM
Use a cast?
char myString[50];
BSP_QSPI_Write((void *)myString, Address, sizeof(myString));
BSP_QSPI_Write((uint8_t *)&myString[0], Address, sizeof(myString));
2018-06-06 07:56 AM
>>Is there any way to do so, other than passing a single character at a time?
Clearly there would be a means to achieving it.
STM32Cube_FW_F7_V1.11.0\Drivers\BSP\STM32F769I-Discovery\stm32f769i_discovery_qspi.c
BSP_QSPI_Write(Buffer, Address, Size)
2018-06-06 10:16 AM
Thanks!
But how can I put my string (let's say char myString[50]) inside the Buffer in
BSP_QSPI_Write()?
This function only accepts uint8_t as a buffer and I have a chars!
2018-06-06 10:21 AM
Use a cast?
char myString[50];
BSP_QSPI_Write((void *)myString, Address, sizeof(myString));
BSP_QSPI_Write((uint8_t *)&myString[0], Address, sizeof(myString));
2018-06-06 10:28 AM
Thank you very much! I was casting in a wrong way..
2018-06-06 10:49 AM
>>Thank you very much! I was casting in a wrong way..
C can be like that, and the cast frequently stops the compiler complaining when it would be helpful that it did.
char myString[100][50];
BSP_QSPI_Write((void *)&myString[0][0], Address, sizeof(myString)); // Base address of my array - writing to QSPI FLASH as a binary blob
Several ways to do this, the form like this might be clearer to a subsequent reader of the code, or future self, that you really want the address of the base elements of the array as the starting point.
2018-06-08 07:45 AM
I have an additional question that comes to mind.
Instead of writing and reading the QSPI memory, can I use a variable to point to one of its block addresses?
For example, I want to point to the QSPI memory with a variable like this:
char myVariable[50]
I need an alternative to Write and Read because I need to write a lot and it takes to much time...
Thanks!
2018-06-08 10:27 AM
I don't believe you can write-in-place
Reading
char *myVariable = (char *)0x90001234;
You could do similar things using the linker script, or scatter file, to create a NOINIT region where you direct QSPI structures into.