gpio.h
Go to the documentation of this file.
1 #ifndef __GPIO_H__
2 #define __GPIO_H__
3 
4 //*****************************************************************************
5 //
8 //
9 //*****************************************************************************
10 
11 //*****************************************************************************
12 //
13 // If building with a C++ compiler, make all of the definitions in this header
14 // have a C binding.
15 //
16 //*****************************************************************************
17 #ifdef __cplusplus
18 extern "C"
19 {
20 #endif
21 
22 #include <msp.h>
23 #include <stdint.h>
24 
25 #define GPIO_PORT_P1 1
26 #define GPIO_PORT_P2 2
27 #define GPIO_PORT_P3 3
28 #define GPIO_PORT_P4 4
29 #define GPIO_PORT_P5 5
30 #define GPIO_PORT_P6 6
31 #define GPIO_PORT_P7 7
32 #define GPIO_PORT_P8 8
33 #define GPIO_PORT_P9 9
34 #define GPIO_PORT_P10 10
35 #define GPIO_PORT_PA 1
36 #define GPIO_PORT_PB 3
37 #define GPIO_PORT_PC 5
38 #define GPIO_PORT_PD 7
39 #define GPIO_PORT_PE 9
40 #define GPIO_PORT_PJ 11
41 
42 
43 #define GPIO_PIN0 (0x0001)
44 #define GPIO_PIN1 (0x0002)
45 #define GPIO_PIN2 (0x0004)
46 #define GPIO_PIN3 (0x0008)
47 #define GPIO_PIN4 (0x0010)
48 #define GPIO_PIN5 (0x0020)
49 #define GPIO_PIN6 (0x0040)
50 #define GPIO_PIN7 (0x0080)
51 #define GPIO_PIN8 (0x0100)
52 #define GPIO_PIN9 (0x0200)
53 #define GPIO_PIN10 (0x0400)
54 #define GPIO_PIN11 (0x0800)
55 #define GPIO_PIN12 (0x1000)
56 #define GPIO_PIN13 (0x2000)
57 #define GPIO_PIN14 (0x4000)
58 #define GPIO_PIN15 (0x8000)
59 #define PIN_ALL8 (0xFF)
60 #define PIN_ALL16 (0xFFFF)
61 
62 #define GPIO_PRIMARY_MODULE_FUNCTION (0x01)
63 #define GPIO_SECONDARY_MODULE_FUNCTION (0x02)
64 #define GPIO_TERTIARY_MODULE_FUNCTION (0x03)
65 
66 #define GPIO_HIGH_TO_LOW_TRANSITION (0x01)
67 #define GPIO_LOW_TO_HIGH_TRANSITION (0x00)
68 
69 #define GPIO_INPUT_PIN_HIGH (0x01)
70 #define GPIO_INPUT_PIN_LOW (0x00)
71 
72 /* DriverLib internal GPIO register offset for optimized performance */
73 #define OFS_LIB_PAIN ((uint32_t)&P1->IN - (uint32_t)P1)
74 #define OFS_LIB_PAOUT ((uint32_t)&P1->OUT - (uint32_t)P1)
75 #define OFS_LIB_PADIR ((uint32_t)&P1->DIR - (uint32_t)P1)
76 #define OFS_LIB_PAREN ((uint32_t)&P1->REN - (uint32_t)P1)
77 #define OFS_LIB_PADS ((uint32_t)&P1->DS - (uint32_t)P1)
78 #define OFS_LIB_PASEL0 ((uint32_t)&P1->SEL0 - (uint32_t)P1)
79 #define OFS_LIB_PASEL1 ((uint32_t)&P1->SEL1 - (uint32_t)P1)
80 #define OFS_LIB_PAIE ((uint32_t)&P1->IE - (uint32_t)P1)
81 #define OFS_LIB_PAIES ((uint32_t)&P1->IES - (uint32_t)P1)
82 #define OFS_LIB_PAIFG ((uint32_t)&P1->IFG - (uint32_t)P1)
83 #define OFS_LIB_P1IE ((uint32_t)&P1->IE - (uint32_t)P1)
84 #define OFS_LIB_P2IE OFS_LIB_P1IE
85 
86 //*****************************************************************************
87 //
88 // Prototypes for the APIs.
89 //
90 //*****************************************************************************
91 
92 //*****************************************************************************
93 //
134 //
135 //*****************************************************************************
136 extern void GPIO_setAsOutputPin(uint_fast8_t selectedPort,
137  uint_fast16_t selectedPins);
138 
139 //*****************************************************************************
140 //
182 //
183 //*****************************************************************************
184 extern void GPIO_setAsInputPin(uint_fast8_t selectedPort,
185  uint_fast16_t selectedPins);
186 
187 //*****************************************************************************
188 //
241 //
242 //*****************************************************************************
244  uint_fast8_t selectedPort, uint_fast16_t selectedPins,
245  uint_fast8_t mode);
246 
247 //*****************************************************************************
248 //
301 //
302 //*****************************************************************************
304  uint_fast8_t selectedPort, uint_fast16_t selectedPins,
305  uint_fast8_t mode);
306 
307 //*****************************************************************************
308 //
349 //
350 //*****************************************************************************
351 extern void GPIO_setOutputHighOnPin(uint_fast8_t selectedPort,
352  uint_fast16_t selectedPins);
353 
354 //*****************************************************************************
355 //
394 //
395 //*****************************************************************************
396 extern void GPIO_setOutputLowOnPin(uint_fast8_t selectedPort,
397  uint_fast16_t selectedPins);
398 
399 //*****************************************************************************
400 //
441 //
442 //*****************************************************************************
443 extern void GPIO_toggleOutputOnPin(uint_fast8_t selectedPort,
444  uint_fast16_t selectedPins);
445 
446 //*****************************************************************************
447 //
490 //
491 //*****************************************************************************
492 extern void GPIO_setAsInputPinWithPullDownResistor(uint_fast8_t selectedPort,
493  uint_fast16_t selectedPins);
494 
495 //*****************************************************************************
496 //
539 //
540 //*****************************************************************************
541 extern void GPIO_setAsInputPinWithPullUpResistor(uint_fast8_t selectedPort,
542  uint_fast16_t selectedPins);
543 
544 //*****************************************************************************
545 //
587 //
588 //*****************************************************************************
589 extern uint8_t GPIO_getInputPinValue(uint_fast8_t selectedPort,
590  uint_fast16_t selectedPins);
591 
592 //*****************************************************************************
593 //
626 //
627 //*****************************************************************************
628 extern void GPIO_enableInterrupt(uint_fast8_t selectedPort,
629  uint_fast16_t selectedPins);
630 
631 //*****************************************************************************
632 //
665 //
666 //*****************************************************************************
667 extern void GPIO_disableInterrupt(uint_fast8_t selectedPort,
668  uint_fast16_t selectedPins);
669 
670 //*****************************************************************************
671 //
720 //
721 //*****************************************************************************
722 extern uint_fast16_t GPIO_getInterruptStatus(uint_fast8_t selectedPort,
723  uint_fast16_t selectedPins);
724 
725 //*****************************************************************************
726 //
759 //
760 //*****************************************************************************
761 extern void GPIO_clearInterruptFlag(uint_fast8_t selectedPort,
762  uint_fast16_t selectedPins);
763 
764 //*****************************************************************************
765 //
813 //
814 //*****************************************************************************
815 extern void GPIO_interruptEdgeSelect(uint_fast8_t selectedPort,
816  uint_fast16_t selectedPins, uint_fast8_t edgeSelect);
817 
818 //*****************************************************************************
819 //
861 //
862 //*****************************************************************************
863 extern uint_fast16_t GPIO_getEnabledInterruptStatus(uint_fast8_t selectedPort);
864 
865 
866 //*****************************************************************************
867 //
887 //
888 //*****************************************************************************
889 extern void GPIO_registerInterrupt(uint_fast8_t selectedPort,
890  void (*intHandler)(void));
891 
892 //*****************************************************************************
893 //
906 //
907 //*****************************************************************************
908 extern void GPIO_unregisterInterrupt(uint_fast8_t selectedPort);
909 
910 //*****************************************************************************
911 //
942 //
943 //*****************************************************************************
944 extern void GPIO_setDriveStrengthHigh(uint_fast8_t selectedPort,
945  uint_fast8_t selectedPins);
946 
947 //*****************************************************************************
948 //
979 //
980 //*****************************************************************************
981 extern void GPIO_setDriveStrengthLow(uint_fast8_t selectedPort,
982  uint_fast8_t selectedPins);
983 
984 /* Backwards Compatibility Layer */
985 #define GPIO_selectInterruptEdge GPIO_interruptEdgeSelect
986 #define GPIO_clearInterrupt GPIO_clearInterruptFlag
987 
988 //*****************************************************************************
989 //
990 // Mark the end of the C bindings section for C++ compilers.
991 //
992 //*****************************************************************************
993 #ifdef __cplusplus
994 }
995 #endif
996 
997 //*****************************************************************************
998 //
999 // Close the Doxygen group.
1001 //
1002 //*****************************************************************************
1003 
1004 #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:80
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:55
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:163
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:230
void GPIO_setDriveStrengthLow(uint_fast8_t selectedPort, uint_fast8_t selectedPins)
Definition: gpio.c:273
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:196
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:217
void GPIO_toggleOutputOnPin(uint_fast8_t selectedPort, uint_fast16_t selectedPins)
This function toggles the output on the selected Pin.
Definition: gpio.c:124
void GPIO_registerInterrupt(uint_fast8_t selectedPort, void(*intHandler)(void))
Definition: gpio.c:284
void GPIO_setAsInputPin(uint_fast8_t selectedPort, uint_fast16_t selectedPins)
This function configures the selected Pin as input pin.
Definition: gpio.c:44
void GPIO_clearInterruptFlag(uint_fast8_t selectedPort, uint_fast16_t selectedPins)
This function clears the interrupt flag on the selected pin.
Definition: gpio.c:206
void GPIO_setAsOutputPin(uint_fast8_t selectedPort, uint_fast16_t selectedPins)
This function configures the selected Pin as output pin.
Definition: gpio.c:34
void GPIO_setOutputLowOnPin(uint_fast8_t selectedPort, uint_fast16_t selectedPins)
This function sets output LOW on the selected Pin.
Definition: gpio.c:114
void GPIO_setDriveStrengthHigh(uint_fast8_t selectedPort, uint_fast8_t selectedPins)
Definition: gpio.c:262
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:149
void GPIO_enableInterrupt(uint_fast8_t selectedPort, uint_fast16_t selectedPins)
This function enables the port interrupt on the selected pin.
Definition: gpio.c:177
void GPIO_setOutputHighOnPin(uint_fast8_t selectedPort, uint_fast16_t selectedPins)
This function sets output HIGH on the selected Pin.
Definition: gpio.c:104
void GPIO_disableInterrupt(uint_fast8_t selectedPort, uint_fast16_t selectedPins)
This function disables the port interrupt on the selected pin.
Definition: gpio.c:186
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:134
void GPIO_unregisterInterrupt(uint_fast8_t selectedPort)
Definition: gpio.c:302

Copyright 2016, Texas Instruments Incorporated