hw_ssi.h 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. /******************************************************************************
  2. * Filename: hw_ssi.h
  3. * Revised: $Date: 2013-04-30 17:13:44 +0200 (Tue, 30 Apr 2013) $
  4. * Revision: $Revision: 9943 $
  5. *
  6. * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
  7. *
  8. *
  9. * Redistribution and use in source and binary forms, with or without
  10. * modification, are permitted provided that the following conditions
  11. * are met:
  12. *
  13. * Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions and the following disclaimer.
  15. *
  16. * Redistributions in binary form must reproduce the above copyright
  17. * notice, this list of conditions and the following disclaimer in the
  18. * documentation and/or other materials provided with the distribution.
  19. *
  20. * Neither the name of Texas Instruments Incorporated nor the names of
  21. * its contributors may be used to endorse or promote products derived
  22. * from this software without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  25. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  26. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  27. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  28. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  29. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  30. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  31. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  32. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  33. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  34. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  35. *
  36. ******************************************************************************/
  37. #ifndef __HW_SSI_H__
  38. #define __HW_SSI_H__
  39. //*****************************************************************************
  40. //
  41. // The following are defines for the SSI register offsets.
  42. //
  43. //*****************************************************************************
  44. #define SSI_O_CR0 0x00000000 // The CR0 register contains bit
  45. // fields that control various
  46. // functions within the SSI module.
  47. // Functionality such as protocol
  48. // mode, clock rate, and data size
  49. // are configured in this register.
  50. #define SSI_O_CR1 0x00000004 // The CR1 register contains bit
  51. // fields that control various
  52. // functions within the SSI module.
  53. // Master and slave mode
  54. // functionality is controlled by
  55. // this register.
  56. #define SSI_O_DR 0x00000008 // The DR register is 16 bits
  57. // wide. When the SSIDR register is
  58. // read, the entry in the receive
  59. // FIFO that is pointed to by the
  60. // current FIFO read pointer is
  61. // accessed. When a data value is
  62. // removed by the SSI receive logic
  63. // from the incoming data frame, it
  64. // is placed into the entry in the
  65. // receive FIFO pointed to by the
  66. // current FIFO write pointer. When
  67. // the DR register is written to,
  68. // the entry in the transmit FIFO
  69. // that is pointed to by the write
  70. // pointer is written to. Data
  71. // values are removed from the
  72. // transmit FIFO one value at a
  73. // time by the transmit logic. Each
  74. // data value is loaded into the
  75. // transmit serial shifter, then
  76. // serially shifted out onto the
  77. // SSITx pin at the programmed bit
  78. // rate. When a data size of less
  79. // than 16 bits is selected, the
  80. // user must right-justify data
  81. // written to the transmit FIFO.
  82. // The transmit logic ignores the
  83. // unused bits. Received data less
  84. // than 16 bits is automatically
  85. // right-justified in the receive
  86. // buffer. When the SSI is
  87. // programmed for MICROWIRE frame
  88. // format, the default size for
  89. // transmit data is eight bits (the
  90. // most significant byte is
  91. // ignored). The receive data size
  92. // is controlled by the programmer.
  93. // The transmit FIFO and the
  94. // receive FIFO are not cleared
  95. // even when the SSE bit in the
  96. // SSICR1 register is cleared,
  97. // allowing the software to fill
  98. // the transmit FIFO before
  99. // enabling the SSI.
  100. #define SSI_O_SR 0x0000000C // The SR register contains bits
  101. // that indicate the FIFO fill
  102. // status and the SSI busy status.
  103. #define SSI_O_CPSR 0x00000010 // The CPSR register specifies the
  104. // division factor which is used to
  105. // derive the SSIClk from the
  106. // system clock. The clock is
  107. // further divided by a value from
  108. // 1 to 256, which is 1 + SCR. SCR
  109. // is programmed in the SSICR0
  110. // register. The frequency of the
  111. // SSIClk is defined by: SSIClk =
  112. // SysClk / (CPSDVSR x (1 + SCR))
  113. // The value programmed into this
  114. // register must be an even number
  115. // between 2 and 254. The
  116. // least-significant bit of the
  117. // programmed number is hard-coded
  118. // to zero. If an odd number is
  119. // written to this register, data
  120. // read back from this register has
  121. // the least-significant bit as
  122. // zero.
  123. #define SSI_O_IM 0x00000014 // The IM register is the
  124. // interrupt mask set or clear
  125. // register. It is a read/write
  126. // register and all bits are
  127. // cleared on reset. On a read,
  128. // this register gives the current
  129. // value of the mask on the
  130. // corresponding interrupt. Setting
  131. // a bit sets the mask, preventing
  132. // the interrupt from being
  133. // signaled to the interrupt
  134. // controller. Clearing a bit
  135. // clears the corresponding mask,
  136. // enabling the interrupt to be
  137. // sent to the interrupt
  138. // controller.
  139. #define SSI_O_RIS 0x00000018 // The RIS register is the raw
  140. // interrupt status register. On a
  141. // read, this register gives the
  142. // current raw status value of the
  143. // corresponding interrupt before
  144. // masking. A write has no effect.
  145. #define SSI_O_MIS 0x0000001C // The MIS register is the masked
  146. // interrupt status register. On a
  147. // read, this register gives the
  148. // current masked status value of
  149. // the corresponding interrupt. A
  150. // write has no effect.
  151. #define SSI_O_ICR 0x00000020 // The ICR register is the
  152. // interrupt clear register. On a
  153. // write of 1, the corresponding
  154. // interrupt is cleared. A write of
  155. // 0 has no effect.
  156. #define SSI_O_DMACTL 0x00000024 // The DMACTL register is the uDMA
  157. // control register.
  158. #define SSI_O_CC 0x00000FC8 // SSI clock configuration The CC
  159. // register controls the baud clock
  160. // and system clocks sources for
  161. // the SSI module. Note: If the
  162. // PIOSC is used for the SSI baud
  163. // clock, the system clock
  164. // frequency must be at least 16
  165. // MHz in run mode.
  166. //*****************************************************************************
  167. //
  168. // The following are defines for the bit fields in the SSI_O_CR0 register.
  169. //
  170. //*****************************************************************************
  171. #define SSI_CR0_SCR_M 0x0000FF00 // SSI serial clock rate (R/W)
  172. // Reset value: 0x0 The value SCR
  173. // is used to generate the transmit
  174. // and receive bit rate of the SSI.
  175. // Where the bit rate is: BR =
  176. // FSSICLK/(CPSDVR * (1 + SCR))
  177. // where CPSDVR is an even value
  178. // from 2-254, programmed in the
  179. // SSICPSR register and SCR is a
  180. // value from 0-255.
  181. #define SSI_CR0_SCR_S 8
  182. #define SSI_CR0_SPH 0x00000080 // SSI serial clock phase (R/W)
  183. // Reset value: 0x0 This bit is
  184. // only applicable to the Motorola
  185. // SPI Format.
  186. #define SSI_CR0_SPH_M 0x00000080
  187. #define SSI_CR0_SPH_S 7
  188. #define SSI_CR0_SPO 0x00000040 // SSI serial clock phase (R/W)
  189. // Reset value: 0x0 This bit is
  190. // only applicable to the Motorola
  191. // SPI Format.
  192. #define SSI_CR0_SPO_M 0x00000040
  193. #define SSI_CR0_SPO_S 6
  194. #define SSI_CR0_FRF_M 0x00000030 // SSI frame format select (R/W)
  195. // Reset value: 0x0 00: Motorola
  196. // SPI frame format 01: TI
  197. // synchronous serial frame format
  198. // 10: National Microwire frame
  199. // format 11: Reserved
  200. #define SSI_CR0_FRF_S 4
  201. #define SSI_CR0_DSS_M 0x0000000F // SSI data size select (R/W)
  202. // Reset value: 0x0 0000-0010:
  203. // Reserved 0011: 4-bit data 0100:
  204. // 5-bit data 0101: 6-bit data
  205. // 0110: 7-bit data 0111: 8-bit
  206. // data 1000: 9-bit data 1001:
  207. // 10-bit data 1010: 11-bit data
  208. // 1011: 12-bit data 1100: 13-bit
  209. // data 1101: 14-bit data 1110:
  210. // 15-bit data 1111: 16-bit data
  211. #define SSI_CR0_DSS_S 0
  212. //*****************************************************************************
  213. //
  214. // The following are defines for the bit fields in the SSI_O_CR1 register.
  215. //
  216. //*****************************************************************************
  217. #define SSI_CR1_SOD 0x00000008 // SSI slave mode output disable
  218. // (R/W) Reset value: 0x0 This bit
  219. // is relevant only in the slave
  220. // mode (MS = 1). In multiple-slave
  221. // systems, it is possible for the
  222. // SSI master to broadcast a
  223. // message to all slaves in the
  224. // system while ensuring that only
  225. // one slave drives data onto the
  226. // serial output line. In such
  227. // systems, the RXD lines from
  228. // multiple slaves could be tied
  229. // together. To operate in such a
  230. // system, the SOD bit can be set
  231. // if the SSI slave is not suppose
  232. // to drive the SSITXD line. 0: SSI
  233. // can drive SSITXD in slave output
  234. // mode 1: SSI must not drive the
  235. // SSITXD output in slave mode
  236. #define SSI_CR1_SOD_M 0x00000008
  237. #define SSI_CR1_SOD_S 3
  238. #define SSI_CR1_MS 0x00000004 // SSI master and slave select
  239. // (R/W) Reset value: 0x0 This bit
  240. // can be modified only when the
  241. // SSI is disabled (SSE = 0). 0:
  242. // Device configured as a master
  243. // (default) 1: Device configured
  244. // as a slave
  245. #define SSI_CR1_MS_M 0x00000004
  246. #define SSI_CR1_MS_S 2
  247. #define SSI_CR1_SSE 0x00000002 // SSI synchronous serial port
  248. // enable (R/W) Reset value: 0x0 0:
  249. // SSI operation is disabled. 1:
  250. // SSI operation is enabled.
  251. #define SSI_CR1_SSE_M 0x00000002
  252. #define SSI_CR1_SSE_S 1
  253. #define SSI_CR1_LBM 0x00000001 // SSI loop-back mode (R/W) Reset
  254. // value: 0x0 0: Normal serial port
  255. // operation is enabled. 1: The
  256. // output of the transmit serial
  257. // shifter is connected to the
  258. // input of the receive serial
  259. // shift register internally.
  260. #define SSI_CR1_LBM_M 0x00000001
  261. #define SSI_CR1_LBM_S 0
  262. //*****************************************************************************
  263. //
  264. // The following are defines for the bit fields in the SSI_O_DR register.
  265. //
  266. //*****************************************************************************
  267. #define SSI_DR_DATA_M 0x0000FFFF // SSI receive/transmit data
  268. // register (R/W) Reset value:
  269. // 0xXXXX A read operation reads
  270. // the receive FIFO. A write
  271. // operation writes the transmit
  272. // FIFO. Software must
  273. // right-justify data when the SSI
  274. // is programmed for a data size
  275. // that is less than 16 bits.
  276. // Unused bits at the top are
  277. // ignored by the transmit logic.
  278. // The receive logic automatically
  279. // right-justified the data.
  280. #define SSI_DR_DATA_S 0
  281. //*****************************************************************************
  282. //
  283. // The following are defines for the bit fields in the SSI_O_SR register.
  284. //
  285. //*****************************************************************************
  286. #define SSI_SR_BSY 0x00000010 // SSI busy bit (RO) Reset value:
  287. // 0x0 0: SSI is idle. 1: SSI is
  288. // currently transmitting and/or
  289. // receiving a frame or the
  290. // transmit FIFO is not empty.
  291. #define SSI_SR_BSY_M 0x00000010
  292. #define SSI_SR_BSY_S 4
  293. #define SSI_SR_RFF 0x00000008 // SSI receive FIFO full (RO)
  294. // Reset value: 0x0 0: Receive FIFO
  295. // is not full. 1: Receive FIFO is
  296. // full.
  297. #define SSI_SR_RFF_M 0x00000008
  298. #define SSI_SR_RFF_S 3
  299. #define SSI_SR_RNE 0x00000004 // SSI receive FIFO not empty (RO)
  300. // Reset value: 0x0 0: Receive FIFO
  301. // is empty. 1: Receive FIFO is not
  302. // empty.
  303. #define SSI_SR_RNE_M 0x00000004
  304. #define SSI_SR_RNE_S 2
  305. #define SSI_SR_TNF 0x00000002 // SSI transmit FIFO not full (RO)
  306. // Reset value: 0x1 0: Transmit
  307. // FIFO is full. 1: Transmit FIFO
  308. // is not full.
  309. #define SSI_SR_TNF_M 0x00000002
  310. #define SSI_SR_TNF_S 1
  311. #define SSI_SR_TFE 0x00000001 // SSI transmit FIFO empty (RO)
  312. // Reset value: 0x1 0: Transmit
  313. // FIFO is not empty. 1: Transmit
  314. // FIFO is empty.
  315. #define SSI_SR_TFE_M 0x00000001
  316. #define SSI_SR_TFE_S 0
  317. //*****************************************************************************
  318. //
  319. // The following are defines for the bit fields in the SSI_O_CPSR register.
  320. //
  321. //*****************************************************************************
  322. #define SSI_CPSR_CPSDVSR_M 0x000000FF // SSI clock prescale divisor
  323. // (R/W) Reset value: 0x0 This
  324. // value must be an even number
  325. // from 2 to 254, depending on the
  326. // frequency of SSICLK. The LSB
  327. // always returns zero on reads.
  328. #define SSI_CPSR_CPSDVSR_S 0
  329. //*****************************************************************************
  330. //
  331. // The following are defines for the bit fields in the SSI_O_IM register.
  332. //
  333. //*****************************************************************************
  334. #define SSI_IM_TXIM 0x00000008 // SSI transmit FIFO interrupt
  335. // mask (R/W) Reset value: 0x0 0:
  336. // TX FIFO half empty or condition
  337. // interrupt is masked. 1: TX FIFO
  338. // half empty or less condition
  339. // interrupt is not masked.
  340. #define SSI_IM_TXIM_M 0x00000008
  341. #define SSI_IM_TXIM_S 3
  342. #define SSI_IM_RXIM 0x00000004 // SSI receive FIFO interrupt mask
  343. // (R/W) Reset value: 0x0 0: RX
  344. // FIFO half empty or condition
  345. // interrupt is masked. 1: RX FIFO
  346. // half empty or less condition
  347. // interrupt is not masked.
  348. #define SSI_IM_RXIM_M 0x00000004
  349. #define SSI_IM_RXIM_S 2
  350. #define SSI_IM_RTIM 0x00000002 // SSI receive time-out interrupt
  351. // mask (R/W) Reset value: 0x0 0:
  352. // RX FIFO time-out interrupt is
  353. // masked. 1: RX FIFO time-out
  354. // interrupt is not masked
  355. #define SSI_IM_RTIM_M 0x00000002
  356. #define SSI_IM_RTIM_S 1
  357. #define SSI_IM_RORIM 0x00000001 // SSI receive overrun interrupt
  358. // mask (R/W) Reset value: 0x0 0:
  359. // RX FIFO Overrun interrupt is
  360. // masked. 1: RX FIFO Overrun
  361. // interrupt is not masked
  362. #define SSI_IM_RORIM_M 0x00000001
  363. #define SSI_IM_RORIM_S 0
  364. //*****************************************************************************
  365. //
  366. // The following are defines for the bit fields in the SSI_O_RIS register.
  367. //
  368. //*****************************************************************************
  369. #define SSI_RIS_TXRIS 0x00000008 // SSI SSITXINTR raw state (RO)
  370. // Reset value: 0x1 Gives the raw
  371. // interrupt state (before masking)
  372. // of SSITXINTR
  373. #define SSI_RIS_TXRIS_M 0x00000008
  374. #define SSI_RIS_TXRIS_S 3
  375. #define SSI_RIS_RXRIS 0x00000004 // SSI SSIRXINTR raw state (RO)
  376. // Reset value: 0x0 Gives the raw
  377. // interrupt state (before masking)
  378. // of SSIRXINTR
  379. #define SSI_RIS_RXRIS_M 0x00000004
  380. #define SSI_RIS_RXRIS_S 2
  381. #define SSI_RIS_RTRIS 0x00000002 // SSI SSIRTINTR raw state (RO)
  382. // Reset value: 0x0 Gives the raw
  383. // interrupt state (before masking)
  384. // of SSIRTINTR
  385. #define SSI_RIS_RTRIS_M 0x00000002
  386. #define SSI_RIS_RTRIS_S 1
  387. #define SSI_RIS_RORRIS 0x00000001 // SSI SSIRORINTR raw state (RO)
  388. // Reset value: 0x0 Gives the raw
  389. // interrupt state (before masking)
  390. // of SSIRORINTR
  391. #define SSI_RIS_RORRIS_M 0x00000001
  392. #define SSI_RIS_RORRIS_S 0
  393. //*****************************************************************************
  394. //
  395. // The following are defines for the bit fields in the SSI_O_MIS register.
  396. //
  397. //*****************************************************************************
  398. #define SSI_MIS_TXMIS 0x00000008 // SSI SSITXINTR masked state (RO)
  399. // Reset value: 0x0 Gives the
  400. // interrupt state (after masking)
  401. // of SSITXINTR
  402. #define SSI_MIS_TXMIS_M 0x00000008
  403. #define SSI_MIS_TXMIS_S 3
  404. #define SSI_MIS_RXMIS 0x00000004 // SSI SSIRXINTR masked state (RO)
  405. // Reset value: 0x0 Gives the
  406. // interrupt state (after masking)
  407. // of SSIRXINTR
  408. #define SSI_MIS_RXMIS_M 0x00000004
  409. #define SSI_MIS_RXMIS_S 2
  410. #define SSI_MIS_RTMIS 0x00000002 // SSI SSIRTINTR masked state (RO)
  411. // Reset value: 0x0 Gives the
  412. // interrupt state (after masking)
  413. // of SSIRTINTR
  414. #define SSI_MIS_RTMIS_M 0x00000002
  415. #define SSI_MIS_RTMIS_S 1
  416. #define SSI_MIS_RORMIS 0x00000001 // SSI SSIRORINTR masked state
  417. // (RO) Reset value: 0x0 Gives the
  418. // interrupt state (after masking)
  419. // of SSIRORINTR
  420. #define SSI_MIS_RORMIS_M 0x00000001
  421. #define SSI_MIS_RORMIS_S 0
  422. //*****************************************************************************
  423. //
  424. // The following are defines for the bit fields in the SSI_O_ICR register.
  425. //
  426. //*****************************************************************************
  427. #define SSI_ICR_RTIC 0x00000002 // SSI receive time-out interrupt
  428. // clear (W1C) Reset value: 0x0 0:
  429. // No effect on interrupt 1: Clears
  430. // interrupt
  431. #define SSI_ICR_RTIC_M 0x00000002
  432. #define SSI_ICR_RTIC_S 1
  433. #define SSI_ICR_RORIC 0x00000001 // SSI receive overrun interrupt
  434. // clear (W1C) Reset value: 0x0 0:
  435. // No effect on interrupt 1: Clears
  436. // interrupt
  437. #define SSI_ICR_RORIC_M 0x00000001
  438. #define SSI_ICR_RORIC_S 0
  439. //*****************************************************************************
  440. //
  441. // The following are defines for the bit fields in the SSI_O_DMACTL register.
  442. //
  443. //*****************************************************************************
  444. #define SSI_DMACTL_TXDMAE 0x00000002 // Transmit DMA enable 0: uDMA for
  445. // the transmit FIFO is disabled.
  446. // 1: uDMA for the transmit FIFO is
  447. // enabled.
  448. #define SSI_DMACTL_TXDMAE_M 0x00000002
  449. #define SSI_DMACTL_TXDMAE_S 1
  450. #define SSI_DMACTL_RXDMAE 0x00000001 // Receive DMA enable 0: uDMA for
  451. // the receive FIFO is disabled. 1:
  452. // uDMA for the receive FIFO is
  453. // enabled.
  454. #define SSI_DMACTL_RXDMAE_M 0x00000001
  455. #define SSI_DMACTL_RXDMAE_S 0
  456. //*****************************************************************************
  457. //
  458. // The following are defines for the bit fields in the SSI_O_CC register.
  459. //
  460. //*****************************************************************************
  461. #define SSI_CC_CS_M 0x00000007 // SSI baud and system clock
  462. // source The following bits
  463. // determine the clock source that
  464. // generates the baud and system
  465. // clocks for the SSI. bit0
  466. // (PIOSC): 1: The SSI baud clock
  467. // is determined by the IO DIV
  468. // setting in the system
  469. // controller. 0: The SSI baud
  470. // clock is determined by the SYS
  471. // DIV setting in the system
  472. // controller. bit1: Unused bit2:
  473. // (DSEN) Only meaningful when the
  474. // system is in deep sleep mode.
  475. // This bit is a don't care when
  476. // not in sleep mode. 1: The SSI
  477. // system clock is running on the
  478. // same clock as the baud clock, as
  479. // per PIOSC setting above. 0: The
  480. // SSI system clock is determined
  481. // by the SYS DIV setting in the
  482. // system controller.
  483. #define SSI_CC_CS_S 0
  484. #endif // __HW_SSI_H__