Microchip® Advanced Software Framework

main.c File Reference

SAM0 USB Host Mass Storage Bootloader Application with CRC Check.

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

#include <asf.h>
#include <string.h>
#include "conf_usb_host.h"
#include "conf_bootloader.h"
#include "main.h"

Macros

#define MSC_DELAY_SOF_COUNT   1000
 

Functions

static void bootloader_system_init (void)
 Initializes the device for the bootloader. More...
 
static void check_boot_mode (void)
 
static bool integrity_check_in_disk (void)
 Function to check the integrity of the firmware in usb disk. More...
 
static bool integrity_check_in_flash (void)
 Function to check the integrity of the firmware in internal flash. More...
 
int main (void)
 Main function. More...
 
void main_usb_connection_event (uhc_device_t *dev, bool b_present)
 Callback on enumeration status change of a MSC device. More...
 
void main_usb_sof_event (void)
 Notify that a SOF has been sent (each 1 ms) More...
 
static bool program_memory (void)
 Function to program the Flash. More...
 
static void start_application (void)
 Function to start the application. More...
 
static void start_application_with_wdt (void)
 Function to issue a WDT reset to start the application. More...
 

Variables

COMPILER_WORD_ALIGNED volatile
uint8_t 
buffer [FLASH_BUFFER_SIZE]
 
static DIR file_dir
 
static FIL file_object
 
static uint32_t firmware_crc = 0
 
static FATFS fs
 
char input_file_name []
 
static volatile bool lun_connected = false
 
static TCHAR root_directory [20] = {'0', ':', 0}
 
static volatile uint32_t sof_count = 0
 

#define MSC_DELAY_SOF_COUNT   1000

Referenced by main().

static void check_boot_mode ( void  )
static
void main_usb_connection_event ( uhc_device_t dev,
bool  b_present 
)

Callback on enumeration status change of a MSC device.

Notify that a USB device has been connected or disconnected.

References lun_connected, sof_count, and UNUSED.

void main_usb_sof_event ( void  )

Notify that a SOF has been sent (each 1 ms)

References sof_count.

static void start_application ( void  )
static

Function to start the application.

References APP_START_ADDRESS.

Referenced by check_boot_mode().

static void start_application_with_wdt ( void  )
static

Function to issue a WDT reset to start the application.

This will reset the clock & peripheral configurations.

Referenced by main().

DIR file_dir
static
FIL file_object
static
uint32_t firmware_crc = 0
static
FATFS fs
static

Referenced by chk_mounted(), and f_mount().

char input_file_name[]
Initial value:
= {
}
#define FIRMWARE_IN_FILE_NAME
Firmware file input name.
Definition: conf_bootloader.h:48

Referenced by integrity_check_in_disk(), main(), and program_memory().

volatile bool lun_connected = false
static

Referenced by main(), and main_usb_connection_event().

TCHAR root_directory[20] = {'0', ':', 0}
static

Referenced by main().

volatile uint32_t sof_count = 0
static