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" {
1199
1199
1200
1200
int getAnalogRead (const uint8_t command[], uint8_t response[])
1201
1201
{
1202
- uint8_t pin = command[4 ];
1202
+ uint8_t adc_channel = command[4 ];
1203
1203
1204
- /* Power up the ADC. */
1205
- adc_power_on ();
1206
1204
/* 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 );
1208
1206
/* Set maximum analog bit-width = 12 bit. */
1209
1207
adc1_config_width (ADC_WIDTH_BIT_12);
1210
1208
/* 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);
1212
1210
/* 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);
1216
1212
1217
1213
response[2 ] = 1 ; // number of parameters
1218
1214
response[3 ] = sizeof (adc_raw); // parameter 1 length = 2 bytes
You can’t perform that action at this time.
0 commit comments