Commit 5ec6dad3 authored by Martin Vítek's avatar Martin Vítek
Browse files

Add extern irq from encoder button

parent 1dddb566
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include <stdint.h>
......@@ -14,19 +15,41 @@ static void uart_string(const char *text);
static void wellcome();
gpio led(PORTD, PIN0_bm);
ISR(PORTA_INT0_vect)
{
led.toggle();
}
ISR(BADISR_vect)
{
reti();
};
const HD44780_config lcd_config = {PORTD, PIN2_bm, PIN3_bm, PIN4_bm, PIN5_bm, PIN6_bm, PIN7_bm};
HD44780 lcd(lcd_config);
int main()
{
gpio led(PORTD, PIN0_bm);
led.set_direction(OUTPUT);
gpio backlight(PORTD, PIN1_bm);
backlight.set_direction(OUTPUT);
backlight.on();
gpio button(PORTA, PIN2_bm);
button.set_direction(INPUT);
//button.set_mode(TOTEM_PULL_UP);
//button.set_invert(true);
PORTA.INTCTRL = PORT_INT0LVL_HI_gc;
PORTA.INT0MASK = PIN2_bm;
PORTA.PIN2CTRL |= PORT_ISC_RISING_gc | PORT_OPC_PULLUP_gc | PORT_INVEN_bm;
PMIC.CTRL = PMIC_HILVLEN_bm | PMIC_RREN_bm;
PORTC.DIRSET = PIN4_bm | PIN5_bm | PIN6_bm | PIN7_bm;
PORTC.OUTCLR = PIN4_bm | PIN5_bm | PIN6_bm | PIN7_bm;
......@@ -34,15 +57,19 @@ int main()
uart_ini();
lcd.init();
sei();
wellcome();
for(;;)
{
/*
led.toggle();
_delay_ms(500);
led.toggle();
_delay_ms(500);
*/
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment