Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void main() {
- [...]
- while (1) {
- if (uart_available()) {
- c = uart_getchar();
- process_opcode(c);
- }
- }
- }
- void process_opcode(uint8_t c){
- uint8_t opcode = c >> 5;
- uint8_t reg = c & 0x1f;
- switch (opcode){
- case SETREG_REQ:
- process_setreg_request(reg);
- break;
- case GETREG_REQ:
- process_getreg_request(reg);
- }
- }
- void process_setreg_request(uint8_t reg){
- uint8_t value;
- value = uart_getchar();
- switch(reg){
- // General USB registers
- case (REG_UHWCON):
- UHWCON = value;
- break;
- case (REG_USBCON):
- USBCON = value;
- break;
- case (REG_USBINT):
- USBINT = value;
- break;
- case (REG_USBSTA):
- USBSTA = value;
- break;
- [...]
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement