summaryrefslogtreecommitdiffstats
path: root/bsps/arm/lpc176x/include/bsp/lpc-gpio.h
blob: 9cb23df14233ec1a8e844fca460cddbe789405f9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/**
 * @file lpc-gpio.h
 *
 * @ingroup lpc176x
 *
 * @brief API of the GPIO driver for the lpc176x bsp in RTEMS.
 */

/*
 * Copyright (c) 2014 Taller Technologies.
 *
 * @author  Boretto Martin    (martin.boretto@tallertechnologies.com)
 * @author  Diaz Marcos (marcos.diaz@tallertechnologies.com)
 * @author  Lenarduzzi Federico  (federico.lenarduzzi@tallertechnologies.com)
 * @author  Daniel Chicco  (daniel.chicco@tallertechnologies.com)
 *
 * The license and distribution terms for this file may be
 * found in the file LICENSE in this distribution or at
 * http://www.rtems.org/license/LICENSE.
 */

#ifndef LIBBSP_ARM_LPC176X_GPIO_H
#define LIBBSP_ARM_LPC176X_GPIO_H

#include <bsp/lpc176x.h>
#include <bsp/gpio-defs.h>

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

/**
 * @brief Configures the pin as input or output GPIO.
 *
 * @param pin The pin to configure
 * @param dir Input or output.
 */
rtems_status_code lpc176x_gpio_config(
  lpc176x_pin_number     pin,
  lpc176x_gpio_direction dir
);

/**
 * @brief Configures the pin as input, enables interrupt for an
 * edge/s and sets isrfunct as the function to call when that
 * interrupt occurs.
 *
 * @param pin The pin to configure.
 * @param edge Which edge or edges will activate the interrupt.
 * @param isrfunct The function that is called when the interrupt occurs.
 * @return RTEMS_SUCCESSFULL if the configurations was success.
 */
rtems_status_code lpc176x_gpio_config_input_with_interrupt(
  lpc176x_pin_number              pin,
  lpc176x_gpio_interrupt          edge,
  lpc176x_gpio_interrupt_function isrfunct
);

/**
 * @brief Sets the output pin to 1.
 *
 * @param pin The pin to set
 */
rtems_status_code lpc176x_gpio_set_pin( lpc176x_pin_number pin );

/**
 * @brief Sets the output pin to 0.
 *
 * @param pin The pin to set
 */
rtems_status_code lpc176x_gpio_clear_pin( lpc176x_pin_number pin );

/**
 * @brief Sets the output pin to 0 or 1 according to value.
 *
 * @param pin The pin to set
 * @param value the value to set.
 */
rtems_status_code lpc176x_gpio_write_pin(
  lpc176x_pin_number pin,
  bool               value
);

/**
 * @brief Returns the value at the given input pin.
 *
 * @param pin The pin where to read the value.
 * @param pin_value TRUE if the pin value was getted successfuly.
 * @return RTEMS_SUCCESSFUL if the pin value was getted successfuly.
 */
rtems_status_code lpc176x_gpio_get_pin_value(
  lpc176x_pin_number pin,
  bool              *pin_value
);

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* LIBBSP_ARM_LPC176X_GPIO_H */