Rev 902 | Rev 2039 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 902 | Rev 1437 | ||
---|---|---|---|
1 | /**************************************************************************** |
1 | /**************************************************************************** |
2 | * Copyright (C) 2009-2011 by Claas Anders "CaScAdE" Rathje * |
2 | * Copyright (C) 2009-2012 by Claas Anders "CaScAdE" Rathje * |
3 | * admiralcascade@gmail.com * |
3 | * admiralcascade@gmail.com * |
4 | * Project-URL: http://www.mylifesucks.de/oss/c-osd/ * |
4 | * Project-URL: http://www.mylifesucks.de/oss/c-osd/ * |
5 | * * |
5 | * * |
6 | * This program is free software; you can redistribute it and/or modify * |
6 | * This program is free software; you can redistribute it and/or modify * |
7 | * it under the terms of the GNU General Public License as published by * |
7 | * it under the terms of the GNU General Public License as published by * |
8 | * the Free Software Foundation; either version 2 of the License. * |
8 | * the Free Software Foundation; either version 2 of the License. * |
9 | * * |
9 | * * |
10 | * This program is distributed in the hope that it will be useful, * |
10 | * This program is distributed in the hope that it will be useful, * |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
13 | * GNU General Public License for more details. * |
13 | * GNU General Public License for more details. * |
14 | * * |
14 | * * |
15 | * You should have received a copy of the GNU General Public License * |
15 | * You should have received a copy of the GNU General Public License * |
16 | * along with this program; if not, write to the * |
16 | * along with this program; if not, write to the * |
17 | * Free Software Foundation, Inc., * |
17 | * Free Software Foundation, Inc., * |
18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
19 | ****************************************************************************/ |
19 | ****************************************************************************/ |
20 | 20 | ||
21 | #ifndef _MAX7456_SOFTWARE_SPI_H |
21 | #ifndef _MAX7456_SOFTWARE_SPI_H |
22 | #define _MAX7456_SOFTWARE_SPI_H |
22 | #define _MAX7456_SOFTWARE_SPI_H |
23 | 23 | ||
24 | 24 | ||
25 | /* ########################################################################## |
25 | /* ########################################################################## |
26 | * Software SPI to communicate with MAX7456 |
26 | * Software SPI to communicate with MAX7456 |
27 | * ##########################################################################*/ |
27 | * ##########################################################################*/ |
28 | #define MAX_CS_HIGH PORTA |= (1 << PA1); |
28 | #define MAX_CS_HIGH PORTA |= (1 << PA1); |
29 | #define MAX_CS_LOW PORTA &= ~(1 << PA1); |
29 | #define MAX_CS_LOW PORTA &= ~(1 << PA1); |
30 | #define MAX_SDIN_HIGH PORTA |= (1 << PA2); |
30 | #define MAX_SDIN_HIGH PORTA |= (1 << PA2); |
31 | #define MAX_SDIN_LOW PORTA &= ~(1 << PA2); |
31 | #define MAX_SDIN_LOW PORTA &= ~(1 << PA2); |
32 | #define MAX_SCLK_HIGH PORTA |= (1 << PA3); |
32 | #define MAX_SCLK_HIGH PORTA |= (1 << PA3); |
33 | #define MAX_SCLK_LOW PORTA &= ~(1 << PA3); |
33 | #define MAX_SCLK_LOW PORTA &= ~(1 << PA3); |
34 | #define MAX_RESET_HIGH PORTA |= (1 << PA5); |
34 | #define MAX_RESET_HIGH PORTA |= (1 << PA5); |
35 | #define MAX_RESET_LOW PORTA &= ~(1 << PA5); |
35 | #define MAX_RESET_LOW PORTA &= ~(1 << PA5); |
- | 36 | ||
- | 37 | /* ########################################################################## |
|
- | 38 | * MAX7456 Register definitions |
|
- | 39 | * ##########################################################################*/ |
|
- | 40 | ||
- | 41 | #define MAX7456_REG_READ_OFFSET 0x80 |
|
- | 42 | ||
- | 43 | #define MAX7456_VM0 0x00 |
|
- | 44 | #define MAX7456_VM1 0x01 |
|
- | 45 | #define MAX7456_HOS 0x02 |
|
- | 46 | #define MAX7456_VOS 0x03 |
|
- | 47 | #define MAX7456_DMM 0x04 |
|
- | 48 | #define MAX7456_DMAH 0x05 |
|
- | 49 | #define MAX7456_DMAL 0x06 |
|
- | 50 | #define MAX7456_DMDI 0x07 |
|
- | 51 | #define MAX7456_CMM 0x08 |
|
- | 52 | #define MAX7456_CMAH 0x09 |
|
- | 53 | #define MAX7456_CMAL 0x0A |
|
- | 54 | #define MAX7456_CMDI 0x0B |
|
- | 55 | #define MAX7456_OSDM 0x0C |
|
- | 56 | #define MAX7456_RB0 0x10 |
|
- | 57 | #define MAX7456_RB1 0x11 |
|
- | 58 | #define MAX7456_RB2 0x12 |
|
- | 59 | #define MAX7456_RB3 0x13 |
|
- | 60 | #define MAX7456_RB4 0x14 |
|
- | 61 | #define MAX7456_RB5 0x15 |
|
- | 62 | #define MAX7456_RB6 0x16 |
|
- | 63 | #define MAX7456_RB7 0x17 |
|
- | 64 | #define MAX7456_RB8 0x18 |
|
- | 65 | #define MAX7456_RB9 0x19 |
|
- | 66 | #define MAX7456_RB10 0x1A |
|
- | 67 | #define MAX7456_RB11 0x1B |
|
- | 68 | #define MAX7456_RB12 0x1C |
|
- | 69 | #define MAX7456_RB13 0x1D |
|
- | 70 | #define MAX7456_RB14 0x1E |
|
- | 71 | #define MAX7456_RB15 0x1F |
|
- | 72 | #define MAX7456_OSDBL 0x6C |
|
- | 73 | ||
- | 74 | // READ-ONLY REGs |
|
- | 75 | ||
- | 76 | #define MAX7456_STAT 0xA0 |
|
- | 77 | #define MAX7456_DMDO 0xB0 |
|
- | 78 | #define MAX7456_CMDO 0xC0 |
|
36 | 79 | ||
37 | 80 | ||
38 | /* ########################################################################## |
81 | /* ########################################################################## |
39 | * MAX7456 SPI & Display stuff |
82 | * MAX7456 SPI & Display stuff |
40 | * ##########################################################################*/ |
83 | * ##########################################################################*/ |
41 | 84 | ||
42 | /** |
85 | /** |
43 | * Send a byte through SPI |
86 | * Send a byte through SPI |
44 | */ |
87 | */ |
45 | void spi_send(uint8_t); |
88 | void spi_send(uint8_t); |
46 | 89 | ||
47 | /** |
90 | /** |
48 | * Send <byte> to <address> of MAX7456 |
91 | * Send <byte> to <address> of MAX7456 |
49 | */ |
92 | */ |
50 | void spi_send_byte(uint8_t, uint8_t); |
93 | void spi_send_byte(uint8_t, uint8_t); |
51 | 94 | ||
52 | /** |
95 | /** |
53 | * write a <character> to <address> of MAX7456 display memory |
96 | * write a <character> to <address> of MAX7456 display memory |
54 | */ |
97 | */ |
55 | void write_char(uint16_t, char); |
98 | void write_char(uint16_t, char); |
56 | 99 | ||
57 | /** |
100 | /** |
58 | * write a character <attribute> to <address> of MAX7456 display memory |
101 | * write a character <attribute> to <address> of MAX7456 display memory |
59 | */ |
102 | */ |
60 | void write_char_att(uint16_t, char); |
103 | void write_char_att(uint16_t, char); |
61 | /** |
104 | /** |
62 | * write a <character> at <x>/<y> to MAX7456 display memory |
105 | * write a <character> at <x>/<y> to MAX7456 display memory |
63 | */ |
106 | */ |
64 | void write_char_xy(uint8_t, uint8_t, char); |
107 | void write_char_xy(uint8_t, uint8_t, char); |
65 | /** |
108 | /** |
66 | * write a character <attribute> at <x>/<y> to MAX7456 display memory |
109 | * write a character <attribute> at <x>/<y> to MAX7456 display memory |
67 | */ |
110 | */ |
68 | void write_char_att_xy(uint8_t, uint8_t, char attribute); |
111 | void write_char_att_xy(uint8_t, uint8_t, char attribute); |
69 | 112 | ||
70 | /** |
113 | /** |
71 | * clear display memory |
114 | * clear display memory |
72 | * (also sets 8bit mode) |
115 | * (also sets 8bit mode) |
73 | */ |
116 | */ |
74 | void clear(void); |
117 | void clear(void); |
75 | 118 | ||
76 | /** |
119 | /** |
77 | * write an ascii <character> to <address> of MAX7456 display memory |
120 | * write an ascii <character> to <address> of MAX7456 display memory |
78 | */ |
121 | */ |
79 | void write_ascii_char(uint16_t, char); |
122 | void write_ascii_char(uint16_t, char); |
80 | 123 | ||
81 | /** |
124 | /** |
82 | * write an ascii <string> at <x>/<y> to MAX7456 display memory |
125 | * write an ascii <string> at <x>/<y> to MAX7456 display memory |
83 | */ |
126 | */ |
84 | void write_ascii_string(uint8_t, uint8_t, char*); |
127 | void write_ascii_string(uint8_t, uint8_t, char*); |
85 | 128 | ||
86 | /** |
129 | /** |
87 | * write an ascii <string> with lenght <len> at <x>/<y> to MAX7456 display memory |
130 | * write an ascii <string> with lenght <len> at <x>/<y> to MAX7456 display memory |
88 | */ |
131 | */ |
89 | void write_ascii_string_len(uint8_t x, uint8_t y, char *string, uint8_t len); |
132 | void write_ascii_string_len(uint8_t x, uint8_t y, char *string, uint8_t len); |
90 | 133 | ||
91 | /** |
134 | /** |
92 | * write an ascii <string> from progmen at <x>/<y> to MAX7456 display memory |
135 | * write an ascii <string> from progmen at <x>/<y> to MAX7456 display memory |
93 | */ |
136 | */ |
94 | void write_ascii_string_pgm(uint8_t, uint8_t, const char*); |
137 | void write_ascii_string_pgm(uint8_t, uint8_t, const char*); |
95 | 138 | ||
96 | /** |
139 | /** |
97 | * write an <string> from progmen at <x>/<y> downwards to MAX7456 display memory |
140 | * write an <string> from progmen at <x>/<y> downwards to MAX7456 display memory |
98 | */ |
141 | */ |
99 | void write_string_pgm_down(uint8_t, uint8_t, const char*, uint8_t); |
142 | void write_string_pgm_down(uint8_t, uint8_t, const char*, uint8_t); |
100 | 143 | ||
101 | /** |
144 | /** |
102 | * Write a unsigned <number> at <x>/<y> to MAX7456 display memory |
145 | * Write a unsigned <number> at <x>/<y> to MAX7456 display memory |
103 | * <length> represents the length to rightbound the number |
146 | * <length> represents the length to rightbound the number |
104 | * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
147 | * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
105 | */ |
148 | */ |
106 | void write_ndigit_number_u(uint8_t, uint8_t, uint16_t, int16_t, uint8_t); |
149 | void write_ndigit_number_u(uint8_t, uint8_t, uint16_t, int16_t, uint8_t); |
107 | 150 | ||
108 | /** |
151 | /** |
109 | * Write a signed <number> at <x>/<y> to MAX7456 display memory |
152 | * Write a signed <number> at <x>/<y> to MAX7456 display memory |
110 | * <length> represents the length to rightbound the number |
153 | * <length> represents the length to rightbound the number |
111 | * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
154 | * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
112 | */ |
155 | */ |
113 | void write_ndigit_number_s(uint8_t, uint8_t, int16_t, int16_t, uint8_t); |
156 | void write_ndigit_number_s(uint8_t, uint8_t, int16_t, int16_t, uint8_t); |
114 | 157 | ||
115 | /** |
158 | /** |
116 | * Write a unsigned <number> at <x>/<y> to MAX7456 display memory as /10th of value |
159 | * Write a unsigned <number> at <x>/<y> to MAX7456 display memory as /10th of value |
117 | * <length> represents the length to rightbound the number |
160 | * <length> represents the length to rightbound the number |
118 | * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
161 | * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
119 | */ |
162 | */ |
120 | void write_ndigit_number_u_10th(uint8_t, uint8_t, uint16_t, int16_t, uint8_t); |
163 | void write_ndigit_number_u_10th(uint8_t, uint8_t, uint16_t, int16_t, uint8_t); |
121 | 164 | ||
122 | /** |
165 | /** |
123 | * Write a signed <number> at <x>/<y> to MAX7456 display memory as /10th of value |
166 | * Write a signed <number> at <x>/<y> to MAX7456 display memory as /10th of value |
124 | * <length> represents the length to rightbound the number |
167 | * <length> represents the length to rightbound the number |
125 | * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
168 | * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
126 | */ |
169 | */ |
127 | void write_ndigit_number_s_10th(uint8_t, uint8_t, int16_t, int16_t, uint8_t); |
170 | void write_ndigit_number_s_10th(uint8_t, uint8_t, int16_t, int16_t, uint8_t); |
128 | 171 | ||
129 | /** |
172 | /** |
130 | * write <seconds> as human readable time at <x>/<y> to MAX7456 display mem |
173 | * write <seconds> as human readable time at <x>/<y> to MAX7456 display mem |
131 | */ |
174 | */ |
132 | void write_time(uint8_t, uint8_t, uint16_t); |
175 | void write_time(uint8_t, uint8_t, uint16_t); |
133 | 176 | ||
134 | #if (ALLCHARSDEBUG|(WRITECHARS != -1)) |
177 | #if (ALLCHARSDEBUG|(WRITECHARS != -1)) |
135 | /** |
178 | /** |
136 | * for testing write all chars to screen |
179 | * for testing write all chars to screen |
137 | */ |
180 | */ |
138 | void write_all_chars(); |
181 | void write_all_chars(); |
139 | 182 | ||
140 | /** |
183 | /** |
141 | * let the MAX7456 learn a new character at <number> |
184 | * let the MAX7456 learn a new character at <number> |
142 | * with <data>. |
185 | * with <data>. |
143 | */ |
186 | */ |
144 | void learn_char(uint8_t, unsigned char*); |
187 | void learn_char(uint8_t, unsigned char*); |
145 | #endif |
188 | #endif |
146 | 189 | ||
147 | /** |
190 | /** |
148 | * wirte a <position> at <x>/<y> assuming it is a gps position for long-/latitude |
191 | * wirte a <position> at <x>/<y> assuming it is a gps position for long-/latitude |
149 | */ |
192 | */ |
150 | void write_gps_pos(uint8_t, uint8_t, int32_t); |
193 | void write_gps_pos(uint8_t, uint8_t, int32_t); |
151 | 194 | ||
152 | #endif |
195 | #endif |
153 | 196 |