Code:
/*
* Speakjet Testprogramm
*
*/
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/signal.h>
#include <avr/pgmspace.h>
#include <inttypes.h>
#define MCU_FREQ 16000000L
#define BAUD 9600L
volatile uint16_t ms_count;
#define WP 5
uint8_t announce[] = {
/* welcome */ 145, 131, 145, 4, 195, 136, 140, WP,
/* to */ 192, 162, WP,
/* the */ 169, 134, WP,
/* mavric */ 140, 132, 166, 148, 129, 194, WP,
/* speakjet */ 187, 198, 128, 194, 4, 165, 131, 191, WP,
/* test */ 191, 131, 187, 191, WP,
/* program */ 199, 148, 137, 179, 148, 132, 140
};
#define N_ANNC sizeof(announce)
void UART1_init(uint16_t baud)
{
uint16_t brr;
brr = MCU_FREQ / (16L*(long)baud) - 1;
UBRR1H = brr >> 8;;
UBRR1L = brr & 0x00ff;
UCSR1B = BV(TXEN);
}
void uart_putc(uint8_t uart, char c)
{
if (uart == 0) {
loop_until_bit_is_set(UCSR0A, UDRE);
outp(c, UDR0);
}
else if (uart == 1) {
while ((UCSR1A & BV(UDRE)) == 0)
;
UDR1 = c;
}
}
int main(void)
{
uint8_t i;
UART1_init(BAUD);
for (i=0; i<N_ANNC; i++)
uart_putc(1, announce[i]);
while (1)
;
}
Lesezeichen