OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [lwIP_AVR32_UC3/] [DRIVERS/] [FLASHC/] [flashc.h] - Blame information for rev 583

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 583 jeremybenn
/*This file is prepared for Doxygen automatic documentation generation.*/
2
/*! \file *********************************************************************
3
 *
4
 * \brief FLASHC driver for AVR32 UC3.
5
 *
6
 * AVR32 Flash Controller driver module.
7
 *
8
 * - Compiler:           IAR EWAVR32 and GNU GCC for AVR32
9
 * - Supported devices:  All AVR32 devices with a FLASHC module can be used.
10
 * - AppNote:
11
 *
12
 * \author               Atmel Corporation: http://www.atmel.com \n
13
 *                       Support and FAQ: http://support.atmel.no/
14
 *
15
 ******************************************************************************/
16
 
17
/* Copyright (c) 2007, Atmel Corporation All rights reserved.
18
 *
19
 * Redistribution and use in source and binary forms, with or without
20
 * modification, are permitted provided that the following conditions are met:
21
 *
22
 * 1. Redistributions of source code must retain the above copyright notice,
23
 * this list of conditions and the following disclaimer.
24
 *
25
 * 2. Redistributions in binary form must reproduce the above copyright notice,
26
 * this list of conditions and the following disclaimer in the documentation
27
 * and/or other materials provided with the distribution.
28
 *
29
 * 3. The name of ATMEL may not be used to endorse or promote products derived
30
 * from this software without specific prior written permission.
31
 *
32
 * THIS SOFTWARE IS PROVIDED BY ATMEL ``AS IS'' AND ANY EXPRESS OR IMPLIED
33
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
34
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND
35
 * SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT,
36
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
37
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
38
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
39
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
40
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
41
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42
 */
43
 
44
 
45
#ifndef _FLASHC_H_
46
#define _FLASHC_H_
47
 
48
#include <avr32/io.h>
49
#include <stddef.h>
50
#include "compiler.h"
51
 
52
 
53
//! Number of flash regions defined by the FLASHC.
54
#define AVR32_FLASHC_REGIONS  (AVR32_FLASHC_FLASH_SIZE /\
55
                               (AVR32_FLASHC_PAGES_PR_REGION * AVR32_FLASHC_PAGE_SIZE))
56
 
57
 
58
/*! \name Flash Properties
59
 */
60
//! @{
61
 
62
/*! \brief Gets the size of the whole flash array.
63
 *
64
 * \return The size of the whole flash array in bytes.
65
 */
66
extern unsigned int flashc_get_flash_size(void);
67
 
68
/*! \brief Gets the total number of pages in the flash array.
69
 *
70
 * \return The total number of pages in the flash array.
71
 */
72
extern unsigned int flashc_get_page_count(void);
73
 
74
/*! \brief Gets the number of pages in each flash region.
75
 *
76
 * \return The number of pages in each flash region.
77
 */
78
extern unsigned int flashc_get_page_count_per_region(void);
79
 
80
/*! \brief Gets the region number of a page.
81
 *
82
 * \param page_number The page number:
83
 *   \arg \c 0 to <tt>(flashc_get_page_count() - 1)</tt>: a page number within
84
 *        the flash array;
85
 *   \arg <tt>< 0</tt>: the current page number.
86
 *
87
 * \return The region number of the specified page.
88
 */
89
extern unsigned int flashc_get_page_region(int page_number);
90
 
91
/*! \brief Gets the number of the first page of a region.
92
 *
93
 * \param region The region number: \c 0 to <tt>(AVR32_FLASHC_REGIONS - 1)</tt>.
94
 *
95
 * \return The number of the first page of the specified region.
96
 */
97
extern unsigned int flashc_get_region_first_page_number(unsigned int region);
98
 
99
//! @}
100
 
101
 
102
/*! \name FLASHC Control
103
 */
104
//! @{
105
 
106
/*! \brief Gets the number of wait states of flash read accesses.
107
 *
108
 * \return The number of wait states of flash read accesses.
109
 */
110
extern unsigned int flashc_get_wait_state(void);
111
 
112
/*! \brief Sets the number of wait states of flash read accesses.
113
 *
114
 * \param wait_state The number of wait states of flash read accesses: \c 0 to
115
 *                   \c 1.
116
 */
117
extern void flashc_set_wait_state(unsigned int wait_state);
118
 
119
/*! \brief Tells whether the Flash Ready interrupt is enabled.
120
 *
121
 * \return Whether the Flash Ready interrupt is enabled.
122
 */
