Embedded System Design 2 - Project
pin_mapping.h
Go to the documentation of this file.
1 /***************************************************************************//**
2  * @file pin_mapping.h
3  * @brief The pin definitions for the regular and custom Happy Gecko board.
4  * @version 2.0
5  * @author Brecht Van Eeckhoudt
6  *
7  * ******************************************************************************
8  *
9  * @section Versions
10  *
11  * @li v1.0: Started with custom board pinout.
12  * @li v1.1: Added regular board pinout, selectable with define statement.
13  * @li v1.2: Added documentation.
14  * @li v1.3: Updated code with new DEFINE checks.
15  * @li v1.4: Added IIC definitions.
16  * @li v2.0: Updated version number.
17  *
18  * ******************************************************************************
19  *
20  * @section License
21  *
22  * **Copyright (C) 2019 - Brecht Van Eeckhoudt**
23  *
24  * This program is free software: you can redistribute it and/or modify
25  * it under the terms of the **GNU General Public License** as published by
26  * the Free Software Foundation, either **version 3** of the License, or
27  * (at your option) any later version.
28  *
29  * This program is distributed in the hope that it will be useful,
30  * but WITHOUT ANY WARRANTY; without even the implied warranty of
31  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32  * GNU General Public License for more details.
33  *
34  * *A copy of the GNU General Public License can be found in the `LICENSE`
35  * file along with this source code.*
36  *
37  * @n
38  *
39  * Some methods use code obtained from examples from [Silicon Labs' GitHub](https://github.com/SiliconLabs/peripheral_examples).
40  * These sections are licensed under the Silabs License Agreement. See the file
41  * "Silabs_License_Agreement.txt" for details. Before using this software for
42  * any purpose, you must agree to the terms of that agreement.
43  *
44  ******************************************************************************/
45 
46 
47 /* Include guards prevent multiple inclusions of the same header */
48 #ifndef _PIN_MAPPING_H_
49 #define _PIN_MAPPING_H_
50 
51 
52 /* Include necessary for this header file */
53 #include "em_device.h" /* Include necessary MCU-specific header file */
54 #include "em_gpio.h" /* General Purpose IO */
55 
56 
57 /** Public definition to select the Happy Gecko board *version*
58  * @li `1` - Use the custom Happy Gecko board pinout.
59  * @li `0` - Use the regular Happy Gecko board pinout. */
60 #define CUSTOM_BOARD 1
61 
62 
63 #if CUSTOM_BOARD == 1 /* Custom Happy Gecko pinout */
64 
65  /* ADXL362 */
66  #define ADXL_SPI USART0
67  #define ADXL_SPI_LOC 0
68  #define ADXL_MOSI_PORT gpioPortE
69  #define ADXL_MOSI_PIN 10
70  #define ADXL_MISO_PORT gpioPortE
71  #define ADXL_MISO_PIN 11
72  #define ADXL_CLK_PORT gpioPortE
73  #define ADXL_CLK_PIN 12
74  #define ADXL_NCS_PORT gpioPortF /* Can't use the US0_CS port (PE13) to manually set/clear CS line */
75  #define ADXL_NCS_PIN 5
76 
77  #define ADXL_INT1_PORT gpioPortF
78  #define ADXL_INT1_PIN 3
79  #define ADXL_INT2_PORT gpioPortF /* Unused */
80  #define ADXL_INT2_PIN 4 /* Unused */
81  #define ADXL_VDD_PORT gpioPortA
82  #define ADXL_VDD_PIN 1
83 
84  /* LED */
85  #define LED_PORT gpioPortA
86  #define LED_PIN 2
87 
88  /* Buttons */
89  #define PB0_PORT gpioPortC
90  #define PB0_PIN 9
91  #define PB1_PORT gpioPortC
92  #define PB1_PIN 10
93 
94  /* UART */
95  #define DBG_UART USART1
96  #define DBG_UART_LOC 4
97  #define DBG_TXD_PORT gpioPortF
98  #define DBG_TXD_PIN 2
99  #define DBG_RXD_PORT gpioPortA
100  #define DBG_RXD_PIN 0
101 
102  /* DS18B20 */
103  #define TEMP_DATA_PORT gpioPortC
104  #define TEMP_DATA_PIN 4
105  #define TEMP_VDD_PORT gpioPortB
106  #define TEMP_VDD_PIN 11
107 
108  /* Link breakage sensor */
109  #define BREAK1_PORT gpioPortC
110  #define BREAK1_PIN 2
111  #define BREAK2_PORT gpioPortC
112  #define BREAK2_PIN 3
113 
114  /* RN2483 */
115  #define RN2483_UART LEUART0
116  #define RN2483_UART_LOC 0
117  #define RN2483_TX_PORT gpioPortD
118  #define RN2483_TX_PIN 4
119  #define RN2483_RX_PORT gpioPortD
120  #define RN2483_RX_PIN 5
121  #define RN2483_RESET_PORT gpioPortA
122  #define RN2483_RESET_PIN 10
123 
124  /* External header */
125  #define IIC_EXT I2C0 /* Unused */
126  #define IIT_EXT_LOC 4 /* Unused */
127  #define IIC_SDA_PORT gpioPortC /* Unused */
128  #define IIC_SDA_PIN 0 /* Unused */
129  #define IIC_SCL_PORT gpioPortC /* Unused */
130  #define IIC_SCL_PIN 1 /* Unused */
131 
132  /* Power supply enable */
133  #define PM_RN2483_PORT gpioPortA
134  #define PM_RN2483_PIN 8
135  #define PM_SENS_EXT_PORT gpioPortA
136  #define PM_SENS_EXT_PIN 9
137 
138 #else /* Regular Happy Gecko pinout */
139 
140  /* ADXL362 */
141  #define ADXL_SPI USART0
142  #define ADXL_SPI_LOC 0
143  #define ADXL_MOSI_PORT gpioPortE
144  #define ADXL_MOSI_PIN 10
145  #define ADXL_MISO_PORT gpioPortE
146  #define ADXL_MISO_PIN 11
147  #define ADXL_CLK_PORT gpioPortE
148  #define ADXL_CLK_PIN 12
149  #define ADXL_NCS_PORT gpioPortD /* Can't use the US0_CS port (PE13) to manually set/clear CS line */
150  #define ADXL_NCS_PIN 4
151 
152  #define ADXL_INT1_PORT gpioPortD
153  #define ADXL_INT1_PIN 7
154  // #define ADXL_INT2_PORT gpioPortF
155  // #define ADXL_INT2_PIN 4
156  #define ADXL_VDD_PORT gpioPortD
157  #define ADXL_VDD_PIN 5
158 
159  /* LED */
160  #define LED_PORT gpioPortF
161  #define LED_PIN 4
162 
163  /* Buttons */
164  #define PB0_PORT gpioPortC
165  #define PB0_PIN 9
166  #define PB1_PORT gpioPortC
167  #define PB1_PIN 10
168 
169  /* UART */
170  #define DBG_UART USART1
171  #define DBG_UART_LOC 4
172  #define DBG_TXD_PORT gpioPortF
173  #define DBG_TXD_PIN 2
174  #define DBG_RXD_PORT gpioPortA
175  #define DBG_RXD_PIN 0
176 
177  /* DS18B20 */
178  #define TEMP_DATA_PORT gpioPortA
179  #define TEMP_DATA_PIN 1
180  #define TEMP_VDD_PORT gpioPortA
181  #define TEMP_VDD_PIN 2
182 
183  /* Link breakage sensor */
184  #define BREAK1_PORT gpioPortC
185  #define BREAK1_PIN 1
186  #define BREAK2_PORT gpioPortC
187  #define BREAK2_PIN 2
188 
189  /* RN2483 */
190  #define RN2483_UART LEUART0
191  #define RN2483_UART_LOC 0
192  #define RN2483_TX_PORT gpioPortD
193  #define RN2483_TX_PIN 4
194  #define RN2483_RX_PORT gpioPortD
195  #define RN2483_RX_PIN 5
196  #define RN2483_RESET_PORT gpioPortA
197  #define RN2483_RESET_PIN 10
198 
199  /* External header */
200  #define IIC_EXT I2C0 /* Unused */
201  #define IIT_EXT_LOC 4 /* Unused */
202  #define IIC_SDA_PORT gpioPortC /* Unused */
203  #define IIC_SDA_PIN 0 /* Unused */
204  #define IIC_SCL_PORT gpioPortC /* Unused */
205  #define IIC_SCL_PIN 1 /* Unused */
206 
207  /* Power supply enable */
208  #define PM_RN2483_PORT gpioPortA
209  #define PM_RN2483_PIN 8
210  #define PM_SENS_EXT_PORT gpioPortA
211  #define PM_SENS_EXT_PIN 9
212 
213 #endif /* Board pinout selection */
214 
215 
216 #endif /* _PIN_MAPPING_H_ */