Microchip® Advanced Software Framework

usart_irda_example.c File Reference

USART IrDA example for SAM.

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

#include <string.h>
#include "asf.h"
#include "stdio_serial.h"
#include "conf_board.h"
#include "conf_clock.h"
#include "conf_example.h"

Macros

#define ALL_INTERRUPT_MASK   0xffffffff
 All interrupt mask. More...
 
#define BUFFER_SIZE   10
 Buffer size for PDC transfer. More...
 
#define STATE_IDLE   3
 
#define STATE_RECEIVE   1
 
#define STATE_TRANSMIT   0
 Communication state. More...
 
#define STRING_EOL   "\r"
 
#define STRING_HEADER
 

Functions

static void configure_console (void)
 Configure UART for debug message output. More...
 
static void configure_usart (void)
 Configure board USART communication with PC or other terminal. More...
 
static void dump_recv_buf (uint8_t *p_buf, uint8_t uc_size)
 Dump received buffer to uart. More...
 
static void func_receiver (void)
 Disable transmitter and Enable receiver. More...
 
static void func_transmitter (void)
 Disable receiver and Enable transmitter. More...
 
int main (void)
 Application entry point. More...
 
void USART_Handler (void)
 USART IRQ Handler, handling RXBUFF and TXBUFE status. More...
 

Variables

Pdc * g_p_pdc
 Pointer to PDC register base. More...
 
pdc_packet_t g_st_packet
 PDC data packet. More...
 
uint8_t g_uc_recv_data [BUFFER_SIZE] = { 0x0 }
 Data buffer for receiving. More...
 
uint8_t g_uc_send_data [BUFFER_SIZE]
 Data buffer for transmitting. More...
 
uint8_t g_uc_state = STATE_IDLE
 State of BOARD_USART_BASE. More...
 
volatile uint32_t g_ul_recv_done = false
 Receiving Done status. More...
 
volatile uint32_t g_ul_sent_done = false
 Transmitting Done status. More...
 

#define ALL_INTERRUPT_MASK   0xffffffff

All interrupt mask.

Referenced by configure_usart().

#define BUFFER_SIZE   10

Buffer size for PDC transfer.

Referenced by main().

#define STATE_IDLE   3

Referenced by main().

#define STATE_RECEIVE   1

Referenced by main(), and USART_Handler().

#define STATE_TRANSMIT   0

Communication state.

Referenced by main(), and USART_Handler().

#define STRING_EOL   "\r"
#define STRING_HEADER
Value:
"--USART IrDA Example --\r\n" \
"-- "BOARD_NAME" --\r\n" \
"-- Compiled: "__DATE__" "__TIME__" --"STRING_EOL
#define BOARD_NAME
Definition: inc/app_init.h:140
#define STRING_EOL
Definition: usart_irda_example.c:110

Referenced by main().

static void configure_console ( void  )
static
static void configure_usart ( void  )
static
static void dump_recv_buf ( uint8_t *  p_buf,
uint8_t  uc_size 
)
static

Dump received buffer to uart.

Parameters
p_bufPointer to received buffer.
uc_sizeThe size of the buffer.

Referenced by main().

static void func_receiver ( void  )
static

Disable transmitter and Enable receiver.

References pio_configure_pin(), pio_set_pin_low(), UNUSED, usart_disable_tx(), usart_enable_rx(), usart_is_rx_ready(), and usart_read().

Referenced by main().

static void func_transmitter ( void  )
static

Disable receiver and Enable transmitter.

References pio_configure_pin(), usart_disable_rx(), and usart_enable_tx().

Referenced by main().

void USART_Handler ( void  )

USART IRQ Handler, handling RXBUFF and TXBUFE status.

References g_uc_state, g_ul_recv_done, g_ul_sent_done, STATE_RECEIVE, STATE_TRANSMIT, usart_disable_interrupt(), and usart_get_status().

Pdc* g_p_pdc

Pointer to PDC register base.

pdc_packet_t g_st_packet

PDC data packet.

uint8_t g_uc_recv_data[BUFFER_SIZE] = { 0x0 }

Data buffer for receiving.

Referenced by main().

uint8_t g_uc_send_data[BUFFER_SIZE]
Initial value:
=
{ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89 }

Data buffer for transmitting.

Referenced by main().

uint8_t g_uc_state = STATE_IDLE

State of BOARD_USART_BASE.

volatile uint32_t g_ul_recv_done = false

Receiving Done status.

volatile uint32_t g_ul_sent_done = false

Transmitting Done status.