cc3200: Use mp_raise_XXX helper functions to reduce code size.

Reduces code size by 632 bytes.
pull/2531/head
Damien George 2016-10-18 09:53:43 +11:00
rodzic 4d45f286eb
commit 50ddaafa6a
22 zmienionych plików z 114 dodań i 118 usunięć

Wyświetl plik

@ -130,10 +130,6 @@ void mp_hal_delay_ms(mp_uint_t delay) {
}
}
NORETURN void mp_hal_raise(int errno) {
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, mp_obj_new_int(errno)));
}
void mp_hal_set_interrupt_char (int c) {
mpexception_set_interrupt_char (c);
}

Wyświetl plik

@ -62,7 +62,6 @@
extern void HAL_SystemInit (void);
extern void HAL_SystemDeInit (void);
extern void HAL_IncrementTick(void);
extern NORETURN void mp_hal_raise(int errno);
extern void mp_hal_set_interrupt_char (int c);
#endif /* CC3200_LAUNCHXL_HAL_CC3200_HAL_H_ */

Wyświetl plik

@ -112,7 +112,7 @@ void mp_irq_remove (const mp_obj_t parent) {
uint mp_irq_translate_priority (uint priority) {
if (priority < 1 || priority > MP_ARRAY_SIZE(mp_irq_priorities)) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
return mp_irq_priorities[priority - 1];
}

Wyświetl plik

@ -130,7 +130,7 @@ STATIC mp_obj_t machine_main(mp_obj_t main) {
if (MP_OBJ_IS_STR(main)) {
MP_STATE_PORT(machine_config_main) = main;
} else {
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
return mp_const_none;
}

Wyświetl plik

@ -101,7 +101,7 @@ STATIC mp_obj_t network_server_make_new(const mp_obj_type_t *type, mp_uint_t n_a
// check the server id
if (args[0].u_obj != MP_OBJ_NULL) {
if (mp_obj_get_int(args[0].u_obj) != 0) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_resource_not_avaliable));
mp_raise_msg(&mp_type_OSError, mpexception_os_resource_not_avaliable);
}
}

Wyświetl plik

