diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-05-07 16:59:20 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-05-07 16:59:20 +0000 |
commit | 7bbac15cb60bbcbff692c5edaa8a203c3127e958 (patch) | |
tree | 77b8d55c8bdcf52e6484eec897c9e380eb59a8ef /nuttx/configs/vsn/src | |
parent | bbbdceb9d13441f4b96257718ed090b8998759f7 (diff) | |
download | px4-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')
-rw-r--r-- | nuttx/configs/vsn/src/sif.c | 33 | ||||
-rw-r--r-- | nuttx/configs/vsn/src/sysclock.c | 4 |
2 files changed, 34 insertions, 3 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(); diff --git a/nuttx/configs/vsn/src/sysclock.c b/nuttx/configs/vsn/src/sysclock.c index f65ae0670..8b1a0be34 100644 --- a/nuttx/configs/vsn/src/sysclock.c +++ b/nuttx/configs/vsn/src/sysclock.c @@ -78,8 +78,8 @@ void sysclock_select_hsi(void) // Set FLASH prefetch buffer and 1 wait state regval = getreg32(STM32_FLASH_ACR); - regval &= ~ACR_LATENCY_MASK; - regval |= (ACR_LATENCY_1|ACR_PRTFBE); + regval &= ~FLASH_ACR_LATENCY_MASK; + regval |= (FLASH_ACR_LATENCY_1|FLASH_ACR_PRTFBE); putreg32(regval, STM32_FLASH_ACR); // Set the HCLK source/divider |