From e644d87ce064f7de0ab198707433c2e215ea5be0 Mon Sep 17 00:00:00 2001 From: Nélio Laranjeiro Date: Thu, 21 Feb 2008 23:16:48 +0100 Subject: Added the flash module only with the header file. --- digital/avr/modules/flash/flash.h | 97 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 digital/avr/modules/flash/flash.h (limited to 'digital') diff --git a/digital/avr/modules/flash/flash.h b/digital/avr/modules/flash/flash.h new file mode 100644 index 00000000..56f95582 --- /dev/null +++ b/digital/avr/modules/flash/flash.h @@ -0,0 +1,97 @@ +#ifndef flash_h +#define flash_h +/* flash.h */ +/* avr.modules - AVR modules. {{{ + * + * Copyright (C) 2008 Nélio Laranjeiro + * + * APBTeam: + * Web: http://apbteam.org/ + * Email: team AT apbteam DOT org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * }}} */ + +struct flash_t +{ + /** Current Address in the flash memory. */ + uint8_t addr; +}; +typedef struct flash_t flash_t; + +/** Write in the flash byte provided in parameter. + * \param addr the address to store the data. + * \param data the buffer to store the data. + */ +void +flash_write (uint8_t addr, uint8_t data); + +/** Read the data at the address provided. + * \param addr the address of the data to read. + * \return the data read. + */ +uint8_t +flash_read (uint8_t addr); + +/** Read a data from the flash memory from the address provided and for a + * length of the number of bytes provided. + * \param address at wich the data should be read. + * \param buffer the buffer to fill with the read data. + * \param length the length of the data to read. + */ +void +flash_read_array (uint8_t addr, uint8_t *buffer, uint8_t length); + +/** Write in the flash byte provided in parameter. + * \param addr the address to store the data. + * \param data the array to store. + * \param length the array length + */ +void +flash_write_array (uint8_t addr, uint8_t *data, uint8_t length); + +/** Read the memory from the address automaticaly managed, the offset of the + * data shall be provided to get the data. + * \param offset the offset from the current address managed. + * \return data read from the memory. + */ +uint8_t +flash_read_managed (uint8_t offset); + +/** Read an array of data from the memory starting at the address less the + * offset provided in parameters. The data read will be stored in the buffer + * provided in memory too. The buffer shall have at list the length of the + * offset provided. + * \param offset the offset of the current position to read the data. + * \param buffer the buffer to store the data. + */ +void +flash_read_managed_array (uint8_t offset, uint8_t *buffer); + +/** Write a data with a managed array. + * \param data to store in the memory. + */ +flash_write_managed (uint8_t data); + +/** Write an array of data to the flash memory. The length of the array shall + * be provided. + * \param buffer the buffer containing the data to write. + * \param length the data length to write. + */ +void +flash_write_managed_array (uint8_t *buffer, uint8_t length); + +#endif /* flash_h */ -- cgit v1.2.3