@ -93,7 +93,7 @@ STATIC void hash_update_internal(mp_obj_t self_in, mp_obj_t data, bool digest) {
self->digested = false;
}
} else {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_request_not_possible));
mp_raise_msg(&mp_type_OSError, mpexception_os_request_not_possible);
}
}
@ -106,7 +106,7 @@ STATIC mp_obj_t hash_read (mp_obj_t self_in) {
}
} else if (self->c_size < self->b_size) {
// it's a fixed len block which is still incomplete
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_request_not_possible));
mp_raise_msg(&mp_type_OSError, mpexception_os_request_not_possible);
}
if (!self->digested) {

Wyświetl plik

@ -158,7 +158,7 @@ STATIC void mount (mp_obj_t device, const char *path, uint pathlen, bool readonl
#endif
// cannot mount twice or on existing paths
if (f_stat(path, &fno) == FR_OK || osmount_find_by_device(device)) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_request_not_possible));
mp_raise_msg(&mp_type_OSError, mpexception_os_request_not_possible);
}
// create a new object
@ -196,7 +196,7 @@ STATIC void mount (mp_obj_t device, const char *path, uint pathlen, bool readonl
if (f_mount(&self->fatfs, self->path, 1) != FR_OK) {
// remove it and raise
mp_obj_list_remove(&MP_STATE_PORT(mount_obj_list), self);
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_operation_failed));
mp_raise_msg(&mp_type_OSError, mpexception_os_operation_failed);
}
// mount succeeded, increment the count
@ -252,7 +252,7 @@ STATIC mp_obj_t os_chdir(mp_obj_t path_in) {
}
if (res != FR_OK) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_operation_failed));
mp_raise_msg(&mp_type_OSError, mpexception_os_operation_failed);
}
return mp_const_none;
@ -263,7 +263,7 @@ STATIC mp_obj_t os_getcwd(void) {
char buf[MICROPY_ALLOC_PATH_MAX + 1];
FRESULT res = f_getcwd(buf, sizeof buf);
if (res != FR_OK) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(fresult_to_errno_table[res])));
mp_raise_OSError(fresult_to_errno_table[res]);
}
return mp_obj_new_str(buf, strlen(buf), false);
}
@ -303,7 +303,7 @@ STATIC mp_obj_t os_listdir(mp_uint_t n_args, const mp_obj_t *args) {
res = f_opendir(&dir, path); /* Open the directory */
if (res != FR_OK) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_operation_failed));
mp_raise_msg(&mp_type_OSError, mpexception_os_operation_failed);
}
for ( ; ; ) {
@ -335,10 +335,10 @@ STATIC mp_obj_t os_mkdir(mp_obj_t path_o) {
case FR_OK:
return mp_const_none;
case FR_EXIST:
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_request_not_possible));
mp_raise_msg(&mp_type_OSError, mpexception_os_request_not_possible);
break;
default:
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_operation_failed));
mp_raise_msg(&mp_type_OSError, mpexception_os_operation_failed);
}
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(os_mkdir_obj, os_mkdir);
@ -351,7 +351,7 @@ STATIC mp_obj_t os_rename(mp_obj_t path_in, mp_obj_t path_out) {
case FR_OK:
return mp_const_none;
default:
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_operation_failed));
mp_raise_msg(&mp_type_OSError, mpexception_os_operation_failed);
}
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(os_rename_obj, os_rename);
@ -363,7 +363,7 @@ STATIC mp_obj_t os_remove(mp_obj_t path_o) {
case FR_OK:
return mp_const_none;
default:
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_operation_failed));
mp_raise_msg(&mp_type_OSError, mpexception_os_operation_failed);
}
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(os_remove_obj, os_remove);
@ -394,7 +394,7 @@ STATIC mp_obj_t os_stat(mp_obj_t path_in) {
fno.ftime = 0;
fno.fattrib = AM_DIR;
} else if ((res = f_stat(path, &fno)) != FR_OK) {
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(fresult_to_errno_table[res])));
mp_raise_OSError(fresult_to_errno_table[res]);
}
mp_obj_tuple_t *t = mp_obj_new_tuple(10, NULL);
@ -481,7 +481,7 @@ STATIC mp_obj_t os_mount(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *k
return mp_const_none;
invalid_args:
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_value_invalid_arguments));
mp_raise_msg(&mp_type_OSError, mpexception_value_invalid_arguments);
}
MP_DEFINE_CONST_FUN_OBJ_KW(os_mount_obj, 2, os_mount);
@ -490,7 +490,7 @@ STATIC mp_obj_t os_unmount(mp_obj_t path_o) {
// '/flash' cannot be unmounted, also not the current working directory
if (path_equal(path, "/flash")) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_request_not_possible));
mp_raise_msg(&mp_type_OSError, mpexception_os_request_not_possible);
}
// now unmount it
@ -498,7 +498,7 @@ STATIC mp_obj_t os_unmount(mp_obj_t path_o) {
if ((mount_obj = osmount_find_by_path(path))) {
unmount (mount_obj);
} else {
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_msg(&mp_type_ValueError, mpexception_value_invalid_arguments);
}
return mp_const_none;
@ -515,7 +515,7 @@ STATIC mp_obj_t os_mkfs(mp_obj_t device) {
path = mp_obj_str_get_str(device);
// otherwise the relative path check will pass...
if (path[0] != '/') {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_value_invalid_arguments));
mp_raise_msg(&mp_type_OSError, mpexception_value_invalid_arguments);
}
} else {
// mount it briefly
@ -541,7 +541,7 @@ STATIC mp_obj_t os_mkfs(mp_obj_t device) {
}
if (res != FR_OK) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_operation_failed));
mp_raise_msg(&mp_type_OSError, mpexception_os_operation_failed);
}
return mp_const_none;
}

Wyświetl plik

