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 10 #ifndef __LPC17XX_SPI_H__ 11 #define __LPC17XX_SPI_H__ 12 13 #include <stdint.h> 14 #include <stdbool.h> 15 16 // if not use FIFO, R: 600kB/s, W: 500kB/s 17 // if use FIFO, R: 1.2MB/s, W: 800kB/s 18 #define USE_FIFO 1 19 20 /* bit-frequency = PCLK / (CPSDVSR * [SCR+1]), here SCR=0, PCLK=72MHz, must be even */ 21 #define SPI_SPEED_20MHz 4 /* => 18MHz */ 22 #define SPI_SPEED_25MHz 4 /* => 18MHz */ 23 #define SPI_SPEED_400kHz 180 /* => 400kHz */ 24 25 /* external functions */ 26 void LPC17xx_SPI_Init (void); 27 void LPC17xx_SPI_DeInit( void ); 28 void LPC17xx_SPI_Release (void); 29 void LPC17xx_SPI_SetSpeed (uint8_t speed); 30 void LPC17xx_SPI_Select (void); 31 void LPC17xx_SPI_DeSelect (void); 32 void LPC17xx_SPI_SendByte (uint8_t data); 33 uint8_t LPC17xx_SPI_RecvByte (void); 34 35 #if USE_FIFO 36 void LPC17xx_SPI_RecvBlock_FIFO (uint8_t *buff, uint32_t btr); 37 void LPC17xx_SPI_SendBlock_FIFO (const uint8_t *buff); 38 #endif 39 40 #endif // __LPC17XX_SPI_H__ 41