summaryrefslogtreecommitdiff
path: root/src/MSL_C.PPCEABI.bare.H/uart_console_io.c
blob: 1aff7dc830f3285780d9015e29cfcc0bfaa6927e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "console_io.h"

int __TRK_write_console(__file_handle handle, unsigned char* buffer, size_t* count,
                        __idle_proc idle_proc);

static inline int __init_uart_console(void) {
  int err = 0;
  static int initialized = 0;

  if (initialized == 0) {
    err = InitializeUART(57600);

    if (err == 0)
      initialized = 1;
  }

  return (err);
}
int __write_console(__file_handle handle, unsigned char* buffer, size_t* count,
                    __idle_proc idle_proc) {
  if (__init_uart_console() != 0) {
    return 1;
  }

  if (WriteUARTN(buffer, *count) != 0) {
    *count = 0;
    return 1;
  }

  __TRK_write_console(handle, buffer, count, idle_proc);
  return 0;
}

int __close_console() { return 0; }