66,8 → 66,8 |
#define FALSE 0 |
#define TRUE 1 |
|
#define TXD_BUFFER_LEN 100 |
#define RXD_BUFFER_LEN 100 |
#define TXD_BUFFER_LEN 150 |
#define RXD_BUFFER_LEN 150 |
|
volatile uint8_t txd_buffer[TXD_BUFFER_LEN]; |
volatile uint8_t rxd_buffer_locked = FALSE; |
75,6 → 75,8 |
volatile uint8_t txd_complete = TRUE; |
volatile uint8_t ReceivedBytes = 0; |
|
|
|
uint8_t RequestVerInfo = FALSE; |
uint8_t RequestDebugData = FALSE; |
uint8_t RequestDebugLabel = FALSE; |
109,7 → 111,7 |
"ZOffset ", |
"ZRange ", |
"Calstate ", |
"Heading Request ", //15 |
"Heading ", //15 |
"User0 ", |
"User1 ", |
"Analog18 ", |
162,9 → 164,9 |
|
// USART0 Control and Status Register A, B, C |
|
// enable double speed operation in |
// enable double speed operation |
UCSR0A |= (1 << U2X0); |
// enable receiver and transmitter in |
// enable receiver and transmitter |
UCSR0B |= (1 << TXEN0) | (1 << RXEN0); |
// set asynchronous mode |
UCSR0C &= ~(1 << UMSEL01); |
201,7 → 203,7 |
VersionInfo.Minor = VERSION_MINOR; |
VersionInfo.PCCompatible = VERSION_COMPATIBLE; |
|
// Version beim Start ausgeben (nicht schön, aber geht... ) |
// Version beim Start ausgeben (nicht schön, aber geht... ) |
uart_putchar ('\n');uart_putchar ('C');uart_putchar ('P');uart_putchar (':'); |
uart_putchar ('V');uart_putchar (0x30 + VERSION_MAJOR);uart_putchar ('.');uart_putchar (0x30 + VERSION_MINOR/10); uart_putchar (0x30 + VERSION_MINOR%10); |
uart_putchar ('\n'); |
210,6 → 212,7 |
// --------------------------------------------------------------------------------- |
void USART0_EnableTXD(void) |
{ |
//if(!(UCSR0B & (1 << TXEN0))) return; |
DDRD |= (1<<DDD1); // set TXD pin as output |
UCSR0B |= (1 << TXEN0); // enable TX in USART |
} |
217,6 → 220,9 |
// --------------------------------------------------------------------------------- |
void USART0_DisableTXD(void) |
{ |
//if((UCSR0B & (1 << TXEN0))) return; |
while(!txd_complete){ }; |
|
UCSR0B &= ~(1 << TXEN0); // disable TXD in USART |
DDRD &= ~(1<<DDD1); // set TXD pin as input |
} |
236,7 → 242,7 |
if((tmp_tx == '\r') || (ptr_txd_buffer == TXD_BUFFER_LEN)) |
{ |
ptr_txd_buffer = 0; // reset txd pointer |
txd_complete = 1; // stop transmission |
txd_complete = TRUE; // stop transmission |
} |
UDR0 = tmp_tx; // send current byte will trigger this ISR again |
} |
250,9 → 256,9 |
ISR(USART_RX_vect) |
{ |
static uint16_t crc; |
static uint8_t ptr_rxd_buffer = 0; |
uint8_t crc1, crc2; |
uint8_t c; |
static uint8_t ptr_rxd_buffer = 0; |
|
c = UDR0; // catch the received byte |
|
381,7 → 387,7 |
|
|
// -------------------------------------------------------------------------- |
int16_t uart_putchar (int8_t c) |
int uart_putchar (int8_t c) |
{ |
// if tx is not enabled return immediatly |
if(!(UCSR0B & (1 << TXEN0))) return (0); |
406,7 → 412,6 |
{ |
case 'w':// Attitude |
Decode64((uint8_t *) &ExternData, sizeof(ExternData), 3, ReceivedBytes); |
DebugOut.Analog[15]++; |
RequestCompassHeading = TRUE; |
break; |
|
413,8 → 418,20 |
case 'b': // extern control |
case 'c': // extern control with debug request |
Decode64((uint8_t *) &ExternControl,sizeof(ExternControl), 3,ReceivedBytes); |
#define KEY1 0x01 |
#define KEY2 0x02 |
#define KEY3 0x04 |
#define KEY4 0x08 |
#define KEY5 0x10 |
// use right arrow at display for switching the calstate |
if(ExternControl.RemoteButtons & KEY2) |
{ |
ExternData.CalState++; |
if(ExternData.CalState == 6) ExternData.CalState = 0; |
} |
ExternData.Attitude[0] = ExternControl.Par1; |
ExternData.Attitude[1] = ExternControl.Par2; |
PC_Connected = 255; |
break; |
|
case 'h':// x-1 display columns |