123
extern Bool flashc_is_ready_int_enabled(void);
124
 
125
/*! \brief Enables or disables the Flash Ready interrupt.
126
 *
127
 * \param enable Whether to enable the Flash Ready interrupt: \c TRUE or
128
 *               \c FALSE.
129
 */
130
extern void flashc_enable_ready_int(Bool enable);
131
 
132
/*! \brief Tells whether the Lock Error interrupt is enabled.
133
 *
134
 * \return Whether the Lock Error interrupt is enabled.
135
 */
136
extern Bool flashc_is_lock_error_int_enabled(void);
137
 
138
/*! \brief Enables or disables the Lock Error interrupt.
139
 *
140
 * \param enable Whether to enable the Lock Error interrupt: \c TRUE or
141
 *               \c FALSE.
142
 */
143
extern void flashc_enable_lock_error_int(Bool enable);
144
 
145
/*! \brief Tells whether the Programming Error interrupt is enabled.
146
 *
147
 * \return Whether the Programming Error interrupt is enabled.
148
 */
149
extern Bool flashc_is_prog_error_int_enabled(void);
150
 
151
/*! \brief Enables or disables the Programming Error interrupt.
152
 *
153
 * \param enable Whether to enable the Programming Error interrupt: \c TRUE or
154
 *               \c FALSE.
155
 */
156
extern void flashc_enable_prog_error_int(Bool enable);
157
 
158
//! @}
159
 
160
 
161
/*! \name FLASHC Status
162
 */
163
//! @{
164
 
165
/*! \brief Tells whether the FLASHC is ready to run a new command.
166
 *
167
 * \return Whether the FLASHC is ready to run a new command.
168
 */
169
extern Bool flashc_is_ready(void);
170
 
171
/*! \brief Waits actively until the FLASHC is ready to run a new command.
172
 *
173
 * This is the default function assigned to \ref flashc_wait_until_ready.
174
 */
175
extern void flashc_default_wait_until_ready(void);
176
 
177
//! Pointer to the function used by the driver when it needs to wait until the
178
//! FLASHC is ready to run a new command.
179
//! The default function is \ref flashc_default_wait_until_ready.
180
//! The user may change this pointer to use another implementation.
181
extern void (*volatile flashc_wait_until_ready)(void);
182
 
183
/*! \brief Tells whether a Lock Error has occurred during the last function
184
 *         called that issued one or more FLASHC commands.
185
 *
186
 * \return Whether a Lock Error has occurred during the last function called
187
 *         that issued one or more FLASHC commands.
188
 */
189
extern Bool flashc_is_lock_error(void);
190
 
191
/*! \brief Tells whether a Programming Error has occurred during the last
192
 *         function called that issued one or more FLASHC commands.
193
 *
194
 * \return Whether a Programming Error has occurred during the last function
195
 *         called that issued one or more FLASHC commands.
196
 */
197
extern Bool flashc_is_programming_error(void);
198
 
199
//! @}
200
 
201
 
202
/*! \name FLASHC Command Control
203
 */
204
//! @{
205
 
206
/*! \brief Gets the last issued FLASHC command.
207
 *
208
 * \return The last issued FLASHC command.
209
 */
210
extern unsigned int flashc_get_command(void);
211
 
212
/*! \brief Gets the current FLASHC page number.
213
 *
214
 * \return The current FLASHC page number.
215
 */
216
extern unsigned int flashc_get_page_number(void);
217
 
218
/*! \brief Issues a FLASHC command.
219
 *
220
 * \param command The command: \c AVR32_FLASHC_FCMD_CMD_x.
221
 * \param page_number The page number to apply the command to:
222
 *   \arg \c 0 to <tt>(flashc_get_page_count() - 1)</tt>: a page number within
223
 *        the flash array;
224
 *   \arg <tt>< 0</tt>: use this to apply the command to the current page number
225
 *        or if the command does not apply to any page number;
226
 *   \arg this argument may have other meanings according to the command. See
227
 *        the FLASHC chapter of the MCU datasheet.
228
 *
229
 * \warning A Lock Error is issued if the command violates the protection
230
 *          mechanism.
231
 *
232
 * \warning A Programming Error is issued if the command is invalid.
233
 *
234
 * \note The FLASHC error status returned by \ref flashc_is_lock_error and
235
 *       \ref flashc_is_programming_error is updated.
236
 */
237
extern void flashc_issue_command(unsigned int command, int page_number);
238
 
239
//! @}
240
 
241
 
242
/*! \name FLASHC Global Commands
243
 */
244
//! @{
245
 
