Beispiel #1
0
int main (void)
{
  draw_lcd_t lcd;

  // outputs
  GPIOSetDir(OLED_SSEL_PORT, OLED_SSEL_PIN, GPIO_OUTPUT);
  GPIOSetDir(OLED_DC_PORT, OLED_DC_PIN, GPIO_OUTPUT);
  GPIOSetDir(OLED_RESET_PORT, OLED_RESET_PIN, GPIO_OUTPUT);

  GPIOSetValue(OLED_SSEL_PORT, OLED_SSEL_PIN, 1);
  GPIOSetValue(OLED_DC_PORT, OLED_DC_PIN, 1);
  GPIOSetValue(OLED_RESET_PORT, OLED_RESET_PIN, 1);

  SSP0Init(6000000);

  printf("\nInitializing oled driver...");
  oled_init(&lcd);

  rainbow(&lcd);

  //enter forever loop -
  while (1) {
  }

  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;
}
void TEMP_SPI_Init(void)
{
	LPC_GPIO0 -> FIODIR |= (1 << 25);//Set up P0.25 as output to use for Chip Select
	SSP0Init();
}
Beispiel #4
0
int main (void)
{
  uint8_t buf[20];

  //Set LED1-LED8 pins as outputs
  GPIOSetDir( LED1_PORT, LED1_PIN, GPIO_OUTPUT);
  GPIOSetValue( LED1_PORT, LED1_PIN, LED_OFF);
  GPIOSetDir( LED2_PORT, LED2_PIN, GPIO_OUTPUT);
  GPIOSetValue( LED2_PORT, LED2_PIN, LED_OFF);
  GPIOSetDir( LED3_PORT, LED3_PIN, GPIO_OUTPUT);
  GPIOSetValue( LED3_PORT, LED3_PIN, LED_OFF);
  GPIOSetDir( LED4_PORT, LED4_PIN, GPIO_OUTPUT);
  GPIOSetValue( LED4_PORT, LED4_PIN, LED_OFF);
  GPIOSetDir( LED5_PORT, LED5_PIN, GPIO_OUTPUT);
  GPIOSetValue( LED5_PORT, LED5_PIN, LED_OFF);
  GPIOSetDir( LED6_PORT, LED6_PIN, GPIO_OUTPUT);
  GPIOSetValue( LED6_PORT, LED6_PIN, LED_OFF);
  GPIOSetDir( LED7_PORT, LED7_PIN, GPIO_OUTPUT);
  GPIOSetValue( LED7_PORT, LED7_PIN, LED_OFF);
  GPIOSetDir( LED8_PORT, LED8_PIN, GPIO_OUTPUT);
  GPIOSetValue( LED8_PORT, LED8_PIN, LED_OFF);

  //Set SW2/SW3 pins as inputs
  GPIOSetDir( SW2_PORT, SW2_PIN, GPIO_INPUT);
  GPIOSetDir( SW3_PORT, SW3_PIN, GPIO_INPUT);

  //Extra, turn buzzer pin to input
  GPIOSetDir( BUZZ_PORT, BUZZ_PIN, GPIO_OUTPUT);
  GPIOSetValue( BUZZ_PORT, BUZZ_PIN, BUZZ_OFF);

  SSP0Init(1500000);

  //Handle SSEL signal - note: same as LED1, so technically not needed to do this
  GPIOSetDir( SSEL_GPIO_8_PORT, SSEL_GPIO_8_PIN, GPIO_OUTPUT);
  GPIOSetValue( SSEL_GPIO_8_PORT, SSEL_GPIO_8_PIN, SSEL_HIGH);

  //read from spi e2prom
  spiE2PROMread( E2PROM_START_ADDR, buf, 20 );

  //write read bytes on console
  buf[19] = 0;   //null terminate string in case it is missing
  printf("\nString in memory: %s", buf);

  //check if expected string
  if (memcmp(buf, (void *)"Magic text - 123456", 20) != 0)
  {
    buf[0]  = 'M';
    buf[1]  = 'a';
    buf[2]  = 'g';
    buf[3]  = 'i';
    buf[4]  = 'c';
    buf[5]  = ' ';
    buf[6]  = 't';
    buf[7]  = 'e';
    buf[8]  = 'x';
    buf[9]  = 't';
    buf[10] = ' ';
    buf[11] = '-';
    buf[12] = ' ';
    buf[13] = '1';
    buf[14] = '2';
    buf[15] = '3';
    buf[16] = '4';
    buf[17] = '5';
    buf[18] = '6';
    buf[19] = 0x00;

    //write the correct string in memory
    spiE2PROMwrite( E2PROM_START_ADDR, buf, 20 );

    printf("\nString has been written!");
  }

  printf("\nDone!");
  while(1);

  return 0;
}
Beispiel #5
0
void WIZ_SPI_Init(void)
{
	SSP0Init();
}