5 * th9x - http://code.google.com/p/th9x
6 * er9x - http://code.google.com/p/er9x
7 * gruvin9x - http://code.google.com/p/gruvin9x
9 * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
23 uint8_t jetiRxBuffer
[32];
27 void telemetryInterrupt10ms()
30 jetiKeys
= JETI_KEY_NOCHANGE
;
31 if (switchState(KEY_UP
)) jetiKeys
&= JETI_KEY_UP
;
32 if (switchState(KEY_DOWN
)) jetiKeys
&= JETI_KEY_DOWN
;
33 if (switchState(KEY_LEFT
)) jetiKeys
&= JETI_KEY_LEFT
;
34 if (switchState(KEY_RIGHT
)) jetiKeys
&= JETI_KEY_RIGHT
;
36 jetiReady
= 0; // invalidate buffer
45 if (jetiKeys
!= 0xff) {
46 UCSR0B
&= ~(1 << TXB80
);
48 if (jetiKeys
& 0x0100)
49 UCSR0B
|= (1 << TXB80
);
71 if (stat
& ((1 << FE0
) | (1 << DOR0
) | (1 << UPE0
))) {
72 // discard buffer and start new on any error
76 else if ((rh
& (1 << RXB80
)) == 0) {
83 else if (rl
== 0xff) {
92 jetiRxBuffer
[jbp
++] = '@'; //@ => ° Issue 163
94 jetiRxBuffer
[jbp
++] = rl
;
100 void JETI_Init (void)
102 DDRE
&= ~(1 << DDE0
); // set RXD0 pin as input
103 PORTE
&= ~(1 << PORTE0
); // disable pullup on RXD0 pin
109 #include <util/setbaud.h>
110 UBRR0H
= UBRRH_VALUE
;
111 UBRR0L
= UBRRL_VALUE
;
113 UCSR0A
&= ~(1 << U2X0
); // disable double speed operation
116 UCSR0C
= (1 << UPM01
) | (1 << UPM00
) | (1 << UCSZ01
) | (1 << UCSZ00
);
117 UCSR0B
= (1 << UCSZ02
);
119 // flush receive buffer
120 while ( UCSR0A
& (1 << RXC0
) ) UDR0
;
125 void JETI_EnableTXD (void)
127 UCSR0B
|= (1 << TXEN0
); // enable TX
128 UCSR0B
|= (1 << UDRIE0
); // enable UDRE0 interrupt
131 void JETI_DisableTXD (void)
133 UCSR0B
&= ~(1 << TXEN0
); // disable TX
134 UCSR0B
&= ~(1 << UDRIE0
); // disable UDRE0 interrupt
137 void JETI_EnableRXD (void)
139 UCSR0B
|= (1 << RXEN0
); // enable RX
140 UCSR0B
|= (1 << RXCIE0
); // enable Interrupt
143 void JETI_DisableRXD (void)
145 UCSR0B
&= ~(1 << RXEN0
); // disable RX
146 UCSR0B
&= ~(1 << RXCIE0
); // disable Interrupt
150 void JETI_putw (uint16_t c
)
152 loop_until_bit_is_set(UCSR0A
, UDRE0
);
153 UCSR0B
&= ~(1 << TXB80
);
156 UCSR0B
|= (1 << TXB80
);
161 void JETI_putc (uint8_t c
)
163 loop_until_bit_is_set(UCSR0A
, UDRE0
);
164 // UCSRB &= ~(1 << TXB8);
165 UCSR0B
|= (1 << TXB80
);
169 void JETI_puts (char *s
)
178 void JETI_put_start (void)
180 loop_until_bit_is_set(UCSR0A
, UDRE0
);
181 UCSR0B
&= ~(1 << TXB80
);
185 void JETI_put_stop (void)
187 loop_until_bit_is_set(UCSR0A
, UDRE0
);
188 UCSR0B
&= ~(1 << TXB80
);
193 void menuViewTelemetryJeti(event_t event
)
195 drawTelemetryTopBar();
197 for (uint8_t i
=0; i
<16; i
++) {
198 lcdDrawChar((i
+2)*FW
, 3*FH
, jetiRxBuffer
[i
], BSS
);
199 lcdDrawChar((i
+2)*FW
, 4*FH
, jetiRxBuffer
[i
+16], BSS
);
202 if (event
== EVT_KEY_FIRST(KEY_EXIT
)) {
205 chainMenu(menuMainView
);