amiro-lld / drivers / bq241xx / v1 / alld_bq241xx.c @ 1304b12b
History | View | Annotate | Download (4.14 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 | 9466e34d | Thomas Schöpping | * @file alld_bq241xx.c
|
21 | 5e2f673b | Marc Rothmann | * @brief Battery charger function implementations.
|
22 | *
|
||
23 | * @addtogroup lld_charger
|
||
24 | * @{
|
||
25 | */
|
||
26 | 1d5bcc82 | Thomas Schöpping | #include <alld_bq241xx.h> |
27 | d6728c5b | Thomas Schöpping | |
28 | ef078306 | Thomas Schöpping | /******************************************************************************/
|
29 | /* LOCAL DEFINITIONS */
|
||
30 | /******************************************************************************/
|
||
31 | |||
32 | /******************************************************************************/
|
||
33 | /* EXPORTED VARIABLES */
|
||
34 | /******************************************************************************/
|
||
35 | |||
36 | /******************************************************************************/
|
||
37 | /* LOCAL TYPES */
|
||
38 | /******************************************************************************/
|
||
39 | |||
40 | /******************************************************************************/
|
||
41 | /* LOCAL VARIABLES */
|
||
42 | /******************************************************************************/
|
||
43 | |||
44 | /******************************************************************************/
|
||
45 | /* LOCAL FUNCTIONS */
|
||
46 | /******************************************************************************/
|
||
47 | |||
48 | /******************************************************************************/
|
||
49 | /* EXPORTED FUNCTIONS */
|
||
50 | /******************************************************************************/
|
||
51 | |||
52 | d6728c5b | Thomas Schöpping | /**
|
53 | * @brief Read the value of the POWER_EN Gpio pin.
|
||
54 | 1d5bcc82 | Thomas Schöpping | * @param[in] tpsd bq241xx driver
|
55 | d6728c5b | Thomas Schöpping | * @param[out] pinstate current value of the gpio pin
|
56 | * @return An indicator whether the call was successfull
|
||
57 | */
|
||
58 | 1d5bcc82 | Thomas Schöpping | apalExitStatus_t bq241xx_lld_get_enabled(const BQ241xxDriver* const bq241xx, bq241xx_lld_enable_t* const enable) |
59 | d6728c5b | Thomas Schöpping | { |
60 | 1d5bcc82 | Thomas Schöpping | apalDbgAssert(bq241xx != NULL);
|
61 | d6728c5b | Thomas Schöpping | apalDbgAssert(enable != NULL);
|
62 | |||
63 | apalControlGpioState_t gpio_state; |
||
64 | 1d5bcc82 | Thomas Schöpping | apalExitStatus_t status = apalControlGpioGet(bq241xx->gpio_enabled, &gpio_state); |
65 | *enable = gpio_state == APAL_GPIO_ON ? BQ241xx_LLD_ENABLED : BQ241xx_LLD_DISABLED; |
||
66 | d6728c5b | Thomas Schöpping | return status;
|
67 | } |
||
68 | |||
69 | /**
|
||
70 | * @brief Set the value of the POWER_EN Gpio pin.
|
||
71 | 1d5bcc82 | Thomas Schöpping | * @param[in] tpsd bq241xx driver
|
72 | d6728c5b | Thomas Schöpping | * @param[in] pinstate new value of the gpio pin
|
73 | * @return An indicator whether the call was successfull
|
||
74 | */
|
||
75 | 1d5bcc82 | Thomas Schöpping | apalExitStatus_t bq241xx_lld_set_enabled(const BQ241xxDriver* const bq241xx, const bq241xx_lld_enable_t enable) |
76 | d6728c5b | Thomas Schöpping | { |
77 | 1d5bcc82 | Thomas Schöpping | apalDbgAssert(bq241xx != NULL);
|
78 | d6728c5b | Thomas Schöpping | |
79 | 1d5bcc82 | Thomas Schöpping | return apalControlGpioSet(bq241xx->gpio_enabled, enable == BQ241xx_LLD_ENABLED ? APAL_GPIO_ON : APAL_GPIO_OFF);
|
80 | d6728c5b | Thomas Schöpping | } |
81 | |||
82 | /**
|
||
83 | * @brief Read the value of the STAT1 charge status Gpio pin.
|
||
84 | 1d5bcc82 | Thomas Schöpping | * @param[in] tpsd bq241xx driver
|
85 | d6728c5b | Thomas Schöpping | * @param[out] pinstate current value of the gpio pin
|
86 | * @return An indicator whether the call was successfull
|
||
87 | */
|
||
88 | 1d5bcc82 | Thomas Schöpping | apalExitStatus_t bq241xx_lld_get_charge_status(const BQ241xxDriver* const bq241xx, bq241xx_lld_charge_state_t* const charge) |
89 | d6728c5b | Thomas Schöpping | { |
90 | 1d5bcc82 | Thomas Schöpping | apalDbgAssert(bq241xx != NULL);
|
91 | d6728c5b | Thomas Schöpping | apalDbgAssert(charge != NULL);
|
92 | |||
93 | apalControlGpioState_t gpio_state; |
||
94 | 1d5bcc82 | Thomas Schöpping | apalExitStatus_t status = apalControlGpioGet(bq241xx->gpio_charge_status, &gpio_state); |
95 | *charge = gpio_state == APAL_GPIO_ON ? BQ241xx_LLD_CHARGING : BQ241xx_LLD_NOT_CHARGING; |
||
96 | d6728c5b | Thomas Schöpping | return status;
|
97 | } |
||
98 | |||
99 | 5e2f673b | Marc Rothmann | /** @} */
|