资源简介
Software I2C Master and Slave Mode 2
代码片段和文件信息
/* ********************************************************
* 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
相关资源
- iic_slaver.rar
- OLED0.91模组12832 IIC全套显示函数字符显
- IIC Linux 应用层的两种操作方式
- OLED12864显示屏,12位ADC,按键中断,
- 气压传感器BMP180驱动stm32f103
- tcs3472颜色识别程序
- 气压计IIC模式驱动SPL06.rar
- stm32通过IIC读取HMC5883L来计算方向角
- 0.91OLED显示屏_C51系列_IIC_例程
- STM32+IIC+PCF8574T+1602A
- 电容屏USB转IIC代码.zip
- verilog编程fpga通过IIC读取mpu6050数据
- STM32 IIC 状态机 DMA 控制MPU60x0和burst读
- STM32和SHT3X 高精度温湿度传感器驱动
- 四线(IIC)OLED驱动STM32驱动程序
- stm32f407ZET驱动IIC 0.96寸OLED
- 基于stm32显示oled,用的是iic通信,可
- STM32F030F4P6串口通讯,modbus协议,IIC
- STM32F407 软件模拟IIC通信程序
- sony imx290 driver
- msp430F5529驱动 IIC OLED
- stm32 tsm12触摸芯片的触摸驱动软件ii
- TM1651 显程.rar
- STM32f103+SHT30代码.rar
- STM32CUBE配置硬件IIC协议驱动MPU6050,采
- STM32F407-OLED四线IIC.zip
- stm32f103_ bma250hal 库驱动
- Esp8266 进阶之路31乐鑫esp8266 SDK编程使
- stm32F407 库函数的麦轮手动车 PS2手柄
- IIC总线 Verilog FGPA模块实现 注释详尽
评论
共有 条评论