From cb5ac008ef47b00966b573c2df2c1eeacf452b98 Mon Sep 17 00:00:00 2001 From: asterix Date: Tue, 11 May 2010 10:13:50 +0000 Subject: [PATCH] Add flash module. Refactor the cpu implementation. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3647 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/drv/flash.h | 109 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 bertos/drv/flash.h diff --git a/bertos/drv/flash.h b/bertos/drv/flash.h new file mode 100644 index 00000000..eda1e985 --- /dev/null +++ b/bertos/drv/flash.h @@ -0,0 +1,109 @@ +/** +* \file +* +* +* +* \brief Embedded flash for cpu. +* +* \author Francesco Sacchi +* \author Daniele Basile +* +* $WIZ$ module_name = "flash" +* $WIZ$ module_depends = "kfile" +*/ + +#ifndef DRV_FLASH_H +#define DRV_FLASH_H + +#include +#include + + +#include CPU_HEADER(flash) + +/** +* EmbFlash KFile context structure. +*/ +typedef struct Flash +{ + /** + * File descriptor. + */ + KFile fd; + + /** + * Flag for checking if current page is modified. + */ + bool page_dirty; + + /** + * Current buffered page. + */ + page_t curr_page; + + /** + * Temporary buffer cointaing data block to + * write on flash. + */ + uint8_t page_buf[FLASH_PAGE_SIZE]; +} Flash; + +/** +* ID for FLASH +*/ +#define KFT_FLASH MAKE_ID('F', 'L', 'A', 'S') + +/** +* Convert + ASSERT from generic KFile to Flash. +*/ +INLINE Flash * FLASH_CAST(KFile *fd) +{ + ASSERT(fd->_type == KFT_FLASH); + return (Flash *)fd; +} + + +MOD_DEFINE(flash); + +/** + * + * Initialize PWM hw. + */ +INLINE void flash_init(Flash *fd) +{ + flash_hw_init(fd); + + MOD_INIT(flash); +} + + + +#endif /* DRV_FLASH_H */ + -- 2.25.1