Switch to using MP_ERROR_TEXT instead of translate, globally
This commit is contained in:
parent
6b62df4054
commit
774f6ac6ab
2
Makefile
2
Makefile
@ -227,7 +227,7 @@ pseudoxml:
|
|||||||
all-source:
|
all-source:
|
||||||
|
|
||||||
locale/circuitpython.pot: all-source
|
locale/circuitpython.pot: all-source
|
||||||
find $(TRANSLATE_SOURCES) -type d \( $(TRANSLATE_SOURCES_EXC) \) -prune -o -type f \( -iname "*.c" -o -iname "*.h" \) -print | (LC_ALL=C sort) | xgettext -f- -L C -s --add-location=file --keyword=translate --keyword=MP_ERROR_TEXT -o - | sed -e '/"POT-Creation-Date: /d' > $@
|
find $(TRANSLATE_SOURCES) -type d \( $(TRANSLATE_SOURCES_EXC) \) -prune -o -type f \( -iname "*.c" -o -iname "*.h" \) -print | (LC_ALL=C sort) | xgettext -f- -L C -s --add-location=file --keyword=MP_ERROR_TEXT -o - | sed -e '/"POT-Creation-Date: /d' > $@
|
||||||
|
|
||||||
# Historically, `make translate` updated the .pot file and ran msgmerge.
|
# Historically, `make translate` updated the .pot file and ran msgmerge.
|
||||||
# However, this was a frequent source of merge conflicts. Weblate can perform
|
# However, this was a frequent source of merge conflicts. Weblate can perform
|
||||||
|
@ -180,7 +180,7 @@ STATIC void add_generic_services(bleio_adapter_obj_t *adapter) {
|
|||||||
|
|
||||||
STATIC void check_enabled(bleio_adapter_obj_t *adapter) {
|
STATIC void check_enabled(bleio_adapter_obj_t *adapter) {
|
||||||
if (!common_hal_bleio_adapter_get_enabled(adapter)) {
|
if (!common_hal_bleio_adapter_get_enabled(adapter)) {
|
||||||
mp_raise_bleio_BluetoothError(translate("Adapter not enabled"));
|
mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Adapter not enabled"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,18 +297,18 @@ STATIC void bleio_adapter_hci_init(bleio_adapter_obj_t *self) {
|
|||||||
// Get version information.
|
// Get version information.
|
||||||
if (hci_read_local_version(&self->hci_version, &self->hci_revision, &self->lmp_version,
|
if (hci_read_local_version(&self->hci_version, &self->hci_revision, &self->lmp_version,
|
||||||
&self->manufacturer, &self->lmp_subversion) != HCI_OK) {
|
&self->manufacturer, &self->lmp_subversion) != HCI_OK) {
|
||||||
mp_raise_bleio_BluetoothError(translate("Could not read HCI version"));
|
mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Could not read HCI version"));
|
||||||
}
|
}
|
||||||
// Get supported features.
|
// Get supported features.
|
||||||
if (hci_le_read_local_supported_features(self->features) != HCI_OK) {
|
if (hci_le_read_local_supported_features(self->features) != HCI_OK) {
|
||||||
mp_raise_bleio_BluetoothError(translate("Could not read BLE features"));
|
mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Could not read BLE features"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enabled desired events.
|
// Enabled desired events.
|
||||||
// Most importantly, includes:
|
// Most importantly, includes:
|
||||||
// BT_EVT_MASK_LE_META_EVENT BT_EVT_BIT(61)
|
// BT_EVT_MASK_LE_META_EVENT BT_EVT_BIT(61)
|
||||||
if (hci_set_event_mask(0x3FFFFFFFFFFFFFFF) != HCI_OK) {
|
if (hci_set_event_mask(0x3FFFFFFFFFFFFFFF) != HCI_OK) {
|
||||||
mp_raise_bleio_BluetoothError(translate("Could not set event mask"));
|
mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Could not set event mask"));
|
||||||
}
|
}
|
||||||
// The default events for LE are:
|
// The default events for LE are:
|
||||||
// BT_EVT_MASK_LE_CONN_COMPLETE, BT_EVT_MASK_LE_ADVERTISING_REPORT,
|
// BT_EVT_MASK_LE_CONN_COMPLETE, BT_EVT_MASK_LE_ADVERTISING_REPORT,
|
||||||
@ -329,7 +329,7 @@ STATIC void bleio_adapter_hci_init(bleio_adapter_obj_t *self) {
|
|||||||
uint16_t acl_max_num;
|
uint16_t acl_max_num;
|
||||||
uint16_t sco_max_num;
|
uint16_t sco_max_num;
|
||||||
if (hci_read_buffer_size(&acl_max_len, &sco_max_len, &acl_max_num, &sco_max_num) != HCI_OK) {
|
if (hci_read_buffer_size(&acl_max_len, &sco_max_len, &acl_max_num, &sco_max_num) != HCI_OK) {
|
||||||
mp_raise_bleio_BluetoothError(translate("Could not read BLE buffer info"));
|
mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Could not read BLE buffer info"));
|
||||||
}
|
}
|
||||||
self->max_acl_buffer_len = acl_max_len;
|
self->max_acl_buffer_len = acl_max_len;
|
||||||
self->max_acl_num_buffers = acl_max_num;
|
self->max_acl_num_buffers = acl_max_num;
|
||||||
@ -339,7 +339,7 @@ STATIC void bleio_adapter_hci_init(bleio_adapter_obj_t *self) {
|
|||||||
if (BT_FEAT_LE_EXT_ADV(self->features)) {
|
if (BT_FEAT_LE_EXT_ADV(self->features)) {
|
||||||
uint16_t max_adv_data_len;
|
uint16_t max_adv_data_len;
|
||||||
if (hci_le_read_maximum_advertising_data_length(&max_adv_data_len) != HCI_OK) {
|
if (hci_le_read_maximum_advertising_data_length(&max_adv_data_len) != HCI_OK) {
|
||||||
mp_raise_bleio_BluetoothError(translate("Could not get max advertising length"));
|
mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Could not get max advertising length"));
|
||||||
}
|
}
|
||||||
self->max_adv_data_len = max_adv_data_len;
|
self->max_adv_data_len = max_adv_data_len;
|
||||||
} else {
|
} else {
|
||||||
@ -472,7 +472,7 @@ mp_obj_t common_hal_bleio_adapter_start_scan(bleio_adapter_obj_t *self, uint8_t
|
|||||||
|
|
||||||
if (self->scan_results != NULL) {
|
if (self->scan_results != NULL) {
|
||||||
if (!shared_module_bleio_scanresults_get_done(self->scan_results)) {
|
if (!shared_module_bleio_scanresults_get_done(self->scan_results)) {
|
||||||
mp_raise_bleio_BluetoothError(translate("Scan already in progress. Stop with stop_scan."));
|
mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Scan already in progress. Stop with stop_scan."));
|
||||||
}
|
}
|
||||||
self->scan_results = NULL;
|
self->scan_results = NULL;
|
||||||
}
|
}
|
||||||
@ -601,7 +601,7 @@ mp_obj_t common_hal_bleio_adapter_connect(bleio_adapter_obj_t *self, bleio_addre
|
|||||||
|
|
||||||
// uint16_t conn_handle = event_info.conn_handle;
|
// uint16_t conn_handle = event_info.conn_handle;
|
||||||
// if (conn_handle == BLE_CONN_HANDLE_INVALID) {
|
// if (conn_handle == BLE_CONN_HANDLE_INVALID) {
|
||||||
// mp_raise_bleio_BluetoothError(translate("Failed to connect: timeout"));
|
// mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Failed to connect: timeout"));
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// // Negotiate for better PHY, larger MTU and data lengths since we are the central. These are
|
// // Negotiate for better PHY, larger MTU and data lengths since we are the central. These are
|
||||||
@ -622,14 +622,14 @@ mp_obj_t common_hal_bleio_adapter_connect(bleio_adapter_obj_t *self, bleio_addre
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
mp_raise_bleio_BluetoothError(translate("Failed to connect: internal error"));
|
mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Failed to connect: internal error"));
|
||||||
|
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC void check_data_fit(size_t data_len, bool connectable) {
|
STATIC void check_data_fit(size_t data_len, bool connectable) {
|
||||||
if (data_len > MAX_ADVERTISEMENT_SIZE) {
|
if (data_len > MAX_ADVERTISEMENT_SIZE) {
|
||||||
mp_raise_ValueError(translate("Data too large for advertisement packet"));
|
mp_raise_ValueError(MP_ERROR_TEXT("Data too large for advertisement packet"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -686,7 +686,7 @@ uint32_t _common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self,
|
|||||||
|
|
||||||
if (extended) {
|
if (extended) {
|
||||||
if (!BT_FEAT_LE_EXT_ADV(self->features)) {
|
if (!BT_FEAT_LE_EXT_ADV(self->features)) {
|
||||||
mp_raise_bleio_BluetoothError(translate("Data length needs extended advertising, but this adapter does not support it"));
|
mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Data length needs extended advertising, but this adapter does not support it"));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t props = 0;
|
uint16_t props = 0;
|
||||||
@ -801,7 +801,7 @@ void common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self,
|
|||||||
check_data_fit(scan_response_data_bufinfo->len, connectable);
|
check_data_fit(scan_response_data_bufinfo->len, connectable);
|
||||||
|
|
||||||
if (advertising_data_bufinfo->len > MAX_ADVERTISEMENT_SIZE && scan_response_data_bufinfo->len > 0) {
|
if (advertising_data_bufinfo->len > MAX_ADVERTISEMENT_SIZE && scan_response_data_bufinfo->len > 0) {
|
||||||
mp_raise_bleio_BluetoothError(translate("Extended advertisements with scan response not supported."));
|
mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Extended advertisements with scan response not supported."));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Anonymous mode requires a timeout so that we don't continue to broadcast
|
// Anonymous mode requires a timeout so that we don't continue to broadcast
|
||||||
@ -811,13 +811,13 @@ void common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self,
|
|||||||
timeout = MAX_ANONYMOUS_ADV_TIMEOUT_SECS;
|
timeout = MAX_ANONYMOUS_ADV_TIMEOUT_SECS;
|
||||||
} else {
|
} else {
|
||||||
if (timeout > MAX_LIMITED_DISCOVERABLE_ADV_TIMEOUT_SECS) {
|
if (timeout > MAX_LIMITED_DISCOVERABLE_ADV_TIMEOUT_SECS) {
|
||||||
mp_raise_bleio_BluetoothError(translate("Timeout is too long: Maximum timeout length is %d seconds"),
|
mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Timeout is too long: Maximum timeout length is %d seconds"),
|
||||||
MAX_LIMITED_DISCOVERABLE_ADV_TIMEOUT_SECS);
|
MAX_LIMITED_DISCOVERABLE_ADV_TIMEOUT_SECS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tx_power != 0) {
|
if (tx_power != 0) {
|
||||||
mp_raise_NotImplementedError(translate("Only tx_power=0 supported"));
|
mp_raise_NotImplementedError(MP_ERROR_TEXT("Only tx_power=0 supported"));
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint32_t result = _common_hal_bleio_adapter_start_advertising(
|
const uint32_t result = _common_hal_bleio_adapter_start_advertising(
|
||||||
@ -829,7 +829,7 @@ void common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self,
|
|||||||
tx_power, directed_to);
|
tx_power, directed_to);
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
mp_raise_bleio_BluetoothError(translate("Already advertising"));
|
mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Already advertising"));
|
||||||
}
|
}
|
||||||
self->circuitpython_advertising = false;
|
self->circuitpython_advertising = false;
|
||||||
}
|
}
|
||||||
|
@ -45,5 +45,5 @@ bleio_uuid_obj_t *bleio_attribute_get_uuid(mp_obj_t *attribute) {
|
|||||||
bleio_service_obj_t *service = MP_OBJ_TO_PTR(attribute);
|
bleio_service_obj_t *service = MP_OBJ_TO_PTR(attribute);
|
||||||
return service->uuid;
|
return service->uuid;
|
||||||
}
|
}
|
||||||
mp_raise_RuntimeError(translate("Invalid BLE attribute"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("Invalid BLE attribute"));
|
||||||
}
|
}
|
||||||
|
@ -108,10 +108,10 @@ size_t common_hal_bleio_characteristic_get_value(bleio_characteristic_obj_t *sel
|
|||||||
|
|
||||||
void common_hal_bleio_characteristic_set_value(bleio_characteristic_obj_t *self, mp_buffer_info_t *bufinfo) {
|
void common_hal_bleio_characteristic_set_value(bleio_characteristic_obj_t *self, mp_buffer_info_t *bufinfo) {
|
||||||
if (self->fixed_length && bufinfo->len != self->max_length) {
|
if (self->fixed_length && bufinfo->len != self->max_length) {
|
||||||
mp_raise_ValueError(translate("Value length != required fixed length"));
|
mp_raise_ValueError(MP_ERROR_TEXT("Value length != required fixed length"));
|
||||||
}
|
}
|
||||||
if (bufinfo->len > self->max_length) {
|
if (bufinfo->len > self->max_length) {
|
||||||
mp_raise_ValueError(translate("Value length > max_length"));
|
mp_raise_ValueError(MP_ERROR_TEXT("Value length > max_length"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do GATT operations only if this characteristic has been added to a registered service.
|
// Do GATT operations only if this characteristic has been added to a registered service.
|
||||||
@ -125,7 +125,7 @@ void common_hal_bleio_characteristic_set_value(bleio_characteristic_obj_t *self,
|
|||||||
} else if (self->props & CHAR_PROP_WRITE_NO_RESPONSE) {
|
} else if (self->props & CHAR_PROP_WRITE_NO_RESPONSE) {
|
||||||
// att_write_cmd(conn_handle, self->handle, bufinfo->buff, bufinfo->len);
|
// att_write_cmd(conn_handle, self->handle, bufinfo->buff, bufinfo->len);
|
||||||
} else {
|
} else {
|
||||||
mp_raise_bleio_BluetoothError(translate("Characteristic not writable"));
|
mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Characteristic not writable"));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Always write the value locally even if no connections are active.
|
// Always write the value locally even if no connections are active.
|
||||||
@ -168,7 +168,7 @@ bleio_characteristic_properties_t common_hal_bleio_characteristic_get_properties
|
|||||||
void common_hal_bleio_characteristic_add_descriptor(bleio_characteristic_obj_t *self, bleio_descriptor_obj_t *descriptor) {
|
void common_hal_bleio_characteristic_add_descriptor(bleio_characteristic_obj_t *self, bleio_descriptor_obj_t *descriptor) {
|
||||||
if (self->handle != common_hal_bleio_adapter_obj.last_added_characteristic_handle) {
|
if (self->handle != common_hal_bleio_adapter_obj.last_added_characteristic_handle) {
|
||||||
mp_raise_bleio_BluetoothError(
|
mp_raise_bleio_BluetoothError(
|
||||||
translate("Descriptor can only be added to most recently added characteristic"));
|
MP_ERROR_TEXT("Descriptor can only be added to most recently added characteristic"));
|
||||||
}
|
}
|
||||||
|
|
||||||
descriptor->handle = bleio_adapter_add_attribute(&common_hal_bleio_adapter_obj, MP_OBJ_TO_PTR(descriptor));
|
descriptor->handle = bleio_adapter_add_attribute(&common_hal_bleio_adapter_obj, MP_OBJ_TO_PTR(descriptor));
|
||||||
@ -181,11 +181,11 @@ void common_hal_bleio_characteristic_add_descriptor(bleio_characteristic_obj_t *
|
|||||||
|
|
||||||
void common_hal_bleio_characteristic_set_cccd(bleio_characteristic_obj_t *self, bool notify, bool indicate) {
|
void common_hal_bleio_characteristic_set_cccd(bleio_characteristic_obj_t *self, bool notify, bool indicate) {
|
||||||
if (self->cccd == NULL) {
|
if (self->cccd == NULL) {
|
||||||
mp_raise_bleio_BluetoothError(translate("No CCCD for this Characteristic"));
|
mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("No CCCD for this Characteristic"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!common_hal_bleio_service_get_is_remote(self->service)) {
|
if (!common_hal_bleio_service_get_is_remote(self->service)) {
|
||||||
mp_raise_bleio_RoleError(translate("Can't set CCCD on local Characteristic"));
|
mp_raise_bleio_RoleError(MP_ERROR_TEXT("Can't set CCCD on local Characteristic"));
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint16_t conn_handle = bleio_connection_get_conn_handle(self->service->connection);
|
const uint16_t conn_handle = bleio_connection_get_conn_handle(self->service->connection);
|
||||||
@ -199,7 +199,7 @@ void common_hal_bleio_characteristic_set_cccd(bleio_characteristic_obj_t *self,
|
|||||||
(void)cccd_value;
|
(void)cccd_value;
|
||||||
// uint8_t rsp[sizeof(bt_att_error_rsp)];
|
// uint8_t rsp[sizeof(bt_att_error_rsp)];
|
||||||
// if (att_write_req(conn_handle, self->cccd->handle, &cccd_value, sizeof(cccd_value)) == 0) {
|
// if (att_write_req(conn_handle, self->cccd->handle, &cccd_value, sizeof(cccd_value)) == 0) {
|
||||||
// mp_raise_bleio_BluetoothError(translate("Could not write CCCD"));
|
// mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Could not write CCCD"));
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -640,7 +640,7 @@ void common_hal_bleio_connection_set_connection_interval(bleio_connection_intern
|
|||||||
// mp_obj_t uuid_obj;
|
// mp_obj_t uuid_obj;
|
||||||
// while ((uuid_obj = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) {
|
// while ((uuid_obj = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) {
|
||||||
// if (!mp_obj_is_type(uuid_obj, &bleio_uuid_type)) {
|
// if (!mp_obj_is_type(uuid_obj, &bleio_uuid_type)) {
|
||||||
// mp_raise_TypeError(translate("non-UUID found in service_uuids_whitelist"));
|
// mp_raise_TypeError(MP_ERROR_TEXT("non-UUID found in service_uuids_whitelist"));
|
||||||
// }
|
// }
|
||||||
// bleio_uuid_obj_t *uuid = MP_OBJ_TO_PTR(uuid_obj);
|
// bleio_uuid_obj_t *uuid = MP_OBJ_TO_PTR(uuid_obj);
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ void common_hal_bleio_descriptor_construct(bleio_descriptor_obj_t *self, bleio_c
|
|||||||
|
|
||||||
const mp_int_t max_length_max = fixed_length ? BLE_GATTS_FIX_ATTR_LEN_MAX : BLE_GATTS_VAR_ATTR_LEN_MAX;
|
const mp_int_t max_length_max = fixed_length ? BLE_GATTS_FIX_ATTR_LEN_MAX : BLE_GATTS_VAR_ATTR_LEN_MAX;
|
||||||
if (max_length < 0 || max_length > max_length_max) {
|
if (max_length < 0 || max_length > max_length_max) {
|
||||||
mp_raise_ValueError_varg(translate("max_length must be 0-%d when fixed_length is %s"),
|
mp_raise_ValueError_varg(MP_ERROR_TEXT("max_length must be 0-%d when fixed_length is %s"),
|
||||||
max_length_max, fixed_length ? "True" : "False");
|
max_length_max, fixed_length ? "True" : "False");
|
||||||
}
|
}
|
||||||
self->max_length = max_length;
|
self->max_length = max_length;
|
||||||
@ -85,10 +85,10 @@ size_t common_hal_bleio_descriptor_get_value(bleio_descriptor_obj_t *self, uint8
|
|||||||
|
|
||||||
void common_hal_bleio_descriptor_set_value(bleio_descriptor_obj_t *self, mp_buffer_info_t *bufinfo) {
|
void common_hal_bleio_descriptor_set_value(bleio_descriptor_obj_t *self, mp_buffer_info_t *bufinfo) {
|
||||||
if (self->fixed_length && bufinfo->len != self->max_length) {
|
if (self->fixed_length && bufinfo->len != self->max_length) {
|
||||||
mp_raise_ValueError(translate("Value length != required fixed length"));
|
mp_raise_ValueError(MP_ERROR_TEXT("Value length != required fixed length"));
|
||||||
}
|
}
|
||||||
if (bufinfo->len > self->max_length) {
|
if (bufinfo->len > self->max_length) {
|
||||||
mp_raise_ValueError(translate("Value length > max_length"));
|
mp_raise_ValueError(MP_ERROR_TEXT("Value length > max_length"));
|
||||||
}
|
}
|
||||||
|
|
||||||
self->value = mp_obj_new_bytes(bufinfo->buf, bufinfo->len);
|
self->value = mp_obj_new_bytes(bufinfo->buf, bufinfo->len);
|
||||||
|
@ -102,7 +102,7 @@ void common_hal_bleio_packet_buffer_construct(
|
|||||||
|
|
||||||
if (incoming) {
|
if (incoming) {
|
||||||
if (!ringbuf_alloc(&self->ringbuf, buffer_size * (sizeof(uint16_t) + max_packet_size))) {
|
if (!ringbuf_alloc(&self->ringbuf, buffer_size * (sizeof(uint16_t) + max_packet_size))) {
|
||||||
mp_raise_ValueError(translate("Buffer too large and unable to allocate"));
|
mp_raise_ValueError(MP_ERROR_TEXT("Buffer too large and unable to allocate"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ mp_int_t common_hal_bleio_packet_buffer_readinto(bleio_packet_buffer_obj_t *self
|
|||||||
mp_int_t common_hal_bleio_packet_buffer_write(bleio_packet_buffer_obj_t *self,
|
mp_int_t common_hal_bleio_packet_buffer_write(bleio_packet_buffer_obj_t *self,
|
||||||
const uint8_t *data, size_t len, uint8_t *header, size_t header_len) {
|
const uint8_t *data, size_t len, uint8_t *header, size_t header_len) {
|
||||||
if (self->outgoing[0] == NULL) {
|
if (self->outgoing[0] == NULL) {
|
||||||
mp_raise_bleio_BluetoothError(translate("Writes not supported on Characteristic"));
|
mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Writes not supported on Characteristic"));
|
||||||
}
|
}
|
||||||
if (self->conn_handle == BLE_CONN_HANDLE_INVALID) {
|
if (self->conn_handle == BLE_CONN_HANDLE_INVALID) {
|
||||||
return -1;
|
return -1;
|
||||||
@ -160,7 +160,7 @@ mp_int_t common_hal_bleio_packet_buffer_write(bleio_packet_buffer_obj_t *self,
|
|||||||
|
|
||||||
if (len + header_len > outgoing_packet_length) {
|
if (len + header_len > outgoing_packet_length) {
|
||||||
// Supplied data will not fit in a single BLE packet.
|
// Supplied data will not fit in a single BLE packet.
|
||||||
mp_raise_ValueError(translate("Total data to write is larger than outgoing_packet_length"));
|
mp_raise_ValueError(MP_ERROR_TEXT("Total data to write is larger than outgoing_packet_length"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len + self->pending_size > outgoing_packet_length) {
|
if (len + self->pending_size > outgoing_packet_length) {
|
||||||
|
@ -53,7 +53,7 @@ uint32_t _common_hal_bleio_service_construct(bleio_service_obj_t *self, bleio_uu
|
|||||||
void common_hal_bleio_service_construct(bleio_service_obj_t *self, bleio_uuid_obj_t *uuid, bool is_secondary) {
|
void common_hal_bleio_service_construct(bleio_service_obj_t *self, bleio_uuid_obj_t *uuid, bool is_secondary) {
|
||||||
if (_common_hal_bleio_service_construct(self, uuid, is_secondary,
|
if (_common_hal_bleio_service_construct(self, uuid, is_secondary,
|
||||||
mp_obj_new_list(0, NULL)) != 0) {
|
mp_obj_new_list(0, NULL)) != 0) {
|
||||||
mp_raise_RuntimeError(translate("Failed to add service"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("Failed to add service"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ void common_hal_bleio_service_add_characteristic(bleio_service_obj_t *self,
|
|||||||
|
|
||||||
if (self->handle != common_hal_bleio_adapter_obj.last_added_service_handle) {
|
if (self->handle != common_hal_bleio_adapter_obj.last_added_service_handle) {
|
||||||
mp_raise_bleio_BluetoothError(
|
mp_raise_bleio_BluetoothError(
|
||||||
translate("Characteristic can only be added to most recently added service"));
|
MP_ERROR_TEXT("Characteristic can only be added to most recently added service"));
|
||||||
}
|
}
|
||||||
characteristic->decl_handle = bleio_adapter_add_attribute(
|
characteristic->decl_handle = bleio_adapter_add_attribute(
|
||||||
&common_hal_bleio_adapter_obj, MP_OBJ_TO_PTR(characteristic));
|
&common_hal_bleio_adapter_obj, MP_OBJ_TO_PTR(characteristic));
|
||||||
|
@ -50,10 +50,10 @@ bool vm_used_ble;
|
|||||||
|
|
||||||
// switch (sec_status) {
|
// switch (sec_status) {
|
||||||
// case BLE_GAP_SEC_STATUS_UNSPECIFIED:
|
// case BLE_GAP_SEC_STATUS_UNSPECIFIED:
|
||||||
// mp_raise_bleio_SecurityError(translate("Unspecified issue. Can be that the pairing prompt on the other device was declined or ignored."));
|
// mp_raise_bleio_SecurityError(MP_ERROR_TEXT("Unspecified issue. Can be that the pairing prompt on the other device was declined or ignored."));
|
||||||
// return;
|
// return;
|
||||||
// default:
|
// default:
|
||||||
// mp_raise_bleio_SecurityError(translate("Unknown security error: 0x%04x"), sec_status);
|
// mp_raise_bleio_SecurityError(MP_ERROR_TEXT("Unknown security error: 0x%04x"), sec_status);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@ -96,14 +96,14 @@ bleio_adapter_obj_t common_hal_bleio_adapter_obj = {
|
|||||||
|
|
||||||
bleio_adapter_obj_t *common_hal_bleio_allocate_adapter_or_raise(void) {
|
bleio_adapter_obj_t *common_hal_bleio_allocate_adapter_or_raise(void) {
|
||||||
if (common_hal_bleio_adapter_obj.allocated) {
|
if (common_hal_bleio_adapter_obj.allocated) {
|
||||||
mp_raise_RuntimeError(translate("Too many Adapters"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("Too many Adapters"));
|
||||||
}
|
}
|
||||||
return &common_hal_bleio_adapter_obj;
|
return &common_hal_bleio_adapter_obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_bleio_check_connected(uint16_t conn_handle) {
|
void common_hal_bleio_check_connected(uint16_t conn_handle) {
|
||||||
if (conn_handle == BLE_CONN_HANDLE_INVALID) {
|
if (conn_handle == BLE_CONN_HANDLE_INVALID) {
|
||||||
mp_raise_ConnectionError(translate("Not connected"));
|
mp_raise_ConnectionError(MP_ERROR_TEXT("Not connected"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1727,52 +1727,52 @@ static void check_att_err(uint8_t err) {
|
|||||||
case 0:
|
case 0:
|
||||||
return;
|
return;
|
||||||
case BT_ATT_ERR_INVALID_HANDLE:
|
case BT_ATT_ERR_INVALID_HANDLE:
|
||||||
msg = translate("Invalid handle");
|
msg = MP_ERROR_TEXT("Invalid handle");
|
||||||
break;
|
break;
|
||||||
case BT_ATT_ERR_READ_NOT_PERMITTED:
|
case BT_ATT_ERR_READ_NOT_PERMITTED:
|
||||||
msg = translate("Read not permitted");
|
msg = MP_ERROR_TEXT("Read not permitted");
|
||||||
break;
|
break;
|
||||||
case BT_ATT_ERR_WRITE_NOT_PERMITTED:
|
case BT_ATT_ERR_WRITE_NOT_PERMITTED:
|
||||||
msg = translate("Write not permitted");
|
msg = MP_ERROR_TEXT("Write not permitted");
|
||||||
break;
|
break;
|
||||||
case BT_ATT_ERR_INVALID_PDU:
|
case BT_ATT_ERR_INVALID_PDU:
|
||||||
msg = translate("Invalid PDU");
|
msg = MP_ERROR_TEXT("Invalid PDU");
|
||||||
break;
|
break;
|
||||||
case BT_ATT_ERR_NOT_SUPPORTED:
|
case BT_ATT_ERR_NOT_SUPPORTED:
|
||||||
msg = translate("Not supported");
|
msg = MP_ERROR_TEXT("Not supported");
|
||||||
break;
|
break;
|
||||||
case BT_ATT_ERR_INVALID_OFFSET:
|
case BT_ATT_ERR_INVALID_OFFSET:
|
||||||
msg = translate("Invalid offset");
|
msg = MP_ERROR_TEXT("Invalid offset");
|
||||||
break;
|
break;
|
||||||
case BT_ATT_ERR_PREPARE_QUEUE_FULL:
|
case BT_ATT_ERR_PREPARE_QUEUE_FULL:
|
||||||
msg = translate("Prepare queue full");
|
msg = MP_ERROR_TEXT("Prepare queue full");
|
||||||
break;
|
break;
|
||||||
case BT_ATT_ERR_ATTRIBUTE_NOT_FOUND:
|
case BT_ATT_ERR_ATTRIBUTE_NOT_FOUND:
|
||||||
msg = translate("Attribute not found");
|
msg = MP_ERROR_TEXT("Attribute not found");
|
||||||
break;
|
break;
|
||||||
case BT_ATT_ERR_ATTRIBUTE_NOT_LONG:
|
case BT_ATT_ERR_ATTRIBUTE_NOT_LONG:
|
||||||
msg = translate("Attribute not long");
|
msg = MP_ERROR_TEXT("Attribute not long");
|
||||||
break;
|
break;
|
||||||
case BT_ATT_ERR_ENCRYPTION_KEY_SIZE:
|
case BT_ATT_ERR_ENCRYPTION_KEY_SIZE:
|
||||||
msg = translate("Encryption key size");
|
msg = MP_ERROR_TEXT("Encryption key size");
|
||||||
break;
|
break;
|
||||||
case BT_ATT_ERR_INVALID_ATTRIBUTE_LEN:
|
case BT_ATT_ERR_INVALID_ATTRIBUTE_LEN:
|
||||||
msg = translate("Invalid attribute length");
|
msg = MP_ERROR_TEXT("Invalid attribute length");
|
||||||
break;
|
break;
|
||||||
case BT_ATT_ERR_UNLIKELY:
|
case BT_ATT_ERR_UNLIKELY:
|
||||||
msg = translate("Unlikely");
|
msg = MP_ERROR_TEXT("Unlikely");
|
||||||
break;
|
break;
|
||||||
case BT_ATT_ERR_UNSUPPORTED_GROUP_TYPE:
|
case BT_ATT_ERR_UNSUPPORTED_GROUP_TYPE:
|
||||||
msg = translate("Unsupported group type");
|
msg = MP_ERROR_TEXT("Unsupported group type");
|
||||||
break;
|
break;
|
||||||
case BT_ATT_ERR_INSUFFICIENT_RESOURCES:
|
case BT_ATT_ERR_INSUFFICIENT_RESOURCES:
|
||||||
msg = translate("Insufficient resources");
|
msg = MP_ERROR_TEXT("Insufficient resources");
|
||||||
break;
|
break;
|
||||||
case BT_ATT_ERR_DB_OUT_OF_SYNC:
|
case BT_ATT_ERR_DB_OUT_OF_SYNC:
|
||||||
msg = translate("DB out of sync");
|
msg = MP_ERROR_TEXT("DB out of sync");
|
||||||
break;
|
break;
|
||||||
case BT_ATT_ERR_VALUE_NOT_ALLOWED:
|
case BT_ATT_ERR_VALUE_NOT_ALLOWED:
|
||||||
msg = translate("Value not allowed");
|
msg = MP_ERROR_TEXT("Value not allowed");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (msg) {
|
if (msg) {
|
||||||
@ -1781,15 +1781,15 @@ static void check_att_err(uint8_t err) {
|
|||||||
|
|
||||||
switch (err) {
|
switch (err) {
|
||||||
case BT_ATT_ERR_AUTHENTICATION:
|
case BT_ATT_ERR_AUTHENTICATION:
|
||||||
msg = translate("Insufficient authentication");
|
msg = MP_ERROR_TEXT("Insufficient authentication");
|
||||||
break;
|
break;
|
||||||
case BT_ATT_ERR_INSUFFICIENT_ENCRYPTION:
|
case BT_ATT_ERR_INSUFFICIENT_ENCRYPTION:
|
||||||
msg = translate("Insufficient encryption");
|
msg = MP_ERROR_TEXT("Insufficient encryption");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (msg) {
|
if (msg) {
|
||||||
mp_raise_bleio_SecurityError(msg);
|
mp_raise_bleio_SecurityError(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
mp_raise_bleio_BluetoothError(translate("Unknown ATT error: 0x%02x"), err);
|
mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Unknown ATT error: 0x%02x"), err);
|
||||||
}
|
}
|
||||||
|
@ -770,35 +770,35 @@ void hci_check_error(hci_result_t result) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
case HCI_RESPONSE_TIMEOUT:
|
case HCI_RESPONSE_TIMEOUT:
|
||||||
mp_raise_bleio_BluetoothError(translate("Timeout waiting for HCI response"));
|
mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Timeout waiting for HCI response"));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case HCI_WRITE_TIMEOUT:
|
case HCI_WRITE_TIMEOUT:
|
||||||
mp_raise_bleio_BluetoothError(translate("Timeout waiting to write HCI request"));
|
mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Timeout waiting to write HCI request"));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case HCI_READ_ERROR:
|
case HCI_READ_ERROR:
|
||||||
mp_raise_bleio_BluetoothError(translate("Error reading from HCI adapter"));
|
mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Error reading from HCI adapter"));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case HCI_WRITE_ERROR:
|
case HCI_WRITE_ERROR:
|
||||||
mp_raise_bleio_BluetoothError(translate("Error writing to HCI adapter"));
|
mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Error writing to HCI adapter"));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case HCI_PACKET_SIZE_ERROR:
|
case HCI_PACKET_SIZE_ERROR:
|
||||||
mp_raise_RuntimeError(translate("HCI packet size mismatch"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("HCI packet size mismatch"));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case HCI_ATT_ERROR:
|
case HCI_ATT_ERROR:
|
||||||
mp_raise_RuntimeError(translate("Error in ATT protocol code"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("Error in ATT protocol code"));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// Should be an HCI status error, > 0.
|
// Should be an HCI status error, > 0.
|
||||||
if (result > 0) {
|
if (result > 0) {
|
||||||
mp_raise_bleio_BluetoothError(translate("HCI status error: %02x"), result);
|
mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("HCI status error: %02x"), result);
|
||||||
} else {
|
} else {
|
||||||
mp_raise_bleio_BluetoothError(translate("Unknown hci_result_t: %d"), result);
|
mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Unknown hci_result_t: %d"), result);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 2df210f87a79deedc9003b1bbd6015a2fea7c03e
|
Subproject commit aec113300008516614a5ff697520fb2ac3bc20bb
|
@ -55,7 +55,7 @@ static bool audio_dma_allocated[AUDIO_DMA_CHANNEL_COUNT];
|
|||||||
uint8_t find_sync_event_channel_raise() {
|
uint8_t find_sync_event_channel_raise() {
|
||||||
uint8_t event_channel = find_sync_event_channel();
|
uint8_t event_channel = find_sync_event_channel();
|
||||||
if (event_channel >= EVSYS_SYNCH_NUM) {
|
if (event_channel >= EVSYS_SYNCH_NUM) {
|
||||||
mp_raise_RuntimeError(translate("All sync event channels in use"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("All sync event channels in use"));
|
||||||
}
|
}
|
||||||
return event_channel;
|
return event_channel;
|
||||||
}
|
}
|
||||||
@ -109,7 +109,7 @@ static void audio_dma_convert_samples(
|
|||||||
*output_spacing = 1;
|
*output_spacing = 1;
|
||||||
|
|
||||||
if (*output_length > available_output_buffer_length) {
|
if (*output_length > available_output_buffer_length) {
|
||||||
mp_raise_RuntimeError(translate("Internal audio buffer too small"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("Internal audio buffer too small"));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t out_i = 0;
|
uint32_t out_i = 0;
|
||||||
|
@ -105,10 +105,10 @@ STATIC mp_obj_t samd_clock_set_calibration(mp_obj_t self_in, mp_obj_t calibratio
|
|||||||
samd_clock_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
samd_clock_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||||
int ret = clock_set_calibration(self->type, self->index, mp_obj_get_int(calibration));
|
int ret = clock_set_calibration(self->type, self->index, mp_obj_get_int(calibration));
|
||||||
if (ret == -2) {
|
if (ret == -2) {
|
||||||
mp_raise_AttributeError(translate("calibration is read only"));
|
mp_raise_AttributeError(MP_ERROR_TEXT("calibration is read only"));
|
||||||
}
|
}
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
mp_raise_ValueError(translate("calibration is out of range"));
|
mp_raise_ValueError(MP_ERROR_TEXT("calibration is out of range"));
|
||||||
}
|
}
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#define CALIBRATE_CRYSTALLESS 1
|
#define CALIBRATE_CRYSTALLESS 1
|
||||||
|
|
||||||
// Explanation of how a user got into safe mode.
|
// Explanation of how a user got into safe mode.
|
||||||
#define BOARD_USER_SAFE_MODE_ACTION translate("You pressed both buttons at start up.")
|
#define BOARD_USER_SAFE_MODE_ACTION MP_ERROR_TEXT("You pressed both buttons at start up.")
|
||||||
|
|
||||||
// Increase stack size slightly due to CPX library import nesting
|
// Increase stack size slightly due to CPX library import nesting
|
||||||
#define CIRCUITPY_DEFAULT_STACK_SIZE (4248) // divisible by 8
|
#define CIRCUITPY_DEFAULT_STACK_SIZE (4248) // divisible by 8
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#define CALIBRATE_CRYSTALLESS 1
|
#define CALIBRATE_CRYSTALLESS 1
|
||||||
|
|
||||||
// Explanation of how a user got into safe mode.
|
// Explanation of how a user got into safe mode.
|
||||||
#define BOARD_USER_SAFE_MODE_ACTION translate("You pressed both buttons at start up.")
|
#define BOARD_USER_SAFE_MODE_ACTION MP_ERROR_TEXT("You pressed both buttons at start up.")
|
||||||
|
|
||||||
// Increase stack size slightly due to CPX library import nesting
|
// Increase stack size slightly due to CPX library import nesting
|
||||||
#define CIRCUITPY_DEFAULT_STACK_SIZE (4248) // divisible by 8
|
#define CIRCUITPY_DEFAULT_STACK_SIZE (4248) // divisible by 8
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#define CALIBRATE_CRYSTALLESS 1
|
#define CALIBRATE_CRYSTALLESS 1
|
||||||
|
|
||||||
// Explanation of how a user got into safe mode.
|
// Explanation of how a user got into safe mode.
|
||||||
#define BOARD_USER_SAFE_MODE_ACTION translate("You pressed both buttons at start up.")
|
#define BOARD_USER_SAFE_MODE_ACTION MP_ERROR_TEXT("You pressed both buttons at start up.")
|
||||||
|
|
||||||
// Increase stack size slightly due to CPX library import nesting.
|
// Increase stack size slightly due to CPX library import nesting.
|
||||||
#define CIRCUITPY_DEFAULT_STACK_SIZE (4248) // divisible by 8
|
#define CIRCUITPY_DEFAULT_STACK_SIZE (4248) // divisible by 8
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#define CALIBRATE_CRYSTALLESS 1
|
#define CALIBRATE_CRYSTALLESS 1
|
||||||
|
|
||||||
// Explanation of how a user got into safe mode.
|
// Explanation of how a user got into safe mode.
|
||||||
#define BOARD_USER_SAFE_MODE_ACTION translate("You pressed both buttons at start up.")
|
#define BOARD_USER_SAFE_MODE_ACTION MP_ERROR_TEXT("You pressed both buttons at start up.")
|
||||||
|
|
||||||
#define DEFAULT_I2C_BUS_SCL (&pin_PA01)
|
#define DEFAULT_I2C_BUS_SCL (&pin_PA01)
|
||||||
#define DEFAULT_I2C_BUS_SDA (&pin_PA00)
|
#define DEFAULT_I2C_BUS_SDA (&pin_PA00)
|
||||||
|
@ -77,7 +77,7 @@ void pew_init() {
|
|||||||
// Find a spare timer.
|
// Find a spare timer.
|
||||||
uint8_t index = find_free_timer();
|
uint8_t index = find_free_timer();
|
||||||
if (index == 0xff) {
|
if (index == 0xff) {
|
||||||
mp_raise_RuntimeError(translate("All timers in use"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("All timers in use"));
|
||||||
}
|
}
|
||||||
Tc *tc = tc_insts[index];
|
Tc *tc = tc_insts[index];
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ mp_obj_t common_hal_alarm_light_sleep_until_alarms(size_t n_alarms, const mp_obj
|
|||||||
|
|
||||||
void common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *alarms, size_t n_dios, digitalio_digitalinout_obj_t **preserve_dios) {
|
void common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *alarms, size_t n_dios, digitalio_digitalinout_obj_t **preserve_dios) {
|
||||||
if (n_dios > 0) {
|
if (n_dios > 0) {
|
||||||
mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_preserve_dios);
|
mp_raise_NotImplementedError_varg(MP_ERROR_TEXT("%q"), MP_QSTR_preserve_dios);
|
||||||
}
|
}
|
||||||
_setup_sleep_alarms(true, n_alarms, alarms);
|
_setup_sleep_alarms(true, n_alarms, alarms);
|
||||||
}
|
}
|
||||||
|
@ -235,9 +235,9 @@ static void pinalarm_set_alarms_light(size_t n_alarms, const mp_obj_t *alarms) {
|
|||||||
case PINALARM_ERR_NOEXTINT:
|
case PINALARM_ERR_NOEXTINT:
|
||||||
raise_ValueError_invalid_pin();
|
raise_ValueError_invalid_pin();
|
||||||
case PINALARM_ERR_NOCHANNEL:
|
case PINALARM_ERR_NOCHANNEL:
|
||||||
mp_raise_RuntimeError(translate("A hardware interrupt channel is already in use"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("A hardware interrupt channel is already in use"));
|
||||||
default:
|
default:
|
||||||
mp_raise_RuntimeError(translate("Unknown reason."));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("Unknown reason."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ void alarm_time_timealarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (timealarm_set) {
|
if (timealarm_set) {
|
||||||
mp_raise_ValueError(translate("Only one alarm.time alarm can be set"));
|
mp_raise_ValueError(MP_ERROR_TEXT("Only one alarm.time alarm can be set"));
|
||||||
}
|
}
|
||||||
timealarm = MP_OBJ_TO_PTR(alarms[i]);
|
timealarm = MP_OBJ_TO_PTR(alarms[i]);
|
||||||
timealarm_set = true;
|
timealarm_set = true;
|
||||||
|
@ -28,5 +28,5 @@
|
|||||||
#include "shared-bindings/microcontroller/__init__.h"
|
#include "shared-bindings/microcontroller/__init__.h"
|
||||||
|
|
||||||
void common_hal_alarm_touch_touchalarm_construct(alarm_touch_touchalarm_obj_t *self, const mcu_pin_obj_t *pin) {
|
void common_hal_alarm_touch_touchalarm_construct(alarm_touch_touchalarm_obj_t *self, const mcu_pin_obj_t *pin) {
|
||||||
mp_raise_NotImplementedError(translate("Touch alarms not available"));
|
mp_raise_NotImplementedError(MP_ERROR_TEXT("Touch alarms not available"));
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@
|
|||||||
void common_hal_analogio_analogout_construct(analogio_analogout_obj_t *self,
|
void common_hal_analogio_analogout_construct(analogio_analogout_obj_t *self,
|
||||||
const mcu_pin_obj_t *pin) {
|
const mcu_pin_obj_t *pin) {
|
||||||
#if !HAVE_ANALOGOUT
|
#if !HAVE_ANALOGOUT
|
||||||
mp_raise_NotImplementedError(translate("No DAC on chip"));
|
mp_raise_NotImplementedError(MP_ERROR_TEXT("No DAC on chip"));
|
||||||
#else
|
#else
|
||||||
|
|
||||||
uint8_t channel;
|
uint8_t channel;
|
||||||
|
@ -99,7 +99,7 @@ void common_hal_audiobusio_i2sout_construct(audiobusio_i2sout_obj_t *self,
|
|||||||
const mcu_pin_obj_t *bit_clock, const mcu_pin_obj_t *word_select,
|
const mcu_pin_obj_t *bit_clock, const mcu_pin_obj_t *word_select,
|
||||||
const mcu_pin_obj_t *data, const mcu_pin_obj_t *main_clock, bool left_justified) {
|
const mcu_pin_obj_t *data, const mcu_pin_obj_t *main_clock, bool left_justified) {
|
||||||
if (main_clock != NULL) {
|
if (main_clock != NULL) {
|
||||||
mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_main_clock);
|
mp_raise_NotImplementedError_varg(MP_ERROR_TEXT("%q"), MP_QSTR_main_clock);
|
||||||
}
|
}
|
||||||
uint8_t serializer = 0xff;
|
uint8_t serializer = 0xff;
|
||||||
uint8_t bc_clock_unit = 0xff;
|
uint8_t bc_clock_unit = 0xff;
|
||||||
@ -159,7 +159,7 @@ void common_hal_audiobusio_i2sout_construct(audiobusio_i2sout_obj_t *self,
|
|||||||
raise_ValueError_invalid_pin_name(MP_QSTR_word_select);
|
raise_ValueError_invalid_pin_name(MP_QSTR_word_select);
|
||||||
}
|
}
|
||||||
if (bc_clock_unit != ws_clock_unit) {
|
if (bc_clock_unit != ws_clock_unit) {
|
||||||
mp_raise_ValueError(translate("Bit clock and word select must share a clock unit"));
|
mp_raise_ValueError(MP_ERROR_TEXT("Bit clock and word select must share a clock unit"));
|
||||||
}
|
}
|
||||||
if (serializer == 0xff) {
|
if (serializer == 0xff) {
|
||||||
raise_ValueError_invalid_pin_name(MP_QSTR_data);
|
raise_ValueError_invalid_pin_name(MP_QSTR_data);
|
||||||
@ -176,12 +176,12 @@ void common_hal_audiobusio_i2sout_construct(audiobusio_i2sout_obj_t *self,
|
|||||||
} else {
|
} else {
|
||||||
#ifdef SAMD21
|
#ifdef SAMD21
|
||||||
if ((I2S->CTRLA.vec.SEREN & (1 << serializer)) != 0) {
|
if ((I2S->CTRLA.vec.SEREN & (1 << serializer)) != 0) {
|
||||||
mp_raise_RuntimeError(translate("Serializer in use"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("Serializer in use"));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef SAM_D5X_E5X
|
#ifdef SAM_D5X_E5X
|
||||||
if (I2S->CTRLA.bit.TXEN == 1) {
|
if (I2S->CTRLA.bit.TXEN == 1) {
|
||||||
mp_raise_RuntimeError(translate("Serializer in use"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("Serializer in use"));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -233,7 +233,7 @@ void common_hal_audiobusio_i2sout_play(audiobusio_i2sout_obj_t *self,
|
|||||||
}
|
}
|
||||||
#ifdef SAMD21
|
#ifdef SAMD21
|
||||||
if ((I2S->CTRLA.vec.CKEN & (1 << self->clock_unit)) == 1) {
|
if ((I2S->CTRLA.vec.CKEN & (1 << self->clock_unit)) == 1) {
|
||||||
mp_raise_RuntimeError(translate("Clock unit in use"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("Clock unit in use"));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
uint8_t bits_per_sample = audiosample_bits_per_sample(sample);
|
uint8_t bits_per_sample = audiosample_bits_per_sample(sample);
|
||||||
@ -243,7 +243,7 @@ void common_hal_audiobusio_i2sout_play(audiobusio_i2sout_obj_t *self,
|
|||||||
// Find a free GCLK to generate the MCLK signal.
|
// Find a free GCLK to generate the MCLK signal.
|
||||||
uint8_t gclk = find_free_gclk(divisor);
|
uint8_t gclk = find_free_gclk(divisor);
|
||||||
if (gclk > GCLK_GEN_NUM) {
|
if (gclk > GCLK_GEN_NUM) {
|
||||||
mp_raise_RuntimeError(translate("Unable to find free GCLK"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("Unable to find free GCLK"));
|
||||||
}
|
}
|
||||||
self->gclk = gclk;
|
self->gclk = gclk;
|
||||||
|
|
||||||
@ -257,7 +257,7 @@ void common_hal_audiobusio_i2sout_play(audiobusio_i2sout_obj_t *self,
|
|||||||
}
|
}
|
||||||
uint8_t channel_count = audiosample_channel_count(sample);
|
uint8_t channel_count = audiosample_channel_count(sample);
|
||||||
if (channel_count > 2) {
|
if (channel_count > 2) {
|
||||||
mp_raise_ValueError(translate("Too many channels in sample"));
|
mp_raise_ValueError(MP_ERROR_TEXT("Too many channels in sample"));
|
||||||
}
|
}
|
||||||
#ifdef SAMD21
|
#ifdef SAMD21
|
||||||
uint32_t serctrl = (self->clock_unit << I2S_SERCTRL_CLKSEL_Pos) | SERCTRL(SERMODE_TX) | I2S_SERCTRL_TXSAME_SAME | I2S_SERCTRL_EXTEND_MSBIT | I2S_SERCTRL_TXDEFAULT_ONE | I2S_SERCTRL_SLOTADJ_LEFT;
|
uint32_t serctrl = (self->clock_unit << I2S_SERCTRL_CLKSEL_Pos) | SERCTRL(SERMODE_TX) | I2S_SERCTRL_TXSAME_SAME | I2S_SERCTRL_EXTEND_MSBIT | I2S_SERCTRL_TXDEFAULT_ONE | I2S_SERCTRL_SLOTADJ_LEFT;
|
||||||
@ -308,10 +308,10 @@ void common_hal_audiobusio_i2sout_play(audiobusio_i2sout_obj_t *self,
|
|||||||
|
|
||||||
if (result == AUDIO_DMA_DMA_BUSY) {
|
if (result == AUDIO_DMA_DMA_BUSY) {
|
||||||
common_hal_audiobusio_i2sout_stop(self);
|
common_hal_audiobusio_i2sout_stop(self);
|
||||||
mp_raise_RuntimeError(translate("No DMA channel found"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("No DMA channel found"));
|
||||||
} else if (result == AUDIO_DMA_MEMORY_ERROR) {
|
} else if (result == AUDIO_DMA_MEMORY_ERROR) {
|
||||||
common_hal_audiobusio_i2sout_stop(self);
|
common_hal_audiobusio_i2sout_stop(self);
|
||||||
mp_raise_RuntimeError(translate("Unable to allocate buffers for signed conversion"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("Unable to allocate buffers for signed conversion"));
|
||||||
}
|
}
|
||||||
|
|
||||||
I2S->INTFLAG.reg = I2S_INTFLAG_TXUR0 | I2S_INTFLAG_TXUR1;
|
I2S->INTFLAG.reg = I2S_INTFLAG_TXUR0 | I2S_INTFLAG_TXUR1;
|
||||||
|
@ -157,7 +157,7 @@ void common_hal_audiobusio_pdmin_construct(audiobusio_pdmin_obj_t *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!(bit_depth == 16 || bit_depth == 8) || !mono || oversample != OVERSAMPLING) {
|
if (!(bit_depth == 16 || bit_depth == 8) || !mono || oversample != OVERSAMPLING) {
|
||||||
mp_raise_NotImplementedError(translate("Only 8 or 16 bit mono with " MP_STRINGIFY(OVERSAMPLING) "x oversampling is supported."));
|
mp_raise_NotImplementedError(MP_ERROR_TEXT("Only 8 or 16 bit mono with " MP_STRINGIFY(OVERSAMPLING) "x oversampling is supported."));
|
||||||
}
|
}
|
||||||
|
|
||||||
turn_on_i2s();
|
turn_on_i2s();
|
||||||
@ -169,12 +169,12 @@ void common_hal_audiobusio_pdmin_construct(audiobusio_pdmin_obj_t *self,
|
|||||||
} else {
|
} else {
|
||||||
#ifdef SAMD21
|
#ifdef SAMD21
|
||||||
if ((I2S->CTRLA.vec.SEREN & (1 << self->serializer)) != 0) {
|
if ((I2S->CTRLA.vec.SEREN & (1 << self->serializer)) != 0) {
|
||||||
mp_raise_RuntimeError(translate("Serializer in use"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("Serializer in use"));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef SAM_D5X_E5X
|
#ifdef SAM_D5X_E5X
|
||||||
if (I2S->CTRLA.bit.RXEN == 1) {
|
if (I2S->CTRLA.bit.RXEN == 1) {
|
||||||
mp_raise_RuntimeError(translate("Serializer in use"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("Serializer in use"));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -189,12 +189,12 @@ void common_hal_audiobusio_pdmin_construct(audiobusio_pdmin_obj_t *self,
|
|||||||
float mic_clock_freq = 48000000.0f / clock_divisor;
|
float mic_clock_freq = 48000000.0f / clock_divisor;
|
||||||
self->sample_rate = mic_clock_freq / oversample;
|
self->sample_rate = mic_clock_freq / oversample;
|
||||||
if (mic_clock_freq < MIN_MIC_CLOCK || clock_divisor == 0) {
|
if (mic_clock_freq < MIN_MIC_CLOCK || clock_divisor == 0) {
|
||||||
mp_raise_ValueError(translate("sampling rate out of range"));
|
mp_raise_ValueError(MP_ERROR_TEXT("sampling rate out of range"));
|
||||||
}
|
}
|
||||||
// Find a free GCLK to generate the MCLK signal.
|
// Find a free GCLK to generate the MCLK signal.
|
||||||
uint8_t gclk = find_free_gclk(clock_divisor);
|
uint8_t gclk = find_free_gclk(clock_divisor);
|
||||||
if (gclk > GCLK_GEN_NUM) {
|
if (gclk > GCLK_GEN_NUM) {
|
||||||
mp_raise_RuntimeError(translate("Unable to find free GCLK"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("Unable to find free GCLK"));
|
||||||
}
|
}
|
||||||
self->gclk = gclk;
|
self->gclk = gclk;
|
||||||
|
|
||||||
|
@ -128,11 +128,11 @@ void common_hal_audioio_audioout_construct(audioio_audioout_obj_t *self,
|
|||||||
#endif
|
#endif
|
||||||
// Only support exclusive use of the DAC.
|
// Only support exclusive use of the DAC.
|
||||||
if (dac_clock_enabled && DAC->CTRLA.bit.ENABLE == 1) {
|
if (dac_clock_enabled && DAC->CTRLA.bit.ENABLE == 1) {
|
||||||
mp_raise_RuntimeError(translate("DAC already in use"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("DAC already in use"));
|
||||||
}
|
}
|
||||||
#ifdef SAMD21
|
#ifdef SAMD21
|
||||||
if (right_channel != NULL) {
|
if (right_channel != NULL) {
|
||||||
mp_raise_ValueError(translate("Right channel unsupported"));
|
mp_raise_ValueError(MP_ERROR_TEXT("Right channel unsupported"));
|
||||||
}
|
}
|
||||||
if (left_channel != &pin_PA02) {
|
if (left_channel != &pin_PA02) {
|
||||||
raise_ValueError_invalid_pin();
|
raise_ValueError_invalid_pin();
|
||||||
@ -148,7 +148,7 @@ void common_hal_audioio_audioout_construct(audioio_audioout_obj_t *self,
|
|||||||
raise_ValueError_invalid_pin_name(MP_QSTR_right_channel);
|
raise_ValueError_invalid_pin_name(MP_QSTR_right_channel);
|
||||||
}
|
}
|
||||||
if (right_channel == left_channel) {
|
if (right_channel == left_channel) {
|
||||||
mp_raise_ValueError_varg(translate("%q and %q must be different"),
|
mp_raise_ValueError_varg(MP_ERROR_TEXT("%q and %q must be different"),
|
||||||
MP_QSTR_left_channel, MP_QSTR_right_channel);
|
MP_QSTR_left_channel, MP_QSTR_right_channel);
|
||||||
}
|
}
|
||||||
claim_pin(left_channel);
|
claim_pin(left_channel);
|
||||||
@ -243,7 +243,7 @@ void common_hal_audioio_audioout_construct(audioio_audioout_obj_t *self,
|
|||||||
}
|
}
|
||||||
if (t == NULL) {
|
if (t == NULL) {
|
||||||
common_hal_audioio_audioout_deinit(self);
|
common_hal_audioio_audioout_deinit(self);
|
||||||
mp_raise_RuntimeError(translate("All timers in use"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("All timers in use"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self->tc_index = tc_index;
|
self->tc_index = tc_index;
|
||||||
@ -286,7 +286,7 @@ void common_hal_audioio_audioout_construct(audioio_audioout_obj_t *self,
|
|||||||
// path.
|
// path.
|
||||||
uint8_t channel = find_async_event_channel();
|
uint8_t channel = find_async_event_channel();
|
||||||
if (channel >= EVSYS_CHANNELS) {
|
if (channel >= EVSYS_CHANNELS) {
|
||||||
mp_raise_RuntimeError(translate("All event channels in use"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("All event channels in use"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SAM_D5X_E5X
|
#ifdef SAM_D5X_E5X
|
||||||
@ -438,9 +438,9 @@ void common_hal_audioio_audioout_play(audioio_audioout_obj_t *self,
|
|||||||
audio_dma_stop(&self->right_dma);
|
audio_dma_stop(&self->right_dma);
|
||||||
#endif
|
#endif
|
||||||
if (result == AUDIO_DMA_DMA_BUSY) {
|
if (result == AUDIO_DMA_DMA_BUSY) {
|
||||||
mp_raise_RuntimeError(translate("No DMA channel found"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("No DMA channel found"));
|
||||||
} else if (result == AUDIO_DMA_MEMORY_ERROR) {
|
} else if (result == AUDIO_DMA_MEMORY_ERROR) {
|
||||||
mp_raise_RuntimeError(translate("Unable to allocate buffers for signed conversion"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("Unable to allocate buffers for signed conversion"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Tc *timer = tc_insts[self->tc_index];
|
Tc *timer = tc_insts[self->tc_index];
|
||||||
|
@ -100,7 +100,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
|
|||||||
if (!gpio_get_pin_level(sda->number) || !gpio_get_pin_level(scl->number)) {
|
if (!gpio_get_pin_level(sda->number) || !gpio_get_pin_level(scl->number)) {
|
||||||
reset_pin_number(sda->number);
|
reset_pin_number(sda->number);
|
||||||
reset_pin_number(scl->number);
|
reset_pin_number(scl->number);
|
||||||
mp_raise_RuntimeError(translate("No pull up found on SDA or SCL; check your wiring"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("No pull up found on SDA or SCL; check your wiring"));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
|
|||||||
uint8_t dopo = 255;
|
uint8_t dopo = 255;
|
||||||
|
|
||||||
if (half_duplex) {
|
if (half_duplex) {
|
||||||
mp_raise_NotImplementedError(translate("Half duplex SPI is not implemented"));
|
mp_raise_NotImplementedError(MP_ERROR_TEXT("Half duplex SPI is not implemented"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure the object starts in its deinit state.
|
// Ensure the object starts in its deinit state.
|
||||||
|
@ -83,7 +83,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||||||
self->cts_pin = NO_PIN;
|
self->cts_pin = NO_PIN;
|
||||||
|
|
||||||
if ((rs485_dir != NULL) || (rs485_invert)) {
|
if ((rs485_dir != NULL) || (rs485_invert)) {
|
||||||
mp_raise_NotImplementedError(translate("RS485"));
|
mp_raise_NotImplementedError(MP_ERROR_TEXT("RS485"));
|
||||||
}
|
}
|
||||||
|
|
||||||
mp_arg_validate_int_max(bits, 8, MP_QSTR_bits);
|
mp_arg_validate_int_max(bits, 8, MP_QSTR_bits);
|
||||||
@ -94,7 +94,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||||||
bool have_cts = cts != NULL;
|
bool have_cts = cts != NULL;
|
||||||
|
|
||||||
if (have_rx && receiver_buffer_size > 0 && (receiver_buffer_size & (receiver_buffer_size - 1)) != 0) {
|
if (have_rx && receiver_buffer_size > 0 && (receiver_buffer_size & (receiver_buffer_size - 1)) != 0) {
|
||||||
mp_raise_ValueError_varg(translate("%q must be power of 2"), MP_QSTR_receiver_buffer_size);
|
mp_raise_ValueError_varg(MP_ERROR_TEXT("%q must be power of 2"), MP_QSTR_receiver_buffer_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
self->baudrate = baudrate;
|
self->baudrate = baudrate;
|
||||||
@ -388,7 +388,7 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) {
|
|||||||
// Read characters.
|
// Read characters.
|
||||||
size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t len, int *errcode) {
|
size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t len, int *errcode) {
|
||||||
if (self->rx_pin == NO_PIN) {
|
if (self->rx_pin == NO_PIN) {
|
||||||
mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_rx);
|
mp_raise_ValueError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_rx);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This assignment is only here because the usart_async routines take a *const argument.
|
// This assignment is only here because the usart_async routines take a *const argument.
|
||||||
@ -445,7 +445,7 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t
|
|||||||
// Write characters.
|
// Write characters.
|
||||||
size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) {
|
size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) {
|
||||||
if (self->tx_pin == NO_PIN) {
|
if (self->tx_pin == NO_PIN) {
|
||||||
mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_tx);
|
mp_raise_ValueError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_tx);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This assignment is only here because the usart_async routines take a *const argument.
|
// This assignment is only here because the usart_async routines take a *const argument.
|
||||||
|
@ -306,24 +306,24 @@ void common_hal_canio_listener_construct(canio_listener_obj_t *self, canio_can_o
|
|||||||
can->fifo1_in_use = true;
|
can->fifo1_in_use = true;
|
||||||
can->hw->IR.reg = CAN_IR_RF1N | CAN_IR_RF1W | CAN_IR_RF1F | CAN_IR_RF1L;
|
can->hw->IR.reg = CAN_IR_RF1N | CAN_IR_RF1W | CAN_IR_RF1F | CAN_IR_RF1L;
|
||||||
} else {
|
} else {
|
||||||
mp_raise_ValueError(translate("All RX FIFOs in use"));
|
mp_raise_ValueError(MP_ERROR_TEXT("All RX FIFOs in use"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!nmatch) {
|
if (!nmatch) {
|
||||||
if (can->hw->GFC.bit.ANFS == CAN_GFC_ANFS_RXF1_Val - self->fifo_idx) {
|
if (can->hw->GFC.bit.ANFS == CAN_GFC_ANFS_RXF1_Val - self->fifo_idx) {
|
||||||
mp_raise_ValueError(translate("Already have all-matches listener"));
|
mp_raise_ValueError(MP_ERROR_TEXT("Already have all-matches listener"));
|
||||||
}
|
}
|
||||||
if (can->hw->GFC.bit.ANFE == CAN_GFC_ANFE_RXF1_Val - self->fifo_idx) {
|
if (can->hw->GFC.bit.ANFE == CAN_GFC_ANFE_RXF1_Val - self->fifo_idx) {
|
||||||
mp_raise_ValueError(translate("Already have all-matches listener"));
|
mp_raise_ValueError(MP_ERROR_TEXT("Already have all-matches listener"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (num_filters_needed(nmatch, matches, false) > num_filters_available(can, false)) {
|
if (num_filters_needed(nmatch, matches, false) > num_filters_available(can, false)) {
|
||||||
mp_raise_ValueError(translate("Filters too complex"));
|
mp_raise_ValueError(MP_ERROR_TEXT("Filters too complex"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (num_filters_needed(nmatch, matches, true) > num_filters_available(can, true)) {
|
if (num_filters_needed(nmatch, matches, true) > num_filters_available(can, true)) {
|
||||||
mp_raise_ValueError(translate("Filters too complex"));
|
mp_raise_ValueError(MP_ERROR_TEXT("Filters too complex"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nothing can fail now so it's safe to assign self->can
|
// Nothing can fail now so it's safe to assign self->can
|
||||||
|
@ -11,13 +11,13 @@
|
|||||||
void common_hal_countio_counter_construct(countio_counter_obj_t *self,
|
void common_hal_countio_counter_construct(countio_counter_obj_t *self,
|
||||||
const mcu_pin_obj_t *pin, countio_edge_t edge, digitalio_pull_t pull) {
|
const mcu_pin_obj_t *pin, countio_edge_t edge, digitalio_pull_t pull) {
|
||||||
if (!pin->has_extint) {
|
if (!pin->has_extint) {
|
||||||
mp_raise_RuntimeError(translate("Pin must support hardware interrupts"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("Pin must support hardware interrupts"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (eic_get_enable()) {
|
if (eic_get_enable()) {
|
||||||
if (!eic_channel_free(pin->extint_channel)) {
|
if (!eic_channel_free(pin->extint_channel)) {
|
||||||
mp_raise_RuntimeError(translate("A hardware interrupt channel is already in use"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("A hardware interrupt channel is already in use"));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
turn_on_external_interrupt_controller();
|
turn_on_external_interrupt_controller();
|
||||||
|
@ -175,7 +175,7 @@ digitalio_pull_t common_hal_digitalio_digitalinout_get_pull(
|
|||||||
digitalio_digitalinout_obj_t *self) {
|
digitalio_digitalinout_obj_t *self) {
|
||||||
uint32_t pin = self->pin->number;
|
uint32_t pin = self->pin->number;
|
||||||
if (self->output) {
|
if (self->output) {
|
||||||
mp_raise_AttributeError(translate("Cannot get pull while in output mode"));
|
mp_raise_AttributeError(MP_ERROR_TEXT("Cannot get pull while in output mode"));
|
||||||
return PULL_NONE;
|
return PULL_NONE;
|
||||||
} else {
|
} else {
|
||||||
if (hri_port_get_PINCFG_PULLEN_bit(PORT, GPIO_PORT(pin), GPIO_PIN(pin)) == 0) {
|
if (hri_port_get_PINCFG_PULLEN_bit(PORT, GPIO_PORT(pin), GPIO_PIN(pin)) == 0) {
|
||||||
|
@ -295,12 +295,12 @@ void common_hal_frequencyio_frequencyin_construct(frequencyio_frequencyin_obj_t*
|
|||||||
#ifdef SAM_D5X_E5X
|
#ifdef SAM_D5X_E5X
|
||||||
((EIC->INTENSET.bit.EXTINT & mask) != 0 || (EIC->EVCTRL.bit.EXTINTEO & mask) != 0)) {
|
((EIC->INTENSET.bit.EXTINT & mask) != 0 || (EIC->EVCTRL.bit.EXTINTEO & mask) != 0)) {
|
||||||
#endif
|
#endif
|
||||||
mp_raise_RuntimeError(translate("EXTINT channel already in use"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("EXTINT channel already in use"));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t timer_index = find_free_timer();
|
uint8_t timer_index = find_free_timer();
|
||||||
if (timer_index == 0xff) {
|
if (timer_index == 0xff) {
|
||||||
mp_raise_RuntimeError(translate("All timers in use"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("All timers in use"));
|
||||||
}
|
}
|
||||||
Tc *tc = tc_insts[timer_index];
|
Tc *tc = tc_insts[timer_index];
|
||||||
|
|
||||||
@ -329,7 +329,7 @@ void common_hal_frequencyio_frequencyin_construct(frequencyio_frequencyin_obj_t*
|
|||||||
frequencyin_samd51_start_dpll();
|
frequencyin_samd51_start_dpll();
|
||||||
if (dpll_gclk == 0xff && !clock_get_enabled(0, GCLK_SOURCE_DPLL1)) {
|
if (dpll_gclk == 0xff && !clock_get_enabled(0, GCLK_SOURCE_DPLL1)) {
|
||||||
common_hal_frequencyio_frequencyin_deinit(self);
|
common_hal_frequencyio_frequencyin_deinit(self);
|
||||||
mp_raise_RuntimeError(translate("No available clocks"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("No available clocks"));
|
||||||
}
|
}
|
||||||
set_timer_handler(timer_index, dpll_gclk, TC_HANDLER_NO_INTERRUPT);
|
set_timer_handler(timer_index, dpll_gclk, TC_HANDLER_NO_INTERRUPT);
|
||||||
turn_on_clocks(true, timer_index, dpll_gclk);
|
turn_on_clocks(true, timer_index, dpll_gclk);
|
||||||
@ -399,7 +399,7 @@ void common_hal_frequencyio_frequencyin_construct(frequencyio_frequencyin_obj_t*
|
|||||||
reference_tc = find_free_timer();
|
reference_tc = find_free_timer();
|
||||||
if (reference_tc == 0xff) {
|
if (reference_tc == 0xff) {
|
||||||
common_hal_frequencyio_frequencyin_deinit(self);
|
common_hal_frequencyio_frequencyin_deinit(self);
|
||||||
mp_raise_RuntimeError(translate("All timers in use"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("All timers in use"));
|
||||||
}
|
}
|
||||||
frequencyin_reference_tc_init();
|
frequencyin_reference_tc_init();
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ void common_hal_imagecapture_parallelimagecapture_construct(imagecapture_paralle
|
|||||||
|
|
||||||
for (int i = 0; i < data_count; i++) {
|
for (int i = 0; i < data_count; i++) {
|
||||||
if (data_pins[i] != PIN_PCC_D0 + i) {
|
if (data_pins[i] != PIN_PCC_D0 + i) {
|
||||||
mp_raise_ValueError_varg(translate("Invalid data_pins[%d]"), i);
|
mp_raise_ValueError_varg(MP_ERROR_TEXT("Invalid data_pins[%d]"), i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// The peripheral supports 8, 10, 12, or 14 data bits, but the code only supports 8 at present
|
// The peripheral supports 8, 10, 12, or 14 data bits, but the code only supports 8 at present
|
||||||
@ -77,7 +77,7 @@ void common_hal_imagecapture_parallelimagecapture_construct(imagecapture_paralle
|
|||||||
// technically, 0 was validated as free already but check again
|
// technically, 0 was validated as free already but check again
|
||||||
for (int i = 0; i < data_count; i++) {
|
for (int i = 0; i < data_count; i++) {
|
||||||
if (!pin_number_is_free(data_pins[i])) {
|
if (!pin_number_is_free(data_pins[i])) {
|
||||||
mp_raise_ValueError_varg(translate("data pin #%d in use"), i);
|
mp_raise_ValueError_varg(MP_ERROR_TEXT("data pin #%d in use"), i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,5 +210,5 @@ mcu_pin_function_t *mcu_find_pin_function(mcu_pin_function_t *table, const mcu_p
|
|||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mp_raise_ValueError_varg(translate("Invalid %q pin"), name);
|
mp_raise_ValueError_varg(MP_ERROR_TEXT("Invalid %q pin"), name);
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ void common_hal_mcu_enable_interrupts(void) {
|
|||||||
void common_hal_mcu_on_next_reset(mcu_runmode_t runmode) {
|
void common_hal_mcu_on_next_reset(mcu_runmode_t runmode) {
|
||||||
if ((runmode == RUNMODE_BOOTLOADER) || (runmode == RUNMODE_UF2)) {
|
if ((runmode == RUNMODE_BOOTLOADER) || (runmode == RUNMODE_UF2)) {
|
||||||
if (!bootloader_available()) {
|
if (!bootloader_available()) {
|
||||||
mp_raise_ValueError(translate("Cannot reset into bootloader because no bootloader is present"));
|
mp_raise_ValueError(MP_ERROR_TEXT("Cannot reset into bootloader because no bootloader is present"));
|
||||||
}
|
}
|
||||||
// Pretend to be the first of the two reset presses needed to enter the
|
// Pretend to be the first of the two reset presses needed to enter the
|
||||||
// bootloader. That way one reset will end in the bootloader.
|
// bootloader. That way one reset will end in the bootloader.
|
||||||
|
@ -39,11 +39,11 @@ void common_hal_paralleldisplaybus_parallelbus_construct(paralleldisplaybus_para
|
|||||||
|
|
||||||
uint8_t data_pin = data0->number;
|
uint8_t data_pin = data0->number;
|
||||||
if (data_pin % 8 != 0) {
|
if (data_pin % 8 != 0) {
|
||||||
mp_raise_ValueError(translate("Data 0 pin must be byte aligned"));
|
mp_raise_ValueError(MP_ERROR_TEXT("Data 0 pin must be byte aligned"));
|
||||||
}
|
}
|
||||||
for (uint8_t i = 0; i < 8; i++) {
|
for (uint8_t i = 0; i < 8; i++) {
|
||||||
if (!pin_number_is_free(data_pin + i)) {
|
if (!pin_number_is_free(data_pin + i)) {
|
||||||
mp_raise_ValueError_varg(translate("Bus pin %d is already in use"), i);
|
mp_raise_ValueError_varg(MP_ERROR_TEXT("Bus pin %d is already in use"), i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PortGroup *const g = &PORT->Group[data0->number / 32];
|
PortGroup *const g = &PORT->Group[data0->number / 32];
|
||||||
|
@ -248,7 +248,7 @@ void common_hal_ps2io_ps2_construct(ps2io_ps2_obj_t *self,
|
|||||||
mp_arg_error_invalid(MP_QSTR_clock_pin);
|
mp_arg_error_invalid(MP_QSTR_clock_pin);
|
||||||
}
|
}
|
||||||
if (eic_get_enable() && !eic_channel_free(clock_pin->extint_channel)) {
|
if (eic_get_enable() && !eic_channel_free(clock_pin->extint_channel)) {
|
||||||
mp_raise_RuntimeError(translate("EXTINT channel already in use"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("EXTINT channel already in use"));
|
||||||
}
|
}
|
||||||
|
|
||||||
clk_hi(self);
|
clk_hi(self);
|
||||||
|
@ -155,7 +155,7 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t *self,
|
|||||||
raise_ValueError_invalid_pin();
|
raise_ValueError_invalid_pin();
|
||||||
}
|
}
|
||||||
if (eic_get_enable() && !eic_channel_free(pin->extint_channel)) {
|
if (eic_get_enable() && !eic_channel_free(pin->extint_channel)) {
|
||||||
mp_raise_RuntimeError(translate("EXTINT channel already in use"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("EXTINT channel already in use"));
|
||||||
}
|
}
|
||||||
|
|
||||||
self->buffer = (uint16_t *)m_malloc(maxlen * sizeof(uint16_t));
|
self->buffer = (uint16_t *)m_malloc(maxlen * sizeof(uint16_t));
|
||||||
@ -182,7 +182,7 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t *self,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (tc == NULL) {
|
if (tc == NULL) {
|
||||||
mp_raise_RuntimeError(translate("All timers in use"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("All timers in use"));
|
||||||
}
|
}
|
||||||
|
|
||||||
pulsein_tc_index = index;
|
pulsein_tc_index = index;
|
||||||
@ -317,11 +317,11 @@ void common_hal_pulseio_pulsein_clear(pulseio_pulsein_obj_t *self) {
|
|||||||
|
|
||||||
uint16_t common_hal_pulseio_pulsein_popleft(pulseio_pulsein_obj_t *self) {
|
uint16_t common_hal_pulseio_pulsein_popleft(pulseio_pulsein_obj_t *self) {
|
||||||
if (self->len == 0) {
|
if (self->len == 0) {
|
||||||
mp_raise_IndexError_varg(translate("pop from empty %q"), MP_QSTR_PulseIn);
|
mp_raise_IndexError_varg(MP_ERROR_TEXT("pop from empty %q"), MP_QSTR_PulseIn);
|
||||||
}
|
}
|
||||||
if (self->errored_too_fast) {
|
if (self->errored_too_fast) {
|
||||||
self->errored_too_fast = 0;
|
self->errored_too_fast = 0;
|
||||||
mp_raise_RuntimeError(translate("Input taking too long"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("Input taking too long"));
|
||||||
}
|
}
|
||||||
common_hal_mcu_disable_interrupts();
|
common_hal_mcu_disable_interrupts();
|
||||||
uint16_t value = self->buffer[self->start];
|
uint16_t value = self->buffer[self->start];
|
||||||
@ -352,7 +352,7 @@ uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t *self, int16_
|
|||||||
if (index < 0 || index >= self->len) {
|
if (index < 0 || index >= self->len) {
|
||||||
common_hal_mcu_enable_interrupts();
|
common_hal_mcu_enable_interrupts();
|
||||||
// Can't use mp_arg_validate_index_range() here due to the critical section.
|
// Can't use mp_arg_validate_index_range() here due to the critical section.
|
||||||
mp_raise_IndexError_varg(translate("%q out of range"), MP_QSTR_index);
|
mp_raise_IndexError_varg(MP_ERROR_TEXT("%q out of range"), MP_QSTR_index);
|
||||||
}
|
}
|
||||||
uint16_t value = self->buffer[(self->start + index) % self->maxlen];
|
uint16_t value = self->buffer[(self->start + index) % self->maxlen];
|
||||||
common_hal_mcu_enable_interrupts();
|
common_hal_mcu_enable_interrupts();
|
||||||
|
@ -123,7 +123,7 @@ void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t *self,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (tc == NULL) {
|
if (tc == NULL) {
|
||||||
mp_raise_RuntimeError(translate("All timers in use"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("All timers in use"));
|
||||||
}
|
}
|
||||||
|
|
||||||
pulseout_tc_index = index;
|
pulseout_tc_index = index;
|
||||||
@ -200,7 +200,7 @@ void common_hal_pulseio_pulseout_deinit(pulseio_pulseout_obj_t *self) {
|
|||||||
|
|
||||||
void common_hal_pulseio_pulseout_send(pulseio_pulseout_obj_t *self, uint16_t *pulses, uint16_t length) {
|
void common_hal_pulseio_pulseout_send(pulseio_pulseout_obj_t *self, uint16_t *pulses, uint16_t length) {
|
||||||
if (active_pincfg != NULL) {
|
if (active_pincfg != NULL) {
|
||||||
mp_raise_RuntimeError(translate("Another send is already active"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("Another send is already active"));
|
||||||
}
|
}
|
||||||
active_pincfg = self->pincfg;
|
active_pincfg = self->pincfg;
|
||||||
pulse_buffer = pulses;
|
pulse_buffer = pulses;
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
void common_hal_rotaryio_incrementalencoder_construct(rotaryio_incrementalencoder_obj_t *self,
|
void common_hal_rotaryio_incrementalencoder_construct(rotaryio_incrementalencoder_obj_t *self,
|
||||||
const mcu_pin_obj_t *pin_a, const mcu_pin_obj_t *pin_b) {
|
const mcu_pin_obj_t *pin_a, const mcu_pin_obj_t *pin_b) {
|
||||||
if (!pin_a->has_extint || !pin_b->has_extint) {
|
if (!pin_a->has_extint || !pin_b->has_extint) {
|
||||||
mp_raise_RuntimeError(translate("Both pins must support hardware interrupts"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("Both pins must support hardware interrupts"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: The SAMD51 has a peripheral dedicated to quadrature encoder debugging. Use it instead
|
// TODO: The SAMD51 has a peripheral dedicated to quadrature encoder debugging. Use it instead
|
||||||
@ -45,7 +45,7 @@ void common_hal_rotaryio_incrementalencoder_construct(rotaryio_incrementalencode
|
|||||||
|
|
||||||
if (eic_get_enable()) {
|
if (eic_get_enable()) {
|
||||||
if (!eic_channel_free(pin_a->extint_channel) || !eic_channel_free(pin_b->extint_channel)) {
|
if (!eic_channel_free(pin_a->extint_channel) || !eic_channel_free(pin_b->extint_channel)) {
|
||||||
mp_raise_RuntimeError(translate("A hardware interrupt channel is already in use"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("A hardware interrupt channel is already in use"));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
turn_on_external_interrupt_controller();
|
turn_on_external_interrupt_controller();
|
||||||
|
@ -148,7 +148,7 @@ CLK PA21 PCC_D? (D32) BROWN
|
|||||||
}
|
}
|
||||||
reset_pin_number(functions[i]->obj->number);
|
reset_pin_number(functions[i]->obj->number);
|
||||||
}
|
}
|
||||||
mp_raise_OSError_msg_varg(translate("%q failure: %d"), MP_QSTR_sd_mmc_check, (int)result);
|
mp_raise_OSError_msg_varg(MP_ERROR_TEXT("%q failure: %d"), MP_QSTR_sd_mmc_check, (int)result);
|
||||||
}
|
}
|
||||||
// sd_mmc_get_capacity() is in KiB, but our "capacity" is in 512-byte blocks
|
// sd_mmc_get_capacity() is in KiB, but our "capacity" is in 512-byte blocks
|
||||||
self->capacity = sd_mmc_get_capacity(0) * 2;
|
self->capacity = sd_mmc_get_capacity(0) * 2;
|
||||||
@ -173,7 +173,7 @@ STATIC void check_for_deinit(sdioio_sdcard_obj_t *self) {
|
|||||||
|
|
||||||
STATIC void check_whole_block(mp_buffer_info_t *bufinfo) {
|
STATIC void check_whole_block(mp_buffer_info_t *bufinfo) {
|
||||||
if (bufinfo->len % 512) {
|
if (bufinfo->len % 512) {
|
||||||
mp_raise_ValueError(translate("Buffer length must be a multiple of 512"));
|
mp_raise_ValueError(MP_ERROR_TEXT("Buffer length must be a multiple of 512"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ void common_hal_touchio_touchin_construct(touchio_touchin_obj_t *self,
|
|||||||
// We run the PTC at 8mhz so divide the 48mhz clock by 6.
|
// We run the PTC at 8mhz so divide the 48mhz clock by 6.
|
||||||
uint8_t gclk = find_free_gclk(6);
|
uint8_t gclk = find_free_gclk(6);
|
||||||
if (gclk > GCLK_GEN_NUM) {
|
if (gclk > GCLK_GEN_NUM) {
|
||||||
mp_raise_RuntimeError(translate("No free GCLKs"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("No free GCLKs"));
|
||||||
}
|
}
|
||||||
enable_clock_generator(gclk, CLOCK_48MHZ, 6);
|
enable_clock_generator(gclk, CLOCK_48MHZ, 6);
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
|
|||||||
BP_Function_Enum miso_alt = 0;
|
BP_Function_Enum miso_alt = 0;
|
||||||
|
|
||||||
if (half_duplex) {
|
if (half_duplex) {
|
||||||
mp_raise_NotImplementedError(translate("Half duplex SPI is not implemented"));
|
mp_raise_NotImplementedError(MP_ERROR_TEXT("Half duplex SPI is not implemented"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// BCM_VERSION != 2711 have 3 SPI but as listed in peripherals/gen/pins.c two are on
|
// BCM_VERSION != 2711 have 3 SPI but as listed in peripherals/gen/pins.c two are on
|
||||||
|
@ -166,7 +166,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||||||
mp_arg_validate_int_min(receiver_buffer_size, 1, MP_QSTR_receiver_buffer_size);
|
mp_arg_validate_int_min(receiver_buffer_size, 1, MP_QSTR_receiver_buffer_size);
|
||||||
|
|
||||||
if ((rs485_dir != NULL) || (rs485_invert)) {
|
if ((rs485_dir != NULL) || (rs485_invert)) {
|
||||||
mp_raise_NotImplementedError(translate("RS485 Not yet supported on this device"));
|
mp_raise_NotImplementedError(MP_ERROR_TEXT("RS485 Not yet supported on this device"));
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t instance_index = NUM_UART;
|
size_t instance_index = NUM_UART;
|
||||||
@ -346,7 +346,7 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) {
|
|||||||
// Write characters.
|
// Write characters.
|
||||||
size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) {
|
size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) {
|
||||||
if (self->tx_pin == NULL) {
|
if (self->tx_pin == NULL) {
|
||||||
mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_tx);
|
mp_raise_ValueError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_tx);
|
||||||
}
|
}
|
||||||
|
|
||||||
COMPLETE_MEMORY_READS;
|
COMPLETE_MEMORY_READS;
|
||||||
@ -394,7 +394,7 @@ STATIC void enable_interrupt(busio_uart_obj_t *self) {
|
|||||||
// Read characters.
|
// Read characters.
|
||||||
size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t len, int *errcode) {
|
size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t len, int *errcode) {
|
||||||
if (self->rx_pin == NULL) {
|
if (self->rx_pin == NULL) {
|
||||||
mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_rx);
|
mp_raise_ValueError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_rx);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
|
@ -151,7 +151,7 @@ digitalio_pull_t common_hal_digitalio_digitalinout_get_pull(
|
|||||||
digitalio_digitalinout_obj_t *self) {
|
digitalio_digitalinout_obj_t *self) {
|
||||||
uint32_t pin = self->pin->number;
|
uint32_t pin = self->pin->number;
|
||||||
if (self->output) {
|
if (self->output) {
|
||||||
mp_raise_AttributeError(translate("Cannot get pull while in output mode"));
|
mp_raise_AttributeError(MP_ERROR_TEXT("Cannot get pull while in output mode"));
|
||||||
return PULL_NONE;
|
return PULL_NONE;
|
||||||
} else {
|
} else {
|
||||||
if (gpio_get_pull(pin) == BP_PULL_UP) {
|
if (gpio_get_pull(pin) == BP_PULL_UP) {
|
||||||
|
@ -66,7 +66,7 @@ void common_hal_neopixel_write(const digitalio_digitalinout_obj_t *digitalinout,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found) {
|
if (!found) {
|
||||||
mp_raise_ValueError(translate("NeoPixel not supported on pin"));
|
mp_raise_ValueError(MP_ERROR_TEXT("NeoPixel not supported on pin"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,5 +54,5 @@ int common_hal_rtc_get_calibration(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_rtc_set_calibration(int calibration) {
|
void common_hal_rtc_set_calibration(int calibration) {
|
||||||
mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_calibration);
|
mp_raise_NotImplementedError_varg(MP_ERROR_TEXT("%q"), MP_QSTR_calibration);
|
||||||
}
|
}
|
||||||
|
@ -320,7 +320,7 @@ uint8_t common_hal_sdioio_sdcard_get_width(sdioio_sdcard_obj_t *self) {
|
|||||||
|
|
||||||
STATIC void check_whole_block(mp_buffer_info_t *bufinfo) {
|
STATIC void check_whole_block(mp_buffer_info_t *bufinfo) {
|
||||||
if (bufinfo->len % 512) {
|
if (bufinfo->len % 512) {
|
||||||
mp_raise_ValueError(translate("Buffer length must be a multiple of 512"));
|
mp_raise_ValueError(MP_ERROR_TEXT("Buffer length must be a multiple of 512"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ void common_hal_videocore_framebuffer_construct(videocore_framebuffer_obj_t *sel
|
|||||||
&bits_per_pixel);
|
&bits_per_pixel);
|
||||||
if (self->framebuffer == NULL) {
|
if (self->framebuffer == NULL) {
|
||||||
if (gc_alloc_possible()) {
|
if (gc_alloc_possible()) {
|
||||||
mp_raise_ValueError(translate("no fb"));
|
mp_raise_ValueError(MP_ERROR_TEXT("no fb"));
|
||||||
} else {
|
} else {
|
||||||
mp_printf(&mp_plat_print, "no fb\n");
|
mp_printf(&mp_plat_print, "no fb\n");
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#include "shared-bindings/analogio/AnalogOut.h"
|
#include "shared-bindings/analogio/AnalogOut.h"
|
||||||
|
|
||||||
void common_hal_analogio_analogout_construct(analogio_analogout_obj_t *self, const mcu_pin_obj_t *pin) {
|
void common_hal_analogio_analogout_construct(analogio_analogout_obj_t *self, const mcu_pin_obj_t *pin) {
|
||||||
mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_AnalogOut);
|
mp_raise_NotImplementedError_varg(MP_ERROR_TEXT("%q"), MP_QSTR_AnalogOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_analogio_analogout_deinit(analogio_analogout_obj_t *self) {
|
void common_hal_analogio_analogout_deinit(analogio_analogout_obj_t *self) {
|
||||||
|
@ -40,7 +40,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, const mcu_pin_obj_t *
|
|||||||
int port = -1;
|
int port = -1;
|
||||||
|
|
||||||
if (half_duplex) {
|
if (half_duplex) {
|
||||||
mp_raise_NotImplementedError(translate("Half duplex SPI is not implemented"));
|
mp_raise_NotImplementedError(MP_ERROR_TEXT("Half duplex SPI is not implemented"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clock->number == PIN_SPI4_SCK &&
|
if (clock->number == PIN_SPI4_SCK &&
|
||||||
|
@ -66,7 +66,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||||||
struct termios tio;
|
struct termios tio;
|
||||||
|
|
||||||
if ((rts != NULL) || (cts != NULL) || (rs485_dir != NULL) || (rs485_invert)) {
|
if ((rts != NULL) || (cts != NULL) || (rs485_dir != NULL) || (rs485_invert)) {
|
||||||
mp_raise_NotImplementedError(translate("RS485"));
|
mp_raise_NotImplementedError(MP_ERROR_TEXT("RS485"));
|
||||||
}
|
}
|
||||||
|
|
||||||
mp_arg_validate_int(bits, 8, MP_QSTR_bits);
|
mp_arg_validate_int(bits, 8, MP_QSTR_bits);
|
||||||
@ -90,7 +90,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||||||
if (busio_uart_dev[self->number].fd < 0) {
|
if (busio_uart_dev[self->number].fd < 0) {
|
||||||
busio_uart_dev[self->number].fd = open(busio_uart_dev[self->number].devpath, O_RDWR);
|
busio_uart_dev[self->number].fd = open(busio_uart_dev[self->number].devpath, O_RDWR);
|
||||||
if (busio_uart_dev[self->number].fd < 0) {
|
if (busio_uart_dev[self->number].fd < 0) {
|
||||||
mp_raise_RuntimeError(translate("UART init"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("UART init"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait to make sure the UART is ready
|
// Wait to make sure the UART is ready
|
||||||
|
@ -149,11 +149,11 @@ static void camera_start_preview() {
|
|||||||
void common_hal_camera_construct(camera_obj_t *self) {
|
void common_hal_camera_construct(camera_obj_t *self) {
|
||||||
if (camera_dev.fd < 0) {
|
if (camera_dev.fd < 0) {
|
||||||
if (video_initialize(camera_dev.devpath) < 0) {
|
if (video_initialize(camera_dev.devpath) < 0) {
|
||||||
mp_raise_RuntimeError(translate("Camera init"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("Camera init"));
|
||||||
}
|
}
|
||||||
camera_dev.fd = open(camera_dev.devpath, 0);
|
camera_dev.fd = open(camera_dev.devpath, 0);
|
||||||
if (camera_dev.fd < 0) {
|
if (camera_dev.fd < 0) {
|
||||||
mp_raise_RuntimeError(translate("Camera init"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("Camera init"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,13 +181,13 @@ bool common_hal_camera_deinited(camera_obj_t *self) {
|
|||||||
|
|
||||||
size_t common_hal_camera_take_picture(camera_obj_t *self, uint8_t *buffer, size_t len, uint16_t width, uint16_t height, camera_imageformat_t format) {
|
size_t common_hal_camera_take_picture(camera_obj_t *self, uint8_t *buffer, size_t len, uint16_t width, uint16_t height, camera_imageformat_t format) {
|
||||||
if (!camera_check_width_and_height(width, height)) {
|
if (!camera_check_width_and_height(width, height)) {
|
||||||
mp_raise_ValueError(translate("Size not supported"));
|
mp_raise_ValueError(MP_ERROR_TEXT("Size not supported"));
|
||||||
}
|
}
|
||||||
if (!camera_check_buffer_length(width, height, format, len)) {
|
if (!camera_check_buffer_length(width, height, format, len)) {
|
||||||
mp_raise_ValueError(translate("Buffer too small"));
|
mp_raise_ValueError(MP_ERROR_TEXT("Buffer too small"));
|
||||||
}
|
}
|
||||||
if (!camera_check_format(format)) {
|
if (!camera_check_format(format)) {
|
||||||
mp_raise_ValueError(translate("Format not supported"));
|
mp_raise_ValueError(MP_ERROR_TEXT("Format not supported"));
|
||||||
}
|
}
|
||||||
|
|
||||||
camera_set_format(V4L2_BUF_TYPE_STILL_CAPTURE, V4L2_PIX_FMT_JPEG, width, height);
|
camera_set_format(V4L2_BUF_TYPE_STILL_CAPTURE, V4L2_PIX_FMT_JPEG, width, height);
|
||||||
|
@ -56,7 +56,7 @@ void common_hal_gnss_construct(gnss_obj_t *self, unsigned long selection) {
|
|||||||
if (gnss_dev.fd < 0) {
|
if (gnss_dev.fd < 0) {
|
||||||
gnss_dev.fd = open(gnss_dev.devpath, O_RDONLY);
|
gnss_dev.fd = open(gnss_dev.devpath, O_RDONLY);
|
||||||
if (gnss_dev.fd < 0) {
|
if (gnss_dev.fd < 0) {
|
||||||
mp_raise_RuntimeError(translate("GNSS init"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("GNSS init"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ void common_hal_mcu_enable_interrupts(void) {
|
|||||||
|
|
||||||
void common_hal_mcu_on_next_reset(mcu_runmode_t runmode) {
|
void common_hal_mcu_on_next_reset(mcu_runmode_t runmode) {
|
||||||
if (runmode == RUNMODE_BOOTLOADER) {
|
if (runmode == RUNMODE_BOOTLOADER) {
|
||||||
mp_raise_ValueError(translate("Cannot reset into bootloader because no bootloader is present"));
|
mp_raise_ValueError(MP_ERROR_TEXT("Cannot reset into bootloader because no bootloader is present"));
|
||||||
} else if (runmode == RUNMODE_SAFE_MODE) {
|
} else if (runmode == RUNMODE_SAFE_MODE) {
|
||||||
safe_mode_on_next_reset(SAFE_MODE_PROGRAMMATIC);
|
safe_mode_on_next_reset(SAFE_MODE_PROGRAMMATIC);
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t *self,
|
|||||||
|
|
||||||
int irq = pulsein_set_config(self, true);
|
int irq = pulsein_set_config(self, true);
|
||||||
if (irq < 0) {
|
if (irq < 0) {
|
||||||
mp_raise_RuntimeError(translate("EXTINT channel already in use"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("EXTINT channel already in use"));
|
||||||
} else {
|
} else {
|
||||||
pulsein_objects[irq - CXD56_IRQ_EXDEVICE_0] = self;
|
pulsein_objects[irq - CXD56_IRQ_EXDEVICE_0] = self;
|
||||||
}
|
}
|
||||||
@ -160,7 +160,7 @@ void common_hal_pulseio_pulsein_clear(pulseio_pulsein_obj_t *self) {
|
|||||||
|
|
||||||
uint16_t common_hal_pulseio_pulsein_popleft(pulseio_pulsein_obj_t *self) {
|
uint16_t common_hal_pulseio_pulsein_popleft(pulseio_pulsein_obj_t *self) {
|
||||||
if (self->len == 0) {
|
if (self->len == 0) {
|
||||||
mp_raise_IndexError_varg(translate("pop from empty %q"), MP_QSTR_PulseIn);
|
mp_raise_IndexError_varg(MP_ERROR_TEXT("pop from empty %q"), MP_QSTR_PulseIn);
|
||||||
}
|
}
|
||||||
common_hal_mcu_disable_interrupts();
|
common_hal_mcu_disable_interrupts();
|
||||||
uint16_t value = self->buffer[self->start];
|
uint16_t value = self->buffer[self->start];
|
||||||
@ -190,7 +190,7 @@ uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t *self, int16_
|
|||||||
}
|
}
|
||||||
if (index < 0 || index >= self->len) {
|
if (index < 0 || index >= self->len) {
|
||||||
common_hal_mcu_enable_interrupts();
|
common_hal_mcu_enable_interrupts();
|
||||||
mp_raise_IndexError_varg(translate("%q out of range"), MP_QSTR_index);
|
mp_raise_IndexError_varg(MP_ERROR_TEXT("%q out of range"), MP_QSTR_index);
|
||||||
}
|
}
|
||||||
uint16_t value = self->buffer[(self->start + index) % self->maxlen];
|
uint16_t value = self->buffer[(self->start + index) % self->maxlen];
|
||||||
common_hal_mcu_enable_interrupts();
|
common_hal_mcu_enable_interrupts();
|
||||||
|
@ -73,7 +73,7 @@ void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pulse_fd < 0) {
|
if (pulse_fd < 0) {
|
||||||
mp_raise_RuntimeError(translate("All timers in use"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("All timers in use"));
|
||||||
}
|
}
|
||||||
|
|
||||||
self->pwm_num = self->pwmout.number;
|
self->pwm_num = self->pwmout.number;
|
||||||
@ -99,7 +99,7 @@ bool common_hal_pulseio_pulseout_deinited(pulseio_pulseout_obj_t *self) {
|
|||||||
|
|
||||||
void common_hal_pulseio_pulseout_send(pulseio_pulseout_obj_t *self, uint16_t *pulses, uint16_t len) {
|
void common_hal_pulseio_pulseout_send(pulseio_pulseout_obj_t *self, uint16_t *pulses, uint16_t len) {
|
||||||
if (pulse_buffer != NULL) {
|
if (pulse_buffer != NULL) {
|
||||||
mp_raise_RuntimeError(translate("Another send is already active"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("Another send is already active"));
|
||||||
}
|
}
|
||||||
|
|
||||||
struct timer_sethandler_s sethandler;
|
struct timer_sethandler_s sethandler;
|
||||||
|
@ -50,5 +50,5 @@ int common_hal_rtc_get_calibration(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_rtc_set_calibration(int calibration) {
|
void common_hal_rtc_set_calibration(int calibration) {
|
||||||
mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_calibration);
|
mp_raise_NotImplementedError_varg(MP_ERROR_TEXT("%q"), MP_QSTR_calibration);
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ void common_hal_sdioio_sdcard_construct(sdioio_sdcard_obj_t *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (open_blockdriver("/dev/mmcsd0", 0, &self->inode) < 0) {
|
if (open_blockdriver("/dev/mmcsd0", 0, &self->inode) < 0) {
|
||||||
mp_raise_RuntimeError(translate("SDCard init"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("SDCard init"));
|
||||||
}
|
}
|
||||||
|
|
||||||
self->inode->u.i_bops->geometry(self->inode, &geo);
|
self->inode->u.i_bops->geometry(self->inode, &geo);
|
||||||
@ -111,7 +111,7 @@ uint32_t common_hal_sdioio_sdcard_get_count(sdioio_sdcard_obj_t *self) {
|
|||||||
|
|
||||||
STATIC void check_whole_block(mp_buffer_info_t *bufinfo) {
|
STATIC void check_whole_block(mp_buffer_info_t *bufinfo) {
|
||||||
if (bufinfo->len % 512) {
|
if (bufinfo->len % 512) {
|
||||||
mp_raise_ValueError(translate("Buffer length must be a multiple of 512"));
|
mp_raise_ValueError(MP_ERROR_TEXT("Buffer length must be a multiple of 512"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ STATIC mp_obj_t espnow_make_new(const mp_obj_type_t *type, size_t n_args, size_t
|
|||||||
espnow_obj_t *self = MP_STATE_PORT(espnow_singleton);
|
espnow_obj_t *self = MP_STATE_PORT(espnow_singleton);
|
||||||
|
|
||||||
if (!common_hal_espnow_deinited(self)) {
|
if (!common_hal_espnow_deinited(self)) {
|
||||||
mp_raise_RuntimeError(translate("Already running"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("Already running"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate a new object
|
// Allocate a new object
|
||||||
|
@ -86,7 +86,7 @@ STATIC mp_obj_t espnow_peer_make_new(const mp_obj_type_t *type, size_t n_args, s
|
|||||||
self->lmk_set = true;
|
self->lmk_set = true;
|
||||||
memcpy(self->peer_info.lmk, common_hal_espnow_get_bytes_len(lmk, ESP_NOW_KEY_LEN), ESP_NOW_KEY_LEN);
|
memcpy(self->peer_info.lmk, common_hal_espnow_get_bytes_len(lmk, ESP_NOW_KEY_LEN), ESP_NOW_KEY_LEN);
|
||||||
} else if (self->peer_info.encrypt) {
|
} else if (self->peer_info.encrypt) {
|
||||||
mp_raise_ValueError_varg(translate("%q is %q"), MP_QSTR_lmk, MP_QSTR_None);
|
mp_raise_ValueError_varg(MP_ERROR_TEXT("%q is %q"), MP_QSTR_lmk, MP_QSTR_None);
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
@ -199,7 +199,7 @@ STATIC mp_obj_t espnow_peer_set_encrypted(const mp_obj_t self_in, const mp_obj_t
|
|||||||
self->peer_info.encrypt = mp_obj_is_true(value);
|
self->peer_info.encrypt = mp_obj_is_true(value);
|
||||||
|
|
||||||
if (!self->lmk_set) {
|
if (!self->lmk_set) {
|
||||||
mp_raise_ValueError_varg(translate("%q is %q"), MP_QSTR_lmk, MP_QSTR_None);
|
mp_raise_ValueError_varg(MP_ERROR_TEXT("%q is %q"), MP_QSTR_lmk, MP_QSTR_None);
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_now_mod_peer(&self->peer_info);
|
esp_now_mod_peer(&self->peer_info);
|
||||||
|
@ -47,7 +47,7 @@
|
|||||||
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO38)
|
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO38)
|
||||||
|
|
||||||
// Explanation of how a user got into safe mode
|
// Explanation of how a user got into safe mode
|
||||||
#define BOARD_USER_SAFE_MODE_ACTION translate("You pressed the SW38 button at start up.")
|
#define BOARD_USER_SAFE_MODE_ACTION MP_ERROR_TEXT("You pressed the SW38 button at start up.")
|
||||||
|
|
||||||
// UART pins attached to the USB-serial converter chip
|
// UART pins attached to the USB-serial converter chip
|
||||||
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1)
|
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1)
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0)
|
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0)
|
||||||
|
|
||||||
// Explanation of how a user got into safe mode
|
// Explanation of how a user got into safe mode
|
||||||
#define BOARD_USER_SAFE_MODE_ACTION translate("You pressed the GPIO0 button at start up.")
|
#define BOARD_USER_SAFE_MODE_ACTION MP_ERROR_TEXT("You pressed the GPIO0 button at start up.")
|
||||||
|
|
||||||
// UART pins
|
// UART pins
|
||||||
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1)
|
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1)
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0)
|
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0)
|
||||||
|
|
||||||
// Explanation of how a user got into safe mode
|
// Explanation of how a user got into safe mode
|
||||||
// #define BOARD_USER_SAFE_MODE_ACTION translate("You pressed the BUT button at start up.")
|
// #define BOARD_USER_SAFE_MODE_ACTION MP_ERROR_TEXT("You pressed the BUT button at start up.")
|
||||||
|
|
||||||
// UART pins attached to the USB-serial converter chip
|
// UART pins attached to the USB-serial converter chip
|
||||||
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1)
|
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1)
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0)
|
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0)
|
||||||
|
|
||||||
// Explanation of how a user got into safe mode
|
// Explanation of how a user got into safe mode
|
||||||
// #define BOARD_USER_SAFE_MODE_ACTION translate("You pressed the BUT button at start up.")
|
// #define BOARD_USER_SAFE_MODE_ACTION MP_ERROR_TEXT("You pressed the BUT button at start up.")
|
||||||
|
|
||||||
// UART pins attached to the USB-serial converter chip
|
// UART pins attached to the USB-serial converter chip
|
||||||
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1)
|
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1)
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO36)
|
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO36)
|
||||||
|
|
||||||
// Explanation of how a user got into safe mode
|
// Explanation of how a user got into safe mode
|
||||||
#define BOARD_USER_SAFE_MODE_ACTION translate("You pressed the Rec button at start up.")
|
#define BOARD_USER_SAFE_MODE_ACTION MP_ERROR_TEXT("You pressed the Rec button at start up.")
|
||||||
|
|
||||||
// UART pins attached to the USB-serial converter chip
|
// UART pins attached to the USB-serial converter chip
|
||||||
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1)
|
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1)
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0)
|
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0)
|
||||||
|
|
||||||
// Explanation of how a user got into safe mode
|
// Explanation of how a user got into safe mode
|
||||||
#define BOARD_USER_SAFE_MODE_ACTION translate("You pressed the VOLUME button at start up.")
|
#define BOARD_USER_SAFE_MODE_ACTION MP_ERROR_TEXT("You pressed the VOLUME button at start up.")
|
||||||
|
|
||||||
// UART pins attached to the USB-serial converter chip
|
// UART pins attached to the USB-serial converter chip
|
||||||
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1)
|
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1)
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO39)
|
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO39)
|
||||||
|
|
||||||
// Explanation of how a user got into safe mode
|
// Explanation of how a user got into safe mode
|
||||||
#define BOARD_USER_SAFE_MODE_ACTION translate("You pressed the central button at start up.")
|
#define BOARD_USER_SAFE_MODE_ACTION MP_ERROR_TEXT("You pressed the central button at start up.")
|
||||||
|
|
||||||
// UART pins attached to the USB-serial converter chip
|
// UART pins attached to the USB-serial converter chip
|
||||||
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1)
|
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1)
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO39)
|
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO39)
|
||||||
|
|
||||||
// Explanation of how a user got into safe mode
|
// Explanation of how a user got into safe mode
|
||||||
#define BOARD_USER_SAFE_MODE_ACTION translate("You pressed the central button at start up.")
|
#define BOARD_USER_SAFE_MODE_ACTION MP_ERROR_TEXT("You pressed the central button at start up.")
|
||||||
|
|
||||||
// UART pins attached to the USB-serial converter chip
|
// UART pins attached to the USB-serial converter chip
|
||||||
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1)
|
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1)
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO39)
|
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO39)
|
||||||
|
|
||||||
// Explanation of how a user got into safe mode
|
// Explanation of how a user got into safe mode
|
||||||
#define BOARD_USER_SAFE_MODE_ACTION translate("You pressed the central button at start up.")
|
#define BOARD_USER_SAFE_MODE_ACTION MP_ERROR_TEXT("You pressed the central button at start up.")
|
||||||
|
|
||||||
// UART pins attached to the USB-serial converter chip
|
// UART pins attached to the USB-serial converter chip
|
||||||
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1)
|
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1)
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO39)
|
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO39)
|
||||||
|
|
||||||
// Explanation of how a user got into safe mode
|
// Explanation of how a user got into safe mode
|
||||||
#define BOARD_USER_SAFE_MODE_ACTION translate("You pressed the central button at start up.")
|
#define BOARD_USER_SAFE_MODE_ACTION MP_ERROR_TEXT("You pressed the central button at start up.")
|
||||||
|
|
||||||
// UART pins attached to the USB-serial converter chip
|
// UART pins attached to the USB-serial converter chip
|
||||||
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1)
|
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1)
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO39)
|
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO39)
|
||||||
|
|
||||||
// Explanation of how a user got into safe mode
|
// Explanation of how a user got into safe mode
|
||||||
#define BOARD_USER_SAFE_MODE_ACTION translate("You pressed button A at start up.")
|
#define BOARD_USER_SAFE_MODE_ACTION MP_ERROR_TEXT("You pressed button A at start up.")
|
||||||
|
|
||||||
// UART pins attached to the USB-serial converter chip
|
// UART pins attached to the USB-serial converter chip
|
||||||
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1)
|
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1)
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO39)
|
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO39)
|
||||||
|
|
||||||
// Explanation of how a user got into safe mode
|
// Explanation of how a user got into safe mode
|
||||||
#define BOARD_USER_SAFE_MODE_ACTION translate("You pressed button A at start up.")
|
#define BOARD_USER_SAFE_MODE_ACTION MP_ERROR_TEXT("You pressed button A at start up.")
|
||||||
|
|
||||||
// UART pins attached to the USB-serial converter chip
|
// UART pins attached to the USB-serial converter chip
|
||||||
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1)
|
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1)
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO39)
|
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO39)
|
||||||
|
|
||||||
// Explanation of how a user got into safe mode
|
// Explanation of how a user got into safe mode
|
||||||
#define BOARD_USER_SAFE_MODE_ACTION translate("You pressed button DOWN at start up.")
|
#define BOARD_USER_SAFE_MODE_ACTION MP_ERROR_TEXT("You pressed button DOWN at start up.")
|
||||||
|
|
||||||
// UART pins attached to the USB-serial converter chip
|
// UART pins attached to the USB-serial converter chip
|
||||||
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1)
|
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1)
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO37)
|
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO37)
|
||||||
|
|
||||||
// Explanation of how a user got into safe mode
|
// Explanation of how a user got into safe mode
|
||||||
#define BOARD_USER_SAFE_MODE_ACTION translate("You pressed button A at start up.")
|
#define BOARD_USER_SAFE_MODE_ACTION MP_ERROR_TEXT("You pressed button A at start up.")
|
||||||
|
|
||||||
// UART pins attached to the USB-serial converter chip
|
// UART pins attached to the USB-serial converter chip
|
||||||
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1)
|
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1)
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO37)
|
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO37)
|
||||||
|
|
||||||
// Explanation of how a user got into safe mode
|
// Explanation of how a user got into safe mode
|
||||||
#define BOARD_USER_SAFE_MODE_ACTION translate("You pressed button A at start up.")
|
#define BOARD_USER_SAFE_MODE_ACTION MP_ERROR_TEXT("You pressed button A at start up.")
|
||||||
|
|
||||||
// UART pins attached to the USB-serial converter chip
|
// UART pins attached to the USB-serial converter chip
|
||||||
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1)
|
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1)
|
||||||
|
@ -219,7 +219,7 @@ mp_obj_t common_hal_bleio_adapter_start_scan(bleio_adapter_obj_t *self, uint8_t
|
|||||||
mp_float_t interval, mp_float_t window, mp_int_t minimum_rssi, bool active) {
|
mp_float_t interval, mp_float_t window, mp_int_t minimum_rssi, bool active) {
|
||||||
if (self->scan_results != NULL) {
|
if (self->scan_results != NULL) {
|
||||||
if (!shared_module_bleio_scanresults_get_done(self->scan_results)) {
|
if (!shared_module_bleio_scanresults_get_done(self->scan_results)) {
|
||||||
mp_raise_bleio_BluetoothError(translate("Scan already in progress. Stop with stop_scan."));
|
mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Scan already in progress. Stop with stop_scan."));
|
||||||
}
|
}
|
||||||
self->scan_results = NULL;
|
self->scan_results = NULL;
|
||||||
}
|
}
|
||||||
@ -389,7 +389,7 @@ mp_obj_t common_hal_bleio_adapter_connect(bleio_adapter_obj_t *self, bleio_addre
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mp_raise_bleio_BluetoothError(translate("Failed to connect: internal error"));
|
mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Failed to connect: internal error"));
|
||||||
|
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
@ -535,7 +535,7 @@ uint32_t _common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self,
|
|||||||
STATIC void check_data_fit(size_t data_len, bool connectable) {
|
STATIC void check_data_fit(size_t data_len, bool connectable) {
|
||||||
if (data_len > MYNEWT_VAL(BLE_EXT_ADV_MAX_SIZE) ||
|
if (data_len > MYNEWT_VAL(BLE_EXT_ADV_MAX_SIZE) ||
|
||||||
(connectable && data_len > MYNEWT_VAL(BLE_EXT_ADV_MAX_SIZE))) {
|
(connectable && data_len > MYNEWT_VAL(BLE_EXT_ADV_MAX_SIZE))) {
|
||||||
mp_raise_ValueError(translate("Data too large for advertisement packet"));
|
mp_raise_ValueError(MP_ERROR_TEXT("Data too large for advertisement packet"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -544,7 +544,7 @@ void common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, bool
|
|||||||
mp_buffer_info_t *advertising_data_bufinfo, mp_buffer_info_t *scan_response_data_bufinfo,
|
mp_buffer_info_t *advertising_data_bufinfo, mp_buffer_info_t *scan_response_data_bufinfo,
|
||||||
mp_int_t tx_power, const bleio_address_obj_t *directed_to) {
|
mp_int_t tx_power, const bleio_address_obj_t *directed_to) {
|
||||||
if (self->user_advertising) {
|
if (self->user_advertising) {
|
||||||
mp_raise_bleio_BluetoothError(translate("Already advertising."));
|
mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Already advertising."));
|
||||||
} else {
|
} else {
|
||||||
// If the user isn't advertising, then the background is. So, stop the
|
// If the user isn't advertising, then the background is. So, stop the
|
||||||
// background advertising so the user can.
|
// background advertising so the user can.
|
||||||
@ -556,12 +556,12 @@ void common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, bool
|
|||||||
check_data_fit(scan_response_data_bufinfo->len, connectable);
|
check_data_fit(scan_response_data_bufinfo->len, connectable);
|
||||||
|
|
||||||
if (advertising_data_bufinfo->len > 31 && scan_response_data_bufinfo->len > 0) {
|
if (advertising_data_bufinfo->len > 31 && scan_response_data_bufinfo->len > 0) {
|
||||||
mp_raise_bleio_BluetoothError(translate("Extended advertisements with scan response not supported."));
|
mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Extended advertisements with scan response not supported."));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (advertising_data_bufinfo->len > 0 && directed_to != NULL) {
|
if (advertising_data_bufinfo->len > 0 && directed_to != NULL) {
|
||||||
mp_raise_bleio_BluetoothError(translate("Data not supported with directed advertising"));
|
mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Data not supported with directed advertising"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (anonymous) {
|
if (anonymous) {
|
||||||
@ -571,7 +571,7 @@ void common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, bool
|
|||||||
if (!timeout) {
|
if (!timeout) {
|
||||||
timeout = BLE_HS_FOREVER;
|
timeout = BLE_HS_FOREVER;
|
||||||
} else if (timeout > INT32_MAX) {
|
} else if (timeout > INT32_MAX) {
|
||||||
mp_raise_bleio_BluetoothError(translate("Timeout is too long: Maximum timeout length is %d seconds"),
|
mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Timeout is too long: Maximum timeout length is %d seconds"),
|
||||||
INT32_MAX / 1000);
|
INT32_MAX / 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,10 +165,10 @@ void common_hal_bleio_characteristic_set_value(bleio_characteristic_obj_t *self,
|
|||||||
// Validate data length for local characteristics only.
|
// Validate data length for local characteristics only.
|
||||||
// TODO: Test this once we can get servers going.
|
// TODO: Test this once we can get servers going.
|
||||||
if (self->fixed_length && bufinfo->len != self->max_length) {
|
if (self->fixed_length && bufinfo->len != self->max_length) {
|
||||||
mp_raise_ValueError(translate("Value length != required fixed length"));
|
mp_raise_ValueError(MP_ERROR_TEXT("Value length != required fixed length"));
|
||||||
}
|
}
|
||||||
if (bufinfo->len > self->max_length) {
|
if (bufinfo->len > self->max_length) {
|
||||||
mp_raise_ValueError(translate("Value length > max_length"));
|
mp_raise_ValueError(MP_ERROR_TEXT("Value length > max_length"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bufinfo == NULL) {
|
if (bufinfo == NULL) {
|
||||||
@ -216,11 +216,11 @@ void common_hal_bleio_characteristic_add_descriptor(bleio_characteristic_obj_t *
|
|||||||
|
|
||||||
void common_hal_bleio_characteristic_set_cccd(bleio_characteristic_obj_t *self, bool notify, bool indicate) {
|
void common_hal_bleio_characteristic_set_cccd(bleio_characteristic_obj_t *self, bool notify, bool indicate) {
|
||||||
if (self->cccd_handle == BLEIO_HANDLE_INVALID) {
|
if (self->cccd_handle == BLEIO_HANDLE_INVALID) {
|
||||||
mp_raise_bleio_BluetoothError(translate("No CCCD for this Characteristic"));
|
mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("No CCCD for this Characteristic"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!common_hal_bleio_service_get_is_remote(self->service)) {
|
if (!common_hal_bleio_service_get_is_remote(self->service)) {
|
||||||
mp_raise_bleio_RoleError(translate("Can't set CCCD on local Characteristic"));
|
mp_raise_bleio_RoleError(MP_ERROR_TEXT("Can't set CCCD on local Characteristic"));
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint16_t conn_handle = bleio_connection_get_conn_handle(self->service->connection);
|
const uint16_t conn_handle = bleio_connection_get_conn_handle(self->service->connection);
|
||||||
|
@ -320,7 +320,7 @@ STATIC void discover_remote_services(bleio_connection_internal_t *self, mp_obj_t
|
|||||||
mp_obj_t uuid_obj;
|
mp_obj_t uuid_obj;
|
||||||
while ((uuid_obj = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) {
|
while ((uuid_obj = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) {
|
||||||
if (!mp_obj_is_type(uuid_obj, &bleio_uuid_type)) {
|
if (!mp_obj_is_type(uuid_obj, &bleio_uuid_type)) {
|
||||||
mp_raise_TypeError(translate("non-UUID found in service_uuids_whitelist"));
|
mp_raise_TypeError(MP_ERROR_TEXT("non-UUID found in service_uuids_whitelist"));
|
||||||
}
|
}
|
||||||
bleio_uuid_obj_t *uuid = MP_OBJ_TO_PTR(uuid_obj);
|
bleio_uuid_obj_t *uuid = MP_OBJ_TO_PTR(uuid_obj);
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ void common_hal_bleio_descriptor_construct(bleio_descriptor_obj_t *self, bleio_c
|
|||||||
|
|
||||||
const mp_int_t max_length_max = BLE_ATT_ATTR_MAX_LEN;
|
const mp_int_t max_length_max = BLE_ATT_ATTR_MAX_LEN;
|
||||||
if (max_length < 0 || max_length > max_length_max) {
|
if (max_length < 0 || max_length > max_length_max) {
|
||||||
mp_raise_ValueError_varg(translate("max_length must be 0-%d when fixed_length is %s"),
|
mp_raise_ValueError_varg(MP_ERROR_TEXT("max_length must be 0-%d when fixed_length is %s"),
|
||||||
max_length_max, fixed_length ? "True" : "False");
|
max_length_max, fixed_length ? "True" : "False");
|
||||||
}
|
}
|
||||||
self->max_length = max_length;
|
self->max_length = max_length;
|
||||||
@ -83,10 +83,10 @@ void common_hal_bleio_descriptor_set_value(bleio_descriptor_obj_t *self, mp_buff
|
|||||||
} else {
|
} else {
|
||||||
// Validate data length for local descriptors only.
|
// Validate data length for local descriptors only.
|
||||||
if (self->fixed_length && bufinfo->len != self->max_length) {
|
if (self->fixed_length && bufinfo->len != self->max_length) {
|
||||||
mp_raise_ValueError(translate("Value length != required fixed length"));
|
mp_raise_ValueError(MP_ERROR_TEXT("Value length != required fixed length"));
|
||||||
}
|
}
|
||||||
if (bufinfo->len > self->max_length) {
|
if (bufinfo->len > self->max_length) {
|
||||||
mp_raise_ValueError(translate("Value length > max_length"));
|
mp_raise_ValueError(MP_ERROR_TEXT("Value length > max_length"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// common_hal_bleio_gatts_write(self->handle, conn_handle, bufinfo);
|
// common_hal_bleio_gatts_write(self->handle, conn_handle, bufinfo);
|
||||||
|
@ -267,7 +267,7 @@ mp_int_t common_hal_bleio_packet_buffer_readinto(bleio_packet_buffer_obj_t *self
|
|||||||
|
|
||||||
mp_int_t common_hal_bleio_packet_buffer_write(bleio_packet_buffer_obj_t *self, const uint8_t *data, size_t len, uint8_t *header, size_t header_len) {
|
mp_int_t common_hal_bleio_packet_buffer_write(bleio_packet_buffer_obj_t *self, const uint8_t *data, size_t len, uint8_t *header, size_t header_len) {
|
||||||
if (self->outgoing[0] == NULL) {
|
if (self->outgoing[0] == NULL) {
|
||||||
mp_raise_bleio_BluetoothError(translate("Writes not supported on Characteristic"));
|
mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Writes not supported on Characteristic"));
|
||||||
}
|
}
|
||||||
if (self->conn_handle == BLEIO_HANDLE_INVALID) {
|
if (self->conn_handle == BLEIO_HANDLE_INVALID) {
|
||||||
return -1;
|
return -1;
|
||||||
@ -280,11 +280,11 @@ mp_int_t common_hal_bleio_packet_buffer_write(bleio_packet_buffer_obj_t *self, c
|
|||||||
mp_int_t total_len = len + header_len;
|
mp_int_t total_len = len + header_len;
|
||||||
if (total_len > outgoing_packet_length) {
|
if (total_len > outgoing_packet_length) {
|
||||||
// Supplied data will not fit in a single BLE packet.
|
// Supplied data will not fit in a single BLE packet.
|
||||||
mp_raise_ValueError_varg(translate("Total data to write is larger than %q"), MP_QSTR_outgoing_packet_length);
|
mp_raise_ValueError_varg(MP_ERROR_TEXT("Total data to write is larger than %q"), MP_QSTR_outgoing_packet_length);
|
||||||
}
|
}
|
||||||
if (total_len > self->max_packet_size) {
|
if (total_len > self->max_packet_size) {
|
||||||
// Supplied data will not fit in a single BLE packet.
|
// Supplied data will not fit in a single BLE packet.
|
||||||
mp_raise_ValueError_varg(translate("Total data to write is larger than %q"), MP_QSTR_max_packet_size);
|
mp_raise_ValueError_varg(MP_ERROR_TEXT("Total data to write is larger than %q"), MP_QSTR_max_packet_size);
|
||||||
}
|
}
|
||||||
outgoing_packet_length = MIN(outgoing_packet_length, self->max_packet_size);
|
outgoing_packet_length = MIN(outgoing_packet_length, self->max_packet_size);
|
||||||
|
|
||||||
|
@ -85,26 +85,26 @@ void check_nimble_error(int rc, const char *file, size_t line) {
|
|||||||
}
|
}
|
||||||
switch (rc) {
|
switch (rc) {
|
||||||
case BLE_HS_ENOMEM:
|
case BLE_HS_ENOMEM:
|
||||||
mp_raise_msg(&mp_type_MemoryError, translate("Nimble out of memory"));
|
mp_raise_msg(&mp_type_MemoryError, MP_ERROR_TEXT("Nimble out of memory"));
|
||||||
return;
|
return;
|
||||||
case BLE_HS_ETIMEOUT:
|
case BLE_HS_ETIMEOUT:
|
||||||
mp_raise_msg(&mp_type_TimeoutError, NULL);
|
mp_raise_msg(&mp_type_TimeoutError, NULL);
|
||||||
return;
|
return;
|
||||||
case BLE_HS_EINVAL:
|
case BLE_HS_EINVAL:
|
||||||
mp_raise_ValueError(translate("Invalid BLE parameter"));
|
mp_raise_ValueError(MP_ERROR_TEXT("Invalid BLE parameter"));
|
||||||
return;
|
return;
|
||||||
case BLE_HS_ENOTCONN:
|
case BLE_HS_ENOTCONN:
|
||||||
mp_raise_ConnectionError(translate("Not connected"));
|
mp_raise_ConnectionError(MP_ERROR_TEXT("Not connected"));
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
#if CIRCUITPY_VERBOSE_BLE
|
#if CIRCUITPY_VERBOSE_BLE
|
||||||
if (file) {
|
if (file) {
|
||||||
mp_raise_bleio_BluetoothError(translate("Unknown system firmware error at %s:%d: %d"), file, line, rc);
|
mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Unknown system firmware error at %s:%d: %d"), file, line, rc);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
(void)file;
|
(void)file;
|
||||||
(void)line;
|
(void)line;
|
||||||
mp_raise_bleio_BluetoothError(translate("Unknown system firmware error: %d"), rc);
|
mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Unknown system firmware error: %d"), rc);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -119,12 +119,12 @@ void check_ble_error(int error_code, const char *file, size_t line) {
|
|||||||
default:
|
default:
|
||||||
#if CIRCUITPY_VERBOSE_BLE
|
#if CIRCUITPY_VERBOSE_BLE
|
||||||
if (file) {
|
if (file) {
|
||||||
mp_raise_bleio_BluetoothError(translate("Unknown BLE error at %s:%d: %d"), file, line, error_code);
|
mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Unknown BLE error at %s:%d: %d"), file, line, error_code);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
(void)file;
|
(void)file;
|
||||||
(void)line;
|
(void)line;
|
||||||
mp_raise_bleio_BluetoothError(translate("Unknown BLE error: %d"), error_code);
|
mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Unknown BLE error: %d"), error_code);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -140,6 +140,6 @@ void check_notify(BaseType_t result) {
|
|||||||
|
|
||||||
void common_hal_bleio_check_connected(uint16_t conn_handle) {
|
void common_hal_bleio_check_connected(uint16_t conn_handle) {
|
||||||
if (conn_handle == BLEIO_HANDLE_INVALID) {
|
if (conn_handle == BLEIO_HANDLE_INVALID) {
|
||||||
mp_raise_ConnectionError(translate("Not connected"));
|
mp_raise_ConnectionError(MP_ERROR_TEXT("Not connected"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,11 +41,11 @@
|
|||||||
|
|
||||||
void common_hal_alarm_pin_pinalarm_construct(alarm_pin_pinalarm_obj_t *self, const mcu_pin_obj_t *pin, bool value, bool edge, bool pull) {
|
void common_hal_alarm_pin_pinalarm_construct(alarm_pin_pinalarm_obj_t *self, const mcu_pin_obj_t *pin, bool value, bool edge, bool pull) {
|
||||||
if (edge) {
|
if (edge) {
|
||||||
mp_raise_ValueError(translate("Cannot wake on pin edge. Only level."));
|
mp_raise_ValueError(MP_ERROR_TEXT("Cannot wake on pin edge. Only level."));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pull && !GPIO_IS_VALID_OUTPUT_GPIO(pin->number)) {
|
if (pull && !GPIO_IS_VALID_OUTPUT_GPIO(pin->number)) {
|
||||||
mp_raise_ValueError(translate("Cannot pull on input-only pin."));
|
mp_raise_ValueError(MP_ERROR_TEXT("Cannot pull on input-only pin."));
|
||||||
}
|
}
|
||||||
self->pin = pin;
|
self->pin = pin;
|
||||||
self->value = value;
|
self->value = value;
|
||||||
@ -205,16 +205,16 @@ void alarm_pin_pinalarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_ob
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (deep_sleep && low_count > 2 && high_count == 0) {
|
if (deep_sleep && low_count > 2 && high_count == 0) {
|
||||||
mp_raise_ValueError(translate("Can only alarm on two low pins from deep sleep."));
|
mp_raise_ValueError(MP_ERROR_TEXT("Can only alarm on two low pins from deep sleep."));
|
||||||
}
|
}
|
||||||
if (deep_sleep && low_count > 1 && high_count > 0) {
|
if (deep_sleep && low_count > 1 && high_count > 0) {
|
||||||
mp_raise_ValueError(translate("Can only alarm on one low pin while others alarm high from deep sleep."));
|
mp_raise_ValueError(MP_ERROR_TEXT("Can only alarm on one low pin while others alarm high from deep sleep."));
|
||||||
}
|
}
|
||||||
// Only use ext0 and ext1 during deep sleep.
|
// Only use ext0 and ext1 during deep sleep.
|
||||||
if (deep_sleep) {
|
if (deep_sleep) {
|
||||||
if (high_count > 0) {
|
if (high_count > 0) {
|
||||||
if (esp_sleep_enable_ext1_wakeup(high_alarms, ESP_EXT1_WAKEUP_ANY_HIGH) != ESP_OK) {
|
if (esp_sleep_enable_ext1_wakeup(high_alarms, ESP_EXT1_WAKEUP_ANY_HIGH) != ESP_OK) {
|
||||||
mp_raise_ValueError(translate("Can only alarm on RTC IO from deep sleep."));
|
mp_raise_ValueError(MP_ERROR_TEXT("Can only alarm on RTC IO from deep sleep."));
|
||||||
}
|
}
|
||||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
||||||
}
|
}
|
||||||
@ -231,13 +231,13 @@ void alarm_pin_pinalarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_ob
|
|||||||
}
|
}
|
||||||
if (low_count > 1) {
|
if (low_count > 1) {
|
||||||
if (esp_sleep_enable_ext1_wakeup(1ull << low_pins[1], ESP_EXT1_WAKEUP_ALL_LOW) != ESP_OK) {
|
if (esp_sleep_enable_ext1_wakeup(1ull << low_pins[1], ESP_EXT1_WAKEUP_ALL_LOW) != ESP_OK) {
|
||||||
mp_raise_ValueError(translate("Can only alarm on RTC IO from deep sleep."));
|
mp_raise_ValueError(MP_ERROR_TEXT("Can only alarm on RTC IO from deep sleep."));
|
||||||
}
|
}
|
||||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
||||||
}
|
}
|
||||||
if (low_count > 0) {
|
if (low_count > 0) {
|
||||||
if (esp_sleep_enable_ext0_wakeup(low_pins[0], 0) != ESP_OK) {
|
if (esp_sleep_enable_ext0_wakeup(low_pins[0], 0) != ESP_OK) {
|
||||||
mp_raise_ValueError(translate("Can only alarm on RTC IO from deep sleep."));
|
mp_raise_ValueError(MP_ERROR_TEXT("Can only alarm on RTC IO from deep sleep."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -249,7 +249,7 @@ void alarm_pin_pinalarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_ob
|
|||||||
pin_31_0_status = 0;
|
pin_31_0_status = 0;
|
||||||
pin_63_32_status = 0;
|
pin_63_32_status = 0;
|
||||||
if (gpio_isr_register(gpio_interrupt, NULL, 0, &gpio_interrupt_handle) != ESP_OK) {
|
if (gpio_isr_register(gpio_interrupt, NULL, 0, &gpio_interrupt_handle) != ESP_OK) {
|
||||||
mp_raise_ValueError(translate("Can only alarm on RTC IO from deep sleep."));
|
mp_raise_ValueError(MP_ERROR_TEXT("Can only alarm on RTC IO from deep sleep."));
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < 64; i++) {
|
for (size_t i = 0; i < 64; i++) {
|
||||||
uint64_t mask = 1ull << i;
|
uint64_t mask = 1ull << i;
|
||||||
|
@ -91,7 +91,7 @@ void alarm_time_timealarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (timealarm_set) {
|
if (timealarm_set) {
|
||||||
mp_raise_ValueError(translate("Only one alarm.time alarm can be set."));
|
mp_raise_ValueError(MP_ERROR_TEXT("Only one alarm.time alarm can be set."));
|
||||||
}
|
}
|
||||||
timealarm = MP_OBJ_TO_PTR(alarms[i]);
|
timealarm = MP_OBJ_TO_PTR(alarms[i]);
|
||||||
timealarm_set = true;
|
timealarm_set = true;
|
||||||
|
@ -98,7 +98,7 @@ void alarm_touch_touchalarm_set_alarm(const bool deep_sleep, const size_t n_alar
|
|||||||
for (size_t i = 0; i < n_alarms; i++) {
|
for (size_t i = 0; i < n_alarms; i++) {
|
||||||
if (mp_obj_is_type(alarms[i], &alarm_touch_touchalarm_type)) {
|
if (mp_obj_is_type(alarms[i], &alarm_touch_touchalarm_type)) {
|
||||||
if (deep_sleep && touch_alarm_set) {
|
if (deep_sleep && touch_alarm_set) {
|
||||||
mp_raise_ValueError_varg(translate("Only one %q can be set in deep sleep."), MP_QSTR_TouchAlarm);
|
mp_raise_ValueError_varg(MP_ERROR_TEXT("Only one %q can be set in deep sleep."), MP_QSTR_TouchAlarm);
|
||||||
}
|
}
|
||||||
touch_alarm = MP_OBJ_TO_PTR(alarms[i]);
|
touch_alarm = MP_OBJ_TO_PTR(alarms[i]);
|
||||||
touch_channel_mask |= 1 << touch_alarm->pin->number;
|
touch_channel_mask |= 1 << touch_alarm->pin->number;
|
||||||
|
@ -249,7 +249,7 @@ uint32_t common_hal_analogbufio_bufferedin_readinto(analogbufio_bufferedin_obj_t
|
|||||||
adc_digi_output_format_t output_format = ADC_DIGI_OUTPUT_FORMAT_TYPE1;
|
adc_digi_output_format_t output_format = ADC_DIGI_OUTPUT_FORMAT_TYPE1;
|
||||||
|
|
||||||
if (bytes_per_sample != 2) {
|
if (bytes_per_sample != 2) {
|
||||||
mp_raise_ValueError_varg(translate("%q must be array of type 'H'"), MP_QSTR_buffer);
|
mp_raise_ValueError_varg(MP_ERROR_TEXT("%q must be array of type 'H'"), MP_QSTR_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
start_dma(self, &convert_mode, &output_format);
|
start_dma(self, &convert_mode, &output_format);
|
||||||
|
@ -50,7 +50,7 @@ void common_hal_audiobusio_i2sout_construct(audiobusio_i2sout_obj_t *self,
|
|||||||
const mcu_pin_obj_t *bit_clock, const mcu_pin_obj_t *word_select,
|
const mcu_pin_obj_t *bit_clock, const mcu_pin_obj_t *word_select,
|
||||||
const mcu_pin_obj_t *data, const mcu_pin_obj_t *main_clock, bool left_justified) {
|
const mcu_pin_obj_t *data, const mcu_pin_obj_t *main_clock, bool left_justified) {
|
||||||
if (main_clock != NULL) {
|
if (main_clock != NULL) {
|
||||||
mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_main_clock);
|
mp_raise_NotImplementedError_varg(MP_ERROR_TEXT("%q"), MP_QSTR_main_clock);
|
||||||
}
|
}
|
||||||
port_i2s_allocate_init(&self->i2s, left_justified);
|
port_i2s_allocate_init(&self->i2s, left_justified);
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ void port_i2s_allocate_init(i2s_t *self, bool left_justified) {
|
|||||||
};
|
};
|
||||||
esp_err_t err = i2s_new_channel(&chan_config, &self->handle, NULL);
|
esp_err_t err = i2s_new_channel(&chan_config, &self->handle, NULL);
|
||||||
if (err == ESP_ERR_NOT_FOUND) {
|
if (err == ESP_ERR_NOT_FOUND) {
|
||||||
mp_raise_RuntimeError(translate("Peripheral in use"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("Peripheral in use"));
|
||||||
}
|
}
|
||||||
|
|
||||||
i2s_event_callbacks_t callbacks = {
|
i2s_event_callbacks_t callbacks = {
|
||||||
|
@ -70,13 +70,13 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
|
|||||||
if (gpio_get_level(sda->number) == 0 || gpio_get_level(scl->number) == 0) {
|
if (gpio_get_level(sda->number) == 0 || gpio_get_level(scl->number) == 0) {
|
||||||
reset_pin_number(sda->number);
|
reset_pin_number(sda->number);
|
||||||
reset_pin_number(scl->number);
|
reset_pin_number(scl->number);
|
||||||
mp_raise_RuntimeError(translate("No pull up found on SDA or SCL; check your wiring"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("No pull up found on SDA or SCL; check your wiring"));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
self->xSemaphore = xSemaphoreCreateMutex();
|
self->xSemaphore = xSemaphoreCreateMutex();
|
||||||
if (self->xSemaphore == NULL) {
|
if (self->xSemaphore == NULL) {
|
||||||
mp_raise_RuntimeError(translate("Unable to create lock"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("Unable to create lock"));
|
||||||
}
|
}
|
||||||
self->sda_pin = sda;
|
self->sda_pin = sda;
|
||||||
self->scl_pin = scl;
|
self->scl_pin = scl;
|
||||||
@ -84,7 +84,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
|
|||||||
self->has_lock = 0;
|
self->has_lock = 0;
|
||||||
|
|
||||||
if (self->i2c_num == I2C_NUM_MAX) {
|
if (self->i2c_num == I2C_NUM_MAX) {
|
||||||
mp_raise_ValueError(translate("All I2C peripherals are in use"));
|
mp_raise_ValueError(MP_ERROR_TEXT("All I2C peripherals are in use"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete any previous driver.
|
// Delete any previous driver.
|
||||||
@ -113,7 +113,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
|
|||||||
if (err == ESP_FAIL) {
|
if (err == ESP_FAIL) {
|
||||||
mp_raise_OSError(MP_EIO);
|
mp_raise_OSError(MP_EIO);
|
||||||
} else {
|
} else {
|
||||||
mp_raise_RuntimeError(translate("init I2C"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("init I2C"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ static void set_spi_config(busio_spi_obj_t *self,
|
|||||||
};
|
};
|
||||||
esp_err_t result = spi_bus_add_device(self->host_id, &device_config, &spi_handle[self->host_id]);
|
esp_err_t result = spi_bus_add_device(self->host_id, &device_config, &spi_handle[self->host_id]);
|
||||||
if (result != ESP_OK) {
|
if (result != ESP_OK) {
|
||||||
mp_raise_RuntimeError(translate("SPI configuration failed"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("SPI configuration failed"));
|
||||||
}
|
}
|
||||||
self->baudrate = closest_clock;
|
self->baudrate = closest_clock;
|
||||||
self->polarity = polarity;
|
self->polarity = polarity;
|
||||||
@ -88,7 +88,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (half_duplex) {
|
if (half_duplex) {
|
||||||
mp_raise_NotImplementedError(translate("Half duplex SPI is not implemented"));
|
mp_raise_NotImplementedError(MP_ERROR_TEXT("Half duplex SPI is not implemented"));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (spi_host_device_t host_id = SPI2_HOST; host_id < SOC_SPI_PERIPH_NUM; host_id++) {
|
for (spi_host_device_t host_id = SPI2_HOST; host_id < SOC_SPI_PERIPH_NUM; host_id++) {
|
||||||
@ -98,12 +98,12 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (self->host_id == 0) {
|
if (self->host_id == 0) {
|
||||||
mp_raise_ValueError(translate("All SPI peripherals are in use"));
|
mp_raise_ValueError(MP_ERROR_TEXT("All SPI peripherals are in use"));
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t result = spi_bus_initialize(self->host_id, &bus_config, SPI_DMA_CH_AUTO);
|
esp_err_t result = spi_bus_initialize(self->host_id, &bus_config, SPI_DMA_CH_AUTO);
|
||||||
if (result == ESP_ERR_NO_MEM) {
|
if (result == ESP_ERR_NO_MEM) {
|
||||||
mp_raise_msg(&mp_type_MemoryError, translate("ESP-IDF memory allocation failed"));
|
mp_raise_msg(&mp_type_MemoryError, MP_ERROR_TEXT("ESP-IDF memory allocation failed"));
|
||||||
} else if (result == ESP_ERR_INVALID_ARG) {
|
} else if (result == ESP_ERR_INVALID_ARG) {
|
||||||
raise_ValueError_invalid_pins();
|
raise_ValueError_invalid_pins();
|
||||||
}
|
}
|
||||||
@ -186,7 +186,7 @@ void common_hal_busio_spi_unlock(busio_spi_obj_t *self) {
|
|||||||
bool common_hal_busio_spi_write(busio_spi_obj_t *self,
|
bool common_hal_busio_spi_write(busio_spi_obj_t *self,
|
||||||
const uint8_t *data, size_t len) {
|
const uint8_t *data, size_t len) {
|
||||||
if (self->MOSI == NULL) {
|
if (self->MOSI == NULL) {
|
||||||
mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_mosi);
|
mp_raise_ValueError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_mosi);
|
||||||
}
|
}
|
||||||
return common_hal_busio_spi_transfer(self, data, NULL, len);
|
return common_hal_busio_spi_transfer(self, data, NULL, len);
|
||||||
}
|
}
|
||||||
@ -194,7 +194,7 @@ bool common_hal_busio_spi_write(busio_spi_obj_t *self,
|
|||||||
bool common_hal_busio_spi_read(busio_spi_obj_t *self,
|
bool common_hal_busio_spi_read(busio_spi_obj_t *self,
|
||||||
uint8_t *data, size_t len, uint8_t write_value) {
|
uint8_t *data, size_t len, uint8_t write_value) {
|
||||||
if (self->MISO == NULL) {
|
if (self->MISO == NULL) {
|
||||||
mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_miso);
|
mp_raise_ValueError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_miso);
|
||||||
}
|
}
|
||||||
if (self->MOSI == NULL) {
|
if (self->MOSI == NULL) {
|
||||||
return common_hal_busio_spi_transfer(self, NULL, data, len);
|
return common_hal_busio_spi_transfer(self, NULL, data, len);
|
||||||
@ -210,10 +210,10 @@ bool common_hal_busio_spi_transfer(busio_spi_obj_t *self,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (self->MOSI == NULL && data_out != NULL) {
|
if (self->MOSI == NULL && data_out != NULL) {
|
||||||
mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_mosi);
|
mp_raise_ValueError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_mosi);
|
||||||
}
|
}
|
||||||
if (self->MISO == NULL && data_in != NULL) {
|
if (self->MISO == NULL && data_in != NULL) {
|
||||||
mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_miso);
|
mp_raise_ValueError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_miso);
|
||||||
}
|
}
|
||||||
|
|
||||||
spi_transaction_t transactions[MAX_SPI_TRANSACTIONS];
|
spi_transaction_t transactions[MAX_SPI_TRANSACTIONS];
|
||||||
|
@ -117,10 +117,10 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||||||
// Filter for sane settings for RS485
|
// Filter for sane settings for RS485
|
||||||
if (have_rs485_dir) {
|
if (have_rs485_dir) {
|
||||||
if (have_rts || have_cts) {
|
if (have_rts || have_cts) {
|
||||||
mp_raise_ValueError(translate("Cannot specify RTS or CTS in RS485 mode"));
|
mp_raise_ValueError(MP_ERROR_TEXT("Cannot specify RTS or CTS in RS485 mode"));
|
||||||
}
|
}
|
||||||
} else if (rs485_invert) {
|
} else if (rs485_invert) {
|
||||||
mp_raise_ValueError(translate("RS485 inversion specified when not in RS485 mode"));
|
mp_raise_ValueError(MP_ERROR_TEXT("RS485 inversion specified when not in RS485 mode"));
|
||||||
}
|
}
|
||||||
|
|
||||||
self->timeout_ms = timeout * 1000;
|
self->timeout_ms = timeout * 1000;
|
||||||
@ -132,7 +132,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (self->uart_num == UART_NUM_MAX) {
|
if (self->uart_num == UART_NUM_MAX) {
|
||||||
mp_raise_ValueError(translate("All UART peripherals are in use"));
|
mp_raise_ValueError(MP_ERROR_TEXT("All UART peripherals are in use"));
|
||||||
}
|
}
|
||||||
|
|
||||||
uart_mode_t mode = UART_MODE_UART;
|
uart_mode_t mode = UART_MODE_UART;
|
||||||
@ -159,7 +159,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||||||
// Install the driver before we change the settings.
|
// Install the driver before we change the settings.
|
||||||
if (uart_driver_install(self->uart_num, receiver_buffer_size, 0, 20, &self->event_queue, 0) != ESP_OK ||
|
if (uart_driver_install(self->uart_num, receiver_buffer_size, 0, 20, &self->event_queue, 0) != ESP_OK ||
|
||||||
uart_set_mode(self->uart_num, mode) != ESP_OK) {
|
uart_set_mode(self->uart_num, mode) != ESP_OK) {
|
||||||
mp_raise_RuntimeError(translate("UART init"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("UART init"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// On the console uart, enable pattern detection to look for CTRL+C
|
// On the console uart, enable pattern detection to look for CTRL+C
|
||||||
@ -233,7 +233,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||||||
|
|
||||||
// config all in one?
|
// config all in one?
|
||||||
if (uart_param_config(self->uart_num, &uart_config) != ESP_OK) {
|
if (uart_param_config(self->uart_num, &uart_config) != ESP_OK) {
|
||||||
mp_raise_RuntimeError(translate("UART init"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("UART init"));
|
||||||
}
|
}
|
||||||
|
|
||||||
self->tx_pin = NULL;
|
self->tx_pin = NULL;
|
||||||
@ -303,7 +303,7 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) {
|
|||||||
// Read characters.
|
// Read characters.
|
||||||
size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t len, int *errcode) {
|
size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t len, int *errcode) {
|
||||||
if (self->rx_pin == NULL) {
|
if (self->rx_pin == NULL) {
|
||||||
mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_rx);
|
mp_raise_ValueError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_rx);
|
||||||
}
|
}
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
// Nothing to read.
|
// Nothing to read.
|
||||||
@ -356,7 +356,7 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t
|
|||||||
// Write characters.
|
// Write characters.
|
||||||
size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) {
|
size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) {
|
||||||
if (self->tx_pin == NULL) {
|
if (self->tx_pin == NULL) {
|
||||||
mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_tx);
|
mp_raise_ValueError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_tx);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t left_to_write = len;
|
size_t left_to_write = len;
|
||||||
|
@ -113,7 +113,7 @@ STATIC twai_timing_config_t get_t_config(int baudrate) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
mp_raise_ValueError(translate("Baudrate not supported by peripheral"));
|
mp_raise_ValueError(MP_ERROR_TEXT("Baudrate not supported by peripheral"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,11 +121,11 @@ void common_hal_canio_can_construct(canio_can_obj_t *self, const mcu_pin_obj_t *
|
|||||||
#define DIV_ROUND(a, b) (((a) + (b) / 2) / (b))
|
#define DIV_ROUND(a, b) (((a) + (b) / 2) / (b))
|
||||||
#define DIV_ROUND_UP(a, b) (((a) + (b) - 1) / (b))
|
#define DIV_ROUND_UP(a, b) (((a) + (b) - 1) / (b))
|
||||||
if (reserved_can) {
|
if (reserved_can) {
|
||||||
mp_raise_ValueError(translate("All CAN peripherals are in use"));
|
mp_raise_ValueError(MP_ERROR_TEXT("All CAN peripherals are in use"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loopback && silent) {
|
if (loopback && silent) {
|
||||||
mp_raise_ValueError(translate("loopback + silent mode not supported by peripheral"));
|
mp_raise_ValueError(MP_ERROR_TEXT("loopback + silent mode not supported by peripheral"));
|
||||||
}
|
}
|
||||||
|
|
||||||
twai_timing_config_t t_config = get_t_config(baudrate);
|
twai_timing_config_t t_config = get_t_config(baudrate);
|
||||||
@ -143,16 +143,16 @@ void common_hal_canio_can_construct(canio_can_obj_t *self, const mcu_pin_obj_t *
|
|||||||
|
|
||||||
esp_err_t result = twai_driver_install(&g_config, &t_config, &f_config);
|
esp_err_t result = twai_driver_install(&g_config, &t_config, &f_config);
|
||||||
if (result == ESP_ERR_NO_MEM) {
|
if (result == ESP_ERR_NO_MEM) {
|
||||||
mp_raise_msg(&mp_type_MemoryError, translate("ESP-IDF memory allocation failed"));
|
mp_raise_msg(&mp_type_MemoryError, MP_ERROR_TEXT("ESP-IDF memory allocation failed"));
|
||||||
} else if (result == ESP_ERR_INVALID_ARG) {
|
} else if (result == ESP_ERR_INVALID_ARG) {
|
||||||
raise_ValueError_invalid_pins();
|
raise_ValueError_invalid_pins();
|
||||||
} else if (result != ESP_OK) {
|
} else if (result != ESP_OK) {
|
||||||
mp_raise_OSError_msg_varg(translate("twai_driver_install returned esp-idf error #%d"), (int)result);
|
mp_raise_OSError_msg_varg(MP_ERROR_TEXT("twai_driver_install returned esp-idf error #%d"), (int)result);
|
||||||
}
|
}
|
||||||
|
|
||||||
result = twai_start();
|
result = twai_start();
|
||||||
if (result != ESP_OK) {
|
if (result != ESP_OK) {
|
||||||
mp_raise_OSError_msg_varg(translate("twai_start returned esp-idf error #%d"), (int)result);
|
mp_raise_OSError_msg_varg(MP_ERROR_TEXT("twai_start returned esp-idf error #%d"), (int)result);
|
||||||
}
|
}
|
||||||
|
|
||||||
self->silent = silent;
|
self->silent = silent;
|
||||||
|
@ -88,10 +88,10 @@ STATIC void set_filters(canio_listener_obj_t *self, size_t nmatch, canio_match_o
|
|||||||
|
|
||||||
void common_hal_canio_listener_construct(canio_listener_obj_t *self, canio_can_obj_t *can, size_t nmatch, canio_match_obj_t **matches, float timeout) {
|
void common_hal_canio_listener_construct(canio_listener_obj_t *self, canio_can_obj_t *can, size_t nmatch, canio_match_obj_t **matches, float timeout) {
|
||||||
if (can->fifo_in_use) {
|
if (can->fifo_in_use) {
|
||||||
mp_raise_ValueError(translate("All RX FIFOs in use"));
|
mp_raise_ValueError(MP_ERROR_TEXT("All RX FIFOs in use"));
|
||||||
}
|
}
|
||||||
if (nmatch > 1) {
|
if (nmatch > 1) {
|
||||||
mp_raise_ValueError(translate("Filters too complex"));
|
mp_raise_ValueError(MP_ERROR_TEXT("Filters too complex"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nothing can fail now so it's safe to assign self->can
|
// Nothing can fail now so it's safe to assign self->can
|
||||||
|
@ -51,7 +51,7 @@ void common_hal_countio_counter_construct(countio_counter_obj_t *self,
|
|||||||
// Initialize PCNT unit
|
// Initialize PCNT unit
|
||||||
const int8_t unit = peripherals_pcnt_init(&pcnt_config);
|
const int8_t unit = peripherals_pcnt_init(&pcnt_config);
|
||||||
if (unit == -1) {
|
if (unit == -1) {
|
||||||
mp_raise_RuntimeError(translate("All PCNT units in use"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("All PCNT units in use"));
|
||||||
}
|
}
|
||||||
|
|
||||||
self->pin = pin->number;
|
self->pin = pin->number;
|
||||||
|
@ -75,7 +75,7 @@ static void claim_and_record(const mcu_pin_obj_t *pin, uint64_t *used_pins_mask)
|
|||||||
static int valid_pin(const mcu_pin_obj_t *pin, qstr name) {
|
static int valid_pin(const mcu_pin_obj_t *pin, qstr name) {
|
||||||
int result = common_hal_mcu_pin_number(pin);
|
int result = common_hal_mcu_pin_number(pin);
|
||||||
if (result == NO_PIN) {
|
if (result == NO_PIN) {
|
||||||
mp_raise_ValueError_varg(translate("Invalid %q pin"), name);
|
mp_raise_ValueError_varg(MP_ERROR_TEXT("Invalid %q pin"), name);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -94,7 +94,7 @@ void common_hal_dotclockframebuffer_framebuffer_construct(dotclockframebuffer_fr
|
|||||||
bool de_idle_high, bool pclk_active_high, bool pclk_idle_high, int overscan_left) {
|
bool de_idle_high, bool pclk_active_high, bool pclk_idle_high, int overscan_left) {
|
||||||
|
|
||||||
if (num_red != 5 || num_green != 6 || num_blue != 5) {
|
if (num_red != 5 || num_green != 6 || num_blue != 5) {
|
||||||
mp_raise_ValueError(translate("Must provide 5/6/5 RGB pins"));
|
mp_raise_ValueError(MP_ERROR_TEXT("Must provide 5/6/5 RGB pins"));
|
||||||
}
|
}
|
||||||
|
|
||||||
claim_and_record(de, &self->used_pins_mask);
|
claim_and_record(de, &self->used_pins_mask);
|
||||||
|
@ -47,7 +47,7 @@ void dualbank_reset(void) {
|
|||||||
|
|
||||||
static void __attribute__((noreturn)) task_fatal_error(void) {
|
static void __attribute__((noreturn)) task_fatal_error(void) {
|
||||||
ESP_LOGE(TAG, "Exiting task due to fatal error...");
|
ESP_LOGE(TAG, "Exiting task due to fatal error...");
|
||||||
mp_raise_RuntimeError(translate("Update Failed"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("Update Failed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_dualbank_flash(const void *buf, const size_t len, const size_t offset) {
|
void common_hal_dualbank_flash(const void *buf, const size_t len, const size_t offset) {
|
||||||
@ -86,14 +86,14 @@ void common_hal_dualbank_flash(const void *buf, const size_t len, const size_t o
|
|||||||
// check new version with running version
|
// check new version with running version
|
||||||
if (memcmp(new_app_info.version, running_app_info.version, sizeof(new_app_info.version)) == 0) {
|
if (memcmp(new_app_info.version, running_app_info.version, sizeof(new_app_info.version)) == 0) {
|
||||||
ESP_LOGW(TAG, "New version is the same as running version.");
|
ESP_LOGW(TAG, "New version is the same as running version.");
|
||||||
mp_raise_RuntimeError(translate("Firmware is duplicate"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("Firmware is duplicate"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// check new version with last invalid partition
|
// check new version with last invalid partition
|
||||||
if (last_invalid != NULL) {
|
if (last_invalid != NULL) {
|
||||||
if (memcmp(new_app_info.version, invalid_app_info.version, sizeof(new_app_info.version)) == 0) {
|
if (memcmp(new_app_info.version, invalid_app_info.version, sizeof(new_app_info.version)) == 0) {
|
||||||
ESP_LOGW(TAG, "New version is the same as invalid version.");
|
ESP_LOGW(TAG, "New version is the same as invalid version.");
|
||||||
mp_raise_RuntimeError(translate("Firmware is invalid"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("Firmware is invalid"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ void common_hal_dualbank_flash(const void *buf, const size_t len, const size_t o
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGE(TAG, "received package is not fit len");
|
ESP_LOGE(TAG, "received package is not fit len");
|
||||||
mp_raise_RuntimeError(translate("Firmware is too big"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("Firmware is too big"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ void common_hal_dualbank_switch(void) {
|
|||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
if (err == ESP_ERR_OTA_VALIDATE_FAILED) {
|
if (err == ESP_ERR_OTA_VALIDATE_FAILED) {
|
||||||
ESP_LOGE(TAG, "Image validation failed, image is corrupted");
|
ESP_LOGE(TAG, "Image validation failed, image is corrupted");
|
||||||
mp_raise_RuntimeError(translate("Firmware is invalid"));
|
mp_raise_RuntimeError(MP_ERROR_TEXT("Firmware is invalid"));
|
||||||
}
|
}
|
||||||
ESP_LOGE(TAG, "esp_ota_set_boot_partition failed (%s)!", esp_err_to_name(err));
|
ESP_LOGE(TAG, "esp_ota_set_boot_partition failed (%s)!", esp_err_to_name(err));
|
||||||
task_fatal_error();
|
task_fatal_error();
|
||||||
|
@ -78,7 +78,7 @@ void common_hal_espcamera_camera_construct(
|
|||||||
camera_grab_mode_t grab_mode) {
|
camera_grab_mode_t grab_mode) {
|
||||||
|
|
||||||
if (common_hal_espidf_get_reserved_psram() == 0) {
|
if (common_hal_espidf_get_reserved_psram() == 0) {
|
||||||
mp_raise_msg(&mp_type_MemoryError, translate(
|
mp_raise_msg(&mp_type_MemoryError, MP_ERROR_TEXT(
|
||||||
"espcamera.Camera requires reserved PSRAM to be configured. See the documentation for instructions."));
|
"espcamera.Camera requires reserved PSRAM to be configured. See the documentation for instructions."));
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
@ -197,7 +197,7 @@ camera_fb_t *common_hal_espcamera_camera_take(espcamera_camera_obj_t *self, int
|
|||||||
sensor_t *sensor = esp_camera_sensor_get(); \
|
sensor_t *sensor = esp_camera_sensor_get(); \
|
||||||
i2c_unlock(self); \
|
i2c_unlock(self); \
|
||||||
if (!sensor->setter_function_name) { \
|
if (!sensor->setter_function_name) { \
|
||||||
mp_raise_AttributeError(translate("no such attribute")); \
|
mp_raise_AttributeError(MP_ERROR_TEXT("no such attribute")); \
|
||||||
} \
|
} \
|
||||||
return sensor->status_field_name; \
|
return sensor->status_field_name; \
|
||||||
}
|
}
|
||||||
@ -208,10 +208,10 @@ camera_fb_t *common_hal_espcamera_camera_take(espcamera_camera_obj_t *self, int
|
|||||||
sensor_t *sensor = esp_camera_sensor_get(); \
|
sensor_t *sensor = esp_camera_sensor_get(); \
|
||||||
i2c_unlock(self); \
|
i2c_unlock(self); \
|
||||||
if (!sensor->setter_function_name) { \
|
if (!sensor->setter_function_name) { \
|
||||||
mp_raise_AttributeError(translate("no such attribute")); \
|
mp_raise_AttributeError(MP_ERROR_TEXT("no such attribute")); \
|
||||||
} \
|
} \
|
||||||
if (sensor->setter_function_name(sensor, value) < 0) { \
|
if (sensor->setter_function_name(sensor, value) < 0) { \
|
||||||
mp_raise_ValueError(translate("invalid setting")); \
|
mp_raise_ValueError(MP_ERROR_TEXT("invalid setting")); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,41 +126,41 @@ void raise_esp_error(esp_err_t err) {
|
|||||||
const mp_obj_type_t *exception_type = &mp_type_espidf_IDFError;
|
const mp_obj_type_t *exception_type = &mp_type_espidf_IDFError;
|
||||||
switch (err) {
|
switch (err) {
|
||||||
case ESP_FAIL:
|
case ESP_FAIL:
|
||||||
msg = translate("Generic Failure");
|
msg = MP_ERROR_TEXT("Generic Failure");
|
||||||
break;
|
break;
|
||||||
case ESP_ERR_NO_MEM:
|
case ESP_ERR_NO_MEM:
|
||||||
exception_type = &mp_type_espidf_MemoryError;
|
exception_type = &mp_type_espidf_MemoryError;
|
||||||
msg = translate("Out of memory");
|
msg = MP_ERROR_TEXT("Out of memory");
|
||||||
break;
|
break;
|
||||||
case ESP_ERR_INVALID_ARG:
|
case ESP_ERR_INVALID_ARG:
|
||||||
msg = translate("Invalid argument");
|
msg = MP_ERROR_TEXT("Invalid argument");
|
||||||
break;
|
break;
|
||||||
case ESP_ERR_INVALID_STATE:
|
case ESP_ERR_INVALID_STATE:
|
||||||
msg = translate("Invalid state");
|
msg = MP_ERROR_TEXT("Invalid state");
|
||||||
break;
|
break;
|
||||||
case ESP_ERR_INVALID_SIZE:
|
case ESP_ERR_INVALID_SIZE:
|
||||||
msg = translate("Invalid size");
|
msg = MP_ERROR_TEXT("Invalid size");
|
||||||
break;
|
break;
|
||||||
case ESP_ERR_NOT_FOUND:
|
case ESP_ERR_NOT_FOUND:
|
||||||
msg = translate("Requested resource not found");
|
msg = MP_ERROR_TEXT("Requested resource not found");
|
||||||
break;
|
break;
|
||||||
case ESP_ERR_NOT_SUPPORTED:
|
case ESP_ERR_NOT_SUPPORTED:
|
||||||
msg = translate("Operation or feature not supported");
|
msg = MP_ERROR_TEXT("Operation or feature not supported");
|
||||||
break;
|
break;
|
||||||
case ESP_ERR_TIMEOUT:
|
case ESP_ERR_TIMEOUT:
|
||||||
msg = translate("Operation timed out");
|
msg = MP_ERROR_TEXT("Operation timed out");
|
||||||
break;
|
break;
|
||||||
case ESP_ERR_INVALID_RESPONSE:
|
case ESP_ERR_INVALID_RESPONSE:
|
||||||
msg = translate("Received response was invalid");
|
msg = MP_ERROR_TEXT("Received response was invalid");
|
||||||
break;
|
break;
|
||||||
case ESP_ERR_INVALID_CRC:
|
case ESP_ERR_INVALID_CRC:
|
||||||
msg = translate("CRC or checksum was invalid");
|
msg = MP_ERROR_TEXT("CRC or checksum was invalid");
|
||||||
break;
|
break;
|
||||||
case ESP_ERR_INVALID_VERSION:
|
case ESP_ERR_INVALID_VERSION:
|
||||||
msg = translate("Version was invalid");
|
msg = MP_ERROR_TEXT("Version was invalid");
|
||||||
break;
|
break;
|
||||||
case ESP_ERR_INVALID_MAC:
|
case ESP_ERR_INVALID_MAC:
|
||||||
msg = translate("MAC address was invalid");
|
msg = MP_ERROR_TEXT("MAC address was invalid");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (msg) {
|
if (msg) {
|
||||||
@ -184,7 +184,7 @@ void raise_esp_error(esp_err_t err) {
|
|||||||
group = "WiFi";
|
group = "WiFi";
|
||||||
}
|
}
|
||||||
|
|
||||||
mp_raise_msg_varg(exception_type, translate("%s error 0x%x"), group, err);
|
mp_raise_msg_varg(exception_type, MP_ERROR_TEXT("%s error 0x%x"), group, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cp_check_esp_error(esp_err_t err) {
|
void cp_check_esp_error(esp_err_t err) {
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user