i2c.c

来自「ADS1240转换程序」· C语言 代码 · 共 45 行

C
45
字号
#include "hpa449lib.h"
/*****************************************************************************
** [file] 
** i2c.c
** [Puropse]
** I2C site selection functions
*/

void I2C_Init(void)
{
   // need to initialize both I2C sites
	I2C_A_Init();
	I2C_B_Init();
}

int I2C_SetSite(int SiteCode)
{
   int Success = 1;
   switch (SiteCode)
   {
      case SITE_A:
         I2C_StartFcn = I2C_A_Start;
         I2C_StopFcn = I2C_A_Stop;
         I2C_SendByteFcn = I2C_A_SendByte;
         I2C_ReceiveByteFcn = I2C_A_ReceiveByte;
         break;
	   case SITE_B:
         I2C_StartFcn = I2C_B_Start;
         I2C_StopFcn = I2C_B_Stop;
         I2C_SendByteFcn = I2C_B_SendByte;
         I2C_ReceiveByteFcn = I2C_B_ReceiveByte;
	      break;
	   default:
	      Success = 0;
   }
   return Success;
}

// default to site A
void (*I2C_StartFcn)() = I2C_A_Start;
void (*I2C_StopFcn)() = I2C_A_Stop;
int (*I2C_SendByteFcn)(unsigned char) = I2C_A_SendByte;
unsigned char (*I2C_ReceiveByteFcn)(int) = I2C_A_ReceiveByte;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?