Microchip® Advanced Software Framework

winc1500/serial_bridge_example/serial_bridge_ultra.c File Reference

Serial Bridge.

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

#include <asf.h>
#include "common/include/nm_common.h"
#include "bsp/include/nm_bsp.h"
#include "bus_wrapper/include/nm_bus_wrapper.h"
#include "driver/source/nmbus.h"
#include "driver/include/m2m_wifi.h"
#include "stdio_serial.h"

Data Structures

struct  uart_cmd_hdr_t
 

Macros

#define CONF_STDIO_BAUDRATE   115200
 
#define CONF_STDIO_MUX_SETTING   EDBG_CDC_SERCOM_MUX_SETTING
 
#define CONF_STDIO_PINMUX_PAD0   EDBG_CDC_SERCOM_PINMUX_PAD0
 
#define CONF_STDIO_PINMUX_PAD1   EDBG_CDC_SERCOM_PINMUX_PAD1
 
#define CONF_STDIO_PINMUX_PAD2   EDBG_CDC_SERCOM_PINMUX_PAD2
 
#define CONF_STDIO_PINMUX_PAD3   EDBG_CDC_SERCOM_PINMUX_PAD3
 
#define CONF_STDIO_USART_MODULE   EDBG_CDC_MODULE
 
#define READ_BUFF   2
 
#define READ_REG   0
 
#define RECONFIGURE_UART   5
 
#define RESET   4
 
#define SPI_TRANSFER_SIZE   512
 
#define USART_CMD_HDR_LENGTH   sizeof(uart_cmd_hdr)
 
#define WRITE_BUFF   3
 
#define WRITE_REG   1
 

Typedefs

typedef struct uart_cmd_hdr_t uart_cmd_hdr
 

Enumerations

enum  nm_usart_cmd_process_states {
  INIT = 0,
  WAIT_SYNC,
  WAITING,
  COLLECTING_HDR,
  COLLECTING_PAYLOAD,
  PROCESSING
}
 
enum  nm_usart_event_types {
  USART_PKT_RECEIVED = 0,
  USART_PKT_TRANSMITTED,
  USART_ERROR_ON_RECEPTION
}
 UART commands. More...
 

Functions

static void configure_console (uint32_t baud)
 Configure UART console. More...
 
static sint8 enter_wifi_firmware_download (void)
 Process input UART command and forward to SPI. More...
 
int main (void)
 Main application function. More...
 
static void nm_usart_protocol_handler (struct usart_module *module, enum nm_usart_event_types event_name)
 
static void nm_usart_send_regval (struct usart_module *module, uint8_t *tx_data, uint16_t length)
 
static void usart_rx_complete_handler (struct usart_module *const module)
 
static void usart_tx_complete_handler (struct usart_module *const module)
 

Variables

static struct usart_module cdc_uart_module
 
static uint8_t change_state = 0
 
static uint8_t new_state = INIT
 
static uint8_t schedule_rx = 0
 
static uint16_t * schedule_rx_buffer = NULL
 
static uint16_t schedule_rx_length = 0
 
static uint8_t serial_command_pending = 0
 
static uart_cmd_hdr uart_cmd
 
static uint8uart_cmd_buf
 
static uint8_t uart_reconfigure = 0
 
static uint16_t usart_cmd_recv_buffer [8]
 
static uint8_t usart_err_on_reception = 0
 
static uint16_t usart_payload_buffer [512]
 
static uint8_t * usart_pkt = NULL
 
static uint8_t usart_pkt_received = 0
 
static uint8_t usart_prot_handler_status = INIT
 
static uint8_t usart_tx_buffer [16]
 

#define CONF_STDIO_BAUDRATE   115200

Referenced by main().

#define CONF_STDIO_MUX_SETTING   EDBG_CDC_SERCOM_MUX_SETTING

Referenced by configure_console().

#define CONF_STDIO_PINMUX_PAD0   EDBG_CDC_SERCOM_PINMUX_PAD0

Referenced by configure_console().

#define CONF_STDIO_PINMUX_PAD1   EDBG_CDC_SERCOM_PINMUX_PAD1

Referenced by configure_console().

#define CONF_STDIO_PINMUX_PAD2   EDBG_CDC_SERCOM_PINMUX_PAD2

Referenced by configure_console().

#define CONF_STDIO_PINMUX_PAD3   EDBG_CDC_SERCOM_PINMUX_PAD3

Referenced by configure_console().

#define CONF_STDIO_USART_MODULE   EDBG_CDC_MODULE

Referenced by configure_console().

#define READ_BUFF   2
#define READ_REG   0
#define RECONFIGURE_UART   5
#define RESET   4
#define SPI_TRANSFER_SIZE   512
#define USART_CMD_HDR_LENGTH   sizeof(uart_cmd_hdr)
#define WRITE_BUFF   3
#define WRITE_REG   1

typedef struct uart_cmd_hdr_t uart_cmd_hdr

Enumerator
INIT 
WAIT_SYNC 
WAITING 
COLLECTING_HDR 
COLLECTING_PAYLOAD 
PROCESSING 

UART commands.

Enumerator
USART_PKT_RECEIVED 
USART_PKT_TRANSMITTED 
USART_ERROR_ON_RECEPTION 

int main ( void  )

Main application function.

Application entry point.

Returns
program return value.

References CONF_STDIO_BAUDRATE, configure_console(), enter_wifi_firmware_download(), nm_bsp_init(), and system_init().

static void nm_usart_send_regval ( struct usart_module module,
uint8_t *  tx_data,
uint16_t  length 
)
static

References i, j, and usart_write_buffer_job().

Referenced by enter_wifi_firmware_download().

static void usart_rx_complete_handler ( struct usart_module *const  module)
static
static void usart_tx_complete_handler ( struct usart_module *const  module)
static

struct usart_module cdc_uart_module
static
uint8_t change_state = 0
static
uint8_t schedule_rx = 0
static
uint16_t* schedule_rx_buffer = NULL
static
uint8_t serial_command_pending = 0
static
uart_cmd_hdr uart_cmd
static
uint8* uart_cmd_buf
static
uint8_t uart_reconfigure = 0
static
uint16_t usart_cmd_recv_buffer[8]
static
uint8_t usart_err_on_reception = 0
static
uint16_t usart_payload_buffer[512]
static
uint8_t* usart_pkt = NULL
static
uint8_t usart_pkt_received = 0
static
uint8_t usart_tx_buffer[16]
static