Changeset 6d8c366 in avrstuff for chiptest/main.c


Ignore:
Timestamp:
Jul 29, 2014, 10:37:32 PM (10 years ago)
Author:
Adrien Destugues <pulkomandy@…>
Branches:
main
Children:
d31c2f5
Parents:
cd3a9ac
Message:

Chiptest: use libusart.

git-svn-id: svn://pulkomandy.tk/avrstuff@110 c6672c3c-f6b6-47f9-9001-1fd6b12fecbe

File:
1 edited

Legend:

Unmodified
Added
Removed
  • chiptest/main.c

    rcd3a9ac r6d8c366  
     1#include <usart.h>
     2
    13#include <avr/io.h>
    24#include <avr/interrupt.h>
     
    1214#define DDRLED DDRB
    1315#define PORTLED PORTB
    14 #define LEDBIT 1 << PB2
     16#define LEDBIT (1 << PB2)
    1517
    1618#define BAUD 9600 // Safe value even for low clocks. (used by setbaud.h)
     
    2325
    2426        //debug LED - output
    25         DDRLED |= 255;
     27        DDRLED |= LEDBIT;
     28        PORTLED &= ~LEDBIT;
    2629
    27         PORTLED = 0;
    28 
    29         // Serial baudrate - use avrlibc magic to compute the baudrate register
    30         // values.
    31         #include <util/setbaud.h>
    32         UBRRH = UBRRH_VALUE;
    33         UBRRL = UBRRL_VALUE;
    34         #if USE_2X
    35                 UCSRA |= (1 << U2X);
    36         #else
    37                 UCSRA &= ~(1 << U2X);
    38         #endif
    39 
    40         // Enable the serial port.
    41         UCSRB = (1<<RXEN) |(1<<TXEN);
    42         UCSRC = (1 << UCSZ1) | (1 << UCSZ0);
     30        USARTInit();
    4331
    4432        // Let's rock!
     
    5543                        {
    5644                                PORTLED ^= LEDBIT; // Toggle the LED
    57                                 UDR = 'H'; // Send a byte to the UART
     45                                USARTWriteChar('H'); // Send a byte to the UART
    5846                        }
    5947                }
Note: See TracChangeset for help on using the changeset viewer.