@ -156,7 +156,7 @@ STATIC mp_obj_t socket_make_new(const mp_obj_type_t *type, mp_uint_t n_args, mp_
// create the socket
int _errno;
if (wlan_socket_socket(s, &_errno) != 0) {
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(-_errno)));
mp_raise_OSError(-_errno);
}
// add the socket to the list
modusocket_socket_add(s->sock_base.sd, true);
@ -182,7 +182,7 @@ STATIC mp_obj_t socket_bind(mp_obj_t self_in, mp_obj_t addr_in) {
// call the NIC to bind the socket
int _errno;
if (wlan_socket_bind(self, ip, port, &_errno) != 0) {
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(-_errno)));
mp_raise_OSError(-_errno);
}
return mp_const_none;
}
@ -200,7 +200,7 @@ STATIC mp_obj_t socket_listen(mp_uint_t n_args, const mp_obj_t *args) {
int _errno;
if (wlan_socket_listen(self, backlog, &_errno) != 0) {
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(-_errno)));
mp_raise_OSError(-_errno);
}
return mp_const_none;
}
@ -220,7 +220,7 @@ STATIC mp_obj_t socket_accept(mp_obj_t self_in) {
mp_uint_t port;
int _errno;
if (wlan_socket_accept(self, socket2, ip, &port, &_errno) != 0) {
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(-_errno)));
mp_raise_OSError(-_errno);
}
// add the socket to the list
@ -248,7 +248,7 @@ STATIC mp_obj_t socket_connect(mp_obj_t self_in, mp_obj_t addr_in) {
if (!self->sock_base.cert_req && _errno == SL_ESECSNOVERIFY) {
return mp_const_none;
}
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(-_errno)));
mp_raise_OSError(-_errno);
}
return mp_const_none;
}
@ -262,7 +262,7 @@ STATIC mp_obj_t socket_send(mp_obj_t self_in, mp_obj_t buf_in) {
int _errno;
mp_int_t ret = wlan_socket_send(self, bufinfo.buf, bufinfo.len, &_errno);
if (ret < 0) {
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(-_errno)));
mp_raise_OSError(-_errno);
}
return mp_obj_new_int_from_uint(ret);
}
@ -278,9 +278,9 @@ STATIC mp_obj_t socket_recv(mp_obj_t self_in, mp_obj_t len_in) {
mp_int_t ret = wlan_socket_recv(self, (byte*)vstr.buf, len, &_errno);
if (ret < 0) {
if (_errno == EAGAIN && self->sock_base.has_timeout) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_TimeoutError, "timed out"));
mp_raise_msg(&mp_type_TimeoutError, "timed out");
}
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(-_errno)));
mp_raise_OSError(-_errno);
}
if (ret == 0) {
return mp_const_empty_bytes;
@ -307,7 +307,7 @@ STATIC mp_obj_t socket_sendto(mp_obj_t self_in, mp_obj_t data_in, mp_obj_t addr_
int _errno;
mp_int_t ret = wlan_socket_sendto(self, bufinfo.buf, bufinfo.len, ip, port, &_errno);
if (ret < 0) {
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(-_errno)));
mp_raise_OSError(-_errno);
}
return mp_obj_new_int(ret);
}
@ -324,9 +324,9 @@ STATIC mp_obj_t socket_recvfrom(mp_obj_t self_in, mp_obj_t len_in) {
mp_int_t ret = wlan_socket_recvfrom(self, (byte*)vstr.buf, vstr.len, ip, &port, &_errno);
if (ret < 0) {
if (_errno == EAGAIN && self->sock_base.has_timeout) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_TimeoutError, "timed out"));
mp_raise_msg(&mp_type_TimeoutError, "timed out");
}
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(-_errno)));
mp_raise_OSError(-_errno);
}
mp_obj_t tuple[2];
if (ret == 0) {
@ -364,7 +364,7 @@ STATIC mp_obj_t socket_setsockopt(mp_uint_t n_args, const mp_obj_t *args) {
int _errno;
if (wlan_socket_setsockopt(self, level, opt, optval, optlen, &_errno) != 0) {
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(-_errno)));
mp_raise_OSError(-_errno);
}
return mp_const_none;
}
@ -384,7 +384,7 @@ STATIC mp_obj_t socket_settimeout(mp_obj_t self_in, mp_obj_t timeout_in) {
}
int _errno;
if (wlan_socket_settimeout(self, timeout, &_errno) != 0) {
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(-_errno)));
mp_raise_OSError(-_errno);
}
return mp_const_none;
}
@ -408,7 +408,7 @@ STATIC mp_obj_t socket_makefile(mp_uint_t n_args, const mp_obj_t *args) {
if (n_args > 1) {
const char *mode = mp_obj_str_get_str(args[1]);
if (strcmp(mode, "rb") && strcmp(mode, "wb")) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
}
return self;
@ -504,7 +504,7 @@ STATIC mp_obj_t mod_usocket_getaddrinfo(mp_obj_t host_in, mp_obj_t port_in) {
uint8_t out_ip[MOD_NETWORK_IPV4ADDR_BUF_SIZE];
int32_t result = wlan_gethostbyname(host, hlen, out_ip, AF_INET);
if (result < 0) {
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(-result)));
mp_raise_OSError(-result);
}
mp_obj_tuple_t *tuple = mp_obj_new_tuple(5, NULL);
tuple->items[0] = MP_OBJ_NEW_SMALL_INT(AF_INET);

Wyświetl plik

@ -131,10 +131,10 @@ STATIC mp_obj_t mod_ssl_wrap_socket(mp_uint_t n_args, const mp_obj_t *pos_args,
return ssl_sock;
socket_error:
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(_errno)));
mp_raise_OSError(_errno);
arg_error:
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_ssl_wrap_socket_obj, 0, mod_ssl_wrap_socket);

Wyświetl plik

