📄 uart.c
字号:
#include "includes.h"
#include "ipport.h"
#include "dlcs.h"
#include "at_core.h"
#include "uart_drv.h"
#ifdef dputchar
#undef dputchar
#endif
#define UART_KB 1
#define BAUD_KB 57600L
int
uart_init(int unit)
{
unit = unit;
/* uarts_init(UART_MODEM, BAUD_MODEM);*/
return 0; /* OK return */
}
/* void uart_putc(unit, char) - puts a byte out serial port.
Returns 0 in AX if OK, else -1 if RDY timeout.
*/
int
uart_putc(int unit, u_char outchar)
{
unit = unit;
/* uarts_write(UART_MODEM, outchar);*/
WriteBytetoDLC(DLC_GPRS, outchar);
return 0;
}
/* uart_getc() - get the next character from the uart input buffer.
Returns a 16 or 32 bit value. If a char is ready, the upper bits are zero
and the lower 8 bits have the byte value. If no char is ready, all bits
are SET (ie, 16 bit value is 0xFFFF)
*/
int
uart_getc(int unit)
{
unit = unit;
/* return uarts_read(UART_MODEM);*/
return ReadBytefromDLC(DLC_GPRS);
}
/* uart_ready() - Returns true (0xFFFF) if UART is ready to send
a character, FALSE (0) if not. This allows a non-blocking UART send
routine to be written in C.
*/
int
uart_ready(int unit)
{
unit = unit;
/* return uarts_ready(UART_MODEM);*/
if (CanWriteDLC(DLC_GPRS)) return -1;
else return 0;
}
/* void uart_close(void) - shut down UART */
void uart_close(int unit)
{
unit = unit;
//dprintf("uart_close!");
}
int
uart_stats(void * pio, int unit)
{
pio = pio;
unit = unit;
return 0;
}
void
initkb(void)
{
/*#if EN_LCD == 0
uarts_init(UART_KB, BAUD_KB);
#endif */
}
/* dputchar() - this is the port-dependant portion of the ttyio system.
* Output to dprintf() ends up here.
For the Samsung board, we use UART 0.
*/
void
dputchar(int c) /* char to send to dstdio */
{
#if EN_LCD == 0
if (c == '\n') {
SendFromUART_BYTE(UART_KB, 0x0d);
SendFromUART_BYTE(UART_KB, 0x0a);
// uarts_write(UART_KB, 0x0d);
// uarts_write(UART_KB, 0x0a);
} else {
SendFromUART_BYTE(UART_KB, c);
// uarts_write(UART_KB, c);
}
#else
c = c;
#endif
}
int
kbhit(void)
{
#if EN_LCD == 0
// if (uarts_recv(UART_KB)) return -1;
// else
return 0;
#else
return 0;
#endif
}
int
getch(void)
{
#if EN_LCD == 0
return -1;
return uarts_read(UART_KB);
#else
return -1;
#endif
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -