Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
2bf5a947
Commit
2bf5a947
authored
Jun 15, 2017
by
Damien George
Browse files
stmhal: Make error messages more consistent across peripherals.
parent
48d867b4
Changes
12
Hide whitespace changes
Inline
Side-by-side
stmhal/can.c
View file @
2bf5a947
...
...
@@ -321,7 +321,7 @@ STATIC mp_obj_t pyb_can_init_helper(pyb_can_obj_t *self, mp_uint_t n_args, const
// init CAN (if it fails, it's because the port doesn't exist)
if
(
!
can_init
(
self
))
{
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"CAN
port
%d does
no
t exist"
,
self
->
can_id
));
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"CAN
(
%d
)
does
n'
t exist"
,
self
->
can_id
));
}
return
mp_const_none
;
...
...
@@ -357,13 +357,13 @@ STATIC mp_obj_t pyb_can_make_new(const mp_obj_type_t *type, size_t n_args, size_
can_idx
=
PYB_CAN_2
;
#endif
}
else
{
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"CAN(%s) does
no
t exist"
,
port
));
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"CAN(%s) does
n'
t exist"
,
port
));
}
}
else
{
can_idx
=
mp_obj_get_int
(
args
[
0
]);
}
if
(
can_idx
<
1
||
can_idx
>
MP_ARRAY_SIZE
(
MP_STATE_PORT
(
pyb_can_obj_all
)))
{
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"CAN(%d) does
no
t exist"
,
can_idx
));
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"CAN(%d) does
n'
t exist"
,
can_idx
));
}
pyb_can_obj_t
*
self
;
...
...
stmhal/dac.c
View file @
2bf5a947
...
...
@@ -221,7 +221,7 @@ STATIC mp_obj_t pyb_dac_make_new(const mp_obj_type_t *type, size_t n_args, size_
}
else
if
(
pin
==
&
pin_A5
)
{
dac_id
=
2
;
}
else
{
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"
p
in
%q does
no
t have DAC capabilities"
,
pin
->
name
));
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"
P
in
(
%q
)
does
n'
t have DAC capabilities"
,
pin
->
name
));
}
}
...
...
@@ -237,7 +237,7 @@ STATIC mp_obj_t pyb_dac_make_new(const mp_obj_type_t *type, size_t n_args, size_
dac
->
dac_channel
=
DAC_CHANNEL_2
;
dac
->
tx_dma_descr
=
&
dma_DAC_2_TX
;
}
else
{
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"DAC
%d does
no
t exist"
,
dac_id
));
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"DAC
(
%d
)
does
n'
t exist"
,
dac_id
));
}
// configure the peripheral
...
...
stmhal/i2c.c
View file @
2bf5a947
...
...
@@ -626,14 +626,14 @@ STATIC mp_obj_t pyb_i2c_make_new(const mp_obj_type_t *type, size_t n_args, size_
#endif
}
else
{
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"I2C(%s) does
no
t exist"
,
port
));
"I2C(%s) does
n'
t exist"
,
port
));
}
}
else
{
i2c_id
=
mp_obj_get_int
(
args
[
0
]);
if
(
i2c_id
<
1
||
i2c_id
>
MP_ARRAY_SIZE
(
pyb_i2c_obj
)
||
pyb_i2c_obj
[
i2c_id
-
1
].
i2c
==
NULL
)
{
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"I2C(%d) does
no
t exist"
,
i2c_id
));
"I2C(%d) does
n'
t exist"
,
i2c_id
));
}
}
...
...
stmhal/lcd.c
View file @
2bf5a947
...
...
@@ -220,7 +220,7 @@ STATIC mp_obj_t pyb_lcd_make_new(const mp_obj_type_t *type, size_t n_args, size_
lcd
->
pin_a0
=
&
pyb_pin_Y5
;
lcd
->
pin_bl
=
&
pyb_pin_Y12
;
}
else
{
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"LCD
bus '
%s
'
does
no
t exist"
,
lcd_id
));
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"LCD
(
%s
)
does
n'
t exist"
,
lcd_id
));
}
// init the SPI bus
...
...
stmhal/led.c
View file @
2bf5a947
...
...
@@ -299,7 +299,7 @@ STATIC mp_obj_t led_obj_make_new(const mp_obj_type_t *type, size_t n_args, size_
// check led number
if
(
!
(
1
<=
led_id
&&
led_id
<=
NUM_LEDS
))
{
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"LED(%d) does
no
t exist"
,
led_id
));
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"LED(%d) does
n'
t exist"
,
led_id
));
}
// return static led object
...
...
stmhal/machine_i2c.c
View file @
2bf5a947
...
...
@@ -510,14 +510,14 @@ mp_obj_t machine_hard_i2c_make_new(const mp_obj_type_t *type, size_t n_args, siz
#endif
}
else
{
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"I2C(%s) does
no
t exist"
,
port
));
"I2C(%s) does
n'
t exist"
,
port
));
}
}
else
{
i2c_id
=
mp_obj_get_int
(
args
[
ARG_id
].
u_obj
);
if
(
i2c_id
<
1
||
i2c_id
>
MP_ARRAY_SIZE
(
machine_hard_i2c_obj
)
||
machine_hard_i2c_obj
[
i2c_id
-
1
].
base
.
type
==
NULL
)
{
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"I2C(%d) does
no
t exist"
,
i2c_id
));
"I2C(%d) does
n'
t exist"
,
i2c_id
));
}
}
...
...
stmhal/pin.c
View file @
2bf5a947
...
...
@@ -176,7 +176,7 @@ const pin_obj_t *pin_find(mp_obj_t user_obj) {
return
pin_obj
;
}
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"
p
in
'%s' not a valid pin identifier
"
,
mp_obj_str_get_str
(
user_obj
)));
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"
P
in
(%s) doesn't exist
"
,
mp_obj_str_get_str
(
user_obj
)));
}
/// \method __str__()
...
...
stmhal/servo.c
View file @
2bf5a947
...
...
@@ -194,7 +194,7 @@ STATIC mp_obj_t pyb_servo_make_new(const mp_obj_type_t *type, size_t n_args, siz
// check servo number
if
(
!
(
0
<=
servo_id
&&
servo_id
<
PYB_SERVO_NUM
))
{
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"Servo
%d does
no
t exist"
,
servo_id
+
1
));
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"Servo
(
%d
)
does
n'
t exist"
,
servo_id
+
1
));
}
// get and init servo object
...
...
stmhal/spi.c
View file @
2bf5a947
...
...
@@ -182,7 +182,7 @@ STATIC int spi_find(mp_obj_t id) {
#endif
}
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"SPI(%s) does
no
t exist"
,
port
));
"SPI(%s) does
n'
t exist"
,
port
));
}
else
{
// given an integer id
int
spi_id
=
mp_obj_get_int
(
id
);
...
...
@@ -191,7 +191,7 @@ STATIC int spi_find(mp_obj_t id) {
return
spi_id
;
}
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"SPI(%d) does
no
t exist"
,
spi_id
));
"SPI(%d) does
n'
t exist"
,
spi_id
));
}
}
...
...
stmhal/timer.c
View file @
2bf5a947
...
...
@@ -702,7 +702,7 @@ STATIC mp_obj_t pyb_timer_make_new(const mp_obj_type_t *type, size_t n_args, siz
#if defined(TIM17)
case
17
:
tim
->
tim
.
Instance
=
TIM17
;
tim
->
irqn
=
TIM1_TRG_COM_TIM17_IRQn
;
break
;
#endif
default:
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"Timer
%d does
no
t exist"
,
tim
->
tim_id
));
default:
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"Timer
(
%d
)
does
n'
t exist"
,
tim
->
tim_id
));
}
// set the global variable for interrupt callbacks
...
...
@@ -896,7 +896,7 @@ STATIC mp_obj_t pyb_timer_channel(mp_uint_t n_args, const mp_obj_t *pos_args, mp
const
pin_obj_t
*
pin
=
pin_obj
;
const
pin_af_obj_t
*
af
=
pin_find_af
(
pin
,
AF_FN_TIM
,
self
->
tim_id
);
if
(
af
==
NULL
)
{
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"
p
in
%q doesn't have an af for T
IM
%d"
,
pin
->
name
,
self
->
tim_id
));
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"
P
in
(
%q
)
doesn't have an af for T
imer(
%d
)
"
,
pin
->
name
,
self
->
tim_id
));
}
// pin.init(mode=AF_PP, af=idx)
const
mp_obj_t
args2
[
6
]
=
{
...
...
stmhal/uart.c
View file @
2bf5a947
...
...
@@ -615,7 +615,7 @@ STATIC mp_obj_t pyb_uart_init_helper(pyb_uart_obj_t *self, mp_uint_t n_args, con
// init UART (if it fails, it's because the port doesn't exist)
if
(
!
uart_init2
(
self
))
{
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"UART(%d) does
no
t exist"
,
self
->
uart_id
));
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"UART(%d) does
n'
t exist"
,
self
->
uart_id
));
}
// set timeout
...
...
@@ -751,12 +751,12 @@ STATIC mp_obj_t pyb_uart_make_new(const mp_obj_type_t *type, size_t n_args, size
uart_id
=
PYB_UART_6
;
#endif
}
else
{
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"UART(%s) does
no
t exist"
,
port
));
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"UART(%s) does
n'
t exist"
,
port
));
}
}
else
{
uart_id
=
mp_obj_get_int
(
args
[
0
]);
if
(
!
uart_exists
(
uart_id
))
{
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"UART(%d) does
no
t exist"
,
uart_id
));
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"UART(%d) does
n'
t exist"
,
uart_id
));
}
}
...
...
stmhal/wdt.c
View file @
2bf5a947
...
...
@@ -49,7 +49,7 @@ STATIC mp_obj_t pyb_wdt_make_new(const mp_obj_type_t *type, size_t n_args, size_
mp_int_t
id
=
args
[
ARG_id
].
u_int
;
if
(
id
!=
0
)
{
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"WDT(%d) does
no
t exist"
,
id
));
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"WDT(%d) does
n'
t exist"
,
id
));
}
// timeout is in milliseconds
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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