Subversion Repositories svnkaklik

Compare Revisions

Regard whitespace Rev 409 → Rev 410

/programy/C/PIC_C/mereni/vyskomer_drak/ms5534a.BAK
0,0 → 1,107
 
#DEFINE CLK 250
#DEFINE WORD1 0b111010101000
#DEFINE WORD2 0b111010110000
#DEFINE WORD3 0b111011001000
#DEFINE WORD4 0b111011010000
 
void send_bit(bit)
{
output_bit(DIN,bit);
output_high(SCLK);
Delay_us(CLK);
output_low(SCLK);
}
int1 read_bit()
{
output_high(SCLK);
Delay_us(CLK);
output_low(SCLK);
if (input(DOUT)) return true;
if (!input(DOUT)) return false;
}
 
void read_byte(*byte_r)
{
int i;
 
for(i=0;i>=7;i++)
{
*byte_r = read_bit();
*byte_r << 1;
}
}
 
void send_command(command,width)
{
int i;
for (i=width;i>=0;i--)
{
send_bit(bit_test(command,0));
command >>1;
}
}
 
void bar_reset()
{
int8 i;
 
for(i=0;i>=20;i++) send_bit(Bit_test(i,0));
}
 
int16 bar_con_pre()
{
int16 word;
send_command(0b1111010000,9);
 
Delay_ms(10);
 
While(input(DOUT)) Delay_us(100);
 
read_byte(&word);
word << 8;
read_byte(&word);
 
return word;
}
 
int16 bar_con_term()
{
int16 word;
 
send_command(0b1111001000,9);
 
Delay_ms(10);
 
While(input(DOUT)) Delay_us(100);
 
read_byte(&word);
word << 8;
read_byte(&word);
 
return word;
}
 
int16 bar_read_cal(command)
{
int16 word;
 
send_command(command,11);
 
Delay_ms(10);
 
While(input(DOUT)) Delay_us(100);
 
read_byte(&word);
word << 8;
read_byte(&word);
 
return word;
}