blob: 14f1ae5e96486a88dd6380637b31d969f59f0ff1 [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/**
Kévin Redon1f8ecef2019-01-31 13:36:12 +010014 * Example of using SIM0 to write "Hello World" using the IO abstraction.
15 *
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.
20 */
21
22static uint8_t example_SIM0[12] = "Hello World!";
23
24static void tx_cb_SIM0(const struct usart_async_descriptor *const io_descr)
25{
26 /* Transfer completed */
27}
28
29void SIM0_example(void)
30{
31 struct io_descriptor *io;
32
33 usart_async_register_callback(&SIM0, USART_ASYNC_TXC_CB, tx_cb_SIM0);
34 /*usart_async_register_callback(&SIM0, USART_ASYNC_RXC_CB, rx_cb);
35 usart_async_register_callback(&SIM0, USART_ASYNC_ERROR_CB, err_cb);*/
36 usart_async_get_io_descriptor(&SIM0, &io);
37 usart_async_enable(&SIM0);
38
39 io_write(io, example_SIM0, 12);
40}
41
42/**
43 * Example of using SIM1 to write "Hello World" using the IO abstraction.
44 *
45 * Since the driver is asynchronous we need to use statically allocated memory for string
46 * because driver initiates transfer and then returns before the transmission is completed.
47 *
48 * Once transfer has been completed the tx_cb function will be called.
49 */
50
51static uint8_t example_SIM1[12] = "Hello World!";
52
53static void tx_cb_SIM1(const struct usart_async_descriptor *const io_descr)
54{
55 /* Transfer completed */
56}
57
58void SIM1_example(void)
59{
60 struct io_descriptor *io;
61
62 usart_async_register_callback(&SIM1, USART_ASYNC_TXC_CB, tx_cb_SIM1);
63 /*usart_async_register_callback(&SIM1, USART_ASYNC_RXC_CB, rx_cb);
64 usart_async_register_callback(&SIM1, USART_ASYNC_ERROR_CB, err_cb);*/
65 usart_async_get_io_descriptor(&SIM1, &io);
66 usart_async_enable(&SIM1);
67
68 io_write(io, example_SIM1, 12);
69}
70
71/**
72 * Example of using SIM2 to write "Hello World" using the IO abstraction.
73 *
74 * Since the driver is asynchronous we need to use statically allocated memory for string
75 * because driver initiates transfer and then returns before the transmission is completed.
76 *
77 * Once transfer has been completed the tx_cb function will be called.
78 */
79
80static uint8_t example_SIM2[12] = "Hello World!";
81
82static void tx_cb_SIM2(const struct usart_async_descriptor *const io_descr)
83{
84 /* Transfer completed */
85}
86
87void SIM2_example(void)
88{
89 struct io_descriptor *io;
90
91 usart_async_register_callback(&SIM2, USART_ASYNC_TXC_CB, tx_cb_SIM2);
92 /*usart_async_register_callback(&SIM2, USART_ASYNC_RXC_CB, rx_cb);
93 usart_async_register_callback(&SIM2, USART_ASYNC_ERROR_CB, err_cb);*/
94 usart_async_get_io_descriptor(&SIM2, &io);
95 usart_async_enable(&SIM2);
96
97 io_write(io, example_SIM2, 12);
98}
99
100/**
101 * Example of using SIM3 to write "Hello World" using the IO abstraction.
102 *
103 * Since the driver is asynchronous we need to use statically allocated memory for string
104 * because driver initiates transfer and then returns before the transmission is completed.
105 *
106 * Once transfer has been completed the tx_cb function will be called.
107 */
108
109static uint8_t example_SIM3[12] = "Hello World!";
110
111static void tx_cb_SIM3(const struct usart_async_descriptor *const io_descr)
112{
113 /* Transfer completed */
114}
115
116void SIM3_example(void)
117{
118 struct io_descriptor *io;
119
120 usart_async_register_callback(&SIM3, USART_ASYNC_TXC_CB, tx_cb_SIM3);
121 /*usart_async_register_callback(&SIM3, USART_ASYNC_RXC_CB, rx_cb);
122 usart_async_register_callback(&SIM3, USART_ASYNC_ERROR_CB, err_cb);*/
123 usart_async_get_io_descriptor(&SIM3, &io);
124 usart_async_enable(&SIM3);
125
126 io_write(io, example_SIM3, 12);
127}
128
129/**
130 * Example of using SIM4 to write "Hello World" using the IO abstraction.
131 *
132 * Since the driver is asynchronous we need to use statically allocated memory for string
133 * because driver initiates transfer and then returns before the transmission is completed.
134 *
135 * Once transfer has been completed the tx_cb function will be called.
136 */
137
138static uint8_t example_SIM4[12] = "Hello World!";
139
140static void tx_cb_SIM4(const struct usart_async_descriptor *const io_descr)
141{
142 /* Transfer completed */
143}
144
145void SIM4_example(void)
146{
147 struct io_descriptor *io;
148
149 usart_async_register_callback(&SIM4, USART_ASYNC_TXC_CB, tx_cb_SIM4);
150 /*usart_async_register_callback(&SIM4, USART_ASYNC_RXC_CB, rx_cb);
151 usart_async_register_callback(&SIM4, USART_ASYNC_ERROR_CB, err_cb);*/
152 usart_async_get_io_descriptor(&SIM4, &io);
153 usart_async_enable(&SIM4);
154
155 io_write(io, example_SIM4, 12);
156}
157
158/**
159 * Example of using SIM5 to write "Hello World" using the IO abstraction.
160 *
161 * Since the driver is asynchronous we need to use statically allocated memory for string
162 * because driver initiates transfer and then returns before the transmission is completed.
163 *
164 * Once transfer has been completed the tx_cb function will be called.
165 */
166
167static uint8_t example_SIM5[12] = "Hello World!";
168
169static void tx_cb_SIM5(const struct usart_async_descriptor *const io_descr)
170{
171 /* Transfer completed */
172}
173
174void SIM5_example(void)
175{
176 struct io_descriptor *io;
177
178 usart_async_register_callback(&SIM5, USART_ASYNC_TXC_CB, tx_cb_SIM5);
179 /*usart_async_register_callback(&SIM5, USART_ASYNC_RXC_CB, rx_cb);
180 usart_async_register_callback(&SIM5, USART_ASYNC_ERROR_CB, err_cb);*/
181 usart_async_get_io_descriptor(&SIM5, &io);
182 usart_async_enable(&SIM5);
183
184 io_write(io, example_SIM5, 12);
185}
186
187/**
188 * Example of using SIM6 to write "Hello World" using the IO abstraction.
189 *
190 * Since the driver is asynchronous we need to use statically allocated memory for string
191 * because driver initiates transfer and then returns before the transmission is completed.
192 *
193 * Once transfer has been completed the tx_cb function will be called.
194 */
195
196static uint8_t example_SIM6[12] = "Hello World!";
197
198static void tx_cb_SIM6(const struct usart_async_descriptor *const io_descr)
199{
200 /* Transfer completed */
201}
202
203void SIM6_example(void)
204{
205 struct io_descriptor *io;
206
207 usart_async_register_callback(&SIM6, USART_ASYNC_TXC_CB, tx_cb_SIM6);
208 /*usart_async_register_callback(&SIM6, USART_ASYNC_RXC_CB, rx_cb);
209 usart_async_register_callback(&SIM6, USART_ASYNC_ERROR_CB, err_cb);*/
210 usart_async_get_io_descriptor(&SIM6, &io);
211 usart_async_enable(&SIM6);
212
213 io_write(io, example_SIM6, 12);
214}
215
216/**
Kévin Redon4cd3f7d2019-01-24 17:57:13 +0100217 * Example of using UART_debug to write "Hello World" using the IO abstraction.
Kévin Redonccbed0b2019-01-24 18:30:26 +0100218 *
219 * Since the driver is asynchronous we need to use statically allocated memory for string
220 * because driver initiates transfer and then returns before the transmission is completed.
221 *
222 * Once transfer has been completed the tx_cb function will be called.
Kévin Redon4cd3f7d2019-01-24 17:57:13 +0100223 */
Kévin Redonccbed0b2019-01-24 18:30:26 +0100224
225static uint8_t example_UART_debug[12] = "Hello World!";
226
227static void tx_cb_UART_debug(const struct usart_async_descriptor *const io_descr)
228{
229 /* Transfer completed */
230}
231
Kévin Redon4cd3f7d2019-01-24 17:57:13 +0100232void UART_debug_example(void)
233{
234 struct io_descriptor *io;
Kévin Redon4cd3f7d2019-01-24 17:57:13 +0100235
Kévin Redonccbed0b2019-01-24 18:30:26 +0100236 usart_async_register_callback(&UART_debug, USART_ASYNC_TXC_CB, tx_cb_UART_debug);
237 /*usart_async_register_callback(&UART_debug, USART_ASYNC_RXC_CB, rx_cb);
238 usart_async_register_callback(&UART_debug, USART_ASYNC_ERROR_CB, err_cb);*/
239 usart_async_get_io_descriptor(&UART_debug, &io);
240 usart_async_enable(&UART_debug);
241
242 io_write(io, example_UART_debug, 12);
Kévin Redon4cd3f7d2019-01-24 17:57:13 +0100243}