gpio.h
Go to the documentation of this file.
1 /* --COPYRIGHT--,BSD
2  * Copyright (c) 2017, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  * --/COPYRIGHT--*/
32 #ifndef __GPIO_H__
33 #define __GPIO_H__
34 
35 //*****************************************************************************
36 //
39 //
40 //*****************************************************************************
41 
42 //*****************************************************************************
43 //
44 // If building with a C++ compiler, make all of the definitions in this header
45 // have a C binding.
46 //
47 //*****************************************************************************
48 #ifdef __cplusplus
49 extern "C"
50 {
51 #endif
52 
53 #include <ti/devices/msp432p4xx/inc/msp.h>
54 #include <stdint.h>
55 
56 #define GPIO_PORT_P1 1
57 #define GPIO_PORT_P2 2
58 #define GPIO_PORT_P3 3
59 #define GPIO_PORT_P4 4
60 #define GPIO_PORT_P5 5
61 #define GPIO_PORT_P6 6
62 #define GPIO_PORT_P7 7
63 #define GPIO_PORT_P8 8
64 #define GPIO_PORT_P9 9
65 #define GPIO_PORT_P10 10
66 #define GPIO_PORT_PA 1
67 #define GPIO_PORT_PB 3
68 #define GPIO_PORT_PC 5
69 #define GPIO_PORT_PD 7
70 #define GPIO_PORT_PE 9
71 #define GPIO_PORT_PJ 11
72 
73 
74 #define GPIO_PIN0 (0x0001)
75 #define GPIO_PIN1 (0x0002)
76 #define GPIO_PIN2 (0x0004)
77 #define GPIO_PIN3 (0x0008)
78 #define GPIO_PIN4 (0x0010)
79 #define GPIO_PIN5 (0x0020)
80 #define GPIO_PIN6 (0x0040)
81 #define GPIO_PIN7 (0x0080)
82 #define GPIO_PIN8 (0x0100)
83 #define GPIO_PIN9 (0x0200)
84 #define GPIO_PIN10 (0x0400)
85 #define GPIO_PIN11 (0x0800)
86 #define GPIO_PIN12 (0x1000)
87 #define GPIO_PIN13 (0x2000)
88 #define GPIO_PIN14 (0x4000)
89 #define GPIO_PIN15 (0x8000)
90 #define PIN_ALL8 (0xFF)
91 #define PIN_ALL16 (0xFFFF)
92 
93 #define GPIO_PRIMARY_MODULE_FUNCTION (0x01)
94 #define GPIO_SECONDARY_MODULE_FUNCTION (0x02)
95 #define GPIO_TERTIARY_MODULE_FUNCTION (0x03)
96 
97 #define GPIO_HIGH_TO_LOW_TRANSITION (0x01)
98 #define GPIO_LOW_TO_HIGH_TRANSITION (0x00)
99 
100 #define GPIO_INPUT_PIN_HIGH (0x01)
101 #define GPIO_INPUT_PIN_LOW (0x00)
102 
103 /* DriverLib internal GPIO register offset for optimized performance */
104 #define OFS_LIB_PAIN ((uint32_t)&P1->IN - (uint32_t)P1)
105 #define OFS_LIB_PAOUT ((uint32_t)&P1->OUT - (uint32_t)P1)
106 #define OFS_LIB_PADIR ((uint32_t)&P1->DIR - (uint32_t)P1)
107 #define OFS_LIB_PAREN ((uint32_t)&P1->REN - (uint32_t)P1)
108 #define OFS_LIB_PADS ((uint32_t)&P1->DS - (uint32_t)P1)
109 #define OFS_LIB_PASEL0 ((uint32_t)&P1->SEL0 - (uint32_t)P1)
110 #define OFS_LIB_PASEL1 ((uint32_t)&P1->SEL1 - (uint32_t)P1)
111 #define OFS_LIB_PAIE ((uint32_t)&P1->IE - (uint32_t)P1)
112 #define OFS_LIB_PAIES ((uint32_t)&P1->IES - (uint32_t)P1)
113 #define OFS_LIB_PAIFG ((uint32_t)&P1->IFG - (uint32_t)P1)
114 #define OFS_LIB_P1IE ((uint32_t)&P1->IE - (uint32_t)P1)
115 #define OFS_LIB_P2IE OFS_LIB_P1IE
116 
117 //*****************************************************************************
118 //
119 // Prototypes for the APIs.
120 //
121 //*****************************************************************************
122 
123 //*****************************************************************************
124 //
165 //
166 //*****************************************************************************
167 extern void GPIO_setAsOutputPin(uint_fast8_t selectedPort,
168  uint_fast16_t selectedPins);
169 
170 //*****************************************************************************
171 //
213 //
214 //*****************************************************************************
215 extern void GPIO_setAsInputPin(uint_fast8_t selectedPort,
216  uint_fast16_t selectedPins);
217 
218 //*****************************************************************************
219 //
272 //
273 //*****************************************************************************
275  uint_fast8_t selectedPort, uint_fast16_t selectedPins,
276  uint_fast8_t mode);
277 
278 //*****************************************************************************
279 //
332 //
333 //*****************************************************************************
335  uint_fast8_t selectedPort, uint_fast16_t selectedPins,
336  uint_fast8_t mode);
337 
338 //*****************************************************************************
339 //
380 //
381 //*****************************************************************************
382 extern void GPIO_setOutputHighOnPin(uint_fast8_t selectedPort,
383  uint_fast16_t selectedPins);
384 
385 //*****************************************************************************
386 //
425 //
426 //*****************************************************************************
427 extern void GPIO_setOutputLowOnPin(uint_fast8_t selectedPort,
428  uint_fast16_t selectedPins);
429 
430 //*****************************************************************************
431 //
472 //
473 //*****************************************************************************
474 extern void GPIO_toggleOutputOnPin(uint_fast8_t selectedPort,
475  uint_fast16_t selectedPins);
476 
477 //*****************************************************************************
478 //
521 //
522 //*****************************************************************************
523 extern void GPIO_setAsInputPinWithPullDownResistor(uint_fast8_t selectedPort,
524  uint_fast16_t selectedPins);
525 
526 //*****************************************************************************
527 //
570 //
571 //*****************************************************************************
572 extern void GPIO_setAsInputPinWithPullUpResistor(uint_fast8_t selectedPort,
573  uint_fast16_t selectedPins);
574 
575 //*****************************************************************************
576 //
618 //
619 //*****************************************************************************
620 extern uint8_t GPIO_getInputPinValue(uint_fast8_t selectedPort,
621  uint_fast16_t selectedPins);
622 
623 //*****************************************************************************
624 //
657 //
658 //*****************************************************************************
659 extern void GPIO_enableInterrupt(uint_fast8_t selectedPort,
660  uint_fast16_t selectedPins);
661 
662 //*****************************************************************************
663 //
696 //
697 //*****************************************************************************
698 extern void GPIO_disableInterrupt(uint_fast8_t selectedPort,
699  uint_fast16_t selectedPins);
700 
701 //*****************************************************************************
702 //
750 //
751 //*****************************************************************************
752 extern uint_fast16_t GPIO_getInterruptStatus(uint_fast8_t selectedPort,
753  uint_fast16_t selectedPins);
754 
755 //*****************************************************************************
756 //
788 //
789 //*****************************************************************************
790 extern void GPIO_clearInterruptFlag(uint_fast8_t selectedPort,
791  uint_fast16_t selectedPins);
792 
793 //*****************************************************************************
794 //
842 //
843 //*****************************************************************************
844 extern void GPIO_interruptEdgeSelect(uint_fast8_t selectedPort,
845  uint_fast16_t selectedPins, uint_fast8_t edgeSelect);
846 
847 //*****************************************************************************
848 //
890 //
891 //*****************************************************************************
892 extern uint_fast16_t GPIO_getEnabledInterruptStatus(uint_fast8_t selectedPort);
893 
894 
895 //*****************************************************************************
896 //
916 //
917 //*****************************************************************************
918 extern void GPIO_registerInterrupt(uint_fast8_t selectedPort,
919  void (*intHandler)(void));
920 
921 //*****************************************************************************
922 //
935 //
936 //*****************************************************************************
937 extern void GPIO_unregisterInterrupt(uint_fast8_t selectedPort);
938 
939 //*****************************************************************************
940 //
971 //
972 //*****************************************************************************
973 extern void GPIO_setDriveStrengthHigh(uint_fast8_t selectedPort,
974  uint_fast8_t selectedPins);
975 
976 //*****************************************************************************
977 //
1008 //
1009 //*****************************************************************************
1010 extern void GPIO_setDriveStrengthLow(uint_fast8_t selectedPort,
1011  uint_fast8_t selectedPins);
1012 
1013 /* Backwards Compatibility Layer */
1014 #define GPIO_selectInterruptEdge GPIO_interruptEdgeSelect
1015 #define GPIO_clearInterrupt GPIO_clearInterruptFlag
1016 
1017 //*****************************************************************************
1018 //
1019 // Mark the end of the C bindings section for C++ compilers.
1020 //
1021 //*****************************************************************************
1022 #ifdef __cplusplus
1023 }
1024 #endif
1025 
1026 //*****************************************************************************
1027 //
1028 // Close the Doxygen group.
1030 //
1031 //*****************************************************************************
1032 
1033 #endif // __GPIO_H__
void GPIO_setAsPeripheralModuleFunctionInputPin(uint_fast8_t selectedPort, uint_fast16_t selectedPins, uint_fast8_t mode)
This function configures the peripheral module function in the input direction for the selected pin f...
Definition: gpio.c:111
void GPIO_setAsPeripheralModuleFunctionOutputPin(uint_fast8_t selectedPort, uint_fast16_t selectedPins, uint_fast8_t mode)
This function configures the peripheral module function in the output direction for the selected pin ...
Definition: gpio.c:86
uint8_t GPIO_getInputPinValue(uint_fast8_t selectedPort, uint_fast16_t selectedPins)
This function gets the input value on the selected pin.
Definition: gpio.c:194
uint_fast16_t GPIO_getEnabledInterruptStatus(uint_fast8_t selectedPort)
This function gets the interrupt status of the provided PIN and masks it with the interrupts that are...
Definition: gpio.c:261
void GPIO_setDriveStrengthLow(uint_fast8_t selectedPort, uint_fast8_t selectedPins)
Definition: gpio.c:304
uint_fast16_t GPIO_getInterruptStatus(uint_fast8_t selectedPort, uint_fast16_t selectedPins)
This function gets the interrupt status of the selected pin.
Definition: gpio.c:227
void GPIO_interruptEdgeSelect(uint_fast8_t selectedPort, uint_fast16_t selectedPins, uint_fast8_t edgeSelect)
This function selects on what edge the port interrupt flag should be set for a transition.
Definition: gpio.c:248
void GPIO_toggleOutputOnPin(uint_fast8_t selectedPort, uint_fast16_t selectedPins)
This function toggles the output on the selected Pin.
Definition: gpio.c:155
void GPIO_registerInterrupt(uint_fast8_t selectedPort, void(*intHandler)(void))
Definition: gpio.c:315
void GPIO_setAsInputPin(uint_fast8_t selectedPort, uint_fast16_t selectedPins)
This function configures the selected Pin as input pin.
Definition: gpio.c:75
void GPIO_clearInterruptFlag(uint_fast8_t selectedPort, uint_fast16_t selectedPins)
This function clears the interrupt flag on the selected pin.
Definition: gpio.c:237
void GPIO_setAsOutputPin(uint_fast8_t selectedPort, uint_fast16_t selectedPins)
This function configures the selected Pin as output pin.
Definition: gpio.c:65
void GPIO_setOutputLowOnPin(uint_fast8_t selectedPort, uint_fast16_t selectedPins)
This function sets output LOW on the selected Pin.
Definition: gpio.c:145
void GPIO_setDriveStrengthHigh(uint_fast8_t selectedPort, uint_fast8_t selectedPins)
Definition: gpio.c:293
void GPIO_setAsInputPinWithPullUpResistor(uint_fast8_t selectedPort, uint_fast16_t selectedPins)
This function sets the selected Pin in input Mode with Pull Up resistor.
Definition: gpio.c:180
void GPIO_enableInterrupt(uint_fast8_t selectedPort, uint_fast16_t selectedPins)
This function enables the port interrupt on the selected pin.
Definition: gpio.c:208
void GPIO_setOutputHighOnPin(uint_fast8_t selectedPort, uint_fast16_t selectedPins)
This function sets output HIGH on the selected Pin.
Definition: gpio.c:135
void GPIO_disableInterrupt(uint_fast8_t selectedPort, uint_fast16_t selectedPins)
This function disables the port interrupt on the selected pin.
Definition: gpio.c:217
void GPIO_setAsInputPinWithPullDownResistor(uint_fast8_t selectedPort, uint_fast16_t selectedPins)
This function sets the selected Pin in input Mode with Pull Down resistor.
Definition: gpio.c:165
void GPIO_unregisterInterrupt(uint_fast8_t selectedPort)
Definition: gpio.c:333

Copyright 2018, Texas Instruments Incorporated