added interrupt for summer and build src filter

This commit is contained in:
Sven Vogel 2023-10-31 13:04:32 +01:00
parent f9ed357485
commit bc915a7a3f
6 changed files with 52 additions and 13 deletions

View File

@ -12,3 +12,11 @@
platform = atmelavr platform = atmelavr
board = nanoatmega328 board = nanoatmega328
framework = arduino framework = arduino
build_src_filter =
+<*>
-<.git/>
-<.svn/>
-<blink/>
-<button_interrupt/>
-<button_poll/>
-<trafficlight/>

View File

@ -10,8 +10,6 @@
// PORTx set bit of port value // PORTx set bit of port value
// PINx read voltage of bit of port D // PINx read voltage of bit of port D
#ifdef BUTTON_POLL
void init() { void init() {
// --------------------------------------- // ---------------------------------------
// set Port B to output // set Port B to output
@ -43,5 +41,3 @@ void loop() {
CLR_BIT(PORTB, DDB5); CLR_BIT(PORTB, DDB5);
} }
} }
#endif

View File

@ -5,12 +5,8 @@ extern void loop();
//#include "blink/blink.h" //#include "blink/blink.h"
//#include "button_poll/button.h" //#include "button_poll/button.h"
//#include "button_interupt/button.h" //#include "button_interupt/button.h"
#include "trafficlight/trafficlight.h" //#include "trafficlight/trafficlight.h"
#include "summer/summer.h"
//#define BLINK
//#define BUTTON_POLL
//#define BUTTON_INTERRUPT
#define TRAFFIC_LIGHT
int main() { int main() {
init(); init();

29
src/summer/summer.cpp Normal file
View File

@ -0,0 +1,29 @@
//
// Created by servostar on 30.10.23.
//
#include "summer.h"
ISR (TIMER0_COMPA_vect)
{
PORTB = ~PORTB;
}
void init() {
DDRB = 255;
PORTB = 0;
TCCR0A |= (1 << WGM01); // set timer to CTC
OCR0A = 0x70; // count up to this value
TIMSK0 |= (1 << OCIE0A); // enable timer 0
sei(); // enable interrupts
TCCR0B |= (1 << CS02); // start timer and set prescaler to 256
}
void loop() {
}

13
src/summer/summer.h Normal file
View File

@ -0,0 +1,13 @@
//
// Created by servostar on 30.10.23.
//
#ifndef ARDUINO_SUMMER_H
#define ARDUINO_SUMMER_H
#include "prelude.h"
void init();
void loop();
#endif //ARDUINO_SUMMER_H

View File

@ -4,8 +4,6 @@
#include "trafficlight.h" #include "trafficlight.h"
#ifdef TRAFFIC_LIGHT
void init() { void init() {
// set Port B bit 0,1,2 to output mode // set Port B bit 0,1,2 to output mode
DDRB = 0b00000111; DDRB = 0b00000111;
@ -31,4 +29,3 @@ void loop() {
// set to red // set to red
PORTB ^= 0b00000110; PORTB ^= 0b00000110;
} }
#endif