Exemple #1
0
void InitGPIO(void)
{
	/* Activate GPIO clock per port. Not sure of which ports we use, so enable everything */
	MAP_PRCMPeripheralClkEnable(PRCM_GPIOA0, PRCM_RUN_MODE_CLK);
	MAP_PRCMPeripheralClkEnable(PRCM_GPIOA1, PRCM_RUN_MODE_CLK);
	MAP_PRCMPeripheralClkEnable(PRCM_GPIOA2, PRCM_RUN_MODE_CLK);
	MAP_PRCMPeripheralClkEnable(PRCM_GPIOA3, PRCM_RUN_MODE_CLK);
	MAP_PRCMPeripheralClkEnable(PRCM_GPIOA4, PRCM_RUN_MODE_CLK);

    /* Configure UART pins */
    MAP_PinTypeUART(PIN_55, PIN_MODE_3);
    MAP_PinTypeUART(PIN_57, PIN_MODE_3);

    /* Configure I2C pins */
    MAP_PinTypeI2C(PIN_01, PIN_MODE_1);
    MAP_PinTypeI2C(PIN_02, PIN_MODE_1);

    /* COngifure current sense ADC inputs */
    MAP_PinTypeADC(AISEN,PIN_MODE_255);
    MAP_PinTypeADC(BISEN,PIN_MODE_255);
    MAP_ADCChannelEnable(ADC_BASE, AISENx);
    MAP_ADCChannelEnable(ADC_BASE, BISENx);
    MAP_ADCEnable(ADC_BASE);

	/* Set pin mode for DIP and LED pins */
	MAP_PinTypeGPIO(RLED, PIN_MODE_0, false);
	MAP_PinTypeGPIO(BLED, PIN_MODE_0, false);
	MAP_PinTypeGPIO(DIP1, PIN_MODE_0, false);
	MAP_PinTypeGPIO(DIP2, PIN_MODE_0, false);
	MAP_PinTypeGPIO(DIP3, PIN_MODE_0, false);
	MAP_PinTypeGPIO(DIP4, PIN_MODE_0, false);
	MAP_PinTypeGPIO(ODO1, PIN_MODE_0, false);
	MAP_PinTypeGPIO(ODO2, PIN_MODE_0, false);

	/* Get port name and bin number from GPIO number (TI lookup table) LED, DIP, ODO */
	GPIO_IF_GetPortNPin(RLEDx, &port_rled, &pin_rled);
	GPIO_IF_GetPortNPin(BLEDx, &port_bled, &pin_bled);
	GPIO_IF_GetPortNPin(DIP1x, &port_dip1, &pin_dip1);
	GPIO_IF_GetPortNPin(DIP2x, &port_dip2, &pin_dip2);
	GPIO_IF_GetPortNPin(DIP3x, &port_dip3, &pin_dip3);
	GPIO_IF_GetPortNPin(DIP4x, &port_dip4, &pin_dip4);
	GPIO_IF_GetPortNPin(ODO1x, &port_odo1, &pin_odo1);
	GPIO_IF_GetPortNPin(ODO2x, &port_odo2, &pin_odo2);

	/* Set pin direction LED, DIP, ODO */
	GPIODirModeSet(port_rled, pin_rled, 1);
	GPIODirModeSet(port_bled, pin_bled, 1);
	GPIODirModeSet(port_dip1, pin_dip1, 0);
	GPIODirModeSet(port_dip2, pin_dip2, 0);
	GPIODirModeSet(port_dip3, pin_dip3, 0);
	GPIODirModeSet(port_dip4, pin_dip4, 0);
	GPIODirModeSet(port_odo1, pin_odo1, 0);
	GPIODirModeSet(port_odo2, pin_odo2, 0);
}
Exemple #2
0
/******************************************************************************
 DEFINE PUBLIC FUNCTIONS
 ******************************************************************************/
STATIC void pybadc_init (pyb_adc_obj_t *self) {
    // enable the ADC channel
    MAP_ADCChannelEnable(ADC_BASE, self->channel);
    // enable and configure the timer
    MAP_ADCTimerConfig(ADC_BASE, (1 << 17) - 1);
    MAP_ADCTimerEnable(ADC_BASE);
    // enable the ADC peripheral
    MAP_ADCEnable(ADC_BASE);
}
Exemple #3
0
/******************************************************************************
 DEFINE PUBLIC FUNCTIONS
 ******************************************************************************/
