Zum SPI-Modus kann ich nichts sagen, dazu kenne ich den Due nicht gut genug, habe da schon vor einiger Zeit beschlossen zum Teensy zu wechseln.
Es stimmt aber nicht, dass die LIN-Library Bitbanging bei den Datenbytes macht. Das macht sie nur bei den LIN-Spezialitäten, die andere Bitzeiten erfordern.
Ausschnitte:
// Start interface
sleep(1); // Go to Normal mode
// Synch Break
serial_pause(13);
// Send data via Serial interface
if(ch==1){ // For LIN1 or Serial1
Serial1.begin(bound_rate); // config Serial
Serial1.write(0x55); // write Synch Byte to serial
Serial1.write(ident); // write Identification Byte to serial
for(int i=0;i<data_size;i++) Serial1.write(data[i]); // write data to serial
Serial1.write(checksum); // write Checksum Byte to serial
Serial1.end(); // clear Serial config
Und nur die Dinge wie das LIN-Break macht sie durch Bitbanging.
int lin_stack::serial_pause(int no_bits){
// Calculate delay needed for 13 bits, depends on bound rate
unsigned int del = period*no_bits; // delay for number of bits (no-bits) in microseconds, depends on period
if(ch=2){
PIOA->PIO_PER = PIO_PA13; // enable PIO register
PIOA->PIO_OER = PIO_PA13; // enable PA13 as output
PIOA->PIO_CODR = PIO_PA13; // clear PA13
delayMicroseconds(del); // delay
PIOA->PIO_SODR = PIO_PA13; // set pin high
PIOA->PIO_PDR = PIO_PA13; // clear configuration for PIO, needs to be done because Serial wont work with it
}else if(ch=1){
PIOA->PIO_PER = PIO_PA11; // enable PIO register
PIOA->PIO_OER = PIO_PA11; // enable PA11 as output
PIOA->PIO_CODR = PIO_PA11; // clear PA11
delayMicroseconds(del); // delay
PIOA->PIO_SODR = PIO_PA11; // set pin high
PIOA->PIO_PDR = PIO_PA11; // clear configuration for PIO, needs to be done because Serial wont work with it
Ich bin mir nur nicht sicher, wie das Starbit bei deinem Protokoll da hineinpasst.
Bei Teensy würde ich mich wohl an Beispielen orientieren, wo über PIT-Timer und DMA beliebige Bitfolgen über Pins ausgegeben werden. Bin aber weit davon entfernt, dass a) mal eben so hinzuschreiben oder b) auf den Due umzuschreiben.