@ -29,7 +29,7 @@
#include <string.h>
#include "py/mpconfig.h"
#include "py/nlr.h"
#include "py/runtime.h"
#include "py/obj.h"
#include "py/smallint.h"
#include "py/mphal.h"
@ -109,7 +109,7 @@ STATIC mp_obj_t time_mktime(mp_obj_t tuple) {
// localtime generates a tuple of len 8. CPython uses 9, so we accept both.
if (len < 8 || len > 9) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, mpexception_num_type_invalid_arguments));
mp_raise_TypeError(mpexception_num_type_invalid_arguments);
}
return mp_obj_new_int_from_uint(timeutils_mktime(mp_obj_get_int(elem[0]), mp_obj_get_int(elem[1]), mp_obj_get_int(elem[2]),

Wyświetl plik

@ -603,7 +603,7 @@ STATIC void wlan_reset (void) {
STATIC void wlan_validate_mode (uint mode) {
if (mode != ROLE_STA && mode != ROLE_AP) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
}
@ -614,7 +614,7 @@ STATIC void wlan_set_mode (uint mode) {
STATIC void wlan_validate_ssid_len (uint32_t len) {
if (len > MODWLAN_SSID_LEN_MAX) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
}
@ -647,7 +647,7 @@ STATIC void wlan_validate_security (uint8_t auth, const char *key, uint8_t len)
return;
invalid_args:
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
STATIC void wlan_set_security (uint8_t auth, const char *key, uint8_t len) {
@ -670,7 +670,7 @@ STATIC void wlan_set_security (uint8_t auth, const char *key, uint8_t len) {
STATIC void wlan_validate_channel (uint8_t channel) {
if (channel < 1 || channel > 11) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
}
@ -682,7 +682,7 @@ STATIC void wlan_set_channel (uint8_t channel) {
#if MICROPY_HW_ANTENNA_DIVERSITY
STATIC void wlan_validate_antenna (uint8_t antenna) {
if (antenna != ANTENNA_TYPE_INTERNAL && antenna != ANTENNA_TYPE_EXTERNAL) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
}
@ -847,7 +847,7 @@ STATIC mp_obj_t wlan_make_new(const mp_obj_type_t *type, mp_uint_t n_args, mp_ui
if (n_args > 1 || n_kw > 0) {
// check the peripheral id
if (args[0].u_int != 0) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_resource_not_avaliable));
mp_raise_msg(&mp_type_OSError, mpexception_os_resource_not_avaliable);
}
// start the peripheral
wlan_init_helper(self, &args[1]);
@ -871,7 +871,7 @@ STATIC mp_obj_t wlan_scan(mp_obj_t self_in) {
// check for correct wlan mode
if (wlan_obj.mode == ROLE_AP) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_request_not_possible));
mp_raise_msg(&mp_type_OSError, mpexception_os_request_not_possible);
}
Sl_WlanNetworkEntry_t wlanEntry;
@ -925,7 +925,7 @@ STATIC mp_obj_t wlan_connect(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_
// check for the correct wlan mode
if (wlan_obj.mode == ROLE_AP) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_request_not_possible));
mp_raise_msg(&mp_type_OSError, mpexception_os_request_not_possible);
}
// parse args
@ -973,9 +973,9 @@ STATIC mp_obj_t wlan_connect(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_
modwlan_Status_t status;
status = wlan_do_connect (ssid, ssid_len, bssid, auth, key, key_len, timeout);
if (status == MODWLAN_ERROR_TIMEOUT) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_operation_failed));
mp_raise_msg(&mp_type_OSError, mpexception_os_operation_failed);
} else if (status == MODWLAN_ERROR_INVALID_PARAMS) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
return mp_const_none;
}
@ -1004,7 +1004,7 @@ STATIC mp_obj_t wlan_ifconfig (mp_uint_t n_args, const mp_obj_t *pos_args, mp_ma
// check the interface id
if (args[0].u_int != 0) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_resource_not_avaliable));
mp_raise_msg(&mp_type_OSError, mpexception_os_resource_not_avaliable);
}
// get the configuration
@ -1051,7 +1051,7 @@ STATIC mp_obj_t wlan_ifconfig (mp_uint_t n_args, const mp_obj_t *pos_args, mp_ma
// check for the correct string
const char *mode = mp_obj_str_get_str(args[1].u_obj);
if (strcmp("dhcp", mode)) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
// only if we are not in AP mode
@ -1165,7 +1165,7 @@ STATIC mp_obj_t wlan_mac (mp_uint_t n_args, const mp_obj_t *args) {
mp_buffer_info_t bufinfo;
mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_READ);
if (bufinfo.len != 6) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
memcpy(self->mac, bufinfo.buf, SL_MAC_ADDR_LEN);
sl_NetCfgSet(SL_MAC_ADDRESS_SET, 1, SL_MAC_ADDR_LEN, (_u8 *)self->mac);
@ -1201,7 +1201,7 @@ STATIC mp_obj_t wlan_irq (mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *
return _irq;
invalid_args:
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(wlan_irq_obj, 1, wlan_irq);
@ -1230,18 +1230,18 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(wlan_irq_obj, 1, wlan_irq);
//
// // the call to sl_NetAppSet corrupts the input string URN=args[1], so we copy into a local buffer
// if (len > MAX_DEVICE_URN_LEN) {
// nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
// mp_raise_ValueError(mpexception_value_invalid_arguments);
// }
// strcpy(urn, p);
//
// if (sl_NetAppSet(SL_NET_APP_DEVICE_CONFIG_ID, NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN, len, (unsigned char *)urn) < 0) {
// nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_operation_failed));
// mp_raise_msg(&mp_type_OSError, mpexception_os_operation_failed);
// }
// }
// else {
// // get the URN
// if (sl_NetAppGet(SL_NET_APP_DEVICE_CONFIG_ID, NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN, &len, (uint8_t *)urn) < 0) {
// nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_operation_failed));
// mp_raise_msg(&mp_type_OSError, mpexception_os_operation_failed);
// }
// return mp_obj_new_str(urn, (len - 1), false);
// }

Wyświetl plik

@ -104,7 +104,7 @@ STATIC void pyb_adc_init (pyb_adc_obj_t *self) {
STATIC void pyb_adc_check_init(void) {
// not initialized
if (!pyb_adc_obj.enabled) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_request_not_possible));
mp_raise_msg(&mp_type_OSError, mpexception_os_request_not_possible);
}
}
@ -149,12 +149,12 @@ STATIC mp_obj_t adc_make_new(const mp_obj_type_t *type, mp_uint_t n_args, mp_uin
// check the peripheral id
if (args[0].u_int != 0) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_resource_not_avaliable));
mp_raise_msg(&mp_type_OSError, mpexception_os_resource_not_avaliable);
}
// check the number of bits
if (args[1].u_int != 12) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
// setup the object
@ -173,7 +173,7 @@ STATIC mp_obj_t adc_init(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *k
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(args), &pyb_adc_init_args[1], args);
// check the number of bits
if (args[0].u_int != 12) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
pyb_adc_init(pos_args[0]);
return mp_const_none;
@ -206,11 +206,11 @@ STATIC mp_obj_t adc_channel(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t
if (args[0].u_obj != MP_OBJ_NULL) {
ch_id = mp_obj_get_int(args[0].u_obj);
if (ch_id >= PYB_ADC_NUM_CHANNELS) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_os_resource_not_avaliable));
mp_raise_ValueError(mpexception_os_resource_not_avaliable);
} else if (args[1].u_obj != mp_const_none) {
uint pin_ch_id = pin_find_peripheral_type (args[1].u_obj, PIN_FN_ADC, 0);
if (ch_id != pin_ch_id) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
}
} else {
@ -277,7 +277,7 @@ STATIC mp_obj_t adc_channel_value(mp_obj_t self_in) {
// the channel must be enabled
if (!self->enabled) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_request_not_possible));
mp_raise_msg(&mp_type_OSError, mpexception_os_request_not_possible);
}
// wait until a new value is available

