2017-07-18 11:15:10 +08:00
|
|
|
|
// <20><><EFBFBD>Ź<EFBFBD><C5B9><EFBFBD>(<28><>ͨgpio<69><6F>pwm<77><6D><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>)<29><><EFBFBD>ؽӿ<D8BD>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "ls1c_public.h"
|
|
|
|
|
#include "ls1c_regs.h"
|
|
|
|
|
#include "ls1c_gpio.h"
|
|
|
|
|
#include "ls1c_pin.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* <EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>pin<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>;(<EFBFBD><EFBFBD>ͨgpio<EFBFBD><EFBFBD><EFBFBD><EFBFBD>gpio)
|
|
|
|
|
* @gpio gpio<EFBFBD><EFBFBD><EFBFBD>ű<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @purpose <EFBFBD><EFBFBD>;
|
|
|
|
|
*/
|
|
|
|
|
void pin_set_purpose(unsigned int gpio, pin_purpose_t purpose)
|
|
|
|
|
{
|
|
|
|
|
volatile unsigned int *gpio_cfgx; // GPIO_CFGx<47>Ĵ<EFBFBD><C4B4><EFBFBD>
|
|
|
|
|
unsigned int pin = GPIO_GET_PIN(gpio);
|
|
|
|
|
|
|
|
|
|
gpio_cfgx = gpio_get_cfg_reg(gpio);
|
|
|
|
|
if (PIN_PURPOSE_GPIO == purpose) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨgpio
|
|
|
|
|
{
|
|
|
|
|
reg_set_one_bit(gpio_cfgx, pin);
|
|
|
|
|
}
|
|
|
|
|
else // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><>gpio)
|
|
|
|
|
{
|
|
|
|
|
reg_clr_one_bit(gpio_cfgx, pin);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>pinΪ<EFBFBD><EFBFBD>n<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @gpio gpio<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @remap <EFBFBD><EFBFBD>n<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
void pin_set_remap(unsigned int gpio, pin_remap_t remap)
|
|
|
|
|
{
|
|
|
|
|
volatile unsigned int *reg = NULL; // <20><><EFBFBD>üĴ<C3BC><C4B4><EFBFBD>
|
|
|
|
|
unsigned int port = GPIO_GET_PORT(gpio);
|
|
|
|
|
unsigned int pin = GPIO_GET_PIN(gpio);
|
2018-02-09 09:21:02 +08:00
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
/*ָ<><D6B8>ȫ<EFBFBD><C8AB>pin<69><6E><EFBFBD><EFBFBD>Ϊ0*/
|
|
|
|
|
for(i =0; i <=4; i++)
|
|
|
|
|
{
|
|
|
|
|
reg = (volatile unsigned int *)((LS1C_CBUS_FIRST0)+((port)*0x04)+((i)*0x10));
|
|
|
|
|
// <20><>0
|
|
|
|
|
reg_clr_one_bit(reg, pin);
|
|
|
|
|
}
|
2017-07-18 11:15:10 +08:00
|
|
|
|
|
|
|
|
|
switch (port)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
switch (remap)
|
|
|
|
|
{
|
|
|
|
|
case PIN_REMAP_FIRST:
|
|
|
|
|
reg = (volatile unsigned int *)LS1C_CBUS_FIRST0;
|
|
|
|
|
break;
|
|
|
|
|
case PIN_REMAP_SECOND:
|
|
|
|
|
reg = (volatile unsigned int *)LS1C_CBUS_SECOND0;
|
|
|
|
|
break;
|
|
|
|
|
case PIN_REMAP_THIRD:
|
|
|
|
|
reg = (volatile unsigned int *)LS1C_CBUS_THIRD0;
|
|
|
|
|
break;
|
|
|
|
|
case PIN_REMAP_FOURTH:
|
|
|
|
|
reg = (volatile unsigned int *)LS1C_CBUS_FOURTH0;
|
|
|
|
|
break;
|
|
|
|
|
case PIN_REMAP_FIFTH:
|
|
|
|
|
reg = (volatile unsigned int *)LS1C_CBUS_FIFTH0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
|
switch (remap)
|
|
|
|
|
{
|
|
|
|
|
case PIN_REMAP_FIRST:
|
|
|
|
|
reg = (volatile unsigned int *)LS1C_CBUS_FIRST1;
|
|
|
|
|
break;
|
|
|
|
|
case PIN_REMAP_SECOND:
|
|
|
|
|
reg = (volatile unsigned int *)LS1C_CBUS_SECOND1;
|
|
|
|
|
break;
|
|
|
|
|
case PIN_REMAP_THIRD:
|
|
|
|
|
reg = (volatile unsigned int *)LS1C_CBUS_THIRD1;
|
|
|
|
|
break;
|
|
|
|
|
case PIN_REMAP_FOURTH:
|
|
|
|
|
reg = (volatile unsigned int *)LS1C_CBUS_FOURTH1;
|
|
|
|
|
break;
|
|
|
|
|
case PIN_REMAP_FIFTH:
|
|
|
|
|
reg = (volatile unsigned int *)LS1C_CBUS_FIFTH1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
|
switch (remap)
|
|
|
|
|
{
|
|
|
|
|
case PIN_REMAP_FIRST:
|
|
|
|
|
reg = (volatile unsigned int *)LS1C_CBUS_FIRST2;
|
|
|
|
|
break;
|
|
|
|
|
case PIN_REMAP_SECOND:
|
|
|
|
|
reg = (volatile unsigned int *)LS1C_CBUS_SECOND2;
|
|
|
|
|
break;
|
|
|
|
|
case PIN_REMAP_THIRD:
|
|
|
|
|
reg = (volatile unsigned int *)LS1C_CBUS_THIRD2;
|
|
|
|
|
break;
|
|
|
|
|
case PIN_REMAP_FOURTH:
|
|
|
|
|
reg = (volatile unsigned int *)LS1C_CBUS_FOURTH2;
|
|
|
|
|
break;
|
|
|
|
|
case PIN_REMAP_FIFTH:
|
|
|
|
|
reg = (volatile unsigned int *)LS1C_CBUS_FIFTH2;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
|
switch (remap)
|
|
|
|
|
{
|
|
|
|
|
case PIN_REMAP_FIRST:
|
|
|
|
|
reg = (volatile unsigned int *)LS1C_CBUS_FIRST3;
|
|
|
|
|
break;
|
|
|
|
|
case PIN_REMAP_SECOND:
|
|
|
|
|
reg = (volatile unsigned int *)LS1C_CBUS_SECOND3;
|
|
|
|
|
break;
|
|
|
|
|
case PIN_REMAP_THIRD:
|
|
|
|
|
reg = (volatile unsigned int *)LS1C_CBUS_THIRD3;
|
|
|
|
|
break;
|
|
|
|
|
case PIN_REMAP_FOURTH:
|
|
|
|
|
reg = (volatile unsigned int *)LS1C_CBUS_FOURTH3;
|
|
|
|
|
break;
|
|
|
|
|
case PIN_REMAP_FIFTH:
|
|
|
|
|
reg = (volatile unsigned int *)LS1C_CBUS_FIFTH3;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><>1
|
|
|
|
|
reg_set_one_bit(reg, pin);
|
|
|
|
|
|
|
|
|
|
return ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|