summaryrefslogtreecommitdiff
path: root/nuttx/configs/vsn/src/sif.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-05-07 16:59:20 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-05-07 16:59:20 +0000
commit7bbac15cb60bbcbff692c5edaa8a203c3127e958 (patch)
tree77b8d55c8bdcf52e6484eec897c9e380eb59a8ef /nuttx/configs/vsn/src/sif.c
parentbbbdceb9d13441f4b96257718ed090b8998759f7 (diff)
downloadpx4-nuttx-7bbac15cb60bbcbff692c5edaa8a203c3127e958.tar.gz
px4-nuttx-7bbac15cb60bbcbff692c5edaa8a203c3127e958.tar.bz2
px4-nuttx-7bbac15cb60bbcbff692c5edaa8a203c3127e958.zip
Add STM32 FLASH driver
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3573 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/configs/vsn/src/sif.c')
-rw-r--r--nuttx/configs/vsn/src/sif.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/nuttx/configs/vsn/src/sif.c b/nuttx/configs/vsn/src/sif.c
index 4be214444..2cd807138 100644
--- a/nuttx/configs/vsn/src/sif.c
+++ b/nuttx/configs/vsn/src/sif.c
@@ -74,6 +74,7 @@
#include <nuttx/clock.h>
#include <nuttx/time.h>
#include <nuttx/rtc.h>
+#include <nuttx/progmem.h>
#include <nuttx/i2c.h>
#include <nuttx/sensors/st_lis331dl.h>
@@ -512,6 +513,36 @@ int sif_main(int argc, char *argv[])
t_set.tv_sec = atoi(argv[2]);
clock_settime(CLOCK_REALTIME, &t_set);
}
+ else if (!strcmp(argv[1], "free") ) {
+ uint16_t page = 0, stpage = 0xFFFF;
+ int status;
+ do {
+ status = up_progmem_ispageerased(page++);
+
+ /* Is this beginning of new free space section */
+ if (status == 0) {
+ if (stpage == 0xFFFF) stpage = page-1;
+ }
+ else if (status != 0) {
+ if (stpage != 0xFFFF) {
+ printf("Free Range:\t%d\t-\t%d\n", stpage, page-2);
+ stpage = 0xFFFF;
+ }
+ }
+ }
+ while (status >= 0);
+ }
+ else if (!strcmp(argv[1], "erase") && argc == 3 ) {
+ int page = atoi(argv[2]);
+ printf("Erase result: %d\n", up_progmem_erasepage(page) );
+ }
+ else if (!strcmp(argv[1], "flash") && argc == 3 ) {
+ uint16_t page = atoi(argv[2]);
+ uint32_t addr = page * up_progmem_pagesize(page);
+
+ printf("Write result: %d (writing to address %xh)\n",
+ up_progmem_write( addr, "Test", 4 ), addr);
+ }
else if (!strcmp(argv[1], "i2c") && argc == 3) {
int val = atoi(argv[2]);
@@ -520,7 +551,7 @@ int sif_main(int argc, char *argv[])
struct st_lis331dl_dev_s * lis = st_lis331dl_init(vsn_sif.i2c1, val);
if (lis) {
- struct st_lis331dl_vector_s * a;
+ const struct st_lis331dl_vector_s * a;
int i;
uint32_t time_stamp = clock_systimer();