Wyświetl plik

@ -144,7 +144,7 @@ STATIC bool pyb_i2c_transaction(uint cmd) {
STATIC void pyb_i2c_check_init(pyb_i2c_obj_t *self) {
// not initialized
if (!self->baudrate) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_request_not_possible));
mp_raise_msg(&mp_type_OSError, mpexception_os_request_not_possible);
}
}
@ -256,7 +256,7 @@ STATIC void pyb_i2c_read_into (mp_arg_val_t *args, vstr_t *vstr) {
// receive the data
if (!pyb_i2c_read(args[0].u_int, (byte *)vstr->buf, vstr->len)) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_operation_failed));
mp_raise_msg(&mp_type_OSError, mpexception_os_operation_failed);
}
}
@ -275,7 +275,7 @@ STATIC void pyb_i2c_readmem_into (mp_arg_val_t *args, vstr_t *vstr) {
if (pyb_i2c_mem_addr_write (i2c_addr, (byte *)&mem_addr, mem_addr_size)) {
// Read the specified length of data
if (!pyb_i2c_read (i2c_addr, (byte *)vstr->buf, vstr->len)) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_operation_failed));
mp_raise_msg(&mp_type_OSError, mpexception_os_operation_failed);
}
}
}
@ -323,7 +323,7 @@ STATIC mp_obj_t pyb_i2c_init_helper(pyb_i2c_obj_t *self, const mp_arg_val_t *arg
return mp_const_none;
invalid_args:
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
STATIC const mp_arg_t pyb_i2c_init_args[] = {
@ -341,7 +341,7 @@ STATIC mp_obj_t pyb_i2c_make_new(const mp_obj_type_t *type, mp_uint_t n_args, mp
// check the peripheral id
if (args[0].u_int != 0) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_resource_not_avaliable));
mp_raise_msg(&mp_type_OSError, mpexception_os_resource_not_avaliable);
}
// setup the object
@ -445,7 +445,7 @@ STATIC mp_obj_t pyb_i2c_writeto(mp_uint_t n_args, const mp_obj_t *pos_args, mp_m
// send the data
if (!pyb_i2c_write(args[0].u_int, bufinfo.buf, bufinfo.len, args[2].u_bool)) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_operation_failed));
mp_raise_msg(&mp_type_OSError, mpexception_os_operation_failed);
}
// return the number of bytes written
@ -514,7 +514,7 @@ STATIC mp_obj_t pyb_i2c_writeto_mem(mp_uint_t n_args, const mp_obj_t *pos_args,
return mp_obj_new_int(bufinfo.len);
}
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_operation_failed));
mp_raise_msg(&mp_type_OSError, mpexception_os_operation_failed);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_i2c_writeto_mem_obj, 1, pyb_i2c_writeto_mem);

