File tree 20 files changed +1625
-72
lines changed
variants/STM32L476RE-Dragonfly
20 files changed +1625
-72
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ extern "C"{
49
49
#undef DAC1
50
50
#undef SPI1
51
51
#undef SPI2
52
+ #undef RTC
52
53
53
54
#define F_CPU SystemCoreClock
54
55
Original file line number Diff line number Diff line change 29
29
#include " Arduino.h"
30
30
#include " wiring_private.h"
31
31
32
+ uint32_t STM32Class::readBackup (unsigned int index)
33
+ {
34
+ return stm32l4_rtc_read_backup (index );
35
+ }
36
+
37
+ void STM32Class::writeBackup (unsigned int index, uint32_t data)
38
+ {
39
+ stm32l4_rtc_write_backup (index , data);
40
+ }
41
+
32
42
uint64_t STM32Class::getSerial ()
33
43
{
34
44
uint32_t serial0, serial1, serial2;
Original file line number Diff line number Diff line change 33
33
34
34
class STM32Class {
35
35
public:
36
+ uint32_t readBackup (unsigned int idx);
37
+ void writeBackup (unsigned int idx, uint32_t val);
38
+
36
39
uint64_t getSerial ();
37
40
38
41
float getVBAT ();
Original file line number Diff line number Diff line change @@ -90,6 +90,8 @@ void init( void )
90
90
armv7m_systick_initialize (STM32L4_SYSTICK_IRQ_PRIORITY );
91
91
armv7m_timer_initialize ();
92
92
93
+ stm32l4_rtc_configure (STM32L4_RTC_IRQ_PRIORITY );
94
+
93
95
stm32l4_exti_create (& stm32l4_exti , STM32L4_EXTI_IRQ_PRIORITY );
94
96
stm32l4_exti_enable (& stm32l4_exti );
95
97
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ extern "C" {
49
49
#include "stm32l4_spi.h"
50
50
#include "stm32l4_usbd_cdc.h"
51
51
#include "stm32l4_system.h"
52
+ #include "stm32l4_rtc.h"
52
53
53
54
#include "wiring_constants.h"
54
55
@@ -60,9 +61,10 @@ extern "C" {
60
61
#define STM32L4_PWM_IRQ_PRIORITY 15
61
62
62
63
#define STM32L4_USB_IRQ_PRIORITY 14
63
- #define STM32L4_I2C_IRQ_PRIORITY 13
64
- #define STM32L4_UART_IRQ_PRIORITY 12
65
- #define STM32L4_SPI_IRQ_PRIORITY 11
64
+ #define STM32L4_RTC_IRQ_PRIORITY 13
65
+ #define STM32L4_I2C_IRQ_PRIORITY 12
66
+ #define STM32L4_UART_IRQ_PRIORITY 11
67
+ #define STM32L4_SPI_IRQ_PRIORITY 10
66
68
67
69
#define STM32L4_EXTI_IRQ_PRIORITY 4
68
70
#define STM32L4_SYSTICK_IRQ_PRIORITY 3
Original file line number Diff line number Diff line change
1
+ /*
2
+ Epoch time example for Arduino Zero and MKR1000
3
+
4
+ Demonstrates how to set time using epoch for the Arduino Zero and MKR1000
5
+
6
+ This example code is in the public domain
7
+
8
+ created by Sandeep Mistry <s.mistry@arduino.cc>
9
+ 31 Dec 2015
10
+ modified
11
+ 18 Feb 2016
12
+ */
13
+
14
+ #include < RTC.h>
15
+
16
+ void setup () {
17
+ Serial.begin (9600 );
18
+
19
+ RTC.setEpoch (1451606400 ); // Jan 1, 2016
20
+ }
21
+
22
+ void loop () {
23
+ Serial.print (" Unix time = " );
24
+ Serial.println (RTC.getEpoch ());
25
+
26
+ Serial.print (" Seconds since Jan 1 2000 = " );
27
+ Serial.println (RTC.getY2kEpoch ());
28
+
29
+ // Print date...
30
+ Serial.print (RTC.getDay ());
31
+ Serial.print (" /" );
32
+ Serial.print (RTC.getMonth ());
33
+ Serial.print (" /" );
34
+ Serial.print (RTC.getYear ());
35
+ Serial.print (" \t " );
36
+
37
+ // ...and time
38
+ print2digits (RTC.getHours ());
39
+ Serial.print (" :" );
40
+ print2digits (RTC.getMinutes ());
41
+ Serial.print (" :" );
42
+ print2digits (RTC.getSeconds ());
43
+
44
+ Serial.println ();
45
+
46
+ delay (1000 );
47
+ }
48
+
49
+ void print2digits (int number) {
50
+ if (number < 10 ) {
51
+ Serial.print (" 0" );
52
+ }
53
+ Serial.print (number);
54
+ }
55
+
Original file line number Diff line number Diff line change
1
+ /*
2
+ Simple RTC for Arduino Zero and MKR1000
3
+
4
+ Demonstrates the use of the RTC library for the Arduino Zero and MKR1000
5
+
6
+ This example code is in the public domain
7
+
8
+ http://arduino.cc/en/Tutorial/SimpleRTC
9
+
10
+ created by Arturo Guadalupi <a.guadalupi@arduino.cc>
11
+ 15 Jun 2015
12
+ modified
13
+ 18 Feb 2016
14
+ modified by Andrea Richetta <a.richetta@arduino.cc>
15
+ 24 Aug 2016
16
+ */
17
+
18
+ #include < RTC.h>
19
+
20
+ /* Change these values to set the current initial time */
21
+ const byte seconds = 0 ;
22
+ const byte minutes = 0 ;
23
+ const byte hours = 16 ;
24
+
25
+ /* Change these values to set the current initial date */
26
+ const byte day = 15 ;
27
+ const byte month = 6 ;
28
+ const byte year = 15 ;
29
+
30
+ void setup ()
31
+ {
32
+ Serial.begin (9600 );
33
+
34
+ // Set the time
35
+ RTC.setHours (hours);
36
+ RTC.setMinutes (minutes);
37
+ RTC.setSeconds (seconds);
38
+
39
+ // Set the date
40
+ RTC.setDay (day);
41
+ RTC.setMonth (month);
42
+ RTC.setYear (year);
43
+
44
+ // you can use also
45
+ // RTC.setTime(hours, minutes, seconds);
46
+ // RTC.setDate(day, month, year);
47
+ }
48
+
49
+ void loop ()
50
+ {
51
+ // Print date...
52
+ print2digits (RTC.getDay ());
53
+ Serial.print (" /" );
54
+ print2digits (RTC.getMonth ());
55
+ Serial.print (" /" );
56
+ print2digits (RTC.getYear ());
57
+ Serial.print (" " );
58
+
59
+ // ...and time
60
+ print2digits (RTC.getHours ());
61
+ Serial.print (" :" );
62
+ print2digits (RTC.getMinutes ());
63
+ Serial.print (" :" );
64
+ print2digits (RTC.getSeconds ());
65
+
66
+ Serial.println ();
67
+
68
+ delay (1000 );
69
+ }
70
+
71
+
72
+
73
+ void print2digits (int number) {
74
+ if (number < 10 ) {
75
+ Serial.print (" 0" ); // print a 0 before if the number is < than 10
76
+ }
77
+ Serial.print (number);
78
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ Simple RTC Alarm for Arduino Zero and MKR1000
3
+
4
+ Demonstrates how to set an RTC alarm for the Arduino Zero and MKR1000
5
+
6
+ This example code is in the public domain
7
+
8
+ http://arduino.cc/en/Tutorial/SimpleRTCAlarm
9
+
10
+ created by Arturo Guadalupi <a.guadalupi@arduino.cc>
11
+ 25 Sept 2015
12
+
13
+ modified
14
+ 21 Oct 2015
15
+ */
16
+
17
+ #include < RTC.h>
18
+
19
+ /* Change these values to set the current initial time */
20
+ const byte seconds = 0 ;
21
+ const byte minutes = 0 ;
22
+ const byte hours = 16 ;
23
+
24
+ /* Change these values to set the current initial date */
25
+ const byte day = 25 ;
26
+ const byte month = 9 ;
27
+ const byte year = 15 ;
28
+
29
+ void setup ()
30
+ {
31
+ Serial.begin (9600 );
32
+
33
+ RTC.setTime (hours, minutes, seconds);
34
+ RTC.setDate (day, month, year);
35
+
36
+ RTC.setAlarmTime (16 , 0 , 10 );
37
+ RTC.enableAlarm (RTC.MATCH_HHMMSS );
38
+
39
+ RTC.attachInterrupt (alarmMatch);
40
+ }
41
+
42
+ void loop ()
43
+ {
44
+
45
+ }
46
+
47
+ void alarmMatch ()
48
+ {
49
+ Serial.println (" Alarm Match!" );
50
+ }
Original file line number Diff line number Diff line change
1
+ #######################################
2
+ # Syntax Coloring Map For RTC
3
+ #######################################
4
+
5
+ #######################################
6
+ # Datatypes (KEYWORD1)
7
+ #######################################
8
+
9
+ RTCZero KEYWORD1
10
+
11
+ #######################################
12
+ # Methods and Functions (KEYWORD2)
13
+ #######################################
14
+
15
+ getDay KEYWORD2
16
+ getMonth KEYWORD2
17
+ getYear KEYWORD2
18
+ getHours KEYWORD2
19
+ getMinutes KEYWORD2
20
+ getSeconds KEYWORD2
21
+
22
+ setDay KEYWORD2
23
+ setMonth KEYWORD2
24
+ setYear KEYWORD2
25
+ setHours KEYWORD2
26
+ setMinutes KEYWORD2
27
+ setSeconds KEYWORD2
28
+ setDate KEYWORD2
29
+ setTime KEYWORD2
30
+
31
+ getEpoch KEYWORD2
32
+ getY2kEpoch KEYWORD2
33
+ setEpoch KEYWORD2
34
+ setY2kEpoch KEYWORD2
35
+
36
+ getAlarmDay KEYWORD2
37
+ getAlarmMonth KEYWORD2
38
+ getAlarmYear KEYWORD2
39
+ getAlarmHours KEYWORD2
40
+ getAlarmMinutes KEYWORD2
41
+ getAlarmSeconds KEYWORD2
42
+
43
+ setAlarmDay KEYWORD2
44
+ setAlarmMonth KEYWORD2
45
+ setAlarmYear KEYWORD2
46
+ setAlarmHours KEYWORD2
47
+ setAlarmMinutes KEYWORD2
48
+ setAlarmSeconds KEYWORD2
49
+ setAlarmDate KEYWORD2
50
+ setAlarmTime KEYWORD2
51
+
52
+ enableAlarm KEYWORD2
53
+ disableAlarm KEYWORD2
54
+
55
+ #######################################
56
+ # Constants (LITERAL1)
57
+ #######################################
Original file line number Diff line number Diff line change
1
+ name =RTC
2
+ version =1.0
3
+ author =Thomas Roell
4
+ maintainer =grumpyoldpizza@gmail.com
5
+ sentence =Allows to use the RTC functionalities.
6
+ paragraph =With this library you can use the RTC peripheral to program actions related to date and time.
7
+ category =Timing
8
+ url =http://www.arduino.cc/en/Reference/RTCZero
9
+ architectures =stm32l4
You can’t perform that action at this time.
0 commit comments