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

📄 sermx1.c

📁 QNX ADS BSP code for i.MX27 chips
💻 C
字号:
/* * $QNXLicenseC:  * Copyright 2007, QNX Software Systems.   *   * Licensed under the Apache License, Version 2.0 (the "License"). You   * may not reproduce, modify or distribute this software except in   * compliance with the License. You may obtain a copy of the License   * at: http://www.apache.org/licenses/LICENSE-2.0   *   * Unless required by applicable law or agreed to in writing, software   * distributed under the License is distributed on an "AS IS" basis,   * WITHOUT WARRANTIES OF ANY KIND, either express or implied.  *  * This file may contain contributions from others, either as   * contributors under the License or as licensors under other terms.    * Please review this entire file for other proprietary rights or license   * notices, as well as the QNX Development Suite License Guide at   * http://licensing.qnx.com/license-guide/ for other information.  * $  */#include "ipl.h"#include <hw/inout.h>#include <arm/mx1.h>static unsigned char	mx1uart_pollkey();static unsigned char	mx1uart_getchar();static void				mx1uart_putchar(unsigned char);static const ser_dev mx1_dev = {	mx1uart_getchar,	mx1uart_putchar,	mx1uart_pollkey};static unsigned mx1_uart;voidinit_sermx1(unsigned port, unsigned baud, unsigned clk){	/* Enable UART clock, Disable UART */	out32(port + MX1_UART_CR1, MX1_UCR1_UARTCLKEN);	/* Reset UART */	out32(port + MX1_UART_CR2, 0);	/* 	 * 8-bit, no-parity, 1 stop bit	 * ignore RTS, active CTS	 */	out32(port + MX1_UART_CR2, 0x5021);	out32(port + MX1_UART_CR3, 4);	out32(port + MX1_UART_CR4, 0x41);	/*	 * We assume the clock is 44.333MHz, and baud rate is 115200 bps	 */	out32(port + MX1_UART_FCR, 0x0A01);	out32(port + MX1_UART_BIR, 0x033E);	out32(port + MX1_UART_BMR, 0x270F);	/* Enable UART */	out32(port + MX1_UART_CR1, MX1_UCR1_UARTCLKEN | MX1_UCR1_UARTEN);	/* Enable Tx/Rx */	out32(port + MX1_UART_CR2, 0x5027);	mx1_uart = port;	/*	 * Register our debug functions	 */	init_serdev((ser_dev *)&mx1_dev);}static unsigned char mx1uart_pollkey(void){	if (in32(mx1_uart + MX1_UART_SR2) & MX1_USR2_RDR)		return 1;	else		return 0;}static unsigned char mx1uart_getchar(void){	while (!(mx1uart_pollkey()))		;	return ((unsigned char)in32(mx1_uart + MX1_UART_RXDATA));}static void mx1uart_putchar(unsigned char data){	while (!(in32(mx1_uart + MX1_UART_SR1) & MX1_USR1_TRDY))		;	out32(mx1_uart + MX1_UART_TXDATA, (unsigned)data);}

⌨️ 快捷键说明

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