Microchip® Advanced Software Framework

serial_bridge_ultra.c File Reference

Serial Bridge.

Copyright (c) 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_ultra.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

sint8 enter_wifi_firmware_download (void)
 
uint32 get_systicks (void)
 
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)
 
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...
 
void SysTick_Handler (void)
 

Variables

static struct
serial_bridge_frame_buffer 
frame_buffer
 
tstrWifiInitParam gstrWifiParam
 
static volatile uint32 ms_systicks
 
struct serial_bridge_frame_lookup serial_bridge_lookup_table []
 

#define PACKET_QUEUE_BUFFER_SIZE   2048
#define SERIAL_BRIDGE_LOOKUP_TABLE_ENTRIES   sizeof(serial_bridge_lookup_table) / sizeof(struct serial_bridge_frame_lookup)

uint32 get_systicks ( void  )

References ms_systicks.

int main ( void  )

Main application function.

Application entry point.

Returns
program return value.

References buffered_uart_init(), enter_wifi_firmware_download(), M2M_ERR, M2M_SUCCESS, m2m_wifi_download_mode(), nm_bsp_init(), system_cpu_clock_get_hz(), and system_init().

static int serial_bridge_frame_get_nm_command ( struct serial_bridge_frame frame,
struct nm_command cmd 
)
static
static int serial_bridge_frame_receive ( struct serial_bridge_frame_buffer frame,
uint16_t  len 
)
static
static int serial_bridge_process_read_block ( struct serial_bridge_frame frame)
static
static int serial_bridge_process_read_reg_with_ret ( struct serial_bridge_frame frame)
static
static int serial_bridge_process_reboot_cmd ( struct serial_bridge_frame frame)
static
static int serial_bridge_process_reconfigure ( struct serial_bridge_frame frame)
static
static int serial_bridge_process_sync_cmd ( struct serial_bridge_frame frame)
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 int serial_bridge_process_write_reg ( struct serial_bridge_frame frame)
static
void SysTick_Handler ( void  )

tstrWifiInitParam gstrWifiParam
volatile uint32 ms_systicks
static

Referenced by get_systicks().

struct serial_bridge_frame_lookup serial_bridge_lookup_table[]
Initial value:
= {
{{0x12 }, 1, 1, serial_bridge_process_sync_cmd },
{{0xa5, 0x01}, 2, sizeof(struct serial_bridge_frame), serial_bridge_process_write_reg },
{{0xa5, 0x02}, 2, sizeof(struct serial_bridge_frame), serial_bridge_process_read_block },
{{0xa5, 0x03}, 2, sizeof(struct serial_bridge_frame), serial_bridge_process_write_block },
{{0xa5, 0x05}, 2, sizeof(struct serial_bridge_frame), serial_bridge_process_reconfigure },
}
static int serial_bridge_process_reboot_cmd(struct serial_bridge_frame *frame)
Definition: serial_bridge_ultra.c:174
static int serial_bridge_process_write_block(struct serial_bridge_frame *frame)
Handles frame from nm_uart_write_block() in nmuart.c.
Definition: serial_bridge_ultra.c:242
static int serial_bridge_process_read_block(struct serial_bridge_frame *frame)
Handles the UART frame from nm_read_block() in nmuart.c.
Definition: serial_bridge_ultra.c:223
static int serial_bridge_process_sync_cmd(struct serial_bridge_frame *frame)
Handles the UART frame from nm_sync_cmd() in nmuart.c.
Definition: serial_bridge_ultra.c:167
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.
Definition: serial_bridge_ultra.c:183
Definition: serial_bridge_ultra.c:76
static int serial_bridge_process_reconfigure(struct serial_bridge_frame *frame)
Handles the UART frame from nm_reconfigure() in nmuart.c.
Definition: serial_bridge_ultra.c:264
static int serial_bridge_process_write_reg(struct serial_bridge_frame *frame)
Handles the UART frame from nm_write_reg() in nmuart.c.
Definition: serial_bridge_ultra.c:206