Beschreibung

This commit is contained in:
Tristan Krause 2019-06-25 11:02:08 +02:00
parent aa5aeff9d1
commit c09e5b5b48
5 changed files with 94 additions and 6 deletions

View file

@ -0,0 +1,30 @@
# Name: Makefile
# Project: B15F (board15 Famulus Edition)
# Author: Tristan Krause
# Creation Date: 2019-05-15
# Environment
COMPILER_PATH = g++
# Options
CFLAGS = -std=c++17 -O3 -Wall -Wextra
LDFLAGS = -lb15fdrv
OBJECTS = main.o
OUT = main.elf
COMPILE = $(COMPILER_PATH) $(CFLAGS)
main: $(OBJECTS)
$(COMPILE) $(OBJECTS) -o $(OUT) $(LDFLAGS)
help:
@echo "This Makefile has the following targets:"
@echo "make main .... to compile"
@echo "make clean ... to delete objects and executables"
clean:
@echo "Cleaning..."
rm -f $(OBJECTS) $(OUT) *.bin gnuplotscript.gp
.cpp.o:
$(COMPILE) -c $< -o $@

View file

@ -0,0 +1,40 @@
#include <b15f/b15f.h>
#include <b15f/plottyfile.h>
/*
* Dieses Beispiel liest ein par Interrupt Counter aus.
* Die Counter sind 16-Bit groß und in einem Feld.
* Die Vector Nummer ist gleich die Counter-Nummer im Feld.
* Ausname: Vector 0 (Reset). Dieser ist im Feld stattdessen der BADISR-Interrupt
*/
int main()
{
uint8_t tmp;
B15F& drv = B15F::getInstance();
// INT2 für falling edge
tmp = drv.getRegister(&EICRA);
tmp |= _BV(ISC21);
drv.setRegister(&EICRA, tmp);
// aktiviere INT2
tmp = drv.getRegister(&EIMSK);
tmp |= _BV(INT2);
drv.setRegister(&EIMSK, tmp);
// ab jetzt sollte kann man INT2 mit einem Pullup/Pulldown Widerstand betreiben.
// Nachdem man eine Flanke auf INT2 gegeben hat und dieses Programm erneut aufruft, siehtman wie counter[INT2] hochzählt.
// Erhalte Adress-Offset zum ersten Counter.
uint16_t* cnt = drv.getInterruptCounterOffset();
std::cout << "mem offset: " << reinterpret_cast<size_t>(cnt) << std::endl;
// gib beispielhaft ein par Counter aus:
std::cout << "counter[BADISR]: " << (int) drv.getMem16(cnt) << std::endl;
std::cout << "counter[INT0]: " << (int) drv.getMem16(cnt + 1) << std::endl;
std::cout << "counter[INT1]: " << (int) drv.getMem16(cnt + 2) << std::endl;
std::cout << "counter[INT2]: " << (int) drv.getMem16(cnt + 3) << std::endl;
std::cout << "counter[ANALOG_COMP]: " << (int) drv.getMem16(cnt + 23) << std::endl;
std::cout << "counter[TIMER3_OVF]: " << (int) drv.getMem16(cnt + 34) << std::endl;
}