mirror of
https://github.com/micropython/micropython.git
synced 2025-12-16 01:40:14 +01:00
renesas-ra: Rename pyb_rtc_ to machine_rtc_.
Signed-off-by: Takeo Takahashi <takeo.takahashi.xv@renesas.com>
This commit is contained in:
@@ -150,29 +150,29 @@ uint64_t mp_hal_time_ns(void) {
|
||||
/******************************************************************************/
|
||||
// MicroPython bindings
|
||||
|
||||
typedef struct _pyb_rtc_obj_t {
|
||||
typedef struct _machine_rtc_obj_t {
|
||||
mp_obj_base_t base;
|
||||
} pyb_rtc_obj_t;
|
||||
} machine_rtc_obj_t;
|
||||
|
||||
STATIC const pyb_rtc_obj_t pyb_rtc_obj = {{&pyb_rtc_type}};
|
||||
STATIC const machine_rtc_obj_t machine_rtc_obj = {{&machine_rtc_type}};
|
||||
|
||||
/// \classmethod \constructor()
|
||||
/// Create an RTC object.
|
||||
STATIC mp_obj_t pyb_rtc_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t machine_rtc_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||
// check arguments
|
||||
mp_arg_check_num(n_args, n_kw, 0, 0, false);
|
||||
|
||||
// return constant object
|
||||
return MP_OBJ_FROM_PTR(&pyb_rtc_obj);
|
||||
return MP_OBJ_FROM_PTR(&machine_rtc_obj);
|
||||
}
|
||||
|
||||
// force rtc to re-initialise
|
||||
mp_obj_t pyb_rtc_init(mp_obj_t self_in) {
|
||||
mp_obj_t machine_rtc_init(mp_obj_t self_in) {
|
||||
rtc_init_start(true);
|
||||
rtc_init_finalise();
|
||||
return mp_const_none;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(pyb_rtc_init_obj, pyb_rtc_init);
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(machine_rtc_init_obj, machine_rtc_init);
|
||||
|
||||
/// \method info()
|
||||
/// Get information about the startup time and reset source.
|
||||
@@ -181,10 +181,10 @@ MP_DEFINE_CONST_FUN_OBJ_1(pyb_rtc_init_obj, pyb_rtc_init);
|
||||
/// 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) {
|
||||
mp_obj_t machine_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);
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(machine_rtc_info_obj, machine_rtc_info);
|
||||
|
||||
/// \method datetime([datetimetuple])
|
||||
/// Get or set the date and time of the RTC.
|
||||
@@ -217,7 +217,7 @@ uint32_t rtc_us_to_subsec(uint32_t us) {
|
||||
#define rtc_subsec_to_us
|
||||
#endif
|
||||
|
||||
mp_obj_t pyb_rtc_datetime(size_t n_args, const mp_obj_t *args) {
|
||||
mp_obj_t machine_rtc_datetime(size_t n_args, const mp_obj_t *args) {
|
||||
rtc_init_finalise();
|
||||
if (n_args == 1) {
|
||||
ra_rtc_t time;
|
||||
@@ -249,12 +249,12 @@ mp_obj_t pyb_rtc_datetime(size_t n_args, const mp_obj_t *args) {
|
||||
return mp_const_none;
|
||||
}
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_rtc_datetime_obj, 1, 2, pyb_rtc_datetime);
|
||||
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_rtc_datetime_obj, 1, 2, machine_rtc_datetime);
|
||||
|
||||
// wakeup(None)
|
||||
// wakeup(ms, callback=None) - ms should be between 4ms - 2000ms
|
||||
// wakeup(wucksel, wut, callback) - not implemented
|
||||
mp_obj_t pyb_rtc_wakeup(size_t n_args, const mp_obj_t *args) {
|
||||
mp_obj_t machine_rtc_wakeup(size_t n_args, const mp_obj_t *args) {
|
||||
bool enable = false;
|
||||
mp_int_t ms;
|
||||
mp_obj_t callback = mp_const_none;
|
||||
@@ -307,13 +307,13 @@ mp_obj_t pyb_rtc_wakeup(size_t n_args, const mp_obj_t *args) {
|
||||
}
|
||||
return mp_const_none;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_rtc_wakeup_obj, 2, 3, pyb_rtc_wakeup);
|
||||
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_rtc_wakeup_obj, 2, 3, machine_rtc_wakeup);
|
||||
|
||||
// calibration(None)
|
||||
// calibration(cal)
|
||||
// When an integer argument is provided, check that it falls in the range [-63(s) to 63(s)]
|
||||
// and set the calibration value; otherwise return calibration value
|
||||
mp_obj_t pyb_rtc_calibration(size_t n_args, const mp_obj_t *args) {
|
||||
mp_obj_t machine_rtc_calibration(size_t n_args, const mp_obj_t *args) {
|
||||
rtc_init_finalise();
|
||||
mp_int_t cal;
|
||||
if (n_args == 2) {
|
||||
@@ -330,20 +330,20 @@ mp_obj_t pyb_rtc_calibration(size_t n_args, const mp_obj_t *args) {
|
||||
return mp_obj_new_int(cal);
|
||||
}
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_rtc_calibration_obj, 1, 2, pyb_rtc_calibration);
|
||||
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_rtc_calibration_obj, 1, 2, machine_rtc_calibration);
|
||||
|
||||
STATIC const mp_rom_map_elem_t pyb_rtc_locals_dict_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_init), MP_ROM_PTR(&pyb_rtc_init_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_info), MP_ROM_PTR(&pyb_rtc_info_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_datetime), MP_ROM_PTR(&pyb_rtc_datetime_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_wakeup), MP_ROM_PTR(&pyb_rtc_wakeup_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_calibration), MP_ROM_PTR(&pyb_rtc_calibration_obj) },
|
||||
STATIC const mp_rom_map_elem_t machine_rtc_locals_dict_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_init), MP_ROM_PTR(&machine_rtc_init_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_info), MP_ROM_PTR(&machine_rtc_info_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_datetime), MP_ROM_PTR(&machine_rtc_datetime_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_wakeup), MP_ROM_PTR(&machine_rtc_wakeup_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_calibration), MP_ROM_PTR(&machine_rtc_calibration_obj) },
|
||||
};
|
||||
STATIC MP_DEFINE_CONST_DICT(pyb_rtc_locals_dict, pyb_rtc_locals_dict_table);
|
||||
STATIC MP_DEFINE_CONST_DICT(machine_rtc_locals_dict, machine_rtc_locals_dict_table);
|
||||
|
||||
const mp_obj_type_t pyb_rtc_type = {
|
||||
const mp_obj_type_t machine_rtc_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_RTC,
|
||||
.make_new = pyb_rtc_make_new,
|
||||
.locals_dict = (mp_obj_dict_t *)&pyb_rtc_locals_dict,
|
||||
.make_new = machine_rtc_make_new,
|
||||
.locals_dict = (mp_obj_dict_t *)&machine_rtc_locals_dict,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user