Statistics
| Branch: | Tag: | Revision:

amiro-lld / source / alld_ltc4412.c @ 11500ad8

History | View | Annotate | Download (2.802 KB)

1
/*
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 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_ltc4412.c
21
 * @brief   PowerPath Controller function implementations
22
 *
23
 * @addtogroup lld_powerpath
24
 * @{
25
 */
26

    
27
#include <alld_ltc4412.h>
28

    
29
#if defined(AMIROLLD_CFG_USE_LTC4412) || defined(__DOXYGEN__)
30

    
31
/**
32
 * @brief Read the value of the PATH_DCEN Gpio pin.
33
 * @param[in]   tpsd        ltc4412 drivers
34
 * @param[out]  pinstate    current value of the gpio pin
35
 * @return                  An indicator whether the call was successfull
36
 */
37
inline apalExitStatus_t
38
ltc4412_lld_get_ctrl(const LTC4412Driver* const ltc4412, ltc4412_lld_ctrl_t* const ctrl)
39
{
40
  apalDbgAssert(ltc4412 != NULL);
41
  apalDbgAssert(ctrl != NULL);
42

    
43
  apalControlGpioState_t gpio_state;
44
  apalExitStatus_t status = apalControlGpioGet(ltc4412->gpio_ctrl, &gpio_state);
45
  *ctrl = gpio_state == APAL_GPIO_ON ? LTC4412_LLD_CTRL_ACTIVE : LTC4412_LLD_CTRL_INACTIVE;
46
  return status;
47
}
48

    
49
/**
50
 * @brief Set the value of the PATH_DCEN Gpio pin.
51
 * @param[in]   tpsd        ltc4412 drivers
52
 * @param[in]   ctrl        new value of the gpio pin
53
 * @return                  An indicator whether the call was successfull
54
 */
55
inline apalExitStatus_t
56
ltc4412_lld_set_ctrl(const LTC4412Driver* const ltc4412, const ltc4412_lld_ctrl_t ctrl)
57
{
58
  apalDbgAssert(ltc4412 != NULL);
59

    
60
  return apalControlGpioSet(ltc4412->gpio_ctrl, ctrl == LTC4412_LLD_CTRL_ACTIVE ? APAL_GPIO_ON : APAL_GPIO_OFF);
61
}
62

    
63
/**
64
 * @brief Read the value of the PATH_DCSTAT Gpio pin.
65
 * @param[in]   tpsd        ltc4412 drivers
66
 * @param[out]  pinstate    current value of the gpio pin
67
 * @return                  An indicator whether the call was successfull
68
 */
69
inline apalExitStatus_t
70
ltc4412_lld_get_stat(const LTC4412Driver* const ltc4412, ltc4412_lld_stat_t* const stat)
71
{
72
  apalDbgAssert(ltc4412 != NULL);
73
  apalDbgAssert(stat != NULL);
74

    
75
  apalControlGpioState_t gpio_state;
76
  apalExitStatus_t status = apalControlGpioGet(ltc4412->gpio_stat, &gpio_state);
77
  *stat = gpio_state == APAL_GPIO_ON ? LTC4412_LLD_STAT_ACTIVE : LTC4412_LLD_STAT_INACTIVE;
78
  return status;
79
}
80

    
81
#endif /* defined(AMIROLLD_CFG_USE_LTC4412) */
82

    
83
/** @} */