コード例 #1
0
extern void TSW_VoidInit(void)
{
	DIO_u8ReadPinDir(TSW_PIN1,DIO_u8INPUT);
	DIO_u8ReadPinDir(TSW_PIN2,DIO_u8INPUT);
	DIO_u8ReadPinDir(TSW_PIN3,DIO_u8INPUT);
	DIO_u8ReadPinDir(TSW_PIN4,DIO_u8INPUT);
}
コード例 #2
0
ファイル: DIO_Prog.c プロジェクト: Embedded36/Ahmed_Adel
extern u8 DIO_u8ReadPinVal(u8 Copy_u8PinIdx, u8* Copy_u8PtrToVal)
    {
    u8 local_u8PortNumber;
    u8 local_u8PinNumber;
    u8 local_u8ErrorFlag;
    u8 local_u8PinValue;
    u8 local_u8PinDir;

    /*Comment!: Read Pin Direction*/
    DIO_u8ReadPinDir(Copy_u8PinIdx, &local_u8PinDir);

    /*Comment!: Check Pin Direction*/
    if (local_u8PinDir == DIO_u8INPUT)
	{

	/*Comment!: local_u8PortNumber=Copy_u8PinIdx/8 */
	local_u8PortNumber = Copy_u8PinIdx >> DIO_DEVIED_BY_EIGHT;

	/*Comment!: Getting pin number in port */
	local_u8PinNumber = Copy_u8PinIdx % DIO_u8PINS_PER_PORT;

	/*Comment!: Check pin index in range or out of range*/
	if (local_u8PortNumber < DIO_u8NUM_OF_PORTS)
	    {
	    /*Comment!: Get bit value then return its value */
	    local_u8PinValue = GET_BIT(*INPUT_PORTS_ARRAY[local_u8PortNumber],
		    local_u8PinNumber);

	    *Copy_u8PtrToVal = local_u8PinValue;

	    local_u8ErrorFlag = ok;
	    }

	else
	    {
	    local_u8ErrorFlag = error;
	    }

	}