Microchip® Advanced Software Framework

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
In System Programming UC3 implementation

This implementation links the UC3 NVM functions to the common isp API.

Also, it manage :

Functions

static void mem_bootloader_read (void *dst, isp_addr_t src, uint16_t nbytes)
 Copy a bootloader version memory section to a RAM buffer. More...
 
static void mem_configuration_read (void *dst, isp_addr_t src, uint16_t nbytes)
 Copy the fuse bits values to a RAM buffer. More...
 
static void mem_configuration_write (isp_addr_t dst, const void *src, uint16_t nbytes)
 Copy the RAM buffer values to fuse bits. More...
 
static void mem_flash_read (void *dst, isp_addr_t src, uint16_t nbytes)
 Copy a flash memory section to a RAM buffer. More...
 
static void mem_flash_write (isp_addr_t dst, const void *src, uint16_t nbytes)
 Copy a RAM buffer to a flash memory section. More...
 
static void mem_security_read (void *dst, isp_addr_t src, uint16_t nbytes)
 Copy the security bit value to a RAM buffer. More...
 
static void mem_security_write (isp_addr_t dst, const void *src, uint16_t nbytes)
 Set the security bit. More...
 
static void mem_signature_read (void *dst, isp_addr_t src, uint16_t nbytes)
 Copy a signature memory section to a RAM buffer. More...
 
static void mem_user_read (void *dst, isp_addr_t src, uint16_t nbytes)
 Copy an user page memory section to a RAM buffer. More...
 
static void mem_user_write (isp_addr_t dst, const void *src, uint16_t nbytes)
 Copy a RAM buffer to a user page memory section. More...
 

Variables

const isp_mem_t isp_bootloader
 Interface for memory bootloader version. More...
 
const isp_mem_t isp_conf
 Interface for memory configuration (fuse bits) More...
 
const isp_mem_t isp_flash
 Interface for memory flash. More...
 
const isp_mem_t isp_no_available
 Interface for memory no available. More...
 
const isp_mem_t isp_security
 Interface for bit security. More...
 
const isp_mem_t isp_signature
 Interface for memory signature. More...
 
const isp_mem_t isp_user
 Interface for memory user page. More...
 

Specific memories

static isp_mem_signature_t mem_signature
 Memory signature that stores information about the device. More...
 
static isp_mem_bootloader_t mem_bootloader
 Memory bootloader that stores the bootloader version. More...
 

Memories list declaration

const isp_mems_t isp_memories
 Memories list declaration. More...
 

Miscellaneous functions of the In System Programming module

void isp_init (void)
 Initializes the ISP interface. More...
 
bool isp_is_security (void)
 Gives the security state of the chip. More...
 
bool isp_erase_chip (void)
 Erase the application flash area and eventually the eeprom. More...
 
bool isp_erase_chip_split (void)
 Erase a part of the application flash area This function must be called again as long as it returns 0. More...
 
void isp_start_appli (void)
 Resets the device to start the user application. More...
 
static uint8_t isp_crc8 (uint8_t inCrc, uint8_t inData)
 Calculates the CRC-8-CCITT. More...
 
void isp_force_boot_isp (bool force)
 Change the boot process configuration to enable/disable the ISP mode for the next startup. More...
 

static uint8_t isp_crc8 ( uint8_t  inCrc,
uint8_t  inData 
)
static

Calculates the CRC-8-CCITT.

CRC-8-CCITT is defined to be x^8 + x^2 + x + 1 To use this function use the following template: crc = isp_crc8( crc, data );

References BOOT_CFG1_CRC8_POLYNOMIAL, data, and i.

Referenced by isp_force_boot_isp().

bool isp_erase_chip ( void  )

Erase the application flash area and eventually the eeprom.

Returns
1 if function was successfully done, otherwise 0.

Referenced by udi_dfu_atmel_erase_chip().

bool isp_erase_chip_split ( void  )

Erase a part of the application flash area This function must be called again as long as it returns 0.

Returns
1 if the whole application flash area is erased, otherwise it is not finished.

This function has been created to split a long erase so that the ISP application is able to answer external pending requests.

Referenced by udi_dfu_atmel_erase_chip().

void isp_force_boot_isp ( bool  force)

Change the boot process configuration to enable/disable the ISP mode for the next startup.

Parameters
forceEnable the ISP mode for the next startup if true

References BOOT_CFG1, BOOT_CFG1_ADDRESS, BOOT_CFG1_CRC8_MASK, BOOT_CFG1_CRC8_OFFSET, BOOT_CFG1_FORCE_MASK, BOOT_CFG1_FORCE_OFFSET, i, and isp_crc8().

