Microchip® Advanced Software Framework

mega_setbaud_example.c File Reference

megaAVR STK600 AVR libc setbaud Example

Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries.

#include "compiler.h"
#include "conf_clock.h"
#include "conf_uart.h"
#include <util/setbaud.h>

Macros

#define _ASSERT_ENABLE_
 
#define TIMEOUT   250
 

Functions

int main (void)
 Example application on how to use the libc setbaud utility. More...
 
static uint8_t uart_getchar (void)
 Function for getting a char from the UART. More...
 
static void uart_init (void)
 Initialize the uart with correct baud rate settings. More...
 
static void uart_putchar (uint8_t data)
 Function for sending a char over the UART. More...
 

#define _ASSERT_ENABLE_
#define TIMEOUT   250

Referenced by uart_getchar().

static uint8_t uart_getchar ( void  )
static

Function for getting a char from the UART.

Note
This function is blocking and will expect to receive something on the UART.
Return values
uint8_tthe data received from the UART
0if timeout

References TIMEOUT.

Referenced by main().

static void uart_init ( void  )
static

Initialize the uart with correct baud rate settings.

This function will initialize the UART baud rate registers with the correct values using the AVR libc setbaud utility. In addition set the UART to 8-bit, 1 stop and no parity.

Referenced by main().

static void uart_putchar ( uint8_t  data)
static

Function for sending a char over the UART.

Parameters
datathe data to send over UART

References data.

Referenced by main().