amiro-lld / drivers / AT24C01B / v1 / alld_AT24C01B.h @ c9774bf5
History | View | Annotate | Download (4.713 KB)
1 | d6728c5b | Thomas Schöpping | /*
|
---|---|---|---|
2 | AMiRo-LLD is a compilation of low-level hardware drivers for the Autonomous Mini Robot (AMiRo) platform.
|
||
3 | f125ae07 | Thomas Schöpping | Copyright (C) 2016..2019 Thomas Schöpping et al.
|
4 | d6728c5b | Thomas Schöpping | |
5 | This program is free software: you can redistribute it and/or modify
|
||
6 | f0ca400f | Thomas Schöpping | it under the terms of the GNU Lesser General Public License as published by
|
7 | d6728c5b | Thomas Schöpping | the Free Software Foundation, either version 3 of the License, or
|
8 | (at your option) any later version.
|
||
9 | |||
10 | This program is distributed in the hope that it will be useful,
|
||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
13 | f0ca400f | Thomas Schöpping | GNU Lesser General Public License for more details.
|
14 | d6728c5b | Thomas Schöpping | |
15 | f0ca400f | Thomas Schöpping | You should have received a copy of the GNU Lesser General Public License
|
16 | d6728c5b | Thomas Schöpping | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17 | */
|
||
18 | |||
19 | 5e2f673b | Marc Rothmann | /**
|
20 | 9466e34d | Thomas Schöpping | * @file alld_AT24C01B.h
|
21 | 5e2f673b | Marc Rothmann | * @brief EEPROM macros and structures.
|
22 | *
|
||
23 | * @addtogroup lld_eeprom
|
||
24 | * @{
|
||
25 | */
|
||
26 | |||
27 | 9466e34d | Thomas Schöpping | #ifndef AMIROLLD_AT24C01B_H
|
28 | #define AMIROLLD_AT24C01B_H
|
||
29 | d6728c5b | Thomas Schöpping | |
30 | #include <amiro-lld.h> |
||
31 | |||
32 | ef078306 | Thomas Schöpping | /******************************************************************************/
|
33 | /* CONSTANTS */
|
||
34 | /******************************************************************************/
|
||
35 | |||
36 | d6728c5b | Thomas Schöpping | /**
|
37 | * @brief Memory size of the EEPROM in bits.
|
||
38 | */
|
||
39 | 1d5bcc82 | Thomas Schöpping | #define AT24C01B_LLD_SIZE_BITS 1024 |
40 | d6728c5b | Thomas Schöpping | |
41 | /**
|
||
42 | * @brief Memory size of the EEPROM in bytes
|
||
43 | */
|
||
44 | 1d5bcc82 | Thomas Schöpping | #define AT24C01B_LLD_SIZE_BYTES 128 |
45 | d6728c5b | Thomas Schöpping | |
46 | |||
47 | /**
|
||
48 | * @brief Size of a page in bytes
|
||
49 | */
|
||
50 | 1d5bcc82 | Thomas Schöpping | #define AT24C01B_LLD_PAGE_SIZE_BYTES 8 |
51 | d6728c5b | Thomas Schöpping | |
52 | /**
|
||
53 | * @brief Time in microseconds a write operation takes to complete (I2C will not respond).
|
||
54 | * @note The system should wait slightly longer.
|
||
55 | */
|
||
56 | 1d5bcc82 | Thomas Schöpping | #define AT24C01B_LLD_WRITECYCLETIME_US 5000 |
57 | d6728c5b | Thomas Schöpping | |
58 | /**
|
||
59 | * @brief Maximum I2C frequency.
|
||
60 | */
|
||
61 | 1d5bcc82 | Thomas Schöpping | #define AT24C01B_LLD_I2C_MAXFREQUENCY 400000 |
62 | d6728c5b | Thomas Schöpping | |
63 | /**
|
||
64 | * @brief Maximum I2C frequency at 5V.
|
||
65 | */
|
||
66 | 1d5bcc82 | Thomas Schöpping | #define AT24C01B_LLD_I2C_MAXFREQUENCY_5V 1000000 |
67 | d6728c5b | Thomas Schöpping | |
68 | ef078306 | Thomas Schöpping | |
69 | /******************************************************************************/
|
||
70 | /* SETTINGS */
|
||
71 | /******************************************************************************/
|
||
72 | |||
73 | /******************************************************************************/
|
||
74 | /* CHECKS */
|
||
75 | /******************************************************************************/
|
||
76 | |||
77 | /******************************************************************************/
|
||
78 | /* DATA STRUCTURES AND TYPES */
|
||
79 | /******************************************************************************/
|
||
80 | |||
81 | d6728c5b | Thomas Schöpping | /**
|
82 | 1d5bcc82 | Thomas Schöpping | * @brief The AT24C01B driver struct
|
83 | d6728c5b | Thomas Schöpping | */
|
84 | typedef struct { |
||
85 | apalI2CDriver_t* i2cd; /**< @brief The I2C Driver */
|
||
86 | cf1f756b | Thomas Schöpping | apalI2Caddr_t addr; /**< @brief The address of the AT24C01B for I2C communication, which is defined by the wiring of the A0, A1, A2 pins */
|
87 | 1d5bcc82 | Thomas Schöpping | } AT24C01BDriver; |
88 | d6728c5b | Thomas Schöpping | |
89 | /**
|
||
90 | * @brief Bitmasks for the I2C address, including the wiring of the A0, A1, A2 pins.
|
||
91 | */
|
||
92 | enum {
|
||
93 | 1d5bcc82 | Thomas Schöpping | AT24C01B_LLD_I2C_ADDR_FIXED = 0x0050u,
|
94 | AT24C01B_LLD_I2C_ADDR_A0 = 0x0001u,
|
||
95 | AT24C01B_LLD_I2C_ADDR_A1 = 0x0002u,
|
||
96 | AT24C01B_LLD_I2C_ADDR_A2 = 0x0004u,
|
||
97 | d6728c5b | Thomas Schöpping | }; |
98 | |||
99 | ef078306 | Thomas Schöpping | /******************************************************************************/
|
100 | /* MACROS */
|
||
101 | /******************************************************************************/
|
||
102 | |||
103 | /******************************************************************************/
|
||
104 | /* EXTERN DECLARATIONS */
|
||
105 | /******************************************************************************/
|
||
106 | |||
107 | d6728c5b | Thomas Schöpping | #ifdef __cplusplus
|
108 | extern "C" { |
||
109 | #endif
|
||
110 | 1d5bcc82 | Thomas Schöpping | apalExitStatus_t at24c01b_lld_poll_ack(const AT24C01BDriver* const at24c01b, const apalTime_t timeout); |
111 | apalExitStatus_t at24c01b_lld_read_current_address(const AT24C01BDriver* const at24c01b, uint8_t* const data, const uint8_t num, const apalTime_t timeout); |
||
112 | apalExitStatus_t at24c01b_lld_read(const AT24C01BDriver* const at24c01b, const uint8_t addr, uint8_t* const data, const uint8_t num, const apalTime_t timeout); |
||
113 | apalExitStatus_t at24c01b_lld_write_byte(const AT24C01BDriver* const at24c01b, const uint8_t addr, const uint8_t data, const apalTime_t timeout); |
||
114 | apalExitStatus_t at24c01b_lld_write_page(const AT24C01BDriver* const at24c01b, const uint8_t addr, const uint8_t* const data, const uint8_t num, const apalTime_t timeout); |
||
115 | d6728c5b | Thomas Schöpping | #ifdef __cplusplus
|
116 | } |
||
117 | #endif
|
||
118 | |||
119 | ef078306 | Thomas Schöpping | /******************************************************************************/
|
120 | /* INLINE FUNCTIONS */
|
||
121 | /******************************************************************************/
|
||
122 | |||
123 | 9466e34d | Thomas Schöpping | #endif /* AMIROLLD_AT24C01BN_H */ |
124 | d6728c5b | Thomas Schöpping | |
125 | 5e2f673b | Marc Rothmann | /** @} */ |