📄 main.c
字号:
/**************** (c) 2003 STMicroelectronics ********************************
PROJECT : EVALUATION BOARD - ST7 I2C
COMPILERS : COSMIC AND METROWERKS
MODULE : main.c
REVISION DATE : 12/06/03
AUTHOR : Micro Controller Division Application Team
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
THE SOFTWARE INCLUDED IN THIS FILE IS FOR GUIDANCE ONLY. STMicroelectronics
SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR CONSEQUENTIAL
DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM USE OF THIS SOFTWARE.
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
DESCRIPTION : ST7 I2C main test software.
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
MODIFICATIONS :
27/08/98 - V1.0 - First version (error management:AF).
12/06/03 - V1.1 - 1) Compatibility With Cosmic And Metroworks.
2) Generation Of Non - Ack.
3) Update for st72324
******************************************************************************/
/* EXTERNAL DECLARATIONS *****************************************************/
/* List of all the variables defined in another module and used in this one. */
/* MODEL => #include {file_name}.h */
#include "map72324.h" /* Declaration of the I2C HW registers.*/
#include "i2cm_drv.h" /* I2C single master driver.*/
#include "variable.h"
#include "lib_bits.h"
/* MACRO FUNCTION DECLARATIONS ***********************************************/
/* MODEL => #define macro_name macro */
#ifdef __HIWARE__
#define WAIT_1ms() for (i=0xFF; i>0; i--) asm NOP /* Wait for ~1ms.*/
#else
#ifdef __CSMC__
#define WAIT_1ms() for (i=0xFF; i>0; i--) { _asm( "NOP" ); }
/* Wait for ~1ms.*/
#endif
#endif
/* STATIC DECLARATIONS *******************************************************/
/* List of all the variables/constant defined in another module and used in */
/* this one. */
/* MODEL => static type_name var_name; or #define */
void main (void)
{
I2Cm_Init(); /* I2C peripheral initialization routine.*/
while (1)
{
#ifdef __HIWARE__
asm
{
trans:
}
#else
#ifdef __CSMC__
{
_asm ( "trans:");
}
#endif
#endif
ClrBit(I2C_SR1,RCPT);
I2Cm_Start();
I2Cm_Tx(send_tab,n); /* Transmit data byte to the slave. */
if (ValBit(I2C_SR2,AF))
{
ClrBit(I2C_SR2,AF);
t_count_err++;
#ifdef __HIWARE__
asm JRA trans
#else
#ifdef __CSMC__
{
_asm( "JRA trans");
}
#endif
#endif
}
I2Cm_Stop();
WAIT_1ms();
#ifdef __HIWARE__
asm
{
recept:
}
#else
#ifdef __CSMC__
{
_asm ("recept:");
}
#endif
#endif
I2Cm_Start();
I2Cm_Rx(rec_tab,n); /* Receive data byte from the slave. */
if (ValBit(I2C_SR2,AF))
{
ClrBit(I2C_SR2,AF);
r_count_err++;
#ifdef __HIWARE__
asm JRA recept
#else
#ifdef __CSMC__
_asm("JRA recept");
#endif
#endif
}
I2Cm_Stop();
WAIT_1ms();
}
}
/***************** (c) 2003 STMicroelectronics ************** END OF FILE ***/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -