| 123456789101112131415161718192021222324252627282930313233 |
- #include "io.h"
- #include "serial.h"
- #include "timer.h"
- #include "idle.h"
- void program_serial_loop_main(const char *arg)
- {
- unsigned int port = SERIAL_COM1;
- unsigned int last_send;
- const char msg[] = "hello serial\r\n";
- (void)arg;
- serial_init(port);
- last_send = get_ticks_ms();
- for (;;) {
- unsigned int now = get_ticks_ms();
- if (now - last_send >= 1000) {
- last_send = now;
- serial_puts(port, msg);
- }
- while (serial_has_data(port)) {
- char c = serial_getc_nb(port);
- if (c)
- io_putchar(c);
- }
- cpu_idle();
- }
- }
|