hw_spi.h 1.3 KB

123456789101112131415161718192021222324252627282930
  1. #ifndef __HW_SPI_H__
  2. #define __HW_SPI_H__
  3. #define HW_SPI_NUMBER 1
  4. #define HW_SPI_DEVICE_NUMBER 3
  5. #define RT_SPI_CPHA (1<<0) /* bit[0]:CPHA, clock phase */
  6. #define RT_SPI_CPOL (1<<1) /* bit[1]:CPOL, clock polarity */
  7. /**
  8. * At CPOL=0 the base value of the clock is zero
  9. * - For CPHA=0, data are captured on the clock's rising edge (low->high transition)
  10. * and data are propagated on a falling edge (high->low clock transition).
  11. * - For CPHA=1, data are captured on the clock's falling edge and data are
  12. * propagated on a rising edge.
  13. * At CPOL=1 the base value of the clock is one (inversion of CPOL=0)
  14. * - For CPHA=0, data are captured on clock's falling edge and data are propagated
  15. * on a rising edge.
  16. * - For CPHA=1, data are captured on clock's rising edge and data are propagated
  17. * on a falling edge.
  18. */
  19. #define RT_SPI_LSB (0<<2) /* bit[2]: 0-LSB */
  20. #define RT_SPI_MSB (1<<2) /* bit[2]: 1-MSB */
  21. void hw_spi_init(void);
  22. void hw_spi_device_take(int port);
  23. void hw_spi_device_release(int port);
  24. int hw_spi_readwrite(uint8_t port, const uint8_t *cmd, uint8_t *dst, int size);
  25. uint16_t hw_spi_readwrite_halfword(uint8_t port, uint16_t value);
  26. #endif