1 /******************************************************************************
2 *  Filename:       ioc.c
3 *  Revised:        2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020)
4 *  Revision:       56760
5 *
6 *  Description:    Driver for the IOC.
7 *
8 *  Copyright (c) 2015 - 2017, 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 "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  IOCIOEvtSet
59     #define IOCIOEvtSet                     NOROM_IOCIOEvtSet
60     #undef  IOCIOPortPullSet
61     #define IOCIOPortPullSet                NOROM_IOCIOPortPullSet
62     #undef  IOCIOHystSet
63     #define IOCIOHystSet                    NOROM_IOCIOHystSet
64     #undef  IOCIOInputSet
65     #define IOCIOInputSet                   NOROM_IOCIOInputSet
66     #undef  IOCIOSlewCtrlSet
67     #define IOCIOSlewCtrlSet                NOROM_IOCIOSlewCtrlSet
68     #undef  IOCIODrvStrengthSet
69     #define IOCIODrvStrengthSet             NOROM_IOCIODrvStrengthSet
70     #undef  IOCIOPortIdSet
71     #define IOCIOPortIdSet                  NOROM_IOCIOPortIdSet
72     #undef  IOCIntEnable
73     #define IOCIntEnable                    NOROM_IOCIntEnable
74     #undef  IOCIntDisable
75     #define IOCIntDisable                   NOROM_IOCIntDisable
76     #undef  IOCPinTypeGpioInput
77     #define IOCPinTypeGpioInput             NOROM_IOCPinTypeGpioInput
78     #undef  IOCPinTypeGpioOutput
79     #define IOCPinTypeGpioOutput            NOROM_IOCPinTypeGpioOutput
80     #undef  IOCPinTypeUart
81     #define IOCPinTypeUart                  NOROM_IOCPinTypeUart
82     #undef  IOCPinTypeSsiMaster
83     #define IOCPinTypeSsiMaster             NOROM_IOCPinTypeSsiMaster
84     #undef  IOCPinTypeSsiSlave
85     #define IOCPinTypeSsiSlave              NOROM_IOCPinTypeSsiSlave
86     #undef  IOCPinTypeI2c
87     #define IOCPinTypeI2c                   NOROM_IOCPinTypeI2c
88     #undef  IOCPinTypeAux
89     #define IOCPinTypeAux                   NOROM_IOCPinTypeAux
90 #endif
91 
92 //*****************************************************************************
93 //
94 // Set the configuration of an IO port
95 //
96 //*****************************************************************************
97 void
IOCPortConfigureSet(uint32_t ui32IOId,uint32_t ui32PortId,uint32_t ui32IOConfig)98 IOCPortConfigureSet(uint32_t ui32IOId, uint32_t ui32PortId,
99                     uint32_t ui32IOConfig)
100 {
101     uint32_t ui32Reg;
102 
103     // Check the arguments.
104     ASSERT(ui32IOId <= IOID_31);
105     ASSERT(ui32PortId <= IOC_PORT_RFC_GPI1);
106 
107     // Get the register address.
108     ui32Reg = IOC_BASE + ( ui32IOId << 2 );
109 
110     // Configure the port.
111     HWREG(ui32Reg) = ui32IOConfig | ui32PortId;
112 }
113 
114 //*****************************************************************************
115 //
116 // Get the configuration of an IO port
117 //
118 //*****************************************************************************
119 uint32_t
IOCPortConfigureGet(uint32_t ui32IOId)120 IOCPortConfigureGet(uint32_t ui32IOId)
121 {
122     uint32_t ui32Reg;
123 
124     // Check the arguments.
125     ASSERT(ui32IOId <= IOID_31);
126 
127     // Get the register address.
128     ui32Reg = IOC_BASE + ( ui32IOId << 2 );
129 
130     // Return the IO configuration.
131     return HWREG(ui32Reg);
132 }
133 
134 //*****************************************************************************
135 //
136 // Set wake-up on an IO port
137 //
138 //*****************************************************************************
139 void
IOCIOShutdownSet(uint32_t ui32IOId,uint32_t ui32IOShutdown)140 IOCIOShutdownSet(uint32_t ui32IOId, uint32_t ui32IOShutdown)
141 {
142     uint32_t ui32Reg;
143     uint32_t ui32Config;
144 
145     // Check the arguments.
146     ASSERT(ui32IOId <= IOID_31);
147     ASSERT((ui32IOShutdown == IOC_NO_WAKE_UP) ||
148            (ui32IOShutdown == IOC_WAKE_ON_LOW) ||
149            (ui32IOShutdown == IOC_WAKE_ON_HIGH));
150 
151     // Get the register address.
152     ui32Reg = IOC_BASE + ( ui32IOId << 2 );
153 
154     // Configure the IO.
155     ui32Config = HWREG(ui32Reg);
156     ui32Config &= ~IOC_IOCFG0_WU_CFG_M;
157     HWREG(ui32Reg) = ui32Config | ui32IOShutdown;
158 }
159 
160 
161 //*****************************************************************************
162 //
163 // Set the IO Mode of an IO Port
164 //
165 //*****************************************************************************
166 void
IOCIOModeSet(uint32_t ui32IOId,uint32_t ui32IOMode)167 IOCIOModeSet(uint32_t ui32IOId, uint32_t ui32IOMode)
168 {
169     uint32_t ui32Reg;
170     uint32_t ui32Config;
171 
172     // Check the arguments.
173     ASSERT(ui32IOId <= IOID_31);
174     ASSERT((ui32IOMode == IOC_IOMODE_NORMAL) ||
175            (ui32IOMode == IOC_IOMODE_INV) ||
176            (ui32IOMode == IOC_IOMODE_OPEN_DRAIN_NORMAL) ||
177            (ui32IOMode == IOC_IOMODE_OPEN_DRAIN_INV) ||
178            (ui32IOMode == IOC_IOMODE_OPEN_SRC_NORMAL) ||
179            (ui32IOMode == IOC_IOMODE_OPEN_SRC_INV));
180 
181     // Get the register address.
182     ui32Reg = IOC_BASE + ( ui32IOId << 2 );
183 
184     // Configure the IO.
185     ui32Config = HWREG(ui32Reg);
186     ui32Config &= ~IOC_IOCFG0_IOMODE_M;
187     HWREG(ui32Reg) = ui32Config | ui32IOMode;
188 }
189 
190 //*****************************************************************************
191 //
192 // Setup interrupt detection on an IO Port
193 //
194 //*****************************************************************************
195 void
IOCIOIntSet(uint32_t ui32IOId,uint32_t ui32Int,uint32_t ui32EdgeDet)196 IOCIOIntSet(uint32_t ui32IOId, uint32_t ui32Int, uint32_t ui32EdgeDet)
197 {
198     uint32_t ui32IOReg;
199     uint32_t ui32Config;
200 
201     // Check the arguments.
202     ASSERT(ui32IOId <= IOID_31);
203     ASSERT((ui32Int == IOC_INT_ENABLE) ||
204            (ui32Int == IOC_INT_DISABLE));
205     ASSERT((ui32EdgeDet == IOC_NO_EDGE) ||
206            (ui32EdgeDet == IOC_FALLING_EDGE) ||
207            (ui32EdgeDet == IOC_RISING_EDGE) ||
208            (ui32EdgeDet == IOC_BOTH_EDGES));
209 
210     // Get the register address.
211     ui32IOReg = IOC_BASE + ( ui32IOId << 2 );
212 
213     // Configure the IO.
214     ui32Config = HWREG(ui32IOReg);
215     ui32Config &=  ~(IOC_IOCFG0_EDGE_IRQ_EN | IOC_IOCFG0_EDGE_DET_M);
216     HWREG(ui32IOReg) = ui32Config | ((ui32Int ? IOC_IOCFG0_EDGE_IRQ_EN : 0) | ui32EdgeDet);
217 }
218 
219 //*****************************************************************************
220 //
221 // Setup event generation on IO edge detection
222 //
223 //*****************************************************************************
224 void
IOCIOEvtSet(uint32_t ui32IOId,uint32_t ui32Evt)225 IOCIOEvtSet(uint32_t ui32IOId, uint32_t ui32Evt)
226 {
227     uint32_t ui32IOReg;
228     uint32_t ui32Config;
229 
230     // Check the arguments.
231     ASSERT(ui32IOId <= IOID_31);
232     ASSERT( (ui32Evt & ~(IOC_IOCFG0_IOEV_AON_PROG2_EN_M |
233                          IOC_IOCFG0_IOEV_AON_PROG1_EN_M |
234                          IOC_IOCFG0_IOEV_AON_PROG0_EN_M |
235                          IOC_IOCFG0_IOEV_RTC_EN_M |
236                          IOC_IOCFG0_IOEV_MCU_WU_EN_M) ) == 0x00000000);
237 
238     // Get the register address.
239     ui32IOReg = IOC_BASE + ( ui32IOId << 2 );
240 
241     // Read current configuration.
242     ui32Config = HWREG(ui32IOReg);
243 
244     // Disable generation of all events.
245     ui32Config &=  ~(IOC_IOCFG0_IOEV_AON_PROG2_EN_M |
246                      IOC_IOCFG0_IOEV_AON_PROG1_EN_M |
247                      IOC_IOCFG0_IOEV_AON_PROG0_EN_M |
248                      IOC_IOCFG0_IOEV_RTC_EN_M |
249                      IOC_IOCFG0_IOEV_MCU_WU_EN_M);
250 
251     // Enable the required events.
252     HWREG(ui32IOReg) = ui32Config | ui32Evt;
253 }
254 
255 //*****************************************************************************
256 //
257 // Set the pull on an IO port
258 //
259 //*****************************************************************************
260 void
IOCIOPortPullSet(uint32_t ui32IOId,uint32_t ui32Pull)261 IOCIOPortPullSet(uint32_t ui32IOId, uint32_t ui32Pull)
262 {
263     uint32_t ui32IOReg;
264     uint32_t ui32Config;
265 
266     // Check the argument.
267     ASSERT(ui32IOId <= IOID_31);
268     ASSERT((ui32Pull == IOC_NO_IOPULL) ||
269            (ui32Pull == IOC_IOPULL_UP) ||
270            (ui32Pull == IOC_IOPULL_DOWN));
271 
272     // Get the register address.
273     ui32IOReg = IOC_BASE + ( ui32IOId << 2 );
274 
275     // Configure the IO.
276     ui32Config = HWREG(ui32IOReg);
277     ui32Config &= ~IOC_IOCFG0_PULL_CTL_M;
278     HWREG(ui32IOReg) = ui32Config | ui32Pull;
279 }
280 
281 //*****************************************************************************
282 //
283 // Configure hysteresis on and IO port
284 //
285 //*****************************************************************************
286 void
IOCIOHystSet(uint32_t ui32IOId,uint32_t ui32Hysteresis)287 IOCIOHystSet(uint32_t ui32IOId, uint32_t ui32Hysteresis)
288 {
289     uint32_t ui32IOReg;
290     uint32_t ui32Config;
291 
292     // Check the arguments.
293     ASSERT(ui32IOId <= IOID_31);
294     ASSERT((ui32Hysteresis == IOC_HYST_ENABLE) ||
295            (ui32Hysteresis == IOC_HYST_DISABLE));
296 
297     // Get the register address.
298     ui32IOReg = IOC_BASE + ( ui32IOId << 2 );
299 
300     // Configure the IO.
301     ui32Config = HWREG(ui32IOReg);
302     ui32Config &= ~IOC_IOCFG0_HYST_EN;
303     HWREG(ui32IOReg) = ui32Config | ui32Hysteresis;
304 }
305 
306 //*****************************************************************************
307 //
308 // Enable/disable IO port as input
309 //
310 //*****************************************************************************
311 void
IOCIOInputSet(uint32_t ui32IOId,uint32_t ui32Input)312 IOCIOInputSet(uint32_t ui32IOId, uint32_t ui32Input)
313 {
314     uint32_t ui32IOReg;
315     uint32_t ui32Config;
316 
317     // Check the arguments.
318     ASSERT(ui32IOId <= IOID_31);
319     ASSERT((ui32Input == IOC_INPUT_ENABLE) ||
320            (ui32Input == IOC_INPUT_DISABLE));
321 
322     // Get the register address.
323     ui32IOReg = IOC_BASE + ( ui32IOId << 2 );
324 
325     // Configure the IO.
326     ui32Config = HWREG(ui32IOReg);
327     ui32Config &= ~IOC_IOCFG0_IE;
328     HWREG(ui32IOReg) = ui32Config | ui32Input;
329 }
330 
331 //*****************************************************************************
332 //
333 // Enable/disable the slew control on an IO port
334 //
335 //*****************************************************************************
336 void
IOCIOSlewCtrlSet(uint32_t ui32IOId,uint32_t ui32SlewEnable)337 IOCIOSlewCtrlSet(uint32_t ui32IOId, uint32_t ui32SlewEnable)
338 {
339     uint32_t ui32IOReg;
340     uint32_t ui32Config;
341 
342     // Check the arguments.
343     ASSERT(ui32IOId <= IOID_31);
344     ASSERT((ui32SlewEnable == IOC_SLEW_ENABLE) ||
345            (ui32SlewEnable == IOC_SLEW_DISABLE));
346 
347     // Get the register address.
348     ui32IOReg = IOC_BASE + ( ui32IOId << 2 );
349 
350     // Configure the IO.
351     ui32Config = HWREG(ui32IOReg);
352     ui32Config &= ~IOC_IOCFG0_SLEW_RED;
353     HWREG(ui32IOReg) = ui32Config | ui32SlewEnable;
354 }
355 
356 //*****************************************************************************
357 //
358 // Configure the drive strength and maximum current of an IO port
359 //
360 //*****************************************************************************
361 void
IOCIODrvStrengthSet(uint32_t ui32IOId,uint32_t ui32IOCurrent,uint32_t ui32DrvStrength)362 IOCIODrvStrengthSet(uint32_t ui32IOId, uint32_t ui32IOCurrent,
363                     uint32_t ui32DrvStrength)
364 {
365     uint32_t ui32IOReg;
366     uint32_t ui32Config;
367 
368     // Check the arguments.
369     ASSERT(ui32IOId <= IOID_31);
370     ASSERT((ui32IOCurrent == IOC_CURRENT_2MA) ||
371            (ui32IOCurrent == IOC_CURRENT_4MA) ||
372            (ui32IOCurrent == IOC_CURRENT_8MA));
373     ASSERT((ui32DrvStrength == IOC_STRENGTH_MIN) ||
374            (ui32DrvStrength == IOC_STRENGTH_MAX) ||
375            (ui32DrvStrength == IOC_STRENGTH_MED) ||
376            (ui32DrvStrength == IOC_STRENGTH_AUTO));
377 
378     // Get the register address.
379     ui32IOReg = IOC_BASE + ( ui32IOId << 2 );
380 
381     // Configure the IO.
382     ui32Config = HWREG(ui32IOReg);
383     ui32Config &= ~(IOC_IOCFG0_IOCURR_M | IOC_IOCFG0_IOSTR_M);
384     HWREG(ui32IOReg) = ui32Config | (ui32IOCurrent | ui32DrvStrength);
385 }
386 
387 //*****************************************************************************
388 //
389 // Setup the Port ID for this IO
390 //
391 //*****************************************************************************
392 void
IOCIOPortIdSet(uint32_t ui32IOId,uint32_t ui32PortId)393 IOCIOPortIdSet(uint32_t ui32IOId, uint32_t ui32PortId)
394 {
395     uint32_t ui32IOReg;
396     uint32_t ui32Config;
397 
398     // Check the arguments.
399     ASSERT(ui32IOId <= IOID_31);
400     ASSERT(ui32PortId <= IOC_PORT_RFC_GPI1);
401 
402     // Get the register address.
403     ui32IOReg = IOC_BASE + ( ui32IOId << 2 );
404 
405     // Configure the IO.
406     ui32Config = HWREG(ui32IOReg);
407     ui32Config &= ~IOC_IOCFG0_PORT_ID_M;
408     HWREG(ui32IOReg) = ui32Config | ui32PortId;
409 }
410 
411 //*****************************************************************************
412 //
413 // Enables individual IO edge detect interrupt
414 //
415 //*****************************************************************************
416 void
IOCIntEnable(uint32_t ui32IOId)417 IOCIntEnable(uint32_t ui32IOId)
418 {
419     uint32_t ui32IOReg;
420     uint32_t ui32Config;
421 
422     // Check the arguments.
423     ASSERT(ui32IOId <= IOID_31);
424 
425     // Get the register address.
426     ui32IOReg = IOC_BASE + ( ui32IOId << 2 );
427 
428     // Enable the specified interrupt.
429     ui32Config = HWREG(ui32IOReg);
430     ui32Config |= IOC_IOCFG0_EDGE_IRQ_EN;
431     HWREG(ui32IOReg) = ui32Config;
432 }
433 
434 //*****************************************************************************
435 //
436 // Disables individual IO edge interrupt sources
437 //
438 //*****************************************************************************
439 void
IOCIntDisable(uint32_t ui32IOId)440 IOCIntDisable(uint32_t ui32IOId)
441 {
442     uint32_t ui32IOReg;
443     uint32_t ui32Config;
444 
445     // Check the arguments.
446     ASSERT(ui32IOId <= IOID_31);
447 
448     // Get the register address.
449     ui32IOReg = IOC_BASE + ( ui32IOId << 2 );
450 
451     // Disable the specified interrupt.
452     ui32Config = HWREG(ui32IOReg);
453     ui32Config &= ~IOC_IOCFG0_EDGE_IRQ_EN;
454     HWREG(ui32IOReg) = ui32Config;
455 }
456 
457 //*****************************************************************************
458 //
459 // Setup an IO for standard GPIO input
460 //
461 //*****************************************************************************
462 void
IOCPinTypeGpioInput(uint32_t ui32IOId)463 IOCPinTypeGpioInput(uint32_t ui32IOId)
464 {
465     // Check the arguments.
466     ASSERT(ui32IOId <= IOID_31);
467 
468     // Setup the IO for standard input.
469     IOCPortConfigureSet(ui32IOId, IOC_PORT_GPIO, IOC_STD_INPUT);
470 
471     // Enable input mode in the GPIO module.
472     GPIO_setOutputEnableDio(ui32IOId, GPIO_OUTPUT_DISABLE);
473 }
474 
475 //*****************************************************************************
476 //
477 // Setup an IO for standard GPIO output
478 //
479 //*****************************************************************************
480 void
IOCPinTypeGpioOutput(uint32_t ui32IOId)481 IOCPinTypeGpioOutput(uint32_t ui32IOId)
482 {
483     // Check the arguments.
484     ASSERT(ui32IOId <= IOID_31);
485 
486     // Setup the IO for standard input.
487     IOCPortConfigureSet(ui32IOId, IOC_PORT_GPIO, IOC_STD_OUTPUT);
488 
489     // Enable output mode in the GPIO module.
490     GPIO_setOutputEnableDio(ui32IOId, GPIO_OUTPUT_ENABLE);
491 }
492 
493 //*****************************************************************************
494 //
495 // Configure a set of IOs for standard UART peripheral control
496 //
497 //*****************************************************************************
498 void
IOCPinTypeUart(uint32_t ui32Base,uint32_t ui32Rx,uint32_t ui32Tx,uint32_t ui32Cts,uint32_t ui32Rts)499 IOCPinTypeUart(uint32_t ui32Base, uint32_t ui32Rx, uint32_t ui32Tx,
500                uint32_t ui32Cts, uint32_t ui32Rts)
501 {
502     // Check the arguments.
503     ASSERT(ui32Base == UART0_BASE);
504     ASSERT((ui32Rx <= IOID_31) || (ui32Rx == IOID_UNUSED));
505     ASSERT((ui32Tx <= IOID_31) || (ui32Tx == IOID_UNUSED));
506     ASSERT((ui32Cts <= IOID_31) || (ui32Cts == IOID_UNUSED));
507     ASSERT((ui32Rts <= IOID_31) || (ui32Rts == IOID_UNUSED));
508 
509     // Setup the IOs in the desired configuration.
510     if(ui32Rx != IOID_UNUSED)
511     {
512         IOCPortConfigureSet(ui32Rx, IOC_PORT_MCU_UART0_RX, IOC_STD_INPUT);
513     }
514     if(ui32Tx != IOID_UNUSED)
515     {
516         IOCPortConfigureSet(ui32Tx, IOC_PORT_MCU_UART0_TX, IOC_STD_OUTPUT);
517     }
518     if(ui32Cts != IOID_UNUSED)
519     {
520         IOCPortConfigureSet(ui32Cts, IOC_PORT_MCU_UART0_CTS, IOC_STD_INPUT);
521     }
522     if(ui32Rts != IOID_UNUSED)
523     {
524         IOCPortConfigureSet(ui32Rts, IOC_PORT_MCU_UART0_RTS, IOC_STD_OUTPUT);
525     }
526 }
527 
528 //*****************************************************************************
529 //
530 // Configure a set of IOs for standard SSI peripheral master control
531 //
532 //*****************************************************************************
533 void
IOCPinTypeSsiMaster(uint32_t ui32Base,uint32_t ui32Rx,uint32_t ui32Tx,uint32_t ui32Fss,uint32_t ui32Clk)534 IOCPinTypeSsiMaster(uint32_t ui32Base, uint32_t ui32Rx,
535                     uint32_t ui32Tx, uint32_t ui32Fss,
536                     uint32_t ui32Clk)
537 {
538     // Check the arguments.
539     ASSERT((ui32Base == SSI0_BASE) || (ui32Base == SSI1_BASE));
540     ASSERT((ui32Rx <= IOID_31) || (ui32Rx == IOID_UNUSED));
541     ASSERT((ui32Tx <= IOID_31) || (ui32Tx == IOID_UNUSED));
542     ASSERT((ui32Fss <= IOID_31) || (ui32Fss == IOID_UNUSED));
543     ASSERT((ui32Clk <= IOID_31) || (ui32Clk == IOID_UNUSED));
544 
545     // Setup the IOs in the desired configuration.
546     if(ui32Base == SSI0_BASE)
547     {
548         if(ui32Rx != IOID_UNUSED)
549         {
550             IOCPortConfigureSet(ui32Rx, IOC_PORT_MCU_SSI0_RX, IOC_STD_INPUT);
551         }
552         if(ui32Tx != IOID_UNUSED)
553         {
554             IOCPortConfigureSet(ui32Tx, IOC_PORT_MCU_SSI0_TX, IOC_STD_OUTPUT);
555         }
556         if(ui32Fss != IOID_UNUSED)
557         {
558             IOCPortConfigureSet(ui32Fss, IOC_PORT_MCU_SSI0_FSS, IOC_STD_OUTPUT);
559         }
560         if(ui32Clk != IOID_UNUSED)
561         {
562             IOCPortConfigureSet(ui32Clk, IOC_PORT_MCU_SSI0_CLK, IOC_STD_OUTPUT);
563         }
564     }
565     else
566     {
567         if(ui32Rx != IOID_UNUSED)
568         {
569             IOCPortConfigureSet(ui32Rx, IOC_PORT_MCU_SSI1_RX, IOC_STD_INPUT);
570         }
571         if(ui32Tx != IOID_UNUSED)
572         {
573             IOCPortConfigureSet(ui32Tx, IOC_PORT_MCU_SSI1_TX, IOC_STD_OUTPUT);
574         }
575         if(ui32Fss != IOID_UNUSED)
576         {
577             IOCPortConfigureSet(ui32Fss, IOC_PORT_MCU_SSI1_FSS, IOC_STD_OUTPUT);
578         }
579         if(ui32Clk != IOID_UNUSED)
580         {
581             IOCPortConfigureSet(ui32Clk, IOC_PORT_MCU_SSI1_CLK, IOC_STD_OUTPUT);
582         }
583     }
584 }
585 
586 //*****************************************************************************
587 //
588 // Configure a set of IOs for standard SSI peripheral slave control
589 //
590 //*****************************************************************************
591 void
IOCPinTypeSsiSlave(uint32_t ui32Base,uint32_t ui32Rx,uint32_t ui32Tx,uint32_t ui32Fss,uint32_t ui32Clk)592 IOCPinTypeSsiSlave(uint32_t ui32Base, uint32_t ui32Rx,
593                    uint32_t ui32Tx, uint32_t ui32Fss,
594                    uint32_t ui32Clk)
595 {
596     // Check the arguments.
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     // Setup the IOs in the desired configuration.
604     if(ui32Base == SSI0_BASE)
605     {
606         if(ui32Rx != IOID_UNUSED)
607         {
608             IOCPortConfigureSet(ui32Rx, IOC_PORT_MCU_SSI0_RX,  IOC_STD_INPUT);
609         }
610         if(ui32Tx != IOID_UNUSED)
611         {
612             IOCPortConfigureSet(ui32Tx, IOC_PORT_MCU_SSI0_TX, IOC_STD_OUTPUT);
613         }
614         if(ui32Fss != IOID_UNUSED)
615         {
616             IOCPortConfigureSet(ui32Fss, IOC_PORT_MCU_SSI0_FSS, IOC_STD_INPUT);
617         }
618         if(ui32Clk != IOID_UNUSED)
619         {
620             IOCPortConfigureSet(ui32Clk, IOC_PORT_MCU_SSI0_CLK, IOC_STD_INPUT);
621         }
622     }
623     else
624     {
625         if(ui32Rx != IOID_UNUSED)
626         {
627             IOCPortConfigureSet(ui32Rx, IOC_PORT_MCU_SSI1_RX, IOC_STD_INPUT);
628         }
629         if(ui32Tx != IOID_UNUSED)
630         {
631             IOCPortConfigureSet(ui32Tx, IOC_PORT_MCU_SSI1_TX, IOC_STD_OUTPUT);
632         }
633         if(ui32Fss != IOID_UNUSED)
634         {
635             IOCPortConfigureSet(ui32Fss, IOC_PORT_MCU_SSI1_FSS, IOC_STD_INPUT);
636         }
637         if(ui32Clk != IOID_UNUSED)
638         {
639             IOCPortConfigureSet(ui32Clk, IOC_PORT_MCU_SSI1_CLK, IOC_STD_INPUT);
640         }
641     }
642 }
643 
644 //*****************************************************************************
645 //
646 // Configure a set of IOs for standard I2C peripheral control
647 //
648 //*****************************************************************************
649 void
IOCPinTypeI2c(uint32_t ui32Base,uint32_t ui32Data,uint32_t ui32Clk)650 IOCPinTypeI2c(uint32_t ui32Base, uint32_t ui32Data, uint32_t ui32Clk)
651 {
652     uint32_t ui32IOConfig;
653 
654     // Check the arguments.
655     ASSERT((ui32Data <= IOID_31) || (ui32Data == IOID_UNUSED));
656     ASSERT((ui32Clk <= IOID_31) || (ui32Clk == IOID_UNUSED));
657 
658     // Define the IO configuration parameters.
659     ui32IOConfig = IOC_CURRENT_2MA | IOC_STRENGTH_AUTO | IOC_IOPULL_UP |
660                    IOC_SLEW_DISABLE | IOC_HYST_DISABLE | IOC_NO_EDGE |
661                    IOC_INT_DISABLE | IOC_IOMODE_OPEN_DRAIN_NORMAL |
662                    IOC_NO_WAKE_UP | IOC_INPUT_ENABLE;
663 
664     // Setup the IOs in the desired configuration.
665     IOCPortConfigureSet(ui32Data, IOC_PORT_MCU_I2C_MSSDA, ui32IOConfig);
666     IOCPortConfigureSet(ui32Clk, IOC_PORT_MCU_I2C_MSSCL, ui32IOConfig);
667 }
668 
669 
670 //*****************************************************************************
671 //
672 // Configure an IO for AUX control
673 //
674 //*****************************************************************************
675 void
IOCPinTypeAux(uint32_t ui32IOId)676 IOCPinTypeAux(uint32_t ui32IOId)
677 {
678     // Check the arguments.
679     ASSERT((ui32IOId <= IOID_31) || (ui32IOId == IOID_UNUSED));
680 
681     // Setup the IO.
682     IOCPortConfigureSet(ui32IOId, IOC_PORT_AUX_IO, IOC_STD_INPUT);
683 }
684