Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
451f78d1
Commit
451f78d1
authored
May 03, 2014
by
Damien George
Browse files
stmhal: Add documentation for RTC class.
parent
7a140226
Changes
1
Hide whitespace changes
Inline
Side-by-side
stmhal/rtc.c
View file @
451f78d1
...
...
@@ -9,6 +9,12 @@
#include
"runtime.h"
#include
"rtc.h"
/// \moduleref pyb
/// \class RTC - real time clock
///
/// The RTC is and independent clock that keeps track of the date
/// and time.
RTC_HandleTypeDef
RTCHandle
;
// rtc_info indicates various things about RTC startup
...
...
@@ -159,13 +165,13 @@ void rtc_init(void) {
// fresh reset; configure RTC Calendar
RTC_CalendarConfig
();
}
else
{
// RTC was previously set, so leave it alon
// RTC was previously set, so leave it alon
e
if
(
__HAL_RCC_GET_FLAG
(
RCC_FLAG_PORRST
)
!=
RESET
)
{
// power on reset occured
// power on reset occur
r
ed
rtc_info
|=
0x10000
;
}
if
(
__HAL_RCC_GET_FLAG
(
RCC_FLAG_PINRST
)
!=
RESET
)
{
// external reset occured
// external reset occur
r
ed
rtc_info
|=
0x20000
;
}
// Clear source Reset Flag
...
...
@@ -213,6 +219,8 @@ typedef struct _pyb_rtc_obj_t {
STATIC
const
pyb_rtc_obj_t
pyb_rtc_obj
=
{{
&
pyb_rtc_type
}};
/// \classmethod \constructor()
/// Create an RTC object.
STATIC
mp_obj_t
pyb_rtc_make_new
(
mp_obj_t
type_in
,
uint
n_args
,
uint
n_kw
,
const
mp_obj_t
*
args
)
{
// check arguments
mp_arg_check_num
(
n_args
,
n_kw
,
0
,
0
,
false
);
...
...
@@ -221,11 +229,32 @@ STATIC mp_obj_t pyb_rtc_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const
return
(
mp_obj_t
)
&
pyb_rtc_obj
;
}
/// \method info()
/// Get information about the startup time and reset source.
///
/// - The lower 0xffff are the number of milliseconds the RTC took to
/// start up.
/// - Bit 0x10000 is set if a power-on reset occurred.
/// - Bit 0x20000 is set if an external reset occurred
mp_obj_t
pyb_rtc_info
(
mp_obj_t
self_in
)
{
return
mp_obj_new_int
(
rtc_info
);
}
MP_DEFINE_CONST_FUN_OBJ_1
(
pyb_rtc_info_obj
,
pyb_rtc_info
);
/// \method datetime([datetimetuple])
/// Get or set the date and time of the RTC.
///
/// With no arguments, this method returns an 8-tuple with the current
/// date and time. With 1 argument (being an 8-tuple) it sets the date
/// and time.
///
/// The 8-tuple has the following format:
///
/// (year, month, day, weekday, hours, minutes, seconds, subseconds)
///
/// `weekday` is 1-7 for Monday through Sunday.
///
/// `subseconds` is 0-59.
mp_obj_t
pyb_rtc_datetime
(
uint
n_args
,
const
mp_obj_t
*
args
)
{
if
(
n_args
==
1
)
{
// get date and time
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment