I'm trying to make a library for the HX711 sensor ((https://cdn.sparkfun.com/datasheets/Sen ... nglish.pdf).)
I took a cue from github's stm32 library (HAL):
- https://github.com/freakone/HX711
- https://github.com/nimaltd/HX711
and rewrote the code for chibios ... but I can't read the data
I've only one load cell and I've connected as indicate in the following picture
this is my read function... I read always 0 (return 0 caused by the timeout)
Code: Select all
uint32_t HX711_Value( void ) {
uint32_t data = 0;
uint8_t cont = 0;
while( (data = palReadLine( LINE_DATA )) == PAL_HIGH ) {
chThdSleepMilliseconds( 5 );
cont++;
if( cont < TIMEOUT ) {
return 0;
}
}
for( uint8_t i=0 ; i<24 ; i++ ) {
palSetLine( LINE_SCK );
chThdSleepMicroseconds( 1 );
data = data << 1;
palClearLine( LINE_DATA );
chThdSleepMicroseconds( 1 );
if( (data = palReadLine( LINE_DATA )) == PAL_HIGH ) {
data++;
}
}
palSetLine( LINE_SCK );
chThdSleepMicroseconds( 1 );
data = data ^ 0x800000;
palClearLine( LINE_DATA );
chThdSleepMicroseconds( 1 );
return data;
}
LINE_DATA is
Code: Select all
palSetLineMode( LINE_DATA, PAL_MODE_INPUT_PULLUP );
palSetLine( LINE_DATA );
LINE_SCK is
Code: Select all
palSetLineMode( LINE_SCK, PAL_MODE_OUTPUT_PUSHPULL );
palClearLine( LINE_SCK );
I want to use PAL_STM32_OSPEED_LOWEST for both the pin but I don't know how declare it in addition to INPUT_PULLUP and OUTPUT_PUSHPULL... I'll try with && but it doesn't work.
so, please, can you give me some advice?
regards,
alex