资源简介
Software I2C Master and Slave Mode 2
![](http://www.nz998.com/pic/42747.jpg)
代码片段和文件信息
/* ********************************************************
* File : scl_interrupt_XP.c
* Description : Codes for I2C slave functionality.
*
Copyright 2005 ZiLOG Inc. ALL RIGHTS RESERVED.
*
* The source code in this file was written by an
* authorized ZiLOG employee or a licensed consultant.
* The source code has been verified to the fullest
* extent possible.
*
* Permission to use this code is granted on a royalty-free
* basis. However users are cautioned to authenticate the
* code contained herein.
*
* ZiLOG DOES NOT GUARANTEE THE VERACITY OF THE SOFTWARE.
**************************************************************/
#include
#include “scl_interrupt_XP.h“
unsigned char test_address =0;
unsigned char i2c_flag; // To hold the Different status of I2C
unsigned char bit_counter; // To keep count of no of bits received
// This counter will reset when the count ==9
unsigned char data_receive_byte; // To store the data byte received.
unsigned char data_transmit_byte; // To store the data to be transmitted
unsigned char volatile sda_bit; //Read the SDA bit
unsigned char bus_status; // To set bus busy or free flag
unsigned char rising_edge_counter; // Keeps counts of no of SCL rising edges
// in a byte.
unsigned char volatile address_received; //Store the address received
unsigned char volatile data_byte; // Store the data received.
unsigned char volatile edge;
unsigned char volatile temp1;
unsigned char volatile send_bit; // Stores the MSB to be transmitted
unsigned char byte_count; // Count no of bytes received.
//Initialization of the function pointer
void (*function_ptr[4])(void) = {
slave_address_receive
slave_data_receive
slave_transmitter
address_mismatch };
/* *******************************************************************************
The main routine sets the Port pins PC0 and PC1 to work as either input or output
with open drain.The I2C bus status is set to free(No Transaction on the I2C bus).
Sets the interrupt PC0 and PC1 to highist priority.Enables the interrupt. User can
add his code in this main OR can call some function from main.
/*********************************************************************************/
int main()
{
if(F0830){//Needed for 20MHz external resonator
init_external_systemclock();
}
PCADDR = 0x06 ; //For pull up mode.
PCCTL |= 0x03; // Port pin PC0 and PC1 to pull up mode.
i2c_flag = I2C_ADDRESS_RECEIVE;
PCADDR = 0x01; //Set the Value to select DATA direction
PCCTL |= SDA_DIRECTION_IN; // Change SDA to INPUT
PCCTL |= SCL_DIRECTION_IN; //OR with PC1
bus_status = I2C_BUS_FREE; // Indicates bus status is “FREE“
IRQ2ENL = 0x03;
IRQ2ENH = 0x03; // Set SDA and SCL for Highist priority
EI(); //Enable all interrupts
data_byte=0; //We‘ll watch for data_byte to change
PCOUT|=0x08; //LED Off
PCDD&=~0x08; //L
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 4947 2007-10-27 19:40 gpioportpins\I2CMaster.C
文件 1334 2007-10-28 10:49 gpioportpins\I2CMaster.h
文件 4487 2007-10-28 10:47 gpioportpins\MasterTest.C
文件 11231 2007-10-28 10:51 gpioportpins\scl_interrupt_XP.c
文件 2151 2007-10-23 17:16 gpioportpins\scl_interrupt_XP.h
文件 2927 2005-02-16 13:07 gpioportpins\sda_interrup_XP.c
目录 0 2010-06-05 13:43 gpioportpins
----------- --------- ---------- ----- ----
27077 7
相关资源
- DAS1302蜂鸣 独立按键 闹钟设定 IIC存储
- STM32 DS3231驱动.zip
- IIC proteus仿真实验
- STM32F030从机中断接收的iic代码,附带
- STM32使用模拟IIC实现24C02读取
- 0.96OLED_C51系列_IIC应答_例程
- (带有源代码)基于FPGA的模拟I2C接口
- zw_OLED-STM32F4-IIC.zip
- STM32硬件IIC主机例程以读写EEPROM为例
- stm32单片机IIC通讯采集sht20温湿度传感
- 基于IIC的OLED显示程序
- OLED程序例程(STM32_OLED(C8T6))
- stm32f103iic读取AT24XX全系eeprom
- fpga与eeprom通信
- STM32用IIC通信实现OLED显示程序代码及
- ATTINY24A 接收IIC程序控制直流电机
- 基于STM32F103控制16PWM路舵机驱动板PC
- STM8L 硬件IIC主机
- DTH11温湿度显示在IIC_OLED上,好用,自
- STM32 IIC驱动DRV10983
- STM32--IIC通信两个JY-901模块
- WiiCCD Master 3.51 + Wbfs Master 2.15
- 基于FPGA的pcf8591的AD采样程序verilog
- WiiCCD_Master_3.51_+_Wbfs_Master_2.16.rar
- 关于七针0.96寸OLED使用IIC接口的说明
- Verilog IIC读MPU6050-融合滤波-单轴-代码
- STM8程序IAR环境
- 0.96寸OLED+原子STM32F4+IIC通信
- FPGA实现IIC通信.zip
- STM32读取_电量管理芯片_BQ76930芯片电压
评论
共有 条评论