自己写的SSP0/1驱动,SSP0测试通过
#include "lpc17xx.h" /* LPC17xx Peripheral Registers */
#include "type.h"
#include "nvic.h"
#include "ssp.h"
/*****************************************************************************
** Function name: SSP0Init
** Descriptions: SSP0 initialization mark: operate SEL outside
** parameters: none
** Returned value: true or false
*****************************************************************************/
DWORD SSP0Init( void )
{
/* set p1.24 as MOSI0, p1.23 as MISO0, p1.20 as SCK0, P1.21 as GPIO */
PINSEL3 |= 0x0003C300;
/* set p1.21 output */
FIO1DIR |= 0x00200000;
FIO1SET |= 0x00200000;
/* set ssp0 clock */
SSP0CPSR = 0x04;
/* SSP0 Control Register 0 */
SSP0CR0 = (0x00 << 8) | // SCR SSP0CLK =Fpclk/(CSPDVR*(SCR+1)) = 50000000/2 =25000000
(0x00 << 7) | // CPHA=0
(0x00 << 6) | // CPOL=0
(0x00 << 4) | // FRF Frame Format 00=SPI, 01=SSI, 10=Microwire, 11=reserve
(0x07 << 0); // DSS&nbs