Revision cf1f756b

View differences:

include/alld_a3906.h
32 32
 * @brief A3906 driver struct.
33 33
 */
34 34
typedef struct {
35
  apalControlGpio_t power_pin;  /**< @brief GPIO to enable/disable power of the A3906. */
35
  apalControlGpio_t* power_pin;   /**< @brief GPIO to enable/disable power of the A3906. */
36 36
} A3906Driver;
37 37

  
38 38
/**
include/alld_at24c01bn-sh-b.h
60 60
 */
61 61
typedef struct {
62 62
  apalI2CDriver_t* i2cd;  /**< @brief The I2C Driver */
63
  uint8_t addr;           /**< @brief The address of the AT24C01B for I2C communication, which is defined by the wiring of the A0, A1, A2 pins */
63
  apalI2Caddr_t addr;     /**< @brief The address of the AT24C01B for I2C communication, which is defined by the wiring of the A0, A1, A2 pins */
64 64
} AT24C01BNDriver;
65 65

  
66 66
/**
67 67
 * @brief Bitmasks for the I2C address, including the wiring of the A0, A1, A2 pins.
68 68
 */
69 69
enum {
70
  AT24C01BN_LLD_I2C_ADDR_FIXED      = 0x50u,
71
  AT24C01BN_LLD_I2C_ADDR_A0         = 0x01u,
72
  AT24C01BN_LLD_I2C_ADDR_A1         = 0x02u,
73
  AT24C01BN_LLD_I2C_ADDR_A2         = 0x04u,
70
  AT24C01BN_LLD_I2C_ADDR_FIXED      = 0x0050u,
71
  AT24C01BN_LLD_I2C_ADDR_A0         = 0x0001u,
72
  AT24C01BN_LLD_I2C_ADDR_A1         = 0x0002u,
73
  AT24C01BN_LLD_I2C_ADDR_A2         = 0x0004u,
74 74
};
75 75

  
76 76
#ifdef __cplusplus
include/alld_bq24103a.h
37 37
 * @brief The BQ24103A driver struct.
38 38
 */
39 39
typedef struct {
40
  apalControlGpio_t gpio_enabled;       /**< @brief GPIO to enable/disable the bq24103a */
41
  apalControlGpio_t gpio_charge_status; /**< @brief GPIO showing the status of the bq24103a */
40
  apalControlGpio_t* gpio_enabled;        /**< @brief GPIO to enable/disable the bq24103a */
41
  apalControlGpio_t* gpio_charge_status;  /**< @brief GPIO showing the status of the bq24103a */
42 42
} BQ24103ADriver;
43 43

  
44 44
/**
include/alld_bq27500.h
200 200
 * @brief BQ27500 Driver struct.
201 201
 */
202 202
typedef struct {
203
  apalI2CDriver_t* i2cd;          /**< @brief I2C driver to access the BQ27500 */
204
  apalControlGpio_t gpio_batlow;  /**< @brief Gpio to indicate whether the battery is low  */
205
  apalControlGpio_t gpio_batgood; /**< @brief Gpio to indicate whether the battery is good */
203
  apalI2CDriver_t* i2cd;            /**< @brief I2C driver to access the BQ27500 */
204
  apalControlGpio_t* gpio_batlow;   /**< @brief Gpio to indicate whether the battery is low  */
205
  apalControlGpio_t* gpio_batgood;  /**< @brief Gpio to indicate whether the battery is good */
206 206
} BQ27500Driver;
207 207

  
208 208
/**
include/alld_ina219.h
32 32
 * @brief I2C address masks.
33 33
 */
34 34
enum {
35
  INA219_LLD_I2C_ADDR_FIXED   = 0x40u,
36
  INA219_LLD_I2C_ADDR_A0      = 0x01u,
37
  INA219_LLD_I2C_ADDR_A1      = 0x04u,
35
  INA219_LLD_I2C_ADDR_FIXED   = 0x0040u,
36
  INA219_LLD_I2C_ADDR_A0      = 0x0001u,
37
  INA219_LLD_I2C_ADDR_A1      = 0x0004u,
38 38
};
39 39

  
40 40
/**
......
139 139
 */
