usb_osal.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /**
  2. * @file usb_osal.h
  3. * @brief
  4. *
  5. * Copyright (c) 2022 sakumisu
  6. *
  7. * Licensed to the Apache Software Foundation (ASF) under one or more
  8. * contributor license agreements. See the NOTICE file distributed with
  9. * this work for additional information regarding copyright ownership. The
  10. * ASF licenses this file to you under the Apache License, Version 2.0 (the
  11. * "License"); you may not use this file except in compliance with the
  12. * License. You may obtain a copy of the License at
  13. *
  14. * http://www.apache.org/licenses/LICENSE-2.0
  15. *
  16. * Unless required by applicable law or agreed to in writing, software
  17. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  18. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  19. * License for the specific language governing permissions and limitations
  20. * under the License.
  21. *
  22. */
  23. #ifndef _USB_OSAL_H
  24. #define _USB_OSAL_H
  25. #include <stdint.h>
  26. #include <string.h>
  27. typedef void *usb_osal_thread_t;
  28. typedef void *usb_osal_sem_t;
  29. typedef void *usb_osal_mutex_t;
  30. typedef void *usb_osal_event_t;
  31. typedef void (*usb_thread_entry_t)(void *argument);
  32. usb_osal_thread_t usb_osal_thread_create(const char *name, uint32_t stack_size, uint32_t prio, usb_thread_entry_t entry, void *args);
  33. void usb_osal_thread_delete(usb_osal_thread_t thread);
  34. void usb_osal_thread_suspend(usb_osal_thread_t thread);
  35. void usb_osal_thread_resume(usb_osal_thread_t thread);
  36. usb_osal_sem_t usb_osal_sem_create(uint32_t initial_count);
  37. void usb_osal_sem_delete(usb_osal_sem_t sem);
  38. int usb_osal_sem_take(usb_osal_sem_t sem, uint32_t timeout);
  39. int usb_osal_sem_give(usb_osal_sem_t sem);
  40. usb_osal_mutex_t usb_osal_mutex_create(void);
  41. void usb_osal_mutex_delete(usb_osal_mutex_t mutex);
  42. int usb_osal_mutex_take(usb_osal_mutex_t mutex);
  43. int usb_osal_mutex_give(usb_osal_mutex_t mutex);
  44. usb_osal_event_t usb_osal_event_create(void);
  45. void usb_osal_event_delete(usb_osal_event_t event);
  46. int usb_osal_event_recv(usb_osal_event_t event, uint32_t set, uint32_t *recved);
  47. int usb_osal_event_send(usb_osal_event_t event, uint32_t set);
  48. size_t usb_osal_enter_critical_section(void);
  49. void usb_osal_leave_critical_section(size_t flag);
  50. void usb_osal_msleep(uint32_t delay);
  51. #endif