Beispiel #1
0
/*-----------------------------------------------------------------------------
| Function    : S32 set_gpio_output(U16 pin_num, U8 set)
+------------------------------------------------------------------------------
| Description : for writing data to the GPIO pins
|
| Parameters  : pin_num -
|                 gpio pin number
|               set -
|                 set/clear information
| Returns     : DAL_ERROR is returned if failure else the value returned
|               by the lower layer function is passed on.
+-----------------------------------------------------------------------------*/
S32 set_gpio_output(U16 pin_num, U8 set)
{
    S32                      ret_val = OMAPFLASH_DAL_ERROR;
    U8                       module_num = pin_num/NUM_OF_BITS_IN_REG + 1;
    /* GPIO module to which the GPIO pin number belongs to */
    U32                      snum = (module_num-1)*NUM_OF_BITS_IN_REG;
    U32                      offset = pin_num - snum;
    /* position of the GPIO pin in respective module register*/

    /* check whether the gpio number is valid */
    /* if yes continue else return*/
    ret_val = check_gpio_pin_num(pin_num);
    if(ret_val != OMAPFLASH_SUCCESS)
    {
        dbg_print(DBG_LEVEL_INFO, "wrong gpio-pin number \n");
        return(ret_val);
    }

    /* if the output pin value has to be made 1,then the data to be
    written will be - the bit corresponding to that pin is set
    else that bit is cleared and that function is called  */
    if (set)
    {
        gpio_write_output_pin(module_num, (1<<offset), (1<<offset));
    }
    else
    {
        gpio_write_output_pin(module_num, (1<<offset), (0<<offset));
    }
    /* return from this function*/
    // Commented out in order for CPLD flashing to be speeded up
    //    dbg_print(DBG_LEVEL_INFO,
    //              "wrote the data to gpio pin %d \n",pin_num);
    return(ret_val);
}
Beispiel #2
0
/* Writing data to the GPIO pins. */
S32 set_gpio_output(U16 pin_num, U8 set)
{
	S32 ret_val = FAILURE;
	/* GPIO module to which the GPIO pin number belongs to. */
	U8 module_num = (pin_num / NUM_OF_BITS_IN_REG + 1);
	U32 snum = ((module_num - 1) * NUM_OF_BITS_IN_REG);
	/* Position of the GPIO pin in respective module register. */
	U32 offset = (pin_num - snum);

	/* 
	 ** Check whether the gpio number is valid. 
	 ** if yes continue else return.
	 */
	ret_val = check_gpio_pin_num(pin_num);
	if (SUCCESS != ret_val) {
#ifdef OMAP3530_DEBUG
		DEBUG("%s:%d - Wrong gpio-pin number.\r\n", __FILE__, __LINE__);
#endif
		return (ret_val);
	}

	/* 
	 ** If the output pin value has to be made 1, then the data to be
	 ** written will be - the bit corresponding to that pin is set
	 ** else that bit is cleared and that function is called. 
	 */
	if (set) {
		gpio_write_output_pin(module_num, (1 << offset), (1 << offset));
	} else {
		gpio_write_output_pin(module_num, (1 << offset), (0 << offset));
	}

#ifdef OMAP3530_DEBUG
	DEBUG("Wrote the data to gpio pin - %d.\r\n", pin_num);
#endif
	return (ret_val);
}