00001
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 #ifndef _FLASHCDW_H_
00049 #define _FLASHCDW_H_
00050
00051 #include <avr32/io.h>
00052 #include <stddef.h>
00053 #include "compiler.h"
00054
00055
00056 #ifdef AVR32_FLASHCDW_101_H_INCLUDED
00057
00058 #define AVR32_FLASHCDW_FGPFRLO_UPROT 22
00059 #define AVR32_FLASHCDW_FGPFRLO_UPROT_MASK 0x00400000
00060 #define AVR32_FLASHCDW_FGPFRLO_UPROT_OFFSET 22
00061 #define AVR32_FLASHCDW_FGPFRLO_UPROT_SIZE 1
00062
00063 #define AVR32_FLASHCDW_FGPFRLO_SECURE 20
00064 #define AVR32_FLASHCDW_FGPFRLO_SECURE_MASK 0x00300000
00065 #define AVR32_FLASHCDW_FGPFRLO_SECURE_OFFSET 20
00066 #define AVR32_FLASHCDW_FGPFRLO_SECURE_SIZE 2
00067
00069 #define AVR32_FLASHCDW_FGPFRLO_SECURE_SSEN_SSDDIS 2
00070
00072 #define AVR32_FLASHCDW_FGPFRLO_SECURE_SSEN_SSDEN 1
00073
00074
00075
00076 #endif
00077
00078
00080 #define AVR32_FLASHCDW_REGIONS (AVR32_FLASHCDW_FLASH_SIZE /\
00081 (AVR32_FLASHCDW_PAGES_PR_REGION * AVR32_FLASHCDW_PAGE_SIZE))
00082
00083
00086
00087
00092 extern unsigned int flashcdw_get_flash_size(void);
00093
00098 extern unsigned int flashcdw_get_page_count(void);
00099
00104 extern unsigned int flashcdw_get_page_count_per_region(void);
00105
00115 extern unsigned int flashcdw_get_page_region(int page_number);
00116
00123 extern unsigned int flashcdw_get_region_first_page_number(unsigned int region);
00124
00126
00127
00130
00131
00136 extern unsigned int flashcdw_get_wait_state(void);
00137
00143 extern void flashcdw_set_wait_state(unsigned int wait_state);
00144
00150 void flashcdw_set_flash_waitstate_and_readmode(unsigned long cpu_f_hz);
00151
00156 extern Bool flashcdw_is_ready_int_enabled(void);
00157
00163 extern void flashcdw_enable_ready_int(Bool enable);
00164
00169 extern Bool flashcdw_is_lock_error_int_enabled(void);
00170
00176 extern void flashcdw_enable_lock_error_int(Bool enable);
00177
00182 extern Bool flashcdw_is_prog_error_int_enabled(void);
00183
00189 extern void flashcdw_enable_prog_error_int(Bool enable);
00190
00192
00193
00196
00197
00202 extern Bool flashcdw_is_ready(void);
00203
00208 extern void flashcdw_default_wait_until_ready(void);
00209
00214 extern void (*volatile flashcdw_wait_until_ready)(void);
00215
00222 extern Bool flashcdw_is_lock_error(void);
00223
00230 extern Bool flashcdw_is_programming_error(void);
00231
00236 extern Bool flashcdw_is_high_speed_enabled(void);
00237
00239
00240
00243
00244
00249 extern unsigned int flashcdw_get_command(void);
00250
00255 extern unsigned int flashcdw_get_page_number(void);
00256
00276 extern void flashcdw_issue_command(unsigned int command, int page_number);
00277
00279
00280
00283
00284
00290 extern void flashcdw_no_operation(void);
00291
00308 extern void flashcdw_erase_all(void);
00309
00311
00312
00315
00316
00321 extern Bool flashcdw_is_security_bit_active(void);
00322
00328 extern void flashcdw_activate_security_bit(void);
00329
00334 extern unsigned int flashcdw_get_bootloader_protected_size(void);
00335
00350 extern unsigned int flashcdw_set_bootloader_protected_size(unsigned int bootprot_size);
00351
00356 extern Bool flashcdw_is_external_privileged_fetch_locked(void);
00357
00367 extern void flashcdw_lock_external_privileged_fetch(Bool lock);
00368
00373 extern Bool flashcdw_is_jtag_user_protection_enabled(void);
00374
00382 extern void flashcdw_enable_jtag_user_protection(void);
00383
00391 extern void flashcdw_disable_jtag_user_protection(void);
00392
00397 extern Bool flashcdw_is_secure_state_enabled(void);
00398
00403 extern Bool flashcdw_is_secure_state_debug_enabled(void);
00404
00412 extern void flashcdw_enable_secure_state_no_debug(void);
00413
00421 extern void flashcdw_enable_secure_state_with_debug(void);
00422
00432 extern Bool flashcdw_is_page_region_locked(int page_number);
00433
00440 extern Bool flashcdw_is_region_locked(unsigned int region);
00441
00454 extern void flashcdw_lock_page_region(int page_number, Bool lock);
00455
00464 extern void flashcdw_lock_region(unsigned int region, Bool lock);
00465
00473 extern void flashcdw_lock_all_regions(Bool lock);
00474
00476
00477
00480
00481
00492 extern Bool flashcdw_read_gp_fuse_bit(unsigned int gp_fuse_bit);
00493
00507 extern U64 flashcdw_read_gp_fuse_bitfield(unsigned int pos, unsigned int width);
00508
00519 extern U8 flashcdw_read_gp_fuse_byte(unsigned int gp_fuse_byte);
00520
00529 extern U64 flashcdw_read_all_gp_fuses(void);
00530
00552 extern Bool flashcdw_erase_gp_fuse_bit(unsigned int gp_fuse_bit, Bool check);
00553
00578 extern Bool flashcdw_erase_gp_fuse_bitfield(unsigned int pos, unsigned int width, Bool check);
00579
00600 extern Bool flashcdw_erase_gp_fuse_byte(unsigned int gp_fuse_byte, Bool check);
00601
00621 extern Bool flashcdw_erase_all_gp_fuses(Bool check);
00622
00641 extern void flashcdw_write_gp_fuse_bit(unsigned int gp_fuse_bit, Bool value);
00642
00664 extern void flashcdw_write_gp_fuse_bitfield(unsigned int pos, unsigned int width, U64 value);
00665
00683 extern void flashcdw_write_gp_fuse_byte(unsigned int gp_fuse_byte, U8 value);
00684
00701 extern void flashcdw_write_all_gp_fuses(U64 value);
00702
00720 extern void flashcdw_set_gp_fuse_bit(unsigned int gp_fuse_bit, Bool value);
00721
00742 extern void flashcdw_set_gp_fuse_bitfield(unsigned int pos, unsigned int width, U64 value);
00743
00760 extern void flashcdw_set_gp_fuse_byte(unsigned int gp_fuse_byte, U8 value);
00761
00777 extern void flashcdw_set_all_gp_fuses(U64 value);
00778
00780
00781
00784
00785
00796 extern void flashcdw_clear_page_buffer(void);
00797
00804 extern Bool flashcdw_is_page_erased(void);
00805
00818 extern Bool flashcdw_quick_page_read(int page_number);
00819
00840 extern Bool flashcdw_erase_page(int page_number, Bool check);
00841
00857 extern Bool flashcdw_erase_all_pages(Bool check);
00858
00877 extern void flashcdw_write_page(int page_number);
00878
00886 extern Bool flashcdw_quick_user_page_read(void);
00887
00900 extern Bool flashcdw_erase_user_page(Bool check);
00901
00911 extern void flashcdw_write_user_page(void);
00912
00941 extern volatile void *flashcdw_memset8(volatile void *dst, U8 src, size_t nbytes, Bool erase);
00942
00971 extern volatile void *flashcdw_memset16(volatile void *dst, U16 src, size_t nbytes, Bool erase);
00972
01001 extern volatile void *flashcdw_memset32(volatile void *dst, U32 src, size_t nbytes, Bool erase);
01002
01031 extern volatile void *flashcdw_memset64(volatile void *dst, U64 src, size_t nbytes, Bool erase);
01032
01062 #define flashcdw_memset(dst, src, src_width, nbytes, erase) \
01063 TPASTE2(flashcdw_memset, src_width)((dst), (src), (nbytes), (erase))
01064
01096 extern volatile void *flashcdw_memcpy(volatile void *dst, const void *src, size_t nbytes, Bool erase);
01097
01099
01100
01101 #endif // _FLASHCDW_H_