Statistics
| Branch: | Tag: | Revision:

amiro-lld / include / AT24C01B / v1 / alld_AT24C01B_v1.h @ c4db2363

History | View | Annotate | Download (4.892 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 1d5bcc82 Thomas Schöpping
 * @file    alld_AT24C01B_v1.h
21 5e2f673b Marc Rothmann
 * @brief   EEPROM macros and structures.
22
 *
23
 * @addtogroup lld_eeprom
24
 * @{
25
 */
26
27 1d5bcc82 Thomas Schöpping
#ifndef AMIROLLD_AT24C01B_V1_H
28
#define AMIROLLD_AT24C01B_V1_H
29 d6728c5b Thomas Schöpping
30
#include <amiro-lld.h>
31
32 1d5bcc82 Thomas Schöpping
#if (defined(AMIROLLD_CFG_AT24C01B) && (AMIROLLD_CFG_AT24C01B == 1)) || defined(__DOXYGEN__)
33 d6728c5b Thomas Schöpping
34 ef078306 Thomas Schöpping
/******************************************************************************/
35
/* CONSTANTS                                                                  */
36
/******************************************************************************/
37
38 d6728c5b Thomas Schöpping
/**
39
 * @brief Memory size of the EEPROM in bits.
40
 */
41 1d5bcc82 Thomas Schöpping
#define AT24C01B_LLD_SIZE_BITS              1024
42 d6728c5b Thomas Schöpping
43
/**
44
 * @brief Memory size of the EEPROM in bytes
45
 */
46 1d5bcc82 Thomas Schöpping
#define AT24C01B_LLD_SIZE_BYTES             128
47 d6728c5b Thomas Schöpping
48
49
/**
50
 * @brief Size of a page in bytes
51
 */
52 1d5bcc82 Thomas Schöpping
#define AT24C01B_LLD_PAGE_SIZE_BYTES        8
53 d6728c5b Thomas Schöpping
54
/**
55
 * @brief  Time in microseconds a write operation takes to complete (I2C will not respond).
56
 * @note   The system should wait slightly longer.
57
 */
58 1d5bcc82 Thomas Schöpping
#define AT24C01B_LLD_WRITECYCLETIME_US      5000
59 d6728c5b Thomas Schöpping
60
/**
61
 * @brief Maximum I2C frequency.
62
 */
63 1d5bcc82 Thomas Schöpping
#define AT24C01B_LLD_I2C_MAXFREQUENCY       400000
64 d6728c5b Thomas Schöpping
65
/**
66
 * @brief Maximum I2C frequency at 5V.
67
 */
68 1d5bcc82 Thomas Schöpping
#define AT24C01B_LLD_I2C_MAXFREQUENCY_5V    1000000
69 d6728c5b Thomas Schöpping
70 ef078306 Thomas Schöpping
71
/******************************************************************************/
72
/* SETTINGS                                                                   */
73
/******************************************************************************/
74
75
/******************************************************************************/
76
/* CHECKS                                                                     */
77
/******************************************************************************/
78
79
/******************************************************************************/
80
/* DATA STRUCTURES AND TYPES                                                  */
81
/******************************************************************************/
82
83 d6728c5b Thomas Schöpping
/**
84 1d5bcc82 Thomas Schöpping
 * @brief The AT24C01B driver struct
85 d6728c5b Thomas Schöpping
 */
86
typedef struct {
87
  apalI2CDriver_t* i2cd;  /**< @brief The I2C Driver */
88 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 */
89 1d5bcc82 Thomas Schöpping
} AT24C01BDriver;
90 d6728c5b Thomas Schöpping
91
/**
92
 * @brief Bitmasks for the I2C address, including the wiring of the A0, A1, A2 pins.
93
 */
94
enum {
95 1d5bcc82 Thomas Schöpping
  AT24C01B_LLD_I2C_ADDR_FIXED       = 0x0050u,
96
  AT24C01B_LLD_I2C_ADDR_A0          = 0x0001u,
97
  AT24C01B_LLD_I2C_ADDR_A1          = 0x0002u,
98
  AT24C01B_LLD_I2C_ADDR_A2          = 0x0004u,
99 d6728c5b Thomas Schöpping
};
100
101 ef078306 Thomas Schöpping
/******************************************************************************/
102
/* MACROS                                                                     */
103
/******************************************************************************/
104
105
/******************************************************************************/
106
/* EXTERN DECLARATIONS                                                        */
107
/******************************************************************************/
108
109 d6728c5b Thomas Schöpping
#ifdef __cplusplus
110
extern "C" {
111
#endif
112 1d5bcc82 Thomas Schöpping
  apalExitStatus_t at24c01b_lld_poll_ack(const AT24C01BDriver* const at24c01b, const apalTime_t timeout);
113
  apalExitStatus_t at24c01b_lld_read_current_address(const AT24C01BDriver* const at24c01b, uint8_t* const data, const uint8_t num, const apalTime_t timeout);
114
  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);
115
  apalExitStatus_t at24c01b_lld_write_byte(const AT24C01BDriver* const at24c01b, const uint8_t addr, const uint8_t data, const apalTime_t timeout);
116
  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);
117 d6728c5b Thomas Schöpping
#ifdef __cplusplus
118
}
119
#endif
120
121 ef078306 Thomas Schöpping
/******************************************************************************/
122
/* INLINE FUNCTIONS                                                           */
123
/******************************************************************************/
124
125 1d5bcc82 Thomas Schöpping
#endif /* defined(AMIROLLD_CFG_AT24C01B) && (AMIROLLD_CFG_AT24C01B == 1) */
126 d6728c5b Thomas Schöpping
127 1d5bcc82 Thomas Schöpping
#endif /* AMIROLLD_AT24C01BN_V1_H */
128 d6728c5b Thomas Schöpping
129 5e2f673b Marc Rothmann
/** @} */