renesas-ra: Rename pyb_rtc_ to machine_rtc_.

Signed-off-by: Takeo Takahashi <takeo.takahashi.xv@renesas.com>
pull/8616/head
Takeo Takahashi 2022-05-03 19:46:03 +09:00
rodzic 5f57ec464a
commit 965747bd97
3 zmienionych plików z 30 dodań i 30 usunięć

Wyświetl plik

@ -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,
};

Wyświetl plik

@ -224,7 +224,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(machine_idle_obj, machine_idle);
STATIC mp_obj_t machine_lightsleep(size_t n_args, const mp_obj_t *args) {
if (n_args != 0) {
mp_obj_t args2[2] = {MP_OBJ_NULL, args[0]};
pyb_rtc_wakeup(2, args2);
machine_rtc_wakeup(2, args2);
}
powerctrl_enter_stop_mode();
return mp_const_none;
@ -234,7 +234,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_lightsleep_obj, 0, 1, machine_lights
STATIC mp_obj_t machine_deepsleep(size_t n_args, const mp_obj_t *args) {
if (n_args != 0) {
mp_obj_t args2[2] = {MP_OBJ_NULL, args[0]};
pyb_rtc_wakeup(2, args2);
machine_rtc_wakeup(2, args2);
}
powerctrl_enter_standby_mode();
return mp_const_none;
@ -273,7 +273,7 @@ STATIC const mp_rom_map_elem_t machine_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_Pin), MP_ROM_PTR(&machine_pin_type) },
{ MP_ROM_QSTR(MP_QSTR_Signal), MP_ROM_PTR(&machine_signal_type) },
{ MP_ROM_QSTR(MP_QSTR_RTC), MP_ROM_PTR(&pyb_rtc_type) },
{ MP_ROM_QSTR(MP_QSTR_RTC), MP_ROM_PTR(&machine_rtc_type) },
{ MP_ROM_QSTR(MP_QSTR_ADC), MP_ROM_PTR(&machine_adc_type) },
#if MICROPY_PY_MACHINE_I2C
#if MICROPY_HW_ENABLE_HW_I2C

Wyświetl plik

@ -28,7 +28,7 @@
#define MICROPY_INCLUDED_RA_RTC_H
#include "py/obj.h"
extern const mp_obj_type_t pyb_rtc_type;
extern const mp_obj_type_t machine_rtc_type;
typedef struct
{
@ -64,6 +64,6 @@ void rtc_get_date(RTC_DateTypeDef *date);
void rtc_init_start(bool force_init);
void rtc_init_finalise(void);
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);
#endif // MICROPY_INCLUDED_RA_RTC_H