]>
git.gir.st - tmk_keyboard.git/blob - tool/mbed/mbed-sdk/libraries/USBHost/USBHost/USBHALHost.h
1 /* mbed USBHost Library
2 * Copyright (c) 2006-2013 ARM Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include "USBHostTypes.h"
21 #include "USBHostConf.h"
33 * init variables and memory where will be stored HCCA, ED and TD
38 * Initialize host controller. Enable USB interrupts. This part is not in the constructor because,
39 * this function calls a virtual method if a device is already connected
49 * return the value contained in the control HEAD ED register
51 * @returns address of the control Head ED
53 uint32_t controlHeadED();
56 * return the value contained in the bulk HEAD ED register
58 * @returns address of the bulk head ED
60 uint32_t bulkHeadED();
63 * return the value of the head interrupt ED contained in the HCCA
65 * @returns address of the head interrupt ED contained in the HCCA
67 uint32_t interruptHeadED();
70 * Update the head ED for control transfers
72 void updateControlHeadED(uint32_t addr
);
75 * Update the head ED for bulk transfers
77 void updateBulkHeadED(uint32_t addr
);
80 * Update the head ED for interrupt transfers
82 void updateInterruptHeadED(uint32_t addr
);
85 * Enable List for the specified endpoint type
87 * @param type enable the list of ENDPOINT_TYPE type
89 void enableList(ENDPOINT_TYPE type
);
92 * Disable List for the specified endpoint type
94 * @param type disable the list of ENDPOINT_TYPE type
96 bool disableList(ENDPOINT_TYPE type
);
99 * Virtual method called when a device has been connected
101 * @param hub hub number of the device
102 * @param port port number of the device
103 * @param lowSpeed 1 if low speed, 0 otherwise
104 * @param hub_parent reference to the hub where the device is connected (NULL if the hub parent is the root hub)
106 virtual void deviceConnected(int hub
, int port
, bool lowSpeed
, USBHostHub
* hub_parent
= NULL
) = 0;
109 * Virtual method called when a device has been disconnected
111 * @param hub hub number of the device
112 * @param port port number of the device
113 * @param hub_parent reference to the hub where the device is connected (NULL if the hub parent is the root hub)
114 * @param addr list of the TDs which have been completed to dequeue freed TDs
116 virtual void deviceDisconnected(int hub
, int port
, USBHostHub
* hub_parent
, volatile uint32_t addr
) = 0;
119 * Virtual method called when a transfer has been completed
121 * @param addr list of the TDs which have been completed
123 virtual void transferCompleted(volatile uint32_t addr
) = 0;
126 * Find a memory section for a new ED
128 * @returns the address of the new ED
130 volatile uint8_t * getED();
133 * Find a memory section for a new TD
135 * @returns the address of the new TD
137 volatile uint8_t * getTD();
140 * Release a previous memory section reserved for an ED
142 * @param ed address of the ED
144 void freeED(volatile uint8_t * ed
);
147 * Release a previous memory section reserved for an TD
149 * @param td address of the TD
151 void freeTD(volatile uint8_t * td
);
154 static void _usbisr(void);
155 void UsbIrqhandler();
159 HCCA
volatile * usb_hcca
; //256 bytes aligned
160 uint8_t volatile * usb_edBuf
; //4 bytes aligned
161 uint8_t volatile * usb_tdBuf
; //4 bytes aligned
163 static USBHALHost
* instHost
;
165 bool volatile edBufAlloc
[MAX_ENDPOINT
];
166 bool volatile tdBufAlloc
[MAX_TD
];