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) |
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 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 |
Initializes the device for the bootloader.
References cpu_irq_enable, delay_ms, port_config::direction, nvm_config::manual_page_write, nvm_get_config_defaults(), nvm_set_config(), port_get_config_defaults(), PORT_PIN_DIR_OUTPUT, port_pin_set_config(), sleepmgr_init(), system_init(), and uhc_start().
Referenced by main().
|
static |
References board_init(), port_pin_get_input_level(), and start_application().
Referenced by main().
int main | ( | void | ) |
Main function.
Execution starts here.
References bootloader_system_init(), check_boot_mode(), cpu_irq_disable, f_close(), f_mount(), f_open(), f_opendir(), FA_OPEN_EXISTING, FA_READ, FR_OK, FIL::fsize, input_file_name, lun_connected, MSC_DELAY_SOF_COUNT, NULL, program_memory(), root_directory, sof_count, start_application_with_wdt(), uhc_stop(), and uhi_msc_mem_get_lun().
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 |
Function to program the Flash.
Decrypt the firmware and program it.
References buffer, buffer_size, cpu_irq_disable, cpu_irq_enable, f_close(), f_open(), f_read(), FA_OPEN_EXISTING, FA_READ, FIL::fsize, i, input_file_name, nvm_erase_row(), nvm_write_buffer(), port_pin_set_output_level(), and STATUS_BUSY.
Referenced by main().
|
static |
Function to start the application.
Referenced by check_boot_mode().
|
static |
Function to issue a WDT reset to start the application.
This will reset the clock & peripheral configurations.
Referenced by main().
COMPILER_WORD_ALIGNED volatile uint8_t buffer[FLASH_BUFFER_SIZE] |
|
static |
|
static |
|
static |
char input_file_name[] |
Referenced by main(), and program_memory().
Referenced by main(), and main_usb_connection_event().
|
static |
Referenced by main(), main_usb_connection_event(), and main_usb_sof_event().