I have a problem with ICU module. I have an Inemo board and an ultrasonic sensor and try to read a distance from the sensor using ICU Driver but the last_width callback is never called.
Furthermore the sensor is supplied with a voltage of 5 volts so I have connected VCC to V_EXT of iNemo.
Code: Select all
float readDistance( void ){
static float width = 0;
static float distance = 0;
pwmStart(&PWMD2, &pwmcfg_us);
palSetPad(GPIOA, 3);
pwmEnableChannel(&PWMD2, 3, PWM_PERCENTAGE_TO_WIDTH(&PWMD2, 2));
icuStart(&ICUD3, &icucfg);
palSetPadMode(GPIOA, 11, PAL_MODE_INPUT);
icuEnable(&ICUD3);
chThdSleepMilliseconds(50);
pwmDisableChannel(&PWMD2, 3);
pwmStop(&PWMD2);
icuDisable(&ICUD3);
icuStop(&ICUD3);
width =last_width;
distance = ( (float) width * CONSTANT );
return distance;
}