romapi_i2cm.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * @brief I2C master ROM API declarations and functions
  3. * These are the public ROM APIs and functions of the I2C master
  4. * driver.
  5. *
  6. * @note
  7. * Copyright(C) NXP Semiconductors, 2014
  8. * All rights reserved.
  9. *
  10. * @par
  11. * Software that is described herein is for illustrative purposes only
  12. * which provides customers with programming information regarding the
  13. * LPC products. This software is supplied "AS IS" without any warranties of
  14. * any kind, and NXP Semiconductors and its licensor disclaim any and
  15. * all warranties, express or implied, including all implied warranties of
  16. * merchantability, fitness for a particular purpose and non-infringement of
  17. * intellectual property rights. NXP Semiconductors assumes no responsibility
  18. * or liability for the use of the software, conveys no license or rights under any
  19. * patent, copyright, mask work right, or any other intellectual property rights in
  20. * or to any products. NXP Semiconductors reserves the right to make changes
  21. * in the software without notification. NXP Semiconductors also makes no
  22. * representation or warranty that such application will be suitable for the
  23. * specified use without further testing or modification.
  24. *
  25. * @par
  26. * Permission to use, copy, modify, and distribute this software and its
  27. * documentation is hereby granted, under NXP Semiconductors' and its
  28. * licensor's relevant copyrights in the software, without fee, provided that it
  29. * is used in conjunction with NXP Semiconductors microcontrollers. This
  30. * copyright, permission, and disclaimer notice must appear in all copies of
  31. * this code.
  32. */
  33. #include "romapi_5410x.h"
  34. /* Get memory size in bytes needed for I2C master driver context */
  35. uint32_t ROM_I2CM_GetMemSize(void)
  36. {
  37. #if defined(ROMDRIVERSV2_PRESENT)
  38. return ROMAPI_I2CM_API->GetMemSize();
  39. #else
  40. return i2cm_api.GetMemSize();
  41. #endif
  42. }
  43. /* Initialize I2C master peripheral */
  44. ROM_I2CM_HANDLE_T ROM_I2CM_Init(void *mem, const ROM_I2CM_INIT_T *pInit)
  45. {
  46. #if defined(ROMDRIVERSV2_PRESENT)
  47. return ROMAPI_I2CM_API->Init(mem, pInit);
  48. #else
  49. return i2cm_api.Init(mem, pInit);
  50. #endif
  51. }
  52. /* Set I2C master clock rate */
  53. uint32_t ROM_I2CM_SetClockRate(ROM_I2CM_HANDLE_T pHandle, uint32_t inRate, uint32_t i2cRate)
  54. {
  55. #if defined(ROMDRIVERSV2_PRESENT)
  56. return ROMAPI_I2CM_API->SetClockRate(pHandle, inRate, i2cRate);
  57. #else
  58. return i2cm_api.SetClockRate(pHandle, inRate, i2cRate);
  59. #endif
  60. }
  61. /* Register a I2C master callback */
  62. void ROM_I2CM_RegisterCallback(ROM_I2CM_HANDLE_T pHandle, ROM_I2CM_CALLBACK_T cbIndex, void *pCB)
  63. {
  64. #if defined(ROMDRIVERSV2_PRESENT)
  65. ROMAPI_I2CM_API->RegisterCallback(pHandle, cbIndex, pCB);
  66. #else
  67. i2cm_api.RegisterCallback(pHandle, cbIndex, pCB);
  68. #endif
  69. }
  70. /* Start a I2C master transfer */
  71. ErrorCode_t ROM_I2CM_Transfer(ROM_I2CM_HANDLE_T pHandle, ROM_I2CM_XFER_T *pXfer)
  72. {
  73. #if defined(ROMDRIVERSV2_PRESENT)
  74. return ROMAPI_I2CM_API->Transfer(pHandle, pXfer);
  75. #else
  76. return i2cm_api.Transfer(pHandle, pXfer);
  77. #endif
  78. }
  79. /* I2C master transfer (interrupt) handler */
  80. void ROM_I2CM_TransferHandler(ROM_I2CM_HANDLE_T pHandle)
  81. {
  82. #if defined(ROMDRIVERSV2_PRESENT)
  83. ROMAPI_I2CM_API->TransferHandler(pHandle);
  84. #else
  85. i2cm_api.TransferHandler(pHandle);
  86. #endif
  87. }
  88. /* Return the I2C master ROM driver version */
  89. uint16_t ROM_I2CM_GetDriverVersion(void)
  90. {
  91. #if defined(ROMDRIVERSV2_PRESENT)
  92. return ROMAPI_I2CM_API->GetDriverVersion();
  93. #else
  94. return i2cm_api.GetDriverVersion();
  95. #endif
  96. }