1 | /* ================================================================== */
|
2 | /* */
|
3 | /* Definitionen allgemein */
|
4 | /* */
|
5 | /* ================================================================== */
|
6 | #ifndef _OL_TM1638_DEF_H_
|
7 | #define _OL_TM1638_DEF_H_
|
8 |
|
9 | #ifndef F_CPU
|
10 | #define F_CPU 3686400UL //STK500
|
11 | //#define F_CPU 8000000UL // ATM128 Board
|
12 | //#define F_CPU 16000000UL // beliebig, auch Arduino
|
13 | #endif //F_CPU
|
14 |
|
15 | #include <avr/io.h>
|
16 | #include <util/delay.h>
|
17 |
|
18 | /* ================================================================== */
|
19 | /* */
|
20 | /* Programmierungsablauf */
|
21 | /* */
|
22 | /* */
|
23 | /* ================================================================== */
|
24 |
|
25 | // Command 1 : Display Mode Setting Command
|
26 | // STRB
|
27 | //
|
28 | // Command 2 : Data Setting Command
|
29 | // STRB
|
30 | //
|
31 | // DATA 1..n : Transfer Display Data
|
32 | // STRB
|
33 | //
|
34 | // Command 4 : Display Control Command
|
35 | // STRB
|
36 | //
|
37 | /* ================================================================== */
|
38 | /* */
|
39 | /* Port und Pin Definitionen */
|
40 | /* */
|
41 | /* ================================================================== */
|
42 |
|
43 | #define SS_DDR DDRD
|
44 | #define SS_PORT PORTD
|
45 | #define SS_DOUT PD0
|
46 | #define SS_SCK PD1
|
47 | #define SS_STB PD2
|
48 |
|
49 | /*====================================================================*/
|
50 | /* */
|
51 | /* Definitionen für TM1638 */
|
52 | /* */
|
53 | /* */
|
54 | /*====================================================================*/
|
55 |
|
56 | //init:
|
57 |
|
58 | //SS_PORT =(1<< SS_STB) | (1<< SS_SCK) | (1<< SS_DOUT)
|
59 | //delay 500 us
|
60 | //SS_PORT =(1<< SS_STB) | (1<< SS_SCK)
|
61 | //delay 1us
|
62 |
|
63 | //**********************************************************************
|
64 | // set Data Command
|
65 | //**********************************************************************
|
66 |
|
67 | // Command Binärwert hexWert
|
68 | //
|
69 | // write data to Displ-Reg 0b0100xxxx 0x
|
70 | // Read KeyScanning Data 0b0100xxxx 0x
|
71 | // Auto Increment 0b0100xxxx 0x
|
72 | // Fixed Adress 0b0100xxxx 0x
|
73 | // Normal Mode 0b0100xxxx 0x
|
74 | // Test Mode 0b0100xxxx 0x
|
75 |
|
76 | //**********************************************************************
|
77 | // set Adress Command
|
78 | //**********************************************************************
|
79 |
|
80 | // Displayaddr Binärwert hexWert
|
81 | //
|
82 | // 0x00 0b11000000 0xC0
|
83 | // 0x01 0b11000001 0xC1
|
84 | // 0x02 0b11000010 0xC2
|
85 | // 0x03 0b11000011 0xC3
|
86 | // 0x04 0b11000100 0xC4
|
87 | // 0x05 0b11000101 0xC5
|
88 | // 0x06 0b11000110 0xC6
|
89 | // 0x07 0b11000111 0xC7
|
90 | // 0x08 0b11001000 0xC8
|
91 | // 0x09 0b11001001 0xC9
|
92 | // 0x0A 0b11001010 0xCA
|
93 | // 0x0B 0b11001011 0xCB
|
94 | // 0x0C 0b11001100 0xCC
|
95 | // 0x0D 0b11001101 0xCD
|
96 | // 0x0E 0b11001110 0xCE
|
97 | // 0x0F 0b11001111 0xCF
|