示例#1
0
void initializeSystem(void) {
    CyGlobalIntEnable;
    
    UART_Start(); 
    
    PrISM_1_Start();
    PrISM_2_Start();
    
    Opamp_1_Start();
    
    // Start the Bluetooth Stack
    CyBle_Start(CustomEventHandler);	
    
    // Set up the LED. First set its output to be off so that the LED doesn't blink on.
    // Then set the drive mode to strong.
	PrISM_1_WritePulse0(255);
	PrISM_1_WritePulse1(255);
	PrISM_2_WritePulse0(255);
	
	RED_SetDriveMode(RED_DM_STRONG);
	GREEN_SetDriveMode(GREEN_DM_STRONG);
	BLUE_SetDriveMode(BLUE_DM_STRONG);
    
    // Start the ADC
    ADC_SAR_Seq_Start();
    ADC_SAR_Seq_StartConvert();
    ADC_SAR_Seq_IRQ_Enable();
    // Enable an interupt for when the ADC has data
    ADC_SAR_Seq_IRQ_StartEx(ADC_SAR_Seq_ISR_LOC);
    
    // Start the Timer for the ADC
    ADC_Timer_Start();
    
    elapsed = 0;
}
/*******************************************************************************
* Function Name: ADC_SAR_Seq_IRQ_Start
********************************************************************************
*
* Summary:
*  Set up the interrupt and enable it. This function disables the interrupt, 
*  sets the default interrupt vector, sets the priority from the value in the
*  Design Wide Resources Interrupt Editor, then enables the interrupt to the 
*  interrupt controller.
*
* Parameters:  
*   None
*
* Return:
*   None
*
*******************************************************************************/
void ADC_SAR_Seq_IRQ_Start(void)
{
    /* For all we know the interrupt is active. */
    ADC_SAR_Seq_IRQ_Disable();

    /* Set the ISR to point to the ADC_SAR_Seq_IRQ Interrupt. */
    ADC_SAR_Seq_IRQ_SetVector(&ADC_SAR_Seq_IRQ_Interrupt);

    /* Set the priority. */
    ADC_SAR_Seq_IRQ_SetPriority((uint8)ADC_SAR_Seq_IRQ_INTC_PRIOR_NUMBER);

    /* Enable it. */
    ADC_SAR_Seq_IRQ_Enable();
}