91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 9KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2021-05-09
  • 語言: 其他
  • 標簽: IIC??

資源簡介

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


評論

共有 條評論