Mercurial > ~darius > hgwebdir.cgi > avr
comparison testavr.c @ 17:a58b41b7d15c
Covert to a later version of avr-libc. Stuff like not using inb/outb,
etc..
author | darius |
---|---|
date | Fri, 25 Nov 2005 21:45:51 +1030 |
parents | 026dc24d85e0 |
children | 108a703c39e6 |
comparison
equal
deleted
inserted
replaced
16:026dc24d85e0 | 17:a58b41b7d15c |
---|---|
57 int8_t temp; | 57 int8_t temp; |
58 uint16_t tfrac; | 58 uint16_t tfrac; |
59 | 59 |
60 cli(); | 60 cli(); |
61 | 61 |
62 outp(0xfc, DDRC); | 62 DDRC = 0xfc; |
63 outp(0x00, PORTC); | 63 PORTC = 0x00; |
64 DDRA = 0xff; | 64 DDRA = 0xff; |
65 | 65 |
66 /* Init UART */ | 66 /* Init UART */ |
67 outp(UART_BAUD_SELECT(UART_BAUD_RATE,XTAL_CPU), UBRR); | 67 UBRR = UART_BAUD_SELECT(UART_BAUD_RATE,XTAL_CPU); |
68 | 68 |
69 /* Enable receiver and transmitter. Turn on transmit interrupts */ | 69 /* Enable receiver and transmitter. Turn on transmit interrupts */ |
70 outp(BV(RXEN) | BV(TXEN), UCR); | 70 UCR = _BV(RXEN) | _BV(TXEN); |
71 | 71 |
72 uart_putsP(PSTR("\n\r\n\r===============\n\r" | 72 uart_putsP(PSTR("\n\r\n\r===============\n\r" |
73 "Inited!\n\r\n\r")); | 73 "Inited!\n\r\n\r")); |
74 | 74 |
75 while (1) { | 75 while (1) { |
314 } | 314 } |
315 | 315 |
316 int | 316 int |
317 uart_putc(char c) { | 317 uart_putc(char c) { |
318 loop_until_bit_is_set(USR, UDRE); | 318 loop_until_bit_is_set(USR, UDRE); |
319 outp(c, UDR); | 319 UDR = c; |
320 | 320 |
321 return(0); | 321 return(0); |
322 } | 322 } |
323 | 323 |
324 void | 324 void |
325 uart_putsP(const char *addr) { | 325 uart_putsP(const char *addr) { |
326 char c; | 326 char c; |
327 | 327 |
328 while ((c = PRG_RDB((unsigned short)addr++))) | 328 while ((c = pgm_read_byte_near(addr++))) |
329 uart_putc(c); | 329 uart_putc(c); |
330 } | 330 } |
331 | 331 |
332 void | 332 void |
333 uart_puts(const char *addr) { | 333 uart_puts(const char *addr) { |
354 uart_puts(utoa(a, s, 16)); | 354 uart_puts(utoa(a, s, 16)); |
355 } | 355 } |
356 | 356 |
357 int | 357 int |
358 uart_getc(void) { | 358 uart_getc(void) { |
359 while (!(inp(USR) & 0x80)) | 359 while (!USR & 0x80) |
360 ; | 360 ; |
361 | 361 |
362 return (inp(UDR)); | 362 return (UDR); |
363 } | 363 } |
364 | 364 |