2 * @brief GIO Driver Inmplmentation File
\r
8 /* (c) Texas Instruments 2009-2010, All rights reserved. */
\r
14 /** @fn void gioInit(void)
\r
15 * @brief Initializes the GIO Driver
\r
17 * This function initializes the GIO module and set the GIO ports
\r
18 * to the inital values.
\r
22 /** bring GIO module out of reset */
\r
24 gioREG->INTENACLR = 0xFF;
\r
25 gioREG->LVLCLR = 0xFF;
\r
27 /** @b initalise @b Port @b A */
\r
29 /** - Port A output values */
\r
30 gioPORTA->DOUT = 0 /* Bit 0 */
\r
31 | (0 << 1) /* Bit 1 */
\r
32 | (0 << 2) /* Bit 2 */
\r
33 | (0 << 3) /* Bit 3 */
\r
34 | (0 << 4) /* Bit 4 */
\r
35 | (0 << 5) /* Bit 5 */
\r
36 | (0 << 6) /* Bit 6 */
\r
37 | (0 << 7); /* Bit 7 */
\r
39 /** - Port A direction */
\r
40 gioPORTA->DIR = 1 /* Bit 0 */
\r
41 | (1 << 1) /* Bit 1 */
\r
42 | (0 << 2) /* Bit 2 */
\r
43 | (0 << 3) /* Bit 3 */
\r
44 | (0 << 4) /* Bit 4 */
\r
45 | (0 << 5) /* Bit 5 */
\r
46 | (0 << 6) /* Bit 6 */
\r
47 | (0 << 7); /* Bit 7 */
\r
49 /** - Port A open drain enable */
\r
50 gioPORTA->PDR = 0 /* Bit 0 */
\r
51 | (0 << 1) /* Bit 1 */
\r
52 | (0 << 2) /* Bit 2 */
\r
53 | (0 << 3) /* Bit 3 */
\r
54 | (0 << 4) /* Bit 4 */
\r
55 | (0 << 5) /* Bit 5 */
\r
56 | (0 << 6) /* Bit 6 */
\r
57 | (0 << 7); /* Bit 7 */
\r
59 /** - Port A pullup / pulldown selection */
\r
60 gioPORTA->PSL = 0 /* Bit 0 */
\r
61 | (0 << 1) /* Bit 1 */
\r
62 | (0 << 2) /* Bit 2 */
\r
63 | (0 << 3) /* Bit 3 */
\r
64 | (0 << 4) /* Bit 4 */
\r
65 | (0 << 5) /* Bit 5 */
\r
66 | (0 << 6) /* Bit 6 */
\r
67 | (0 << 7); /* Bit 7 */
\r
69 /** - Port A pullup / pulldown enable*/
\r
70 gioPORTA->PULDIS = 0 /* Bit 0 */
\r
71 | (0 << 1) /* Bit 1 */
\r
72 | (0 << 2) /* Bit 2 */
\r
73 | (0 << 3) /* Bit 3 */
\r
74 | (0 << 4) /* Bit 4 */
\r
75 | (0 << 5) /* Bit 5 */
\r
76 | (0 << 6) /* Bit 6 */
\r
77 | (0 << 7); /* Bit 7 */
\r
79 /** @b initalise @b Port @b B */
\r
81 /** - Port B output values */
\r
82 gioPORTB->DOUT = 0 /* Bit 0 */
\r
83 | (0 << 1) /* Bit 1 */
\r
84 | (0 << 2) /* Bit 2 */
\r
85 | (0 << 3) /* Bit 3 */
\r
86 | (0 << 4) /* Bit 4 */
\r
87 | (0 << 5) /* Bit 5 */
\r
88 | (0 << 6) /* Bit 6 */
\r
89 | (0 << 7); /* Bit 7 */
\r
91 /** - Port B direction */
\r
92 gioPORTB->DIR = 0 /* Bit 0 */
\r
93 | (0 << 1) /* Bit 1 */
\r
94 | (0 << 2) /* Bit 2 */
\r
95 | (0 << 3) /* Bit 3 */
\r
96 | (0 << 4) /* Bit 4 */
\r
97 | (0 << 5) /* Bit 5 */
\r
98 | (0 << 6) /* Bit 6 */
\r
99 | (0 << 7); /* Bit 7 */
\r
101 /** - Port B open drain enable */
\r
102 gioPORTB->PDR = 0 /* Bit 0 */
\r
103 | (0 << 1) /* Bit 1 */
\r
104 | (0 << 2) /* Bit 2 */
\r
105 | (0 << 3) /* Bit 3 */
\r
106 | (0 << 4) /* Bit 4 */
\r
107 | (0 << 5) /* Bit 5 */
\r
108 | (0 << 6) /* Bit 6 */
\r
109 | (0 << 7); /* Bit 7 */
\r
111 /** - Port B pullup / pulldown selection */
\r
112 gioPORTB->PSL = 0 /* Bit 0 */
\r
113 | (0 << 1) /* Bit 1 */
\r
114 | (0 << 2) /* Bit 2 */
\r
115 | (0 << 3) /* Bit 3 */
\r
116 | (0 << 4) /* Bit 4 */
\r
117 | (0 << 5) /* Bit 5 */
\r
118 | (0 << 6) /* Bit 6 */
\r
119 | (0 << 7); /* Bit 7 */
\r
121 /** - Port B pullup / pulldown enable*/
\r
122 gioPORTB->PULDIS = 0 /* Bit 0 */
\r
123 | (0 << 1) /* Bit 1 */
\r
124 | (0 << 2) /* Bit 2 */
\r
125 | (0 << 3) /* Bit 3 */
\r
126 | (0 << 4) /* Bit 4 */
\r
127 | (0 << 5) /* Bit 5 */
\r
128 | (0 << 6) /* Bit 6 */
\r
129 | (0 << 7); /* Bit 7 */
\r
132 /** @b initalise @b interrupts */
\r
134 /** - interrupt polarity */
\r
135 gioREG->POL = 0 /* Bit 0 */
\r
136 | (0 << 1) /* Bit 1 */
\r
137 | (0 << 2) /* Bit 2 */
\r
138 | (0 << 3) /* Bit 3 */
\r
139 | (0 << 4) /* Bit 4 */
\r
140 | (0 << 5) /* Bit 5 */
\r
141 | (0 << 6) /* Bit 6 */
\r
142 | (0 << 7); /* Bit 7 */
\r
144 /** - interrupt level */
\r
145 gioREG->LVLSET = 0 /* Bit 0 */
\r
146 | (0 << 1) /* Bit 1 */
\r
147 | (0 << 2) /* Bit 2 */
\r
148 | (0 << 3) /* Bit 3 */
\r
149 | (0 << 4) /* Bit 4 */
\r
150 | (0 << 5) /* Bit 5 */
\r
151 | (0 << 6) /* Bit 6 */
\r
152 | (0 << 7); /* Bit 7 */
\r
155 /** - clear all pending interrupts */
\r
156 gioREG->FLG = 0xFF;
\r
158 /** - enable interrupts */
\r
159 gioREG->INTENASET = 0 /* Bit 0 */
\r
160 | (0 << 1) /* Bit 1 */
\r
161 | (0 << 2) /* Bit 2 */
\r
162 | (0 << 3) /* Bit 3 */
\r
163 | (0 << 4) /* Bit 4 */
\r
164 | (0 << 5) /* Bit 5 */
\r
165 | (0 << 6) /* Bit 6 */
\r
166 | (0 << 7); /* Bit 7 */
\r
170 /** @fn void gioSetDirection(gioPORT_t *port, unsigned dir)
\r
171 * @brief Set Port Direction
\r
172 * @param[in] port pointer to GIO port:
\r
173 * - gioPORTA: PortA pointer
\r
174 * - gioPORTB: PortB pointer
\r
175 * @param[in] dir value to write to DIR register
\r
177 * Set the direction of GIO pins at runtime.
\r
179 void gioSetDirection(gioPORT_t *port, unsigned dir)
\r
185 /** @fn void gioSetBit(gioPORT_t *port, unsigned bit, unsigned value)
\r
187 * @param[in] port pointer to GIO port:
\r
188 * - gioPORTA: PortA pointer
\r
189 * - gioPORTB: PortB pointer
\r
190 * @param[in] bit number 0-7 that specifies the bit to be written to.
\r
193 * @param[in] value binrary value to write to bit
\r
195 * Writes a value to the specified pin of the given GIO port
\r
197 void gioSetBit(gioPORT_t *port, unsigned bit, unsigned value)
\r
201 port->DSET = 1 << bit;
\r
205 port->DCLR = 1 << bit;
\r
210 /** @fn void gioSetPort(gioPORT_t *port, unsigned value)
\r
211 * @brief Write Port Value
\r
212 * @param[in] port pointer to GIO port:
\r
213 * - gioPORTA: PortA pointer
\r
214 * - gioPORTB: PortB pointer
\r
215 * @param[in] value value to write to port
\r
217 * Writes a value to all pin of a given GIO port
\r
219 void gioSetPort(gioPORT_t *port, unsigned value)
\r
221 port->DOUT = value;
\r
225 /** @fn unsigned gioGetBit(gioPORT_t *port, unsigned bit)
\r
227 * @param[in] port pointer to GIO port:
\r
228 * - gioPORTA: PortA pointer
\r
229 * - gioPORTB: PortB pointer
\r
230 * @param[in] bit number 0-7 that specifies the bit to be written to.
\r
234 * Reads a the current value from the specified pin of the given GIO port
\r
236 unsigned gioGetBit(gioPORT_t *port, unsigned bit)
\r
238 return (port->DIN >> bit) & 1U;
\r
242 /** @fn unsigned gioGetPort(gioPORT_t *port)
\r
243 * @brief Read Port Value
\r
244 * @param[in] port pointer to GIO port:
\r
245 * - gioPORTA: PortA pointer
\r
246 * - gioPORTB: PortB pointer
\r
248 * Reads a the current value of a given GIO port
\r
250 unsigned gioGetPort(gioPORT_t *port)
\r
256 /** @fn void gioEnableNotification(unsigned bit)
\r
257 * @brief Enable Interrupt
\r
258 * @param[in] bit interrupt pin to enable
\r
262 * Enables an innterrupt pin of PortA
\r
264 void gioEnableNotification(unsigned bit)
\r
266 gioREG->INTENASET = 1 << bit;
\r
270 /** @fn void gioDisableNotification(unsigned bit)
\r
271 * @brief Disable Interrupt
\r
272 * @param[in] bit interrupt pin to enable
\r
276 * Disables an innterrupt pin of PortA
\r
278 void gioDisableNotification(unsigned bit)
\r
280 gioREG->INTENACLR = 1 << bit;
\r