mbed-os5 only for TYBLE16
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
Diff: hal/mbed_ticker_api.c
- Revision:
- 1:9db0e321a9f4
- Parent:
- 0:5b88d5760320
diff -r 5b88d5760320 -r 9db0e321a9f4 hal/mbed_ticker_api.c --- a/hal/mbed_ticker_api.c Tue Dec 17 23:23:45 2019 +0000 +++ b/hal/mbed_ticker_api.c Tue Dec 31 06:02:27 2019 +0000 @@ -19,6 +19,7 @@ #include "hal/ticker_api.h" #include "platform/mbed_critical.h" #include "platform/mbed_assert.h" +#include "platform/mbed_error.h" static void schedule_interrupt(const ticker_data_t *const ticker); static void update_present_time(const ticker_data_t *const ticker); @@ -42,8 +43,17 @@ const ticker_info_t *info = ticker->interface->get_info(); uint32_t frequency = info->frequency; if (info->frequency == 0) { - MBED_ASSERT(0); +#if MBED_TRAP_ERRORS_ENABLED + MBED_ERROR( + MBED_MAKE_ERROR( + MBED_MODULE_HAL, + MBED_ERROR_CODE_NOT_READY + ), + "Ticker frequency is zero" + ); +#else frequency = 1000000; +#endif // MBED_TRAP_ERRORS_ENABLED } uint8_t frequency_shifts = 0; @@ -56,8 +66,17 @@ uint32_t bits = info->bits; if ((info->bits > 32) || (info->bits < 4)) { - MBED_ASSERT(0); +#if MBED_TRAP_ERRORS_ENABLED + MBED_ERROR( + MBED_MAKE_ERROR( + MBED_MODULE_HAL, + MBED_ERROR_CODE_INVALID_SIZE + ), + "Ticker number of bit is greater than 32 or less than 4 bits" + ); +#else bits = 32; +#endif // MBED_TRAP_ERRORS_ENABLED } uint32_t max_delta = 0x7 << (bits - 4); // 7/16th uint64_t max_delta_us =