246
/*! \brief Issues a No Operation command to the FLASHC.
247
 *
248
 * \note The FLASHC error status returned by \ref flashc_is_lock_error and
249
 *       \ref flashc_is_programming_error is updated.
250
 */
251
extern void flashc_no_operation(void);
252
 
253
/*! \brief Issues an Erase All command to the FLASHC.
254
 *
255
 * This command erases all bits in the flash array, the general-purpose fuse
256
 * bits and the Security bit. The User page is not erased.
257
 *
258
 * This command also ensures that all volatile memories, such as register file
259
 * and RAMs, are erased before the Security bit is erased, i.e. deactivated.
260
 *
261
 * \warning A Lock Error is issued if at least one region is locked or the
262
 *          bootloader protection is active.
263
 *
264
 * \note The FLASHC error status returned by \ref flashc_is_lock_error and
265
 *       \ref flashc_is_programming_error is updated.
266
 *
267
 * \note An erase operation can only set bits.
268
 */
269
extern void flashc_erase_all(void);
270
 
271
//! @}
272
 
273
 
274
/*! \name FLASHC Protection Mechanisms
275
 */
276
//! @{
277
 
278
/*! \brief Tells whether the Security bit is active.
279
 *
280
 * \return Whether the Security bit is active.
281
 */
282
extern Bool flashc_is_security_bit_active(void);
283
 
284
/*! \brief Activates the Security bit.
285
 *
286
 * \note The FLASHC error status returned by \ref flashc_is_lock_error and
287
 *       \ref flashc_is_programming_error is updated.
288
 */
289
extern void flashc_activate_security_bit(void);
290
 
291
/*! \brief Gets the bootloader protected size.
292
 *
293
 * \return The bootloader protected size in bytes.
294
 */
295
extern unsigned int flashc_get_bootloader_protected_size(void);
296
 
297
/*! \brief Sets the bootloader protected size.
298
 *
299
 * \param bootprot_size The wanted bootloader protected size in bytes. If this
300
 *                      size is not supported, the actual size will be the
301
 *                      nearest greater available size or the maximal possible
302
 *                      size if the requested size is too large.
303
 *
304
 * \return The actual bootloader protected size in bytes.
305
 *
306
 * \warning A Lock Error is issued if the Security bit is active.
307
 *
308
 * \note The FLASHC error status returned by \ref flashc_is_lock_error and
309
 *       \ref flashc_is_programming_error is updated.
310
 */
311
extern unsigned int flashc_set_bootloader_protected_size(unsigned int bootprot_size);
312
 
313
/*! \brief Tells whether external privileged fetch is locked.
314
 *
315
 * \return Whether external privileged fetch is locked.
316
 */
317
extern Bool flashc_is_external_privileged_fetch_locked(void);
318
 
319
/*! \brief Locks or unlocks external privileged fetch.
320
 *
321
 * \param lock Whether to lock external privileged fetch: \c TRUE or \c FALSE.
322
 *
323
 * \warning A Lock Error is issued if the Security bit is active.
324
 *
325
 * \note The FLASHC error status returned by \ref flashc_is_lock_error and
326
 *       \ref flashc_is_programming_error is updated.
327
 */
328
extern void flashc_lock_external_privileged_fetch(Bool lock);
329
 
330
/*! \brief Tells whether the region of a page is locked.
331
 *
332
 * \param page_number The page number:
333
 *   \arg \c 0 to <tt>(flashc_get_page_count() - 1)</tt>: a page number within
334
 *        the flash array;
335
 *   \arg <tt>< 0</tt>: the current page number.
336
 *
337
 * \return Whether the region of the specified page is locked.
338
 */
339
extern Bool flashc_is_page_region_locked(int page_number);
340
 
341
/*! \brief Tells whether a region is locked.
342
 *
343
 * \param region The region number: \c 0 to <tt>(AVR32_FLASHC_REGIONS - 1)</tt>.
344
 *
345
 * \return Whether the specified region is locked.
346
 */
347
extern Bool flashc_is_region_locked(unsigned int region);
348
 
349
/*! \brief Locks or unlocks the region of a page.
350
 *
351
 * \param page_number The page number:
352
 *   \arg \c 0 to <tt>(flashc_get_page_count() - 1)</tt>: a page number within
353
 *        the flash array;
354
 *   \arg <tt>< 0</tt>: the current page number.
355
 * \param lock Whether to lock the region of the specified page: \c TRUE or
356
 *             \c FALSE.
357
 *
358
 * \note The FLASHC error status returned by \ref flashc_is_lock_error and
359
 *       \ref flashc_is_programming_error is updated.
360
 */
