michallenc commented on code in PR #11595:
URL: https://github.com/apache/nuttx/pull/11595#discussion_r1465587383


##########
arch/arm/src/samv7/sam_dac.c:
##########
@@ -257,7 +288,40 @@ static void dac_reset(struct dac_dev_s *dev)
 
 static int dac_setup(struct dac_dev_s *dev)
 {
-#warning "Missing logic"
+  struct sam_chan_s *chan = dev->ad_priv;
+  int ret;
+
+  /* Initialize the DAC peripheral module */
+
+  ret = dac_module_init();
+  if (ret < 0)
+    {
+      aerr("ERROR: Failed to initialize the DAC peripheral module: %d\n",
+            ret);

Review Comment:
   Done



##########
arch/arm/src/samv7/sam_dac.c:
##########
@@ -226,15 +226,46 @@ static int dac_interrupt(int irq, void *context, void 
*arg)
 
 static void dac_reset(struct dac_dev_s *dev)
 {
+  struct sam_chan_s *chan = dev->ad_priv;
+#ifdef CONFIG_SAMV7_DAC_TRIGGER
+  uint32_t regval;
+#endif
   irqstate_t flags;
 
   /* Reset only the selected DAC channel; the other DAC channel must remain
-   * functional.
+   * functional. The controller however does not have an option to reset
+   * single channel, therefore we have to do this manually by writing zeroes
+   * to all important registers.
+   */
+
+  /* This should be called only before dac_setup(), therefore the channel
+   * should not be in use. Skip reset if it is.
    */
 
-  flags   = enter_critical_section();
+  if (chan->inuse)
+    {
+      /* Yes.. then return EBUSY */
+
+      return;
+    }
 
-#warning "Missing logic"
+  flags = enter_critical_section();
+
+  /* Disable channel */
+
+  putreg32(1 << chan->intf, SAM_DACC_CHDR);

Review Comment:
   Done



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to