Referenced by udi_dfu_atmel_setup(), and udi_dfu_flip_msg_decode().

void isp_init ( void  )

Initializes the ISP interface.

Example, load the JTAG ID in signature memory

References Get_debug_register, mem_signature, and Rd_bitfield.

Referenced by udi_dfu_atmel_enable().

bool isp_is_security ( void  )

Gives the security state of the chip.

Returns
1 if chip is secured, otherwise 0.

References isp_mem_t::fnct_read.

Referenced by udi_dfu_atmel_enable().

void isp_start_appli ( void  )

Resets the device to start the user application.

The ISP mode must be disabled before (See isp_force_boot_isp(false)) to allow the boot process to jump to the user application.

Note
: this function is usually implemented by using a watchdog reset or a software reset to restart the CPU.

References cpu_irq_disable, UC3C, UC3D, and UC3L3_L4.

Referenced by udi_dfu_atmel_setup().

static void mem_bootloader_read ( void *  dst,
isp_addr_t  src,
uint16_t  nbytes 
)
static

Copy a bootloader version memory section to a RAM buffer.

Parameters
dstPointer to data destination.
srcPointer to source memory.
nbytesNumber of bytes to transfer.
static void mem_configuration_read ( void *  dst,
isp_addr_t  src,
uint16_t  nbytes 
)
static

Copy the fuse bits values to a RAM buffer.

Parameters
dstByte array to store fuse bit values (1bit/Byte).
srcFuse bit address to read
nbytesNumber of bit to read
static void mem_configuration_write ( isp_addr_t  dst,
const void *  src,
uint16_t  nbytes 
)
static

Copy the RAM buffer values to fuse bits.

Parameters
dstFuse bit address to write
srcByte array of fuse bit values (1bit/Byte).
nbytesNumber of bit to write
static void mem_flash_read ( void *  dst,
isp_addr_t  src,
uint16_t  nbytes 
)
static

Copy a flash memory section to a RAM buffer.

Parameters
dstPointer to data destination.
srcPointer to source flash.
nbytesNumber of bytes to transfer.
static void mem_flash_write ( isp_addr_t  dst,
const void *  src,
uint16_t  nbytes 
)
static

Copy a RAM buffer to a flash memory section.

Parameters
dstPointer to flash destination.
srcPointer to source data.
nbytesNumber of bytes to transfer.
static void mem_security_read ( void *  dst,
isp_addr_t  src,
uint16_t  nbytes 
)
static

Copy the security bit value to a RAM buffer.

Parameters
dstPointer to store security bit value.
srcNot used
nbytesMust be different of 0
static void mem_security_write ( isp_addr_t  dst,
const void *  src,
uint16_t  nbytes 
)
static

Set the security bit.

Parameters
dstNot used
srcPointer to new security bit value (Must be different of 0)
nbytesMust be different of 0
static void mem_signature_read ( void *  dst,
isp_addr_t  src,
uint16_t  nbytes 
)
static

Copy a signature memory section to a RAM buffer.

Parameters
dstPointer to data destination.
srcPointer to source memory.
nbytesNumber of bytes to transfer.

References mem_signature.

static void mem_user_read ( void *  dst,
isp_addr_t  src,
uint16_t  nbytes 
)
static

Copy an user page memory section to a RAM buffer.

Parameters
dstPointer to data destination.
srcPointer to source memory.
nbytesNumber of bytes to transfer.
static void mem_user_write ( isp_addr_t  dst,
const void *  src,
uint16_t  nbytes 
)
static

Copy a RAM buffer to a user page memory section.

Parameters
dstPointer to user page destination.
srcPointer to source data.
nbytesNumber of bytes to transfer.

const isp_mem_t isp_bootloader
Initial value:
= {
.size = sizeof(mem_bootloader),
.fnct_read = mem_bootloader_read,
.fnct_write = NULL,
}
#define NULL
Definition: lwip-1.4.1/src/include/lwip/def.h:47
static isp_mem_bootloader_t mem_bootloader
Memory bootloader that stores the bootloader version.
Definition: isp.c:86
static void mem_bootloader_read(void *dst, isp_addr_t src, uint16_t nbytes)
Copy a bootloader version memory section to a RAM buffer.
Definition: isp.c:182

Interface for memory bootloader version.

