📄 main.c
字号:
/******************************************************************************
COPYRIGHT 2002 STMicroelectronics
Source File Name : main.c
Group : IPSW,CMG-IPDF
Author : MCD Application Team
Date First Issued: 04/03/2002
********************************Documentation**********************************
General Purpose - It is application file which calls the functions in i2c.c.
This example carries out the single byte transmission and continuous
transmission in pollling mode or in interrupt driven without buffer mode as per
the selection made in the ST7lib_Config.h. Also it carries out the reception of
a single byte and a buffer of data in polling mode or in interrupt driven
without buffer mode.The transmission and reception are carried out at a speed
of 200 KHz.
Also for transmission and reception in interrupt driven case, interrupt is
enabled for generating the interrupt.
********************************Revision History*******************************
_______________________________________________________________________________
Date :04/03/2002 Release:1.0
--*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**/
#include "ST7lib_config.h" /* List of all ST7 devices and communication mode */
#include "main.h"
/* Declaration of prototypes of user defined functions used in main.c */
void main(void)
{
unsigned char Rx_Data;
unsigned char Buff_Test[size_buff];
unsigned char Buff[size_buff] = {0, 1, 2, 5, 50, 10, 100, 200, 225, 255};
I2C_TxErrCode_t Temp1 ;
I2C_RxErrCode_t Temp2 ;
Temp1 = Temp2 = 0x00 ;
I2C_Init ((unsigned char)I2C_ENABLE_ACK | (unsigned char)I2C_IT_ENABLE);
/* Enable acknowledge and interrupts */
EnableInterrupts; /* Interrupt mask is reset for enabling interrupt */
I2C_MultiMaster_Config (); /* Configure I2C as multimaster I2C device */
I2C_Select_Speed (I2C_FASTSPEED, (unsigned int)200);
/* Selects fast speed mode, Speed is 200KHz */
I2C_Generate_Start ();
while(!(I2C_IsTransmitCompleted()== I2C_START_OK));
/*================================================
Transmission through 慞olling
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -