ChibiOS - Non blocking xap_send_base

This commit is contained in:
zvecr 2022-11-23 17:43:55 +00:00
parent d7c6f31567
commit ff2f0d943b
2 changed files with 18 additions and 1 deletions

View File

@ -100,3 +100,14 @@ const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][2] = {
[_ADJUST] = { ENCODER_CCW_CW(RGB_RMOD, RGB_MOD), ENCODER_CCW_CW(KC_RIGHT, KC_LEFT) },
};
#endif
void housekeeping_task_user(void) {
static uint32_t timer = 0;
static uint8_t count = 0;
if (timer_elapsed32(timer) > 1000) {
timer = timer_read32();
count++;
xap_broadcast(0x03, &count, 1);
}
}

View File

@ -1138,7 +1138,13 @@ void xap_send_base(uint8_t *data, uint8_t length) {
if (length != XAP_EPSIZE) {
return;
}
chnWrite(&drivers.xap_driver.driver, data, length);
// see console sendchar for timeout details
static bool timed_out = false;
const sysinterval_t timeout = timed_out ? TIME_IMMEDIATE : TIME_MS2I(5);
const size_t result = chnWriteTimeout(&drivers.xap_driver.driver, data, length, timeout);
timed_out = (result == 0);
}
void xap_send(xap_token_t token, xap_response_flags_t response_flags, const void *data, size_t length) {