const isp_mem_t isp_conf
Initial value:
= {
.size = FLASH_API_GPF_NUM,
.fnct_read = mem_configuration_read,
.fnct_write = mem_configuration_write,
}
static void mem_configuration_read(void *dst, isp_addr_t src, uint16_t nbytes)
Copy the fuse bits values to a RAM buffer.
Definition: isp.c:152
static void mem_configuration_write(isp_addr_t dst, const void *src, uint16_t nbytes)
Copy the RAM buffer values to fuse bits.
Definition: isp.c:167

Interface for memory configuration (fuse bits)

const isp_mem_t isp_flash
Initial value:
= {
.size = FLASH_API_SIZE,
.fnct_read = mem_flash_read,
.fnct_write = mem_flash_write,
}
static void mem_flash_read(void *dst, isp_addr_t src, uint16_t nbytes)
Copy a flash memory section to a RAM buffer.
Definition: isp.c:100
static void mem_flash_write(isp_addr_t dst, const void *src, uint16_t nbytes)
Copy a RAM buffer to a flash memory section.
Definition: isp.c:112

Interface for memory flash.

const isp_mems_t isp_memories
Initial value:
= {
.list = {
.flash = &isp_flash,
.eeprom = &isp_no_available,
.security = &isp_security,
.conf = &isp_conf,
.bootloader = &isp_bootloader,
.signature = &isp_signature,
.user = &isp_user,
.int_ram = &isp_no_available,
.ext_mem_cs0 = &isp_no_available,
.ext_mem_cs1 = &isp_no_available,
.ext_mem_cs2 = &isp_no_available,
.ext_mem_cs3 = &isp_no_available,
.ext_mem_cs4 = &isp_no_available,
.ext_mem_cs5 = &isp_no_available,
.ext_mem_cs6 = &isp_no_available,
.ext_mem_cs7 = &isp_no_available,
.ext_mem_df = &isp_no_available,
}
}
const isp_mem_t isp_flash
Interface for memory flash.
Definition: isp.c:224
const isp_mem_t isp_signature
Interface for memory signature.
Definition: isp.c:252
const isp_mem_t isp_security
Interface for bit security.
Definition: isp.c:231
const isp_mem_t isp_no_available
Interface for memory no available.
Definition: isp.c:266
const isp_mem_t isp_user
Interface for memory user page.
Definition: isp.c:259
const isp_mem_t isp_conf
Interface for memory configuration (fuse bits)
Definition: isp.c:238
const isp_mem_t isp_bootloader
Interface for memory bootloader version.
Definition: isp.c:245

Memories list declaration.

Referenced by udi_dfu_atmel_sel_mem().

const isp_mem_t isp_no_available
Initial value:
= {
.size = 0,
.fnct_read = NULL,
.fnct_write = NULL,
}
#define NULL
Definition: lwip-1.4.1/src/include/lwip/def.h:47

Interface for memory no available.

const isp_mem_t isp_security
Initial value:
= {
.size = 1,
.fnct_read = mem_security_read,
.fnct_write = mem_security_write,
}
static void mem_security_write(isp_addr_t dst, const void *src, uint16_t nbytes)
Set the security bit.
Definition: isp.c:138
static void mem_security_read(void *dst, isp_addr_t src, uint16_t nbytes)
Copy the security bit value to a RAM buffer.
Definition: isp.c:124

Interface for bit security.

const isp_mem_t isp_signature
Initial value:
= {
.size = sizeof(mem_signature),
.fnct_read = mem_signature_read,
.fnct_write = NULL,
}
#define NULL
Definition: lwip-1.4.1/src/include/lwip/def.h:47
static isp_mem_signature_t mem_signature
Memory signature that stores information about the device.
Definition: isp.c:83
static void mem_signature_read(void *dst, isp_addr_t src, uint16_t nbytes)
Copy a signature memory section to a RAM buffer.
Definition: isp.c:194

Interface for memory signature.

const isp_mem_t isp_user
Initial value:
= {
.size = FLASH_API_USER_PAGE_SIZE,
.fnct_read = mem_user_read,
.fnct_write = mem_user_write,
}
static void mem_user_write(isp_addr_t dst, const void *src, uint16_t nbytes)
Copy a RAM buffer to a user page memory section.
Definition: isp.c:218
static void mem_user_read(void *dst, isp_addr_t src, uint16_t nbytes)
Copy an user page memory section to a RAM buffer.
Definition: isp.c:206

Interface for memory user page.

isp_mem_bootloader_t mem_bootloader
static
Initial value:
= {
.version = BOOTLOADER_VERSION,
.id1 = 0,
.id2 = 0,
}

Memory bootloader that stores the bootloader version.

isp_mem_signature_t mem_signature
static

Memory signature that stores information about the device.

Referenced by isp_init(), and mem_signature_read().