361
extern void flashc_lock_page_region(int page_number, Bool lock);
362
 
363
/*! \brief Locks or unlocks a region.
364
 *
365
 * \param region The region number: \c 0 to <tt>(AVR32_FLASHC_REGIONS - 1)</tt>.
366
 * \param lock Whether to lock the specified region: \c TRUE or \c FALSE.
367
 *
368
 * \note The FLASHC error status returned by \ref flashc_is_lock_error and
369
 *       \ref flashc_is_programming_error is updated.
370
 */
371
extern void flashc_lock_region(unsigned int region, Bool lock);
372
 
373
/*! \brief Locks or unlocks all regions.
374
 *
375
 * \param lock Whether to lock the regions: \c TRUE or \c FALSE.
376
 *
377
 * \note The FLASHC error status returned by \ref flashc_is_lock_error and
378
 *       \ref flashc_is_programming_error is updated.
379
 */
380
extern void flashc_lock_all_regions(Bool lock);
381
 
382
//! @}
383
 
384
 
385
/*! \name Access to General-Purpose Fuses
386
 */
387
//! @{
388
 
389
/*! \brief Reads a general-purpose fuse bit.
390
 *
391
 * \param gp_fuse_bit The general-purpose fuse bit: \c 0 to \c 31.
392
 *
393
 * \return The value of the specified general-purpose fuse bit.
394
 */
395
extern Bool flashc_read_gp_fuse_bit(unsigned int gp_fuse_bit);
396
 
397
/*! \brief Reads a general-purpose fuse bit-field.
398
 *
399
 * \param pos The bit-position of the general-purpose fuse bit-field: \c 0 to
400
 *            \c 31.
401
 * \param width The bit-width of the general-purpose fuse bit-field: \c 0 to
402
 *              \c 32.
403
 *
404
 * \return The value of the specified general-purpose fuse bit-field.
405
 */
406
extern U32 flashc_read_gp_fuse_bitfield(unsigned int pos, unsigned int width);
407
 
408
/*! \brief Reads a general-purpose fuse byte.
409
 *
410
 * \param gp_fuse_byte The general-purpose fuse byte: \c 0 to \c 3.
411
 *
412
 * \return The value of the specified general-purpose fuse byte.
413
 */
414
extern U8 flashc_read_gp_fuse_byte(unsigned int gp_fuse_byte);
415
 
416
/*! \brief Reads all general-purpose fuses.
417
 *
418
 * \return The value of all general-purpose fuses as a word.
419
 */
420
extern U32 flashc_read_all_gp_fuses(void);
421
 
422
/*! \brief Erases a general-purpose fuse bit.
423
 *
424
 * \param gp_fuse_bit The general-purpose fuse bit: \c 0 to \c 31.
425
 * \param check Whether to check erase: \c TRUE or \c FALSE.
426
 *
427
 * \return Whether the erase succeeded or always \c TRUE if erase check was not
428
 *         requested.
429
 *
430
 * \warning A Lock Error is issued if the Security bit is active and the command
431
 *          is applied to BOOTPROT or EPFL fuses.
432
 *
433
 * \note The FLASHC error status returned by \ref flashc_is_lock_error and
434
 *       \ref flashc_is_programming_error is updated.
435
 *
436
 * \note An erase operation can only set bits.
437
 */
438
extern Bool flashc_erase_gp_fuse_bit(unsigned int gp_fuse_bit, Bool check);
439
 
440
/*! \brief Erases a general-purpose fuse bit-field.
441
 *
442
 * \param pos The bit-position of the general-purpose fuse bit-field: \c 0 to
443
 *            \c 31.
444
 * \param width The bit-width of the general-purpose fuse bit-field: \c 0 to
445
 *              \c 32.
446
 * \param check Whether to check erase: \c TRUE or \c FALSE.
447
 *
448
 * \return Whether the erase succeeded or always \c TRUE if erase check was not
449
 *         requested.
450
 *
451
 * \warning A Lock Error is issued if the Security bit is active and the command
452
 *          is applied to BOOTPROT or EPFL fuses.
453
 *
454
 * \note The FLASHC error status returned by \ref flashc_is_lock_error and
455
 *       \ref flashc_is_programming_error is updated.
456
 *
457
 * \note An erase operation can only set bits.
458
 */
459
extern Bool flashc_erase_gp_fuse_bitfield(unsigned int pos, unsigned int width, Bool check);
460
 
