Wixel SDK
gpio.c
1 #include <cc2511_types.h>
2 #include <cc2511_map.h>
3 #include <gpio.h>
4 
5 #define PIN_SWITCH(operation) switch(pinNumber) { \
6  case 0: operation(0,0); break; \
7  case 1: operation(0,1); break; \
8  case 2: operation(0,2); break; \
9  case 3: operation(0,3); break; \
10  case 4: operation(0,4); break; \
11  case 5: operation(0,5); break; \
12  case 10: operation(1,0); break; \
13  case 11: operation(1,1); break; \
14  case 12: operation(1,2); break; \
15  case 13: operation(1,3); break; \
16  case 14: operation(1,4); break; \
17  case 15: operation(1,5); break; \
18  case 16: operation(1,6); break; \
19  case 17: operation(1,7); break; \
20  case 20: operation(2,0); break; \
21  case 21: operation(2,1); break; \
22  case 22: operation(2,2); break; \
23  case 23: operation(2,3); break; \
24  case 24: operation(2,4); break; }
25 
26 #define SET_DIGITAL_OUTPUT(port, pin) { \
27  P##port##_##pin = value; \
28  P##port##DIR |= (1<<pin); }
29 
30 #define SET_DIGITAL_INPUT(port, pin) { \
31  if (pulled){ P##port##INP &= ~(1<<pin); } else { P##port##INP |= (1<<pin); } \
32  P##port##DIR &= ~(1<<pin); }
33 
34 #define IS_DIGITAL_INPUT_HIGH(port, pin) { return P##port##_##pin; }
35 
36 void setDigitalOutput(uint8 pinNumber, BIT value) __reentrant
37 {
38  PIN_SWITCH(SET_DIGITAL_OUTPUT);
39 }
40 
41 void setDigitalInput(uint8 pinNumber, BIT pulled) __reentrant
42 {
43  PIN_SWITCH(SET_DIGITAL_INPUT);
44 }
45 
46 BIT isPinHigh(uint8 pinNumber) __reentrant
47 {
48  PIN_SWITCH(IS_DIGITAL_INPUT_HIGH);
49  return 0;
50 }
51 
52 void setPort0PullType(BIT pullType) __reentrant
53 {
54  if (pullType){ P2INP &= ~(1<<5); }
55  else { P2INP |= (1<<5); }
56 }
57 
58 void setPort1PullType(BIT pullType) __reentrant
59 {
60  if (pullType){ P2INP &= ~(1<<6); }
61  else { P2INP |= (1<<6); }
62 }
63 
64 void setPort2PullType(BIT pullType) __reentrant
65 {
66  if (pullType){ P2INP &= ~(1<<7); }
67  else { P2INP |= (1<<7); }
68 }
void setPort0PullType(BIT pullType) __reentrant
Definition: gpio.c:52
void setDigitalInput(uint8 pinNumber, BIT pulled) __reentrant
Configures the specified pin as an input.
Definition: gpio.c:41
void setPort1PullType(BIT pullType) __reentrant
Definition: gpio.c:58
void setDigitalOutput(uint8 pinNumber, BIT value) __reentrant
Configures the specified pin as a digital output.
Definition: gpio.c:36
__bit BIT
Definition: cc2511_types.h:32
unsigned char uint8
Definition: cc2511_types.h:9
BIT isPinHigh(uint8 pinNumber) __reentrant
Returns the current input or output value of the pin.
Definition: gpio.c:46
void setPort2PullType(BIT pullType) __reentrant
Definition: gpio.c:64