TA的每日心情 | 怒 2016-3-1 11:42 |
---|
签到天数: 45 天 连续签到: 1 天 [LV.5]常住居民I
|
本帖最后由 akai1314 于 2016-2-25 21:55 编辑
放假了很久,今天看了半天的demo,写下自己的笔记
从这里拿到了Demo
URL:http://www.atmel.com/images/SHA204_90USB1287_1.0.0.zip
使用atmel studio7 要进行转换.导入才能转化
一 project
硬件独立的文件有:
sha204_example_main.c
sha204_comm_marshaling.∗
sha204_comm.∗
sha204_comm_interface.h
sha204_i2c.c
sha204_swi.∗
sha204_timer_utilities.∗
sha204_lib_return_codes.h
sha204_config.h
sha204_physical.h
硬件dependent文件 -就是硬件依赖模块,意味着 如果跨平台使用这些代码,要修改这些文件
两种选择:
1. 实现sha204_physical.h 中 列出的声明函数
2. 从以下三个模块中选择其一:• bitbang_phys.c: Physical implementation as single wire interface (SWI) using
GPIO (includes delay_x.h).• uart_phys.c: Physical implementation as single wire interface (SWI) using a
UART (includes avr_compatible.h).• i2c_phys.c: Physical implementation as two wire interface (I2C).
本项目中默认的IIC接口, 如果要使用上边三个文件中其中一个atmel已经把三个文件都放在了src 文件夹了。太棒了
我们可以轻松创建3种接口的访问方式:
1.创建的时候 使用sha204_example_-main.c and sha204_comm∗ 添加进项目,所有的硬件都要引入sha204_lib_return_codes.h and sha204_physical.h.
2. Supply communication interface hardware independent modules. For SWI add sha204_swi.∗, for I2C add sha204_i2c.∗. You might have to also modify sha204_-i2c.c, especially for 32-bit CPUs, since their I2C peripherals implement such functionality in hardware. For instance, they might not support the generation of individual Start and Stop conditions.
3.• Supply communication interface hardware dependent modules. If you do notuse an AVR CPU, you have to implement the functions in these modules. For SWI using UART add uart_phys.c, for SWI using GPIO add bitbang_phys.c, and for I2C add i2c_phys.∗. Be aware that uart_phys.c includes avr_compatible.h and bitbang_phys.c includes delay_x.h. Also, both SWI modules include swi_-
phys.h.
4.Supply a timer utility module. You can either use the one provided, timer_-utilities.∗, or provide your own. The SHA204 library uses two delay functions, delay_ms(uint8_t) and delay_10us(uint8_t). These functions do not use hardware timers but loop counters. The supplied module is tuned for an AT90USB1287 CPU running at 16 MHz, but you can easily tune it for other micro-controllers as long as one loop iteration (decrement, compare, and jump) does not take longer than 10 us
创建project 使用IIC接口
从sha204_example_main.c入手
SHA204 是一个SHA-256加密器件。来一个简单的事例就是:我们在登陆一些 金融类的网站时会看到
|
|