140 140
typedef struct {
141 141
  apalI2CDriver_t* i2cd;
142
  uint8_t addr; /**<The address of the INA219 for I2C communication, which is defined by the wiring of the A0 and A1 pins */
142
  apalI2Caddr_t addr;   /**<The address of the INA219 for I2C communication, which is defined by the wiring of the A0 and A1 pins */
143 143
  uint16_t current_lsb_uA;
144 144
  ina219_lld_cfg_t *config;
145 145
} INA219Driver;
include/alld_led.h
32 32
 * @brief LED driver data structure.
33 33
 */
34 34
typedef struct {
35
  apalControlGpio_t      gpio;           /**< @brief The identifier of the GPIO.  */
35
  apalControlGpio_t* gpio;  /**< @brief The identifier of the GPIO.  */
36 36
} LEDDriver;
37 37

  
38 38
/**
include/alld_ltc4412.h
37 37
 * @brief LTC4412 driver struct.
38 38
 */
39 39
typedef struct {
40
  apalControlGpio_t gpio_ctrl; /**< @brief Control GPIO */
41
  apalControlGpio_t gpio_stat; /**< @brief Status GPIO */
40
  apalControlGpio_t* gpio_ctrl;   /**< @brief Control GPIO */
41
  apalControlGpio_t* gpio_stat;   /**< @brief Status GPIO */
42 42
} LTC4412Driver;
43 43

  
44 44
typedef enum {
include/alld_pca9544a.h
33 33
 */
34 34
typedef struct {
35 35
  apalI2CDriver_t* i2cd;  /**< @brief The I²C driver to use. */
36
  uint8_t addr;           /**< @brief The address of the PCA9544A for I2C communication, which is defined by the wiring of the A0, A1, A2 pins */
36
  apalI2Caddr_t addr;     /**< @brief The address of the PCA9544A for I2C communication, which is defined by the wiring of the A0, A1, A2 pins */
37 37
} PCA9544ADriver;
38 38

  
39 39
/**
40 40
 * @brief The fixed address prefix of any PCA9544A.
41 41
 */
42 42
enum {
43
  PCA9544A_LLD_I2C_ADDR_FIXED   = 0x70u,
44
  PCA9544A_LLD_I2C_ADDR_A0      = 0x01u,
45
  PCA9544A_LLD_I2C_ADDR_A1      = 0x02u,
46
  PCA9544A_LLD_I2C_ADDR_A2      = 0x04u,
43
  PCA9544A_LLD_I2C_ADDR_FIXED   = 0x0070u,
44
  PCA9544A_LLD_I2C_ADDR_A0      = 0x0001u,
45
  PCA9544A_LLD_I2C_ADDR_A1      = 0x0002u,
46
  PCA9544A_LLD_I2C_ADDR_A2      = 0x0004u,
47 47
};
48 48

  
49 49
/**
include/alld_tlc5947.h
52 52
 * @brief The TLC5947Driver struct
53 53
 */
54 54
typedef struct {
55
  apalSPIDriver_t* spi_driver;        /**< @brief The SPI Driver.                           */
56
  apalControlGpio_t blank_gpio;       /**< @brief The identifier of the BLANK signal GPIO.  */
57
  apalControlGpio_t xlat_gpio;        /**< @brief The identifier of the XLAT signal GPIO.   */
55
  apalSPIDriver_t* spi_driver;    /**< @brief The SPI Driver.                           */
56
  apalControlGpio_t* blank_gpio;  /**< @brief The identifier of the BLANK signal GPIO.  */
57
  apalControlGpio_t* xlat_gpio;   /**< @brief The identifier of the XLAT signal GPIO.   */
58 58
} TLC5947Driver;
59 59

  
60 60
/**
include/alld_tps2051bdbv.h
37 37
 * @brief The TPS2051B driver struct.
38 38
 */
39 39
typedef struct {
40
  apalControlGpio_t enable;      /**< @brief GPIO to enable/disable the tps2051b. */
41
  apalControlGpio_t overcurrent; /**< @brief GPIO to indicate overcurrent */
40
  apalControlGpio_t* enable;        /**< @brief GPIO to enable/disable the tps2051b. */
41
  apalControlGpio_t* overcurrent;   /**< @brief GPIO to indicate overcurrent */
42 42
} TPS2051BDriver;
43 43

  
44 44
/**
include/alld_tps62113.h
32 32
 * @brief The TPS62113 driver struct.
33 33
 */
34 34
typedef struct {
35
  apalControlGpio_t gpio_power; /**< GPIO to turn power on/off */
35
  apalControlGpio_t* gpio_power;  /**< GPIO to turn power on/off */
36 36
} TPS62113Driver;
37 37

  
38 38
/**
periphALtypes.h
23 23
/* DEPENDENCIES                                                               */
24 24
/*============================================================================*/
25 25

  
26
#include <alldconf.h>
26 27
#include <stdint.h>
27 28

  
28 29
/*============================================================================*/
......
32 33
/**
33 34
 * @brief Time measurement type (in microseconds).
34 35
 */
35
typedef uint64_t    apalTime_t;
36
#if !defined(AMIROLLD_CFG_TIME_SIZE)
37
  #error "AMIROLLD_CFG_TIME_SIZE not defined in alldconf.h"
38
#elif (AMIROLLD_CFG_TIME_SIZE == 8)
39
  typedef uint8_t     apalTime_t;
40
#elif (AMIROLLD_CFG_TIME_SIZE == 16)
41
  typedef uint16_t    apalTime_t;
42
#elif (AMIROLLD_CFG_TIME_SIZE == 32)
43
  typedef uint32_t    apalTime_t;
44
#elif (AMIROLLD_CFG_TIME_SIZE == 64)
45
  typedef uint64_t    apalTime_t;
46
#else
47
  #error "AMIROLLD_CFG_TIME_SIZE must be 8, 16, 32 or 64!"
48
#endif
36 49

  
37 50
/**
38 51
 * @brief Status values used as return value for all (or most) function calls.
......
84 97
} apalGpioActive_t;
85 98

  
86 99
/**
100
 * @brief   Signal direction for the control GPIO.
101
 */
102
typedef enum {
103
  APAL_GPIO_DIRECTION_UNDEFINED     = 0x00,   /**< Signal direction is undefined.     */
104
  APAL_GPIO_DIRECTION_INPUT         = 0x01,   /**< Signal direction is input only.    */
105
  APAL_GPIO_DIRECTION_OUTPUT        = 0x02,   /**< Signal direction is output only    */
106
  APAL_GPIO_DIRECTION_BIDIRECTIONAL = 0x03,   /**< Signal direction is bidirectional. */
107
} apalGpioDirection_t;
108

  
109
/**
87 110
 * @brief   Informative signal edge for input control GPIOs.
88 111
 */
89 112
typedef enum {
......
94 117
} apalGpioEdge_t;
95 118

  
96 119
/**
97
 * @brief   Signal direction for the control GPIO.
120
 * @brief   Inverts the value of the informative signal edge for interrupts.
121
 * @details Rising edge is inverted to falling and vice versa.
122
 *          If none or both edges are enabled, the identical value is returned.
98 123
 */
99
typedef enum {
100
  APAL_GPIO_DIRECTION_UNDEFINED     = 0x00,   /**< Signal direction is undefined.     */
101
  APAL_GPIO_DIRECTION_INPUT         = 0x01,   /**< Signal direction is input only.    */
102
  APAL_GPIO_DIRECTION_OUTPUT        = 0x02,   /**< Signal direction is output only    */
103
  APAL_GPIO_DIRECTION_BIDIRECTIONAL = 0x03,   /**< Signal direction is bidirectional. */
104
} apalGpioDirection_t;
124
#define APAL_GPIO_EDGE_INVERT(edge)                                 \
125
  ((edge == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_EDGE_FALLING :       \
126
   (edge == APAL_GPIO_EDGE_FALLING) ? APAL_GPIO_EDGE_RISING : edge) \
105 127

  
106 128
/**
107 129
 * @brief Control GPIO meta information
108 130
 */
109 131
typedef struct {
132
  apalGpioDirection_t direction : 2;  /**< Direction configuration for according signals */
110 133
  apalGpioActive_t active       : 1;  /**< Active state of the GPIO */
111 134
  apalGpioEdge_t edge           : 2;  /**< Edge configuration for according signals */
112
  apalGpioDirection_t direction : 2;  /**< Direction configuration for according signals */
113 135
} apalGpioMeta_t;
114 136

  
115 137
/**
source/alld_a3906.c
33 33
  apalDbgAssert(a3906 != NULL);
34 34

  
35 35
  // set the output of the pin depending on the activation property
36
  return apalControlGpioSet(&a3906->power_pin, (power_state == A3906_LLD_POWER_ON) ? APAL_GPIO_ON : APAL_GPIO_OFF);
36
  return apalControlGpioSet(a3906->power_pin, (power_state == A3906_LLD_POWER_ON) ? APAL_GPIO_ON : APAL_GPIO_OFF);
37 37
}
38 38

  
39 39
/**
......
52 52

  
53 53
  // get current activation state of power gpio
54 54
  apalControlGpioState_t gpio_state;
55
  apalExitStatus_t status = apalControlGpioGet(&a3906->power_pin, &gpio_state);
55
  apalExitStatus_t status = apalControlGpioGet(a3906->power_pin, &gpio_state);
56 56
  *power_state = gpio_state == APAL_GPIO_ON ? A3906_LLD_POWER_ON : A3906_LLD_POWER_OFF;
57 57
  return status;
58 58
}
source/alld_bq24103a.c
33 33
  apalDbgAssert(enable != NULL);
34 34

  
35 35
  apalControlGpioState_t gpio_state;
36
  apalExitStatus_t status = apalControlGpioGet(&bq24103a->gpio_enabled, &gpio_state);
36
  apalExitStatus_t status = apalControlGpioGet(bq24103a->gpio_enabled, &gpio_state);
37 37
  *enable = gpio_state == APAL_GPIO_ON ? BQ24103A_LLD_ENABLED : BQ24103A_LLD_DISABLED;
38 38
  return status;
39 39
}
......
49 49
{
50 50
  apalDbgAssert(bq24103a != NULL);
51 51

  
52
  return apalControlGpioSet(&bq24103a->gpio_enabled, enable == BQ24103A_LLD_ENABLED ? APAL_GPIO_ON : APAL_GPIO_OFF);
52
  return apalControlGpioSet(bq24103a->gpio_enabled, enable == BQ24103A_LLD_ENABLED ? APAL_GPIO_ON : APAL_GPIO_OFF);
53 53
}
54 54

  
55 55
/**
......
65 65
  apalDbgAssert(charge != NULL);
66 66

  
67 67
  apalControlGpioState_t gpio_state;
68
  apalExitStatus_t status = apalControlGpioGet(&bq24103a->gpio_charge_status, &gpio_state);
68
  apalExitStatus_t status = apalControlGpioGet(bq24103a->gpio_charge_status, &gpio_state);
69 69
  *charge = gpio_state == APAL_GPIO_ON ? BQ24103A_LLD_CHARGING : BQ24103A_LLD_NOT_CHARGING;
70 70
  return status;
71 71
}
source/alld_bq27500.c
36 36
  apalDbgAssert(batlow != NULL);
37 37

  
38 38
  apalControlGpioState_t gpio_state;
39
  apalExitStatus_t status = apalControlGpioGet(&bq27500->gpio_batlow, &gpio_state);
39
  apalExitStatus_t status = apalControlGpioGet(bq27500->gpio_batlow, &gpio_state);
40 40
  *batlow = (gpio_state == APAL_GPIO_ON) ? BQ27500_LLD_BATTERY_LOW : BQ27500_LLD_BATTERY_NOT_LOW;
41 41
  return status;
42 42
}
......
55 55
  apalDbgAssert(batgood != NULL);
56 56

  
57 57
  apalControlGpioState_t gpio_state;
58
  apalExitStatus_t status = apalControlGpioGet(&bq27500->gpio_batgood, &gpio_state);
58
  apalExitStatus_t status = apalControlGpioGet(bq27500->gpio_batgood, &gpio_state);
59 59
  *batgood = (gpio_state == APAL_GPIO_ON) ? BQ27500_LLD_BATTERY_GOOD : BQ27500_LLD_BATTERY_NOT_GOOD;
60 60
  return status;
61 61
}
source/alld_led.c
31 31
{
32 32
  apalDbgAssert(led != NULL);
33 33

  
34
  return apalControlGpioSet(&(led->gpio), (state == LED_LLD_STATE_ON) ? APAL_GPIO_ON : APAL_GPIO_OFF);
34
  return apalControlGpioSet(led->gpio, (state == LED_LLD_STATE_ON) ? APAL_GPIO_ON : APAL_GPIO_OFF);
35 35
}
36 36

  
37 37
/**
......
47 47
  apalDbgAssert(state != NULL);
48 48

  
49 49
  apalControlGpioState_t gpio_state;
50
  apalExitStatus_t status = apalControlGpioGet(&led->gpio, &gpio_state);
50
  apalExitStatus_t status = apalControlGpioGet(led->gpio, &gpio_state);
51 51
  *state = gpio_state == APAL_GPIO_ON ? LED_LLD_STATE_ON : LED_LLD_STATE_OFF;
52 52
  return status;
53 53
}
......
62 62
{
63 63
  apalDbgAssert(led != NULL);
64 64

  
65
  return apalGpioToggle(led->gpio.gpio);
65
  return apalGpioToggle(led->gpio->gpio);
66 66
}
67 67

  
68 68
#endif /* defined(AMIROLLD_CFG_USE_LED) */
source/alld_ltc4412.c
33 33
  apalDbgAssert(ctrl != NULL);
34 34

  
35 35
  apalControlGpioState_t gpio_state;
36
  apalExitStatus_t status = apalControlGpioGet(&ltc4412->gpio_ctrl, &gpio_state);
36
  apalExitStatus_t status = apalControlGpioGet(ltc4412->gpio_ctrl, &gpio_state);
37 37
  *ctrl = gpio_state == APAL_GPIO_ON ? LTC4412_LLD_CTRL_ACTIVE : LTC4412_LLD_CTRL_INACTIVE;
38 38
  return status;
39 39
}
......
49 49
{
50 50
  apalDbgAssert(ltc4412 != NULL);
51 51

  
52
  return apalControlGpioSet(&ltc4412->gpio_ctrl, ctrl == LTC4412_LLD_CTRL_ACTIVE ? APAL_GPIO_ON : APAL_GPIO_OFF);
52
  return apalControlGpioSet(ltc4412->gpio_ctrl, ctrl == LTC4412_LLD_CTRL_ACTIVE ? APAL_GPIO_ON : APAL_GPIO_OFF);
53 53
}
54 54

  
55 55
/**
......
65 65
  apalDbgAssert(stat != NULL);
66 66

  
67 67
  apalControlGpioState_t gpio_state;
68
  apalExitStatus_t status = apalControlGpioGet(&ltc4412->gpio_stat, &gpio_state);
68
  apalExitStatus_t status = apalControlGpioGet(ltc4412->gpio_stat, &gpio_state);
69 69
  *stat = gpio_state == APAL_GPIO_ON ? LTC4412_LLD_STAT_ACTIVE : LTC4412_LLD_STAT_INACTIVE;
70 70
  return status;
71 71
}
source/alld_tlc5947.c
32 32
  apalDbgAssert(tlc5947 != NULL);
33 33

  
34 34
  // set the output value of the GPIO pin depending on the activation property
35
  return apalControlGpioSet(&tlc5947->blank_gpio, blank == TLC5947_LLD_BLANK_ENABLE ? APAL_GPIO_ON : APAL_GPIO_OFF);
35
  return apalControlGpioSet(tlc5947->blank_gpio, blank == TLC5947_LLD_BLANK_ENABLE ? APAL_GPIO_ON : APAL_GPIO_OFF);
36 36
}
37 37

  
38 38
/**
......
48 48
  apalDbgAssert(blank != NULL);
49 49

  
50 50
  apalControlGpioState_t gpio_state;
51
  apalExitStatus_t status = apalControlGpioGet(&tlc5947->blank_gpio, &gpio_state);
51
  apalExitStatus_t status = apalControlGpioGet(tlc5947->blank_gpio, &gpio_state);
52 52
  *blank = gpio_state == APAL_GPIO_ON ? TLC5947_LLD_BLANK_ENABLE : TLC5947_LLD_BLANK_DISABLE;
53 53
  return status;
54 54
}
......
63 63
{
64 64
  apalDbgAssert(tlc5947 != NULL);
65 65

  
66
  apalExitStatus_t status = apalControlGpioSet(&tlc5947->xlat_gpio, APAL_GPIO_ON);
66
  apalExitStatus_t status = apalControlGpioSet(tlc5947->xlat_gpio, APAL_GPIO_ON);
67 67
  // The XLAT signal has to be active for at least 30 ns.
68 68
  // It is assumed that that these function calls satisfy this requirement even without explicit delay.
69
  if (apalControlGpioSet(&tlc5947->xlat_gpio, APAL_GPIO_OFF) == APAL_STATUS_OK && status == APAL_STATUS_OK) {
69
  if (apalControlGpioSet(tlc5947->xlat_gpio, APAL_GPIO_OFF) == APAL_STATUS_OK && status == APAL_STATUS_OK) {
70 70
    return APAL_STATUS_OK;
71 71
  } else {
72 72
    return APAL_STATUS_ERROR;
source/alld_tps2051bdbv.c
31 31
{
32 32
  apalDbgAssert(tps2051b != NULL);
33 33

  
34
  return apalControlGpioSet(&tps2051b->enable, enable == TPS2051B_LLD_ENABLE ? APAL_GPIO_ON : APAL_GPIO_OFF);
34
  return apalControlGpioSet(tps2051b->enable, enable == TPS2051B_LLD_ENABLE ? APAL_GPIO_ON : APAL_GPIO_OFF);
35 35
}
36 36

  
37 37
/**
......
47 47
  apalDbgAssert(enable != NULL);
48 48

  
49 49
  apalControlGpioState_t gpio_state;
50
  apalExitStatus_t status = apalControlGpioGet(&tps2051b->enable, &gpio_state);
50
  apalExitStatus_t status = apalControlGpioGet(tps2051b->enable, &gpio_state);
51 51
  *enable = gpio_state == APAL_GPIO_ON ? TPS2051B_LLD_ENABLE : TPS2051B_LLD_DISABLE;
52 52
  return status;
53 53
}
......
65 65
  apalDbgAssert(oc != NULL);
66 66

  
67 67
  apalControlGpioState_t gpio_state;
68
  apalExitStatus_t status = apalControlGpioGet(&tps2051b->overcurrent, &gpio_state);
68
  apalExitStatus_t status = apalControlGpioGet(tps2051b->overcurrent, &gpio_state);
69 69
  *oc = gpio_state == APAL_GPIO_ON ? TPS2051B_LLD_OVERCURRENT : TPS2051B_LLD_NO_OVERCURRENT;
70 70
  return status;
71 71
}
source/alld_tps62113.c
33 33
  apalDbgAssert(power != NULL);
34 34

  
35 35
  apalControlGpioState_t gpio_state;
36
  apalExitStatus_t status = apalControlGpioGet(&tps62113->gpio_power, &gpio_state);
36
  apalExitStatus_t status = apalControlGpioGet(tps62113->gpio_power, &gpio_state);
37 37
  *power = (gpio_state == APAL_GPIO_ON) ? TPS62113_LLD_POWER_ENABLED : TPS62113_LLD_POWER_DISABLED;
38 38
  return status;
39 39
}
......
49 49
{
50 50
  apalDbgAssert(tps62113 != NULL);
51 51

  
52
  return apalControlGpioSet(&tps62113->gpio_power, (power == TPS62113_LLD_POWER_ENABLED) ? APAL_GPIO_ON : APAL_GPIO_OFF);
52
  return apalControlGpioSet(tps62113->gpio_power, (power == TPS62113_LLD_POWER_ENABLED) ? APAL_GPIO_ON : APAL_GPIO_OFF);
53 53
}
54 54

  
55 55
#endif /* defined(AMIROLLD_CFG_USE_TPS62113) */
templates/alldconf.h
26 26
#define AMIRO_LLD_CFG_VERSION_MAJOR         1
27 27
#define AMIRO_LLD_CFG_VERSION_MINOR         0
28 28

  
29
/**
30
 * @brief   Width of the apalTime_t data type.
31
 *
32
 * @details Possible values are 8, 16, 32, and 64 bits.
33
 *          By definition time is represented ot a microsecond precision.
34
 */
35
#define AMIROLLD_CFG_TIME_SIZE          32
36

  
29 37
/*
30 38
 * DEACTIVATE DRIVERS BY UNDEFINING (i.e. commenting) THE ACCORDING MACROS.
31 39
 */

Also available in: Unified diff