remote set and get register by address

This commit is contained in:
Tristan Krause 2019-05-29 10:13:36 +02:00
parent 2c47159df3
commit 2e88b9c980
69 changed files with 1595 additions and 117 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,35 @@
#include <iostream>
#include <cmath>
#include <b15f/b15f.h>
#include <b15f/plottyfile.h>
const char PLOT_FILE[] = "plot.bin";
constexpr uint8_t SFR_OFFSET = 0x20;
constexpr uint8_t SFR_DDRB = 0x04;
constexpr uint8_t SFR_WDTCSR = 0x60;
constexpr uint8_t SFR_PORTB = 0x05;
/*
* Dieses Beispiel erzeugt einen 300ms langen Impuls an PB0.
*
*/
int main()
{
uint8_t DDRB, PORTB;
B15F& drv = B15F::getInstance();
DDRB = drv.getRegister(SFR_DDRB + SFR_OFFSET);
DDRB |= (1<<0);
drv.setRegister(SFR_DDRB + SFR_OFFSET, DDRB);
PORTB = drv.getRegister(SFR_PORTB + SFR_OFFSET);
PORTB |= (1<<0);
drv.setRegister(SFR_PORTB + SFR_OFFSET, PORTB);
drv.delay_ms(300);
PORTB = drv.getRegister(SFR_PORTB + SFR_OFFSET);
PORTB &= ~(1<<0);
drv.setRegister(SFR_PORTB + SFR_OFFSET, PORTB);
}