Driver_SPI.c 3.4 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_SPI.h"
  19. #define ARM_SPI_DRV_VERSION ARM_DRIVER_VERSION_MAJOR_MINOR(1, 0) /* driver version */
  20. /* Driver Version */
  21. static const ARM_DRIVER_VERSION DriverVersion = {
  22. ARM_SPI_API_VERSION,
  23. ARM_SPI_DRV_VERSION
  24. };
  25. /* Driver Capabilities */
  26. static const ARM_SPI_CAPABILITIES DriverCapabilities = {
  27. 0, /* Reserved (must be zero) */
  28. 0, /* TI Synchronous Serial Interface */
  29. 0, /* Microwire Interface */
  30. 0, /* Signal Mode Fault event: \ref ARM_SPI_EVENT_MODE_FAULT */
  31. 0 /* Reserved (must be zero) */
  32. };
  33. //
  34. // Functions
  35. //
  36. static ARM_DRIVER_VERSION ARM_SPI_GetVersion(void)
  37. {
  38. return DriverVersion;
  39. }
  40. static ARM_SPI_CAPABILITIES ARM_SPI_GetCapabilities(void)
  41. {
  42. return DriverCapabilities;
  43. }
  44. static int32_t ARM_SPI_Initialize(ARM_SPI_SignalEvent_t cb_event)
  45. {
  46. }
  47. static int32_t ARM_SPI_Uninitialize(void)
  48. {
  49. }
  50. static int32_t ARM_SPI_PowerControl(ARM_POWER_STATE state)
  51. {
  52. switch (state)
  53. {
  54. case ARM_POWER_OFF:
  55. break;
  56. case ARM_POWER_LOW:
  57. break;
  58. case ARM_POWER_FULL:
  59. break;
  60. }
  61. return ARM_DRIVER_OK;
  62. }
  63. static int32_t ARM_SPI_Send(const void *data, uint32_t num)
  64. {
  65. }
  66. static int32_t ARM_SPI_Receive(void *data, uint32_t num)
  67. {
  68. }
  69. static int32_t ARM_SPI_Transfer(const void *data_out, void *data_in, uint32_t num)
  70. {
  71. }
  72. static uint32_t ARM_SPI_GetDataCount(void)
  73. {
  74. }
  75. static int32_t ARM_SPI_Control(uint32_t control, uint32_t arg)
  76. {
  77. switch (control & ARM_SPI_CONTROL_Msk)
  78. {
  79. default:
  80. return ARM_DRIVER_ERROR_UNSUPPORTED;
  81. case ARM_SPI_MODE_INACTIVE: // SPI Inactive
  82. return ARM_DRIVER_OK;
  83. case ARM_SPI_MODE_MASTER: // SPI Master (Output on MOSI, Input on MISO); arg = Bus Speed in bps
  84. break;
  85. case ARM_SPI_MODE_SLAVE: // SPI Slave (Output on MISO, Input on MOSI)
  86. break;
  87. case ARM_SPI_SET_BUS_SPEED: // Set Bus Speed in bps; arg = value
  88. break;
  89. case ARM_SPI_GET_BUS_SPEED: // Get Bus Speed in bps
  90. break;
  91. case ARM_SPI_SET_DEFAULT_TX_VALUE: // Set default Transmit value; arg = value
  92. break;
  93. case ARM_SPI_CONTROL_SS: // Control Slave Select; arg = 0:inactive, 1:active
  94. break;
  95. case ARM_SPI_ABORT_TRANSFER: // Abort current data transfer
  96. break;
  97. }
  98. }
  99. static ARM_SPI_STATUS ARM_SPI_GetStatus(void)
  100. {
  101. }
  102. static void ARM_SPI_SignalEvent(uint32_t event)
  103. {
  104. // function body
  105. }
  106. // End SPI Interface
  107. extern \
  108. ARM_DRIVER_SPI Driver_SPI0;
  109. ARM_DRIVER_SPI Driver_SPI0 = {
  110. ARM_SPI_GetVersion,
  111. ARM_SPI_GetCapabilities,
  112. ARM_SPI_Initialize,
  113. ARM_SPI_Uninitialize,
  114. ARM_SPI_PowerControl,
  115. ARM_SPI_Send,
  116. ARM_SPI_Receive,
  117. ARM_SPI_Transfer,
  118. ARM_SPI_GetDataCount,
  119. ARM_SPI_Control,
  120. ARM_SPI_GetStatus
  121. };