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
17d9b500
Commit
17d9b500
authored
May 28, 2015
by
Damien George
Browse files
stmhal: Fix off-by-one error when checking for valid I2C and SPI bus.
parent
5a57447a
Changes
2
Hide whitespace changes
Inline
Side-by-side
stmhal/i2c.c
View file @
17d9b500
...
...
@@ -327,7 +327,7 @@ STATIC mp_obj_t pyb_i2c_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n
}
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
].
i2c
==
NULL
)
{
||
pyb_i2c_obj
[
i2c_id
-
1
].
i2c
==
NULL
)
{
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"I2C(%d) does not exist"
,
i2c_id
));
}
...
...
stmhal/spi.c
View file @
17d9b500
...
...
@@ -485,7 +485,7 @@ STATIC mp_obj_t pyb_spi_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n
}
else
{
spi_id
=
mp_obj_get_int
(
args
[
0
]);
if
(
spi_id
<
1
||
spi_id
>
MP_ARRAY_SIZE
(
pyb_spi_obj
)
||
pyb_spi_obj
[
spi_id
].
spi
==
NULL
)
{
||
pyb_spi_obj
[
spi_id
-
1
].
spi
==
NULL
)
{
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"SPI(%d) does not exist"
,
spi_id
));
}
...
...
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