~chloekek/watch

watch/firmware/atmega328p.d -rw-r--r-- 1.9 KiB View raw
88ad0bb7 — ChloĆ© Keep track of the time and display seconds using LEDs a month ago
                                                                                
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
module watch.atmega328p;

/**
 * The purpose of this value can be found in the ATmega328P datasheet.
 */
             enum ADCH   = cast(ubyte*) 0x79;
/** ditto */ enum ADCL   = cast(ubyte*) 0x78;
/** ditto */ enum ADCSRA = cast(ubyte*) 0x7A;
/** ditto */ enum ADMUX  = cast(ubyte*) 0x7C;
/** ditto */ enum ASSR   = cast(ubyte*) 0xB6;
/** ditto */ enum DDRB   = cast(ubyte*) 0x24;
/** ditto */ enum DDRD   = cast(ubyte*) 0x2A;
/** ditto */ enum EICRA  = cast(ubyte*) 0x69;
/** ditto */ enum EIMSK  = cast(ubyte*) 0x3D;
/** ditto */ enum OCR2A  = cast(ubyte*) 0xB3;
/** ditto */ enum PORTB  = cast(ubyte*) 0x25;
/** ditto */ enum PORTD  = cast(ubyte*) 0x2B;
/** ditto */ enum TCCR0A = cast(ubyte*) 0x44;
/** ditto */ enum TCCR0B = cast(ubyte*) 0x45;
/** ditto */ enum TCCR2B = cast(ubyte*) 0xB1;
/** ditto */ enum TCNT0  = cast(ubyte*) 0x46;
/** ditto */ enum TCNT2  = cast(ubyte*) 0xB2;
/** ditto */ enum TIMSK0 = cast(ubyte*) 0x6E;
/** ditto */ enum TIMSK2 = cast(ubyte*) 0x70;

/** ditto */ enum ADEN   = cast(ubyte) 7;
/** ditto */ enum ADIE   = cast(ubyte) 3;
/** ditto */ enum ADPS0  = cast(ubyte) 0;
/** ditto */ enum ADPS1  = cast(ubyte) 1;
/** ditto */ enum ADPS2  = cast(ubyte) 2;
/** ditto */ enum ADSC   = cast(ubyte) 6;
/** ditto */ enum AS2    = cast(ubyte) 5;
/** ditto */ enum CS00   = cast(ubyte) 0;
/** ditto */ enum CS01   = cast(ubyte) 1;
/** ditto */ enum CS02   = cast(ubyte) 2;
/** ditto */ enum CS20   = cast(ubyte) 0;
/** ditto */ enum CS21   = cast(ubyte) 1;
/** ditto */ enum CS22   = cast(ubyte) 2;
/** ditto */ enum REFS0  = cast(ubyte) 6;
/** ditto */ enum REFS1  = cast(ubyte) 7;
/** ditto */ enum TOIE0  = cast(ubyte) 0;
/** ditto */ enum TOIE2  = cast(ubyte) 0;

/**
 * Execute the AVR sei instruction.
 */
nothrow @nogc @trusted
void sei()
{
    import ldc.llvmasm : __asm;
    __asm("sei", "");
}

/**
 * Execute the AVR sleep instruction.
 */
nothrow @nogc @trusted
void sleep()
{
    import ldc.llvmasm : __asm;
    __asm("sleep", "");
}