Exemple #1
0
S32 get_gpio_input(U32 pin_num)
{
    U32 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 pin in the respective gpio module */
    U32 data = 0;
    S32 ret_val = OMAPFLASH_DAL_ERROR;

    /* 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 \r\n");
        return(ret_val);
    }

    /* call this function to read the value at the particular pin
    of the corresponding module */
    gpio_read_input_pin(module_num,(1<<offset), &data);
    data = data >> offset;
    /* return from this function*/
    // Commented out in order for CPLD flashing to be speeded up
    //    dbg_print(DBG_LEVEL_INFO,
    //              "read the data at gpio pin %d \n",pin_num);
    return(data);
}
Exemple #2
0
S32 get_gpio_input(U32 pin_num)
{
	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 pin in the respective gpio module */
	U32 data = 0;
	S32 ret_val = FAILURE;

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

	/* call this function to read the value at the particular pin
	   of the corresponding module */
	gpio_read_input_pin(module_num, (1 << offset), &data);
	data = data >> offset;
	/* return from this function */
#ifdef OMAP3530_DEBUG
	DEBUG("read the data at gpio pin %d \n", pin_num);
#endif
	return (data);
}