- Main Page
- Related Pages
- Data Structures
- Files

- File List
- Globals

# flashcdw.h

Go to the documentation of this file.

    00001 /*This file is prepared for Doxygen automatic documentation generation.*/
    00017 /* Copyright (c) 2009 Atmel Corporation. All rights reserved.
    00018  *
    00019  * Redistribution and use in source and binary forms, with or without
    00020  * modification, are permitted provided that the following conditions are met:
    00021  *
    00022  * 1. Redistributions of source code must retain the above copyright notice, this
    00023  * list of conditions and the following disclaimer.
    00024  *
    00025  * 2. Redistributions in binary form must reproduce the above copyright notice,
    00026  * this list of conditions and the following disclaimer in the documentation
    00027  * and/or other materials provided with the distribution.
    00028  *
    00029  * 3. The name of Atmel may not be used to endorse or promote products derived
    00030  * from this software without specific prior written permission.
    00031  *
    00032  * 4. This software may only be redistributed and used in connection with an Atmel
    00033  * AVR product.
    00034  *
    00035  * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
    00036  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
    00037  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
    00038  * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
    00039  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    00040  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
    00041  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    00042  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    00043  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    00044  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
    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
    00068 // These defines are missing from or wrong in the toolchain header file flashcdw_101.h
    00069 // #9267
    00070 #endif
    00071
    00073 #if ((__GNUC__ && (__AVR32_UC3L016__ || __AVR32_UC3L032__ || __AVR32_UC3L064__)) \
    00074     ||(__ICCAVR32__ && (__AT32UC3L016__ || __AT32UC3L032__ || __AT32UC3L064__  )))
    00075 #undef AVR32_FLASHCDW_FWS_0_MAX_FREQ
    00076 #undef AVR32_FLASHCDW_FWS_1_MAX_FREQ
    00077 #undef AVR32_FLASHCDW_HSEN_FWS_0_MAX_FREQ
    00078 #undef AVR32_FLASHCDW_HSEN_FWS_1_MAX_FREQ
    00079 #define AVR32_FLASHCDW_FWS_0_MAX_FREQ           15000000
    00080 #define AVR32_FLASHCDW_FWS_1_MAX_FREQ           30000000
    00081 #define AVR32_FLASHCDW_HSEN_FWS_0_MAX_FREQ      25000000
    00082 #define AVR32_FLASHCDW_HSEN_FWS_1_MAX_FREQ      50000000
    00083 // These defines are missing from or wrong in the toolchain header files uc3lxxx.h
    00084 // #9565
    00085 #endif
    00086
    00087
    00089 #define AVR32_FLASHCDW_REGIONS  (AVR32_FLASHCDW_FLASH_SIZE /\
    00090                                (AVR32_FLASHCDW_PAGES_PR_REGION * AVR32_FLASHCDW_PAGE_SIZE))
    00091
    00093 #define AVR32_FLASHCDW_FGPFRLO_SECURE_SSEN_SSDDIS                         2
    00094
    00096 #define AVR32_FLASHCDW_FGPFRLO_SECURE_SSEN_SSDEN                          1
    00097
    00098
    00101
    00102
    00107 extern unsigned int flashcdw_get_flash_size(void);
    00108
    00113 extern unsigned int flashcdw_get_page_count(void);
    00114
    00119 extern unsigned int flashcdw_get_page_count_per_region(void);
    00120
    00130 extern unsigned int flashcdw_get_page_region(int page_number);
    00131
    00138 extern unsigned int flashcdw_get_region_first_page_number(unsigned int region);
    00139
    00141
    00142
    00145
    00146
    00151 extern unsigned int flashcdw_get_wait_state(void);
    00152
    00158 extern void flashcdw_set_wait_state(unsigned int wait_state);
    00159
    00165 void flashcdw_set_flash_waitstate_and_readmode(unsigned long cpu_f_hz);
    00166
    00171 extern Bool flashcdw_is_ready_int_enabled(void);
    00172
    00178 extern void flashcdw_enable_ready_int(Bool enable);
    00179
    00184 extern Bool flashcdw_is_lock_error_int_enabled(void);
    00185
    00191 extern void flashcdw_enable_lock_error_int(Bool enable);
    00192
    00197 extern Bool flashcdw_is_prog_error_int_enabled(void);
    00198
    00204 extern void flashcdw_enable_prog_error_int(Bool enable);
    00205
    00207
    00208
    00211
    00212
    00217 extern Bool flashcdw_is_ready(void);
    00218
    00223 extern void flashcdw_default_wait_until_ready(void);
    00224
    00229 extern void (*volatile flashcdw_wait_until_ready)(void);
    00230
    00237 extern Bool flashcdw_is_lock_error(void);
    00238
    00245 extern Bool flashcdw_is_programming_error(void);
    00246
    00251 extern Bool flashcdw_is_high_speed_enabled(void);
    00252
    00254
    00255
    00258
    00259
    00264 extern unsigned int flashcdw_get_command(void);
    00265
    00270 extern unsigned int flashcdw_get_page_number(void);
    00271
    00291 extern void flashcdw_issue_command(unsigned int command, int page_number);
    00292
    00294
    00295
    00298
    00299
    00305 extern void flashcdw_no_operation(void);
    00306
    00323 extern void flashcdw_erase_all(void);
    00324
    00326
    00327
    00330
    00331
    00336 extern Bool flashcdw_is_security_bit_active(void);
    00337
    00343 extern void flashcdw_activate_security_bit(void);
    00344
    00349 extern unsigned int flashcdw_get_bootloader_protected_size(void);
    00350
    00365 extern unsigned int flashcdw_set_bootloader_protected_size(unsigned int bootprot_size);
    00366
    00371 extern Bool flashcdw_is_external_privileged_fetch_locked(void);
    00372
    00382 extern void flashcdw_lock_external_privileged_fetch(Bool lock);
    00383
    00388 extern Bool flashcdw_is_jtag_user_protection_enabled(void);
    00389
    00397 extern void flashcdw_enable_jtag_user_protection(void);
    00398
    00406 extern void flashcdw_disable_jtag_user_protection(void);
    00407
    00412 extern Bool flashcdw_is_secure_state_enabled(void);
    00413
    00418 extern Bool flashcdw_is_secure_state_debug_enabled(void);
    00419
    00427 extern void flashcdw_enable_secure_state_no_debug(void);
    00428
    00436 extern void flashcdw_enable_secure_state_with_debug(void);
    00437
    00447 extern Bool flashcdw_is_page_region_locked(int page_number);
    00448
    00455 extern Bool flashcdw_is_region_locked(unsigned int region);
    00456
    00469 extern void flashcdw_lock_page_region(int page_number, Bool lock);
    00470
    00479 extern void flashcdw_lock_region(unsigned int region, Bool lock);
    00480
    00488 extern void flashcdw_lock_all_regions(Bool lock);
    00489
    00491
    00492
    00495
    00496
    00507 extern Bool flashcdw_read_gp_fuse_bit(unsigned int gp_fuse_bit);
    00508
    00522 extern U64 flashcdw_read_gp_fuse_bitfield(unsigned int pos, unsigned int width);
    00523
    00534 extern U8 flashcdw_read_gp_fuse_byte(unsigned int gp_fuse_byte);
    00535
    00544 extern U64 flashcdw_read_all_gp_fuses(void);
    00545
    00567 extern Bool flashcdw_erase_gp_fuse_bit(unsigned int gp_fuse_bit, Bool check);
    00568
    00593 extern Bool flashcdw_erase_gp_fuse_bitfield(unsigned int pos, unsigned int width, Bool check);
    00594
    00615 extern Bool flashcdw_erase_gp_fuse_byte(unsigned int gp_fuse_byte, Bool check);
    00616
    00636 extern Bool flashcdw_erase_all_gp_fuses(Bool check);
    00637
    00656 extern void flashcdw_write_gp_fuse_bit(unsigned int gp_fuse_bit, Bool value);
    00657
    00679 extern void flashcdw_write_gp_fuse_bitfield(unsigned int pos, unsigned int width, U64 value);
    00680
    00698 extern void flashcdw_write_gp_fuse_byte(unsigned int gp_fuse_byte, U8 value);
    00699
    00716 extern void flashcdw_write_all_gp_fuses(U64 value);
    00717
    00735 extern void flashcdw_set_gp_fuse_bit(unsigned int gp_fuse_bit, Bool value);
    00736
    00757 extern void flashcdw_set_gp_fuse_bitfield(unsigned int pos, unsigned int width, U64 value);
    00758
    00775 extern void flashcdw_set_gp_fuse_byte(unsigned int gp_fuse_byte, U8 value);
    00776
    00792 extern void flashcdw_set_all_gp_fuses(U64 value);
    00793
    00795
    00796
    00799
    00800
    00811 extern void flashcdw_clear_page_buffer(void);
    00812
    00819 extern Bool flashcdw_is_page_erased(void);
    00820
    00833 extern Bool flashcdw_quick_page_read(int page_number);
    00834
    00855 extern Bool flashcdw_erase_page(int page_number, Bool check);
    00856
    00872 extern Bool flashcdw_erase_all_pages(Bool check);
    00873
    00892 extern void flashcdw_write_page(int page_number);
    00893
    00901 extern Bool flashcdw_quick_user_page_read(void);
    00902
    00915 extern Bool flashcdw_erase_user_page(Bool check);
    00916
    00926 extern void flashcdw_write_user_page(void);
    00927
    00956 extern volatile void *flashcdw_memset8(volatile void *dst, U8 src, size_t nbytes, Bool erase);
    00957
    00986 extern volatile void *flashcdw_memset16(volatile void *dst, U16 src, size_t nbytes, Bool erase);
    00987
    01016 extern volatile void *flashcdw_memset32(volatile void *dst, U32 src, size_t nbytes, Bool erase);
    01017
    01046 extern volatile void *flashcdw_memset64(volatile void *dst, U64 src, size_t nbytes, Bool erase);
    01047
    01077 #define flashcdw_memset(dst, src, src_width, nbytes, erase) \
    01078           TPASTE2(flashcdw_memset, src_width)((dst), (src), (nbytes), (erase))
    01079
    01111 extern volatile void *flashcdw_memcpy(volatile void *dst, const void *src, size_t nbytes, Bool erase);
    01112
    01114
    01115
    01116 #endif  // _FLASHCDW_H_