|
25 | 25 | *******************************************************************************/ |
26 | 26 |
|
27 | 27 | /** |
28 | | -* \addtogroup group_serial_flash Serial Flash |
| 28 | +* \addtogroup group_board_libs Serial Flash |
29 | 29 | * \{ |
30 | | -* Driver for interfacing with the serial flash (QSPI NOR flash). |
31 | | -* |
32 | | -* \defgroup group_serial_flash_macros Macros |
33 | | -* \defgroup group_serial_flash_functions Functions |
34 | 30 | */ |
35 | 31 |
|
36 | 32 | #pragma once |
|
46 | 42 | extern "C" { |
47 | 43 | #endif |
48 | 44 |
|
49 | | -/** |
50 | | -* \addtogroup group_serial_flash_macros |
51 | | -* \{ |
52 | | -*/ |
53 | | - |
54 | 45 | /** The function or operation is not supported on the target or the memory */ |
55 | 46 | #define CY_RSLT_SERIAL_FLASH_ERR_UNSUPPORTED (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_BOARD_LIB_SERIAL_FLASH, 1)) |
56 | 47 |
|
57 | | -/** \} group_serial_flash_macros */ |
58 | | - |
59 | 48 | /** |
60 | | -* \addtogroup group_serial_flash_functions |
61 | | -* \{ |
62 | | -*/ |
63 | | - |
64 | | -/** |
65 | | - * \brief Initializes the serial flash memory. |
| 49 | + * \brief Initializes the serial flash memory. This function accepts up to 8 |
| 50 | + * I/Os. Number of I/Os depend on the type of memory interface. Pass NC when an |
| 51 | + * I/O is unused. |
| 52 | + * Single SPI - (io0, io1) or (io2, io3) or (io4, io5) or (io6, io7) |
| 53 | + * Dual SPI - (io0, io1) or (io2, io3) or (io4, io5) or (io6, io7) |
| 54 | + * Quad SPI - (io0, io1, io2, io3) or (io4, io5, io6, io7) |
| 55 | + * Octal SPI - All 8 I/Os are used. |
66 | 56 | * \param mem_config Memory configuration to be used for initializing |
67 | | - * \param io0 Data/IO pin 0 connected to the memory |
68 | | - * \param io1 Data/IO pin 1 connected to the memory |
69 | | - * \param io2 Data/IO pin 2 connected to the memory |
70 | | - * \param io3 Data/IO pin 3 connected to the memory |
71 | | - * \param io4 Data/IO pin 4 connected to the memory |
72 | | - * \param io5 Data/IO pin 5 connected to the memory |
73 | | - * \param io6 Data/IO pin 6 connected to the memory |
74 | | - * \param io7 Data/IO pin 7 connected to the memory |
| 57 | + * \param io0 Data/IO pin 0 connected to the memory, Pass NC when unused. |
| 58 | + * \param io1 Data/IO pin 1 connected to the memory, Pass NC when unused. |
| 59 | + * \param io2 Data/IO pin 2 connected to the memory, Pass NC when unused. |
| 60 | + * \param io3 Data/IO pin 3 connected to the memory, Pass NC when unused. |
| 61 | + * \param io4 Data/IO pin 4 connected to the memory, Pass NC when unused. |
| 62 | + * \param io5 Data/IO pin 5 connected to the memory, Pass NC when unused. |
| 63 | + * \param io6 Data/IO pin 6 connected to the memory, Pass NC when unused. |
| 64 | + * \param io7 Data/IO pin 7 connected to the memory, Pass NC when unused. |
75 | 65 | * \param sclk Clock pin connected to the memory |
76 | 66 | * \param ssel Slave select pin connected to the memory |
77 | | - * \param hz Clock frequency to be used with the memory |
| 67 | + * \param hz Clock frequency to be used with the memory. This parameter is |
| 68 | + * ignored currently. Change the CLK_HF frequency using either the |
| 69 | + Device Configurator tool or the clock driver. |
78 | 70 | * \returns CY_RSLT_SUCCESS if the initialization was successful, an error code |
79 | 71 | * otherwise. |
80 | 72 | */ |
@@ -111,6 +103,17 @@ size_t cy_serial_flash_qspi_get_size(void); |
111 | 103 | */ |
112 | 104 | size_t cy_serial_flash_qspi_get_erase_size(uint32_t addr); |
113 | 105 |
|
| 106 | +/** |
| 107 | + * \brief Utility function to calculate the starting address of an erase sector |
| 108 | + * to which the given address belongs. |
| 109 | + * \param addr Address in the sector for which the starting address is returned. |
| 110 | + * \returns Starting address of the sector |
| 111 | + */ |
| 112 | +__STATIC_INLINE uint32_t cy_serial_flash_get_sector_start_address(uint32_t addr) |
| 113 | +{ |
| 114 | + return (addr & ~(cy_serial_flash_qspi_get_erase_size(addr) - 1)); |
| 115 | +} |
| 116 | + |
114 | 117 | /** |
115 | 118 | * \brief Reads data from the serial flash memory. This is a blocking |
116 | 119 | * function. Returns error if (addr + length) exceeds the flash size. |
@@ -162,12 +165,10 @@ cy_rslt_t cy_serial_flash_qspi_erase(uint32_t addr, size_t length); |
162 | 165 | */ |
163 | 166 | cy_rslt_t cy_serial_flash_qspi_enable_xip(bool enable); |
164 | 167 |
|
165 | | -/** \} group_serial_flash_functions */ |
166 | | - |
167 | 168 | #if defined(__cplusplus) |
168 | 169 | } |
169 | 170 | #endif |
170 | 171 |
|
171 | 172 | #endif /* CY_IP_MXSMIF */ |
172 | 173 |
|
173 | | -/** \} group_serial_flash */ |
| 174 | +/** \} group_board_libs */ |
0 commit comments