e2db80c4f7cd4e4eb6dc35dedab04d58b031300f
[AROS.git] / arch / arm-raspi / kernel / maygetchar.c
blobe2db80c4f7cd4e4eb6dc35dedab04d58b031300f
1 /*
2 Copyright © 2013, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <aros/kernel.h>
8 #include <asm/bcm2835.h>
9 #include <hardware/pl011uart.h>
11 #include <kernel_base.h>
12 #include <kernel_debug.h>
14 /*****************************************************************************
16 NAME */
17 #include <proto/kernel.h>
19 AROS_LH0(int, KrnMayGetChar,
21 /* SYNOPSIS */
23 /* LOCATION */
24 struct KernelBase *, KernelBase, 26, Kernel)
26 /* FUNCTION
27 Read a single character from low-level debug input stream
29 INPUTS
30 None
32 RESULT
33 An ASCII code of the character or -1 if there's no character
34 available
36 NOTES
37 This function never waits. If there is no character available on
38 the stream it just returns with -1
40 EXAMPLE
42 BUGS
44 SEE ALSO
46 INTERNALS
48 ******************************************************************************/
50 AROS_LIBFUNC_INIT
52 if ((*(volatile uint32_t *)(PL011_0_BASE + PL011_FR) & PL011_FR_RXFE) == 0)
53 return (int)*(volatile uint32_t *)(PL011_0_BASE + PL011_DR);
55 return -1;
57 AROS_LIBFUNC_EXIT