Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
circuitpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
circuitpython
Commits
22a6344e
Commit
22a6344e
authored
Feb 22, 2017
by
Damien George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cc3200: When raising OSError's use MP_Exxx as arg instead of a string.
parent
8bb8e97d
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
43 additions
and
41 deletions
+43
-41
cc3200/misc/mpexception.c
cc3200/misc/mpexception.c
+0
-3
cc3200/misc/mpexception.h
cc3200/misc/mpexception.h
+0
-3
cc3200/mods/modnetwork.c
cc3200/mods/modnetwork.c
+2
-1
cc3200/mods/moduhashlib.c
cc3200/mods/moduhashlib.c
+2
-2
cc3200/mods/modwlan.c
cc3200/mods/modwlan.c
+7
-7
cc3200/mods/pybadc.c
cc3200/mods/pybadc.c
+5
-4
cc3200/mods/pybi2c.c
cc3200/mods/pybi2c.c
+7
-6
cc3200/mods/pybrtc.c
cc3200/mods/pybrtc.c
+5
-4
cc3200/mods/pybsd.c
cc3200/mods/pybsd.c
+3
-2
cc3200/mods/pybspi.c
cc3200/mods/pybspi.c
+3
-2
cc3200/mods/pybtimer.c
cc3200/mods/pybtimer.c
+3
-2
cc3200/mods/pybuart.c
cc3200/mods/pybuart.c
+3
-3
cc3200/mods/pybwdt.c
cc3200/mods/pybwdt.c
+3
-2
No files found.
cc3200/misc/mpexception.c
View file @
22a6344e
...
@@ -40,9 +40,6 @@ STATIC void mpexception_set_user_interrupt (int chr, void *data);
...
@@ -40,9 +40,6 @@ STATIC void mpexception_set_user_interrupt (int chr, void *data);
/******************************************************************************
/******************************************************************************
DECLARE EXPORTED DATA
DECLARE EXPORTED DATA
******************************************************************************/
******************************************************************************/
const
char
mpexception_os_resource_not_avaliable
[]
=
"resource not available"
;
const
char
mpexception_os_operation_failed
[]
=
"the requested operation failed"
;
const
char
mpexception_os_request_not_possible
[]
=
"the requested operation is not possible"
;
const
char
mpexception_value_invalid_arguments
[]
=
"invalid argument(s) value"
;
const
char
mpexception_value_invalid_arguments
[]
=
"invalid argument(s) value"
;
const
char
mpexception_num_type_invalid_arguments
[]
=
"invalid argument(s) num/type"
;
const
char
mpexception_num_type_invalid_arguments
[]
=
"invalid argument(s) num/type"
;
const
char
mpexception_uncaught
[]
=
"uncaught exception"
;
const
char
mpexception_uncaught
[]
=
"uncaught exception"
;
...
...
cc3200/misc/mpexception.h
View file @
22a6344e
...
@@ -28,9 +28,6 @@
...
@@ -28,9 +28,6 @@
#ifndef MPEXCEPTION_H_
#ifndef MPEXCEPTION_H_
#define MPEXCEPTION_H_
#define MPEXCEPTION_H_
extern
const
char
mpexception_os_resource_not_avaliable
[];
extern
const
char
mpexception_os_operation_failed
[];
extern
const
char
mpexception_os_request_not_possible
[];
extern
const
char
mpexception_value_invalid_arguments
[];
extern
const
char
mpexception_value_invalid_arguments
[];
extern
const
char
mpexception_num_type_invalid_arguments
[];
extern
const
char
mpexception_num_type_invalid_arguments
[];
extern
const
char
mpexception_uncaught
[];
extern
const
char
mpexception_uncaught
[];
...
...
cc3200/mods/modnetwork.c
View file @
22a6344e
...
@@ -29,6 +29,7 @@
...
@@ -29,6 +29,7 @@
#include "py/obj.h"
#include "py/obj.h"
#include "py/nlr.h"
#include "py/nlr.h"
#include "py/runtime.h"
#include "py/runtime.h"
#include "py/mperrno.h"
#include "py/mphal.h"
#include "py/mphal.h"
#include "modnetwork.h"
#include "modnetwork.h"
#include "mpexception.h"
#include "mpexception.h"
...
@@ -99,7 +100,7 @@ STATIC mp_obj_t network_server_make_new(const mp_obj_type_t *type, size_t n_args
...
@@ -99,7 +100,7 @@ STATIC mp_obj_t network_server_make_new(const mp_obj_type_t *type, size_t n_args
// check the server id
// check the server id
if
(
args
[
0
].
u_obj
!=
MP_OBJ_NULL
)
{
if
(
args
[
0
].
u_obj
!=
MP_OBJ_NULL
)
{
if
(
mp_obj_get_int
(
args
[
0
].
u_obj
)
!=
0
)
{
if
(
mp_obj_get_int
(
args
[
0
].
u_obj
)
!=
0
)
{
mp_raise_
msg
(
&
mp_type_OSError
,
mpexception_os_resource_not_avaliable
);
mp_raise_
OSError
(
MP_ENODEV
);
}
}
}
}
...
...
cc3200/mods/moduhashlib.c
View file @
22a6344e
...
@@ -93,7 +93,7 @@ STATIC void hash_update_internal(mp_obj_t self_in, mp_obj_t data, bool digest) {
...
@@ -93,7 +93,7 @@ STATIC void hash_update_internal(mp_obj_t self_in, mp_obj_t data, bool digest) {
self
->
digested
=
false
;
self
->
digested
=
false
;
}
}
}
else
{
}
else
{
mp_raise_
msg
(
&
mp_type_OSError
,
mpexception_os_request_not_possible
);
mp_raise_
OSError
(
MP_EPERM
);
}
}
}
}
...
@@ -106,7 +106,7 @@ STATIC mp_obj_t hash_read (mp_obj_t self_in) {
...
@@ -106,7 +106,7 @@ STATIC mp_obj_t hash_read (mp_obj_t self_in) {
}
}
}
else
if
(
self
->
c_size
<
self
->
b_size
)
{
}
else
if
(
self
->
c_size
<
self
->
b_size
)
{
// it's a fixed len block which is still incomplete
// it's a fixed len block which is still incomplete
mp_raise_
msg
(
&
mp_type_OSError
,
mpexception_os_request_not_possible
);
mp_raise_
OSError
(
MP_EPERM
);
}
}
if
(
!
self
->
digested
)
{
if
(
!
self
->
digested
)
{
...
...
cc3200/mods/modwlan.c
View file @
22a6344e
...
@@ -836,7 +836,7 @@ STATIC mp_obj_t wlan_make_new(const mp_obj_type_t *type, size_t n_args, size_t n
...
@@ -836,7 +836,7 @@ STATIC mp_obj_t wlan_make_new(const mp_obj_type_t *type, size_t n_args, size_t n
if
(
n_args
>
1
||
n_kw
>
0
)
{
if
(
n_args
>
1
||
n_kw
>
0
)
{
// check the peripheral id
// check the peripheral id
if
(
args
[
0
].
u_int
!=
0
)
{
if
(
args
[
0
].
u_int
!=
0
)
{
mp_raise_
msg
(
&
mp_type_OSError
,
mpexception_os_resource_not_avaliable
);
mp_raise_
OSError
(
MP_ENODEV
);
}
}
// start the peripheral
// start the peripheral
wlan_init_helper
(
self
,
&
args
[
1
]);
wlan_init_helper
(
self
,
&
args
[
1
]);
...
@@ -860,7 +860,7 @@ STATIC mp_obj_t wlan_scan(mp_obj_t self_in) {
...
@@ -860,7 +860,7 @@ STATIC mp_obj_t wlan_scan(mp_obj_t self_in) {
// check for correct wlan mode
// check for correct wlan mode
if
(
wlan_obj
.
mode
==
ROLE_AP
)
{
if
(
wlan_obj
.
mode
==
ROLE_AP
)
{
mp_raise_
msg
(
&
mp_type_OSError
,
mpexception_os_request_not_possible
);
mp_raise_
OSError
(
MP_EPERM
);
}
}
Sl_WlanNetworkEntry_t
wlanEntry
;
Sl_WlanNetworkEntry_t
wlanEntry
;
...
@@ -914,7 +914,7 @@ STATIC mp_obj_t wlan_connect(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_
...
@@ -914,7 +914,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
// check for the correct wlan mode
if
(
wlan_obj
.
mode
==
ROLE_AP
)
{
if
(
wlan_obj
.
mode
==
ROLE_AP
)
{
mp_raise_
msg
(
&
mp_type_OSError
,
mpexception_os_request_not_possible
);
mp_raise_
OSError
(
MP_EPERM
);
}
}
// parse args
// parse args
...
@@ -962,7 +962,7 @@ STATIC mp_obj_t wlan_connect(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_
...
@@ -962,7 +962,7 @@ STATIC mp_obj_t wlan_connect(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_
modwlan_Status_t
status
;
modwlan_Status_t
status
;
status
=
wlan_do_connect
(
ssid
,
ssid_len
,
bssid
,
auth
,
key
,
key_len
,
timeout
);
status
=
wlan_do_connect
(
ssid
,
ssid_len
,
bssid
,
auth
,
key
,
key_len
,
timeout
);
if
(
status
==
MODWLAN_ERROR_TIMEOUT
)
{
if
(
status
==
MODWLAN_ERROR_TIMEOUT
)
{
mp_raise_
msg
(
&
mp_type_OSError
,
mpexception_os_operation_failed
);
mp_raise_
OSError
(
MP_ETIMEDOUT
);
}
else
if
(
status
==
MODWLAN_ERROR_INVALID_PARAMS
)
{
}
else
if
(
status
==
MODWLAN_ERROR_INVALID_PARAMS
)
{
mp_raise_ValueError
(
mpexception_value_invalid_arguments
);
mp_raise_ValueError
(
mpexception_value_invalid_arguments
);
}
}
...
@@ -993,7 +993,7 @@ STATIC mp_obj_t wlan_ifconfig (mp_uint_t n_args, const mp_obj_t *pos_args, mp_ma
...
@@ -993,7 +993,7 @@ STATIC mp_obj_t wlan_ifconfig (mp_uint_t n_args, const mp_obj_t *pos_args, mp_ma
// check the interface id
// check the interface id
if
(
args
[
0
].
u_int
!=
0
)
{
if
(
args
[
0
].
u_int
!=
0
)
{
mp_raise_
msg
(
&
mp_type_OSError
,
mpexception_os_resource_not_avaliable
);
mp_raise_
OSError
(
MP_EPERM
);
}
}
// get the configuration
// get the configuration
...
@@ -1224,13 +1224,13 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(wlan_irq_obj, 1, wlan_irq);
...
@@ -1224,13 +1224,13 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(wlan_irq_obj, 1, wlan_irq);
// strcpy(urn, p);
// 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) {
// if (sl_NetAppSet(SL_NET_APP_DEVICE_CONFIG_ID, NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN, len, (unsigned char *)urn) < 0) {
// mp_raise_
msg(&mp_type_OSError, mpexception_os_operation_failed
);
// mp_raise_
OSError(MP_EIO
);
// }
// }
// }
// }
// else {
// else {
// // get the URN
// // 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) {
// if (sl_NetAppGet(SL_NET_APP_DEVICE_CONFIG_ID, NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN, &len, (uint8_t *)urn) < 0) {
// mp_raise_
msg(&mp_type_OSError, mpexception_os_operation_failed
);
// mp_raise_
OSError(MP_EIO
);
// }
// }
// return mp_obj_new_str(urn, (len - 1), false);
// return mp_obj_new_str(urn, (len - 1), false);
// }
// }
...
...
cc3200/mods/pybadc.c
View file @
22a6344e
...
@@ -33,6 +33,7 @@
...
@@ -33,6 +33,7 @@
#include "py/runtime.h"
#include "py/runtime.h"
#include "py/binary.h"
#include "py/binary.h"
#include "py/gc.h"
#include "py/gc.h"
#include "py/mperrno.h"
#include "bufhelper.h"
#include "bufhelper.h"
#include "inc/hw_types.h"
#include "inc/hw_types.h"
#include "inc/hw_adc.h"
#include "inc/hw_adc.h"
...
@@ -104,7 +105,7 @@ STATIC void pyb_adc_init (pyb_adc_obj_t *self) {
...
@@ -104,7 +105,7 @@ STATIC void pyb_adc_init (pyb_adc_obj_t *self) {
STATIC
void
pyb_adc_check_init
(
void
)
{
STATIC
void
pyb_adc_check_init
(
void
)
{
// not initialized
// not initialized
if
(
!
pyb_adc_obj
.
enabled
)
{
if
(
!
pyb_adc_obj
.
enabled
)
{
mp_raise_
msg
(
&
mp_type_OSError
,
mpexception_os_request_not_possible
);
mp_raise_
OSError
(
MP_EPERM
);
}
}
}
}
...
@@ -149,7 +150,7 @@ STATIC mp_obj_t adc_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_
...
@@ -149,7 +150,7 @@ STATIC mp_obj_t adc_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_
// check the peripheral id
// check the peripheral id
if
(
args
[
0
].
u_int
!=
0
)
{
if
(
args
[
0
].
u_int
!=
0
)
{
mp_raise_
msg
(
&
mp_type_OSError
,
mpexception_os_resource_not_avaliable
);
mp_raise_
OSError
(
MP_ENODEV
);
}
}
// check the number of bits
// check the number of bits
...
@@ -206,7 +207,7 @@ STATIC mp_obj_t adc_channel(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t
...
@@ -206,7 +207,7 @@ 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
)
{
if
(
args
[
0
].
u_obj
!=
MP_OBJ_NULL
)
{
ch_id
=
mp_obj_get_int
(
args
[
0
].
u_obj
);
ch_id
=
mp_obj_get_int
(
args
[
0
].
u_obj
);
if
(
ch_id
>=
PYB_ADC_NUM_CHANNELS
)
{
if
(
ch_id
>=
PYB_ADC_NUM_CHANNELS
)
{
mp_raise_ValueError
(
mpexception_
os_resource_not_avaliable
);
mp_raise_ValueError
(
mpexception_
value_invalid_arguments
);
}
else
if
(
args
[
1
].
u_obj
!=
mp_const_none
)
{
}
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
);
uint
pin_ch_id
=
pin_find_peripheral_type
(
args
[
1
].
u_obj
,
PIN_FN_ADC
,
0
);
if
(
ch_id
!=
pin_ch_id
)
{
if
(
ch_id
!=
pin_ch_id
)
{
...
@@ -277,7 +278,7 @@ STATIC mp_obj_t adc_channel_value(mp_obj_t self_in) {
...
@@ -277,7 +278,7 @@ STATIC mp_obj_t adc_channel_value(mp_obj_t self_in) {
// the channel must be enabled
// the channel must be enabled
if
(
!
self
->
enabled
)
{
if
(
!
self
->
enabled
)
{
mp_raise_
msg
(
&
mp_type_OSError
,
mpexception_os_request_not_possible
);
mp_raise_
OSError
(
MP_EPERM
);
}
}
// wait until a new value is available
// wait until a new value is available
...
...
cc3200/mods/pybi2c.c
View file @
22a6344e
...
@@ -30,6 +30,7 @@
...
@@ -30,6 +30,7 @@
#include "py/mpstate.h"
#include "py/mpstate.h"
#include "py/runtime.h"
#include "py/runtime.h"
#include "py/mperrno.h"
#include "py/mphal.h"
#include "py/mphal.h"
#include "bufhelper.h"
#include "bufhelper.h"
#include "inc/hw_types.h"
#include "inc/hw_types.h"
...
@@ -144,7 +145,7 @@ STATIC bool pyb_i2c_transaction(uint cmd) {
...
@@ -144,7 +145,7 @@ STATIC bool pyb_i2c_transaction(uint cmd) {
STATIC
void
pyb_i2c_check_init
(
pyb_i2c_obj_t
*
self
)
{
STATIC
void
pyb_i2c_check_init
(
pyb_i2c_obj_t
*
self
)
{
// not initialized
// not initialized
if
(
!
self
->
baudrate
)
{
if
(
!
self
->
baudrate
)
{
mp_raise_
msg
(
&
mp_type_OSError
,
mpexception_os_request_not_possible
);
mp_raise_
OSError
(
MP_EPERM
);
}
}
}
}
...
@@ -256,7 +257,7 @@ STATIC void pyb_i2c_read_into (mp_arg_val_t *args, vstr_t *vstr) {
...
@@ -256,7 +257,7 @@ STATIC void pyb_i2c_read_into (mp_arg_val_t *args, vstr_t *vstr) {
// receive the data
// receive the data
if
(
!
pyb_i2c_read
(
args
[
0
].
u_int
,
(
byte
*
)
vstr
->
buf
,
vstr
->
len
))
{
if
(
!
pyb_i2c_read
(
args
[
0
].
u_int
,
(
byte
*
)
vstr
->
buf
,
vstr
->
len
))
{
mp_raise_
msg
(
&
mp_type_OSError
,
mpexception_os_operation_failed
);
mp_raise_
OSError
(
MP_EIO
);
}
}
}
}
...
@@ -275,7 +276,7 @@ STATIC void pyb_i2c_readmem_into (mp_arg_val_t *args, vstr_t *vstr) {
...
@@ -275,7 +276,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
))
{
if
(
pyb_i2c_mem_addr_write
(
i2c_addr
,
(
byte
*
)
&
mem_addr
,
mem_addr_size
))
{
// Read the specified length of data
// Read the specified length of data
if
(
!
pyb_i2c_read
(
i2c_addr
,
(
byte
*
)
vstr
->
buf
,
vstr
->
len
))
{
if
(
!
pyb_i2c_read
(
i2c_addr
,
(
byte
*
)
vstr
->
buf
,
vstr
->
len
))
{
mp_raise_
msg
(
&
mp_type_OSError
,
mpexception_os_operation_failed
);
mp_raise_
OSError
(
MP_EIO
);
}
}
}
}
}
}
...
@@ -341,7 +342,7 @@ STATIC mp_obj_t pyb_i2c_make_new(const mp_obj_type_t *type, size_t n_args, size_
...
@@ -341,7 +342,7 @@ STATIC mp_obj_t pyb_i2c_make_new(const mp_obj_type_t *type, size_t n_args, size_
// check the peripheral id
// check the peripheral id
if
(
args
[
0
].
u_int
!=
0
)
{
if
(
args
[
0
].
u_int
!=
0
)
{
mp_raise_
msg
(
&
mp_type_OSError
,
mpexception_os_resource_not_avaliable
);
mp_raise_
OSError
(
MP_ENODEV
);
}
}
// setup the object
// setup the object
...
@@ -445,7 +446,7 @@ STATIC mp_obj_t pyb_i2c_writeto(mp_uint_t n_args, const mp_obj_t *pos_args, mp_m
...
@@ -445,7 +446,7 @@ STATIC mp_obj_t pyb_i2c_writeto(mp_uint_t n_args, const mp_obj_t *pos_args, mp_m
// send the data
// send the data
if
(
!
pyb_i2c_write
(
args
[
0
].
u_int
,
bufinfo
.
buf
,
bufinfo
.
len
,
args
[
2
].
u_bool
))
{
if
(
!
pyb_i2c_write
(
args
[
0
].
u_int
,
bufinfo
.
buf
,
bufinfo
.
len
,
args
[
2
].
u_bool
))
{
mp_raise_
msg
(
&
mp_type_OSError
,
mpexception_os_operation_failed
);
mp_raise_
OSError
(
MP_EIO
);
}
}
// return the number of bytes written
// return the number of bytes written
...
@@ -514,7 +515,7 @@ STATIC mp_obj_t pyb_i2c_writeto_mem(mp_uint_t n_args, const mp_obj_t *pos_args,
...
@@ -514,7 +515,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
);
return
mp_obj_new_int
(
bufinfo
.
len
);
}
}
mp_raise_
msg
(
&
mp_type_OSError
,
mpexception_os_operation_failed
);
mp_raise_
OSError
(
MP_EIO
);
}
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_KW
(
pyb_i2c_writeto_mem_obj
,
1
,
pyb_i2c_writeto_mem
);
STATIC
MP_DEFINE_CONST_FUN_OBJ_KW
(
pyb_i2c_writeto_mem_obj
,
1
,
pyb_i2c_writeto_mem
);
...
...
cc3200/mods/pybrtc.c
View file @
22a6344e
...
@@ -28,6 +28,7 @@
...
@@ -28,6 +28,7 @@
#include "py/mpconfig.h"
#include "py/mpconfig.h"
#include "py/obj.h"
#include "py/obj.h"
#include "py/runtime.h"
#include "py/runtime.h"
#include "py/mperrno.h"
#include "inc/hw_types.h"
#include "inc/hw_types.h"
#include "inc/hw_ints.h"
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_memmap.h"
...
@@ -292,7 +293,7 @@ STATIC mp_obj_t pyb_rtc_make_new(const mp_obj_type_t *type, size_t n_args, size_
...
@@ -292,7 +293,7 @@ STATIC mp_obj_t pyb_rtc_make_new(const mp_obj_type_t *type, size_t n_args, size_
// check the peripheral id
// check the peripheral id
if
(
args
[
0
].
u_int
!=
0
)
{
if
(
args
[
0
].
u_int
!=
0
)
{
mp_raise_
msg
(
&
mp_type_OSError
,
mpexception_os_resource_not_avaliable
);
mp_raise_
OSError
(
MP_ENODEV
);
}
}
// setup the object
// setup the object
...
@@ -360,7 +361,7 @@ STATIC mp_obj_t pyb_rtc_alarm (mp_uint_t n_args, const mp_obj_t *pos_args, mp_ma
...
@@ -360,7 +361,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
// check the alarm id
if
(
args
[
0
].
u_int
!=
0
)
{
if
(
args
[
0
].
u_int
!=
0
)
{
mp_raise_
msg
(
&
mp_type_OSError
,
mpexception_os_resource_not_avaliable
);
mp_raise_
OSError
(
MP_ENODEV
);
}
}
uint32_t
f_seconds
;
uint32_t
f_seconds
;
...
@@ -395,7 +396,7 @@ STATIC mp_obj_t pyb_rtc_alarm_left (mp_uint_t n_args, const mp_obj_t *args) {
...
@@ -395,7 +396,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
// only alarm id 0 is available
if
(
n_args
>
1
&&
mp_obj_get_int
(
args
[
1
])
!=
0
)
{
if
(
n_args
>
1
&&
mp_obj_get_int
(
args
[
1
])
!=
0
)
{
mp_raise_
msg
(
&
mp_type_OSError
,
mpexception_os_resource_not_avaliable
);
mp_raise_
OSError
(
MP_ENODEV
);
}
}
// get the current time
// get the current time
...
@@ -413,7 +414,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_rtc_alarm_left_obj, 1, 2, pyb_rtc
...
@@ -413,7 +414,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
)
{
STATIC
mp_obj_t
pyb_rtc_alarm_cancel
(
mp_uint_t
n_args
,
const
mp_obj_t
*
args
)
{
// only alarm id 0 is available
// only alarm id 0 is available
if
(
n_args
>
1
&&
mp_obj_get_int
(
args
[
1
])
!=
0
)
{
if
(
n_args
>
1
&&
mp_obj_get_int
(
args
[
1
])
!=
0
)
{
mp_raise_
msg
(
&
mp_type_OSError
,
mpexception_os_resource_not_avaliable
);
mp_raise_
OSError
(
MP_ENODEV
);
}
}
// disable the alarm
// disable the alarm
pyb_rtc_disable_alarm
();
pyb_rtc_disable_alarm
();
...
...
cc3200/mods/pybsd.c
View file @
22a6344e
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
#include "py/mpconfig.h"
#include "py/mpconfig.h"
#include "py/obj.h"
#include "py/obj.h"
#include "py/runtime.h"
#include "py/runtime.h"
#include "py/mperrno.h"
#include "lib/oofatfs/ff.h"
#include "lib/oofatfs/ff.h"
#include "lib/oofatfs/diskio.h"
#include "lib/oofatfs/diskio.h"
#include "extmod/vfs_fat.h"
#include "extmod/vfs_fat.h"
...
@@ -108,7 +109,7 @@ STATIC mp_obj_t pyb_sd_init_helper (pybsd_obj_t *self, const mp_arg_val_t *args)
...
@@ -108,7 +109,7 @@ STATIC mp_obj_t pyb_sd_init_helper (pybsd_obj_t *self, const mp_arg_val_t *args)
pyb_sd_hw_init
(
self
);
pyb_sd_hw_init
(
self
);
if
(
sd_disk_init
()
!=
0
)
{
if
(
sd_disk_init
()
!=
0
)
{
mp_raise_
msg
(
&
mp_type_OSError
,
mpexception_os_operation_failed
);
mp_raise_
OSError
(
MP_EIO
);
}
}
// register it with the sleep module
// register it with the sleep module
...
@@ -133,7 +134,7 @@ STATIC mp_obj_t pyb_sd_make_new(const mp_obj_type_t *type, size_t n_args, size_t
...
@@ -133,7 +134,7 @@ STATIC mp_obj_t pyb_sd_make_new(const mp_obj_type_t *type, size_t n_args, size_t
// check the peripheral id
// check the peripheral id
if
(
args
[
0
].
u_int
!=
0
)
{
if
(
args
[
0
].
u_int
!=
0
)
{
mp_raise_
msg
(
&
mp_type_OSError
,
mpexception_os_resource_not_avaliable
);
mp_raise_
OSError
(
MP_ENODEV
);
}
}
// setup and initialize the object
// setup and initialize the object
...
...
cc3200/mods/pybspi.c
View file @
22a6344e
...
@@ -30,6 +30,7 @@
...
@@ -30,6 +30,7 @@
#include "py/mpstate.h"
#include "py/mpstate.h"
#include "py/runtime.h"
#include "py/runtime.h"
#include "py/mperrno.h"
#include "bufhelper.h"
#include "bufhelper.h"
#include "inc/hw_types.h"
#include "inc/hw_types.h"
#include "inc/hw_mcspi.h"
#include "inc/hw_mcspi.h"
...
@@ -131,7 +132,7 @@ STATIC void pybspi_rx (pyb_spi_obj_t *self, void *data) {
...
@@ -131,7 +132,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
)
{
STATIC
void
pybspi_transfer
(
pyb_spi_obj_t
*
self
,
const
char
*
txdata
,
char
*
rxdata
,
uint32_t
len
,
uint32_t
*
txchar
)
{
if
(
!
self
->
baudrate
)
{
if
(
!
self
->
baudrate
)
{
mp_raise_
msg
(
&
mp_type_OSError
,
mpexception_os_request_not_possible
);
mp_raise_
OSError
(
MP_EPERM
);
}
}
// send and receive the data
// send and receive the data
MAP_SPICSEnable
(
GSPI_BASE
);
MAP_SPICSEnable
(
GSPI_BASE
);
...
@@ -234,7 +235,7 @@ STATIC mp_obj_t pyb_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_
...
@@ -234,7 +235,7 @@ STATIC mp_obj_t pyb_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_
// check the peripheral id
// check the peripheral id
if
(
args
[
0
].
u_int
!=
0
)
{
if
(
args
[
0
].
u_int
!=
0
)
{
mp_raise_
msg
(
&
mp_type_OSError
,
mpexception_os_resource_not_avaliable
);
mp_raise_
OSError
(
MP_ENODEV
);
}
}
// setup the object
// setup the object
...
...
cc3200/mods/pybtimer.c
View file @
22a6344e
...
@@ -34,6 +34,7 @@
...
@@ -34,6 +34,7 @@
#include "py/nlr.h"
#include "py/nlr.h"
#include "py/runtime.h"
#include "py/runtime.h"
#include "py/gc.h"
#include "py/gc.h"
#include "py/mperrno.h"
#include "py/mphal.h"
#include "py/mphal.h"
#include "inc/hw_types.h"
#include "inc/hw_types.h"
#include "inc/hw_ints.h"
#include "inc/hw_ints.h"
...
@@ -329,7 +330,7 @@ STATIC mp_obj_t pyb_timer_make_new(const mp_obj_type_t *type, size_t n_args, siz
...
@@ -329,7 +330,7 @@ STATIC mp_obj_t pyb_timer_make_new(const mp_obj_type_t *type, size_t n_args, siz
// create a new Timer object
// create a new Timer object
int32_t
timer_idx
=
mp_obj_get_int
(
args
[
0
]);
int32_t
timer_idx
=
mp_obj_get_int
(
args
[
0
]);
if
(
timer_idx
<
0
||
timer_idx
>
(
PYBTIMER_NUM_TIMERS
-
1
))
{
if
(
timer_idx
<
0
||
timer_idx
>
(
PYBTIMER_NUM_TIMERS
-
1
))
{
mp_raise_
msg
(
&
mp_type_OSError
,
mpexception_os_resource_not_avaliable
);
mp_raise_
OSError
(
MP_ENODEV
);
}
}
pyb_timer_obj_t
*
tim
=
&
pyb_timer_obj
[
timer_idx
];
pyb_timer_obj_t
*
tim
=
&
pyb_timer_obj
[
timer_idx
];
...
@@ -370,7 +371,7 @@ STATIC mp_obj_t pyb_timer_channel(mp_uint_t n_args, const mp_obj_t *pos_args, mp
...
@@ -370,7 +371,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
// verify that the timer has been already initialized
if
(
!
tim
->
config
)
{
if
(
!
tim
->
config
)
{
mp_raise_
msg
(
&
mp_type_OSError
,
mpexception_os_request_not_possible
);
mp_raise_
OSError
(
MP_EPERM
);
}
}
if
(
channel_n
!=
TIMER_A
&&
channel_n
!=
TIMER_B
&&
channel_n
!=
(
TIMER_A
|
TIMER_B
))
{
if
(
channel_n
!=
TIMER_A
&&
channel_n
!=
TIMER_B
&&
channel_n
!=
(
TIMER_A
|
TIMER_B
))
{
// invalid channel
// invalid channel
...
...
cc3200/mods/pybuart.c
View file @
22a6344e
...
@@ -279,7 +279,7 @@ STATIC void UARTGenericIntHandler(uint32_t uart_id) {
...
@@ -279,7 +279,7 @@ STATIC void UARTGenericIntHandler(uint32_t uart_id) {
STATIC
void
uart_check_init
(
pyb_uart_obj_t
*
self
)
{
STATIC
void
uart_check_init
(
pyb_uart_obj_t
*
self
)
{
// not initialized
// not initialized
if
(
!
self
->
baudrate
)
{
if
(
!
self
->
baudrate
)
{
mp_raise_
msg
(
&
mp_type_OSError
,
mpexception_os_request_not_possible
);
mp_raise_
OSError
(
MP_EPERM
);
}
}
}
}
...
@@ -471,7 +471,7 @@ STATIC mp_obj_t pyb_uart_make_new(const mp_obj_type_t *type, size_t n_args, size
...
@@ -471,7 +471,7 @@ STATIC mp_obj_t pyb_uart_make_new(const mp_obj_type_t *type, size_t n_args, size
}
}
if
(
uart_id
>
PYB_UART_1
)
{
if
(
uart_id
>
PYB_UART_1
)
{
mp_raise_
msg
(
&
mp_type_OSError
,
mpexception_os_resource_not_avaliable
);
mp_raise_
OSError
(
MP_ENODEV
);
}
}
// get the correct uart instance
// get the correct uart instance
...
@@ -619,7 +619,7 @@ STATIC mp_uint_t pyb_uart_write(mp_obj_t self_in, const void *buf_in, mp_uint_t
...
@@ -619,7 +619,7 @@ STATIC mp_uint_t pyb_uart_write(mp_obj_t self_in, const void *buf_in, mp_uint_t
// write the data
// write the data
if
(
!
uart_tx_strn
(
self
,
buf
,
size
))
{
if
(
!
uart_tx_strn
(
self
,
buf
,
size
))
{
mp_raise_
msg
(
&
mp_type_OSError
,
mpexception_os_operation_failed
);
mp_raise_
OSError
(
MP_EIO
);
}
}
return
size
;
return
size
;
}
}
...
...
cc3200/mods/pybwdt.c
View file @
22a6344e
...
@@ -29,6 +29,7 @@
...
@@ -29,6 +29,7 @@
#include "py/mpconfig.h"
#include "py/mpconfig.h"
#include "py/obj.h"
#include "py/obj.h"
#include "py/runtime.h"
#include "py/runtime.h"
#include "py/mperrno.h"
#include "py/mphal.h"
#include "py/mphal.h"
#include "inc/hw_types.h"
#include "inc/hw_types.h"
#include "inc/hw_gpio.h"
#include "inc/hw_gpio.h"
...
@@ -100,14 +101,14 @@ STATIC mp_obj_t pyb_wdt_make_new(const mp_obj_type_t *type, size_t n_args, size_
...
@@ -100,14 +101,14 @@ STATIC mp_obj_t pyb_wdt_make_new(const mp_obj_type_t *type, size_t n_args, size_
mp_arg_parse_all
(
n_args
,
all_args
,
&
kw_args
,
MP_ARRAY_SIZE
(
args
),
pyb_wdt_init_args
,
args
);
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
)
{
if
(
args
[
0
].
u_obj
!=
mp_const_none
&&
mp_obj_get_int
(
args
[
0
].
u_obj
)
>
0
)
{
mp_raise_
msg
(
&
mp_type_OSError
,
mpexception_os_resource_not_avaliable
);
mp_raise_
OSError
(
MP_ENODEV
);
}
}
uint
timeout_ms
=
args
[
1
].
u_int
;
uint
timeout_ms
=
args
[
1
].
u_int
;
if
(
timeout_ms
<
PYBWDT_MIN_TIMEOUT_MS
)
{
if
(
timeout_ms
<
PYBWDT_MIN_TIMEOUT_MS
)
{
mp_raise_ValueError
(
mpexception_value_invalid_arguments
);
mp_raise_ValueError
(
mpexception_value_invalid_arguments
);
}
}
if
(
pyb_wdt_obj
.
running
)
{
if
(
pyb_wdt_obj
.
running
)
{
mp_raise_
msg
(
&
mp_type_OSError
,
mpexception_os_request_not_possible
);
mp_raise_
OSError
(
MP_EPERM
);
}
}
// Enable the WDT peripheral clock
// Enable the WDT peripheral clock
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment