/** * @brief Main routine for SSP example * @return Nothing */ int main(void) { SystemCoreClockUpdate(); Board_Init(); /* SSP initialization */ Board_SSP_Init(LPC_SSP); Chip_SSP_Init(LPC_SSP); ssp_format.frameFormat = SSP_FRAMEFORMAT_SPI; ssp_format.bits = SSP_DATA_BITS; ssp_format.clockMode = SSP_CLOCK_MODE0; Chip_SSP_SetFormat(LPC_SSP, ssp_format.bits, ssp_format.frameFormat, ssp_format.clockMode); Chip_SSP_Enable(LPC_SSP); /* Initialize GPDMA controller */ Chip_GPDMA_Init(LPC_GPDMA); /* Setting GPDMA interrupt */ NVIC_DisableIRQ(DMA_IRQn); NVIC_SetPriority(DMA_IRQn, ((0x01 << 3) | 0x01)); NVIC_EnableIRQ(DMA_IRQn); /* Setting SSP interrupt */ NVIC_EnableIRQ(SSP_IRQ); appSSPMainMenu(); /* DeInitialize SSP peripheral */ Chip_SSP_DeInit(LPC_SSP); return 0; }
int main(void) { #if defined (__USE_LPCOPEN) #if !defined(NO_BOARD_LIB) SystemCoreClockUpdate(); /* Read clock settings and update SystemCoreClock variable * Set up and initialize all required blocks and * functions related to the board hardware */ Board_Init(); #endif #endif /* SSP initialization */ Board_SSP_Init(LPC_SSP); /* enable */ Chip_SSP_Init(LPC_SSP); Chip_Clock_SetSSP0ClockDiv(18); /* define peripherals options */ ssp_format.frameFormat = SSP_FRAMEFORMAT_SPI; ssp_format.bits = SSP_DATA_BITS; ssp_format.clockMode = SSP_CLOCK_MODE0; /* set parameters to peripherals SSP0 */ Chip_SSP_SetFormat(LPC_SSP, ssp_format.bits, ssp_format.frameFormat, ssp_format.clockMode); /* Set the SSP operating modes, master or slave */ Chip_SSP_SetMaster(LPC_SSP, SSP_MODE_TEST); /* Enable SSP operation */ Chip_SSP_Enable(LPC_SSP); Chip_SSP_SendFrame(LPC_SSP, flipByte(0xB0)); //Chip_SSP_SendFrame(LPC_SSP, 0b00001101); // load address 0 //_delay_ms(1); Chip_SSP_SendFrame(LPC_SSP, 0b01110000); // load D letter //_delay_ms(1); Chip_SSP_SendFrame(LPC_SSP, 0b11001100); //_delay_ms(1); Chip_SSP_SendFrame(LPC_SSP, 0b10101010); //_delay_ms(1); Chip_SSP_SendFrame(LPC_SSP, 0b10011110); //_delay_ms(1); Chip_SSP_SendFrame(LPC_SSP, 0b01110001); return 0 ; }
/* Set up and initialize all required blocks and functions related to the board hardware */ void Board_Init(void) { /* Sets up DEBUG UART */ DEBUGINIT(); /* Initializes GPIO */ Chip_GPIO_Init(LPC_GPIO_PORT); Board_GPIOs_Init(); /* Initialize LEDs */ Board_LED_Init(); /* Initialize uarts */ Board_UART_Init(LPC_USART0); //RS 485 Board_UART_Init(LPC_USART3); // rs232 /* Initialize buttons */ Board_Buttons_Init(); /* Initialize DAC */ Board_DAC_Init(); /* Initialize Timers */ Board_TIMER_Init(); /* Initialize ADCs */ Board_ADC_Init(); /* Initialize Keyboard disabled */ Board_KEYBOARD_disable(); /* Initilize EEPROM */ Board_EEPROM_init(); /* Initialize SPI pins */ Board_SSP_Init(); /* Initialize RTC module */ //Board_RTC_Init(); /* Initialize I2C0 module */ Board_I2C_Master_Init(); Chip_ENET_RMIIEnable(LPC_ETHERNET); }
/* Initialize Pin Muxing for LCD */ void Board_LCD_Init(void) { uint32_t val; Board_SSP_Init(LCD_SSP); val = LCD_SSP->CR0 & 0xFFFF; Chip_SCU_PinMuxSet(LCD_CDM_PORT, LCD_CMD_PIN, LCD_CMD_CFG); Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, LCD_CMD_GPIO_PORT, LCD_CMD_GPIO_PIN); Chip_GPIO_SetPinOutHigh(LPC_GPIO_PORT, LCD_CMD_GPIO_PORT, LCD_CMD_GPIO_PIN); /* Enable the SSP interface */ Chip_SSP_Init(LCD_SSP); Chip_SSP_Set_Mode(LCD_SSP, SSP_MODE_MASTER); Chip_SSP_SetFormat(LCD_SSP, SSP_BITS_8, SSP_FRAMEFORMAT_SPI, SSP_CLOCK_CPHA1_CPOL1); Chip_SSP_SetBitRate(LCD_SSP, LCD_BIT_RATE); Chip_SSP_Enable(LCD_SSP); lcd_cfg_val = LCD_SSP->CR0 & 0xFFFF; LCD_SSP->CR0 = val; }
main() { leds_init(); // delay(500); port_pin(4,10, SCU_MODE_INACT ,init_out); port_pin(4,9, SCU_MODE_INACT ,init_out); port_pin(0,0, SCU_MODE_INACT ,init_out); ////////////////////////////////////////////////////////////////////////////////////////////////////// // Board_SSP_Init(); //Chip_SSP_Init(LPC_SSP); // ssp_format.frameFormat = SSP_FRAMEFORMAT_SPI; //ssp_format.bits = SSP_DATA_BITS; //ssp_format.clockMode = SSP_CLOCK_CPHA0_CPOL0 ; // Chip_SSP_SetFormat(LPC_SSP,ssp_format.frameFormat, ssp_format.bits, ssp_format.clockMode); // Chip_SSP_SetMaster(LPC_SSP, SSP_MODE_TEST); // Chip_SSP_Enable(LPC_SSP); // Buffer_Init(); ////////////////////////////////////////////////////////////////////////////////////////////////////// Board_SSP_Init(); Board_SSP_config(SSP_DATA_BITS,SSP_CLOCK_CPHA0_CPOL0 ,800000 ); HD_reset (); Delay_ms (50) ;// delay 50ms lcd_initial_adafruitIIL9341();//lcd_initial();//////////Initial_ILI9340C(); Delay_ms (300); // Test to enter / exit sleep //LCD_Sleep_ILI9340C (); //Delay_ms (300); //LCD_ExitSleep_ILI9340C (); //Display a black screen LCD_TEST_SingleColor (0xFF,0xE0); led_on(LED1); delay(50); dsp_single_colour(0xF8,0x1F);//rosa led_on(LED2); delay(50); while(1) { // Disp_gradscal(); //»Ò½× delay(5); LCD_Sleep_ILI9340C(); delay(500); LCD_ExitSleep_ILI9340C(); //# define Red 0xf800 //LCD_TEST_SingleColor (Red); write_command(0x2C); dsp_single_colour(0x07,0xE0);//verde delay(50); dsp_single_colour(0xF8,0x00);//rojo delay(50); dsp_single_colour(0x07,0xE0);//verde dsp_single_colour(0x00,0x1F);//azul delay(50); } }