From 13e95264fbfadd7e8b7493bf0b3dd34ace8a91e6 Mon Sep 17 00:00:00 2001 From: Tristan Krause Date: Tue, 26 Mar 2019 08:44:30 +0100 Subject: [PATCH] pio entfernt & spiegel test routine --- B15F.aps | 2 +- B15F.elf | Bin 11112 -> 11128 bytes B15F.hex | 172 ++++++++++++------------- Makefile | 2 +- vars.cpp => global_vars.cpp | 2 +- vars.h => global_vars.h | 6 +- main.cpp | 12 +- pio.h | 95 -------------- pio/dmode.h | 248 ----------------------------------- pio/dread.h | 183 -------------------------- pio/dwrite.h | 249 ------------------------------------ pio/i2c/impl0.h | 78 ----------- pio/mcus.h | 22 ---- pio/mcus/atmega1284.h | 17 --- pio/mcus/atmega16.h | 17 --- pio/mcus/atmega328p.h | 14 -- selftest.cpp | 16 +++ selftest.h | 3 +- spi.cpp | 30 +---- spi.h | 17 ++- 20 files changed, 129 insertions(+), 1056 deletions(-) rename vars.cpp => global_vars.cpp (84%) rename vars.h => global_vars.h (70%) delete mode 100644 pio.h delete mode 100644 pio/dmode.h delete mode 100644 pio/dread.h delete mode 100644 pio/dwrite.h delete mode 100644 pio/i2c/impl0.h delete mode 100644 pio/mcus.h delete mode 100644 pio/mcus/atmega1284.h delete mode 100644 pio/mcus/atmega16.h delete mode 100644 pio/mcus/atmega328p.h diff --git a/B15F.aps b/B15F.aps index e1c2651..08b5532 100644 --- a/B15F.aps +++ b/B15F.aps @@ -1 +1 @@ -B15F22-Mar-2019 14:29:5425-Mar-2019 16:14:23241022-Mar-2019 14:29:5444, 19, 0, 730AVR GCCB15F.elfF:\JTAGICE mkIIATmega1284.xmlfalseR00R01R02R03R04R05R06R07R08R09R10R11R12R13R14R15R16R17R18R19R20R21R22R23R24R25R26R27R28R29R30R31Auto000spi.cppmain.cppMakefilemcp23s17.cppTLC5615.cppadu.cppselftest.cppvars.cppspi.hmcp23s17.hTLC5615.hadu.hselftest.hvars.hdefault\B15F.lssdefault\B15F.mapc++NOatmega128111B15F.elfc++\0-Wall -gdwarf-2 -Os -std=gnu99 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enumsdefaultYESMakefileatmega1284111B15F.elfdefault\0C:\avr8-gnu-toolchain-win32_x86\avr\include\C:\avr8-gnu-toolchain-win32_x86\avr\lib\libc.a-Wall -gdwarf-2 -DF_CPU=20000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enumsdefault0C:\avr8-gnu-toolchain-win32_x86\bin\avr-g++.exeC:\WinAVR-20100110\utils\bin\make.exe00000main.cpp100001Makefile100002selftest.h100003selftest.cpp100004vars.h1 +B15F22-Mar-2019 14:29:5426-Mar-2019 08:32:01241022-Mar-2019 14:29:5444, 19, 0, 730AVR GCCB15F.elfF:\JTAGICE mkIIATmega1284.xmlfalseR00R01R02R03R04R05R06R07R08R09R10R11R12R13R14R15R16R17R18R19R20R21R22R23R24R25R26R27R28R29R30R31Auto000spi.cppmain.cppMakefilemcp23s17.cppTLC5615.cppadu.cppselftest.cppglobal_vars.cppspi.hmcp23s17.hTLC5615.hadu.hselftest.hglobal_vars.hdefault\B15F.lssdefault\B15F.mapc++NOatmega128111B15F.elfc++\0-Wall -gdwarf-2 -Os -std=gnu99 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enumsdefaultYESMakefileatmega1284111B15F.elfdefault\1C:\avr8-gnu-toolchain-win32_x86\avr\include\C:\avr8-gnu-toolchain-win32_x86\avr\lib\libc.a-Wall -gdwarf-2 -DF_CPU=20000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enumsdefault0C:\avr8-gnu-toolchain-win32_x86\bin\avr-g++.exeC:\WinAVR-20100110\utils\bin\make.exeF:\spi.hF:\mcp23s17.hF:\TLC5615.hF:\adu.hF:\selftest.hF:\global_vars.hF:\spi.cppF:\main.cppF:\MakefileF:\mcp23s17.cppF:\TLC5615.cppF:\adu.cppF:\selftest.cppF:\global_vars.cpp00000main.cpp100001Makefile100002selftest.h100003selftest.cpp100004global_vars.cpp100005spi.h100006spi.cpp1 diff --git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F!AMEGB#VZ2E+}plXM$zmG^!@Q(+W6NLr~1JC82tr ztQq2U;mpL=+C&~tHw2l^#~YfI{CvLHPy_hAA%b_PF~a8f{>F&nFW@H{>)G4<97LD- lCA>5I7rYH#+7!t #include #include -#include "vars.h" +#include "global_vars.h" #include "selftest.h" -#define LED B0 +#define LED PB0 ISR(WDT_vect) { while(1) { - dWrite(LED, HIGH); - _delay_ms(200); - dWrite(LED, LOW); + PORTB ^= _BV(LED); _delay_ms(200); } WDTCSR |= _BV(WDIE); @@ -36,8 +34,8 @@ void initAll() int main() { /*WDTCSR = _BV(WDIE) | _BV(WDP3) | _BV(WDP0); - dMode(LED, OUT); - dWrite(LED, LOW); + DDRB |= _BV(LED); + PORTB &= ~_BV(LED); wdt_reset(); sei();*/ diff --git a/pio.h b/pio.h deleted file mode 100644 index 17fd75a..0000000 --- a/pio.h +++ /dev/null @@ -1,95 +0,0 @@ -/*** - * _______ _____ ___ - * |_ __ \|_ _|.' `. - * | |__) | | | / .-. \ - * | ___/ | | | | | | - * _| |_ _| |_\ `-' / - * |_____| |_____|`.___.' - * - * Preprocessor I/O Library - * - * ~ version 1.0.0 - * ~ written by Tristan Krause - * ~ visit www.devfix.net - * - * You should have received a copy of the MIT License. - * If not, see . - * - * How does it work? - * ---------------------------------------------- - * Instead of the classical way - * (1a) DDRA |= (1< - -#ifdef HIGH -#undef HIGH -#endif -#define HIGH 1 - -#ifndef LOW -#undef LOW -#endif -#define LOW 0 - -#ifndef OUT -#undef OUT -#endif -#define OUT 1 - -#ifndef OUTPUT -#undef OUTPUT -#endif -#define OUTPUT 1 - -#ifndef IN -#undef IN -#endif -#define IN 0 - -#ifndef INPUT -#undef INPUT -#endif -#define INPUT 0 - -#include "pio/dmode.h" -#include "pio/dwrite.h" -#include "pio/dread.h" - -#include "pio/mcus.h" - -#endif // PIO_H diff --git a/pio/dmode.h b/pio/dmode.h deleted file mode 100644 index a97cfcc..0000000 --- a/pio/dmode.h +++ /dev/null @@ -1,248 +0,0 @@ -/*** - * dmode.h - * This file is part of the PIO library. - * For license information see "pio.h" in the parent directory. - */ - -#if !defined(PIOLIB) || PIOLIB < 100 -#error This file should be included directly. Use "pio.h" instead. -#endif - -#ifndef PIO_DMODE_H -#define PIO_DMODE_H - -#define dMode(A, B) dMode_(A, B) -#define dMode_(A, B) DMODE ## _ ## A ## _ ## B - -#ifdef PA0 -#define DMODE_A0_1 DDRA |= 0x01 -#define DMODE_A0_0 DDRA &= 0xFE -#else -#define DMODE_A0_1 # Pin A0 not supported on this MCU! -#define DMODE_A0_0 DMODE_A0_1 -#endif -#ifdef PA1 -#define DMODE_A1_1 DDRA |= 0x02 -#define DMODE_A1_0 DDRA &= 0xFD -#else -#define DMODE_A1_1 # Pin A1 not supported on this MCU! -#define DMODE_A1_0 DMODE_A1_1 -#endif -#ifdef PA2 -#define DMODE_A2_1 DDRA |= 0x04 -#define DMODE_A2_0 DDRA &= 0xFB -#else -#define DMODE_A2_1 # Pin A2 not supported on this MCU! -#define DMODE_A2_0 DMODE_A2_1 -#endif -#ifdef PA3 -#define DMODE_A3_1 DDRA |= 0x08 -#define DMODE_A3_0 DDRA &= 0xF7 -#else -#define DMODE_A3_1 # Pin A3 not supported on this MCU! -#define DMODE_A3_0 DMODE_A3_1 -#endif -#ifdef PA4 -#define DMODE_A4_1 DDRA |= 0x10 -#define DMODE_A4_0 DDRA &= 0xEF -#else -#define DMODE_A4_1 # Pin A4 not supported on this MCU! -#define DMODE_A4_0 DMODE_A4_1 -#endif -#ifdef PA5 -#define DMODE_A5_1 DDRA |= 0x20 -#define DMODE_A5_0 DDRA &= 0xDF -#else -#define DMODE_A5_1 # Pin A5 not supported on this MCU! -#define DMODE_A5_0 DMODE_A5_1 -#endif -#ifdef PA6 -#define DMODE_A6_1 DDRA |= 0x40 -#define DMODE_A6_0 DDRA &= 0xBF -#else -#define DMODE_A6_1 # Pin A6 not supported on this MCU! -#define DMODE_A6_0 DMODE_A6_1 -#endif -#ifdef PA7 -#define DMODE_A7_1 DDRA |= 0x80 -#define DMODE_A7_0 DDRA &= 0x7F -#else -#define DMODE_A7_1 # Pin A7 not supported on this MCU! -#define DMODE_A7_0 DMODE_A7_1 -#endif - - -#ifdef PB0 -#define DMODE_B0_1 DDRB |= 0x01 -#define DMODE_B0_0 DDRB &= 0xFE -#else -#define DMODE_B0_1 # Pin B0 not supported on this MCU! -#define DMODE_B0_0 DMODE_B0_1 -#endif -#ifdef PB1 -#define DMODE_B1_1 DDRB |= 0x02 -#define DMODE_B1_0 DDRB &= 0xFD -#else -#define DMODE_B1_1 # Pin B1 not supported on this MCU! -#define DMODE_B1_0 DMODE_B1_1 -#endif -#ifdef PB2 -#define DMODE_B2_1 DDRB |= 0x04 -#define DMODE_B2_0 DDRB &= 0xFB -#else -#define DMODE_B2_1 # Pin B2 not supported on this MCU! -#define DMODE_B2_0 DMODE_B2_1 -#endif -#ifdef PB3 -#define DMODE_B3_1 DDRB |= 0x08 -#define DMODE_B3_0 DDRB &= 0xF7 -#else -#define DMODE_B3_1 # Pin B3 not supported on this MCU! -#define DMODE_B3_0 DMODE_B3_1 -#endif -#ifdef PB4 -#define DMODE_B4_1 DDRB |= 0x10 -#define DMODE_B4_0 DDRB &= 0xEF -#else -#define DMODE_B4_1 # Pin B4 not supported on this MCU! -#define DMODE_B4_0 DMODE_B4_1 -#endif -#ifdef PB5 -#define DMODE_B5_1 DDRB |= 0x20 -#define DMODE_B5_0 DDRB &= 0xDF -#else -#define DMODE_B5_1 # Pin B5 not supported on this MCU! -#define DMODE_B5_0 DMODE_B5_1 -#endif -#ifdef PB6 -#define DMODE_B6_1 DDRB |= 0x40 -#define DMODE_B6_0 DDRB &= 0xBF -#else -#define DMODE_B6_1 # Pin B6 not supported on this MCU! -#define DMODE_B6_0 DMODE_B6_1 -#endif -#ifdef PB7 -#define DMODE_B7_1 DDRB |= 0x80 -#define DMODE_B7_0 DDRB &= 0x7F -#else -#define DMODE_B7_1 # Pin B7 not supported on this MCU! -#define DMODE_B7_0 DMODE_B7_1 -#endif - - -#ifdef PC0 -#define DMODE_C0_1 DDRC |= 0x01 -#define DMODE_C0_0 DDRC &= 0xFE -#else -#define DMODE_C0_1 # Pin C0 not supported on this MCU! -#define DMODE_C0_0 DMODE_C0_1 -#endif -#ifdef PC1 -#define DMODE_C1_1 DDRC |= 0x02 -#define DMODE_C1_0 DDRC &= 0xFD -#else -#define DMODE_C1_1 # Pin C1 not supported on this MCU! -#define DMODE_C1_0 DMODE_C1_1 -#endif -#ifdef PC2 -#define DMODE_C2_1 DDRC |= 0x04 -#define DMODE_C2_0 DDRC &= 0xFB -#else -#define DMODE_C2_1 # Pin C2 not supported on this MCU! -#define DMODE_C2_0 DMODE_C2_1 -#endif -#ifdef PC3 -#define DMODE_C3_1 DDRC |= 0x08 -#define DMODE_C3_0 DDRC &= 0xF7 -#else -#define DMODE_C3_1 # Pin C3 not supported on this MCU! -#define DMODE_C3_0 DMODE_C3_1 -#endif -#ifdef PC4 -#define DMODE_C4_1 DDRC |= 0x10 -#define DMODE_C4_0 DDRC &= 0xEF -#else -#define DMODE_C4_1 # Pin C4 not supported on this MCU! -#define DMODE_C4_0 DMODE_C4_1 -#endif -#ifdef PC5 -#define DMODE_C5_1 DDRC |= 0x20 -#define DMODE_C5_0 DDRC &= 0xDF -#else -#define DMODE_C5_1 # Pin C5 not supported on this MCU! -#define DMODE_C5_0 DMODE_C5_1 -#endif -#ifdef PC6 -#define DMODE_C6_1 DDRC |= 0x40 -#define DMODE_C6_0 DDRC &= 0xBF -#else -#define DMODE_C6_1 # Pin C6 not supported on this MCU! -#define DMODE_C6_0 DMODE_C6_1 -#endif -#ifdef PC7 -#define DMODE_C7_1 DDRC |= 0x80 -#define DMODE_C7_0 DDRC &= 0x7F -#else -#define DMODE_C7_1 # Pin C7 not supported on this MCU! -#define DMODE_C7_0 DMODE_C7_1 -#endif - - -#ifdef PD0 -#define DMODE_D0_1 DDRD |= 0x01 -#define DMODE_D0_0 DDRD &= 0xFE -#else -#define DMODE_D0_1 # Pin D0 not supported on this MCU! -#define DMODE_D0_0 DMODE_D0_1 -#endif -#ifdef PD1 -#define DMODE_D1_1 DDRD |= 0x02 -#define DMODE_D1_0 DDRD &= 0xFD -#else -#define DMODE_D1_1 # Pin D1 not supported on this MCU! -#define DMODE_D1_0 DMODE_D1_1 -#endif -#ifdef PD2 -#define DMODE_D2_1 DDRD |= 0x04 -#define DMODE_D2_0 DDRD &= 0xFB -#else -#define DMODE_D2_1 # Pin D2 not supported on this MCU! -#define DMODE_D2_0 DMODE_D2_1 -#endif -#ifdef PD3 -#define DMODE_D3_1 DDRD |= 0x08 -#define DMODE_D3_0 DDRD &= 0xF7 -#else -#define DMODE_D3_1 # Pin D3 not supported on this MCU! -#define DMODE_D3_0 DMODE_D3_1 -#endif -#ifdef PD4 -#define DMODE_D4_1 DDRD |= 0x10 -#define DMODE_D4_0 DDRD &= 0xEF -#else -#define DMODE_D4_1 # Pin D4 not supported on this MCU! -#define DMODE_D4_0 DMODE_D4_1 -#endif -#ifdef PD5 -#define DMODE_D5_1 DDRD |= 0x20 -#define DMODE_D5_0 DDRD &= 0xDF -#else -#define DMODE_D5_1 # Pin D5 not supported on this MCU! -#define DMODE_D5_0 DMODE_D5_1 -#endif -#ifdef PD6 -#define DMODE_D6_1 DDRD |= 0x40 -#define DMODE_D6_0 DDRD &= 0xBF -#else -#define DMODE_D6_1 # Pin D6 not supported on this MCU! -#define DMODE_D6_0 DMODE_D6_1 -#endif -#ifdef PD7 -#define DMODE_D7_1 DDRD |= 0x80 -#define DMODE_D7_0 DDRD &= 0x7F -#else -#define DMODE_D7_1 # Pin D7 not supported on this MCU! -#define DMODE_D7_0 DMODE_D7_1 -#endif - -#endif // PIO_DMODE_H diff --git a/pio/dread.h b/pio/dread.h deleted file mode 100644 index 2e2d35d..0000000 --- a/pio/dread.h +++ /dev/null @@ -1,183 +0,0 @@ -/*** - * dread.h - * This file is part of the PIO library. - * For license information see "pio.h" in the parent directory. - */ - -#if !defined(PIOLIB) || PIOLIB < 100 -#error This file should be included directly. Use "pio.h" instead. -#endif - -#ifndef PIO_DREAD_H -#define PIO_DREAD_H - -#define dRead(A) dRead_(A) -#define dRead_(A) DREAD ## _ ## A - -#ifdef PA0 -#define DREAD_A0 (PINA & 0x01) -#else -#define DREAD_A0 # Pin A0 not supported on this MCU! -#endif -#ifdef PA1 -#define DREAD_A1 (PINA & 0x02) -#else -#define DREAD_A1 # Pin A1 not supported on this MCU! -#endif -#ifdef PA2 -#define DREAD_A2 (PINA & 0x04) -#else -#define DREAD_A2 # Pin A2 not supported on this MCU! -#endif -#ifdef PA3 -#define DREAD_A3 (PINA & 0x08) -#else -#define DREAD_A3 # Pin A3 not supported on this MCU! -#endif -#ifdef PA4 -#define DREAD_A4 (PINA & 0x10) -#else -#define DREAD_A4 # Pin A4 not supported on this MCU! -#endif -#ifdef PA5 -#define DREAD_A5 (PINA & 0x20) -#else -#define DREAD_A5 # Pin A5 not supported on this MCU! -#endif -#ifdef PA6 -#define DREAD_A6 (PINA & 0x40) -#else -#define DREAD_A6 # Pin A6 not supported on this MCU! -#endif -#ifdef PA7 -#define DREAD_A7 (PINA & 0x80) -#else -#define DREAD_A7 # Pin A7 not supported on this MCU! -#endif - - -#ifdef PB0 -#define DREAD_B0 (PINB & 0x01) -#else -#define DREAD_B0 # Pin B0 not supported on this MCU! -#endif -#ifdef PB1 -#define DREAD_B1 (PINB & 0x02) -#else -#define DREAD_B1 # Pin B1 not supported on this MCU! -#endif -#ifdef PB2 -#define DREAD_B2 (PINB & 0x04) -#else -#define DREAD_B2 # Pin B2 not supported on this MCU! -#endif -#ifdef PB3 -#define DREAD_B3 (PINB & 0x08) -#else -#define DREAD_B3 # Pin B3 not supported on this MCU! -#endif -#ifdef PB4 -#define DREAD_B4 (PINB & 0x10) -#else -#define DREAD_B4 # Pin B4 not supported on this MCU! -#endif -#ifdef PB5 -#define DREAD_B5 (PINB & 0x20) -#else -#define DREAD_B5 # Pin B5 not supported on this MCU! -#endif -#ifdef PB6 -#define DREAD_B6 (PINB & 0x40) -#else -#define DREAD_B6 # Pin B6 not supported on this MCU! -#endif -#ifdef PB7 -#define DREAD_B7 (PINB & 0x80) -#else -#define DREAD_B7 # Pin B7 not supported on this MCU! -#endif - - -#ifdef PC0 -#define DREAD_C0 (PINC & 0x01) -#else -#define DREAD_C0 # Pin C0 not supported on this MCU! -#endif -#ifdef PC1 -#define DREAD_C1 (PINC & 0x02) -#else -#define DREAD_C1 # Pin C1 not supported on this MCU! -#endif -#ifdef PC2 -#define DREAD_C2 (PINC & 0x04) -#else -#define DREAD_C2 # Pin C2 not supported on this MCU! -#endif -#ifdef PC3 -#define DREAD_C3 (PINC & 0x08) -#else -#define DREAD_C3 # Pin C3 not supported on this MCU! -#endif -#ifdef PC4 -#define DREAD_C4 (PINC & 0x10) -#else -#define DREAD_C4 # Pin C4 not supported on this MCU! -#endif -#ifdef PC5 -#define DREAD_C5 (PINC & 0x20) -#else -#define DREAD_C5 # Pin C5 not supported on this MCU! -#endif -#ifdef PC6 -#define DREAD_C6 (PINC & 0x40) -#else -#define DREAD_C6 # Pin C6 not supported on this MCU! -#endif -#ifdef PC7 -#define DREAD_C7 (PINC & 0x80) -#else -#define DREAD_C7 # Pin C7 not supported on this MCU! -#endif - - -#ifdef PD0 -#define DREAD_D0 (PIND & 0x01) -#else -#define DREAD_D0 # Pin D0 not supported on this MCU! -#endif -#ifdef PD1 -#define DREAD_D1 (PIND & 0x02) -#else -#define DREAD_D1 # Pin D1 not supported on this MCU! -#endif -#ifdef PD2 -#define DREAD_D2 (PIND & 0x04) -#else -#define DREAD_D2 # Pin D2 not supported on this MCU! -#endif -#ifdef PD3 -#define DREAD_D3 (PIND & 0x08) -#else -#define DREAD_D3 # Pin D3 not supported on this MCU! -#endif -#ifdef PD4 -#define DREAD_D4 (PIND & 0x10) -#else -#define DREAD_D4 # Pin D4 not supported on this MCU! -#endif -#ifdef PD5 -#define DREAD_D5 (PIND & 0x20) -#else -#define DREAD_D5 # Pin D5 not supported on this MCU! -#endif -#ifdef PD6 -#define DREAD_D6 (PIND & 0x40) -#else -#define DREAD_D6 # Pin D6 not supported on this MCU! -#endif -#ifdef PD7 -#define DREAD_D7 (PIND & 0x80) -#else -#define DREAD_D7 # Pin D7 not supported on this MCU! -#endif -#endif // PIO_DREAD_H diff --git a/pio/dwrite.h b/pio/dwrite.h deleted file mode 100644 index a8ccd2a..0000000 --- a/pio/dwrite.h +++ /dev/null @@ -1,249 +0,0 @@ -/*** - * dwrite.h - * This file is part of the PIO library. - * For license information see "pio.h" in the parent directory. - */ - -#if !defined(PIOLIB) || PIOLIB < 100 -#error This file should be included directly. Use "pio.h" instead. -#endif - -#ifndef PIO_DWRITE_H -#define PIO_DWRITE_H - -#define dWrite(A, B) dWrite_(A, B) -#define dWrite_(A, B) DWRITE ## _ ## A ## _ ## B - -#ifdef PA0 -#define DWRITE_A0_1 PORTA |= 0x01 -#define DWRITE_A0_0 PORTA &= 0xFE -#else -#define DWRITE_A0_1 # Pin A0 not supported on this MCU! -#define DWRITE_A0_0 DWRITE_A0_1 -#endif -#ifdef PA1 -#define DWRITE_A1_1 PORTA |= 0x02 -#define DWRITE_A1_0 PORTA &= 0xFD -#else -#define DWRITE_A1_1 # Pin A1 not supported on this MCU! -#define DWRITE_A1_0 DWRITE_A1_1 -#endif -#ifdef PA2 -#define DWRITE_A2_1 PORTA |= 0x04 -#define DWRITE_A2_0 PORTA &= 0xFB -#else -#define DWRITE_A2_1 # Pin A2 not supported on this MCU! -#define DWRITE_A2_0 DWRITE_A2_1 -#endif -#ifdef PA3 -#define DWRITE_A3_1 PORTA |= 0x08 -#define DWRITE_A3_0 PORTA &= 0xF7 -#else -#define DWRITE_A3_1 # Pin A3 not supported on this MCU! -#define DWRITE_A3_0 DWRITE_A3_1 -#endif -#ifdef PA4 -#define DWRITE_A4_1 PORTA |= 0x10 -#define DWRITE_A4_0 PORTA &= 0xEF -#else -#define DWRITE_A4_1 # Pin A4 not supported on this MCU! -#define DWRITE_A4_0 DWRITE_A4_1 -#endif -#ifdef PA5 -#define DWRITE_A5_1 PORTA |= 0x20 -#define DWRITE_A5_0 PORTA &= 0xDF -#else -#define DWRITE_A5_1 # Pin A5 not supported on this MCU! -#define DWRITE_A5_0 DWRITE_A5_1 -#endif -#ifdef PA6 -#define DWRITE_A6_1 PORTA |= 0x40 -#define DWRITE_A6_0 PORTA &= 0xBF -#else -#define DWRITE_A6_1 # Pin A6 not supported on this MCU! -#define DWRITE_A6_0 DWRITE_A6_1 -#endif -#ifdef PA7 -#define DWRITE_A7_1 PORTA |= 0x80 -#define DWRITE_A7_0 PORTA &= 0x7F -#else -#define DWRITE_A7_1 # Pin A7 not supported on this MCU! -#define DWRITE_A7_0 DWRITE_A7_1 -#endif - - -#ifdef PB0 -#define DWRITE_B0_1 PORTB |= 0x01 -#define DWRITE_B0_0 PORTB &= 0xFE -#else -#define DWRITE_B0_1 # Pin B0 not supported on this MCU! -#define DWRITE_B0_0 DWRITE_B0_1 -#endif -#ifdef PB1 -#define DWRITE_B1_1 PORTB |= 0x02 -#define DWRITE_B1_0 PORTB &= 0xFD -#else -#define DWRITE_B1_1 # Pin B1 not supported on this MCU! -#define DWRITE_B1_0 DWRITE_B1_1 -#endif -#ifdef PB2 -#define DWRITE_B2_1 PORTB |= 0x04 -#define DWRITE_B2_0 PORTB &= 0xFB -#else -#define DWRITE_B2_1 # Pin B2 not supported on this MCU! -#define DWRITE_B2_0 DWRITE_B2_1 -#endif -#ifdef PB3 -#define DWRITE_B3_1 PORTB |= 0x08 -#define DWRITE_B3_0 PORTB &= 0xF7 -#else -#define DWRITE_B3_1 # Pin B3 not supported on this MCU! -#define DWRITE_B3_0 DWRITE_B3_1 -#endif -#ifdef PB4 -#define DWRITE_B4_1 PORTB |= 0x10 -#define DWRITE_B4_0 PORTB &= 0xEF -#else -#define DWRITE_B4_1 # Pin B4 not supported on this MCU! -#define DWRITE_B4_0 DWRITE_B4_1 -#endif -#ifdef PB5 -#define DWRITE_B5_1 PORTB |= 0x20 -#define DWRITE_B5_0 PORTB &= 0xDF -#else -#define DWRITE_B5_1 # Pin B5 not supported on this MCU! -#define DWRITE_B5_0 DWRITE_B5_1 -#endif -#ifdef PB6 -#define DWRITE_B6_1 PORTB |= 0x40 -#define DWRITE_B6_0 PORTB &= 0xBF -#else -#define DWRITE_B6_1 # Pin B6 not supported on this MCU! -#define DWRITE_B6_0 DWRITE_B6_1 -#endif -#ifdef PB7 -#define DWRITE_B7_1 PORTB |= 0x80 -#define DWRITE_B7_0 PORTB &= 0x7F -#else -#define DWRITE_B7_1 # Pin B7 not supported on this MCU! -#define DWRITE_B7_0 DWRITE_B7_1 -#endif - - -#ifdef PC0 -#define DWRITE_C0_1 PORTC |= 0x01 -#define DWRITE_C0_0 PORTC &= 0xFE -#else -#define DWRITE_C0_1 # Pin C0 not supported on this MCU! -#define DWRITE_C0_0 DWRITE_C0_1 -#endif -#ifdef PC1 -#define DWRITE_C1_1 PORTC |= 0x02 -#define DWRITE_C1_0 PORTC &= 0xFD -#else -#define DWRITE_C1_1 # Pin C1 not supported on this MCU! -#define DWRITE_C1_0 DWRITE_C1_1 -#endif -#ifdef PC2 -#define DWRITE_C2_1 PORTC |= 0x04 -#define DWRITE_C2_0 PORTC &= 0xFB -#else -#define DWRITE_C2_1 # Pin C2 not supported on this MCU! -#define DWRITE_C2_0 DWRITE_C2_1 -#endif -#ifdef PC3 -#define DWRITE_C3_1 PORTC |= 0x08 -#define DWRITE_C3_0 PORTC &= 0xF7 -#else -#define DWRITE_C3_1 # Pin C3 not supported on this MCU! -#define DWRITE_C3_0 DWRITE_C3_1 -#endif -#ifdef PC4 -#define DWRITE_C4_1 PORTC |= 0x10 -#define DWRITE_C4_0 PORTC &= 0xEF -#else -#define DWRITE_C4_1 # Pin C4 not supported on this MCU! -#define DWRITE_C4_0 DWRITE_C4_1 -#endif -#ifdef PC5 -#define DWRITE_C5_1 PORTC |= 0x20 -#define DWRITE_C5_0 PORTC &= 0xDF -#else -#define DWRITE_C5_1 # Pin C5 not supported on this MCU! -#define DWRITE_C5_0 DWRITE_C5_1 -#endif -#ifdef PC6 -#define DWRITE_C6_1 PORTC |= 0x40 -#define DWRITE_C6_0 PORTC &= 0xBF -#else -#define DWRITE_C6_1 # Pin C6 not supported on this MCU! -#define DWRITE_C6_0 DWRITE_C6_1 -#endif -#ifdef PC7 -#define DWRITE_C7_1 PORTC |= 0x80 -#define DWRITE_C7_0 PORTC &= 0x7F -#else -#define DWRITE_C7_1 # Pin C7 not supported on this MCU! -#define DWRITE_C7_0 DWRITE_C7_1 -#endif - - -#ifdef PD0 -#define DWRITE_D0_1 PORTD |= 0x01 -#define DWRITE_D0_0 PORTD &= 0xFE -#else -#define DWRITE_D0_1 # Pin D0 not supported on this MCU! -#define DWRITE_D0_0 DWRITE_D0_1 -#endif -#ifdef PD1 -#define DWRITE_D1_1 PORTD |= 0x02 -#define DWRITE_D1_0 PORTD &= 0xFD -#else -#define DWRITE_D1_1 # Pin D1 not supported on this MCU! -#define DWRITE_D1_0 DWRITE_D1_1 -#endif -#ifdef PD2 -#define DWRITE_D2_1 PORTD |= 0x04 -#define DWRITE_D2_0 PORTD &= 0xFB -#else -#define DWRITE_D2_1 # Pin D2 not supported on this MCU! -#define DWRITE_D2_0 DWRITE_D2_1 -#endif -#ifdef PD3 -#define DWRITE_D3_1 PORTD |= 0x08 -#define DWRITE_D3_0 PORTD &= 0xF7 -#else -#define DWRITE_D3_1 # Pin D3 not supported on this MCU! -#define DWRITE_D3_0 DWRITE_D3_1 -#endif -#ifdef PD4 -#define DWRITE_D4_1 PORTD |= 0x10 -#define DWRITE_D4_0 PORTD &= 0xEF -#else -#define DWRITE_D4_1 # Pin D4 not supported on this MCU! -#define DWRITE_D4_0 DWRITE_D4_1 -#endif -#ifdef PD5 -#define DWRITE_D5_1 PORTD |= 0x20 -#define DWRITE_D5_0 PORTD &= 0xDF -#else -#define DWRITE_D5_1 # Pin D5 not supported on this MCU! -#define DWRITE_D5_0 DWRITE_D5_1 -#endif -#ifdef PD6 -#define DWRITE_D6_1 PORTD |= 0x40 -#define DWRITE_D6_0 PORTD &= 0xBF -#else -#define DWRITE_D6_1 # Pin D6 not supported on this MCU! -#define DWRITE_D6_0 DWRITE_D6_1 -#endif -#ifdef PD7 -#define DWRITE_D7_1 PORTD |= 0x80 -#define DWRITE_D7_0 PORTD &= 0x7F -#else -#define DWRITE_D7_1 # Pin D7 not supported on this MCU! -#define DWRITE_D7_0 DWRITE_D7_1 -#endif - - -#endif // PIO_DWRITE_H diff --git a/pio/i2c/impl0.h b/pio/i2c/impl0.h deleted file mode 100644 index 1733b94..0000000 --- a/pio/i2c/impl0.h +++ /dev/null @@ -1,78 +0,0 @@ -/*** - * impl0.h - * This file is part of the PIO library. - * For license information see "pio.h" in the super parent directory. - */ - -#if !defined(PIOLIB) || PIOLIB < 100 -#error This file should be included directly. Use "pio.h" instead. -#endif - -#ifndef F_CPU -#error F_CPU not defined! -#endif - -#ifndef F_I2C -#ifndef PIO_DISABLE_I2C -#warning F_I2C not defined, I2C disabled. -#endif -#else - -#include - -// AVR TWI master transmitter status codes -#define TWS_START 0x08 -#define TWS_REPEATED_START 0x10 -#define TWS_ADDR_ACK 0x18 -#define TWS_ADDR_NOT_ACK 0x20 -#define TWS_DATA_ACK 0x28 -#define TWS_DATA_NOT_ACK 0x30 -#define TWS_ARB_LOST 0x38 - -// functions -void i2cInit(void); -void i2cBeginTransmission(uint8_t); -void i2cSend(uint8_t); -void i2cEndTransmission(void); - -// error function pointer -void (*i2cError)(void) = NULL; - -void i2cInit() { - // i2c clock speed, see SCL frequency formula in datasheet - uint16_t sp = F_CPU / F_I2C - 16; - uint16_t bp = sp; - while(sp > 510) { - TWSR++; - sp /= 4; - } - TWBR = bp / (1<<(2*(TWSR & 0x03)+1)); -} - -void i2cBeginTransmission(uint8_t addr) { - TWCR = _BV(TWEN) | _BV(TWINT) | _BV(TWSTA); - while (!(TWCR & _BV(TWINT))); - if((TWSR & 0xF8) != TWS_START) - i2cError(); - - TWDR = (addr & 0xFE) << 1; - TWCR = _BV(TWEN) | _BV(TWINT); - while (!(TWCR & _BV(TWINT))); - if((TWSR & 0xF8) != TWS_ADDR_ACK) - i2cError(); -} - -void i2cSend(uint8_t b) { - TWDR = b; - TWCR = _BV(TWEN) | _BV(TWINT); - while (!(TWCR & _BV(TWINT))); - if((TWSR & 0xF8) != TWS_DATA_ACK) - i2cError(); -} - -void i2cEndTransmission() { - TWCR = _BV(TWEN) | _BV(TWINT) | _BV(TWSTO); - while (TWCR & _BV(TWSTO)); -} - -#endif diff --git a/pio/mcus.h b/pio/mcus.h deleted file mode 100644 index 0d96938..0000000 --- a/pio/mcus.h +++ /dev/null @@ -1,22 +0,0 @@ -/*** - * mcus.h - * This file is part of the PIO library. - * For license information see "pio.h" in the parent directory. - */ - -#if !defined(PIOLIB) || PIOLIB < 100 -#error This file should be included directly. Use "pio.h" instead. -#endif - -#ifndef PIO_MCUS_H -#define PIO_MCUS_H - -#include "mcus/atmega328p.h" -#include "mcus/atmega16.h" -#include "mcus/atmega1284.h" - -#ifndef MCU -#error No compatible MCU header file found. -#endif - -#endif // PIO_MCUS_H diff --git a/pio/mcus/atmega1284.h b/pio/mcus/atmega1284.h deleted file mode 100644 index 88dc7fc..0000000 --- a/pio/mcus/atmega1284.h +++ /dev/null @@ -1,17 +0,0 @@ -/*** - * atmega1284.h - * This file is part of the PIO library. - * For license information see "pio.h" in the super parent directory. - */ - -#if !defined(PIOLIB) || PIOLIB < 100 -#error This file should not be included directly. Use "pio.h" instead. -#endif - -#ifdef __AVR_ATmega1284__ - -#define MCU ATmega1284 - -#include "../i2c/impl0.h" - -#endif diff --git a/pio/mcus/atmega16.h b/pio/mcus/atmega16.h deleted file mode 100644 index 976b1dd..0000000 --- a/pio/mcus/atmega16.h +++ /dev/null @@ -1,17 +0,0 @@ -/*** - * atmega16.h - * This file is part of the PIO library. - * For license information see "pio.h" in the super parent directory. - */ - -#if !defined(PIOLIB) || PIOLIB < 100 -#error This file should not be included directly. Use "pio.h" instead. -#endif - -#ifdef __AVR_ATmega16__ - -#define MCU ATmega16 - -#include "../i2c/impl0.h" - -#endif diff --git a/pio/mcus/atmega328p.h b/pio/mcus/atmega328p.h deleted file mode 100644 index 14632cc..0000000 --- a/pio/mcus/atmega328p.h +++ /dev/null @@ -1,14 +0,0 @@ -/*** - * atmega328p.h - * This file is part of the PIO library. - * For license information see "pio.h" in the super parent directory. - */ - -#if !defined(PIOLIB) || PIOLIB < 100 -#error This file should not be included directly. Use "pio.h" instead. -#endif - - -#ifdef __AVR_ATmega328P__ -#error Not implemented! -#endif diff --git a/selftest.cpp b/selftest.cpp index f8b532f..911d54e 100644 --- a/selftest.cpp +++ b/selftest.cpp @@ -6,6 +6,7 @@ void testAll(void) testBEBA1(); testDAC0(); testDAC1(); + testMirror(); } void testBEBA0(void) @@ -37,6 +38,8 @@ void testDAC0(void) dac0.setValue(i); _delay_ms(1); } + _delay_ms(100); + dac0.setValue(0); } void testDAC1(void) @@ -46,4 +49,17 @@ void testDAC1(void) dac1.setValue(i); _delay_ms(1); } + _delay_ms(100); + dac1.setValue(0); +} + +void testMirror() +{ + while(1) + { + dac0.setValue(adu.getValue(0)); + dac1.setValue(adu.getValue(1)); + beba0.writePortA(beba0.readPortB()); + beba1.writePortA(sw.readPortB()); + } } diff --git a/selftest.h b/selftest.h index 0957a55..0035ed1 100644 --- a/selftest.h +++ b/selftest.h @@ -1,12 +1,13 @@ #ifndef SELFTEST_H #define SELFTEST_H -#include "vars.h" +#include "global_vars.h" void testAll(void); void testBEBA0(void); void testBEBA1(void); void testDAC0(void); void testDAC1(void); +void testMirror(void); #endif // SELFTEST_H diff --git a/spi.cpp b/spi.cpp index a99cc05..699b8d8 100644 --- a/spi.cpp +++ b/spi.cpp @@ -8,16 +8,11 @@ void SPI::init(void) const { // Konfiguriere SPI DDRs - dMode(SLSL, OUT); - dMode(MOSI, OUT); - dMode(MISO, IN); - dMode(SCLK, OUT); + DDRB |= _BV(SLSL) | _BV(MOSI) | _BV(SCLK); + DDRB &= ~_BV(MISO); // Konfiguriere DMUX DDRs - dMode(DMUX1, OUT); - dMode(DMUX2, OUT); - dMode(DMUX3, OUT); - + DDRD |= _BV(DMUX1) | _BV(DMUX2) | _BV(DMUX3); // aktiviere SPI, Master Modus, SPI Modus 0 // F_SPI = F_CPU / 2 (prescaler 2) @@ -28,23 +23,12 @@ void SPI::init(void) const setAdr(SPIADR::NONE); } -/*void SPI::setFreq(uint32_t freq) const -{ - -}*/ - void SPI::setAdr(uint8_t adr) const { - dWrite(DMUX1, 0); - dWrite(DMUX2, 0); - dWrite(DMUX3, 0); - - if(adr & 0x01) - dWrite(DMUX1, 1); - if(adr & 0x02) - dWrite(DMUX2, 1); - if(adr & 0x04) - dWrite(DMUX3, 1); + PORTD &= ~(_BV(DMUX1) | _BV(DMUX2) | _BV(DMUX3)); + PORTD |= (adr & 0x01) ? _BV(DMUX1) : 0; + PORTD |= (adr & 0x02) ? _BV(DMUX2) : 0; + PORTD |= (adr & 0x04) ? _BV(DMUX3) : 0; } uint8_t SPI::pushByte(uint8_t b) const diff --git a/spi.h b/spi.h index 60cb6f8..4468c3e 100644 --- a/spi.h +++ b/spi.h @@ -2,17 +2,17 @@ #define SPI_H #include +#include #include -#include "pio.h" -#define SLSL B4 -#define MOSI B5 -#define MISO B6 -#define SCLK B7 +#define SLSL PB4 +#define MOSI PB5 +#define MISO PB6 +#define SCLK PB7 -#define DMUX1 D2 -#define DMUX2 D3 -#define DMUX3 D4 +#define DMUX1 PD2 +#define DMUX2 PD3 +#define DMUX3 PD4 enum SPIADR { AA0 = 0, @@ -29,7 +29,6 @@ class SPI public: SPI(void); void init(void) const; - //void setFreq(uint32_t) const; void setAdr(uint8_t) const; uint8_t pushByte(uint8_t) const;