Spi.h 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232
  1. /**
  2. * @file Spi.h
  3. *
  4. * @version 1.0.0
  5. *
  6. * @brief AUTOSAR Spi - Spi driver header file.
  7. * @details AUTOSAR specific Spi driver header file.
  8. * @addtogroup SPI_DRIVER Spi Driver
  9. * @{
  10. */
  11. /*==================================================================================================
  12. * Project : RTD AUTOSAR 4.4
  13. * Platform : CORTEXM
  14. * Peripheral : LPSPI
  15. * Dependencies :
  16. *
  17. * Autosar Version : 4.4.0
  18. * Autosar Revision : ASR_REL_4_4_REV_0000
  19. * Autosar Conf.Variant :
  20. * SW Version : 1.0.0
  21. * Build Version : S32K1_RTD_1_0_0_HF01_D2109_ASR_REL_4_4_REV_0000_20210907
  22. *
  23. * (c) Copyright 2020-2021 NXP Semiconductors
  24. * All Rights Reserved.
  25. *
  26. * NXP Confidential. This software is owned or controlled by NXP and may only be
  27. * used strictly in accordance with the applicable license terms. By expressly
  28. * accepting such terms or by downloading, installing, activating and/or otherwise
  29. * using the software, you are agreeing that you have read, and that you agree to
  30. * comply with and are bound by, such license terms. If you do not agree to be
  31. * bound by the applicable license terms, then you may not retain, install,
  32. * activate or otherwise use the software.
  33. ==================================================================================================*/
  34. #ifndef SPI_H
  35. #define SPI_H
  36. #ifdef __cplusplus
  37. extern "C"
  38. {
  39. #endif
  40. /*==================================================================================================
  41. * INCLUDE FILES
  42. * 1) system and project includes
  43. * 2) needed interfaces from external units
  44. * 3) internal and external interfaces from this unit
  45. ==================================================================================================*/
  46. #include "StandardTypes.h"
  47. #include "Mcal.h"
  48. #include "Spi_Cfg.h"
  49. #include "Spi_IPW_Types.h"
  50. /*==================================================================================================
  51. * SOURCE FILE VERSION INFORMATION
  52. ==================================================================================================*/
  53. #define SPI_MODULE_ID 83
  54. #define SPI_VENDOR_ID 43
  55. #define SPI_AR_RELEASE_MAJOR_VERSION 4
  56. #define SPI_AR_RELEASE_MINOR_VERSION 4
  57. #define SPI_AR_RELEASE_REVISION_VERSION 0
  58. #define SPI_SW_MAJOR_VERSION 1
  59. #define SPI_SW_MINOR_VERSION 0
  60. #define SPI_SW_PATCH_VERSION 0
  61. /*==================================================================================================
  62. * FILE VERSION CHECKS
  63. ==================================================================================================*/
  64. /* Check if this header file and Spi_Cfg.h are of the same vendor */
  65. #if (SPI_VENDOR_ID != SPI_VENDOR_ID_CFG)
  66. #error "Spi.h and Spi_Cfg.h have different vendor ids"
  67. #endif
  68. /* Check if source file and SPI header file are of the same Autosar version */
  69. #if ((SPI_AR_RELEASE_MAJOR_VERSION != SPI_AR_RELEASE_MAJOR_VERSION_CFG) || \
  70. (SPI_AR_RELEASE_MINOR_VERSION != SPI_AR_RELEASE_MINOR_VERSION_CFG) || \
  71. (SPI_AR_RELEASE_REVISION_VERSION != SPI_AR_RELEASE_REVISION_VERSION_CFG))
  72. #error "AutoSar Version Numbers of Spi.h and Spi_Cfg.h are different"
  73. #endif
  74. /* Check if current file and Spi_Cfg header file are of the same Software version */
  75. #if ((SPI_SW_MAJOR_VERSION != SPI_SW_MAJOR_VERSION_CFG) || \
  76. (SPI_SW_MINOR_VERSION != SPI_SW_MINOR_VERSION_CFG) || \
  77. (SPI_SW_PATCH_VERSION != SPI_SW_PATCH_VERSION_CFG))
  78. #error "Software Version Numbers of Spi.h and Spi_Cfg.h are different"
  79. #endif
  80. /* Check if this header file and Spi_IPW_Types.h are of the same vendor */
  81. #if (SPI_VENDOR_ID != SPI_IPW_TYPES_VENDOR_ID)
  82. #error "Spi.h and Spi_IPW_Types.h have different vendor ids"
  83. #endif
  84. /* Check if current file and Spi_IPW_Types header file are of the same Autosar version */
  85. #if ((SPI_AR_RELEASE_MAJOR_VERSION != SPI_IPW_TYPES_AR_RELEASE_MAJOR_VERSION) || \
  86. (SPI_AR_RELEASE_MINOR_VERSION != SPI_IPW_TYPES_AR_RELEASE_MINOR_VERSION) || \
  87. (SPI_AR_RELEASE_REVISION_VERSION != SPI_IPW_TYPES_AR_RELEASE_REVISION_VERSION))
  88. #error "AutoSar Version Numbers of Spi.h and Spi_IPW_Types.h are different"
  89. #endif
  90. /* Check if current file and Spi_IPW_Types header file are of the same Software version */
  91. #if ((SPI_SW_MAJOR_VERSION != SPI_IPW_TYPES_SW_MAJOR_VERSION) || \
  92. (SPI_SW_MINOR_VERSION != SPI_IPW_TYPES_SW_MINOR_VERSION) || \
  93. (SPI_SW_PATCH_VERSION != SPI_IPW_TYPES_SW_PATCH_VERSION))
  94. #error "Software Version Numbers of Spi.h and Spi_IPW_Types.h are different"
  95. #endif
  96. #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
  97. /* Check if current file and StandardTypes header file are of the same Autosar version */
  98. #if ((SPI_AR_RELEASE_MAJOR_VERSION != STD_AR_RELEASE_MAJOR_VERSION) || \
  99. (SPI_AR_RELEASE_MINOR_VERSION != STD_AR_RELEASE_MINOR_VERSION))
  100. #error "AutoSar Version Numbers of Spi.h and StandardTypes.h are different"
  101. #endif
  102. /* Check if current file and Mcal header file are of the same Autosar version */
  103. #if ((SPI_AR_RELEASE_MAJOR_VERSION != MCAL_AR_RELEASE_MAJOR_VERSION) || \
  104. (SPI_AR_RELEASE_MINOR_VERSION != MCAL_AR_RELEASE_MINOR_VERSION))
  105. #error "AutoSar Version Numbers of Spi.h and Mcal.h are different"
  106. #endif
  107. #endif
  108. /*==================================================================================================
  109. * CONSTANTS
  110. ==================================================================================================*/
  111. /*==================================================================================================
  112. * DEFINES AND MACROS
  113. ==================================================================================================*/
  114. #define SPI_PHYUNIT_ASYNC_U32 ((uint32)0u)
  115. /** @brief Define state of hardware unit for synchronous transmission. */
  116. #define SPI_PHYUNIT_SYNC_U32 ((uint32)1u)
  117. /* Error Values */
  118. /**
  119. * @brief API service called with wrong parameter of Channel.
  120. *
  121. */
  122. /** @implements Spi_ErrorCodes_define */
  123. #define SPI_E_PARAM_CHANNEL ((uint8)0x0Au)
  124. /**
  125. * @brief API service called with wrong parameter of Job.
  126. *
  127. */
  128. /** @implements Spi_ErrorCodes_define */
  129. #define SPI_E_PARAM_JOB ((uint8)0x0Bu)
  130. /**
  131. * @brief API service called with wrong parameter of Sequence.
  132. *
  133. */
  134. /** @implements Spi_ErrorCodes_define */
  135. #define SPI_E_PARAM_SEQ ((uint8)0x0Cu)
  136. /**
  137. * @brief API service called with wrong parameter of external buffer length.
  138. *
  139. */
  140. /** @implements Spi_ErrorCodes_define */
  141. #define SPI_E_PARAM_LENGTH ((uint8)0x0Du)
  142. /**
  143. * @brief API service called with wrong parameter of HWUnit.
  144. *
  145. */
  146. /** @implements Spi_ErrorCodes_define */
  147. #define SPI_E_PARAM_UNIT ((uint8)0x0Eu)
  148. /**
  149. * @brief API service called with wrong resource assigned.
  150. *
  151. */
  152. /** @implements Spi_ErrorCodes_define */
  153. #define SPI_E_PARAM_CONFIG ((uint8)0x0Fu)
  154. /**
  155. * @brief API service used without module initialization.
  156. *
  157. */
  158. /** @implements Spi_ErrorCodes_define */
  159. #define SPI_E_UNINIT ((uint8)0x1Au)
  160. /**
  161. * @brief Services called in a wrong sequence.
  162. *
  163. */
  164. /** @implements Spi_ErrorCodes_define */
  165. #define SPI_E_SEQ_PENDING ((uint8)0x2Au)
  166. /**
  167. * @brief Synchronous transmission service called at wrong time.
  168. *
  169. */
  170. /** @implements Spi_ErrorCodes_define */
  171. #define SPI_E_SEQ_IN_PROCESS ((uint8)0x3Au)
  172. /**
  173. * @brief API SPI_Init service called while the SPI driver has already been initialized.
  174. *
  175. */
  176. /** @implements Spi_ErrorCodes_define */
  177. #define SPI_E_ALREADY_INITIALIZED ((uint8)0x4Au)
  178. /**
  179. * @brief The number of sequences, jobs or channels exceeds precompile time sizes.
  180. * @details The number of sequences, jobs or channels in the configuration
  181. * exceeds precompile time related sizes:
  182. * SPI_MAX_SEQUENCE, SPI_MAX_JOB or SPI_MAX_CHANNEL.
  183. *
  184. */
  185. /** @implements Spi_ErrorCodes_define */
  186. #define SPI_E_CONFIG_OUT_OF_RANGE ((uint8)0x5Au)
  187. /**
  188. * @brief API Spi_Init was called with wrong configuration pointer.
  189. *
  190. */
  191. /** @implements Spi_ErrorCodes_define */
  192. #define SPI_E_INIT_FAILED ((uint8)0x6Au)
  193. /**
  194. * @brief When a sequence contains uninitialized external buffers.
  195. *
  196. */
  197. /** @implements Spi_ErrorCodes_define */
  198. #define SPI_E_PARAM_EB_UNIT ((uint8)0x5Bu)
  199. /**
  200. * @brief No job in sequence.
  201. *
  202. */
  203. /** @implements Spi_ErrorCodes_define */
  204. #define SPI_E_SEQ_EMPTY ((uint8)0x5Cu)
  205. /**
  206. * @brief No channel in job.
  207. *
  208. */
  209. /** @implements Spi_ErrorCodes_define */
  210. #define SPI_E_JOB_EMPTY ((uint8)0x5Du)
  211. /**
  212. * @brief If the parameter versioninfo or Spi configuration is NULL_PTR.
  213. *
  214. */
  215. /** @implements Spi_ErrorCodes_define */
  216. #define SPI_E_PARAM_POINTER ((uint8)0x10u)
  217. #define SPI_CHANNEL_FLAG_TX_DEFAULT_U8 ((uint8) 0x01u)
  218. #define SPI_CHANNEL_FLAG_RX_DISCARD_U8 ((uint8) 0x02u)
  219. #define SPI_E_INVALID_POINTER ((uint8)0x6Fu)
  220. #define SPI_E_HWUNIT_BUSY ((uint8)0x7Fu)
  221. /* Service IDs */
  222. /**
  223. * @brief API service ID for SPI Init function.
  224. * @details Parameters used when raising an error or exception.
  225. *
  226. */
  227. /** @implements Spi_ServiceIds_define */
  228. #define SPI_INIT_ID ((uint8) 0x00u)
  229. /**
  230. * @brief API service ID for SPI DeInit function.
  231. * @details Parameters used when raising an error or exception.
  232. *
  233. */
  234. /** @implements Spi_ServiceIds_define */
  235. #define SPI_DEINIT_ID ((uint8) 0x01u)
  236. /**
  237. * @brief API service ID for SPI write IB function.
  238. * @details Parameters used when raising an error or exception.
  239. *
  240. */
  241. /** @implements Spi_ServiceIds_define */
  242. #define SPI_WRITEIB_ID ((uint8) 0x02u)
  243. /**
  244. * @brief API service ID for SPI async transmit function.
  245. * @details Parameters used when raising an error or exception.
  246. *
  247. */
  248. /** @implements Spi_ServiceIds_define */
  249. #define SPI_ASYNCTRANSMIT_ID ((uint8) 0x03u)
  250. /**
  251. * @brief API service ID for SPI read IB function.
  252. * @details Parameters used when raising an error or exception.
  253. *
  254. */
  255. /** @implements Spi_ServiceIds_define */
  256. #define SPI_READIB_ID ((uint8) 0x04u)
  257. /**
  258. * @brief API service ID for SPI setup EB function.
  259. * @details Parameters used when raising an error or exception.
  260. *
  261. */
  262. /** @implements Spi_ServiceIds_define */
  263. #define SPI_SETUPEB_ID ((uint8) 0x05u)
  264. /**
  265. * @brief API service ID for SPI get status function.
  266. * @details Parameters used when raising an error or exception.
  267. *
  268. */
  269. /** @implements Spi_ServiceIds_define */
  270. #define SPI_GETSTATUS_ID ((uint8) 0x06u)
  271. /**
  272. * @brief API service ID for SPI get job result function.
  273. * @details Parameters used when raising an error or exception.
  274. *
  275. */
  276. /** @implements Spi_ServiceIds_define */
  277. #define SPI_GETJOBRESULT_ID ((uint8) 0x07u)
  278. /**
  279. * @brief API service ID for SPI get sequence result function.
  280. * @details Parameters used when raising an error or exception.
  281. *
  282. */
  283. /** @implements Spi_ServiceIds_define */
  284. #define SPI_GETSEQUENCERESULT_ID ((uint8) 0x08u)
  285. /**
  286. * @brief API service ID for SPI get version info function.
  287. * @details Parameters used when raising an error or exception.
  288. *
  289. */
  290. /** @implements Spi_ServiceIds_define */
  291. #define SPI_GETVERSIONINFO_ID ((uint8) 0x09u)
  292. /**
  293. * @brief API service ID for SPI sync transmit function.
  294. * @details Parameters used when raising an error or exception.
  295. *
  296. */
  297. /** @implements Spi_ServiceIds_define */
  298. #define SPI_SYNCTRANSMIT_ID ((uint8) 0x0Au)
  299. /**
  300. * @brief API service ID for SPI get hwunit status function.
  301. * @details Parameters used when raising an error or exception.
  302. *
  303. */
  304. /** @implements Spi_ServiceIds_define */
  305. #define SPI_GETHWUNITSTATUS_ID ((uint8) 0x0Bu)
  306. /**
  307. * @brief API service ID for SPI cancel function.
  308. * @details Parameters used when raising an error or exception.
  309. *
  310. */
  311. /** @implements Spi_ServiceIds_define */
  312. #define SPI_CANCEL_ID ((uint8) 0x0Cu)
  313. /**
  314. * @brief API service ID for SPI set async mode function.
  315. * @details Parameters used when raising an error or exception.
  316. *
  317. */
  318. /** @implements Spi_ServiceIds_define */
  319. #define SPI_SETASYNCMODE_ID ((uint8) 0x0Du)
  320. /**
  321. * @brief API service ID for SPI main function
  322. * @details Parameters used when raising an error or exception
  323. *
  324. * @implements Spi_ServiceIds_define
  325. */
  326. #define SPI_MAINFUNCTION_HANDLING_ID ((uint8)0x10u)
  327. /**
  328. * @brief API service ID for SPI set HW Unit async mode.
  329. * @details Parameters used when raising an error or exception.
  330. *
  331. */
  332. /** @implements Spi_ServiceIds_define */
  333. #define SPI_SETHWUNITASYNCMODE_ID ((uint8)0x80u)
  334. /**
  335. * @brief API service ID for SPI Set Clock Mode.
  336. * @details Parameters used when raising an error or exception.
  337. *
  338. */
  339. /** @implements Spi_ServiceIds_define */
  340. #define SPI_SETCLOCKMODE_ID ((uint8)0x81u)
  341. #if ((SPI_LEVEL_DELIVERED == LEVEL1) || (SPI_LEVEL_DELIVERED == LEVEL2))
  342. /**
  343. * @brief The number of allowed job priority levels (0..3).
  344. * @details The Priority has to be sint8.
  345. *
  346. */
  347. #define SPI_JOB_PRIORITY_LEVELS_COUNT (4)
  348. #endif /* ((SPI_LEVEL_DELIVERED == LEVEL1) || (SPI_LEVEL_DELIVERED == LEVEL2)) */
  349. /*==================================================================================================
  350. * ENUMS
  351. ==================================================================================================*/
  352. /**
  353. * @brief This type defines a range of specific status for SPI Driver.
  354. *
  355. * @implements Spi_StatusType_enum
  356. */
  357. typedef enum
  358. {
  359. SPI_UNINIT = 0, /**< @brief Not initialized or not usable. */
  360. SPI_IDLE, /**< @brief Not currently transmitting any jobs. */
  361. SPI_BUSY /**< @brief Is performing a SPI Job(transmit). */
  362. } Spi_StatusType;
  363. /**
  364. * @brief This type defines a range of specific Jobs status for SPI Driver.
  365. *
  366. * @implements Spi_JobResultType_enum
  367. */
  368. typedef enum
  369. {
  370. SPI_JOB_OK = 0, /**< @brief The last transmission of the Job has been finished successfully. */
  371. SPI_JOB_PENDING, /**< @brief The SPI handler/Driver is performing a SPI Job. */
  372. SPI_JOB_FAILED, /**< @brief The last transmission of the Job has failed. */
  373. SPI_JOB_QUEUED /**< @brief An asynchronous transmit Job has been accepted, while actual
  374. transmission for this Job has not started yet. */
  375. } Spi_JobResultType;
  376. /**
  377. * @brief This type defines a range of specific Sequences status for SPI Driver.
  378. *
  379. * @implements Spi_SeqResultType_enum
  380. */
  381. typedef enum
  382. {
  383. SPI_SEQ_OK = 0, /**< @brief The last transmission of the Sequence has been finished successfully. */
  384. SPI_SEQ_PENDING, /**< @brief The SPI handler/Driver is performing a SPI Sequence. */
  385. SPI_SEQ_FAILED, /**< @brief The last transmission of the Sequence has failed. */
  386. SPI_SEQ_CANCELLED /**< @brief The last transmission of the Sequence has been cancelled by the user. */
  387. } Spi_SeqResultType;
  388. /**
  389. * @brief The enumeration containing the designated values for buffer types (internal or external).
  390. *
  391. */
  392. typedef enum
  393. {
  394. IB = 0, /**< @brief The Channel is configured using Internal Buffer. */
  395. EB /**< @brief The Channel is configured using External Buffer. */
  396. } Spi_BufferType;
  397. /**
  398. * @brief Specifies the asynchronous mechanism mode for SPI buses handled asynchronously in Level 2
  399. * @details #if (LEVEL2 == SPI_LEVEL_DELIVERED)
  400. * Specifies the asynchronous mechanism mode for SPI buses handled
  401. * asynchronously in LEVEL 2. SPI150: This type is available or not
  402. * according to the pre compile time parameter:
  403. * SPI_LEVEL_DELIVERED. This is only relevant for LEVEL 2.
  404. *
  405. * @implements Spi_AsyncModeType_enum
  406. */
  407. typedef enum
  408. {
  409. /** @brief The asynchronous mechanism is ensured by polling, so interrupts
  410. related to SPI buses handled asynchronously are disabled. */
  411. SPI_POLLING_MODE = 0,
  412. /** @brief The asynchronous mechanism is ensured by interrupt, so interrupts
  413. related to SPI buses handled asynchronously are enabled. */
  414. SPI_INTERRUPT_MODE
  415. } Spi_AsyncModeType;
  416. #if (SPI_DUAL_CLOCK_MODE == STD_ON)
  417. /**
  418. * @brief Specifies the Clock Modes.
  419. *
  420. * @implements Spi_DualClockMode_enum
  421. */
  422. typedef enum
  423. {
  424. SPI_NORMAL = 0, /**< @brief Clock reference is from SpiClockRef. */
  425. SPI_ALTERNATE /**< @brief Clock reference is from SpiAlternateClockRef. */
  426. }Spi_DualClockModeType;
  427. #endif
  428. #ifdef SPI_HALF_DUPLEX_MODE_SUPPORT
  429. #if (STD_ON == SPI_HALF_DUPLEX_MODE_SUPPORT)
  430. /**
  431. * @brief Half duplex mode.
  432. */
  433. typedef enum
  434. {
  435. SPI_HALF_DUPLEX_TRANSMIT = 0, /**< Transmit only. */
  436. SPI_HALF_DUPLEX_RECEIVE = 1, /**< Receive only. */
  437. SPI_FULL_DUPLEX = 2 /**< Full duplex mode. */
  438. }Spi_HalfDuplexModeType;
  439. #endif
  440. #endif
  441. /*==================================================================================================
  442. * STRUCTURES AND OTHER TYPEDEFS
  443. ==================================================================================================*/
  444. /*---------------------------------------------------------------------------
  445. * SPI Driver AUTOSAR Related Type Definitions
  446. -----------------------------------------------------------------------------*/
  447. /**
  448. * @brief Type of application data buffer elements.
  449. */
  450. /**
  451. * @implements Spi_DataBufferType_typedef
  452. */
  453. typedef uint8 Spi_DataBufferType;
  454. /**
  455. * @brief Type for defining the number of data elements of the type Spi_DataBufferType.
  456. * @details Type for defining the number of data elements of the type Spi_DataBufferType
  457. * to send or receive by Channel.
  458. *
  459. * @implements Spi_NumberOfDataType_typedef
  460. */
  461. typedef uint16 Spi_NumberOfDataType;
  462. #if (SPI_ALLOW_BIGSIZE_COLLECTIONS == STD_ON)
  463. /**
  464. * @brief Specifies the identification (ID) for a Channel.
  465. *
  466. * @implements Spi_ChannelType_typedef
  467. */
  468. typedef uint32 Spi_ChannelType;
  469. /**
  470. * @brief Specifies the identification (ID) for a Job.
  471. *
  472. * @implements Spi_JobType_typedef
  473. */
  474. typedef uint32 Spi_JobType;
  475. /**
  476. * @brief Specifies the identification (ID) for a sequence of jobs.
  477. *
  478. * @implements Spi_SequenceType_typedef
  479. */
  480. typedef uint32 Spi_SequenceType;
  481. #else
  482. /**
  483. * @brief Specifies the identification (ID) for a Channel.
  484. *
  485. * @implements Spi_ChannelType_typedef
  486. */
  487. typedef uint8 Spi_ChannelType;
  488. /**
  489. * @brief Specifies the identification (ID) for a Job.
  490. *
  491. * @implements Spi_JobType_typedef.
  492. */
  493. typedef uint16 Spi_JobType;
  494. /**
  495. * @brief Specifies the identification (ID) for a sequence of jobs.
  496. *
  497. * @implements Spi_SequenceType_typedef.
  498. */
  499. typedef uint8 Spi_SequenceType;
  500. #endif
  501. /**
  502. * @brief Specifies the ID for a SPI Hardware microcontroller peripheral unit.
  503. * @details This type is used for specifying the identification (ID) for a SPI
  504. * Hardware microcontroller peripheral unit.
  505. *
  506. * @implements Spi_HWUnitType_typedef
  507. */
  508. typedef uint8 Spi_HWUnitType;
  509. /**
  510. * @brief Contains the ID of an external device.
  511. * @details This contains the identification (ID) of the external device for which
  512. * there's a collection of particular settings
  513. *
  514. */
  515. typedef uint8 Spi_ExternalDeviceType;
  516. typedef void (Spi_NotifyType) (void);
  517. /**
  518. * @brief This structure contains all the needed data to configure one SPI Sequence.
  519. *
  520. * @implements Spi_SequenceConfigType_struct
  521. */
  522. typedef struct
  523. {
  524. /** @brief Number of jobs in the sequence. */
  525. Spi_JobType NumJobs;
  526. /** @brief CoreID used */
  527. uint32 SpiCoreUse;
  528. /** @brief Job index list. */
  529. const Spi_JobType *JobIndexList;
  530. /** @brief Job notification handler. */
  531. Spi_NotifyType (*EndNotification);
  532. /** @brief Boolean indicating if the Sequence is interruptible or not. */
  533. uint8 Interruptible;
  534. #if ((SPI_DMA_USED == STD_ON) && (SPI_ENABLE_DMAFASTTRANSFER_SUPPORT == STD_ON))
  535. /** @brief Boolean indicating if the Sequence is transferred in Dma fast mode or not. */
  536. boolean EnableDmaFastTransfer;
  537. #endif
  538. } Spi_SequenceConfigType;
  539. /**
  540. * @brief This structure contains Sequence configuration.
  541. */
  542. typedef struct
  543. {
  544. /** @brief Point to Sequence configuration. */
  545. const Spi_SequenceConfigType *SeqConfig;
  546. } Spi_SeqsConfigType;
  547. /**
  548. * @brief Internal structure used to manage the sequence state.
  549. *
  550. * @implements Spi_SequenceStateType_struct
  551. */
  552. typedef struct
  553. {
  554. /** @brief Sequence Result. */
  555. Spi_SeqResultType Result;
  556. #if ((SPI_LEVEL_DELIVERED == LEVEL1) || (SPI_LEVEL_DELIVERED == LEVEL2))
  557. /** @brief Pointer to the configuration. */
  558. const Spi_SequenceConfigType *Sequence;
  559. /** @brief Position in JobIndexList to the job in transmission of an async sequence. */
  560. const Spi_JobType *CurrentJobIndexPointer;
  561. /** @brief Number of jobs in a pending async sequence, not yet transmitted. */
  562. Spi_JobType RemainingJobs;
  563. #endif
  564. } Spi_SequenceStateType;
  565. /**
  566. * @brief Internal structure used to manage the job state.
  567. *
  568. */
  569. typedef struct
  570. {
  571. /** @brief Job Result. */
  572. Spi_JobResultType Result;
  573. #if ((SPI_LEVEL_DELIVERED == LEVEL1) || (SPI_LEVEL_DELIVERED == LEVEL2))
  574. /** @brief Pointer to the state information of the async sequence. */
  575. Spi_SequenceStateType *AsyncCrtSequenceState;
  576. /** @brief Pointer to the next async job planned for transmission. */
  577. Spi_JobType AsyncNextJob;
  578. #endif
  579. } Spi_JobStateType;
  580. /**
  581. * @brief This is the structure containing all the parameters needed to completely define a Job.
  582. *
  583. * @implements Spi_JobConfigType_struct
  584. */
  585. typedef struct
  586. {
  587. /** @brief Number of channels in the job. */
  588. Spi_ChannelType NumChannels;
  589. /** @brief Channel index list. */
  590. const Spi_ChannelType *ChannelIndexList;
  591. /** @brief Job end notification. */
  592. Spi_NotifyType (*EndNotification);
  593. /** @brief Job start notification. */
  594. Spi_NotifyType (*StartNotification);
  595. /** @brief Priority. */
  596. sint8 Priority;
  597. /** @brief CoreID used */
  598. uint32 SpiCoreUse;
  599. /** @brief Implementation specific field referencing the channel internal state. */
  600. Spi_JobStateType *JobState;
  601. /** @brief HWUnit. */
  602. Spi_HWUnitType HWUnit;
  603. /** @brief ExternalDevice. */
  604. Spi_ExternalDeviceType ExternalDevice;
  605. /** @brief Implementation specific field: cached LLD device attributes. */
  606. const Spi_ExDevicesConfigType *ExternalDeviceConfig;
  607. } Spi_JobConfigType;
  608. /**
  609. * @brief This is the structure containing Job configuration.
  610. */
  611. typedef struct
  612. {
  613. /** @brief Point to Job configuration. */
  614. const Spi_JobConfigType *JobCfg;
  615. } Spi_JobsCfgType;
  616. /**
  617. * @brief The structure contains the pointers to the Tx/Rx memory locations for the given buffer (IB or EB).
  618. *
  619. */
  620. typedef struct
  621. {
  622. /** @brief Transmit buffer pointer. */
  623. Spi_DataBufferType *BufferTX;
  624. /** @brief Receive buffer pointer. */
  625. Spi_DataBufferType *BufferRX;
  626. } Spi_BufferDescriptorType;
  627. /**
  628. * @brief Internal structure used to manage the channel state.
  629. *
  630. */
  631. typedef struct
  632. {
  633. uint8 Flags; /**< @brief Default Transmit Enabled. */
  634. Spi_NumberOfDataType Length; /**< @brief Actual Transfer size for EB. */
  635. } Spi_ChannelStateType;
  636. /**
  637. * @brief This structure holds the HWUnit scheduling queue.
  638. * @details For async transmissions, this structure holds the HWUnit scheduling queue .
  639. * For sync transmissions, only HWUnit Status is managed.
  640. *
  641. */
  642. typedef struct
  643. {
  644. #if ((SPI_LEVEL_DELIVERED == LEVEL1) || (SPI_LEVEL_DELIVERED == LEVEL2))
  645. /** @brief Array of the IDs of jobs to be scheduled, for each priority level. */
  646. Spi_JobType ScheduledJobsListHead[SPI_JOB_PRIORITY_LEVELS_COUNT];
  647. /** @brief Array of the IDs of last jobs in queues, for each priority level. */
  648. Spi_JobType ScheduledJobsListTail[SPI_JOB_PRIORITY_LEVELS_COUNT];
  649. /** @brief Array of the IDs of last jobs in queues, for each priority level. */
  650. sint8 MaxScheduledPriority;
  651. #endif /* ((SPI_LEVEL_DELIVERED == LEVEL1) || (SPI_LEVEL_DELIVERED == LEVEL2)) */
  652. Spi_StatusType Status; /**< @brief DSPI state. */
  653. Spi_ChannelType Channel; /**< Current channel index in Job */
  654. Spi_JobType Job; /**< Current job index */
  655. } Spi_HWUnitQueue;
  656. /**
  657. * @brief The structure contains the channel configuration parameters.
  658. *
  659. * @implements Spi_ChannelConfigType_struct
  660. */
  661. typedef struct
  662. {
  663. /** @brief Buffer Type IB/EB. */
  664. Spi_BufferType BufferType;
  665. /** @brief Data frame size. */
  666. uint8 FrameSize;
  667. /** @brief Bite order (MSB/LSB). */
  668. boolean Lsb;
  669. #ifdef SPI_HALF_DUPLEX_MODE_SUPPORT
  670. #if (STD_ON == SPI_HALF_DUPLEX_MODE_SUPPORT)
  671. /** @brief Half duplex mode. */
  672. Spi_HalfDuplexModeType HalfDuplexMode;
  673. #endif
  674. #endif
  675. /** @brief Default Transmit Value. */
  676. uint32 DefaultTransmitValue;
  677. /** @brief Data length. */
  678. Spi_NumberOfDataType Length;
  679. /** @brief Buffer Descriptor. */
  680. Spi_BufferDescriptorType *BufferDescriptor;
  681. /** @brief CoreID assigned */
  682. uint32 SpiCoreUse;
  683. /** @brief Implementation specific field referencing the channel internal state. */
  684. Spi_ChannelStateType *ChannelState;
  685. } Spi_ChannelConfigType;
  686. /**
  687. * @brief The structure contains the channel configuration.
  688. */
  689. typedef struct
  690. {
  691. /** @brief Point to Channel configuration. */
  692. const Spi_ChannelConfigType *ChannelCfg;
  693. } Spi_ChannelsCfgType;
  694. /*---------------------------------------------------------------------------
  695. * SPI Driver Low Level Implementation Specific Type Definitions
  696. -----------------------------------------------------------------------------*/
  697. /*---------------------------------------------------------------------------
  698. * SPI Driver Configuration Main Structure
  699. -----------------------------------------------------------------------------*/
  700. /**
  701. * @brief This is the top level structure containing all the
  702. * needed parameters for the SPI Handler Driver.
  703. *
  704. * @implements Spi_ConfigType_struct
  705. */
  706. typedef struct
  707. {
  708. /** @brief Number of external devices defined in the configuration. */
  709. uint16 MaxExternalDevice;
  710. /** @brief Number of channels defined in the configuration. */
  711. Spi_ChannelType SpiMaxChannel;
  712. /** @brief Number of jobs defined in the configuration. */
  713. Spi_JobType SpiMaxJob;
  714. /** @brief Number of sequences defined in the configuration. */
  715. Spi_SequenceType SpiMaxSequence;
  716. /** @brief CoreID used */
  717. uint32 SpiCoreUse;
  718. /** @brief Pointer to Array of channels defined in the configuration. */
  719. const Spi_ChannelsCfgType *ChannelConfig;
  720. /** @brief Pointer to Array of jobs defined in the configuration. */
  721. const Spi_JobsCfgType *JobConfig;
  722. /** @brief Pointer to Array of sequences defined in the configuration. */
  723. const Spi_SeqsConfigType *SequenceConfig;
  724. /** @brief External device unit attributes. */
  725. const Spi_ExDevicesConfigType *ExternalDeviceConfig;
  726. /** @brief Pointer to Array of LLD DSPI device instances. */
  727. const Spi_PhyUnitsConfigType *HWUnitConfig;
  728. /** @brief SPI Driver DEM Error: SPI_E_HARDWARE_ERROR. */
  729. #if (SPI_DISABLE_DEM_REPORT_ERROR_STATUS == STD_OFF)
  730. const Mcal_DemErrorType SpiErrorHardwareCfg;
  731. #endif
  732. } Spi_ConfigType;
  733. /*==================================================================================================
  734. * GLOBAL VARIABLE DECLARATIONS
  735. ==================================================================================================*/
  736. #if (SPI_PRECOMPILE_SUPPORT == STD_OFF)
  737. #define SPI_START_SEC_CONFIG_DATA_UNSPECIFIED
  738. #include "Spi_MemMap.h"
  739. /**
  740. * @brief Export Post-Build configurations.
  741. */
  742. SPI_CONFIG_EXT
  743. #define SPI_STOP_SEC_CONFIG_DATA_UNSPECIFIED
  744. #include "Spi_MemMap.h"
  745. #endif /* (SPI_PRECOMPILE_SUPPORT == STD_OFF) */
  746. #define SPI_START_SEC_VAR_CLEARED_UNSPECIFIED
  747. #include "Spi_MemMap.h"
  748. extern const Spi_ConfigType *Spi_apxSpiConfigPtr[SPI_MAX_PARTITIONS];
  749. /**
  750. * @brief Extern arrays contain the state of Sequences, Jobs and Channels.
  751. */
  752. extern Spi_JobStateType Spi_axSpiJobState[SPI_MAX_JOB];
  753. extern Spi_ChannelStateType Spi_axSpiChannelState[SPI_MAX_CHANNEL];
  754. #define SPI_STOP_SEC_VAR_CLEARED_UNSPECIFIED
  755. #include "Spi_MemMap.h"
  756. /*==================================================================================================
  757. * FUNCTION PROTOTYPES
  758. ==================================================================================================*/
  759. #define SPI_START_SEC_CODE
  760. #include "Spi_MemMap.h"
  761. /**
  762. * @brief This function is called after a Job has been executed.
  763. * @details The function calls Job and Sequence end notifications and schedules
  764. * the next job of the sequence or on the liberated HW Unit.
  765. *
  766. * @param[in] JobConfig The just transmited job pointer.
  767. *
  768. * @return void
  769. *
  770. * @pre Pre-compile parameter SPI_LEVEL_DELIVERED shall be LEVEL1 or LEVEL2.
  771. *
  772. */
  773. #if ((LEVEL2 == SPI_LEVEL_DELIVERED) || (LEVEL1 == SPI_LEVEL_DELIVERED))
  774. extern void Spi_JobTransferFinished
  775. (
  776. const Spi_JobConfigType *JobConfig, Spi_JobResultType JobResult
  777. );
  778. #endif
  779. #if (SPI_VERSION_INFO_API == STD_ON)
  780. /**
  781. * @brief This function returns the version information for the SPI driver.
  782. * @details This function returns the version information for the SPI driver.
  783. * - Service ID: 0x09
  784. * - Sync or Async: Synchronous
  785. * - Reentrancy: Non-Reentrant
  786. *
  787. * @param[in,out] VersionInfo Pointer to where to store the version
  788. * information of this module.
  789. *
  790. * @pre Pre-compile parameter SPI_VERSION_INFO_API shall be STD_ON.
  791. * @return void
  792. */
  793. void Spi_GetVersionInfo
  794. (
  795. Std_VersionInfoType *versioninfo
  796. );
  797. #endif
  798. /**
  799. * @brief This function initializes the SPI driver.
  800. * @details This function initializes the SPI driver using the
  801. * pre-established configurations
  802. * - Service ID: 0x00
  803. * - Sync or Async: Synchronous
  804. * - Reentrancy: Non-Reentrant
  805. *
  806. * @param[in] ConfigPtr Specifies the pointer to the configuration set
  807. * @return void
  808. */
  809. void Spi_Init
  810. (
  811. const Spi_ConfigType *ConfigPtr
  812. );
  813. /**
  814. * @brief This function de-initializes the SPI driver.
  815. * @details This function de-initializes the SPI driver using the
  816. * pre-established configurations
  817. * - Service ID: 0x01
  818. * - Sync or Async: Synchronous
  819. * - Reentrancy: Non-Reentrant
  820. *
  821. * @return Std_ReturnType
  822. * @retval E_OK de-initialisation command has been accepted
  823. * @retval E_NOT_OK de-initialisation command has not been accepted
  824. *
  825. * @pre The driver needs to be initialized before calling Spi_DeInit()
  826. * otherwise, the function Spi_DeInit() shall raise the development error
  827. * if SPI_DEV_ERROR_DETECT is STD_ON.
  828. *
  829. */
  830. Std_ReturnType Spi_DeInit(void);
  831. #if ((USAGE0 == SPI_CHANNEL_BUFFERS_ALLOWED) || (USAGE2 == SPI_CHANNEL_BUFFERS_ALLOWED ))
  832. /**
  833. * @brief This function writes the given data into the buffer of a specific channel.
  834. * @details This function writes the given data into the buffer of a specific channel.
  835. * - Service ID: 0x02
  836. * - Sync or Async: Synchronous
  837. * - Reentrancy: Reentrant
  838. *
  839. * @param[in] Channel Channel ID
  840. * @param[in] DataBufferPtr Pointer to source data buffer
  841. *
  842. * @return Std_ReturnType
  843. * @retval E_OK Command has been accepted
  844. * @retval E_NOT_OK Command has not been accepted
  845. *
  846. * @pre The driver needs to be initialized before calling Spi_WriteIB()
  847. * otherwise, the function Spi_WriteIB() shall raise the development error
  848. * if SPI_DEV_ERROR_DETECT is STD_ON.
  849. * @pre Pre-compile parameter SPI_CHANNEL_BUFFERS_ALLOWED shall be USAGE0 or USAGE2.
  850. *
  851. */
  852. Std_ReturnType Spi_WriteIB
  853. (
  854. Spi_ChannelType Channel,
  855. const Spi_DataBufferType *DataBufferPtr
  856. );
  857. /**
  858. * @brief This function reads the data from the buffer of a channel and puts at the memory location.
  859. * @details This function reads the data from the buffer of a specific channel
  860. * and puts at the specified memory location.
  861. * - Service ID: 0x04
  862. * - Sync or Async: Synchronous
  863. * - Reentrancy: Reentrant
  864. *
  865. *
  866. * @param[in] Channel Channel ID
  867. * @param[in,out] DataBufferPointer Pointer to the memory location that will
  868. * be written with the data in the internal
  869. * buffer
  870. *
  871. * @return Std_ReturnType
  872. * @retval E_OK read command has been accepted
  873. * @retval E_NOT_OK read command has not been accepted
  874. *
  875. * @pre The driver needs to be initialized before calling Spi_ReadIB()
  876. * otherwise, the function Spi_ReadIB() shall raise the development error
  877. * if SPI_DEV_ERROR_DETECT is STD_ON.
  878. * @pre Pre-compile parameter SPI_CHANNEL_BUFFERS_ALLOWED shall be USAGE0 or USAGE2.
  879. *
  880. * @implements Spi_ReadIB_Activity
  881. */
  882. Std_ReturnType Spi_ReadIB
  883. (
  884. Spi_ChannelType Channel,
  885. Spi_DataBufferType *DataBufferPointer
  886. );
  887. #endif
  888. #if ((LEVEL2 == SPI_LEVEL_DELIVERED) || (LEVEL1 == SPI_LEVEL_DELIVERED))
  889. /**
  890. * @brief This function triggers the asynchronous transmission for the given sequence.
  891. * @details This function triggers the asynchronous transmission for the given sequence.
  892. * - Service ID: 0x03
  893. * - Sync or Async: Asynchronous
  894. * - Reentrancy: Reentrant
  895. *
  896. * @param[in] Sequence Sequence ID
  897. *
  898. * @return Std_ReturnType
  899. * @retval E_OK Transmission command has been accepted
  900. * @retval E_NOT_OK Transmission command has not been accepted
  901. *
  902. * @pre The driver needs to be initialized before calling Spi_AsyncTransmit()
  903. * otherwise, the function Spi_AsyncTransmit() shall raise the development error
  904. * if SPI_DEV_ERROR_DETECT is STD_ON.
  905. * @pre Pre-compile parameter SPI_LEVEL_DELIVERED shall be LEVEL1 or LEVEL2.
  906. */
  907. Std_ReturnType Spi_AsyncTransmit
  908. (
  909. Spi_SequenceType Sequence
  910. );
  911. #endif
  912. #if ( ( USAGE1 == SPI_CHANNEL_BUFFERS_ALLOWED) || \
  913. ( USAGE2 == SPI_CHANNEL_BUFFERS_ALLOWED) )
  914. /**
  915. * @brief This function setup an external buffer to be used by a specific channel.
  916. * @details This function setup an external buffer to be used by a specific channel.
  917. * - Service ID: 0x05
  918. * - Sync or Async: Synchronous
  919. * - Reentrancy: Reentrant
  920. *
  921. * @param[in] Channel Channel ID
  922. * @param[in] SrcDataBufferPtr Pointer to the memory location that will hold
  923. * the transmitted data
  924. * @param[in] Length Length of the data in the external buffer
  925. * @param[out] DesDataBufferPtr Pointer to the memory location that will hold
  926. * the received data
  927. *
  928. * @return Std_ReturnType
  929. * @retval E_OK Setup command has been accepted
  930. * @retval E_NOT_OK Setup command has not been accepted
  931. *
  932. * @pre The driver needs to be initialized before calling Spi_SetupEB()
  933. * otherwise, the function Spi_SetupEB() shall raise the development error
  934. * if SPI_DEV_ERROR_DETECT is STD_ON.
  935. * @pre Pre-compile parameter SPI_CHANNEL_BUFFERS_ALLOWED shall be USAGE1 or USAGE2.
  936. *
  937. */
  938. Std_ReturnType Spi_SetupEB
  939. (
  940. Spi_ChannelType Channel,
  941. Spi_DataBufferType *SrcDataBufferPtr,
  942. Spi_DataBufferType *DesDataBufferPtr,
  943. Spi_NumberOfDataType Length
  944. );
  945. #endif
  946. /**
  947. * @brief This function returns the status of the SPI driver.
  948. * @details This function returns the status of the SPI driver.
  949. * - Service ID: 0x06
  950. * - Sync or Async: Synchronous
  951. * - Reentrancy: Reentrant
  952. *
  953. * @return Spi_StatusType
  954. * @retval SPI_UNINIT The driver is un-initialized
  955. * @retval SPI_IDLE The driver has no pending transfers
  956. * @retval SPI_BUSY The driver is busy
  957. *
  958. * @pre The driver needs to be initialized before calling Spi_GetStatus()
  959. * otherwise, the function Spi_GetStatus() shall raise the development error
  960. * if SPI_DEV_ERROR_DETECT is STD_ON.
  961. */
  962. Spi_StatusType Spi_GetStatus(void);
  963. /**
  964. * @brief This function is used to request the status of a specific job.
  965. * @details This function is used to request the status of a specific job.
  966. * - Service ID: 0x07
  967. * - Sync or Async: Synchronous
  968. * - Reentrancy: Reentrant
  969. *
  970. * @param[in] Job Job ID
  971. *
  972. * @return Spi_JobResultType
  973. * @retval SPI_JOB_OK The job ended successfully
  974. * @retval SPI_JOB_PENDING The job is pending
  975. * @retval SPI_JOB_FAILED The job has failed
  976. *
  977. * @pre The driver needs to be initialized before calling Spi_GetJobResult()
  978. * otherwise, the function Spi_GetJobResult() shall raise the development error
  979. * if SPI_DEV_ERROR_DETECT is STD_ON.
  980. *
  981. * @implements Spi_GetJobResult_Activity
  982. */
  983. Spi_JobResultType Spi_GetJobResult
  984. (
  985. Spi_JobType Job
  986. );
  987. /**
  988. * @brief This function is used to request the status of a specific sequence.
  989. * @details This function is used to request the status of a specific sequence.
  990. * - Service ID: 0x08
  991. * - Sync or Async: Synchronous
  992. * - Reentrancy: Reentrant
  993. *
  994. * @param[in] Sequence Sequence ID
  995. *
  996. * @return Spi_SeqResultType
  997. * @retval SPI_SEQ_OK The sequence ended successfully
  998. * @retval SPI_SEQ_PENDING The sequence is pending
  999. * @retval SPI_SEQ_FAILED The sequence has failed
  1000. *
  1001. * @pre The driver needs to be initialized before calling Spi_GetSequenceResult()
  1002. * otherwise, the function Spi_GetSequenceResult() shall raise the development
  1003. * error if SPI_DEV_ERROR_DETECT is STD_ON.
  1004. */
  1005. Spi_SeqResultType Spi_GetSequenceResult
  1006. (
  1007. Spi_SequenceType Sequence
  1008. );
  1009. #if ((LEVEL2 == SPI_LEVEL_DELIVERED) || (LEVEL0 == SPI_LEVEL_DELIVERED))
  1010. /**
  1011. * @brief This function is used for synchronous transmission of a given sequence.
  1012. * @details This function is used for synchronous transmission of a given sequence.
  1013. * - Service ID: 0x0a
  1014. * - Sync or Async: Synchronous
  1015. * - Reentrancy: Reentrant
  1016. *
  1017. * @param[in] Sequence Sequence ID
  1018. *
  1019. * @return Std_ReturnType
  1020. * @retval E_OK Transmission command has been completed successfully
  1021. * @retval E_NOT_OK Transmission command has not been accepted
  1022. *
  1023. * @pre The driver needs to be initialized before calling Spi_SyncTransmit().
  1024. * otherwise, the function Spi_SyncTransmit() shall raise the development error
  1025. * if SPI_DEV_ERROR_DETECT is STD_ON.
  1026. * @pre Pre-compile parameter SPI_LEVEL_DELIVERED shall be LEVEL0 or LEVEL2
  1027. */
  1028. Std_ReturnType Spi_SyncTransmit
  1029. (
  1030. Spi_SequenceType Sequence
  1031. );
  1032. #endif
  1033. #if (SPI_HW_STATUS_API == STD_ON)
  1034. /**
  1035. * @brief This function is used to request the status of a specific SPI peripheral unit.
  1036. * @details This function is used to request the status of a specific SPI peripheral unit.
  1037. * - Service ID: 0x0b
  1038. * - Sync or Async: Synchronous
  1039. * - Reentrancy: Reentrant
  1040. *
  1041. * @param[in] HWUnit The HW peripheral for which we need the status
  1042. *
  1043. * @return Spi_StatusType
  1044. * @retval SPI_UNINIT The peripheral is un-initialized
  1045. * @retval SPI_IDLE The peripheral is in idle state
  1046. * @retval SPI_BUSY The peripheral is busy
  1047. *
  1048. * @pre The driver needs to be initialized before calling Spi_GetHWUnitStatus()
  1049. * otherwise, the function Spi_GetHWUnitStatus() shall raise the development
  1050. * error if SPI_DEV_ERROR_DETECT is STD_ON.
  1051. * @pre SPI_HW_STATUS_API == STD_ON
  1052. */
  1053. Spi_StatusType Spi_GetHWUnitStatus
  1054. (
  1055. Spi_HWUnitType HWUnit
  1056. );
  1057. #endif
  1058. #if (SPI_CANCEL_API == STD_ON)
  1059. /**
  1060. * @brief This function is used to request the cancelation of the given sequence.
  1061. * @details This function is used to request the cancelation of the given sequence.
  1062. * - Service ID: 0x0c
  1063. * - Sync or Async: Asynchronous
  1064. * - Reentrancy: Reentrant
  1065. *
  1066. * @param[in] Sequence Sequence ID
  1067. *
  1068. * @pre The driver needs to be initialized before calling Spi_Cancel()
  1069. * otherwise, the function Spi_Cancel() shall raise the development error
  1070. * if SPI_DEV_ERROR_DETECT is STD_ON.
  1071. * @pre Pre-compile parameter SPI_CANCEL_API shall be STD_ON
  1072. * @post The SPI Handler Driver is not responsible on external devices damages or
  1073. * undefined state due to cancelling a sequence transmission.
  1074. */
  1075. void Spi_Cancel
  1076. (
  1077. Spi_SequenceType Sequence
  1078. );
  1079. #endif
  1080. #if (SPI_LEVEL_DELIVERED == LEVEL2)
  1081. /**
  1082. * @brief This function specifies the asynchronous mode for the SPI busses handled asynchronously.
  1083. * @details This function specifies the asynchronous mode for the SPI busses
  1084. * handled asynchronously.
  1085. * - Service ID: 0x0d
  1086. * - Sync or Async: Synchronous
  1087. * - Reentrancy: Non-Reentrant
  1088. *
  1089. * @param[in] AsyncMode This parameter specifies the asynchronous
  1090. * operating mode (SPI_POLLING_MODE or
  1091. * SPI_INTERRUPT_MODE)
  1092. *
  1093. * @return Std_ReturnType
  1094. * @retval E_OK The command ended successfully
  1095. * @retval E_NOT_OK The command has failed
  1096. *
  1097. * @pre The driver needs to be initialized before calling Spi_SetAsyncMode()
  1098. * otherwise, the function Spi_SetAsyncMode() shall raise the development
  1099. * error if SPI_DEV_ERROR_DETECT is STD_ON.
  1100. * @pre Pre-compile parameter SPI_LEVEL_DELIVERED shall be LEVEL2
  1101. */
  1102. Std_ReturnType Spi_SetAsyncMode
  1103. (
  1104. Spi_AsyncModeType AsyncMode
  1105. );
  1106. #endif
  1107. #if ((SPI_LEVEL_DELIVERED == LEVEL2) && (SPI_HWUNIT_ASYNC_MODE == STD_ON))
  1108. /**
  1109. * @brief This function specifies the asynchronous mode for a given HWUnit.
  1110. * @details This function specifies the asynchronous mode for the SPI busses
  1111. * handled asynchronously.
  1112. * For synchronous HW units, the function has no impact.
  1113. * The function will fail in two cases:
  1114. * - driver not initialised (SPI_E_UNINIT reported by DET)
  1115. * - a sequence transmission is pending the the asynchronous HW unit
  1116. * (SPI_E_SEQ_PENDING reported by DET)
  1117. *
  1118. * @param[in] HWUnit The ID of the HWUnit to be configured
  1119. * @param[in] AsyncMode This parameter specifies the asynchronous
  1120. * operating mode (SPI_POLLING_MODE or
  1121. * SPI_INTERRUPT_MODE)
  1122. *
  1123. * @return Std_ReturnType
  1124. * @retval E_OK The command ended successfully
  1125. * @retval E_NOT_OK The command has failed
  1126. *
  1127. * @pre Pre-compile parameter SPI_LEVEL_DELIVERED shall be LEVEL2 and
  1128. * SPI_HWUNIT_ASYNC_MODE should be on STD_ON
  1129. */
  1130. Std_ReturnType Spi_SetHWUnitAsyncMode
  1131. (
  1132. Spi_HWUnitType HWUnit,
  1133. Spi_AsyncModeType AsyncMode
  1134. );
  1135. #endif /* (SPI_LEVEL_DELIVERED == LEVEL2) && (SPI_HWUNIT_ASYNC_MODE == STD_ON) */
  1136. #if (SPI_DUAL_CLOCK_MODE == STD_ON)
  1137. Std_ReturnType Spi_SetClockMode
  1138. (
  1139. Spi_DualClockModeType ClockMode
  1140. );
  1141. #endif
  1142. #define SPI_STOP_SEC_CODE
  1143. #include "Spi_MemMap.h"
  1144. #ifdef __cplusplus
  1145. }
  1146. #endif
  1147. #endif /* SPI_H */
  1148. /** @} */