@mchp-mcc/dspic33a-flash 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -37,6 +37,11 @@ enum FLASH_PROGRAM_ERASE_ERROR_CODE {
37
37
  // Section: Driver Interface
38
38
  const struct ${moduleNameUpperCase}_INTERFACE flash = {
39
39
  .PageErase = FLASH_PageErase,
40
+ <#if flashHasDualPartition == true>
41
+ .BulkErase = FLASH_BulkErase,
42
+ <#else>
43
+ .BulkErase = NULL,
44
+ </#if>
40
45
  .Write = FLASH_WordWrite,
41
46
  <#if flashHasRowProgramming == 1>
42
47
  .RowWrite = FLASH_RowWrite,
@@ -77,11 +82,35 @@ enum FLASH_RETURN_STATUS ${moduleNameUpperCase}_PageErase(flash_adr_t flashAddre
77
82
  ${nvmControlRegister} = FLASH_PAGE_ERASE_OPCODE;
78
83
  ${nvmControlRegister}bits.WR = 1U;
79
84
  while(1U == ${nvmControlRegister}bits.WR){};
85
+ ${nvmControlRegister}bits.WREN = 0U;
80
86
 
81
87
  flashReturnStatus = getProgramEraseErrorCode();
82
88
  }
83
89
  return flashReturnStatus;
84
90
  }
91
+ <#if flashHasDualPartition == true>
92
+ enum FLASH_RETURN_STATUS ${moduleNameUpperCase}_BulkErase(enum FLASH_PANEL panel, flash_key_t unlockKey)
93
+ {
94
+ enum FLASH_RETURN_STATUS flashReturnStatus = FLASH_NO_ERROR;
95
+ if(unlockKey != (flash_key_t)FLASH_UNLOCK_KEY)
96
+ {
97
+ flashReturnStatus = FLASH_INVALID_KEY;
98
+ }
99
+ else if ((panel < 1U) || (panel >= FLASH_PANEL_MAX_PANELS))
100
+ {
101
+ flashReturnStatus = FLASH_INVALID_ADDRESS;
102
+ }
103
+ else
104
+ {
105
+ ${nvmControlRegister} = FLASH_INACTIVE_PARTITION_ERASE_OPCODE;
106
+ ${nvmControlRegister}bits.WR = 1U;
107
+ while(1U == ${nvmControlRegister}bits.WR){};
108
+ ${nvmControlRegister}bits.WREN = 0U;
109
+ flashReturnStatus = getProgramEraseErrorCode();
110
+ }
111
+ return flashReturnStatus;
112
+ }
113
+ </#if>
85
114
 
86
115
  enum FLASH_RETURN_STATUS ${moduleNameUpperCase}_WordWrite(flash_adr_t flashAddress, flash_data_t *data, flash_key_t unlockKey)
87
116
  {
@@ -110,6 +139,7 @@ enum FLASH_RETURN_STATUS ${moduleNameUpperCase}_WordWrite(flash_adr_t flashAddre
110
139
 
111
140
  ${nvmControlRegister}bits.WR = 1U;
112
141
  while (1U == ${nvmControlRegister}bits.WR){};
142
+ ${nvmControlRegister}bits.WREN = 0U;
113
143
 
114
144
  flashReturnStatus = getProgramEraseErrorCode();
115
145
  }
@@ -140,6 +170,7 @@ enum FLASH_RETURN_STATUS ${moduleNameUpperCase}_RowWrite(flash_adr_t flashAddre
140
170
 
141
171
  ${nvmControlRegister}bits.WR = 1U;
142
172
  while (1U == ${nvmControlRegister}bits.WR){};
173
+ ${nvmControlRegister}bits.WREN = 0U;
143
174
 
144
175
  flashReturnStatus = getProgramEraseErrorCode();
145
176
  }
@@ -53,6 +53,23 @@ extern const struct ${moduleNameUpperCase}_INTERFACE flash;
53
53
  */
54
54
  enum FLASH_RETURN_STATUS ${moduleNameUpperCase}_PageErase(flash_adr_t flashAddress, flash_key_t unlockKey);
55
55
 
56
+ <#if flashHasDualPartition == true>
57
+ /**
58
+ * @ingroup ${moduleNameLowerCase}driver
59
+ * @brief This function erases a partition (most of the devices support only inactive panel erase).
60
+ * @param[in] panel : Flash Panel ( 0 = active panel , 1 = inactive panel)
61
+ * @param[in] unlockKey : Flash unlock key
62
+ * @return FLASH_RETURN_STATUS: returns FLASH_NO_ERROR if operation is successful , else returns errors like FLASH_INVALID_ADDRESS, FLASH_WRITE_ERROR
63
+ <#if functionHeaderExample == true>
64
+ *
65
+ * @b Example:
66
+ * @code
67
+ * FLASH_RETURN_STATUS status = ${moduleNameUpperCase}_BulkeErase(panel, unlockKey);
68
+ * @endcode
69
+ </#if>
70
+ */
71
+ enum FLASH_RETURN_STATUS ${moduleNameUpperCase}_BulkErase(enum FLASH_PANEL panel, flash_key_t unlockKey);
72
+ </#if>
56
73
 
57
74
  /**
58
75
  * @ingroup ${moduleNameLowerCase}driver
@@ -40,6 +40,8 @@ struct ${moduleNameUpperCase}_INTERFACE
40
40
  {
41
41
  enum FLASH_RETURN_STATUS (*PageErase)(flash_adr_t address, flash_key_t unlockKey);
42
42
  ///< Pointer to FLASH_PageErase e.g. \ref FLASH_PageErase
43
+ enum FLASH_RETURN_STATUS (*BulkErase)(enum FLASH_PANEL panel, flash_key_t unlockKey);
44
+ ///< Pointer to FLASH_BulkErase e.g. \ref FLASH_BulkErase
43
45
 
44
46
  enum FLASH_RETURN_STATUS (*Write)(flash_adr_t address, flash_data_t* data, flash_key_t unlockKey);
45
47
  ///< Pointer to FLASH_WordWrite e.g. \ref FLASH_WordWrite
@@ -43,6 +43,11 @@ static bool lock = false;
43
43
  const struct ${moduleNameUpperCase}_INTERFACE flash = {
44
44
  <#if generateBlockingAPI == true>
45
45
  .PageErase = FLASH_PageErase,
46
+ <#if flashHasDualPartition == true>
47
+ .BulkErase = FLASH_BulkErase,
48
+ <#else>
49
+ .BulkErase == NULL,
50
+ </#if>
46
51
  .Read = FLASH_Read,
47
52
  .Write = FLASH_WordWrite,
48
53
  <#if flashHasRowProgramming == 1>
@@ -55,7 +60,11 @@ const struct ${moduleNameUpperCase}_INTERFACE flash = {
55
60
  .PageOffsetGet = FLASH_ErasePageOffsetGet,
56
61
  <#if interruptDriven == true>
57
62
  .NonBlockingPageErase = FLASH_NonBlockingPageErase,
63
+ <#if flashHasDualPartition == true>
64
+ .NonBlockingBulkErase = FLASH_NonBlockingBulkErase,
65
+ <#else>
58
66
  .NonBlockingBulkErase = NULL,
67
+ </#if>
59
68
  .NonBlockingRead = FLASH_NonBlockingRead,
60
69
  .NonBlockingWordWrite = FLASH_NonBlockingWordWrite,
61
70
  <#if flashHasRowProgramming == 1>
@@ -75,7 +84,11 @@ const struct ${moduleNameUpperCase}_INTERFACE flash = {
75
84
  .NonBlockingWordWrite = NULL,
76
85
  .NonBlockingRowWrite = NULL,
77
86
  .NonBlockingPolledPageErase = FLASH_NonBlockingPolledPageErase,
87
+ <#if flashHasDualPartition == true>
88
+ .NonBlockingPolledBulkErase = FLASH_NonBlockingPolledBulkErase,
89
+ <#else>
78
90
  .NonBlockingPolledBulkErase = NULL,
91
+ </#if>
79
92
  .NonBlockingPolledRead = FLASH_NonBlockingPolledRead,
80
93
  .NonBlockingPolledWordWrite = FLASH_NonBlockingPolledWordWrite,
81
94
  <#if flashHasRowProgramming == 1>
@@ -100,8 +113,28 @@ void FLASH_Initialize(void)
100
113
 
101
114
  <#if interruptDriven == true>
102
115
  <#if isFlashContextSupported>
116
+ <#if suppressMisraWarning == true>
117
+ /* cppcheck-suppress misra-c2012-8.4
118
+ *
119
+ * (Rule 8.4) REQUIRED: A compatible declaration shall be visible when an object or
120
+ * function with external linkage is defined
121
+ *
122
+ * Reasoning: Interrupt declaration are provided by compiler and are available
123
+ * outside the driver folder
124
+ */
125
+ </#if>
103
126
  void __attribute__ ( ( interrupt, context ) ) ${flashIsrHandlerName}(void)
104
127
  <#else>
128
+ <#if suppressMisraWarning == true>
129
+ /* cppcheck-suppress misra-c2012-8.4
130
+ *
131
+ * (Rule 8.4) REQUIRED: A compatible declaration shall be visible when an object or
132
+ * function with external linkage is defined
133
+ *
134
+ * Reasoning: Interrupt declaration are provided by compiler and are available
135
+ * outside the driver folder
136
+ */
137
+ </#if>
105
138
  void __attribute__ ( ( interrupt ) ) ${flashIsrHandlerName}(void)
106
139
  </#if>
107
140
  {
@@ -202,6 +235,49 @@ enum FLASH_RETURN_STATUS FLASH_NonBlockingPolledPageErase(flash_adr_t flashAddre
202
235
  }
203
236
  return flashReturnStatus;
204
237
  }
238
+ <#if flashHasDualPartition == true>
239
+ <#if interruptDriven == true>
240
+ enum FLASH_RETURN_STATUS FLASH_NonBlockingBulkErase(enum FLASH_PANEL panel, flash_key_t unlockKey, FLASH_CALLBACK callbackHandler, void* context)
241
+ <#else>
242
+ enum FLASH_RETURN_STATUS FLASH_NonBlockingPolledBulkErase(enum FLASH_PANEL panel, flash_key_t unlockKey)
243
+ </#if>
244
+ {
245
+ enum FLASH_RETURN_STATUS flashReturnStatus = FLASH_OP_IN_PROGRESS;
246
+ if(false == lock)
247
+ {
248
+ if(unlockKey != (flash_key_t)FLASH_UNLOCK_KEY)
249
+ {
250
+ flashReturnStatus = FLASH_INVALID_KEY;
251
+ }
252
+ if ((panel < 1U) || (panel >= FLASH_PANEL_MAX_PANELS))
253
+ {
254
+ flashReturnStatus = FLASH_INVALID_ADDRESS;
255
+ }
256
+ <#if interruptDriven == true>
257
+ else if(NULL == callbackHandler)
258
+ {
259
+ flashReturnStatus = FLASH_INVALID_CALLBACK_HANDLER;
260
+ }
261
+ </#if>
262
+ else if(0U != ${nvmControlRegister}bits.WR)
263
+ {
264
+ flashReturnStatus = FLASH_OP_BUSY;
265
+ }
266
+ else
267
+ {
268
+ <#if interruptDriven == true>
269
+ userCallbackHandler = callbackHandler;
270
+ userContext = context;
271
+ </#if>
272
+ lock = true;
273
+ ${nvmControlRegister} = FLASH_INACTIVE_PARTITION_ERASE_OPCODE;
274
+ ${nvmControlRegister}bits.WR = 1U;
275
+ lock = false;
276
+ }
277
+ }
278
+ return flashReturnStatus;
279
+ }
280
+ </#if>
205
281
 
206
282
 
207
283
  <#if interruptDriven == true>
@@ -104,6 +104,49 @@ enum FLASH_RETURN_STATUS FLASH_NonBlockingPageErase(flash_adr_t flashAddress, fl
104
104
  enum FLASH_RETURN_STATUS FLASH_NonBlockingPolledPageErase(flash_adr_t flashAddress, flash_key_t unlockKey);
105
105
  </#if>
106
106
 
107
+ <#if flashHasDualPartition == true>
108
+ <#if interruptDriven == true>
109
+ /**
110
+ * @ingroup ${moduleNameLowerCase}driver
111
+ * @brief This function erases a partition (most of the devices support only inactive panel erase).
112
+ * @param[in] panel : Flash Panel ( 0 = active panel , 1 = inactive panel)
113
+ * @param[in] unlockKey : Flash unlock key
114
+ * @param[in] callbackHandler : Pointer to call back handler
115
+ * @param[in] context : Optional pointer to context to handle user contexts
116
+ * @return FLASH_RETURN_STATUS: returns FLASH_NO_ERROR if operation is successful, if the operation is in progress then it returns FLASH_OP_IN_PROGRESS,
117
+ * if there is a previous operation in progress then it returns FLASH_OP_BUSY , in case of any unsuccessful operation it returns errors like
118
+ * FLASH_INVALID_ADDRESS, FLASH_INVALID_CALLBACK_HANDLER, FLASH_WRITE_ERROR
119
+ <#if functionHeaderExample == true>
120
+ *
121
+ * @b Example:
122
+ * @code
123
+ * FLASH_RETURN_STATUS status = FLASH_NonBlockingBulkErase(panel, unlockKey, callbackHandler, context);
124
+ * @endcode
125
+ </#if>
126
+ */
127
+ enum FLASH_RETURN_STATUS FLASH_NonBlockingBulkErase(enum FLASH_PANEL panel, flash_key_t unlockKey, FLASH_CALLBACK callbackHandler, void* context);
128
+ <#else>
129
+ /**
130
+ * @ingroup ${moduleNameLowerCase}driver
131
+ * @brief his function erases a partition (most of the devices support only inactive panel erase).
132
+ * @param[in] panel : Flash Panel ( 0 = active panel , 1 = inactive panel)
133
+ * @param[in] unlockKey : Flash unlock key
134
+ * @return FLASH_RETURN_STATUS : returns FLASH_NO_ERROR if operation is successful, if the operation is in progress then it returns FLASH_OP_IN_PROGRESS,
135
+ * if there is a previous operation in progress then it returns FLASH_OP_BUSY , in case of any unsuccessful operation it returns errors like
136
+ * FLASH_INVALID_ADDRESS, FLASH_WRITE_ERROR
137
+ * This function locks flash operations to prevent multiple access. Make sure to call FLASH_OperationStatusGet() after calling FLASH_NonBlockingPolledPageErase() to release the lock.
138
+ <#if functionHeaderExample == true>
139
+ *
140
+ * @b Example:
141
+ * @code
142
+ * FLASH_RETURN_STATUS status = FLASH_NonBlockingPolledBulkErase(panel, unlockKey);
143
+ while (FLASH_OperationStatusGet() == FLASH_OP_BUSY);
144
+ * @endcode
145
+ </#if>
146
+ */
147
+ enum FLASH_RETURN_STATUS FLASH_NonBlockingPolledBulkErase(enum FLASH_PANEL panel, flash_key_t unlockKey);
148
+ </#if>
149
+ </#if>
107
150
  <#if interruptDriven == true>
108
151
  /**
109
152
  * @ingroup flashdriver
@@ -46,6 +46,13 @@ ${disclaimer}
46
46
  @brief Defines ${moduleNameUpperCase} word write opcode
47
47
  */
48
48
  #define FLASH_ROW_WRITE_OPCODE ${flashRowWriteOpcode}
49
+ <#if flashHasDualPartition == true>
50
+ /**
51
+ @ingroup ${moduleNameLowerCase}driver
52
+ @brief Defines ${moduleNameUpperCase} inactive partition erase opcode
53
+ */
54
+ #define FLASH_INACTIVE_PARTITION_ERASE_OPCODE ${flashOpcodeInactivePartitionErase}
55
+ </#if>
49
56
  /**
50
57
  @ingroup ${moduleNameLowerCase}driver
51
58
  @brief Defines ${moduleNameUpperCase} flash page size