pio entfernt & spiegel test routine
This commit is contained in:
parent
b7b3fa6327
commit
13e95264fb
172
B15F.hex
172
B15F.hex
|
@ -6,93 +6,91 @@
|
||||||
:100050000C9464000C9464000C9464000C94640090
|
:100050000C9464000C9464000C9464000C94640090
|
||||||
:100060000C9464000C9464000C9464000C94640080
|
:100060000C9464000C9464000C9464000C94640080
|
||||||
:100070000C9464000C9464000C9464000C94640070
|
:100070000C9464000C9464000C9464000C94640070
|
||||||
:100080000C9464000C9464000C946400D10211245C
|
:100080000C9464000C9464000C946400C602112467
|
||||||
:100090001FBECFEFD0E4DEBFCDBF21E0A0E0B1E0D6
|
:100090001FBECFEFD0E4DEBFCDBF21E0A0E0B1E0D6
|
||||||
:1000A00001C01D92A131B207E1F710E0C7E4D0E032
|
:1000A00001C01D92A131B207E1F710E0C7E4D0E032
|
||||||
:1000B00004C02197FE010E94F802C634D107C9F797
|
:1000B00004C02197FE010E94ED02C634D107C9F7A2
|
||||||
:1000C0000E94CC020C9401030C9400001F920F922A
|
:1000C0000E94C1020C94F6020C9400001F920F9241
|
||||||
:1000D0000FB60F921124289A2FEF84E39CE0215051
|
:1000D0000FB60F92112491E085B1892785B92FEFD2
|
||||||
:1000E00080409040E1F700C0000028982FEF84E3A3
|
:1000E00034E38CE0215030408040E1F700C0000054
|
||||||
:1000F0009CE0215080409040E1F700C00000EBCF31
|
:1000F000F3CF80E191E00E949B0060E08DE091E011
|
||||||
:1001000080E191E00E94A20060E08DE091E00E9419
|
:100100000E94DE006FEF8DE091E00E94FF0060E052
|
||||||
:10011000C9006FEF8DE091E00E94EA0060E08AE0A4
|
:100110008AE091E00E94DE006FEF8AE091E00E94A9
|
||||||
:1001200091E00E94C9006FEF8AE091E00E94EA002E
|
:10012000FF006FEF87E091E00E94FF0080E091E028
|
||||||
:100130006FEF87E091E00E94EA0080E091E00C948C
|
:100130000C94D401089584B1806B84B926988AB157
|
||||||
:10014000BF010895249A259A2698279A529A539A7D
|
:100140008C618AB980E58CBD81E08DBD8BB1837EE9
|
||||||
:10015000549A80E58CBD81E08DBD5A985B985C987F
|
:100150008BB95A9A5B9A5C9A08958BB1837E8BB95E
|
||||||
:100160005A9A5B9A5C9A08955A985B985C9860FDDD
|
:100160008BB160FD10C090E0892B8BB98BB161FD24
|
||||||
:100170005A9A61FD5B9A62FD5C9A08956EBD0DB45A
|
:1001700010C090E0892B8BB98BB162FD10C090E06C
|
||||||
:1001800007FEFDCF8EB50895FC0171836083428325
|
:10018000892B8BB9089594E0892B8BB98BB161FFD2
|
||||||
:1001900008951F93CF93DF93EC01162F6A81888116
|
:10019000F0CF98E0892B8BB98BB162FFF0CF90E163
|
||||||
:1001A00099810E94B40060E4888199810E94BE0018
|
:1001A000892B8BB908956EBD0DB407FEFDCF8EB5BA
|
||||||
:1001B00060E0888199810E94BE00612F88819981C9
|
:1001B0000895FC0171836083428308951F93CF9358
|
||||||
:1001C0000E94BE0067E088819981DF91CF911F91E5
|
:1001C000DF93EC01162F6A81888199810E94AD002E
|
||||||
:1001D0000C94B4001F93CF93DF93EC01162F6A8128
|
:1001D00060E4888199810E94D30060E088819981E0
|
||||||
:1001E000888199810E94B40060E4888199810E948D
|
:1001E0000E94D300612F888199810E94D30067E02B
|
||||||
:1001F000BE0061E0888199810E94BE00612F8881E4
|
:1001F00088819981DF91CF911F910C94AD001F935D
|
||||||
:1002000099810E94BE0067E088819981DF91CF913A
|
:10020000CF93DF93EC01162F6A81888199810E9438
|
||||||
:100210001F910C94B4001F93CF93DF93EC01162F22
|
:10021000AD0060E4888199810E94D30061E088810B
|
||||||
:100220006A81888199810E94B40060E48881998103
|
:1002200099810E94D300612F888199810E94D30017
|
||||||
:100230000E94BE0062E1888199810E94BE00612F08
|
:1002300067E088819981DF91CF911F910C94AD0087
|
||||||
:10024000888199810E94BE0067E088819981DF9151
|
:100240001F93CF93DF93EC01162F6A8188819981E8
|
||||||
:10025000CF911F910C94B4001F93CF93DF93EC01C7
|
:100250000E94AD0060E4888199810E94D30062E130
|
||||||
:10026000162F6A81888199810E94B40060E4888198
|
:10026000888199810E94D300612F888199810E94A1
|
||||||
:1002700099810E94BE0063E1888199810E94BE003D
|
:10027000D30067E088819981DF91CF911F910C9421
|
||||||
:10028000612F888199810E94BE0067E088819981F1
|
:10028000AD001F93CF93DF93EC01162F6A81888115
|
||||||
:10029000DF91CF911F910C94B4001F93CF93DF9304
|
:1002900099810E94AD0060E4888199810E94D30019
|
||||||
:1002A000EC016A81888199810E94B40061E48881AF
|
:1002A00063E1888199810E94D300612F88819981BF
|
||||||
:1002B00099810E94BE0062E1888199810E94BE00FE
|
:1002B0000E94D30067E088819981DF91CF911F91DF
|
||||||
:1002C00060E0888199810E94BE00182F67E08881D4
|
:1002C0000C94AD001F93CF93DF93EC016A8188817A
|
||||||
:1002D00099810E94B400812FDF91CF911F910895E1
|
:1002D00099810E94AD0061E4888199810E94D300D8
|
||||||
:1002E0001F93CF93DF93EC016A81888199810E94EB
|
:1002E00062E1888199810E94D30060E088819981D0
|
||||||
:1002F000B40061E4888199810E94BE0063E1888135
|
:1002F0000E94D300182F67E0888199810E94AD0089
|
||||||
:1003000099810E94BE0060E0888199810E94BE00B0
|
:10030000812FDF91CF911F9108951F93CF93DF939A
|
||||||
:10031000182F67E0888199810E94B400812FDF91B6
|
:10031000EC016A81888199810E94AD0061E4888145
|
||||||
:10032000CF911F910895FC01428308950F931F936D
|
:1003200099810E94D30063E1888199810E94D30062
|
||||||
:10033000CF93DF93EC018B016A81888199810E94C0
|
:1003300060E0888199810E94D300182F67E088814E
|
||||||
:10034000B400B8010024660F771F001C660F771FEA
|
:1003400099810E94AD00812FDF91CF911F91089577
|
||||||
:10035000001C672F702D888199810E94BE00602F3C
|
:10035000FC01428308950F931F93CF93DF93EC0129
|
||||||
:10036000660F660F888199810E94BE0067E08881D0
|
:100360008B016A81888199810E94AD00B8010024C7
|
||||||
:100370009981DF91CF911F910F910C94B40010924D
|
:10037000660F771F001C660F771F001C672F702DFC
|
||||||
:100380007C0087E880937A00089580917C00807ECD
|
:10038000888199810E94D300602F660F660F888153
|
||||||
:10039000682B60937C0080917A00806480937A005F
|
:1003900099810E94D30067E088819981DF91CF9194
|
||||||
:1003A00083EA91E00197F1F700C0000080917A00A4
|
:1003A0001F910F910C94AD0010927C0087E8809310
|
||||||
:1003B00086FDFCCF809178009091790008950F938D
|
:1003B0007A00089580917C00807E682B60937C0099
|
||||||
:1003C0001F93CF93DF9361E08DE091E00E940B01DA
|
:1003C00080917A00806480937A0083EA91E00197BB
|
||||||
:1003D000C1E0D0E001E010E02FEF84E39CE0215089
|
:1003D000F1F700C0000080917A0086FDFCCF80918B
|
||||||
:1003E00080409040E1F700C00000B8010C2E01C031
|
:1003E00078009091790008950F931F93CF93DF9336
|
||||||
:1003F000660F0A94EAF78DE091E00E940B012196C6
|
:1003F00061E08DE091E00E942001C1E0D0E001E0E9
|
||||||
:10040000C930D10549F761E08AE091E00E940B0113
|
:1004000010E02FEF84E39CE0215080409040E1F722
|
||||||
:10041000C1E0D0E001E010E08FEF94E32CE08150E8
|
:1004100000C00000B8010C2E01C0660F0A94EAF774
|
||||||
:1004200090402040E1F700C00000B8010C2E01C050
|
:100420008DE091E00E9420012196C930D10549F765
|
||||||
:10043000660F0A94EAF78AE091E00E940B01219688
|
:10043000DF91CF911F910F9108950F931F93CF9349
|
||||||
:10044000C930D10549F7C0E0D0E0BE0184E091E0B9
|
:10044000DF9361E08AE091E00E942001C1E0D0E00A
|
||||||
:100450000E94960187E893E10197F1F700C0000040
|
:1004500001E010E02FEF84E39CE0215080409040C9
|
||||||
:100460002196C11594E0D90781F7C0E0D0E0BE0124
|
:10046000E1F700C00000B8010C2E01C0660F0A942D
|
||||||
:1004700081E091E00E94960187E893E10197F1F70E
|
:10047000EAF78AE091E00E9420012196C930D10577
|
||||||
:1004800000C000002196C11594E0D90781F7DF91E3
|
:1004800049F7DF91CF911F910F910895CF93DF939B
|
||||||
:10049000CF911F910F9108950F931F93CF93DF93E7
|
:10049000C0E0D0E0BE0184E091E00E94AB0187E8BB
|
||||||
:1004A00061E08DE091E00E940B01C1E0D0E001E04D
|
:1004A00093E10197F1F700C000002196C11594E097
|
||||||
:1004B00010E02FEF84E39CE0215080409040E1F772
|
:1004B000D90781F72FE78AE196E0215080409040EC
|
||||||
:1004C00000C00000B8010C2E01C0660F0A94EAF7C4
|
:1004C000E1F700C0000060E070E084E091E0DF91BF
|
||||||
:1004D0008DE091E00E940B012196C930D10549F7CA
|
:1004D000CF910C94AB01CF93DF93C0E0D0E0BE018D
|
||||||
:1004E000DF91CF911F910F9108950F931F93CF9399
|
:1004E00081E091E00E94AB0187E893E10197F1F789
|
||||||
:1004F000DF9361E08AE091E00E940B01C1E0D0E06F
|
:1004F00000C000002196C11594E0D90781F72FE7CD
|
||||||
:1005000001E010E02FEF84E39CE021508040904018
|
:100500008AE196E0215080409040E1F700C0000071
|
||||||
:10051000E1F700C00000B8010C2E01C0660F0A947C
|
:1005100060E070E081E091E0DF91CF910C94AB015D
|
||||||
:10052000EAF78AE091E00E940B012196C930D105DB
|
:1005200060E080E091E00E94DA01BC0184E091E0AB
|
||||||
:1005300049F7DF91CF911F910F910895CF93DF93EA
|
:100530000E94AB0161E080E091E00E94DA01BC0121
|
||||||
:10054000C0E0D0E0BE0184E091E00E94960187E81F
|
:1005400081E091E00E94AB018DE091E00E94850185
|
||||||
:1005500093E10197F1F700C000002196C11594E0E6
|
:10055000682F8DE091E00E94200187E091E00E94E9
|
||||||
:10056000D90781F7DF91CF910895CF93DF93C0E052
|
:100560008501682F8AE091E00E942001D9CF0E9486
|
||||||
:10057000D0E0BE0181E091E00E94960187E893E11E
|
:10057000F4010E941D020E9446020E946B020E942A
|
||||||
:100580000197F1F700C000002196C11594E0D9074A
|
:1005800090020E9479000E94B702FDCF80E191E0C5
|
||||||
:1005900081F7DF91CF9108950E9480000E94DF01D2
|
:100590000E949A0042E060E171E08DE091E00E94EB
|
||||||
:1005A000FDCF80E191E00E94A10042E060E171E0B6
|
:1005A000D90043E060E171E08AE091E00E94D90067
|
||||||
:1005B0008DE091E00E94C40043E060E171E08AE0D8
|
:1005B00045E060E171E087E091E00E94D90040E011
|
||||||
:1005C00091E00E94C40045E060E171E087E091E0C5
|
:1005C00060E171E084E091E00E94A80141E060E117
|
||||||
:1005D0000E94C40040E060E171E084E091E00E948C
|
:1005D00071E081E091E00C94A801EE0FFF1F002470
|
||||||
:1005E000930141E060E171E081E091E00C949301BE
|
:1005E000001C0BBE0790F691E02D0994F894FFCF04
|
||||||
:1005F000EE0FFF1F0024001C0BBE0790F691E02DAC
|
|
||||||
:060600000994F894FFCFFD
|
|
||||||
:00000001FF
|
:00000001FF
|
||||||
|
|
2
Makefile
2
Makefile
|
@ -12,7 +12,7 @@ OUTPUT = B15F.elf
|
||||||
HEX = B15F.hex
|
HEX = B15F.hex
|
||||||
CFLAGS = -std=c++14 -O3 -mmcu=atmega1284 -DF_CPU=20000000 -DPIO_DISABLE_I2C
|
CFLAGS = -std=c++14 -O3 -mmcu=atmega1284 -DF_CPU=20000000 -DPIO_DISABLE_I2C
|
||||||
LDFLAGS =
|
LDFLAGS =
|
||||||
OBJECTS = main.o spi.o mcp23s17.o tlc5615.o adu.o selftest.o vars.o
|
OBJECTS = main.o spi.o mcp23s17.o tlc5615.o adu.o selftest.o global_vars.o
|
||||||
|
|
||||||
|
|
||||||
COMPILE = $(COMPILER_PATH) $(CFLAGS)
|
COMPILE = $(COMPILER_PATH) $(CFLAGS)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "vars.h"
|
#include "global_vars.h"
|
||||||
|
|
||||||
SPI spi;
|
SPI spi;
|
||||||
MCP23S17 beba0(spi, SPIADR::BEBA0);
|
MCP23S17 beba0(spi, SPIADR::BEBA0);
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef VARS_H
|
#ifndef GLOBAL_VARS_H
|
||||||
#define VARS_H
|
#define GLOBAL_VARS_H
|
||||||
|
|
||||||
#include "mcp23s17.h"
|
#include "mcp23s17.h"
|
||||||
#include "tlc5615.h"
|
#include "tlc5615.h"
|
||||||
|
@ -13,4 +13,4 @@ extern TLC5615 dac0;
|
||||||
extern TLC5615 dac1;
|
extern TLC5615 dac1;
|
||||||
extern ADU adu;
|
extern ADU adu;
|
||||||
|
|
||||||
#endif // VARS_H
|
#endif // GLOBAL_VARS_H
|
12
main.cpp
12
main.cpp
|
@ -2,19 +2,17 @@
|
||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
#include <util/delay.h>
|
#include <util/delay.h>
|
||||||
#include <avr/wdt.h>
|
#include <avr/wdt.h>
|
||||||
#include "vars.h"
|
#include "global_vars.h"
|
||||||
#include "selftest.h"
|
#include "selftest.h"
|
||||||
|
|
||||||
|
|
||||||
#define LED B0
|
#define LED PB0
|
||||||
|
|
||||||
ISR(WDT_vect)
|
ISR(WDT_vect)
|
||||||
{
|
{
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
dWrite(LED, HIGH);
|
PORTB ^= _BV(LED);
|
||||||
_delay_ms(200);
|
|
||||||
dWrite(LED, LOW);
|
|
||||||
_delay_ms(200);
|
_delay_ms(200);
|
||||||
}
|
}
|
||||||
WDTCSR |= _BV(WDIE);
|
WDTCSR |= _BV(WDIE);
|
||||||
|
@ -36,8 +34,8 @@ void initAll()
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
/*WDTCSR = _BV(WDIE) | _BV(WDP3) | _BV(WDP0);
|
/*WDTCSR = _BV(WDIE) | _BV(WDP3) | _BV(WDP0);
|
||||||
dMode(LED, OUT);
|
DDRB |= _BV(LED);
|
||||||
dWrite(LED, LOW);
|
PORTB &= ~_BV(LED);
|
||||||
wdt_reset();
|
wdt_reset();
|
||||||
sei();*/
|
sei();*/
|
||||||
|
|
||||||
|
|
95
pio.h
95
pio.h
|
@ -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 <https://opensource.org/licenses/MIT>.
|
|
||||||
*
|
|
||||||
* How does it work?
|
|
||||||
* ----------------------------------------------
|
|
||||||
* Instead of the classical way
|
|
||||||
* (1a) DDRA |= (1<<PA0);
|
|
||||||
* you can now write
|
|
||||||
* (1b) dMode(A0, OUT);
|
|
||||||
*
|
|
||||||
* It gets directly replaced by the fast
|
|
||||||
* PORT manipulation command (1a) using
|
|
||||||
* preprocessor macros. This way, PIO
|
|
||||||
* does not increase the overall memory
|
|
||||||
* consumption or slow down the execution
|
|
||||||
* like Arduino does.
|
|
||||||
*
|
|
||||||
* Why using PIO? The Port commands are enough...
|
|
||||||
* ----------------------------------------------
|
|
||||||
* First, the code gets a bit more readable,
|
|
||||||
* especially for beginners.
|
|
||||||
* Second, you can define pins regardless
|
|
||||||
* their corresponding port, resulting in
|
|
||||||
* a more flexible code. For instance:
|
|
||||||
* (2a) #define LED A0
|
|
||||||
* dMode(LED, OUT);
|
|
||||||
* dWrite(LED, HIGH);
|
|
||||||
* If you now choose another pin, the rest
|
|
||||||
* of the code can stay the same and PIO
|
|
||||||
* will take care of the right PORT commands.
|
|
||||||
* (2b) #define LED D6 // this changed
|
|
||||||
* dMode(LED, OUT); // same command
|
|
||||||
* dWrite(LED, HIGH); // same command
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef PIO_H
|
|
||||||
#define PIO_H
|
|
||||||
|
|
||||||
// current version
|
|
||||||
#define PIOLIB 100
|
|
||||||
|
|
||||||
#include <avr/io.h>
|
|
||||||
|
|
||||||
#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
|
|
248
pio/dmode.h
248
pio/dmode.h
|
@ -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
|
|
183
pio/dread.h
183
pio/dread.h
|
@ -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
|
|
249
pio/dwrite.h
249
pio/dwrite.h
|
@ -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
|
|
|
@ -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 <stdlib.h>
|
|
||||||
|
|
||||||
// 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
|
|
22
pio/mcus.h
22
pio/mcus.h
|
@ -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
|
|
|
@ -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
|
|
|
@ -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
|
|
|
@ -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
|
|
16
selftest.cpp
16
selftest.cpp
|
@ -6,6 +6,7 @@ void testAll(void)
|
||||||
testBEBA1();
|
testBEBA1();
|
||||||
testDAC0();
|
testDAC0();
|
||||||
testDAC1();
|
testDAC1();
|
||||||
|
testMirror();
|
||||||
}
|
}
|
||||||
|
|
||||||
void testBEBA0(void)
|
void testBEBA0(void)
|
||||||
|
@ -37,6 +38,8 @@ void testDAC0(void)
|
||||||
dac0.setValue(i);
|
dac0.setValue(i);
|
||||||
_delay_ms(1);
|
_delay_ms(1);
|
||||||
}
|
}
|
||||||
|
_delay_ms(100);
|
||||||
|
dac0.setValue(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void testDAC1(void)
|
void testDAC1(void)
|
||||||
|
@ -46,4 +49,17 @@ void testDAC1(void)
|
||||||
dac1.setValue(i);
|
dac1.setValue(i);
|
||||||
_delay_ms(1);
|
_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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
#ifndef SELFTEST_H
|
#ifndef SELFTEST_H
|
||||||
#define SELFTEST_H
|
#define SELFTEST_H
|
||||||
|
|
||||||
#include "vars.h"
|
#include "global_vars.h"
|
||||||
|
|
||||||
void testAll(void);
|
void testAll(void);
|
||||||
void testBEBA0(void);
|
void testBEBA0(void);
|
||||||
void testBEBA1(void);
|
void testBEBA1(void);
|
||||||
void testDAC0(void);
|
void testDAC0(void);
|
||||||
void testDAC1(void);
|
void testDAC1(void);
|
||||||
|
void testMirror(void);
|
||||||
|
|
||||||
#endif // SELFTEST_H
|
#endif // SELFTEST_H
|
||||||
|
|
30
spi.cpp
30
spi.cpp
|
@ -8,16 +8,11 @@ void SPI::init(void) const
|
||||||
{
|
{
|
||||||
|
|
||||||
// Konfiguriere SPI DDRs
|
// Konfiguriere SPI DDRs
|
||||||
dMode(SLSL, OUT);
|
DDRB |= _BV(SLSL) | _BV(MOSI) | _BV(SCLK);
|
||||||
dMode(MOSI, OUT);
|
DDRB &= ~_BV(MISO);
|
||||||
dMode(MISO, IN);
|
|
||||||
dMode(SCLK, OUT);
|
|
||||||
|
|
||||||
// Konfiguriere DMUX DDRs
|
// Konfiguriere DMUX DDRs
|
||||||
dMode(DMUX1, OUT);
|
DDRD |= _BV(DMUX1) | _BV(DMUX2) | _BV(DMUX3);
|
||||||
dMode(DMUX2, OUT);
|
|
||||||
dMode(DMUX3, OUT);
|
|
||||||
|
|
||||||
|
|
||||||
// aktiviere SPI, Master Modus, SPI Modus 0
|
// aktiviere SPI, Master Modus, SPI Modus 0
|
||||||
// F_SPI = F_CPU / 2 (prescaler 2)
|
// F_SPI = F_CPU / 2 (prescaler 2)
|
||||||
|
@ -28,23 +23,12 @@ void SPI::init(void) const
|
||||||
setAdr(SPIADR::NONE);
|
setAdr(SPIADR::NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*void SPI::setFreq(uint32_t freq) const
|
|
||||||
{
|
|
||||||
|
|
||||||
}*/
|
|
||||||
|
|
||||||
void SPI::setAdr(uint8_t adr) const
|
void SPI::setAdr(uint8_t adr) const
|
||||||
{
|
{
|
||||||
dWrite(DMUX1, 0);
|
PORTD &= ~(_BV(DMUX1) | _BV(DMUX2) | _BV(DMUX3));
|
||||||
dWrite(DMUX2, 0);
|
PORTD |= (adr & 0x01) ? _BV(DMUX1) : 0;
|
||||||
dWrite(DMUX3, 0);
|
PORTD |= (adr & 0x02) ? _BV(DMUX2) : 0;
|
||||||
|
PORTD |= (adr & 0x04) ? _BV(DMUX3) : 0;
|
||||||
if(adr & 0x01)
|
|
||||||
dWrite(DMUX1, 1);
|
|
||||||
if(adr & 0x02)
|
|
||||||
dWrite(DMUX2, 1);
|
|
||||||
if(adr & 0x04)
|
|
||||||
dWrite(DMUX3, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t SPI::pushByte(uint8_t b) const
|
uint8_t SPI::pushByte(uint8_t b) const
|
||||||
|
|
17
spi.h
17
spi.h
|
@ -2,17 +2,17 @@
|
||||||
#define SPI_H
|
#define SPI_H
|
||||||
|
|
||||||
#include <util/delay.h>
|
#include <util/delay.h>
|
||||||
|
#include <avr/io.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "pio.h"
|
|
||||||
|
|
||||||
#define SLSL B4
|
#define SLSL PB4
|
||||||
#define MOSI B5
|
#define MOSI PB5
|
||||||
#define MISO B6
|
#define MISO PB6
|
||||||
#define SCLK B7
|
#define SCLK PB7
|
||||||
|
|
||||||
#define DMUX1 D2
|
#define DMUX1 PD2
|
||||||
#define DMUX2 D3
|
#define DMUX2 PD3
|
||||||
#define DMUX3 D4
|
#define DMUX3 PD4
|
||||||
|
|
||||||
enum SPIADR {
|
enum SPIADR {
|
||||||
AA0 = 0,
|
AA0 = 0,
|
||||||
|
@ -29,7 +29,6 @@ class SPI
|
||||||
public:
|
public:
|
||||||
SPI(void);
|
SPI(void);
|
||||||
void init(void) const;
|
void init(void) const;
|
||||||
//void setFreq(uint32_t) const;
|
|
||||||
void setAdr(uint8_t) const;
|
void setAdr(uint8_t) const;
|
||||||
uint8_t pushByte(uint8_t) const;
|
uint8_t pushByte(uint8_t) const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue