void SSP1Init( void )
{
uint8_t i, Dummy=Dummy;
LPC_SC->PCONP |= (0x1<<10);/* Enable AHB clock to the SSP1. */
LPC_SC->PCLKSEL0 &= ~(0x3<<20);
/* P0.6~0.9 as SSP1 */
LPC_PINCON->PINSEL0 &= ~((0x3<<12)|(0x3<<16)|(0x3<<18));
LPC_PINCON->PINSEL0 |= ((0x2<<12)|(0x2<<16)|(0x2<<18));
/* Set DSS data to 8-bit, Frame format SPI, CPOL = 0, CPHA = 0, and SCR is 15 */
LPC_SSP1->CR0 = 0x075F;
/* SSPCPSR clock prescale register, master mode, minimum divisor is 0x02 */
LPC_SSP1->CPSR = 0x2;
for ( i = 0; i < FIFOSIZE; i++ )
{
Dummy = LPC_SSP1->DR; /* clear the RxFIFO */
}
NVIC_EnableIRQ(SSP1_IRQn); /* Enable the SSP Interrupt */
LPC_SSP1->CR1 = SSPCR1_SSE;/* Master mode *//* Device select as master, SSP Enabled */
/* Set SSPINMS registers to enable interrupts */
/* enable all error related interrupts */
LPC_SSP1->IMSC = SSPIMSC_RORIM | SSPIMSC_RTIM;
return;
} |