461
/*! \brief Erases a general-purpose fuse byte.
462
 *
463
 * \param gp_fuse_byte The general-purpose fuse byte: \c 0 to \c 3.
464
 * \param check Whether to check erase: \c TRUE or \c FALSE.
465
 *
466
 * \return Whether the erase succeeded or always \c TRUE if erase check was not
467
 *         requested.
468
 *
469
 * \warning A Lock Error is issued if the Security bit is active.
470
 *
471
 * \note The FLASHC error status returned by \ref flashc_is_lock_error and
472
 *       \ref flashc_is_programming_error is updated.
473
 *
474
 * \note An erase operation can only set bits.
475
 */
476
extern Bool flashc_erase_gp_fuse_byte(unsigned int gp_fuse_byte, Bool check);
477
 
478
/*! \brief Erases all general-purpose fuses.
479
 *
480
 * \param check Whether to check erase: \c TRUE or \c FALSE.
481
 *
482
 * \return Whether the erase succeeded or always \c TRUE if erase check was not
483
 *         requested.
484
 *
485
 * \warning A Lock Error is issued if the Security bit is active.
486
 *
487
 * \note The FLASHC error status returned by \ref flashc_is_lock_error and
488
 *       \ref flashc_is_programming_error is updated.
489
 *
490
 * \note An erase operation can only set bits.
491
 */
492
extern Bool flashc_erase_all_gp_fuses(Bool check);
493
 
494
/*! \brief Writes a general-purpose fuse bit.
495
 *
496
 * \param gp_fuse_bit The general-purpose fuse bit: \c 0 to \c 31.
497
 * \param value The value of the specified general-purpose fuse bit.
498
 *
499
 * \warning A Lock Error is issued if the Security bit is active and the command
500
 *          is applied to BOOTPROT or EPFL fuses.
501
 *
502
 * \note The FLASHC error status returned by \ref flashc_is_lock_error and
503
 *       \ref flashc_is_programming_error is updated.
504
 *
505
 * \note A write operation can only clear bits.
506
 */
507
extern void flashc_write_gp_fuse_bit(unsigned int gp_fuse_bit, Bool value);
508
 
509
/*! \brief Writes a general-purpose fuse bit-field.
510
 *
511
 * \param pos The bit-position of the general-purpose fuse bit-field: \c 0 to
512
 *            \c 31.
513
 * \param width The bit-width of the general-purpose fuse bit-field: \c 0 to
514
 *              \c 32.
515
 * \param value The value of the specified general-purpose fuse bit-field.
516
 *
517
 * \warning A Lock Error is issued if the Security bit is active and the command
518
 *          is applied to BOOTPROT or EPFL fuses.
519
 *
520
 * \note The FLASHC error status returned by \ref flashc_is_lock_error and
521
 *       \ref flashc_is_programming_error is updated.
522
 *
523
 * \note A write operation can only clear bits.
524
 */
525
extern void flashc_write_gp_fuse_bitfield(unsigned int pos, unsigned int width, U32 value);
526
 
527
/*! \brief Writes a general-purpose fuse byte.
528
 *
529
 * \param gp_fuse_byte The general-purpose fuse byte: \c 0 to \c 3.
530
 * \param value The value of the specified general-purpose fuse byte.
531
 *
532
 * \warning A Lock Error is issued if the Security bit is active.
533
 *
534
 * \note The FLASHC error status returned by \ref flashc_is_lock_error and
535
 *       \ref flashc_is_programming_error is updated.
536
 *
537
 * \note A write operation can only clear bits.
538
 */
539
extern void flashc_write_gp_fuse_byte(unsigned int gp_fuse_byte, U8 value);
540
 
541
/*! \brief Writes all general-purpose fuses.
542
 *
543
 * \param value The value of all general-purpose fuses as a word.
544
 *
545
 * \warning A Lock Error is issued if the Security bit is active.
546
 *
547
 * \note The FLASHC error status returned by \ref flashc_is_lock_error and
548
 *       \ref flashc_is_programming_error is updated.
549
 *
550
 * \note A write operation can only clear bits.
551
 */
552
extern void flashc_write_all_gp_fuses(U32 value);
553
 
554
/*! \brief Sets a general-purpose fuse bit with the appropriate erase and write
555
 *         operations.
556
 *
557
 * \param gp_fuse_bit The general-purpose fuse bit: \c 0 to \c 31.
558
 * \param value The value of the specified general-purpose fuse bit.
559
 *
560
 * \warning A Lock Error is issued if the Security bit is active and the command
561
 *          is applied to BOOTPROT or EPFL fuses.
562
 *
563
 * \note The FLASHC error status returned by \ref flashc_is_lock_error and
564
 *       \ref flashc_is_programming_error is updated.
565
 */
