-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathavr_io_test.ino
66 lines (52 loc) · 1.04 KB
/
avr_io_test.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "fast_Digital.h"
#include <Arduino.h>
#define LHS PORTD
#define RHS 42
#define DATATYPE Bit_Mask
REG(PORTD,Bit_Mask)
#undef PORTD
PORTD;
REG(PIND,Bit_Mask)
#undef PIND
PIND;
void setup()
{
PORTD = _B{0,3,5,7};
PORTD = ~PORTD;
PORTD->b0 = true;
PORTD->upper_nibble = 0xF;
PORTD = LHS + RHS;
PORTD = LHS - RHS;
PORTD = LHS * RHS;
PORTD = LHS / RHS;
PORTD = LHS % RHS;
PORTD = LHS ^ RHS;
PORTD = LHS & RHS;
PORTD = LHS | RHS;
PORTD = LHS << RHS;
PORTD = LHS >> RHS;
PORTD += RHS;
PORTD -= RHS;
PORTD *= RHS;
PORTD /= RHS;
PORTD %= RHS;
PORTD &= RHS;
PORTD |= RHS;
PORTD ^= RHS;
PORTD <<= RHS;
PORTD >>= RHS;
if( PORTD && false );
if( !PORTD && false );
}
void loop()
{
}
void inline print_pin_registers(){
for(unsigned i=0; i < NUM_DIGITAL_PINS;++i){
Serial.print( String(F("\n Digital PIN ")) + String(i) + F(" is ") );
switch(digitalPinToPort(i)){
case NOT_A_PIN: Serial.print(F("NOT a pin.")); break;
default: Serial.print( String(F("PORT")) + char(digitalPinToPort(i)-1+'A') ); break;
}
}
}