drv_spi.h 822 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright (c) 2006-2023, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2022-07-18 Rbb666 first version
  9. */
  10. #ifndef __DRV_SPI__
  11. #define __DRV_SPI__
  12. #include <rtthread.h>
  13. #include <drivers/spi.h>
  14. #include "drv_gpio.h"
  15. struct ifx_spi_handle
  16. {
  17. const char *bus_name;
  18. cyhal_spi_t *spi_obj;
  19. uint16_t sck_pin;
  20. uint16_t miso_pin;
  21. uint16_t mosi_pin;
  22. uint32_t freq;
  23. };
  24. /* ifx spi dirver class */
  25. struct ifx_spi
  26. {
  27. rt_uint32_t cs_pin;
  28. struct ifx_spi_handle *spi_handle_t;
  29. struct rt_spi_configuration *rt_spi_cfg_t;
  30. struct rt_spi_bus spi_bus;
  31. struct rt_completion cpt;
  32. };
  33. rt_err_t rt_hw_spi_device_attach(const char *bus_name, const char *device_name, rt_base_t cs_pin);
  34. #endif