pkarashchenko commented on code in PR #6311:
URL: https://github.com/apache/incubator-nuttx/pull/6311#discussion_r878855040


##########
arch/arm/src/tlsr82/tlsr82_adc.c:
##########
@@ -364,53 +599,15 @@ static void tlsr82_adc_chan_config(uint32_t pinset)
       return;
     }
 
+  /* Config gpio */
+
+  tlsr82_adc_pin_config(pinset);
+
   /* Config the positive and negative input, here, the negative input
    * is always configured to GND (0x0f).
    */
 
-  tlsr82_analog_write(ADC_CHAN_REG, (pinadc << 4) | 0x0f);
-}
-
-/****************************************************************************
- * Name: read_efuse
- *
- * Description:
- *   Read Efuse data.
- *
- * Input Parameters:
- *   addr   - register address
- *   b_off  - bit offset
- *   b_size - bit size
- *
- * Returned Value:
- *  Efuse data.
- *
- ****************************************************************************/
-
-static uint32_t read_efuse(uint32_t addr, uint32_t b_off, uint32_t b_size)
-{
-  uint32_t data;
-  uint32_t regval;
-  uint32_t shift = 32 - b_size;
-  uint32_t mask = UINT32_MAX >> shift;
-  uint32_t res = b_off % 32;
-  uint32_t regaddr = addr + (b_off / 32 * 4);
-
-  regval = getreg32(regaddr);
-  data = regval >> res;
-  if (res <= shift)
-    {
-      data &= mask;
-    }
-  else
-    {
-      shift = 32 - res;
-
-      regval = getreg32(regaddr + 4);
-      data |= (regval & (mask >> shift)) << shift;
-    }
-
-  return data;
+  tlsr82_analog_write(ADC_CHAN_REG, (pinadc << 4) | ADC_CHAN_NEG_GND);

Review Comment:
   ```suggestion
     tlsr82_analog_write(ADC_CHAN_REG, (pinadc << ADC_CHAN_POS_SHIFT) | 
ADC_CHAN_NEG_GND);
   ```



##########
arch/arm/src/tlsr82/tlsr82_adc.c:
##########
@@ -545,85 +772,79 @@ static uint16_t adc_read(void)
  *
  ****************************************************************************/
 
-#if 0
-
-static void adc_calibrate(void)
+#ifdef CONFIG_TLSR82_ADC_CALI
+static void tlsr82_adc_calibrate(struct adc_chan_s *priv)
 {
-  uint16_t cali_val;
-  uint16_t adc;
-  uint16_t adc_max = 0;
-  uint16_t adc_min = UINT16_MAX;
-  uint32_t adc_sum = 0;
-  uint32_t regval;
+  uint8_t cali_data[7];
 
-  regval = read_efuse(ADC_CAL_BASE_REG, ADC_CAL_VER_OFF, ADC_CAL_VER_LEN);
-  if (regval == 1)
-    {
-      ainfo("Calibrate based on efuse data\n");
-
-      regval = read_efuse(ADC_CAL_BASE_REG, ADC_CAL_DATA_OFF,
-                          ADC_CAL_DATA_LEN);
-      cali_val = regval + ADC_CAL_DATA_COMP;
-    }
-  else
-    {
-      ainfo("Calibrate based on GND voltage\n");
+  uint32_t base_vref;
+  uint32_t vbat_vref;
 
-      /* Enable Vdef */
+  (void)memset((void *)cali_data, 0, 7);

Review Comment:
   ```suggestion
     memset(cali_data, 0, sizeof(cali_data));
   ```
   I think we do not enable "unused result" warning. Or am I wrong?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to