📄 library.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 : library.c
*
* File Description : This file implements library functions.
*
* Author : Haksoo,Kim
* Dept. : AP Development Team
* Created Date : 2006/11/08
* Version : 0.1
*
* History
* - Created(Haksoo,Kim 2006/11/08)
*
**************************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "option.h"
#include "library.h"
#include "sfr6400.h"
#include "system.h"
#include "uart.h"
#include "gpio.h"
//////////
// Function Name : InitUartPort
// Function Description : This function initializes gpio for debugging uart ch.
// Input : ch, uart ch number
// flowControl, whether flow control or not
// Output : NONE
// Version :
void InitUartPort(u8 ch, bool flowControl)
{
switch (ch)
{
default:
case 0:
if(flowControl == TRUE)
{
GPIO_SetFunctionEach(eGPIO_A, eGPIO_0, 2);
GPIO_SetFunctionEach(eGPIO_A, eGPIO_1, 2);
GPIO_SetFunctionEach(eGPIO_A, eGPIO_2, 2);
GPIO_SetFunctionEach(eGPIO_A, eGPIO_3, 2);
}
else
{
GPIO_SetFunctionEach(eGPIO_A, eGPIO_0, 2);
GPIO_SetFunctionEach(eGPIO_A, eGPIO_1, 2);
}
break;
case 1:
if(flowControl == TRUE)
{
GPIO_SetFunctionEach(eGPIO_A, eGPIO_4, 2);
GPIO_SetFunctionEach(eGPIO_A, eGPIO_5, 2);
GPIO_SetFunctionEach(eGPIO_A, eGPIO_6, 2);
GPIO_SetFunctionEach(eGPIO_A, eGPIO_7, 2);
}
else
{
GPIO_SetFunctionEach(eGPIO_A, eGPIO_4, 2);
GPIO_SetFunctionEach(eGPIO_A, eGPIO_5, 2);
}
break;
case 2:
GPIO_SetFunctionEach(eGPIO_B, eGPIO_0, 2);
GPIO_SetFunctionEach(eGPIO_B, eGPIO_1, 2);
break;
case 3:
GPIO_SetFunctionEach(eGPIO_B, eGPIO_2, 2);
GPIO_SetFunctionEach(eGPIO_B, eGPIO_3, 2);
break;
}
return;
}
//////////
// Function Name : InitLED
// Function Desctiption : This function initializes gpio for debugging LED
// Input : NONE
// Output : NONE
// Version :
void InitLED(void)
{
GPIO_SetFunctionEach(eGPIO_N, eGPIO_12, 1);
GPIO_SetFunctionEach(eGPIO_N, eGPIO_13, 1);
GPIO_SetFunctionEach(eGPIO_N, eGPIO_14, 1);
GPIO_SetFunctionEach(eGPIO_N, eGPIO_15, 1);
return;
}
//////////
// Function Name : DisplayLED
// Function Desctiption : This function controls debugging LED
// Input : data, LED value
// Output : NONE
// Version :
void DisplayLED(u8 data)
{
u32 temp;
temp = GPIO_GetDataAll(eGPIO_N);
temp = (temp & ~(0xf000))|((data&0xf)<<12);
GPIO_SetDataAll(eGPIO_N, temp);
return;
}
//////////
// Function Name : OpenConsole
// Function Description : This function opens uart and LED for debugging
// Input : NONE
// Output : NONE
// Version :
void OpenConsole( void)
{
u8 ch=0; //uart channel for debugging
InitUartPort(ch, FALSE);
UART_InitDebugCh(ch, 115200);
InitLED();
return;
}
//////////
// Function Name : CalibrateDelay
// Function Description : This function calibrates delayLoopCount as about 100us
// Input : NONE
// Output : NONE
// Version :
static u32 delayLoopCount;
void CalibrateDelay(void)
{
delayLoopCount = g_ARMCLK/30000;
}
//////////
// Function Name : Delay
// Function Description :
// Input : uTime, time in 100us unit
// Output : NONE
// Version :
void Delay(u32 uTime)
{
u32 i=0,j=delayLoopCount;
for(;uTime>0;uTime--)
{
for(;i<j;i++);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -