spi-bit-ops.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright (c) 2006-2022, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2021-10-11 kyle first version
  9. */
  10. #ifndef __SPI_BIT_OPS_H__
  11. #define __SPI_BIT_OPS_H__
  12. #include <rtdevice.h>
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. struct rt_spi_bit_ops
  17. {
  18. void *const data; /* private data for lowlevel routines */
  19. void (*const tog_sclk)(void *data);
  20. void (*const set_sclk)(void *data, rt_int32_t state);
  21. void (*const set_mosi)(void *data, rt_int32_t state);
  22. void (*const set_miso)(void *data, rt_int32_t state);
  23. rt_int32_t (*const get_sclk)(void *data);
  24. rt_int32_t (*const get_mosi)(void *data);
  25. rt_int32_t (*const get_miso)(void *data);
  26. void (*const dir_mosi)(void *data, rt_int32_t state);
  27. void (*const dir_miso)(void *data, rt_int32_t state);
  28. void (*const udelay)(rt_uint32_t us);
  29. rt_uint32_t delay_us; /* sclk, mosi and miso line delay */
  30. };
  31. struct rt_spi_bit_obj
  32. {
  33. struct rt_spi_bus bus;
  34. struct rt_spi_bit_ops *ops;
  35. struct rt_spi_configuration config;
  36. };
  37. rt_err_t rt_spi_bit_add_bus(struct rt_spi_bit_obj *obj,
  38. const char *bus_name,
  39. struct rt_spi_bit_ops *ops);
  40. #ifdef __cplusplus
  41. }
  42. #endif
  43. #endif