📄 mcuiic.c
字号:
//-----------------------------------------------------------------------------
// mcuiic.c
//-----------------------------------------------------------------------------
// Copyright 2005 Sky Pacific Ltd.
//
// Program Description:
//
// This module handles all LCoS Projector control and driving code
//
// Target: MTV230M
// Tool chain: KEIL C51 7.0.0.1
// Project Name: PXJ800
//
// Release 1.0
// -Initial Revision (DM)
// -28 DEC 2005
//
#include <MTV230.H>
#include <DEFINE.H>
/*==============================================================================
==============================================================================*/
void MCU_Start(void) {
MCU_SDA=1;
MCU_SCL=1;
MCU_SDA=0;
MCU_SCL=0;
}
/*==============================================================================
==============================================================================*/
void MCU_Stop(void) {
idata unsigned char wd;
wd=0xFF;
do{
MCU_SCL=1;
if(--wd==0) {
break;
}
}while(!MCU_SCL);
MCU_SCL=0;
MCU_SDA=0;
MCU_SCL=1;
MCU_SDA=1;
}
/*==============================================================================
==============================================================================*/
bit MCU_Data_In(unsigned char bytedata) {
idata unsigned char i;
for(i=0; i<8; i++) {
MCU_SDA=bytedata&0x80;
MCU_SCL=1;
bytedata<<=1;
MCU_SCL=0;
}
MCU_SDA=1;
MCU_SCL=1;
bIicError=MCU_SDA;
MCU_SCL=0;
MCU_SDA=0;
return bIicError;
}
/*==============================================================================
==============================================================================*/
unsigned char MCU_Data_Out(void) {
idata unsigned char i, bytedata=0;
MCU_SDA=1;
for(i=0; i<8; i++) {
MCU_SCL=1;
bytedata<<=1;
bytedata|=MCU_SDA;
MCU_SCL=0;
}
return bytedata;
}
/*==============================================================================
==============================================================================*/
void MCU_Acknowledge(bit ack) {
MCU_SDA=ack;
MCU_SCL=1;
MCU_SCL=0;
}
/*==============================================================================
==============================================================================*/
unsigned char MCU_Byte_Read(unsigned char device, unsigned char address) {
idata unsigned char bytedata;
MCU_Start();
MCU_Data_In(device);
MCU_Data_In(address);
MCU_Start();
MCU_Data_In(device|1);
bytedata=MCU_Data_Out();
MCU_Acknowledge(1);
MCU_Stop();
return bytedata;
}
/*==============================================================================
==============================================================================*/
void MCU_Byte_Write(unsigned char device, unsigned char address, unsigned char bytedata) {
MCU_Start();
MCU_Data_In(device);
MCU_Data_In(address);
MCU_Data_In(bytedata);
MCU_Stop();
}
/*==============================================================================
==============================================================================*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -