more on wk emulation
This commit is contained in:
parent
97e1f53bfe
commit
7a5d0b97e7
1 changed files with 28 additions and 11 deletions
|
@ -104,7 +104,7 @@ void core1_main()
|
|||
}
|
||||
}
|
||||
|
||||
[[maybe_unused]] static void echo_serial_port(uint8_t itf, uint8_t buf[], uint32_t count)
|
||||
static void usbSend(uint8_t itf, uint8_t buf[], uint32_t count)
|
||||
{
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
tud_cdc_n_write_char(itf, buf[i]);
|
||||
|
@ -113,23 +113,40 @@ void core1_main()
|
|||
tud_cdc_n_write_flush(itf);
|
||||
}
|
||||
|
||||
static void usbSend(uint8_t itf, uint8_t value) {
|
||||
tud_cdc_n_write_char(itf, value);
|
||||
tud_cdc_n_write_flush(itf);
|
||||
}
|
||||
|
||||
void cdc_task()
|
||||
{
|
||||
const uint8_t UsbInIf = 1;
|
||||
const uint8_t USB_IF = 0;
|
||||
|
||||
if (tud_cdc_n_available(UsbInIf)) {
|
||||
if (tud_cdc_n_available(USB_IF)) {
|
||||
uint8_t buf[64];
|
||||
|
||||
uint32_t count = tud_cdc_n_read(UsbInIf, buf, sizeof(buf));
|
||||
if (count > 1) {
|
||||
printf("Command received …\n");
|
||||
//printf("AHA!!! %d\n", (int)tud_cdc_n_available(USB_IF));
|
||||
uint32_t count = tud_cdc_n_read(USB_IF, buf, sizeof(buf));
|
||||
|
||||
if (count > 0) {
|
||||
switch (buf[0]) {
|
||||
case 0: // ADMIN COMMAND
|
||||
case 'a' ... 'z':
|
||||
case 'A' ... 'Z':
|
||||
case '0' ... '9':
|
||||
printf("TODO: Send it!\n");
|
||||
break;
|
||||
case 0x00: // ADMIN COMMAND
|
||||
switch (buf[1]) {
|
||||
case 2: // Host Open
|
||||
// TODO: send back revision code
|
||||
case 0x02: // Host open
|
||||
usbSend(USB_IF, 9); // Send WK1 (v9) for now (no WinKeyer PTT control)
|
||||
break;
|
||||
case 0x04: // Echo test
|
||||
printf("Echo test: %x\n", buf[2]);
|
||||
printf("buf address: %p\n", &buf[2]);
|
||||
usbSend(USB_IF, &buf[2], 1);
|
||||
break;
|
||||
default:
|
||||
printf("Unknown admin command.\n");
|
||||
printf("Unknown admin command: %x\n", buf[1]);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -204,7 +221,7 @@ int main()
|
|||
lastWpm = currentWpm;
|
||||
}
|
||||
|
||||
busy_wait_ms(5000);
|
||||
//busy_wait_ms(5000);
|
||||
if (!used) {
|
||||
//KeyerQueueData keyerQueueData {KeyerQueueCommand::SendMessage, 0, settings.mode, "cq cq de dg2smb dg2smb pse k"};
|
||||
//queue_add_blocking(&keyerQueue, &keyerQueueData);
|
||||
|
|
Loading…
Reference in a new issue