6
ATECC108/ATSHA204 Firmware Library [USER GUIDE]
Atmel-8770C-CryptoAuth-ATECC108-ATSHA204-Firmware-Library-UserGuide_012014
Folder Structure
All modules reside in one folder. Because of this, you can either add the entire folder to your project and
then exclude the modules you don't need from compilation, or you can add the modules that you do need
one by one. Which modules to exclude from compilation depend on the interface you plan to use. Table 1
shows which modules to include in your project, depending on your interface. The modules in the other two
columns have to be excluded if they do not appear in the column you selected.
Table 1. Interface Modules
Porting
When porting the library to other targets or when using CPU clock speeds other than the ones provided by
the examples, certain modules have to be modified, including the physical layer modules you plan to use
(SWI or I2C) and the timer_utilities.c timer function (see “Timer Functions” on page 8).
Physical Layer Modules
To port the hardware-dependent modules for SWI or I2C to your target, you have several options:
Implement the modules from scratch.
Modify the UART or I2C module(s) provided by your target library.
Create a wrapper around your target library that matches the software interface of the
ATECC108/ATSHA204 library’s Physical layer. For instance, your target library for I2C might use
parameters of different type, number, or sequence than those in the i2c_phys.c module [e.g.,
i2c_send_bytes(uint8_t count, uint8_t *data) ].
Modify the calls to hardware-dependent functions in the hardware-independent module for the
Physical layer (sha204_swi.c / sha204_i2c.c) to match the functions in your target library. The
hardware-dependent module for I2C reflects a simple I2C peripheral, where single I2C operations can
be performed (Start, Stop, Write Byte, Read Byte, etc.). Many targets contain more sophisticated I2C
peripherals, where registers have to be loaded first with an I2C address, a Start or Stop condition, a
data buffer pointer, etc. In such cases, sha204_i2c.c has to be rewritten.
The hardware-dependent modules provided by Atmel use loop counters for timeout detection. When
porting, you can either adjust the loop counter start values, which get decremented while waiting for flags
to be set or cleared, or you can use hardware timers or timer services provided by a real-time operating
system you may be using. These values are defined in bitbang_phys.h (SWI GPIO), uart_phys.h (SWI
UART), and i2c_phys.h (I2C), respectively.
Interface SWI GPIO SWI UART I2C I2C_bitbang
Hardware
Independent File sha204_swi.c sha204_swi.c sha204_i2c.c sha204_i2c.c
Hardware
Dependent Files
bitbang_phys.c uart_phys.c i2c_phys.c i2c_phys_bitbang.c
bitbang_config.h uart_config.h i2c_phys.h i2c_phys_bitbang.h
swi_phys.h swi_phys.h
avr_compatible.h
Compilation Switch SHA204_GPIO_BITBANG SHA204_GPIO_UART SHA204_I2C SHA204_I2C_BITBANG