michallenc commented on code in PR #11595:
URL: https://github.com/apache/nuttx/pull/11595#discussion_r1465587723
##########
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);
+ return ret;
+ }
+
+ /* Add channel user. We can do this because the upper layer checks
+ * whether the device is opened for the first time and calls dac_setup
+ * only if this is true. Therefore there can not be a situation where
+ * the application would open DAC1 two times and dac_setup would be called
+ * two times. We however have to check number of users (DAC0 and DAC1)
+ * to know whether we want to disable the entire peripheral during
+ * shutdown.
+ */
+
+ g_dacmodule.users += 1;
Review Comment:
Yes, looks better.
##########
arch/arm/src/samv7/sam_dac.c:
##########
@@ -277,7 +341,43 @@ static int dac_setup(struct dac_dev_s *dev)
static void dac_shutdown(struct dac_dev_s *dev)
{
-#warning "Missing logic"
+ struct sam_chan_s *chan = dev->ad_priv;
+
+ /* We can use dac_reset() to disable the channel. */
+
+ chan->inuse = 0;
+ dac_reset(dev);
+
+ /* Decrement number of peripheral users. */
+
+ g_dacmodule.users -= 1;
Review Comment:
ditto
--
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]