STATIC void pybadc_init (pyb_adc_obj_t *self) {
    // configure the pin in analog mode
    pin_config (self->pin, -1, PIN_TYPE_ANALOG, PIN_TYPE_STD, -1, PIN_STRENGTH_2MA);
    // enable the ADC channel
    MAP_ADCChannelEnable(ADC_BASE, self->channel);
    // enable and configure the timer
    MAP_ADCTimerConfig(ADC_BASE, (1 << 17) - 1);
    MAP_ADCTimerEnable(ADC_BASE);
    // enable the ADC peripheral
    MAP_ADCEnable(ADC_BASE);
}
Exemple #4
0
//used to initialize the ADC associated with the microphone, must be called before
//you do any mic stuff
void InitializeMicrophone() {

		// // Configure ADC timer which is used to timestamp the ADC data samples
		//
		MAP_ADCTimerConfig(ADC_BASE,2^17);

		//
		// Enable ADC timer which is used to timestamp the ADC data samples
		//
		MAP_ADCTimerEnable(ADC_BASE);

	 	// Enable ADC module
		MAP_ADCEnable(ADC_BASE);

		//
		// Enable ADC channel
		//
		MAP_ADCChannelEnable(ADC_BASE, ADC_CH_0);
}
Exemple #5
0
//*****************************************************************************
//
//! main - calls Crypt function after populating either from pre- defined vector 
//! or from User
//!
//! \param  none
//!
//! \return none
//!
//*****************************************************************************
void 
main()
{
    unsigned long  uiAdcInputPin;  
    unsigned int  uiChannel;
    unsigned int  uiIndex=0;
    unsigned long ulSample;      

    //
    // Initialize Board configurations
    //
    BoardInit();

    //
    // Configuring UART for Receiving input and displaying output
    // 1. PinMux setting
    // 2. Initialize UART
    // 3. Displaying Banner
    //
    PinMuxConfig();
    InitTerm();
    DisplayBanner(APP_NAME);

    while(FOREVER)
    {
        //
        // Initialize Array index for multiple execution
        //
        uiIndex=0;
      
        //
        // Read inputs from user
        //
        if(!ReadFromUser(&uiAdcInputPin))
        {
          UART_PRINT("\n\rInvalid Input. Please try again. HAHAHAHAHAHAHAHAHA\n\r");
          continue;
        }

#ifdef CC3200_ES_1_2_1
        //
        // Enable ADC clocks.###IMPORTANT###Need to be removed for PG 1.32
        //
        HWREG(GPRCM_BASE + GPRCM_O_ADC_CLK_CONFIG) = 0x00000043;
        HWREG(ADC_BASE + ADC_O_ADC_CTRL) = 0x00000004;
        HWREG(ADC_BASE + ADC_O_ADC_SPARE0) = 0x00000100;
        HWREG(ADC_BASE + ADC_O_ADC_SPARE1) = 0x0355AA00;
#endif
        //
        // Pinmux for the selected ADC input pin
        //
        MAP_PinTypeADC(uiAdcInputPin,PIN_MODE_255);

        //
        // Convert pin number to channel number
        //
        switch(uiAdcInputPin)
        {
            case PIN_58:
                uiChannel = ADC_CH_1;
                break;
            case PIN_59:
                uiChannel = ADC_CH_2;
                break;
            case PIN_60:
                uiChannel = ADC_CH_3;
                break;
            default:
                break;
        }

        //
        // Configure ADC timer which is used to timestamp the ADC data samples
        //
        MAP_ADCTimerConfig(ADC_BASE,2^17);

        //
        // Enable ADC timer which is used to timestamp the ADC data samples
        //
        MAP_ADCTimerEnable(ADC_BASE);

        //
        // Enable ADC module
        //
        MAP_ADCEnable(ADC_BASE);

        //
        // Enable ADC channel
        //

        MAP_ADCChannelEnable(ADC_BASE, uiChannel);

        while(uiIndex < NO_OF_SAMPLES + 4)
        {
            if(MAP_ADCFIFOLvlGet(ADC_BASE, uiChannel))
            {
                ulSample = MAP_ADCFIFORead(ADC_BASE, uiChannel);
                pulAdcSamples[uiIndex++] = ulSample;
            }


        }

        MAP_ADCChannelDisable(ADC_BASE, uiChannel);

        uiIndex = 0;

        //UART_PRINT("\n\rTotal no of 32 bit ADC data printed :4096 \n\r");
        //UART_PRINT("\n\rADC data format:\n\r");
        //UART_PRINT("\n\rbits[13:2] : ADC sample\n\r");
        //UART_PRINT("\n\rbits[31:14]: Time stamp of ADC sample \n\r");

        //
        // Print out ADC samples
        //

        while(uiIndex < NO_OF_SAMPLES)
        {
            UART_PRINT("\n\rVoltage is %f\n\r",(((float)((pulAdcSamples[4+uiIndex] >> 2 ) & 0x0FFF))*1.4)/4096);
            uiIndex++;
        }


        //UART_PRINT("\n\rVoltage is %f\n\r",((pulAdcSamples[4] >> 2 ) & 0x0FFF)*1.4/4096);
        UART_PRINT("\n\r");

    }

}