summaryrefslogtreecommitdiff
path: root/apps/platform
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2013-11-04 09:24:38 -0600
committerGregory Nutt <gnutt@nuttx.org>2013-11-04 09:24:38 -0600
commit3431328cc6cc0e34d0f746b096cf5ee1bf49643f (patch)
tree5cec1ff9d768de312d00081e7f88d0eff3968ff2 /apps/platform
parente04b26bc4dc97a2bf115d15cb7e200dd1c10e468 (diff)
downloadnuttx-3431328cc6cc0e34d0f746b096cf5ee1bf49643f.tar.gz
nuttx-3431328cc6cc0e34d0f746b096cf5ee1bf49643f.tar.bz2
nuttx-3431328cc6cc0e34d0f746b096cf5ee1bf49643f.zip
apps/platform/mikroe-stm32f4 updated to use new MTD configuratino driver features
Diffstat (limited to 'apps/platform')
-rw-r--r--apps/platform/mikroe-stm32f4/mikroe_configdata.c102
1 files changed, 54 insertions, 48 deletions
diff --git a/apps/platform/mikroe-stm32f4/mikroe_configdata.c b/apps/platform/mikroe-stm32f4/mikroe_configdata.c
index 957bc0985..91c444175 100644
--- a/apps/platform/mikroe-stm32f4/mikroe_configdata.c
+++ b/apps/platform/mikroe-stm32f4/mikroe_configdata.c
@@ -1,7 +1,7 @@
/************************************************************************************
* apps/platform/mikroe-stm32f4/mikroe_configdata.c
*
- * Copyright (C) 2012-2013 Ken Pettit. All rights reserved.
+ * Copyright (C) 2013 Ken Pettit. All rights reserved.
* Author: Ken Pettit <pettitkd@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
@@ -44,6 +44,7 @@
#include <assert.h>
#include <errno.h>
#include <debug.h>
+#include <sys/ioctl.h>
#include <apps/platform/configdata.h>
#include <nuttx/fs/ioctl.h>
@@ -114,7 +115,28 @@ int platform_setconfig(enum config_data_e id, int instance,
struct config_data_s config;
int ret;
int fd;
-#endif
+
+ /* 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;
+
+#else /* CONFIG_MIKROE_STM32F4_CONFIGDATA_PART */
switch (id)
{
@@ -144,28 +166,6 @@ int platform_setconfig(enum config_data_e id, int instance,
fclose(fd);
return OK;
-#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 = (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. */
@@ -174,14 +174,17 @@ int platform_setconfig(enum config_data_e id, int instance,
#else
break;
-#endif
+#endif /* CONFIG_MIKROE_STM32F4_CONFIGDATA_ROM */
default:
break;
}
+
set_errno(ENOSYS);
return -1;
+
+#endif /* CONFIG_MIKROE_STM32F4_CONFIGDATA_PART */
}
/****************************************************************************
@@ -231,7 +234,28 @@ int platform_getconfig(enum config_data_e id, int instance,
struct config_data_s config;
int ret;
int fd;
-#endif
+
+ /* 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;
+
+#else /* CONFIG_MIKROE_STM32F4_CONFIGDATA_PART */
switch (id)
{
@@ -244,6 +268,7 @@ int platform_getconfig(enum config_data_e id, int instance,
if ((fd = fopen(CONFIG_MIKROE_STM32F4_CONFIGDATA_FILENAME, "r")) == NULL)
{
/* Error opening the file */
+
set_errno(ENOENT);
return -1;
}
@@ -258,6 +283,7 @@ int platform_getconfig(enum config_data_e id, int instance,
if (bytes != sizeof(saved_id) + sizeof(saved_instance) + datalen)
{
/* Error! Not enough data in the file */
+
set_errno(EINVAL);
fclose(fd);
return -1;
@@ -272,28 +298,6 @@ int platform_getconfig(enum config_data_e id, int instance,
return OK;
-#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);
@@ -309,6 +313,8 @@ int platform_getconfig(enum config_data_e id, int instance,
set_errno(ENOSYS);
return -1;
+
+#endif /* CONFIG_MIKROE_STM32F4_CONFIGDATA_PART */
}
#endif /* CONFIG_PLATFORM_CONFIGDATA */