Basic DAC Driver, implementation on stm32f4discovery#2018
Basic DAC Driver, implementation on stm32f4discovery#2018haukepetersen merged 1 commit intoRIOT-OS:masterfrom brummer-simon:devel-dac_driver
Conversation
cpu/stm32f4/periph/dac.c
Outdated
There was a problem hiding this comment.
I think it's more your copyright or maybe HAWs.
|
Wow that PR came quick! Looks nice, I'll look and test in more detail later. |
There was a problem hiding this comment.
We need to careful with these pins, so far they are configured for ADC (PA4) and SPI SCK (PA6). Have a look at this table and check if you can find other pins. If not we need to see if we can re-arrange the pin mapping for the f4discovery board
There was a problem hiding this comment.
According to the stm32f4-family Reference Manual(Page 431)
Are the two DAC Channals hardwired to PortA Pin4 and 5. Not much possibility to choose anything else.
|
Congrats to you first PR! Besides some minor newline issues it looks very good! We just have to think about the pin mapping. So far the strategy was, not to map pins twice... |
|
PA4 and PA5 are the only pins for the DAC. I suggest to:
|
|
For completeness you should add |
|
I added periph_dac. Would be great if you change ADC_0_CH1_PIN and SPI_0_*, because I can't test the results here(I got no SPI Device here). |
|
Ok, again some funny design by ST... For this case I would actually leave the pin config for |
|
Ok maybe these ideas are totally stupid and "tinkering" but just to have a start of discussion:
|
|
@haukepetersen, how du you like this DAC interface? I think it's quite clear and in the style of your ADC interface. Just the return tyoes are a bit different. |
cpu/stm32f4/periph/dac.c
Outdated
There was a problem hiding this comment.
Travis is unhappy:
cpu/stm32f4/periph/dac.c:86: style (unreadVariable): Variable 'dac' is assigned a value that is never used.
cpu/stm32f4/periph/dac.c:87: style (unreadVariable): Variable 'val' is assigned a value that is never used.
Maybe you could try to just initialize them without assigning a value?
There was a problem hiding this comment.
I'll try that to shutup Travis but i am sure thats considered bad style in c.
There was a problem hiding this comment.
You could simply guard the file with #if DAC_0_EN instead of #if DAC_NUMOF
|
The interface is fine. I miss one thing in the return values (and in the implementation): The given |
There was a problem hiding this comment.
add this like @haukepetersen commented:
default:
return -1;
There was a problem hiding this comment.
same for the other functions...
There was a problem hiding this comment.
Changed return values and documentation
|
I really don't know what's up with travis in this PR :/ |
|
Ok maybe because #2051. Please rebase! |
|
Okay I merged the current master. I hope this solves the travis issues. |
|
Hi @brummer-simon, seems that you merged the master on-top of this branch. To rebase on the current master you first need to update your local master branch:
This way you have your master updated to the same state as the RIOT master. Now rebase your branch, i.e.
To resolve your situation:
I hope this helps a bit. |
|
Okay I rebased according to the upper comment. |
|
@brummer-simon we have a git cheatsheet where we included a howto [1] for rebasing lately (literally today). [1] https://github.com/RIOT-OS/RIOT/wiki/Git-cheatsheet#how-to-rebase-your-master-on-a-current-riot-master |
|
Finally the Travis CI build went well. As far as is see the only open Issue is the conflicting Pin configration. Any Ideas on this topic? |
|
#2076 looks like a compromise for the pin-problem |
There was a problem hiding this comment.
where did the i2c go?
|
besides one question on the changed feature list I think we can merge this. If you could address this I give my ack |
|
Ok after this PR we can have a look at #2023 :-) |
|
Besides of the "pin-question" I'll give my ACK too but I think you should squash the commits |
|
From the commit messages both commits actually do more or less the same: is there a reason not to squash further? |
|
Interactive Mode doens't let me squash further. |
|
Try Edit: I had Brainlag - either the one above or |
|
I managed to squash it to one commit after fiddeling around with git |
|
I'm happy that Travis is happy, finally! ACK ACK. Can someone please merge this and maybe also PR #2023 then?! |
|
and go. |
Basic DAC Driver, implementation on stm32f4discovery
dac_init(dac_t dev, dac_precision_t precision)
Initializing a DAC Device with a given precision, configures the Device and Channels.
dac_write(dac_t dev, uint8_t channel, uint16_t value)
Writes a value on a specific channel for a device.
dac_poweron(dac_t dev)
Enables a given DAC Device.
dac_poweroff(dac_t dev)
Disables a given DAC Device.
uint16_t dac_map(dac_t dev, int value, int min, int max)
Maps a integer value between interval min and max, to a valid integer to write onto the dac with respect to the selected precision.
uint16_t dac_mapf(dac_t dev, float value, float min, float max)
Maps a float value between interval min and max, to a valid integer to write onto the dac with respect to the selected precision.