You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
253 lines
12 KiB
253 lines
12 KiB
module descriptors (input CLK, /*input RESET, input RD_REQUEST,*/ input /*[1:0]*/ DESC_TYPE, input [6:0] ADR, output /*reg*/ [7:0] VAL/*, input [63:0] kbd_report*/);
|
|
|
|
parameter HID_REPORT_DESC_LEN = 63;
|
|
wire [7:0] RAM_ADR;
|
|
|
|
assign RAM_ADR[6:0] = ADR[6:0];
|
|
assign RAM_ADR[7] = DESC_TYPE;
|
|
//reg [(8*30-1):0] i2c_hid_desc;// = 'h_1E_00__00_01__46_00__02_00__03_00__0A_00__04_00__03_00__05_00__06_00__9F_04__01_01__00_01__00_00_00_00;
|
|
//reg [(8*HID_REPORT_DESC_LEN-1):0] hid_report_desc;
|
|
|
|
//parameter READ_ADRESS_OFFSET = 2;
|
|
|
|
//reg last_rd_request = 0;
|
|
//reg tx_flag = 0; // AT POSEDGE OF RD_REQUEST DATA FROM RAM MOVES TO RAM_RD_REG, AT NEXT CLK DATA MUST BE WRITE TO VAL
|
|
//reg [6:0] real_adress;
|
|
//reg [7:0] ram_rd_t1;
|
|
//reg [7:0] ram_rd_t2;
|
|
|
|
//always @ (posedge CLK) begin
|
|
//if (RESET == 0) begin
|
|
//i2c_hid_desc <= 'h_1E_00__00_01__50_00__02_00__03_00__0A_00__04_00__03_00__05_00__06_00__9F_04__01_01__00_01__00_00_00_00;
|
|
//hid_report_desc <= 'h__05_01__09_06__A1_01__05_07__85_01___19_E0__29_E7__15_00__25_01__75_01__95_08__81_02___95_01__75_08__81_01___95_05__75_01__05_05__85_01__19_01__29_05__91_02___95_01__75_03__91_03___95_06__75_08__15_00__25_65__05_07__19_00__29_65__81_00__C0;
|
|
//i2c_hid_desc [207:200] <= HID_REPORT_DESC_LEN[7:0];
|
|
//i2c_hid_desc [199:192] <= HID_REPORT_DESC_LEN[15:8];
|
|
// last_rd_request <= 0;
|
|
// real_adress = 0;
|
|
//end
|
|
// else begin
|
|
/*if (tx_flag == 1) begin // NEXT CLK AFTER POSEDGE REQUEST
|
|
if (DESC_TYPE == 1)
|
|
VAL <= ram_rd_t1;
|
|
else
|
|
VAL <= ram_rd_t2;
|
|
tx_flag = 0;*/
|
|
//end
|
|
// if ((last_rd_request == 0) && (RD_REQUEST == 1)) begin
|
|
// if (DESC_TYPE == 1)
|
|
// real_adress = ADR;
|
|
// else
|
|
// real_adress = ADR + 32;
|
|
//if (DESC_TYPE == 1) begin
|
|
// tx_flag = 1; // WAIT NEXT CLK
|
|
/* case (ADR) 2: VAL <= 8'h1E; 3: VAL <= 0; // 2-3 - DESCR LEN (30),
|
|
4: VAL <= 0; 5: VAL <= 1; // 4-5 - bcdVersion
|
|
6: VAL <= HID_REPORT_DESC_LEN[7:0]; 7: VAL <= HID_REPORT_DESC_LEN[15:8];
|
|
8: VAL <= 2; 9: VAL <= 0; // 8-9 - REPORT DESC ADR
|
|
10: VAL <= 3; 11: VAL <= 0; // 10-11 - INPUT REG ADR
|
|
12: VAL <= 10; 13: VAL <= 0; // 12-13 - INPUT REG LEN
|
|
14: VAL <= 4; 15: VAL <= 0; // 14-15 - OUT REG ADR
|
|
16: VAL <= 3; 17: VAL <= 0; // 16-17 - OUT REG LEN
|
|
18: VAL <= 5; 19: VAL <= 0; // 18-19 - CMD REG ADR
|
|
20: VAL <= 6; 21: VAL <= 0; // 20-21 - DATA REG ADR
|
|
22: VAL <= 8'h9F; 23: VAL <= 4; // 22-23 - VENDOR ID
|
|
24: VAL <= 1; 25: VAL <= 1; // 24-25 - DEVICE ID
|
|
26: VAL <= 0; 27: VAL <= 1; // 26-27 - VERSION
|
|
28: VAL <= 0; 29: VAL <= 0; 30: VAL <= 0; 31: VAL <= 0; // 28-31 - RSVD
|
|
default: VAL <= 0;
|
|
endcase*/
|
|
|
|
/*end
|
|
else if (DESC_TYPE == 2) begin
|
|
case (ADR) 2: VAL <= 8'h05; 3: VAL <= 8'h01;
|
|
4: VAL <= 8'h09; 5: VAL <= 8'h06;
|
|
6: VAL <= 8'hA1; 7: VAL <= 8'h01;
|
|
8: VAL <= 8'h05; 9: VAL <= 8'h07;
|
|
//10: VAL <= 8'h85; 11: VAL <= 8'h01;
|
|
// MODIFIERS DESC
|
|
10: VAL <= 8'h19; 11: VAL <= 8'hE0;
|
|
12: VAL <= 8'h29; 13: VAL <= 8'hE7;
|
|
14: VAL <= 8'h15; 15: VAL <= 8'h00;
|
|
16: VAL <= 8'h25; 17: VAL <= 8'h01;
|
|
18: VAL <= 8'h75; 19: VAL <= 8'h01;
|
|
20: VAL <= 8'h95; 21: VAL <= 8'h08;
|
|
22: VAL <= 8'h81; 23: VAL <= 8'h02;
|
|
// RESERVED BYTE
|
|
24: VAL <= 8'h95; 25: VAL <= 8'h01;
|
|
26: VAL <= 8'h75; 27: VAL <= 8'h08;
|
|
28: VAL <= 8'h81; 29: VAL <= 8'h01;
|
|
// LEDS
|
|
30: VAL <= 8'h95; 31: VAL <= 8'h05;
|
|
32: VAL <= 8'h75; 33: VAL <= 8'h01;
|
|
34: VAL <= 8'h05; 35: VAL <= 8'h08;
|
|
36: VAL <= 8'h19; 37: VAL <= 8'h01;
|
|
38: VAL <= 8'h29; 39: VAL <= 8'h05;
|
|
40: VAL <= 8'h91; 41: VAL <= 8'h02;
|
|
// RESERVED 3 BITS
|
|
42: VAL <= 8'h95; 43: VAL <= 8'h01;
|
|
44: VAL <= 8'h75; 45: VAL <= 8'h03;
|
|
46: VAL <= 8'h91; 47: VAL <= 8'h03;
|
|
// SIX KEYS (NON-MODIFIERS)
|
|
48: VAL <= 8'h95; 49: VAL <= 8'h06;
|
|
50: VAL <= 8'h75; 51: VAL <= 8'h08;
|
|
52: VAL <= 8'h15; 53: VAL <= 8'h00;
|
|
54: VAL <= 8'h25; 55: VAL <= 8'h65;
|
|
56: VAL <= 8'h05; 57: VAL <= 8'h07;
|
|
58: VAL <= 8'h19; 59: VAL <= 8'h00;
|
|
60: VAL <= 8'h29; 61: VAL <= 8'h65;
|
|
62: VAL <= 8'h81; 63: VAL <= 8'h00;
|
|
// END COLLECTION
|
|
64: VAL <= 8'hC0;
|
|
default: VAL <= 0;
|
|
endcase
|
|
end*/
|
|
/*if (READ_TYPE == 1) begin
|
|
if ((READ_ADRESS < READ_ADRESS_OFFSET) || (READ_ADRESS > (READ_ADRESS_OFFSET + 30 - 1)))
|
|
VAL <= 0;
|
|
else
|
|
VAL <= i2c_hid_desc[ (8 * (30 - READ_ADRESS + READ_ADRESS_OFFSET - 1) + 7) : (8 * (30 - READ_ADRESS + READ_ADRESS_OFFSET - 1) + 0) ];
|
|
end*/
|
|
/*else if (READ_TYPE == 2) begin
|
|
if ((READ_ADRESS < READ_ADRESS_OFFSET) || (READ_ADRESS > (READ_ADRESS_OFFSET + HID_REPORT_DESC_LEN - 1)))
|
|
VAL <= 0;
|
|
else
|
|
VAL <= hid_report_desc[ (8 * (HID_REPORT_DESC_LEN - READ_ADRESS + READ_ADRESS_OFFSET - 1) + 7) : (8 * (HID_REPORT_DESC_LEN - READ_ADRESS + READ_ADRESS_OFFSET - 1) + 0) ];
|
|
end*/
|
|
/*else if (READ_TYPE == 3) begin
|
|
if ((READ_ADRESS < READ_ADRESS_OFFSET) || (READ_ADRESS > (READ_ADRESS_OFFSET + 10 - 1)))
|
|
VAL <= 0;
|
|
else if (READ_ADRESS == READ_ADRESS_OFFSET)
|
|
VAL <= 10;
|
|
else if (READ_ADRESS == (READ_ADRESS_OFFSET + 1))
|
|
VAL <= 0;
|
|
else
|
|
VAL <= kbd_report[ (8 * (10 - READ_ADRESS + READ_ADRESS_OFFSET - 1) + 7) : (8 * (10 - READ_ADRESS + READ_ADRESS_OFFSET - 1) + 0) ];
|
|
end*/
|
|
// end
|
|
// last_rd_request <= RD_REQUEST;
|
|
// end
|
|
//end
|
|
|
|
/* 2: VAL <= 8'h1E; 3: VAL <= 0; // 2-3 - DESCR LEN (30),
|
|
4: VAL <= 0; 5: VAL <= 1; // 4-5 - bcdVersion
|
|
6: VAL <= HID_REPORT_DESC_LEN[7:0]; 7: VAL <= HID_REPORT_DESC_LEN[15:8];
|
|
8: VAL <= 2; 9: VAL <= 0; // 8-9 - REPORT DESC ADR
|
|
10: VAL <= 3; 11: VAL <= 0; // 10-11 - INPUT REG ADR
|
|
12: VAL <= 10; 13: VAL <= 0; // 12-13 - INPUT REG LEN
|
|
14: VAL <= 4; 15: VAL <= 0; // 14-15 - OUT REG ADR
|
|
16: VAL <= 3; 17: VAL <= 0; // 16-17 - OUT REG LEN
|
|
18: VAL <= 5; 19: VAL <= 0; // 18-19 - CMD REG ADR
|
|
20: VAL <= 6; 21: VAL <= 0; // 20-21 - DATA REG ADR
|
|
22: VAL <= 8'h9F; 23: VAL <= 4; // 22-23 - VENDOR ID
|
|
24: VAL <= 1; 25: VAL <= 1; // 24-25 - DEVICE ID
|
|
26: VAL <= 0; 27: VAL <= 1; // 26-27 - VERSION
|
|
28: VAL <= 0; 29: VAL <= 0; 30: VAL <= 0; 31: VAL <= 0; // 28-31 - RSVD
|
|
*/
|
|
|
|
SB_RAM40_4K #(
|
|
/*.INIT_0(256'h0000_0004__0000_000A__0000_0003__0000_0002__0000_003F__0001_0000__0000_001E___0000_0000),
|
|
.INIT_1(256'h0000_0000__0000_0000__0001_0000__0001_0001__0004_009F__0000_0006__0000_0005___0000_0003),*/
|
|
.INIT_0(256'h0003__0000_0004__0000_000A__0000_0003__0000_0002__0000_003F__0001_0000__0000_001E___0000),
|
|
.INIT_1(256'h0000__0000_0000__0000_0000__0001_0000__0001_0001__0004_009F__0000_0006__0000_0005___0000),
|
|
.INIT_8(256'h0025__0000_0015__00E7_0029__00E0_0019__0007_0005__0001_00A1__0006_0009__0001_0005___0000),
|
|
.INIT_9(256'h0075__0005_0095__0001_0081__0008_0075__0001_0095__0002_0081__0008_0095__0001_0075___0001),
|
|
.INIT_A(256'h0095__0003_0091__0003_0075__0001_0095__0002_0091__0005_0029__0001_0019__0008_0005___0001),
|
|
.INIT_B(256'h00C0__0000_0081__0065_0029__0000_0019__0007_0005__0065_0025__0000_0015__0008_0075___0006),
|
|
.INIT_C(256'h0000__0000_0000__0000_0000__0000_0000__0000_0000__0000_0000__0000_0000__0000_0000___0000),
|
|
.WRITE_MODE(1),
|
|
.READ_MODE(1)
|
|
) descriptors (
|
|
.RDATA(VAL),
|
|
.RADDR(RAM_ADR/*real_adress*/),
|
|
.RCLK(CLK),
|
|
.RCLKE(1'b1),
|
|
.RE(1'b1),
|
|
.WADDR(8'b0),
|
|
.WCLK(1'b0),
|
|
.WCLKE(1'b0),
|
|
.WDATA(8'b0),
|
|
.WE(1'b0)
|
|
);
|
|
/*
|
|
SB_RAM40_4K #(
|
|
.INIT_0(256'h0000_0004__0000_000A__0000_0003__0000_0002__0000_003F__0001_0000__0000_001E___0000_0000),
|
|
.INIT_1(256'h0000_0000__0000_0000__0001_0000__0001_0001__0004_009F__0000_0006__0000_0005___0000_0003),
|
|
.WRITE_MODE(1),
|
|
.READ_MODE(1)
|
|
) i2c_hid_desc (
|
|
.RDATA(ram_rd_t1),
|
|
.RADDR(ADR),
|
|
.RCLK(CLK),
|
|
.RCLKE(1'b1),
|
|
.RE(1'b1),
|
|
.WADDR(8'b0),
|
|
.WCLK(1'b0),
|
|
.WCLKE(1'b0),
|
|
.WDATA(8'b0),
|
|
.WE(1'b0)
|
|
);
|
|
|
|
SB_RAM40_4K #(
|
|
.INIT_0(256'h0000_0015__00E7_0029__00E0_0019__0007_0005__0001_00A1__0006_0009__0001_0005___0000_0000),
|
|
.INIT_1(256'h0005_0095__0001_0081__0008_0075__0001_0095__0002_0081__0008_0095__0001_0075___0001_0025),
|
|
.INIT_2(256'h0003_0091__0003_0075__0001_0095__0002_0091__0005_0029__0001_0019__0008_0005___0001_0075),
|
|
.INIT_3(256'h0000_0081__0065_0029__0000_0019__0007_0005__0065_0025__0000_0015__0008_0075___0006_0095),
|
|
.INIT_4(256'h0000_0000__0000_0000__0000_0000__0000_0000__0000_0000__0000_0000__0000_0000___0000_00C0),
|
|
.WRITE_MODE(1),
|
|
.READ_MODE(1)
|
|
) hid_report_desc (
|
|
.RDATA(ram_rd_t2),
|
|
.RADDR(ADR),
|
|
.RCLK(CLK),
|
|
.RCLKE(1'b1),
|
|
.RE(1'b1),
|
|
.WADDR(8'b0),
|
|
.WCLK(1'b0),
|
|
.WCLKE(1'b0),
|
|
.WDATA(8'b0),
|
|
.WE(1'b0)
|
|
);*/
|
|
|
|
endmodule
|
|
|
|
//static const uint8 hid_descriptor_keyboard[] = {
|
|
//****/ 0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */ 2
|
|
//****/ 0x09, 0x06, /* USAGE (Keyboard) */ 4
|
|
//****/ 0xa1, 0x01, /* COLLECTION (Application) */ 6
|
|
//******/ 0x05, 0x07, /* USAGE_PAGE (Keyboard) */ 8
|
|
//******/ 0x85, 0x01, /* REPORT_ID (1) */ 10
|
|
/* Ctrl, Shift and other modifier keys, 8 in total */
|
|
//******/ 0x19, 0xe0, /* USAGE_MINIMUM (kbd LeftControl) */ 12
|
|
//******/ 0x29, 0xe7, /* USAGE_MAXIMUM (kbd Right GUI) */ 14
|
|
//******/ 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ 16
|
|
//******/ 0x25, 0x01, /* LOGICAL_MAXIMUM (1) */ 18
|
|
//******/ 0x75, 0x01, /* REPORT_SIZE (1) */ 20
|
|
//******/ 0x95, 0x08, /* REPORT_COUNT (8) */ 22
|
|
//******/ 0x81, 0x02, /* INPUT (Data,Var,Abs) */ 24
|
|
/* Reserved byte */
|
|
//******/ 0x95, 0x01, /* REPORT_COUNT (1) */ 26
|
|
//******/ 0x75, 0x08, /* REPORT_SIZE (8) */ 28
|
|
//******/ 0x81, 0x01, /* INPUT (Cnst,Ary,Abs) */ 30
|
|
/* LEDs for num lock etc */
|
|
//******/ 0x95, 0x05, /* REPORT_COUNT (5) */ 32
|
|
//******/ 0x75, 0x01, /* REPORT_SIZE (1) */ 34
|
|
//******/ 0x05, 0x08, /* USAGE_PAGE (LEDs) */ 36
|
|
//******/ 0x85, 0x01, /* REPORT_ID (1) */ 38
|
|
//******/ 0x19, 0x01, /* USAGE_MINIMUM (Num Lock) */ 40
|
|
//******/ 0x29, 0x05, /* USAGE_MAXIMUM (Kana) */ 42
|
|
//******/ 0x91, 0x02, /* OUTPUT (Data,Var,Abs) */ 44
|
|
/* Reserved 3 bits */
|
|
//******/ 0x95, 0x01, /* REPORT_COUNT (1) */ 46
|
|
//******/ 0x75, 0x03, /* REPORT_SIZE (3) */ 48
|
|
//******/ 0x91, 0x03, /* OUTPUT (Cnst,Var,Abs) */ 50
|
|
/* Slots for 6 keys that can be pressed down at the same time */
|
|
//******/ 0x95, 0x06, /* REPORT_COUNT (6) */ 52
|
|
//******/ 0x75, 0x08, /* REPORT_SIZE (8) */ 54
|
|
//******/ 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ 56
|
|
//******/ 0x25, 0x65, /* LOGICAL_MAXIMUM (101) */Bluegiga Technologies Oy 58
|
|
//******/ 0x05, 0x07, /* USAGE_PAGE (Keyboard) */ 60
|
|
//******/ 0x19, 0x00, /* USAGE_MINIMUM (Reserved (no event indicated)) */ 62
|
|
//******/ 0x29, 0x65, /* USAGE_MAXIMUM (Keyboard Application) */ 64
|
|
//******/ 0x81, 0x00, /* INPUT (Data,Ary,Abs) */ 66
|
|
//****/ 0xc0 } 67
|