1 /******************************************************************************
2 * Filename: ioc.c
3 *
4 * Description: Driver for the IOC.
5 *
6 * Copyright (c) 2015 - 2022, Texas Instruments Incorporated
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 * 1) Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
14 *
15 * 2) Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 *
19 * 3) Neither the name of the ORGANIZATION nor the names of its contributors may
20 * be used to endorse or promote products derived from this software without
21 * specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 *
35 ******************************************************************************/
36
37 #include "ioc.h"
38
39 //*****************************************************************************
40 //
41 // Handle support for DriverLib in ROM:
42 // This section will undo prototype renaming made in the header file
43 //
44 //*****************************************************************************
45 #if !defined(DOXYGEN)
46 #undef IOCPortConfigureSet
47 #define IOCPortConfigureSet NOROM_IOCPortConfigureSet
48 #undef IOCPortConfigureGet
49 #define IOCPortConfigureGet NOROM_IOCPortConfigureGet
50 #undef IOCIOShutdownSet
51 #define IOCIOShutdownSet NOROM_IOCIOShutdownSet
52 #undef IOCIOModeSet
53 #define IOCIOModeSet NOROM_IOCIOModeSet
54 #undef IOCIOIntSet
55 #define IOCIOIntSet NOROM_IOCIOIntSet
56 #undef IOCIOEvtSet
57 #define IOCIOEvtSet NOROM_IOCIOEvtSet
58 #undef IOCIOPortPullSet
59 #define IOCIOPortPullSet NOROM_IOCIOPortPullSet
60 #undef IOCIOHystSet
61 #define IOCIOHystSet NOROM_IOCIOHystSet
62 #undef IOCIOInputSet
63 #define IOCIOInputSet NOROM_IOCIOInputSet
64 #undef IOCIOSlewCtrlSet
65 #define IOCIOSlewCtrlSet NOROM_IOCIOSlewCtrlSet
66 #undef IOCIODrvStrengthSet
67 #define IOCIODrvStrengthSet NOROM_IOCIODrvStrengthSet
68 #undef IOCIOPortIdSet
69 #define IOCIOPortIdSet NOROM_IOCIOPortIdSet
70 #undef IOCIntEnable
71 #define IOCIntEnable NOROM_IOCIntEnable
72 #undef IOCIntDisable
73 #define IOCIntDisable NOROM_IOCIntDisable
74 #undef IOCPinTypeGpioInput
75 #define IOCPinTypeGpioInput NOROM_IOCPinTypeGpioInput
76 #undef IOCPinTypeGpioOutput
77 #define IOCPinTypeGpioOutput NOROM_IOCPinTypeGpioOutput
78 #undef IOCPinTypeUart
79 #define IOCPinTypeUart NOROM_IOCPinTypeUart
80 #undef IOCPinTypeSsiMaster
81 #define IOCPinTypeSsiMaster NOROM_IOCPinTypeSsiMaster
82 #undef IOCPinTypeSsiSlave
83 #define IOCPinTypeSsiSlave NOROM_IOCPinTypeSsiSlave
84 #undef IOCPinTypeI2c
85 #define IOCPinTypeI2c NOROM_IOCPinTypeI2c
86 #undef IOCPinTypeAux
87 #define IOCPinTypeAux NOROM_IOCPinTypeAux
88 #endif
89
90 //*****************************************************************************
91 //
92 // Set the configuration of an IO port
93 //
94 //*****************************************************************************
95 void
IOCPortConfigureSet(uint32_t ui32IOId,uint32_t ui32PortId,uint32_t ui32IOConfig)96 IOCPortConfigureSet(uint32_t ui32IOId, uint32_t ui32PortId,
97 uint32_t ui32IOConfig)
98 {
99 uint32_t ui32Reg;
100
101 // Check the arguments.
102 ASSERT(ui32IOId <= IOID_31);
103 ASSERT(ui32PortId <= IOC_PORT_RFC_GPI1);
104
105 // Get the register address.
106 ui32Reg = IOC_BASE + ( ui32IOId << 2 );
107
108 // Configure the port.
109 HWREG(ui32Reg) = ui32IOConfig | ui32PortId;
110 }
111
112 //*****************************************************************************
113 //
114 // Get the configuration of an IO port
115 //
116 //*****************************************************************************
117 uint32_t
IOCPortConfigureGet(uint32_t ui32IOId)118 IOCPortConfigureGet(uint32_t ui32IOId)
119 {
120 uint32_t ui32Reg;
121
122 // Check the arguments.
123 ASSERT(ui32IOId <= IOID_31);
124
125 // Get the register address.
126 ui32Reg = IOC_BASE + ( ui32IOId << 2 );
127
128 // Return the IO configuration.
129 return HWREG(ui32Reg);
130 }
131
132 //*****************************************************************************
133 //
134 // Set wake-up on an IO port
135 //
136 //*****************************************************************************
137 void
IOCIOShutdownSet(uint32_t ui32IOId,uint32_t ui32IOShutdown)138 IOCIOShutdownSet(uint32_t ui32IOId, uint32_t ui32IOShutdown)
139 {
140 uint32_t ui32Reg;
141 uint32_t ui32Config;
142
143 // Check the arguments.
144 ASSERT(ui32IOId <= IOID_31);
145 ASSERT((ui32IOShutdown == IOC_NO_WAKE_UP) ||
146 (ui32IOShutdown == IOC_WAKE_ON_LOW) ||
147 (ui32IOShutdown == IOC_WAKE_ON_HIGH));
148
149 // Get the register address.
150 ui32Reg = IOC_BASE + ( ui32IOId << 2 );
151
152 // Configure the IO.
153 ui32Config = HWREG(ui32Reg);
154 ui32Config &= ~IOC_IOCFG0_WU_CFG_M;
155 HWREG(ui32Reg) = ui32Config | ui32IOShutdown;
156 }
157
158
159 //*****************************************************************************
160 //
161 // Set the IO Mode of an IO Port
162 //
163 //*****************************************************************************
164 void
IOCIOModeSet(uint32_t ui32IOId,uint32_t ui32IOMode)165 IOCIOModeSet(uint32_t ui32IOId, uint32_t ui32IOMode)
166 {
167 uint32_t ui32Reg;
168 uint32_t ui32Config;
169
170 // Check the arguments.
171 ASSERT(ui32IOId <= IOID_31);
172 ASSERT((ui32IOMode == IOC_IOMODE_NORMAL) ||
173 (ui32IOMode == IOC_IOMODE_INV) ||
174 (ui32IOMode == IOC_IOMODE_OPEN_DRAIN_NORMAL) ||
175 (ui32IOMode == IOC_IOMODE_OPEN_DRAIN_INV) ||
176 (ui32IOMode == IOC_IOMODE_OPEN_SRC_NORMAL) ||
177 (ui32IOMode == IOC_IOMODE_OPEN_SRC_INV));
178
179 // Get the register address.
180 ui32Reg = IOC_BASE + ( ui32IOId << 2 );
181
182 // Configure the IO.
183 ui32Config = HWREG(ui32Reg);
184 ui32Config &= ~IOC_IOCFG0_IOMODE_M;
185 HWREG(ui32Reg) = ui32Config | ui32IOMode;
186 }
187
188 //*****************************************************************************
189 //
190 // Setup interrupt detection on an IO Port
191 //
192 //*****************************************************************************
193 void
IOCIOIntSet(uint32_t ui32IOId,uint32_t ui32Int,uint32_t ui32EdgeDet)194 IOCIOIntSet(uint32_t ui32IOId, uint32_t ui32Int, uint32_t ui32EdgeDet)
195 {
196 uint32_t ui32IOReg;
197 uint32_t ui32Config;
198
199 // Check the arguments.
200 ASSERT(ui32IOId <= IOID_31);
201 ASSERT((ui32Int == IOC_INT_ENABLE) ||
202 (ui32Int == IOC_INT_DISABLE));
203 ASSERT((ui32EdgeDet == IOC_NO_EDGE) ||
204 (ui32EdgeDet == IOC_FALLING_EDGE) ||
205 (ui32EdgeDet == IOC_RISING_EDGE) ||
206 (ui32EdgeDet == IOC_BOTH_EDGES));
207
208 // Get the register address.
209 ui32IOReg = IOC_BASE + ( ui32IOId << 2 );
210
211 // Configure the IO.
212 ui32Config = HWREG(ui32IOReg);
213 ui32Config &= ~(IOC_IOCFG0_EDGE_IRQ_EN | IOC_IOCFG0_EDGE_DET_M);
214 HWREG(ui32IOReg) = ui32Config | ((ui32Int ? IOC_IOCFG0_EDGE_IRQ_EN : 0) | ui32EdgeDet);
215 }
216
217 //*****************************************************************************
218 //
219 // Setup event generation on IO edge detection
220 //
221 //*****************************************************************************
222 void
IOCIOEvtSet(uint32_t ui32IOId,uint32_t ui32Evt)223 IOCIOEvtSet(uint32_t ui32IOId, uint32_t ui32Evt)
224 {
225 uint32_t ui32IOReg;
226 uint32_t ui32Config;
227
228 // Check the arguments.
229 ASSERT(ui32IOId <= IOID_31);
230 ASSERT( (ui32Evt & ~(IOC_IOCFG0_IOEV_AON_PROG2_EN_M |
231 IOC_IOCFG0_IOEV_AON_PROG1_EN_M |
232 IOC_IOCFG0_IOEV_AON_PROG0_EN_M |
233 IOC_IOCFG0_IOEV_RTC_EN_M |
234 IOC_IOCFG0_IOEV_MCU_WU_EN_M) ) == 0x00000000);
235
236 // Get the register address.
237 ui32IOReg = IOC_BASE + ( ui32IOId << 2 );
238
239 // Read current configuration.
240 ui32Config = HWREG(ui32IOReg);
241
242 // Disable generation of all events.
243 ui32Config &= ~(IOC_IOCFG0_IOEV_AON_PROG2_EN_M |
244 IOC_IOCFG0_IOEV_AON_PROG1_EN_M |
245 IOC_IOCFG0_IOEV_AON_PROG0_EN_M |
246 IOC_IOCFG0_IOEV_RTC_EN_M |
247 IOC_IOCFG0_IOEV_MCU_WU_EN_M);
248
249 // Enable the required events.
250 HWREG(ui32IOReg) = ui32Config | ui32Evt;
251 }
252
253 //*****************************************************************************
254 //
255 // Set the pull on an IO port
256 //
257 //*****************************************************************************
258 void
IOCIOPortPullSet(uint32_t ui32IOId,uint32_t ui32Pull)259 IOCIOPortPullSet(uint32_t ui32IOId, uint32_t ui32Pull)
260 {
261 uint32_t ui32IOReg;
262 uint32_t ui32Config;
263
264 // Check the argument.
265 ASSERT(ui32IOId <= IOID_31);
266 ASSERT((ui32Pull == IOC_NO_IOPULL) ||
267 (ui32Pull == IOC_IOPULL_UP) ||
268 (ui32Pull == IOC_IOPULL_DOWN));
269
270 // Get the register address.
271 ui32IOReg = IOC_BASE + ( ui32IOId << 2 );
272
273 // Configure the IO.
274 ui32Config = HWREG(ui32IOReg);
275 ui32Config &= ~IOC_IOCFG0_PULL_CTL_M;
276 HWREG(ui32IOReg) = ui32Config | ui32Pull;
277 }
278
279 //*****************************************************************************
280 //
281 // Configure hysteresis on and IO port
282 //
283 //*****************************************************************************
284 void
IOCIOHystSet(uint32_t ui32IOId,uint32_t ui32Hysteresis)285 IOCIOHystSet(uint32_t ui32IOId, uint32_t ui32Hysteresis)
286 {
287 uint32_t ui32IOReg;
288 uint32_t ui32Config;
289
290 // Check the arguments.
291 ASSERT(ui32IOId <= IOID_31);
292 ASSERT((ui32Hysteresis == IOC_HYST_ENABLE) ||
293 (ui32Hysteresis == IOC_HYST_DISABLE));
294
295 // Get the register address.
296 ui32IOReg = IOC_BASE + ( ui32IOId << 2 );
297
298 // Configure the IO.
299 ui32Config = HWREG(ui32IOReg);
300 ui32Config &= ~IOC_IOCFG0_HYST_EN;
301 HWREG(ui32IOReg) = ui32Config | ui32Hysteresis;
302 }
303
304 //*****************************************************************************
305 //
306 // Enable/disable IO port as input
307 //
308 //*****************************************************************************
309 void
IOCIOInputSet(uint32_t ui32IOId,uint32_t ui32Input)310 IOCIOInputSet(uint32_t ui32IOId, uint32_t ui32Input)
311 {
312 uint32_t ui32IOReg;
313 uint32_t ui32Config;
314
315 // Check the arguments.
316 ASSERT(ui32IOId <= IOID_31);
317 ASSERT((ui32Input == IOC_INPUT_ENABLE) ||
318 (ui32Input == IOC_INPUT_DISABLE));
319
320 // Get the register address.
321 ui32IOReg = IOC_BASE + ( ui32IOId << 2 );
322
323 // Configure the IO.
324 ui32Config = HWREG(ui32IOReg);
325 ui32Config &= ~IOC_IOCFG0_IE;
326 HWREG(ui32IOReg) = ui32Config | ui32Input;
327 }
328
329 //*****************************************************************************
330 //
331 // Enable/disable the slew control on an IO port
332 //
333 //*****************************************************************************
334 void
IOCIOSlewCtrlSet(uint32_t ui32IOId,uint32_t ui32SlewEnable)335 IOCIOSlewCtrlSet(uint32_t ui32IOId, uint32_t ui32SlewEnable)
336 {
337 uint32_t ui32IOReg;
338 uint32_t ui32Config;
339
340 // Check the arguments.
341 ASSERT(ui32IOId <= IOID_31);
342 ASSERT((ui32SlewEnable == IOC_SLEW_ENABLE) ||
343 (ui32SlewEnable == IOC_SLEW_DISABLE));
344
345 // Get the register address.
346 ui32IOReg = IOC_BASE + ( ui32IOId << 2 );
347
348 // Configure the IO.
349 ui32Config = HWREG(ui32IOReg);
350 ui32Config &= ~IOC_IOCFG0_SLEW_RED;
351 HWREG(ui32IOReg) = ui32Config | ui32SlewEnable;
352 }
353
354 //*****************************************************************************
355 //
356 // Configure the drive strength and maximum current of an IO port
357 //
358 //*****************************************************************************
359 void
IOCIODrvStrengthSet(uint32_t ui32IOId,uint32_t ui32IOCurrent,uint32_t ui32DrvStrength)360 IOCIODrvStrengthSet(uint32_t ui32IOId, uint32_t ui32IOCurrent,
361 uint32_t ui32DrvStrength)
362 {
363 uint32_t ui32IOReg;
364 uint32_t ui32Config;
365
366 // Check the arguments.
367 ASSERT(ui32IOId <= IOID_31);
368 ASSERT((ui32IOCurrent == IOC_CURRENT_2MA) ||
369 (ui32IOCurrent == IOC_CURRENT_4MA) ||
370 (ui32IOCurrent == IOC_CURRENT_8MA));
371 ASSERT((ui32DrvStrength == IOC_STRENGTH_MIN) ||
372 (ui32DrvStrength == IOC_STRENGTH_MAX) ||
373 (ui32DrvStrength == IOC_STRENGTH_MED) ||
374 (ui32DrvStrength == IOC_STRENGTH_AUTO));
375
376 // Get the register address.
377 ui32IOReg = IOC_BASE + ( ui32IOId << 2 );
378
379 // Configure the IO.
380 ui32Config = HWREG(ui32IOReg);
381 ui32Config &= ~(IOC_IOCFG0_IOCURR_M | IOC_IOCFG0_IOSTR_M);
382 HWREG(ui32IOReg) = ui32Config | (ui32IOCurrent | ui32DrvStrength);
383 }
384
385 //*****************************************************************************
386 //
387 // Setup the Port ID for this IO
388 //
389 //*****************************************************************************
390 void
IOCIOPortIdSet(uint32_t ui32IOId,uint32_t ui32PortId)391 IOCIOPortIdSet(uint32_t ui32IOId, uint32_t ui32PortId)
392 {
393 uint32_t ui32IOReg;
394 uint32_t ui32Config;
395
396 // Check the arguments.
397 ASSERT(ui32IOId <= IOID_31);
398 ASSERT(ui32PortId <= IOC_PORT_RFC_GPI1);
399
400 // Get the register address.
401 ui32IOReg = IOC_BASE + ( ui32IOId << 2 );
402
403 // Configure the IO.
404 ui32Config = HWREG(ui32IOReg);
405 ui32Config &= ~IOC_IOCFG0_PORT_ID_M;
406 HWREG(ui32IOReg) = ui32Config | ui32PortId;
407 }
408
409 //*****************************************************************************
410 //
411 // Enables individual IO edge detect interrupt
412 //
413 //*****************************************************************************
414 void
IOCIntEnable(uint32_t ui32IOId)415 IOCIntEnable(uint32_t ui32IOId)
416 {
417 uint32_t ui32IOReg;
418 uint32_t ui32Config;
419
420 // Check the arguments.
421 ASSERT(ui32IOId <= IOID_31);
422
423 // Get the register address.
424 ui32IOReg = IOC_BASE + ( ui32IOId << 2 );
425
426 // Enable the specified interrupt.
427 ui32Config = HWREG(ui32IOReg);
428 ui32Config |= IOC_IOCFG0_EDGE_IRQ_EN;
429 HWREG(ui32IOReg) = ui32Config;
430 }
431
432 //*****************************************************************************
433 //
434 // Disables individual IO edge interrupt sources
435 //
436 //*****************************************************************************
437 void
IOCIntDisable(uint32_t ui32IOId)438 IOCIntDisable(uint32_t ui32IOId)
439 {
440 uint32_t ui32IOReg;
441 uint32_t ui32Config;
442
443 // Check the arguments.
444 ASSERT(ui32IOId <= IOID_31);
445
446 // Get the register address.
447 ui32IOReg = IOC_BASE + ( ui32IOId << 2 );
448
449 // Disable the specified interrupt.
450 ui32Config = HWREG(ui32IOReg);
451 ui32Config &= ~IOC_IOCFG0_EDGE_IRQ_EN;
452 HWREG(ui32IOReg) = ui32Config;
453 }
454
455 //*****************************************************************************
456 //
457 // Setup an IO for standard GPIO input
458 //
459 //*****************************************************************************
460 void
IOCPinTypeGpioInput(uint32_t ui32IOId)461 IOCPinTypeGpioInput(uint32_t ui32IOId)
462 {
463 // Check the arguments.
464 ASSERT(ui32IOId <= IOID_31);
465
466 // Setup the IO for standard input.
467 IOCPortConfigureSet(ui32IOId, IOC_PORT_GPIO, IOC_STD_INPUT);
468
469 // Enable input mode in the GPIO module.
470 GPIO_setOutputEnableDio(ui32IOId, GPIO_OUTPUT_DISABLE);
471 }
472
473 //*****************************************************************************
474 //
475 // Setup an IO for standard GPIO output
476 //
477 //*****************************************************************************
478 void
IOCPinTypeGpioOutput(uint32_t ui32IOId)479 IOCPinTypeGpioOutput(uint32_t ui32IOId)
480 {
481 // Check the arguments.
482 ASSERT(ui32IOId <= IOID_31);
483
484 // Setup the IO for standard input.
485 IOCPortConfigureSet(ui32IOId, IOC_PORT_GPIO, IOC_STD_OUTPUT);
486
487 // Enable output mode in the GPIO module.
488 GPIO_setOutputEnableDio(ui32IOId, GPIO_OUTPUT_ENABLE);
489 }
490
491 //*****************************************************************************
492 //
493 // Configure a set of IOs for standard UART peripheral control
494 //
495 //*****************************************************************************
496 void
IOCPinTypeUart(uint32_t ui32Base,uint32_t ui32Rx,uint32_t ui32Tx,uint32_t ui32Cts,uint32_t ui32Rts)497 IOCPinTypeUart(uint32_t ui32Base, uint32_t ui32Rx, uint32_t ui32Tx,
498 uint32_t ui32Cts, uint32_t ui32Rts)
499 {
500 // Check the arguments.
501 ASSERT(ui32Base == UART0_BASE);
502 ASSERT((ui32Rx <= IOID_31) || (ui32Rx == IOID_UNUSED));
503 ASSERT((ui32Tx <= IOID_31) || (ui32Tx == IOID_UNUSED));
504 ASSERT((ui32Cts <= IOID_31) || (ui32Cts == IOID_UNUSED));
505 ASSERT((ui32Rts <= IOID_31) || (ui32Rts == IOID_UNUSED));
506
507 // Setup the IOs in the desired configuration.
508 if(ui32Rx != IOID_UNUSED)
509 {
510 IOCPortConfigureSet(ui32Rx, IOC_PORT_MCU_UART0_RX, IOC_STD_INPUT);
511 }
512 if(ui32Tx != IOID_UNUSED)
513 {
514 IOCPortConfigureSet(ui32Tx, IOC_PORT_MCU_UART0_TX, IOC_STD_OUTPUT);
515 }
516 if(ui32Cts != IOID_UNUSED)
517 {
518 IOCPortConfigureSet(ui32Cts, IOC_PORT_MCU_UART0_CTS, IOC_STD_INPUT);
519 }
520 if(ui32Rts != IOID_UNUSED)
521 {
522 IOCPortConfigureSet(ui32Rts, IOC_PORT_MCU_UART0_RTS, IOC_STD_OUTPUT);
523 }
524 }
525
526 //*****************************************************************************
527 //
528 // Configure a set of IOs for standard SSI peripheral master control
529 //
530 //*****************************************************************************
531 void
IOCPinTypeSsiMaster(uint32_t ui32Base,uint32_t ui32Rx,uint32_t ui32Tx,uint32_t ui32Fss,uint32_t ui32Clk)532 IOCPinTypeSsiMaster(uint32_t ui32Base, uint32_t ui32Rx,
533 uint32_t ui32Tx, uint32_t ui32Fss,
534 uint32_t ui32Clk)
535 {
536 // Check the arguments.
537
538 ASSERT((ui32Base == SSI0_BASE) || (ui32Base == SSI1_BASE));
539 ASSERT((ui32Rx <= IOID_31) || (ui32Rx == IOID_UNUSED));
540 ASSERT((ui32Tx <= IOID_31) || (ui32Tx == IOID_UNUSED));
541 ASSERT((ui32Fss <= IOID_31) || (ui32Fss == IOID_UNUSED));
542 ASSERT((ui32Clk <= IOID_31) || (ui32Clk == IOID_UNUSED));
543
544 // Setup the IOs in the desired configuration.
545 if(ui32Base == SSI0_BASE)
546 {
547 if(ui32Rx != IOID_UNUSED)
548 {
549 IOCPortConfigureSet(ui32Rx, IOC_PORT_MCU_SSI0_RX, IOC_STD_INPUT);
550 }
551 if(ui32Tx != IOID_UNUSED)
552 {
553 IOCPortConfigureSet(ui32Tx, IOC_PORT_MCU_SSI0_TX, IOC_STD_OUTPUT);
554 }
555 if(ui32Fss != IOID_UNUSED)
556 {
557 IOCPortConfigureSet(ui32Fss, IOC_PORT_MCU_SSI0_FSS, IOC_STD_OUTPUT);
558 }
559 if(ui32Clk != IOID_UNUSED)
560 {
561 IOCPortConfigureSet(ui32Clk, IOC_PORT_MCU_SSI0_CLK, IOC_STD_OUTPUT);
562 }
563 }
564 else
565 {
566 if(ui32Rx != IOID_UNUSED)
567 {
568 IOCPortConfigureSet(ui32Rx, IOC_PORT_MCU_SSI1_RX, IOC_STD_INPUT);
569 }
570 if(ui32Tx != IOID_UNUSED)
571 {
572 IOCPortConfigureSet(ui32Tx, IOC_PORT_MCU_SSI1_TX, IOC_STD_OUTPUT);
573 }
574 if(ui32Fss != IOID_UNUSED)
575 {
576 IOCPortConfigureSet(ui32Fss, IOC_PORT_MCU_SSI1_FSS, IOC_STD_OUTPUT);
577 }
578 if(ui32Clk != IOID_UNUSED)
579 {
580 IOCPortConfigureSet(ui32Clk, IOC_PORT_MCU_SSI1_CLK, IOC_STD_OUTPUT);
581 }
582 }
583 }
584
585 //*****************************************************************************
586 //
587 // Configure a set of IOs for standard SSI peripheral slave control
588 //
589 //*****************************************************************************
590 void
IOCPinTypeSsiSlave(uint32_t ui32Base,uint32_t ui32Rx,uint32_t ui32Tx,uint32_t ui32Fss,uint32_t ui32Clk)591 IOCPinTypeSsiSlave(uint32_t ui32Base, uint32_t ui32Rx,
592 uint32_t ui32Tx, uint32_t ui32Fss,
593 uint32_t ui32Clk)
594 {
595 // Check the arguments.
596 ASSERT((ui32Base == SSI0_BASE) || (ui32Base == SSI1_BASE));
597 ASSERT((ui32Rx <= IOID_31) || (ui32Rx == IOID_UNUSED));
598 ASSERT((ui32Tx <= IOID_31) || (ui32Tx == IOID_UNUSED));
599 ASSERT((ui32Fss <= IOID_31) || (ui32Fss == IOID_UNUSED));
600 ASSERT((ui32Clk <= IOID_31) || (ui32Clk == IOID_UNUSED));
601
602 // Setup the IOs in the desired configuration.
603 if(ui32Base == SSI0_BASE)
604 {
605 if(ui32Rx != IOID_UNUSED)
606 {
607 IOCPortConfigureSet(ui32Rx, IOC_PORT_MCU_SSI0_RX, IOC_STD_INPUT);
608 }
609 if(ui32Tx != IOID_UNUSED)
610 {
611 IOCPortConfigureSet(ui32Tx, IOC_PORT_MCU_SSI0_TX, IOC_STD_OUTPUT);
612 }
613 if(ui32Fss != IOID_UNUSED)
614 {
615 IOCPortConfigureSet(ui32Fss, IOC_PORT_MCU_SSI0_FSS, IOC_STD_INPUT);
616 }
617 if(ui32Clk != IOID_UNUSED)
618 {
619 IOCPortConfigureSet(ui32Clk, IOC_PORT_MCU_SSI0_CLK, IOC_STD_INPUT);
620 }
621 }
622 else
623 {
624 if(ui32Rx != IOID_UNUSED)
625 {
626 IOCPortConfigureSet(ui32Rx, IOC_PORT_MCU_SSI1_RX, IOC_STD_INPUT);
627 }
628 if(ui32Tx != IOID_UNUSED)
629 {
630 IOCPortConfigureSet(ui32Tx, IOC_PORT_MCU_SSI1_TX, IOC_STD_OUTPUT);
631 }
632 if(ui32Fss != IOID_UNUSED)
633 {
634 IOCPortConfigureSet(ui32Fss, IOC_PORT_MCU_SSI1_FSS, IOC_STD_INPUT);
635 }
636 if(ui32Clk != IOID_UNUSED)
637 {
638 IOCPortConfigureSet(ui32Clk, IOC_PORT_MCU_SSI1_CLK, IOC_STD_INPUT);
639 }
640 }
641 }
642
643 //*****************************************************************************
644 //
645 // Configure a set of IOs for standard I2C peripheral control
646 //
647 //*****************************************************************************
648 void
IOCPinTypeI2c(uint32_t ui32Base,uint32_t ui32Data,uint32_t ui32Clk)649 IOCPinTypeI2c(uint32_t ui32Base, uint32_t ui32Data, uint32_t ui32Clk)
650 {
651 uint32_t ui32IOConfig;
652
653 // Check the arguments.
654 ASSERT((ui32Data <= IOID_31) || (ui32Data == IOID_UNUSED));
655 ASSERT((ui32Clk <= IOID_31) || (ui32Clk == IOID_UNUSED));
656
657 // Define the IO configuration parameters.
658 ui32IOConfig = IOC_CURRENT_2MA | IOC_STRENGTH_AUTO | IOC_IOPULL_UP |
659 IOC_SLEW_DISABLE | IOC_HYST_DISABLE | IOC_NO_EDGE |
660 IOC_INT_DISABLE | IOC_IOMODE_OPEN_DRAIN_NORMAL |
661 IOC_NO_WAKE_UP | IOC_INPUT_ENABLE;
662
663 // Setup the IOs in the desired configuration.
664 IOCPortConfigureSet(ui32Data, IOC_PORT_MCU_I2C_MSSDA, ui32IOConfig);
665 IOCPortConfigureSet(ui32Clk, IOC_PORT_MCU_I2C_MSSCL, ui32IOConfig);
666 }
667
668 //*****************************************************************************
669 //
670 // Configure an IO for AUX control
671 //
672 //*****************************************************************************
673 void
IOCPinTypeAux(uint32_t ui32IOId)674 IOCPinTypeAux(uint32_t ui32IOId)
675 {
676 // Check the arguments.
677 ASSERT((ui32IOId <= IOID_31) || (ui32IOId == IOID_UNUSED));
678
679 // Setup the IO.
680 IOCPortConfigureSet(ui32IOId, IOC_PORT_AUX_IO, IOC_STD_INPUT);
681 }
682