コード例 #1
0
ファイル: uart.c プロジェクト: bpyellets/EGR1440
void UART_registerInterrupt(uint32_t moduleInstance, void (*intHandler)(void))
{
    switch (moduleInstance)
    {
    case EUSCI_A0_BASE:
        Interrupt_registerInterrupt(INT_EUSCIA0, intHandler);
        Interrupt_enableInterrupt(INT_EUSCIA0);
        break;
    case EUSCI_A1_BASE:
        Interrupt_registerInterrupt(INT_EUSCIA1, intHandler);
        Interrupt_enableInterrupt(INT_EUSCIA1);
        break;
#ifdef EUSCI_A2_BASE
    case EUSCI_A2_BASE:
        Interrupt_registerInterrupt(INT_EUSCIA2, intHandler);
        Interrupt_enableInterrupt(INT_EUSCIA2);
        break;
#endif
#ifdef EUSCI_A3_BASE
    case EUSCI_A3_BASE:
        Interrupt_registerInterrupt(INT_EUSCIA3, intHandler);
        Interrupt_enableInterrupt(INT_EUSCIA3);
        break;
#endif
    default:
        ASSERT(false);
    }
}
コード例 #2
0
ファイル: i2c.c プロジェクト: AlexTunea23/MPU6050
void I2C_registerInterrupt(uint32_t moduleInstance, void (*intHandler)(void))
{
    switch (moduleInstance)
    {
    case EUSCI_B0_MODULE:
        Interrupt_registerInterrupt(INT_EUSCIB0, intHandler);
        Interrupt_enableInterrupt(INT_EUSCIB0);
        break;
    case EUSCI_B1_MODULE:
        Interrupt_registerInterrupt(INT_EUSCIB1, intHandler);
        Interrupt_enableInterrupt(INT_EUSCIB1);
        break;
#ifdef EUSCI_B2_MODULE
    case EUSCI_B2_MODULE:
        Interrupt_registerInterrupt(INT_EUSCIB2, intHandler);
        Interrupt_enableInterrupt(INT_EUSCIB2);
        break;
#endif
#ifdef EUSCI_B3_MODULE
    case EUSCI_B3_MODULE:
        Interrupt_registerInterrupt(INT_EUSCIB3, intHandler);
        Interrupt_enableInterrupt(INT_EUSCIB3);
        break;
#endif
    default:
        ASSERT(false);
    }
}
コード例 #3
0
ファイル: comp_e.c プロジェクト: AlexTunea23/MPU6050
void COMP_E_registerInterrupt(uint32_t comparator, void (*intHandler)(void))
{
    switch (comparator)
    {
    case COMP_E0_MODULE:
        Interrupt_registerInterrupt(INT_COMP_E0, intHandler);
        Interrupt_enableInterrupt(INT_COMP_E0);
        break;
    case COMP_E1_MODULE:
        Interrupt_registerInterrupt(INT_COMP_E1, intHandler);
        Interrupt_enableInterrupt(INT_COMP_E1);
        break;
    default:
        ASSERT(false);
    }
}
コード例 #4
0
ファイル: timer_a.c プロジェクト: ArduCAM/Energia
void Timer_A_registerInterrupt(uint32_t timer, uint_fast8_t interruptSelect,
        void (*intHandler)(void))
{
    if (interruptSelect == TIMER_A_CCR0_INTERRUPT)
    {
        switch (timer)
        {
        case TIMER_A0_MODULE:
            Interrupt_registerInterrupt(INT_TA0_0, intHandler);
            Interrupt_enableInterrupt(INT_TA0_0);
            break;
        case TIMER_A1_MODULE:
            Interrupt_registerInterrupt(INT_TA1_0, intHandler);
            Interrupt_enableInterrupt(INT_TA1_0);
            break;
        case TIMER_A2_MODULE:
            Interrupt_registerInterrupt(INT_TA2_0, intHandler);
            Interrupt_enableInterrupt(INT_TA2_0);
            break;
        case TIMER_A3_MODULE:
            Interrupt_registerInterrupt(INT_TA3_0, intHandler);
            Interrupt_enableInterrupt(INT_TA3_0);
            break;
        default:
            ASSERT(false);
        }
    } else if (interruptSelect == TIMER_A_CCRX_AND_OVERFLOW_INTERRUPT)
    {
        switch (timer)
        {
        case TIMER_A0_MODULE:
            Interrupt_registerInterrupt(INT_TA0_N, intHandler);
            Interrupt_enableInterrupt(INT_TA0_N);
            break;
        case TIMER_A1_MODULE:
            Interrupt_registerInterrupt(INT_TA1_N, intHandler);
            Interrupt_enableInterrupt(INT_TA1_N);
            break;
        case TIMER_A2_MODULE:
            Interrupt_registerInterrupt(INT_TA2_N, intHandler);
            Interrupt_enableInterrupt(INT_TA2_N);
            break;
        case TIMER_A3_MODULE:
            Interrupt_registerInterrupt(INT_TA3_N, intHandler);
            Interrupt_enableInterrupt(INT_TA3_N);
            break;
        default:
            ASSERT(false);
        }
    } else
    {
        ASSERT(false);
    }
}
コード例 #5
0
ファイル: pss.c プロジェクト: ArduCAM/Energia
void PSS_registerInterrupt(void (*intHandler)(void))
{
    //
    // Register the interrupt handler, returning an error if an error occurs.
    //
    Interrupt_registerInterrupt(INT_PSS, intHandler);

    //
    // Enable the system control interrupt.
    //
    Interrupt_enableInterrupt(INT_PSS);
}
コード例 #6
0
ファイル: gpio.c プロジェクト: DDEFISHER/ECE461Project2
void GPIO_registerInterrupt(uint_fast8_t selectedPort, void (*intHandler)(void))
{
    uint32_t wPortInt;

    wPortInt = GPIO_PORT_TO_INT[selectedPort];

    //
    // Register the interrupt handler, returning an error if an error occurs.
    //
    Interrupt_registerInterrupt(wPortInt, intHandler);

    //
    // Enable the system control interrupt.
    //
    Interrupt_enableInterrupt(wPortInt);
}
コード例 #7
0
void buttonInit(void){
	GPIO_setCallback(Board_BUTTON0, gpioButton0);
	GPIO_enableInt(Board_BUTTON0);

	/* Configure RGB LED pins */
	GPIO_setAsOutputPin(GPIO_PORT_P2, GPIO_PIN4 | GPIO_PIN6);
	GPIO_setAsOutputPin(GPIO_PORT_P5, GPIO_PIN6);

	/* Set RGB LED to red */
	P2OUT |= BIT6;
	P2OUT &= ~BIT4;
	P5OUT &= ~BIT6;

	/* Setup Button */
	GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P5,GPIO_PIN1);
	GPIO_clearInterruptFlag(GPIO_PORT_P5, GPIO_PIN1);
	GPIO_enableInterrupt(GPIO_PORT_P5, GPIO_PIN1);
	GPIO_interruptEdgeSelect(GPIO_PORT_P5, GPIO_PIN1, GPIO_HIGH_TO_LOW_TRANSITION);
	Interrupt_enableInterrupt(INT_PORT5);
}
int main(void)
{
    /* Halting WDT */
    WDT_A_holdTimer();
    Interrupt_enableSleepOnIsrExit();
    
    /* Initializing ADC (MCLK/1/1) */
    ADC14_enableModule();
    ADC14_initModule(ADC_CLOCKSOURCE_MCLK, ADC_PREDIVIDER_1, ADC_DIVIDER_1,
            0);

    /* Configuring ADC Memory (ADC_MEM0 A0/A1 Differential) in repeat mode
     * with use of external references */
    ADC14_configureSingleSampleMode(ADC_MEM0, true);
    ADC14_configureConversionMemory(ADC_MEM0, ADC_VREFPOS_EXTPOS_VREFNEG_EXTNEG,
            ADC_INPUT_A0, true);

    /* Setting up GPIO pins as analog inputs (and references) */
    GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P5,
            GPIO_PIN6 | GPIO_PIN5 | GPIO_PIN4, GPIO_TERTIARY_MODULE_FUNCTION);

    /* Enabling sample timer in auto iteration mode and interrupts*/
    ADC14_enableSampleTimer(ADC_AUTOMATIC_ITERATION);
    ADC14_enableInterrupt(ADC_INT0);

    /* Enabling Interrupts */
    Interrupt_enableInterrupt(INT_ADC14);
    Interrupt_enableMaster();

    /* Triggering the start of the sample */
    ADC14_enableConversion();
    ADC14_toggleConversionTrigger();

    /* Going to sleep */
    while (1)
    {
        PCM_gotoLPM0();
    }
}
コード例 #9
0
ファイル: cli_uart.c プロジェクト: DDEFISHER/ECE461Final
int
CLI_Read(unsigned char *pBuff)
{
    if(pBuff == NULL)
        return -1;
#ifdef _USE_CLI_
    cli_have_cmd = 0;
    g_ucUARTBuffer = pBuff;
    UCA0IE |= UCRXIE;

    Interrupt_enableMaster();
    Interrupt_enableInterrupt(INT_EUSCIA0);
    PCM_gotoLPM0();

    // __bis_SR_register(LPM0_bits + GIE);

    while(cli_have_cmd == 0);
    UCA0IE &= ~UCRXIE;

    return strlen((const char *)pBuff);
#else
    return 0;
#endif
}
コード例 #10
0
ファイル: timer32.c プロジェクト: Eclo/FreeRTOS
void Timer32_registerInterrupt(uint32_t timerInterrupt,
                               void (*intHandler)(void))
{
    Interrupt_registerInterrupt(timerInterrupt, intHandler);
    Interrupt_enableInterrupt(timerInterrupt);
}
コード例 #11
0
ファイル: main.c プロジェクト: bbdomingue/Mechatronics
int main(void) 
{
    WDT_A_holdTimer();

    //Configure Timer
    unsigned int dcoFrequency = 3E+6;
    MAP_CS_setDCOFrequency(dcoFrequency);
    MAP_CS_initClockSignal(CS_SMCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_1); // ( 3Mhz / 64 ) / (Period = 46875) = 1 second

    //Set LED's as outputs and turn off
    MAP_GPIO_setAsOutputPin(GPIO_PORT_P1,GPIO_PIN0);
    MAP_GPIO_setAsOutputPin(GPIO_PORT_P2,GPIO_PIN0);
    MAP_GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0);
    MAP_GPIO_setOutputLowOnPin(GPIO_PORT_P2, GPIO_PIN0);


	////////////////////////////////////////////////////////////////////////////////////////////////////
    //			ADC INITILIZATION P5.5
	////////////////////////////////////////////////////////////////////////////////////////////////////

    /* Initializing ADC */
    MAP_ADC14_enableModule();

    GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P5, GPIO_PIN5, GPIO_TERTIARY_MODULE_FUNCTION); //writes 0's in PXSEL registers for pins 1.2 and 1.3
    MAP_ADC14_setResolution(ADC_10BIT); // initialize to use a 10 Bit ADC
    MAP_ADC14_initModule(ADC_CLOCKSOURCE_SMCLK, ADC_PREDIVIDER_1, ADC_DIVIDER_1,0);

    /* Configuring ADC Memory */
    MAP_ADC14_configureSingleSampleMode(ADC_MEM0, false); //put results in this 16 bit register location to hold results, false means we are manually triggering
    MAP_ADC14_configureConversionMemory(ADC_MEM0, ADC_VREFPOS_AVCC_VREFNEG_VSS, ADC_INPUT_A0, false); //pin 5.5 is tied to channel 0 (A0)
    /* Configuring Sample Timer */
    MAP_ADC14_enableSampleTimer(ADC_MANUAL_ITERATION);

    //Timer A setup
    MAP_Timer_A_configureUpMode(TIMER_A0_MODULE, &upConfig0);
    Interrupt_enableInterrupt(INT_TA0_0);
	Timer_A_startCounter(TIMER_A0_MODULE, TIMER_A_UP_MODE);


    /* Enabling/Toggling Conversion */
    MAP_ADC14_enableConversion();
    MAP_ADC14_toggleConversionTrigger();

	////////////////////////////////////////////////////////////////////////////////////////////////////
    //			END ADC
	////////////////////////////////////////////////////////////////////////////////////////////////////



	////////////////////////////////////////////////////////////////////////////////////////////////////
	//            Timer A 2 and PWM on P5.6
	////////////////////////////////////////////////////////////////////////////////////////////////////

    GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P5, GPIO_PIN6, GPIO_PRIMARY_MODULE_FUNCTION); //writes 0's in PXSEL registers for pins 1.2 and 1.3


    // Set Timer A period (PWM signal period)
    TA2CCR0 = 10000 ; // i think i wrote this wring, his example he showed in class is is 10000
    // Set Duty cycle
    TA2CCR1 = DUTY_CYCLE * 10000; //inital DutyCycle of 0%.. Duty_Cycle is macro
    // Set output mode to Reset/Set
    TA2CCTL1 = OUTMOD_7 ;    // Macro which is equal to 0x00e0, defined in msp432p401r.h
        // Initialize Timer A
    TA2CTL = TASSEL__SMCLK | MC__UP | TACLR ;  // this bitwise or’s multiple settings at the same time (this just sets different bits in the register to set these functionalities/settings)
    											//Does this start the timer?? (is next line necessary?)

	Timer_A_startCounter(TIMER_A2_MODULE, TIMER_A_UP_MODE);
	////////////////////////////////////////////////////////////////////////////////////////////////////
	//          END Timer A 2 and PWM on 5.6
	////////////////////////////////////////////////////////////////////////////////////////////////////


    Interrupt_enableMaster() ;


    while(1){

    	while(MAP_ADC14_isBusy()==0){ // poll the busy flag. we have a conversion going bc we already triggerted it above, so we are waiting for the conversion to be done, when it is, we are going to call the get result function. this just returns the 16 bit value rsults
    		ADC_result = (uint16_t)MAP_ADC14_getResult(ADC_MEM0); //just goes to memory location takes results and returns the 16 bit value... this just continues to get repopulted.
    		MAP_ADC14_toggleConversionTrigger(); ////once we got the result we start a new conversion and we go back to top and begin wiaitng until its dones again
    	}//end nested while
    }//end inf while
}//end main