amiro-lld / drivers / P9221R / v1 / alld_P9221R.h @ 0b0996ce
History | View | Annotate | Download (4.581 KB)
1 | 6ef38c23 | Julia Niermann | /*
|
---|---|---|---|
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 | e7af07e7 | Julia Niermann | * @file alld_P9221R.h
|
21 | 0b0996ce | Julia Niermann | * @brief qi charger macros and structures.
|
22 | 6ef38c23 | Julia Niermann | *
|
23 | * @addtogroup lld_power
|
||
24 | * @{
|
||
25 | */
|
||
26 | |||
27 | 0b0996ce | Julia Niermann | |
28 | e7af07e7 | Julia Niermann | #ifndef AMIROLLD_P9221R_H
|
29 | #define AMIROLLD_P9221R_H
|
||
30 | 6ef38c23 | Julia Niermann | |
31 | #include <amiro-lld.h> |
||
32 | |||
33 | /******************************************************************************/
|
||
34 | /* CONSTANTS */
|
||
35 | /******************************************************************************/
|
||
36 | |||
37 | 067c98f7 | Julia Niermann | /**
|
38 | * @brief Maximum I2C frequency.
|
||
39 | */
|
||
40 | #define P9221R_LLD_I2C_MAXFREQUENCY 400000 |
||
41 | |||
42 | 6ef38c23 | Julia Niermann | /******************************************************************************/
|
43 | /* SETTINGS */
|
||
44 | /******************************************************************************/
|
||
45 | |||
46 | /******************************************************************************/
|
||
47 | /* CHECKS */
|
||
48 | /******************************************************************************/
|
||
49 | |||
50 | /******************************************************************************/
|
||
51 | /* DATA STRUCTURES AND TYPES */
|
||
52 | /******************************************************************************/
|
||
53 | 7aa812e9 | Julia Niermann | |
54 | /**
|
||
55 | * @brief I2C address masks.
|
||
56 | */
|
||
57 | enum {
|
||
58 | P9221R_LLD_I2C_ADDR_FIXED = 0x0061u,
|
||
59 | }; |
||
60 | |||
61 | 6ef38c23 | Julia Niermann | /**
|
62 | * @brief Registers.
|
||
63 | */
|
||
64 | typedef enum { |
||
65 | 73345246 | Julia Niermann | P9221R_LLD_REGISTER_PARTNUMBER = 0x0000,
|
66 | P9221R_LLD_REGISTER_INTERRUPTENABLE = 0x0038,
|
||
67 | 6ef38c23 | Julia Niermann | // Writeable Registers
|
68 | 73345246 | Julia Niermann | P9221R_LLD_REGISTER_BATTERY_STATUS_SENT = 0x003A,
|
69 | P9221R_LLD_REGISTER_END_POWER_TRANSFER = 0x003B,
|
||
70 | 6ef38c23 | Julia Niermann | // Read-Only Registers
|
71 | 73345246 | Julia Niermann | P9221R_LLD_REGISTER_OUTPUT_VOLTAGE_LSB = 0x003C,
|
72 | P9221R_LLD_REGISTER_OUTPUT_VOLTAGE_MSB = 0x003D,
|
||
73 | P9221R_LLD_REGISTER_IOUT_CURRENT_LSB = 0x0044,
|
||
74 | P9221R_LLD_REGISTER_IOUT_CURRENT_MSB = 0x0045,
|
||
75 | P9221R_LLD_REGISTER_OPERATING_FREQUENCY_MSB = 0x0048,
|
||
76 | P9221R_LLD_REGISTER_OPERATING_FREQUENCY_LSB = 0x0049,
|
||
77 | P9221R_LLD_REGISTER_ALIGNMENT_X = 0x004B,
|
||
78 | P9221R_LLD_REGISTER_ALIGNMENT_Y = 0x004C,
|
||
79 | 6ef38c23 | Julia Niermann | } p9221r_lld_register_t; |
80 | |||
81 | |||
82 | typedef struct { |
||
83 | apalI2CDriver_t* i2cd; |
||
84 | apalI2Caddr_t addr; |
||
85 | uint16_t current_lsb_uA; |
||
86 | 2344a771 | Julia Niermann | //P9221R_lld_cfg_t *config;
|
87 | e7af07e7 | Julia Niermann | } P9221RDriver; |
88 | 6ef38c23 | Julia Niermann | |
89 | |||
90 | /******************************************************************************/
|
||
91 | /* MACROS */
|
||
92 | /******************************************************************************/
|
||
93 | |||
94 | /******************************************************************************/
|
||
95 | /* EXTERN DECLARATIONS */
|
||
96 | /******************************************************************************/
|
||
97 | |||
98 | #ifdef __cplusplus
|
||
99 | extern "C" { |
||
100 | #endif
|
||
101 | 9797f02a | Julia Niermann | apalExitStatus_t p9221r_lld_read_register(const P9221RDriver* const p9221r, const p9221r_lld_register_t addr, uint8_t* const data, const uint8_t num, const apalTime_t timeout); |
102 | 6ef38c23 | Julia Niermann | apalExitStatus_t p9221r_lld_write_register(const P9221RDriver* const p9221r, const p9221r_lld_register_t addr, const uint16_t* const data, const uint8_t num, const apalTime_t timeout); |
103 | 9be47646 | Julia Niermann | apalExitStatus_t p9221r_lld_read_alignment(const P9221RDriver* const p9221r, int8_t* const alignment, const apalTime_t timeout); |
104 | c89b966e | Ruben Lipperts | apalExitStatus_t p9221r_lld_read_voltage(const P9221RDriver* const p9221r, float* const voltage, const apalTime_t timeout); |
105 | apalExitStatus_t p9221r_lld_read_current(const P9221RDriver* const p9221r, float* const current, const apalTime_t timeout); |
||
106 | 9797f02a | Julia Niermann | |
107 | 6ef38c23 | Julia Niermann | #ifdef __cplusplus
|
108 | } |
||
109 | #endif
|
||
110 | |||
111 | /******************************************************************************/
|
||
112 | /* INLINE FUNCTIONS */
|
||
113 | /******************************************************************************/
|
||
114 | |||
115 | e7af07e7 | Julia Niermann | #endif /* AMIROLLD_P9221R_H */ |
116 | |||
117 | /** @} */
|