View difference between Paste ID: zL8zVHJB and gkSPtwfu
SHOW: | | - or go back to the newest paste.
1
void main() {
2-
[...]
2+
   [...]
3-
while (1) {
3+
   while (1) {
4-
if (uart_available()) {
4+
      if (uart_available()) {
5-
c = uart_getchar();
5+
         c = uart_getchar();
6-
process_opcode(c);
6+
         process_opcode(c);
7
      }
8
   }
9
}
10
11-
uint8_t opcode = c >> 5;
11+
12-
uint8_t reg = c & 0x1f;
12+
   uint8_t opcode = c >> 5;
13-
switch (opcode){
13+
   uint8_t reg = c & 0x1f;
14-
case SETREG_REQ:
14+
   switch (opcode){
15-
process_setreg_request(reg);
15+
      case SETREG_REQ:
16-
break;
16+
         process_setreg_request(reg);
17-
case GETREG_REQ:
17+
         break;
18-
process_getreg_request(reg);
18+
      case GETREG_REQ:
19
         process_getreg_request(reg);
20
   }
21
}
22-
uint8_t value;
22+
23-
value = uart_getchar();
23+
24-
switch(reg){
24+
   uint8_t value;
25-
// General USB registers
25+
   value = uart_getchar();
26-
case (REG_UHWCON):
26+
   switch(reg){
27-
UHWCON = value;
27+
      // General USB registers
28-
break;
28+
      case (REG_UHWCON):
29-
case (REG_USBCON):
29+
         UHWCON = value;
30-
USBCON = value;
30+
         break;
31-
break;
31+
      case (REG_USBCON):
32-
case (REG_USBINT):
32+
         USBCON = value;
33-
USBINT = value;
33+
         break;
34-
break;
34+
      case (REG_USBINT):
35-
case (REG_USBSTA):
35+
         USBINT = value;
36-
USBSTA = value;
36+
         break;
37-
break;
37+
      case (REG_USBSTA):
38-
[...]
38+
         USBSTA = value;
39
         break;
40
      [...]
41
   }
42
}