MajicDesigns / MD_DS3231

DS3231 Real Time Clock Library
GNU Lesser General Public License v2.1
31 stars 11 forks source link

Library wont't compile for Arduino Due board #13

Closed miltonneal54 closed 4 years ago

miltonneal54 commented 4 years ago

I downloaded the MD_DS3231 library to try with my new DS3231 RTC. I tried the sketches in the example folder only to find the library failed to compile when using my DUE board but ok when I tried on my UNO board. Following is the the output from the compiler when using my DUE. Any help in solving this issue would be appreciated.. Milton

Arduino: 1.8.12 (Windows 7), Board: "Arduino Due (Programming Port)"

In file included from C:\Users\Milton\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.8\system/CMSIS/Device/ATMEL/sam3xa/include/sam3xa.h:44:0,

             from C:\Users\Milton\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.8\system/CMSIS/Device/ATMEL/sam3.h:59,

             from C:\Users\Milton\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.8\system/CMSIS/Device/ATMEL/sam.h:198,

             from C:\Users\Milton\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.8\system/libsam/chip.h:25,

             from C:\Users\Milton\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.8\cores\arduino/Arduino.h:42,

             from sketch\MD_DS3231_LCD_Time.ino.cpp:1:

C:\Users\Milton\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.8\system/CMSIS/Device/ATMEL/sam3xa/include/sam3x8e.h:502:29: error: expected ')' before '*' token

define RTC ((Rtc *)0x400E1A60U) /*< \brief (RTC ) Base Address /

                         ^

C:\Users\Milton\Documents\Arduino\libraries\MD_DS3231\src/MD_DS3231.h:763:18: note: in expansion of macro 'RTC'

extern MD_DS3231 RTC; ///< Library created instance of the RTC class

              ^

C:\Users\Milton\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.8\system/CMSIS/Device/ATMEL/sam3xa/include/sam3x8e.h:502:29: error: expected ')' before '*' token

define RTC ((Rtc *)0x400E1A60U) /*< \brief (RTC ) Base Address /

                         ^

C:\Users\Milton\Documents\Arduino\libraries\MD_DS3231\src/MD_DS3231.h:763:18: note: in expansion of macro 'RTC'

extern MD_DS3231 RTC; ///< Library created instance of the RTC class

              ^

C:\Users\Milton\Documents\Arduino\libraries\MD_DS3231\examples\MD_DS3231_LCD_Time\MD_DS3231_LCD_Time.ino: In function 'void printTime()':

MD_DS3231_LCD_Time:45:28: error: request for member 'dow' in '1074666080u', which is of pointer type 'Rtc*' (maybe you meant to use '->' ?)

lcd.print(dow2String(RTC.dow));

                        ^

MD_DS3231_LCD_Time:47:17: error: request for member 'yyyy' in '1074666080u', which is of pointer type 'Rtc*' (maybe you meant to use '->' ?)

lcd.print(RTC.yyyy);

             ^

MD_DS3231_LCD_Time:49:13: error: request for member 'mm' in '1074666080u', which is of pointer type 'Rtc*' (maybe you meant to use '->' ?)

p2dig(RTC.mm);

         ^

MD_DS3231_LCD_Time:51:13: error: request for member 'dd' in '1074666080u', which is of pointer type 'Rtc*' (maybe you meant to use '->' ?)

p2dig(RTC.dd);

         ^

MD_DS3231_LCD_Time:54:13: error: request for member 'h' in '1074666080u', which is of pointer type 'Rtc*' (maybe you meant to use '->' ?)

p2dig(RTC.h);

         ^

MD_DS3231_LCD_Time:56:13: error: request for member 'm' in '1074666080u', which is of pointer type 'Rtc*' (maybe you meant to use '->' ?)

p2dig(RTC.m);

         ^

MD_DS3231_LCD_Time:58:13: error: request for member 's' in '1074666080u', which is of pointer type 'Rtc*' (maybe you meant to use '->' ?)

p2dig(RTC.s);

         ^

MD_DS3231_LCD_Time:59:11: error: request for member 'status' in '1074666080u', which is of pointer type 'Rtc*' (maybe you meant to use '->' ?)

if (RTC.status(DS3231_12H) == DS3231_ON)

       ^

MD_DS3231_LCD_Time:60:19: error: request for member 'pm' in '1074666080u', which is of pointer type 'Rtc*' (maybe you meant to use '->' ?)

 lcd.print(RTC.pm ? " pm" : " am");

               ^

C:\Users\Milton\Documents\Arduino\libraries\MD_DS3231\examples\MD_DS3231_LCD_Time\MD_DS3231_LCD_Time.ino: In function 'void displayUpdate()':

MD_DS3231_LCD_Time:66:7: error: request for member 'readTime' in '1074666080u', which is of pointer type 'Rtc*' (maybe you meant to use '->' ?)

RTC.readTime();

   ^

C:\Users\Milton\Documents\Arduino\libraries\MD_DS3231\examples\MD_DS3231_LCD_Time\MD_DS3231_LCD_Time.ino: In function 'void setup()':

MD_DS3231_LCD_Time:90:7: error: request for member 'setAlarm1Callback' in '1074666080u', which is of pointer type 'Rtc*' (maybe you meant to use '->' ?)

RTC.setAlarm1Callback(alarmICB);

   ^

MD_DS3231_LCD_Time:105:7: error: request for member 'setAlarm1Type' in '1074666080u', which is of pointer type 'Rtc*' (maybe you meant to use '->' ?)

RTC.setAlarm1Type(DS3231_ALM_SEC);

   ^

C:\Users\Milton\Documents\Arduino\libraries\MD_DS3231\examples\MD_DS3231_LCD_Time\MD_DS3231_LCD_Time.ino: In function 'void loop()':

MD_DS3231_LCD_Time:114:7: error: request for member 'checkAlarm1' in '1074666080u', which is of pointer type 'Rtc*' (maybe you meant to use '->' ?)

RTC.checkAlarm1();

   ^

Multiple libraries were found for "MD_DS3231.h" Used: C:\Users\Milton\Documents\Arduino\libraries\MD_DS3231 Not used: C:\Users\Milton\Documents\Arduino\libraries\arduino_128441 exit status 1 request for member 'dow' in '1074666080u', which is of pointer type 'Rtc*' (maybe you meant to use '->' ?)

This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.

MajicDesigns commented 4 years ago

There seems to be a clash between the library and the SAM libraries around the definition of RTC. You can disable the MD_DS3231 library crating an RTC object by editing the header file and changing #define ENABLE_RTC_INSTANCE 1 ///< Enable default RTC instance creation to be set to 0. This will mean that you need to declare the RTC variable in your own code, and of course you can call it whatever you like so that it does not clash any more.

miltonneal54 commented 4 years ago

Hello Marco, Your suggestion is spot on. This fixes the issue with compiling with the DUE board. Perhaps this is worth noting in your documentation. You can clear this as resolved, thanks for your help. Milton