-
Notifications
You must be signed in to change notification settings - Fork 1.3k
STM32: DAC Support #2208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
STM32: DAC Support #2208
Conversation
@ladyada builds are failing due to obnoxious include issue with other boards than the 405, but they shouldn't prevent testing, so here's a binary. |
Ok, so the build is failing because the ST hal doesn't include empty defines for boards that don't support the DAC, like the F412 and F411. However, since there's no way to exclude the Analogio module specifically without also excluding analogin, I'm forced to add ugly If there's a more elegant way to somehow not included the entire incompatible AnalogOut module, please let me know. |
i know that nrf52 has analogin but not analogout (it uses PWM out instead) so check that out! |
@ladyada well, in the NRF case, there's no files to include at all. For the Atmel case, it seems like you can have the DAC not be "available" on some chips, but the macros and structs are still defined, they just don't do anything. So I think this is the first time this has come up. |
The problem is that " If you want to make it a little neater you could do something like:
Is |
@dhalbert I can make HAS_DAC 1 or 0, I agree that's more clear. I guess there's nothing particularly wrong or unusual about having to use the preprocessor to reformat the file into a stub, but it just seems like this is something that ought to be handled further up the chain. Not exactly a high priority though. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, looks really good. A couple replies but ok to merge as is too.
This PR adds dual channel DAC support to STM32 boards that support the feature, such as the STM32F405 found on the Pyboard and Feather F405. Both channels can be used simultaneously.
@tannewt let me know if you'd like me to add a struct in here that tracks whether each channel is on, and de-inits the clock if both are turned off. I haven't seen a lot of meta-level tracking of what features are on or off on the common-hal layer so I wanted to check if you thought that was a good idea style wise.
Tested on a feather F405.