Ejemplo n.º 1
0
//*****************************************************************************
//
//! \brief Read the state or data from the ST7735.
//!
//! \param ucRS determines if the IR or DR to select.
//!
//! The parameter of ucDC can be:
//! - ST7735_RS_COMMAND - select the IR.
//! - ST7735_RS_DATA - select the DR.
//!
//! \return None.
//
//*****************************************************************************
unsigned long 
ST7735Read(unsigned char ucRS)
{
    unsigned long ulData = 0;

    //
    // Set D7 - D0 direction to GPIO Input
    //      
    xGPIOSPinTypeGPIOInput(ST7735_PIN_D7);
    xGPIOSPinTypeGPIOInput(ST7735_PIN_D6);
    xGPIOSPinTypeGPIOInput(ST7735_PIN_D5);
    xGPIOSPinTypeGPIOInput(ST7735_PIN_D4);
    xGPIOSPinTypeGPIOInput(ST7735_PIN_D3);
    xGPIOSPinTypeGPIOInput(ST7735_PIN_D2);
    xGPIOSPinTypeGPIOInput(ST7735_PIN_D1);
    xGPIOSPinTypeGPIOInput(ST7735_PIN_D0);       

    //
    // DC:Command, RD:Write/Read, CS:Enable
    //
    xGPIOSPinWrite(ST7735_PIN_RS, ucRS);
    xGPIOSPinWrite(ST7735_PIN_WR, ST7735_WR_HIGH);	
    xGPIOSPinWrite(ST7735_PIN_CS, ST7735_CS_ENABLE);

    xSysCtlDelay(100);
    
    //
    // Read the Data
    //
		xGPIOSPinWrite(ST7735_PIN_RD, ST7735_RD_LOW);
    xSysCtlDelay(100);
    xGPIOSPinWrite(ST7735_PIN_RD, ST7735_RD_HIGH);
    ulData |= xGPIOSPinRead(ST7735_PIN_D7) << 7;
    ulData |= xGPIOSPinRead(ST7735_PIN_D6) << 6;
    ulData |= xGPIOSPinRead(ST7735_PIN_D5) << 5;
    ulData |= xGPIOSPinRead(ST7735_PIN_D4) << 4;
    ulData |= xGPIOSPinRead(ST7735_PIN_D3) << 3;
    ulData |= xGPIOSPinRead(ST7735_PIN_D2) << 2;
    ulData |= xGPIOSPinRead(ST7735_PIN_D1) << 1;
    ulData |= xGPIOSPinRead(ST7735_PIN_D0) << 0;
    
    xGPIOSPinWrite(ST7735_PIN_CS, ST7735_CS_DISABLE); 

    //
    // At the End, set D7 - D0 direction to GPIO OutPut
    //  
    xGPIOSPinTypeGPIOOutput(ST7735_PIN_D7);
    xGPIOSPinTypeGPIOOutput(ST7735_PIN_D6);
    xGPIOSPinTypeGPIOOutput(ST7735_PIN_D5);
    xGPIOSPinTypeGPIOOutput(ST7735_PIN_D4);
    xGPIOSPinTypeGPIOOutput(ST7735_PIN_D3);
    xGPIOSPinTypeGPIOOutput(ST7735_PIN_D2);
    xGPIOSPinTypeGPIOOutput(ST7735_PIN_D1);
    xGPIOSPinTypeGPIOOutput(ST7735_PIN_D0);   
    
    return ulData;
}
Ejemplo n.º 2
0
//*****************************************************************************
//
//! \brief ad7417arz 001 test execute main body.
//!
//! First set the OTI as compare output mode ,then turned to Int mode.When the 
//! temperature up to 30 centigrade, the OTI pin will be low level ,then clear 
//! the ucFlag to end of the while and set the OTI as Int mode. 
//!
//! \return None.
//
//*****************************************************************************
static void di_ad7417arz001Execute(void)
{
    unsigned long ulTemp;
    unsigned char ucFlag = 1;
     int i;
    
    //
    // Configure the setpoint register
    //
    AD7417LowLimitSetLong(26);
    AD7417UpLimitSetLong(26);
    
    //
    // Config the OTI connected pin as input pin
    //
    xGPIOSPinTypeGPIOInput(AD7417_PIN_OTI);
    
    //
    // Config the OTI active level low , Fault QUEUE is 1
    // OTI compare mode, temperature channel
    //
    
    AD7417TempConfig(AD7417_OTI_CMP | AD7417_OTI_ACTIVE_LOW |
                     AD7417_FAULTQUE_1 | AD7417_TEMP_CHANNEL);
    while(ucFlag)
    {
        ulTemp = AD7417TempReadLDC();
        for(i = 0; i < 10000; i++);
        PrintN(ulTemp);
        ulTemp = xGPIOSPinRead(AD7417_PIN_OTI);
        if(!ulTemp)
        {
            ucFlag = 0;
            
            //
            // Change the mode to int mode,the 
            //
            AD7417TempConfig(AD7417_OTI_INT);
            
            //
            // Change the UpLimit TO 31 C to prevent active 
            //
            AD7417UpLimitSetLong(26);
        }       
    }
    
    //
    // Change to INT mode 
    //
    AD7417TempConfig(AD7417_OTI_INT | AD7417_OTI_ACTIVE_LOW |
                     AD7417_FAULTQUE_1 | AD7417_TEMP_CHANNEL);
    
    AD7417OTIntEnable();
    AD7417OTIntCallbackInit(ReadOperation);
    ulTemp = AD7417TempReadLDC();
    for(i = 0; i < 10000; i++);
    PrintN(ulTemp);
    TestAssertQ("a", "OTI INT mode test fail");
}
Ejemplo n.º 3
0
unsigned long ENCODER_INT_Callback(void *pvCBData, unsigned long ulEvent, unsigned long ulMsgParam, void *pvMsgData)
{
	// unsigned char encoderbits;
	xSysCtlDelay(ENCODER_DEBOUNCE_DELAY);
    xGPIOSPinIntClear(ENCODER_PIN_A);
    xGPIOSPinIntClear(ENCODER_PIN_B);

    ENCODER_PREV_STATE = (xGPIOSPinRead(ENCODER_PIN_B) << 1) | xGPIOSPinRead(ENCODER_PIN_A) | (ENCODER_PREV_STATE << 2);

    // encoder_count += ENCODER_TABLE[(ENCODER_PREV_STATE & 0x0f)];  /* Index into table */

    switch (ENCODER_TABLE[(ENCODER_PREV_STATE & 0x0f)])
    {
    	case -1:
    		ENCODER_USER_Callback(-1);
    		break;
    	case 1:
    		ENCODER_USER_Callback(1);
    	default:
    		break;
    }

    return 0;
}
Ejemplo n.º 4
0
Archivo: CH376.c Proyecto: AlexGora/cox
//*****************************************************************************
//
//! \brief query CH376 interrupt line
//!
//! \param None
//!
//! \return TRUE or FALSE according to interrupt line.
//
//*****************************************************************************
UINT8   Query376Interrupt( void )
{
#ifdef CH376_INT_WIRE
    return( CH376_INT_REQ() ? FALSE : TRUE);
#else
#ifdef CH376_SPI_SDO_INT
    unsigned char res = 0;
    res = xGPIOSPinRead(CH376_MISO_PIN);
    return( res ? FALSE : TRUE );
#else
#ifdef CH376_USE_PARALLEL
    return( xReadCH376Status( ) & PARA_STATE_INTB ? FALSE : TRUE );
#endif
#endif
#endif
}