Skip to content
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: compiler errors in DAC #5543

Closed
OlegHahm opened this issue Jun 11, 2016 · 3 comments
Closed

stm32: compiler errors in DAC #5543

OlegHahm opened this issue Jun 11, 2016 · 3 comments
Assignees
Labels
Area: drivers Area: Device drivers Platform: ARM Platform: This PR/issue effects ARM-based platforms State: duplicate State: The issue/PR is a duplicate of another issue/PR Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)

Comments

@OlegHahm
Copy link
Member

Trying to compile any application for iotlab-m3 on current master results in:

"make" -C /home/oleg/git/RIOT/cpu/stm32_common/periph
dac.c: In function 'dac_set'
dac.c:76:19: error: array subscript is above array bounds [-Werror=array-bounds]
     if (dac_config[line].chan) {
         ~~~~~~~~~~^~~~~~
dac.c: In function 'dac_poweron'
dac.c:91:38: error: array subscript is above array bounds [-Werror=array-bounds]
     DAC->CR |= (1 << (16 * dac_config[line].chan));
                            ~~~~~~~~~~^~~~~~
dac.c: In function 'dac_poweroff'
dac.c:96:39: error: array subscript is above array bounds [-Werror=array-bounds]
     DAC->CR &= ~(1 << (16 * dac_config[line].chan));
                             ~~~~~~~

I assume that the cause for this error exists for some time, but shows only now because of an update gcc:

arm-none-eabi-gcc (Arch Repository) 6.1.1 20160526
@OlegHahm OlegHahm added Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) Platform: ARM Platform: This PR/issue effects ARM-based platforms Area: drivers Area: Device drivers labels Jun 11, 2016
@OlegHahm OlegHahm added this to the Release 2016.07 milestone Jun 11, 2016
@OlegHahm
Copy link
Member Author

A simple fix might be:

diff --git a/cpu/stm32_common/periph/dac.c b/cpu/stm32_common/periph/dac.c
index d250802..79c6464 100644
--- a/cpu/stm32_common/periph/dac.c
+++ b/cpu/stm32_common/periph/dac.c
@@ -71,6 +71,10 @@ int8_t dac_init(dac_t line)

 void dac_set(dac_t line, uint16_t value)
 {
+#ifndef DAC_CONFIG
+    (void) line;
+    (void) value;
+#else
     value = (value >> 4);       /* scale to 12-bit */
 #ifdef DAC_DHR12R2_DACC2DHR
     if (dac_config[line].chan) {
@@ -84,11 +88,16 @@ void dac_set(dac_t line, uint16_t value)

     _DAC(line)->DHR12R1 = value;
 #endif
+#endif
 }

 void dac_poweron(dac_t line)
 {
+#ifndef DAC_CONFIG
+    (void) line;
+#else
     DAC->CR |= (1 << (16 * dac_config[line].chan));
+#endif
 }

@miri64
Copy link
Member

miri64 commented Jun 12, 2016

Duplicate / subpart of #5519

@miri64 miri64 added the State: duplicate State: The issue/PR is a duplicate of another issue/PR label Jun 12, 2016
@miri64 miri64 closed this as completed Jun 12, 2016
@OlegHahm
Copy link
Member Author

Ups, overlooked this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: drivers Area: Device drivers Platform: ARM Platform: This PR/issue effects ARM-based platforms State: duplicate State: The issue/PR is a duplicate of another issue/PR Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)
Projects
None yet
Development

No branches or pull requests

3 participants