資源簡介
用于altera的NIOSII的外設,Avalon總線接口,有完整的文檔和HAL驅動文件,復制到相應目錄(內有說明)就可以在SOPC Build中添加到設計中,使用方便
代碼片段和文件信息
#include?“system.h“
#include?“oc_i2c_regs.h“
#include?“alt_types.h“
void?I2CWaitTIP(alt_u32?base);
/*********************************************************************************************************
**?Function?name: InitI2C
**
**?Descriptions: Initialize?the?I2C?Open?Core.?The?frequency?of?SCL?is?set?as?freq
**????????????????????Interrupt?will?be?or?not?be?enabled?by?the?IEN??
**
**?input?parameters: base:?The?base?address?of?I2C?Core;
**????????????????????freq:?The?frequency?of?SCL?we?want
**????????????????????IEN?:?When?the?IEN?is?1?interrupt?will?be?enabled;
**??????????????????????????When?the?IEN?is?NOT?1?interrupt?will?be?disabled.???????????????????????
**
**?Returned?value: None?
**?????????
**?Used?global?variables: None
**?Calling?modules: ??None
**
**?Created?by: Jing.Zhang
**?Created?Date: 2005/09/30
**-------------------------------------------------------------------------------------------------------
**?Modified?by:
**?Modified?date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
void?InitI2C(alt_u32?base?alt_u32?freq?alt_u8?IEN)
{
alt_u32?prescale;
//?Calculate?the?prescale?value
prescale?=?ALT_CPU_FREQ/((freq<<2)?+?freq);
??//?Setup?prescaler?for?the?freq?of?SCL?with?sysclk?of?ALT_CPU_FREQ
??IOWR_OC_I2C_PRERLO(base?prescale?&?0xff);
??IOWR_OC_I2C_PRERHI(base(prescale?&?0xff00)>>8);
??//?Enable?core
??if(IEN?==?1)?//?Enable?interrupt
??{
?? IOWR_OC_I2C_CTR(base?0xC0);
??}
??else?//?Enable?core?while?disable?interrupt
??{
?? IOWR_OC_I2C_CTR(base?0x80);
??}
}
/*********************************************************************************************************
**?Function?name:?????I2CWaitTIP
**
**?Descriptions:??????Wait?for?the?completion?of?transfer.?
**
**?input?parameters:??base:????The?base?address?of?I2C?Core;
**?????????????????
**????????????
**?Returned?value:????None?
**?????????
**?Used?global?variables:?None
**?Calling?modules:???????None
**
**?Created?by:????????Jing.Zhang
**?Created?Date:??????2005/09/30
**-------------------------------------------------------------------------------------------------------
**?Modified?by:
**?Modified?date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
void?I2CWaitTIP(alt_u32?base)
{
??while?(IORD_OC_I2C_SR(base)?&?I2C_SR_TIP)?{}
}
/*********************************************************************************************************
**?Function?name: I2CWrite
**
**?Descriptions: Write?num?bytes?data?to?slave?device?by?I2C?bus.?
**
**?input?parameters: base:????The?base?address?of?I2C?Core;
**????????????????????address:?The?add
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????31277??2007-01-22?20:55??oc_i2c_master\cb_generator.pl
?????文件???????7781??2007-01-22?20:55??oc_i2c_master\class.ptf
?????文件????????567??2007-01-22?20:55??oc_i2c_master\使用說明.txt
?????文件????????324??2007-01-22?20:55??oc_i2c_master\HAL\inc\oc_i2c.h
?????目錄??????????0??2009-04-01?10:46??oc_i2c_master\HAL\inc
?????文件????????130??2007-01-22?20:55??oc_i2c_master\HAL\src\component.mk
?????文件???????6717??2007-03-15?17:08??oc_i2c_master\HAL\src\oc_i2c.c
?????目錄??????????0??2009-04-01?10:46??oc_i2c_master\HAL\src
?????目錄??????????0??2009-04-01?10:46??oc_i2c_master\HAL
?????文件??????14480??2007-01-22?20:55??oc_i2c_master\hdl\i2c_master_bit_ctrl.vhd
?????文件??????11845??2007-01-22?20:55??oc_i2c_master\hdl\i2c_master_byte_ctrl.vhd
?????文件??????12010??2007-01-22?20:55??oc_i2c_master\hdl\i2c_master_top.vhd
?????文件???????3253??2007-01-22?20:55??oc_i2c_master\hdl\oc_i2c_master.vhd
?????目錄??????????0??2009-04-01?10:46??oc_i2c_master\hdl
?????文件?????193668??2007-01-22?20:55??oc_i2c_master\I2C_doc\i2c_specs.pdf
?????目錄??????????0??2009-04-01?10:46??oc_i2c_master\I2C_doc
?????文件???????1302??2007-03-15?17:16??oc_i2c_master\inc\oc_i2c_regs.h
?????目錄??????????0??2009-04-01?10:46??oc_i2c_master\inc
?????目錄??????????0??2009-04-01?10:46??oc_i2c_master
-----------?---------??----------?-----??----
???????????????283354????????????????????19
- 上一篇:QPST救磚所需資料
- 下一篇:倉庫管理系統課程設計
評論
共有 條評論