📄 tgpio55.c
字号:
//CSL test GPIO
#ifndef _TGPIO55_C
#define _TGPIO55_C
#include <stdio.h>
#include "includes.h"
#include "tgpio55.h"
static Uint16 dsp_gpio_mask=0;
void InitDspGpio(void)
//设置那些gpio是dsp控制的
{
Uint16 val=0;
dsp_gpio_mask=~GPIO_RGET(PCSR);
if( val != DSP_GPIO_MASK) {
puts("mpu 和 dsp对gpio的设置冲突 \n");
return;
}
GPIO_eventDisable(DSP_GPIO_MASK);
}
void InitGpioMode(Uint16 gpio_no,Uint16 direc )
//gpio_no:gpio 编号
//dir:方向
{
Uint16 gpio_msk=0,dir=0;
#if(DEBUG_GPIO)
if( (gpio_no>16) ){
printf("gpio no. %d is invalid\n",gpio_no);
return;
}
if( (DSP_GPIO_MASK&(1<<gpio_no))==0 ){
printf("gpio no. %d isn't controled by dsp\n",gpio_no);
return;
}
#endif
GPIO_RSET(DCRQ,DSP_GPIO_MASK);
gpio_msk=1<<gpio_no;
dir=GPIO_RGET(DCRQ);
if(direc==1)
dir=GPIO_RGET(DCRQ)| gpio_msk;
else
dir=GPIO_RGET(DCRQ)&(~gpio_msk);
GPIO_RSET(DCRQ,dir);
GPIO_eventDisable(gpio_msk);
}
void WrGpio(Uint16 gpio_no,Uint16 val )
//gpio_no:gpio 编号
//val:值0/1
{
Uint16 tval=0;
#if(DEBUG_GPIO==1)
if(gpio_no>16){
printf("gpio no. %d is invalid\n",gpio_no);
return;
}
if( !(DSP_GPIO_MASK&(1<<gpio_no)) ){
printf("gpio no. %d isn't controled by dsp\n",gpio_no);
return;
}
#endif
// GPIO_pinWrite(gpio_no,val);
if(val == 1){
tval=GPIO_RGET(DORQ);
tval=tval| (1<<gpio_no);
GPIO_RSET(DORQ, tval);
}
else if(val == 0){
tval=GPIO_RGET(DORQ);
tval=tval & (~(1<<gpio_no));
GPIO_RSET(DORQ, tval);
}
}
Uint16 RdGpio(Uint16 gpio_no )
//gpio_no:gpio 编号
//返回:0或1
{
Uint16 val=0;
#if(DEBUG_GPIO==1)
if(gpio_no>16){
printf("gpio no. %d is invalid\n",gpio_no);
return;
}
if( (DSP_GPIO_MASK&(1<<gpio_no))==0 ){
printf("gpio no. %d isn't controled by dsp\n",gpio_no);
return;
}
#endif
val = GPIO_RGET(DIRQ)&(1<<gpio_no);
if(val>0)
return(1);
return(0);
}
#endif //_TGPIO_C
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -