diff options
author | Drashna Jael're <drashna@live.com> | 2021-12-07 09:27:44 -0800 |
---|---|---|
committer | Drashna Jael're <drashna@live.com> | 2021-12-07 09:27:44 -0800 |
commit | 7c18b1c9d3d968ded45e072af3483547c3ec7859 (patch) | |
tree | ed7c8a4176033046eacff21228364290b44fcfdb /platforms/webusb.h | |
parent | 43002bdf77ab0f48af6b04e87edcc37f7cb7b905 (diff) | |
parent | 6d0a62920410f50d7f6707960ca1ca0c8fd1d1fa (diff) |
Merge commit '6d0a62920410f50d7f6707960ca1ca0c8fd1d1fa' into firmware21
Diffstat (limited to 'platforms/webusb.h')
-rw-r--r-- | platforms/webusb.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/platforms/webusb.h b/platforms/webusb.h new file mode 100644 index 0000000000..7bec7c50e1 --- /dev/null +++ b/platforms/webusb.h @@ -0,0 +1,46 @@ +#pragma once + +#include <stdint.h> +#include <stdbool.h> + +#ifndef FIRMWARE_VERSION +#define FIRMWARE_VERSION u8"default" +#endif +#define WEBUSB_STOP_BIT -2 +#define WEBUSB_BLINK_STEPS 512 +#define WEBUSB_BLINK_END WEBUSB_BLINK_STEPS * 60 + +void webusb_receive(uint8_t *data, uint8_t length); +void webusb_send(uint8_t *data, uint8_t length); +void webusb_layer_event(void); +void webusb_error(uint8_t code); +void webusb_set_pairing_state(void); +bool webusb_receive_quantum(uint8_t *data, uint8_t length); + +typedef struct{ + bool paired; + bool pairing; +} webusb_state_t; + +extern webusb_state_t webusb_state; + +enum Webusb_Status_Code { + WEBUSB_STATUS_NOT_PAIRED = -1, + WEBUSB_STATUS_OK, + WEBUSB_STATUS_UNKNOWN_COMMAND, + WEBUSB_STATUS_SAFE_RANGE, +}; + +enum Webusb_Command_Code { + WEBUSB_CMD_PAIR, + WEBUSB_CMD_GET_FW_VERSION, + WEBUSB_CMD_SAFE_RANGE, + +}; + +enum Webusb_Event_Code { + WEBUSB_EVT_PAIRED, + WEBUSB_EVT_FW_VERSION, + WEBUSB_EVT_SAFE_RANGE, + +}; |