Changeset 3d932af6 in mainline


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, topic/simplify-dev-export
Children:
6bb0f43
Parents:
2cc6e97
Message:

Add support for custom data in endpoint structure.

Location:
uspace/lib/usb
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usb/include/usb/host/endpoint.h

    r2cc6e97 r3d932af6  
    5454        fibril_condvar_t avail;
    5555        volatile bool active;
     56        struct {
     57                void *data;
     58                int (*toggle_get)(void *);
     59                void (*toggle_set)(void *, int);
     60        } hc_data;
    5661} endpoint_t;
    5762
     
    6166
    6267void endpoint_destroy(endpoint_t *instance);
     68
     69void endpoint_set_hc_data(endpoint_t *instance,
     70    void *data, int (*toggle_get)(void *), void (*toggle_set)(void *, int));
     71
     72void endpoint_clear_hc_data(endpoint_t *instance);
    6373
    6474void endpoint_use(endpoint_t *instance);
  • 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.