Robot Control Library
pinmux.h
Go to the documentation of this file.
1/**
2 * <rc/pinmux.h>
3 *
4 * @brief C interface for the Sitara pinmux helper driver
5 *
6 * On the Robotics Cape, we allow changing the pinmux on the SPI, GPS, and UART1
7 * headers in case you wish to expose GPIO, CAN, or PWM functionality. We use
8 * the GPIO number to identify the pins even though they may be used for things
9 * other than GPIO as this provides consistency with the GPIO functions which
10 * will likely be used. A list of defines are also given here to make your code
11 * easier to read and to indicate which pins are available for pinmuxing.
12 *
13 * Not all pinmux modes are available on each pin. However, every pin can be
14 * configured as a GPIO output, or input with either an internal pullup (PU) or
15 * pulldown (PD) resistor.
16 *
17 * The GPS header pins 3 and 4 can be configured to PWM mode which breaks out
18 * channels A and B of PWM subsystem 0 which are not used by the motor drivers
19 * and so are free for the user to do with as they please. They default to UART
20 * mode for communicating with GPS receivers and can also be used in any GPIO
21 * mode.
22 *
23 * The UART1 header pins 3 and 4 also default to UART mode and can be used in
24 * any GPIO mode. However, they also break out the CAN bus RX and TX lines.
25 * However, to use CAN bus you also need to set up a CAN-PHY IC yourself.
26 *
27 * All SPI pins can be used for SPI or GPIO. If you intend to use these pins for
28 * pure GPIO use then use the set_pinmux_mode() function described here. Note
29 * that when configuring the SPI slave select lines for manual or automatic mode
30 * as described in the SPI section of this manual, the rc_spi_init function uses
31 * this pinmux mode in the backend to set up the pin for you.
32 *
33 * The beaglebone Blue additionally has 2 GPIO headers, GP0 & GP1, with 3.3v,
34 * ground, and 4 GPIO signals broken out on each. All 4 signal pins on GP0 can
35 * be configured as one of the 3 different GPIO modes, and so can pins 3 and 4
36 * of GP1. Pins 5 and 6 of the GP1 header are fixed in output mode and are tied
37 * to the Red and Green LED signals in case those signals wish to be extended to
38 * lights outside of a robot's case.
39 *
40 *
41 * @addtogroup Pinmux
42 * @ingroup IO
43 * @{
44 */
45
46#ifndef RC_PINMUX_H
47#define RC_PINMUX_H
48
49#ifdef __cplusplus
50extern "C" {
51#endif
52
53
54/** @name Configurable pins shared between Robotics Cape and BeagleBone Blue */
55///@{
56#define DSM_HEADER_PIN 30 ///< P9.11, normally DSM UART4
57#define GPS_HEADER_PIN_3 2 ///< P9_22, normally GPS UART2 RX
58#define GPS_HEADER_PIN_4 3 ///< P9_21, normally GPS UART2 TX
59#define UART1_HEADER_PIN_3 14 ///< P9_26, normally UART1 RX
60#define UART1_HEADER_PIN_4 15 ///< P9_24, normally UART1 TX
61#define SPI_HEADER_PIN_3 112 ///< P9_30, normally SPI1 MOSI
62#define SPI_HEADER_PIN_4 111 ///< P9_29, normally SPI1 MISO
63#define SPI_HEADER_PIN_5 110 ///< P9_31, normally SPI1 SCLK
64///@}
65
66/** @name Configurable pins for Robotics Cape only */
67///@{
68#define CAPE_SPI_PIN_6_SS1 113 ///< P9_28, normally SPI mode
69#define CAPE_SPI_PIN_6_SS2 49 ///< P9_23, normally GPIO mode
70///@}
71
72
73/** @name Configurable pins for BeagleBone Blue only */
74///@{
75#define BLUE_SPI_PIN_6_SS1 29 ///< gpio 0_29 pin H18
76#define BLUE_SPI_PIN_6_SS2 7 ///< gpio 0_7 pin C18
77#define BLUE_GP0_PIN_3 57 ///< gpio 1_25 pin U16
78#define BLUE_GP0_PIN_4 49 ///< gpio 1_17 pin P9.23
79#define BLUE_GP0_PIN_5 116 ///< gpio 3_20 pin D13
80#define BLUE_GP0_PIN_6 113 ///< gpio 3_17 pin P9_28
81#define BLUE_GP1_PIN_3 98 ///< gpio 3_2 pin J15
82#define BLUE_GP1_PIN_4 97 ///< gpio 3_1 pin H17
83///@}
84
85
86/**
87 * Gives options for pinmuxing. Not every mode if available on each pin. Refer
88 * to the official BeagleBone pin table for which to use.
89 */
90typedef enum rc_pinmux_mode_t{
99
100/**
101 * @brief sets once of the pins defined in this header to a particular mode
102 *
103 * @param[in] pin The pin
104 * @param[in] mode The mode
105 *
106 * @return 0 on success, -1 on failure
107 */
109
110/**
111 * @brief puts everything back to standard
112 *
113 * @return 0 on success, -1 on failure
114 */
116
117
118#ifdef __cplusplus
119}
120#endif
121
122#endif // RC_PINMUX_H
123
124/** @} end group Pinmux */
int rc_pinmux_set_default(void)
puts everything back to standard
int rc_pinmux_set(int pin, rc_pinmux_mode_t mode)
sets once of the pins defined in this header to a particular mode
rc_pinmux_mode_t
Definition: pinmux.h:90
@ PINMUX_UART
Definition: pinmux.h:96
@ PINMUX_PWM
Definition: pinmux.h:94
@ PINMUX_GPIO_PD
Definition: pinmux.h:93
@ PINMUX_CAN
Definition: pinmux.h:97
@ PINMUX_GPIO_PU
Definition: pinmux.h:92
@ PINMUX_SPI
Definition: pinmux.h:95
@ PINMUX_GPIO
Definition: pinmux.h:91