📄 gpio_api_5009.c
字号:
/******************************************************************************
* File name : Gpio_api.c
* Start date : 2003. 5. 13
* By : Taejin Kwon
* Contact : eric.kwon@samsung.com
* Description: APIs for GPIO
*
*****************************************************************************/
#ifndef _GPIO_API_C_
#define _GPIO_API_C_
/******************************************************************************
* INCLUDES *
******************************************************************************/
// yyd 060404
#include "API/HAPI/SH_capability.h"
#include "CUSTOM/Key_defs.h"
#include "COMMON/Common.h"
#include "MAIN/Global_state.h"
/******************************************************************************
* Global Defines
******************************************************************************/
#if _APP_CAP_NAV_USB_DISC
extern BOOL gUSB_Device_Bad;
#endif
extern BOOL gEmpty_Disc;
#if _APP_CAP_NAV_FX_DATA
extern BOOL gMemory_Card_Bad;
#endif
extern VOID myKeyMsgSender(unsigned char ucdata );
VOID SetInputMode(unsigned char port,unsigned char io)
{
//rPCON8 define for s5s5001 else for s5l5000
#ifdef rPCON8
unsigned int mask = ~(0x0f<<(io<<2));
#else
unsigned int mask = ~(3<<(io<<1));
#endif
//set rPCONX = 00
switch(port){
case 0:
rPCON0 &= mask;
break;
case 1:
rPCON1 &= mask;
break;
case 2:
rPCON2 &= mask;
break;
case 3:
rPCON3 &= mask;
break;
case 4:
rPCON4 &= mask;
break;
}
}
VOID SetOutputMode(unsigned char port,unsigned char io)
{
//rPCON8 define for s5s5001 else for s5l5000
#ifdef rPCON8
unsigned int mask1 = (1<<(io<<2));
unsigned int mask2 = ~(0x0E<<(io<<1));
#else
unsigned int mask1 = (1<<(io<<1));
unsigned int mask2 = ~(2<<(io<<1));
#endif
//set rPCONX = 01
switch(port){
case 0:
rPCON0 |= mask1;
rPCON0 &= mask2;
break;
case 1:
rPCON1 |= mask1;
rPCON1 &= mask2;
break;
case 2:
rPCON2 |= mask1;
rPCON2 &= mask2;
break;
case 3:
rPCON3 |= mask1;
rPCON3 &= mask2;
break;
case 4:
rPCON4 |= mask1;
rPCON4 &= mask2;
break;
}
}
VOID SetGpioPort(unsigned char port,unsigned char io)
{
unsigned char iomask = (1<<io);
SetOutputMode(port,io);
switch(port){
case 0:
OUT_High(rPDAT0,iomask);
break;
case 1:
OUT_High(rPDAT1,iomask);
break;
case 2:
OUT_High(rPDAT2,iomask);
break;
case 3:
OUT_High(rPDAT3,iomask);
break;
case 4:
OUT_High(rPDAT4,iomask);
break;
}
}
VOID ClrGpioPort(unsigned char port,unsigned char io)
{
unsigned char iomask = (1<<io);
SetOutputMode(port,io);
switch(port){
case 0:
OUT_Low(rPDAT0,iomask);
break;
case 1:
OUT_Low(rPDAT1,iomask);
break;
case 2:
OUT_Low(rPDAT2,iomask);
break;
case 3:
OUT_Low(rPDAT3,iomask);
break;
case 4:
OUT_Low(rPDAT4,iomask);
break;
}
}
unsigned char GetGpioPort(unsigned char port,unsigned char io)
{
unsigned char iodata;
unsigned char iomask = (1<<io);
SetInputMode(port,io);
switch(port){
case 0:
iodata = (rPDAT0&iomask);
break;
case 1:
iodata = (rPDAT1&iomask);
break;
case 2:
iodata = (rPDAT2&iomask);
break;
case 3:
iodata = (rPDAT3&iomask);
break;
case 4:
iodata = (rPDAT4&iomask);
break;
}
return (iodata?1:0);
}
extern FP_IFCALLBACK AttachedKeySendCallback;
/******************************************************************************
* Function Defines
******************************************************************************/
/******************************************************************************
* Function name : GPIO_Init
* Arguments :
* Return :
* By : Taejin Kwon
* Description : Initialize GPIO
* Ref. Developer's Toolkit #08
*****************************************************************************/
//rPCON0 = 0x43322222; //ARM JTAG, I2S Input, SPDIF In/Out
//rPCON1 = 0x01114225; //P1.3 CKO output, I2S Output
//rPCON2 = 0x22233112; //P2.6 output, I2C mode
//rPCON3 = 0x22221112; //P3.6 LED output, Servo control
//-----------------------------------------------------------------------------
//CAUTION (For S5L5008)
//-----------------------------------------------------------------------------
// PxPUR : 1: The pull-up resitor is diabled.
// : 0: The pull-up resitor of the corresponding port pin is enabled.
//-----------------------------------------------------------------------------
VOID GPIO_Init( VOID )
{
#ifdef _BOARD_EVA
rPCON0 = 0x22222222;
rPCON1 = 0x22222111;
rPCON2 = 0x55222222;
rPCON3 = 0x00100111;
rPCON5 = 0x77777777;
#else
// yyd 060404 for PWM
#if AUD_SUPPORT_PWM_INSTEAD_OF_ADAC /* PWM can be implanted on 5008 */
// SSCR yyd 060101: for PWM h/w mute
#ifdef _RELEASE
#if _COP_ROCO_BOARD
rPCON0 = ((6<<28)|(2<<24)|(1<<20)|(2<<16)|(2<<12)|(2<<8)|(1<<4)|(2<<0));
rPDAT0 &= 0xdf;
#else
rPCON0 = ((6<<28)|(2<<24)|(2<<20)|(2<<16)|(2<<12)|(2<<8)|(1<<4)|(2<<0));
#endif
#else
rPCON0 = ((6<<28)|(2<<24)|(2<<20)|(2<<16)|(2<<12)|(2<<8)|(2<<4)|(2<<0));
#endif
#if defined(_PWM_AUDIO)||defined(_AUDIO_DAC)
#if 1//def RELEASE
#if _COP_ROCO_BOARD
rPCON1 = ((3<<28)|(2<<24)|(2<<20)|(2<<16)|(2<<12)|(0<<8)|(1<<4)|(1<<0)); // linson
#else
rPCON1 = ((3<<28)|(2<<24)|(2<<20)|(2<<16)|(2<<12)|(0<<8)|(0<<4)|(0<<0));
#endif
#else
rPCON1 = ((3<<28)|(2<<24)|(2<<20)|(2<<16)|(2<<12)|(1<<8)|(0<<4)|(0<<0));//jiangmq.for hardware mute debug.
#endif
#else
#if _COP_ROCO_BOARD
rPCON1 = ((3<<28)|(2<<24)|(2<<20)|(2<<16)|(2<<12)|(0<<8)|(1<<4)|(1<<0));// linson
#else
rPCON1 = ((3<<28)|(2<<24)|(2<<20)|(2<<16)|(2<<12)|(2<<8)|(2<<4)|(2<<0));
#endif
#endif
// rP1PUR |= 0x06;
#if _COP_ROCO_BOARD
rPCON2 = ((3<<28)|(3<<24)|(3<<20)|(0<<16)|(0<<12)|(0<<8)|(1<<4)|(0<<0)); //linson
#else
rPCON2 = ((3<<28)|(3<<24)|(3<<20)|(3<<16)|(3<<12)|(0<<8)|(1<<4)|(0<<0)); //linson
#endif
rP2PUR |= 0x03; //open_sw/close_sw
rPDAT2 |= 0x04; //CD/DVD
rPCON3 = ((2<<24)|(2<<20)|(1<<16)|(1<<12)|(1<<8)|(5<<4)|(5<<0));
// rPDAT3 |= 0x01; //xu0901
rPCON4 = ((2<<28)|(2<<24)|(2<<20)|(2<<16)|(2<<12)|(2<<8)|(2<<4)|(2<<0));
rPCON5 = ((2<<28)|(2<<24)|(2<<20)|(2<<16)|(2<<12)|(2<<8)|(2<<4)|(2<<0));
rPCON6 = ((2<<28)|(2<<24)|(2<<20)|(2<<16)|(2<<12)|(2<<8)|(2<<4)|(2<<0));
rPCON7 = ((2<<28)|(2<<24)|(2<<20)|(2<<16)|(2<<12)|(2<<8)|(2<<4)|(2<<0));
// yyd 060401
rPWM0_CONTROL1 = 0x00301818; //0x003C1818;
rPWM1_CONTROL1 = 0x00301818;
rPWM2_CONTROL1 = 0x00301818;
#if 1
rPWM0_CONTROL2 = 0x00014A10;
rPWM1_CONTROL2 = 0x00014A10;
rPWM2_CONTROL2 = 0x00014A10;
#endif
// SSCR yyd 060601: for 5009 PWM noise
rPWM_MUTE00 = 0x40000200; // SRC=1(volumed data), MUTEth = 0x0001 00 (abs 1)
rPWM_MUTE10 = 0x00000200; // MCLRth = 0x0002 00 (abs 1)
rPWM_MUTE20 = 0x00016000; // NUM_MCLK=1, NUM_MUTE=0x6000(24576samples)
rPWM_MUTE30 = 0x00000000; // Mute flag all clear
// SSCR yyd 060601:To mute in booting time
#ifdef _RELEASE
GPIO_SetAudioMuteState( TRUE );
#endif
#else
#ifdef _AUDIO_DAC
/*
CAUTION!!!!!!!!.
In DVS solution
CD/DVD and RRQ_H is initialized '1'
Close_sw and Open_sw should need pull-up
*/
/*
P1.1, P1.0, P0.6, P0.3 must high before reset.
if those are low before reset, S5L5010x enters test mode.
*/
#ifdef _RELEASE
/*
P0.7 P0.6 P0.5 P0.4 P0.3 P0.2 P0.1 P0.0
RXD TXD RTCK SC_CTL2 SC_CTL1 SC_CTL0 SYS_TDO SYS_nTRST
I O x O O O x x
*/
#if _COP_ROCO_BOARD
rPCON0 = ((2<<28)|(2<<24)|(1<<20)|(1<<16)|(1<<12)|(1<<8)|(2<<4)|(2<<0));
#else
rPCON0 = ((2<<28)|(2<<24)|(2<<20)|(1<<16)|(1<<12)|(1<<8)|(2<<4)|(2<<0));
#endif
#else
/*
P0.7 P0.6 P0.5 P0.4 P0.3 P0.2 P0.1 P0.0
RXD TXD RTCK SYS_TCK SYS_TMS SYS_TDI SYS_TDO SYS_nTRST
I O x x x x x x
*/
rPCON0 = ((2<<28)|(2<<24)|(2<<20)|(2<<16)|(2<<12)|(2<<8)|(2<<4)|(2<<0));
#endif
// rPDAT0 = 0x80;
/*
P1.7 P1.6 P1.5 P1.4 P1.3 P1.2 P1.1 P1.0
CD_DVD SPDIFO IIC_CLK IIC_DATA IRIN SPICLK MISO MOSI
O x x x x x x x
*/
#if defined(_PWM_AUDIO)||defined(_AUDIO_DAC)
rPCON1 = ((1<<28)|(2<<24)|(2<<20)|(2<<16)|(2<<12)|(0<<8)|(0<<4)|(0<<0));
#else
rPCON1 = ((1<<28)|(2<<24)|(2<<20)|(2<<16)|(2<<12)|(2<<8)|(2<<4)|(2<<0));
#endif
// rPDAT1 |= 0x00;
// rP1PUR |= 0x06;
/*
P2.7 P2.6 P2.5 P2.4 P2.3 P2.2 P2.1 P2.0
OPEN_SW CLOSE_SW IISDATA_2 IISDATA_1 IISDATA_0 IISWSO IISMCLKO IISBLCKO
I I x x x x x x
*/
rPCON2 = ((0<<28)|(0<<24)|(2<<20)|(2<<16)|(2<<12)|(2<<8)|(2<<4)|(2<<0));
// rPDAT2 |= 0x10;
// rP2PUR |= 0x08;
/*
P3.7 P3.6 P3.5 P3.4 P3.3 P3.2 P3.1 P3.0
- OPEN DR_MUTE CLOSE HOTPLUG BTCLK HSYNC VSYNC
x O O O I x x x
*/
rPCON3 = ((1<<24)|(1<<20)|(1<<16)|(0<<12)|(2<<8)|(5<<4)|(5<<0));
// rPDAT3 |= 0x01;
// rP3PUR |= 0x50;
/*
P4.7 ~ P4.0 : FDA9 ~ FDA0 (Flash memory)
P5.7 ~ P5.0 : FDA17 ~ FAD10
P6.7 ~ P6.0 : FDB5 ~ FDA18
P7.1 ~ P7.0 : FDB7 ~ FDB6 (P7.7 ~ P7.2 : No_Pin)
*/
rPCON4 = ((2<<28)|(2<<24)|(2<<20)|(2<<16)|(2<<12)|(2<<8)|(2<<4)|(2<<0));
// for servo monitor; P5.3--P5.0
// rPCON5 = ((2<<28)|(2<<24)|(2<<20)|(2<<16)|(7<<12)|(7<<8)|(7<<4)|(7<<0));
rPCON5 = ((2<<28)|(2<<24)|(2<<20)|(2<<16)|(2<<12)|(2<<8)|(2<<4)|(2<<0));
rPCON6 = ((2<<28)|(2<<24)|(2<<20)|(2<<16)|(2<<12)|(2<<8)|(2<<4)|(2<<0));
rPCON7 = ((2<<28)|(2<<24)|(2<<20)|(2<<16)|(2<<12)|(2<<8)|(2<<4)|(2<<0));
#else
/*
CAUTION!!!!!!!!.
In DVS solution
CD/DVD and RRQ_H is initialized '1'
Close_sw and Open_sw should need pull-up
*/
/*
P1.1, P1.0, P0.6, P0.3 must high before reset.
if those are low before reset, S5L5010x enters test mode.
*/
/*
P0.7 P0.6 P0.5 P0.4 P0.3 P0.2 P0.1 P0.0
x x RTCK SYS_TDO SYS_TMS SYS_TCK SYS_TDI SYS_nTRST
close x x x x x x
FMON1 FMON0
O/CLOSE DR_MUTE
*/// P0.7 SD_CLK
// rPCON0 = ((0<<28)|(1<<24)|(2<<20)|(2<<16)|(2<<12)|(2<<8)|(2<<4)|(2<<0)); //Old Board
rPCON0 = ((6<<28)|(2<<24)|(2<<20)|(2<<16)|(2<<12)|(2<<8)|(2<<4)|(2<<0));
// rPDAT0 = 0x80;
/*
P1.7 P1.6 P1.5 P1.4 P1.3 P1.2 P1.1 P1.0
RXD TXD VRCD SCLK TXD_L RXD SRQ CD/DVD
I O O x x x I O
S_SENSE FMON3 FMON2
*/
/* Zhan 20050819
P1.7 P1.6 P1.5 P1.4 P1.3 P1.2 P1.1 P1.0
RXD TXD IR MC ML MD X OPEN
I O I O O O O O
S_SENSE FMON3 FMON2
*/
/*XU 051125 FOR 5009
P1.7 P1.6 P1.5 P1.4 P1.3 P1.2 P1.1 P1.0
MEMORY_CARD_INT SPDIFO IIS_CLK IIS_DATA IR OPEN_SW CLOSE_SW DR_MUTE
I O I O I I O O
*/
//rPCON1 = ((2<<28)|(2<<24)|(1<<20)|(0<<16)|(2<<12)|(2<<8)|(0<<4)|(1<<0));
#if defined(_PWM_AUDIO)||defined(_AUDIO_DAC)
rPCON1 = ((0<<28)|(2<<24)|(2<<20)|(2<<16)|(2<<12)|(0<<8)|(0<<4)|(0<<0));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -