Subversion Repositories MK3Mag

Compare Revisions

Ignore whitespace Rev 28 → Rev 29

/branches/MK3Mag V0.14 Code Redesign Killagreg/uart.c
66,8 → 66,9
#define FALSE 0
#define TRUE 1
 
// keep buffers as small as possible
#define TXD_BUFFER_LEN 100
#define RXD_BUFFER_LEN 100
#define RXD_BUFFER_LEN 30
 
volatile uint8_t txd_buffer[TXD_BUFFER_LEN];
volatile uint8_t rxd_buffer_locked = FALSE;
83,6 → 84,8
uint8_t RequestFlags = 0x00;
uint8_t RequestDebugLabel = 0;
 
uint8_t PC_Connected = 0;
uint8_t FC_Connected = 0;
 
uint8_t MySlaveAddr = 0;
 
137,7 → 140,7
/****************************************************************/
void USART0_Init (void)
{
uint16_t ubrr = (uint16_t) ((uint32_t) SYSCLK/(8 * BAUD_RATE) - 1);
uint16_t ubrr = (uint16_t) ((uint32_t) F_CPU/(8 * BAUD_RATE) - 1);
 
// disable all interrupts before configuration
cli();
202,15 → 205,16
 
 
// 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');
USART0_putchar ('\n');
USART0_putchar ('C');
USART0_putchar ('P');
USART0_putchar (':');
USART0_putchar ('V');
USART0_putchar (0x30 + VERSION_MAJOR);
USART0_putchar ('.');
USART0_putchar (0x30 + VERSION_MINOR/10);
USART0_putchar (0x30 + VERSION_MINOR%10);
USART0_putchar ('\n');
}
 
// ---------------------------------------------------------------------------------
393,11 → 397,11
 
 
// --------------------------------------------------------------------------
int uart_putchar (int8_t c)
int16_t USART0_putchar (int8_t c)
{
// if tx is not enabled return immediatly
if(!(UCSR0B & (1 << TXEN0))) return (0);
if (c == '\n') uart_putchar('\r');
if (c == '\n') USART0_putchar('\r');
// wait until previous character was send
loop_until_bit_is_set(UCSR0A, UDRE0);
// send character
418,10 → 422,10
{
case 'w':// Attitude
Decode64((uint8_t *) &ExternData, sizeof(ExternData), 3, ReceivedBytes);
I2C_WriteAttitude.Nick = ExternData.Attitude[NICK];
I2C_WriteAttitude.Nick = ExternData.Attitude[ROLL];
RequestFlags |= COMPASS_HEADING;
AttitudeSource = ATTITUDE_SOURCE_UART;
RequestFlags |= COMPASS_HEADING;
Orientation = ExternData.Orientation;
FC_Connected = 255;
break;
 
case 'b': // extern control
510,3 → 514,13
RequestFlags &= ~COMPASS_HEADING;
}
}
 
 
void USART0_Print(int8_t *msg)
{
uint8_t i = 0;
while(msg[i] != 0)
{
USART0_putchar(msg[i++]);
}
}