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