⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 serial.h

📁 * The functions debug_init() and debug() implement non-RTOS * serial port initialization and a blo
💻 H
字号:
/**
 * \file serial.h
 * \brief Serial port API
 *
 * The functions debug_init() and debug() implement non-RTOS
 * serial port initialization and a blocked debug output. The
 * debug() function can be used in 'error message and die'
 * situations.
 */
#ifndef SERIAL_H
#define SERIAL_H

#include <stdint.h>

/* Serial port debug interface */
void debug_init();

void debug(char *msg);

/* Serial port RTOS interface */
int32_t serial_init();

/* Read a character from the serial port */
int32_t serial_getchar();

/* Write a character to the serial port */
int32_t serial_putchar(int8_t ch);

/* Write a string to the serial port */
int32_t serial_puts(int8_t *msg);

/* Read a string */
int32_t serial_gets(int8_t *msg, uint32_t max);

/* Serial port configuration.
 *
 * UART1 configuration: Ch 9 pp101-114 User Manual.
 *
 * The LPC213x devices use the VPB clock to generate
 * a 16x baud-rate clock reference to the UART.
 *
 * Examples:
 * VPB clock = 15MHz.
 *
 * Baud rate   Divisor
 * ---------   -------
 *    9600		 97
 *   14400		 65
 *   19200		 48
 *   38400		 24
 *   57600		 16
 *  115200		  8
 *
 * and the VPB clock could be 60MHz on the LPC devices,
 * it just happens to reset to CPU clock divided by 4.
 */
#define SERIAL_CLOCK (15000000/16)
#define SERIAL_PARITY_NONE       0
#define SERIAL_PARITY_ODD        1
#define SERIAL_PARITY_EVEN       2
#define SERIAL_PARITY_FORCE_ONE  3
#define SERIAL_PARITY_FORCE_ZERO 4

int32_t serial_config(
	uint32_t baud_rate,
	uint32_t data_width,
	uint32_t stop_bits,
	uint32_t parity);

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -