📄 scc_uart.h
字号:
#ifndef __SCC_UART_H
#define __SCC_UART_H
/*#include "simple.h"*/
/*
* transmit BD's
*/
#define T_R 0x8000 /* ready bit */
#define T_W 0x2000 /* wrap bit */
#define T_I 0x1000 /* interrupt on completion */
#define T_CR 0x0800 /* clear to send report */
#define T_A 0x0400 /* address characters in buffer */
#define T_CM 0x0200 /* continuous mode */
#define T_P 0x0100 /* send preamble before data */
#define T_NS 0x0080 /* no stop bit in transmit */
#define T_CT 0x0001 /* error: CTS lost */
#ifndef T_ERROR
#define T_ERROR T_CT
#endif
/*
* receive BD's
*/
#define R_E 0x8000 /* buffer empty */
#define R_W 0x2000 /* wrap bit */
#define R_I 0x1000 /* interrupt on reception */
#define R_C 0x0800 /* buffer contains control character */
#define R_A 0x0400 /* buffer contains address character */
#define R_CM 0x0200 /* continuous mode */
#define R_ID 0x0100 /* buffer closed due to idles */
#define R_AM 0x0080 /* address match */
#define R_BR 0x0020 /* break character received */
#define R_FR 0x0010 /* framing error */
#define R_PR 0x0008 /* parity error */
#define R_OV 0x0002 /* receive overrun */
#define R_CD 0x0001 /* carrier detect lost */
#ifndef R_ERROR
#define R_ERROR (R_BR | R_FR | R_PR | R_OV | R_CD)
#endif
/*
* UART Specific PRAM
*/
#define UART_TOSEQ_REA 0x2000
#define UART_TOSEQ_I 0x1000
#define UART_TOSEQ_CT 0x0800
#define UART_TOSEQ_A 0x0100
#define UART_LAST_CHAR 0x8000
#define UART_REJECT_CHAR 0x4000
#define UART_RCCM (0x00FF | UART_LAST_CHAR | UART_REJECT_CHAR)
/*
* UART PSMR (Protocol Specific Mode register)
*/
#define UART_PSMR_FLC 0x8000
#define UART_PSMR_SL 0x4000
#define UART_PSMR_CL5 (0x0<<12)
#define UART_PSMR_CL6 (0x1<<12)
#define UART_PSMR_CL7 (0x2<<12)
#define UART_PSMR_CL8 (0x3<<12)
#define UART_PSMR_UM_NORM (0x0<<10)
#define UART_PSMR_UM_MULT (0x1<<10)
#define UART_PSMR_UM_MULT_AUTO (0x3<<10)
#define UART_PSMR_FRZ 0x0200
#define UART_PSMR_RZS 0x0100
#define UART_PSMR_SYN 0x0080
#define UART_PSMR_DRT 0x0040
#define UART_PSMR_PEN 0x0010
#define UART_PSMR_RPM_ODD (0x0<<2)
#define UART_PSMR_RPM_LOW (0x1<<2)
#define UART_PSMR_RPM_EVEN (0x2<<2)
#define UART_PSMR_RPM_HIGH (0x3<<2)
#define UART_PSMR_TPM_ODD 0x0
#define UART_PSMR_TPM_LOW 0x1
#define UART_PSMR_TPM_EVEN 0x2
#define UART_PSMR_TPM_HIGH 0x3
/*
* uart interrupts
*/
#define UART_GLr 0x1000 /* Glitch on rx */
#define UART_GLt 0x0800 /* Glitch on tx */
#define UART_AB 0x0200 /* Auto band */
#define UART_IDL 0x0100 /* idle sequence status changed */
#define UART_GRA 0x0080 /* Graceful stop complete */
#define UART_BRKe 0x0040 /* break end */
#define UART_BRKs 0x0020 /* break start */
#define UART_CCR 0x0008 /* control character received */
#define UART_BSY 0x0004 /* busy */
#define UART_TX 0x0002 /* transmit buffer */
#define UART_RX 0x0001 /* receive buffer */
#define UART_ERROR (UART_GLr | UART_GLt | UART_AB)
/*
* uart specific structure
*/
typedef struct {
unsigned char reject; /* reject the character */
unsigned char ch; /* control character */
void (*user_func)(int); /* pointer to routine associated with the cc */
} CONT_CHAR;
#define NULL_USER_FUNC ((void (*)(int))0)
typedef enum {
PARITY_NO, PARITY_ODD, PARITY_LOW, PARITY_EVEN, PARITY_HIGH
} PARITY;
#define CC_MAX 8
typedef struct {
unsigned short max_frame_length;
PARITY parity; /* Parity control flag. */
unsigned short data; /* Number of data bits. */
unsigned short stop; /* Number of stop bits. */
unsigned long baud; /* Baud rate */
unsigned short number_of_cc;/* Number of control character to be handled. */
CONT_CHAR cc[CC_MAX];
} UART_SPECIFIC;
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -