Definition in file usart_example.c.
#include <avr32/io.h>
#include "compiler.h"
#include "board.h"
#include "pm_at32ap7000.h"
#include "gpio.h"
#include "usart.h"
Go to the source code of this file.
Defines | |
USART Settings | |
#define | EXAMPLE_USART (&AVR32_USART1) |
#define | EXAMPLE_USART_RX_FUNCTION AVR32_USART1_RXD_0_FUNCTION |
#define | EXAMPLE_USART_RX_PIN AVR32_USART1_RXD_0_PIN |
#define | EXAMPLE_USART_TX_FUNCTION AVR32_USART1_TXD_0_FUNCTION |
#define | EXAMPLE_USART_TX_PIN AVR32_USART1_TXD_0_PIN |
Functions | |
int | main (void) |
This is an example demonstrating the USART RS232 TX and RX functionalities using the USART driver. |
#define EXAMPLE_USART (&AVR32_USART1) |
#define EXAMPLE_USART_RX_FUNCTION AVR32_USART1_RXD_0_FUNCTION |
#define EXAMPLE_USART_RX_PIN AVR32_USART1_RXD_0_PIN |
#define EXAMPLE_USART_TX_FUNCTION AVR32_USART1_TXD_0_FUNCTION |
#define EXAMPLE_USART_TX_PIN AVR32_USART1_TXD_0_PIN |
int main | ( | void | ) |
This is an example demonstrating the USART RS232 TX and RX functionalities using the USART driver.
Definition at line 116 of file usart_example.c.
References EXAMPLE_USART, EXAMPLE_USART_RX_FUNCTION, EXAMPLE_USART_RX_PIN, EXAMPLE_USART_TX_FUNCTION, EXAMPLE_USART_TX_PIN, USART_1_STOPBIT, USART_FAILURE, usart_get_echo_line(), usart_init_rs232(), USART_NO_PARITY, USART_NORMAL_CHMODE, and usart_write_line().
00117 { 00118 static const gpio_map_t USART_GPIO_MAP = 00119 { 00120 {EXAMPLE_USART_RX_PIN, EXAMPLE_USART_RX_FUNCTION}, 00121 {EXAMPLE_USART_TX_PIN, EXAMPLE_USART_TX_FUNCTION} 00122 }; 00123 00124 // USART options. 00125 static const usart_options_t USART_OPTIONS = 00126 { 00127 .baudrate = 115200, 00128 .charlength = 8, 00129 .paritytype = USART_NO_PARITY, 00130 .stopbits = USART_1_STOPBIT, 00131 .channelmode = USART_NORMAL_CHMODE 00132 }; 00133 00134 // Reset PM. Makes sure we get the expected clocking after a soft reset (e.g.: JTAG reset) 00135 pm_reset(); 00136 00137 // Assign GPIO to USART. 00138 gpio_enable_module(USART_GPIO_MAP, 00139 sizeof(USART_GPIO_MAP) / sizeof(USART_GPIO_MAP[0])); 00140 00141 // Initialize USART in RS232 mode. 00142 usart_init_rs232(EXAMPLE_USART, &USART_OPTIONS, FOSC0); 00143 00144 // Hello world! 00145 usart_write_line(EXAMPLE_USART, "Hello, this is AT32AP7000 saying hello! (press enter)\n"); 00146 00147 // Press enter to continue. 00148 while (usart_get_echo_line(EXAMPLE_USART) == USART_FAILURE); // Get and echo characters until end of line. 00149 00150 usart_write_line(EXAMPLE_USART, "Goodbye.\n"); 00151 00152 while (TRUE); 00153 }