Ejemplo n.º 1
0
//!
//! \return none
//!
//! \brief  Initializes Push Button Ports and Pins
//
//*****************************************************************************
void Button_IF_Init(P_INT_HANDLER S2InterruptHdl,P_INT_HANDLER S3InterruptHdl )
{
 
  //
  // Set Interrupt Type for GPIO
  //
  MAP_GPIOIntTypeSet(GPIOA1_BASE,GPIO_PIN_5,GPIO_FALLING_EDGE);
  MAP_GPIOIntTypeSet(GPIOA2_BASE,GPIO_PIN_6,GPIO_FALLING_EDGE);

  g_S3InterruptHdl = S3InterruptHdl;
  g_S2InterruptHdl = S2InterruptHdl;
  //
  // Register Interrupt handler
  //
  osi_InterruptRegister(INT_GPIOA1,(P_OSI_INTR_ENTRY)GPIOs3IntHandler, INT_PRIORITY_LVL_1);
  osi_InterruptRegister(INT_GPIOA2,(P_OSI_INTR_ENTRY)GPIOs2IntHandler, INT_PRIORITY_LVL_1);
  //
  // Enable Interrupt
  //
  MAP_GPIOIntClear(GPIOA1_BASE,GPIO_PIN_5);
  MAP_GPIOIntEnable(GPIOA1_BASE,GPIO_INT_PIN_5);
  
  MAP_GPIOIntClear(GPIOA2_BASE,GPIO_PIN_6);
  MAP_GPIOIntEnable(GPIOA2_BASE,GPIO_INT_PIN_6);

}
Ejemplo n.º 2
0
//****************************************************************************
//
//! Main function
//!
//! \param none
//! 
//! This function  
//!    1. Configures the GPIOA1 and A2 interrupt.
//!
//! \return None.
//
//****************************************************************************
int main() {
	//
	// Initialize Board configurations
	//
	BoardInit();

	//
	// Power on the corresponding GPIO port B for 9,10,11.
	// Set up the GPIO lines to mode 0 (GPIO)
	//
	PinMuxConfig();

	//
	// Configure the GPIO13 - SW2 interrupt
	//
	MAP_GPIOIntRegister(GPIOA1_BASE, GPIOA1IntHandler);
	MAP_GPIOIntTypeSet(GPIOA1_BASE, GPIO_PIN_5, GPIO_RISING_EDGE);

	//
	// Configure the GPIO22 interrupt
	//
	MAP_GPIOIntRegister(GPIOA2_BASE, GPIOA2IntHandler);
	MAP_GPIOIntTypeSet(GPIOA2_BASE, GPIO_PIN_6, GPIO_RISING_EDGE);

	//
	// Enable GPIO13 Interrupt
	//
	MAP_GPIOIntClear(GPIOA1_BASE, GPIO_PIN_5);
	MAP_IntPendClear(INT_GPIOA1);
	MAP_IntEnable(INT_GPIOA1);
	MAP_GPIOIntEnable(GPIOA1_BASE, GPIO_PIN_5);

	//
	// Enable GPIO22 Interrupt
	//
	MAP_GPIOIntClear(GPIOA2_BASE, GPIO_PIN_6);
	MAP_IntPendClear(INT_GPIOA2);
	MAP_IntEnable(INT_GPIOA2);
	MAP_GPIOIntEnable(GPIOA2_BASE, GPIO_PIN_6);

	//
	// Infinite loop. All processing happens now in the interrupt handler.
	while (1) {

	}

	return 0;
}
Ejemplo n.º 3
0
//****************************************************************************
//
//! Configures the GPIO selected as input to generate interrupt on activity
//!
//! \param uiGPIOPort is the GPIO port address
//! \param ucGPIOPin is the GPIO pin of the specified port
//! \param uiIntType is the type of the interrupt (refer gpio.h)
//! \param pfnIntHandler is the interrupt handler to register
//! 
//! This function  
//!    1. Sets GPIO interrupt type
//!    2. Registers Interrupt handler
//!    3. Enables Interrupt
//!
//! \return None
//
//****************************************************************************
void
GPIO_IF_ConfigureNIntEnable(unsigned int uiGPIOPort,
                                  unsigned char ucGPIOPin,
                                  unsigned int uiIntType,
                                  void (*pfnIntHandler)(void))
{
    //
    // Set GPIO interrupt type
    //
    MAP_GPIOIntTypeSet(uiGPIOPort,ucGPIOPin,uiIntType);

    //
    // Register Interrupt handler
    //
#ifdef USE_TIRTOS
    osi_InterruptRegister(GetPeripheralIntNum(uiGPIOPort),
                                        pfnIntHandler, INT_PRIORITY_LVL_1);
                
#else
    MAP_GPIOIntRegister(uiGPIOPort,pfnIntHandler);
#endif

    //
    // Enable Interrupt
    //
    MAP_GPIOIntClear(uiGPIOPort,ucGPIOPin);
    MAP_GPIOIntEnable(uiGPIOPort,ucGPIOPin);
}
Ejemplo n.º 4
0
//****************************************************************************
//
//! Configures the GPIO selected as input to generate interrupt on activity
//!
//! \param uiGPIOPort is the GPIO port address
//! \param ucGPIOPin is the GPIO pin of the specified port
//! \param uiIntType is the type of the interrupt (refer gpio.h)
//! \param pfnIntHandler is the interrupt handler to register
//! 
//! This function  
//!    1. Sets GPIO interrupt type
//!    2. Registers Interrupt handler
//!    3. Enables Interrupt
//!
//! \return None
//
//****************************************************************************
void
GPIO_IF_ConfigureNIntEnable(unsigned int uiGPIOPort,
                                  unsigned char ucGPIOPin,
                                  unsigned int uiIntType,
                                  void (*pfnIntHandler)(void))
{
    //
    // Set GPIO interrupt type
    //
    MAP_GPIOIntTypeSet(uiGPIOPort,ucGPIOPin,uiIntType);

    //
    // Register Interrupt handler
    //
#if defined(USE_TIRTOS) || defined(USE_FREERTOS) || defined(SL_PLATFORM_MULTI_THREADED) 
    // USE_TIRTOS: if app uses TI-RTOS (either networking/non-networking)
    // USE_FREERTOS: if app uses Free-RTOS (either networking/non-networking)
    // SL_PLATFORM_MULTI_THREADED: if app uses any OS + networking(simplelink)
    osi_InterruptRegister(GetPeripheralIntNum(uiGPIOPort),
                                        pfnIntHandler, INT_PRIORITY_LVL_1);
                
#else
	MAP_IntPrioritySet(GetPeripheralIntNum(uiGPIOPort), INT_PRIORITY_LVL_1);
    MAP_GPIOIntRegister(uiGPIOPort,pfnIntHandler);
#endif

    //
    // Enable Interrupt
    //
    MAP_GPIOIntClear(uiGPIOPort,ucGPIOPin);
    MAP_GPIOIntEnable(uiGPIOPort,ucGPIOPin);
}
Ejemplo n.º 5
0
STATIC void pin_irq_enable (mp_obj_t self_in) {
    const pin_obj_t *self = self_in;
    uint hib_pin, idx;

    pin_get_hibernate_pin_and_idx (self, &hib_pin, &idx);
    if (idx < PYBPIN_NUM_WAKE_PINS) {
        if (pybpin_wake_pin[idx].lpds != PYBPIN_WAKES_NOT) {
            // enable GPIO as a wake source during LPDS
            MAP_PRCMLPDSWakeUpGPIOSelect(idx, pybpin_wake_pin[idx].lpds);
            MAP_PRCMLPDSWakeupSourceEnable(PRCM_LPDS_GPIO);
        }

        if (pybpin_wake_pin[idx].hib != PYBPIN_WAKES_NOT) {
            // enable GPIO as a wake source during hibernate
            MAP_PRCMHibernateWakeUpGPIOSelect(hib_pin, pybpin_wake_pin[idx].hib);
            MAP_PRCMHibernateWakeupSourceEnable(hib_pin);
        }
        else {
            MAP_PRCMHibernateWakeupSourceDisable(hib_pin);
        }
    }
    // if idx is invalid, the pin supports active interrupts for sure
    if (idx >= PYBPIN_NUM_WAKE_PINS || pybpin_wake_pin[idx].active) {
        MAP_GPIOIntClear(self->port, self->bit);
        MAP_GPIOIntEnable(self->port, self->bit);
    }
    // in case it was enabled before
    else if (idx < PYBPIN_NUM_WAKE_PINS && !pybpin_wake_pin[idx].active) {
        MAP_GPIOIntDisable(self->port, self->bit);
    }
}
Ejemplo n.º 6
0
void Button_IF_EnableInterrupt(unsigned char ucSwitch)
{
    if(ucSwitch & SW2)
    {
        //Enable GPIO Interrupt
        MAP_GPIOIntClear(GPIOA2_BASE,GPIO_PIN_6);
        MAP_IntPendClear(INT_GPIOA2);
        MAP_IntEnable(INT_GPIOA2);
        MAP_GPIOIntEnable(GPIOA2_BASE,GPIO_PIN_6);
    }
    
    if(ucSwitch & SW3)
    {
         //Enable GPIO Interrupt 
         MAP_GPIOIntClear(GPIOA1_BASE,GPIO_PIN_5);     
         MAP_IntPendClear(INT_GPIOA1);
         MAP_IntEnable(INT_GPIOA1);
         MAP_GPIOIntEnable(GPIOA1_BASE,GPIO_PIN_5);  
    }
}
Ejemplo n.º 7
0
//!
//! \return                     0 - Success
//!                               -1 - Error
//!
//! \brief  Initializes Audio Player Push Button Controls
//
//*****************************************************************************
long InitControl(P_AUDIO_HANDLER pAudioInControl,P_AUDIO_HANDLER pAudioOutControl)
{
  long lRetVal = -1;
  //
  // Set Interrupt Type for GPIO
  // 
  MAP_GPIOIntTypeSet(GPIOA1_BASE,GPIO_PIN_5,GPIO_FALLING_EDGE);
  MAP_GPIOIntTypeSet(GPIOA2_BASE,GPIO_PIN_6,GPIO_FALLING_EDGE);
  
  //
  // Store Interrupt handlers
  //
  g_pAudioInControlHdl = pAudioInControl;
  g_pAudioOutControlHdl = pAudioOutControl;
  
  //
  // Register Interrupt handler
  //
  lRetVal = osi_InterruptRegister(INT_GPIOA1,(P_OSI_INTR_ENTRY)MICButtonHandler,\
                                   INT_PRIORITY_LVL_1);
  ASSERT_ON_ERROR(lRetVal);

  lRetVal = osi_InterruptRegister(INT_GPIOA2,(P_OSI_INTR_ENTRY) \
                                      SpeakerButtonHandler,INT_PRIORITY_LVL_1);
  ASSERT_ON_ERROR(lRetVal);
  
  //
  // Enable Interrupt
  //
  MAP_GPIOIntClear(GPIOA1_BASE,GPIO_PIN_5);
  MAP_GPIOIntEnable(GPIOA1_BASE,GPIO_INT_PIN_5);
  MAP_GPIOIntClear(GPIOA2_BASE,GPIO_PIN_6);
  MAP_GPIOIntEnable(GPIOA2_BASE,GPIO_INT_PIN_6);
  
  return SUCCESS;

}
Ejemplo n.º 8
0
//*****************************************************************************
//
//! MicroPhone Control Routine
//!
//! \param  pValue - pointer to a memory structure that is passed 
//!         to the interrupt handler.
//!
//! \return None
//
//*****************************************************************************
void MicroPhoneControl(void* pValue)
{
    int iCount=0;
    unsigned long ulPin5Val = 1; 
    
    //Check whether GPIO Level is Stable As No Debouncing Circuit in LP
    for(iCount=0;iCount<3;iCount++)
    {
        osi_Sleep(200);
        ulPin5Val = MAP_GPIOPinRead(GPIOA1_BASE,GPIO_PIN_5);
        if(ulPin5Val)
        {
            //False Alarm
            return;
        }
    }
    if (g_ucMicStartFlag ==  0)
    {
        for(iCount = 0; iCount<3; iCount++)
        {
            //Blink LED 3 times to Indicate ON
            GPIO_IF_LedOff(MCU_GREEN_LED_GPIO);
            osi_Sleep(50);
            GPIO_IF_LedOn(MCU_GREEN_LED_GPIO);
            osi_Sleep(50);
        }
         g_ucMicStartFlag = 1;
        
     }
     else
     {
        //Blink LED 3 times to Indicate OFF
        for(iCount = 0; iCount<3; iCount++)
        {
            GPIO_IF_LedOn(MCU_GREEN_LED_GPIO);
            osi_Sleep(50);
            GPIO_IF_LedOff(MCU_GREEN_LED_GPIO);
            osi_Sleep(50);
        }
        g_ucMicStartFlag = 0;
     }
    
     //Enable GPIO Interrupt 
     MAP_GPIOIntClear(GPIOA1_BASE,GPIO_PIN_5);
     MAP_IntPendClear(INT_GPIOA1);
     MAP_IntEnable(INT_GPIOA1);
     MAP_GPIOIntEnable(GPIOA1_BASE,GPIO_PIN_5);

}
Ejemplo n.º 9
0
//*****************************************************************************
//
// Initialize the I2C, MPU9150 and Gesture systems.
//
//*****************************************************************************
void
MotionInit(void)
{
    //
    // Enable port S used for motion interrupt.
    //
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOS);

    //
    // The I2C3 peripheral must be enabled before use.
    //
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C3);
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);

    //
    // Configure the pin muxing for I2C3 functions on port G4 and G5.
    //
    MAP_GPIOPinConfigure(GPIO_PG4_I2C3SCL);
    MAP_GPIOPinConfigure(GPIO_PG5_I2C3SDA);

    //
    // Select the I2C function for these pins.  This function will also
    // configure the GPIO pins pins for I2C operation, setting them to
    // open-drain operation with weak pull-ups.  Consult the data sheet
    // to see which functions are allocated per pin.
    //
    MAP_GPIOPinTypeI2CSCL(GPIO_PORTG_BASE, GPIO_PIN_4);
    MAP_GPIOPinTypeI2C(GPIO_PORTG_BASE, GPIO_PIN_5);

    //
    // Configure and Enable the GPIO interrupt. Used for INT signal from the
    // MPU9150
    //
    MAP_GPIOPinTypeGPIOInput(GPIO_PORTS_BASE, GPIO_PIN_2);
    MAP_GPIOIntEnable(GPIO_PORTS_BASE, GPIO_PIN_2);
    MAP_GPIOIntTypeSet(GPIO_PORTS_BASE, GPIO_PIN_2, GPIO_FALLING_EDGE);
    MAP_IntEnable(INT_GPIOS);

    //
    // Enable interrupts to the processor.
    //
    MAP_IntMasterEnable();

    //
    // Initialize I2C3 peripheral.
    //
    I2CMInit(&g_sI2CInst, I2C3_BASE, INT_I2C3, 0xff, 0xff,
             g_ui32SysClock);

    //
    // Set the motion state to initializing.
    //
    g_ui8MotionState = MOTION_STATE_INIT;

    //
    // Initialize the MPU9150 Driver.
    //
    MPU9150Init(&g_sMPU9150Inst, &g_sI2CInst, MPU9150_I2C_ADDRESS,
                MotionCallback, &g_sMPU9150Inst);

    //
    // Wait for transaction to complete
    //
    MotionI2CWait(__FILE__, __LINE__);

    //
    // Write application specifice sensor configuration such as filter settings
    // and sensor range settings.
    //
    g_sMPU9150Inst.pui8Data[0] = MPU9150_CONFIG_DLPF_CFG_94_98;
    g_sMPU9150Inst.pui8Data[1] = MPU9150_GYRO_CONFIG_FS_SEL_250;
    g_sMPU9150Inst.pui8Data[2] = (MPU9150_ACCEL_CONFIG_ACCEL_HPF_5HZ |
                                  MPU9150_ACCEL_CONFIG_AFS_SEL_2G);
    MPU9150Write(&g_sMPU9150Inst, MPU9150_O_CONFIG, g_sMPU9150Inst.pui8Data, 3,
                 MotionCallback, &g_sMPU9150Inst);

    //
    // Wait for transaction to complete
    //
    MotionI2CWait(__FILE__, __LINE__);

    //
    // Configure the data ready interrupt pin output of the MPU9150.
    //
    g_sMPU9150Inst.pui8Data[0] = (MPU9150_INT_PIN_CFG_INT_LEVEL |
                                  MPU9150_INT_PIN_CFG_INT_RD_CLEAR |
                                  MPU9150_INT_PIN_CFG_LATCH_INT_EN);
    g_sMPU9150Inst.pui8Data[1] = MPU9150_INT_ENABLE_DATA_RDY_EN;
    MPU9150Write(&g_sMPU9150Inst, MPU9150_O_INT_PIN_CFG,
                 g_sMPU9150Inst.pui8Data, 2, MotionCallback, &g_sMPU9150Inst);

    //
    // Wait for transaction to complete
    //
    MotionI2CWait(__FILE__, __LINE__);

    //
    // Initialize the DCM system.
    //
    CompDCMInit(&g_sCompDCMInst, 1.0f / ((float) MOTION_SAMPLE_FREQ_HZ),
                DCM_ACCEL_WEIGHT, DCM_GYRO_WEIGHT, DCM_MAG_WEIGHT);

    //
    // Initialize the gesture instance and establish a initial state estimate.
    //
    GestureInit(&g_sGestureInst, g_pfInitProb, g_ppfPath, g_ppfTransitionProb,
                g_ppfEmitProb, GESTURE_PATH_LENGTH, GESTURE_NUM_STATES,
                GESTURE_STATE_IDLE);
}
Ejemplo n.º 10
0
void SpeakerControl(void* pValue)
{
    int iCount=0;
    unsigned long ulPin6Val = 1;
  long lRetVal = -1;
    
    //Check whether GPIO Level is Stable As No Debouncing Circuit in LP
    for(iCount=0;iCount<3;iCount++)
    {
        osi_Sleep(200);
        ulPin6Val = MAP_GPIOPinRead(GPIOA2_BASE,GPIO_PIN_6);
        if(ulPin6Val)
        {
            //False Alarm
            return;
        }
    }
    
    if (g_ucSpkrStartFlag ==  0)
    {
#ifndef MULTICAST   
        //Un Register mDNS Service.
    lRetVal = sl_NetAppMDNSUnRegisterService((signed char *)CC3200_MDNS_NAME,\
                          (unsigned char)strlen((const char *)CC3200_MDNS_NAME));
    if(lRetVal < 0)
    {
      UART_PRINT("Unable to unregister MDNS service\n\r");
    }
    //Registering for the mDNS service.              
    lRetVal = sl_NetAppMDNSRegisterService((signed char *)CC3200_MDNS_NAME, \
                          (unsigned char)strlen((const char *)CC3200_MDNS_NAME),\
                          (signed char *)"multicast",\
                          (unsigned char)strlen((const char *)"multicast"),\
                           AUDIO_PORT,1000,0);    
    if(lRetVal < 0)
    {
      UART_PRINT("Unable to register MDNS service\n\r");
      LOOP_FOREVER();
    }
#endif 
        
        //Blink LED 3 times to Indicate ON
        for(iCount = 0; iCount<3; iCount++)
        {
            GPIO_IF_LedOff(MCU_ORANGE_LED_GPIO);
            osi_Sleep(50);
            GPIO_IF_LedOn(MCU_ORANGE_LED_GPIO);
            osi_Sleep(50);
        }                     
        g_ucSpkrStartFlag = 1;
    }
    else
    {
        //Un Register mDNS Service.
    lRetVal = sl_NetAppMDNSUnRegisterService((signed char *)CC3200_MDNS_NAME,\
                           (unsigned char)strlen((const char *)CC3200_MDNS_NAME));        
    if(lRetVal < 0)
    {
      UART_PRINT("Unable to unregister MDNS service\n\r");
    }
        //Blink LED 3 times to Indicate OFF
        for(iCount = 0; iCount<3; iCount++)
        {
            GPIO_IF_LedOn(MCU_ORANGE_LED_GPIO);
            osi_Sleep(50);
            GPIO_IF_LedOff(MCU_ORANGE_LED_GPIO);
            osi_Sleep(50);
        }
        g_ucSpkrStartFlag = 0;            
    }
    
    //Enable GPIO Interrupt
    MAP_GPIOIntClear(GPIOA2_BASE,GPIO_PIN_6);
    MAP_IntPendClear(INT_GPIOA2);
    MAP_IntEnable(INT_GPIOA2);
    MAP_GPIOIntEnable(GPIOA2_BASE,GPIO_PIN_6);
}
Ejemplo n.º 11
0
/*
 * initialize tm4c
 */
