amiro-lld / source / alld_bq24103a.c @ e2db16a4
History | View | Annotate | Download (2.719 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 | Copyright (C) 2016..2018 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 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 General Public License for more details.
|
||
14 | |||
15 | You should have received a copy of the GNU General Public License
|
||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
17 | */
|
||
18 | |||
19 | #include <alld_bq24103a.h> |
||
20 | |||
21 | #if defined(AMIROLLD_CFG_USE_BQ24103A) || defined(__DOXYGEN__)
|
||
22 | |||
23 | /**
|
||
24 | * @brief Read the value of the POWER_EN Gpio pin.
|
||
25 | * @param[in] tpsd bq24103a drivers
|
||
26 | * @param[out] pinstate current value of the gpio pin
|
||
27 | * @return An indicator whether the call was successfull
|
||
28 | */
|
||
29 | inline apalExitStatus_t
|
||
30 | bq24103a_lld_get_enabled(const BQ24103ADriver* const bq24103a, bq24103a_lld_enable_t* const enable) |
||
31 | { |
||
32 | apalDbgAssert(bq24103a != NULL);
|
||
33 | apalDbgAssert(enable != NULL);
|
||
34 | |||
35 | apalControlGpioState_t gpio_state; |
||
36 | apalExitStatus_t status = apalControlGpioGet(&bq24103a->gpio_enabled, &gpio_state); |
||
37 | *enable = gpio_state == APAL_GPIO_ON ? BQ24103A_LLD_ENABLED : BQ24103A_LLD_DISABLED; |
||
38 | return status;
|
||
39 | } |
||
40 | |||
41 | /**
|
||
42 | * @brief Set the value of the POWER_EN Gpio pin.
|
||
43 | * @param[in] tpsd bq24103a drivers
|
||
44 | * @param[in] pinstate new value of the gpio pin
|
||
45 | * @return An indicator whether the call was successfull
|
||
46 | */
|
||
47 | inline apalExitStatus_t
|
||
48 | bq24103a_lld_set_enabled(const BQ24103ADriver* const bq24103a, const bq24103a_lld_enable_t enable) |
||
49 | { |
||
50 | apalDbgAssert(bq24103a != NULL);
|
||
51 | |||
52 | return apalControlGpioSet(&bq24103a->gpio_enabled, enable == BQ24103A_LLD_ENABLED ? APAL_GPIO_ON : APAL_GPIO_OFF);
|
||
53 | } |
||
54 | |||
55 | /**
|
||
56 | * @brief Read the value of the STAT1 charge status Gpio pin.
|
||
57 | * @param[in] tpsd bq24103a drivers
|
||
58 | * @param[out] pinstate current value of the gpio pin
|
||
59 | * @return An indicator whether the call was successfull
|
||
60 | */
|
||
61 | inline apalExitStatus_t
|
||
62 | bq24103a_lld_get_charge_status(const BQ24103ADriver* const bq24103a, bq24103a_lld_charge_state_t* const charge) |
||
63 | { |
||
64 | apalDbgAssert(bq24103a != NULL);
|
||
65 | apalDbgAssert(charge != NULL);
|
||
66 | |||
67 | apalControlGpioState_t gpio_state; |
||
68 | apalExitStatus_t status = apalControlGpioGet(&bq24103a->gpio_charge_status, &gpio_state); |
||
69 | *charge = gpio_state == APAL_GPIO_ON ? BQ24103A_LLD_CHARGING : BQ24103A_LLD_NOT_CHARGING; |
||
70 | return status;
|
||
71 | } |
||
72 | |||
73 | #endif /* defined(AMIROLLD_CFG_USE_BQ24103A) */ |