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 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_prot_handler_status = INIT |
static uint8_t | usart_tx_buffer [16] |
#define CONF_STDIO_BAUDRATE 115200 |
Referenced by cdc_uart_init(), configure_console(), configure_usart(), main(), and serial_console_init().
#define CONF_STDIO_MUX_SETTING EDBG_CDC_SERCOM_MUX_SETTING |
Referenced by cdc_uart_init(), configure_console(), configure_usart(), main(), and serial_console_init().
#define CONF_STDIO_PINMUX_PAD0 EDBG_CDC_SERCOM_PINMUX_PAD0 |
Referenced by cdc_uart_init(), configure_console(), configure_usart(), main(), and serial_console_init().
#define CONF_STDIO_PINMUX_PAD1 EDBG_CDC_SERCOM_PINMUX_PAD1 |
Referenced by cdc_uart_init(), configure_console(), configure_usart(), main(), and serial_console_init().
#define CONF_STDIO_PINMUX_PAD2 EDBG_CDC_SERCOM_PINMUX_PAD2 |
Referenced by cdc_uart_init(), configure_console(), configure_usart(), main(), and serial_console_init().
#define CONF_STDIO_PINMUX_PAD3 EDBG_CDC_SERCOM_PINMUX_PAD3 |
Referenced by cdc_uart_init(), configure_console(), configure_usart(), main(), and serial_console_init().
#define CONF_STDIO_USART_MODULE EDBG_CDC_MODULE |
Referenced by configure_console(), and serial_console_init().
#define READ_BUFF 2 |
Referenced by enter_wifi_firmware_download().
#define READ_REG 0 |
Referenced by enter_wifi_firmware_download().
#define RECONFIGURE_UART 5 |
Referenced by enter_wifi_firmware_download().
#define RESET 4 |
#define SPI_TRANSFER_SIZE 512 |
#define USART_CMD_HDR_LENGTH sizeof(uart_cmd_hdr) |
Referenced by nm_usart_protocol_handler().
#define WRITE_BUFF 3 |
Referenced by enter_wifi_firmware_download(), and nm_usart_protocol_handler().
#define WRITE_REG 1 |
Referenced by enter_wifi_firmware_download(), and nm_usart_protocol_handler().
typedef struct uart_cmd_hdr_t uart_cmd_hdr |
enum nm_usart_event_types |
|
static |
Configure UART console.
baud | UART baudrate to use. |
References usart_config::baudrate, cdc_uart_module, CONF_STDIO_MUX_SETTING, CONF_STDIO_PINMUX_PAD0, CONF_STDIO_PINMUX_PAD1, CONF_STDIO_PINMUX_PAD2, CONF_STDIO_PINMUX_PAD3, CONF_STDIO_USART_MODULE, usart_config::mux_setting, usart_config::pinmux_pad0, usart_config::pinmux_pad1, usart_config::pinmux_pad2, usart_config::pinmux_pad3, schedule_rx_length, USART_CALLBACK_BUFFER_RECEIVED, USART_CALLBACK_BUFFER_TRANSMITTED, usart_cmd_recv_buffer, usart_enable(), usart_enable_callback(), usart_get_config_defaults(), usart_read_job(), usart_register_callback(), usart_rx_complete_handler(), and usart_tx_complete_handler().
Referenced by enter_wifi_firmware_download(), and main().
|
static |
Process input UART command and forward to SPI.
References uart_cmd_hdr_t::addr, cdc_uart_module, uart_cmd_hdr_t::cmd, configure_console(), M2M_ERR_INIT, M2M_SUCCESS, m2m_wifi_download_mode(), nm_read_block(), nm_read_reg(), nm_usart_protocol_handler(), nm_usart_send_regval(), nm_write_block(), nm_write_reg(), PROCESSING, READ_BUFF, READ_REG, RECONFIGURE_UART, schedule_rx, schedule_rx_buffer, schedule_rx_length, serial_command_pending, uart_reconfigure, usart_cmd_recv_buffer, usart_disable(), usart_err_on_reception, USART_ERROR_ON_RECEPTION, usart_payload_buffer, USART_PKT_RECEIVED, usart_pkt_received, usart_prot_handler_status, usart_tx_buffer, usart_write_buffer_job(), usart_write_job(), uart_cmd_hdr_t::val, WAIT_SYNC, WRITE_BUFF, and WRITE_REG.
Referenced by main().
int main | ( | void | ) |
Main application function.
Application entry point.
References CONF_STDIO_BAUDRATE, configure_console(), enter_wifi_firmware_download(), nm_bsp_init(), and system_init().
|
static |
References change_state, uart_cmd_hdr_t::cmd, COLLECTING_HDR, COLLECTING_PAYLOAD, i, INIT, new_state, PROCESSING, schedule_rx, schedule_rx_buffer, schedule_rx_length, serial_command_pending, uart_cmd_buf, uart_reconfigure, USART_CMD_HDR_LENGTH, usart_cmd_recv_buffer, USART_ERROR_ON_RECEPTION, usart_payload_buffer, usart_pkt, USART_PKT_RECEIVED, usart_prot_handler_status, usart_read_buffer_job(), usart_read_job(), usart_write_job(), WAIT_SYNC, WAITING, WRITE_BUFF, and WRITE_REG.
Referenced by enter_wifi_firmware_download().
|
static |
References i, j, and usart_write_buffer_job().
Referenced by enter_wifi_firmware_download().
|
static |
References change_state, new_state, schedule_rx_length, usart_pkt, usart_pkt_received, and usart_prot_handler_status.
Referenced by configure_console().
|
static |
References change_state, new_state, schedule_rx, schedule_rx_buffer, schedule_rx_length, usart_prot_handler_status, usart_read_buffer_job(), and usart_read_job().
Referenced by configure_console().
|
static |
|
static |
Referenced by nm_usart_protocol_handler(), usart_rx_complete_handler(), and usart_tx_complete_handler().
|
static |
|
static |
Referenced by enter_wifi_firmware_download(), nm_usart_protocol_handler(), and usart_tx_complete_handler().
|
static |
Referenced by enter_wifi_firmware_download(), nm_usart_protocol_handler(), and usart_tx_complete_handler().
|
static |
|
static |
Referenced by enter_wifi_firmware_download(), and nm_usart_protocol_handler().
|
static |
|
static |
Referenced by nm_usart_protocol_handler().
|
static |
Referenced by enter_wifi_firmware_download(), and nm_usart_protocol_handler().
|
static |
Referenced by configure_console(), enter_wifi_firmware_download(), and nm_usart_protocol_handler().
|
static |
Referenced by enter_wifi_firmware_download().
|
static |
Referenced by enter_wifi_firmware_download(), and nm_usart_protocol_handler().
|
static |
Referenced by nm_usart_protocol_handler(), and usart_rx_complete_handler().
|
static |
Referenced by enter_wifi_firmware_download(), and usart_rx_complete_handler().
|
static |
|
static |
Referenced by enter_wifi_firmware_download().