usbinst.c
2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*HEADER******************************************************************
**************************************************************************
***
*** Copyright (c) 2001-2002 ARC International.
*** All rights reserved
***
*** This software embodies materials and concepts which are
*** confidential to ARC International and is made
*** available solely pursuant to the terms of a written license
*** agreement with ARC International
***
*** File: usbinst.c
***
*** Comments:
*** This file contains the function to install the low-level driver functions
***
**************************************************************************
*END*********************************************************************/
#include "mqx.h"
#include "bsp.h"
#include "usbprv.h"
/*FUNCTION*-------------------------------------------------------------
*
* Function Name : _usb_driver_install
* Returned Value : None
* Comments :
* Installs the device
*END*-----------------------------------------------------------------*/
uint_8 _usb_driver_install
(
/* [IN] device number */
uint_32 device_number,
/* [IN] address if the callback functions structure */
pointer callback_struct_ptr
)
{ /* Body */
pointer callback_struct_table_ptr;
callback_struct_table_ptr = _mqx_get_io_component_handle(IO_USB_COMPONENT);
if (!callback_struct_table_ptr) {
callback_struct_table_ptr =
USB_memalloc(BSP_MAX_USB_DRIVERS*
sizeof(USB_CALLBACK_FUNCTIONS_STRUCT));
if (!callback_struct_table_ptr) {
return USBERR_DRIVER_INSTALL_FAILED;
} /* Endif */
USB_memzero((uchar_ptr)callback_struct_table_ptr,
sizeof(callback_struct_table_ptr));
_mqx_set_io_component_handle(IO_USB_COMPONENT,
callback_struct_table_ptr);
} /* Endif */
*((USB_CALLBACK_FUNCTIONS_STRUCT_PTR)\
(((USB_CALLBACK_FUNCTIONS_STRUCT_PTR)callback_struct_table_ptr) +
device_number)) =
*((USB_CALLBACK_FUNCTIONS_STRUCT_PTR)callback_struct_ptr);
} /* EndBody */
/* EOF */