Skip to content

Commit

Permalink
Add I2C offset that configures the dedicated keyboard and mouse slave…
Browse files Browse the repository at this point in the history
… addresses
  • Loading branch information
stefan-b-jakobsson committed Jan 18, 2024
1 parent 8fa51db commit 78b9ad1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions smc_wire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,14 @@ uint8_t SmcWire::read() {
return value;
}

void SmcWire::setKeyboardAddress(uint8_t addr) {
kbd_address = addr;
}

void SmcWire::setMouseAddress(uint8_t addr) {
mse_address = addr;
}


/*
USI Interrupt Handlers
Expand Down
2 changes: 2 additions & 0 deletions smc_wire.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ class SmcWire {
void write(uint8_t value);
uint8_t available();
uint8_t read();
void setKeyboardAddress(uint8_t);
void setMouseAddress(uint8_t);
};
10 changes: 10 additions & 0 deletions x16-smc.ino
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@
#define CMD_GET_KBD_STATUS 0x18
#define CMD_KBD_CMD1 0x19
#define CMD_KBD_CMD2 0x1a
#define CMD_KBD_SET_ADDRESS 0x1b
#define CMD_SET_MOUSE_ID 0x20
#define CMD_GET_MOUSE_MOV 0x21
#define CMD_GET_MOUSE_ID 0x22
#define CMD_SET_MOUSE_ADDRESS 0x23
#define CMD_GET_VER1 0x30
#define CMD_GET_VER2 0x31
#define CMD_GET_VER3 0x32
Expand Down Expand Up @@ -421,10 +423,18 @@ void I2C_Receive(int) {
}
break;

case CMD_KBD_SET_ADDRESS:
smcWire.setKeyboardAddress(I2C_Data[1]);
break;

case CMD_SET_MOUSE_ID:
mouseSetRequestedId(I2C_Data[1]);
break;

case CMD_SET_MOUSE_ADDRESS:
smcWire.setMouseAddress(I2C_Data[1]);
break;

case CMD_BOOTLDR_START:
if (I2C_Data[1] == 0x31) {
bootloaderTimer = 2000;
Expand Down

0 comments on commit 78b9ad1

Please sign in to comment.