📄 gpio.c
字号:
//
// Copyright (c) Samsung Electronics. All rights reserved.
//
//------------------------------------------------------------------------------
//
// File: gpio.c
//
// This file implement part of GPIO module for SMDK24A0 SoC.
//
#include <windows.h>
#include <ceddk.h>
#include <nkintr.h>
#include <oal.h>
#include <s3c24A0.h>
#include <s3c24a0_ioport.h>
#include <intr.h>
//------------------------------------------------------------------------------
//
// Globals.
// The global variables are storing virual address for interrupt and port
// registers for use in interrupt handling to avoid possible time consumig
// call to OALPAtoVA function.
//
static S3C24A0_IOPORT_REG *g_pPortRegs;
//------------------------------------------------------------------------------
void OEMInitPort(void)
{
DWORD rdata;
g_pPortRegs = (S3C24A0_IOPORT_REG*)OALPAtoVA(S3C24A0_BASE_REG_PA_IOPORT, FALSE);
#if 0
// DWORD rdata;
//CAUTION:Follow the configuration order for setting the ports.
// 1) setting value(GPDAT)
// 2) setting control register (GPCON_U,GPCON_M, GPCON_L))
// 3) configure pull-up resistor(GPUP)
//Ports :GP31 GP30 GP29 GP28 GP27 GP26 GP25 GP24 PG23 GP22 GP21 GP20 GP19
//GPDAT :0 0 0 0 0 0 0 0 0 0 0 0 0
//GPCON_U:i i i i i i i i i i i i i
//GPPU :x o o x x x x x x x x x x
g_pPortRegs->GPCON_U = 0x3fbffff;
//-----------------------------------------------------------------------
//Ports :GP18 GP17 GP16 GP15 GP14 GP13 GP12 GP11
//GPDAT :0 0 0 0 0 0 0 0
//GPCON_M:i i i i i i i i
//GPPU :x o o o x o x x
g_pPortRegs->GPCON_M = 0xd5aa;
//-----------------------------------------------------------------------
//Ports :GP10 GP9 GP8 GP7 GP6 GP5 GP4 GP3 GP2 GP1 GP0
//GPDAT :0 0 0 0 0 0 0 0 0 0 0
//GPCON_L:i i i O O O O i i i i
//GPPU :o x o x x x x o o x x
g_pPortRegs->GPCON_L = 0x255545;
//disable pull-up function
g_pPortRegs->GPPU = 0xffffffff;
g_pPortRegs->GPCON_U &= ~((3 << 24)|(3 << 22)); // Configure GP31 and GP30 for UART1 Tx and Rx, respectively.
g_pPortRegs->GPCON_U |= ((2 << 24)|(2 << 22)); //
g_pPortRegs->GPCON_U &= ~((3 << 20)|(3 << 18)); // Configure GP29 and GP28 for UART1 Tx and Rx, respectively.
g_pPortRegs->GPCON_U |= ((2 << 20)|(2 << 18)); //
g_pPortRegs->GPPU |= (1 << 31)|(1 << 30); // Disable pull-up on TXD1 and RXD1.
//External interrupt will be falling edge triggered.
g_pPortRegs->EXTINTC0= 0x222; //EINT2~0
g_pPortRegs->EXTINTC1 = 0x22222222; //EINT10~3
g_pPortRegs->EXTINTC2 = 0x22222222; //EINT18~11, falling edge & disabling filter
#endif
// Ethernet gpio enable
rdata = g_pPortRegs->GPCON_M;
rdata &= ~(3 << 4);
rdata |= (2 << 4);
g_pPortRegs->GPCON_M = rdata; /* External Interrupt #13 Enable */
rdata = g_pPortRegs->EXTINTC2;
rdata &= ~(7 << 8);
rdata |= (4 << 8);
g_pPortRegs->EXTINTC2 = rdata; /* Rising Edge Detect Mode */
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -