znp_spi.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. /**************************************************************************************************
  2. Filename: znp_spi.h
  3. Revised: $Date: 2010-07-28 18:42:54 -0700 (Wed, 28 Jul 2010) $
  4. Revision: $Revision: 23203 $
  5. Description:
  6. This file contains the declaration to the H/W ZNP SPI driver.
  7. Copyright 2009-2010 Texas Instruments Incorporated. All rights reserved.
  8. IMPORTANT: Your use of this Software is limited to those specific rights
  9. granted under the terms of a software license agreement between the user
  10. who downloaded the software, his/her employer (which must be your employer)
  11. and Texas Instruments Incorporated (the "License"). You may not use this
  12. Software unless you agree to abide by the terms of the License. The License
  13. limits your use, and you acknowledge, that the Software may not be modified,
  14. copied or distributed unless embedded on a Texas Instruments microcontroller
  15. or used solely and exclusively in conjunction with a Texas Instruments radio
  16. frequency transceiver, which is integrated into your product. Other than for
  17. the foregoing purpose, you may not use, reproduce, copy, prepare derivative
  18. works of, modify, distribute, perform, display or sell this Software and/or
  19. its documentation for any purpose.
  20. YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
  21. PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
  22. INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
  23. NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
  24. TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
  25. NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
  26. LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
  27. INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
  28. OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
  29. OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
  30. (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
  31. Should you have any questions regarding your right to use this Software,
  32. contact Texas Instruments Incorporated at www.TI.com.
  33. **************************************************************************************************/
  34. #ifndef ZNP_SPI_H
  35. #define ZNP_SPI_H
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39. /* ------------------------------------------------------------------------------------------------
  40. * Includes
  41. * ------------------------------------------------------------------------------------------------
  42. */
  43. #include "hal_board.h"
  44. #include "MT_RPC.h"
  45. /* ------------------------------------------------------------------------------------------------
  46. * Constants
  47. * ------------------------------------------------------------------------------------------------
  48. */
  49. /* ------------------------------------------------------------------------------------------------
  50. * Typedefs
  51. * ------------------------------------------------------------------------------------------------
  52. */
  53. /* ------------------------------------------------------------------------------------------------
  54. * Functions
  55. * ------------------------------------------------------------------------------------------------
  56. */
  57. /**************************************************************************************************
  58. * @fn npSpiInit
  59. *
  60. * @brief This function is called to set up the SPI interface.
  61. *
  62. * input parameters
  63. *
  64. * None.
  65. *
  66. * output parameters
  67. *
  68. * None.
  69. *
  70. * @return None.
  71. **************************************************************************************************
  72. */
  73. extern void npSpiInit(void);
  74. /**************************************************************************************************
  75. * @fn npSpiMonitor
  76. *
  77. * @brief This function monitors the SPI signals for error conditions and for the end of a
  78. * transaction. If an error is detected it attempts to recover.
  79. *
  80. * input parameters
  81. *
  82. * None.
  83. *
  84. * output parameters
  85. *
  86. * None.
  87. *
  88. * @return None.
  89. **************************************************************************************************
  90. */
  91. extern void npSpiMonitor(void);
  92. /**************************************************************************************************
  93. * @fn npSpiRxIsr
  94. *
  95. * @brief This function handles the DMA Rx complete interrupt.
  96. *
  97. * input parameters
  98. *
  99. * None.
  100. *
  101. * output parameters
  102. *
  103. * None.
  104. *
  105. * @return None.
  106. **************************************************************************************************
  107. */
  108. extern void npSpiRxIsr(void);
  109. /**************************************************************************************************
  110. * @fn npSpiTxIsr
  111. *
  112. * @brief This function handles the DMA Tx complete interrupt.
  113. *
  114. * input parameters
  115. *
  116. * None.
  117. *
  118. * output parameters
  119. *
  120. * None.
  121. *
  122. * @return None.
  123. **************************************************************************************************
  124. */
  125. extern void npSpiTxIsr(void);
  126. /**************************************************************************************************
  127. * @fn npSpiPollCallback
  128. *
  129. * @brief This function is called by the SPI driver when a POLL frame is received.
  130. *
  131. * input parameters
  132. *
  133. * None.
  134. *
  135. * output parameters
  136. *
  137. * None.
  138. *
  139. * @return A pointer to an OSAL message buffer containing the next AREQ frame to transmit,
  140. * if any; NULL otherwise.
  141. **************************************************************************************************
  142. */
  143. extern uint8 *npSpiPollCallback(void);
  144. /**************************************************************************************************
  145. * @fn npSpiPollReadyback
  146. *
  147. * @brief This function is called by the SPI driver to check if any data is ready to send.
  148. *
  149. * input parameters
  150. *
  151. * None.
  152. *
  153. * output parameters
  154. *
  155. * None.
  156. *
  157. * @return TRUE if data is ready to send; FALSE otherwise.
  158. **************************************************************************************************
  159. */
  160. extern bool npSpiReadyCallback(void);
  161. /**************************************************************************************************
  162. * @fn npSpiSRspAlloc
  163. *
  164. * @brief This function is called by MT to allocate a buffer in which to build an SRSP frame.
  165. * MT must only call this function after processing a received SREQ frame.
  166. *
  167. * input parameters
  168. *
  169. * @param len - Length of the buffer required.
  170. *
  171. * output parameters
  172. *
  173. * None.
  174. *
  175. * @return NULL for failure; a pointer to the npSpiBuf on success. Success is determined by
  176. * the correct npSpiState and H/W signals as well as a valid length request.
  177. **************************************************************************************************
  178. */
  179. extern uint8 *npSpiSRspAlloc(uint8 len);
  180. /**************************************************************************************************
  181. * @fn npSpiAReqAlloc
  182. *
  183. * @brief This function is called by MT to allocate a buffer in which to buld an AREQ frame.
  184. *
  185. * input parameters
  186. *
  187. * @param len - Length of the buffer required.
  188. *
  189. * output parameters
  190. *
  191. * None.
  192. *
  193. * @return NULL for failure; otherwise a pointer to the data of an osal message.
  194. **************************************************************************************************
  195. */
  196. extern uint8 *npSpiAReqAlloc(uint8 len);
  197. /**************************************************************************************************
  198. * @fn npSpiSRspReady
  199. *
  200. * @brief This function is called by MT to notify SPI driver that an SRSP is ready to Tx.
  201. *
  202. * input parameters
  203. *
  204. * @param pBuf - Pointer to the buffer to transmit on the SPI.
  205. *
  206. * output parameters
  207. *
  208. * None.
  209. *
  210. * @return None.
  211. **************************************************************************************************
  212. */
  213. extern void npSpiSRspReady(uint8 *pBuf);
  214. /**************************************************************************************************
  215. * @fn npSpiAReqReady
  216. *
  217. * @brief This function is called by MT to notify the SPI driver that an AREQ frame is ready
  218. * to be transmitted.
  219. *
  220. * input parameters
  221. *
  222. * None.
  223. *
  224. * output parameters
  225. *
  226. * None.
  227. *
  228. * @return None.
  229. **************************************************************************************************
  230. */
  231. extern void npSpiAReqReady(void);
  232. /**************************************************************************************************
  233. * @fn npSpiAReqComplete
  234. *
  235. * @brief This function is called by MT to notify the SPI driver that the processing of a
  236. * received AREQ is complete.
  237. *
  238. * input parameters
  239. *
  240. * None.
  241. *
  242. * output parameters
  243. *
  244. * None.
  245. *
  246. * @return None.
  247. **************************************************************************************************
  248. */
  249. extern void npSpiAReqComplete(void);
  250. /**************************************************************************************************
  251. * @fn npSpiGetReqBuf
  252. *
  253. * @brief This function is called by the application to get the buffer containing the
  254. * currently received AREQ or SREQ.
  255. *
  256. * input parameters
  257. *
  258. * None.
  259. *
  260. * output parameters
  261. *
  262. * None.
  263. *
  264. * @return Pointer to the buffer containing the currently received AREQ or SREQ.
  265. **************************************************************************************************
  266. */
  267. extern uint8 *npSpiGetReqBuf(void);
  268. /**************************************************************************************************
  269. * @fn npSpiMrdyIsr
  270. *
  271. * @brief This function is called when a GPIO falling-edge interrupt occurs on the MRDY.
  272. *
  273. * input parameters
  274. *
  275. * None.
  276. *
  277. * output parameters
  278. *
  279. * None.
  280. *
  281. * @return None.
  282. **************************************************************************************************
  283. */
  284. void npSpiMrdyIsr(void);
  285. /**************************************************************************************************
  286. * @fn npSpiIdle
  287. *
  288. * @brief This function returns true if SPI is idle and there is no queued data.
  289. *
  290. * input parameters
  291. *
  292. * None.
  293. *
  294. * output parameters
  295. *
  296. * None.
  297. *
  298. * @return True if SPI is idle with no quequed data.
  299. **************************************************************************************************
  300. */
  301. bool npSpiIdle(void);
  302. /**************************************************************************************************
  303. */
  304. #ifdef __cplusplus
  305. };
  306. #endif
  307. #endif