/*
* uart0.c - uart0 api & driver
*
* Board: akae2440
* environment: bootloader & ADS
* Author: akaedu
* Date: 2009-5-26
* web: www.akaedu.org
*
*
* GPIO address_MAP
*
* CPLD_MAP_BASE physical address is 0x20800000
* CPLD_LED physical address is 0x20800000
* CPLD_SEG physical address is 0x20800080
* CPLD_DIP physical address is 0x208000a0
*
* GPIO port_MAP
*
* GPA_PORT~GPB_PORT(130 multi-functional input port pins)
* GPIO_BASE : GPACON : 0x56000000
*
* NAME GPIO CPLD_IN CPLD_OUT GPIO_CON MODE_bit_CON GPIO_DAT MODE_bit_DAT
* BEEP GPB0 TOUT0 BEEP 0x56000010 [1:0] 0x56000014 [0]
*
* GPIO key_scn_MAP
*
* NAME PORT_OUT PORT_IN
* KEY(sw1) KBOUT1 : GPB8 KBIN1 : ENT0 : GPF0
* KEY(sw2) KBOUT0 : GPB9 KBIN1 : ENT0 : GPF0
* KEY(sw3) KBOUT1 : GPB8 KBIN0 : ENT2 : GPF2
* KEY(sw4) KBOUT1 : GPB8 KBIN1 : ENT2 : GPF2
*
* GPIO_CON GPIO_DAT GPIO MODE_bit_CON MODE_bit_DAT
* GPBCON : 0x56000010 GPBDAT : 0x56000014 GPB8 [17:16] [8]
* GPBCON : 0x56000010 GPBDAT : 0x56000014 GPB9 [19:18] [9]
* GPFCON : 0x56000050 GPBDAT : 0x56000054 GPF0 [1:0] [0]
* GPFCON : 0x56000050 GPBDAT : 0x56000054 GPF2 [5:4] [2]
*
* UART
* ULCON0 : 0x50000000
* UCON0 : 0x50000004
* UFCON0 : 0x50000008
* UMCON0 : 0x5000000c
* UTRSTAT0 : 0x50000010
* UERSTAT0 : 0x50000014
* UFSTAT0 : 0x50000018
* UMSTAT0 : 0x5000001c
* UTXH0 : 0x50000020
* URXH0 : 0x50000024
* UBRDIV0 : 0x50000028
*
*
*/
#include "uart0.h"
/*uart Special Registers off_size*/
#define UART0_BASE (0x50000000)
#define UART1_BASE (0x50004000)
#define ULCON 0x00
#define UCON 0x04
#define UFCON 0x08
#define UMCON 0x0c
#define UTRSTAT 0x10
#define UERSTAT 0x14
#define UFSTAT 0x18
#define UMSTAT 0x1c
#define UTXH 0x20
#define URXH 0x24
#define UBRDIV 0x28
/* UART Status Register bits */
#define UTRSTAT_T_EMPTY (1 << 2)
#define UTRSTAT_BUF_EMPTY (1 << 1)
#define UTRSTAT_R_READY (1 << 0)
#define ULCON0 *((volatile unsigned int *)(UART0_BASE+ULCON))
#define UCON0 *((volatile unsigned int *)(UART0_BASE+UCON))
#define UFCON0 *((volatile unsigned int *)(UART0_BASE+UFCON))
#define UMCON0 *((volatile unsigned int *)(UART0_BASE+UMCON))
#define UBRDIV0 *((volatile unsigned int *)(UART0_BASE+UBRDIV))
#define UTRSTAT0 *((volatile unsigned int *)(UART0_BASE+UTRSTAT))
#define UTXH0 *((volatile unsigned int *)(UART0_BASE+UTXH))
#define URXH0 *((volatile unsigned int *)(UART0_BASE+URXH))
/*
#define ULCON0 *((volatile unsigned int *)0x50000000)
#define UCON0 *((volatile unsigned int *)0x50000004)
#define UFCON0 *((volatile unsigned int *)0x50000008)
#define UMCON0 *((volatile unsigned int *)0x5000000c)
#define UBRDIV0 *((volatile unsigned int *)0x50000028)
#define UTRSTAT0 *((volatile unsigned int *)0x50000010)
#define UTXH0 *((volatile unsigned int *)0x50000020)
#define URXH0 *((volatile unsigned int *)0x50000024)
*/
#define GPHCON *((volatile unsigned int *)0x50000070)
int uart0_init(void)
{
/* 8 N 1 */
ULCON0=3;
/* interrupt request or polling mode */
UCON0 = 5;
/* init UFCON0 UMCON0 */
UFCON0 = 0;
UMCON0 = 0;
/* configure GPH2:TDX[0] GPH3:RDX[0]*/
GPHCON |=0xa0;
/*
* UBRDIV = PCLK/(baudrate * 16) - 1
* PCLK = 50.7Mhz
*
* baudrate 115200
*/
UBRDIV0 = 26;
return 0;
}
char uart0_getchar(void)
{
char ch;
while (!(UTRSTAT0 & UTRSTAT_R_READY))
;
ch = URXH0;
return ch;
}
int uart0_putchar(char ch)
{
while (!(UTRSTAT0 & UTRSTAT_T_EMPTY))
;
UTXH0= ch;
return 0;
}
int uart0_test(void)
{
char ch;
uart0_init();
while(1)
{
ch = uart0_getchar();
uart0_putchar(ch);
}
return 0;
}
没有合适的资源?快使用搜索试试~ 我知道了~
s3c2440_example.rar_five58b_iar S3C2440 example_s3c2440_s3c2440
共91个文件
tdt:21个
o:19个
c:17个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 3 浏览量
2022-09-21
06:25:35
上传
评论
收藏 199KB RAR 举报
温馨提示
s3c2440 裸板例子, 常用的都在这里啦
资源推荐
资源详情
资源评论
收起资源包目录
s3c2440_example.rar (91个子文件)
s3c2440 example
timer0_test
timer0_test_Data
Release
TargetDataWindows.tdt 52KB
CWSettingsWindows.stg 3KB
Debug
TargetDataWindows.tdt 53KB
DebugRel
ObjectCode
beep.o 6KB
timer.o 5KB
main.o 5KB
TargetDataWindows.tdt 55KB
timer0_test.axf 9KB
main.c 116B
timer0.h 244B
beep.c 2KB
timer0_test.mcp 193KB
beep.h 277B
timer.c 2KB
dip_test
dip.c 2KB
main.c 110B
dip_test_Data
Release
TargetDataWindows.tdt 53KB
CWSettingsWindows.stg 3KB
Debug
TargetDataWindows.tdt 54KB
DebugRel
ObjectCode
seg7_test.o 7KB
seg7.o 8KB
dip.o 7KB
main.o 5KB
dip_test.axf 9KB
TargetDataWindows.tdt 60KB
seg7.c 2KB
dip.h 259B
dip_test.mcp 193KB
seg7.h 2KB
key_test
key.h 254B
main.c 113B
led.h 325B
led.c 2KB
key.c 2KB
key_test_Data
Release
TargetDataWindows.tdt 52KB
CWSettingsWindows.stg 3KB
Debug
TargetDataWindows.tdt 54KB
DebugRel
ObjectCode
led.o 6KB
key.o 6KB
main.o 5KB
key_test.axf 10KB
TargetDataWindows.tdt 58KB
key_test.mcp 195KB
led_test
led_test_Data
Release
TargetDataWindows.tdt 53KB
CWSettingsWindows.stg 3KB
Debug
TargetDataWindows.tdt 54KB
DebugRel
led_test.bin 496B
ObjectCode
led.o 6KB
main.o 5KB
led_test.axf 8KB
TargetDataWindows.tdt 55KB
main.c 110B
led.h 325B
led.c 2KB
led_test.mcp 193KB
beep_test
beep_test_Data
Release
TargetDataWindows.tdt 53KB
CWSettingsWindows.stg 3KB
Debug
TargetDataWindows.tdt 54KB
DebugRel
ObjectCode
beep.o 6KB
main.o 5KB
beep_test.axf 7KB
TargetDataWindows.tdt 56KB
main.c 112B
beep_test.mcp 193KB
beep.c 2KB
beep.h 277B
uart0_test
main.c 114B
uart0_test.mcp 193KB
uart0_test_Data
Release
TargetDataWindows.tdt 53KB
CWSettingsWindows.stg 3KB
Debug
TargetDataWindows.tdt 54KB
DebugRel
uart0_test.axf 8KB
ObjectCode
uart0.o 6KB
main.o 5KB
uart0_test.bin 392B
TargetDataWindows.tdt 55KB
uart0.c 4KB
uart0.h 300B
seg7_test
seg7_test_Data
Release
TargetDataWindows.tdt 53KB
CWSettingsWindows.stg 3KB
Debug
TargetDataWindows.tdt 54KB
DebugRel
ObjectCode
seg7_test.o 7KB
seg7.o 6KB
main.o 5KB
seg7_test.axf 7KB
seg7_test.bin 436B
TargetDataWindows.tdt 55KB
main.c 114B
seg7.c 2KB
seg7_test.mcp 193KB
seg7.h 320B
共 91 条
- 1
资源评论
刘良运
- 粉丝: 66
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功