Werner's Miscellanea
Sign in or create your account | Project List | Help
Werner's Miscellanea Git Source Tree
Root/
| 1 | /* |
| 2 | * include/labsw/ep0.h - EP0 extension protocol |
| 3 | * |
| 4 | * Written 2011 by Werner Almesberger |
| 5 | * Copyright 2011 Werner Almesberger |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | */ |
| 12 | |
| 13 | |
| 14 | #ifndef EP0_H |
| 15 | #define EP0_H |
| 16 | |
| 17 | /* |
| 18 | * Direction bRequest wValue wIndex wLength |
| 19 | * |
| 20 | * ->host LABSW_ID - - 3 |
| 21 | * ->host LABSW_BUILD - - #bytes |
| 22 | * host-> LABSW_RESET - - 0 |
| 23 | * |
| 24 | * ->host LABSW_GET - - 2 |
| 25 | * host-> LABSW_SET values mask 0 |
| 26 | */ |
| 27 | |
| 28 | /* |
| 29 | * EP0 protocol: |
| 30 | * |
| 31 | * 0.0 initial release |
| 32 | */ |
| 33 | |
| 34 | #define EP0LABSW_MAJOR 0 /* EP0 protocol, major revision */ |
| 35 | #define EP0LABSW_MINOR 0 /* EP0 protocol, minor revision */ |
| 36 | |
| 37 | /* |
| 38 | * bmRequestType: |
| 39 | * |
| 40 | * D7 D6..5 D4...0 |
| 41 | * | | | |
| 42 | * direction (0 = host->dev) |
| 43 | * type (2 = vendor) |
| 44 | * recipient (0 = device) |
| 45 | */ |
| 46 | |
| 47 | |
| 48 | #define LABSW_TO_DEV(req) (0x40 | (req) << 8) |
| 49 | #define LABSW_FROM_DEV(req) (0xc0 | (req) << 8) |
| 50 | |
| 51 | |
| 52 | enum cntr_requests { |
| 53 | LABSW_ID = 0x00, |
| 54 | LABSW_BUILD, |
| 55 | LABSW_RESET, |
| 56 | LABSW_GET = 0x10, |
| 57 | LABSW_SET, |
| 58 | }; |
| 59 | |
| 60 | /* |
| 61 | * LABSW_GET encoding: |
| 62 | * |
| 63 | * byte 0 byte 1 |
| 64 | * 76543210 76543210 |
| 65 | * 0000|||IN_1 00000||BUT_MAIN |
| 66 | * ||IN_2 |BUT_CH1 |
| 67 | * |IN_3 BUT_CH2 |
| 68 | * IN_4 |
| 69 | * |
| 70 | * LABSW_SET encoding: |
| 71 | * |
| 72 | * value/mask |
| 73 | * fedc.ba98.7654.3210 |
| 74 | * 00|| |||| |||| |||CH1_RELAY |
| 75 | * || |||| |||| ||CH1_OPT |
| 76 | * || |||| |||| |CH2_RELAY |
| 77 | * || |||| |||| CH2_OPT |
| 78 | * || |||| |||OUT_1 |
| 79 | * || |||| ||OUT_2 |
| 80 | * || |||| |OUT_3 |
| 81 | * || |||| OUT_4 |
| 82 | * || |||LED_MAIN_R |
| 83 | * || ||LED_MAIN_G |
| 84 | * || |LED_CH1_R |
| 85 | * || LED_CH1_G |
| 86 | * |LED_CH2_R |
| 87 | * LED_CH2_G |
| 88 | */ |
| 89 | |
| 90 | enum labsw_bit_get0 { |
| 91 | LABSW_IN1 = 1, |
| 92 | LABSW_IN2 = 2, |
| 93 | LABSW_IN3 = 4, |
| 94 | LABSW_IN4 = 8, |
| 95 | }; |
| 96 | |
| 97 | enum labsw_bit_get1 { |
| 98 | LABSW_BUT_MAIN = 1, |
| 99 | LABSW_BUT_CH1 = 2, |
| 100 | LABSW_BUT_CH2 = 4, |
| 101 | }; |
| 102 | |
| 103 | enum labsw_bit_set { |
| 104 | LABSW_CH1_RELAY = 0x0001, |
| 105 | LABSW_CH1_OPT = 0x0002, |
| 106 | LABSW_CH2_RELAY = 0x0004, |
| 107 | LABSW_CH2_OPT = 0x0008, |
| 108 | LABSW_OUT1 = 0x0010, |
| 109 | LABSW_OUT2 = 0x0020, |
| 110 | LABSW_OUT3 = 0x0040, |
| 111 | LABSW_OUT4 = 0x0080, |
| 112 | LABSW_MAIN_R = 0x0100, |
| 113 | LABSW_MAIN_G = 0x0200, |
| 114 | LABSW_CH1_R = 0x0400, |
| 115 | LABSW_CH1_G = 0x0800, |
| 116 | LABSW_CH2_R = 0x1000, |
| 117 | LABSW_CH2_G = 0x2000, |
| 118 | }; |
| 119 | |
| 120 | void ep0_init(void); |
| 121 | |
| 122 | #endif /* !EP0_H */ |
| 123 |
Branches:
master
