flash_avr.c File Reference
Self programming routines. More...
#include "flash_avr.h"#include "cfg/cfg_flash_avr.h"#include <cfg/macros.h>#include <cfg/compiler.h>#include <cfg/debug.h>#include <cpu/irq.h>#include <cfg/log.h>#include <drv/wdt.h>#include <kern/kfile.h>#include <avr/io.h>#include <avr/boot.h>#include <avr/pgmspace.h>#include <string.h>Go to the source code of this file.
Typedefs | |
| typedef uint16_t | avr_page_addr_t |
| Definition of type for avr flash module. | |
Functions | |
| static void | flash_avr_flush (FlashAvr *fd) |
| Private avr flush funtion. | |
| static int | flash_avr_kfileFlush (struct KFile *_fd) |
| Flush avr flash function. | |
| static void | flash_avr_loadPage (FlashAvr *fd, avr_page_t page) |
| Check current page and if page is different, load it in temporary buffer. | |
| static size_t | flash_avr_write (struct KFile *_fd, const void *_buf, size_t size) |
| Write program memory. | |
| static void | flash_avr_open (struct FlashAvr *fd) |
| Open flash file fd name and mode are unused, cause flash memory is threated like one file. | |
| static int | flash_avr_close (struct KFile *_fd) |
| Close file fd. | |
| static struct KFile * | flash_avr_reopen (struct KFile *fd) |
| Reopen file fd. | |
| static size_t | flash_avr_read (struct KFile *_fd, void *buf, size_t size) |
| Read from file fd size bytes and put it in buffer buf. | |
| void | flash_avr_init (struct FlashAvr *fd) |
| Init AVR flash read/write file. | |
Detailed Description
Self programming routines.
- Version:
- Id
- flash_avr.c 2506 2009-04-15 08:29:07Z duplo
This module implements a kfile-like access for Atmel avr internal flash. Internal flash writing access is controlled by BOOTSZ fuses, check datasheet for details.
Definition in file flash_avr.c.
Function Documentation
| static void flash_avr_flush | ( | FlashAvr * | fd | ) | [static] |
Private avr flush funtion.
Write current buffered page in flash memory (if modified). This function erase flash memory page before writing.
This function is only use internally in this module.
Definition at line 85 of file flash_avr.c.
| static int flash_avr_kfileFlush | ( | struct KFile * | _fd | ) | [static] |
Flush avr flash function.
Write current buffered page in flash memory (if modified). This function erase flash memory page before writing.
Definition at line 141 of file flash_avr.c.
| static size_t flash_avr_read | ( | struct KFile * | _fd, | |
| void * | buf, | |||
| size_t | size | |||
| ) | [static] |
Read from file fd size bytes and put it in buffer buf.
- Returns:
- the number of bytes read.
Definition at line 248 of file flash_avr.c.
| static size_t flash_avr_write | ( | struct KFile * | _fd, | |
| const void * | _buf, | |||
| size_t | size | |||
| ) | [static] |
Write program memory.
Write size bytes from buffer _buf to file fd
- Note:
- Write operations are buffered.
Definition at line 170 of file flash_avr.c.
