diff options
author | Uladzimir Pylinski <barthess@yandex.ru> | 2016-02-17 22:45:56 +0300 |
---|---|---|
committer | Uladzimir Pylinski <barthess@yandex.ru> | 2016-02-17 22:45:56 +0300 |
commit | d56a6f02425c6b7780953dc99fb5d0966165ec59 (patch) | |
tree | c76651f270fd186e2c3d0fc7db93b6b2777c17d0 /os/hal/include/ee24xx.h | |
parent | 31066ddfbffd2ee801e63c090e30929bae5b0e43 (diff) | |
parent | 9028916e8b89dcf9f8b41cefbd075efdf80cbac6 (diff) | |
download | ChibiOS-Contrib-d56a6f02425c6b7780953dc99fb5d0966165ec59.tar.gz ChibiOS-Contrib-d56a6f02425c6b7780953dc99fb5d0966165ec59.tar.bz2 ChibiOS-Contrib-d56a6f02425c6b7780953dc99fb5d0966165ec59.zip |
Merge pull request #42 from fpoussin/eeprom-pull
EEPROM Driver (pull request #42 from fpoussin/eeprom-pull)
The original driver was from barthess, modified by timonwong, fixed/cleaned it for 3.x/16.x+
Url: https://github.com/timonwong/ChibiOS-EEPROM
Testhal included, tested on real hardware as well for the SPI part.
Diffstat (limited to 'os/hal/include/ee24xx.h')
-rw-r--r-- | os/hal/include/ee24xx.h | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/os/hal/include/ee24xx.h b/os/hal/include/ee24xx.h new file mode 100644 index 0000000..ab12fd1 --- /dev/null +++ b/os/hal/include/ee24xx.h @@ -0,0 +1,64 @@ +/* + Copyright 2012 Uladzimir Pylinski aka barthess. + You may use this work without restrictions, as long as this notice is included. + The work is provided "as is" without warranty of any kind, neither express nor implied. +*/ + +#ifndef EE24XX_H +#define EE24XX_H + +#include "hal.h" + +#if defined(HAL_USE_EEPROM) && HAL_USE_EEPROM && EEPROM_USE_EE24XX + +#define EEPROM_DEV_24XX 24 + +/** + * @extends EepromFileConfig + */ +typedef struct { + _eeprom_file_config_data + /** + * Driver connected to IC. + */ + I2CDriver *i2cp; + /** + * Address of IC on I2C bus. + */ + i2caddr_t addr; + /** + * Pointer to write buffer. The safest size is (pagesize + 2) + */ + uint8_t *write_buf; +} I2CEepromFileConfig; + +/** + * @brief @p I2CEepromFileStream specific data. + */ +#define _eeprom_file_stream_data_i2c \ + _eeprom_file_stream_data + +/** + * @extends EepromFileStream + * + * @brief EEPROM file stream driver class for I2C device. + */ +typedef struct { + const struct EepromFileStreamVMT *vmt; + _eeprom_file_stream_data_i2c + /* Overwritten parent data member. */ + const I2CEepromFileConfig *cfg; +} I2CEepromFileStream; + + +/** + * Open I2C EEPROM IC as file and return pointer to the file stream object + * @note Fucntion allways successfully open file. All checking makes + * in read/write functions. + */ +#define I2CEepromFileOpen(efs, eepcfg, eepdev) \ + EepromFileOpen((EepromFileStream *)efs, (EepromFileConfig *)eepcfg, eepdev); + +#endif /* #if defined(EEPROM_USE_EE24XX) && EEPROM_USE_EE24XX */ + +#endif // EE24XX_H |