Skip to content

Commit

Permalink
firmware: read IO pins through the pull extender (-72 bytes XRAM).
Browse files Browse the repository at this point in the history
  • Loading branch information
purdeaandrei committed Aug 1, 2024
1 parent deb776c commit ed5a255
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions firmware/glasgow.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ void iobuf_read_alert_cache_ina233(__xdata uint8_t *mask, bool clear);
// Pull API
bool iobuf_set_pull(uint8_t selector, uint8_t enable, uint8_t level);
bool iobuf_get_pull(uint8_t selector, __xdata uint8_t *enable, __xdata uint8_t *level);
bool iobuf_get_input(uint8_t selector, __xdata uint8_t *value);

// FIFO API
void fifo_init();
Expand Down
20 changes: 15 additions & 5 deletions firmware/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -759,13 +759,23 @@ void handle_pending_usb_setup() {

if(arg_get) {
while(EP0CS & _BUSY);
if(glasgow_config.revision < GLASGOW_REV_C0 ||
!iobuf_get_pull(arg_selector,
(__xdata uint8_t *)EP0BUF + 0,
(__xdata uint8_t *)EP0BUF + 1)) {
if(glasgow_config.revision < GLASGOW_REV_C0) {
goto stall_ep0_return;
}
if (req->wIndex & 0x100) {
if (!iobuf_get_input(arg_selector, (__xdata uint8_t *)EP0BUF + 0)) {
goto stall_ep0_return;
} else {
SETUP_EP0_BUF(1);
}
} else {
SETUP_EP0_BUF(2);
if (!iobuf_get_pull(arg_selector,
(__xdata uint8_t *)EP0BUF + 0,
(__xdata uint8_t *)EP0BUF + 1)) {
goto stall_ep0_return;
} else {
SETUP_EP0_BUF(2);
}
}
} else {
SETUP_EP0_BUF(2);
Expand Down
4 changes: 4 additions & 0 deletions firmware/pull.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,7 @@ bool iobuf_get_pull(uint8_t selector, __xdata uint8_t *enable, __xdata uint8_t *
*enable = ~*enable;
return true;
}

bool iobuf_get_input(uint8_t selector, __xdata uint8_t *value) {
return pull_read(selector, TCA9534_CMD_INPUT_PORT, value);
}

0 comments on commit ed5a255

Please sign in to comment.