1 /******************************************************************************
2 *  Filename:       ssi.h
3 *  Revised:        2015-09-21 15:19:36 +0200 (Mon, 21 Sep 2015)
4 *  Revision:       44629
5 *
6 *  Description:    Defines and macros for the SSI.
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 //*****************************************************************************
40 //
41 //! \addtogroup peripheral_group
42 //! @{
43 //! \addtogroup ssi_api
44 //! @{
45 //
46 //*****************************************************************************
47 
48 #ifndef __SSI_H__
49 #define __SSI_H__
50 
51 //*****************************************************************************
52 //
53 // If building with a C++ compiler, make all of the definitions in this header
54 // have a C binding.
55 //
56 //*****************************************************************************
57 #ifdef __cplusplus
58 extern "C"
59 {
60 #endif
61 
62 #include <stdbool.h>
63 #include <stdint.h>
64 #include <inc/hw_ints.h>
65 #include <inc/hw_memmap.h>
66 #include <inc/hw_types.h>
67 #include <inc/hw_ssi.h>
68 #include <driverlib/debug.h>
69 #include <driverlib/interrupt.h>
70 
71 //*****************************************************************************
72 //
73 // Support for DriverLib in ROM:
74 // This section renames all functions that are not "static inline", so that
75 // calling these functions will default to implementation in flash. At the end
76 // of this file a second renaming will change the defaults to implementation in
77 // ROM for available functions.
78 //
79 // To force use of the implementation in flash, e.g. for debugging:
80 // - Globally: Define DRIVERLIB_NOROM at project level
81 // - Per function: Use prefix "NOROM_" when calling the function
82 //
83 //*****************************************************************************
84 #if !defined(DOXYGEN)
85     #define SSIConfigSetExpClk              NOROM_SSIConfigSetExpClk
86     #define SSIDataPut                      NOROM_SSIDataPut
87     #define SSIDataPutNonBlocking           NOROM_SSIDataPutNonBlocking
88     #define SSIDataGet                      NOROM_SSIDataGet
89     #define SSIDataGetNonBlocking           NOROM_SSIDataGetNonBlocking
90     #define SSIIntRegister                  NOROM_SSIIntRegister
91     #define SSIIntUnregister                NOROM_SSIIntUnregister
92 #endif
93 
94 //*****************************************************************************
95 //
96 // Values that can be passed to SSIIntEnable, SSIIntDisable, and SSIIntClear
97 // as the ui32IntFlags parameter, and returned by SSIIntStatus.
98 //
99 //*****************************************************************************
100 #define SSI_TXFF                0x00000008  // TX FIFO half full or less
101 #define SSI_RXFF                0x00000004  // RX FIFO half full or more
102 #define SSI_RXTO                0x00000002  // RX timeout
103 #define SSI_RXOR                0x00000001  // RX overrun
104 
105 //*****************************************************************************
106 //
107 // Values that are returned from SSIStatus
108 //
109 //*****************************************************************************
110 #define SSI_RX_FULL             0x00000008  // Receive FIFO full
111 #define SSI_RX_NOT_EMPTY        0x00000004  // Receive FIFO not empty
112 #define SSI_TX_NOT_FULL         0x00000002  // Transmit FIFO not full
113 #define SSI_TX_EMPTY            0x00000001  // Transmit FIFO empty
114 #define SSI_STATUS_MASK         0x0000000F
115 
116 //*****************************************************************************
117 //
118 // Values that can be passed to SSIConfigSetExpClk.
119 //
120 //*****************************************************************************
121 #define SSI_FRF_MOTO_MODE_0     0x00000000  // Moto fmt, polarity 0, phase 0
122 #define SSI_FRF_MOTO_MODE_1     0x00000002  // Moto fmt, polarity 0, phase 1
123 #define SSI_FRF_MOTO_MODE_2     0x00000001  // Moto fmt, polarity 1, phase 0
124 #define SSI_FRF_MOTO_MODE_3     0x00000003  // Moto fmt, polarity 1, phase 1
125 #define SSI_FRF_TI              0x00000010  // TI frame format
126 #define SSI_FRF_NMW             0x00000020  // National MicroWire frame format
127 
128 #define SSI_MODE_MASTER         0x00000000  // SSI master
129 #define SSI_MODE_SLAVE          0x00000001  // SSI slave
130 #define SSI_MODE_SLAVE_OD       0x00000002  // SSI slave with output disabled
131 
132 //*****************************************************************************
133 //
134 // Values that can be passed to SSIDMAEnable() and SSIDMADisable().
135 //
136 //*****************************************************************************
137 #define SSI_DMA_TX              0x00000002  // Enable DMA for transmit
138 #define SSI_DMA_RX              0x00000001  // Enable DMA for receive
139 
140 //*****************************************************************************
141 //
142 // API Functions and prototypes
143 //
144 //*****************************************************************************
145 
146 #ifdef DRIVERLIB_DEBUG
147 //*****************************************************************************
148 //
149 //! \internal
150 //!
151 //! \brief Checks an SSI base address.
152 //!
153 //! This function determines if an SSI module base address is valid.
154 //!
155 //! \param ui32Base specifies the SSI module base address.
156 //!
157 //! \return Returns \c true if the base address is valid and \c false
158 //! otherwise.
159 //
160 //*****************************************************************************
161 static bool
SSIBaseValid(uint32_t ui32Base)162 SSIBaseValid(uint32_t ui32Base)
163 {
164     return(ui32Base == SSI0_BASE || ui32Base == SSI1_BASE);
165 }
166 #endif
167 
168 //*****************************************************************************
169 //
170 //! \brief Configures the synchronous serial port.
171 //!
172 //! This function configures the synchronous serial port.  It sets
173 //! the SSI protocol, mode of operation, bit rate, and data width.
174 //!
175 //! The \c ui32Protocol parameter defines the data frame format. The Motorola
176 //! frame formats imply the following polarity and phase configurations:
177 //!
178 //! <pre>
179 //! Polarity Phase       Mode
180 //!   0       0   SSI_FRF_MOTO_MODE_0
181 //!   0       1   SSI_FRF_MOTO_MODE_1
182 //!   1       0   SSI_FRF_MOTO_MODE_2
183 //!   1       1   SSI_FRF_MOTO_MODE_3
184 //! </pre>
185 //!
186 //! The \c ui32Mode parameter defines the operating mode of the SSI module.
187 //! The SSI module can operate as a master or slave; if a slave, the SSI can be
188 //! configured to disable output on its serial output line.
189 //!
190 //! The \c ui32BitRate parameter defines the bit rate for the SSI. This bit
191 //! rate must satisfy the following clock ratio criteria:
192 //! - Master mode : FSSI >= 2 * bit rate
193 //! - Slave mode  : FSSI >= 12 * bit rate
194 //!
195 //! where FSSI is the frequency of the clock supplied to the SSI module.
196 //!
197 //! The \c ui32DataWidth parameter defines the width of the data transfers, and
198 //! can be a value between 4 and 16, inclusive.
199 //!
200 //! \note The peripheral clock is not necessarily the same as the processor clock.
201 //! The frequency of the peripheral clock is set by the system control.
202 //!
203 //! \param ui32Base specifies the SSI module base address.
204 //! \param ui32SSIClk is the rate of the clock supplied to the SSI module.
205 //! \param ui32Protocol specifies the data transfer protocol.
206 //! The parameter can be one of the following values:
207 //! - \ref SSI_FRF_MOTO_MODE_0
208 //! - \ref SSI_FRF_MOTO_MODE_1
209 //! - \ref SSI_FRF_MOTO_MODE_2
210 //! - \ref SSI_FRF_MOTO_MODE_3
211 //! - \ref SSI_FRF_TI
212 //! - \ref SSI_FRF_NMW.
213 //! \param ui32Mode specifies the mode of operation.
214 //! The parameter can be one of the following values:
215 //! - \ref SSI_MODE_MASTER
216 //! - \ref SSI_MODE_SLAVE
217 //! - \ref SSI_MODE_SLAVE_OD
218 //! \param ui32BitRate specifies the clock rate.
219 //! \param ui32DataWidth specifies number of bits transferred per frame.
220 //! Must be a value between 4 and 16, both included.
221 //!
222 //! \return None
223 //
224 //*****************************************************************************
225 extern void SSIConfigSetExpClk(uint32_t ui32Base, uint32_t ui32SSIClk,
226                                uint32_t ui32Protocol, uint32_t ui32Mode,
227                                uint32_t ui32BitRate, uint32_t ui32DataWidth);
228 
229 //*****************************************************************************
230 //
231 //! \brief Enables the synchronous serial port.
232 //!
233 //! This function enables operation of the synchronous serial port.  The
234 //! synchronous serial port must be configured before it is enabled.
235 //!
236 //! \param ui32Base specifies the SSI module base address.
237 //!
238 //! \return None
239 //
240 //*****************************************************************************
241 __STATIC_INLINE void
SSIEnable(uint32_t ui32Base)242 SSIEnable(uint32_t ui32Base)
243 {
244     //
245     // Check the arguments.
246     //
247     ASSERT(SSIBaseValid(ui32Base));
248 
249     //
250     // Read-modify-write the enable bit.
251     //
252     HWREG(ui32Base + SSI_O_CR1) |= SSI_CR1_SSE;
253 }
254 
255 //*****************************************************************************
256 //
257 //! \brief Disables the synchronous serial port.
258 //!
259 //! This function disables operation of the synchronous serial port.
260 //!
261 //! \param ui32Base specifies the SSI module base address.
262 //!
263 //! \return None
264 //
265 //*****************************************************************************
266 __STATIC_INLINE void
SSIDisable(uint32_t ui32Base)267 SSIDisable(uint32_t ui32Base)
268 {
269     //
270     // Check the arguments.
271     //
272     ASSERT(SSIBaseValid(ui32Base));
273 
274     //
275     // Read-modify-write the enable bit.
276     //
277     HWREG(ui32Base + SSI_O_CR1) &= ~(SSI_CR1_SSE);
278 }
279 
280 //*****************************************************************************
281 //
282 //! \brief Puts a data element into the SSI transmit FIFO.
283 //!
284 //! This function places the supplied data into the transmit FIFO of the
285 //! specified SSI module.
286 //!
287 //! \note The upper 32 - N bits of the \c ui32Data are discarded by the
288 //! hardware, where N is the data width as configured by \ref SSIConfigSetExpClk().
289 //! For example, if the interface is configured for 8-bit data width, the upper
290 //! 24 bits of \c ui32Data are discarded.
291 //!
292 //! \param ui32Base specifies the SSI module base address.
293 //! \param ui32Data is the data to be transmitted over the SSI interface.
294 //!
295 //! \return None
296 //
297 //*****************************************************************************
298 extern void SSIDataPut(uint32_t ui32Base, uint32_t ui32Data);
299 
300 //*****************************************************************************
301 //
302 //! \brief Puts a data element into the SSI transmit FIFO.
303 //!
304 //! This function places the supplied data into the transmit FIFO of the
305 //! specified SSI module. If there is no space in the FIFO, then this function
306 //! returns a zero.
307 //!
308 //! \note The upper 32 - N bits of the \c ui32Data are discarded by the hardware,
309 //! where N is the data width as configured by \ref SSIConfigSetExpClk(). For
310 //! example, if the interface is configured for 8-bit data width, the upper 24
311 //! bits of \c ui32Data are discarded.
312 //!
313 //! \param ui32Base specifies the SSI module base address.
314 //! \param ui32Data is the data to be transmitted over the SSI interface.
315 //!
316 //! \return Returns the number of elements written to the SSI transmit FIFO.
317 //
318 //*****************************************************************************
319 extern int32_t SSIDataPutNonBlocking(uint32_t ui32Base, uint32_t ui32Data);
320 
321 //*****************************************************************************
322 //
323 //! \brief Gets a data element from the SSI receive FIFO.
324 //!
325 //! This function gets received data from the receive FIFO of the specified
326 //! SSI module and places that data into the location specified by the
327 //! \c pui32Data parameter.
328 //!
329 //! \note Only the lower N bits of the value written to \c pui32Data contain
330 //! valid data, where N is the data width as configured by
331 //! \ref SSIConfigSetExpClk(). For example, if the interface is configured for
332 //! 8-bit data width, only the lower 8 bits of the value written to
333 //! \c pui32Data contain valid data.
334 //!
335 //! \param ui32Base specifies the SSI module base address.
336 //! \param pui32Data is a pointer to a storage location for data that was
337 //! received over the SSI interface.
338 //!
339 //! \return None
340 //
341 //*****************************************************************************
342 extern void SSIDataGet(uint32_t ui32Base, uint32_t *pui32Data);
343 
344 //*****************************************************************************
345 //
346 //! \brief Gets a data element from the SSI receive FIFO.
347 //!
348 //! This function gets received data from the receive FIFO of the specified SSI
349 //! module and places that data into the location specified by the \c ui32Data
350 //! parameter. If there is no data in the FIFO, then this function returns a
351 //! zero.
352 //!
353 //! \note Only the lower N bits of the value written to \c pui32Data contain
354 //! valid data, where N is the data width as configured by
355 //! \ref SSIConfigSetExpClk(). For example, if the interface is configured for
356 //! 8-bit data width, only the lower 8 bits of the value written to \c pui32Data
357 //! contain valid data.
358 //!
359 //! \param ui32Base specifies the SSI module base address.
360 //! \param pui32Data is a pointer to a storage location for data that was
361 //! received over the SSI interface.
362 //!
363 //! \return Returns the number of elements read from the SSI receive FIFO.
364 //
365 //*****************************************************************************
366 extern int32_t SSIDataGetNonBlocking(uint32_t ui32Base, uint32_t *pui32Data);
367 
368 //*****************************************************************************
369 //
370 //! \brief Determines whether the SSI transmitter is busy or not.
371 //!
372 //! Allows the caller to determine whether all transmitted bytes have cleared
373 //! the transmitter hardware. If \c false is returned, then the transmit FIFO
374 //! is empty and all bits of the last transmitted word have left the hardware
375 //! shift register.
376 //!
377 //! \param ui32Base is the base address of the SSI port.
378 //!
379 //! \return Returns status of the SSI transmit buffer.
380 //! - \c true  : SSI is transmitting.
381 //! - \c false : SSI transmissions are complete.
382 //
383 //*****************************************************************************
384 __STATIC_INLINE bool
SSIBusy(uint32_t ui32Base)385 SSIBusy(uint32_t ui32Base)
386 {
387     //
388     // Check the arguments.
389     //
390     ASSERT(SSIBaseValid(ui32Base));
391 
392     //
393     // Determine if the SSI is busy.
394     //
395     return((HWREG(ui32Base + SSI_O_SR) & SSI_SR_BSY) ? true : false);
396 }
397 
398 //*****************************************************************************
399 //
400 //! \brief Get the status of the SSI data buffers.
401 //!
402 //! This function is used to poll the status of the internal FIFOs in the SSI
403 //! module. The status of both TX and RX FIFO is returned.
404 //!
405 //! \param ui32Base specifies the SSI module base address.
406 //!
407 //! \return Returns the current status of the internal SSI data buffers.
408 //! The status is a bitwise OR'ed combination of:
409 //! - \ref SSI_RX_FULL        : Receive FIFO full.
410 //! - \ref SSI_RX_NOT_EMPTY   : Receive FIFO not empty.
411 //! - \ref SSI_TX_NOT_FULL    : Transmit FIFO not full.
412 //! - \ref SSI_TX_EMPTY       : Transmit FIFO empty.
413 //
414 //*****************************************************************************
415 __STATIC_INLINE uint32_t
SSIStatus(uint32_t ui32Base)416 SSIStatus(uint32_t ui32Base)
417 {
418     //
419     // Check the arguments.
420     //
421     ASSERT(SSIBaseValid(ui32Base));
422 
423     //
424     // Return the status
425     //
426     return (HWREG(ui32Base + SSI_O_SR) & SSI_STATUS_MASK);
427 }
428 
429 //*****************************************************************************
430 //
431 //! \brief Registers an interrupt handler for the synchronous serial port.
432 //!
433 //! This sets the handler to be called when an SSI interrupt
434 //! occurs. This will enable the global interrupt in the interrupt controller;
435 //! specific SSI interrupts must be enabled via \ref SSIIntEnable(). If necessary,
436 //! it is the interrupt handler's responsibility to clear the interrupt source
437 //! via \ref SSIIntClear().
438 //!
439 //! \param ui32Base specifies the SSI module base address.
440 //! \param pfnHandler is a pointer to the function to be called when the
441 //! synchronous serial port interrupt occurs.
442 //!
443 //! \return None
444 //!
445 //! \sa \ref IntRegister() for important information about registering interrupt
446 //! handlers.
447 //
448 //*****************************************************************************
449 extern void SSIIntRegister(uint32_t ui32Base, void (*pfnHandler)(void));
450 
451 //*****************************************************************************
452 //
453 //! \brief Unregisters an interrupt handler for the synchronous serial port.
454 //!
455 //! This function will clear the handler to be called when a SSI
456 //! interrupt occurs. This will also mask off the interrupt in the interrupt
457 //! controller so that the interrupt handler no longer is called.
458 //!
459 //! \param ui32Base specifies the SSI module base address.
460 //!
461 //! \return None
462 //!
463 //! \sa \ref IntRegister() for important information about registering interrupt
464 //! handlers.
465 //
466 //*****************************************************************************
467 extern void SSIIntUnregister(uint32_t ui32Base);
468 
469 //*****************************************************************************
470 //
471 //! \brief Enables individual SSI interrupt sources.
472 //!
473 //! Enables the indicated SSI interrupt sources. Only the sources that are
474 //! enabled can be reflected to the processor interrupt; disabled sources have
475 //! no effect on the processor.
476 //!
477 //! \param ui32Base specifies the SSI module base address.
478 //! \param ui32IntFlags is a bit mask of the interrupt sources to be enabled.
479 //! - \ref SSI_TXFF
480 //! - \ref SSI_RXFF
481 //! - \ref SSI_RXTO
482 //! - \ref SSI_RXOR
483 //!
484 //! \return None
485 //
486 //*****************************************************************************
487 __STATIC_INLINE void
SSIIntEnable(uint32_t ui32Base,uint32_t ui32IntFlags)488 SSIIntEnable(uint32_t ui32Base, uint32_t ui32IntFlags)
489 {
490     //
491     // Check the arguments.
492     //
493     ASSERT(SSIBaseValid(ui32Base));
494 
495     //
496     // Enable the specified interrupts.
497     //
498     HWREG(ui32Base + SSI_O_IMSC) |= ui32IntFlags;
499 }
500 
501 //*****************************************************************************
502 //
503 //! \brief Disables individual SSI interrupt sources.
504 //!
505 //! Disables the indicated SSI interrupt sources.
506 //!
507 //! \param ui32Base specifies the SSI module base address.
508 //! \param ui32IntFlags is a bit mask of the interrupt sources to be disabled.
509 //! - \ref SSI_TXFF
510 //! - \ref SSI_RXFF
511 //! - \ref SSI_RXTO
512 //! - \ref SSI_RXOR
513 //!
514 //! \return None
515 //
516 //*****************************************************************************
517 __STATIC_INLINE void
SSIIntDisable(uint32_t ui32Base,uint32_t ui32IntFlags)518 SSIIntDisable(uint32_t ui32Base, uint32_t ui32IntFlags)
519 {
520     //
521     // Check the arguments.
522     //
523     ASSERT(SSIBaseValid(ui32Base));
524 
525     //
526     // Disable the specified interrupts.
527     //
528     HWREG(ui32Base + SSI_O_IMSC) &= ~(ui32IntFlags);
529 }
530 
531 //*****************************************************************************
532 //
533 //! \brief Clears SSI interrupt sources.
534 //!
535 //! The specified SSI interrupt sources are cleared so that they no longer
536 //! assert. This function must be called in the interrupt handler to keep the
537 //! interrupts from being recognized again immediately upon exit.
538 //!
539 //! \note Due to write buffers and synchronizers in the system it may take several
540 //! clock cycles from a register write clearing an event in a module and until the
541 //! event is actually cleared in the NVIC of the system CPU. It is recommended to
542 //! clear the event source early in the interrupt service routine (ISR) to allow
543 //! the event clear to propagate to the NVIC before returning from the ISR.
544 //! At the same time, an early event clear allows new events of the same type to be
545 //! pended instead of ignored if the event is cleared later in the ISR.
546 //! It is the responsibility of the programmer to make sure that enough time has passed
547 //! before returning from the ISR to avoid false re-triggering of the cleared event.
548 //! A simple, although not necessarily optimal, way of clearing an event before
549 //! returning from the ISR is:
550 //! -# Write to clear event (interrupt source). (buffered write)
551 //! -# Dummy read from the event source module. (making sure the write has propagated)
552 //! -# Wait two system CPU clock cycles (user code or two NOPs). (allowing cleared event to propagate through any synchronizers)
553 //!
554 //! \param ui32Base specifies the SSI module base address.
555 //! \param ui32IntFlags is a bit mask of the interrupt sources to be cleared.
556 //! The parameter can consist of either or both of:
557 //! - \ref SSI_RXTO : Timeout interrupt.
558 //! - \ref SSI_RXOR : Overrun interrupt.
559 //!
560 //! \return None
561 //
562 //*****************************************************************************
563 __STATIC_INLINE void
SSIIntClear(uint32_t ui32Base,uint32_t ui32IntFlags)564 SSIIntClear(uint32_t ui32Base, uint32_t ui32IntFlags)
565 {
566     //
567     // Check the arguments.
568     //
569     ASSERT(SSIBaseValid(ui32Base));
570 
571     //
572     // Clear the requested interrupt sources.
573     //
574     HWREG(ui32Base + SSI_O_ICR) = ui32IntFlags;
575 }
576 
577 //*****************************************************************************
578 //
579 //! \brief Gets the current interrupt status.
580 //!
581 //! This function returns the interrupt status for the SSI module.  Either the
582 //! raw interrupt status or the status of interrupts that are allowed to
583 //! reflect to the processor can be returned.
584 //!
585 //! \param ui32Base specifies the SSI module base address.
586 //! \param bMasked selects either raw or masked interrupt.
587 //! \c false : Raw interrupt status is required.
588 //! \c true  : Masked interrupt status is required.
589 //!
590 //! \return Returns the current interrupt status as an OR'ed combination of:
591 //! - \ref SSI_TXFF
592 //! - \ref SSI_RXFF
593 //! - \ref SSI_RXTO
594 //! - \ref SSI_RXOR
595 //
596 //*****************************************************************************
597 __STATIC_INLINE uint32_t
SSIIntStatus(uint32_t ui32Base,bool bMasked)598 SSIIntStatus(uint32_t ui32Base, bool bMasked)
599 {
600     //
601     // Check the arguments.
602     //
603     ASSERT(SSIBaseValid(ui32Base));
604 
605     //
606     // Return either the interrupt status or the raw interrupt status as
607     // requested.
608     //
609     if(bMasked)
610     {
611         return(HWREG(ui32Base + SSI_O_MIS));
612     }
613     else
614     {
615         return(HWREG(ui32Base + SSI_O_RIS));
616     }
617 }
618 
619 //*****************************************************************************
620 //
621 //! \brief Enable SSI DMA operation.
622 //!
623 //! The specified SSI DMA features are enabled. The SSI can be
624 //! configured to use DMA for transmit and/or receive data transfers.
625 //!
626 //! \note The uDMA controller must also be set up before DMA can be used
627 //! with the SSI.
628 //!
629 //! \param ui32Base is the base address of the SSI port.
630 //! \param ui32DMAFlags is a bit mask of the DMA features to enable.
631 //! The parameter is the bitwise OR of any of the following values:
632 //! - \ref SSI_DMA_RX : Enable DMA for receive.
633 //! - \ref SSI_DMA_TX : Enable DMA for transmit.
634 //!
635 //! \return None
636 //
637 //*****************************************************************************
638 __STATIC_INLINE void
SSIDMAEnable(uint32_t ui32Base,uint32_t ui32DMAFlags)639 SSIDMAEnable(uint32_t ui32Base, uint32_t ui32DMAFlags)
640 {
641     //
642     // Check the arguments.
643     //
644     ASSERT(SSIBaseValid(ui32Base));
645 
646     //
647     // Set the requested bits in the SSI DMA control register.
648     //
649     HWREG(ui32Base + SSI_O_DMACR) |= ui32DMAFlags;
650 }
651 
652 //*****************************************************************************
653 //
654 //! \brief Disable SSI DMA operation.
655 //!
656 //! This function is used to disable SSI DMA features that were enabled
657 //! by \ref SSIDMAEnable(). The specified SSI DMA features are disabled.
658 //!
659 //! \param ui32Base is the base address of the SSI port.
660 //! \param ui32DMAFlags is a bit mask of the DMA features to disable.
661 //! The parameter is the bitwise OR of any of the following values:
662 //! - \ref SSI_DMA_RX : Disable DMA for receive.
663 //! - \ref SSI_DMA_TX : Disable DMA for transmit.
664 //!
665 //! \return None
666 //
667 //*****************************************************************************
668 __STATIC_INLINE void
SSIDMADisable(uint32_t ui32Base,uint32_t ui32DMAFlags)669 SSIDMADisable(uint32_t ui32Base, uint32_t ui32DMAFlags)
670 {
671     //
672     // Check the arguments.
673     //
674     ASSERT(SSIBaseValid(ui32Base));
675 
676     //
677     // Clear the requested bits in the SSI DMA control register.
678     //
679     HWREG(ui32Base + SSI_O_DMACR) &= ~ui32DMAFlags;
680 }
681 
682 //*****************************************************************************
683 //
684 // Support for DriverLib in ROM:
685 // Redirect to implementation in ROM when available.
686 //
687 //*****************************************************************************
688 #if !defined(DRIVERLIB_NOROM) && !defined(DOXYGEN)
689     #include <driverlib/rom.h>
690     #ifdef ROM_SSIConfigSetExpClk
691         #undef  SSIConfigSetExpClk
692         #define SSIConfigSetExpClk              ROM_SSIConfigSetExpClk
693     #endif
694     #ifdef ROM_SSIDataPut
695         #undef  SSIDataPut
696         #define SSIDataPut                      ROM_SSIDataPut
697     #endif
698     #ifdef ROM_SSIDataPutNonBlocking
699         #undef  SSIDataPutNonBlocking
700         #define SSIDataPutNonBlocking           ROM_SSIDataPutNonBlocking
701     #endif
702     #ifdef ROM_SSIDataGet
703         #undef  SSIDataGet
704         #define SSIDataGet                      ROM_SSIDataGet
705     #endif
706     #ifdef ROM_SSIDataGetNonBlocking
707         #undef  SSIDataGetNonBlocking
708         #define SSIDataGetNonBlocking           ROM_SSIDataGetNonBlocking
709     #endif
710     #ifdef ROM_SSIIntRegister
711         #undef  SSIIntRegister
712         #define SSIIntRegister                  ROM_SSIIntRegister
713     #endif
714     #ifdef ROM_SSIIntUnregister
715         #undef  SSIIntUnregister
716         #define SSIIntUnregister                ROM_SSIIntUnregister
717     #endif
718 #endif
719 
720 //*****************************************************************************
721 //
722 // Mark the end of the C bindings section for C++ compilers.
723 //
724 //*****************************************************************************
725 #ifdef __cplusplus
726 }
727 #endif
728 
729 #endif // __SSI_H__
730 
731 //*****************************************************************************
732 //
733 //! Close the Doxygen group.
734 //! @}
735 //! @}
736 //
737 //*****************************************************************************
738