blob: 8384c871f3fad8f66f2716f50b94c391fee8862f [file] [log] [blame]
Kévin Redon69b92d92019-01-24 16:39:20 +01001/*
2 * Code generated from Atmel Start.
3 *
4 * This file will be overwritten when reconfiguring your Atmel Start project.
5 * Please copy examples or other code you want to keep to a separate file
6 * to avoid losing it when reconfiguring.
7 */
8
9#include "driver_examples.h"
10#include "driver_init.h"
11#include "utils.h"
Kévin Redon4cd3f7d2019-01-24 17:57:13 +010012
13/**
14 * Example of using UART_debug to write "Hello World" using the IO abstraction.
Kévin Redonccbed0b2019-01-24 18:30:26 +010015 *
16 * Since the driver is asynchronous we need to use statically allocated memory for string
17 * because driver initiates transfer and then returns before the transmission is completed.
18 *
19 * Once transfer has been completed the tx_cb function will be called.
Kévin Redon4cd3f7d2019-01-24 17:57:13 +010020 */
Kévin Redonccbed0b2019-01-24 18:30:26 +010021
22static uint8_t example_UART_debug[12] = "Hello World!";
23
24static void tx_cb_UART_debug(const struct usart_async_descriptor *const io_descr)
25{
26 /* Transfer completed */
27}
28
Kévin Redon4cd3f7d2019-01-24 17:57:13 +010029void UART_debug_example(void)
30{
31 struct io_descriptor *io;
Kévin Redon4cd3f7d2019-01-24 17:57:13 +010032
Kévin Redonccbed0b2019-01-24 18:30:26 +010033 usart_async_register_callback(&UART_debug, USART_ASYNC_TXC_CB, tx_cb_UART_debug);
34 /*usart_async_register_callback(&UART_debug, USART_ASYNC_RXC_CB, rx_cb);
35 usart_async_register_callback(&UART_debug, USART_ASYNC_ERROR_CB, err_cb);*/
36 usart_async_get_io_descriptor(&UART_debug, &io);
37 usart_async_enable(&UART_debug);
38
39 io_write(io, example_UART_debug, 12);
Kévin Redon4cd3f7d2019-01-24 17:57:13 +010040}