//***************************************************************************** // // This function is called to start an acquisition running. It determines // which channels are to be logged, enables the ADC sequencers, and computes // the first RTC match value. This will start the acquisition running. // //***************************************************************************** void AcquireStart() { unsigned long ulIdx; ulIdx = ulSelectedMask; g_ulNumItems = 0; while(ulIdx) { if(ulIdx & 1) { g_ulNumItems++; } ulIdx >>= 1; } //USBStickOpenLogFile(0); ROM_ADCSequenceEnable(ADC0_BASE,SEQUENCER); //ROM_ADCSequenceDataGet(ADC0_BASE,SEQUENCER,&g_ulADCData[0]); ROM_ADCIntClear(ADC0_BASE,SEQUENCER); ROM_ADCIntEnable(ADC0_BASE,SEQUENCER); ROM_IntEnable(INT_ADC0SS2); ROM_TimerEnable(TIMER0_BASE, TIMER_A); //ROM_IntEnable(INT_TIMER1A); //ROM_TimerIntEnable(TIMER1_BASE, TIMER_TIMA_TIMEOUT); //ROM_TimerEnable(TIMER1_BASE, TIMER_A); ROM_IntMasterEnable(); }
//***************************************************************************** // //! Initializes the touch screen driver. //! //! \param ui32SysClock is the frequency of the system clock. //! //! This function initializes the touch screen driver, beginning the process of //! reading from the touch screen. This driver uses the following hardware //! resources: //! //! - ADC 0 sample sequence 3 //! - Timer 5 subtimer B //! //! \return None. // //***************************************************************************** void TouchScreenInit(uint32_t ui32SysClock) { // // Set the initial state of the touch screen driver's state machine. // g_ui32TSState = TS_STATE_INIT; // // There is no touch screen handler initially. // g_pfnTSHandler = 0; // // Enable the peripherals used by the touch screen interface. // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER5); // // Configure the ADC sample sequence used to read the touch screen reading. // ROM_ADCHardwareOversampleConfigure(ADC0_BASE, 4); ROM_ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_TIMER, 0); ROM_ADCSequenceStepConfigure(ADC0_BASE, 3, 0, TS_YP_ADC | ADC_CTL_END | ADC_CTL_IE); ROM_ADCSequenceEnable(ADC0_BASE, 3); // // Enable the ADC sample sequence interrupt. // ROM_ADCIntEnable(ADC0_BASE, 3); ROM_IntEnable(INT_ADC0SS3); // // Configure the timer to trigger the sampling of the touch screen // every 2.5 milliseconds. // if((HWREG(TIMER5_BASE + TIMER_O_CTL) & TIMER_CTL_TAEN) == 0) { ROM_TimerConfigure(TIMER5_BASE, (TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_PWM | TIMER_CFG_B_PERIODIC)); } ROM_TimerPrescaleSet(TIMER5_BASE, TIMER_B, 255); ROM_TimerLoadSet(TIMER5_BASE, TIMER_B, ((ui32SysClock / 256) / 400) - 1); TimerControlTrigger(TIMER5_BASE, TIMER_B, true); // // Enable the timer. At this point, the touch screen state machine will // sample and run every 2.5 ms. // ROM_TimerEnable(TIMER5_BASE, TIMER_B); }
void BattSense_init(void) { ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC1); ROM_GPIOPinTypeADC(GPIO_PORTB_BASE, GPIO_PIN_4); ROM_ADCHardwareOversampleConfigure(ADC1_BASE, 64); ROM_ADCSequenceConfigure(ADC1_BASE, 3, ADC_TRIGGER_PROCESSOR, 0); ROM_ADCSequenceStepConfigure(ADC1_BASE, 3, 0, ADC_CTL_END | ADC_CTL_CH10 | ADC_CTL_IE); ROM_ADCSequenceEnable(ADC1_BASE, 3); ADCIntRegister(ADC1_BASE, 3, &BattSenseISR); ROM_ADCIntEnable(ADC1_BASE, 3); battery_Runtimeout(&BattSenseTimerTimout, 10000); }
void LightSensorInit(void) { // Set up pin as ADC ROM_GPIOPinTypeADC(LIGHTSENSOR_PORT, LIGHTSENSOR_PIN); ROM_ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0); ROM_ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH0 | ADC_CTL_IE | ADC_CTL_END); ROM_ADCSequenceEnable(ADC0_BASE, 3); ROM_ADCIntEnable(ADC0_BASE, 3); ROM_ADCIntClear(ADC0_BASE, 3); ADCIntRegister(ADC0_BASE, 3, LightSensorIntHandler); }
//***************************************************************************** // // Initializes the ADC. // //***************************************************************************** void ADCInit(void) { // // Set the ADC speed to 1 Msps. // ROM_SysCtlADCSpeedSet(SYSCTL_ADCSPEED_1MSPS); // // Configure the GPIOs used with the analog inputs. // GPIOPinTypeADC(ADC_POSITION_PORT, ADC_POSITION_PIN); GPIOPinTypeADC(ADC_CURRENT_PORT, ADC_CURRENT_PIN); GPIOPinTypeADC(ADC_VBUS_PORT, ADC_VBUS_PIN); GPIOPinTypeADC(ADC_VBOOTA_PORT, ADC_VBOOTA_PIN); GPIOPinTypeADC(ADC_VBOOTB_PORT, ADC_VBOOTB_PIN); // // Configure the ADC sample sequence that is triggered by PWM // generator 2 // ROM_ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_PWM0, 0); ROM_ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ADC_CURRENT_CH); ROM_ADCSequenceStepConfigure(ADC0_BASE, 0, 1, ADC_VBUS_CH); ROM_ADCSequenceStepConfigure(ADC0_BASE, 0, 2, ADC_POSITION_CH); ROM_ADCSequenceStepConfigure(ADC0_BASE, 0, 3, (ADC_CTL_TS | ADC_CTL_IE | ADC_CTL_END)); ROM_ADCSequenceEnable(ADC0_BASE, 0); // // Enable interrupts // ROM_ADCIntEnable(ADC0_BASE, 0); ROM_IntEnable(INT_ADC0SS0); // // Set the zero current to indicate that the initial sampling has just // begun. // g_usCurrentZero = 0xffff; }
void IRDetector_init(void) { ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); ROM_GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3); ROM_GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3, 0x00); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); ROM_GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3); ROM_ADCHardwareOversampleConfigure(ADC0_BASE, 32); ROM_ADCSequenceConfigure(ADC0_BASE, 2, ADC_TRIGGER_PROCESSOR, 0); ROM_ADCSequenceStepConfigure(ADC0_BASE, 2, 0, ADC_CTL_END | ADC_CTL_CH0 | ADC_CTL_IE); //PE3, enable interrupt ROM_ADCSequenceEnable(ADC0_BASE, 2); ADCIntRegister(ADC0_BASE, 2, &IR_Detector_ISR); ROM_ADCIntEnable(ADC0_BASE, 2); ADC_Step = 0; TURN_ON_IRD1(); ir_Runtimeout(&IR_Timer_Timeout, 1); }
//***************************************************************************** // //! Initializes the touch screen driver. //! //! This function initializes the touch screen driver, beginning the process of //! reading from the touch screen. This driver uses the following hardware //! resources: //! //! - ADC sample sequence 3 //! - Timer 1 subtimer A //! //! \return None. // //***************************************************************************** void TouchScreenInit(void) { // // Set the initial state of the touch screen driver's state machine. // g_ulTSState = TS_STATE_INIT; // // Determine which calibration parameter set we will be using. // g_plParmSet = g_lTouchParameters[SET_NORMAL]; if(g_eDaughterType == DAUGHTER_SRAM_FLASH) { // // If the SRAM/Flash daughter board is present, select the appropriate // calibration parameters and reading threshold value. // g_plParmSet = g_lTouchParameters[SET_SRAM_FLASH]; g_sTouchMin = 40; } else if(g_eDaughterType == DAUGHTER_FPGA) { // // If the FPGA daughter board is present, select the appropriate // calibration parameters and reading threshold value. // g_plParmSet = g_lTouchParameters[SET_FPGA]; g_sTouchMin = 70; } // // There is no touch screen handler initially. // g_pfnTSHandler = 0; // // Enable the peripherals used by the touch screen interface. // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); ROM_SysCtlPeripheralEnable(TS_P_PERIPH); ROM_SysCtlPeripheralEnable(TS_N_PERIPH); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1); // // Configure the ADC sample sequence used to read the touch screen reading. // ROM_ADCHardwareOversampleConfigure(ADC0_BASE, 4); ROM_ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_TIMER, 0); ROM_ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH_YP | ADC_CTL_END | ADC_CTL_IE); ROM_ADCSequenceEnable(ADC0_BASE, 3); // // Enable the ADC sample sequence interrupt. // ROM_ADCIntEnable(ADC0_BASE, 3); ROM_IntEnable(INT_ADC0SS3); // // Configure the GPIOs used to drive the touch screen layers. // ROM_GPIOPinTypeGPIOOutput(TS_P_BASE, TS_XP_PIN | TS_YP_PIN); // // If no daughter board or one which does not rewire the touchscreen // interface is installed, set up GPIOs to drive the XN and YN signals. // if((g_eDaughterType != DAUGHTER_SRAM_FLASH) && (g_eDaughterType != DAUGHTER_FPGA)) { ROM_GPIOPinTypeGPIOOutput(TS_N_BASE, TS_XN_PIN | TS_YN_PIN); } ROM_GPIOPinWrite(TS_P_BASE, TS_XP_PIN | TS_YP_PIN, 0x00); if(g_eDaughterType == DAUGHTER_SRAM_FLASH) { HWREGB(LCD_CONTROL_CLR_REG) = LCD_CONTROL_XN | LCD_CONTROL_YN; } else if(g_eDaughterType == DAUGHTER_FPGA) { HWREGH(LCD_FPGA_CONTROL_CLR_REG) = LCD_CONTROL_XN | LCD_CONTROL_YN; } else { ROM_GPIOPinWrite(TS_N_BASE, TS_XN_PIN | TS_YN_PIN, 0x00); } // // See if the ADC trigger timer has been configured, and configure it only // if it has not been configured yet. // if((HWREG(TIMER1_BASE + TIMER_O_CTL) & TIMER_CTL_TAEN) == 0) { // // Configure the timer to trigger the sampling of the touch screen // every millisecond. // ROM_TimerConfigure(TIMER1_BASE, (TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_PERIODIC | TIMER_CFG_B_PERIODIC)); ROM_TimerLoadSet(TIMER1_BASE, TIMER_A, (ROM_SysCtlClockGet() / 1000) - 1); ROM_TimerControlTrigger(TIMER1_BASE, TIMER_A, true); // // Enable the timer. At this point, the touch screen state machine // will sample and run once per millisecond. // ROM_TimerEnable(TIMER1_BASE, TIMER_A); } }
//***************************************************************************** // //! Initializes the touch screen driver. //! //! This function initializes the touch screen driver, beginning the process of //! reading from the touch screen. This driver uses the following hardware //! resources: //! //! - ADC sample sequence 3 //! - Timer 1 subtimer A //! //! \return None. // //***************************************************************************** void TouchScreenInit(void) { // // Set the initial state of the touch screen driver's state machine. // g_ulTSState = TS_STATE_INIT; // // There is no touch screen handler initially. // g_pfnTSHandler = 0; // // Enable the peripherals used by the touch screen interface. // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); ROM_SysCtlPeripheralEnable(TS_P_PERIPH); ROM_SysCtlPeripheralEnable(TS_N_PERIPH); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1); // // Configure the ADC sample sequence used to read the touch screen reading. // ROM_ADCHardwareOversampleConfigure(ADC0_BASE, 4); ROM_ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_TIMER, 0); ROM_ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH_YP | ADC_CTL_END | ADC_CTL_IE); ROM_ADCSequenceEnable(ADC0_BASE, 3); // // Enable the ADC sample sequence interrupt. // ROM_ADCIntEnable(ADC0_BASE, 3); ROM_IntEnable(INT_ADC0SS3); // // Configure the GPIOs used to drive the touch screen layers. // ROM_GPIOPinTypeGPIOOutput(TS_P_BASE, TS_XP_PIN | TS_YP_PIN); ROM_GPIOPinTypeGPIOOutput(TS_N_BASE, TS_XN_PIN | TS_YN_PIN); ROM_GPIOPinWrite(TS_P_BASE, TS_XP_PIN | TS_YP_PIN, 0x00); ROM_GPIOPinWrite(TS_N_BASE, TS_XN_PIN | TS_YN_PIN, 0x00); // // See if the ADC trigger timer has been configured, and configure it only // if it has not been configured yet. // if((HWREG(TIMER1_BASE + TIMER_O_CTL) & TIMER_CTL_TAEN) == 0) { // // Configure the timer to trigger the sampling of the touch screen // every millisecond. // ROM_TimerConfigure(TIMER1_BASE, (TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_PERIODIC | TIMER_CFG_B_PERIODIC)); ROM_TimerLoadSet(TIMER1_BASE, TIMER_A, (SysCtlClockGet() / 1000) - 1); ROM_TimerControlTrigger(TIMER1_BASE, TIMER_A, true); // // Enable the timer. At this point, the touch screen state machine // will sample and run once per millisecond. // ROM_TimerEnable(TIMER1_BASE, TIMER_A); } }