romapi_spis.c 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * @brief SPI slave 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 slave driver context */
  33. uint32_t ROM_SPIS_GetMemSize(void)
  34. {
  35. #if defined(ROMDRIVERSV2_PRESENT)
  36. return ROMAPI_SPIS_API->GetMemSize();
  37. #else
  38. return spis_api.GetMemSize();
  39. #endif
  40. }
  41. /* Initialize SPI slave peripheral */
  42. ROM_SPIS_HANDLE_T ROM_SPIS_Init(void *mem, ROM_SPIS_INIT_T *pInit)
  43. {
  44. #if defined(ROMDRIVERSV2_PRESENT)
  45. return ROMAPI_SPIS_API->Init(mem, pInit);
  46. #else
  47. return spis_api.Init(mem, pInit);
  48. #endif
  49. }
  50. void ROM_SPIS_RegisterCallback(ROM_SPIS_HANDLE_T pHandle, ROM_SPIS_CALLBACK_T cbIndex, void *pCB)
  51. {
  52. #if defined(ROMDRIVERSV2_PRESENT)
  53. ROMAPI_SPIS_API->RegisterCallback(pHandle, cbIndex, pCB);
  54. #else
  55. spis_api.RegisterCallback(pHandle, cbIndex, pCB);
  56. #endif
  57. }
  58. ErrorCode_t ROM_SPIS_SetupSlave(ROM_SPIS_HANDLE_T pHandle, ROM_SPIS_SLAVE_T *pSlaveSetup)
  59. {
  60. #if defined(ROMDRIVERSV2_PRESENT)
  61. return ROMAPI_SPIS_API->SetupSlave(pHandle, pSlaveSetup);
  62. #else
  63. return spis_api.SetupSlave(pHandle, pSlaveSetup);
  64. #endif
  65. }
  66. ErrorCode_t ROM_SPIS_Transfer(ROM_SPIS_HANDLE_T pHandle, ROM_SPIS_XFER_T *pXfer)
  67. {
  68. #if defined(ROMDRIVERSV2_PRESENT)
  69. return ROMAPI_SPIS_API->Transfer(pHandle, pXfer);
  70. #else
  71. return spis_api.Transfer(pHandle, pXfer);
  72. #endif
  73. }
  74. void ROM_SPIS_TransferHandler(ROM_SPIS_HANDLE_T pHandle)
  75. {
  76. #if defined(ROMDRIVERSV2_PRESENT)
  77. ROMAPI_SPIS_API->TransferHandler(pHandle);
  78. #else
  79. spis_api.TransferHandler(pHandle);
  80. #endif
  81. }
  82. /* Return the SPI slave ROM driver version */
  83. uint16_t ROM_SPIS_GetDriverVersion(void)
  84. {
  85. #if defined(ROMDRIVERSV2_PRESENT)
  86. return ROMAPI_SPIS_API->GetDriverVersion();
  87. #else
  88. return spis_api.GetDriverVersion();
  89. #endif
  90. }