amiro-lld / include / P9221R / v1 / alld_P9221R_v1.h @ a9c9cd33
History | View | Annotate | Download (4.859 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 | * @file alld_P9221R_v1.h
|
||
21 | * @brief Power Monitor macros and structures.
|
||
22 | *
|
||
23 | * @addtogroup lld_power
|
||
24 | * @{
|
||
25 | */
|
||
26 | |||
27 | #ifndef AMIROLLD_P9221R_V1_H
|
||
28 | #define AMIROLLD_P9221R_V1_H
|
||
29 | |||
30 | #include <amiro-lld.h> |
||
31 | |||
32 | 54dbb62d | Julia Niermann | #if (defined(AMIROLLD_CFG_P9221R) && (AMIROLLD_CFG_P9221R == 1)) || defined(__DOXYGEN__) |
33 | |||
34 | 6ef38c23 | Julia Niermann | /******************************************************************************/
|
35 | /* CONSTANTS */
|
||
36 | /******************************************************************************/
|
||
37 | |||
38 | 067c98f7 | Julia Niermann | /**
|
39 | * @brief Maximum I2C frequency.
|
||
40 | */
|
||
41 | #define P9221R_LLD_I2C_MAXFREQUENCY 400000 |
||
42 | |||
43 | 6ef38c23 | Julia Niermann | /******************************************************************************/
|
44 | /* SETTINGS */
|
||
45 | /******************************************************************************/
|
||
46 | |||
47 | /******************************************************************************/
|
||
48 | /* CHECKS */
|
||
49 | /******************************************************************************/
|
||
50 | |||
51 | /******************************************************************************/
|
||
52 | /* DATA STRUCTURES AND TYPES */
|
||
53 | /******************************************************************************/
|
||
54 | 7aa812e9 | Julia Niermann | |
55 | /**
|
||
56 | * @brief I2C address masks.
|
||
57 | */
|
||
58 | enum {
|
||
59 | P9221R_LLD_I2C_ADDR_FIXED = 0x0061u,
|
||
60 | }; |
||
61 | |||
62 | 6ef38c23 | Julia Niermann | /**
|
63 | * @brief Registers.
|
||
64 | */
|
||
65 | typedef enum { |
||
66 | 067c98f7 | Julia Niermann | P9221R_LLD_REGISTER_PARTNUMBER = 0x00,
|
67 | P9221R_LLD_REGISTER_INTERRUPTENABLE = 0x38,
|
||
68 | 6ef38c23 | Julia Niermann | // Writeable Registers
|
69 | P9221R_LLD_REGISTER_BATTERY_STATUS_SENT = 0x3A,
|
||
70 | P9221R_LLD_REGISTER_END_POWER_TRANSFER = 0x3B,
|
||
71 | // Read-Only Registers
|
||
72 | P9221R_LLD_REGISTER_OUTPUT_VOLTAGE_LSB = 0x3C,
|
||
73 | P9221R_LLD_REGISTER_OUTPUT_VOLTAGE_MSB = 0x3D,
|
||
74 | P9221R_LLD_REGISTER_IOUT_CURRENT_LSB = 0x44,
|
||
75 | P9221R_LLD_REGISTER_IOUT_CURRENT_MSB = 0x45,
|
||
76 | P9221R_LLD_REGISTER_OPERATING_FREQUENCY_MSB = 0x48,
|
||
77 | P9221R_LLD_REGISTER_OPERATING_FREQUENCY_LSB = 0x49,
|
||
78 | P9221R_LLD_REGISTER_ALIGNMENT_X = 0x4B,
|
||
79 | P9221R_LLD_REGISTER_ALIGNMENT_Y = 0x4C,
|
||
80 | } p9221r_lld_register_t; |
||
81 | |||
82 | |||
83 | typedef struct { |
||
84 | apalI2CDriver_t* i2cd; |
||
85 | apalI2Caddr_t addr; |
||
86 | uint16_t current_lsb_uA; |
||
87 | 2344a771 | Julia Niermann | //P9221R_lld_cfg_t *config;
|
88 | }P9221RDriver; |
||
89 | 6ef38c23 | Julia Niermann | |
90 | |||
91 | /******************************************************************************/
|
||
92 | /* MACROS */
|
||
93 | /******************************************************************************/
|
||
94 | |||
95 | /******************************************************************************/
|
||
96 | /* EXTERN DECLARATIONS */
|
||
97 | /******************************************************************************/
|
||
98 | |||
99 | #ifdef __cplusplus
|
||
100 | extern "C" { |
||
101 | #endif
|
||
102 | 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); |
103 | 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); |
104 | a9c9cd33 | Ruben Lipperts | apalExitStatus_t p9221r_lld_read_x_alignment(const P9221RDriver* const p9221r, int8_t* const x_alignment, const apalTime_t timeout); |
105 | apalExitStatus_t p9221r_lld_read_y_alignment(const P9221RDriver* const p9221r, int8_t* const y_alignment, const apalTime_t timeout); |
||
106 | apalExitStatus_t p9221r_lld_read_voltage(const P9221RDriver* const p9221r, uint16_t* const voltage, const apalTime_t timeout); |
||
107 | apalExitStatus_t p9221r_lld_read_current(const P9221RDriver* const p9221r, uint16_t* const current, const apalTime_t timeout); |
||
108 | 9797f02a | Julia Niermann | |
109 | 6ef38c23 | Julia Niermann | #ifdef __cplusplus
|
110 | } |
||
111 | #endif
|
||
112 | |||
113 | /******************************************************************************/
|
||
114 | /* INLINE FUNCTIONS */
|
||
115 | /******************************************************************************/
|
||
116 | |||
117 | 54dbb62d | Julia Niermann | #endif /* defined(AMIROLLD_CFG_P9221R) && (AMIROLLD_CFG_P9221R == 1) */ |
118 | |||
119 | #endif /* AMIROLLD_P9221R_V1_H */ |