Wyświetl plik

@ -145,7 +145,7 @@ pin_obj_t *pin_find(mp_obj_t user_obj) {
return pin_obj;
}
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
void pin_config (pin_obj_t *self, int af, uint mode, uint pull, int value, uint strength) {
@ -185,7 +185,7 @@ uint8_t pin_find_peripheral_unit (const mp_obj_t pin, uint8_t fn, uint8_t type)
return pin_o->af_list[i].unit;
}
}
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
uint8_t pin_find_peripheral_type (const mp_obj_t pin, uint8_t fn, uint8_t unit) {
@ -195,13 +195,13 @@ uint8_t pin_find_peripheral_type (const mp_obj_t pin, uint8_t fn, uint8_t unit)
return pin_o->af_list[i].type;
}
}
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
int8_t pin_find_af_index (const pin_obj_t* pin, uint8_t fn, uint8_t unit, uint8_t type) {
int8_t af = pin_obj_find_af(pin, fn, unit, type);
if (af < 0) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
return af;
}
@ -426,18 +426,18 @@ STATIC void pin_extint_register(pin_obj_t *self, uint32_t intmode, uint32_t prio
STATIC void pin_validate_mode (uint mode) {
if (mode != GPIO_DIR_MODE_IN && mode != GPIO_DIR_MODE_OUT && mode != PIN_TYPE_OD &&
mode != GPIO_DIR_MODE_ALT && mode != GPIO_DIR_MODE_ALT_OD) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
}
STATIC void pin_validate_pull (uint pull) {
if (pull != PIN_TYPE_STD && pull != PIN_TYPE_STD_PU && pull != PIN_TYPE_STD_PD) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
}
STATIC void pin_validate_drive(uint strength) {
if (strength != PIN_STRENGTH_2MA && strength != PIN_STRENGTH_4MA && strength != PIN_STRENGTH_6MA) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
}
@ -450,7 +450,7 @@ STATIC void pin_validate_af(const pin_obj_t* pin, int8_t idx, uint8_t *fn, uint8
return;
}
}
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
STATIC uint8_t pin_get_value (const pin_obj_t* self) {
@ -591,7 +591,7 @@ STATIC mp_obj_t pin_obj_init_helper(pin_obj_t *self, mp_uint_t n_args, const mp_
return mp_const_none;
invalid_args:
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
STATIC void pin_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
@ -905,7 +905,7 @@ STATIC mp_obj_t pin_irq (mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *k
return _irq;
invalid_args:
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pin_irq_obj, 1, pin_irq);

Wyświetl plik

@ -202,7 +202,7 @@ STATIC uint pyb_rtc_datetime_s_us(const mp_obj_t datetime, uint32_t *seconds) {
// verify the tuple
if (len < 3 || len > 8) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
tm.tm_year = mp_obj_get_int(items[0]);
@ -294,7 +294,7 @@ STATIC mp_obj_t pyb_rtc_make_new(const mp_obj_type_t *type, mp_uint_t n_args, mp
// check the peripheral id
if (args[0].u_int != 0) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_resource_not_avaliable));
mp_raise_msg(&mp_type_OSError, mpexception_os_resource_not_avaliable);
}
// setup the object
@ -362,7 +362,7 @@ STATIC mp_obj_t pyb_rtc_alarm (mp_uint_t n_args, const mp_obj_t *pos_args, mp_ma
// check the alarm id
if (args[0].u_int != 0) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_resource_not_avaliable));
mp_raise_msg(&mp_type_OSError, mpexception_os_resource_not_avaliable);
}
uint32_t f_seconds;
@ -371,7 +371,7 @@ STATIC mp_obj_t pyb_rtc_alarm (mp_uint_t n_args, const mp_obj_t *pos_args, mp_ma
if (MP_OBJ_IS_TYPE(args[1].u_obj, &mp_type_tuple)) { // datetime tuple given
// repeat cannot be used with a datetime tuple
if (repeat) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
f_mseconds = pyb_rtc_datetime_s_us (args[1].u_obj, &f_seconds) / 1000;
} else { // then it must be an integer
@ -397,7 +397,7 @@ STATIC mp_obj_t pyb_rtc_alarm_left (mp_uint_t n_args, const mp_obj_t *args) {
// only alarm id 0 is available
if (n_args > 1 && mp_obj_get_int(args[1]) != 0) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_resource_not_avaliable));
mp_raise_msg(&mp_type_OSError, mpexception_os_resource_not_avaliable);
}
// get the current time
@ -415,7 +415,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_rtc_alarm_left_obj, 1, 2, pyb_rtc
STATIC mp_obj_t pyb_rtc_alarm_cancel (mp_uint_t n_args, const mp_obj_t *args) {
// only alarm id 0 is available
if (n_args > 1 && mp_obj_get_int(args[1]) != 0) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_resource_not_avaliable));
mp_raise_msg(&mp_type_OSError, mpexception_os_resource_not_avaliable);
}
// disable the alarm
pyb_rtc_disable_alarm();
@ -453,7 +453,7 @@ STATIC mp_obj_t pyb_rtc_irq (mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_
return _irq;
invalid_args:
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_rtc_irq_obj, 1, pyb_rtc_irq);

