コード例 #1
0
ファイル: Selection_Sort.c プロジェクト: molkoo/c_study
void main()
{
	printf("Initialize Data\n");

	MakeRandomNumber();
	DisplayBuffer();
	printf("Sort end Data\n");
	SelectionSort();
	DisplayBuffer();
	printf("\n");
}
コード例 #2
0
ファイル: editor.c プロジェクト: AdventureKing/UTSASCHOOLWORK
main()
{
    bufferADT buffer;

    buffer = NewBuffer();
    while (TRUE) {
        printf("*");
        ExecuteCommand(buffer, GetLine());
        DisplayBuffer(buffer);
    }
    FreeBuffer(buffer);
}
コード例 #3
0
ファイル: main.c プロジェクト: Balu1991/Wifly_Light
//****************************************************************************
//
//! Parses the readreg command parameters and invokes the I2C APIs
//! i2c readreg 0x<dev_addr> 0x<reg_offset> <rdlen>
//!
//! \param pcInpString pointer to the readreg command parameters
//! 
//! This function  
//!    1. Parses the readreg command parameters.
//!    2. Invokes the corresponding I2C APIs
//!
//! \return 0: Success, < 0: Failure.
//
//****************************************************************************
int
ProcessReadRegCommand(char *pcInpString)
{
    unsigned char ucDevAddr, ucRegOffset, ucRdLen;
    unsigned char aucRdDataBuf[256];
    char *pcErrPtr;

    //
    // Get the device address
    //
    pcInpString = strtok(NULL, " ");
    RETERR_IF_TRUE(pcInpString == NULL);
    ucDevAddr = (unsigned char)strtoul(pcInpString+2, &pcErrPtr, 16);
    //
    // Get the register offset address
    //
    pcInpString = strtok(NULL, " ");
    RETERR_IF_TRUE(pcInpString == NULL);
    ucRegOffset = (unsigned char)strtoul(pcInpString+2, &pcErrPtr, 16);

    //
    // Get the length of data to be read
    //
    pcInpString = strtok(NULL, " ");
    RETERR_IF_TRUE(pcInpString == NULL);
    ucRdLen = (unsigned char)strtoul(pcInpString, &pcErrPtr, 10);
    //RETERR_IF_TRUE(ucLen > sizeof(aucDataBuf));

    //
    // Write the register address to be read from.
    // Stop bit implicitly assumed to be 0.
    //
    RET_IF_ERR(I2C_IF_Write(ucDevAddr,&ucRegOffset,1,0));
    
    //
    // Read the specified length of data
    //
    RET_IF_ERR(I2C_IF_Read(ucDevAddr, &aucRdDataBuf[0], ucRdLen));

    UART_PRINT("I2C Read From address complete\n\r");
    
    //
    // Display the buffer over UART on successful readreg
    //
    DisplayBuffer(aucRdDataBuf, ucRdLen);

    return SUCCESS;
}
コード例 #4
0
ファイル: main.c プロジェクト: Balu1991/Wifly_Light
//****************************************************************************
//
//! Parses the read command parameters and invokes the I2C APIs
//!
//! \param pcInpString pointer to the user command parameters
//! 
//! This function  
//!    1. Parses the read command parameters.
//!    2. Invokes the corresponding I2C APIs
//!
//! \return 0: Success, < 0: Failure.
//
//****************************************************************************
int
ProcessReadCommand(char *pcInpString)
{
    unsigned char ucDevAddr, ucLen;
    unsigned char aucDataBuf[256];
    char *pcErrPtr;
    int iRetVal;

    //
    // Get the device address
    //
    pcInpString = strtok(NULL, " ");
    RETERR_IF_TRUE(pcInpString == NULL);
    ucDevAddr = (unsigned char)strtoul(pcInpString+2, &pcErrPtr, 16);
    //
    // Get the length of data to be read
    //
    pcInpString = strtok(NULL, " ");
    RETERR_IF_TRUE(pcInpString == NULL);
    ucLen = (unsigned char)strtoul(pcInpString, &pcErrPtr, 10);
    //RETERR_IF_TRUE(ucLen > sizeof(aucDataBuf));
    
    //
    // Read the specified length of data
    //
    iRetVal = I2C_IF_Read(ucDevAddr, aucDataBuf, ucLen);

    if(iRetVal == SUCCESS)
    {
        UART_PRINT("I2C Read complete\n\r");
        
        //
        // Display the buffer over UART on successful write
        //
        DisplayBuffer(aucDataBuf, ucLen);
    }
    else
    {
        UART_PRINT("I2C Read failed\n\r");
        return FAILURE;
    }

    return SUCCESS;
}
コード例 #5
0
ファイル: mouse.cpp プロジェクト: 340211173/hf-2011
VOID
ProcessMouseInput (
	UCHAR Byte
	)

/*++

Routine Description
	
	This function is always called when kernel debugger is active to 
	 process data byte from mouse when i8042 driver detects mouse packet.
	NGdbg drives PS/2 mouse in polled mode because all its interface code
	 is executing at IRQL at least DIRQL for keyboard or higher.
	So it is not necessary to set up mouse ISR routine.

Arguments

	Byte

		Data byte from 60h port, which is detected as mouse byte by
		 i8042 driver.

Return Value

	None

Environment

	IRQL = Keyboard DIRQL or higher.
	Called from I8xGetBytePolled.

--*/

{
//	KdPrint (("Mouse input.. %d [%X]\n", BytesLoaded, Byte));

	if (Resynch)
	{
		BytesLoaded = 0;
		Packet.Raw[BytesLoaded] = Byte;
		if (!( Packet.u1.e1.Synch &&
			Packet.u1.e1.Left &&
			Packet.u1.e1.Right &&
			!Packet.u1.e1.Middle))
		{
			KdPrint(("Re-synching [%X]..\n", Byte));
			return;
		}

		++ BytesLoaded;

		KdPrint(("Resynchronized\n"));
		Resynch = FALSE;
		GuiTextOut ("Re-synchronized\n");
		DisplayBuffer ();
		return;
	}

	Packet.Raw[BytesLoaded] = Byte;
	++ BytesLoaded;
		
	if (BytesLoaded == 4)
	{
		BytesLoaded = 0;

//		KdPrint(("Got full mouse packet\n"));

		if (!Packet.u1.e1.Synch)
		{
			KdPrint(("Mouse packet corrupted, dump follows\n"));
			MouDumpPacket (&Packet);

			Resynch = TRUE;
			KdPrint(("Re-synchronization request, please, press left+right buttons\n"));
			GuiTextOut ("Re-synchronization request, please, press left+right buttons\n");
			DisplayBuffer ();

			return;
		}

		//
		// Got valid mouse p 8acket.
		//

		MouDumpPacket (&Packet);

		ReportMouseStateChange ();
	}
}