566
extern void flashc_set_gp_fuse_bit(unsigned int gp_fuse_bit, Bool value);
567
 
568
/*! \brief Sets a general-purpose fuse bit-field with the appropriate erase and
569
 *         write operations.
570
 *
571
 * \param pos The bit-position of the general-purpose fuse bit-field: \c 0 to
572
 *            \c 31.
573
 * \param width The bit-width of the general-purpose fuse bit-field: \c 0 to
574
 *              \c 32.
575
 * \param value The value of the specified general-purpose fuse bit-field.
576
 *
577
 * \warning A Lock Error is issued if the Security bit is active and the command
578
 *          is applied to BOOTPROT or EPFL fuses.
579
 *
580
 * \note The FLASHC error status returned by \ref flashc_is_lock_error and
581
 *       \ref flashc_is_programming_error is updated.
582
 */
583
extern void flashc_set_gp_fuse_bitfield(unsigned int pos, unsigned int width, U32 value);
584
 
585
/*! \brief Sets a general-purpose fuse byte with the appropriate erase and write
586
 *         operations.
587
 *
588
 * \param gp_fuse_byte The general-purpose fuse byte: \c 0 to \c 3.
589
 * \param value The value of the specified general-purpose fuse byte.
590
 *
591
 * \warning A Lock Error is issued if the Security bit is active.
592
 *
593
 * \note The FLASHC error status returned by \ref flashc_is_lock_error and
594
 *       \ref flashc_is_programming_error is updated.
595
 */
596
extern void flashc_set_gp_fuse_byte(unsigned int gp_fuse_byte, U8 value);
597
 
598
/*! \brief Sets all general-purpose fuses with the appropriate erase and write
599
 *         operations.
600
 *
601
 * \param value The value of all general-purpose fuses as a word.
602
 *
603
 * \warning A Lock Error is issued if the Security bit is active.
604
 *
605
 * \note The FLASHC error status returned by \ref flashc_is_lock_error and
606
 *       \ref flashc_is_programming_error is updated.
607
 */
608
extern void flashc_set_all_gp_fuses(U32 value);
609
 
610
//! @}
611
 
612
 
613
/*! \name Access to Flash Pages
614
 */
615
//! @{
616
 
617
/*! \brief Clears the page buffer.
618
 *
619
 * This command resets all bits in the page buffer to one. Write accesses to the
620
 * page buffer can only change page buffer bits from one to zero.
621
 *
622
 * \warning The page buffer is not automatically reset after a page write.
623
 *
624
 * \note The FLASHC error status returned by \ref flashc_is_lock_error and
625
 *       \ref flashc_is_programming_error is updated.
626
 */
627
extern void flashc_clear_page_buffer(void);
628
 
629
/*! \brief Tells whether the page to which the last Quick Page Read command was
630
 *         applied was erased.
631
 *
632
 * \return Whether the page to which the last Quick Page Read command was
633
 *         applied was erased.
634
 */
635
extern Bool flashc_is_page_erased(void);
636
 
637
/*! \brief Applies the Quick Page Read command to a page.
638
 *
639
 * \param page_number The page number:
640
 *   \arg \c 0 to <tt>(flashc_get_page_count() - 1)</tt>: a page number within
641
 *        the flash array;
642
 *   \arg <tt>< 0</tt>: the current page number.
643
 *
644
 * \return Whether the specified page is erased.
645
 *
646
 * \note The FLASHC error status returned by \ref flashc_is_lock_error and
647
 *       \ref flashc_is_programming_error is updated.
648
 */
649
extern Bool flashc_quick_page_read(int page_number);
650
 
651
/*! \brief Erases a page.
652
 *
653
 * \param page_number The page number:
654
 *   \arg \c 0 to <tt>(flashc_get_page_count() - 1)</tt>: a page number within
655
 *        the flash array;
656
 *   \arg <tt>< 0</tt>: the current page number.
657
 * \param check Whether to check erase: \c TRUE or \c FALSE.
658
 *
659
 * \return Whether the erase succeeded or always \c TRUE if erase check was not
660
 *         requested.
661
 *
662
 * \warning A Lock Error is issued if the command is applied to a page belonging
663
 *          to a locked region or to the bootloader protected area.
664
 *
665
 * \note The FLASHC error status returned by \ref flashc_is_lock_error and
666
 *       \ref flashc_is_programming_error is updated.
667
 *
668
 * \note An erase operation can only set bits.
669
 */
