aboutsummaryrefslogtreecommitdiffstats
path: root/os/ex
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2016-05-06 12:45:08 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2016-05-06 12:45:08 +0000
commitcca13e793a801428adc457909326c2545b79f2b6 (patch)
tree1ed481a570540d0d73bc05f43babbff6dab8eb24 /os/ex
parent5643920c58428d1e8eefda947773450f107e1f05 (diff)
downloadChibiOS-cca13e793a801428adc457909326c2545b79f2b6.tar.gz
ChibiOS-cca13e793a801428adc457909326c2545b79f2b6.tar.bz2
ChibiOS-cca13e793a801428adc457909326c2545b79f2b6.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9433 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/ex')
-rw-r--r--os/ex/Micron/n25q128.c84
-rw-r--r--os/ex/Micron/n25q128.h50
2 files changed, 126 insertions, 8 deletions
diff --git a/os/ex/Micron/n25q128.c b/os/ex/Micron/n25q128.c
index 5643336ad..53e54aecd 100644
--- a/os/ex/Micron/n25q128.c
+++ b/os/ex/Micron/n25q128.c
@@ -33,6 +33,27 @@
/* Driver local definitions. */
/*===========================================================================*/
+static const flash_descriptor_t *get_attributes(void *instance);
+static flash_error_t erase_all(void *instance);
+static flash_error_t erase_sectors(void *instance,
+ flash_sector_t sector,
+ flash_sector_t n);
+static flash_error_t are_sectors_erased(void *instance,
+ flash_sector_t sector,
+ flash_sector_t n);
+static flash_error_t program(void *instance, flash_address_t addr,
+ const uint8_t *pp, size_t n);
+static flash_error_t read(void *instance, flash_address_t addr,
+ uint8_t *rp, size_t n);
+
+/**
+ * @brief Virtual methods table.
+ */
+static const struct N25Q128DriverVMT n25q128_vmt = {
+ get_attributes, erase_all, erase_sectors, are_sectors_erased,
+ program, read
+};
+
/*===========================================================================*/
/* Driver exported variables. */
/*===========================================================================*/
@@ -45,6 +66,64 @@
/* Driver local functions. */
/*===========================================================================*/
+static const flash_descriptor_t *get_attributes(void *instance) {
+
+ (void)instance;
+
+ return FLASH_NO_ERROR;
+}
+
+static flash_error_t erase_all(void *instance) {
+
+ (void)instance;
+
+ return FLASH_NO_ERROR;
+}
+
+static flash_error_t erase_sectors(void *instance,
+ flash_sector_t sector,
+ flash_sector_t n) {
+
+ (void)instance;
+ (void)sector;
+ (void)n;
+
+ return FLASH_NO_ERROR;
+}
+
+static flash_error_t are_sectors_erased(void *instance,
+ flash_sector_t sector,
+ flash_sector_t n) {
+
+ (void)instance;
+ (void)sector;
+ (void)n;
+
+ return FLASH_NO_ERROR;
+}
+
+static flash_error_t program(void *instance, flash_address_t addr,
+ const uint8_t *pp, size_t n) {
+
+ (void)instance;
+ (void)addr;
+ (void)pp;
+ (void)n;
+
+ return FLASH_NO_ERROR;
+}
+
+static flash_error_t read(void *instance, flash_address_t addr,
+ uint8_t *rp, size_t n) {
+
+ (void)instance;
+ (void)addr;
+ (void)rp;
+ (void)n;
+
+ return FLASH_NO_ERROR;
+}
+
/*===========================================================================*/
/* Driver exported functions. */
/*===========================================================================*/
@@ -58,6 +137,8 @@
*/
void n15q128ObjectInit(N25Q128Driver *devp) {
+ devp->vmt_baseflash = &n25q128_vmt;
+ devp->config = NULL;
}
/**
@@ -70,6 +151,8 @@ void n15q128ObjectInit(N25Q128Driver *devp) {
*/
void n15q128Start(N25Q128Driver *devp, const N25Q128Config *config) {
+ (void)devp;
+ (void)config;
}
/**
@@ -81,6 +164,7 @@ void n15q128Start(N25Q128Driver *devp, const N25Q128Config *config) {
*/
void n15q128Stop(N25Q128Driver *devp) {
+ (void)devp;
}
/** @} */
diff --git a/os/ex/Micron/n25q128.h b/os/ex/Micron/n25q128.h
index 13e9ec3bf..e0f301a30 100644
--- a/os/ex/Micron/n25q128.h
+++ b/os/ex/Micron/n25q128.h
@@ -33,6 +33,40 @@
/* Driver constants. */
/*===========================================================================*/
+/**
+ * @name Command codes
+ * @{
+ */
+#define N25Q128_CMD_RESET_ENABLE 0x66
+#define N25Q128_CMD_RESET_MEMORY 0x99
+#define N25Q128_CMD_READ_ID 0x9E
+#define N25Q128_CMD_READ_DISCOVERY_PARAMETER 0x5A
+#define N25Q128_CMD_READ 0x03
+#define N25Q128_CMD_FAST_READ 0x08
+#define N25Q128_CMD_WRITE_ENABLE 0x06
+#define N25Q128_CMD_WRITE_DISABLE 0x04
+#define N25Q128_CMD_READ_STATUS_REGISTER 0x05
+#define N25Q128_CMD_WRITE_STATUS_REGISTER 0x01
+#define N25Q128_CMD_READ_LOCK_REGISTER 0xE8
+#define N25Q128_CMD_WRITE_LOCK_REGISTER 0xE5
+#define N25Q128_CMD_READ_FLAG_STATUS_REGISTER 0x70
+#define N25Q128_CMD_CLEAR_FLAG_STATUS_REGISTER 0x50
+#define N25Q128_CMD_READ_NV_CONFIGURATION_REGISTER 0xB5
+#define N25Q128_CMD_WRITE_NV_CONFIGURATION_REGISTER 0xB1
+#define N25Q128_CMD_READ_V_CONF_REGISTER 0x85
+#define N25Q128_CMD_WRITE_V_CONF_REGISTER 0x81
+#define N25Q128_CMD_READ_ENHANCED_V_CONF_REGISTER 0x65
+#define N25Q128_CMD_WRITE_ENHANCED_V_CONF_REGISTER 0x61
+#define N25Q128_CMD_PAGE_PROGRAM 0x02
+#define N25Q128_CMD_SUBSECTOR_ERASE 0x20
+#define N25Q128_CMD_SECTOR_ERASE 0xD8
+#define N25Q128_CMD_BULK_ERASE 0xC7
+#define N25Q128_CMD_PROGRAM_ERASE_RESUME 0x7A
+#define N25Q128_CMD_PROGRAM_ERASE_SUSPEND 0x75
+#define N25Q128_CMD_READ_OTP_ARRAY 0x4B
+#define N25Q128_CMD_PROGRAM_OTP_ARRAY 0x42
+/** @} */
+
/*===========================================================================*/
/* Driver pre-compile time settings. */
/*===========================================================================*/
@@ -96,12 +130,6 @@ typedef struct {
struct N25Q128DriverVMT {
_n25q128_methods
};
-
-/**
- * @brief @p N25Q128Driver specific data.
- */
-#define _n25q128_data \
- _base_flash_data
/**
* @extends BaseFlash
@@ -109,9 +137,15 @@ struct N25Q128DriverVMT {
* @brief Type of N25Q128 flash class.
*/
typedef struct {
- /** @brief BaseSensor Virtual Methods Table. */
+ /**
+ * @brief BaseFlash Virtual Methods Table.
+ */
const struct N25Q128DriverVMT *vmt_baseflash;
- _n25q128_data
+ _base_flash_data
+ /**
+ * @brief Current configuration data.
+ */
+ const N25Q128Config *config;
} N25Q128Driver;
/*===========================================================================*/