Serial.Attach

01 Feb 2010

It would be nice to get interrupt notifications when the serial port has writing a byte or the output queue is empty in addition to when a byte is received.  

 

01 Feb 2010

Hi Eli,

Thanks; ticketed. We'll look at a nice way of doing this.

If you have a particular use case that you could provide some pseudo-code for that would be useful (i.e. write a program as if it existed, to demonstrate the way you'd like to use it).

Thanks!

Simon

02 Feb 2010

Here is my current code.    I have my own large software byte queues for Tx and Rx.    I can use the Rx interrupt to fill my incoming byte queue byte but need a ticker to periodcally check to see if I can move data from my software queue to the tx hardware:

 

//*****************************  Code Start

#include"System.h"

ByteQueue PCBackDoorTx,PCBackDoorRx;
BYTE PCBackDoorTx_Queue_Storage[PC_BACKDOOR_QUEUE_SIZE];
BYTE PCBackDoorRx_Queue_Storage[PC_BACKDOOR_QUEUE_SIZE];

Serial PCBackDoor(USBTX, USBRX);
Ticker PCBackDoorTxQueueCheck;

//IRQ for when data is received
void PCBackDoorRxIRQ();

void InitPCBackDoor()
{
InitByteQueue(&PCBackDoorTx,PC_BACKDOOR_QUEUE_SIZE,&PCBackDoorTx_Queue_Storage[0]);
InitByteQueue(&PCBackDoorRx,PC_BACKDOOR_QUEUE_SIZE,&PCBackDoorRx_Queue_Storage[0]);

PCBackDoor.baud(57600);
PCBackDoor.format(8,Serial::None,1); 


//The Rx IRQ wil fill up my big software Rx Queue
PCBackDoor.attach(PCBackDoorRxIRQ);

//Periodicically check my outgoing Tx Queue (every 10 mS)
PCBackDoorTxQueueCheckTicker.attach_us(&PCBackDoorMoveTxQueue,10000);
}

void PCBackDoorMoveTxQueue()
{
BYTE Temp;

while(PCBackDoor.writeable())
{
if(BytesInQueue(&PCBackDoorTx) == 0)
{
break;
}
else
{
ByteDequeue(&PCBackDoorTx,&Temp);
PCBackDoor.putc(Temp);
}
}
}

void PCBackDoorRxIRQ()
{
while(PCBackDoor.readable())
{
ByteEnqueue(&PCBackDoorRx,(BYTE)PCBackDoor.getc());  
}
}

 

 

//************************Code end

 

 

What I would like is some sort of notification that the last transmission has been completed so I don't need the periodic timer calls to poll to see if the serial port is writeable.