52 #include <avr/pgmspace.h>
56 #error SPM_PAGESIZE undefined!!!
67 #define MEM_BASE_ADDRESS 0x10000UL
74 bit reserved_disk_space =
FALSE;
77 U32 AVRF_DISK_SIZE = 111;
80 void avrf_check_init(
void );
124 *u32_nb_sector = AVRF_DISK_SIZE;
227 gl_ptr_mem = (pos * 512) + MEM_BASE_ADDRESS;
274 for (i = 8; i != 0; i--)
278 for (j = 0; j < 64; j++) {
293 while (nb_sector != 0);
316 gl_ptr_mem = (pos * 512) + MEM_BASE_ADDRESS;
338 #define LAST_BOOT_ENTRY 0xFFFE
341 void dfuclone_boot_buffer_write(uint16_t dummy, uint32_t baseaddr, uint16_t pageaddr, uint16_t word);
342 void dfuclone_boot_page_erase(uint32_t dummy1, uint16_t dummy2, uint32_t address);
343 void dfuclone_boot_page_write(uint32_t dummy1, uint16_t dummy2, uint32_t address);
348 #ifdef USE_AVRDFU_BOOTLOADER
350 #error UNTESTED/UNSUPPORTED AT THIS TIME
353 void (*dfu_boot_buffer_write) (uint16_t dummy, uint32_t baseaddr, uint16_t pageaddr, uint16_t word)=
354 (
void (*)(uint16_t, uint32_t, uint16_t, uint16_t))(LAST_BOOT_ENTRY-6);
356 void (*dfu_boot_page_write) (uint32_t dummy1, uint16_t dummy2, uint32_t address)=
357 (
void (*)(uint32_t, uint16_t, uint32_t))(LAST_BOOT_ENTRY-4);
359 void (*dfu_boot_page_erase) (uint32_t dummy1, uint16_t dummy2, uint32_t address)=
360 (
void (*)(uint32_t, uint16_t, uint32_t))(LAST_BOOT_ENTRY-2);
365 void (*dfu_boot_buffer_write) (uint16_t dummy, uint32_t baseaddr, uint16_t pageaddr, uint16_t word)=
366 dfuclone_boot_buffer_write;
368 void (*dfu_boot_page_write) (uint32_t dummy1, uint16_t dummy2, uint32_t address)=
369 dfuclone_boot_page_write;
371 void (*dfu_boot_page_erase) (uint32_t dummy1, uint16_t dummy2, uint32_t address)=
372 dfuclone_boot_page_erase;
406 U16 sector_bytecounter = 0;
412 for (i = 8; i != 0; i--)
421 (*dfu_boot_page_erase)(0, 0, gl_ptr_mem);
425 for (j = 0; j < 32; j++) {
428 (*dfu_boot_buffer_write)(0, gl_ptr_mem, pgindex, w);
435 if (pgindex == SPM_PAGESIZE) {
437 (*dfu_boot_page_write)(0,0, gl_ptr_mem);
441 gl_ptr_mem += SPM_PAGESIZE;
444 sector_bytecounter += SPM_PAGESIZE;
446 if(sector_bytecounter == 512) {
448 sector_bytecounter = 0;
456 while (nb_sector != 0);
462 #ifndef USE_AVRDFU_BOOTLOADER
465 BOOTLOADER_SECTION
void dfuclone_boot_buffer_write(uint16_t dummy, uint32_t baseaddr, uint16_t pageaddr, uint16_t word)
467 boot_page_fill(baseaddr + pageaddr, word);
472 BOOTLOADER_SECTION
void dfuclone_boot_page_erase(uint32_t dummy1, uint16_t dummy2, uint32_t address)
474 boot_page_erase(address);
475 boot_spm_busy_wait();
480 BOOTLOADER_SECTION
void dfuclone_boot_page_write(uint32_t dummy1, uint16_t dummy2, uint32_t address)
482 boot_page_write(address);
483 boot_spm_busy_wait();
487 #endif //USE_AVRDFU_BOOTLOADER
void avrf_read_close(void)
This function unselects the current DF memory.
void avrf_write_close(void)
This function fills the end of the logical sector (512B) and launch page programming.
Ctrl_status avrf_usb_write(void)
This fonction transfer the usb data (programed in scsi_write_10) directly to the memory data...
Ctrl_status
Define control status.
bit avrf_read_sector(Uint16 nb_sector)
This function is optimized and writes nb-sector * 512 Bytes from DataFlash memory to USB controller...
#define Usb_read_byte()
returns FIFO byte for current endpoint
bit avrf_write_open(Uint32 pos)
This function opens a DF memory in write mode at a given sector address.
This file writes/reads to/from flash memory internal to the AVR.
Ctrl_status avrf_read_10(U32 addr, U16 nb_sector)
This function performs a read operation of n sectors from a given address on.
#define Usb_write_byte(byte)
writes byte in FIFO for current endpoint
void avrf_mem_init(void)
This function initializes the hw/sw ressources required to drive the AVR Flash.
Bool avrf_wr_protect(void)
This function returns the write protected status of the memory.
Ctrl_status avrf_usb_read()
This fonction transfer the memory data (programed in scsi_read_10) directly to the usb interface...
Ctrl_status avrf_read_capacity(U32 *u32_nb_sector)
This function gives the address of the last valid sector.
#define Usb_send_in()
sends IN
Ctrl_status avrf_test_unit_ready(void)
This function tests the state of the AVR Flash.
bit avrf_read_open(Uint32 pos)
This function opens a DF memory in read mode at a given sector address.
Ctrl_status avrf_write_10(U32 addr, U16 nb_sector)
This fonction initialise the memory for a write operation.
#define Is_usb_write_enabled()
tests if endpoint write allowed
#define FALSE
An alias for zero, used for clarity.
#define Is_usb_read_enabled()
tests if endpoint read allowed
Bool avrf_removal(void)
This function tells if the memory has been removed or not.
#define Usb_ack_receive_out()
acks reveive OUT
bit avrf_write_sector(Uint16 nb_sector)
This function is optimized and writes nb-sector * 512 Bytes from USB controller to DataFlash memory...