Commit 593da0cd authored by deroo's avatar deroo
Browse files

fix typos in README

parent 91ec3514
......@@ -23,7 +23,7 @@ with the values of 4096, 4 and 256, respectively.
Finally, it declares 2 macros:
NANO33BLE_PUT_ARRAY_IN_FLASH( \<datatype\>, \<arrayName\>, \<numberOfArrayElements\> )
NANO33BLE_FLASH_LOWEST_PAGE
NANO33BLE_FLASH_LOWEST_PAGE
which are described below.
This code is most useful for implementing non-volatile arrays,
......@@ -57,7 +57,7 @@ double *arrayInFlash;
to declare an array of doubles named "arrayInFlash".
The asterisk ( * ) before the array name is important.
The scope of the array is determined by where the declaration is made.
If outside of any function, the scope is global (all functions can see the array), while if it is inside a function, it will be seen only within that function , and others to which it is passed in the function argument list.
If outside of any function, the scope is global (all functions can see the array), while if it is inside a function, it will be seen only within that function , and others to which it is passed in function argument lists.
The second step is to specify where and how big the array is.
This is done using a macro:
......@@ -91,14 +91,16 @@ as doing so defeats the non-volatility property of flash.
Valid datatypes for arrays in flash using this library include structs and typedefs, in addition to the predefined C datatypes. Structs appear to default to multiples of flash words, so the programmer's attention to alignment issues does not appear to be neccessary.
Some limitations: the sizeof operator on any array in flash will always return 4 (=flashBytesPerWord). Also, C string functions like strcpy and strlen do not always work as one would expect to manipulate the arrays in flash, 'tho memcpy and strcpy do work to copy the contents out of flash, and memcpy does work to copy into flash if the number of bytes is a multple of flashBytesPerWord. I recommend using macros (ie. #define) or variables to declare the number of array elements as the sketch cannot easily figure out by itself how big a flash array has been declared after the declaration.
Some limitations: the sizeof() operator on any array in flash will always return 4 (=flashBytesPerWord).
Also, C string functions like strcpy() and strlen() do not always work as one would expect to manipulate the arrays in flash, 'tho memcpy() and strcpy() do work to copy the contents out of flash, and memcpy() does work to copy into flash if the number of bytes is a multple of flashBytesPerWord.
I recommend using macros (ie. #define) or variables to declare the number of array elements as the sketch cannot easily figure out by itself how big a flash array has been declared after the declaration.
If you want more control over the details of the declarations in flash,
declare arrays in flash using pointers:
\<datatype\> *\<arrayInFlash\> = ( \<datatype\> *)\<flashAddress\>;
where the flashAddress is the number of bytes into the flash memory.
This form of the statement does both tasks listed separately above:
it declares the array, defines its scope, and locates it.
This form of the statement does all of the tasks listed separately above:
it declares the array and its type, defines its scope, and locates it.
For example,
int *intsInFlash = (int *)(flashNumberOfPages-2)*flashBytesPerPage;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment