qmk_firmware

QMK firmware for my keyboards (Corne, Sweep Ferris) and trackball (Ploopy Adept)
Log | Files | Refs | Submodules | LICENSE

usb_endpoints.h (3458B)


      1 // Copyright 2023 Stefan Kerkmann (@KarlK90)
      2 // SPDX-License-Identifier: GPL-3.0-or-later
      3 
      4 #pragma once
      5 
      6 #include "usb_descriptor.h"
      7 
      8 #if !defined(USB_DEFAULT_BUFFER_CAPACITY)
      9 #    define USB_DEFAULT_BUFFER_CAPACITY 4
     10 #endif
     11 
     12 #if !defined(KEYBOARD_IN_CAPACITY)
     13 #    define KEYBOARD_IN_CAPACITY USB_DEFAULT_BUFFER_CAPACITY
     14 #endif
     15 #if !defined(SHARED_IN_CAPACITY)
     16 #    define SHARED_IN_CAPACITY USB_DEFAULT_BUFFER_CAPACITY
     17 #endif
     18 #if !defined(MOUSE_IN_CAPACITY)
     19 #    define MOUSE_IN_CAPACITY USB_DEFAULT_BUFFER_CAPACITY
     20 #endif
     21 
     22 #if !defined(JOYSTICK_IN_CAPACITY)
     23 #    define JOYSTICK_IN_CAPACITY USB_DEFAULT_BUFFER_CAPACITY
     24 #endif
     25 
     26 #if !defined(DIGITIZER_IN_CAPACITY)
     27 #    define DIGITIZER_IN_CAPACITY USB_DEFAULT_BUFFER_CAPACITY
     28 #endif
     29 
     30 #if !defined(CONSOLE_IN_CAPACITY)
     31 #    define CONSOLE_IN_CAPACITY USB_DEFAULT_BUFFER_CAPACITY
     32 #endif
     33 
     34 #if !defined(CONSOLE_OUT_CAPACITY)
     35 #    define CONSOLE_OUT_CAPACITY USB_DEFAULT_BUFFER_CAPACITY
     36 #endif
     37 
     38 #if !defined(RAW_IN_CAPACITY)
     39 #    define RAW_IN_CAPACITY USB_DEFAULT_BUFFER_CAPACITY
     40 #endif
     41 
     42 #if !defined(RAW_OUT_CAPACITY)
     43 #    define RAW_OUT_CAPACITY USB_DEFAULT_BUFFER_CAPACITY
     44 #endif
     45 
     46 #if !defined(MIDI_STREAM_IN_CAPACITY)
     47 #    define MIDI_STREAM_IN_CAPACITY USB_DEFAULT_BUFFER_CAPACITY
     48 #endif
     49 
     50 #if !defined(MIDI_STREAM_OUT_CAPACITY)
     51 #    define MIDI_STREAM_OUT_CAPACITY USB_DEFAULT_BUFFER_CAPACITY
     52 #endif
     53 
     54 #if !defined(CDC_IN_CAPACITY)
     55 #    define CDC_IN_CAPACITY USB_DEFAULT_BUFFER_CAPACITY
     56 #endif
     57 
     58 #if !defined(CDC_OUT_CAPACITY)
     59 #    define CDC_OUT_CAPACITY USB_DEFAULT_BUFFER_CAPACITY
     60 #endif
     61 
     62 #define CDC_SIGNALING_DUMMY_CAPACITY 1
     63 
     64 typedef enum {
     65 #if defined(SHARED_EP_ENABLE)
     66     USB_ENDPOINT_IN_SHARED,
     67 #endif
     68 
     69 #if !defined(KEYBOARD_SHARED_EP)
     70     USB_ENDPOINT_IN_KEYBOARD,
     71 #endif
     72 
     73 #if defined(MOUSE_ENABLE) && !defined(MOUSE_SHARED_EP)
     74     USB_ENDPOINT_IN_MOUSE,
     75 #endif
     76 
     77 #if defined(JOYSTICK_ENABLE) && !defined(JOYSTICK_SHARED_EP)
     78     USB_ENDPOINT_IN_JOYSTICK,
     79 #endif
     80 
     81 #if defined(DIGITIZER_ENABLE) && !defined(DIGITIZER_SHARED_EP)
     82     USB_ENDPOINT_IN_DIGITIZER,
     83 #endif
     84 
     85 #if defined(CONSOLE_ENABLE)
     86     USB_ENDPOINT_IN_CONSOLE,
     87 #endif
     88 
     89 #if defined(RAW_ENABLE)
     90     USB_ENDPOINT_IN_RAW,
     91 #endif
     92 
     93 #if defined(MIDI_ENABLE)
     94     USB_ENDPOINT_IN_MIDI,
     95 #endif
     96 
     97 #if defined(VIRTSER_ENABLE)
     98     USB_ENDPOINT_IN_CDC_DATA,
     99     USB_ENDPOINT_IN_CDC_SIGNALING,
    100 #endif
    101     USB_ENDPOINT_IN_COUNT,
    102 /* All non shared endpoints have to be consequtive numbers starting from 0, so
    103  * that they can be used as array indices. The shared endpoints all point to
    104  * the same endpoint so they have to be defined last to not reset the enum
    105  * counter. */
    106 #if defined(SHARED_EP_ENABLE)
    107 #    if defined(KEYBOARD_SHARED_EP)
    108     USB_ENDPOINT_IN_KEYBOARD = USB_ENDPOINT_IN_SHARED,
    109 #    endif
    110 #    if defined(MOUSE_SHARED_EP)
    111     USB_ENDPOINT_IN_MOUSE = USB_ENDPOINT_IN_SHARED,
    112 #    endif
    113 #    if defined(JOYSTICK_SHARED_EP)
    114     USB_ENDPOINT_IN_JOYSTICK = USB_ENDPOINT_IN_SHARED,
    115 #    endif
    116 #    if defined(DIGITIZER_SHARED_EP)
    117     USB_ENDPOINT_IN_DIGITIZER = USB_ENDPOINT_IN_SHARED,
    118 #    endif
    119 #endif
    120 } usb_endpoint_in_lut_t;
    121 
    122 #define IS_VALID_USB_ENDPOINT_IN_LUT(i) ((i) >= 0 && (i) < USB_ENDPOINT_IN_COUNT)
    123 
    124 extern usb_endpoint_in_lut_t usb_endpoint_interface_lut[TOTAL_INTERFACES];
    125 
    126 typedef enum {
    127 #if defined(RAW_ENABLE)
    128     USB_ENDPOINT_OUT_RAW,
    129 #endif
    130 #if defined(MIDI_ENABLE)
    131     USB_ENDPOINT_OUT_MIDI,
    132 #endif
    133 #if defined(VIRTSER_ENABLE)
    134     USB_ENDPOINT_OUT_CDC_DATA,
    135 #endif
    136     USB_ENDPOINT_OUT_COUNT,
    137 } usb_endpoint_out_lut_t;