#include "config.h"
Go to the source code of this file.
Defines | |
| #define | Flash_read_id1() ( (*boot_flash_read_sig)(0x0000)) |
| This macro function allows to read device ID1 of the product. | |
| #define | Flash_read_id2() ( (*boot_flash_read_sig)(0x0002)) |
| This macro function allows to read device ID2 of the product. | |
| #define | Flash_read_id3() ( (*boot_flash_read_sig)(0x0004)) |
| This macro function allows to read device ID3 of the product. | |
| #define | Flash_read_osccal() ( (*boot_flash_read_sig)(0x0001)) |
| This macro function allows to read the OSCAL byte of the product. | |
| #define | Flash_read_fuse_low() ( (*boot_flash_read_fuse)(0x0000)) |
| This macro function allows to read the low fuse byte of the product. | |
| #define | Flash_read_fuse_high() ( (*boot_flash_read_fuse)(0x0003)) |
| This macro function allows to read device high fuse byte of the product. | |
| #define | Flash_read_fuse_extended() ( (*boot_flash_read_fuse)(0x0002)) |
| This macro function allows to read extended fuse byte of the product. | |
| #define | Flash_read_lock() ( (*boot_flash_read_fuse)(0x0001)) |
| This macro function allows to read lock byte of the product. | |
Functions | |
| Bool | flash_lib_check (void) |
| This function checks the presence of bootloader. | |
| void | flash_wr_byte (Uint32 addr_byte, Uchar value) |
| This function allows to write a byte in the flash memory. | |
| Uchar | flash_wr_block (Byte _MemType_ *src, Uint32 dst, U16 n) |
| This function allows to write up to 65535 bytes in the flash memory. | |
| U8 | flash_rd_byte (Uchar farcode *addr) |
| This function allows to read a byte in the flash memory. | |
| U16 | flash_rd_word (U16 farcode *addr) |
| This function allows to read a word in the flash memory. | |
Variables | |
| U8(* | boot_flash_read_sig )(unsigned long adr) |
| U8(* | boot_flash_read_fuse )(unsigned long adr) |
Definition in file flash_lib.h.
| #define Flash_read_id1 | ( | ) | ( (*boot_flash_read_sig)(0x0000)) |
This macro function allows to read device ID1 of the product.
Definition at line 60 of file flash_lib.h.
| #define Flash_read_id2 | ( | ) | ( (*boot_flash_read_sig)(0x0002)) |
This macro function allows to read device ID2 of the product.
Definition at line 66 of file flash_lib.h.
| #define Flash_read_id3 | ( | ) | ( (*boot_flash_read_sig)(0x0004)) |
This macro function allows to read device ID3 of the product.
Definition at line 72 of file flash_lib.h.
| #define Flash_read_osccal | ( | ) | ( (*boot_flash_read_sig)(0x0001)) |
This macro function allows to read the OSCAL byte of the product.
Definition at line 78 of file flash_lib.h.
| #define Flash_read_fuse_low | ( | ) | ( (*boot_flash_read_fuse)(0x0000)) |
This macro function allows to read the low fuse byte of the product.
Definition at line 84 of file flash_lib.h.
| #define Flash_read_fuse_high | ( | ) | ( (*boot_flash_read_fuse)(0x0003)) |
This macro function allows to read device high fuse byte of the product.
Definition at line 90 of file flash_lib.h.
| #define Flash_read_fuse_extended | ( | ) | ( (*boot_flash_read_fuse)(0x0002)) |
This macro function allows to read extended fuse byte of the product.
Definition at line 96 of file flash_lib.h.
| #define Flash_read_lock | ( | ) | ( (*boot_flash_read_fuse)(0x0001)) |
This macro function allows to read lock byte of the product.
Definition at line 102 of file flash_lib.h.
| Bool flash_lib_check | ( | void | ) |
This function checks the presence of bootloader.
Definition at line 75 of file flash_lib.c.
References boot_flash_page_erase_and_write.
00076 { 00077 return (*((code U16*)((U32)boot_flash_page_erase_and_write*2)) != 0xFFFF); 00078 }
This function allows to write a byte in the flash memory.
| addr_byte | Address in flash memory to write the byte. | |
| value | Value to write in the flash memory |
Definition at line 86 of file flash_lib.c.
References Disable_flash, Enable_flash, and flash_wr_block().
00087 { 00088 Enable_flash(); 00089 flash_wr_block(&value, addr_byte, 1); 00090 Disable_flash(); 00091 }
This function allows to write up to 65535 bytes in the flash memory.
This function manages alignement issue.
| *src | Address of data to write. | |
| dst | Start address in flash memory where write data | |
| n | number of byte to write |
| src | Address of data to write. | |
| dst | Start address in flash memory where write data | |
| n | number of byte to write |
Definition at line 101 of file flash_lib.c.
References FALSE, flash_rd_byte(), flash_rd_word(), LOW, LSB, MSB, and TRUE.
00102 { 00103 U16 nb_word, temp16; 00104 U32 address; 00105 U32 save_page_adr; 00106 U8 page_is_blank; 00107 00108 while(n) // While there is data to load from src buffer 00109 { 00110 page_is_blank=TRUE; 00111 address=dst-(LOW(dst)%FLASH_PAGE_SIZE); // Compute the start of the page to be modified 00112 save_page_adr=address; // Memorize page addr 00113 00114 // For each word in this page 00115 for(nb_word=0;nb_word<FLASH_PAGE_SIZE/2;nb_word++) 00116 { 00117 if(n) // Still some data to load from src 00118 { 00119 if(address>=dst) // Current address is inside the target range adr 00120 { 00121 MSB(temp16)=(*(U8*)src); // Load MSB of word from buffer src 00122 src++; n--; 00123 if(n) // Still some data to load ? 00124 { 00125 LSB(temp16)=(*(U8*)src); // Load LSB of word from buffer src 00126 src++; n--; 00127 } 00128 else // Only the MSB of the working belong to src buffer 00129 { // Load LSB form exisying flash 00130 LSB(temp16)=flash_rd_byte((U8 farcode*)address+1); 00131 } 00132 } 00133 else // Current word addr out of dst target 00134 { // Load MSB from existing flash 00135 MSB(temp16)=flash_rd_byte((U8 farcode*)address); 00136 if(address+1==dst) // Is LSB word addr in dst range ? 00137 { 00138 LSB(temp16)=(*(U8*)src); 00139 src++; n--; 00140 } 00141 else // LSB read from existing flash 00142 { 00143 LSB(temp16)=flash_rd_byte((U8 farcode*)address+1); 00144 } 00145 } 00146 } 00147 else // Complete page with words from existing flash 00148 { 00149 temp16=flash_rd_word((U16 farcode*)address); 00150 } 00151 //Load temp buffer 00152 (*boot_flash_fill_temp_buffer)(temp16,address); 00153 address+=2; 00154 } 00155 address=save_page_adr; 00156 for(nb_word=0;nb_word<FLASH_PAGE_SIZE/2;nb_word++) 00157 { 00158 if(flash_rd_word((U16 farcode*)address)!=0xFFFF) // Check for Blank page 00159 { 00160 page_is_blank=FALSE; 00161 break; 00162 } 00163 address+=2; 00164 } 00165 // Now launch prog sequence (with or without page erase) 00166 address=save_page_adr; 00167 if(page_is_blank) { (*boot_flash_prg_page)(save_page_adr); } 00168 else{(*boot_flash_page_erase_and_write)(save_page_adr);} 00169 //- First Flash address update for the next page 00170 address = save_page_adr + FLASH_PAGE_SIZE; 00171 } 00172 return TRUE; 00173 }
This function allows to read a byte in the flash memory.
| *add | Address of flash memory to read. |
Definition at line 181 of file flash_lib.c.
References Disable_flash, and Enable_flash.
00182 { 00183 unsigned char temp; 00184 Enable_flash(); 00185 temp = *addr; 00186 Disable_flash(); 00187 return temp; 00188 }
This function allows to read a word in the flash memory.
| *add | Address of flash memory to read. |
Definition at line 196 of file flash_lib.c.
References Union16::b, Disable_flash, Enable_flash, flash_rd_byte(), and Union16::w.
00197 { 00198 Union16 temp; 00199 Enable_flash(); 00200 temp.b[1] = flash_rd_byte ((Uchar farcode*) addr); 00201 temp.b[0] = flash_rd_byte ((Uchar farcode*)addr+1); 00202 Disable_flash(); 00203 return temp.w; 00204 }
| U8(* boot_flash_read_sig)(unsigned long adr) |
Definition at line 60 of file flash_lib.c.
| U8(* boot_flash_read_fuse)(unsigned long adr) |
Definition at line 61 of file flash_lib.c.
1.5.3