Enabled measurement of volume level on MD-UV3x0

replace/38fb2bd9b3d442fbc5a5bfae02a726376bb599ad
Silvano Seva 2021-03-15 15:05:18 +01:00
rodzic 07d886a442
commit 4ed16fb51c
5 zmienionych plików z 11 dodań i 9 usunięć

Wyświetl plik

@ -24,7 +24,7 @@
/* /*
* The sample buffer is structured as follows: * The sample buffer is structured as follows:
* *
* | vbat | rssi | vox | vol | * | vbat | vol | rssi | vox |
* *
* NOTE: we are forced to allocate it through a malloc in order to make it be * NOTE: we are forced to allocate it through a malloc in order to make it be
* in the "large" 128kB RAM. This because the linker script maps the .data and * in the "large" 128kB RAM. This because the linker script maps the .data and
@ -48,8 +48,8 @@ void adc1_init()
* - PB0: RSSI level * - PB0: RSSI level
*/ */
gpio_setMode(AIN_VBAT, INPUT_ANALOG); gpio_setMode(AIN_VBAT, INPUT_ANALOG);
#if defined(PLATFORM_MD3x0)
gpio_setMode(AIN_VOLUME, INPUT_ANALOG); gpio_setMode(AIN_VOLUME, INPUT_ANALOG);
#if defined(PLATFORM_MD3x0)
gpio_setMode(AIN_MIC, INPUT_ANALOG); gpio_setMode(AIN_MIC, INPUT_ANALOG);
gpio_setMode(AIN_RSSI, INPUT_ANALOG); gpio_setMode(AIN_RSSI, INPUT_ANALOG);
#endif #endif
@ -85,8 +85,9 @@ void adc1_init()
| (3 << 10) /* CH3, vox level on PA3 */ | (3 << 10) /* CH3, vox level on PA3 */
| (0 << 15); /* CH0, volume potentiometer level on PA0 */ | (0 << 15); /* CH0, volume potentiometer level on PA0 */
#else #else
ADC1->SQR1 = 0; /* Convert one channel */ ADC1->SQR1 = 1 << 20; /* Convert two channel */
ADC1->SQR3 |= (1 << 0); /* CH1, battery voltage on PA1 */ ADC1->SQR3 |= (1 << 0) /* CH1, battery voltage on PA1 */
| (0 << 15); /* CH0, volume potentiometer level on PA0 */
#endif #endif
/* DMA2 Stream 0 configuration: /* DMA2 Stream 0 configuration:

Wyświetl plik

@ -49,9 +49,9 @@ void adc1_terminate();
/** /**
* Get current measurement of a given channel, mapped as below: * Get current measurement of a given channel, mapped as below:
* - channel 0: battery voltage * - channel 0: battery voltage
* - channel 1: RSSI level * - channel 1: volume level
* - channel 2: vox level * - channel 2: RSSI level
* - channel 3: volume level * - channel 3: vox level
* *
* NOTE: the mapping above DOES NOT correspond to the physical ADC channel * NOTE: the mapping above DOES NOT correspond to the physical ADC channel
* mapping! * mapping!

Wyświetl plik

@ -290,7 +290,7 @@ float radio_getRssi(const freq_t rxFreq)
if(rxFreq < 401035000) offset_index = 0; if(rxFreq < 401035000) offset_index = 0;
if(rxFreq > 479995000) offset_index = 8; if(rxFreq > 479995000) offset_index = 8;
float rssi_mv = adc1_getMeasurement(1); float rssi_mv = adc1_getMeasurement(2);
float rssi_dbm = (rssi_mv - rssi_offset[offset_index]) / rssi_gain; float rssi_dbm = (rssi_mv - rssi_offset[offset_index]) / rssi_gain;
return rssi_dbm; return rssi_dbm;
} }

Wyświetl plik

@ -72,6 +72,7 @@
#define RED_LED GPIOE,1 #define RED_LED GPIOE,1
/* Analog inputs */ /* Analog inputs */
#define AIN_VOLUME GPIOA,0
#define AIN_VBAT GPIOA,1 #define AIN_VBAT GPIOA,1
/* Channel selection rotary encoder */ /* Channel selection rotary encoder */

Wyświetl plik

@ -147,7 +147,7 @@ float platform_getMicLevel()
float platform_getVolumeLevel() float platform_getVolumeLevel()
{ {
return 0.0f; return adc1_getMeasurement(1);
} }
uint8_t platform_getChSelector() uint8_t platform_getChSelector()