Update RMKB to support SNAP (#17042)
This commit is contained in:
		
							parent
							
								
									76eff706f6
								
							
						
					
					
						commit
						120d5d5520
					
				
					 2 changed files with 6 additions and 6 deletions
				
			
		| 
						 | 
					@ -62,13 +62,12 @@ static void send_msg(uint16_t keycode, bool pressed) {
 | 
				
			||||||
  msg[IDX_KCMSB] = (keycode >> 8) & 0xFF;
 | 
					  msg[IDX_KCMSB] = (keycode >> 8) & 0xFF;
 | 
				
			||||||
  msg[IDX_PRESSED] = pressed;
 | 
					  msg[IDX_PRESSED] = pressed;
 | 
				
			||||||
  msg[IDX_CHECKSUM] = chksum8(msg, UART_MSG_LEN-1);
 | 
					  msg[IDX_CHECKSUM] = chksum8(msg, UART_MSG_LEN-1);
 | 
				
			||||||
 | 
					 | 
				
			||||||
  uart_transmit(msg, UART_MSG_LEN);
 | 
					  uart_transmit(msg, UART_MSG_LEN);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void print_message_buffer(void) {
 | 
					static inline void print_message_buffer(void) {
 | 
				
			||||||
  for (int i=0; i<UART_MSG_LEN; i++) {
 | 
					  for (int i=0; i<UART_MSG_LEN; i++) {
 | 
				
			||||||
    dprintf("msg[%u]: %u\n", i, msg[i]);
 | 
					    dprintf("msg[%u]: 0x%02X\n", i, msg[i]);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -77,7 +76,7 @@ static void process_uart(void) {
 | 
				
			||||||
  if (msg[IDX_PREAMBLE] != UART_PREAMBLE || msg[IDX_CHECKSUM] != chksum) {
 | 
					  if (msg[IDX_PREAMBLE] != UART_PREAMBLE || msg[IDX_CHECKSUM] != chksum) {
 | 
				
			||||||
     dprintf("UART checksum mismatch!\n");
 | 
					     dprintf("UART checksum mismatch!\n");
 | 
				
			||||||
     print_message_buffer();
 | 
					     print_message_buffer();
 | 
				
			||||||
     dprintf("calc checksum: %u\n", chksum);
 | 
					     dprintf("calc checksum: 0x%02X\n", chksum);
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    uint16_t keycode = (uint16_t)msg[IDX_KCLSB] | ((uint16_t)msg[IDX_KCMSB] << 8);
 | 
					    uint16_t keycode = (uint16_t)msg[IDX_KCLSB] | ((uint16_t)msg[IDX_KCMSB] << 8);
 | 
				
			||||||
    bool pressed = (bool)msg[IDX_PRESSED];
 | 
					    bool pressed = (bool)msg[IDX_PRESSED];
 | 
				
			||||||
| 
						 | 
					@ -102,13 +101,14 @@ static void process_uart(void) {
 | 
				
			||||||
static void get_msg(void) {
 | 
					static void get_msg(void) {
 | 
				
			||||||
  while (uart_available()) {
 | 
					  while (uart_available()) {
 | 
				
			||||||
    msg[msg_idx] = uart_read();
 | 
					    msg[msg_idx] = uart_read();
 | 
				
			||||||
    dprintf("idx: %u, recv: %u\n", msg_idx, msg[msg_idx]);
 | 
					    dprintf("idx: %u, recv: 0x%002X\n", msg_idx, msg[msg_idx]);
 | 
				
			||||||
    if (msg_idx == 0 && (msg[msg_idx] != UART_PREAMBLE)) {
 | 
					    if (msg_idx == 0 && (msg[msg_idx] != UART_PREAMBLE)) {
 | 
				
			||||||
      dprintf("Byte sync error!\n");
 | 
					      dprintf("Byte sync error!\n");
 | 
				
			||||||
      msg_idx = 0;
 | 
					      msg_idx = 0;
 | 
				
			||||||
    } else if (msg_idx == (UART_MSG_LEN-1)) {
 | 
					    } else if (msg_idx == (UART_MSG_LEN-1)) {
 | 
				
			||||||
      process_uart();
 | 
					      process_uart();
 | 
				
			||||||
      msg_idx = 0;
 | 
					      msg_idx = 0;
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      msg_idx++;
 | 
					      msg_idx++;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,7 +17,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "quantum.h"
 | 
					#include "quantum.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define SERIAL_UART_BAUD 153600 //low error rate for 32u4 @ 16MHz
 | 
					#define SERIAL_UART_BAUD 76800 //low error rate for 32u4 @ 16MHz
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define UART_PREAMBLE 0x69
 | 
					#define UART_PREAMBLE 0x69
 | 
				
			||||||
#define UART_MSG_LEN  5
 | 
					#define UART_MSG_LEN  5
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue