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 <msp432.h>
23 #include <stdint.h>
24 #include "register_remap.h"
25 
26 #define GPIO_PORT_P1 1
27 #define GPIO_PORT_P2 2
28 #define GPIO_PORT_P3 3
29 #define GPIO_PORT_P4 4
30 #define GPIO_PORT_P5 5
31 #define GPIO_PORT_P6 6
32 #define GPIO_PORT_P7 7
33 #define GPIO_PORT_P8 8
34 #define GPIO_PORT_P9 9
35 #define GPIO_PORT_P10 10
36 #define GPIO_PORT_PJ 11
37 
38 #define GPIO_PIN0 (0x0001)
39 #define GPIO_PIN1 (0x0002)
40 #define GPIO_PIN2 (0x0004)
41 #define GPIO_PIN3 (0x0008)
42 #define GPIO_PIN4 (0x0010)
43 #define GPIO_PIN5 (0x0020)
44 #define GPIO_PIN6 (0x0040)
45 #define GPIO_PIN7 (0x0080)
46 #define GPIO_PIN8 (0x0100)
47 #define GPIO_PIN9 (0x0200)
48 #define GPIO_PIN10 (0x0400)
49 #define GPIO_PIN11 (0x0800)
50 #define GPIO_PIN12 (0x1000)
51 #define GPIO_PIN13 (0x2000)
52 #define GPIO_PIN14 (0x4000)
53 #define GPIO_PIN15 (0x8000)
54 #define PIN_ALL8 (0xFF)
55 #define PIN_ALL16 (0xFFFF)
56 
57 #define GPIO_PRIMARY_MODULE_FUNCTION (0x01)
58 #define GPIO_SECONDARY_MODULE_FUNCTION (0x02)
59 #define GPIO_TERTIARY_MODULE_FUNCTION (0x03)
60 
61 #define GPIO_HIGH_TO_LOW_TRANSITION (0x01)
62 #define GPIO_LOW_TO_HIGH_TRANSITION (0x00)
63 
64 #define GPIO_INPUT_PIN_HIGH (0x01)
65 #define GPIO_INPUT_PIN_LOW (0x00)
66 
67 //*****************************************************************************
68 //
69 // Prototypes for the APIs.
70 //
71 //*****************************************************************************
72 
73 //*****************************************************************************
74 //
115 //
116 //*****************************************************************************
117 extern void GPIO_setAsOutputPin(uint_fast8_t selectedPort,
118  uint_fast16_t selectedPins);
119 
120 //*****************************************************************************
121 //
163 //
164 //*****************************************************************************
165 extern void GPIO_setAsInputPin(uint_fast8_t selectedPort,
166  uint_fast16_t selectedPins);
167 
168 //*****************************************************************************
169 //
222 //
223 //*****************************************************************************
225  uint_fast8_t selectedPort, uint_fast16_t selectedPins,
226  uint_fast8_t mode);
227 
228 //*****************************************************************************
229 //
282 //
283 //*****************************************************************************
285  uint_fast8_t selectedPort, uint_fast16_t selectedPins,
286  uint_fast8_t mode);
287 
288 //*****************************************************************************
289 //
330 //
331 //*****************************************************************************
332 extern void GPIO_setOutputHighOnPin(uint_fast8_t selectedPort,
333  uint_fast16_t selectedPins);
334 
335 //*****************************************************************************
336 //
377 //
378 //*****************************************************************************
379 extern void GPIO_setOutputLowOnPin(uint_fast8_t selectedPort,
380  uint_fast16_t selectedPins);
381 
382 //*****************************************************************************
383 //
424 //
425 //*****************************************************************************
426 extern void GPIO_toggleOutputOnPin(uint_fast8_t selectedPort,
427  uint_fast16_t selectedPins);
428 
429 //*****************************************************************************
430 //
473 //
474 //*****************************************************************************
475 extern void GPIO_setAsInputPinWithPullDownResistor(uint_fast8_t selectedPort,
476  uint_fast16_t selectedPins);
477 
478 //*****************************************************************************
479 //
522 //
523 //*****************************************************************************
524 extern void GPIO_setAsInputPinWithPullUpResistor(uint_fast8_t selectedPort,
525  uint_fast16_t selectedPins);
526 
527 //*****************************************************************************
528 //
570 //
571 //*****************************************************************************
572 extern uint8_t GPIO_getInputPinValue(uint_fast8_t selectedPort,
573  uint_fast16_t selectedPins);
574 
575 //*****************************************************************************
576 //
609 //
610 //*****************************************************************************
611 extern void GPIO_enableInterrupt(uint_fast8_t selectedPort,
612  uint_fast16_t selectedPins);
613 
614 //*****************************************************************************
615 //
648 //
649 //*****************************************************************************
650 extern void GPIO_disableInterrupt(uint_fast8_t selectedPort,
651  uint_fast16_t selectedPins);
652 
653 //*****************************************************************************
654 //
703 //
704 //*****************************************************************************
705 extern uint_fast16_t GPIO_getInterruptStatus(uint_fast8_t selectedPort,
706  uint_fast16_t selectedPins);
707 
708 //*****************************************************************************
709 //
742 //
743 //*****************************************************************************
744 extern void GPIO_clearInterruptFlag(uint_fast8_t selectedPort,
745  uint_fast16_t selectedPins);
746 
747 //*****************************************************************************
748 //
796 //
797 //*****************************************************************************
798 extern void GPIO_interruptEdgeSelect(uint_fast8_t selectedPort,
799  uint_fast16_t selectedPins, uint_fast8_t edgeSelect);
800 
801 //*****************************************************************************
802 //
844 //
845 //*****************************************************************************
846 extern uint_fast16_t GPIO_getEnabledInterruptStatus(uint_fast8_t selectedPort);
847 
848 
849 //*****************************************************************************
850 //
870 //
871 //*****************************************************************************
872 extern void GPIO_registerInterrupt(uint_fast8_t selectedPort,
873  void (*intHandler)(void));
874 
875 //*****************************************************************************
876 //
889 //
890 //*****************************************************************************
891 extern void GPIO_unregisterInterrupt(uint_fast8_t selectedPort);
892 
893 //*****************************************************************************
894 //
925 //
926 //*****************************************************************************
927 extern void GPIO_setDriveStrengthHigh(uint_fast8_t selectedPort,
928  uint_fast8_t selectedPins);
929 
930 //*****************************************************************************
931 //
962 //
963 //*****************************************************************************
964 extern void GPIO_setDriveStrengthLow(uint_fast8_t selectedPort,
965  uint_fast8_t selectedPins);
966 
967 //*****************************************************************************
968 //
969 // Mark the end of the C bindings section for C++ compilers.
970 //
971 //*****************************************************************************
972 #ifdef __cplusplus
973 }
974 #endif
975 
976 //*****************************************************************************
977 //
978 // Close the Doxygen group.
980 //
981 //*****************************************************************************
982 
983 #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:81
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:56
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:164
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:231
void GPIO_setDriveStrengthLow(uint_fast8_t selectedPort, uint_fast8_t selectedPins)
Definition: gpio.c:274
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:197
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:218
void GPIO_toggleOutputOnPin(uint_fast8_t selectedPort, uint_fast16_t selectedPins)
This function toggles the output on the selected Pin.
Definition: gpio.c:125
void GPIO_registerInterrupt(uint_fast8_t selectedPort, void(*intHandler)(void))
Definition: gpio.c:285
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:207
void GPIO_setAsOutputPin(uint_fast8_t selectedPort, uint_fast16_t selectedPins)
This function configures the selected Pin as output pin.
Definition: gpio.c:33
void GPIO_setOutputLowOnPin(uint_fast8_t selectedPort, uint_fast16_t selectedPins)
This function sets output LOW on the selected Pin.
Definition: gpio.c:115
void GPIO_setDriveStrengthHigh(uint_fast8_t selectedPort, uint_fast8_t selectedPins)
Definition: gpio.c:263
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:150
void GPIO_enableInterrupt(uint_fast8_t selectedPort, uint_fast16_t selectedPins)
This function enables the port interrupt on the selected pin.
Definition: gpio.c:178
void GPIO_setOutputHighOnPin(uint_fast8_t selectedPort, uint_fast16_t selectedPins)
This function sets output HIGH on the selected Pin.
Definition: gpio.c:105
void GPIO_disableInterrupt(uint_fast8_t selectedPort, uint_fast16_t selectedPins)
This function disables the port interrupt on the selected pin.
Definition: gpio.c:187
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:135
void GPIO_unregisterInterrupt(uint_fast8_t selectedPort)
Definition: gpio.c:303

Copyright 2014, Texas Instruments Incorporated