Fixed error in ADC conversion sequence in MD-3x0 platforms, improved behaviour of 'platform_pwrButtonStatus' in targets having the power switch on the volume knob.

This commit is contained in:
Silvano Seva 2021-04-11 18:18:58 +02:00
parent 1e7c2ceac3
commit 7209414a2b
5 changed files with 18 additions and 6 deletions

View File

@ -104,8 +104,8 @@ void adc1_init()
| (15 << 5); /* CH15, HTEMP value on PC5 */ | (15 << 5); /* CH15, HTEMP value on PC5 */
#elif defined(PLATFORM_MD3x0) #elif defined(PLATFORM_MD3x0)
ADC1->SQR1 = 3 << 20; /* Four channels to be converted */ ADC1->SQR1 = 3 << 20; /* Four channels to be converted */
ADC1->SQR3 |= (1 << 0) /* CH1, battery voltage on PA1 */ ADC1->SQR3 |= (0 << 0) /* CH0, volume potentiometer level on PA0 */
| (0 << 5) /* CH0, volume potentiometer level on PA0 */ | (1 << 5) /* CH1, battery voltage on PA1 */
| (8 << 10) /* CH8, RSSI value on PB0 */ | (8 << 10) /* CH8, RSSI value on PB0 */
| (3 << 15); /* CH3, vox level on PA3 */ | (3 << 15); /* CH3, vox level on PA3 */
#else #else

View File

@ -144,8 +144,11 @@ bool platform_pwrButtonStatus()
{ {
/* /*
* When power knob is set to off, battery voltage measurement returns 0V. * When power knob is set to off, battery voltage measurement returns 0V.
* Here we set the threshold to 1V since, with knob in off position, there
* is always a bit of noise in the ADC measurement making the returned
* voltage not to be exactly zero.
*/ */
return (platform_getVbat() > 0.0f) ? true : false; return (platform_getVbat() > 1.0f) ? true : false;
} }
void platform_ledOn(led_t led) void platform_ledOn(led_t led)

View File

@ -143,8 +143,11 @@ bool platform_pwrButtonStatus()
{ {
/* /*
* When power knob is set to off, battery voltage measurement returns 0V. * When power knob is set to off, battery voltage measurement returns 0V.
* Here we set the threshold to 1V since, with knob in off position, there
* is always a bit of noise in the ADC measurement making the returned
* voltage not to be exactly zero.
*/ */
return (platform_getVbat() > 0.0f) ? true : false; return (platform_getVbat() > 1.0f) ? true : false;
} }
void platform_ledOn(led_t led) void platform_ledOn(led_t led)

View File

@ -126,8 +126,11 @@ bool platform_pwrButtonStatus()
{ {
/* /*
* When power knob is set to off, battery voltage measurement returns 0V. * When power knob is set to off, battery voltage measurement returns 0V.
* Here we set the threshold to 1V since, with knob in off position, there
* is always a bit of noise in the ADC measurement making the returned
* voltage not to be exactly zero.
*/ */
return (adc1_getMeasurement(ADC_VBAT_CH) > 0.0f) ? true : false; return (platform_getVbat() > 1.0f) ? true : false;
} }
void platform_ledOn(led_t led) void platform_ledOn(led_t led)

View File

@ -120,8 +120,11 @@ bool platform_pwrButtonStatus()
{ {
/* /*
* When power knob is set to off, battery voltage measurement returns 0V. * When power knob is set to off, battery voltage measurement returns 0V.
* Here we set the threshold to 1V since, with knob in off position, there
* is always a bit of noise in the ADC measurement making the returned
* voltage not to be exactly zero.
*/ */
return (adc1_getMeasurement(ADC_VBAT_CH) > 0.0f) ? true : false; return (platform_getVbat() > 1.0f) ? true : false;
} }
void platform_ledOn(led_t led) void platform_ledOn(led_t led)