-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
drivers/at24cxxx: eeprom api wrapper for eepreg
- Loading branch information
Showing
6 changed files
with
153 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
SRC := $(filter-out eeprom_wrapper.c,$(wildcard *.c)) | ||
|
||
# enable submodules | ||
SUBMODULES := 1 | ||
|
||
include $(RIOTBASE)/Makefile.base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
/* | ||
* Copyright (C) 2019 Otto-von-Guericke-Universität Magdeburg | ||
* | ||
* This file is subject to the terms and conditions of the GNU Lesser | ||
* General Public License v2.1. See the file LICENSE in the top level | ||
* directory for more details. | ||
*/ | ||
|
||
/** | ||
* @ingroup drivers_at24cxxx | ||
* @{ | ||
* | ||
* @file | ||
* @brief Implementation of expected EEPROM interface, expected by EEPROM registry | ||
* | ||
* @author Fabian Hüßler <fabian.huessler@ovgu.de> | ||
* @} | ||
*/ | ||
|
||
#include "at24cxxx.h" | ||
|
||
/** | ||
* @brief Wrapper around @see at24cxxx_read_byte that uses | ||
* the first parameters in the at24cxxx_params array | ||
* | ||
* This allows the use of EEPROM registry. | ||
* | ||
* @param[in] pos position in EEPROM memory | ||
* | ||
* @return Read byte | ||
*/ | ||
uint8_t eeprom_read_byte(uint32_t pos) | ||
{ | ||
return at24cxxx_read_byte( | ||
at24cxxx_get_default_dev(), pos); | ||
} | ||
|
||
/** | ||
* @brief Wrapper around @see at24cxxx_read that uses | ||
* the first parameters in the at24cxxx_params array | ||
* | ||
* This allows the use of EEPROM registry. | ||
* | ||
* @param[in] pos position in EEPROM memory | ||
* @param[out] data read buffer | ||
* @param[in] len requested length to be read | ||
* | ||
* @return @p len on success | ||
* @return 0 on failure | ||
*/ | ||
size_t eeprom_read(uint32_t pos, void *data, size_t len) | ||
{ | ||
return at24cxxx_read( | ||
at24cxxx_get_default_dev(), pos, data, len); | ||
} | ||
|
||
/** | ||
* @brief Wrapper around @see at24cxxx_write_byte that uses | ||
* the first parameters in the at24cxxx_params array | ||
* | ||
* This allows the use of EEPROM registry. | ||
* | ||
* @param[in] pos position in EEPROM memory | ||
* @param[in] data value to be written | ||
*/ | ||
void eeprom_write_byte(uint32_t pos, uint8_t data) | ||
{ | ||
at24cxxx_write_byte( | ||
at24cxxx_get_default_dev(), pos, data); | ||
} | ||
|
||
/** | ||
* @brief Wrapper around @see at24cxxx_write that uses | ||
* the first parameters in the at24cxxx_params array | ||
* | ||
* This allows the use of EEPROM registry. | ||
* | ||
* @param[in] pos position in EEPROM memory | ||
* @param[in] data write buffer | ||
* @param[in] len requested length to be written | ||
* | ||
* @return number of bytes that have been written | ||
* @return 0 on failure | ||
*/ | ||
size_t eeprom_write(uint32_t pos, const void *data, size_t len) | ||
{ | ||
return at24cxxx_write( | ||
at24cxxx_get_default_dev(), pos, data, len); | ||
} | ||
|
||
/** | ||
* @brief Wrapper around @see at24cxxx_set that uses | ||
* the first parameters in the at24cxxx_params array | ||
* | ||
* This allows the use of EEPROM registry. | ||
* | ||
* @param[in] pos position in EEPROM memory | ||
* @param[in] val value to be set | ||
* @param[in] len requested length to be written | ||
* | ||
* @return number of bytes that have been written | ||
* @return 0 on failure | ||
*/ | ||
size_t eeprom_set(uint32_t pos, uint8_t val, size_t len) | ||
{ | ||
return at24cxxx_set( | ||
at24cxxx_get_default_dev(), pos, val, len); | ||
} | ||
|
||
/** | ||
* @brief Wrapper around @see at24cxxx_clear that uses | ||
* the first parameters in the at24cxxx_params array | ||
* | ||
* This allows the use of EEPROM registry. | ||
* | ||
* @param[in] pos position in EEPROM memory | ||
* @param[in] len requested length to be written | ||
* | ||
* @return number of bytes that have been cleared | ||
*/ | ||
size_t eeprom_clear(uint32_t pos, size_t len) | ||
{ | ||
return at24cxxx_clear( | ||
at24cxxx_get_default_dev(), pos, len); | ||
} | ||
|
||
/** | ||
* @brief Wrapper around @see at24cxxx_erase that uses | ||
* the first parameters in the at24cxxx_params array | ||
* | ||
* This allows the use of EEPROM registry. | ||
* | ||
* @return number of bytes that have been cleared | ||
*/ | ||
size_t eeprom_erase(void) | ||
{ | ||
return at24cxxx_erase( | ||
at24cxxx_get_default_dev()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters