1 /* -----------------------------------------------------------------------------
2 * Copyright (c) 2013-2014 ARM Limited. All rights reserved.
4 * $Date: 2. January 2014
7 * Project: NAND Flash Driver API
8 * -------------------------------------------------------------------------- */
12 \defgroup nand_interface_gr NAND Interface
13 \brief Driver API for NAND Flash Device Interface (%Driver_NAND.h).
16 <b>NAND</b> devices are a type of non-volatile storage and do not require power to hold data.
17 Wikipedia offers more information about
18 the <a href="http://en.wikipedia.org/wiki/Flash_memory#ARM_NAND_memories" target="_blank"><b>Flash Memories</b></a>, including NAND.
23 \image html NAND_Schematics.png "Simplified NAND Flash Schematic"
29 The following header files define the Application Programming Interface (API) for the NAND interface:
30 - \b %Driver_NAND.h : Driver API for NAND Flash Device Interface
32 The driver implementation is a typical part of the Device Family Pack (DFP) that supports the
33 peripherals of the microcontroller family.
38 The driver functions are published in the access struct as explained in \ref DriverFunctions
39 - \ref ARM_DRIVER_NAND : access struct for NAND driver functions
44 \todo provide details for the driver implementation text above
46 A typical setup sequence for the driver is shown below:
51 *******************************************************************************************************************/
55 \defgroup nand_execution_status Status Error Codes
56 \ingroup common_drv_gr
57 \brief Negative values indicate errors (NAND has specific codes in addition to common \ref execution_status).
59 The NAND driver has additional status error codes that are listed below.
60 Note that the NAND driver also returns the common \ref execution_status.
63 \def ARM_NAND_ERROR_ECC
64 ECC generation or correction failed during \ref ARM_NAND_ReadData, \ref ARM_NAND_WriteData or \ref ARM_NAND_ExecuteSequence.
70 \defgroup NAND_events NAND Events
71 \ingroup nand_interface_gr
72 \brief The NAND driver generates call back events that are notified via the function \ref ARM_NAND_SignalEvent.
74 This section provides the event values for the \ref ARM_NAND_SignalEvent callback function.
76 The following call back notification events are generated:
78 \def ARM_NAND_EVENT_DEVICE_READY
79 \def ARM_NAND_EVENT_DRIVER_READY
80 \def ARM_NAND_EVENT_DRIVER_DONE
81 \def ARM_NAND_EVENT_ECC_ERROR
87 \defgroup nand_driver_flag_codes NAND Flags
88 \ingroup nand_interface_gr
89 \brief Specify Flag codes.
91 The defines can be used in the function \ref ARM_NAND_ReadData and \ref ARM_NAND_WriteData for the parameter \em mode
92 and in the function \ref ARM_NAND_ExecuteSequence for the parameter \em code.
94 \def ARM_NAND_DRIVER_DONE_EVENT
100 \defgroup nand_control_gr NAND Control Codes
101 \ingroup nand_interface_gr
102 \brief Many parameters of the NAND driver are configured using the \ref ARM_NAND_Control function.
105 Refer to the function \ref ARM_NAND_Control for further details.
109 \defgroup nand_control_codes NAND Mode Controls
110 \ingroup nand_control_gr
111 \brief Specify operation modes of the NAND interface.
113 These controls can be used in the function \ref ARM_NAND_Control for the parameter \em control.
115 \def ARM_NAND_BUS_MODE
116 \def ARM_NAND_BUS_DATA_WIDTH
117 \def ARM_NAND_DRIVER_STRENGTH
118 \def ARM_NAND_DEVICE_READY_EVENT
119 \def ARM_NAND_DRIVER_READY_EVENT
124 \defgroup nand_bus_mode_codes NAND Bus Modes
125 \ingroup nand_control_gr
126 \brief Specify bus mode of the NAND interface.
128 The defines can be used in the function \ref ARM_NAND_Control for the parameter \em arg and with the \ref ARM_NAND_BUS_MODE as the \em control code.
130 \def ARM_NAND_BUS_SDR
131 \def ARM_NAND_BUS_DDR
132 \def ARM_NAND_BUS_DDR2
133 \def ARM_NAND_BUS_TIMING_MODE_0
134 \def ARM_NAND_BUS_TIMING_MODE_1
135 \def ARM_NAND_BUS_TIMING_MODE_2
136 \def ARM_NAND_BUS_TIMING_MODE_3
137 \def ARM_NAND_BUS_TIMING_MODE_4
138 \def ARM_NAND_BUS_TIMING_MODE_5
139 \def ARM_NAND_BUS_TIMING_MODE_6
140 \def ARM_NAND_BUS_TIMING_MODE_7
141 \def ARM_NAND_BUS_DDR2_DO_WCYC_0
142 \def ARM_NAND_BUS_DDR2_DO_WCYC_1
143 \def ARM_NAND_BUS_DDR2_DO_WCYC_2
144 \def ARM_NAND_BUS_DDR2_DO_WCYC_4
145 \def ARM_NAND_BUS_DDR2_DI_WCYC_0
146 \def ARM_NAND_BUS_DDR2_DI_WCYC_1
147 \def ARM_NAND_BUS_DDR2_DI_WCYC_2
148 \def ARM_NAND_BUS_DDR2_DI_WCYC_4
149 \def ARM_NAND_BUS_DDR2_VEN
150 \def ARM_NAND_BUS_DDR2_CMPD
151 \def ARM_NAND_BUS_DDR2_CMPR
156 \defgroup nand_data_bus_width_codes NAND Data Bus Width
157 \ingroup nand_control_gr
158 \brief Specify data bus width of the NAND interface.
160 The defines can be used in the function \ref ARM_NAND_Control for the parameter \em arg and with the \ref ARM_NAND_BUS_DATA_WIDTH as the \em control code.
162 \def ARM_NAND_BUS_DATA_WIDTH_8
163 \def ARM_NAND_BUS_DATA_WIDTH_16
168 \defgroup nand_driver_strength_codes NAND Driver Strength
169 \ingroup nand_control_gr
170 \brief Specify driver strength of the NAND interface.
172 The defines can be used in the function \ref ARM_NAND_Control for the parameter \em arg and with the \ref ARM_NAND_DRIVER_STRENGTH as the \em control code.
174 \def ARM_NAND_DRIVER_STRENGTH_18
175 \def ARM_NAND_DRIVER_STRENGTH_25
176 \def ARM_NAND_DRIVER_STRENGTH_35
177 \def ARM_NAND_DRIVER_STRENGTH_50
187 \defgroup nand_driver_ecc_codes NAND ECC Codes
188 \ingroup nand_interface_gr
189 \brief Specify ECC codes.
191 The defines can be used in the function \ref ARM_NAND_ReadData and \ref ARM_NAND_WriteData for the parameter \em mode
192 and in the function \ref ARM_NAND_ExecuteSequence for the parameter \em code.
202 \defgroup nand_driver_seq_exec_codes NAND Sequence Execution Codes
203 \ingroup nand_interface_gr
204 \brief Specify execution codes
206 The defines can be used in the function \ref ARM_NAND_ExecuteSequence for the parameter \em code.
208 \def ARM_NAND_CODE_SEND_CMD1
209 \def ARM_NAND_CODE_SEND_ADDR_COL1
210 \def ARM_NAND_CODE_SEND_ADDR_COL2
211 \def ARM_NAND_CODE_SEND_ADDR_ROW1
212 \def ARM_NAND_CODE_SEND_ADDR_ROW2
213 \def ARM_NAND_CODE_SEND_ADDR_ROW3
214 \def ARM_NAND_CODE_INC_ADDR_ROW
215 \def ARM_NAND_CODE_WRITE_DATA
216 \def ARM_NAND_CODE_SEND_CMD2
217 \def ARM_NAND_CODE_WAIT_BUSY
218 \def ARM_NAND_CODE_READ_DATA
219 \def ARM_NAND_CODE_SEND_CMD3
220 \def ARM_NAND_CODE_READ_STATUS
225 /*------------ Structures --------------------------------------------------------------------------------------*/
227 \struct ARM_NAND_STATUS
229 Structure with information about the status of a NAND. The data fields encode flags for the driver.
232 - \ref ARM_NAND_GetStatus
233 *****************************************************************************************************************/
236 \struct ARM_DRIVER_NAND
238 The functions of the NAND driver are accessed by function pointers exposed by this structure. Refer to \ref DriverFunctions for overview information.
240 Each instance of a NAND interface provides such an access structure.
241 The instance is identified by a postfix number in the symbol name of the access structure, for example:
242 - \b Driver_NAND0 is the name of the access struct of the first instance (no. 0).
243 - \b Driver_NAND1 is the name of the access struct of the second instance (no. 1).
245 A middleware configuration setting allows connecting the middleware to a specific driver instance <b>Driver_NAND<i>n</i></b>.
246 The default is \token{0}, which connects a middleware to the first instance of a driver.
247 *******************************************************************************************************************/
250 \struct ARM_NAND_CAPABILITIES
252 A NAND driver can be implemented with different capabilities. The data fields of this struct encode
253 the capabilities implemented by this driver.
256 - \ref ARM_NAND_GetCapabilities
257 *******************************************************************************************************************/
261 \typedef ARM_NAND_SignalEvent_t
263 Provides the typedef for the callback function \ref ARM_NAND_SignalEvent.
265 <b>Parameter for:</b>
266 - \ref ARM_NAND_Initialize
267 *******************************************************************************************************************/
271 \struct ARM_NAND_ECC_INFO
273 Structure with information about the Error Correction Code for a NAND.
275 <b>Parameter for:</b>
276 - \ref ARM_NAND_InquireECC
277 *****************************************************************************************************************/
284 ARM_DRIVER_VERSION ARM_NAND_GetVersion (void) {
288 \fn ARM_DRIVER_VERSION ARM_NAND_GetVersion (void)
290 The function \b ARM_NAND_GetVersion returns version information of the driver implementation in \ref ARM_DRIVER_VERSION
291 - API version is the version of the CMSIS-Driver specification used to implement this driver.
292 - Driver version is source code version of the actual driver implementation.
296 extern ARM_DRIVER_NAND Driver_NAND0;
297 ARM_DRIVER_NAND *drv_info;
299 void setup_nand (void) {
300 ARM_DRIVER_VERSION version;
302 drv_info = &Driver_NAND0;
303 version = drv_info->GetVersion ();
304 if (version.api < 0x10A) { // requires at minimum API version 1.10 or higher
310 *******************************************************************************************************************/
312 ARM_NAND_CAPABILITIES ARM_NAND_GetCapabilities (void) {
316 \fn ARM_NAND_CAPABILITIES ARM_NAND_GetCapabilities (void)
318 The function \b ARM_NAND_GetCapabilities retrieves information about capabilities in this driver implementation.
319 The data fields of the structure \ref ARM_NAND_CAPABILITIES encode various capabilities, for example
320 if a hardware is able to create signal events using the \ref ARM_NAND_SignalEvent
325 extern ARM_DRIVER_NAND Driver_NAND0;
326 ARM_DRIVER_NAND *drv_info;
328 void read_capabilities (void) {
329 ARM_NAND_CAPABILITIES drv_capabilities;
331 drv_info = &Driver_NAND0;
332 drv_capabilities = drv_info->GetCapabilities ();
333 // interrogate capabilities
337 *******************************************************************************************************************/
339 int32_t ARM_NAND_Initialize (ARM_NAND_SignalEvent_t cb_event) {
343 \fn int32_t ARM_NAND_Initialize (ARM_NAND_SignalEvent_t cb_event)
345 The function \b ARM_NAND_Initialize initializes the NAND interface.
346 It is called when the middleware component starts operation.
348 The function performs the following operations:
349 - Initializes the resources needed for the NAND interface.
350 - Registers the \ref ARM_NAND_SignalEvent callback function.
352 The parameter \em cb_event is a pointer to the \ref ARM_NAND_SignalEvent callback function; use a NULL pointer
353 when no callback signals are required.
356 - see \ref nand_interface_gr - Driver Functions
358 *******************************************************************************************************************/
360 int32_t ARM_NAND_Uninitialize (void) {
364 \fn int32_t ARM_NAND_Uninitialize (void)
366 The function \b ARM_NAND_Uninitialize de-initializes the resources of NAND interface.
368 It is called when the middleware component stops operation and releases the software resources used by the interface.
369 *******************************************************************************************************************/
371 int32_t ARM_NAND_PowerControl (ARM_POWER_STATE state) {
375 \fn int32_t ARM_NAND_PowerControl (ARM_POWER_STATE state)
377 The function \b ARM_NAND_PowerControl controls the power modes of the NAND interface.
379 The parameter \em state sets the operation and can have the following values:
380 - \ref ARM_POWER_FULL : set-up peripheral for data transfers, enable interrupts (NVIC) and optionally DMA.
381 Can be called multiple times. If the peripheral is already in this mode the function performs
382 no operation and returns with \ref ARM_DRIVER_OK.
383 - \ref ARM_POWER_LOW : may use power saving. Returns \ref ARM_DRIVER_ERROR_UNSUPPORTED when not implemented.
384 - \ref ARM_POWER_OFF : terminates any pending data transfers, disables peripheral, disables related interrupts and DMA.
386 Refer to \ref CallSequence for more information.
387 *******************************************************************************************************************/
390 int32_t ARM_NAND_DevicePower (uint32_t voltage) {
394 \fn int32_t ARM_NAND_DevicePower (uint32_t voltage)
396 The function \b ARM_NAND_DevicePower controls the power supply of the NAND device.
398 The parameter \em voltage sets the device supply voltage as defined in the table.
400 \b AMR_NAND_POWER_xxx_xxx specifies power settings.
402 Device Power Bits | Description
403 :--------------------------------|:--------------------------------------------
404 \ref ARM_NAND_POWER_VCC_OFF | Set VCC Power off
405 \ref ARM_NAND_POWER_VCC_3V3 | Set VCC = 3.3V
406 \ref ARM_NAND_POWER_VCC_1V8 | Set VCC = 1.8V
407 \ref ARM_NAND_POWER_VCCQ_OFF | Set VCCQ I/O Power off
408 \ref ARM_NAND_POWER_VCCQ_3V3 | Set VCCQ = 3.3V
409 \ref ARM_NAND_POWER_VCCQ_1V8 | Set VCCQ = 1.8V
410 \ref ARM_NAND_POWER_VPP_OFF | Set VPP off
411 \ref ARM_NAND_POWER_VPP_ON | Set VPP on
413 *******************************************************************************************************************/
415 int32_t ARM_NAND_WriteProtect (uint32_t dev_num, bool enable) {
419 \fn int32_t ARM_NAND_WriteProtect (uint32_t dev_num, bool enable)
421 The function \b ARM_NAND_WriteProtect controls the Write Protect (WPn) pin of a NAND device.
423 The parameter \em dev_num is the device number. \n
424 The parameter \em enable specifies whether to enable or disable write protection.
425 *******************************************************************************************************************/
427 int32_t ARM_NAND_ChipEnable (uint32_t dev_num, bool enable) {
431 \fn int32_t ARM_NAND_ChipEnable (uint32_t dev_num, bool enable)
433 The function \b ARM_NAND_ChipEnable control the Chip Enable (CEn) pin of a NAND device.
435 The parameter \em dev_num is the device number. \n
436 The parameter \em enable specifies whether to enable or disable the device.
438 This function is optional and supported only when the data field \em ce_manual = \token{1} in the structure \ref ARM_NAND_CAPABILITIES.
439 Otherwise, the Chip Enable (CEn) signal is controlled automatically by SendCommand/Address, Read/WriteData and ExecuteSequence
440 (for example when the NAND device is connected to a memory bus).
441 *******************************************************************************************************************/
443 int32_t ARM_NAND_GetDeviceBusy (uint32_t dev_num) {
447 \fn int32_t ARM_NAND_GetDeviceBusy (uint32_t dev_num)
449 The function \b ARM_NAND_GetDeviceBusy returns the status of the Device Busy pin: [\token{1=busy; 0=not busy or error}].
451 The parameter \em dev_num is the device number.
452 *******************************************************************************************************************/
454 int32_t ARM_NAND_SendCommand (uint32_t dev_num, uint8_t cmd) {
458 \fn int32_t ARM_NAND_SendCommand (uint32_t dev_num, uint8_t cmd)
460 The function \b ARM_NAND_SendCommand sends a command to the NAND device.
462 The parameter \em dev_num is the device number. \n
463 The parameter \em cmd is the command sent to the NAND device.
464 *******************************************************************************************************************/
466 int32_t ARM_NAND_SendAddress (uint32_t dev_num, uint8_t addr) {
470 \fn int32_t ARM_NAND_SendAddress (uint32_t dev_num, uint8_t addr)
472 Send an address to the NAND device.
473 The parameter \em dev_num is the device number.
474 The parameter \em addr is the address.
475 *******************************************************************************************************************/
477 int32_t ARM_NAND_ReadData (uint32_t dev_num, void *data, uint32_t cnt, uint32_t mode) {
481 \fn int32_t ARM_NAND_ReadData (uint32_t dev_num, void *data, uint32_t cnt, uint32_t mode)
483 The function \b ARM_NAND_ReadData reads data from a NAND device.
485 The parameter \em dev_num is the device number. \n
486 The parameter \em data is a pointer to the buffer that stores the data read from a NAND device. \n
487 The parameter \em cnt is the number of data items to read. \n
488 The parameter \em mode defines the operation mode as listed in the table below.
490 Read Data Mode | Description
491 :----------------------------------|:--------------------------------------------
492 \ref ARM_NAND_ECC(n) | Select ECC
493 \ref ARM_NAND_ECC0 | Use ECC0 of selected ECC
494 \ref ARM_NAND_ECC1 | Use ECC1 of selected ECC
495 \ref ARM_NAND_DRIVER_DONE_EVENT | Generate \ref ARM_NAND_EVENT_DRIVER_DONE
497 The data item size is defined by the data type, which depends on the configured data bus width.
500 - \em uint8_t for 8-bit data bus
501 - \em uint16_t for 16-bit data bus
503 The function executes in the following ways:
504 - When the operation is blocking (typical for devices connected to memory bus when not using DMA),
505 then the function returns after all data is read and returns the number of data items read.
506 - When the operation is non-blocking (typical for NAND controllers), then the function only starts the operation and returns with zero number of data items read.
507 After the operation is completed, the \ref ARM_NAND_EVENT_DRIVER_DONE event is generated (if enabled by \b ARM_NAND_DRIVER_DONE_EVENT).
508 Progress of the operation can also be monitored by calling the \ref ARM_NAND_GetStatus function and checking the \em busy data field.
509 Operation is automatically aborted if ECC is used and ECC correction fails, which generates the \ref ARM_NAND_EVENT_ECC_ERROR event
510 (together with \ref ARM_NAND_DRIVER_DONE_EVENT if enabled).
512 *******************************************************************************************************************/
514 int32_t ARM_NAND_WriteData (uint32_t dev_num, const void *data, uint32_t cnt, uint32_t mode) {
518 \fn int32_t ARM_NAND_WriteData (uint32_t dev_num, const void *data, uint32_t cnt, uint32_t mode)
520 The function \b ARM_NAND_WriteData writes data to a NAND device.
522 The parameter \em dev_num is the device number. \n
523 The parameter \em data is a pointer to the buffer with data to write. \n
524 The parameter \em cnt is the number of data items to write. \n
525 The parameter \em mode defines the operation mode as listed in the table below.
527 Write Data Mode | Description
528 :----------------------------------|:--------------------------------------------
529 \ref ARM_NAND_ECC(n) | Select ECC
530 \ref ARM_NAND_ECC0 | Use ECC0 of selected ECC
531 \ref ARM_NAND_ECC1 | Use ECC1 of selected ECC
532 \ref ARM_NAND_DRIVER_DONE_EVENT | Generate \ref ARM_NAND_EVENT_DRIVER_DONE
534 The data item size is defined by the data type, which depends on the configured data bus width.
537 - \em uint8_t for 8-bit data bus
538 - \em uint16_t for 16-bit data bus
540 The function executes in the following ways:
541 - When the operation is blocking (typical for devices connected to memory bus when not using DMA),
542 then the function returns after all data is written and returns the number of data items written.
543 - When the operation is non-blocking (typical for NAND controllers), then the function only starts the operation
544 and returns with zero number of data items written. After the operation is completed,
545 the \ref ARM_NAND_EVENT_DRIVER_DONE event is generated (if enabled by \b ARM_NAND_DRIVER_DONE_EVENT).
546 Progress of the operation can also be monitored by calling the \ref ARM_NAND_GetStatus function and checking the \em busy data field.
547 Operation is automatically aborted if ECC is used and ECC generation fails,
548 which generates the \ref ARM_NAND_EVENT_ECC_ERROR event (together with \ref ARM_NAND_DRIVER_DONE_EVENT if enabled).
549 *******************************************************************************************************************/
551 int32_t ARM_NAND_ExecuteSequence (uint32_t dev_num, uint32_t code, uint32_t cmd,
552 uint32_t addr_col, uint32_t addr_row,
553 void *data, uint32_t data_cnt,
554 uint8_t *status, uint32_t *count) {
558 \fn int32_t ARM_NAND_ExecuteSequence (uint32_t dev_num, uint32_t code, uint32_t cmd, uint32_t addr_col, uint32_t addr_row, void *data, uint32_t data_cnt, uint8_t *status, uint32_t *count)
560 The function \b ARM_NAND_ExecuteSequence executes a sequence of operations for a NAND device.
562 The parameter \em dev_num is the device number. \n
563 The parameter \em code is the sequence encoding as defined in the table <b>Sequence execution Code</b>. \n
564 The parameter \em cmd is the command or a series of commands. \n
565 The parameter \em addr_col is the column address. \n
566 The parameter \em addr_row is the row address. \n
567 The parameter \em data is a pointer to the buffer that stores the data to or loads the data from. \n
568 The parameter \em data_cnt is the number of data items to read or write in one iteration. \n
569 The parameter \em status is a pointer to the buffer that stores the status read. \n
570 The parameter \em count is a pointer to the number of iterations. \n
572 \b ARM_NAND_CODE_xxx specifies sequence execution codes.
574 Sequence Execution Code | Description
575 :----------------------------------|:--------------------------------------------
576 \ref ARM_NAND_CODE_SEND_CMD1 | Send Command 1 (cmd[7..0])
577 \ref ARM_NAND_CODE_SEND_ADDR_COL1 | Send Column Address 1 (addr_col[7..0])
578 \ref ARM_NAND_CODE_SEND_ADDR_COL2 | Send Column Address 2 (addr_col[15..8])
579 \ref ARM_NAND_CODE_SEND_ADDR_ROW1 | Send Row Address 1 (addr_row[7..0])
580 \ref ARM_NAND_CODE_SEND_ADDR_ROW2 | Send Row Address 2 (addr_row[15..8])
581 \ref ARM_NAND_CODE_SEND_ADDR_ROW3 | Send Row Address 3 (addr_row[23..16])
582 \ref ARM_NAND_CODE_INC_ADDR_ROW | Auto-increment Row Address
583 \ref ARM_NAND_CODE_WRITE_DATA | Write Data
584 \ref ARM_NAND_CODE_SEND_CMD2 | Send Command 2 (cmd[15..8])
585 \ref ARM_NAND_CODE_WAIT_BUSY | Wait while R/Bn busy
586 \ref ARM_NAND_CODE_READ_DATA | Read Data
587 \ref ARM_NAND_CODE_SEND_CMD3 | Send Command 3 (cmd[23..16])
588 \ref ARM_NAND_CODE_READ_STATUS | Read Status byte and check FAIL bit (bit 0)
589 \ref ARM_NAND_ECC(n) | Select ECC
590 \ref ARM_NAND_ECC0 | Use ECC0 of selected ECC
591 \ref ARM_NAND_ECC1 | Use ECC1 of selected ECC
592 \ref ARM_NAND_DRIVER_DONE_EVENT | Generate \ref ARM_NAND_EVENT_DRIVER_DONE
594 The data item size is defined by the data type, which depends on the configured data bus width.
597 - \em uint8_t for 8-bit data bus
598 - \em uint16_t for 16-bit data bus
600 The function is non-blocking and returns as soon as the driver has started executing the specified sequence.
601 When the operation is completed, the \ref ARM_NAND_EVENT_DRIVER_DONE event is generated (if enabled by \b ARM_NAND_DRIVER_DONE_EVENT).
602 Progress of the operation can also be monitored by calling the \ref ARM_NAND_GetStatus function and checking the \em busy data field.
604 Driver executes the number of specified iterations where in each iteration
605 items specified by \b ARM_NAND_CODE_xxx are executed in the order as listed in the table <b>Sequence execution Code</b>.
606 The parameter \em count is holding the current number of iterations left.
608 Execution is automatically aborted and \ref ARM_NAND_EVENT_DRIVER_DONE event is generated (if enabled by \b ARM_NAND_DRIVER_DONE_EVENT):
609 - if Read Status is enabled and the FAIL bit (bit 0) is set
610 - if ECC is used and ECC fails (also sets \ref ARM_NAND_EVENT_ECC_ERROR event)
613 \ref ARM_NAND_CODE_WAIT_BUSY can only be specified if the Device Ready event can be generated (reported by \em event_device_ready in \ref ARM_NAND_CAPABILITIES).
614 The event \ref ARM_NAND_EVENT_DEVICE_READY is not generated during sequence execution but rather used internally by the driver.
615 *******************************************************************************************************************/
617 int32_t ARM_NAND_AbortSequence (uint32_t dev_num) {
621 \fn int32_t ARM_NAND_AbortSequence (uint32_t dev_num)
623 The function \b ARM_NAND_AbortSequence aborts execution of the current sequence for a NAND device.
625 The parameter \em dev_num is the device number.
626 *******************************************************************************************************************/
628 int32_t ARM_NAND_Control (uint32_t dev_num, uint32_t control, uint32_t arg) {
632 \fn int32_t ARM_NAND_Control (uint32_t dev_num, uint32_t control, uint32_t arg)
634 The function \b ARM_NAND_Control controls the NAND interface and executes operations.
636 The parameter \em dev_num is the device number. \n
637 The parameter \em control specifies the operation. \n
638 The parameter \em arg provides (depending on the \em control) additional information or sets values.
640 The table lists the operations for the parameter \em control.
642 Parameter \em control | Operation
643 :--------------------------------|:--------------------------------------------
644 \ref ARM_NAND_BUS_MODE | Set the bus mode. The parameter \em arg sets the \ref bus_mode_tab "\b Bus Mode".
645 \ref ARM_NAND_BUS_DATA_WIDTH | Set the data bus width. The parameter \em arg sets the \ref bus_data_width_tab "\b Bus Data Width".
646 \ref ARM_NAND_DRIVER_STRENGTH | Set the driver strength. The parameter \em arg sets the \ref driver_strength_tab "\b Driver Strength".
647 \ref ARM_NAND_DRIVER_READY_EVENT | Control generation of callback event \ref ARM_NAND_EVENT_DRIVER_READY. Enable: \em arg = \token{1}. Disable: \em arg = \token{0}.
648 \ref ARM_NAND_DEVICE_READY_EVENT | Control generation of callback event \ref ARM_NAND_EVENT_DEVICE_READY; Enable: \em arg = \token{1}. Disable: \em arg = \token{0}.
651 - \ref ARM_NAND_GetCapabilities returns information about supported operations, which are stored in the structure \ref ARM_NAND_CAPABILITIES.
652 - \ref ARM_NAND_SignalEvent provides information about the callback events \ref ARM_NAND_EVENT_DRIVER_READY and \ref ARM_NAND_EVENT_DEVICE_READY
654 The table lists values for the parameter \em arg used with the \em control operation \ref ARM_NAND_BUS_MODE, \ref ARM_NAND_BUS_DATA_WIDTH, and
655 \ref ARM_NAND_DRIVER_STRENGTH. Values from different categories can be ORed.
658 <table class="cmtable" summary="">
659 <tr><th> Parameter \em arg <br> for <i>control</i> = \ref ARM_NAND_BUS_MODE </th>
662 <th> Description </th>
663 <th width="30%"> Supported when \ref ARM_NAND_CAPABILITIES </th></tr>
664 <tr><td> \ref ARM_NAND_BUS_TIMING_MODE_0 (default) </td>
665 <td rowspan="8" style="text-align:right"> 0..3 </td>
666 <td rowspan="8"> \anchor bus_timing_tab Bus Timing Mode </td>
668 <td rowspan="8"> The maximum timing mode that can be applied to a specific \ref bus_data_interface_tab "\b Bus Data Interface"
669 is stored in the data fields: <br><br>
670 <i>sdr_timing_mode</i> - for SDR <br>
671 <i>ddr_timing_mode</i> - for NV-DDR <br>
672 <i>ddr2_timing_mode</i> - for NV_DDR2 </td></tr>
673 <tr><td> \ref ARM_NAND_BUS_TIMING_MODE_1 </td><td> \token{1} </td></tr>
674 <tr><td> \ref ARM_NAND_BUS_TIMING_MODE_2 </td><td> \token{2} </td></tr>
675 <tr><td> \ref ARM_NAND_BUS_TIMING_MODE_3 </td><td> \token{3} </td></tr>
676 <tr><td> \ref ARM_NAND_BUS_TIMING_MODE_4 </td><td> \token{4} (SDR EDO capable) </td></tr>
677 <tr><td> \ref ARM_NAND_BUS_TIMING_MODE_5 </td><td> \token{5} (SDR EDO capable) </td></tr>
678 <tr><td> \ref ARM_NAND_BUS_TIMING_MODE_6 </td><td> \token{6} (NV-DDR2 only) </td></tr>
679 <tr><td> \ref ARM_NAND_BUS_TIMING_MODE_7 </td><td> \token{7} (NV-DDR2 only) </td></tr>
680 <tr><td> \ref ARM_NAND_BUS_SDR (default) \anchor bus_data_interface_tab </td>
681 <td rowspan="3" style="text-align:right"> 4..7 </td>
682 <td rowspan="3"> Bus Data Interface </td>
683 <td> SDR (Single Data Rate) - Traditional interface </td>
684 <td> <i>always supported</i> </td></tr>
685 <tr><td> \ref ARM_NAND_BUS_DDR </td><td> NV-DDR (Double Data Rate) </td><td> data field <i>ddr</i> = \token{1} </td></tr>
686 <tr><td> \ref ARM_NAND_BUS_DDR2 </td><td> NV-DDR2 (Double Data Rate) </td><td> data field <i>ddr2</i> = \token{1} </td></tr>
687 <tr><td style="white-space: nowrap"> \ref ARM_NAND_BUS_DDR2_DO_WCYC_0 (default) </td>
688 <td rowspan="4" style="text-align:right"> 8..11 </td>
689 <td rowspan="4" style="white-space: nowrap"> Data Output Warm-up \anchor bus_output_tab </td>
690 <td> Set the DDR2 Data Output Warm-up to \token{0} cycles </td>
691 <td rowspan="4"> <b>Data Output Warm-up</b> cycles are dummy cycles for interface calibration with no incremental data transfer
692 and apply to NV-DDR2 of the \ref bus_data_interface_tab "\b Bus Data Interface".
694 <tr><td> \ref ARM_NAND_BUS_DDR2_DO_WCYC_1 </td><td> Set the DDR2 Data Output Warm-up to \token{1} cycles </td></tr>
695 <tr><td> \ref ARM_NAND_BUS_DDR2_DO_WCYC_2 </td><td> Set the DDR2 Data Output Warm-up to \token{2} cycles </td></tr>
696 <tr><td> \ref ARM_NAND_BUS_DDR2_DO_WCYC_4 </td><td> Set the DDR2 Data Output Warm-up to \token{4} cycles </td></tr>
697 <tr><td style="white-space: nowrap"> \ref ARM_NAND_BUS_DDR2_DI_WCYC_0 (default) \anchor bus_input_tab</td>
698 <td rowspan="4" style="text-align:right"> 12..15 </td>
699 <td rowspan="4" style="white-space: nowrap"> Data Input Warm-up </td>
700 <td> Set the DDR2 Data Input Warm-up to \token{0} cycles </td>
701 <td rowspan="4"> <b>Data Input Warm-up</b> cycles are dummy cycles for interface calibration with no incremental data transfer
702 and apply to NV-DDR2 of the \ref bus_data_interface_tab "\b Bus Data Interface".
704 <tr><td> \ref ARM_NAND_BUS_DDR2_DI_WCYC_1 </td><td> Set the DDR2 Data Input Warm-up to \token{1} cycles </td></tr>
705 <tr><td> \ref ARM_NAND_BUS_DDR2_DI_WCYC_2 </td><td> Set the DDR2 Data Input Warm-up to \token{2} cycles </td></tr>
706 <tr><td> \ref ARM_NAND_BUS_DDR2_DI_WCYC_4 </td><td> Set the DDR2 Data Input Warm-up to \token{4} cycles </td></tr>
707 <tr><td style="white-space: nowrap"> \ref ARM_NAND_BUS_DDR2_VEN \anchor bus_misc_tab </td>
708 <td style="text-align:right"> 16 </td>
709 <td rowspan="3" style="white-space: nowrap"> Miscellaneous </td>
710 <td> Set the DDR2 Enable external VREFQ as reference </td>
711 <td rowspan="3">
713 <tr><td> \ref ARM_NAND_BUS_DDR2_CMPD </td><td style="text-align:right"> 17 </td><td> Set the DDR2 Enable complementary DQS (DQS_c) signal </td></tr>
714 <tr><td> \ref ARM_NAND_BUS_DDR2_CMPR </td><td style="text-align:right"> 18 </td><td> Set the DDR2 Enable complementary RE_n (RE_c) signal </td></tr>
715 <tr><th> Parameter \em arg <br> for <i>control</i> = \ref ARM_NAND_BUS_DATA_WIDTH </th>
717 <th> Category \anchor bus_data_width_tab </th>
718 <th> Description </th>
719 <th width="30%"> Supported when \ref ARM_NAND_CAPABILITIES </th></tr>
720 <tr><td style="white-space: nowrap"> \ref ARM_NAND_BUS_DATA_WIDTH_8 (default) </td>
721 <td rowspan="2" style="text-align:right"> 0..1 </td>
722 <td rowspan="2" style="white-space: nowrap"> Bus Data Width </td>
723 <td> Set to \token{8 bit} </td>
724 <td> <i>always supported</i>
726 <tr><td> \ref ARM_NAND_BUS_DATA_WIDTH_16 </td><td> Set to \token{16 bit} </td><td> data field <i>data_width_16</i> = \token{1} </td></tr>
727 <tr><th style="white-space: nowrap"> Parameter \em arg <br> for <i>control</i> = \ref ARM_NAND_DRIVER_STRENGTH </th>
729 <th> Category \anchor driver_strength_tab </th>
730 <th> Description </th>
731 <th width="30%"> Supported when \ref ARM_NAND_CAPABILITIES </th></tr>
732 <tr><td style="white-space: nowrap"> \ref ARM_NAND_DRIVER_STRENGTH_18 </td>
733 <td rowspan="4" style="text-align:right"> 0..3 </td>
734 <td rowspan="4" style="white-space: nowrap"> Driver Strength </td>
735 <td> Set the Driver Strength 2.0x = 18 Ohms </td>
736 <td> data field <i>driver_strength_18</i> = \token{1}
738 <tr><td> \ref ARM_NAND_DRIVER_STRENGTH_25 </td><td> Set the Driver Strength 1.4x = 25 Ohms </td><td> data field <i>driver_strength_25</i> = \token{1} </td></tr>
739 <tr><td> \ref ARM_NAND_DRIVER_STRENGTH_35 (default) </td><td> Set the Driver Strength 1.0x = 35 Ohms </td><td> <i>always supported</i> </td></tr>
740 <tr><td> \ref ARM_NAND_DRIVER_STRENGTH_50 </td><td> Set the Driver Strength 0.7x = 50 Ohms </td><td> data field <i>driver_strength_50</i> = \token{1} </td></tr>
745 extern ARM_DRIVER_NAND Driver_NAND0;
747 status = Driver_NAND0.Control (0, ARM_NAND_BUS_MODE, ARM_NAND_BUS_TIMING_MODE_5 |
749 ARM_NAND_BUS_DDR2_VEN);
751 status = Driver_NAND0.Control (0, ARM_NAND_BUS_DATA_WIDTH, ARM_NAND_BUS_DATA_WIDTH_16);
753 status = Driver_NAND0.Control (0, ARM_NAND_DRIVER_STRENGTH, ARM_NAND_DRIVER_STRENGTH_50);
756 *******************************************************************************************************************/
758 ARM_NAND_STATUS ARM_NAND_GetStatus (uint32_t dev_num) {
762 \fn ARM_NAND_STATUS ARM_NAND_GetStatus (uint32_t dev_num)
764 The function \b ARM_NAND_GetStatus returns the current NAND device status.
766 The parameter \em dev_num is the device number.
767 *******************************************************************************************************************/
769 int32_t ARM_NAND_InquireECC (int32_t index, ARM_NAND_ECC_INFO *info) {
773 \fn int32_t ARM_NAND_InquireECC (int32_t index, ARM_NAND_ECC_INFO *info)
775 The function \b reads error correction code information.
777 The parameter \em index is the device number. \n
778 The parameter \em info is a pointer of type \ref ARM_NAND_ECC_INFO. The data fields store the information.
779 *******************************************************************************************************************/
781 void ARM_NAND_SignalEvent (uint32_t dev_num, uint32_t event) {
785 \fn void ARM_NAND_SignalEvent (uint32_t dev_num, uint32_t event)
787 The function \b ARM_NAND_SignalEvent is a callback function registered by the function \ref ARM_NAND_Initialize.
789 The parameter \em dev_num is the device number. \n
790 The parameter \em event indicates one or more events that occurred during driver operation.
791 Each event is encoded in a separate bit and therefore it is possible to signal multiple events within the same call.
793 Not every event is necessarily generated by the driver. This depends on the implemented capabilities stored in the
794 data fields of the structure \ref ARM_NAND_CAPABILITIES, which can be retrieved with the function \ref ARM_NAND_GetCapabilities.
796 The following events can be generated:
798 Parameter \em event | Bit | Description
799 :---------------------------------|-----|:---------------------------
800 \ref ARM_NAND_EVENT_DEVICE_READY | 0 | Occurs when rising edge is detected on R/Bn (Ready/Busy) pin indicating that the device is ready.
801 \ref ARM_NAND_EVENT_DRIVER_READY | 1 | Occurs to indicate that commands can be executed (after previously being busy and not able to start the requested operation).
802 \ref ARM_NAND_EVENT_DRIVER_DONE | 2 | Occurs after an operation completes. An operation was successfully started before with \ref ARM_NAND_ReadData, \ref ARM_NAND_WriteData, \ref ARM_NAND_ExecuteSequence.
803 \ref ARM_NAND_EVENT_ECC_ERROR | 3 | Occurs when ECC generation failed or ECC correction failed. An operation was successfully started before with \ref ARM_NAND_ReadData, \ref ARM_NAND_WriteData, \ref ARM_NAND_ExecuteSequence.
805 The event \ref ARM_NAND_EVENT_DEVICE_READY occurs after complete execution of commands
806 (initiated with the functions \ref ARM_NAND_SendCommand, \ref ARM_NAND_SendAddress, \ref ARM_NAND_ReadData, \ref ARM_NAND_WriteData, \ref ARM_NAND_ExecuteSequence).
807 It is useful to indicate completion of complex operations (such as erase).
808 The event is only generated when \ref ARM_NAND_GetCapabilities returns data field \em event_device_ready = \token{1}
809 and was enabled by calling \ref ARM_NAND_Control (\ref ARM_NAND_DEVICE_READY_EVENT, 1).
810 If the event is not available, poll the \em busy data field using the function \ref ARM_NAND_GetStatus.
812 The event \ref ARM_NAND_EVENT_DRIVER_READY occurs when previously a function
813 (\ref ARM_NAND_SendCommand, \ref ARM_NAND_SendAddress, \ref ARM_NAND_ReadData, \ref ARM_NAND_WriteData, \ref ARM_NAND_ExecuteSequence)
814 returned with \ref ARM_DRIVER_ERROR_BUSY. It is useful when functions are called simultaneously from independent threads
815 (for example to control multiple devices) and the threads have no knowledge about each other (driver rejects reentrant calls with return of \ref ARM_DRIVER_ERROR_BUSY).
816 \em dev_num indicates the device that returned previously busy.
817 *******************************************************************************************************************/
822 // End NAND Interface