Advertisement
Guest User

Untitled

a guest
Jul 6th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.29 KB | None | 0 0
  1. //*****************************************************************************
  2. //
  3. // ssi.c - Driver for Synchronous Serial Interface.
  4. //
  5. // Copyright (c) 2005-2010 Texas Instruments Incorporated. All rights reserved.
  6. // Software License Agreement
  7. //
  8. // Texas Instruments (TI) is supplying this software for use solely and
  9. // exclusively on TI's microcontroller products. The software is owned by
  10. // TI and/or its suppliers, and is protected under applicable copyright
  11. // laws. You may not combine this software with "viral" open-source
  12. // software in order to form a larger program.
  13. //
  14. // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
  15. // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
  16. // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  17. // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
  18. // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
  19. // DAMAGES, FOR ANY REASON WHATSOEVER.
  20. //
  21. // This is part of revision 6594 of the Stellaris Peripheral Driver Library.
  22. //
  23. //*****************************************************************************
  24.  
  25. //*****************************************************************************
  26. //
  27. //! \addtogroup ssi_api
  28. //! @{
  29. //
  30. //*****************************************************************************
  31.  
  32. #include "inc/hw_ints.h"
  33. #include "inc/hw_memmap.h"
  34. #include "inc/hw_ssi.h"
  35. #include "inc/hw_types.h"
  36. #include "driverlib/debug.h"
  37. #include "driverlib/interrupt.h"
  38. #include "driverlib/ssi.h"
  39.  
  40. //*****************************************************************************
  41. //
  42. //! Configures the synchronous serial interface.
  43. //!
  44. //! \param ulBase specifies the SSI module base address.
  45. //! \param ulSSIClk is the rate of the clock supplied to the SSI module.
  46. //! \param ulProtocol specifies the data transfer protocol.
  47. //! \param ulMode specifies the mode of operation.
  48. //! \param ulBitRate specifies the clock rate.
  49. //! \param ulDataWidth specifies number of bits transferred per frame.
  50. //!
  51. //! This function configures the synchronous serial interface. It sets
  52. //! the SSI protocol, mode of operation, bit rate, and data width.
  53. //!
  54. //! The \e ulProtocol parameter defines the data frame format. The
  55. //! \e ulProtocol parameter can be one of the following values:
  56. //! \b SSI_FRF_MOTO_MODE_0, \b SSI_FRF_MOTO_MODE_1, \b SSI_FRF_MOTO_MODE_2,
  57. //! \b SSI_FRF_MOTO_MODE_3, \b SSI_FRF_TI, or \b SSI_FRF_NMW. The Motorola
  58. //! frame formats imply the following polarity and phase configurations:
  59. //!
  60. //! <pre>
  61. //! Polarity Phase Mode
  62. //! 0 0 SSI_FRF_MOTO_MODE_0
  63. //! 0 1 SSI_FRF_MOTO_MODE_1
  64. //! 1 0 SSI_FRF_MOTO_MODE_2
  65. //! 1 1 SSI_FRF_MOTO_MODE_3
  66. //! </pre>
  67. //!
  68. //! The \e ulMode parameter defines the operating mode of the SSI module. The
  69. //! SSI module can operate as a master or slave; if a slave, the SSI can be
  70. //! configured to disable output on its serial output line. The \e ulMode
  71. //! parameter can be one of the following values: \b SSI_MODE_MASTER,
  72. //! \b SSI_MODE_SLAVE, or \b SSI_MODE_SLAVE_OD.
  73. //!
  74. //! The \e ulBitRate parameter defines the bit rate for the SSI. This bit rate
  75. //! must satisfy the following clock ratio criteria:
  76. //!
  77. //! - FSSI >= 2 * bit rate (master mode)
  78. //! - FSSI >= 12 * bit rate (slave modes)
  79. //!
  80. //! where FSSI is the frequency of the clock supplied to the SSI module.
  81. //!
  82. //! The \e ulDataWidth parameter defines the width of the data transfers, and
  83. //! can be a value between 4 and 16, inclusive.
  84. //!
  85. //! The peripheral clock will be the same as the processor clock. This will be
  86. //! the value returned by SysCtlClockGet(), or it can be explicitly hard coded
  87. //! if it is constant and known (to save the code/execution overhead of a call
  88. //! to SysCtlClockGet()).
  89. //!
  90. //! This function replaces the original SSIConfig() API and performs the same
  91. //! actions. A macro is provided in <tt>ssi.h</tt> to map the original API to
  92. //! this API.
  93. //!
  94. //! \return None.
  95. //
  96. //*****************************************************************************
  97. void SSIConfigSetExpClk(unsigned long ulBase, unsigned long ulSSIClk,
  98. unsigned long ulProtocol, unsigned long ulMode,
  99. unsigned long ulBitRate, unsigned long ulDataWidth) {
  100. unsigned long ulMaxBitRate;
  101. unsigned long ulRegVal;
  102. unsigned long ulPreDiv;
  103. unsigned long ulSCR;
  104. unsigned long ulSPH_SPO;
  105.  
  106. //
  107. // Check the arguments.
  108. //
  109. ASSERT((ulBase == SSI0_BASE) || (ulBase == SSI1_BASE));
  110. ASSERT((ulProtocol == SSI_FRF_MOTO_MODE_0) ||
  111. (ulProtocol == SSI_FRF_MOTO_MODE_1) ||
  112. (ulProtocol == SSI_FRF_MOTO_MODE_2) ||
  113. (ulProtocol == SSI_FRF_MOTO_MODE_3) ||
  114. (ulProtocol == SSI_FRF_TI) ||
  115. (ulProtocol == SSI_FRF_NMW));
  116. ASSERT((ulMode == SSI_MODE_MASTER) ||
  117. (ulMode == SSI_MODE_SLAVE) ||
  118. (ulMode == SSI_MODE_SLAVE_OD));
  119. ASSERT(((ulMode == SSI_MODE_MASTER) && (ulBitRate <= (ulSSIClk / 2))) ||
  120. ((ulMode != SSI_MODE_MASTER) && (ulBitRate <= (ulSSIClk / 12))));
  121. ASSERT((ulSSIClk / ulBitRate) <= (254 * 256));
  122. ASSERT((ulDataWidth >= 4) && (ulDataWidth <= 16));
  123.  
  124. //
  125. // Set the mode.
  126. //
  127. ulRegVal = (ulMode == SSI_MODE_SLAVE_OD) ? SSI_CR1_SOD : 0;
  128. ulRegVal |= (ulMode == SSI_MODE_MASTER) ? 0 : SSI_CR1_MS;
  129. HWREG(ulBase + SSI_O_CR1) = ulRegVal;
  130.  
  131. //
  132. // Set the clock predivider.
  133. //
  134. ulMaxBitRate = ulSSIClk / ulBitRate;
  135. ulPreDiv = 0;
  136. do {
  137. ulPreDiv += 2;
  138. ulSCR = (ulMaxBitRate / ulPreDiv) - 1;
  139. } while (ulSCR > 255);
  140. HWREG(ulBase + SSI_O_CPSR) = ulPreDiv;
  141.  
  142. //
  143. // Set protocol and clock rate.
  144. //
  145. ulSPH_SPO = (ulProtocol & 3) << 6;
  146. ulProtocol &= SSI_CR0_FRF_M;
  147. ulRegVal = (ulSCR << 8) | ulSPH_SPO | ulProtocol | (ulDataWidth - 1);
  148. HWREG(ulBase + SSI_O_CR0) = ulRegVal;
  149. }
  150.  
  151. //*****************************************************************************
  152. //
  153. //! Enables the synchronous serial interface.
  154. //!
  155. //! \param ulBase specifies the SSI module base address.
  156. //!
  157. //! This function enables operation of the synchronous serial interface. The
  158. //! synchronous serial interface must be configured before it is enabled.
  159. //!
  160. //! \return None.
  161. //
  162. //*****************************************************************************
  163. void SSIEnable(unsigned long ulBase) {
  164. //
  165. // Check the arguments.
  166. //
  167. ASSERT((ulBase == SSI0_BASE) || (ulBase == SSI1_BASE));
  168.  
  169. //
  170. // Read-modify-write the enable bit.
  171. //
  172. HWREG(ulBase + SSI_O_CR1) |= SSI_CR1_SSE;
  173. }
  174.  
  175. //*****************************************************************************
  176. //
  177. //! Disables the synchronous serial interface.
  178. //!
  179. //! \param ulBase specifies the SSI module base address.
  180. //!
  181. //! This function disables operation of the synchronous serial interface.
  182. //!
  183. //! \return None.
  184. //
  185. //*****************************************************************************
  186. void SSIDisable(unsigned long ulBase) {
  187. //
  188. // Check the arguments.
  189. //
  190. ASSERT((ulBase == SSI0_BASE) || (ulBase == SSI1_BASE));
  191.  
  192. //
  193. // Read-modify-write the enable bit.
  194. //
  195. HWREG(ulBase + SSI_O_CR1) &= ~(SSI_CR1_SSE);
  196. }
  197.  
  198. //*****************************************************************************
  199. //
  200. //! Registers an interrupt handler for the synchronous serial interface.
  201. //!
  202. //! \param ulBase specifies the SSI module base address.
  203. //! \param pfnHandler is a pointer to the function to be called when the
  204. //! synchronous serial interface interrupt occurs.
  205. //!
  206. //! This sets the handler to be called when an SSI interrupt
  207. //! occurs. This will enable the global interrupt in the interrupt controller;
  208. //! specific SSI interrupts must be enabled via SSIIntEnable(). If necessary,
  209. //! it is the interrupt handler's responsibility to clear the interrupt source
  210. //! via SSIIntClear().
  211. //!
  212. //! \sa IntRegister() for important information about registering interrupt
  213. //! handlers.
  214. //!
  215. //! \return None.
  216. //
  217. //*****************************************************************************
  218. void SSIIntRegister(unsigned long ulBase, void(*pfnHandler)(void)) {
  219. unsigned long ulInt;
  220.  
  221. //
  222. // Check the arguments.
  223. //
  224. ASSERT((ulBase == SSI0_BASE) || (ulBase == SSI1_BASE));
  225.  
  226. //
  227. // Determine the interrupt number based on the SSI port.
  228. //
  229. ulInt = (ulBase == SSI0_BASE) ? INT_SSI0 : INT_SSI1;
  230.  
  231. //
  232. // Register the interrupt handler, returning an error if an error occurs.
  233. //
  234. IntRegister(ulInt, pfnHandler);
  235.  
  236. //
  237. // Enable the synchronous serial interface interrupt.
  238. //
  239. IntEnable(ulInt);
  240. }
  241.  
  242. //*****************************************************************************
  243. //
  244. //! Unregisters an interrupt handler for the synchronous serial interface.
  245. //!
  246. //! \param ulBase specifies the SSI module base address.
  247. //!
  248. //! This function will clear the handler to be called when a SSI
  249. //! interrupt occurs. This will also mask off the interrupt in the interrupt
  250. //! controller so that the interrupt handler no longer is called.
  251. //!
  252. //! \sa IntRegister() for important information about registering interrupt
  253. //! handlers.
  254. //!
  255. //! \return None.
  256. //
  257. //*****************************************************************************
  258. void SSIIntUnregister(unsigned long ulBase) {
  259. unsigned long ulInt;
  260.  
  261. //
  262. // Check the arguments.
  263. //
  264. ASSERT((ulBase == SSI0_BASE) || (ulBase == SSI1_BASE));
  265.  
  266. //
  267. // Determine the interrupt number based on the SSI port.
  268. //
  269. ulInt = (ulBase == SSI0_BASE) ? INT_SSI0 : INT_SSI1;
  270.  
  271. //
  272. // Disable the interrupt.
  273. //
  274. IntDisable(ulInt);
  275.  
  276. //
  277. // Unregister the interrupt handler.
  278. //
  279. IntUnregister(ulInt);
  280. }
  281.  
  282. //*****************************************************************************
  283. //
  284. //! Enables individual SSI interrupt sources.
  285. //!
  286. //! \param ulBase specifies the SSI module base address.
  287. //! \param ulIntFlags is a bit mask of the interrupt sources to be enabled.
  288. //!
  289. //! Enables the indicated SSI interrupt sources. Only the sources that are
  290. //! enabled can be reflected to the processor interrupt; disabled sources have
  291. //! no effect on the processor. The \e ulIntFlags parameter can be any of the
  292. //! \b SSI_TXFF, \b SSI_RXFF, \b SSI_RXTO, or \b SSI_RXOR values.
  293. //!
  294. //! \return None.
  295. //
  296. //*****************************************************************************
  297. void SSIIntEnable(unsigned long ulBase, unsigned long ulIntFlags) {
  298. //
  299. // Check the arguments.
  300. //
  301. ASSERT((ulBase == SSI0_BASE) || (ulBase == SSI1_BASE));
  302.  
  303. //
  304. // Enable the specified interrupts.
  305. //
  306. HWREG(ulBase + SSI_O_IM) |= ulIntFlags;
  307. }
  308.  
  309. //*****************************************************************************
  310. //
  311. //! Disables individual SSI interrupt sources.
  312. //!
  313. //! \param ulBase specifies the SSI module base address.
  314. //! \param ulIntFlags is a bit mask of the interrupt sources to be disabled.
  315. //!
  316. //! Disables the indicated SSI interrupt sources. The \e ulIntFlags parameter
  317. //! can be any of the \b SSI_TXFF, \b SSI_RXFF, \b SSI_RXTO, or \b SSI_RXOR
  318. //! values.
  319. //!
  320. //! \return None.
  321. //
  322. //*****************************************************************************
  323. void SSIIntDisable(unsigned long ulBase, unsigned long ulIntFlags) {
  324. //
  325. // Check the arguments.
  326. //
  327. ASSERT((ulBase == SSI0_BASE) || (ulBase == SSI1_BASE));
  328.  
  329. //
  330. // Disable the specified interrupts.
  331. //
  332. HWREG(ulBase + SSI_O_IM) &= ~(ulIntFlags);
  333. }
  334.  
  335. //*****************************************************************************
  336. //
  337. //! Gets the current interrupt status.
  338. //!
  339. //! \param ulBase specifies the SSI module base address.
  340. //! \param bMasked is \b false if the raw interrupt status is required or
  341. //! \b true if the masked interrupt status is required.
  342. //!
  343. //! This function returns the interrupt status for the SSI module. Either the
  344. //! raw interrupt status or the status of interrupts that are allowed to
  345. //! reflect to the processor can be returned.
  346. //!
  347. //! \return The current interrupt status, enumerated as a bit field of
  348. //! \b SSI_TXFF, \b SSI_RXFF, \b SSI_RXTO, and \b SSI_RXOR.
  349. //
  350. //*****************************************************************************
  351. unsigned long SSIIntStatus(unsigned long ulBase, tBoolean bMasked) {
  352. //
  353. // Check the arguments.
  354. //
  355. ASSERT((ulBase == SSI0_BASE) || (ulBase == SSI1_BASE));
  356.  
  357. //
  358. // Return either the interrupt status or the raw interrupt status as
  359. // requested.
  360. //
  361. if (bMasked) {
  362. return (HWREG(ulBase + SSI_O_MIS));
  363. } else {
  364. return (HWREG(ulBase + SSI_O_RIS));
  365. }
  366. }
  367.  
  368. //*****************************************************************************
  369. //
  370. //! Clears SSI interrupt sources.
  371. //!
  372. //! \param ulBase specifies the SSI module base address.
  373. //! \param ulIntFlags is a bit mask of the interrupt sources to be cleared.
  374. //!
  375. //! The specified SSI interrupt sources are cleared so that they no longer
  376. //! assert. This function must be called in the interrupt handler to keep the
  377. //! interrupts from being recognized again immediately upon exit. The
  378. //! \e ulIntFlags parameter can consist of either or both the \b SSI_RXTO and
  379. //! \b SSI_RXOR values.
  380. //!
  381. //! \note Since there is a write buffer in the Cortex-M3 processor, it may take
  382. //! several clock cycles before the interrupt source is actually cleared.
  383. //! Therefore, it is recommended that the interrupt source be cleared early in
  384. //! the interrupt handler (as opposed to the very last action) to avoid
  385. //! returning from the interrupt handler before the interrupt source is
  386. //! actually cleared. Failure to do so may result in the interrupt handler
  387. //! being immediately reentered (since NVIC still sees the interrupt source
  388. //! asserted).
  389. //!
  390. //! \return None.
  391. //
  392. //*****************************************************************************
  393. void SSIIntClear(unsigned long ulBase, unsigned long ulIntFlags) {
  394. //
  395. // Check the arguments.
  396. //
  397. ASSERT((ulBase == SSI0_BASE) || (ulBase == SSI1_BASE));
  398.  
  399. //
  400. // Clear the requested interrupt sources.
  401. //
  402. HWREG(ulBase + SSI_O_ICR) = ulIntFlags;
  403. }
  404.  
  405. //*****************************************************************************
  406. //
  407. //! Puts a data element into the SSI transmit FIFO.
  408. //!
  409. //! \param ulBase specifies the SSI module base address.
  410. //! \param ulData is the data to be transmitted over the SSI interface.
  411. //!
  412. //! This function places the supplied data into the transmit FIFO of the
  413. //! specified SSI module.
  414. //!
  415. //! \note The upper 32 - N bits of the \e ulData are discarded by the hardware,
  416. //! where N is the data width as configured by SSIConfigSetExpClk(). For
  417. //! example, if the interface is configured for 8-bit data width, the upper 24
  418. //! bits of \e ulData are discarded.
  419. //!
  420. //! \return None.
  421. //
  422. //*****************************************************************************
  423. void SSIDataPut(unsigned long ulBase, unsigned long ulData) {
  424. //
  425. // Check the arguments.
  426. //
  427. ASSERT((ulBase == SSI0_BASE) || (ulBase == SSI1_BASE));ASSERT((ulData &
  428. (0xfffffffe << (HWREG(ulBase + SSI_O_CR0) & SSI_CR0_DSS_M))) == 0);
  429.  
  430. //
  431. // Wait until there is space.
  432. //
  433. while (!(HWREG(ulBase + SSI_O_SR) & SSI_SR_TNF)) {
  434. }
  435.  
  436. //
  437. // Write the data to the SSI.
  438. //
  439. HWREG(ulBase + SSI_O_DR) = ulData;
  440. }
  441.  
  442. //*****************************************************************************
  443. //
  444. //! Puts a data element into the SSI transmit FIFO.
  445. //!
  446. //! \param ulBase specifies the SSI module base address.
  447. //! \param ulData is the data to be transmitted over the SSI interface.
  448. //!
  449. //! This function places the supplied data into the transmit FIFO of the
  450. //! specified SSI module. If there is no space in the FIFO, then this function
  451. //! returns a zero.
  452. //!
  453. //! This function replaces the original SSIDataNonBlockingPut() API and
  454. //! performs the same actions. A macro is provided in <tt>ssi.h</tt> to map
  455. //! the original API to this API.
  456. //!
  457. //! \note The upper 32 - N bits of the \e ulData are discarded by the hardware,
  458. //! where N is the data width as configured by SSIConfigSetExpClk(). For
  459. //! example, if the interface is configured for 8-bit data width, the upper 24
  460. //! bits of \e ulData are discarded.
  461. //!
  462. //! \return Returns the number of elements written to the SSI transmit FIFO.
  463. //
  464. //*****************************************************************************
  465. long SSIDataPutNonBlocking(unsigned long ulBase, unsigned long ulData) {
  466. //
  467. // Check the arguments.
  468. //
  469. ASSERT((ulBase == SSI0_BASE) || (ulBase == SSI1_BASE));ASSERT((ulData &
  470. (0xfffffffe << (HWREG(ulBase + SSI_O_CR0) & SSI_CR0_DSS_M))) == 0);
  471.  
  472. //
  473. // Check for space to write.
  474. //
  475. if (HWREG(ulBase + SSI_O_SR) & SSI_SR_TNF) {
  476. HWREG(ulBase + SSI_O_DR) = ulData;
  477. return (1);
  478. } else {
  479. return (0);
  480. }
  481. }
  482.  
  483. //*****************************************************************************
  484. //
  485. //! Gets a data element from the SSI receive FIFO.
  486. //!
  487. //! \param ulBase specifies the SSI module base address.
  488. //! \param pulData is a pointer to a storage location for data that was
  489. //! received over the SSI interface.
  490. //!
  491. //! This function gets received data from the receive FIFO of the specified
  492. //! SSI module and places that data into the location specified by the
  493. //! \e pulData parameter.
  494. //!
  495. //! \note Only the lower N bits of the value written to \e pulData contain
  496. //! valid data, where N is the data width as configured by
  497. //! SSIConfigSetExpClk(). For example, if the interface is configured for
  498. //! 8-bit data width, only the lower 8 bits of the value written to \e pulData
  499. //! contain valid data.
  500. //!
  501. //! \return None.
  502. //
  503. //*****************************************************************************
  504. void SSIDataGet(unsigned long ulBase, unsigned long* pulData) {
  505. //
  506. // Check the arguments.
  507. //
  508. ASSERT((ulBase == SSI0_BASE) || (ulBase == SSI1_BASE));
  509.  
  510. //
  511. // Wait until there is data to be read.
  512. //
  513. while (!(HWREG(ulBase + SSI_O_SR) & SSI_SR_RNE)) {
  514. }
  515.  
  516. //
  517. // Read data from SSI.
  518. //
  519. *pulData = HWREG(ulBase + SSI_O_DR);
  520. }
  521.  
  522. //*****************************************************************************
  523. //
  524. //! Gets a data element from the SSI receive FIFO.
  525. //!
  526. //! \param ulBase specifies the SSI module base address.
  527. //! \param pulData is a pointer to a storage location for data that was
  528. //! received over the SSI interface.
  529. //!
  530. //! This function gets received data from the receive FIFO of the specified SSI
  531. //! module and places that data into the location specified by the \e ulData
  532. //! parameter. If there is no data in the FIFO, then this function returns a
  533. //! zero.
  534. //!
  535. //! This function replaces the original SSIDataNonBlockingGet() API and
  536. //! performs the same actions. A macro is provided in <tt>ssi.h</tt> to map
  537. //! the original API to this API.
  538. //!
  539. //! \note Only the lower N bits of the value written to \e pulData contain
  540. //! valid data, where N is the data width as configured by
  541. //! SSIConfigSetExpClk(). For example, if the interface is configured for
  542. //! 8-bit data width, only the lower 8 bits of the value written to \e pulData
  543. //! contain valid data.
  544. //!
  545. //! \return Returns the number of elements read from the SSI receive FIFO.
  546. //
  547. //*****************************************************************************
  548. long SSIDataGetNonBlocking(unsigned long ulBase, unsigned long *pulData) {
  549. //
  550. // Check the arguments.
  551. //
  552. ASSERT((ulBase == SSI0_BASE) || (ulBase == SSI1_BASE));
  553.  
  554. //
  555. // Check for data to read.
  556. //
  557. if (HWREG(ulBase + SSI_O_SR) & SSI_SR_RNE) {
  558. *pulData = HWREG(ulBase + SSI_O_DR);
  559. return (1);
  560. } else {
  561. return (0);
  562. }
  563. }
  564.  
  565. //*****************************************************************************
  566. //
  567. //! Enable SSI DMA operation.
  568. //!
  569. //! \param ulBase is the base address of the SSI port.
  570. //! \param ulDMAFlags is a bit mask of the DMA features to enable.
  571. //!
  572. //! The specified SSI DMA features are enabled. The SSI can be
  573. //! configured to use DMA for transmit and/or receive data transfers.
  574. //! The \e ulDMAFlags parameter is the logical OR of any of the following
  575. //! values:
  576. //!
  577. //! - SSI_DMA_RX - enable DMA for receive
  578. //! - SSI_DMA_TX - enable DMA for transmit
  579. //!
  580. //! \note The uDMA controller must also be set up before DMA can be used
  581. //! with the SSI.
  582. //!
  583. //! \return None.
  584. //
  585. //*****************************************************************************
  586. void SSIDMAEnable(unsigned long ulBase, unsigned long ulDMAFlags) {
  587. //
  588. // Check the arguments.
  589. //
  590. ASSERT((ulBase == SSI0_BASE) || (ulBase == SSI1_BASE));
  591.  
  592. //
  593. // Set the requested bits in the UART DMA control register.
  594. //
  595. HWREG(ulBase + SSI_O_DMACTL) |= ulDMAFlags;
  596. }
  597.  
  598. //*****************************************************************************
  599. //
  600. //! Disable SSI DMA operation.
  601. //!
  602. //! \param ulBase is the base address of the SSI port.
  603. //! \param ulDMAFlags is a bit mask of the DMA features to disable.
  604. //!
  605. //! This function is used to disable SSI DMA features that were enabled
  606. //! by SSIDMAEnable(). The specified SSI DMA features are disabled. The
  607. //! \e ulDMAFlags parameter is the logical OR of any of the following values:
  608. //!
  609. //! - SSI_DMA_RX - disable DMA for receive
  610. //! - SSI_DMA_TX - disable DMA for transmit
  611. //!
  612. //! \return None.
  613. //
  614. //*****************************************************************************
  615. void SSIDMADisable(unsigned long ulBase, unsigned long ulDMAFlags) {
  616. //
  617. // Check the arguments.
  618. //
  619. ASSERT((ulBase == SSI0_BASE) || (ulBase == SSI1_BASE));
  620.  
  621. //
  622. // Clear the requested bits in the UART DMA control register.
  623. //
  624. HWREG(ulBase + SSI_O_DMACTL) &= ~ulDMAFlags;
  625. }
  626.  
  627. //*****************************************************************************
  628. //
  629. //! Determines whether the SSI transmitter is busy or not.
  630. //!
  631. //! \param ulBase is the base address of the SSI port.
  632. //!
  633. //! Allows the caller to determine whether all transmitted bytes have cleared
  634. //! the transmitter hardware. If \b false is returned, then the transmit FIFO
  635. //! is empty and all bits of the last transmitted word have left the hardware
  636. //! shift register.
  637. //!
  638. //! \return Returns \b true if the SSI is transmitting or \b false if all
  639. //! transmissions are complete.
  640. //
  641. //*****************************************************************************
  642. tBoolean SSIBusy(unsigned long ulBase) {
  643. //
  644. // Check the arguments.
  645. //
  646. ASSERT((ulBase == SSI0_BASE) || (ulBase == SSI1_BASE));
  647.  
  648. //
  649. // Determine if the SSI is busy.
  650. //
  651. return ((HWREG(ulBase + SSI_O_SR) & SSI_SR_BSY) ? true : false);
  652. }
  653.  
  654. //*****************************************************************************
  655. //
  656. // Close the Doxygen group.
  657. //! @}
  658. //
  659. //*****************************************************************************
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement