Example #1
0
void main(void) {
    keyboard_init();
    printf_init();
    timer_init();
    system_enable_interrupts();

    while (1) {
        int key = keyboard_read_scancode(); 
        printf("%02x ", key );
	if (key != 0xf0 && key != 0xe0) {
            printf("\n");
	}
    }
}
Example #2
0
/*
 * Disable all interrupts except  GPIO interrupt 0, which is for pins 0-31. This
 * interrupt is IRQ 49, so bit 17 of the second register (BCM2835 ARM
 * Peripherals Manual, top of page 113).
 */
void kdriver_init() {
  gpio_init();

  // Ensure all interrupts are disabled.
  PUT32(RPI_INT_DISABLE_1, 0xFFFFFFFF);
  PUT32(RPI_INT_DISABLE_2, 0xFFFFFFFF);

  // We'll be hooking up a button to Pin 23, so set it up appropriately.
  gpio_set_input(GPIO_PIN23);
  gpio_set_pullup(GPIO_PIN23); 
  gpio_detect_falling_edge(GPIO_PIN23);

  // Enable GPIO interrupt 0
  PUT32(RPI_INT_ENABLE_2, 0x00100000);

  // Enable interrupts
  system_enable_interrupts();
}
Example #3
0
void keyboard_init(void) {
  gpio_init();
  // Ensure all interrupts are disabled.
  PUT32(RPI_INT_DISABLE_1, 0xFFFFFFFF);
  PUT32(RPI_INT_DISABLE_2, 0xFFFFFFFF);

  gpio_set_function(CLK, GPIO_FUNC_INPUT);
  gpio_set_pullup(CLK);
  gpio_detect_falling_edge(CLK);

  gpio_set_function(DATA, GPIO_FUNC_INPUT);
  gpio_set_pullup(DATA);

  // Enable GPIO interrupt 0
  PUT32(RPI_INT_ENABLE_2, 0x00100000);

  // Enable interrupts
  system_enable_interrupts(); 
}