int main(void)
{
    
    printf("\n\nStarting to Run TestOpenCloseADC.\n");
    printf("This will test the ADC by enabling\n");
    printf("and disabling the ADC cape\n");
    
    if (enableADC() == CE_GOOD)
    {
        printf("ADC has been successfully enabled\n");
        
    } else
    {
        printf("There was a problem enabling the cape\n");
    }
    
    if (disableADC() != CE_GOOD)
    {
        printf("Problem with disabling the ADC Cape\n");
        
    } else
    {
        printf("ADC Cape has been disabled\n");
    }
    
    return 0;
}
Пример #2
0
void prvSetupHardware( void )
{
    /* 
      If running on Rev A2 silicon, turn the LDO voltage up to 2.75V.  This is
      a workaround to allow the PLL to operate reliably. 
    */
  
    // if( DEVICE_IS_REVA2 )
    // {
    //     SysCtlLDOSet( SYSCTL_LDO_2_75V );
    // }
  
    // // Set the clocking to run from the PLL at 50 MHz
    
    // SysCtlClockSet( SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ );
    
    /*   
      Enable Port F for Ethernet LEDs
            LED0        Bit 3   Output
            LED1        Bit 2   Output 
    */
    
    SysCtlPeripheralEnable( SYSCTL_PERIPH_GPIOF );
    GPIODirModeSet( GPIO_PORTF_BASE, (GPIO_PIN_2 | GPIO_PIN_3), GPIO_DIR_MODE_HW );
    GPIOPadConfigSet( GPIO_PORTF_BASE, (GPIO_PIN_2 | GPIO_PIN_3 ), GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD ); 
  
    enableSysClock();
    enableGPIO();
    enableADC();
    enableUART();
}
int main(void)
{

    FILE *fp;
    int cycles = 0;
    float pinValue = 0;
    char tempV[40];
    time_t rawtime;
    
    printf("\n\nStarting to Run ReadingADC.\n");
    printf("This will read the photoresistor\n");
    printf("and record its value and the time\n");
    printf("every 10 minutes for 24 hours.\n");
    printf("It will record all these values to:\n");
    printf("%s\n\n", REQFILE);
    
    if (enableADC() == CE_GOOD)
    {
        printf("ADC has been successfully enabled\n");
        
        while (cycles < 145)
        {
            time(&rawtime);
            
            if (readADCPIN(P9_40, &pinValue) != CE_GOOD)
            {
                printf("problem reading ADC value\n");
            }
            if (readADCPIN(P9_40, &pinValue) != CE_GOOD)
            {
                printf("problem reading ADC value\n");
            }
            
            if ((fp = fopen(REQFILE, "ab")) == NULL)
            {
                printf("Cannot open file");
            }
            
            sprintf(tempV, "%f, %s\n", pinValue, ctime(&rawtime));
            fwrite(tempV, sizeof(tempV[0]), sizeof(tempV)/sizeof(tempV[0]), fp);
            
            fclose(fp);
            
            printf("Reading %i has been saved\n", cycles);
            
            if (cycles != 144)
            {
                // This will sleep for 10 minutes
                sleep(600);
            }
            cycles++;
        }
    } else
    {
        printf("There was a problem enabling the cape\n");
    }
    
    // This is commented out because I am having problem with the
    // disable locking up the SLOTS
//    if (disableADC() != CE_GOOD)
//    {
//        printf("Problem with disabling the ADC Cape\n");
//        
//    } else
//    {
//        printf("ADC Cape has been disabled\n");
//    }
    
    return 0;
}
Пример #4
0
void TCS3414::start() {
  enableADC();
}