usage:
Code: Select all
for (int i=0x0000; i<0x0004; i++){b = htonl(i);tusbwa1((const uint8_t *)&b, 4);}vTaskDelay(pdMS_TO_TICKS(100));
for (int i=0x00F0; i<0x00F8; i++){b = htonl(i);tusbwa1((const uint8_t *)&b, 4);}vTaskDelay(pdMS_TO_TICKS(100));
for (int i=0x0F00; i<0x0F0F; i++){b = htonl(i);tusbwa1((const uint8_t *)&b, 4);}vTaskDelay(pdMS_TO_TICKS(100));
for (int i=0xF000; i<0xF00F; i++){b = htonl(i);tusbwa1((const uint8_t *)&b, 4);}vTaskDelay(pdMS_TO_TICKS(100));
Code: Select all
bool tusbwa1(const uint8_t* data, size_t len) {
int max_retries = 100;
size_t total_sent = 0;
int retries = 0;
while (total_sent < len) {
vTaskDelay(pdMS_TO_TICKS(1));
size_t sent = tinyusb_cdcacm_write_queue(TINYUSB_CDC_ACM_1, data + total_sent, len - total_sent);
vTaskDelay(pdMS_TO_TICKS(1));
tud_remote_wakeup();
vTaskDelay(pdMS_TO_TICKS(1));
if (sent == 0) {
tinyusb_cdcacm_write_flush(TINYUSB_CDC_ACM_1, pdMS_TO_TICKS(100));
retries++;
if (retries > max_retries) { return false; }
} else {
total_sent += sent;
retries = 0; // Reset retries after progress
}
}
// tinyusb_cdcacm_write_flush(TINYUSB_CDC_ACM_1, pdMS_TO_TICKS(100));
return true;
}
Code: Select all
00000000: 0000 0f00 000f 0500 000f 0600 000f 0700 ................
00000010: 000f 0800 000f 0900 000f 0a00 000f 0b00 ................
CORRECTION:
My problem is that cat /dev/ttyACM3 needed to have settings on the TTY for this to work properly.
Code: Select all
stty -F /dev/ttyACM3 raw -echo