void init_satellite()
{
	FPUEnable();
	FPULazyStackingEnable();

	/*
	 * init clock
	 */
	MAP_SysCtlClockSet(SYSCTL_SYSDIV_3 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);	//66.6..MHz

	MAP_IntMasterEnable();

	/*
	 * Enable peripherals
	 */
	MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);	//for LED indication

	MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);	//for UART
	MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);

	MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);	//for IRQ and SW_EN
	MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);	//for SPI


	/*
	 * configure
	 */
	MAP_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);
	MAP_GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, SIGNAL_LOW);	//off

	MAP_GPIOPinConfigure(GPIO_PA0_U0RX);
	MAP_GPIOPinConfigure(GPIO_PA1_U0TX);
	MAP_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
	UARTStdioConfig(UART_PORT, UART_BAUDRATE, SysCtlClockGet());


	MAP_GPIOIntDisable(GPIO_PORTB_BASE, SIGNAL_HIGH);	//interrupt disable

	MAP_GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_2);	//IRQ as input
	MAP_GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_2, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
	MAP_GPIOIntTypeSet(GPIO_PORTB_BASE, GPIO_PIN_2, GPIO_FALLING_EDGE);		//enable interrupt

	MAP_GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_5);	//sw enable
	MAP_GPIODirModeSet(GPIO_PORTB_BASE, GPIO_PIN_5, GPIO_DIR_MODE_OUT);
	MAP_GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_5, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPD);

	MAP_GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_5, SIGNAL_LOW);

	MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
	MAP_GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, GPIO_PIN_0);

	MAP_GPIOPadConfigSet(GPIO_PORTE_BASE, GPIO_PIN_0, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
	MAP_GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_0, SIGNAL_HIGH);	//chip select

	MAP_GPIOIntEnable(GPIO_PORTB_BASE, GPIO_PIN_2);	//enable interrupt for WLAN_IRQ pin

	SpiCleanGPIOISR();	//clear interrupt status

	MAP_IntEnable(INT_GPIOB);	//spi


	init_worker();

	setState(READY);
}