diff options
author | Damien George <damien.p.george@gmail.com> | 2014-10-23 14:25:32 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-10-23 14:25:32 +0100 |
commit | 185cb0d943aa73485a83e1c146d9db899973378d (patch) | |
tree | 4e3128ddb6e30ba15f666aabbddb82f8df3729c1 /stmhal/can.c | |
parent | e7bb0443cda9bfb88791c3a99bf0331217390eb4 (diff) |
stmhal: Use OSError with POSIX error code for HAL errors.
Addresses issue #921.
Diffstat (limited to 'stmhal/can.c')
-rw-r--r-- | stmhal/can.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/stmhal/can.c b/stmhal/can.c index 920a4ad0b..5600bfae0 100644 --- a/stmhal/can.c +++ b/stmhal/can.c @@ -29,8 +29,6 @@ #include <stdarg.h> #include <errno.h> -#include "stm32f4xx_hal.h" - #include "mpconfig.h" #include "nlr.h" #include "misc.h" @@ -41,6 +39,7 @@ #include "bufhelper.h" #include "can.h" #include "pybioctl.h" +#include MICROPY_HAL_H #if MICROPY_HW_ENABLE_CAN @@ -334,8 +333,7 @@ STATIC mp_obj_t pyb_can_send(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_ HAL_StatusTypeDef status = HAL_CAN_Transmit(&self->can, args[2].u_int); if (status != HAL_OK) { - // TODO really need a HardwareError object, or something - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_Exception, "HAL_CAN_Transmit failed with code %d", status)); + mp_hal_raise(status); } return mp_const_none; @@ -367,8 +365,7 @@ STATIC mp_obj_t pyb_can_recv(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_ HAL_StatusTypeDef status = HAL_CAN_Receive(&self->can, args[0].u_int, args[1].u_int); if (status != HAL_OK) { - // TODO really need a HardwareError object, or something - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_Exception, "HAL_CAN_Receive failed with code %d", status)); + mp_hal_raise(status); } // return the received data |