670
extern Bool flashc_erase_page(int page_number, Bool check);
671
 
672
/*! \brief Erases all pages within the flash array.
673
 *
674
 * \param check Whether to check erase: \c TRUE or \c FALSE.
675
 *
676
 * \return Whether the erase succeeded or always \c TRUE if erase check was not
677
 *         requested.
678
 *
679
 * \warning A Lock Error is issued if at least one region is locked or the
680
 *          bootloader protection is active.
681
 *
682
 * \note The FLASHC error status returned by \ref flashc_is_lock_error and
683
 *       \ref flashc_is_programming_error is updated.
684
 *
685
 * \note An erase operation can only set bits.
686
 */
687
extern Bool flashc_erase_all_pages(Bool check);
688
 
689
/*! \brief Writes a page from the page buffer.
690
 *
691
 * \param page_number The page number:
692
 *   \arg \c 0 to <tt>(flashc_get_page_count() - 1)</tt>: a page number within
693
 *        the flash array;
694
 *   \arg <tt>< 0</tt>: the current page number.
695
 *
696
 * \warning A Lock Error is issued if the command is applied to a page belonging
697
 *          to a locked region or to the bootloader protected area.
698
 *
699
 * \warning The page buffer is not automatically reset after a page write.
700
 *
701
 * \note The FLASHC error status returned by \ref flashc_is_lock_error and
702
 *       \ref flashc_is_programming_error is updated.
703
 *
704
 * \note A write operation can only clear bits.
705
 */
706
extern void flashc_write_page(int page_number);
707
 
708
/*! \brief Checks whether the User page is erased.
709
 *
710
 * \return Whether the User page is erased.
711
 */
712
extern Bool flashc_check_user_page_erase(void);
713
 
714
/*! \brief Erases the User page.
715
 *
716
 * \param check Whether to check erase: \c TRUE or \c FALSE.
717
 *
718
 * \return Whether the erase succeeded or always \c TRUE if erase check was not
719
 *         requested.
720
 *
721
 * \note The FLASHC error status returned by \ref flashc_is_lock_error and
722
 *       \ref flashc_is_programming_error is updated.
723
 *
724
 * \note An erase operation can only set bits.
725
 */
726
extern Bool flashc_erase_user_page(Bool check);
727
 
728
/*! \brief Writes the User page from the page buffer.
729
 *
730
 * \warning The page buffer is not automatically reset after a page write.
731
 *
732
 * \note The FLASHC error status returned by \ref flashc_is_lock_error and
733
 *       \ref flashc_is_programming_error is updated.
734
 *
735
 * \note A write operation can only clear bits.
736
 */
737
extern void flashc_write_user_page(void);
738
 
739
/*! \brief Copies \a nbytes bytes to the flash destination pointed to by \a dst
740
 *         from the repeated \a src source byte.
741
 *
742
 * The destination areas that are not within the flash array or the User page
743
 * are ignored.
744
 *
745
 * All pointer and size alignments are supported.
746
 *
747
 * \param dst Pointer to flash destination.
748
 * \param src Source byte.
749
 * \param nbytes Number of bytes to set.
750
 * \param erase Whether to erase before writing: \c TRUE or \c FALSE.
751
 *
752
 * \return The value of \a dst.
753
 *
754
 * \warning A Lock Error is issued if the command is applied to pages belonging
755
 *          to a locked region or to the bootloader protected area.
756
 *
757
 * \note The FLASHC error status returned by \ref flashc_is_lock_error and
758
 *       \ref flashc_is_programming_error is updated.
759
 */
760
extern volatile void *flashc_memset8(volatile void *dst, U8 src, size_t nbytes, Bool erase);
761
 
762
/*! \brief Copies \a nbytes bytes to the flash destination pointed to by \a dst
763
 *         from the repeated \a src big-endian source half-word.
764
 *
765
 * The destination areas that are not within the flash array or the User page
766
 * are ignored.
767
 *
768
 * All pointer and size alignments are supported.
769
 *
770
 * \param dst Pointer to flash destination.
771
 * \param src Source half-word.
772
 * \param nbytes Number of bytes to set.
773
 * \param erase Whether to erase before writing: \c TRUE or \c FALSE.
774
 *
775
 * \return The value of \a dst.
776
 *
777
 * \warning A Lock Error is issued if the command is applied to pages belonging
778
 *          to a locked region or to the bootloader protected area.
779
 *
780
 * \note The FLASHC error status returned by \ref flashc_is_lock_error and
781
 *       \ref flashc_is_programming_error is updated.
782
 */
