The Mikroe STM32 F4 board now uses /dev/config for configuration data storage. From Ken Pettit
This commit is contained in:
parent
74b0933088
commit
3a8c1cdccd
@ -718,4 +718,5 @@
|
|||||||
data. From Ken Pettit (2013-10-30).
|
data. From Ken Pettit (2013-10-30).
|
||||||
* apps/nshlib/nsh_dbgcmds.c and others: Add skip= and count=
|
* apps/nshlib/nsh_dbgcmds.c and others: Add skip= and count=
|
||||||
options to the hexdump command. From Ken Pettit (2013-11-1).
|
options to the hexdump command. From Ken Pettit (2013-11-1).
|
||||||
|
* apps/platrorm/mikroe-stm32f4: Now uses /dev/config for configuration
|
||||||
|
data storage. From Ken Pettit (2013-11-1).
|
||||||
|
@ -12,7 +12,7 @@ choice
|
|||||||
default MIKROE_STM32F4_CONFIGDATA_PART
|
default MIKROE_STM32F4_CONFIGDATA_PART
|
||||||
|
|
||||||
config MIKROE_STM32F4_CONFIGDATA_PART
|
config MIKROE_STM32F4_CONFIGDATA_PART
|
||||||
bool "Dedicated FLASH partition"
|
bool "Dedicated FLASH partition using /dev/config"
|
||||||
|
|
||||||
config MIKROE_STM32F4_CONFIGDATA_FS
|
config MIKROE_STM32F4_CONFIGDATA_FS
|
||||||
bool "File system file"
|
bool "File system file"
|
||||||
@ -32,14 +32,6 @@ config MIKROE_STM32F4_CONFIGDATA_FILENAME
|
|||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if MIKROE_STM32F4_CONFIGDATA_PART
|
|
||||||
|
|
||||||
config MIKROE_STM32F4_CONFIGDATA_PART_SIZE
|
|
||||||
int "Size (in erase blocks) of configuration data partition"
|
|
||||||
default 2
|
|
||||||
|
|
||||||
endif
|
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
@ -46,6 +46,8 @@
|
|||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <apps/platform/configdata.h>
|
#include <apps/platform/configdata.h>
|
||||||
|
#include <nuttx/fs/ioctl.h>
|
||||||
|
#include <nuttx/configdata.h>
|
||||||
|
|
||||||
#ifdef CONFIG_PLATFORM_CONFIGDATA
|
#ifdef CONFIG_PLATFORM_CONFIGDATA
|
||||||
|
|
||||||
@ -108,6 +110,11 @@ int platform_setconfig(enum config_data_e id, int instance,
|
|||||||
#ifdef CONFIG_MIKROE_STM32F4_CONFIGDATA_FS
|
#ifdef CONFIG_MIKROE_STM32F4_CONFIGDATA_FS
|
||||||
FILE* fd;
|
FILE* fd;
|
||||||
#endif
|
#endif
|
||||||
|
#if CONFIG_MIKROE_STM32F4_CONFIGDATA_PART
|
||||||
|
struct config_data_s config;
|
||||||
|
int ret;
|
||||||
|
int fd;
|
||||||
|
#endif
|
||||||
|
|
||||||
switch (id)
|
switch (id)
|
||||||
{
|
{
|
||||||
@ -137,9 +144,29 @@ int platform_setconfig(enum config_data_e id, int instance,
|
|||||||
fclose(fd);
|
fclose(fd);
|
||||||
return OK;
|
return OK;
|
||||||
|
|
||||||
#elif CONFIG_MIKROE_STM32F4_CONFIGDATA_PART
|
#elif CONFIG_MIKROE_STM32F4_CONFIGDATA_PART
|
||||||
# error This configuration not supported yet!
|
|
||||||
#elif CONFIG_MIKROE_STM32F4_CONFIGDATA_ROM
|
/* Try to open the /dev/config device file */
|
||||||
|
|
||||||
|
if ((fd = open("/dev/config", O_RDOK)) == -1)
|
||||||
|
{
|
||||||
|
/* Error opening the config device */
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Setup structure for the SETCONFIG ioctl */
|
||||||
|
|
||||||
|
config.id = (enum config_data_e)id;
|
||||||
|
config.instance = instance;
|
||||||
|
config.configdata = (FAR uint8_t *) configdata;
|
||||||
|
config.len = datalen;
|
||||||
|
|
||||||
|
ret = ioctl(fd, CFGDIOC_SETCONFIG, (unsigned long) &config);
|
||||||
|
close(fd);
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
#elif CONFIG_MIKROE_STM32F4_CONFIGDATA_ROM
|
||||||
|
|
||||||
/* We are reading from a read-only system, so nothing to do. */
|
/* We are reading from a read-only system, so nothing to do. */
|
||||||
|
|
||||||
@ -194,12 +221,17 @@ int platform_getconfig(enum config_data_e id, int instance,
|
|||||||
size_t bytes;
|
size_t bytes;
|
||||||
enum config_data_e saved_id;
|
enum config_data_e saved_id;
|
||||||
int saved_instance;
|
int saved_instance;
|
||||||
#elif CONFIG_MIKROE_STM32F4_CONFIGDATA_ROM
|
#elif CONFIG_MIKROE_STM32F4_CONFIGDATA_ROM
|
||||||
static const uint8_t touch_cal_data[] = {
|
static const uint8_t touch_cal_data[] = {
|
||||||
0x9a, 0x2f, 0x00, 0x00,
|
0x9a, 0x2f, 0x00, 0x00,
|
||||||
0x40, 0xbc, 0x69, 0xfe, 0x70, 0x2e, 0x00,
|
0x40, 0xbc, 0x69, 0xfe, 0x70, 0x2e, 0x00,
|
||||||
0x00, 0xb8, 0x2d, 0xdb, 0xff };
|
0x00, 0xb8, 0x2d, 0xdb, 0xff };
|
||||||
#endif
|
#endif
|
||||||
|
#if CONFIG_MIKROE_STM32F4_CONFIGDATA_PART
|
||||||
|
struct config_data_s config;
|
||||||
|
int ret;
|
||||||
|
int fd;
|
||||||
|
#endif
|
||||||
|
|
||||||
switch (id)
|
switch (id)
|
||||||
{
|
{
|
||||||
@ -240,7 +272,29 @@ int platform_getconfig(enum config_data_e id, int instance,
|
|||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
|
|
||||||
#elif CONFIG_MIKROE_STM32F4_CONFIGDATA_ROM
|
#elif CONFIG_MIKROE_STM32F4_CONFIGDATA_PART
|
||||||
|
|
||||||
|
/* Try to open the /dev/config device file */
|
||||||
|
|
||||||
|
if ((fd = open("/dev/config", O_RDOK)) == -1)
|
||||||
|
{
|
||||||
|
/* Error opening the config device */
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Setup structure for the SETCONFIG ioctl */
|
||||||
|
|
||||||
|
config.id = (enum config_data_e)id;
|
||||||
|
config.instance = instance;
|
||||||
|
config.configdata = configdata;
|
||||||
|
config.len = datalen;
|
||||||
|
|
||||||
|
ret = ioctl(fd, CFGDIOC_GETCONFIG, (unsigned long) &config);
|
||||||
|
close(fd);
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
#elif CONFIG_MIKROE_STM32F4_CONFIGDATA_ROM
|
||||||
|
|
||||||
memcpy(configdata, touch_cal_data, datalen);
|
memcpy(configdata, touch_cal_data, datalen);
|
||||||
return OK;
|
return OK;
|
||||||
|
Loading…
Reference in New Issue
Block a user