Wyświetl plik

@ -107,7 +107,7 @@ STATIC mp_obj_t pyb_sd_init_helper (pybsd_obj_t *self, const mp_arg_val_t *args)
pyb_sd_hw_init (self);
if (sd_disk_init() != 0) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_operation_failed));
mp_raise_msg(&mp_type_OSError, mpexception_os_operation_failed);
}
// register it with the sleep module
@ -132,7 +132,7 @@ STATIC mp_obj_t pyb_sd_make_new (const mp_obj_type_t *type, mp_uint_t n_args, mp
// check the peripheral id
if (args[0].u_int != 0) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_resource_not_avaliable));
mp_raise_msg(&mp_type_OSError, mpexception_os_resource_not_avaliable);
}
// setup and initialize the object

Wyświetl plik

@ -131,7 +131,7 @@ STATIC void pybspi_rx (pyb_spi_obj_t *self, void *data) {
STATIC void pybspi_transfer (pyb_spi_obj_t *self, const char *txdata, char *rxdata, uint32_t len, uint32_t *txchar) {
if (!self->baudrate) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_request_not_possible));
mp_raise_msg(&mp_type_OSError, mpexception_os_request_not_possible);
}
// send and receive the data
MAP_SPICSEnable(GSPI_BASE);
@ -218,7 +218,7 @@ STATIC mp_obj_t pyb_spi_init_helper(pyb_spi_obj_t *self, const mp_arg_val_t *arg
return mp_const_none;
invalid_args:
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
static const mp_arg_t pyb_spi_init_args[] = {
@ -240,7 +240,7 @@ STATIC mp_obj_t pyb_spi_make_new(const mp_obj_type_t *type, mp_uint_t n_args, mp
// check the peripheral id
if (args[0].u_int != 0) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_resource_not_avaliable));
mp_raise_msg(&mp_type_OSError, mpexception_os_resource_not_avaliable);
}
// setup the object
@ -357,7 +357,7 @@ STATIC mp_obj_t pyb_spi_write_readinto (mp_obj_t self, mp_obj_t writebuf, mp_obj
// get the read buffer
mp_get_buffer_raise(readbuf, &bufinfo_read, MP_BUFFER_WRITE);
if (bufinfo_read.len != bufinfo_write.len) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
}

Wyświetl plik

