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