amiro-lld / drivers / AT24C01B / v1 / alld_AT24C01B.h @ 23ab29c0
History | View | Annotate | Download (4.713 KB)
1 |
/*
|
---|---|
2 |
AMiRo-LLD is a compilation of low-level hardware drivers for the Autonomous Mini Robot (AMiRo) platform.
|
3 |
Copyright (C) 2016..2019 Thomas Schöpping et al.
|
4 |
|
5 |
This program is free software: you can redistribute it and/or modify
|
6 |
it under the terms of the GNU Lesser General Public License as published by
|
7 |
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 |
GNU Lesser General Public License for more details.
|
14 |
|
15 |
You should have received a copy of the GNU Lesser General Public License
|
16 |
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17 |
*/
|
18 |
|
19 |
/**
|
20 |
* @file alld_AT24C01B.h
|
21 |
* @brief EEPROM macros and structures.
|
22 |
*
|
23 |
* @addtogroup lld_eeprom
|
24 |
* @{
|
25 |
*/
|
26 |
|
27 |
#ifndef AMIROLLD_AT24C01B_H
|
28 |
#define AMIROLLD_AT24C01B_H
|
29 |
|
30 |
#include <amiro-lld.h> |
31 |
|
32 |
/******************************************************************************/
|
33 |
/* CONSTANTS */
|
34 |
/******************************************************************************/
|
35 |
|
36 |
/**
|
37 |
* @brief Memory size of the EEPROM in bits.
|
38 |
*/
|
39 |
#define AT24C01B_LLD_SIZE_BITS 1024 |
40 |
|
41 |
/**
|
42 |
* @brief Memory size of the EEPROM in bytes
|
43 |
*/
|
44 |
#define AT24C01B_LLD_SIZE_BYTES 128 |
45 |
|
46 |
|
47 |
/**
|
48 |
* @brief Size of a page in bytes
|
49 |
*/
|
50 |
#define AT24C01B_LLD_PAGE_SIZE_BYTES 8 |
51 |
|
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 |
#define AT24C01B_LLD_WRITECYCLETIME_US 5000 |
57 |
|
58 |
/**
|
59 |
* @brief Maximum I2C frequency.
|
60 |
*/
|
61 |
#define AT24C01B_LLD_I2C_MAXFREQUENCY 400000 |
62 |
|
63 |
/**
|
64 |
* @brief Maximum I2C frequency at 5V.
|
65 |
*/
|
66 |
#define AT24C01B_LLD_I2C_MAXFREQUENCY_5V 1000000 |
67 |
|
68 |
|
69 |
/******************************************************************************/
|
70 |
/* SETTINGS */
|
71 |
/******************************************************************************/
|
72 |
|
73 |
/******************************************************************************/
|
74 |
/* CHECKS */
|
75 |
/******************************************************************************/
|
76 |
|
77 |
/******************************************************************************/
|
78 |
/* DATA STRUCTURES AND TYPES */
|
79 |
/******************************************************************************/
|
80 |
|
81 |
/**
|
82 |
* @brief The AT24C01B driver struct
|
83 |
*/
|
84 |
typedef struct { |
85 |
apalI2CDriver_t* i2cd; /**< @brief The I2C Driver */
|
86 |
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 |
} AT24C01BDriver; |
88 |
|
89 |
/**
|
90 |
* @brief Bitmasks for the I2C address, including the wiring of the A0, A1, A2 pins.
|
91 |
*/
|
92 |
enum {
|
93 |
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 |
}; |
98 |
|
99 |
/******************************************************************************/
|
100 |
/* MACROS */
|
101 |
/******************************************************************************/
|
102 |
|
103 |
/******************************************************************************/
|
104 |
/* EXTERN DECLARATIONS */
|
105 |
/******************************************************************************/
|
106 |
|
107 |
#ifdef __cplusplus
|
108 |
extern "C" { |
109 |
#endif
|
110 |
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 |
#ifdef __cplusplus
|
116 |
} |
117 |
#endif
|
118 |
|
119 |
/******************************************************************************/
|
120 |
/* INLINE FUNCTIONS */
|
121 |
/******************************************************************************/
|
122 |
|
123 |
#endif /* AMIROLLD_AT24C01BN_H */ |
124 |
|
125 |
/** @} */
|