/*****************************************************************************
* 函 数 名  : bsp_gpio_set_value
*
* 功能描述  : 设置GPIO 引脚的电平值
*
* 输入参数  : u32 gpio        GPIO引脚编号
*              u32 value      管脚高/低电平
*
* 返 回 值  : 无
*
* 修改记录  : 2012年11月27日
*****************************************************************************/
void bsp_gpio_set_value(u32 gpio,u32 value)
{
    u32 chip_num;
    u32 pin;
    u32 u32GpioAddr = 0;
    u32 gpio_value = 0;
    unsigned long irq_flags;

    /* 如果GPIO 没有初始化,返回错误 */
    if (GPIO_DEF_NOT_RUNNING == g_u32GpioRunning)
    {
        gpio_print_error(" GPIO is not inited.\n");
        return ;
    }

    if(gpio >= GPIO_TOTAL_PINS_NUM)
    {
        gpio_print_error(" GPIO parameter error.\n");
        return;
    }

    /*检测GPIO方向是否输出,如果为输入,则返回错误*/
    if(0 == bsp_gpio_direction_get(gpio))
    {
        gpio_print_error(" GPIO direction error.\n");
        return;
    }

    chip_num   = gpio / (u32)GPIO_MAX_PINS;
    pin        = gpio % (u32)GPIO_MAX_PINS;

	if(chip_num < GPIO_MAX_BANK_NUM){

	    u32GpioAddr = s_u32GpioBaseAddr[chip_num];
	}
	else{
        gpio_print_error(" GPIO bank number error.\n");
		return ;
	}


    spin_lock_irqsave(&g_gpio_spinlock, irq_flags);
    (void)bsp_ipc_spin_lock(IPC_SEM_GPIO);

    gpio_value = readl(u32GpioAddr + HI_GPIO_SWPORT_DR_OFFSET);
    if(!!value)
    {
        writel(gpio_value | ((u32)0x1 << pin), u32GpioAddr + HI_GPIO_SWPORT_DR_OFFSET);
    }
    else
    {
        writel(gpio_value & ~((u32)0x1 << pin), u32GpioAddr + HI_GPIO_SWPORT_DR_OFFSET);
    }

    (void)bsp_ipc_spin_unlock(IPC_SEM_GPIO);
    spin_unlock_irqrestore(&g_gpio_spinlock, irq_flags);

}
s32 ipc_test_case03(void)
{
	s32 ret = 0;
	unsigned long flags = 0;
	local_irq_save(flags);
	ret = bsp_ipc_spin_lock(IPC_SEM2_IPC_TEST);
	if(ret != OK)
	{
		bsp_trace(BSP_LOG_LEVEL_ERROR,BSP_MODU_IPC,"[%s]:spinlock error\n",__FUNCTION__);
		local_irq_restore(flags);
		return ERROR;
	}
	ret = bsp_ipc_spin_unlock(IPC_SEM2_IPC_TEST);
	if(ret != OK)
	{
		bsp_trace(BSP_LOG_LEVEL_ERROR,BSP_MODU_IPC,"[%s]:spinunlock error\n",__FUNCTION__);
		local_irq_restore(flags);
		return ERROR;
	}
	local_irq_restore(flags);
	return OK;
}
s32 ipc_test_spinlock(void)
{
	s32 ret = 0;
	unsigned long flags = 0;
	local_irq_save(flags);
	ret = bsp_ipc_spin_lock(IPC_SEM1_IPC_TEST);/*复用此信号量,测试与m3争用*/
	if(ret != OK)
	{
		bsp_trace(BSP_LOG_LEVEL_ERROR,BSP_MODU_IPC,"[%s]:spinlock error\n",__FUNCTION__);
		local_irq_restore(flags);
		return ERROR;
	}
	delay(5000);
	ret = bsp_ipc_spin_unlock(IPC_SEM1_IPC_TEST);
	if(ret != OK)
	{
		bsp_trace(BSP_LOG_LEVEL_ERROR,BSP_MODU_IPC,"[%s]:spinunlock error\n",__FUNCTION__);
		local_irq_restore(flags);
		return ERROR;
	}
	local_irq_restore(flags);
	return OK;
}
Beispiel #4
0
BSP_S32 BSP_IPC_SpinLock_IrqSave(BSP_U32 u32SignalNum, unsigned long *flags)
{
	local_irq_save(*flags);
	return  bsp_ipc_spin_lock(u32SignalNum);
	
}
Beispiel #5
0
BSP_VOID BSP_IPC_SpinLock (BSP_U32 u32SignalNum)
{
	(void)bsp_ipc_spin_lock (u32SignalNum);
 	return;
}
void mdrv_ipc_spin_lock(unsigned int u32SignalNum)
{
	(void)bsp_ipc_spin_lock (u32SignalNum);
 	return;
}