Omnimaga

Calculator Community => TI Calculators => Calculator C => Topic started by: compu on July 27, 2011, 06:19:26 am

Title: Non-blocking serial read-function?
Post by: compu on July 27, 2011, 06:19:26 am
I have a small question about Nspire C:
Is there a non-blocking function to check if data is available for reading at the serial port?
Title: Re: Non-blocking serial read-function?
Post by: ExtendeD on July 30, 2011, 02:59:32 am
You will have to use direct I/O access. It's not different than doing it from a computer: http://hackspire.unsads.com/wiki/index.php/Memory-mapped_I/O_ports#90020000_-_Serial_UART

Here is a code snippet that was once used in Ndless, equivalent to puts():

Code: [Select]
void ut_puts(const char *str) {
volatile unsigned *line_status_reg = (unsigned*)0x90020014;
volatile unsigned *xmit_holding_reg = (unsigned*)0x90020000;
while(*str) {
while(!(*line_status_reg & 0b100000)); // wait for empty xmit holding reg
*xmit_holding_reg = *str++;
}
}
Title: Re: Non-blocking serial read-function?
Post by: compu on July 30, 2011, 06:20:26 am
Thank you! :)