Driver_SPI.c 3.5 KB

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