poll(): refactor every poll argument t_us and tflp -> time_curr_us
added comment to usbh_hubbed.h Signed-off-by: Amir Hammad <amir.hammad@hotmail.com>
This commit is contained in:
parent
e9c2632a19
commit
e35c1e9fc6
6 changed files with 30 additions and 20 deletions
|
|
@ -91,7 +91,7 @@ struct _usbh_driver {
|
|||
void (*init)(void *drvdata);
|
||||
void (*write)(void *drvdata, const usbh_packet_t *packet);
|
||||
void (*read)(void *drvdata, usbh_packet_t *packet);
|
||||
enum USBH_POLL_STATUS (*poll)(void *drvdata, uint32_t t_us);
|
||||
enum USBH_POLL_STATUS (*poll)(void *drvdata, uint32_t time_curr_us);
|
||||
uint8_t (*root_speed)(void *drvdata);
|
||||
|
||||
// Pointer to Low-level driver data
|
||||
|
|
|
|||
|
|
@ -62,14 +62,23 @@ typedef struct _usbh_dev_driver_info usbh_dev_driver_info_t;
|
|||
struct _usbh_dev_driver {
|
||||
bool (*analyze_descriptor)(void *drv, void *descriptor);
|
||||
void *(*init)(void *usbh_dev);
|
||||
void (*poll)(void *drvdata, uint32_t t_us);
|
||||
void (*poll)(void *drvdata, uint32_t time_curr_us);
|
||||
void (*remove)(void *drvdata);
|
||||
const usbh_dev_driver_info_t * const info;
|
||||
};
|
||||
typedef struct _usbh_dev_driver usbh_dev_driver_t;
|
||||
|
||||
void usbh_init(const void *drivers[], const usbh_dev_driver_t * const device_drivers[]);
|
||||
void usbh_poll(uint32_t t_us);
|
||||
|
||||
/**
|
||||
* \brief usbh_poll
|
||||
* \param time_curr_us - use monotically rising time
|
||||
*
|
||||
* time_curr_us:
|
||||
* * can overflow, in time of this writing, after 1s)
|
||||
* * unit is microseconds
|
||||
*/
|
||||
void usbh_poll(uint32_t time_curr_us);
|
||||
|
||||
END_DECLS
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
static void *gp_xbox_init(void *usbh_dev);
|
||||
static bool gp_xbox_analyze_descriptor(void *drvdata, void *descriptor);
|
||||
static void gp_xbox_poll(void *drvdata, uint32_t tflp);
|
||||
static void gp_xbox_poll(void *drvdata, uint32_t time_curr_us);
|
||||
static void gp_xbox_remove(void *drvdata);
|
||||
|
||||
static const usbh_dev_driver_info_t usbh_gp_xbox_driver_info = {
|
||||
|
|
@ -367,12 +367,13 @@ static void read_gp_xbox_in(gp_xbox_device_t *gp_xbox)
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* tflp time from last poll [us]
|
||||
* \param time_curr_us - monotically rising time (see usbh_hubbed.h)
|
||||
* unit is microseconds
|
||||
*/
|
||||
static void gp_xbox_poll(void *drvdata, uint32_t tflp)
|
||||
static void gp_xbox_poll(void *drvdata, uint32_t time_curr_us)
|
||||
{
|
||||
(void)tflp;
|
||||
(void)time_curr_us;
|
||||
|
||||
gp_xbox_device_t *gp_xbox = drvdata;
|
||||
usbh_device_t *dev = gp_xbox->usbh_device;
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
static void *mouse_init(void *usbh_dev);
|
||||
static bool mouse_analyze_descriptor(void *drvdata, void *descriptor);
|
||||
static void mouse_poll(void *drvdata, uint32_t tflp);
|
||||
static void mouse_poll(void *drvdata, uint32_t time_curr_us);
|
||||
static void mouse_remove(void *drvdata);
|
||||
|
||||
static const usbh_dev_driver_info_t usbh_hid_mouse_driver_info = {
|
||||
|
|
@ -248,13 +248,13 @@ static void read_mouse_in(void *drvdata)
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* tflp time from last poll [us]
|
||||
* \param time_curr_us - monotically rising time (see usbh_hubbed.h)
|
||||
* unit is microseconds
|
||||
*/
|
||||
static void mouse_poll(void *drvdata, uint32_t tflp)
|
||||
static void mouse_poll(void *drvdata, uint32_t time_curr_us)
|
||||
{
|
||||
(void)drvdata;
|
||||
(void)tflp;
|
||||
(void)time_curr_us;
|
||||
|
||||
hid_mouse_device_t *mouse = drvdata;
|
||||
usbh_device_t *dev = mouse->usbh_device;
|
||||
switch (mouse->state_next) {
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ static hub_device_t hub_device[USBH_MAX_HUBS];
|
|||
|
||||
static void *hub_init(void *usbh_dev);
|
||||
static bool hub_analyze_descriptor(void *drvdata, void *descriptor);
|
||||
static void hub_poll(void *drvdata, uint32_t tflp);
|
||||
static void hub_poll(void *drvdata, uint32_t time_curr_us);
|
||||
static void event(usbh_device_t *dev, usbh_packet_callback_data_t cb_data);
|
||||
static void hub_remove(void *drvdata);
|
||||
|
||||
|
|
@ -765,8 +765,8 @@ static void read_ep1(void *drvdata)
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* tflp time from last poll [ms]
|
||||
* \param time_curr_us - monotically rising time (see usbh_hubbed.h)
|
||||
* unit is microseconds
|
||||
*/
|
||||
static void hub_poll(void *drvdata, uint32_t time_curr_us)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -568,7 +568,7 @@ void device_enumeration_start(usbh_device_t *dev)
|
|||
* Should be called with at least 1kHz frequency
|
||||
*
|
||||
*/
|
||||
void usbh_poll(uint32_t t_us)
|
||||
void usbh_poll(uint32_t time_curr_us)
|
||||
{
|
||||
uint32_t k = 0;
|
||||
while (usbh_data.lld_drivers[k]) {
|
||||
|
|
@ -577,7 +577,7 @@ void usbh_poll(uint32_t t_us)
|
|||
usbh_generic_data_t *lld_data = usbh_data.lld_drivers[k]->driver_data;
|
||||
|
||||
enum USBH_POLL_STATUS poll_status =
|
||||
usbh_data.lld_drivers[k]->poll(lld_data, t_us);
|
||||
usbh_data.lld_drivers[k]->poll(lld_data, time_curr_us);
|
||||
|
||||
switch (poll_status) {
|
||||
case USBH_POLL_STATUS_DEVICE_CONNECTED:
|
||||
|
|
@ -613,7 +613,7 @@ void usbh_poll(uint32_t t_us)
|
|||
}
|
||||
|
||||
if (lld_data->usbh_device[0].drv && usbh_device[0].drvdata) {
|
||||
usbh_device[0].drv->poll(usbh_device[0].drvdata, t_us);
|
||||
usbh_device[0].drv->poll(usbh_device[0].drvdata, time_curr_us);
|
||||
}
|
||||
|
||||
k++;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue