Subversion Repositories Projects

Rev

Rev 1866 | Rev 2099 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
331 cascade 1
/****************************************************************************
2039 - 2
 *   Copyright (C) 2009-2014 by Claas Anders "CaScAdE" Rathje               *
331 cascade 3
 *   admiralcascade@gmail.com                                               *
4
 *   Project-URL: http://www.mylifesucks.de/oss/c-osd/                      *
5
 *                                                                          *
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   *
8
 *   the Free Software Foundation; either version 2 of the License.         *
9
 *                                                                          *
10
 *   This program is distributed in the hope that it will be useful,        *
11
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
12
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
13
 *   GNU General Public License for more details.                           *
14
 *                                                                          *
15
 *   You should have received a copy of the GNU General Public License      *
16
 *   along with this program; if not, write to the                          *
17
 *   Free Software Foundation, Inc.,                                        *
18
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.              *
19
 ****************************************************************************/
20
 
762 - 21
#ifndef _MAX7456_SOFTWARE_SPI_H
22
#define _MAX7456_SOFTWARE_SPI_H
23
 
24
 
331 cascade 25
/* ##########################################################################
26
 * Software SPI to communicate with MAX7456
27
 * ##########################################################################*/
28
#define MAX_CS_HIGH             PORTA |=  (1 << PA1);
29
#define MAX_CS_LOW              PORTA &= ~(1 << PA1);
30
#define MAX_SDIN_HIGH           PORTA |=  (1 << PA2);
31
#define MAX_SDIN_LOW            PORTA &= ~(1 << PA2);
32
#define MAX_SCLK_HIGH           PORTA |=  (1 << PA3);
33
#define MAX_SCLK_LOW            PORTA &= ~(1 << PA3);
34
#define MAX_RESET_HIGH          PORTA |=  (1 << PA5);
35
#define MAX_RESET_LOW           PORTA &= ~(1 << PA5);
36
 
1437 - 37
/* ##########################################################################
38
 * MAX7456 Register definitions
39
 * ##########################################################################*/
331 cascade 40
 
1437 - 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
79
 
80
 
331 cascade 81
/* ##########################################################################
82
 * MAX7456 SPI & Display stuff
83
 * ##########################################################################*/
84
 
85
/**
86
 * Send a byte through SPI
87
 */
88
void spi_send(uint8_t);
89
 
90
/**
91
 *  Send <byte> to <address> of MAX7456
92
 */
93
void spi_send_byte(uint8_t, uint8_t);
94
 
95
/**
96
 *  write a <character> to <address> of MAX7456 display memory
97
 */
98
void write_char(uint16_t, char);
99
 
100
/**
101
 *  write a character <attribute> to <address> of MAX7456 display memory
102
 */
103
void write_char_att(uint16_t, char);
104
/**
105
 *  write a <character> at <x>/<y> to MAX7456 display memory
106
 */
107
void write_char_xy(uint8_t, uint8_t, char);
108
/**
109
 *  write a  character <attribute> at <x>/<y> to MAX7456 display memory
110
 */
111
void write_char_att_xy(uint8_t, uint8_t, char attribute);
112
 
113
/**
404 cascade 114
 *  clear display memory
115
 *  (also sets 8bit mode)
331 cascade 116
 */
117
void clear(void);
118
 
119
/**
120
 *  write an ascii <character> to <address> of MAX7456 display memory
121
 */
122
void write_ascii_char(uint16_t, char);
123
 
124
/**
125
 *  write an ascii <string> at <x>/<y> to MAX7456 display memory
126
 */
127
void write_ascii_string(uint8_t, uint8_t, char*);
128
 
129
/**
783 - 130
 *  write an ascii <string> with lenght <len> at <x>/<y> to MAX7456 display memory
131
 */
132
void write_ascii_string_len(uint8_t x, uint8_t y, char *string, uint8_t len);
133
 
134
/**
346 cascade 135
 *  write an ascii <string> from progmen at <x>/<y> to MAX7456 display memory
136
 */
489 woggle 137
void write_ascii_string_pgm(uint8_t, uint8_t, const char*);
346 cascade 138
 
139
/**
379 cascade 140
 *  write an <string> from progmen at <x>/<y> downwards to MAX7456 display memory
141
 */
489 woggle 142
void write_string_pgm_down(uint8_t, uint8_t, const char*, uint8_t);
379 cascade 143
 
144
/**
519 cascade 145
 * Write a unsigned <number> at <x>/<y> to MAX7456 display memory
146
 * <length> represents the length to rightbound the number
349 cascade 147
 * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of   7
331 cascade 148
 */
349 cascade 149
void write_ndigit_number_u(uint8_t, uint8_t, uint16_t, int16_t, uint8_t);
331 cascade 150
 
151
/**
519 cascade 152
 * Write a signed <number> at <x>/<y> to MAX7456 display memory
153
 * <length> represents the length to rightbound the number
349 cascade 154
 * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of   7
331 cascade 155
 */
349 cascade 156
void write_ndigit_number_s(uint8_t, uint8_t, int16_t, int16_t, uint8_t);
331 cascade 157
 
158
/**
519 cascade 159
 * Write a unsigned <number> at <x>/<y> to MAX7456 display memory as /10th of value
160
 * <length> represents the length to rightbound the number
161
 * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of   7
331 cascade 162
 */
349 cascade 163
void write_ndigit_number_u_10th(uint8_t, uint8_t, uint16_t, int16_t, uint8_t);
331 cascade 164
 
165
/**
519 cascade 166
 * Write a signed <number> at <x>/<y> to MAX7456 display memory as /10th of value
167
 * <length> represents the length to rightbound the number
168
 * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of   7
331 cascade 169
 */
349 cascade 170
void write_ndigit_number_s_10th(uint8_t, uint8_t, int16_t, int16_t, uint8_t);
331 cascade 171
 
172
/**
173
 *  write <seconds> as human readable time at <x>/<y> to MAX7456 display mem
174
 */
175
void write_time(uint8_t, uint8_t, uint16_t);
176
 
736 cascade 177
#if (ALLCHARSDEBUG|(WRITECHARS != -1))
331 cascade 178
/**
179
 * for testing write all chars to screen
180
 */
181
void write_all_chars();
182
 
183
/**
184
 * let the MAX7456 learn a new character at <number>
185
 * with <data>.
186
 */
187
void learn_char(uint8_t, unsigned char*);
736 cascade 188
#endif
412 cascade 189
 
190
/**
191
 * wirte a <position> at <x>/<y> assuming it is a gps position for long-/latitude
192
 */
193
void write_gps_pos(uint8_t, uint8_t, int32_t);
762 - 194
 
195
#endif