romapi_i2cs.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * @brief I2C 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 I2C slave driver context */
  33. uint32_t ROM_I2CS_GetMemSize(void)
  34. {
  35. #if defined(ROMDRIVERSV2_PRESENT)
  36. return ROMAPI_I2CS_API->GetMemSize();
  37. #else
  38. return i2cs_api.GetMemSize();
  39. #endif
  40. }
  41. /* Initialize I2C slave peripheral */
  42. ROM_I2CS_HANDLE_T ROM_I2CS_Init(void *mem, ROM_I2CS_INIT_T *pInit)
  43. {
  44. #if defined(ROMDRIVERSV2_PRESENT)
  45. return ROMAPI_I2CS_API->Init(mem, pInit);
  46. #else
  47. return i2cs_api.Init(mem, pInit);
  48. #endif
  49. }
  50. /* Set I2C slave clock rate */
  51. void ROM_I2CS_SetupSlave(ROM_I2CS_HANDLE_T pHandle, ROM_I2CS_SLAVE_T *pSlaveSetup)
  52. {
  53. #if defined(ROMDRIVERSV2_PRESENT)
  54. ROMAPI_I2CS_API->SetupSlave(pHandle, pSlaveSetup);
  55. #else
  56. i2cs_api.SetupSlave(pHandle, pSlaveSetup);
  57. #endif
  58. }
  59. /* Register a I2C slave callback */
  60. void ROM_I2CS_RegisterCallback(ROM_I2CS_HANDLE_T pHandle, ROM_I2CS_CALLBACK_T cbIndex, void *pCB)
  61. {
  62. #if defined(ROMDRIVERSV2_PRESENT)
  63. ROMAPI_I2CS_API->RegisterCallback(pHandle, cbIndex, pCB);
  64. #else
  65. i2cs_api.RegisterCallback(pHandle, cbIndex, pCB);
  66. #endif
  67. }
  68. /* Start a I2C slave transfer */
  69. ErrorCode_t ROM_I2CS_Transfer(ROM_I2CS_HANDLE_T pHandle, ROM_I2CS_XFER_T *pXfer)
  70. {
  71. #if defined(ROMDRIVERSV2_PRESENT)
  72. return ROMAPI_I2CS_API->Transfer(pHandle, pXfer);
  73. #else
  74. return i2cs_api.Transfer(pHandle, pXfer);
  75. #endif
  76. }
  77. /* I2C slave transfer (interrupt) handler */
  78. void ROM_I2CS_TransferHandler(ROM_I2CS_HANDLE_T pHandle)
  79. {
  80. #if defined(ROMDRIVERSV2_PRESENT)
  81. ROMAPI_I2CS_API->TransferHandler(pHandle);
  82. #else
  83. i2cs_api.TransferHandler(pHandle);
  84. #endif
  85. }
  86. /* Return the I2C slave ROM driver version */
  87. uint16_t ROM_I2CS_GetDriverVersion(void)
  88. {
  89. #if defined(ROMDRIVERSV2_PRESENT)
  90. return ROMAPI_I2CS_API->GetDriverVersion();
  91. #else
  92. return i2cs_api.GetDriverVersion();
  93. #endif
  94. }