Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firmware read pull io expander input #650

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
Loading