Changeset 3d932af6 in mainline for uspace/lib/usb/src/host/endpoint.c


Ignore:
Timestamp:
2011-04-12T21:07:27Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade
Children:
6bb0f43
Parents:
2cc6e97
Message:

Add support for custom data in endpoint structure.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usb/src/host/endpoint.c

    r2cc6e97 r3d932af6  
    6363}
    6464/*----------------------------------------------------------------------------*/
     65void endpoint_set_hc_data(endpoint_t *instance,
     66    void *data, int (*toggle_get)(void *), void (*toggle_set)(void *, int))
     67{
     68        assert(instance);
     69        instance->hc_data.data = data;
     70        instance->hc_data.toggle_get = toggle_get;
     71        instance->hc_data.toggle_set = toggle_set;
     72}
     73/*----------------------------------------------------------------------------*/
     74void endpoint_clear_hc_data(endpoint_t *instance)
     75{
     76        assert(instance);
     77        instance->hc_data.data = NULL;
     78        instance->hc_data.toggle_get = NULL;
     79        instance->hc_data.toggle_set = NULL;
     80}
     81/*----------------------------------------------------------------------------*/
    6582void endpoint_use(endpoint_t *instance)
    6683{
     
    85102{
    86103        assert(instance);
     104        if (instance->hc_data.toggle_get)
     105                instance->toggle =
     106                    instance->hc_data.toggle_get(instance->hc_data.data);
    87107        return (int)instance->toggle;
    88108}
     
    92112        assert(instance);
    93113        assert(toggle == 0 || toggle == 1);
     114        if (instance->hc_data.toggle_set)
     115                instance->hc_data.toggle_set(instance->hc_data.data, toggle);
    94116        instance->toggle = toggle;
    95117}
Note: See TracChangeset for help on using the changeset viewer.