783
extern volatile void *flashc_memset16(volatile void *dst, U16 src, size_t nbytes, Bool erase);
784
 
785
/*! \brief Copies \a nbytes bytes to the flash destination pointed to by \a dst
786
 *         from the repeated \a src big-endian source word.
787
 *
788
 * The destination areas that are not within the flash array or the User page
789
 * are ignored.
790
 *
791
 * All pointer and size alignments are supported.
792
 *
793
 * \param dst Pointer to flash destination.
794
 * \param src Source word.
795
 * \param nbytes Number of bytes to set.
796
 * \param erase Whether to erase before writing: \c TRUE or \c FALSE.
797
 *
798
 * \return The value of \a dst.
799
 *
800
 * \warning A Lock Error is issued if the command is applied to pages belonging
801
 *          to a locked region or to the bootloader protected area.
802
 *
803
 * \note The FLASHC error status returned by \ref flashc_is_lock_error and
804
 *       \ref flashc_is_programming_error is updated.
805
 */
806
extern volatile void *flashc_memset32(volatile void *dst, U32 src, size_t nbytes, Bool erase);
807
 
808
/*! \brief Copies \a nbytes bytes to the flash destination pointed to by \a dst
809
 *         from the repeated \a src big-endian source double-word.
810
 *
811
 * The destination areas that are not within the flash array or the User page
812
 * are ignored.
813
 *
814
 * All pointer and size alignments are supported.
815
 *
816
 * \param dst Pointer to flash destination.
817
 * \param src Source double-word.
818
 * \param nbytes Number of bytes to set.
819
 * \param erase Whether to erase before writing: \c TRUE or \c FALSE.
820
 *
821
 * \return The value of \a dst.
822
 *
823
 * \warning A Lock Error is issued if the command is applied to pages belonging
824
 *          to a locked region or to the bootloader protected area.
825
 *
826
 * \note The FLASHC error status returned by \ref flashc_is_lock_error and
827
 *       \ref flashc_is_programming_error is updated.
828
 */
829
extern volatile void *flashc_memset64(volatile void *dst, U64 src, size_t nbytes, Bool erase);
830
 
831
/*! \brief Copies \a nbytes bytes to the flash destination pointed to by \a dst
832
 *         from the repeated \a src big-endian source pattern.
833
 *
834
 * The destination areas that are not within the flash array or the User page
835
 * are ignored.
836
 *
837
 * All pointer and size alignments are supported.
838
 *
839
 * \param dst Pointer to flash destination.
840
 * \param src Source double-word.
841
 * \param src_width \a src width in bits: 8, 16, 32 or 64.
842
 * \param nbytes Number of bytes to set.
843
 * \param erase Whether to erase before writing: \c TRUE or \c FALSE.
844
 *
845
 * \return The value of \a dst.
846
 *
847
 * \warning A Lock Error is issued if the command is applied to pages belonging
848
 *          to a locked region or to the bootloader protected area.
849
 *
850
 * \note The FLASHC error status returned by \ref flashc_is_lock_error and
851
 *       \ref flashc_is_programming_error is updated.
852
 */
853
#define flashc_memset(dst, src, src_width, nbytes, erase) \
854
          TPASTE2(flashc_memset, src_width)((dst), (src), (nbytes), (erase))
855
 
856
/*! \brief Copies \a nbytes bytes to the flash destination pointed to by \a dst
857
 *         from the source pointed to by \a src.
858
 *
859
 * The destination areas that are not within the flash array or the User page
860
 * are ignored.
861
 *
862
 * All pointer and size alignments are supported.
863
 *
864
 * \param dst Pointer to flash destination.
865
 * \param src Pointer to source data.
866
 * \param nbytes Number of bytes to copy.
867
 * \param erase Whether to erase before writing: \c TRUE or \c FALSE.
868
 *
869
 * \return The value of \a dst.
870
 *
871
 * \warning If copying takes place between areas that overlap, the behavior is
872
 *          undefined.
873
 *
874
 * \warning A Lock Error is issued if the command is applied to pages belonging
875
 *          to a locked region or to the bootloader protected area.
876
 *
877
 * \note The FLASHC error status returned by \ref flashc_is_lock_error and
878
 *       \ref flashc_is_programming_error is updated.
879
 */
880
extern volatile void *flashc_memcpy(volatile void *dst, const void *src, size_t nbytes, Bool erase);
881
 
882
//! @}
883
 
884
 
885
#endif  // _FLASHC_H_

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.