spi.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. */
  9. #ifndef __LPC17XX_SPI_H__
  10. #define __LPC17XX_SPI_H__
  11. #include <stdint.h>
  12. #include <stdbool.h>
  13. // if not use FIFO, R: 600kB/s, W: 500kB/s
  14. // if use FIFO, R: 1.2MB/s, W: 800kB/s
  15. #define USE_FIFO 1
  16. /* bit-frequency = PCLK / (CPSDVSR * [SCR+1]), here SCR=0, PCLK=72MHz, must be even */
  17. #define SPI_SPEED_20MHz 4 /* => 18MHz */
  18. #define SPI_SPEED_25MHz 4 /* => 18MHz */
  19. #define SPI_SPEED_400kHz 180 /* => 400kHz */
  20. /* external functions */
  21. void LPC17xx_SPI_Init (void);
  22. void LPC17xx_SPI_DeInit( void );
  23. void LPC17xx_SPI_Release (void);
  24. void LPC17xx_SPI_SetSpeed (uint8_t speed);
  25. void LPC17xx_SPI_Select (void);
  26. void LPC17xx_SPI_DeSelect (void);
  27. void LPC17xx_SPI_SendByte (uint8_t data);
  28. uint8_t LPC17xx_SPI_RecvByte (void);
  29. #if USE_FIFO
  30. void LPC17xx_SPI_RecvBlock_FIFO (uint8_t *buff, uint32_t btr);
  31. void LPC17xx_SPI_SendBlock_FIFO (const uint8_t *buff);
  32. #endif
  33. #endif // __LPC17XX_SPI_H__