Example #1
0
void lcd_init() {

	LPC_GPIO0 -> FIODIR |= LCD_RS;
	LPC_GPIO1 -> FIODIR |= LCD_CS;

	SSP1Init();
	delay_ms(10);
	writeConfigWithDelay(ST7735_SLPOUT, 50); // sleep out
	writeConfig(ST7735_FRMCTR1, 3, frmctr); // frame rate in normal mode
	writeConfig(ST7735_FRMCTR2, 3, frmctr); // frame rate in idle mode
	writeConfig(ST7735_FRMCTR3, 6, frmctr); // frame rate in partial mode
	writeConfig(ST7735_INVCTR, 1, invctr); // display inversion control
	writeConfig(ST7735_PWCTR1, 3, pwctr1); // power control settings
	writeConfig(ST7735_PWCTR2, 1, pwctr2); // power control settings
	writeConfig(ST7735_PWCTR3, 2, pwctr3); // power control settings
	writeConfig(ST7735_PWCTR4, 2, pwctr4); // power control settings
	writeConfig(ST7735_PWCTR5, 2, pwctr5); // power control settings
	writeConfig(ST7735_VMCTR1, 1, vmctr1); // power control settings
	writeConfig(ST7735_INVOFF, 0, 0); // display inversion off
	writeConfig(ST7735_MADCTL, 1, madctl); // screen rotation / display format
	writeConfig(ST7735_COLMOD, 1, colmod); // color mode
	writeConfigWithDelay(ST7735_NORON, 1); // normal display on
	writeConfigWithDelay(ST7735_DISPON, 10); // display on
	delay_ms(10);
}
/******************************************************************************
**   Main Function  main()
******************************************************************************/
int main (void)
{
  /* SystemClockUpdate() updates the SystemFrequency variable */
  SystemClockUpdate(); //SystemFrequency = 72000000 by default
  Systick_Init();      //10 ms de bir tick atacak sekilde Systick i baslat

  Gpio_Config();       //Beacon MCU da kullanilacak pinleri konfigure et

  ADF7021_CHIP_POWER_DOWN;        //CE pini asagi cek
  Delay_ms(10);
  ADF7021_LOAD_REGISTER_DISABLE;  //LE pinini yukari cek, load register disable olsun
  Delay_ms(10);
  ADF7021_CHIP_POWER_UP;          //CE pinini yukari cek, ADF7012 enable olsun
  Delay_ms(10);

  SSP1Init();			          // SSP1 portunda SPI konusalim*/
  DACInit();                      // 1.2kHz ve 2kHz sinus olusturmak icin DAC peripheral i baslatalim
  Delay_ms(10);

  Init_Adf7012();                 //Adf7012 registerlarini istedigimiz konfigurasyonda yazalim
  Init_Timer(10);                 //10us intervalinde timer0 baslat
  Enable_Timer();                 //Timer0 enable et


  while ( 1 );                    //main de yapilacak is kalmadi bundan sonra isr lerle devam edecegiz
  return 0;
}
/******************************************************************************
**   Main Function  main()
******************************************************************************/
int main (void)
{
  uint32_t i, portnum = PORT_NUM;

  /* SystemClockUpdate() updates the SystemFrequency variable */
  SystemClockUpdate();

  if ( portnum == 0 )
	SSP0Init();			/* initialize SSP port */
  else if ( portnum == 1 )
	SSP1Init();
  
  for ( i = 0; i < SSP_BUFSIZE; i++ )
  {
	src_addr[i] = (uint8_t)i;
	dest_addr[i] = 0;
  }

#if TX_RX_ONLY
  /* For the inter-board communication, one board is set as
  master transmit, the other is set to slave receive. */
#if SSP_SLAVE
  /* Slave receive */
  SSPReceive( portnum, (uint8_t *)dest_addr, SSP_BUFSIZE );
  for ( i = 0; i < SSP_BUFSIZE; i++ )
  {
	if ( src_addr[i] != dest_addr[i] )
	{
	  while ( 1 );				/* Verification failure, fatal error */
	} 
  }
#else
  /* Master transmit */
  SSPSend( portnum, (uint8_t *)src_addr, SSP_BUFSIZE);
#endif
#else
  /* TX_RX_ONLY=0, it's either an internal loopback test
  within SSP peripheral or communicate with a serial EEPROM. */
#if LOOPBACK_MODE
  LoopbackTest( portnum, LOCATION_NUM );
#else
  SEEPROMTest( portnum, LOCATION_NUM );
#endif			/* endif NOT LOOPBACK_MODE */
#endif			/* endif NOT TX_RX_ONLY */
  /* Never exit from main(), for easy debugging. */
  while ( 1 );
  return 0;
}