rt-thread-official/bsp/nxp/lpc/lpc176x/drivers/spi.h

41 lines
1.1 KiB
C
Raw Normal View History

2021-03-17 02:26:35 +08:00
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
*/
2013-01-08 22:40:58 +08:00
#ifndef __LPC17XX_SPI_H__
#define __LPC17XX_SPI_H__
#include <stdint.h>
#include <stdbool.h>
2021-03-17 02:26:35 +08:00
// if not use FIFO, R: 600kB/s, W: 500kB/s
// if use FIFO, R: 1.2MB/s, W: 800kB/s
2013-01-08 22:40:58 +08:00
#define USE_FIFO 1
2021-03-17 02:26:35 +08:00
/* bit-frequency = PCLK / (CPSDVSR * [SCR+1]), here SCR=0, PCLK=72MHz, must be even */
#define SPI_SPEED_20MHz 4 /* => 18MHz */
#define SPI_SPEED_25MHz 4 /* => 18MHz */
#define SPI_SPEED_400kHz 180 /* => 400kHz */
2013-01-08 22:40:58 +08:00
/* external functions */
void LPC17xx_SPI_Init (void);
void LPC17xx_SPI_DeInit( void );
void LPC17xx_SPI_Release (void);
void LPC17xx_SPI_SetSpeed (uint8_t speed);
void LPC17xx_SPI_Select (void);
void LPC17xx_SPI_DeSelect (void);
void LPC17xx_SPI_SendByte (uint8_t data);
uint8_t LPC17xx_SPI_RecvByte (void);
#if USE_FIFO
2021-03-17 02:26:35 +08:00
void LPC17xx_SPI_RecvBlock_FIFO (uint8_t *buff, uint32_t btr);
2013-01-08 22:40:58 +08:00
void LPC17xx_SPI_SendBlock_FIFO (const uint8_t *buff);
#endif
2021-03-17 02:26:35 +08:00
#endif // __LPC17XX_SPI_H__