Altera Embedded Peripherals IP Manuale Utente Pagina 78

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 336
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 77
Table 8-3: Example: Sending and Receiving Characters
/* A simple program that recognizes the characters 't' and 'v' */
#include <stdio.h>
#include <string.h>
int main ()
{
char* msg = "Detected the character 't'.\n";
FILE* fp;
char prompt = 0;
fp = fopen ("/dev/uart1", "r+"); //Open file for reading and writing
if (fp)
{
while (prompt != 'v')
{ // Loop until we receive a 'v'.
prompt = getc(fp); // Get a character from the UART.
if (prompt == 't')
{ // Print a message if character is 't'.
fwrite (msg, strlen (msg), 1, fp);
}
}
fprintf(fp, "Closing the UART file.\n");
fclose (fp);
}
return 0;
}
For more information about the HAL system library, refer to the Nios II Software Developer's
Handbook.
Driver Options: Fast vs Small Implementations
To accommodate the requirements of different types of systems, the UART driver provides two variants: a
fast version and a small version. The fast version is the default. Both fast and small drivers fully support
the C standard library functions and the HAL API.
The fast driver is an interrupt-driven implementation, which allows the processor to perform other tasks
when the device is not ready to send or receive data. Because the UART data rate is slow compared to the
processor, the fast driver can provide a large performance benefit for systems that could be performing
other tasks in the interim.
UG-01085
2014.24.07
Driver Options: Fast vs Small Implementations
8-9
UART Core
Altera Corporation
Send Feedback
Vedere la pagina 77
1 2 ... 73 74 75 76 77 78 79 80 81 82 83 ... 335 336

Commenti su questo manuale

Nessun commento