#include "driver_config.h"
#include "target_config.h"
#include "gpio.h"
#include "timer32.h"
#include "ssp.h"
#include "uart.h"
extern volatile uint32_t UARTCount;
extern volatile uint8_t UARTBuffer[BUFSIZE];
extern volatile uint8_t UARTBuffer1[BUFSIZE];
uint8_t i=0;
uint16_t buff[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int casse;
int cnt;
int cont = 0;
int cont1=0;
int cont2 = 0;
int main (void) {
/* Basic chip initialization is taken care of in SystemInit() called
* from the startup code. SystemInit() and chip settings are defined
* in the CMSIS system_<part family>.c file.
*/
SystemInit();
/* NVIC is installed inside UARTInit file. */
UARTInit(UART_BAUD);
// for(cont1=0; cont1<30000; cont1++)
//{
//cont1++;
// }
SSP_IOConfig( 0 ); /* initialize SSP port, share pins with SPI1
on port2(p2.0-3). */
//SSP_Init( SSP_NUM );
//GPIOSetDir(PORT0,2,0);
LPC_IOCON ->PIO0_8 &= ~0x07; /* SSP I/O config */
LPC_IOCON->PIO0_8 |= 0x01; /* SSP MISO */
LPC_IOCON->PIO0_9 &= ~0x07;
LPC_IOCON->PIO0_9 |= 0x01;
LPC_IOCON->SCK_LOC = 0x02;
LPC_IOCON->PIO0_6 = 0x02;
LPC_IOCON->PIO0_2 &= ~0x07;
LPC_IOCON->PIO0_2 |= 0x01;
if ( LPC_SSP0->CR1 & SSPCR1_SSE )
{
/* The slave bit can't be set until SSE bit is zero. */
LPC_SSP0->CR1 &= ~SSPCR1_SSE;
}
LPC_SSP0->CR1 = SSPCR1_MS; /* Enable slave bit first */
LPC_SSP0->CR1 |= SSPCR1_SSE;
LPC_SSP0->CR0 = 0x04CF;
LPC_SSP0 ->CR1 = 0x06;
while(1)
{
while ( !(LPC_SSP0->SR & SSPSR_RNE) );
{//printf(" I am in buff loop buff");
buff = (uint16_t)LPC_SSP0->DR;
i++;
if(buff == 0x0400)
{
while ( (LPC_SSP0->SR & (SSPSR_TNF|SSPSR_BSY)) != SSPSR_TNF );
LPC_SSP0->DR = 0x4567;
}
}
}
return 0;
}
|