Exemplo n.º 1
0
void startc ( void )
{
    gpio_fsel(gpio47, GPIO_FN_OUTPUT);
    gpio_fsel(gpio23, GPIO_FN_OUTPUT);
    gpio_fsel(gpio24, GPIO_FN_INPUT);

    while(1)
    {
        gpio_set(gpio47);

        enum { HIGH = 1 };
        if (gpio_level(gpio24) == HIGH)
        {
            gpio_set(gpio23);
        }
        else
        {
            gpio_clear(gpio23);
        }

        for (volatile int busy=0; busy<0x400000; busy++);

        gpio_clear(gpio47);

        for (volatile int busy=0; busy<0x400000; busy++);
    }
}
Exemplo n.º 2
0
int notmain(){
  initex();
  addexc(IRQVECT, irq_handler);
  putsp(IRQMODE, 0x8000);
  putsp(SVCMODE, 0x8000000);
  for ( i= 0; i<6; i++ )
    gpio_fsel(leds[i], OUTPUT);
  gpio_fsel(ALT, OUTPUT);
  systim_add(2, 1);
  systim_add(2, 3);
  irq_enable(C1INT);
  irq_enable(C3INT);
  cuenta= 5;
  int_globalenable(IRQ);
  while(1);
}
Exemplo n.º 3
0
unsigned int spi_init(unsigned int cdiv, unsigned int cspins) {
	unsigned int spi;
	spi = get32(AUX_ENABLES);
	put32(AUX_ENABLES, spi | 2);
	if(cspins | 1) {
		gpio_fsel(GP7, ALT0);
	}
	if(cspins | 2) {
		gpio_fsel(GP8, ALT0);
	}
	gpio_fsel(GP9, ALT0);
	gpio_fsel(GP10, ALT0);
	gpio_fsel(GP11, ALT0);
	put32(AUX_SPI0_CS, 0x0000030);
	put32(AUX_SPI0_CLK, cdiv);

	return SYS_CLOCK / cdiv;
}
Exemplo n.º 4
0
void act_led_off(void) {
	gpio_fsel(LED_PIN, GPIO_F_OUT);
	gpio_set(LED_PIN);
}
Exemplo n.º 5
0
void act_led_on(void) {
	gpio_fsel(LED_PIN, GPIO_F_OUT);
	gpio_clr(LED_PIN);
}
Exemplo n.º 6
0
static void setup_gpio()
{
	// pin 16 is led, set gpio to output
	gpio_fsel(16, GPIO_FSEL_OUTPUT);
}