File tree Expand file tree Collapse file tree 1 file changed +4
-8
lines changed Expand file tree Collapse file tree 1 file changed +4
-8
lines changed Original file line number Diff line number Diff line change @@ -1199,20 +1199,16 @@ extern "C" {
11991199
12001200int getAnalogRead (const uint8_t command[], uint8_t response[])
12011201{
1202- uint8_t pin = command[4 ];
1202+ uint8_t adc_channel = command[4 ];
12031203
1204- /* Power up the ADC. */
1205- adc_power_on ();
12061204 /* Initialize the ADC. */
1207- adc_gpio_init (ADC_UNIT_1, (adc_channel_t )pin );
1205+ adc_gpio_init (ADC_UNIT_1, (adc_channel_t )adc_channel );
12081206 /* Set maximum analog bit-width = 12 bit. */
12091207 adc1_config_width (ADC_WIDTH_BIT_12);
12101208 /* Configure channel attenuation. */
1211- adc1_config_channel_atten ((adc1_channel_t )pin , ADC_ATTEN_DB_0);
1209+ adc1_config_channel_atten ((adc1_channel_t )adc_channel , ADC_ATTEN_DB_0);
12121210 /* Read the analog value from the pin. */
1213- uint16_t const adc_raw = adc1_get_raw ((adc1_channel_t )pin);
1214- /* Power down the ADC. */
1215- adc_power_off ();
1211+ uint16_t const adc_raw = adc1_get_raw ((adc1_channel_t )adc_channel);
12161212
12171213 response[2 ] = 1 ; // number of parameters
12181214 response[3 ] = sizeof (adc_raw); // parameter 1 length = 2 bytes
You can’t perform that action at this time.
0 commit comments