2014-10-23 09:25:32 -04:00
|
|
|
#include <errno.h>
|
|
|
|
|
2015-01-01 16:06:20 -05:00
|
|
|
#include "py/nlr.h"
|
|
|
|
#include "py/obj.h"
|
2014-11-27 11:58:31 -05:00
|
|
|
#include "usb.h"
|
2014-10-23 09:25:32 -04:00
|
|
|
#include "mphal.h"
|
|
|
|
|
|
|
|
// this table converts from HAL_StatusTypeDef to POSIX errno
|
|
|
|
const byte mp_hal_status_to_errno_table[4] = {
|
|
|
|
[HAL_OK] = 0,
|
|
|
|
[HAL_ERROR] = EIO,
|
|
|
|
[HAL_BUSY] = EBUSY,
|
|
|
|
[HAL_TIMEOUT] = ETIMEDOUT,
|
|
|
|
};
|
|
|
|
|
|
|
|
NORETURN void mp_hal_raise(HAL_StatusTypeDef status) {
|
2014-11-15 15:39:44 -05:00
|
|
|
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(mp_hal_status_to_errno_table[status])));
|
2014-10-23 09:25:32 -04:00
|
|
|
}
|
2014-11-27 11:58:31 -05:00
|
|
|
|
|
|
|
void mp_hal_set_interrupt_char(int c) {
|
|
|
|
usb_vcp_set_interrupt_char(c);
|
|
|
|
}
|