├── Firmware ├── Debug │ ├── fifo.ls │ ├── fifo.o │ ├── hardware.ls │ ├── hardware.o │ ├── hotkey.elf │ ├── hotkey.lkf │ ├── hotkey.map │ ├── hotkey.s19 │ ├── hotkey.sm8 │ ├── main.ls │ ├── main.o │ ├── stm8_interrupt_vector.ls │ └── stm8_interrupt_vector.o ├── Hotkey.stw ├── Hotkey.wdb ├── Hotkey.wed ├── Release │ └── hotkey.lkf ├── checkres.spy ├── hardware.c ├── hardware.h ├── hotkey.dep ├── hotkey.pdb ├── hotkey.stp ├── hotkey_Programmer │ ├── hotkey_STVP.stp │ └── hotkey_STVP_OPTION BYTE.hex ├── irq.h ├── main.c ├── stm8_interrupt_vector.c ├── stm8_interrupt_vector.h ├── stm8s.h └── stm8s_conf.h ├── Hardware ├── AZHW371 HDMI Switch.pdf ├── Acive Or'ing (optional) │ ├── Active or'ing.pdf │ ├── LT Spice simulation │ │ ├── Active or'ing diode discrete -0.asc │ │ ├── note.txt │ │ └── si2307bd.lib │ ├── Or'ing.brd │ ├── Or'ing.sch │ ├── RPi3 Model B or'ing circuit.png │ └── active or'ing PCB.png ├── KVM boards - top.jpg ├── KVM boards.jpg ├── STM8S003 -OSH.brd ├── STM8S003 -OSH.pdf ├── STM8S003 -OSH.sch ├── STM8S003 -OSH_ListByValues.csv ├── Sketchup - 3D model │ └── Sketchup -KVM 3D model.zip ├── USB Connector.brd ├── USB Connector.sch ├── USB Mux-v0.1.pdf ├── USB Mux-v0.1_ListByValues.csv ├── USB Mux-v0.2.brd ├── USB Mux-v0.2.sch └── Wiring diagram.png ├── KVM-Hotkey ├── Debug │ ├── fifo.ls │ ├── fifo.o │ ├── hardware.ls │ ├── hardware.o │ ├── hotkey.lkf │ ├── hotkey.map │ ├── hotkey.s19 │ ├── hotkey.sm8 │ ├── main.ls │ ├── main.o │ ├── stm8_interrupt_vector.ls │ └── stm8_interrupt_vector.o ├── Hotkey.stw ├── Hotkey.wdb ├── Hotkey.wed ├── Release │ └── hotkey.lkf ├── TAGS.txt ├── TAGS_Filelist.txt ├── hardware.c ├── hardware.h ├── hotkey.dep ├── hotkey.pdb ├── hotkey.stp ├── irq.h ├── main.c ├── stm8_interrupt_vector.c ├── stm8_interrupt_vector.h ├── stm8s.h └── stm8s_conf.h └── README.md /Firmware/Debug/fifo.ls: -------------------------------------------------------------------------------- 1 | 1 ; C Compiler for STM8 (COSMIC Software) 2 | 2 ; Parser V4.11.5 - 29 Dec 2015 3 | 3 ; Generator (Limited) V4.4.4 - 27 Jan 2016 4 | 89 ; 26 void FIFO_Clear(FIFO *Queue) 5 | 89 ; 27 { 6 | 91 switch .text 7 | 92 0000 _FIFO_Clear: 8 | 96 ; 28 Queue->Head = Queue->Tail = 0; 9 | 98 0000 6f02 clr (2,x) 10 | 99 0002 6f01 clr (1,x) 11 | 100 ; 29 } 12 | 103 0004 81 ret 13 | 140 ; 31 uint8_t FIFO_WriteAvail(FIFO *Queue) 14 | 140 ; 32 { 15 | 141 switch .text 16 | 142 0005 _FIFO_WriteAvail: 17 | 144 0005 89 pushw x 18 | 145 0006 89 pushw x 19 | 146 00000002 OFST: set 2 20 | 149 ; 33 return(FIFO_INC(Queue->Head,Queue->SizeMask)!=Queue->Tail); 21 | 151 0007 f6 ld a,(x) 22 | 152 0008 5f clrw x 23 | 153 0009 97 ld xl,a 24 | 154 000a 1f01 ldw (OFST-1,sp),x 25 | 156 000c 1e03 ldw x,(OFST+1,sp) 26 | 157 000e e601 ld a,(1,x) 27 | 158 0010 5f clrw x 28 | 159 0011 97 ld xl,a 29 | 160 0012 5c incw x 30 | 161 0013 01 rrwa x,a 31 | 162 0014 1402 and a,(OFST+0,sp) 32 | 163 0016 01 rrwa x,a 33 | 164 0017 1401 and a,(OFST-1,sp) 34 | 165 0019 01 rrwa x,a 35 | 166 001a 1603 ldw y,(OFST+1,sp) 36 | 167 001c 90e602 ld a,(2,y) 37 | 168 001f 905f clrw y 38 | 169 0021 9097 ld yl,a 39 | 170 0023 90bf00 ldw c_y,y 40 | 171 0026 b300 cpw x,c_y 41 | 172 0028 2704 jreq L01 42 | 173 002a a601 ld a,#1 43 | 174 002c 2001 jra L21 44 | 175 002e L01: 45 | 176 002e 4f clr a 46 | 177 002f L21: 47 | 180 002f 5b04 addw sp,#4 48 | 181 0031 81 ret 49 | 228 ; 36 uint8_t FIFO_Write(FIFO *Queue, FIFO_Data_t data) 50 | 228 ; 37 { 51 | 229 switch .text 52 | 230 0032 _FIFO_Write: 53 | 232 0032 89 pushw x 54 | 233 00000000 OFST: set 0 55 | 236 ; 38 if(FIFO_WriteAvail(Queue)) 56 | 238 0033 add0 call _FIFO_WriteAvail 57 | 240 0035 4d tnz a 58 | 241 0036 271d jreq L311 59 | 242 ; 40 Queue->Head = FIFO_INC(Queue->Head,Queue->SizeMask); 60 | 244 0038 1e01 ldw x,(OFST+1,sp) 61 | 245 003a e601 ld a,(1,x) 62 | 246 003c 4c inc a 63 | 247 003d 1e01 ldw x,(OFST+1,sp) 64 | 248 003f f4 and a,(x) 65 | 249 0040 1e01 ldw x,(OFST+1,sp) 66 | 250 0042 e701 ld (1,x),a 67 | 251 ; 41 FIFO_BUF(Queue)[Queue->Head] = data; 68 | 253 0044 1e01 ldw x,(OFST+1,sp) 69 | 254 0046 e601 ld a,(1,x) 70 | 255 0048 5f clrw x 71 | 256 0049 97 ld xl,a 72 | 257 004a 72fb01 addw x,(OFST+1,sp) 73 | 258 004d 7b05 ld a,(OFST+5,sp) 74 | 259 004f e703 ld (3,x),a 75 | 260 ; 42 return 1; 76 | 262 0051 a601 ld a,#1 77 | 264 0053 2001 jra L61 78 | 265 0055 L311: 79 | 266 ; 44 return 0; 80 | 268 0055 4f clr a 81 | 270 0056 L61: 82 | 272 0056 85 popw x 83 | 273 0057 81 ret 84 | 310 ; 47 uint8_t FIFO_ReadAvail(FIFO *Queue) 85 | 310 ; 48 { 86 | 311 switch .text 87 | 312 0058 _FIFO_ReadAvail: 88 | 314 0058 89 pushw x 89 | 315 00000000 OFST: set 0 90 | 318 ; 49 return(Queue->Head != Queue->Tail); 91 | 320 0059 e601 ld a,(1,x) 92 | 321 005b 1e01 ldw x,(OFST+1,sp) 93 | 322 005d e102 cp a,(2,x) 94 | 323 005f 2704 jreq L22 95 | 324 0061 a601 ld a,#1 96 | 325 0063 2001 jra L42 97 | 326 0065 L22: 98 | 327 0065 4f clr a 99 | 328 0066 L42: 100 | 331 0066 85 popw x 101 | 332 0067 81 ret 102 | 380 ; 52 uint8_t FIFO_Read(FIFO *Queue, FIFO_Data_t *data) 103 | 380 ; 53 { 104 | 381 switch .text 105 | 382 0068 _FIFO_Read: 106 | 384 0068 89 pushw x 107 | 385 00000000 OFST: set 0 108 | 388 ; 54 if (FIFO_ReadAvail(Queue)) 109 | 390 0069 aded call _FIFO_ReadAvail 110 | 392 006b 4d tnz a 111 | 393 006c 271e jreq L161 112 | 394 ; 56 Queue->Tail = FIFO_INC(Queue->Tail,Queue->SizeMask); 113 | 396 006e 1e01 ldw x,(OFST+1,sp) 114 | 397 0070 e602 ld a,(2,x) 115 | 398 0072 4c inc a 116 | 399 0073 1e01 ldw x,(OFST+1,sp) 117 | 400 0075 f4 and a,(x) 118 | 401 0076 1e01 ldw x,(OFST+1,sp) 119 | 402 0078 e702 ld (2,x),a 120 | 403 ; 57 *data = FIFO_BUF(Queue)[Queue->Tail]; 121 | 405 007a 1e01 ldw x,(OFST+1,sp) 122 | 406 007c e602 ld a,(2,x) 123 | 407 007e 5f clrw x 124 | 408 007f 97 ld xl,a 125 | 409 0080 72fb01 addw x,(OFST+1,sp) 126 | 410 0083 e603 ld a,(3,x) 127 | 411 0085 1e05 ldw x,(OFST+5,sp) 128 | 412 0087 f7 ld (x),a 129 | 413 ; 58 return 1; 130 | 415 0088 a601 ld a,#1 131 | 417 008a 2001 jra L03 132 | 418 008c L161: 133 | 419 ; 60 return 0; 134 | 421 008c 4f clr a 135 | 423 008d L03: 136 | 425 008d 85 popw x 137 | 426 008e 81 ret 138 | 473 ; 63 uint8_t Getc(FIFO *Queue) 139 | 473 ; 64 { 140 | 474 switch .text 141 | 475 008f _Getc: 142 | 477 008f 89 pushw x 143 | 478 0090 88 push a 144 | 479 00000001 OFST: set 1 145 | 482 0091 L112: 146 | 483 ; 67 while(!FIFO_Read(Queue,&ch)) 147 | 485 0091 96 ldw x,sp 148 | 486 0092 1c0001 addw x,#OFST+0 149 | 487 0095 89 pushw x 150 | 488 0096 1e04 ldw x,(OFST+3,sp) 151 | 489 0098 adce call _FIFO_Read 152 | 491 009a 85 popw x 153 | 492 009b 4d tnz a 154 | 493 009c 27f3 jreq L112 155 | 494 ; 70 return ch; 156 | 496 009e 7b01 ld a,(OFST+0,sp) 157 | 499 00a0 5b03 addw sp,#3 158 | 500 00a2 81 ret 159 | 513 xdef _Getc 160 | 514 xdef _FIFO_ReadAvail 161 | 515 xdef _FIFO_Read 162 | 516 xdef _FIFO_WriteAvail 163 | 517 xdef _FIFO_Write 164 | 518 xdef _FIFO_Clear 165 | 519 xref.b c_y 166 | 538 end 167 | -------------------------------------------------------------------------------- /Firmware/Debug/fifo.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FPGA-Computer/KVM-Switch/3f3526bb809239746657e17d94fe30fd696eddca/Firmware/Debug/fifo.o -------------------------------------------------------------------------------- /Firmware/Debug/hardware.ls: -------------------------------------------------------------------------------- 1 | 1 ; C Compiler for STM8 (COSMIC Software) 2 | 2 ; Parser V4.11.5 - 29 Dec 2015 3 | 3 ; Generator (Limited) V4.4.4 - 27 Jan 2016 4 | 15 .const: section .text 5 | 16 0000 _Mux_Tbl: 6 | 17 0000 40 dc.b 64 7 | 18 0001 00 dc.b 0 8 | 19 0002 80 dc.b 128 9 | 20 0003 c0 dc.b 192 10 | 52 ; 40 void Init_Hardware(void) 11 | 52 ; 41 { 12 | 54 switch .text 13 | 55 0000 _Init_Hardware: 14 | 59 ; 42 CLK->CKDIVR = 0; // Clk divider, CPU divider = 1 15 | 61 0000 725f50c6 clr 20678 16 | 62 ; 43 EXTI->CR1 = (0x02 << 2); // PB2 Interrupt: Falling edge 17 | 64 0004 350850a0 mov 20640,#8 18 | 65 ; 44 PS2_PORT->CR2 = PS2_CLK; // Enable PS2_CLK interrupt 19 | 67 0008 35105009 mov 20489,#16 20 | 68 ; 47 HDMI_PORT->DDR = HDMI_SW|USB_IN1|USB_IN2; 21 | 70 000c 35e0500c mov 20492,#224 22 | 71 ; 48 HDMI_PORT->CR1 = HDMI_S1|HDMI_S2|USB_IN1|USB_IN2; 23 | 73 0010 35d8500d mov 20493,#216 24 | 74 ; 51 GPIOA->CR1 = GPIOA->DDR = PA1|PA2|PA3; 25 | 76 0014 350e5002 mov 20482,#14 26 | 77 0018 5550025003 mov 20483,20482 27 | 78 ; 52 GPIOD->CR1 = GPIOD->DDR = PD2|PD3|PD4; 28 | 80 001d 351c5011 mov 20497,#28 29 | 81 0021 5550115012 mov 20498,20497 30 | 82 ; 55 TIM4->CR1 = TIM4_CR1_ARPE|TIM4_CR1_URS|TIM4_CR1_CEN; 31 | 84 0026 35855340 mov 21312,#133 32 | 85 ; 57 TIM4->IER = TIM4_IER_UIE; // Update IRQ enable 33 | 87 002a 35015343 mov 21315,#1 34 | 88 ; 58 TIM4->PSCR = TIM4_PSCR; // TIM4: 16MHz/2^TIM4_PSCR 35 | 90 002e 35035347 mov 21319,#3 36 | 91 ; 59 TIM4->ARR = TIM4_ARR; // Auto-reload 37 | 93 0032 35c85348 mov 21320,#200 38 | 94 ; 62 ITC->ISPR2 = 0x03; 39 | 96 0036 35037f71 mov 32625,#3 40 | 97 ; 64 ITC->ISPR1 = ITC->ISPR3 = ITC->ISPR4 = ITC->ISPR5 = ITC->ISPR6 = 0x00; 41 | 99 003a 725f7f75 clr 32629 42 | 100 003e 725f7f74 clr 32628 43 | 101 0042 725f7f73 clr 32627 44 | 102 0046 725f7f72 clr 32626 45 | 103 004a 725f7f70 clr 32624 46 | 104 ; 66 PS2.State = PS2_Idle; 47 | 106 004e 3f08 clr _PS2+2 48 | 107 ; 68 Hotkeys.State = HK_Idle; 49 | 109 0050 3f04 clr _Hotkeys 50 | 110 ; 69 Hotkeys.KeyAttr = 0; 51 | 112 0052 3f05 clr _Hotkeys+1 52 | 113 ; 71 rim(); 53 | 116 0054 9a rim 54 | 118 ; 72 } 55 | 122 0055 81 ret 56 | 149 ; 75 @far @interrupt void TIM4_IRQ(void) 57 | 149 ; 76 { 58 | 151 switch .text 59 | 152 0056 f_TIM4_IRQ: 60 | 156 ; 77 TIM4->SR1 &= ~TIM4_SR1_UIF; // Clear update IRQ 61 | 158 0056 72115344 bres 21316,#0 62 | 159 ; 79 if(Micro_Timer1) 63 | 161 005a 3d03 tnz _Micro_Timer1 64 | 162 005c 2702 jreq L13 65 | 163 ; 80 Micro_Timer1--; 66 | 165 005e 3a03 dec _Micro_Timer1 67 | 166 0060 L13: 68 | 167 ; 82 if(Milli_Divider) 69 | 169 0060 3d00 tnz _Milli_Divider 70 | 170 0062 2704 jreq L33 71 | 171 ; 83 Milli_Divider--; 72 | 173 0064 3a00 dec _Milli_Divider 73 | 175 0066 2016 jra L53 74 | 176 0068 L33: 75 | 177 ; 86 if(Milli_Timer1) 76 | 179 0068 3d02 tnz _Milli_Timer1 77 | 180 006a 2702 jreq L73 78 | 181 ; 87 Milli_Timer1--; 79 | 183 006c 3a02 dec _Milli_Timer1 80 | 184 006e L73: 81 | 185 ; 89 if(Milli_Timer2) // HDMI button 82 | 187 006e 3d01 tnz _Milli_Timer2 83 | 188 0070 2704 jreq L14 84 | 189 ; 90 Milli_Timer2--; 85 | 191 0072 3a01 dec _Milli_Timer2 86 | 193 0074 2004 jra L34 87 | 194 0076 L14: 88 | 195 ; 92 HDMI_PORT->ODR |= HDMI_SW; // Clear select button 89 | 197 0076 721a500a bset 20490,#5 90 | 198 007a L34: 91 | 199 ; 94 Milli_Divider = MILLI_DIVIDER_RELOAD; 92 | 201 007a 35640000 mov _Milli_Divider,#100 93 | 202 007e L53: 94 | 203 ; 96 } 95 | 206 007e 80 iret 96 | 230 ; 98 @far @interrupt void PORTB_IRQ(void) 97 | 230 ; 99 { 98 | 231 switch .text 99 | 232 007f f_PORTB_IRQ: 100 | 236 ; 100 if((PS2.State == PS2_Idle)||(!Micro_Timer1)) // Start bit or resynchronized 101 | 238 007f 3d08 tnz _PS2+2 102 | 239 0081 2704 jreq L75 103 | 241 0083 3d03 tnz _Micro_Timer1 104 | 242 0085 2614 jrne L55 105 | 243 0087 L75: 106 | 244 ; 103 Micro_Timer1 = us_TO_TICKS(PS2_BIT_TIMEOUT); 107 | 246 0087 350f0003 mov _Micro_Timer1,#15 108 | 247 ; 105 PS2.State = (PS2_PORT->IDR & PS2_DATA)?PS2_CMD_1:PS2_KBD_1; 109 | 249 008b c65006 ld a,20486 110 | 250 008e a520 bcp a,#32 111 | 251 0090 2704 jreq L21 112 | 252 0092 a601 ld a,#1 113 | 253 0094 2002 jra L41 114 | 254 0096 L21: 115 | 255 0096 a641 ld a,#65 116 | 256 0098 L41: 117 | 257 0098 b708 ld _PS2+2,a 118 | 259 009a L16: 119 | 260 ; 128 } 120 | 263 009a 80 iret 121 | 264 009b L55: 122 | 265 ; 109 if(PS2.State++ & PS2_KBD) // Scan/respond code 123 | 267 009b b608 ld a,_PS2+2 124 | 268 009d 3c08 inc _PS2+2 125 | 269 009f 5f clrw x 126 | 270 00a0 a540 bcp a,#64 127 | 271 00a2 2727 jreq L36 128 | 272 ; 111 if(PS2.State == PS2_KBD_LAST) 129 | 274 00a4 b608 ld a,_PS2+2 130 | 275 00a6 a14b cp a,#75 131 | 276 00a8 2608 jrne L56 132 | 277 ; 113 PS2.Avail = 1; 133 | 279 00aa 3501000a mov _PS2+4,#1 134 | 280 ; 114 PS2.State = PS2_Idle; 135 | 282 00ae 3f08 clr _PS2+2 136 | 284 00b0 20e8 jra L16 137 | 285 00b2 L56: 138 | 286 ; 118 PS2.ScanCode >>= 1; 139 | 288 00b2 be06 ldw x,_PS2 140 | 289 00b4 54 srlw x 141 | 290 00b5 bf06 ldw _PS2,x 142 | 291 ; 120 if(PS2_PORT->IDR & PS2_DATA) 143 | 293 00b7 c65006 ld a,20486 144 | 294 00ba a520 bcp a,#32 145 | 295 00bc 27dc jreq L16 146 | 296 ; 121 PS2.ScanCode |= 0x200; 147 | 298 00be be06 ldw x,_PS2 148 | 299 00c0 01 rrwa x,a 149 | 300 00c1 aa00 or a,#0 150 | 301 00c3 01 rrwa x,a 151 | 302 00c4 aa02 or a,#2 152 | 303 00c6 01 rrwa x,a 153 | 304 00c7 bf06 ldw _PS2,x 154 | 305 00c9 20cf jra L16 155 | 306 00cb L36: 156 | 307 ; 125 if(PS2.State == PS2_CMD_LAST) 157 | 309 00cb b608 ld a,_PS2+2 158 | 310 00cd a10c cp a,#12 159 | 311 00cf 26c9 jrne L16 160 | 312 ; 126 PS2.State = PS2_Idle; 161 | 314 00d1 3f08 clr _PS2+2 162 | 315 00d3 20c5 jra L16 163 | 384 ; 131 void PS2_Task(void) 164 | 384 ; 132 { 165 | 386 switch .text 166 | 387 00d5 _PS2_Task: 167 | 389 00d5 5206 subw sp,#6 168 | 390 00000006 OFST: set 6 169 | 393 ; 136 if(PS2.Avail) 170 | 395 00d7 3d0a tnz _PS2+4 171 | 396 00d9 2603 jrne L22 172 | 397 00db cc01a8 jp L141 173 | 398 00de L22: 174 | 399 ; 139 sim(); 175 | 402 00de 9b sim 176 | 404 ; 140 ScanCode = PS2.ScanCode; 177 | 407 00df be06 ldw x,_PS2 178 | 408 00e1 1f05 ldw (OFST-1,sp),x 179 | 410 ; 141 PS2.Avail = 0; 180 | 412 00e3 3f0a clr _PS2+4 181 | 413 ; 142 rim(); 182 | 416 00e5 9a rim 183 | 418 ; 144 Parity = PS2.ScanCode & 0x01; 184 | 421 00e6 b606 ld a,_PS2 185 | 422 00e8 97 ld xl,a 186 | 423 00e9 b607 ld a,_PS2+1 187 | 424 00eb a401 and a,#1 188 | 425 00ed 5f clrw x 189 | 426 ; 145 ScanCode = (ScanCode >> 1) & 0xff; 190 | 428 00ee 1e05 ldw x,(OFST-1,sp) 191 | 429 00f0 54 srlw x 192 | 430 00f1 01 rrwa x,a 193 | 431 00f2 a4ff and a,#255 194 | 432 00f4 5f clrw x 195 | 433 00f5 02 rlwa x,a 196 | 434 00f6 1f05 ldw (OFST-1,sp),x 197 | 435 00f8 01 rrwa x,a 198 | 437 ; 147 if (ScanCode == PS2_KBD_CODE_RELEASE) 199 | 439 00f9 1e05 ldw x,(OFST-1,sp) 200 | 440 00fb a300f0 cpw x,#240 201 | 441 00fe 2608 jrne L341 202 | 442 ; 148 Hotkeys.KeyAttr |= Key_Release; 203 | 444 0100 72100005 bset _Hotkeys+1,#0 204 | 446 0104 aca801a8 jpf L141 205 | 447 0108 L341: 206 | 448 ; 149 else if (ScanCode == PS2_KBD_CODE_EXTENDED) 207 | 450 0108 1e05 ldw x,(OFST-1,sp) 208 | 451 010a a300e0 cpw x,#224 209 | 452 010d 2608 jrne L741 210 | 453 ; 150 Hotkeys.KeyAttr |= Key_Extend; 211 | 455 010f 72120005 bset _Hotkeys+1,#1 212 | 457 0113 aca801a8 jpf L141 213 | 458 0117 L741: 214 | 459 ; 153 switch(Hotkeys.State) 215 | 461 0117 b604 ld a,_Hotkeys 216 | 463 ; 202 break; 217 | 464 0119 4d tnz a 218 | 465 011a 270b jreq L77 219 | 466 011c 4a dec a 220 | 467 011d 271f jreq L101 221 | 468 011f 4a dec a 222 | 469 0120 273e jreq L301 223 | 470 0122 4a dec a 224 | 471 0123 275a jreq L501 225 | 472 0125 207d jra L551 226 | 473 0127 L77: 227 | 474 ; 155 case HK_Idle: // wait for hot key press 228 | 474 ; 156 if(HOTKEY_MAKE) 229 | 476 0127 1e05 ldw x,(OFST-1,sp) 230 | 477 0129 a30014 cpw x,#20 231 | 478 012c 2676 jrne L551 232 | 480 012e b605 ld a,_Hotkeys+1 233 | 481 0130 a102 cp a,#2 234 | 482 0132 2670 jrne L551 235 | 483 ; 158 Hotkeys.State = HK_KeyMake_1; 236 | 485 0134 35010004 mov _Hotkeys,#1 237 | 486 ; 159 Milli_Timer1 = HOTKEY_RELEASE_DELAY; 238 | 488 0138 35190002 mov _Milli_Timer1,#25 239 | 489 ; 160 return; 240 | 491 013c 201b jra L02 241 | 492 013e L101: 242 | 493 ; 164 case HK_KeyMake_1: // wait for hot key release instead of hold 243 | 493 ; 165 if(HOTKEY_RELEASE && Milli_Timer1) 244 | 495 013e 1e05 ldw x,(OFST-1,sp) 245 | 496 0140 a30014 cpw x,#20 246 | 497 0143 2617 jrne L161 247 | 499 0145 b605 ld a,_Hotkeys+1 248 | 500 0147 a103 cp a,#3 249 | 501 0149 2611 jrne L161 250 | 503 014b 3d02 tnz _Milli_Timer1 251 | 504 014d 270d jreq L161 252 | 505 ; 167 Hotkeys.KeyAttr = 0; 253 | 507 014f 3f05 clr _Hotkeys+1 254 | 508 ; 168 Hotkeys.State = HK_KeyBreak_1; 255 | 510 0151 35020004 mov _Hotkeys,#2 256 | 511 ; 169 Milli_Timer1 = HOTKEY_WAIT_DELAY; 257 | 513 0155 35140002 mov _Milli_Timer1,#20 258 | 514 ; 170 return; 259 | 515 0159 L02: 260 | 518 0159 5b06 addw sp,#6 261 | 519 015b 81 ret 262 | 520 015c L161: 263 | 521 ; 173 Hotkeys.State = HK_Idle; 264 | 523 015c 3f04 clr _Hotkeys 265 | 524 015e 2044 jra L551 266 | 525 0160 L301: 267 | 526 ; 176 case HK_KeyBreak_1: // wait for hot key release 268 | 526 ; 177 if(HOTKEY_MAKE && Milli_Timer1) 269 | 528 0160 1e05 ldw x,(OFST-1,sp) 270 | 529 0162 a30014 cpw x,#20 271 | 530 0165 2614 jrne L561 272 | 532 0167 b605 ld a,_Hotkeys+1 273 | 533 0169 a102 cp a,#2 274 | 534 016b 260e jrne L561 275 | 536 016d 3d02 tnz _Milli_Timer1 276 | 537 016f 270a jreq L561 277 | 538 ; 179 Hotkeys.State = HK_KeyMake_2; 278 | 540 0171 35030004 mov _Hotkeys,#3 279 | 541 ; 180 Milli_Timer1 = HOTKEY_RELEASE_DELAY; 280 | 543 0175 35190002 mov _Milli_Timer1,#25 281 | 544 ; 181 return; 282 | 546 0179 20de jra L02 283 | 547 017b L561: 284 | 548 ; 184 Hotkeys.State = HK_Idle; 285 | 550 017b 3f04 clr _Hotkeys 286 | 551 017d 2025 jra L551 287 | 552 017f L501: 288 | 553 ; 187 case HK_KeyMake_2: // wait for hot key press again 289 | 553 ; 188 if(HOTKEY_RELEASE && Milli_Timer1) 290 | 555 017f 1e05 ldw x,(OFST-1,sp) 291 | 556 0181 a30014 cpw x,#20 292 | 557 0184 261c jrne L171 293 | 559 0186 b605 ld a,_Hotkeys+1 294 | 560 0188 a103 cp a,#3 295 | 561 018a 2616 jrne L171 296 | 563 018c 3d02 tnz _Milli_Timer1 297 | 564 018e 2712 jreq L171 298 | 565 ; 191 Milli_Timer1 = HOTKEY_USB_WAIT; 299 | 567 0190 35050002 mov _Milli_Timer1,#5 300 | 568 0194 L371: 301 | 569 ; 193 while(Milli_Timer1) 302 | 572 0194 3d02 tnz _Milli_Timer1 303 | 573 0196 26fc jrne L371 304 | 574 ; 196 HDMI_PORT->ODR &= ~HDMI_SW; // Press select button(active low) 305 | 576 0198 721b500a bres 20490,#5 306 | 577 ; 197 Milli_Timer2 = HDMI_SW_DELAY; // hold for delay 307 | 579 019c 350a0001 mov _Milli_Timer2,#10 308 | 581 01a0 2002 jra L551 309 | 582 01a2 L171: 310 | 583 ; 200 Hotkeys.State = HK_Idle; 311 | 585 01a2 3f04 clr _Hotkeys 312 | 586 01a4 L551: 313 | 587 ; 206 Hotkeys.State = HK_Idle; 314 | 589 01a4 3f04 clr _Hotkeys 315 | 590 ; 207 Hotkeys.KeyAttr = 0; 316 | 592 01a6 3f05 clr _Hotkeys+1 317 | 593 01a8 L141: 318 | 594 ; 211 HDMI = (HDMI_PORT->IDR & HDMI_SEL_MASK)>>HDMI_SHIFT; 319 | 596 01a8 c6500b ld a,20491 320 | 597 01ab 44 srl a 321 | 598 01ac 44 srl a 322 | 599 01ad 44 srl a 323 | 600 01ae a403 and a,#3 324 | 601 01b0 6b03 ld (OFST-3,sp),a 325 | 603 ; 213 USB = Mux_Tbl[HDMI]; 326 | 605 01b2 7b03 ld a,(OFST-3,sp) 327 | 606 01b4 5f clrw x 328 | 607 01b5 97 ld xl,a 329 | 608 01b6 d60000 ld a,(_Mux_Tbl,x) 330 | 609 01b9 6b04 ld (OFST-2,sp),a 331 | 611 ; 216 if(((HDMI!= HDMI_NO_CONNECT)&&(HDMI_PORT->ODR & USB_SEL_MASK)!= USB)) 332 | 613 01bb 7b03 ld a,(OFST-3,sp) 333 | 614 01bd a101 cp a,#1 334 | 615 01bf 2715 jreq L302 335 | 617 01c1 c6500a ld a,20490 336 | 618 01c4 a4c0 and a,#192 337 | 619 01c6 1104 cp a,(OFST-2,sp) 338 | 620 01c8 270c jreq L302 339 | 621 ; 219 sim(); 340 | 624 01ca 9b sim 341 | 626 ; 220 HDMI_PORT->ODR = (HDMI_PORT->ODR & HDMI_SW)|USB; 342 | 629 01cb c6500a ld a,20490 343 | 630 01ce a420 and a,#32 344 | 631 01d0 1a04 or a,(OFST-2,sp) 345 | 632 01d2 c7500a ld 20490,a 346 | 633 ; 221 rim(); 347 | 636 01d5 9a rim 348 | 639 01d6 L302: 349 | 640 ; 223 } 350 | 642 01d6 2081 jra L02 351 | 783 xdef _Mux_Tbl 352 | 784 switch .ubsct 353 | 785 0000 _Milli_Divider: 354 | 786 0000 00 ds.b 1 355 | 787 xdef _Milli_Divider 356 | 788 0001 _Milli_Timer2: 357 | 789 0001 00 ds.b 1 358 | 790 xdef _Milli_Timer2 359 | 791 0002 _Milli_Timer1: 360 | 792 0002 00 ds.b 1 361 | 793 xdef _Milli_Timer1 362 | 794 0003 _Micro_Timer1: 363 | 795 0003 00 ds.b 1 364 | 796 xdef _Micro_Timer1 365 | 797 0004 _Hotkeys: 366 | 798 0004 0000 ds.b 2 367 | 799 xdef _Hotkeys 368 | 800 0006 _PS2: 369 | 801 0006 0000000000 ds.b 5 370 | 802 xdef _PS2 371 | 803 xdef _PS2_Task 372 | 804 xdef _Init_Hardware 373 | 805 xdef f_TIM4_IRQ 374 | 806 xdef f_PORTB_IRQ 375 | 826 end 376 | -------------------------------------------------------------------------------- /Firmware/Debug/hardware.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FPGA-Computer/KVM-Switch/3f3526bb809239746657e17d94fe30fd696eddca/Firmware/Debug/hardware.o -------------------------------------------------------------------------------- /Firmware/Debug/hotkey.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FPGA-Computer/KVM-Switch/3f3526bb809239746657e17d94fe30fd696eddca/Firmware/Debug/hotkey.elf -------------------------------------------------------------------------------- /Firmware/Debug/hotkey.lkf: -------------------------------------------------------------------------------- 1 | # LINK COMMAND FILE AUTOMATICALLY GENERATED BY STVD: 2 | # * TOTALLY IF AUTO MODE IS ENABLED 3 | # * ONLY INSIDE MARKERS IN SEMI-AUTO MODE 4 | # 5 | # CHOOSE THE CUSTOM MODE IN STVD IN ORDER TO HAVE FULL CONTROL OVER THIS FILE. 6 | # 7 | # Sections delimited by and markers are reserved for 8 | # STVD: DO NOT MODIFY INSIDE. 9 | # 10 | # Manual modifications are allowed OUTSIDE these sections, WHEN STVD AUTO MODE 11 | # IS DISABLED. 12 | # 13 | # CAUTION: 14 | # * Changing from Custom to Semi-Auto mode removes modifications in 15 | # STVD-reserved sections 16 | # * Changing to Auto mode removes all modifications. 17 | # 18 | # In Semi-Auto mode, you are allowed to remove and markers 19 | # in order to gain control over the concerned sections. As a consequence any 20 | # modification from the STVD graphical interface concerning this section will be 21 | # ignored. 22 | # 23 | # Please refer to Cosmic User Manuals before any modification. 24 | # Note that errors in editing this file may have unpredictable results when 25 | # running STVD. 26 | 27 | # Segment configuration - section reserved for STVD 28 | # 29 | # Segment Code,Constants: 30 | +seg .const -b 0x8080 -m 0x1f80 -n .const -it 31 | +seg .text -a .const -n .text 32 | # Segment Eeprom: 33 | +seg .eeprom -b 0x4000 -m 0x80 -n .eeprom 34 | # Segment Zero Page: 35 | +seg .bsct -b 0x0 -m 0x100 -n .bsct 36 | +seg .ubsct -a .bsct -n .ubsct 37 | +seg .bit -a .ubsct -n .bit -id 38 | +seg .share -a .bit -n .share -is 39 | # Segment Ram: 40 | +seg .data -b 0x100 -m 0x100 -n .data 41 | +seg .bss -a .data -n .bss 42 | # 43 | 44 | 45 | # Startup file - section reserved for STVD 46 | # 47 | crtsi0.sm8 48 | # 49 | 50 | 51 | # Object files list - section reserved for STVD 52 | # 53 | Debug\hardware.o 54 | Debug\main.o 55 | # 56 | 57 | 58 | # Library list - section reserved for STVD 59 | # 60 | libis0.sm8 61 | libm0.sm8 62 | # 63 | 64 | 65 | # Interrupt vectors file - section reserved for STVD 66 | # 67 | +seg .const -b 0x8000 -k 68 | Debug\stm8_interrupt_vector.o 69 | # 70 | 71 | # Defines - section reserved for STVD 72 | # 73 | +def __endzp=@.ubsct # end of uninitialized zpage 74 | +def __memory=@.bss # end of bss segment 75 | +def __startmem=@.bss 76 | +def __endmem=0x1ff 77 | +def __stack=0x3ff 78 | # 79 | -------------------------------------------------------------------------------- /Firmware/Debug/hotkey.map: -------------------------------------------------------------------------------- 1 | 2 | Map of Debug\hotkey.sm8 from link file Debug\hotkey.lkf - Mon Jun 10 10:17:33 2019 3 | 4 | 5 | -------- 6 | Segments 7 | -------- 8 | 9 | start 00008080 end 00008084 length 4 segment .const 10 | start 00008087 end 000082b8 length 561 segment .text 11 | start 00004000 end 00004000 length 0 segment .eeprom 12 | start 00000000 end 00000000 length 0 segment .bsct 13 | start 00000000 end 00000011 length 17 segment .ubsct 14 | start 00000011 end 00000011 length 0 segment .bit 15 | start 00000011 end 00000011 length 0 segment .share 16 | start 00000100 end 00000100 length 0 segment .data 17 | start 00000100 end 00000100 length 0 segment .bss 18 | start 00000000 end 00000218 length 536 segment .info. 19 | start 00000000 end 0000056c length 1388 segment .debug 20 | start 00008000 end 00008080 length 128 segment .const 21 | start 00008084 end 00008087 length 3 segment .init 22 | 23 | 24 | ------- 25 | Modules 26 | ------- 27 | 28 | C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\crtsi0.sm8: 29 | start 00008087 end 000080d7 length 80 section .text 30 | start 00000100 end 00000100 length 0 section .bss 31 | start 00000000 end 00000000 length 0 section .ubsct 32 | start 00000000 end 0000002f length 47 section .info. 33 | 34 | Debug\hardware.o: 35 | start 000080d7 end 000082af length 472 section .text 36 | start 00000000 end 0000000b length 11 section .ubsct 37 | start 00000000 end 0000037b length 891 section .debug 38 | start 0000002f end 0000009f length 112 section .info. 39 | start 00008080 end 00008084 length 4 section .const 40 | 41 | Debug\main.o: 42 | start 000082af end 000082b7 length 8 section .text 43 | start 0000037b end 00000429 length 174 section .debug 44 | start 0000009f end 0000010b length 108 section .info. 45 | 46 | (C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\libm0.sm8)xreg.o: 47 | start 0000000b end 0000000e length 3 section .ubsct 48 | start 0000010b end 00000139 length 46 section .info. 49 | 50 | (C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\libm0.sm8)yreg.o: 51 | start 0000000e end 00000011 length 3 section .ubsct 52 | start 00000139 end 00000167 length 46 section .info. 53 | 54 | Debug\stm8_interrupt_vector.o: 55 | start 000082b7 end 000082b8 length 1 section .text 56 | start 00000429 end 0000056c length 323 section .debug 57 | start 00000167 end 000001e4 length 125 section .info. 58 | start 00008000 end 00008080 length 128 section .const 59 | 60 | 61 | ----------- 62 | Stack usage 63 | ----------- 64 | 65 | Debug\hardware.o: 66 | _Init_Hardware 2 (2) 67 | _PS2_Task 8 (8) 68 | f_PORTB_IRQ > 6 (6) 69 | f_TIM4_IRQ > 6 (6) 70 | 71 | Debug\main.o: 72 | _main > 10 (2) 73 | 74 | Debug\stm8_interrupt_vector.o: 75 | f_Default_IRQ_Handler > 6 (6) 76 | 77 | Stack size: 16 78 | 79 | 80 | --------- 81 | Call tree 82 | --------- 83 | 1 > __stext: (0) 84 | 85 | 2 > _main: (2) 86 | 3 + _Init_Hardware: (2) 87 | 4 + _PS2_Task: (8) 88 | 89 | 5 > f_Default_IRQ_Handler: (6) 90 | 91 | 6 > f_PORTB_IRQ: (6) 92 | 93 | 7 > f_TIM4_IRQ: (6) 94 | 95 | 8 _Init_Hardware --> 3 96 | 97 | 9 _PS2_Task --> 4 98 | 99 | 100 | 101 | ------- 102 | Symbols 103 | ------- 104 | 105 | _Hotkeys 00000004 defined in Debug\hardware.o section .ubsct 106 | _Init_Hardware 000080d7 defined in Debug\hardware.o section .text 107 | used in Debug\main.o 108 | _Micro_Timer1 00000003 defined in Debug\hardware.o section .ubsct 109 | _Milli_Divider 00000000 defined in Debug\hardware.o section .ubsct 110 | _Milli_Timer1 00000002 defined in Debug\hardware.o section .ubsct 111 | _Milli_Timer2 00000001 defined in Debug\hardware.o section .ubsct 112 | _Mux_Tbl 00008080 defined in Debug\hardware.o section .const 113 | _PS2 00000006 defined in Debug\hardware.o section .ubsct 114 | _PS2_Task 000081ac defined in Debug\hardware.o section .text 115 | used in Debug\main.o 116 | __endmem 000001ff defined in command file 117 | *** not used *** 118 | __endzp 00000011 defined in command file section .ubsct 119 | used in C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\crtsi0.sm8 120 | __idesc__ 00008084 defined in linker section .init 121 | used in C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\crtsi0.sm8 122 | __memory 00000100 defined in command file section .bss 123 | used in C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\crtsi0.sm8 124 | __stack 000003ff defined in command file 125 | used in C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\crtsi0.sm8 126 | __startmem 00000100 defined in command file section .bss 127 | *** not used *** 128 | __stext 00008087 defined in C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\crtsi0.sm8 section .text 129 | used in Debug\stm8_interrupt_vector.o 130 | __vectab 00008000 defined in Debug\stm8_interrupt_vector.o section .const 131 | _exit 000080d5 defined in C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\crtsi0.sm8 section .text 132 | _main 000082af defined in Debug\main.o section .text 133 | used in C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\crtsi0.sm8 134 | c_x 0000000b defined in (C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\libm0.sm8)xreg.o section .ubsct 135 | used in C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\crtsi0.sm8 136 | c_y 0000000e defined in (C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\libm0.sm8)yreg.o section .ubsct 137 | used in C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\crtsi0.sm8 138 | f_Default_IRQ_Handler 000082b7 defined in Debug\stm8_interrupt_vector.o section .text 139 | f_PORTB_IRQ 00008156 defined in Debug\hardware.o section .text 140 | used in Debug\stm8_interrupt_vector.o 141 | f_TIM4_IRQ 0000812d defined in Debug\hardware.o section .text 142 | used in Debug\stm8_interrupt_vector.o 143 | -------------------------------------------------------------------------------- /Firmware/Debug/hotkey.s19: -------------------------------------------------------------------------------- 1 | S013000044656275675C686F746B65792E736D38CF 2 | S1078080400080C078 3 | S1238087AE03FF9490CE8084AE8086F62725A5602717BF0BEE03BF0EBE0BEE0190F6F75CDD 4 | S12380A7905C90B30E26F5BE0B909390EE031C000520D8AE00002002F75CA3001126F9AE33 5 | S12380C701002002F75CA3010026F9CD82AF20FE725F50C6350850A03510500935E0500C1D 6 | S12380E735D8500D350E50025550025003351C501155501150123585534035015343350361 7 | S1238107534735C8534835037F71725F7F75725F7F74725F7F73725F7F72725F7F703F08E5 8 | S12381273F043F059A81721153443D0327023A033D0027043A0020163D0227023A023D0118 9 | S123814727043A012004721A500A35640000803D0827043D032614350F0003C65006A52079 10 | S12381672704A6012002A641B70880B6083C085FA5402727B608A14B26083501000A3F08E7 11 | S123818720E8BE0654BF06C65006A52027DCBE0601AA0001AA0201BF0620CFB608A10C26A9 12 | S12381A7C93F0820C552063D0A2603CC827F9BBE061F053F0A9AB60697B607A4015F1E058D 13 | S12381C75401A4FF5F021F05011E05A300F0260872100005AC00827F1E05A300E0260872B8 14 | S12381E7120005AC00827FB6044D270B4A271F4A273E4A275A207D1E05A300142676B6059F 15 | S1238207A10226703501000435190002201B1E05A300142617B605A10326113D02270D3FF6 16 | S12382270535020004351400025B06813F0420441E05A300142614B605A102260E3D022713 17 | S12382470A350300043519000220DE3F0420251E05A30014261CB605A10326163D022712C8 18 | S1238267350500023D0226FC721B500A350A000120023F043F043F05C6500B444444A403AF 19 | S12382876B037B035F97D680806B047B03A1012715C6500AA4C01104270C9BC6500AA42005 20 | S11482A71A04C7500A9A2081CD80D7CD81AC20FB808F 21 | S123800082008087820082B7820082B7820082B7820082B7820082B782008156820082B718 22 | S1238020820082B7820082B7820082B7820082B7820082B7820082B7820082B7820082B764 23 | S1238040820082B7820082B7820082B7820082B7820082B7820082B7820082B7820082B744 24 | S1238060820082B78200812D820082B7820082B7820082B7820082B7820082B7820082B7AF 25 | S1068084808700EE 26 | S903FFFFFE 27 | -------------------------------------------------------------------------------- /Firmware/Debug/hotkey.sm8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FPGA-Computer/KVM-Switch/3f3526bb809239746657e17d94fe30fd696eddca/Firmware/Debug/hotkey.sm8 -------------------------------------------------------------------------------- /Firmware/Debug/main.ls: -------------------------------------------------------------------------------- 1 | 1 ; C Compiler for STM8 (COSMIC Software) 2 | 2 ; Parser V4.11.5 - 29 Dec 2015 3 | 3 ; Generator (Limited) V4.4.4 - 27 Jan 2016 4 | 45 ; 26 void main(void) 5 | 45 ; 27 { 6 | 47 switch .text 7 | 48 0000 _main: 8 | 52 ; 28 Init_Hardware(); 9 | 54 0000 cd0000 call _Init_Hardware 10 | 56 0003 L12: 11 | 57 ; 32 PS2_Task(); 12 | 59 0003 cd0000 call _PS2_Task 13 | 62 0006 20fb jra L12 14 | 75 xdef _main 15 | 76 xref _PS2_Task 16 | 77 xref _Init_Hardware 17 | 96 end 18 | -------------------------------------------------------------------------------- /Firmware/Debug/main.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FPGA-Computer/KVM-Switch/3f3526bb809239746657e17d94fe30fd696eddca/Firmware/Debug/main.o -------------------------------------------------------------------------------- /Firmware/Debug/stm8_interrupt_vector.ls: -------------------------------------------------------------------------------- 1 | 1 ; C Compiler for STM8 (COSMIC Software) 2 | 2 ; Parser V4.11.5 - 29 Dec 2015 3 | 3 ; Generator (Limited) V4.4.4 - 27 Jan 2016 4 | 45 ; 34 @far @interrupt void Default_IRQ_Handler(void) 5 | 45 ; 35 { 6 | 46 switch .text 7 | 47 0000 f_Default_IRQ_Handler: 8 | 51 ; 36 } 9 | 54 0000 80 iret 10 | 56 .const: section .text 11 | 57 0000 __vectab: 12 | 58 0000 82 dc.b 130 13 | 60 0001 00 dc.b page(__stext) 14 | 61 0002 0000 dc.w __stext 15 | 62 0004 82 dc.b 130 16 | 64 0005 00 dc.b page(f_Default_IRQ_Handler) 17 | 65 0006 0000 dc.w f_Default_IRQ_Handler 18 | 66 0008 82 dc.b 130 19 | 68 0009 00 dc.b page(f_Default_IRQ_Handler) 20 | 69 000a 0000 dc.w f_Default_IRQ_Handler 21 | 70 000c 82 dc.b 130 22 | 72 000d 00 dc.b page(f_Default_IRQ_Handler) 23 | 73 000e 0000 dc.w f_Default_IRQ_Handler 24 | 74 0010 82 dc.b 130 25 | 76 0011 00 dc.b page(f_Default_IRQ_Handler) 26 | 77 0012 0000 dc.w f_Default_IRQ_Handler 27 | 78 0014 82 dc.b 130 28 | 80 0015 00 dc.b page(f_Default_IRQ_Handler) 29 | 81 0016 0000 dc.w f_Default_IRQ_Handler 30 | 82 0018 82 dc.b 130 31 | 84 0019 00 dc.b page(f_PORTB_IRQ) 32 | 85 001a 0000 dc.w f_PORTB_IRQ 33 | 86 001c 82 dc.b 130 34 | 88 001d 00 dc.b page(f_Default_IRQ_Handler) 35 | 89 001e 0000 dc.w f_Default_IRQ_Handler 36 | 90 0020 82 dc.b 130 37 | 92 0021 00 dc.b page(f_Default_IRQ_Handler) 38 | 93 0022 0000 dc.w f_Default_IRQ_Handler 39 | 94 0024 82 dc.b 130 40 | 96 0025 00 dc.b page(f_Default_IRQ_Handler) 41 | 97 0026 0000 dc.w f_Default_IRQ_Handler 42 | 98 0028 82 dc.b 130 43 | 100 0029 00 dc.b page(f_Default_IRQ_Handler) 44 | 101 002a 0000 dc.w f_Default_IRQ_Handler 45 | 102 002c 82 dc.b 130 46 | 104 002d 00 dc.b page(f_Default_IRQ_Handler) 47 | 105 002e 0000 dc.w f_Default_IRQ_Handler 48 | 106 0030 82 dc.b 130 49 | 108 0031 00 dc.b page(f_Default_IRQ_Handler) 50 | 109 0032 0000 dc.w f_Default_IRQ_Handler 51 | 110 0034 82 dc.b 130 52 | 112 0035 00 dc.b page(f_Default_IRQ_Handler) 53 | 113 0036 0000 dc.w f_Default_IRQ_Handler 54 | 114 0038 82 dc.b 130 55 | 116 0039 00 dc.b page(f_Default_IRQ_Handler) 56 | 117 003a 0000 dc.w f_Default_IRQ_Handler 57 | 118 003c 82 dc.b 130 58 | 120 003d 00 dc.b page(f_Default_IRQ_Handler) 59 | 121 003e 0000 dc.w f_Default_IRQ_Handler 60 | 122 0040 82 dc.b 130 61 | 124 0041 00 dc.b page(f_Default_IRQ_Handler) 62 | 125 0042 0000 dc.w f_Default_IRQ_Handler 63 | 126 0044 82 dc.b 130 64 | 128 0045 00 dc.b page(f_Default_IRQ_Handler) 65 | 129 0046 0000 dc.w f_Default_IRQ_Handler 66 | 130 0048 82 dc.b 130 67 | 132 0049 00 dc.b page(f_Default_IRQ_Handler) 68 | 133 004a 0000 dc.w f_Default_IRQ_Handler 69 | 134 004c 82 dc.b 130 70 | 136 004d 00 dc.b page(f_Default_IRQ_Handler) 71 | 137 004e 0000 dc.w f_Default_IRQ_Handler 72 | 138 0050 82 dc.b 130 73 | 140 0051 00 dc.b page(f_Default_IRQ_Handler) 74 | 141 0052 0000 dc.w f_Default_IRQ_Handler 75 | 142 0054 82 dc.b 130 76 | 144 0055 00 dc.b page(f_Default_IRQ_Handler) 77 | 145 0056 0000 dc.w f_Default_IRQ_Handler 78 | 146 0058 82 dc.b 130 79 | 148 0059 00 dc.b page(f_Default_IRQ_Handler) 80 | 149 005a 0000 dc.w f_Default_IRQ_Handler 81 | 150 005c 82 dc.b 130 82 | 152 005d 00 dc.b page(f_Default_IRQ_Handler) 83 | 153 005e 0000 dc.w f_Default_IRQ_Handler 84 | 154 0060 82 dc.b 130 85 | 156 0061 00 dc.b page(f_Default_IRQ_Handler) 86 | 157 0062 0000 dc.w f_Default_IRQ_Handler 87 | 158 0064 82 dc.b 130 88 | 160 0065 00 dc.b page(f_TIM4_IRQ) 89 | 161 0066 0000 dc.w f_TIM4_IRQ 90 | 162 0068 82 dc.b 130 91 | 164 0069 00 dc.b page(f_Default_IRQ_Handler) 92 | 165 006a 0000 dc.w f_Default_IRQ_Handler 93 | 166 006c 82 dc.b 130 94 | 168 006d 00 dc.b page(f_Default_IRQ_Handler) 95 | 169 006e 0000 dc.w f_Default_IRQ_Handler 96 | 170 0070 82 dc.b 130 97 | 172 0071 00 dc.b page(f_Default_IRQ_Handler) 98 | 173 0072 0000 dc.w f_Default_IRQ_Handler 99 | 174 0074 82 dc.b 130 100 | 176 0075 00 dc.b page(f_Default_IRQ_Handler) 101 | 177 0076 0000 dc.w f_Default_IRQ_Handler 102 | 178 0078 82 dc.b 130 103 | 180 0079 00 dc.b page(f_Default_IRQ_Handler) 104 | 181 007a 0000 dc.w f_Default_IRQ_Handler 105 | 182 007c 82 dc.b 130 106 | 184 007d 00 dc.b page(f_Default_IRQ_Handler) 107 | 185 007e 0000 dc.w f_Default_IRQ_Handler 108 | 235 xdef __vectab 109 | 236 xdef f_Default_IRQ_Handler 110 | 237 xref __stext 111 | 238 xref f_TIM4_IRQ 112 | 239 xref f_PORTB_IRQ 113 | 258 end 114 | -------------------------------------------------------------------------------- /Firmware/Debug/stm8_interrupt_vector.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FPGA-Computer/KVM-Switch/3f3526bb809239746657e17d94fe30fd696eddca/Firmware/Debug/stm8_interrupt_vector.o -------------------------------------------------------------------------------- /Firmware/Hotkey.stw: -------------------------------------------------------------------------------- 1 | ; STMicroelectronics Workspace file 2 | 3 | [Version] 4 | Keyword=ST7Workspace-V0.7 5 | 6 | [Project0] 7 | Filename=hotkey.stp 8 | Dependencies= 9 | [Options] 10 | ActiveProject=hotkey 11 | ActiveConfig=Debug 12 | AddSortedElements=1 13 | -------------------------------------------------------------------------------- /Firmware/Release/hotkey.lkf: -------------------------------------------------------------------------------- 1 | # LINK COMMAND FILE AUTOMATICALLY GENERATED BY STVD: 2 | # * TOTALLY IF AUTO MODE IS ENABLED 3 | # * ONLY INSIDE MARKERS IN SEMI-AUTO MODE 4 | # 5 | # CHOOSE THE CUSTOM MODE IN STVD IN ORDER TO HAVE FULL CONTROL OVER THIS FILE. 6 | # 7 | # Sections delimited by and markers are reserved for 8 | # STVD: DO NOT MODIFY INSIDE. 9 | # 10 | # Manual modifications are allowed OUTSIDE these sections, WHEN STVD AUTO MODE 11 | # IS DISABLED. 12 | # 13 | # CAUTION: 14 | # * Changing from Custom to Semi-Auto mode removes modifications in 15 | # STVD-reserved sections 16 | # * Changing to Auto mode removes all modifications. 17 | # 18 | # In Semi-Auto mode, you are allowed to remove and markers 19 | # in order to gain control over the concerned sections. As a consequence any 20 | # modification from the STVD graphical interface concerning this section will be 21 | # ignored. 22 | # 23 | # Please refer to Cosmic User Manuals before any modification. 24 | # Note that errors in editing this file may have unpredictable results when 25 | # running STVD. 26 | 27 | # Segment configuration - section reserved for STVD 28 | # 29 | # Segment Code,Constants: 30 | +seg .const -b 0x8080 -m 0x1f80 -n .const -it 31 | +seg .text -a .const -n .text 32 | # Segment Eeprom: 33 | +seg .eeprom -b 0x4000 -m 0x80 -n .eeprom 34 | # Segment Zero Page: 35 | +seg .bsct -b 0x0 -m 0x100 -n .bsct 36 | +seg .ubsct -a .bsct -n .ubsct 37 | +seg .bit -a .ubsct -n .bit -id 38 | +seg .share -a .bit -n .share -is 39 | # Segment Ram: 40 | +seg .data -b 0x100 -m 0x100 -n .data 41 | +seg .bss -a .data -n .bss 42 | # 43 | 44 | 45 | # Startup file - section reserved for STVD 46 | # 47 | crtsi0.sm8 48 | # 49 | 50 | 51 | # Object files list - section reserved for STVD 52 | # 53 | Release\hardware.o 54 | Release\main.o 55 | # 56 | 57 | 58 | # Library list - section reserved for STVD 59 | # 60 | libis0.sm8 61 | libm0.sm8 62 | # 63 | 64 | 65 | # Interrupt vectors file - section reserved for STVD 66 | # 67 | +seg .const -b 0x8000 -k 68 | Release\stm8_interrupt_vector.o 69 | # 70 | 71 | # Defines - section reserved for STVD 72 | # 73 | +def __endzp=@.ubsct # end of uninitialized zpage 74 | +def __memory=@.bss # end of bss segment 75 | +def __startmem=@.bss 76 | +def __endmem=0x1ff 77 | +def __stack=0x3ff 78 | # 79 | -------------------------------------------------------------------------------- /Firmware/checkres.spy: -------------------------------------------------------------------------------- 1 | ; 2 | ; ** Welcome to ST Visual Debug SPY System ** 3 | ; ** Copyright STMicroelectronics (c) 1999, all rights reserved ** 4 | ; Level 1 5 | ; Date 08/15/17 6 | ; Time 11:41:00 7 | ; 8 | <.\confmenu.cpp:170-11:41:00> 9 | Error: resource handle has not been restored in .\mainfrm.cpp:3205 10 | -------------------------------------------------------------------------------- /Firmware/hardware.c: -------------------------------------------------------------------------------- 1 | /* 2 | * hardware.c 3 | * 4 | * Created: April-28-17, 5:42:00 PM 5 | * Author: K. C. Lee 6 | * Copyright (c) 2017 by K. C. Lee 7 | 8 | This program is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this program. 20 | 21 | If not, see http://www.gnu.org/licenses/gpl-3.0.en.html 22 | */ 23 | 24 | #include "hardware.h" 25 | 26 | KBD_States PS2; 27 | Hotkey_State Hotkeys; 28 | 29 | uint8_t Micro_Timer1,Milli_Timer1,Milli_Timer2,Milli_Divider; 30 | 31 | const uint8_t Mux_Tbl[]= 32 | { 33 | // USB Mux HDMI Mux 34 | 0x01 << USB_SHIFT, // 00 Output 1 35 | 0x00 << USB_SHIFT, // 01 No connect 36 | 0x02 << USB_SHIFT, // 10 Output 2 37 | 0x03 << USB_SHIFT // 11 Output 3 38 | }; 39 | 40 | void Init_Hardware(void) 41 | { 42 | CLK->CKDIVR = 0; // Clk divider, CPU divider = 1 43 | EXTI->CR1 = (0x02 << 2); // PB2 Interrupt: Falling edge 44 | PS2_PORT->CR2 = PS2_CLK; // Enable PS2_CLK interrupt 45 | 46 | // Button: open drain, USB: Push/pull; HDMI_S1, HDMI_S2: input+pullup 47 | HDMI_PORT->DDR = HDMI_SW|USB_IN1|USB_IN2; 48 | HDMI_PORT->CR1 = HDMI_S1|HDMI_S2|USB_IN1|USB_IN2; 49 | 50 | // unused GPIO defaults to output, push-pull 51 | GPIOA->CR1 = GPIOA->DDR = PA1|PA2|PA3; 52 | GPIOD->CR1 = GPIOD->DDR = PD2|PD3|PD4; 53 | 54 | // tim4 8-bit timer: Auto-reload, update = over/under flow, Counter enable 55 | TIM4->CR1 = TIM4_CR1_ARPE|TIM4_CR1_URS|TIM4_CR1_CEN; 56 | 57 | TIM4->IER = TIM4_IER_UIE; // Update IRQ enable 58 | TIM4->PSCR = TIM4_PSCR; // TIM4: 16MHz/2^TIM4_PSCR 59 | TIM4->ARR = TIM4_ARR; // Auto-reload 60 | 61 | // IRQ4 (PORTB PS2 CLK) = level 3 (high) 62 | ITC->ISPR2 = 0x03; 63 | // Rest of IRQ level 0 (low) 64 | ITC->ISPR1 = ITC->ISPR3 = ITC->ISPR4 = ITC->ISPR5 = ITC->ISPR6 = 0x00; 65 | 66 | PS2.State = PS2_Idle; 67 | 68 | Hotkeys.State = HK_Idle; 69 | Hotkeys.KeyAttr = 0; 70 | // Turn on interrupts 71 | rim(); 72 | } 73 | 74 | // Low priority timer interrupt: 10kHz 75 | @far @interrupt void TIM4_IRQ(void) 76 | { 77 | TIM4->SR1 &= ~TIM4_SR1_UIF; // Clear update IRQ 78 | 79 | if(Micro_Timer1) 80 | Micro_Timer1--; 81 | 82 | if(Milli_Divider) 83 | Milli_Divider--; 84 | else 85 | { // 100Hz interrupt 86 | if(Milli_Timer1) 87 | Milli_Timer1--; 88 | 89 | if(Milli_Timer2) // HDMI button 90 | Milli_Timer2--; 91 | else 92 | HDMI_PORT->ODR |= HDMI_SW; // Clear select button 93 | 94 | Milli_Divider = MILLI_DIVIDER_RELOAD; 95 | } 96 | } 97 | 98 | @far @interrupt void PORTB_IRQ(void) 99 | { 100 | if((PS2.State == PS2_Idle)||(!Micro_Timer1)) // Start bit or resynchronized 101 | { 102 | // rewind timer 103 | Micro_Timer1 = us_TO_TICKS(PS2_BIT_TIMEOUT); 104 | // first bit determines source: keyboard or PC 105 | PS2.State = (PS2_PORT->IDR & PS2_DATA)?PS2_CMD_1:PS2_KBD_1; 106 | } 107 | else 108 | { 109 | if(PS2.State++ & PS2_KBD) // Scan/respond code 110 | { 111 | if(PS2.State == PS2_KBD_LAST) 112 | { 113 | PS2.Avail = 1; 114 | PS2.State = PS2_Idle; 115 | } 116 | else 117 | { 118 | PS2.ScanCode >>= 1; 119 | 120 | if(PS2_PORT->IDR & PS2_DATA) 121 | PS2.ScanCode |= 0x200; 122 | } 123 | } 124 | else // Ignore Cmd to keyboard 125 | if(PS2.State == PS2_CMD_LAST) 126 | PS2.State = PS2_Idle; 127 | } 128 | } 129 | 130 | // high level polling task 131 | void PS2_Task(void) 132 | { 133 | uint16_t ScanCode, Parity; 134 | uint8_t HDMI, USB; 135 | 136 | if(PS2.Avail) 137 | { 138 | // Critical section 139 | sim(); 140 | ScanCode = PS2.ScanCode; 141 | PS2.Avail = 0; 142 | rim(); 143 | 144 | Parity = PS2.ScanCode & 0x01; 145 | ScanCode = (ScanCode >> 1) & 0xff; 146 | 147 | if (ScanCode == PS2_KBD_CODE_RELEASE) 148 | Hotkeys.KeyAttr |= Key_Release; 149 | else if (ScanCode == PS2_KBD_CODE_EXTENDED) 150 | Hotkeys.KeyAttr |= Key_Extend; 151 | else 152 | { 153 | switch(Hotkeys.State) 154 | { 155 | case HK_Idle: // wait for hot key press 156 | if(HOTKEY_MAKE) 157 | { 158 | Hotkeys.State = HK_KeyMake_1; 159 | Milli_Timer1 = HOTKEY_RELEASE_DELAY; 160 | return; 161 | } 162 | break; 163 | 164 | case HK_KeyMake_1: // wait for hot key release instead of hold 165 | if(HOTKEY_RELEASE && Milli_Timer1) 166 | { 167 | Hotkeys.KeyAttr = 0; 168 | Hotkeys.State = HK_KeyBreak_1; 169 | Milli_Timer1 = HOTKEY_WAIT_DELAY; 170 | return; 171 | } 172 | else 173 | Hotkeys.State = HK_Idle; 174 | break; 175 | 176 | case HK_KeyBreak_1: // wait for hot key release 177 | if(HOTKEY_MAKE && Milli_Timer1) 178 | { 179 | Hotkeys.State = HK_KeyMake_2; 180 | Milli_Timer1 = HOTKEY_RELEASE_DELAY; 181 | return; 182 | } 183 | else 184 | Hotkeys.State = HK_Idle; 185 | break; 186 | 187 | case HK_KeyMake_2: // wait for hot key press again 188 | if(HOTKEY_RELEASE && Milli_Timer1) 189 | { 190 | // Wait for USB to finish sending hot key release to host 191 | Milli_Timer1 = HOTKEY_USB_WAIT; 192 | 193 | while(Milli_Timer1) 194 | /* busy wait */; 195 | 196 | HDMI_PORT->ODR &= ~HDMI_SW; // Press select button(active low) 197 | Milli_Timer2 = HDMI_SW_DELAY; // hold for delay 198 | } 199 | else 200 | Hotkeys.State = HK_Idle; 201 | 202 | break; 203 | } 204 | 205 | // default to idle 206 | Hotkeys.State = HK_Idle; 207 | Hotkeys.KeyAttr = 0; 208 | } 209 | } 210 | 211 | HDMI = (HDMI_PORT->IDR & HDMI_SEL_MASK)>>HDMI_SHIFT; 212 | // HDMI Mux setting mapped to USB 213 | USB = Mux_Tbl[HDMI]; 214 | 215 | // filters out inactive HDMI, update when USB is not adready the same port 216 | if(((HDMI!= HDMI_NO_CONNECT)&&(HDMI_PORT->ODR & USB_SEL_MASK)!= USB)) 217 | { 218 | // Make the Read-Modify-Write I/O atomic 219 | sim(); 220 | HDMI_PORT->ODR = (HDMI_PORT->ODR & HDMI_SW)|USB; 221 | rim(); 222 | } 223 | } 224 | -------------------------------------------------------------------------------- /Firmware/hardware.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hardware.h 3 | * 4 | * Created: 22/12/2016 6:03:25 AM 5 | * Author: K. C. Lee 6 | * Copyright (c) 2016 by K. C. Lee 7 | 8 | This program is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this program. 20 | 21 | If not, see http://www.gnu.org/licenses/gpl-3.0.en.html 22 | */ 23 | 24 | #ifndef HARDWARE_H_ 25 | #define HARDWARE_H_ 26 | 27 | #ifndef __CSMC__ 28 | #define __CSMC__ 29 | #endif 30 | #define STM8S003 31 | 32 | #include "stm8s.h" 33 | //#include 34 | 35 | // STM8S003F3P6 36 | enum _PA { PA1=0x02, PA2=0x04, PA3=0x08 }; 37 | enum _PB { PB4=0x10, PB5=0x20 }; 38 | enum _PC { PC3=0x08, PC4=0x10, PC5=0x20, PC6=0x40, PC7=0x80 }; 39 | enum _PD { PD1=0x02, PD2=0x04, PD3=0x08, PD4=0x10, PD5=0x20, PD6=0x40 }; 40 | 41 | #include "irq.h" 42 | 43 | #define PS2_CLK PB4 44 | #define PS2_DATA PB5 45 | #define PS2_PORT GPIOB 46 | 47 | #define HDMI_S1 PC3 48 | #define HDMI_S2 PC4 49 | 50 | #define HDMI_SW PC5 51 | 52 | #define USB_IN1 PC6 53 | #define USB_IN2 PC7 54 | #define HDMI_PORT GPIOC 55 | 56 | #define HDMI_NO_CONNECT 0x01 57 | #define USB_NO_CONNECT 0x00 58 | 59 | #define HDMI_SEL_MASK (HDMI_S1 | HDMI_S2) 60 | #define USB_SEL_MASK (USB_IN1 | USB_IN2) 61 | 62 | #define HDMI_SHIFT 3 63 | #define USB_SHIFT 6 64 | 65 | #define PS2_KBD 0x40 66 | #define PS2_CMD 0x00 67 | 68 | #define PS2_KBD_BITS 10 69 | #define PS2_CMD_BITS 11 70 | 71 | #define PS2_BIT_TIMEOUT 1500 // us 72 | 73 | enum Key_States 74 | { 75 | PS2_Idle = 0, 76 | PS2_KBD_1 = PS2_KBD+1, 77 | PS2_KBD_LAST = PS2_KBD_1+PS2_KBD_BITS, 78 | PS2_CMD_1 = PS2_CMD+1, 79 | PS2_CMD_LAST = PS2_CMD_1+PS2_CMD_BITS 80 | }; 81 | 82 | enum Hotkey_States 83 | { 84 | HK_Idle, 85 | HK_KeyMake_1, 86 | HK_KeyBreak_1, 87 | HK_KeyMake_2 88 | }; 89 | 90 | enum KeyAttrib 91 | { 92 | Key_Regular = 0x00, 93 | Key_Release = 0x01, 94 | Key_Extend = 0x02 95 | }; 96 | 97 | typedef struct 98 | { 99 | volatile uint16_t ScanCode; 100 | uint8_t State; 101 | uint8_t Attrib; 102 | volatile uint8_t Avail; 103 | } KBD_States; 104 | 105 | #define PS2_KBD_CODE_EXTENDED 0xe0 106 | #define PS2_KBD_CODE_RELEASE 0xf0 107 | 108 | // CTRL 109 | #define HOTKEY_SCANCODE 0x14 110 | 111 | #define RCTRL // Hotkey: Right CRTL 112 | 113 | #ifdef RCTRL // Hotkey: Right CRTL 114 | #define HOTKEY_MAKE ((ScanCode == HOTKEY_SCANCODE) && (Hotkeys.KeyAttr==Key_Extend)) 115 | #define HOTKEY_RELEASE ((ScanCode == HOTKEY_SCANCODE) && (Hotkeys.KeyAttr==(Key_Extend|Key_Release))) 116 | #else // Hotkey: Left CRTL 117 | #define HOTKEY_MAKE ((ScanCode == HOTKEY_SCANCODE) && !Hotkeys.KeyAttr) 118 | #define HOTKEY_RELEASE ((ScanCode == HOTKEY_SCANCODE) && (Hotkeys.KeyAttr==Key_Release)) 119 | #endif 120 | 121 | #define HOTKEY_RELEASE_DELAY ms_TO_TICKS(250) 122 | #define HOTKEY_WAIT_DELAY ms_TO_TICKS(200) 123 | #define HOTKEY_USB_WAIT ms_TO_TICKS(50) 124 | #define HDMI_SW_DELAY ms_TO_TICKS(100) 125 | 126 | typedef struct 127 | { 128 | uint8_t State; 129 | uint8_t KeyAttr; 130 | } Hotkey_State; 131 | 132 | #define TIM4_PSCR 3 133 | #define TIM4_ARR 200 134 | #define MILLI_DIVIDER_RELOAD 100 135 | 136 | // 16MHz/2^TIM4_PSCR/TIM4_ARR = 10kHz (100us per tick) 137 | // 10kHz/MILLI_DIVIDER_RELOAD = 100Hz (10ms per tick) 138 | 139 | // Minimum delay 140 | #define us_TO_TICKS(X) ((X)/100) 141 | #define ms_TO_TICKS(X) ((X)/10) 142 | 143 | void Init_Hardware(void); 144 | void PS2_Task(void); 145 | 146 | // uart 115200 147 | #define UART_BAUD 115200UL 148 | #define UART_BRR_DIV ((int)(HSI_VALUE/UART_BAUD+0.5)) 149 | #define UART_BRR1 ((UART_BRR_DIV & 0x0ff0)>>4) 150 | #define UART_BRR2 (((UART_BRR_DIV & 0xf000)>>8)|(UART_BRR_DIV & 0x0f)) 151 | 152 | void Init_Serial(void); 153 | uint8_t GetC(void); 154 | void PutC(uint8_t ch); 155 | void Puthex2(uint8_t n); 156 | void Puthex4(uint16_t n); 157 | void NewLine(void); 158 | 159 | #define Poll_Serial() (UART1->SR & UART1_SR_RXNE) 160 | #define Get_Char() (UART1->DR) 161 | 162 | #endif 163 | -------------------------------------------------------------------------------- /Firmware/hotkey.dep: -------------------------------------------------------------------------------- 1 | ; STMicroelectronics dependencies file 2 | 3 | [Version] 4 | Keyword=ST7Project 5 | Number=1.3 6 | 7 | [Root.Source Files.hardware.c.Config.0] 8 | ExternDep= hardware.c "C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\Hstm8\mods0.h" hardware.h stm8s.h stm8s_conf.h "C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\Hstm8\stdio.h" irq.h 9 | 10 | [Root.Source Files.main.c.Config.0] 11 | ExternDep= main.c "C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\Hstm8\mods0.h" hardware.h stm8s.h stm8s_conf.h "C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\Hstm8\stdio.h" irq.h 12 | 13 | [Root.Source Files.stm8_interrupt_vector.c.Config.0] 14 | ExternDep= stm8_interrupt_vector.c "C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\Hstm8\mods0.h" irq.h stm8_interrupt_vector.h -------------------------------------------------------------------------------- /Firmware/hotkey.pdb: -------------------------------------------------------------------------------- 1 | [DebugState_v1-Debug.DebugContext] 2 | DumpRWOnFly1=0 3 | DumpRWOnFly2=0 4 | DumpRWOnFly3=0 5 | DumpRWOnFly4=0 6 | WatchVariables1=PS2!0;PS2_Buf!0;ScanCode!0;Hotkeys!0; 7 | FormatWatch1=0 8 | FormatViewType1=1 9 | FormatViewAddress1=1 10 | WatchRWOnFlyTab1=0 11 | WatchVariables2= 12 | FormatWatch2=0 13 | FormatViewType2=1 14 | FormatViewAddress2=1 15 | WatchRWOnFlyTab2=0 16 | WatchVariables3= 17 | FormatWatch3=0 18 | FormatViewType3=1 19 | FormatViewAddress3=1 20 | WatchRWOnFlyTab3=0 21 | WatchVariables4= 22 | FormatWatch4=0 23 | FormatViewType4=1 24 | FormatViewAddress4=1 25 | WatchRWOnFlyTab4=0 26 | FormatLocals=0 27 | FormatParameters=0 28 | [DebugState_v1-Debug.AddOn.St7Registers] 29 | ActiveTab=2 30 | [DebugState_v1-Debug.AddOn.St7PeripheralRegister] 31 | DisplayFormat=1 32 | ShowPeriphAddress=0 33 | ShowRegisterAddress=1 34 | [DebugState_v1-Debug.AddOn.St7McuIcdConf] 35 | McuName=STM8S003F3 36 | [DebugState_v1-Debug.AddOn.IcdBreak] 37 | ICDBreak0=CR:0x00000000,BK1:0x00000000,BK2:0x00000000 38 | [DebugState_v1-Debug.AddOn.SteppingMode] 39 | Mode=hardware 40 | -------------------------------------------------------------------------------- /Firmware/hotkey.stp: -------------------------------------------------------------------------------- 1 | ; STMicroelectronics Project file 2 | 3 | [Version] 4 | Keyword=ST7Project 5 | Number=1.3 6 | 7 | [Project] 8 | Name=hotkey 9 | Toolset=STM8 Cosmic 10 | 11 | [Config] 12 | 0=Config.0 13 | 1=Config.1 14 | 15 | [Config.0] 16 | ConfigName=Debug 17 | Target=hotkey.elf 18 | OutputFolder=Debug 19 | Debug=$(TargetFName) 20 | 21 | [Config.1] 22 | ConfigName=Release 23 | Target=hotkey.elf 24 | OutputFolder=Release 25 | Debug=$(TargetFName) 26 | 27 | [Root] 28 | ElemType=Project 29 | PathName=hotkey 30 | Child=Root.Source Files 31 | Config.0=Root.Config.0 32 | Config.1=Root.Config.1 33 | 34 | [Root.Config.0] 35 | Settings.0.0=Root.Config.0.Settings.0 36 | Settings.0.1=Root.Config.0.Settings.1 37 | Settings.0.2=Root.Config.0.Settings.2 38 | Settings.0.3=Root.Config.0.Settings.3 39 | Settings.0.4=Root.Config.0.Settings.4 40 | Settings.0.5=Root.Config.0.Settings.5 41 | Settings.0.6=Root.Config.0.Settings.6 42 | Settings.0.7=Root.Config.0.Settings.7 43 | Settings.0.8=Root.Config.0.Settings.8 44 | 45 | [Root.Config.1] 46 | Settings.1.0=Root.Config.1.Settings.0 47 | Settings.1.1=Root.Config.1.Settings.1 48 | Settings.1.2=Root.Config.1.Settings.2 49 | Settings.1.3=Root.Config.1.Settings.3 50 | Settings.1.4=Root.Config.1.Settings.4 51 | Settings.1.5=Root.Config.1.Settings.5 52 | Settings.1.6=Root.Config.1.Settings.6 53 | Settings.1.7=Root.Config.1.Settings.7 54 | Settings.1.8=Root.Config.1.Settings.8 55 | 56 | [Root.Config.0.Settings.0] 57 | String.6.0=2017,3,27,21,19,37 58 | String.100.0=ST Assembler Linker 59 | String.100.1=ST7 Cosmic 60 | String.100.2=STM8 Cosmic 61 | String.100.3=ST7 Metrowerks V1.1 62 | String.100.4=Raisonance 63 | String.101.0=STM8 Cosmic 64 | String.102.0=C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8 65 | String.103.0= 66 | String.104.0=Hstm8 67 | String.105.0=Lib 68 | String.106.0=Debug 69 | String.107.0=hotkey.elf 70 | Int.108=0 71 | 72 | [Root.Config.0.Settings.1] 73 | String.6.0=2017,3,27,21,19,37 74 | String.100.0=$(TargetFName) 75 | String.101.0= 76 | String.103.0=.\; 77 | 78 | [Root.Config.0.Settings.2] 79 | String.2.0= 80 | String.6.0=2017,3,27,21,19,37 81 | String.100.0=STM8S003F3P 82 | 83 | [Root.Config.0.Settings.3] 84 | String.2.0=Compiling $(InputFile)... 85 | String.3.0=cxstm8 -customDbg -customDebCompat -customOpt-no -customLst -l +mods0 -customC-pp $(ToolsetIncOpts) -cl$(IntermPath) -co$(IntermPath) $(InputFile) 86 | String.4.0=$(IntermPath)$(InputName).$(ObjectExt) 87 | String.5.0=$(IntermPath)$(InputName).ls 88 | String.6.0=2017,3,27,21,19,37 89 | 90 | [Root.Config.0.Settings.4] 91 | String.2.0=Assembling $(InputFile)... 92 | String.3.0=castm8 -xx -l $(ToolsetIncOpts) -o$(IntermPath)$(InputName).$(ObjectExt) $(InputFile) 93 | String.4.0=$(IntermPath)$(InputName).$(ObjectExt) 94 | String.5.0=$(IntermPath)$(InputName).ls 95 | String.6.0=2017,3,27,21,19,37 96 | 97 | [Root.Config.0.Settings.5] 98 | String.2.0=Running Pre-Link step 99 | String.6.0=2017,3,27,21,19,37 100 | String.8.0= 101 | 102 | [Root.Config.0.Settings.6] 103 | String.2.0=Running Linker 104 | String.3.0=clnk -customMapFile -customMapFile-m $(OutputPath)$(TargetSName).map -fakeRunConv -fakeInteger -fakeSemiAutoGen $(ToolsetLibOpts) -o $(OutputPath)$(TargetSName).sm8 -fakeOutFile$(ProjectSFile).elf -customCfgFile $(OutputPath)$(TargetSName).lkf -fakeVectFilestm8_interrupt_vector.c -fakeStartupcrtsi0.sm8 105 | String.3.1=cvdwarf $(OutputPath)$(TargetSName).sm8 -fakeVectAddr0x8000 106 | String.4.0=$(OutputPath)$(TargetFName) 107 | String.5.0=$(OutputPath)$(TargetSName).map $(OutputPath)$(TargetSName).st7 $(OutputPath)$(TargetSName).s19 108 | String.6.0=2017,8,15,0,26,19 109 | String.101.0=crtsi.st7 110 | String.102.0=+seg .const -b 0x8080 -m 0x1f80 -n .const -it 111 | String.102.1=+seg .text -a .const -n .text 112 | String.102.2=+seg .eeprom -b 0x4000 -m 0x80 -n .eeprom 113 | String.102.3=+seg .bsct -b 0x0 -m 0x100 -n .bsct 114 | String.102.4=+seg .ubsct -a .bsct -n .ubsct 115 | String.102.5=+seg .bit -a .ubsct -n .bit -id 116 | String.102.6=+seg .share -a .bit -n .share -is 117 | String.102.7=+seg .data -b 0x100 -m 0x100 -n .data 118 | String.102.8=+seg .bss -a .data -n .bss 119 | String.103.0=Code,Constants[0x8080-0x9fff]=.const,.text 120 | String.103.1=Eeprom[0x4000-0x407f]=.eeprom 121 | String.103.2=Zero Page[0x0-0xff]=.bsct,.ubsct,.bit,.share 122 | String.103.3=Ram[0x100-0x1ff]=.data,.bss 123 | String.104.0=0x3ff 124 | Int.0=0 125 | Int.1=0 126 | 127 | [Root.Config.0.Settings.7] 128 | String.2.0=Running Post-Build step 129 | String.3.0=chex -o $(OutputPath)$(TargetSName).s19 $(OutputPath)$(TargetSName).sm8 130 | String.3.1=MapInfo $(OutputPath) $(TargetSName).Map 131 | String.6.0=2017,3,30,12,45,5 132 | 133 | [Root.Config.0.Settings.8] 134 | String.2.0=Performing Custom Build on $(InputFile) 135 | String.6.0=2017,3,27,21,19,37 136 | 137 | [Root.Config.1.Settings.0] 138 | String.6.0=2017,3,27,21,19,37 139 | String.100.0=ST Assembler Linker 140 | String.100.1=ST7 Cosmic 141 | String.100.2=STM8 Cosmic 142 | String.100.3=ST7 Metrowerks V1.1 143 | String.100.4=Raisonance 144 | String.101.0=STM8 Cosmic 145 | String.102.0=C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8 146 | String.103.0= 147 | String.104.0=Hstm8 148 | String.105.0=Lib 149 | String.106.0=Release 150 | String.107.0=hotkey.elf 151 | Int.108=0 152 | 153 | [Root.Config.1.Settings.1] 154 | String.6.0=2017,3,27,21,19,37 155 | String.100.0=$(TargetFName) 156 | String.101.0= 157 | String.103.0=.\; 158 | 159 | [Root.Config.1.Settings.2] 160 | String.2.0= 161 | String.6.0=2017,3,27,21,19,37 162 | String.100.0=STM8S003F3P 163 | 164 | [Root.Config.1.Settings.3] 165 | String.2.0=Compiling $(InputFile)... 166 | String.3.0=cxstm8 +mods0 -customC-pp $(ToolsetIncOpts) -cl$(IntermPath) -co$(IntermPath) $(InputFile) 167 | String.4.0=$(IntermPath)$(InputName).$(ObjectExt) 168 | String.5.0=$(IntermPath)$(InputName).ls 169 | String.6.0=2017,3,27,21,19,37 170 | 171 | [Root.Config.1.Settings.4] 172 | String.2.0=Assembling $(InputFile)... 173 | String.3.0=castm8 $(ToolsetIncOpts) -o$(IntermPath)$(InputName).$(ObjectExt) $(InputFile) 174 | String.4.0=$(IntermPath)$(InputName).$(ObjectExt) 175 | String.5.0=$(IntermPath)$(InputName).ls 176 | String.6.0=2017,3,27,21,19,37 177 | 178 | [Root.Config.1.Settings.5] 179 | String.2.0=Running Pre-Link step 180 | String.6.0=2017,3,27,21,19,37 181 | 182 | [Root.Config.1.Settings.6] 183 | String.2.0=Running Linker 184 | String.3.0=clnk -fakeRunConv -fakeInteger -fakeSemiAutoGen $(ToolsetLibOpts) -o $(OutputPath)$(TargetSName).sm8 -fakeOutFile$(ProjectSFile).elf -customCfgFile $(OutputPath)$(TargetSName).lkf -fakeVectFilestm8_interrupt_vector.c -fakeStartupcrtsi0.sm8 185 | String.3.1=cvdwarf $(OutputPath)$(TargetSName).sm8 -fakeVectAddr0x8000 186 | String.4.0=$(OutputPath)$(TargetFName) 187 | String.5.0=$(OutputPath)$(TargetSName).map $(OutputPath)$(TargetSName).st7 $(OutputPath)$(TargetSName).s19 188 | String.6.0=2017,8,15,0,26,19 189 | String.101.0=crtsi.st7 190 | String.102.0=+seg .const -b 0x8080 -m 0x1f80 -n .const -it 191 | String.102.1=+seg .text -a .const -n .text 192 | String.102.2=+seg .eeprom -b 0x4000 -m 0x80 -n .eeprom 193 | String.102.3=+seg .bsct -b 0x0 -m 0x100 -n .bsct 194 | String.102.4=+seg .ubsct -a .bsct -n .ubsct 195 | String.102.5=+seg .bit -a .ubsct -n .bit -id 196 | String.102.6=+seg .share -a .bit -n .share -is 197 | String.102.7=+seg .data -b 0x100 -m 0x100 -n .data 198 | String.102.8=+seg .bss -a .data -n .bss 199 | String.103.0=Code,Constants[0x8080-0x9fff]=.const,.text 200 | String.103.1=Eeprom[0x4000-0x407f]=.eeprom 201 | String.103.2=Zero Page[0x0-0xff]=.bsct,.ubsct,.bit,.share 202 | String.103.3=Ram[0x100-0x1ff]=.data,.bss 203 | String.104.0=0x3ff 204 | Int.0=0 205 | Int.1=0 206 | 207 | [Root.Config.1.Settings.7] 208 | String.2.0=Running Post-Build step 209 | String.3.0=chex -o $(OutputPath)$(TargetSName).s19 $(OutputPath)$(TargetSName).sm8 210 | String.6.0=2017,3,27,21,19,37 211 | 212 | [Root.Config.1.Settings.8] 213 | String.2.0=Performing Custom Build on $(InputFile) 214 | String.6.0=2017,3,27,21,19,37 215 | 216 | [Root.Source Files] 217 | ElemType=Folder 218 | PathName=Source Files 219 | Child=Root.Source Files.hardware.c 220 | Next=Root.Include Files 221 | Config.0=Root.Source Files.Config.0 222 | Config.1=Root.Source Files.Config.1 223 | 224 | [Root.Source Files.Config.0] 225 | Settings.0.0=Root.Source Files.Config.0.Settings.0 226 | Settings.0.1=Root.Source Files.Config.0.Settings.1 227 | Settings.0.2=Root.Source Files.Config.0.Settings.2 228 | Settings.0.3=Root.Source Files.Config.0.Settings.3 229 | 230 | [Root.Source Files.Config.1] 231 | Settings.1.0=Root.Source Files.Config.1.Settings.0 232 | Settings.1.1=Root.Source Files.Config.1.Settings.1 233 | Settings.1.2=Root.Source Files.Config.1.Settings.2 234 | Settings.1.3=Root.Source Files.Config.1.Settings.3 235 | 236 | [Root.Source Files.Config.0.Settings.0] 237 | String.6.0=2017,3,27,21,19,37 238 | String.8.0=Debug 239 | Int.0=0 240 | Int.1=0 241 | 242 | [Root.Source Files.Config.0.Settings.1] 243 | String.2.0=Compiling $(InputFile)... 244 | String.3.0=cxstm8 -customDbg -customDebCompat -customOpt-no -customLst -l +mods0 -customC-pp $(ToolsetIncOpts) -cl$(IntermPath) -co$(IntermPath) $(InputFile) 245 | String.4.0=$(IntermPath)$(InputName).$(ObjectExt) 246 | String.5.0=$(IntermPath)$(InputName).ls 247 | String.6.0=2017,3,27,21,19,37 248 | 249 | [Root.Source Files.Config.0.Settings.2] 250 | String.2.0=Assembling $(InputFile)... 251 | String.3.0=castm8 -xx -l $(ToolsetIncOpts) -o$(IntermPath)$(InputName).$(ObjectExt) $(InputFile) 252 | String.4.0=$(IntermPath)$(InputName).$(ObjectExt) 253 | String.5.0=$(IntermPath)$(InputName).ls 254 | String.6.0=2017,3,27,21,19,37 255 | 256 | [Root.Source Files.Config.0.Settings.3] 257 | String.2.0=Performing Custom Build on $(InputFile) 258 | String.3.0= 259 | String.4.0= 260 | String.5.0= 261 | String.6.0=2017,3,27,21,19,37 262 | 263 | [Root.Source Files.Config.1.Settings.0] 264 | String.6.0=2017,3,27,21,19,37 265 | String.8.0=Release 266 | Int.0=0 267 | Int.1=0 268 | 269 | [Root.Source Files.Config.1.Settings.1] 270 | String.2.0=Compiling $(InputFile)... 271 | String.3.0=cxstm8 +mods0 -customC-pp $(ToolsetIncOpts) -cl$(IntermPath) -co$(IntermPath) $(InputFile) 272 | String.4.0=$(IntermPath)$(InputName).$(ObjectExt) 273 | String.5.0=$(IntermPath)$(InputName).ls 274 | String.6.0=2017,3,27,21,19,37 275 | 276 | [Root.Source Files.Config.1.Settings.2] 277 | String.2.0=Assembling $(InputFile)... 278 | String.3.0=castm8 $(ToolsetIncOpts) -o$(IntermPath)$(InputName).$(ObjectExt) $(InputFile) 279 | String.4.0=$(IntermPath)$(InputName).$(ObjectExt) 280 | String.5.0=$(IntermPath)$(InputName).ls 281 | String.6.0=2017,3,27,21,19,37 282 | 283 | [Root.Source Files.Config.1.Settings.3] 284 | String.2.0=Performing Custom Build on $(InputFile) 285 | String.3.0= 286 | String.4.0= 287 | String.5.0= 288 | String.6.0=2017,3,27,21,19,37 289 | 290 | [Root.Source Files.hardware.c] 291 | ElemType=File 292 | PathName=hardware.c 293 | Next=Root.Source Files.main.c 294 | 295 | [Root.Source Files.main.c] 296 | ElemType=File 297 | PathName=main.c 298 | Next=Root.Source Files.stm8_interrupt_vector.c 299 | 300 | [Root.Source Files.stm8_interrupt_vector.c] 301 | ElemType=File 302 | PathName=stm8_interrupt_vector.c 303 | 304 | [Root.Include Files] 305 | ElemType=Folder 306 | PathName=Include Files 307 | Child=Root.Include Files.hardware.h 308 | Config.0=Root.Include Files.Config.0 309 | Config.1=Root.Include Files.Config.1 310 | 311 | [Root.Include Files.Config.0] 312 | Settings.0.0=Root.Include Files.Config.0.Settings.0 313 | Settings.0.1=Root.Include Files.Config.0.Settings.1 314 | Settings.0.2=Root.Include Files.Config.0.Settings.2 315 | Settings.0.3=Root.Include Files.Config.0.Settings.3 316 | 317 | [Root.Include Files.Config.1] 318 | Settings.1.0=Root.Include Files.Config.1.Settings.0 319 | Settings.1.1=Root.Include Files.Config.1.Settings.1 320 | Settings.1.2=Root.Include Files.Config.1.Settings.2 321 | Settings.1.3=Root.Include Files.Config.1.Settings.3 322 | 323 | [Root.Include Files.Config.0.Settings.0] 324 | String.6.0=2017,3,27,21,19,37 325 | String.8.0=Debug 326 | Int.0=0 327 | Int.1=0 328 | 329 | [Root.Include Files.Config.0.Settings.1] 330 | String.2.0=Compiling $(InputFile)... 331 | String.3.0=cxstm8 -customDbg -customDebCompat -customOpt-no -customLst -l +mods0 -customC-pp $(ToolsetIncOpts) -cl$(IntermPath) -co$(IntermPath) $(InputFile) 332 | String.4.0=$(IntermPath)$(InputName).$(ObjectExt) 333 | String.5.0=$(IntermPath)$(InputName).ls 334 | String.6.0=2017,3,27,21,19,37 335 | 336 | [Root.Include Files.Config.0.Settings.2] 337 | String.2.0=Assembling $(InputFile)... 338 | String.3.0=castm8 -xx -l $(ToolsetIncOpts) -o$(IntermPath)$(InputName).$(ObjectExt) $(InputFile) 339 | String.4.0=$(IntermPath)$(InputName).$(ObjectExt) 340 | String.5.0=$(IntermPath)$(InputName).ls 341 | String.6.0=2017,3,27,21,19,37 342 | 343 | [Root.Include Files.Config.0.Settings.3] 344 | String.2.0=Performing Custom Build on $(InputFile) 345 | String.3.0= 346 | String.4.0= 347 | String.5.0= 348 | String.6.0=2017,3,27,21,19,37 349 | 350 | [Root.Include Files.Config.1.Settings.0] 351 | String.6.0=2017,3,27,21,19,37 352 | String.8.0=Release 353 | Int.0=0 354 | Int.1=0 355 | 356 | [Root.Include Files.Config.1.Settings.1] 357 | String.2.0=Compiling $(InputFile)... 358 | String.3.0=cxstm8 +mods0 -customC-pp $(ToolsetIncOpts) -cl$(IntermPath) -co$(IntermPath) $(InputFile) 359 | String.4.0=$(IntermPath)$(InputName).$(ObjectExt) 360 | String.5.0=$(IntermPath)$(InputName).ls 361 | String.6.0=2017,3,27,21,19,37 362 | 363 | [Root.Include Files.Config.1.Settings.2] 364 | String.2.0=Assembling $(InputFile)... 365 | String.3.0=castm8 $(ToolsetIncOpts) -o$(IntermPath)$(InputName).$(ObjectExt) $(InputFile) 366 | String.4.0=$(IntermPath)$(InputName).$(ObjectExt) 367 | String.5.0=$(IntermPath)$(InputName).ls 368 | String.6.0=2017,3,27,21,19,37 369 | 370 | [Root.Include Files.Config.1.Settings.3] 371 | String.2.0=Performing Custom Build on $(InputFile) 372 | String.3.0= 373 | String.4.0= 374 | String.5.0= 375 | String.6.0=2017,3,27,21,19,37 376 | 377 | [Root.Include Files.hardware.h] 378 | ElemType=File 379 | PathName=hardware.h 380 | Next=Root.Include Files.irq.h 381 | 382 | [Root.Include Files.irq.h] 383 | ElemType=File 384 | PathName=irq.h 385 | Next=Root.Include Files.stm8s.h 386 | 387 | [Root.Include Files.stm8s.h] 388 | ElemType=File 389 | PathName=stm8s.h -------------------------------------------------------------------------------- /Firmware/hotkey_Programmer/hotkey_STVP.stp: -------------------------------------------------------------------------------- 1 | [Last Settings] 2 | Hardware=ST-LINK 3 | PROTOCOL=SWIM 4 | Port=USB 5 | DEVICE=STM8S003F3 6 | Verify after programming=1 7 | Blank check before programming (when available)=1 8 | Erase device memory before programming (when available)=0 9 | Unlock protection before a programming cycle=0 10 | [DATA MEMORY] 11 | Count=0 12 | ProgramEvenIfBlank=0 13 | [PROGRAM MEMORY] 14 | Count=0 15 | ProgramEvenIfBlank=0 16 | [OPTION BYTE] 17 | Count=1 18 | File0=C:\My Documents\projects\STM8\KVM-Hotkey\hotkey_Programmer\hotkey_STVP_OPTION BYTE.hex 19 | ProgramEvenIfBlank=0 20 | -------------------------------------------------------------------------------- /Firmware/hotkey_Programmer/hotkey_STVP_OPTION BYTE.hex: -------------------------------------------------------------------------------- 1 | :0148000000B7 2 | :0148010000B6 3 | :0148030000B4 4 | :0148050000B2 5 | :0148070000B0 6 | :0148090000AE 7 | :00000001FF 8 | -------------------------------------------------------------------------------- /Firmware/irq.h: -------------------------------------------------------------------------------- 1 | /* 2 | * irq.h 3 | * 4 | * Created: April-28-17, 5:42:00 PM 5 | * Author: K. C. Lee 6 | * Copyright (c) 2017 by K. C. Lee 7 | 8 | This program is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this program. 20 | 21 | If not, see http://www.gnu.org/licenses/gpl-3.0.en.html 22 | */ 23 | 24 | @far @interrupt void PORTB_IRQ(void); 25 | @far @interrupt void TIM4_IRQ(void); 26 | 27 | #define IRQ4 PORTB_IRQ 28 | #define IRQ23 TIM4_IRQ 29 | -------------------------------------------------------------------------------- /Firmware/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * main.c 3 | * 4 | * Created: April-28-17, 5:42:00 PM 5 | * Author: K. C. Lee 6 | * Copyright (c) 2017 by K. C. Lee 7 | 8 | This program is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this program. 20 | 21 | If not, see http://www.gnu.org/licenses/gpl-3.0.en.html 22 | */ 23 | 24 | #include "hardware.h" 25 | 26 | void main(void) 27 | { 28 | Init_Hardware(); 29 | 30 | while(1) 31 | { 32 | PS2_Task(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Firmware/stm8_interrupt_vector.c: -------------------------------------------------------------------------------- 1 | /* 2 | * stm8_interrupt_vector.c 3 | * 4 | * Created: February-03-17, 4:56:38 PM 5 | * Author: K. C. Lee 6 | * Copyright (c) 2017 by K. C. Lee 7 | 8 | This program is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this program. 20 | 21 | If not, see http://www.gnu.org/licenses/gpl-3.0.en.html 22 | */ 23 | 24 | #include "irq.h" 25 | #include "stm8_interrupt_vector.h" 26 | 27 | typedef struct 28 | { 29 | unsigned char irq; 30 | void @far (*irq_handler)(void); 31 | } irq_vectors; 32 | 33 | extern void _stext(); 34 | @far @interrupt void Default_IRQ_Handler(void) 35 | { 36 | } 37 | 38 | const irq_vectors _vectab[] = 39 | { 40 | {0x82,(void @far (*)(void))_stext}, /* reset */ 41 | {0x82,TRAP}, // trap 42 | {0x82,IRQ0}, // irq0 43 | {0x82,IRQ1}, // irq1 44 | {0x82,IRQ2}, // irq2 45 | {0x82,IRQ3}, // irq3 46 | {0x82,IRQ4}, // irq4 47 | {0x82,IRQ5}, // irq5 48 | {0x82,IRQ6}, // irq6 49 | {0x82,IRQ7}, // irq7 50 | {0x82,IRQ8}, // irq8 51 | {0x82,IRQ9}, // irq9 52 | {0x82,IRQ10}, // irq10 53 | {0x82,IRQ11}, // irq11 54 | {0x82,IRQ12}, // irq12 55 | {0x82,IRQ13}, // irq13 56 | {0x82,IRQ14}, // irq14 57 | {0x82,IRQ15}, // irq15 58 | {0x82,IRQ16}, // irq16 59 | {0x82,IRQ17}, // irq17 60 | {0x82,IRQ18}, // irq18 61 | {0x82,IRQ19}, // irq19 62 | {0x82,IRQ20}, // irq20 63 | {0x82,IRQ21}, // irq21 64 | {0x82,IRQ22}, // irq22 65 | {0x82,IRQ23}, // irq23 66 | {0x82,IRQ24}, // irq24 67 | {0x82,IRQ25}, // irq25 68 | {0x82,IRQ26}, // irq26 69 | {0x82,IRQ27}, // irq27 70 | {0x82,IRQ28}, // irq28 71 | {0x82,IRQ29}, // irq29 72 | }; 73 | -------------------------------------------------------------------------------- /Firmware/stm8_interrupt_vector.h: -------------------------------------------------------------------------------- 1 | /* 2 | * stm8_interrupt_vector.h 3 | * 4 | * Created: February-10-17, 9:47:05 PM 5 | * Author: K. C. Lee 6 | * Copyright (c) 2017 by K. C. Lee 7 | 8 | This program is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this program. 20 | 21 | If not, see http://www.gnu.org/licenses/gpl-3.0.en.html 22 | */ 23 | 24 | #ifndef TRAP 25 | #define TRAP Default_IRQ_Handler 26 | #endif 27 | 28 | #ifndef IRQ0 29 | #define IRQ0 Default_IRQ_Handler 30 | #endif 31 | 32 | #ifndef IRQ1 33 | #define IRQ1 Default_IRQ_Handler 34 | #endif 35 | 36 | #ifndef IRQ2 37 | #define IRQ2 Default_IRQ_Handler 38 | #endif 39 | 40 | #ifndef IRQ3 41 | #define IRQ3 Default_IRQ_Handler 42 | #endif 43 | 44 | #ifndef IRQ4 45 | #define IRQ4 Default_IRQ_Handler 46 | #endif 47 | 48 | #ifndef IRQ5 49 | #define IRQ5 Default_IRQ_Handler 50 | #endif 51 | 52 | #ifndef IRQ6 53 | #define IRQ6 Default_IRQ_Handler 54 | #endif 55 | 56 | #ifndef IRQ7 57 | #define IRQ7 Default_IRQ_Handler 58 | #endif 59 | 60 | #ifndef IRQ8 61 | #define IRQ8 Default_IRQ_Handler 62 | #endif 63 | 64 | #ifndef IRQ9 65 | #define IRQ9 Default_IRQ_Handler 66 | #endif 67 | 68 | #ifndef IRQ10 69 | #define IRQ10 Default_IRQ_Handler 70 | #endif 71 | 72 | #ifndef IRQ11 73 | #define IRQ11 Default_IRQ_Handler 74 | #endif 75 | 76 | #ifndef IRQ12 77 | #define IRQ12 Default_IRQ_Handler 78 | #endif 79 | 80 | #ifndef IRQ13 81 | #define IRQ13 Default_IRQ_Handler 82 | #endif 83 | 84 | #ifndef IRQ14 85 | #define IRQ14 Default_IRQ_Handler 86 | #endif 87 | 88 | #ifndef IRQ15 89 | #define IRQ15 Default_IRQ_Handler 90 | #endif 91 | 92 | #ifndef IRQ16 93 | #define IRQ16 Default_IRQ_Handler 94 | #endif 95 | 96 | #ifndef IRQ17 97 | #define IRQ17 Default_IRQ_Handler 98 | #endif 99 | 100 | #ifndef IRQ18 101 | #define IRQ18 Default_IRQ_Handler 102 | #endif 103 | 104 | #ifndef IRQ19 105 | #define IRQ19 Default_IRQ_Handler 106 | #endif 107 | 108 | #ifndef IRQ20 109 | #define IRQ20 Default_IRQ_Handler 110 | #endif 111 | 112 | #ifndef IRQ21 113 | #define IRQ21 Default_IRQ_Handler 114 | #endif 115 | 116 | #ifndef IRQ22 117 | #define IRQ22 Default_IRQ_Handler 118 | #endif 119 | 120 | #ifndef IRQ23 121 | #define IRQ23 Default_IRQ_Handler 122 | #endif 123 | 124 | #ifndef IRQ24 125 | #define IRQ24 Default_IRQ_Handler 126 | #endif 127 | 128 | #ifndef IRQ25 129 | #define IRQ25 Default_IRQ_Handler 130 | #endif 131 | 132 | #ifndef IRQ26 133 | #define IRQ26 Default_IRQ_Handler 134 | #endif 135 | 136 | #ifndef IRQ27 137 | #define IRQ27 Default_IRQ_Handler 138 | #endif 139 | 140 | #ifndef IRQ28 141 | #define IRQ28 Default_IRQ_Handler 142 | #endif 143 | 144 | #ifndef IRQ29 145 | #define IRQ29 Default_IRQ_Handler 146 | #endif 147 | 148 | -------------------------------------------------------------------------------- /Firmware/stm8s_conf.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FPGA-Computer/KVM-Switch/3f3526bb809239746657e17d94fe30fd696eddca/Firmware/stm8s_conf.h -------------------------------------------------------------------------------- /Hardware/AZHW371 HDMI Switch.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FPGA-Computer/KVM-Switch/3f3526bb809239746657e17d94fe30fd696eddca/Hardware/AZHW371 HDMI Switch.pdf -------------------------------------------------------------------------------- /Hardware/Acive Or'ing (optional)/Active or'ing.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FPGA-Computer/KVM-Switch/3f3526bb809239746657e17d94fe30fd696eddca/Hardware/Acive Or'ing (optional)/Active or'ing.pdf -------------------------------------------------------------------------------- /Hardware/Acive Or'ing (optional)/LT Spice simulation/Active or'ing diode discrete -0.asc: -------------------------------------------------------------------------------- 1 | Version 4 2 | SHEET 1 1396 680 3 | WIRE 624 -1088 -176 -1088 4 | WIRE 720 -1088 624 -1088 5 | WIRE 976 -1088 816 -1088 6 | WIRE 1152 -1088 976 -1088 7 | WIRE 1264 -1088 1152 -1088 8 | WIRE 1264 -1024 1264 -1088 9 | WIRE 624 -976 624 -1088 10 | WIRE 976 -976 976 -1088 11 | WIRE -176 -960 -176 -1088 12 | WIRE 736 -928 688 -928 13 | WIRE 912 -928 736 -928 14 | WIRE 1264 -912 1264 -944 15 | WIRE -176 -848 -176 -880 16 | WIRE 624 -848 624 -880 17 | WIRE 736 -848 736 -928 18 | WIRE 736 -848 624 -848 19 | WIRE 800 -848 800 -1040 20 | WIRE 976 -848 976 -880 21 | WIRE 976 -848 800 -848 22 | WIRE 624 -816 624 -848 23 | WIRE 976 -800 976 -848 24 | WIRE 624 -688 624 -736 25 | WIRE 976 -688 976 -720 26 | WIRE 624 -528 -176 -528 27 | WIRE 720 -528 624 -528 28 | WIRE 976 -528 816 -528 29 | WIRE 1152 -528 1152 -1088 30 | WIRE 1152 -528 976 -528 31 | WIRE 624 -416 624 -528 32 | WIRE 976 -416 976 -528 33 | WIRE -176 -400 -176 -528 34 | WIRE 736 -368 688 -368 35 | WIRE 912 -368 736 -368 36 | WIRE -176 -288 -176 -320 37 | WIRE 624 -288 624 -320 38 | WIRE 736 -288 736 -368 39 | WIRE 736 -288 624 -288 40 | WIRE 800 -272 800 -480 41 | WIRE 976 -272 976 -320 42 | WIRE 976 -272 800 -272 43 | WIRE 624 -256 624 -288 44 | WIRE 976 -240 976 -272 45 | WIRE 624 -128 624 -176 46 | WIRE 976 -128 976 -160 47 | FLAG -176 -848 0 48 | FLAG -176 -288 0 49 | FLAG 624 -128 0 50 | FLAG 1264 -912 0 51 | FLAG 976 -128 0 52 | FLAG 624 -688 0 53 | FLAG 976 -688 0 54 | SYMBOL voltage -176 -976 R0 55 | WINDOW 123 0 0 Left 0 56 | WINDOW 39 24 44 Left 2 57 | SYMATTR SpiceLine Rser=1R 58 | SYMATTR InstName V1 59 | SYMATTR Value 5V 60 | SYMBOL voltage -176 -416 R0 61 | WINDOW 123 0 0 Left 0 62 | WINDOW 39 24 44 Left 2 63 | SYMATTR SpiceLine Rser=1R 64 | SYMATTR InstName V2 65 | SYMATTR Value PULSE(0V 5.0V 10ms 100ms 10ms 10ms 120ms 100) 66 | SYMBOL pmos 720 -480 R270 67 | WINDOW 3 56 72 Invisible 2 68 | WINDOW 38 92 28 Left 2 69 | WINDOW 0 93 56 Left 2 70 | SYMATTR Value "" 71 | SYMATTR SpiceModel Si2307BDS 72 | SYMATTR InstName M2 73 | SYMATTR Prefix X 74 | SYMBOL pnp2 688 -320 R180 75 | SYMATTR InstName Q4 76 | SYMATTR Value 2N2905A 77 | SYMBOL res 608 -272 R0 78 | SYMATTR InstName R4 79 | SYMATTR Value 100K 80 | SYMBOL res 1248 -1040 R0 81 | SYMATTR InstName R3 82 | SYMATTR Value 5r 83 | SYMBOL pnp2 912 -320 M180 84 | SYMATTR InstName Q3 85 | SYMATTR Value 2N3906 86 | SYMBOL res 960 -256 R0 87 | SYMATTR InstName R5 88 | SYMATTR Value 47K 89 | SYMBOL pmos 720 -1040 R270 90 | WINDOW 3 56 72 Invisible 2 91 | WINDOW 38 92 28 Left 2 92 | WINDOW 0 93 56 Left 2 93 | SYMATTR Value "" 94 | SYMATTR SpiceModel Si2307BDS 95 | SYMATTR InstName M1 96 | SYMATTR Prefix X 97 | SYMBOL pnp2 688 -880 R180 98 | SYMATTR InstName Q1 99 | SYMATTR Value 2N4126 100 | SYMBOL res 608 -832 R0 101 | SYMATTR InstName R1 102 | SYMATTR Value 100K 103 | SYMBOL pnp2 912 -880 M180 104 | SYMATTR InstName Q2 105 | SYMATTR Value 2N3906 106 | SYMBOL res 960 -816 R0 107 | SYMATTR InstName R2 108 | SYMATTR Value 47K 109 | TEXT -456 504 Left 2 !.include "Si2307bd.lib" 110 | TEXT -456 528 Left 2 !.tran 150ms 111 | -------------------------------------------------------------------------------- /Hardware/Acive Or'ing (optional)/LT Spice simulation/note.txt: -------------------------------------------------------------------------------- 1 | Different PNP transistors are used to test if matching pair is actually needed. 2 | 3 | -------------------------------------------------------------------------------- /Hardware/Acive Or'ing (optional)/LT Spice simulation/si2307bd.lib: -------------------------------------------------------------------------------- 1 | *March 21, 2005 2 | *Doc. ID: 78857, S-50383, Rev. B 3 | *File Name: Si2307BDS_PS.txt and Si2307BDS_PS.lib 4 | .SUBCKT Si2307BDS 4 1 2 5 | M1 3 1 2 2 PMOS W=647931u L=0.25u 6 | M2 2 1 2 4 NMOS W=647931u L=0.50u 7 | R1 4 3 RTEMP 23E-3 8 | CGS 1 2 250E-12 9 | DBD 4 2 DBD 10 | *************************************************************** 11 | .MODEL PMOS PMOS ( LEVEL = 3 TOX = 5E-8 12 | + RS = 25E-3 RD = 0 NSUB = 1.2E17 13 | + KP = 4E-6 UO = 400 14 | + VMAX = 0 XJ = 5E-7 KAPPA = 1E-1 15 | + ETA = 1E-4 TPG = -1 16 | + IS = 0 LD = 0 17 | + CGSO = 0 CGDO = 0 CGBO = 0 18 | + NFS = 0.8E12 DELTA = 0.1) 19 | *************************************************************** 20 | .MODEL NMOS NMOS ( LEVEL = 3 TOX = 5E-8 21 | +NSUB = 9E16 TPG = -1) 22 | *************************************************************** 23 | .MODEL DBD D (CJO=80E-12 VJ=0.38 M=0.23 24 | +RS=0.1 FC=0.5 IS=1E-12 TT=6E-8 N=1 BV=30.2) 25 | *************************************************************** 26 | .MODEL RTEMP RES (TC1=6E-3 TC2=5.5E-6) 27 | *************************************************************** 28 | .ENDS 29 | 30 | -------------------------------------------------------------------------------- /Hardware/Acive Or'ing (optional)/RPi3 Model B or'ing circuit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FPGA-Computer/KVM-Switch/3f3526bb809239746657e17d94fe30fd696eddca/Hardware/Acive Or'ing (optional)/RPi3 Model B or'ing circuit.png -------------------------------------------------------------------------------- /Hardware/Acive Or'ing (optional)/active or'ing PCB.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FPGA-Computer/KVM-Switch/3f3526bb809239746657e17d94fe30fd696eddca/Hardware/Acive Or'ing (optional)/active or'ing PCB.png -------------------------------------------------------------------------------- /Hardware/KVM boards - top.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FPGA-Computer/KVM-Switch/3f3526bb809239746657e17d94fe30fd696eddca/Hardware/KVM boards - top.jpg -------------------------------------------------------------------------------- /Hardware/KVM boards.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FPGA-Computer/KVM-Switch/3f3526bb809239746657e17d94fe30fd696eddca/Hardware/KVM boards.jpg -------------------------------------------------------------------------------- /Hardware/STM8S003 -OSH.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FPGA-Computer/KVM-Switch/3f3526bb809239746657e17d94fe30fd696eddca/Hardware/STM8S003 -OSH.pdf -------------------------------------------------------------------------------- /Hardware/STM8S003 -OSH_ListByValues.csv: -------------------------------------------------------------------------------- 1 | Qty,Value,Part Num,Package,Parts 2 | 2,0.1uF,0.1uF X7R 0603,CAPC1608X92N,"C3, C4" 3 | 1,1uF,1uF X5R/X7R 0603,CAPC1608X92N,C2 4 | 2,100K,100K 0603,RESC1608X55N,"R1, R2" 5 | 1,STM8S003F3,STM8S003F3,TSSOP20,U1 6 | 1,SWIM Debug,1x3 header for debugger,1X03,J1 7 | 1,PCB,Ordering: https://oshpark.com/shared_projects/IDmovVvi,, 8 | -------------------------------------------------------------------------------- /Hardware/Sketchup - 3D model/Sketchup -KVM 3D model.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FPGA-Computer/KVM-Switch/3f3526bb809239746657e17d94fe30fd696eddca/Hardware/Sketchup - 3D model/Sketchup -KVM 3D model.zip -------------------------------------------------------------------------------- /Hardware/USB Connector.sch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | <b>Frames for Sheet and Layout</b> 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | Date: 166 | >LAST_DATE_TIME 167 | Sheet: 168 | >SHEET 169 | REV: 170 | TITLE: 171 | Document Number: 172 | >DRAWING_NAME 173 | 174 | 175 | 176 | 177 | <b>FRAME</b> A Size , 8 1/2 x 11 INCH, Landscape<p> 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | <b>Berg Connectors</b><p> 194 | Based on the following source: 195 | <ul> 196 | <li>http://catalog.fciconnect.com 197 | </ul> 198 | <author>Created by librarian@cadsoft.de</author> 199 | 200 | 201 | <b>USB connector</b> with shield<p> 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | >NAME 265 | >VALUE 266 | E L E C T R O N I C S 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | >NAME 296 | >VALUE 297 | USB 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | <b>Supply Symbols</b><p> 336 | GND, VCC, 0V, +5V, -5V, etc.<p> 337 | Please keep in mind, that these devices are necessary for the 338 | automatic wiring of the supply signals.<p> 339 | The pin name defined in the symbol is identical to the net which is to be wired automatically.<p> 340 | In this library the device names are the same as the pin names of the symbols, therefore the correct signal names appear next to the supply symbols in the schematic.<p> 341 | <author>Created by librarian@cadsoft.de</author> 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | >VALUE 350 | 351 | 352 | 353 | 354 | 355 | <b>SUPPLY SYMBOL</b> 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | -------------------------------------------------------------------------------- /Hardware/USB Mux-v0.1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FPGA-Computer/KVM-Switch/3f3526bb809239746657e17d94fe30fd696eddca/Hardware/USB Mux-v0.1.pdf -------------------------------------------------------------------------------- /Hardware/USB Mux-v0.1_ListByValues.csv: -------------------------------------------------------------------------------- 1 | Qty,Value,Part Num,Package,Parts, 2 | 3,,SMT MICRO USB CONNECTOR,USB-AB-MICRO-SMD_V03_SMT,"USB1, USB2, USB3", 3 | 1,0.1uF,0U1 0603,CAPC1608X92N,C1, 4 | 2,1uF,1UF 0603,CAPC1608X92N,"C2, C3", 5 | 3,MBRS140,MBRS140,DIOM5436X265N,"D1, D2, D3", 6 | 1,NCN9252,NCN9252,UQN12,U1, 7 | 1,XC6206P332MR,XC6206P332MR,SOT95P280X135-3N,U2,Alternative: MCP1700T-3302E/TT 8 | 1,PCB,,,,https://oshpark.com/shared_projects/noy8f3xy 9 | -------------------------------------------------------------------------------- /Hardware/Wiring diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FPGA-Computer/KVM-Switch/3f3526bb809239746657e17d94fe30fd696eddca/Hardware/Wiring diagram.png -------------------------------------------------------------------------------- /KVM-Hotkey/Debug/fifo.ls: -------------------------------------------------------------------------------- 1 | 1 ; C Compiler for STM8 (COSMIC Software) 2 | 2 ; Parser V4.11.5 - 29 Dec 2015 3 | 3 ; Generator (Limited) V4.4.4 - 27 Jan 2016 4 | 89 ; 26 void FIFO_Clear(FIFO *Queue) 5 | 89 ; 27 { 6 | 91 switch .text 7 | 92 0000 _FIFO_Clear: 8 | 96 ; 28 Queue->Head = Queue->Tail = 0; 9 | 98 0000 6f02 clr (2,x) 10 | 99 0002 6f01 clr (1,x) 11 | 100 ; 29 } 12 | 103 0004 81 ret 13 | 140 ; 31 uint8_t FIFO_WriteAvail(FIFO *Queue) 14 | 140 ; 32 { 15 | 141 switch .text 16 | 142 0005 _FIFO_WriteAvail: 17 | 144 0005 89 pushw x 18 | 145 0006 89 pushw x 19 | 146 00000002 OFST: set 2 20 | 149 ; 33 return(FIFO_INC(Queue->Head,Queue->SizeMask)!=Queue->Tail); 21 | 151 0007 f6 ld a,(x) 22 | 152 0008 5f clrw x 23 | 153 0009 97 ld xl,a 24 | 154 000a 1f01 ldw (OFST-1,sp),x 25 | 156 000c 1e03 ldw x,(OFST+1,sp) 26 | 157 000e e601 ld a,(1,x) 27 | 158 0010 5f clrw x 28 | 159 0011 97 ld xl,a 29 | 160 0012 5c incw x 30 | 161 0013 01 rrwa x,a 31 | 162 0014 1402 and a,(OFST+0,sp) 32 | 163 0016 01 rrwa x,a 33 | 164 0017 1401 and a,(OFST-1,sp) 34 | 165 0019 01 rrwa x,a 35 | 166 001a 1603 ldw y,(OFST+1,sp) 36 | 167 001c 90e602 ld a,(2,y) 37 | 168 001f 905f clrw y 38 | 169 0021 9097 ld yl,a 39 | 170 0023 90bf00 ldw c_y,y 40 | 171 0026 b300 cpw x,c_y 41 | 172 0028 2704 jreq L01 42 | 173 002a a601 ld a,#1 43 | 174 002c 2001 jra L21 44 | 175 002e L01: 45 | 176 002e 4f clr a 46 | 177 002f L21: 47 | 180 002f 5b04 addw sp,#4 48 | 181 0031 81 ret 49 | 228 ; 36 uint8_t FIFO_Write(FIFO *Queue, FIFO_Data_t data) 50 | 228 ; 37 { 51 | 229 switch .text 52 | 230 0032 _FIFO_Write: 53 | 232 0032 89 pushw x 54 | 233 00000000 OFST: set 0 55 | 236 ; 38 if(FIFO_WriteAvail(Queue)) 56 | 238 0033 add0 call _FIFO_WriteAvail 57 | 240 0035 4d tnz a 58 | 241 0036 271d jreq L311 59 | 242 ; 40 Queue->Head = FIFO_INC(Queue->Head,Queue->SizeMask); 60 | 244 0038 1e01 ldw x,(OFST+1,sp) 61 | 245 003a e601 ld a,(1,x) 62 | 246 003c 4c inc a 63 | 247 003d 1e01 ldw x,(OFST+1,sp) 64 | 248 003f f4 and a,(x) 65 | 249 0040 1e01 ldw x,(OFST+1,sp) 66 | 250 0042 e701 ld (1,x),a 67 | 251 ; 41 FIFO_BUF(Queue)[Queue->Head] = data; 68 | 253 0044 1e01 ldw x,(OFST+1,sp) 69 | 254 0046 e601 ld a,(1,x) 70 | 255 0048 5f clrw x 71 | 256 0049 97 ld xl,a 72 | 257 004a 72fb01 addw x,(OFST+1,sp) 73 | 258 004d 7b05 ld a,(OFST+5,sp) 74 | 259 004f e703 ld (3,x),a 75 | 260 ; 42 return 1; 76 | 262 0051 a601 ld a,#1 77 | 264 0053 2001 jra L61 78 | 265 0055 L311: 79 | 266 ; 44 return 0; 80 | 268 0055 4f clr a 81 | 270 0056 L61: 82 | 272 0056 85 popw x 83 | 273 0057 81 ret 84 | 310 ; 47 uint8_t FIFO_ReadAvail(FIFO *Queue) 85 | 310 ; 48 { 86 | 311 switch .text 87 | 312 0058 _FIFO_ReadAvail: 88 | 314 0058 89 pushw x 89 | 315 00000000 OFST: set 0 90 | 318 ; 49 return(Queue->Head != Queue->Tail); 91 | 320 0059 e601 ld a,(1,x) 92 | 321 005b 1e01 ldw x,(OFST+1,sp) 93 | 322 005d e102 cp a,(2,x) 94 | 323 005f 2704 jreq L22 95 | 324 0061 a601 ld a,#1 96 | 325 0063 2001 jra L42 97 | 326 0065 L22: 98 | 327 0065 4f clr a 99 | 328 0066 L42: 100 | 331 0066 85 popw x 101 | 332 0067 81 ret 102 | 380 ; 52 uint8_t FIFO_Read(FIFO *Queue, FIFO_Data_t *data) 103 | 380 ; 53 { 104 | 381 switch .text 105 | 382 0068 _FIFO_Read: 106 | 384 0068 89 pushw x 107 | 385 00000000 OFST: set 0 108 | 388 ; 54 if (FIFO_ReadAvail(Queue)) 109 | 390 0069 aded call _FIFO_ReadAvail 110 | 392 006b 4d tnz a 111 | 393 006c 271e jreq L161 112 | 394 ; 56 Queue->Tail = FIFO_INC(Queue->Tail,Queue->SizeMask); 113 | 396 006e 1e01 ldw x,(OFST+1,sp) 114 | 397 0070 e602 ld a,(2,x) 115 | 398 0072 4c inc a 116 | 399 0073 1e01 ldw x,(OFST+1,sp) 117 | 400 0075 f4 and a,(x) 118 | 401 0076 1e01 ldw x,(OFST+1,sp) 119 | 402 0078 e702 ld (2,x),a 120 | 403 ; 57 *data = FIFO_BUF(Queue)[Queue->Tail]; 121 | 405 007a 1e01 ldw x,(OFST+1,sp) 122 | 406 007c e602 ld a,(2,x) 123 | 407 007e 5f clrw x 124 | 408 007f 97 ld xl,a 125 | 409 0080 72fb01 addw x,(OFST+1,sp) 126 | 410 0083 e603 ld a,(3,x) 127 | 411 0085 1e05 ldw x,(OFST+5,sp) 128 | 412 0087 f7 ld (x),a 129 | 413 ; 58 return 1; 130 | 415 0088 a601 ld a,#1 131 | 417 008a 2001 jra L03 132 | 418 008c L161: 133 | 419 ; 60 return 0; 134 | 421 008c 4f clr a 135 | 423 008d L03: 136 | 425 008d 85 popw x 137 | 426 008e 81 ret 138 | 473 ; 63 uint8_t Getc(FIFO *Queue) 139 | 473 ; 64 { 140 | 474 switch .text 141 | 475 008f _Getc: 142 | 477 008f 89 pushw x 143 | 478 0090 88 push a 144 | 479 00000001 OFST: set 1 145 | 482 0091 L112: 146 | 483 ; 67 while(!FIFO_Read(Queue,&ch)) 147 | 485 0091 96 ldw x,sp 148 | 486 0092 1c0001 addw x,#OFST+0 149 | 487 0095 89 pushw x 150 | 488 0096 1e04 ldw x,(OFST+3,sp) 151 | 489 0098 adce call _FIFO_Read 152 | 491 009a 85 popw x 153 | 492 009b 4d tnz a 154 | 493 009c 27f3 jreq L112 155 | 494 ; 70 return ch; 156 | 496 009e 7b01 ld a,(OFST+0,sp) 157 | 499 00a0 5b03 addw sp,#3 158 | 500 00a2 81 ret 159 | 513 xdef _Getc 160 | 514 xdef _FIFO_ReadAvail 161 | 515 xdef _FIFO_Read 162 | 516 xdef _FIFO_WriteAvail 163 | 517 xdef _FIFO_Write 164 | 518 xdef _FIFO_Clear 165 | 519 xref.b c_y 166 | 538 end 167 | -------------------------------------------------------------------------------- /KVM-Hotkey/Debug/fifo.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FPGA-Computer/KVM-Switch/3f3526bb809239746657e17d94fe30fd696eddca/KVM-Hotkey/Debug/fifo.o -------------------------------------------------------------------------------- /KVM-Hotkey/Debug/hardware.ls: -------------------------------------------------------------------------------- 1 | 1 ; C Compiler for STM8 (COSMIC Software) 2 | 2 ; Parser V4.11.5 - 29 Dec 2015 3 | 3 ; Generator (Limited) V4.4.4 - 27 Jan 2016 4 | 47 ; 8 void Init_Hardware(void) 5 | 47 ; 9 { 6 | 49 switch .text 7 | 50 0000 _Init_Hardware: 8 | 54 ; 10 CLK->CKDIVR = 0; // Clk divider, CPU divider = 1 9 | 56 0000 725f50c6 clr 20678 10 | 57 ; 11 EXTI->CR1 = 0x02 << 2; // PB2 Interrupt: Falling edge 11 | 59 0004 350850a0 mov 20640,#8 12 | 60 ; 12 PS2_PORT->CR2 = PS2_CLK; // Enable PS2_CLK interrupt 13 | 62 0008 35105009 mov 20489,#16 14 | 63 ; 15 GPIOA->CR1 = GPIOA->DDR = PA1|PA2|PA3; 15 | 65 000c 350e5002 mov 20482,#14 16 | 66 0010 5550025003 mov 20483,20482 17 | 67 ; 16 GPIOC->CR1 = GPIOC->DDR = PC3|PC4|PC5|PC6|PC7; 18 | 69 0015 35f8500c mov 20492,#248 19 | 70 0019 55500c500d mov 20493,20492 20 | 71 ; 17 GPIOD->CR1 = GPIOD->DDR = PD1|PD2|PD3|PD4; 21 | 73 001e 351e5011 mov 20497,#30 22 | 74 0022 5550115012 mov 20498,20497 23 | 75 ; 20 TIM4->CR1 = TIM4_CR1_ARPE|TIM4_CR1_URS|TIM4_CR1_CEN; 24 | 77 0027 35855340 mov 21312,#133 25 | 78 ; 22 TIM4->IER = TIM4_IER_UIE; // Update IRQ enable 26 | 80 002b 35015343 mov 21315,#1 27 | 81 ; 23 TIM4->PSCR = TIM4_PSCR; // TIM4: 16MHz/2^TIM4_PSCR 28 | 83 002f 35035347 mov 21319,#3 29 | 84 ; 24 TIM4->ARR = TIM4_ARR; // Auto-reload 30 | 86 0033 35c85348 mov 21320,#200 31 | 87 ; 27 ITC->ISPR2 = 0x03; 32 | 89 0037 35037f71 mov 32625,#3 33 | 90 ; 29 ITC->ISPR1 = ITC->ISPR3 = ITC->ISPR4 = ITC->ISPR5 = ITC->ISPR6 = 0x00; 34 | 92 003b 725f7f75 clr 32629 35 | 93 003f 725f7f74 clr 32628 36 | 94 0043 725f7f73 clr 32627 37 | 95 0047 725f7f72 clr 32626 38 | 96 004b 725f7f70 clr 32624 39 | 97 ; 31 Init_Serial(); 40 | 99 004f cd0185 call _Init_Serial 41 | 101 ; 33 PS2.State = PS2_Idle; 42 | 103 0052 3f07 clr _PS2+2 43 | 104 ; 35 Hotkeys.State = HK_Idle; 44 | 106 0054 3f03 clr _Hotkeys 45 | 107 ; 36 Hotkeys.KeyAttr = 0; 46 | 109 0056 3f04 clr _Hotkeys+1 47 | 110 ; 38 rim(); 48 | 113 0058 9a rim 49 | 115 ; 39 } 50 | 119 0059 81 ret 51 | 145 ; 42 @far @interrupt void TIM4_IRQ(void) 52 | 145 ; 43 { 53 | 147 switch .text 54 | 148 005a f_TIM4_IRQ: 55 | 152 ; 44 TIM4->SR1 &= ~TIM4_SR1_UIF; // Clear update IRQ 56 | 154 005a 72115344 bres 21316,#0 57 | 155 ; 46 if(Micro_Timer1) 58 | 157 005e 3d02 tnz _Micro_Timer1 59 | 158 0060 2702 jreq L13 60 | 159 ; 47 Micro_Timer1--; 61 | 161 0062 3a02 dec _Micro_Timer1 62 | 162 0064 L13: 63 | 163 ; 49 if(Milli_Divider) 64 | 165 0064 3d00 tnz _Milli_Divider 65 | 166 0066 2704 jreq L33 66 | 167 ; 50 Milli_Divider--; 67 | 169 0068 3a00 dec _Milli_Divider 68 | 171 006a 200a jra L53 69 | 172 006c L33: 70 | 173 ; 53 if(Milli_Timer1) 71 | 175 006c 3d01 tnz _Milli_Timer1 72 | 176 006e 2702 jreq L73 73 | 177 ; 54 Milli_Timer1--; 74 | 179 0070 3a01 dec _Milli_Timer1 75 | 180 0072 L73: 76 | 181 ; 56 Milli_Divider = MILLI_DIVIDER_RELOAD; 77 | 183 0072 35640000 mov _Milli_Divider,#100 78 | 184 0076 L53: 79 | 185 ; 58 } 80 | 188 0076 80 iret 81 | 212 ; 60 @far @interrupt void PORTB_IRQ(void) 82 | 212 ; 61 { 83 | 213 switch .text 84 | 214 0077 f_PORTB_IRQ: 85 | 218 ; 62 if((PS2.State == PS2_Idle)||(!Micro_Timer1)) // Start bit or resynchronized 86 | 220 0077 3d07 tnz _PS2+2 87 | 221 0079 2704 jreq L35 88 | 223 007b 3d02 tnz _Micro_Timer1 89 | 224 007d 2614 jrne L15 90 | 225 007f L35: 91 | 226 ; 65 Micro_Timer1 = us_TO_TICKS(PS2_BIT_TIMEOUT); 92 | 228 007f 350f0002 mov _Micro_Timer1,#15 93 | 229 ; 67 PS2.State = (PS2_PORT->IDR & PS2_DATA)?PS2_CMD_1:PS2_KBD_1; 94 | 231 0083 c65006 ld a,20486 95 | 232 0086 a520 bcp a,#32 96 | 233 0088 2704 jreq L21 97 | 234 008a a601 ld a,#1 98 | 235 008c 2002 jra L41 99 | 236 008e L21: 100 | 237 008e a641 ld a,#65 101 | 238 0090 L41: 102 | 239 0090 b707 ld _PS2+2,a 103 | 241 0092 L55: 104 | 242 ; 90 } 105 | 245 0092 80 iret 106 | 246 0093 L15: 107 | 247 ; 71 if(PS2.State++ & PS2_KBD) // Scan/respond code 108 | 249 0093 b607 ld a,_PS2+2 109 | 250 0095 3c07 inc _PS2+2 110 | 251 0097 5f clrw x 111 | 252 0098 a540 bcp a,#64 112 | 253 009a 2727 jreq L75 113 | 254 ; 73 if(PS2.State == PS2_KBD_LAST) 114 | 256 009c b607 ld a,_PS2+2 115 | 257 009e a14b cp a,#75 116 | 258 00a0 2608 jrne L16 117 | 259 ; 75 PS2.Avail = 1; 118 | 261 00a2 35010009 mov _PS2+4,#1 119 | 262 ; 76 PS2.State = PS2_Idle; 120 | 264 00a6 3f07 clr _PS2+2 121 | 266 00a8 20e8 jra L55 122 | 267 00aa L16: 123 | 268 ; 80 PS2.ScanCode >>= 1; 124 | 270 00aa be05 ldw x,_PS2 125 | 271 00ac 54 srlw x 126 | 272 00ad bf05 ldw _PS2,x 127 | 273 ; 82 if(PS2_PORT->IDR & PS2_DATA) 128 | 275 00af c65006 ld a,20486 129 | 276 00b2 a520 bcp a,#32 130 | 277 00b4 27dc jreq L55 131 | 278 ; 83 PS2.ScanCode |= 0x200; 132 | 280 00b6 be05 ldw x,_PS2 133 | 281 00b8 01 rrwa x,a 134 | 282 00b9 aa00 or a,#0 135 | 283 00bb 01 rrwa x,a 136 | 284 00bc aa02 or a,#2 137 | 285 00be 01 rrwa x,a 138 | 286 00bf bf05 ldw _PS2,x 139 | 287 00c1 20cf jra L55 140 | 288 00c3 L75: 141 | 289 ; 87 if(PS2.State == PS2_CMD_LAST) 142 | 291 00c3 b607 ld a,_PS2+2 143 | 292 00c5 a10c cp a,#12 144 | 293 00c7 26c9 jrne L55 145 | 294 ; 88 PS2.State = PS2_Idle; 146 | 296 00c9 3f07 clr _PS2+2 147 | 297 00cb 20c5 jra L55 148 | 346 ; 93 void PS2_Task(void) 149 | 346 ; 94 { 150 | 348 switch .text 151 | 349 00cd _PS2_Task: 152 | 351 00cd 5204 subw sp,#4 153 | 352 00000004 OFST: set 4 154 | 355 ; 97 if(PS2.Avail) 155 | 357 00cf 3d09 tnz _PS2+4 156 | 358 00d1 2603 jrne L22 157 | 359 00d3 cc0183 jp L521 158 | 360 00d6 L22: 159 | 361 ; 100 sim(); 160 | 364 00d6 9b sim 161 | 366 ; 101 ScanCode = PS2.ScanCode; 162 | 369 00d7 be05 ldw x,_PS2 163 | 370 00d9 1f03 ldw (OFST-1,sp),x 164 | 372 ; 102 PS2.Avail = 0; 165 | 374 00db 3f09 clr _PS2+4 166 | 375 ; 103 rim(); 167 | 378 00dd 9a rim 168 | 380 ; 105 Parity = PS2.ScanCode & 0x01; 169 | 383 00de b605 ld a,_PS2 170 | 384 00e0 97 ld xl,a 171 | 385 00e1 b606 ld a,_PS2+1 172 | 386 00e3 a401 and a,#1 173 | 387 00e5 5f clrw x 174 | 388 ; 106 ScanCode = (ScanCode >> 1) & 0xff; 175 | 390 00e6 1e03 ldw x,(OFST-1,sp) 176 | 391 00e8 54 srlw x 177 | 392 00e9 01 rrwa x,a 178 | 393 00ea a4ff and a,#255 179 | 394 00ec 5f clrw x 180 | 395 00ed 02 rlwa x,a 181 | 396 00ee 1f03 ldw (OFST-1,sp),x 182 | 397 00f0 01 rrwa x,a 183 | 399 ; 108 if (ScanCode == PS2_KBD_CODE_RELEASE) 184 | 401 00f1 1e03 ldw x,(OFST-1,sp) 185 | 402 00f3 a300f0 cpw x,#240 186 | 403 00f6 2607 jrne L721 187 | 404 ; 109 Hotkeys.KeyAttr |= Key_Release; 188 | 406 00f8 72100004 bset _Hotkeys+1,#0 189 | 408 00fc cc0183 jra L521 190 | 409 00ff L721: 191 | 410 ; 110 else if (ScanCode == PS2_KBD_CODE_EXTENDED) 192 | 412 00ff 1e03 ldw x,(OFST-1,sp) 193 | 413 0101 a300e0 cpw x,#224 194 | 414 0104 2606 jrne L331 195 | 415 ; 111 Hotkeys.KeyAttr |= Key_Extend; 196 | 417 0106 72120004 bset _Hotkeys+1,#1 197 | 419 010a 2077 jra L521 198 | 420 010c L331: 199 | 421 ; 114 switch(Hotkeys.State) 200 | 423 010c b603 ld a,_Hotkeys 201 | 425 ; 150 break; 202 | 426 010e 4d tnz a 203 | 427 010f 270b jreq L37 204 | 428 0111 4a dec a 205 | 429 0112 271d jreq L57 206 | 430 0114 4a dec a 207 | 431 0115 2738 jreq L77 208 | 432 0117 4a dec a 209 | 433 0118 274e jreq L101 210 | 434 011a 2063 jra L141 211 | 435 011c L37: 212 | 436 ; 116 case HK_Idle: 213 | 436 ; 117 if((ScanCode == HOTKEY_SCANCODE) && !Hotkeys.KeyAttr) 214 | 438 011c 1e03 ldw x,(OFST-1,sp) 215 | 439 011e a30014 cpw x,#20 216 | 440 0121 265c jrne L141 217 | 442 0123 3d04 tnz _Hotkeys+1 218 | 443 0125 2658 jrne L141 219 | 444 ; 119 Hotkeys.State = HK_KeyMake_1; 220 | 446 0127 35010003 mov _Hotkeys,#1 221 | 447 ; 120 Milli_Timer1 = HOTKEY_RELEASE_DELAY; 222 | 449 012b 35190001 mov _Milli_Timer1,#25 223 | 450 ; 121 return; 224 | 452 012f 201b jra L02 225 | 453 0131 L57: 226 | 454 ; 125 case HK_KeyMake_1: 227 | 454 ; 126 if((ScanCode == HOTKEY_SCANCODE) && (Hotkeys.KeyAttr==Key_Release) && Milli_Timer1) 228 | 456 0131 1e03 ldw x,(OFST-1,sp) 229 | 457 0133 a30014 cpw x,#20 230 | 458 0136 2647 jrne L141 231 | 460 0138 b604 ld a,_Hotkeys+1 232 | 461 013a a101 cp a,#1 233 | 462 013c 2641 jrne L141 234 | 464 013e 3d01 tnz _Milli_Timer1 235 | 465 0140 273d jreq L141 236 | 466 ; 128 Hotkeys.KeyAttr = 0; 237 | 468 0142 3f04 clr _Hotkeys+1 238 | 469 ; 129 Hotkeys.State = HK_KeyBreak_1; 239 | 471 0144 35020003 mov _Hotkeys,#2 240 | 472 ; 130 Milli_Timer1 = HOTKEY_WAIT_DELAY; 241 | 474 0148 35140001 mov _Milli_Timer1,#20 242 | 475 ; 131 return; 243 | 476 014c L02: 244 | 479 014c 5b04 addw sp,#4 245 | 480 014e 81 ret 246 | 481 014f L77: 247 | 482 ; 135 case HK_KeyBreak_1: 248 | 482 ; 136 if((ScanCode == HOTKEY_SCANCODE) && !Hotkeys.KeyAttr && Milli_Timer1) 249 | 484 014f 1e03 ldw x,(OFST-1,sp) 250 | 485 0151 a30014 cpw x,#20 251 | 486 0154 2629 jrne L141 252 | 488 0156 3d04 tnz _Hotkeys+1 253 | 489 0158 2625 jrne L141 254 | 491 015a 3d01 tnz _Milli_Timer1 255 | 492 015c 2721 jreq L141 256 | 493 ; 138 Hotkeys.State = HK_KeyMake_2; 257 | 495 015e 35030003 mov _Hotkeys,#3 258 | 496 ; 139 Milli_Timer1 = HOTKEY_RELEASE_DELAY; 259 | 498 0162 35190001 mov _Milli_Timer1,#25 260 | 499 ; 140 return; 261 | 501 0166 20e4 jra L02 262 | 502 0168 L101: 263 | 503 ; 144 case HK_KeyMake_2: 264 | 503 ; 145 if((ScanCode == HOTKEY_SCANCODE) && (Hotkeys.KeyAttr==Key_Release) && Milli_Timer1) 265 | 505 0168 1e03 ldw x,(OFST-1,sp) 266 | 506 016a a30014 cpw x,#20 267 | 507 016d 2610 jrne L141 268 | 509 016f b604 ld a,_Hotkeys+1 269 | 510 0171 a101 cp a,#1 270 | 511 0173 260a jrne L141 271 | 513 0175 3d01 tnz _Milli_Timer1 272 | 514 0177 2706 jreq L141 273 | 515 ; 147 PutC('!'); 274 | 517 0179 a621 ld a,#33 275 | 518 017b ad20 call _PutC 276 | 520 ; 148 NewLine(); 277 | 522 017d ad54 call _NewLine 278 | 524 017f L141: 279 | 525 ; 154 Hotkeys.State = HK_Idle; 280 | 527 017f 3f03 clr _Hotkeys 281 | 528 ; 155 Hotkeys.KeyAttr = 0; 282 | 530 0181 3f04 clr _Hotkeys+1 283 | 531 0183 L521: 284 | 532 ; 158 } 285 | 534 0183 20c7 jra L02 286 | 557 ; 160 void Init_Serial(void) 287 | 557 ; 161 { 288 | 558 switch .text 289 | 559 0185 _Init_Serial: 290 | 563 ; 162 UART1->BRR2 = UART_BRR2; 291 | 565 0185 350a5233 mov 21043,#10 292 | 566 ; 163 UART1->BRR1 = UART_BRR1; 293 | 568 0189 35085232 mov 21042,#8 294 | 569 ; 165 UART1->CR2 = UART1_CR2_TEN|UART1_CR2_REN; 295 | 571 018d 350c5235 mov 21045,#12 296 | 572 ; 166 } 297 | 575 0191 81 ret 298 | 598 ; 168 uint8_t GetC(void) 299 | 598 ; 169 { 300 | 599 switch .text 301 | 600 0192 _GetC: 302 | 604 0192 L571: 303 | 605 ; 170 while(!Poll_Serial()) 304 | 607 0192 c65230 ld a,21040 305 | 608 0195 a520 bcp a,#32 306 | 609 0197 27f9 jreq L571 307 | 610 ; 172 return(UART1->DR); 308 | 612 0199 c65231 ld a,21041 309 | 615 019c 81 ret 310 | 649 ; 175 void PutC(uint8_t ch) 311 | 649 ; 176 { 312 | 650 switch .text 313 | 651 019d _PutC: 314 | 653 019d 88 push a 315 | 654 00000000 OFST: set 0 316 | 657 019e L122: 317 | 658 ; 177 while(!(UART1->SR & UART1_SR_TXE)) 318 | 660 019e c65230 ld a,21040 319 | 661 01a1 a580 bcp a,#128 320 | 662 01a3 27f9 jreq L122 321 | 663 ; 179 UART1->DR = ch; 322 | 665 01a5 7b01 ld a,(OFST+1,sp) 323 | 666 01a7 c75231 ld 21041,a 324 | 667 ; 180 } 325 | 670 01aa 84 pop a 326 | 671 01ab 81 ret 327 | 706 ; 182 void Puthex(uint8_t n) 328 | 706 ; 183 { PutC((n<10)?n+'0':n-10+'A'); 329 | 707 switch .text 330 | 708 01ac _Puthex: 331 | 714 01ac a10a cp a,#10 332 | 715 01ae 2404 jruge L43 333 | 716 01b0 ab30 add a,#48 334 | 717 01b2 2002 jra L63 335 | 718 01b4 L43: 336 | 719 01b4 ab37 add a,#55 337 | 720 01b6 L63: 338 | 721 01b6 ade5 call _PutC 339 | 723 ; 184 } 340 | 726 01b8 81 ret 341 | 761 ; 186 void Puthex2(uint8_t n) 342 | 761 ; 187 { Puthex(n>>4); 343 | 762 switch .text 344 | 763 01b9 _Puthex2: 345 | 765 01b9 88 push a 346 | 766 00000000 OFST: set 0 347 | 771 01ba 4e swap a 348 | 772 01bb a40f and a,#15 349 | 773 01bd aded call _Puthex 350 | 775 ; 188 Puthex(n&0x0f); 351 | 777 01bf 7b01 ld a,(OFST+1,sp) 352 | 778 01c1 a40f and a,#15 353 | 779 01c3 ade7 call _Puthex 354 | 781 ; 189 } 355 | 784 01c5 84 pop a 356 | 785 01c6 81 ret 357 | 820 ; 191 void Puthex4(uint16_t n) 358 | 820 ; 192 { Puthex2(n>>8); 359 | 821 switch .text 360 | 822 01c7 _Puthex4: 361 | 824 01c7 89 pushw x 362 | 825 00000000 OFST: set 0 363 | 830 01c8 9e ld a,xh 364 | 831 01c9 adee call _Puthex2 365 | 833 ; 193 Puthex2(n&0xff); 366 | 835 01cb 7b02 ld a,(OFST+2,sp) 367 | 836 01cd a4ff and a,#255 368 | 837 01cf ade8 call _Puthex2 369 | 839 ; 194 } 370 | 842 01d1 85 popw x 371 | 843 01d2 81 ret 372 | 867 ; 196 void NewLine(void) 373 | 867 ; 197 { PutC('\x0d'); 374 | 868 switch .text 375 | 869 01d3 _NewLine: 376 | 875 01d3 a60d ld a,#13 377 | 876 01d5 adc6 call _PutC 378 | 878 ; 198 PutC('\x0a'); 379 | 880 01d7 a60a ld a,#10 380 | 881 01d9 adc2 call _PutC 381 | 883 ; 199 } 382 | 886 01db 81 ret 383 | 1008 xdef _Puthex 384 | 1009 switch .ubsct 385 | 1010 0000 _Milli_Divider: 386 | 1011 0000 00 ds.b 1 387 | 1012 xdef _Milli_Divider 388 | 1013 0001 _Milli_Timer1: 389 | 1014 0001 00 ds.b 1 390 | 1015 xdef _Milli_Timer1 391 | 1016 0002 _Micro_Timer1: 392 | 1017 0002 00 ds.b 1 393 | 1018 xdef _Micro_Timer1 394 | 1019 0003 _Hotkeys: 395 | 1020 0003 0000 ds.b 2 396 | 1021 xdef _Hotkeys 397 | 1022 0005 _PS2: 398 | 1023 0005 0000000000 ds.b 5 399 | 1024 xdef _PS2 400 | 1025 xdef _NewLine 401 | 1026 xdef _Puthex4 402 | 1027 xdef _Puthex2 403 | 1028 xdef _PutC 404 | 1029 xdef _GetC 405 | 1030 xdef _Init_Serial 406 | 1031 xdef _PS2_Task 407 | 1032 xdef _Init_Hardware 408 | 1033 xdef f_TIM4_IRQ 409 | 1034 xdef f_PORTB_IRQ 410 | 1054 end 411 | -------------------------------------------------------------------------------- /KVM-Hotkey/Debug/hardware.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FPGA-Computer/KVM-Switch/3f3526bb809239746657e17d94fe30fd696eddca/KVM-Hotkey/Debug/hardware.o -------------------------------------------------------------------------------- /KVM-Hotkey/Debug/hotkey.lkf: -------------------------------------------------------------------------------- 1 | # LINK COMMAND FILE AUTOMATICALLY GENERATED BY STVD: 2 | # * TOTALLY IF AUTO MODE IS ENABLED 3 | # * ONLY INSIDE MARKERS IN SEMI-AUTO MODE 4 | # 5 | # CHOOSE THE CUSTOM MODE IN STVD IN ORDER TO HAVE FULL CONTROL OVER THIS FILE. 6 | # 7 | # Sections delimited by and markers are reserved for 8 | # STVD: DO NOT MODIFY INSIDE. 9 | # 10 | # Manual modifications are allowed OUTSIDE these sections, WHEN STVD AUTO MODE 11 | # IS DISABLED. 12 | # 13 | # CAUTION: 14 | # * Changing from Custom to Semi-Auto mode removes modifications in 15 | # STVD-reserved sections 16 | # * Changing to Auto mode removes all modifications. 17 | # 18 | # In Semi-Auto mode, you are allowed to remove and markers 19 | # in order to gain control over the concerned sections. As a consequence any 20 | # modification from the STVD graphical interface concerning this section will be 21 | # ignored. 22 | # 23 | # Please refer to Cosmic User Manuals before any modification. 24 | # Note that errors in editing this file may have unpredictable results when 25 | # running STVD. 26 | 27 | # Segment configuration - section reserved for STVD 28 | # 29 | # Segment Code,Constants: 30 | +seg .const -b 0x8080 -m 0x1f80 -n .const -it 31 | +seg .text -a .const -n .text 32 | # Segment Eeprom: 33 | +seg .eeprom -b 0x4000 -m 0x80 -n .eeprom 34 | # Segment Zero Page: 35 | +seg .bsct -b 0x0 -m 0x100 -n .bsct 36 | +seg .ubsct -a .bsct -n .ubsct 37 | +seg .bit -a .ubsct -n .bit -id 38 | +seg .share -a .bit -n .share -is 39 | # Segment Ram: 40 | +seg .data -b 0x100 -m 0x100 -n .data 41 | +seg .bss -a .data -n .bss 42 | # 43 | 44 | 45 | # Startup file - section reserved for STVD 46 | # 47 | crtsi0.sm8 48 | # 49 | 50 | 51 | # Object files list - section reserved for STVD 52 | # 53 | Debug\hardware.o 54 | Debug\main.o 55 | # 56 | 57 | 58 | # Library list - section reserved for STVD 59 | # 60 | libis0.sm8 61 | libm0.sm8 62 | # 63 | 64 | 65 | # Interrupt vectors file - section reserved for STVD 66 | # 67 | +seg .const -b 0x8000 -k 68 | Debug\stm8_interrupt_vector.o 69 | # 70 | 71 | # Defines - section reserved for STVD 72 | # 73 | +def __endzp=@.ubsct # end of uninitialized zpage 74 | +def __memory=@.bss # end of bss segment 75 | +def __startmem=@.bss 76 | +def __endmem=0x1ff 77 | +def __stack=0x3ff 78 | # 79 | -------------------------------------------------------------------------------- /KVM-Hotkey/Debug/hotkey.map: -------------------------------------------------------------------------------- 1 | 2 | Map of Debug\hotkey.sm8 from link file Debug\hotkey.lkf - Fri Mar 31 13:28:27 2017 3 | 4 | 5 | -------- 6 | Segments 7 | -------- 8 | 9 | start 00008080 end 00008080 length 0 segment .const 10 | start 00008083 end 000082b8 length 565 segment .text 11 | start 00004000 end 00004000 length 0 segment .eeprom 12 | start 00000000 end 00000000 length 0 segment .bsct 13 | start 00000000 end 00000010 length 16 segment .ubsct 14 | start 00000010 end 00000010 length 0 segment .bit 15 | start 00000010 end 00000010 length 0 segment .share 16 | start 00000100 end 00000100 length 0 segment .data 17 | start 00000100 end 00000100 length 0 segment .bss 18 | start 00000000 end 00000218 length 536 segment .info. 19 | start 00000000 end 000006ef length 1775 segment .debug 20 | start 00008000 end 00008080 length 128 segment .const 21 | start 00008080 end 00008083 length 3 segment .init 22 | 23 | 24 | ------- 25 | Modules 26 | ------- 27 | 28 | C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\Lib\crtsi0.sm8: 29 | start 00008083 end 000080d3 length 80 section .text 30 | start 00000100 end 00000100 length 0 section .bss 31 | start 00000000 end 00000000 length 0 section .ubsct 32 | start 00000000 end 0000002f length 47 section .info. 33 | 34 | Debug\hardware.o: 35 | start 000080d3 end 000082af length 476 section .text 36 | start 00000000 end 0000000a length 10 section .ubsct 37 | start 00000000 end 000004fe length 1278 section .debug 38 | start 0000002f end 0000009f length 112 section .info. 39 | 40 | Debug\main.o: 41 | start 000082af end 000082b7 length 8 section .text 42 | start 000004fe end 000005ac length 174 section .debug 43 | start 0000009f end 0000010b length 108 section .info. 44 | 45 | (C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\Lib\libm0.sm8)xreg.o: 46 | start 0000000a end 0000000d length 3 section .ubsct 47 | start 0000010b end 00000139 length 46 section .info. 48 | 49 | (C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\Lib\libm0.sm8)yreg.o: 50 | start 0000000d end 00000010 length 3 section .ubsct 51 | start 00000139 end 00000167 length 46 section .info. 52 | 53 | Debug\stm8_interrupt_vector.o: 54 | start 000082b7 end 000082b8 length 1 section .text 55 | start 000005ac end 000006ef length 323 section .debug 56 | start 00000167 end 000001e4 length 125 section .info. 57 | start 00008000 end 00008080 length 128 section .const 58 | 59 | 60 | ----------- 61 | Stack usage 62 | ----------- 63 | 64 | Debug\hardware.o: 65 | _GetC > 2 (2) 66 | _Init_Hardware 4 (2) 67 | _Init_Serial 2 (2) 68 | _NewLine 5 (2) 69 | _PS2_Task 11 (6) 70 | _PutC 3 (3) 71 | _Puthex 5 (2) 72 | _Puthex2 8 (3) 73 | _Puthex4 > 12 (4) 74 | f_PORTB_IRQ > 6 (6) 75 | f_TIM4_IRQ > 6 (6) 76 | 77 | Debug\main.o: 78 | _main > 13 (2) 79 | 80 | Debug\stm8_interrupt_vector.o: 81 | f_Default_IRQ_Handler > 6 (6) 82 | 83 | Stack size: 19 84 | 85 | 86 | --------- 87 | Call tree 88 | --------- 89 | 1 > _GetC: (2) 90 | 91 | 2 > _Puthex4: (4) 92 | 3 + _Puthex2: (3) 93 | 4 | + _Puthex: (2) 94 | 5 | | + _PutC: (3) 95 | | | 96 | | 97 | 98 | 6 > __stext: (0) 99 | 100 | 7 > _main: (2) 101 | 8 + _Init_Hardware: (2) 102 | 9 | + _Init_Serial: (2) 103 | | 104 | 10 + _PS2_Task: (6) 105 | 11 | + _NewLine: (2) 106 | 12 | | + _PutC --> 5 107 | | | 108 | 13 | + _PutC --> 5 109 | | 110 | 111 | 14 > f_Default_IRQ_Handler: (6) 112 | 113 | 15 > f_PORTB_IRQ: (6) 114 | 115 | 16 > f_TIM4_IRQ: (6) 116 | 117 | 17 _Init_Hardware --> 8 118 | 119 | 18 _Init_Serial --> 9 120 | 121 | 19 _NewLine --> 11 122 | 123 | 20 _PS2_Task --> 10 124 | 125 | 21 _PutC --> 5 126 | 127 | 22 _Puthex --> 4 128 | 129 | 23 _Puthex2 --> 3 130 | 131 | 132 | 133 | ------- 134 | Symbols 135 | ------- 136 | 137 | _GetC 00008265 defined in Debug\hardware.o section .text 138 | _Hotkeys 00000003 defined in Debug\hardware.o section .ubsct 139 | _Init_Hardware 000080d3 defined in Debug\hardware.o section .text 140 | used in Debug\main.o 141 | _Init_Serial 00008258 defined in Debug\hardware.o section .text 142 | _Micro_Timer1 00000002 defined in Debug\hardware.o section .ubsct 143 | _Milli_Divider 00000000 defined in Debug\hardware.o section .ubsct 144 | _Milli_Timer1 00000001 defined in Debug\hardware.o section .ubsct 145 | _NewLine 000082a6 defined in Debug\hardware.o section .text 146 | _PS2 00000005 defined in Debug\hardware.o section .ubsct 147 | _PS2_Task 000081a0 defined in Debug\hardware.o section .text 148 | used in Debug\main.o 149 | _PutC 00008270 defined in Debug\hardware.o section .text 150 | _Puthex 0000827f defined in Debug\hardware.o section .text 151 | _Puthex2 0000828c defined in Debug\hardware.o section .text 152 | _Puthex4 0000829a defined in Debug\hardware.o section .text 153 | __endmem 000001ff defined in command file 154 | *** not used *** 155 | __endzp 00000010 defined in command file section .ubsct 156 | used in C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\Lib\crtsi0.sm8 157 | __idesc__ 00008080 defined in linker section .init 158 | used in C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\Lib\crtsi0.sm8 159 | __memory 00000100 defined in command file section .bss 160 | used in C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\Lib\crtsi0.sm8 161 | __stack 000003ff defined in command file 162 | used in C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\Lib\crtsi0.sm8 163 | __startmem 00000100 defined in command file section .bss 164 | *** not used *** 165 | __stext 00008083 defined in C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\Lib\crtsi0.sm8 section .text 166 | used in Debug\stm8_interrupt_vector.o 167 | __vectab 00008000 defined in Debug\stm8_interrupt_vector.o section .const 168 | _exit 000080d1 defined in C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\Lib\crtsi0.sm8 section .text 169 | _main 000082af defined in Debug\main.o section .text 170 | used in C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\Lib\crtsi0.sm8 171 | c_x 0000000a defined in (C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\Lib\libm0.sm8)xreg.o section .ubsct 172 | used in C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\Lib\crtsi0.sm8 173 | c_y 0000000d defined in (C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\Lib\libm0.sm8)yreg.o section .ubsct 174 | used in C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\Lib\crtsi0.sm8 175 | f_Default_IRQ_Handler 000082b7 defined in Debug\stm8_interrupt_vector.o section .text 176 | f_PORTB_IRQ 0000814a defined in Debug\hardware.o section .text 177 | used in Debug\stm8_interrupt_vector.o 178 | f_TIM4_IRQ 0000812d defined in Debug\hardware.o section .text 179 | used in Debug\stm8_interrupt_vector.o 180 | -------------------------------------------------------------------------------- /KVM-Hotkey/Debug/hotkey.s19: -------------------------------------------------------------------------------- 1 | S013000044656275675C686F746B65792E736D38CF 2 | S1238083AE03FF9490CE8080AE8082F62725A5602717BF0AEE03BF0DBE0AEE0190F6F75CEC 3 | S12380A3905C90B30D26F5BE0A909390EE031C000520D8AE00002002F75CA3001026F9AE3A 4 | S12380C301002002F75CA3010026F9CD82AF20FE725F50C6350850A035105009350E5002FD 5 | S12380E3555002500335F8500C55500C500D351E50115550115012358553403501534335CE 6 | S123810303534735C8534835037F71725F7F75725F7F74725F7F73725F7F72725F7F70CD60 7 | S123812382583F073F033F049A81721153443D0227023A023D0027043A00200A3D01270287 8 | S12381433A0135640000803D0727043D022614350F0002C65006A5202704A6012002A641DA 9 | S1238163B70780B6073C075FA5402727B607A14B2608350100093F0720E8BE0554BF05C623 10 | S12381835006A52027DCBE0501AA0001AA0201BF0520CFB607A10C26C93F0720C552043DD4 11 | S12381A3092603CC82569BBE051F033F099AB60597B606A4015F1E035401A4FF5F021F03D2 12 | S12381C3011E03A300F0260772100004CC82561E03A300E02606721200042077B6034D2770 13 | S12381E30B4A271D4A27384A274E20631E03A30014265C3D04265835010003351900012033 14 | S12382031B1E03A300142647B604A10126413D01273D3F0435020003351400015B04811ECD 15 | S123822303A3001426293D0426253D012721350300033519000120E41E03A300142610B6CA 16 | S123824304A101260A3D012706A621AD20AD543F033F0420C7350A523335085232350C52BD 17 | S12382633581C65230A52027F9C652318188C65230A58027F97B01C752318481A10A240497 18 | S1238283AB302002AB37ADE581884EA40FADED7B01A40FADE78481899EADEE7B02A4FFAD6B 19 | S11882A3E88581A60DADC6A60AADC281CD80D3CD81A020FB8065 20 | S123800082008083820082B7820082B7820082B7820082B7820082B78200814A820082B728 21 | S1238020820082B7820082B7820082B7820082B7820082B7820082B7820082B7820082B764 22 | S1238040820082B7820082B7820082B7820082B7820082B7820082B7820082B7820082B744 23 | S1238060820082B78200812D820082B7820082B7820082B7820082B7820082B7820082B7AF 24 | S1068080808300F6 25 | S903FFFFFE 26 | -------------------------------------------------------------------------------- /KVM-Hotkey/Debug/hotkey.sm8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FPGA-Computer/KVM-Switch/3f3526bb809239746657e17d94fe30fd696eddca/KVM-Hotkey/Debug/hotkey.sm8 -------------------------------------------------------------------------------- /KVM-Hotkey/Debug/main.ls: -------------------------------------------------------------------------------- 1 | 1 ; C Compiler for STM8 (COSMIC Software) 2 | 2 ; Parser V4.11.5 - 29 Dec 2015 3 | 3 ; Generator (Limited) V4.4.4 - 27 Jan 2016 4 | 45 ; 3 void main(void) 5 | 45 ; 4 { 6 | 47 switch .text 7 | 48 0000 _main: 8 | 52 ; 5 Init_Hardware(); 9 | 54 0000 cd0000 call _Init_Hardware 10 | 56 0003 L12: 11 | 57 ; 9 PS2_Task(); 12 | 59 0003 cd0000 call _PS2_Task 13 | 62 0006 20fb jra L12 14 | 75 xdef _main 15 | 76 xref _PS2_Task 16 | 77 xref _Init_Hardware 17 | 96 end 18 | -------------------------------------------------------------------------------- /KVM-Hotkey/Debug/main.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FPGA-Computer/KVM-Switch/3f3526bb809239746657e17d94fe30fd696eddca/KVM-Hotkey/Debug/main.o -------------------------------------------------------------------------------- /KVM-Hotkey/Debug/stm8_interrupt_vector.ls: -------------------------------------------------------------------------------- 1 | 1 ; C Compiler for STM8 (COSMIC Software) 2 | 2 ; Parser V4.11.5 - 29 Dec 2015 3 | 3 ; Generator (Limited) V4.4.4 - 27 Jan 2016 4 | 45 ; 34 @far @interrupt void Default_IRQ_Handler(void) 5 | 45 ; 35 { 6 | 46 switch .text 7 | 47 0000 f_Default_IRQ_Handler: 8 | 51 ; 36 } 9 | 54 0000 80 iret 10 | 56 .const: section .text 11 | 57 0000 __vectab: 12 | 58 0000 82 dc.b 130 13 | 60 0001 00 dc.b page(__stext) 14 | 61 0002 0000 dc.w __stext 15 | 62 0004 82 dc.b 130 16 | 64 0005 00 dc.b page(f_Default_IRQ_Handler) 17 | 65 0006 0000 dc.w f_Default_IRQ_Handler 18 | 66 0008 82 dc.b 130 19 | 68 0009 00 dc.b page(f_Default_IRQ_Handler) 20 | 69 000a 0000 dc.w f_Default_IRQ_Handler 21 | 70 000c 82 dc.b 130 22 | 72 000d 00 dc.b page(f_Default_IRQ_Handler) 23 | 73 000e 0000 dc.w f_Default_IRQ_Handler 24 | 74 0010 82 dc.b 130 25 | 76 0011 00 dc.b page(f_Default_IRQ_Handler) 26 | 77 0012 0000 dc.w f_Default_IRQ_Handler 27 | 78 0014 82 dc.b 130 28 | 80 0015 00 dc.b page(f_Default_IRQ_Handler) 29 | 81 0016 0000 dc.w f_Default_IRQ_Handler 30 | 82 0018 82 dc.b 130 31 | 84 0019 00 dc.b page(f_PORTB_IRQ) 32 | 85 001a 0000 dc.w f_PORTB_IRQ 33 | 86 001c 82 dc.b 130 34 | 88 001d 00 dc.b page(f_Default_IRQ_Handler) 35 | 89 001e 0000 dc.w f_Default_IRQ_Handler 36 | 90 0020 82 dc.b 130 37 | 92 0021 00 dc.b page(f_Default_IRQ_Handler) 38 | 93 0022 0000 dc.w f_Default_IRQ_Handler 39 | 94 0024 82 dc.b 130 40 | 96 0025 00 dc.b page(f_Default_IRQ_Handler) 41 | 97 0026 0000 dc.w f_Default_IRQ_Handler 42 | 98 0028 82 dc.b 130 43 | 100 0029 00 dc.b page(f_Default_IRQ_Handler) 44 | 101 002a 0000 dc.w f_Default_IRQ_Handler 45 | 102 002c 82 dc.b 130 46 | 104 002d 00 dc.b page(f_Default_IRQ_Handler) 47 | 105 002e 0000 dc.w f_Default_IRQ_Handler 48 | 106 0030 82 dc.b 130 49 | 108 0031 00 dc.b page(f_Default_IRQ_Handler) 50 | 109 0032 0000 dc.w f_Default_IRQ_Handler 51 | 110 0034 82 dc.b 130 52 | 112 0035 00 dc.b page(f_Default_IRQ_Handler) 53 | 113 0036 0000 dc.w f_Default_IRQ_Handler 54 | 114 0038 82 dc.b 130 55 | 116 0039 00 dc.b page(f_Default_IRQ_Handler) 56 | 117 003a 0000 dc.w f_Default_IRQ_Handler 57 | 118 003c 82 dc.b 130 58 | 120 003d 00 dc.b page(f_Default_IRQ_Handler) 59 | 121 003e 0000 dc.w f_Default_IRQ_Handler 60 | 122 0040 82 dc.b 130 61 | 124 0041 00 dc.b page(f_Default_IRQ_Handler) 62 | 125 0042 0000 dc.w f_Default_IRQ_Handler 63 | 126 0044 82 dc.b 130 64 | 128 0045 00 dc.b page(f_Default_IRQ_Handler) 65 | 129 0046 0000 dc.w f_Default_IRQ_Handler 66 | 130 0048 82 dc.b 130 67 | 132 0049 00 dc.b page(f_Default_IRQ_Handler) 68 | 133 004a 0000 dc.w f_Default_IRQ_Handler 69 | 134 004c 82 dc.b 130 70 | 136 004d 00 dc.b page(f_Default_IRQ_Handler) 71 | 137 004e 0000 dc.w f_Default_IRQ_Handler 72 | 138 0050 82 dc.b 130 73 | 140 0051 00 dc.b page(f_Default_IRQ_Handler) 74 | 141 0052 0000 dc.w f_Default_IRQ_Handler 75 | 142 0054 82 dc.b 130 76 | 144 0055 00 dc.b page(f_Default_IRQ_Handler) 77 | 145 0056 0000 dc.w f_Default_IRQ_Handler 78 | 146 0058 82 dc.b 130 79 | 148 0059 00 dc.b page(f_Default_IRQ_Handler) 80 | 149 005a 0000 dc.w f_Default_IRQ_Handler 81 | 150 005c 82 dc.b 130 82 | 152 005d 00 dc.b page(f_Default_IRQ_Handler) 83 | 153 005e 0000 dc.w f_Default_IRQ_Handler 84 | 154 0060 82 dc.b 130 85 | 156 0061 00 dc.b page(f_Default_IRQ_Handler) 86 | 157 0062 0000 dc.w f_Default_IRQ_Handler 87 | 158 0064 82 dc.b 130 88 | 160 0065 00 dc.b page(f_TIM4_IRQ) 89 | 161 0066 0000 dc.w f_TIM4_IRQ 90 | 162 0068 82 dc.b 130 91 | 164 0069 00 dc.b page(f_Default_IRQ_Handler) 92 | 165 006a 0000 dc.w f_Default_IRQ_Handler 93 | 166 006c 82 dc.b 130 94 | 168 006d 00 dc.b page(f_Default_IRQ_Handler) 95 | 169 006e 0000 dc.w f_Default_IRQ_Handler 96 | 170 0070 82 dc.b 130 97 | 172 0071 00 dc.b page(f_Default_IRQ_Handler) 98 | 173 0072 0000 dc.w f_Default_IRQ_Handler 99 | 174 0074 82 dc.b 130 100 | 176 0075 00 dc.b page(f_Default_IRQ_Handler) 101 | 177 0076 0000 dc.w f_Default_IRQ_Handler 102 | 178 0078 82 dc.b 130 103 | 180 0079 00 dc.b page(f_Default_IRQ_Handler) 104 | 181 007a 0000 dc.w f_Default_IRQ_Handler 105 | 182 007c 82 dc.b 130 106 | 184 007d 00 dc.b page(f_Default_IRQ_Handler) 107 | 185 007e 0000 dc.w f_Default_IRQ_Handler 108 | 235 xdef __vectab 109 | 236 xdef f_Default_IRQ_Handler 110 | 237 xref __stext 111 | 238 xref f_TIM4_IRQ 112 | 239 xref f_PORTB_IRQ 113 | 258 end 114 | -------------------------------------------------------------------------------- /KVM-Hotkey/Debug/stm8_interrupt_vector.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FPGA-Computer/KVM-Switch/3f3526bb809239746657e17d94fe30fd696eddca/KVM-Hotkey/Debug/stm8_interrupt_vector.o -------------------------------------------------------------------------------- /KVM-Hotkey/Hotkey.stw: -------------------------------------------------------------------------------- 1 | ; STMicroelectronics Workspace file 2 | 3 | [Version] 4 | Keyword=ST7Workspace-V0.7 5 | 6 | [Project0] 7 | Filename=hotkey.stp 8 | Dependencies= 9 | [Options] 10 | ActiveProject=hotkey 11 | ActiveConfig=Debug 12 | AddSortedElements=1 13 | -------------------------------------------------------------------------------- /KVM-Hotkey/Release/hotkey.lkf: -------------------------------------------------------------------------------- 1 | # LINK COMMAND FILE AUTOMATICALLY GENERATED BY STVD: 2 | # * TOTALLY IF AUTO MODE IS ENABLED 3 | # * ONLY INSIDE MARKERS IN SEMI-AUTO MODE 4 | # 5 | # CHOOSE THE CUSTOM MODE IN STVD IN ORDER TO HAVE FULL CONTROL OVER THIS FILE. 6 | # 7 | # Sections delimited by and markers are reserved for 8 | # STVD: DO NOT MODIFY INSIDE. 9 | # 10 | # Manual modifications are allowed OUTSIDE these sections, WHEN STVD AUTO MODE 11 | # IS DISABLED. 12 | # 13 | # CAUTION: 14 | # * Changing from Custom to Semi-Auto mode removes modifications in 15 | # STVD-reserved sections 16 | # * Changing to Auto mode removes all modifications. 17 | # 18 | # In Semi-Auto mode, you are allowed to remove and markers 19 | # in order to gain control over the concerned sections. As a consequence any 20 | # modification from the STVD graphical interface concerning this section will be 21 | # ignored. 22 | # 23 | # Please refer to Cosmic User Manuals before any modification. 24 | # Note that errors in editing this file may have unpredictable results when 25 | # running STVD. 26 | 27 | # Segment configuration - section reserved for STVD 28 | # 29 | # Segment Code,Constants: 30 | +seg .const -b 0x8080 -m 0x1f80 -n .const -it 31 | +seg .text -a .const -n .text 32 | # Segment Eeprom: 33 | +seg .eeprom -b 0x4000 -m 0x80 -n .eeprom 34 | # Segment Zero Page: 35 | +seg .bsct -b 0x0 -m 0x100 -n .bsct 36 | +seg .ubsct -a .bsct -n .ubsct 37 | +seg .bit -a .ubsct -n .bit -id 38 | +seg .share -a .bit -n .share -is 39 | # Segment Ram: 40 | +seg .data -b 0x100 -m 0x100 -n .data 41 | +seg .bss -a .data -n .bss 42 | # 43 | 44 | 45 | # Startup file - section reserved for STVD 46 | # 47 | crtsi0.sm8 48 | # 49 | 50 | 51 | # Object files list - section reserved for STVD 52 | # 53 | Release\hardware.o 54 | Release\main.o 55 | # 56 | 57 | 58 | # Library list - section reserved for STVD 59 | # 60 | libis0.sm8 61 | libm0.sm8 62 | # 63 | 64 | 65 | # Interrupt vectors file - section reserved for STVD 66 | # 67 | +seg .const -b 0x8000 -k 68 | Release\stm8_interrupt_vector.o 69 | # 70 | 71 | # Defines - section reserved for STVD 72 | # 73 | +def __endzp=@.ubsct # end of uninitialized zpage 74 | +def __memory=@.bss # end of bss segment 75 | +def __startmem=@.bss 76 | +def __endmem=0x1ff 77 | +def __stack=0x3ff 78 | # 79 | -------------------------------------------------------------------------------- /KVM-Hotkey/TAGS_Filelist.txt: -------------------------------------------------------------------------------- 1 | hardware.c 2 | main.c 3 | stm8_interrupt_vector.c 4 | fifo.h 5 | hardware.h 6 | irq.h 7 | stm8s.h 8 | ..\..\..\..\program files (x86)\cosmic\fse_compilers\cxstm8\hstm8\mods0.h 9 | ..\..\..\..\program files (x86)\cosmic\fse_compilers\cxstm8\hstm8\stdio.h 10 | stm8s_conf.h 11 | -------------------------------------------------------------------------------- /KVM-Hotkey/hardware.c: -------------------------------------------------------------------------------- 1 | #include "hardware.h" 2 | 3 | KBD_States PS2; 4 | Hotkey_State Hotkeys; 5 | 6 | uint8_t Micro_Timer1,Milli_Timer1,Milli_Divider; 7 | 8 | void Init_Hardware(void) 9 | { 10 | CLK->CKDIVR = 0; // Clk divider, CPU divider = 1 11 | EXTI->CR1 = 0x02 << 2; // PB2 Interrupt: Falling edge 12 | PS2_PORT->CR2 = PS2_CLK; // Enable PS2_CLK interrupt 13 | 14 | // All GPIO defaults to output, push-pull 15 | GPIOA->CR1 = GPIOA->DDR = PA1|PA2|PA3; 16 | GPIOC->CR1 = GPIOC->DDR = PC3|PC4|PC5|PC6|PC7; 17 | GPIOD->CR1 = GPIOD->DDR = PD1|PD2|PD3|PD4; 18 | 19 | // tim4 8-bit timer: Auto-reload, update = over/under flow, Counter enable 20 | TIM4->CR1 = TIM4_CR1_ARPE|TIM4_CR1_URS|TIM4_CR1_CEN; 21 | 22 | TIM4->IER = TIM4_IER_UIE; // Update IRQ enable 23 | TIM4->PSCR = TIM4_PSCR; // TIM4: 16MHz/2^TIM4_PSCR 24 | TIM4->ARR = TIM4_ARR; // Auto-reload 25 | 26 | // IRQ4 (PORTB PS2 CLK) = level 3 (high) 27 | ITC->ISPR2 = 0x03; 28 | // Rest of IRQ level 0 (low) 29 | ITC->ISPR1 = ITC->ISPR3 = ITC->ISPR4 = ITC->ISPR5 = ITC->ISPR6 = 0x00; 30 | 31 | Init_Serial(); 32 | 33 | PS2.State = PS2_Idle; 34 | 35 | Hotkeys.State = HK_Idle; 36 | Hotkeys.KeyAttr = 0; 37 | // Turn on interrupts 38 | rim(); 39 | } 40 | 41 | // Low priority timer interrupt: 10kHz 42 | @far @interrupt void TIM4_IRQ(void) 43 | { 44 | TIM4->SR1 &= ~TIM4_SR1_UIF; // Clear update IRQ 45 | 46 | if(Micro_Timer1) 47 | Micro_Timer1--; 48 | 49 | if(Milli_Divider) 50 | Milli_Divider--; 51 | else 52 | { // 100Hz interrupt 53 | if(Milli_Timer1) 54 | Milli_Timer1--; 55 | 56 | Milli_Divider = MILLI_DIVIDER_RELOAD; 57 | } 58 | } 59 | 60 | @far @interrupt void PORTB_IRQ(void) 61 | { 62 | if((PS2.State == PS2_Idle)||(!Micro_Timer1)) // Start bit or resynchronized 63 | { 64 | // rewind timer 65 | Micro_Timer1 = us_TO_TICKS(PS2_BIT_TIMEOUT); 66 | // first bit determines source: keyboard or PC 67 | PS2.State = (PS2_PORT->IDR & PS2_DATA)?PS2_CMD_1:PS2_KBD_1; 68 | } 69 | else 70 | { 71 | if(PS2.State++ & PS2_KBD) // Scan/respond code 72 | { 73 | if(PS2.State == PS2_KBD_LAST) 74 | { 75 | PS2.Avail = 1; 76 | PS2.State = PS2_Idle; 77 | } 78 | else 79 | { 80 | PS2.ScanCode >>= 1; 81 | 82 | if(PS2_PORT->IDR & PS2_DATA) 83 | PS2.ScanCode |= 0x200; 84 | } 85 | } 86 | else // Ignore Cmd to keyboard 87 | if(PS2.State == PS2_CMD_LAST) 88 | PS2.State = PS2_Idle; 89 | } 90 | } 91 | 92 | // high level polling task 93 | void PS2_Task(void) 94 | { 95 | uint16_t ScanCode, Parity; 96 | 97 | if(PS2.Avail) 98 | { 99 | // Critical section 100 | sim(); 101 | ScanCode = PS2.ScanCode; 102 | PS2.Avail = 0; 103 | rim(); 104 | 105 | Parity = PS2.ScanCode & 0x01; 106 | ScanCode = (ScanCode >> 1) & 0xff; 107 | 108 | if (ScanCode == PS2_KBD_CODE_RELEASE) 109 | Hotkeys.KeyAttr |= Key_Release; 110 | else if (ScanCode == PS2_KBD_CODE_EXTENDED) 111 | Hotkeys.KeyAttr |= Key_Extend; 112 | else 113 | { 114 | switch(Hotkeys.State) 115 | { 116 | case HK_Idle: 117 | if((ScanCode == HOTKEY_SCANCODE) && !Hotkeys.KeyAttr) 118 | { 119 | Hotkeys.State = HK_KeyMake_1; 120 | Milli_Timer1 = HOTKEY_RELEASE_DELAY; 121 | return; 122 | } 123 | break; 124 | 125 | case HK_KeyMake_1: 126 | if((ScanCode == HOTKEY_SCANCODE) && (Hotkeys.KeyAttr==Key_Release) && Milli_Timer1) 127 | { 128 | Hotkeys.KeyAttr = 0; 129 | Hotkeys.State = HK_KeyBreak_1; 130 | Milli_Timer1 = HOTKEY_WAIT_DELAY; 131 | return; 132 | } 133 | break; 134 | 135 | case HK_KeyBreak_1: 136 | if((ScanCode == HOTKEY_SCANCODE) && !Hotkeys.KeyAttr && Milli_Timer1) 137 | { 138 | Hotkeys.State = HK_KeyMake_2; 139 | Milli_Timer1 = HOTKEY_RELEASE_DELAY; 140 | return; 141 | } 142 | break; 143 | 144 | case HK_KeyMake_2: 145 | if((ScanCode == HOTKEY_SCANCODE) && (Hotkeys.KeyAttr==Key_Release) && Milli_Timer1) 146 | { 147 | PutC('!'); 148 | NewLine(); 149 | } 150 | break; 151 | } 152 | 153 | // default to idle 154 | Hotkeys.State = HK_Idle; 155 | Hotkeys.KeyAttr = 0; 156 | } 157 | } 158 | } 159 | 160 | void Init_Serial(void) 161 | { 162 | UART1->BRR2 = UART_BRR2; 163 | UART1->BRR1 = UART_BRR1; 164 | // tx, rx enable 165 | UART1->CR2 = UART1_CR2_TEN|UART1_CR2_REN; 166 | } 167 | 168 | uint8_t GetC(void) 169 | { 170 | while(!Poll_Serial()) 171 | ; 172 | return(UART1->DR); 173 | } 174 | 175 | void PutC(uint8_t ch) 176 | { 177 | while(!(UART1->SR & UART1_SR_TXE)) 178 | ; 179 | UART1->DR = ch; 180 | } 181 | 182 | void Puthex(uint8_t n) 183 | { PutC((n<10)?n+'0':n-10+'A'); 184 | } 185 | 186 | void Puthex2(uint8_t n) 187 | { Puthex(n>>4); 188 | Puthex(n&0x0f); 189 | } 190 | 191 | void Puthex4(uint16_t n) 192 | { Puthex2(n>>8); 193 | Puthex2(n&0xff); 194 | } 195 | 196 | void NewLine(void) 197 | { PutC('\x0d'); 198 | PutC('\x0a'); 199 | } 200 | -------------------------------------------------------------------------------- /KVM-Hotkey/hardware.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hardware.h 3 | * 4 | * Created: 22/12/2016 6:03:25 AM 5 | * Author: K. C. Lee 6 | * Copyright (c) 2016 by K. C. Lee 7 | 8 | This program is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this program. 20 | 21 | If not, see http://www.gnu.org/licenses/gpl-3.0.en.html 22 | */ 23 | 24 | #ifndef HARDWARE_H_ 25 | #define HARDWARE_H_ 26 | 27 | #ifndef __CSMC__ 28 | #define __CSMC__ 29 | #endif 30 | #define STM8S003 31 | 32 | #include "stm8s.h" 33 | #include 34 | 35 | // STM8S003F3P6 36 | enum _PA { PA1=0x02, PA2=0x04, PA3=0x08 }; 37 | enum _PB { PB4=0x10, PB5=0x20 }; 38 | enum _PC { PC3=0x08, PC4=0x10, PC5=0x20, PC6=0x40, PC7=0x80 }; 39 | enum _PD { PD1=0x02, PD2=0x04, PD3=0x08, PD4=0x10, PD5=0x20, PD6=0x40 }; 40 | 41 | #include "irq.h" 42 | 43 | #define PS2_CLK PB4 44 | #define PS2_DATA PB5 45 | #define PS2_PORT GPIOB 46 | 47 | #define PS2_KBD 0x40 48 | #define PS2_CMD 0x00 49 | 50 | #define PS2_KBD_BITS 10 51 | #define PS2_CMD_BITS 11 52 | 53 | #define PS2_BIT_TIMEOUT 1500 // us 54 | 55 | enum Key_States 56 | { 57 | PS2_Idle = 0, 58 | PS2_KBD_1 = PS2_KBD+1, 59 | PS2_KBD_LAST = PS2_KBD_1+PS2_KBD_BITS, 60 | PS2_CMD_1 = PS2_CMD+1, 61 | PS2_CMD_LAST = PS2_CMD_1+PS2_CMD_BITS 62 | }; 63 | 64 | enum Hotkey_States 65 | { 66 | HK_Idle, 67 | HK_KeyMake_1, 68 | HK_KeyBreak_1, 69 | HK_KeyMake_2 70 | }; 71 | 72 | enum KeyAttrib 73 | { 74 | Key_Regular = 0x00, 75 | Key_Release = 0x01, 76 | Key_Extend = 0x02 77 | }; 78 | 79 | typedef struct 80 | { 81 | volatile uint16_t ScanCode; 82 | uint8_t State; 83 | uint8_t Attrib; 84 | volatile uint8_t Avail; 85 | } KBD_States; 86 | 87 | #define PS2_KBD_CODE_EXTENDED 0xe0 88 | #define PS2_KBD_CODE_RELEASE 0xf0 89 | 90 | #define HOTKEY_SCANCODE 0x14 91 | 92 | #define HOTKEY_RELEASE_DELAY ms_TO_TICKS(250) 93 | #define HOTKEY_WAIT_DELAY ms_TO_TICKS(200) 94 | 95 | typedef struct 96 | { 97 | uint8_t State; 98 | uint8_t KeyAttr; 99 | } Hotkey_State; 100 | 101 | #define TIM4_PSCR 3 102 | #define TIM4_ARR 200 103 | #define MILLI_DIVIDER_RELOAD 100 104 | 105 | // 16MHz/2^TIM4_PSCR/TIM4_ARR = 10kHz (100us per tick) 106 | // 10kHz/MILLI_DIVIDER_RELOAD = 100Hz (10ms per tick) 107 | 108 | // Minimum delay 109 | #define us_TO_TICKS(X) ((X)/100) 110 | #define ms_TO_TICKS(X) ((X)/10) 111 | 112 | void Init_Hardware(void); 113 | void PS2_Task(void); 114 | 115 | // uart 115200 116 | #define UART_BAUD 115200UL 117 | #define UART_BRR_DIV ((int)(HSI_VALUE/UART_BAUD+0.5)) 118 | #define UART_BRR1 ((UART_BRR_DIV & 0x0ff0)>>4) 119 | #define UART_BRR2 (((UART_BRR_DIV & 0xf000)>>8)|(UART_BRR_DIV & 0x0f)) 120 | 121 | void Init_Serial(void); 122 | uint8_t GetC(void); 123 | void PutC(uint8_t ch); 124 | void Puthex2(uint8_t n); 125 | void Puthex4(uint16_t n); 126 | void NewLine(void); 127 | 128 | #define Poll_Serial() (UART1->SR & UART1_SR_RXNE) 129 | #define Get_Char() (UART1->DR) 130 | 131 | #endif 132 | -------------------------------------------------------------------------------- /KVM-Hotkey/hotkey.dep: -------------------------------------------------------------------------------- 1 | ; STMicroelectronics dependencies file 2 | 3 | [Version] 4 | Keyword=ST7Project 5 | Number=1.3 6 | 7 | [Root.Source Files.hardware.c.Config.0] 8 | ExternDep= hardware.c "C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\Hstm8\mods0.h" 9 | 10 | [Root.Source Files.main.c.Config.0] 11 | ExternDep= main.c "C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\Hstm8\mods0.h" hardware.h stm8s.h stm8s_conf.h "C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\Hstm8\stdio.h" irq.h 12 | 13 | [Root.Source Files.stm8_interrupt_vector.c.Config.0] 14 | ExternDep= stm8_interrupt_vector.c "C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\Hstm8\mods0.h" irq.h stm8_interrupt_vector.h -------------------------------------------------------------------------------- /KVM-Hotkey/hotkey.pdb: -------------------------------------------------------------------------------- 1 | [DebugState_v1-Debug.DebugContext] 2 | DumpRWOnFly1=0 3 | DumpRWOnFly2=0 4 | DumpRWOnFly3=0 5 | DumpRWOnFly4=0 6 | WatchVariables1=PS2!0;PS2_Buf!0;ScanCode!0;Hotkeys!0; 7 | FormatWatch1=0 8 | FormatViewType1=1 9 | FormatViewAddress1=1 10 | WatchRWOnFlyTab1=0 11 | WatchVariables2= 12 | FormatWatch2=0 13 | FormatViewType2=1 14 | FormatViewAddress2=1 15 | WatchRWOnFlyTab2=0 16 | WatchVariables3= 17 | FormatWatch3=0 18 | FormatViewType3=1 19 | FormatViewAddress3=1 20 | WatchRWOnFlyTab3=0 21 | WatchVariables4= 22 | FormatWatch4=0 23 | FormatViewType4=1 24 | FormatViewAddress4=1 25 | WatchRWOnFlyTab4=0 26 | FormatLocals=0 27 | FormatParameters=0 28 | [DebugState_v1-Debug.AddOn.St7Registers] 29 | ActiveTab=2 30 | [DebugState_v1-Debug.AddOn.St7PeripheralRegister] 31 | DisplayFormat=1 32 | ShowPeriphAddress=0 33 | ShowRegisterAddress=1 34 | [DebugState_v1-Debug.AddOn.St7McuIcdConf] 35 | McuName=STM8S003F3 36 | [DebugState_v1-Debug.AddOn.IcdBreak] 37 | ICDBreak0=CR:0x00000000,BK1:0x00000000,BK2:0x00000000 38 | [DebugState_v1-Debug.AddOn.SteppingMode] 39 | Mode=hardware 40 | -------------------------------------------------------------------------------- /KVM-Hotkey/hotkey.stp: -------------------------------------------------------------------------------- 1 | ; STMicroelectronics Project file 2 | 3 | [Version] 4 | Keyword=ST7Project 5 | Number=1.3 6 | 7 | [Project] 8 | Name=hotkey 9 | Toolset=STM8 Cosmic 10 | 11 | [Config] 12 | 0=Config.0 13 | 1=Config.1 14 | 15 | [Config.0] 16 | ConfigName=Debug 17 | Target=hotkey.elf 18 | OutputFolder=Debug 19 | Debug=$(TargetFName) 20 | 21 | [Config.1] 22 | ConfigName=Release 23 | Target=hotkey.elf 24 | OutputFolder=Release 25 | Debug=$(TargetFName) 26 | 27 | [Root] 28 | ElemType=Project 29 | PathName=hotkey 30 | Child=Root.Source Files 31 | Config.0=Root.Config.0 32 | Config.1=Root.Config.1 33 | 34 | [Root.Config.0] 35 | Settings.0.0=Root.Config.0.Settings.0 36 | Settings.0.1=Root.Config.0.Settings.1 37 | Settings.0.2=Root.Config.0.Settings.2 38 | Settings.0.3=Root.Config.0.Settings.3 39 | Settings.0.4=Root.Config.0.Settings.4 40 | Settings.0.5=Root.Config.0.Settings.5 41 | Settings.0.6=Root.Config.0.Settings.6 42 | Settings.0.7=Root.Config.0.Settings.7 43 | Settings.0.8=Root.Config.0.Settings.8 44 | 45 | [Root.Config.1] 46 | Settings.1.0=Root.Config.1.Settings.0 47 | Settings.1.1=Root.Config.1.Settings.1 48 | Settings.1.2=Root.Config.1.Settings.2 49 | Settings.1.3=Root.Config.1.Settings.3 50 | Settings.1.4=Root.Config.1.Settings.4 51 | Settings.1.5=Root.Config.1.Settings.5 52 | Settings.1.6=Root.Config.1.Settings.6 53 | Settings.1.7=Root.Config.1.Settings.7 54 | Settings.1.8=Root.Config.1.Settings.8 55 | 56 | [Root.Config.0.Settings.0] 57 | String.6.0=2017,3,27,21,19,37 58 | String.100.0=ST Assembler Linker 59 | String.100.1=ST7 Cosmic 60 | String.100.2=STM8 Cosmic 61 | String.100.3=ST7 Metrowerks V1.1 62 | String.100.4=Raisonance 63 | String.101.0=STM8 Cosmic 64 | String.102.0=C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8 65 | String.103.0= 66 | String.104.0=Hstm8 67 | String.105.0=Lib 68 | String.106.0=Debug 69 | String.107.0=hotkey.elf 70 | Int.108=0 71 | 72 | [Root.Config.0.Settings.1] 73 | String.6.0=2017,3,27,21,19,37 74 | String.100.0=$(TargetFName) 75 | String.101.0= 76 | String.103.0=.\; 77 | 78 | [Root.Config.0.Settings.2] 79 | String.2.0= 80 | String.6.0=2017,3,27,21,19,37 81 | String.100.0=STM8S003F3P 82 | 83 | [Root.Config.0.Settings.3] 84 | String.2.0=Compiling $(InputFile)... 85 | String.3.0=cxstm8 -customDbg -customDebCompat -customOpt-no -customLst -l +mods0 -customC-pp $(ToolsetIncOpts) -cl$(IntermPath) -co$(IntermPath) $(InputFile) 86 | String.4.0=$(IntermPath)$(InputName).$(ObjectExt) 87 | String.5.0=$(IntermPath)$(InputName).ls 88 | String.6.0=2017,3,27,21,19,37 89 | 90 | [Root.Config.0.Settings.4] 91 | String.2.0=Assembling $(InputFile)... 92 | String.3.0=castm8 -xx -l $(ToolsetIncOpts) -o$(IntermPath)$(InputName).$(ObjectExt) $(InputFile) 93 | String.4.0=$(IntermPath)$(InputName).$(ObjectExt) 94 | String.5.0=$(IntermPath)$(InputName).ls 95 | String.6.0=2017,3,27,21,19,37 96 | 97 | [Root.Config.0.Settings.5] 98 | String.2.0=Running Pre-Link step 99 | String.6.0=2017,3,27,21,19,37 100 | String.8.0= 101 | 102 | [Root.Config.0.Settings.6] 103 | String.2.0=Running Linker 104 | String.3.0=clnk -customMapFile -customMapFile-m $(OutputPath)$(TargetSName).map -fakeRunConv -fakeInteger -fakeSemiAutoGen $(ToolsetLibOpts) -o $(OutputPath)$(TargetSName).sm8 -fakeOutFile$(ProjectSFile).elf -customCfgFile $(OutputPath)$(TargetSName).lkf -fakeVectFilestm8_interrupt_vector.c -fakeStartupcrtsi0.sm8 105 | String.3.1=cvdwarf $(OutputPath)$(TargetSName).sm8 -fakeVectAddr0x8000 106 | String.4.0=$(OutputPath)$(TargetFName) 107 | String.5.0=$(OutputPath)$(TargetSName).map $(OutputPath)$(TargetSName).st7 $(OutputPath)$(TargetSName).s19 108 | String.6.0=2017,3,27,21,19,37 109 | String.101.0=crtsi.st7 110 | String.102.0=+seg .const -b 0x8080 -m 0x1f80 -n .const -it 111 | String.102.1=+seg .text -a .const -n .text 112 | String.102.2=+seg .eeprom -b 0x4000 -m 0x80 -n .eeprom 113 | String.102.3=+seg .bsct -b 0x0 -m 0x100 -n .bsct 114 | String.102.4=+seg .ubsct -a .bsct -n .ubsct 115 | String.102.5=+seg .bit -a .ubsct -n .bit -id 116 | String.102.6=+seg .share -a .bit -n .share -is 117 | String.102.7=+seg .data -b 0x100 -m 0x100 -n .data 118 | String.102.8=+seg .bss -a .data -n .bss 119 | String.103.0=Code,Constants[0x8080-0x9fff]=.const,.text 120 | String.103.1=Eeprom[0x4000-0x407f]=.eeprom 121 | String.103.2=Zero Page[0x0-0xff]=.bsct,.ubsct,.bit,.share 122 | String.103.3=Ram[0x100-0x1ff]=.data,.bss 123 | String.104.0=0x3ff 124 | Int.0=0 125 | Int.1=0 126 | 127 | [Root.Config.0.Settings.7] 128 | String.2.0=Running Post-Build step 129 | String.3.0=chex -o $(OutputPath)$(TargetSName).s19 $(OutputPath)$(TargetSName).sm8 130 | String.3.1=MapInfo $(OutputPath) $(TargetSName).Map 131 | String.6.0=2017,3,30,12,45,5 132 | 133 | [Root.Config.0.Settings.8] 134 | String.2.0=Performing Custom Build on $(InputFile) 135 | String.6.0=2017,3,27,21,19,37 136 | 137 | [Root.Config.1.Settings.0] 138 | String.6.0=2017,3,27,21,19,37 139 | String.100.0=ST Assembler Linker 140 | String.100.1=ST7 Cosmic 141 | String.100.2=STM8 Cosmic 142 | String.100.3=ST7 Metrowerks V1.1 143 | String.100.4=Raisonance 144 | String.101.0=STM8 Cosmic 145 | String.102.0=C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8 146 | String.103.0= 147 | String.104.0=Hstm8 148 | String.105.0=Lib 149 | String.106.0=Release 150 | String.107.0=hotkey.elf 151 | Int.108=0 152 | 153 | [Root.Config.1.Settings.1] 154 | String.6.0=2017,3,27,21,19,37 155 | String.100.0=$(TargetFName) 156 | String.101.0= 157 | String.103.0=.\; 158 | 159 | [Root.Config.1.Settings.2] 160 | String.2.0= 161 | String.6.0=2017,3,27,21,19,37 162 | String.100.0=STM8S003F3P 163 | 164 | [Root.Config.1.Settings.3] 165 | String.2.0=Compiling $(InputFile)... 166 | String.3.0=cxstm8 +mods0 -customC-pp $(ToolsetIncOpts) -cl$(IntermPath) -co$(IntermPath) $(InputFile) 167 | String.4.0=$(IntermPath)$(InputName).$(ObjectExt) 168 | String.5.0=$(IntermPath)$(InputName).ls 169 | String.6.0=2017,3,27,21,19,37 170 | 171 | [Root.Config.1.Settings.4] 172 | String.2.0=Assembling $(InputFile)... 173 | String.3.0=castm8 $(ToolsetIncOpts) -o$(IntermPath)$(InputName).$(ObjectExt) $(InputFile) 174 | String.4.0=$(IntermPath)$(InputName).$(ObjectExt) 175 | String.5.0=$(IntermPath)$(InputName).ls 176 | String.6.0=2017,3,27,21,19,37 177 | 178 | [Root.Config.1.Settings.5] 179 | String.2.0=Running Pre-Link step 180 | String.6.0=2017,3,27,21,19,37 181 | 182 | [Root.Config.1.Settings.6] 183 | String.2.0=Running Linker 184 | String.3.0=clnk -fakeRunConv -fakeInteger -fakeSemiAutoGen $(ToolsetLibOpts) -o $(OutputPath)$(TargetSName).sm8 -fakeOutFile$(ProjectSFile).elf -customCfgFile $(OutputPath)$(TargetSName).lkf -fakeVectFilestm8_interrupt_vector.c -fakeStartupcrtsi0.sm8 185 | String.3.1=cvdwarf $(OutputPath)$(TargetSName).sm8 -fakeVectAddr0x8000 186 | String.4.0=$(OutputPath)$(TargetFName) 187 | String.5.0=$(OutputPath)$(TargetSName).map $(OutputPath)$(TargetSName).st7 $(OutputPath)$(TargetSName).s19 188 | String.6.0=2017,3,27,21,19,37 189 | String.101.0=crtsi.st7 190 | String.102.0=+seg .const -b 0x8080 -m 0x1f80 -n .const -it 191 | String.102.1=+seg .text -a .const -n .text 192 | String.102.2=+seg .eeprom -b 0x4000 -m 0x80 -n .eeprom 193 | String.102.3=+seg .bsct -b 0x0 -m 0x100 -n .bsct 194 | String.102.4=+seg .ubsct -a .bsct -n .ubsct 195 | String.102.5=+seg .bit -a .ubsct -n .bit -id 196 | String.102.6=+seg .share -a .bit -n .share -is 197 | String.102.7=+seg .data -b 0x100 -m 0x100 -n .data 198 | String.102.8=+seg .bss -a .data -n .bss 199 | String.103.0=Code,Constants[0x8080-0x9fff]=.const,.text 200 | String.103.1=Eeprom[0x4000-0x407f]=.eeprom 201 | String.103.2=Zero Page[0x0-0xff]=.bsct,.ubsct,.bit,.share 202 | String.103.3=Ram[0x100-0x1ff]=.data,.bss 203 | String.104.0=0x3ff 204 | Int.0=0 205 | Int.1=0 206 | 207 | [Root.Config.1.Settings.7] 208 | String.2.0=Running Post-Build step 209 | String.3.0=chex -o $(OutputPath)$(TargetSName).s19 $(OutputPath)$(TargetSName).sm8 210 | String.6.0=2017,3,27,21,19,37 211 | 212 | [Root.Config.1.Settings.8] 213 | String.2.0=Performing Custom Build on $(InputFile) 214 | String.6.0=2017,3,27,21,19,37 215 | 216 | [Root.Source Files] 217 | ElemType=Folder 218 | PathName=Source Files 219 | Child=Root.Source Files.hardware.c 220 | Next=Root.Include Files 221 | Config.0=Root.Source Files.Config.0 222 | Config.1=Root.Source Files.Config.1 223 | 224 | [Root.Source Files.Config.0] 225 | Settings.0.0=Root.Source Files.Config.0.Settings.0 226 | Settings.0.1=Root.Source Files.Config.0.Settings.1 227 | Settings.0.2=Root.Source Files.Config.0.Settings.2 228 | Settings.0.3=Root.Source Files.Config.0.Settings.3 229 | 230 | [Root.Source Files.Config.1] 231 | Settings.1.0=Root.Source Files.Config.1.Settings.0 232 | Settings.1.1=Root.Source Files.Config.1.Settings.1 233 | Settings.1.2=Root.Source Files.Config.1.Settings.2 234 | Settings.1.3=Root.Source Files.Config.1.Settings.3 235 | 236 | [Root.Source Files.Config.0.Settings.0] 237 | String.6.0=2017,3,27,21,19,37 238 | String.8.0=Debug 239 | Int.0=0 240 | Int.1=0 241 | 242 | [Root.Source Files.Config.0.Settings.1] 243 | String.2.0=Compiling $(InputFile)... 244 | String.3.0=cxstm8 -customDbg -customDebCompat -customOpt-no -customLst -l +mods0 -customC-pp $(ToolsetIncOpts) -cl$(IntermPath) -co$(IntermPath) $(InputFile) 245 | String.4.0=$(IntermPath)$(InputName).$(ObjectExt) 246 | String.5.0=$(IntermPath)$(InputName).ls 247 | String.6.0=2017,3,27,21,19,37 248 | 249 | [Root.Source Files.Config.0.Settings.2] 250 | String.2.0=Assembling $(InputFile)... 251 | String.3.0=castm8 -xx -l $(ToolsetIncOpts) -o$(IntermPath)$(InputName).$(ObjectExt) $(InputFile) 252 | String.4.0=$(IntermPath)$(InputName).$(ObjectExt) 253 | String.5.0=$(IntermPath)$(InputName).ls 254 | String.6.0=2017,3,27,21,19,37 255 | 256 | [Root.Source Files.Config.0.Settings.3] 257 | String.2.0=Performing Custom Build on $(InputFile) 258 | String.3.0= 259 | String.4.0= 260 | String.5.0= 261 | String.6.0=2017,3,27,21,19,37 262 | 263 | [Root.Source Files.Config.1.Settings.0] 264 | String.6.0=2017,3,27,21,19,37 265 | String.8.0=Release 266 | Int.0=0 267 | Int.1=0 268 | 269 | [Root.Source Files.Config.1.Settings.1] 270 | String.2.0=Compiling $(InputFile)... 271 | String.3.0=cxstm8 +mods0 -customC-pp $(ToolsetIncOpts) -cl$(IntermPath) -co$(IntermPath) $(InputFile) 272 | String.4.0=$(IntermPath)$(InputName).$(ObjectExt) 273 | String.5.0=$(IntermPath)$(InputName).ls 274 | String.6.0=2017,3,27,21,19,37 275 | 276 | [Root.Source Files.Config.1.Settings.2] 277 | String.2.0=Assembling $(InputFile)... 278 | String.3.0=castm8 $(ToolsetIncOpts) -o$(IntermPath)$(InputName).$(ObjectExt) $(InputFile) 279 | String.4.0=$(IntermPath)$(InputName).$(ObjectExt) 280 | String.5.0=$(IntermPath)$(InputName).ls 281 | String.6.0=2017,3,27,21,19,37 282 | 283 | [Root.Source Files.Config.1.Settings.3] 284 | String.2.0=Performing Custom Build on $(InputFile) 285 | String.3.0= 286 | String.4.0= 287 | String.5.0= 288 | String.6.0=2017,3,27,21,19,37 289 | 290 | [Root.Source Files.hardware.c] 291 | ElemType=File 292 | PathName=hardware.c 293 | Next=Root.Source Files.main.c 294 | 295 | [Root.Source Files.main.c] 296 | ElemType=File 297 | PathName=main.c 298 | Next=Root.Source Files.stm8_interrupt_vector.c 299 | 300 | [Root.Source Files.stm8_interrupt_vector.c] 301 | ElemType=File 302 | PathName=stm8_interrupt_vector.c 303 | 304 | [Root.Include Files] 305 | ElemType=Folder 306 | PathName=Include Files 307 | Child=Root.Include Files.fifo.h 308 | Config.0=Root.Include Files.Config.0 309 | Config.1=Root.Include Files.Config.1 310 | 311 | [Root.Include Files.Config.0] 312 | Settings.0.0=Root.Include Files.Config.0.Settings.0 313 | Settings.0.1=Root.Include Files.Config.0.Settings.1 314 | Settings.0.2=Root.Include Files.Config.0.Settings.2 315 | Settings.0.3=Root.Include Files.Config.0.Settings.3 316 | 317 | [Root.Include Files.Config.1] 318 | Settings.1.0=Root.Include Files.Config.1.Settings.0 319 | Settings.1.1=Root.Include Files.Config.1.Settings.1 320 | Settings.1.2=Root.Include Files.Config.1.Settings.2 321 | Settings.1.3=Root.Include Files.Config.1.Settings.3 322 | 323 | [Root.Include Files.Config.0.Settings.0] 324 | String.6.0=2017,3,27,21,19,37 325 | String.8.0=Debug 326 | Int.0=0 327 | Int.1=0 328 | 329 | [Root.Include Files.Config.0.Settings.1] 330 | String.2.0=Compiling $(InputFile)... 331 | String.3.0=cxstm8 -customDbg -customDebCompat -customOpt-no -customLst -l +mods0 -customC-pp $(ToolsetIncOpts) -cl$(IntermPath) -co$(IntermPath) $(InputFile) 332 | String.4.0=$(IntermPath)$(InputName).$(ObjectExt) 333 | String.5.0=$(IntermPath)$(InputName).ls 334 | String.6.0=2017,3,27,21,19,37 335 | 336 | [Root.Include Files.Config.0.Settings.2] 337 | String.2.0=Assembling $(InputFile)... 338 | String.3.0=castm8 -xx -l $(ToolsetIncOpts) -o$(IntermPath)$(InputName).$(ObjectExt) $(InputFile) 339 | String.4.0=$(IntermPath)$(InputName).$(ObjectExt) 340 | String.5.0=$(IntermPath)$(InputName).ls 341 | String.6.0=2017,3,27,21,19,37 342 | 343 | [Root.Include Files.Config.0.Settings.3] 344 | String.2.0=Performing Custom Build on $(InputFile) 345 | String.3.0= 346 | String.4.0= 347 | String.5.0= 348 | String.6.0=2017,3,27,21,19,37 349 | 350 | [Root.Include Files.Config.1.Settings.0] 351 | String.6.0=2017,3,27,21,19,37 352 | String.8.0=Release 353 | Int.0=0 354 | Int.1=0 355 | 356 | [Root.Include Files.Config.1.Settings.1] 357 | String.2.0=Compiling $(InputFile)... 358 | String.3.0=cxstm8 +mods0 -customC-pp $(ToolsetIncOpts) -cl$(IntermPath) -co$(IntermPath) $(InputFile) 359 | String.4.0=$(IntermPath)$(InputName).$(ObjectExt) 360 | String.5.0=$(IntermPath)$(InputName).ls 361 | String.6.0=2017,3,27,21,19,37 362 | 363 | [Root.Include Files.Config.1.Settings.2] 364 | String.2.0=Assembling $(InputFile)... 365 | String.3.0=castm8 $(ToolsetIncOpts) -o$(IntermPath)$(InputName).$(ObjectExt) $(InputFile) 366 | String.4.0=$(IntermPath)$(InputName).$(ObjectExt) 367 | String.5.0=$(IntermPath)$(InputName).ls 368 | String.6.0=2017,3,27,21,19,37 369 | 370 | [Root.Include Files.Config.1.Settings.3] 371 | String.2.0=Performing Custom Build on $(InputFile) 372 | String.3.0= 373 | String.4.0= 374 | String.5.0= 375 | String.6.0=2017,3,27,21,19,37 376 | 377 | [Root.Include Files.fifo.h] 378 | ElemType=File 379 | PathName=fifo.h 380 | Next=Root.Include Files.hardware.h 381 | 382 | [Root.Include Files.hardware.h] 383 | ElemType=File 384 | PathName=hardware.h 385 | Next=Root.Include Files.irq.h 386 | 387 | [Root.Include Files.irq.h] 388 | ElemType=File 389 | PathName=irq.h 390 | Next=Root.Include Files.stm8s.h 391 | 392 | [Root.Include Files.stm8s.h] 393 | ElemType=File 394 | PathName=stm8s.h -------------------------------------------------------------------------------- /KVM-Hotkey/irq.h: -------------------------------------------------------------------------------- 1 | @far @interrupt void PORTB_IRQ(void); 2 | @far @interrupt void TIM4_IRQ(void); 3 | 4 | #define IRQ4 PORTB_IRQ 5 | #define IRQ23 TIM4_IRQ 6 | -------------------------------------------------------------------------------- /KVM-Hotkey/main.c: -------------------------------------------------------------------------------- 1 | #include "hardware.h" 2 | 3 | void main(void) 4 | { 5 | Init_Hardware(); 6 | 7 | while(1) 8 | { 9 | PS2_Task(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /KVM-Hotkey/stm8_interrupt_vector.c: -------------------------------------------------------------------------------- 1 | /* 2 | * stm8_interrupt_vector.c 3 | * 4 | * Created: February-03-17, 4:56:38 PM 5 | * Author: K. C. Lee 6 | * Copyright (c) 2017 by K. C. Lee 7 | 8 | This program is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this program. 20 | 21 | If not, see http://www.gnu.org/licenses/gpl-3.0.en.html 22 | */ 23 | 24 | #include "irq.h" 25 | #include "stm8_interrupt_vector.h" 26 | 27 | typedef struct 28 | { 29 | unsigned char irq; 30 | void @far (*irq_handler)(void); 31 | } irq_vectors; 32 | 33 | extern void _stext(); 34 | @far @interrupt void Default_IRQ_Handler(void) 35 | { 36 | } 37 | 38 | const irq_vectors _vectab[] = 39 | { 40 | {0x82,(void @far (*)(void))_stext}, /* reset */ 41 | {0x82,TRAP}, // trap 42 | {0x82,IRQ0}, // irq0 43 | {0x82,IRQ1}, // irq1 44 | {0x82,IRQ2}, // irq2 45 | {0x82,IRQ3}, // irq3 46 | {0x82,IRQ4}, // irq4 47 | {0x82,IRQ5}, // irq5 48 | {0x82,IRQ6}, // irq6 49 | {0x82,IRQ7}, // irq7 50 | {0x82,IRQ8}, // irq8 51 | {0x82,IRQ9}, // irq9 52 | {0x82,IRQ10}, // irq10 53 | {0x82,IRQ11}, // irq11 54 | {0x82,IRQ12}, // irq12 55 | {0x82,IRQ13}, // irq13 56 | {0x82,IRQ14}, // irq14 57 | {0x82,IRQ15}, // irq15 58 | {0x82,IRQ16}, // irq16 59 | {0x82,IRQ17}, // irq17 60 | {0x82,IRQ18}, // irq18 61 | {0x82,IRQ19}, // irq19 62 | {0x82,IRQ20}, // irq20 63 | {0x82,IRQ21}, // irq21 64 | {0x82,IRQ22}, // irq22 65 | {0x82,IRQ23}, // irq23 66 | {0x82,IRQ24}, // irq24 67 | {0x82,IRQ25}, // irq25 68 | {0x82,IRQ26}, // irq26 69 | {0x82,IRQ27}, // irq27 70 | {0x82,IRQ28}, // irq28 71 | {0x82,IRQ29}, // irq29 72 | }; 73 | -------------------------------------------------------------------------------- /KVM-Hotkey/stm8_interrupt_vector.h: -------------------------------------------------------------------------------- 1 | /* 2 | * stm8_interrupt_vector.h 3 | * 4 | * Created: February-10-17, 9:47:05 PM 5 | * Author: K. C. Lee 6 | * Copyright (c) 2017 by K. C. Lee 7 | 8 | This program is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this program. 20 | 21 | If not, see http://www.gnu.org/licenses/gpl-3.0.en.html 22 | */ 23 | 24 | #ifndef TRAP 25 | #define TRAP Default_IRQ_Handler 26 | #endif 27 | 28 | #ifndef IRQ0 29 | #define IRQ0 Default_IRQ_Handler 30 | #endif 31 | 32 | #ifndef IRQ1 33 | #define IRQ1 Default_IRQ_Handler 34 | #endif 35 | 36 | #ifndef IRQ2 37 | #define IRQ2 Default_IRQ_Handler 38 | #endif 39 | 40 | #ifndef IRQ3 41 | #define IRQ3 Default_IRQ_Handler 42 | #endif 43 | 44 | #ifndef IRQ4 45 | #define IRQ4 Default_IRQ_Handler 46 | #endif 47 | 48 | #ifndef IRQ5 49 | #define IRQ5 Default_IRQ_Handler 50 | #endif 51 | 52 | #ifndef IRQ6 53 | #define IRQ6 Default_IRQ_Handler 54 | #endif 55 | 56 | #ifndef IRQ7 57 | #define IRQ7 Default_IRQ_Handler 58 | #endif 59 | 60 | #ifndef IRQ8 61 | #define IRQ8 Default_IRQ_Handler 62 | #endif 63 | 64 | #ifndef IRQ9 65 | #define IRQ9 Default_IRQ_Handler 66 | #endif 67 | 68 | #ifndef IRQ10 69 | #define IRQ10 Default_IRQ_Handler 70 | #endif 71 | 72 | #ifndef IRQ11 73 | #define IRQ11 Default_IRQ_Handler 74 | #endif 75 | 76 | #ifndef IRQ12 77 | #define IRQ12 Default_IRQ_Handler 78 | #endif 79 | 80 | #ifndef IRQ13 81 | #define IRQ13 Default_IRQ_Handler 82 | #endif 83 | 84 | #ifndef IRQ14 85 | #define IRQ14 Default_IRQ_Handler 86 | #endif 87 | 88 | #ifndef IRQ15 89 | #define IRQ15 Default_IRQ_Handler 90 | #endif 91 | 92 | #ifndef IRQ16 93 | #define IRQ16 Default_IRQ_Handler 94 | #endif 95 | 96 | #ifndef IRQ17 97 | #define IRQ17 Default_IRQ_Handler 98 | #endif 99 | 100 | #ifndef IRQ18 101 | #define IRQ18 Default_IRQ_Handler 102 | #endif 103 | 104 | #ifndef IRQ19 105 | #define IRQ19 Default_IRQ_Handler 106 | #endif 107 | 108 | #ifndef IRQ20 109 | #define IRQ20 Default_IRQ_Handler 110 | #endif 111 | 112 | #ifndef IRQ21 113 | #define IRQ21 Default_IRQ_Handler 114 | #endif 115 | 116 | #ifndef IRQ22 117 | #define IRQ22 Default_IRQ_Handler 118 | #endif 119 | 120 | #ifndef IRQ23 121 | #define IRQ23 Default_IRQ_Handler 122 | #endif 123 | 124 | #ifndef IRQ24 125 | #define IRQ24 Default_IRQ_Handler 126 | #endif 127 | 128 | #ifndef IRQ25 129 | #define IRQ25 Default_IRQ_Handler 130 | #endif 131 | 132 | #ifndef IRQ26 133 | #define IRQ26 Default_IRQ_Handler 134 | #endif 135 | 136 | #ifndef IRQ27 137 | #define IRQ27 Default_IRQ_Handler 138 | #endif 139 | 140 | #ifndef IRQ28 141 | #define IRQ28 Default_IRQ_Handler 142 | #endif 143 | 144 | #ifndef IRQ29 145 | #define IRQ29 Default_IRQ_Handler 146 | #endif 147 | 148 | -------------------------------------------------------------------------------- /KVM-Hotkey/stm8s_conf.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FPGA-Computer/KVM-Switch/3f3526bb809239746657e17d94fe30fd696eddca/KVM-Hotkey/stm8s_conf.h -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | KVM Switch 2 | built from $5 HDMI switch + custom hardware 3 | 4 | Details: https://hw-by-design.blogspot.com/2018/07/low-cost-kvm-switch.html 5 | 6 | Hardware/ - Eagle CAD schematic, PCB, Sketchup 3D model (zipped) 7 | Firmware/ - STM8S003 firmware source code for hotkey 8 | KVM-Hotkey/ - initial test code I used during development. 9 | Included here for archive and completeiness because of my hosting changes. 10 | 11 | Firmware written by me are licensed under GPL 3.0. 12 | Additional incorporated code are under their own licenses. 13 | 14 | Hardware is licensed under CC BY-4.0 15 | 16 | https://creativecommons.org/licenses/by/4.0/ 17 | 18 | Updates: change to Right CTRL key as hotkey. 19 | 20 | Updates: 21 | 22 | - Optional active or'ing circuit to replace Schottky diodes for lower voltage drops. 23 | 24 | Or'ing circuit imspired by RPi 3 Model B rev. 1.2 USB power circuit. The matching transistor pair is 25 | not needed - verified by simulation. Voltage drop (roughly 50mV @0.5A). The circuit can share current 26 | from multiple USB supplies. 27 | 28 | - new USB Mux-v0.2 PCB layout with larger wiring pads, pads for optional or'ing circuit 29 | 30 | --------------------------------------------------------------------------------