@ -223,7 +223,7 @@ STATIC uint32_t compute_prescaler_period_and_match_value(pyb_timer_channel_obj_t
return prescaler;
error:
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
STATIC void timer_init (pyb_timer_obj_t *tim) {
@ -319,7 +319,7 @@ STATIC mp_obj_t pyb_timer_init_helper(pyb_timer_obj_t *tim, mp_uint_t n_args, co
return mp_const_none;
error:
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
STATIC mp_obj_t pyb_timer_make_new(const mp_obj_type_t *type, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
@ -329,7 +329,7 @@ STATIC mp_obj_t pyb_timer_make_new(const mp_obj_type_t *type, mp_uint_t n_args,
// create a new Timer object
int32_t timer_idx = mp_obj_get_int(args[0]);
if (timer_idx < 0 || timer_idx > (PYBTIMER_NUM_TIMERS - 1)) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_resource_not_avaliable));
mp_raise_msg(&mp_type_OSError, mpexception_os_resource_not_avaliable);
}
pyb_timer_obj_t *tim = &pyb_timer_obj[timer_idx];
@ -370,7 +370,7 @@ STATIC mp_obj_t pyb_timer_channel(mp_uint_t n_args, const mp_obj_t *pos_args, mp
// verify that the timer has been already initialized
if (!tim->config) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_request_not_possible));
mp_raise_msg(&mp_type_OSError, mpexception_os_request_not_possible);
}
if (channel_n != TIMER_A && channel_n != TIMER_B && channel_n != (TIMER_A | TIMER_B)) {
// invalid channel
@ -440,7 +440,7 @@ STATIC mp_obj_t pyb_timer_channel(mp_uint_t n_args, const mp_obj_t *pos_args, mp
return ch;
error:
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_timer_channel_obj, 2, pyb_timer_channel);
@ -560,7 +560,7 @@ STATIC mp_obj_t pyb_timer_channel_freq(mp_uint_t n_args, const mp_obj_t *args) {
// set
int32_t _frequency = mp_obj_get_int(args[1]);
if (_frequency <= 0) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
ch->frequency = _frequency;
ch->period = 1000000 / _frequency;
@ -579,7 +579,7 @@ STATIC mp_obj_t pyb_timer_channel_period(mp_uint_t n_args, const mp_obj_t *args)
// set
int32_t _period = mp_obj_get_int(args[1]);
if (_period <= 0) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
ch->period = _period;
ch->frequency = 1000000 / _period;
@ -712,7 +712,7 @@ STATIC mp_obj_t pyb_timer_channel_irq (mp_uint_t n_args, const mp_obj_t *pos_arg
return _irq;
invalid_args:
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_timer_channel_irq_obj, 1, pyb_timer_channel_irq);

Wyświetl plik

@ -280,7 +280,7 @@ STATIC void UARTGenericIntHandler(uint32_t uart_id) {
STATIC void uart_check_init(pyb_uart_obj_t *self) {
// not initialized
if (!self->baudrate) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_request_not_possible));
mp_raise_msg(&mp_type_OSError, mpexception_os_request_not_possible);
}
}
@ -432,7 +432,7 @@ STATIC mp_obj_t pyb_uart_init_helper(pyb_uart_obj_t *self, const mp_arg_val_t *a
return mp_const_none;
error:
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
STATIC const mp_arg_t pyb_uart_init_args[] = {
@ -472,7 +472,7 @@ STATIC mp_obj_t pyb_uart_make_new(const mp_obj_type_t *type, mp_uint_t n_args, m
}
if (uart_id > PYB_UART_1) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_resource_not_avaliable));
mp_raise_msg(&mp_type_OSError, mpexception_os_resource_not_avaliable);
}
// get the correct uart instance
@ -556,7 +556,7 @@ STATIC mp_obj_t pyb_uart_irq (mp_uint_t n_args, const mp_obj_t *pos_args, mp_map
return uart_irq_new (self, trigger, priority, args[2].u_obj);
invalid_args:
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_uart_irq_obj, 1, pyb_uart_irq);
@ -622,7 +622,7 @@ STATIC mp_uint_t pyb_uart_write(mp_obj_t self_in, const void *buf_in, mp_uint_t
// write the data
if (!uart_tx_strn(self, buf, size)) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_operation_failed));
mp_raise_msg(&mp_type_OSError, mpexception_os_operation_failed);
}
return size;
}

Wyświetl plik

@ -100,14 +100,14 @@ STATIC mp_obj_t pyb_wdt_make_new(const mp_obj_type_t *type, mp_uint_t n_args, mp
mp_arg_parse_all(n_args, all_args, &kw_args, MP_ARRAY_SIZE(args), pyb_wdt_init_args, args);
if (args[0].u_obj != mp_const_none && mp_obj_get_int(args[0].u_obj) > 0) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_resource_not_avaliable));
mp_raise_msg(&mp_type_OSError, mpexception_os_resource_not_avaliable);
}
uint timeout_ms = args[1].u_int;
if (timeout_ms < PYBWDT_MIN_TIMEOUT_MS) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
if (pyb_wdt_obj.running) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_request_not_possible));
mp_raise_msg(&mp_type_OSError, mpexception_os_request_not_possible);
}
// Enable the WDT peripheral clock

Wyświetl plik

@ -28,6 +28,7 @@
#include "py/mpconfig.h"
#include "py/mpstate.h"
#include "py/runtime.h"
#include "py/gc.h"
#include "py/mpthread.h"
#include "mptask.h"
@ -131,7 +132,7 @@ void mp_thread_create(void *(*entry)(void*), void *arg, size_t *stack_size) {
TaskHandle_t id = xTaskCreateStatic(freertos_entry, "Thread", *stack_size / sizeof(void*), arg, 2, stack, tcb);
if (id == NULL) {
mp_thread_mutex_unlock(&thread_mutex);
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "can't create thread"));
mp_raise_msg(&mp_type_OSError, "can't create thread");
}
// add thread to linked list of all threads

Wyświetl plik

@ -29,7 +29,7 @@
#include "py/mpconfig.h"
#include "py/misc.h"
#include "py/nlr.h"
#include "py/runtime.h"
#include "py/mphal.h"
#include "serverstask.h"
#include "simplelink.h"
@ -187,7 +187,7 @@ void servers_close_socket (int16_t *sd) {
void servers_set_login (char *user, char *pass) {
if (strlen(user) > SERVERS_USER_PASS_LEN_MAX || strlen(pass) > SERVERS_USER_PASS_LEN_MAX) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
memcpy(servers_user, user, SERVERS_USER_PASS_LEN_MAX);
memcpy(servers_pass, pass, SERVERS_USER_PASS_LEN_MAX);
@ -196,7 +196,7 @@ void servers_set_login (char *user, char *pass) {
void servers_set_timeout (uint32_t timeout) {
if (timeout < SERVERS_MIN_TIMEOUT_MS) {
// timeout is too low
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
mp_raise_ValueError(mpexception_value_invalid_arguments);
}
servers_data.timeout = timeout;
}