资源简介
用于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救砖所需资料
- 下一篇:仓库管理系统课程设计
相关资源
- 易语言自定义加解密文本源码
- 自定义电子面单模版
- DAS1302蜂鸣 独立按键 闹钟设定 IIC存储
- 可自定义导航网站源码
- 自定义的TabCtrl控件实现
- STM32 DS3231驱动.zip
- IIC proteus仿真实验
- tekla 自定义节点
- delphi 自定义消息窗口和进度条窗口,
- Excel自定义函数:字符串相似度
- Delphi自定义函数程序
- ios-工具类自定义带箭头弹出视图.zi
- 自定义VIewGroup实现仿淘宝商品详情页
- STM32F030从机中断接收的iic代码,附带
- Spring Boot中自定义注解结合AOP实现主备
- 易语言高级表格自定义计算公式源码
- 自定义键盘 身份证键盘
- STM32使用模拟IIC实现24C02读取
- 百度地图类库 自定义信息窗口.zip
- OpcRcw.Ae.dll OpcRcw.Batch.dll OpcRcw.Comn.dll
- 0.96OLED_C51系列_IIC应答_例程
- Excel自定义函数_身份证号码校验
- (带有源代码)基于FPGA的模拟I2C接口
- Arm-linux 自定义开机启动程序,避开从
- 皮卡丘远控自定义图片捆绑.rar
- zw_OLED-STM32F4-IIC.zip
- STM32硬件IIC主机例程以读写EEPROM为例
- stm32单片机IIC通讯采集sht20温湿度传感
- 基于IIC的OLED显示程序
- TinyMCE自定义上传图片
评论
共有 条评论