Driver_I2C.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*
  2. * Copyright (c) 2013-2020 Arm Limited. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the License); you may
  7. * not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  14. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. #include "Driver_I2C.h"
  19. #define ARM_I2C_DRV_VERSION ARM_DRIVER_VERSION_MAJOR_MINOR(1, 0) /* driver version */
  20. /* Driver Version */
  21. static const ARM_DRIVER_VERSION DriverVersion = {
  22. ARM_I2C_API_VERSION,
  23. ARM_I2C_DRV_VERSION
  24. };
  25. /* Driver Capabilities */
  26. static const ARM_I2C_CAPABILITIES DriverCapabilities = {
  27. 0 /* supports 10-bit addressing */
  28. };
  29. //
  30. // Functions
  31. //
  32. static ARM_DRIVER_VERSION ARM_I2C_GetVersion(void)
  33. {
  34. return DriverVersion;
  35. }
  36. static ARM_I2C_CAPABILITIES ARM_I2C_GetCapabilities(void)
  37. {
  38. return DriverCapabilities;
  39. }
  40. static int32_t ARM_I2C_Initialize(ARM_I2C_SignalEvent_t cb_event)
  41. {
  42. }
  43. static int32_t ARM_I2C_Uninitialize(void)
  44. {
  45. }
  46. static int32_t ARM_I2C_PowerControl(ARM_POWER_STATE state)
  47. {
  48. switch (state)
  49. {
  50. case ARM_POWER_OFF:
  51. break;
  52. case ARM_POWER_LOW:
  53. break;
  54. case ARM_POWER_FULL:
  55. break;
  56. }
  57. return ARM_DRIVER_OK;
  58. }
  59. static int32_t ARM_I2C_MasterTransmit(uint32_t addr, const uint8_t *data, uint32_t num, bool xfer_pending)
  60. {
  61. }
  62. static int32_t ARM_I2C_MasterReceive(uint32_t addr, uint8_t *data, uint32_t num, bool xfer_pending)
  63. {
  64. }
  65. static int32_t ARM_I2C_SlaveTransmit(const uint8_t *data, uint32_t num)
  66. {
  67. }
  68. static int32_t ARM_I2C_SlaveReceive(uint8_t *data, uint32_t num)
  69. {
  70. }
  71. static int32_t ARM_I2C_GetDataCount(void)
  72. {
  73. }
  74. static int32_t ARM_I2C_Control(uint32_t control, uint32_t arg)
  75. {
  76. switch (control)
  77. {
  78. case ARM_I2C_OWN_ADDRESS:
  79. break;
  80. case ARM_I2C_BUS_SPEED:
  81. switch (arg)
  82. {
  83. case ARM_I2C_BUS_SPEED_STANDARD:
  84. break;
  85. case ARM_I2C_BUS_SPEED_FAST:
  86. break;
  87. case ARM_I2C_BUS_SPEED_FAST_PLUS:
  88. break;
  89. default:
  90. return ARM_DRIVER_ERROR_UNSUPPORTED;
  91. }
  92. break;
  93. case ARM_I2C_BUS_CLEAR:
  94. break;
  95. case ARM_I2C_ABORT_TRANSFER:
  96. break;
  97. default:
  98. return ARM_DRIVER_ERROR_UNSUPPORTED;
  99. }
  100. }
  101. static ARM_I2C_STATUS ARM_I2C_GetStatus(void)
  102. {
  103. }
  104. static void ARM_I2C_SignalEvent(uint32_t event)
  105. {
  106. // function body
  107. }
  108. // End I2C Interface
  109. extern \
  110. ARM_DRIVER_I2C Driver_I2C0;
  111. ARM_DRIVER_I2C Driver_I2C0 = {
  112. ARM_I2C_GetVersion,
  113. ARM_I2C_GetCapabilities,
  114. ARM_I2C_Initialize,
  115. ARM_I2C_Uninitialize,
  116. ARM_I2C_PowerControl,
  117. ARM_I2C_MasterTransmit,
  118. ARM_I2C_MasterReceive,
  119. ARM_I2C_SlaveTransmit,
  120. ARM_I2C_SlaveReceive,
  121. ARM_I2C_GetDataCount,
  122. ARM_I2C_Control,
  123. ARM_I2C_GetStatus
  124. };