#ifndef HX_MBI5026
#define HX_MBI5026
#include "hxcomm.h"
sbit MBI_DAT = P0^0;
sbit MBI_CLK = P0^1;
sbit MBI_LE = P0^2;
sbit MBI_ENB = P0^3;
void hxMbiInit();
void hxMbiWrite( UINT uDat );
void hxMbiEnable();
void hxMbiDisable();
#endif
#include "../myInc/hxmbi5026.h"
void hxMbiInit()
{
// P0M0 &= 0xF0;
// P0M1 &= 0xF0;
hxMbiWrite( 0x00 );
hxMbiEnable();
}
void hxMbiWrite( UINT uDat )
{
UCHAR i;
MBI_LE = 0;
callnop( 5 );
MBI_CLK = 0;
callnop( 5 );
for( i = 0; i < 16; ++ i )
{
MBI_CLK = 0;
callnop( 5 );
MBI_DAT = ( bit )( uDat & 0x01 );
callnop( 5 );
MBI_CLK = 1;
callnop( 5 );
uDat >>= 1;
}
MBI_LE = 1;
callnop( 10 );
MBI_LE = 0;
callnop( 5 );
}
void hxMbiEnable()
{
MBI_ENB = 0;
callnop( 2 );
}
void hxMbiDisable()
{
MBI_ENB = 1;
callnop( 2 );
}