Microchip® Advanced Software Framework

udi_dfu_atmel.c File Reference

USB Device Atmel Firmware Upgrade (DFU) interface definitions.

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

#include "conf_usb.h"
#include "usb_protocol.h"
#include "usb_protocol_dfu.h"
#include "udd.h"
#include "udc.h"
#include "udi_dfu_atmel.h"
#include "conf_isp.h"
#include "isp.h"
#include "flip_protocol.h"
#include "string.h"

Macros

#define CAT_CMD(val1, val2)   (((uint16_t)val1<<8)|(val2<<0))
 Macro to simplify and to optimize command decode process. More...
 

Functions

void udi_dfu_atmel_disable (void)
 
bool udi_dfu_atmel_enable (void)
 
uint8_t udi_dfu_atmel_getsetting (void)
 
static void udi_dfu_atmel_mem_check (void)
 Process a blank check on memory. More...
 
static bool udi_dfu_atmel_mem_getaddr (uint8_t *arg)
 Gets a memory address in a Atmel DFU command. More...
 
static bool udi_dfu_atmel_mem_protected (void)
 Change DFU status to notify that the memory is protected. More...
 
static bool udi_dfu_atmel_mem_read (void)
 Reads memory and transfer data to USB interface. More...
 
static bool udi_dfu_atmel_mem_send_last_add (void)
 Send address which has failed during check memory. More...
 
static bool udi_dfu_atmel_mem_write (void)
 Writes memory with data from USB interface. More...
 
static void udi_dfu_atmel_sel_mem (uint8_t mem_num)
 Selects the memory. More...
 
bool udi_dfu_atmel_setup (void)
 
Internal routines to manage DFU requests
static void udi_dfu_atmel_reset_protocol (void)
 Resets DFU status and usb setup process callbacks. More...
 
static bool udi_dfu_flip_msg_decode (void)
 Decodes the Atmel DFU Command Called by over_under_run callback when the first data packet from a DNLOAD DFU request is received. More...
 
Manages Atmel DFU command from protocol version 2
static bool udi_dfu_atmel_program (void)
 Decodes and prepares program memory command. More...
 
static bool udi_dfu_atmel_read (void)
 Decodes and prepares read memory command. More...
 
static bool udi_dfu_atmel_blankcheck (void)
 Decodes and process blank check memory command. More...
 
static bool udi_dfu_atmel_erase_chip (void)
 Decodes and process erase chip command. More...
 
static void udi_dfu_atmel_start (void)
 Decodes and prepares CPU reset command. More...
 
static bool udi_dfu_atmel_select_memory (void)
 Decodes and process memory select command. More...
 

Variables

UDC_DESC_STORAGE udi_api_t udi_api_dfu_atmel
 Global structure which contains standard UDI interface for UDC. More...
 
To manage memories
static bool udi_dfu_atmel_mem_b_protected
 Flag to signal that memory is write protected. More...
 
static isp_addr_t udi_dfu_atmel_mem_add
 Memory address to read, write or check blank. More...
 
static isp_addr_t udi_dfu_atmel_mem_nb_data
 Number of data to process during read, write or check blank. More...
 
static isp_mem_t udi_dfu_atmel_mem_sel
 Memory ID selected to read, write or check blank. More...
 

Internal variables to manage DFU requests

#define DFU_ATMEL_BUF_TRANS_SIZE   FLIP_V2_BUF_TRANS_SIZE
 
static dfu_status_t udi_dfu_atmel_status
 Status of DFU process. More...
 
union {
   flip_msg_v2_t   msg
 
   uint8_t   payload [USB_DEVICE_EP_CTRL_SIZE]
 
udi_dfu_flip_msg
 Structure to store the command fields. More...
 
static COMPILER_WORD_ALIGNED
uint8_t 
udi_dfu_atmel_buf_trans [DFU_ATMEL_BUF_TRANS_SIZE]
 Buffer to receive or send data. More...
 
static bool(* udi_dfu_atmel_upload_callback )(void)
 Callback to use when an upload request is received. More...
 
static bool udi_dfu_atmel_reset
 Notify a reset request to start. More...
 
static bool udi_dfu_atmel_security
 Store the current security level. More...
 

#define CAT_CMD (   val1,
  val2 
)    (((uint16_t)val1<<8)|(val2<<0))

Macro to simplify and to optimize command decode process.

Referenced by udi_dfu_flip_msg_decode().

bool udi_dfu_atmel_mem_b_protected
static

Flag to signal that memory is write protected.

Referenced by udi_dfu_atmel_program(), udi_dfu_atmel_read(), and udi_dfu_atmel_sel_mem().

isp_addr_t udi_dfu_atmel_mem_nb_data
static

Number of data to process during read, write or check blank.

Referenced by udi_dfu_atmel_mem_check(), udi_dfu_atmel_mem_getaddr(), udi_dfu_atmel_mem_read(), and udi_dfu_atmel_mem_write().

isp_mem_t udi_dfu_atmel_mem_sel
static

Memory ID selected to read, write or check blank.

bool udi_dfu_atmel_reset
static

Notify a reset request to start.

Referenced by udi_dfu_atmel_enable(), udi_dfu_atmel_setup(), and udi_dfu_atmel_start().

bool udi_dfu_atmel_security
static

Store the current security level.

Referenced by udi_dfu_atmel_enable(), udi_dfu_atmel_erase_chip(), udi_dfu_atmel_program(), and udi_dfu_atmel_read().

dfu_status_t udi_dfu_atmel_status
static

Status of DFU process.

bool(* udi_dfu_atmel_upload_callback)(void)
static

Callback to use when an upload request is received.

Referenced by udi_dfu_atmel_mem_check(), udi_dfu_atmel_read(), udi_dfu_atmel_setup(), and udi_dfu_flip_msg_decode().