Skip to content

Commit 12ea04c

Browse files
committed
Add cyw43.set_power_management
1 parent 91f1266 commit 12ea04c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

ports/raspberrypi/bindings/cyw43/__init__.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,23 @@ const mp_obj_type_t cyw43_pin_type = {
4949
)
5050
};
5151

52+
//| def set_power_management(/, value:int) -> None:
53+
//| """Set the power management register
54+
//|
55+
//| According to Raspberry Pi documentation, the value 0xa11140
56+
//| increases responsiveness at the cost of higher power usage.
57+
//|
58+
//| Besides this value, there appears to be no other public documentation
59+
//| of the values that can be used.
60+
//| """
61+
//|
62+
STATIC mp_obj_t cyw43_set_power_management(const mp_obj_t value_in) {
63+
mp_int_t value = mp_obj_get_int(value_in);
64+
cyw43_wifi_pm(&cyw43_state, value);
65+
return mp_const_none;
66+
}
67+
STATIC MP_DEFINE_CONST_FUN_OBJ_1(cyw43_set_power_management_obj, cyw43_set_power_management);
68+
5269
const mcu_pin_obj_t *validate_obj_is_pin_including_cyw43(mp_obj_t obj) {
5370
if (!mp_obj_is_type(obj, &mcu_pin_type) && !mp_obj_is_type(obj, &cyw43_pin_type)) {
5471
mp_raise_TypeError_varg(translate("Expected a %q or %q"), mcu_pin_type.name, cyw43_pin_type.name);
@@ -65,6 +82,7 @@ const mcu_pin_obj_t *validate_obj_is_free_pin_including_cyw43(mp_obj_t obj) {
6582
STATIC const mp_rom_map_elem_t cyw43_module_globals_table[] = {
6683
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_cyw43) },
6784
{ MP_ROM_QSTR(MP_QSTR_CywPin), MP_ROM_QSTR(MP_QSTR_CywPin) },
85+
{ MP_ROM_QSTR(MP_QSTR_set_power_management), MP_ROM_QSTR(MP_QSTR_set_power_management) },
6886
};
6987

7088
STATIC MP_DEFINE_CONST_DICT(cyw43_module_globals, cyw43_module_globals_table);

0 commit comments

Comments
 (0)