Serial Bridge.
Copyright (c) 2020-2021 Microchip Technology Inc. and its subsidiaries.
#include <asf.h>
#include "common/include/nm_common.h"
#include "bus_wrapper/include/nm_bus_wrapper.h"
#include "driver/source/nmbus.h"
#include "driver/include/m2m_wifi.h"
#include "buffered_uart.h"
#include <string.h>
Data Structures | |
struct | nm_command |
struct | serial_bridge_frame |
struct | serial_bridge_frame_buffer |
struct | serial_bridge_frame_lookup |
Macros | |
#define | PACKET_QUEUE_BUFFER_SIZE 2048 |
#define | SERIAL_BRIDGE_LOOKUP_TABLE_ENTRIES sizeof(serial_bridge_lookup_table) / sizeof(struct serial_bridge_frame_lookup) |
Functions | |
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 | serial_bridge_frame_buffer_pop (struct serial_bridge_frame_buffer *frame, int size) |
static int | serial_bridge_frame_get_nm_command (struct serial_bridge_frame *frame, struct nm_command *cmd) |
Read out the first 13bytes and copy into cmd buffer after checking the frame. More... | |
static int | serial_bridge_frame_receive (struct serial_bridge_frame_buffer *frame, uint16_t len) |
static void | serial_bridge_process_frame (void) |
Parse incoming frame and find the handler to process the request. More... | |
static int | serial_bridge_process_read_block (struct serial_bridge_frame *frame) |
Handles the UART frame from nm_read_block() in nmuart.c. More... | |
static int | serial_bridge_process_read_reg_with_ret (struct serial_bridge_frame *frame) |
Handles the UART frame from nm_read_reg_with_ret() in nmuart.c. More... | |
static int | serial_bridge_process_reboot_cmd (struct serial_bridge_frame *frame) |
static int | serial_bridge_process_reconfigure (struct serial_bridge_frame *frame) |
Handles the UART frame from nm_reconfigure() in nmuart.c. More... | |
static int | serial_bridge_process_sync_cmd (struct serial_bridge_frame *frame) |
Handles the UART frame from nm_sync_cmd() in nmuart.c. More... | |
static int | serial_bridge_process_write_block (struct serial_bridge_frame *frame) |
Handles frame from nm_uart_write_block() in nmuart.c. More... | |
static int | serial_bridge_process_write_reg (struct serial_bridge_frame *frame) |
Handles the UART frame from nm_write_reg() in nmuart.c. More... | |
Variables | |
static struct serial_bridge_frame_buffer | frame_buffer |
tstrWifiInitParam | gstrWifiParam |
struct serial_bridge_frame_lookup | serial_bridge_lookup_table [] |
#define PACKET_QUEUE_BUFFER_SIZE 2048 |
Referenced by serial_bridge_process_read_block().
#define SERIAL_BRIDGE_LOOKUP_TABLE_ENTRIES sizeof(serial_bridge_lookup_table) / sizeof(struct serial_bridge_frame_lookup) |
Referenced by serial_bridge_process_frame().
|
static |
Process input UART command and forward to SPI.
References serial_bridge_frame_buffer::buffer, buffered_uart_rx(), frame_buffer, M2M_ERR_INIT, M2M_SUCCESS, nm_cpu_start(), serial_bridge_process_frame(), serial_bridge_process_sync_cmd(), and serial_bridge_frame_buffer::size.
Referenced by main().
int main | ( | void | ) |
Main application function.
Application entry point.
References board_init(), buffered_uart_init(), enter_wifi_firmware_download(), M2M_ERR, M2M_SUCCESS, m2m_wifi_download_mode(), nm_bsp_init(), and sysclk_init().
|
static |
|
static |
Read out the first 13bytes and copy into cmd buffer after checking the frame.
frame buffer pointer is pop'ed by this function.
References nm_command::addr, nm_command::cmd, serial_bridge_frame::cmd, serial_bridge_frame_buffer_pop(), nm_command::size, and nm_command::val.
Referenced by serial_bridge_process_read_block(), serial_bridge_process_read_reg_with_ret(), serial_bridge_process_reconfigure(), serial_bridge_process_write_block(), and serial_bridge_process_write_reg().
|
static |
References serial_bridge_frame_buffer::buffer, buffered_uart_rx(), and serial_bridge_frame_buffer::size.
Referenced by serial_bridge_process_write_block().
|
static |
Parse incoming frame and find the handler to process the request.
References serial_bridge_frame_buffer::buffer, buffered_uart_putchar(), frame_buffer, serial_bridge_frame_lookup::header_size, serial_bridge_frame_lookup::min_size, serial_bridge_frame_buffer_pop(), SERIAL_BRIDGE_LOOKUP_TABLE_ENTRIES, and serial_bridge_frame_buffer::size.
Referenced by enter_wifi_firmware_download().
|
static |
Handles the UART frame from nm_read_block() in nmuart.c.
References nm_command::addr, buffered_uart_putchar(), buffered_uart_tx(), nm_read_block(), PACKET_QUEUE_BUFFER_SIZE, serial_bridge_frame_get_nm_command(), and nm_command::size.
|
static |
Handles the UART frame from nm_read_reg_with_ret() in nmuart.c.
References nm_command::addr, buffered_uart_putchar(), nm_read_reg(), serial_bridge_frame_get_nm_command(), and nm_command::val.
|
static |
|
static |
Handles the UART frame from nm_reconfigure() in nmuart.c.
References buffered_uart_init(), buffered_uart_putchar(), buffered_uart_term(), delay_ms, serial_bridge_frame_get_nm_command(), and nm_command::val.
|
static |
Handles the UART frame from nm_sync_cmd() in nmuart.c.
References buffered_uart_putchar(), and serial_bridge_frame_buffer_pop().
Referenced by enter_wifi_firmware_download().
|
static |
Handles frame from nm_uart_write_block() in nmuart.c.
References nm_command::addr, buffered_uart_putchar(), nm_write_block(), serial_bridge_frame_buffer_pop(), serial_bridge_frame_get_nm_command(), serial_bridge_frame_receive(), and nm_command::size.
|
static |
Handles the UART frame from nm_write_reg() in nmuart.c.
References nm_command::addr, buffered_uart_putchar(), nm_write_reg(), serial_bridge_frame_get_nm_command(), and nm_command::val.
|
static |
Referenced by enter_wifi_firmware_download(), and serial_bridge_process_frame().
tstrWifiInitParam gstrWifiParam |
struct serial_bridge_frame_lookup serial_bridge_lookup_table[] |