romapi_spim.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * @brief SPI master ROM API declarations and functions
  3. *
  4. * @note
  5. * Copyright(C) NXP Semiconductors, 2014
  6. * All rights reserved.
  7. *
  8. * @par
  9. * Software that is described herein is for illustrative purposes only
  10. * which provides customers with programming information regarding the
  11. * LPC products. This software is supplied "AS IS" without any warranties of
  12. * any kind, and NXP Semiconductors and its licensor disclaim any and
  13. * all warranties, express or implied, including all implied warranties of
  14. * merchantability, fitness for a particular purpose and non-infringement of
  15. * intellectual property rights. NXP Semiconductors assumes no responsibility
  16. * or liability for the use of the software, conveys no license or rights under any
  17. * patent, copyright, mask work right, or any other intellectual property rights in
  18. * or to any products. NXP Semiconductors reserves the right to make changes
  19. * in the software without notification. NXP Semiconductors also makes no
  20. * representation or warranty that such application will be suitable for the
  21. * specified use without further testing or modification.
  22. *
  23. * @par
  24. * Permission to use, copy, modify, and distribute this software and its
  25. * documentation is hereby granted, under NXP Semiconductors' and its
  26. * licensor's relevant copyrights in the software, without fee, provided that it
  27. * is used in conjunction with NXP Semiconductors microcontrollers. This
  28. * copyright, permission, and disclaimer notice must appear in all copies of
  29. * this code.
  30. */
  31. #ifndef __ROMAPI_SPIM_H_
  32. #define __ROMAPI_SPIM_H_
  33. #include "hw_spimd.h"
  34. #ifdef __cplusplus
  35. extern "C" {
  36. #endif
  37. /** @defgroup ROMAPI_SPIM_WRAPPER CHIP: SPI master ROM wrapper functions
  38. * @ingroup ROMAPI_5410X
  39. * @{
  40. */
  41. /**
  42. * @brief Get memory size in bytes needed for SPI master driver context
  43. * @return Size in bytes needed for the ROM driver
  44. */
  45. uint32_t ROM_SPIM_GetMemSize(void);
  46. /**
  47. * @brief Initialize SPI master peripheral
  48. * @param mem : Pointer to memory area used to driver context
  49. * @param pInit : Pointer to SPI master init data
  50. * @return NULL on error, or a pointer to the device context handle
  51. */
  52. ROM_SPIM_HANDLE_T ROM_SPIM_Init(void *mem, ROM_SPIM_INIT_T *pInit);
  53. /**
  54. * @brief Register a SPI master callback
  55. * @param pHandle : Pointer to driver context handle
  56. * @param cbIndex : Callback to register
  57. * @param pCB : Pointer to callback function
  58. * @return Nothing
  59. */
  60. void ROM_SPIM_RegisterCallback(ROM_SPIM_HANDLE_T pHandle, ROM_SPIM_CALLBACK_T cbIndex, void *pCB);
  61. ErrorCode_t ROM_SPIM_SetupTransfer(ROM_SPIM_HANDLE_T pHandle, ROM_SPIM_XFER_CONFIG_T *pCfg);
  62. /**
  63. * @brief Start a SPI master transfer
  64. * @param pHandle : Pointer to driver context handle
  65. * @param pXfer : Pointer to master transfer configuration
  66. * @return Error code
  67. * @note This function starts the transfer and returns immediately.
  68. */
  69. ErrorCode_t ROM_SPIM_Transfer(ROM_SPIM_HANDLE_T pHandle, ROM_SPIM_XFER_T *pXfer);
  70. /**
  71. * @brief SPI master transfer (interrupt) handler
  72. * @param pHandle : Pointer to driver context handle
  73. * @return Nothing
  74. * @note This function should be called from the SPI interrupt handler and
  75. * is used in interrupt and DMA modes.
  76. */
  77. void ROM_SPIM_TransferHandler(ROM_SPIM_HANDLE_T pHandle);
  78. /**
  79. * @brief Safely stop a SPI master transfer
  80. * @param pHandle : Pointer to driver context handle
  81. * @return Nothing
  82. * @note This function completes the SPI transfer at the next possible
  83. * transfer completion state. This should be called when DMA is used and
  84. * DMA transfer is complete, or whenever the transfer neesd to be aborted.
  85. * It will safely transmit any data already inside the SPI transmit FIFOs
  86. * before stopping.
  87. */
  88. void ROM_SPIM_ClosePendingTransfer(ROM_SPIM_HANDLE_T pHandle);
  89. /**
  90. * @brief Return the SPI master ROM driver version
  91. * @return Driver version number
  92. * @note The returned driver version number consists of a major and minor
  93. * number, with the minor number in the lower 8 bits and the major number in
  94. * the upper 8 bits.
  95. */
  96. uint16_t ROM_SPIM_GetDriverVersion(void);
  97. /**
  98. * @}
  99. */
  100. #ifdef __cplusplus
  101. }
  102. #endif
  103. #endif /* __ROMAPI_SPIM_H_ */