WAT-910BD H/W MANUAL
WAT-910BD H/W MANUAL
WAT-910BD H/W MANUAL
WAT-910BD H/W MANUAL
while( i < 2 ){
// 2 byte loop
j = 1 ;
// bit mask
while(j < 0xFF){
// 8bit send
SendBit = SEND_BUFF[i] & j ? 1 : 0 ;
// Bit Test
j = j << 1 ;
// j *= 2 ;
p3_4 = 0 ;
// SCLK = L
p3_3 = SendBit ;
// output LSB first bit data on MOSI
wait_nop() ;
p3_4 = 1 ;
// SCLK = H(latch)
}
i ++ ;
// next byte
wait_nop() ;
}
// SPI READ start
pd3_3 = 0 ;
// set port direction MISO(input)
wait_nop() ;
wait_nop() ;
wait_nop() ;
wait_nop() ;
i = 0 ;
while( i < R_Byte ){
// Loop R_Byte times
j = 0 ;
// reset bit counter
READ_BUFF[i] = 0x00 ;
// clear buffer
while(j < 8){
// 8bit receive
p3_4 = 0 ;
// SCLK = L(Data Change)
wait_nop() ;
wait_nop() ;
p3_4 = 1 ;
// SCLK = H(latch)
// LSB first receive from MISO
READ_BUFF[i] += (unsigned char)p3_3 << j ;
j ++ ;
// Next Bit
}
i ++ ;
// Next Byte
}
p3_5 = 1 ;
// SS = H(END)
return TRUE ;
}
//----------------------------------------
// msec wait
//----------------------------------------
void
wait_ms(unsigned int wms)
{
unsigned int w_cnt ;
while ( wms--){
w_cnt = CLKMS ;
while(w_cnt--){}
}
}
- 54 -