Пример #1
0
void
acc_init (uint8_t enabled)
{
	/* PIO, PIO0_4 in standard IO functionality */
	LPC_IOCON->PIO0_4 = 1 << 8;

	/* setup SPI chipselect pin */
	spi_init_pin (SPI_CS_ACC3D);

	/* PIO, Inactive Pull, Digital Mode */
	LPC_IOCON->PIO1_11 = 0x80;
	GPIOSetDir (1, 11, 0);

	/* propagate power settings */
	acc_power (enabled);
}
Пример #2
0
void
nRFCMD_Init (void)
{
  /* setup SPI chipselect pin */
  spi_init_pin (SPI_CS_NRF);

  /* setup IOs */
  LPC_IOCON->PIO1_9 = 0;
  GPIOSetDir (RF_IRQ_CPU_PORT, RF_IRQ_CPU_PIN, 0);
  NVIC_EnableIRQ (WAKEUP_PIO1_9_IRQn);
  LPC_SYSCON->STARTAPRP0 = (LPC_SYSCON->STARTAPRP0 & ~STARTxPRP0_PIO1_9);
  LPC_SYSCON->STARTRSRP0CLR = STARTxPRP0_PIO1_9;
  LPC_SYSCON->STARTERP0 |= STARTxPRP0_PIO1_9;

  LPC_IOCON->JTAG_TDI_PIO0_11 = 0x81;
  GPIOSetDir (CPU_CE_RF_PORT, CPU_CE_RF_PIN, 1);
  GPIOSetValue (CPU_CE_RF_PORT, CPU_CE_RF_PIN, 0);

  LPC_IOCON->PIO0_2 = 0;
  GPIOSetDir (CPU_SWITCH_RF_PORT, CPU_SWITCH_RF_PIN, 1);
  GPIOSetValue (CPU_SWITCH_RF_PORT, CPU_SWITCH_RF_PIN, 0);
}
Пример #3
0
int
main (void)
{
	double t;
	int i, word, x, y;
	const TWordPos *w;
	TRGB color, *p;

	/* Initialize GPIO (sets up clock) */
	GPIOInit ();

	/* Set LED port pin to output */
	GPIOSetDir (LED_PORT, LED_PIN0, 1);
	GPIOSetValue (LED_PORT, LED_PIN0, LED_OFF);

	/* Init Power Management Routines */
	pmu_init ();

	/* setup SPI chipselect pin */
	spi_init ();
	spi_init_pin (SPI_CS_RGB);

	/* transmit image */
	t = 0;
	word = 0;
	while(1)
	{
		/* set background to red */
		memset(g_data, g_cie[0x00], sizeof(g_data));
		for(y=0; y<LED_Y; y++)
			for(x=0; x<LED_X; x++)
			{
				g_data[y][x].r = g_cie[0x16];
				g_data[y][x].g = g_cie[0x0B];
			}

		/* get next word */
		i = g_sentence[word/DELAY];
		word++;
		if(word>=(WORD_COUNT*DELAY))
			word=0;

		if(i>=0)
		{
			w = &g_words[i];

			for(i=0; i<w->length; i++)
			{
				/* word coordinates */
				x = w->x + i;
				y = w->y;

				/* update color */
				color.r = (sin( x*0.1+cos(y*0.1+t))*CIE_MAX_INDEX2)+CIE_MAX_INDEX2;
				color.g = (cos(-y*0.2-sin(x*0.3-t))*CIE_MAX_INDEX2)+CIE_MAX_INDEX2;
				color.b = (cos( x*0.5-cos(y*0.4+t))*CIE_MAX_INDEX2)+CIE_MAX_INDEX2;

				p = &g_data[y][x];
				p->r = g_cie[color.r];
				p->g = g_cie[color.g];
				p->b = g_cie[color.b];
			}
		}
		/* send data */
		update_leds();
		pmu_wait_ms(1);

		t+=0.01;
	}
}
Пример #4
0
int
main (void)
{
  int t, firstrun;
  volatile int i;

  /* Initialize GPIO (sets up clock) */
  GPIOInit ();
  /* initialize  pins */
  pin_init ();
  /* setup SPI chipselect pins */
  spi_init_pin (SPI_CS_NRF);

  /* blink as a sign of boot to detect crashes */
  for (t = 0; t < 10; t++)
    {
      pin_led (GPIO_LED0);
      for (i = 0; i < 100000; i++);
      pin_led (GPIO_LEDS_OFF);
      for (i = 0; i < 100000; i++);
    }

  /* Init USB HID interface */
  hid_init ();
  /* Init SPI */
  spi_init ();
  /* Init OpenBeacon nRF24L01 interface */
  nRFAPI_Init (81, broadcast_mac, sizeof (broadcast_mac), 0);
  /* Init 3D acceleration sensor */
  acc_init ();
  /* Init Storage */
  storage_init ();
  /* Init Bluetooth */
  bt_init ();

  /* main loop */
  t = 0;
  firstrun = 1;
  while (1)
    {
      /* blink LED0 on every 32th run - FIXME later with sleep */
      if ((t++ & 0x1F) == 0)
	{
	  pin_led (GPIO_LED0);
	  for (i = 0; i < 100000; i++);
	  pin_led (GPIO_LEDS_OFF);
	}
      for (i = 0; i < 200000; i++);

      if (UARTCount)
	{
	  /* blink LED1 upon Bluetooth command */
	  pin_led (GPIO_LED1);

	  /* show help screen upon Bluetooth connect */
	  if (firstrun)
	    {
	      debug_printf ("press 'H' for help...\n# ");
	      firstrun = 0;
	    }
	  else
	    /* execute menue command with last character received */
	    main_menue (UARTBuffer[UARTCount - 1]);

	  /* LED1 off again */
	  pin_led (GPIO_LEDS_OFF);

	  /* clear UART buffer */
	  UARTCount = 0;
	}
    }
}
Пример #5
0
void
storage_init (void)
{
  /* setup SPI chipselect pin */
  spi_init_pin (SPI_CS_FLASH);
}