VSF Documented
|
#include "component/usb/vsf_usb_cfg.h"
#include "kernel/vsf_kernel.h"
#include "component/usb/host/vsf_usbh.h"
#include "./vsf_webusb_hcd.h"
#include <emscripten.h>
#include <emscripten/val.h>
#include <emscripten/threading.h>
Data Structures | |
struct | vk_webusb_hcd_dev_t |
struct | vk_webusb_hcd_t |
struct | vk_webusb_hcd_urb_t |
struct | promise_result |
Macros | |
#define | __VSF_USBH_CLASS_IMPLEMENT_HCD__ |
#define | __VSF_USBH_CLASS_IMPLEMENT_HUB__ |
#define | __VSF_EDA_CLASS_INHERIT__ |
#define | __OOC_CPP__ |
#define | VSF_EVT_WEBUSB_HCD_BASE ((VSF_EVT_USER + 0x100) & ~0xFF) |
#define | VSF_WEBUSB_HCD_DEF_DEV(__N, __BIT) |
Typedefs | |
typedef enum vk_webusb_hcd_dev_state_t | vk_webusb_hcd_dev_state_t |
typedef struct vk_webusb_hcd_dev_t | vk_webusb_hcd_dev_t |
typedef struct vk_webusb_hcd_t | vk_webusb_hcd_t |
typedef enum vk_webusb_hcd_state_t | vk_webusb_hcd_state_t |
typedef struct vk_webusb_hcd_urb_t | vk_webusb_hcd_urb_t |
typedef enum vk_webusb_hcd_evt_t | vk_webusb_hcd_evt_t |
Enumerations | |
enum | webusb_error { WEBUSB_SUCCESS = 0 , WEBUSB_ERROR_IO = -1 , WEBUSB_ERROR_INVALID_PARAM = -2 , WEBUSB_ERROR_ACCESS = -3 , WEBUSB_ERROR_NO_DEVICE = -4 , WEBUSB_ERROR_NOT_FOUND = -5 , WEBUSB_ERROR_BUSY = -6 , WEBUSB_ERROR_TIMEOUT = -7 , WEBUSB_ERROR_OVERFLOW = -8 , WEBUSB_ERROR_PIPE = -9 , WEBUSB_ERROR_INTERRUPTED = -10 , WEBUSB_ERROR_NO_MEM = -11 , WEBUSB_ERROR_NOT_SUPPORTED = -12 , WEBUSB_ERROR_OTHER = -99 } |
enum | vk_webusb_hcd_dev_state_t { VSF_WEBUSB_HCD_DEV_STATE_DETACHED , VSF_WEBUSB_HCD_DEV_STATE_DETACHING , VSF_WEBUSB_HCD_DEV_STATE_ATTACHED } |
enum | vk_webusb_hcd_state_t { VSF_WEBUSB_HCD_URB_STATE_IDLE , VSF_WEBUSB_HCD_URB_STATE_QUEUED , VSF_WEBUSB_HCD_URB_STATE_SUBMITTING , VSF_WEBUSB_HCD_URB_STATE_WAIT_TO_FREE , VSF_WEBUSB_HCD_URB_STATE_TO_FREE } |
enum | vk_webusb_hcd_evt_t { VSF_EVT_WEBUSB_HCD_ATTACH = VSF_EVT_WEBUSB_HCD_BASE + 0x100 , VSF_EVT_WEBUSB_HCD_DETACH = VSF_EVT_WEBUSB_HCD_BASE + 0x200 } |
Functions | |
vsf_err_t | __vk_webusb_hcd_init_evthandler (vsf_eda_t *eda, vsf_evt_t evt, vk_usbh_hcd_t *hcd) |
vsf_err_t | __vk_webusb_hcd_fini (vk_usbh_hcd_t *hcd) |
vsf_err_t | __vk_webusb_hcd_suspend (vk_usbh_hcd_t *hcd) |
vsf_err_t | __vk_webusb_hcd_resume (vk_usbh_hcd_t *hcd) |
uint_fast16_t | __vk_webusb_hcd_get_frame_number (vk_usbh_hcd_t *hcd) |
vsf_err_t | __vk_webusb_hcd_alloc_device (vk_usbh_hcd_t *hcd, vk_usbh_hcd_dev_t *dev) |
void | __vk_webusb_hcd_free_device (vk_usbh_hcd_t *hcd, vk_usbh_hcd_dev_t *dev) |
vk_usbh_hcd_urb_t * | __vk_webusb_hcd_alloc_urb (vk_usbh_hcd_t *hcd) |
void | __vk_webusb_hcd_free_urb (vk_usbh_hcd_t *hcd, vk_usbh_hcd_urb_t *urb) |
vsf_err_t | __vk_webusb_hcd_submit_urb (vk_usbh_hcd_t *hcd, vk_usbh_hcd_urb_t *urb) |
vsf_err_t | __vk_webusb_hcd_relink_urb (vk_usbh_hcd_t *hcd, vk_usbh_hcd_urb_t *urb) |
vsf_err_t | __vk_webusb_hcd_reset_dev (vk_usbh_hcd_t *hcd, vk_usbh_hcd_dev_t *dev) |
bool | __vk_webusb_hcd_is_dev_reset (vk_usbh_hcd_t *hcd, vk_usbh_hcd_dev_t *dev) |
void | __vk_webusb_hcd_dev_thread (void *arg) |
EM_JS (EM_VAL, __vk_webusb_empromise_catch_imp,(EM_VAL handle), { let promise=Emval.toValue(handle);promise=promise.then(value=>({error :0, value}), error=> { const ERROR_CODES={ NetworkError :-1, DataError :-2, TypeMismatchError :-2, IndexSizeError :-2, SecurityError :-3, NotFoundError :-5, InvalidStateError :-6, TimeoutError :-7, AbortError :-10, NotSupportedError :-12, };let errorCode=-99;if(error instanceof DOMException) { errorCode=ERROR_CODES[error.name] ?? errorCode;} else if((error instanceof RangeError)||(error instanceof TypeError)) { errorCode=-2;} return {error:errorCode, value:undefined};});return Emval.toHandle(promise);}) | |
val | create_out_buffer (uint8_t *buffer, size_t size) |
Variables | |
const vk_usbh_hcd_drv_t | vk_webusb_hcd_drv |
#define __VSF_USBH_CLASS_IMPLEMENT_HCD__ |
#define __VSF_USBH_CLASS_IMPLEMENT_HUB__ |
#define __VSF_EDA_CLASS_INHERIT__ |
#define __OOC_CPP__ |
#define VSF_EVT_WEBUSB_HCD_BASE ((VSF_EVT_USER + 0x100) & ~0xFF) |
#define VSF_WEBUSB_HCD_DEF_DEV | ( | __N, | |
__BIT | |||
) |
typedef enum vk_webusb_hcd_dev_state_t vk_webusb_hcd_dev_state_t |
typedef struct vk_webusb_hcd_dev_t vk_webusb_hcd_dev_t |
typedef struct vk_webusb_hcd_t vk_webusb_hcd_t |
typedef enum vk_webusb_hcd_state_t vk_webusb_hcd_state_t |
typedef struct vk_webusb_hcd_urb_t vk_webusb_hcd_urb_t |
typedef enum vk_webusb_hcd_evt_t vk_webusb_hcd_evt_t |
enum webusb_error |
enum vk_webusb_hcd_evt_t |
vsf_err_t __vk_webusb_hcd_init_evthandler | ( | vsf_eda_t * | eda, |
vsf_evt_t | evt, | ||
vk_usbh_hcd_t * | hcd | ||
) |
vsf_err_t __vk_webusb_hcd_fini | ( | vk_usbh_hcd_t * | hcd | ) |
vsf_err_t __vk_webusb_hcd_suspend | ( | vk_usbh_hcd_t * | hcd | ) |
vsf_err_t __vk_webusb_hcd_resume | ( | vk_usbh_hcd_t * | hcd | ) |
uint_fast16_t __vk_webusb_hcd_get_frame_number | ( | vk_usbh_hcd_t * | hcd | ) |
vsf_err_t __vk_webusb_hcd_alloc_device | ( | vk_usbh_hcd_t * | hcd, |
vk_usbh_hcd_dev_t * | dev | ||
) |
void __vk_webusb_hcd_free_device | ( | vk_usbh_hcd_t * | hcd, |
vk_usbh_hcd_dev_t * | dev | ||
) |
vk_usbh_hcd_urb_t * __vk_webusb_hcd_alloc_urb | ( | vk_usbh_hcd_t * | hcd | ) |
void __vk_webusb_hcd_free_urb | ( | vk_usbh_hcd_t * | hcd, |
vk_usbh_hcd_urb_t * | urb | ||
) |
vsf_err_t __vk_webusb_hcd_submit_urb | ( | vk_usbh_hcd_t * | hcd, |
vk_usbh_hcd_urb_t * | urb | ||
) |
vsf_err_t __vk_webusb_hcd_relink_urb | ( | vk_usbh_hcd_t * | hcd, |
vk_usbh_hcd_urb_t * | urb | ||
) |
vsf_err_t __vk_webusb_hcd_reset_dev | ( | vk_usbh_hcd_t * | hcd, |
vk_usbh_hcd_dev_t * | dev | ||
) |
bool __vk_webusb_hcd_is_dev_reset | ( | vk_usbh_hcd_t * | hcd, |
vk_usbh_hcd_dev_t * | dev | ||
) |
void __vk_webusb_hcd_dev_thread | ( | void * | arg | ) |
EM_JS | ( | EM_VAL | , |
__vk_webusb_empromise_catch_imp | , | ||
(EM_VAL handle) | , | ||
{ let promise=Emval.toValue(handle);promise=promise.then(value=>({error :0, value}), error=> { const ERROR_CODES={ NetworkError :-1, DataError :-2, TypeMismatchError :-2, IndexSizeError :-2, SecurityError :-3, NotFoundError :-5, InvalidStateError :-6, TimeoutError :-7, AbortError :-10, NotSupportedError :-12, };let errorCode=-99;if(error instanceof DOMException) { errorCode=ERROR_CODES[error.name] ?? errorCode;} else if((error instanceof RangeError)||(error instanceof TypeError)) { errorCode=-2;} return {error:errorCode, value:undefined};});return Emval.toHandle(promise);} | |||
) |
const vk_usbh_hcd_drv_t vk_webusb_hcd_drv |