aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/lib/complex/serial_nor/hal_serial_nor.h
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2018-10-07 11:59:35 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2018-10-07 11:59:35 +0000
commitdc7ae21c744272f7796386c4a8ad68cb41278359 (patch)
tree88072dc161b3c10ac53816fe825ff3bd2b992c3e /os/hal/lib/complex/serial_nor/hal_serial_nor.h
parent40932b20589b66407578a84eb573dd0bfc5395cd (diff)
downloadChibiOS-dc7ae21c744272f7796386c4a8ad68cb41278359.tar.gz
ChibiOS-dc7ae21c744272f7796386c4a8ad68cb41278359.tar.bz2
ChibiOS-dc7ae21c744272f7796386c4a8ad68cb41278359.zip
Renamed for consistency.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12346 110e8d01-0319-4d1e-a829-52ad28d1bb01
Diffstat (limited to 'os/hal/lib/complex/serial_nor/hal_serial_nor.h')
-rw-r--r--os/hal/lib/complex/serial_nor/hal_serial_nor.h200
1 files changed, 200 insertions, 0 deletions
diff --git a/os/hal/lib/complex/serial_nor/hal_serial_nor.h b/os/hal/lib/complex/serial_nor/hal_serial_nor.h
new file mode 100644
index 000000000..6be8e8e0c
--- /dev/null
+++ b/os/hal/lib/complex/serial_nor/hal_serial_nor.h
@@ -0,0 +1,200 @@
+/*
+ ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/**
+ * @file serial_nor.h
+ * @brief Serial NOR driver header.
+ *
+ * @addtogroup SERIAL_NOR
+ * @ingroup SERIAL_NOR
+ * @{
+ */
+
+#ifndef HAL_SERIAL_NOR_H
+#define HAL_SERIAL_NOR_H
+
+#include "hal_flash.h"
+
+/*===========================================================================*/
+/* Driver constants. */
+/*===========================================================================*/
+
+/**
+ * @name Bus interface modes.
+ * @{
+ */
+#define SNOR_BUS_MODE_SPI 0U
+#define SNOR_BUS_MODE_WSPI1L 1U
+#define SNOR_BUS_MODE_WSPI2L 2U
+#define SNOR_BUS_MODE_WSPI4L 4U
+#define SNOR_BUS_MODE_WSPI8L 8U
+/** @} */
+
+#define SNOR_BUS_CMD_EXTENDED_ADDRESSING 0x80000000U
+
+/*===========================================================================*/
+/* Driver pre-compile time settings. */
+/*===========================================================================*/
+
+/**
+ * @name Configuration options
+ * @{
+ */
+/**
+ * @brief Physical transport interface.
+ */
+#if !defined(SNOR_BUS_MODE) || defined(__DOXYGEN__)
+#define SNOR_BUS_MODE SNOR_BUS_MODE_WSPI4L
+#endif
+
+/**
+ * @brief Shared bus switch.
+ * @details If set to @p TRUE the device acquires bus ownership
+ * on each transaction.
+ * @note Requires @p SPI_USE_MUTUAL_EXCLUSION or
+ * @p WSPI_USE_MUTUAL_EXCLUSION depending on mode selected
+ * with @p SNOR_BUS_MODE.
+ */
+#if !defined(SNOR_SHARED_BUS) || defined(__DOXYGEN__)
+#define SNOR_SHARED_BUS TRUE
+#endif
+/** @} */
+
+/*===========================================================================*/
+/* Derived constants and error checks. */
+/*===========================================================================*/
+
+#if (SNOR_BUS_MODE != SNOR_BUS_MODE_SPI) || defined(__DOXYGEN__)
+#define BUSConfig WSPIConfig
+#define BUSDriver WSPIDriver
+#else
+#define BUSConfig SPIConfig
+#define BUSDriver SPIDriver
+#endif
+
+/*===========================================================================*/
+/* Driver data structures and types. */
+/*===========================================================================*/
+
+/**
+ * @brief Type of a SNOR configuration structure.
+ */
+typedef struct {
+ BUSDriver *busp;
+ const BUSConfig *buscfg;
+} SNORConfig;
+
+/**
+ * @brief @p SNORDriver specific methods.
+ */
+#define _snor_flash_methods_alone \
+ /* Read SFDP.*/ \
+ flash_error_t (*read_sfdp)(void *instance, \
+ flash_offset_t offset, \
+ size_t n, \
+ uint8_t *rp);
+
+/**
+ * @brief @p SNORDriver specific methods with inherited ones.
+ */
+#define _snor_flash_methods \
+ _base_flash_methods \
+ _snor_flash_methods_alone
+
+/**
+ * @extends BaseFlashVMT
+ *
+ * @brief @p SNOR virtual methods table.
+ */
+struct SNORDriverVMT {
+ _snor_flash_methods
+};
+
+/**
+ * @extends BaseFlash
+ *
+ * @brief Type of SNOR flash class.
+ */
+typedef struct {
+ /**
+ * @brief SNORDriver Virtual Methods Table.
+ */
+ const struct SNORDriverVMT *vmt;
+ _base_flash_data
+ /**
+ * @brief Current configuration data.
+ */
+ const SNORConfig *config;
+ /**
+ * @brief Device ID and unique ID.
+ */
+ uint8_t device_id[20];
+} SNORDriver;
+
+/*===========================================================================*/
+/* Driver macros. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ void bus_cmd(BUSDriver *busp, uint32_t cmd);
+ void bus_cmd_send(BUSDriver *busp, uint32_t cmd, size_t n, const uint8_t *p);
+ void bus_cmd_receive(BUSDriver *busp,
+ uint32_t cmd,
+ size_t n,
+ uint8_t *p);
+ void bus_cmd_addr(BUSDriver *busp, uint32_t cmd, flash_offset_t offset);
+ void bus_cmd_addr_send(BUSDriver *busp,
+ uint32_t cmd,
+ flash_offset_t offset,
+ size_t n,
+ const uint8_t *p);
+ void bus_cmd_addr_receive(BUSDriver *busp,
+ uint32_t cmd,
+ flash_offset_t offset,
+ size_t n,
+ uint8_t *p);
+ void bus_cmd_addr_dummy_receive(BUSDriver *busp,
+ uint32_t cmd,
+ flash_offset_t offset,
+ uint32_t dummy,
+ size_t n,
+ uint8_t *p);
+ void snorObjectInit(SNORDriver *devp);
+ void snorStart(SNORDriver *devp, const SNORConfig *config);
+ void snorStop(SNORDriver *devp);
+#if (SNOR_BUS_MODE != SNOR_BUS_MODE_SPI) || defined(__DOXYGEN__)
+#if (WSPI_SUPPORTS_MEMMAP == TRUE) || defined(__DOXYGEN__)
+ void snorMemoryMap(SNORDriver *devp, uint8_t ** addrp);
+ void snorMemoryUnmap(SNORDriver *devp);
+#endif /* QSPI_SUPPORTS_MEMMAP == TRUE */
+#endif /* SNOR_BUS_MODE != SNOR_BUS_MODE_SPI */
+#ifdef __cplusplus
+}
+#endif
+
+/* Device-specific implementations.*/
+#include "hal_flash_device.h"
+
+#endif /* HAL_SERIAL_NOR_H */
+
+/** @} */
+