amiro-lld / source / alld_bq24103a.c @ 21076167
History | View | Annotate | Download (4.28 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 | * @file alld_bq24103a.c
|
||
21 | * @brief Battery charger function implementations.
|
||
22 | *
|
||
23 | * @addtogroup lld_charger
|
||
24 | * @{
|
||
25 | */
|
||
26 | d6728c5b | Thomas Schöpping | #include <alld_bq24103a.h> |
27 | |||
28 | #if defined(AMIROLLD_CFG_USE_BQ24103A) || defined(__DOXYGEN__)
|
||
29 | |||
30 | ef078306 | Thomas Schöpping | /******************************************************************************/
|
31 | /* LOCAL DEFINITIONS */
|
||
32 | /******************************************************************************/
|
||
33 | |||
34 | /******************************************************************************/
|
||
35 | /* EXPORTED VARIABLES */
|
||
36 | /******************************************************************************/
|
||
37 | |||
38 | /******************************************************************************/
|
||
39 | /* LOCAL TYPES */
|
||
40 | /******************************************************************************/
|
||
41 | |||
42 | /******************************************************************************/
|
||
43 | /* LOCAL VARIABLES */
|
||
44 | /******************************************************************************/
|
||
45 | |||
46 | /******************************************************************************/
|
||
47 | /* LOCAL FUNCTIONS */
|
||
48 | /******************************************************************************/
|
||
49 | |||
50 | /******************************************************************************/
|
||
51 | /* EXPORTED FUNCTIONS */
|
||
52 | /******************************************************************************/
|
||
53 | |||
54 | d6728c5b | Thomas Schöpping | /**
|
55 | * @brief Read the value of the POWER_EN Gpio pin.
|
||
56 | * @param[in] tpsd bq24103a drivers
|
||
57 | * @param[out] pinstate current value of the gpio pin
|
||
58 | * @return An indicator whether the call was successfull
|
||
59 | */
|
||
60 | 21076167 | Thomas Schöpping | apalExitStatus_t bq24103a_lld_get_enabled(const BQ24103ADriver* const bq24103a, bq24103a_lld_enable_t* const enable) |
61 | d6728c5b | Thomas Schöpping | { |
62 | apalDbgAssert(bq24103a != NULL);
|
||
63 | apalDbgAssert(enable != NULL);
|
||
64 | |||
65 | apalControlGpioState_t gpio_state; |
||
66 | cf1f756b | Thomas Schöpping | apalExitStatus_t status = apalControlGpioGet(bq24103a->gpio_enabled, &gpio_state); |
67 | d6728c5b | Thomas Schöpping | *enable = gpio_state == APAL_GPIO_ON ? BQ24103A_LLD_ENABLED : BQ24103A_LLD_DISABLED; |
68 | return status;
|
||
69 | } |
||
70 | |||
71 | /**
|
||
72 | * @brief Set the value of the POWER_EN Gpio pin.
|
||
73 | * @param[in] tpsd bq24103a drivers
|
||
74 | * @param[in] pinstate new value of the gpio pin
|
||
75 | * @return An indicator whether the call was successfull
|
||
76 | */
|
||
77 | 21076167 | Thomas Schöpping | apalExitStatus_t bq24103a_lld_set_enabled(const BQ24103ADriver* const bq24103a, const bq24103a_lld_enable_t enable) |
78 | d6728c5b | Thomas Schöpping | { |
79 | apalDbgAssert(bq24103a != NULL);
|
||
80 | |||
81 | cf1f756b | Thomas Schöpping | return apalControlGpioSet(bq24103a->gpio_enabled, enable == BQ24103A_LLD_ENABLED ? APAL_GPIO_ON : APAL_GPIO_OFF);
|
82 | d6728c5b | Thomas Schöpping | } |
83 | |||
84 | /**
|
||
85 | * @brief Read the value of the STAT1 charge status Gpio pin.
|
||
86 | * @param[in] tpsd bq24103a drivers
|
||
87 | * @param[out] pinstate current value of the gpio pin
|
||
88 | * @return An indicator whether the call was successfull
|
||
89 | */
|
||
90 | 21076167 | Thomas Schöpping | apalExitStatus_t bq24103a_lld_get_charge_status(const BQ24103ADriver* const bq24103a, bq24103a_lld_charge_state_t* const charge) |
91 | d6728c5b | Thomas Schöpping | { |
92 | apalDbgAssert(bq24103a != NULL);
|
||
93 | apalDbgAssert(charge != NULL);
|
||
94 | |||
95 | apalControlGpioState_t gpio_state; |
||
96 | cf1f756b | Thomas Schöpping | apalExitStatus_t status = apalControlGpioGet(bq24103a->gpio_charge_status, &gpio_state); |
97 | d6728c5b | Thomas Schöpping | *charge = gpio_state == APAL_GPIO_ON ? BQ24103A_LLD_CHARGING : BQ24103A_LLD_NOT_CHARGING; |
98 | return status;
|
||
99 | } |
||
100 | |||
101 | #endif /* defined(AMIROLLD_CFG_USE_BQ24103A) */ |
||
102 | 5e2f673b | Marc Rothmann | |
103 | /** @} */ |