spi.h 907 B

12345678910111213141516171819202122232425262728293031
  1. #ifndef __LPC17XX_SPI_H__
  2. #define __LPC17XX_SPI_H__
  3. #include <stdint.h>
  4. #include <stdbool.h>
  5. // if not use FIFO, R: 600kB/s, W: 500kB/s
  6. // if use FIFO, R: 1.2MB/s, W: 800kB/s
  7. #define USE_FIFO 1
  8. /* bit-frequency = PCLK / (CPSDVSR * [SCR+1]), here SCR=0, PCLK=72MHz, must be even */
  9. #define SPI_SPEED_20MHz 4 /* => 18MHz */
  10. #define SPI_SPEED_25MHz 4 /* => 18MHz */
  11. #define SPI_SPEED_400kHz 180 /* => 400kHz */
  12. /* external functions */
  13. void LPC17xx_SPI_Init (void);
  14. void LPC17xx_SPI_DeInit( void );
  15. void LPC17xx_SPI_Release (void);
  16. void LPC17xx_SPI_SetSpeed (uint8_t speed);
  17. void LPC17xx_SPI_Select (void);
  18. void LPC17xx_SPI_DeSelect (void);
  19. void LPC17xx_SPI_SendByte (uint8_t data);
  20. uint8_t LPC17xx_SPI_RecvByte (void);
  21. #if USE_FIFO
  22. void LPC17xx_SPI_RecvBlock_FIFO (uint8_t *buff, uint32_t btr);
  23. void LPC17xx_SPI_SendBlock_FIFO (const uint8_t *buff);
  24. #endif
  25. #endif // __LPC17XX_SPI_H__