summaryrefslogtreecommitdiff
path: root/osal/usb_osal_rtthread.c
diff options
context:
space:
mode:
Diffstat (limited to 'osal/usb_osal_rtthread.c')
-rw-r--r--osal/usb_osal_rtthread.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/osal/usb_osal_rtthread.c b/osal/usb_osal_rtthread.c
index e8cbce3a..d355699c 100644
--- a/osal/usb_osal_rtthread.c
+++ b/osal/usb_osal_rtthread.c
@@ -5,6 +5,8 @@
*/
#include "usb_osal.h"
#include "usb_errno.h"
+#include "usb_config.h"
+#include "usb_log.h"
#include <rtthread.h>
#include <rthw.h>
@@ -12,6 +14,11 @@ usb_osal_thread_t usb_osal_thread_create(const char *name, uint32_t stack_size,
{
rt_thread_t htask;
htask = rt_thread_create(name, entry, args, stack_size, prio, 10);
+ if (htask == NULL) {
+ USB_LOG_ERR("Create thread %s failed\r\n", name);
+ while (1) {
+ }
+ }
rt_thread_startup(htask);
return (usb_osal_thread_t)htask;
}
@@ -27,7 +34,13 @@ void usb_osal_thread_delete(usb_osal_thread_t thread)
usb_osal_sem_t usb_osal_sem_create(uint32_t initial_count)
{
- return (usb_osal_sem_t)rt_sem_create("usbh_sem", initial_count, RT_IPC_FLAG_FIFO);
+ usb_osal_sem_t sem = (usb_osal_sem_t)rt_sem_create("usbh_sem", initial_count, RT_IPC_FLAG_FIFO);
+ if (sem == NULL) {
+ USB_LOG_ERR("Create semaphore failed\r\n");
+ while (1) {
+ }
+ }
+ return sem;
}
void usb_osal_sem_delete(usb_osal_sem_t sem)
@@ -68,7 +81,13 @@ void usb_osal_sem_reset(usb_osal_sem_t sem)
usb_osal_mutex_t usb_osal_mutex_create(void)
{
- return (usb_osal_mutex_t)rt_mutex_create("usbh_mutex", RT_IPC_FLAG_FIFO);
+ usb_osal_mutex_t mutex = (usb_osal_mutex_t)rt_mutex_create("usbh_mutex", RT_IPC_FLAG_FIFO);
+ if (mutex == NULL) {
+ USB_LOG_ERR("Create mutex failed\r\n");
+ while (1) {
+ }
+ }
+ return mutex;
}
void usb_osal_mutex_delete(usb_osal_mutex_t mutex)
@@ -127,11 +146,18 @@ struct usb_osal_timer *usb_osal_timer_create(const char *name, uint32_t timeout_
struct usb_osal_timer *timer;
timer = rt_malloc(sizeof(struct usb_osal_timer));
+ if (timer == NULL) {
+ USB_LOG_ERR("Create usb_osal_timer failed\r\n");
+ while (1) {
+ }
+ }
memset(timer, 0, sizeof(struct usb_osal_timer));
timer->timer = (void *)rt_timer_create(name, handler, argument, timeout_ms, is_period ? (RT_TIMER_FLAG_PERIODIC | RT_TIMER_FLAG_SOFT_TIMER) : (RT_TIMER_FLAG_ONE_SHOT | RT_TIMER_FLAG_SOFT_TIMER));
if (timer->timer == NULL) {
- return NULL;
+ USB_LOG_ERR("Create timer failed\r\n");
+ while (1) {
+ }
}
return timer;
}