void SetupSPI(void)
{
LPC_IOCON->PIO0_8 =0x1;// set MISO0 on PIO0.8
LPC_IOCON->PIO0_9 =0x1;// set MOSI0 on PIO0.9
LPC_IOCON->PIO1_29 = 0x1;
LPC_GPIO->DIR[1] = LPC_GPIO->DIR[1] | (1<<15);//Chip select Config set 1.15 as output
LPC_GPIO->CLR[1] = 15;//Enable CS active LOW
LPC_SYSCON->SYSAHBCLKCTRL |= (0x1<<11);// enable power
LPC_SYSCON->SSP0CLKDIV = 0x2;/* Divided by 2 */
LPC_SYSCON->PRESETCTRL |= (0x1<<0);//SSP0 reset de-asserted.
LPC_SSP0->CR0 = 0x0F07;//Set DSS data to 8-bit, Frame format SPI, CPOL = 0, CPHA = 0, and SCR is 15
LPC_SSP0->CPSR = 96;//SSPCPSR clock prescale register, master mode, minimum divisor is 0x02
LPC_SSP0->CR1 = 0x2;// enable SPI
LPC_SSP0->DR = 0xAA;// TEST DATA
while(1);
} |