romapi_spim.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. #include "romapi_5410x.h"
  32. /* Get memory size in bytes needed for SPI master driver context */
  33. uint32_t ROM_SPIM_GetMemSize(void)
  34. {
  35. #if defined(ROMDRIVERSV2_PRESENT)
  36. return ROMAPI_SPIM_API->GetMemSize();
  37. #else
  38. return spim_api.GetMemSize();
  39. #endif
  40. }
  41. /* Initialize SPI master peripheral */
  42. ROM_SPIM_HANDLE_T ROM_SPIM_Init(void *mem, ROM_SPIM_INIT_T *pInit)
  43. {
  44. #if defined(ROMDRIVERSV2_PRESENT)
  45. return ROMAPI_SPIM_API->Init(mem, pInit);
  46. #else
  47. return spim_api.Init(mem, pInit);
  48. #endif
  49. }
  50. void ROM_SPIM_RegisterCallback(ROM_SPIM_HANDLE_T pHandle, ROM_SPIM_CALLBACK_T cbIndex, void *pCB)
  51. {
  52. #if defined(ROMDRIVERSV2_PRESENT)
  53. ROMAPI_SPIM_API->RegisterCallback(pHandle, cbIndex, pCB);
  54. #else
  55. spim_api.RegisterCallback(pHandle, cbIndex, pCB);
  56. #endif
  57. }
  58. ErrorCode_t ROM_SPIM_SetupTransfer(ROM_SPIM_HANDLE_T pHandle, ROM_SPIM_XFER_CONFIG_T *pCfg)
  59. {
  60. #if defined(ROMDRIVERSV2_PRESENT)
  61. return ROMAPI_SPIM_API->SetupTransfer(pHandle, pCfg);
  62. #else
  63. return spim_api.SetupTransfer(pHandle, pCfg);
  64. #endif
  65. }
  66. ErrorCode_t ROM_SPIM_Transfer(ROM_SPIM_HANDLE_T pHandle, ROM_SPIM_XFER_T *pXfer)
  67. {
  68. #if defined(ROMDRIVERSV2_PRESENT)
  69. return ROMAPI_SPIM_API->Transfer(pHandle, pXfer);
  70. #else
  71. return spim_api.Transfer(pHandle, pXfer);
  72. #endif
  73. }
  74. void ROM_SPIM_TransferHandler(ROM_SPIM_HANDLE_T pHandle)
  75. {
  76. #if defined(ROMDRIVERSV2_PRESENT)
  77. ROMAPI_SPIM_API->TransferHandler(pHandle);
  78. #else
  79. spim_api.TransferHandler(pHandle);
  80. #endif
  81. }
  82. void ROM_SPIM_ClosePendingTransfer(ROM_SPIM_HANDLE_T pHandle)
  83. {
  84. #if defined(ROMDRIVERSV2_PRESENT)
  85. ROMAPI_SPIM_API->ClosePendingTransfer(pHandle);
  86. #else
  87. spim_api.ClosePendingTransfer(pHandle);
  88. #endif
  89. }
  90. /* Return the SPI master ROM driver version */
  91. uint16_t ROM_SPIM_GetDriverVersion(void)
  92. {
  93. #if defined(ROMDRIVERSV2_PRESENT)
  94. return ROMAPI_SPIM_API->GetDriverVersion();
  95. #else
  96. return spim_api.GetDriverVersion();
  97. #endif
  98. }