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

📄 console.c

📁 Samsugn 6400 NAND boot code
💻 C
字号:
/**************************************************************************************
* 
*	Project Name : S3C6400 Validation
*
*	Copyright 2006 by Samsung Electronics, Inc.
*	All rights reserved.
*
*	Project Description :
*		This software is only for validating functions of the S3C6400.
*		Anybody can use this software without our permission.
*  
*--------------------------------------------------------------------------------------
* 
*	File Name : Console.c
*  
*	File Description : This file implements the functons for UART Debug&LED setting.
*
*	Author : Heemyung.noh
*	Dept. : AP Development Team
*	Created Date : 2007/02/02
*	Version : 0.1 
* 
*	History
*	- Created(Heemyung.noh 2007/02/02)
*  
**************************************************************************************/

#include "Option.h"
#include "sfr6400.h"
#include "System.h"



//===========================[ UART ]==============================

volatile unsigned int DebugUartCh=1;

unsigned int Uart_putc(unsigned int c) // edited by junon 060530
{
	if(c=='\n') {
		while(!(rUTRSTAT0 & 0x2));
		WrUTXH0('\r');
	}
	while(!(rUTRSTAT0 & 0x2));	 //Wait until THR is empty.
	WrUTXH0(c);
	return c;
}

int Uart_puts( const char *s)
{
	while(*s!=0) Uart_putc( *s++);
	return 0;	
}

void Uart_Init(unsigned int pclk,unsigned int baud)
{
	rGPACON 	= 	0x22;
  
	if(pclk == 0)    pclk    = g_PCLK;

	rUFCON0 = 0x0;   //UART channel 0 FIFO control register, FIFO disable
	rUMCON0 = 0x0;   //UART chaneel 0 MODEM control register, AFC disable
    
	rULCON0 = 0x3;   //Line control register : Normal,No parity,1 stop,8 bits
    
	//    [10]       [9]     		[8]		[7]        		[6]		[5]			[4]			[3:2]			[1:0]
	// Clock Sel  Tx Int  	Rx Int	Rx Time Out	Rx err 	Loop-back	Send break	Transmit Mode	Receive Mode
	//     0          1       		0         	0          		1        	0           		0            		01          			01
	//   PCLK       Level    	Pulse   	Disable    	Generate Normal      	Normal        	     Interrupt or Polling
	rUCON0  = 0x245;   // Control register


	if(g_PCLK == 25000000)
	{
		rUBRDIV0 = 12; 			//(pclk/16/baud) - 1;
		rUDIVSLOT0 = 0x0777;		// num of 1's = 16*0.9
	}
	else if(g_PCLK == 33250000)
	{
		rUBRDIV0 = 17; 			//(pclk/16/baud) - 1;
		rUDIVSLOT0 = 0x0;		// num of 1's = 16*0.9
	}
	else if(g_PCLK == 50000000)
	{
		rUBRDIV0 = 26; 		//(pclk/16/baud) - 1;
		rUDIVSLOT0 = 0x03;		// num of 1's = 16*0.9		
	}
}

//////////
// Function Name : InitLED
// Function Desctiption : This function initializes gpio for debugging LED
// Input : NONE
// Output : NONE
// Version :
void InitLED(void)
{
	rGPNCON = (rGPNCON & ~(0xff<<24)) | (0x55<<24);
	return;
}

//////////
// Function Name : DisplayLED
// Function Desctiption : This function controls debugging LED
// Input : data, LED value 
// Output : NONE
// Version :
void DisplayLED(u8 data)
{
	rGPNDAT = (rGPNDAT & ~(0xf<<12)) | (data<<12);
}


⌨️ 快捷键说明

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