SAM4SD32 (SAM4S-EK2)
Loading...
Searching...
No Matches
usart_serial.c
Go to the documentation of this file.
1
35/*
36 * Support and FAQ: visit <a href="https://www.microchip.com/support/">Microchip Support</a>
37 */
38#include "serial.h"
39
40/*
41 * Send a sequence of bytes to USART device.
42 * API documentation is provided in the corresponding declaration in
43 * common/services/serial/sam_uart/uart_serial.h.
44 */
45status_code_t usart_serial_write_packet(usart_if usart, const uint8_t *data,
46 size_t len)
47{
48 while (len) {
49 usart_serial_putchar(usart, *data);
50 len--;
51 data++;
52 }
53 return STATUS_OK;
54}
55
56
57/*
58 * Receive a sequence of bytes from USART device.
59 * API documentation is provided in the corresponding declaration in
60 * common/services/serial/sam_uart/uart_serial.h.
61 */
62status_code_t usart_serial_read_packet(usart_if usart, uint8_t *data,
63 size_t len)
64{
65 while (len) {
66 usart_serial_getchar(usart, data);
67 len--;
68 data++;
69 }
70 return STATUS_OK;
71}
Serial Mode management.
static int usart_serial_putchar(usart_if p_usart, const uint8_t c)
Sends a character with the USART.
Usart * usart_if
This type can be used independently to refer to USART module for the architecture used.
Definition uart_serial.h:78
static void usart_serial_getchar(usart_if p_usart, uint8_t *data)
Waits until a character is received, and returns it.
status_code_t usart_serial_read_packet(usart_if usart, uint8_t *data, size_t len)
Receive a sequence of bytes to a USART device.
status_code_t usart_serial_write_packet(usart_if usart, const uint8_t *data, size_t len)
Send a sequence of bytes to a USART device.