Pārlūkot izejas kodu

Serial CP210x support for more boards

Updated some of the init code for the CP210x.

Before it worked with the one USB to serial adapter I had, but
we foudn it id did not work with Adafruit USB adaptor nor with their metro boards
main
Kurt Eckhardt pirms 5 gadiem
vecāks
revīzija
e27d6af3d2
1 mainītis faili ar 11 papildinājumiem un 17 dzēšanām
  1. +11
    -17
      serial.cpp

+ 11
- 17
serial.cpp Parādīt failu

if (format_ & 0x100) cp210x_format |= 2; if (format_ & 0x100) cp210x_format |= 2;


mk_setup(setup, 0x41, 3, cp210x_format, 0, 0); // data format 8N1 mk_setup(setup, 0x41, 3, cp210x_format, 0, 0); // data format 8N1
println("CP210x setup, 0x41, 3, cp210x_format ",cp210x_format, HEX);
queue_Control_Transfer(device, &setup, NULL, this); queue_Control_Transfer(device, &setup, NULL, this);
control_queued = true; control_queued = true;
return; return;
setupdata[2] = (baudrate >> 16) & 0xff; setupdata[2] = (baudrate >> 16) & 0xff;
setupdata[3] = (baudrate >> 24) & 0xff; setupdata[3] = (baudrate >> 24) & 0xff;
mk_setup(setup, 0x40, 0x1e, 0, 0, 4); mk_setup(setup, 0x40, 0x1e, 0, 0, 4);
println("CP210x Set Baud 0x40, 0x1e");
queue_Control_Transfer(device, &setup, setupdata, this); queue_Control_Transfer(device, &setup, setupdata, this);
control_queued = true; control_queued = true;
return; return;
} }
// configure flow control
// Appears to be an enable command
if (pending_control & 4) { if (pending_control & 4) {
pending_control &= ~4; pending_control &= ~4;
memset(setupdata, 0, sizeof(setupdata)); // clear out the data memset(setupdata, 0, sizeof(setupdata)); // clear out the data
setupdata[0] = 1; // Set dtr active?
mk_setup(setup, 0x41, 13, 0, 0, 0x10);
queue_Control_Transfer(device, &setup, setupdata, this);
println("CP210x 0x41, 0, 1");
mk_setup(setup, 0x41, 0, 1, 0, 0);
queue_Control_Transfer(device, &setup, NULL, this);
control_queued = true; control_queued = true;
return; return;
} }
// set DTR

// MHS_REQUEST
if (pending_control & 8) { if (pending_control & 8) {
pending_control &= ~8;
mk_setup(setup, 0x41, 7, 0x0101, 0, 0);
pending_control &= ~0x88;
mk_setup(setup, 0x41, 7, 0x0303, 0, 0);
queue_Control_Transfer(device, &setup, NULL, this); queue_Control_Transfer(device, &setup, NULL, this);
control_queued = true; control_queued = true;
println("CP210x 0x41, 7, 0x0303");
return; return;
} }
// clear DTR
if (pending_control & 0x80) {
pending_control &= ~0x80;
println("CP210x clear DTR");
mk_setup(setup, 0x40, 1, 0x0100, 0, 0);
queue_Control_Transfer(device, &setup, NULL, this);
control_queued = true;
return;
}

} }
} }



Notiek ielāde…
Atcelt
Saglabāt