Beispiel #1
0
/**
 * *brief	init trig pin as input, install interrupt handler on event 1
 * IO pins on lpc11xx can be configured for hysteresis ~0.4V, we enable this to avoid
 * multiple interrupts when optocoupler input is fired from a potential noisy and slow input
 * */
void trigInputInit(void)
{
    /* init timers */
    /* avoid triggerning after reset, and allow inputs to settle */
    timeLast1 = 0;
    timeLast2 = 0;
    timeEdge1 = 0;
    timeEdge2 = 0;

    /* allow interrupts on GPIO 1 & 2 */
    NVIC_EnableIRQ(EINT1_IRQn);
    NVIC_EnableIRQ(EINT2_IRQn);

    /* hard coded pins set pullups and hysteresis TODO*/
    LPC_IOCON->PIO2_2  = 0x00000030;
    LPC_IOCON->PIO1_10 = 0x000000B0;


    GPIOSetDir( TRIG_IN_PORT_1, TRIG_IN_PIN_1, 0);
    GPIOSetDir( TRIG_IN_PORT_2, TRIG_IN_PIN_2, 0);

    /* attach pin to falling edge Interrupt */
    GPIOSetInterrupt(TRIG_IN_PORT_1, TRIG_IN_PIN_1, 0, 0, 0);
    GPIOSetInterrupt(TRIG_IN_PORT_2, TRIG_IN_PIN_2, 0, 0, 0);
    /*enable interrupts*/
    GPIOIntEnable( TRIG_IN_PORT_1, TRIG_IN_PIN_1);
    GPIOIntEnable( TRIG_IN_PORT_2, TRIG_IN_PIN_2);
}
Beispiel #2
0
/*****************************************************************************
**   Main Function  main()
******************************************************************************/
int main (void)
{
  SystemInit();

  GPIOInit();

  /* use port0_1 as input event, interrupt test. */
  GPIOSetDir( PORT0, 1, 0 );
  /* port0_1, single trigger, active high. */
  GPIOSetInterrupt( PORT0, 1, 0, 0, 0 );
  GPIOIntEnable( PORT0, 1 );

  /* use port1_1 as input event, interrupt test. */
  GPIOSetDir( PORT1, 1, 0 );
  /* port0_1, single edge trigger, active high. */
  GPIOSetInterrupt( PORT1, 1, 0, 0, 0 );
  GPIOIntEnable( PORT1, 1 );

  /* use port2_1 as input event, interrupt test. */
  GPIOSetDir( PORT2, 1, 0 );
  /* port0_1, single edge trigger, active high. */
  GPIOSetInterrupt( PORT2, 1, 0, 0, 0 );
  GPIOIntEnable( PORT2, 1 );

  /* use port3_1 as input event, interrupt test. */
  GPIOSetDir( PORT3, 1, 0 );
  /* port0_1, single edge trigger, active high. */
  GPIOSetInterrupt( PORT3, 1, 0, 0, 0 );
  GPIOIntEnable( PORT3, 1 );

  while( 1 );
}
Beispiel #3
0
void Input_Init(void) {
    // Mo clock cho ngoai vi
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);

    // Cau hinh la ngo vao cho port F
    GPIODirModeSet(GPIO_PORTF_BASE, 0x1F,
    GPIO_DIR_MODE_IN);

    // Cau hinh la ngo vao cho port E
    GPIODirModeSet(GPIO_PORTE_BASE, 0x0F,
    GPIO_DIR_MODE_IN);

    // Cau hinh tro keo len cho port F
    GPIOPadConfigSet(GPIO_PORTF_BASE, 0x1F,
    GPIO_STRENGTH_2MA,
    GPIO_PIN_TYPE_STD_WPU);

    GPIOPadConfigSet(GPIO_PORTE_BASE, 0x0F,
    GPIO_STRENGTH_2MA,
    GPIO_PIN_TYPE_STD_WPU);

    // Cau hinh va enable ngat cho port F
    GPIOIntTypeSet(GPIO_PORTF_BASE, 0x1F, GPIO_RISING_EDGE);
    IntEnable(INT_GPIOF);
    GPIOIntEnable(GPIO_PORTF_BASE, 0x1F);

    GPIOIntTypeSet(GPIO_PORTE_BASE, 0x0F, GPIO_RISING_EDGE);
    IntEnable(INT_GPIOE);
    GPIOIntEnable(GPIO_PORTE_BASE, 0x0F);
}
Beispiel #4
0
void spi_gpio_init(uint8_t int_flag)
{
        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);

        //F0-----MISO    -----  INPUT
        ROM_GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_0);

        //F1,F2,F3:MOSI,CLK,CSN  -----  OUTPUT
        ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);

        //CE-----PA6                 -----  OUTPUT
        ROM_GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_6);

        //IRQ-----PA7    -----  INPUT
        ROM_GPIOPinTypeGPIOInput(GPIO_PORTA_BASE, GPIO_PIN_7);

        if(int_flag == 1) //开引脚外部中断
        {
                GPIOIntTypeSet(GPIO_PORTA_BASE,GPIO_PIN_7,GPIO_FALLING_EDGE);
                GPIOIntEnable(GPIO_PORTA_BASE,GPIO_INT_PIN_7); //打开PA7外部中断进行数据读取
                GPIOIntRegister(GPIO_PORTA_BASE, PA7_int_hander);//指定外部中断处理函数
        }
        else
        {
                GPIOIntDisable(GPIO_PORTA_BASE,GPIO_INT_PIN_7);
        }
}
Beispiel #5
0
void confGPIO(){
	//Inicializa el puerto F (LEDs) --> No hace falta si usamos la libreria RGB
	 //   ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
	 // ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);
	//ROM_GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 0);	//LEDS APAGADOS

	ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
	GPIOPinTypeGPIOInput(GPIO_PORTE_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);
	SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_GPIOE);



	//Inicializa los LEDs usando libreria RGB
	RGBInit(1);
	SysCtlPeripheralSleepEnable(GREEN_TIMER_PERIPH);
	SysCtlPeripheralSleepEnable(BLUE_TIMER_PERIPH);
	RGBEnable();

	//Inicializamos los botones y su interrupción
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
	ButtonsInit();
	GPIOIntClear(GPIO_PORTF_BASE, GPIO_INT_PIN_0|GPIO_INT_PIN_4);
	GPIOIntRegister(GPIO_PORTF_BASE,ButtonHandler);
	GPIOIntTypeSet(GPIO_PORTF_BASE,GPIO_INT_PIN_0|GPIO_INT_PIN_4, GPIO_BOTH_EDGES);
	GPIOIntEnable(GPIO_PORTF_BASE, GPIO_INT_PIN_0|GPIO_INT_PIN_4);
	SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_GPIOF);


}
Beispiel #6
0
void setup_buttonInterrupts(){

	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
	GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_4);
	GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_0);

	GPIOIntEnable(GPIO_PORTF_BASE, (GPIO_INT_PIN_1 | GPIO_INT_PIN_2 | GPIO_INT_PIN_4));
	GPIOIntRegister(GPIO_PORTF_BASE, bHandler);
	GPIOIntTypeSet(GPIO_PORTF_BASE, (GPIO_PIN_1 | GPIO_PIN_2 | GPIO_INT_PIN_4) , GPIO_FALLING_EDGE);

	GPIOIntEnable(GPIO_PORTB_BASE, GPIO_INT_PIN_0);
	GPIOIntRegister(GPIO_PORTB_BASE, brakeHandler);
	GPIOIntTypeSet(GPIO_PORTB_BASE, GPIO_PIN_0, GPIO_FALLING_EDGE);

}
Beispiel #7
0
int main(void) {

	SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);
	IntMasterEnable();

	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);

	GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5);
	GPIOPinTypeGPIOInput(GPIO_PORTC_BASE, GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7);

	GPIOPadConfigSet(GPIO_PORTC_BASE, GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7, 0, GPIO_PIN_TYPE_STD_WPU);

	GPIOIntRegister(GPIO_PORTC_BASE, decodeMatrixInput);
	GPIOIntTypeSet(GPIO_PORTC_BASE, GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7, GPIO_FALLING_EDGE);
	GPIOIntEnable(GPIO_PORTC_BASE, GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7);

	GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5, 0);

	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
	GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_0);

	srand(time(NULL));

	initLEDStrip();

	activePattern = 15; // init active pattern to blank

	while (1)
		activatePattern(activePattern);
}
Beispiel #8
0
/*****************************************************
 * 	Function: init_BtnHandler
 *	Description: Initializes button interrupt
 *			Initializes timer for button counter
 *	Input: NONE
 *	Output: NONE
 *****************************************************/
void init_BtnHandler(void)
{
	// Unlock un-maskable pin
	HWREG(BTN_OVERRIDE_REG + GPIO_O_LOCK) = GPIO_LOCK_KEY;

	// Set up our interrupt for button presses
	IntMasterDisable();																				// Disable all interrupts
	GPIOIntDisable(BTN_OVERRIDE_REG, BTN_OVERRIDE);
	GPIOPinTypeGPIOInput(BTN_OVERRIDE_REG, BTN_OVERRIDE);
	GPIOPadConfigSet(BTN_OVERRIDE_REG, BTN_OVERRIDE, GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD_WPU);		// Set Pull-up
	GPIOIntTypeSet(BTN_OVERRIDE_REG, BTN_OVERRIDE, GPIO_BOTH_EDGES); 								// Set edge to trigger on
	GPIOIntClear(BTN_OVERRIDE_REG, BTN_OVERRIDE); 													// Clear the interrupt bit
	GPIOIntEnable(BTN_OVERRIDE_REG, BTN_OVERRIDE); 													// Enable the interrupt
	IntEnable(INT_GPIOE);

	// Lock un-maskable pin
	HWREG(BTN_OVERRIDE_REG + GPIO_O_LOCK) = 0;

	// Setup timer interrupt for button pressing
	// This timer will run up and when it is released we will check how long it was running
	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
	TimerConfigure(BTN_OVERRIDE_TIM_BASE, TIMER_CFG_PERIODIC);					// Setup interrupt as 32 bit timer counting up
	TimerLoadSet(BTN_OVERRIDE_TIM_BASE, BTN_OVERRIDE_TIM, clockTime/1000);		// Load Timer
	IntEnable(INT_TIMER0A);
	TimerIntEnable(BTN_OVERRIDE_TIM_BASE, TIMER_TIMA_TIMEOUT);

	// Turn the input pin to the button high
	GPIOPinTypeGPIOOutput(BTN_OVERRIDE_CONTROL_REG, BTN_OVERRIDE_CONTROL);
	GPIOPinWrite(BTN_OVERRIDE_CONTROL_REG, BTN_OVERRIDE_CONTROL, BTN_OVERRIDE_CONTROL);
}
Beispiel #9
0
void CC3100_InterruptEnable()
{
    GPIOIntEnable(CC3100_IRQBASE,CC3100_IRQPIN);
#ifdef SL_IF_TYPE_UART
    ROM_UARTIntEnable(CC3100_UARTBASE, UART_INT_RX);
#endif
}
Beispiel #10
0
void mode2set()
{
	GPIOIntClear(GPIO_PORTF_BASE, GPIO_PIN_4);		//Clear any existing interrupts
	GPIOIntEnable(GPIO_PORTF_BASE, GPIO_PIN_4);		//Enable the GPIO Interrupts on Port F
	TimerLoadSet(TIMER1_BASE, TIMER_A,SysCtlClockGet()/3);	//Set the Max Value of the timer
	IntEnable(INT_TIMER1A);
	TimerIntEnable(TIMER1_BASE,TIMER_TIMA_TIMEOUT);	//Enable Timer1 Interrupt
}
Beispiel #11
0
/**
 * @brief	calculate time between sucessive AC trigger pulses, or read a DC signal,
 * depending on configuration, return trigger status if signal is valid
 *
 * @return	TRIGGER_ACTIVE or	NO_TRIGGER
 * */
int trigInputRead(void)
{
    int ret = NO_TRIGGER;

#ifdef TRIG_ON_AC
    /* atomic section, no IRQ's while calculating */
    GPIOIntDisable( TRIG_IN_PORT_1, TRIG_IN_PIN_1);
    GPIOIntDisable( TRIG_IN_PORT_2, TRIG_IN_PIN_2);


    /* any changes  wich is not noise ?*/
    if ((timeEdge1 - timeLast1) > TRIG_TIME_MS_MIN)
    {
        //GPIOSetValue( 1, 11, 1);

        ret |=  TRIGGER1_ACTIVE;
        /* allign timers */
        timeEdge1 = millis();
        timeLast1 =timeEdge1;

        //GPIOSetValue( 1, 11, 0);
    }
    /* any changes  wich is not noise ?*/
    if ((timeEdge2 - timeLast2) > TRIG_TIME_MS_MAX)
    {
        ret |=  TRIGGER2_ACTIVE;
        timeEdge2 = millis();
        timeLast2 =timeEdge2;
    }
    GPIOIntEnable( TRIG_IN_PORT_1, TRIG_IN_PIN_1);
    GPIOIntEnable( TRIG_IN_PORT_2, TRIG_IN_PIN_2);
    /* atomic section ends here */
#endif

//#ifdef TRIG_ON_DC
#if 0
    /* if trigger is low, we have DC*/
    if (!(LPC_GPIO_PORT->PIN0 & TRIG_IN_PIN))
    {
        return TRIGGER_ACTIVE;
    }
#endif
    return ret;
}
Beispiel #12
0
void GPIOIntInit(){
	//Enables GPIO interrupt
    MAP_IntEnable(INT_GPIOA1);
    //Register GPIO interrup with the function GIOPIntHandler()
    GPIOIntRegister(GPIOA1_BASE, GPIOIntHandler);
    //Enables the GPIO interrupt
    GPIOIntEnable(GPIOA1_BASE, 0x10);
    //Set type to falling edge
    GPIOIntTypeSet(GPIOA1_BASE, 0x10, GPIO_FALLING_EDGE);
}
Beispiel #13
0
// interrupter in PIO
void init_eint(void)
{
//P0.7
  GPIO_SetIOCONFunc(PORT0, 7);	
  /* 使用Port0.7作为外部中断输入测试 */
  GPIOSetDir( PORT0, 7, 0 );
  /* P0.7外部中断单端触发、高电平有效 */
  GPIOSetInterrupt( PORT0, 1, 7, 0, 0 );
  GPIOIntEnable( PORT0, 7 );
}
/*
 *  ======== WiFiCC3100_open ========
 */
WiFi_Handle WiFiCC3100_open(WiFi_Handle handle, unsigned int spiIndex,
	WiFi_evntCallback evntCallback, WiFi_Params *params)
{
    unsigned int              key;
    WiFiCC3100_Object        *object = handle->object;
    WiFiCC3100_HWAttrs const *hwAttrs = handle->hwAttrs;
    union {
#if !defined(MSP430WARE)
        Hwi_Params            hwiParams;
#endif
        Semaphore_Params      semParams;
    } paramsUnion;

    key = Hwi_disable();
    if (object->isOpen) {
        Hwi_restore(key);
        Log_warning0("WiFi Hwi already in use.");
        return (NULL);
    }
    object->isOpen = true;
    Hwi_restore(key);

    /* Construct semaphores to block read/write transactions. */
    Semaphore_Params_init(&(paramsUnion.semParams));
    paramsUnion.semParams.mode = Semaphore_Mode_BINARY;
    paramsUnion.semParams.instance->name = "WiFi.writeSemaphore";
    Semaphore_construct(&(object->writeSemaphore), 0, &(paramsUnion.semParams));

    paramsUnion.semParams.instance->name = "WiFi.readSemaphore";
    Semaphore_construct(&(object->readSemaphore), 0, &(paramsUnion.semParams));

#if !defined(MSP430WARE)
    Hwi_Params_init(&(paramsUnion.hwiParams));
    paramsUnion.hwiParams.arg = (UArg) handle;
    paramsUnion.hwiParams.enableInt = false;

    /* Hwi_construct cannot fail, use NULL instead of an Error Block */
    Hwi_construct(&(object->wifiHwi), hwAttrs->irqIntNum,
	    WiFiCC3100_hostIntHandler, &(paramsUnion.hwiParams), NULL);
#endif

#if defined(MSP430WARE) || defined(MSP432WARE)
    MAP_GPIO_clearInterruptFlag(hwAttrs->irqPort, hwAttrs->irqPin);
    MAP_GPIO_enableInterrupt(hwAttrs->irqPort, hwAttrs->irqPin);
#else
    GPIOIntClear(hwAttrs->irqPort, hwAttrs->irqPin);
    GPIOIntEnable(hwAttrs->irqPort, hwAttrs->irqPin);
#endif

    /* Store SPI interface parameters */
    object->spiIndex = spiIndex;
    object->bitRate = params->bitRate;

    return (handle);
}
Beispiel #15
0
extern "C" int main(void) {
    unsigned long ir_period;

    // 40 MHz system clock
    SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|
        SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);

	ConfigureUART();
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

    //
    // Unlock PF0 so we can change it to a GPIO input
    // Once we have enabled (unlocked) the commit register then re-lock it
    // to prevent further changes.  PF0 is muxed with NMI thus a special case.
    //
    HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY;
    HWREG(GPIO_PORTF_BASE + GPIO_O_CR) |= 0x01;
    HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = 0;

	// Interrupt on sw1
    GPIODirModeSet(IR_PORT, IR_PIN, GPIO_DIR_MODE_IN);
    GPIOPadConfigSet(IR_PORT, IR_PIN, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
	GPIOPinTypeGPIOInput(IR_PORT, IR_PIN);
	GPIOIntTypeSet(IR_PORT, IR_PIN, GPIO_FALLING_EDGE);
	GPIOIntRegister(IR_PORT, ir_input_isr);
	GPIOIntEnable(IR_PORT, IR_PIN );

	IntMasterEnable();

    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1);
    GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1, 0);
    GPIOPinConfigure(GPIO_PF1_T0CCP1);
    GPIOPinTypeTimer(GPIO_PORTF_BASE, GPIO_PIN_1);

    // Configure timer
    ir_period = SysCtlClockGet() / (IR_CARRIER / 2);

	UARTprintf("ir_period:%d\n", ir_period);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
    TimerConfigure(TIMER0_BASE, TIMER_CFG_SPLIT_PAIR|TIMER_CFG_B_PWM);
    TimerLoadSet(TIMER0_BASE, TIMER_B, ir_period);
    TimerMatchSet(TIMER0_BASE, TIMER_B, ir_period / 2); // PWM
    TimerEnable(TIMER0_BASE, TIMER_B);

	unsigned long m = 0;
	while(1) {
		TimerMatchSet(TIMER0_BASE, TIMER_B, m++); // PWM
		if (m > ir_period) m = 0;
		int i = 0;
		while (i++ < 5000)
			if (!ir.empty())
				UARTprintf("%u", ir.pop_front());
	}
}
Beispiel #16
0
void GPIO_Init() {
	//INPUTS: PB2 - ENABLE READ / PD1 - COUNT
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
	GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_2);
	GPIOPinTypeGPIOInput(GPIO_PORTD_BASE, GPIO_PIN_1);
	//CONFIGURE GPIO INTERRUPT  (PD1 RISE AND DOWN)
	GPIOIntTypeSet(GPIO_PORTD_BASE,GPIO_PIN_1,GPIO_BOTH_EDGES);
	GPIOIntRegister(GPIO_PORTD_BASE,GPIODIntHandler);
	GPIOIntEnable(GPIO_PORTD_BASE, GPIO_INT_PIN_1);
}
Beispiel #17
0
void interrupt_setup(void)
{

    // Interrupt setuü
    GPIOIntDisable(GPIO_PORTF_BASE, GPIO_PIN_4);        // Disable interrupt for PF4 (in case it was enabled)
    GPIOIntClear(GPIO_PORTF_BASE, GPIO_PIN_4);      // Clear pending interrupts for PF4
    GPIOIntRegister(GPIO_PORTF_BASE, onButtonDown);     // Register our handler function for port F
    GPIOIntTypeSet(GPIO_PORTF_BASE, GPIO_PIN_4,
        GPIO_FALLING_EDGE);             // Configure PF4 for falling edge trigger
    GPIOIntEnable(GPIO_PORTF_BASE, GPIO_PIN_4);     // Enable interrupt for PF4

}
Beispiel #18
0
/*********************************************************************************************************
** Function name:           ConfigureFanFb
** Descriptions:            
** input parameters:        
**                          
** Output parameters::      无
** Returned value:          
**                          
** Created by:     zhangwen          
** Created Date:            
**--------------------------------------------------------------------------------------------------------
** Modified by:            
** Modified date:          
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
void ConfigureFanFb()
{      
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
    //
    // Reset the error indicator.
    GPIOPinTypeGPIOInput(GPIO_PORTD_BASE,GPIO_PIN_2);
    GPIOIntTypeSet(GPIO_PORTD_BASE, GPIO_PIN_2, GPIO_RISING_EDGE);

    ROM_GPIODirModeSet(GPIO_PORTD_BASE, GPIO_PIN_2, GPIO_DIR_MODE_IN);
    //GPIOPadConfigSet(GPIO_PORTD_BASE, GPIO_PIN_2,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_OD);
    GPIOIntEnable(GPIO_PORTD_BASE,GPIO_PIN_2);
    IntEnable(INT_GPIOD); // 使能GPIOD端口中断
}
Beispiel #19
0
void Keyboard_Handler(void)
{
   // task setup
   INT8U  key      = NO_KEY;
   INT32U read = 0;

   ButtonsInit();

   if (OSSemCreate(0,&sKeyboard) != ALLOC_EVENT_OK)
   {
     // Oh Oh
     // Não deveria entrar aqui !!!
     while(1){};
   };

   if (OSQueueCreate(64, &qKeyboard) != ALLOC_EVENT_OK)
   {
     // Oh Oh
     // Não deveria entrar aqui !!!
     while(1){};
   };

   // task main loop
   for (;;)
   {
      // Wait for a keyboard interrupt
      OSSemPend (sKeyboard,0);
      DelayTask(50);

      read = GPIOPinRead(BUTTONS_GPIO_BASE, ALL_BUTTONS);

      // Find out which key was pressed
      key = (INT8U)read;

      // Copy the key to the keyboard buffer
      if(key != NO_KEY)
      {
    	if (OSQueuePost(qKeyboard, key) == BUFFER_UNDERRUN)
        {
          // Buffer overflow
          OSQueueClean(qKeyboard);
        }
      }

      key = NO_KEY;
      DelayTask(200);
      // Enable interrupt to the next key detection
      GPIOIntEnable(BUTTONS_GPIO_BASE, ALL_BUTTONS);
   }
}
Beispiel #20
0
int main() {

  //SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
  //Enable Peripherals
  SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
  SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
  SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
  SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
  SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);



  //Start specific Pin Ports
  GPIOPinTypeGPIOOutput(port_A, GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4);
  GPIOPinTypeGPIOOutput(port_C, GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7);
  GPIOPinTypeGPIOOutput(port_D, GPIO_PIN_6);
  GPIOPinTypeGPIOOutput(port_E, GPIO_PIN_0);
  GPIOPinTypeGPIOOutput(port_F, GPIO_PIN_4 | GPIO_PIN_1);

  //Input Pins
  GPIOPinTypeGPIOInput(port_F, GPIO_PIN_2 | GPIO_PIN_3);

  //Enable pin for interrupt
  GPIOIntEnable(GPIO_PORTF_BASE, (GPIO_INT_PIN_2 | GPIO_INT_PIN_3));


  //Set ISR
  GPIOIntRegister(GPIO_PORTF_BASE, scroll_button_isr);

  //Set interrupt type
  GPIOIntTypeSet(GPIO_PORTF_BASE, (GPIO_PIN_2 | GPIO_PIN_3) , GPIO_FALLING_EDGE);

  ROM_SysCtlPeripheralSleepDisable(SYSCTL_PERIPH_GPIOA);
  ROM_SysCtlPeripheralSleepDisable(SYSCTL_PERIPH_GPIOC);
  ROM_SysCtlPeripheralSleepDisable(SYSCTL_PERIPH_GPIOD);
  ROM_SysCtlPeripheralSleepDisable(SYSCTL_PERIPH_GPIOE);


  ROM_SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_GPIOF);
  ROM_SysCtlPeripheralClockGating(true);

  //Initialize the display
  initializeDisplay();


  //Write phrases
  write_phrases();


}
Beispiel #21
0
int main() {

  //Enable Peripherals
  SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); 
  SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC); 
  SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);  
  SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);  
  SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);  
  SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);

  
  //Start specific Pin Ports
  GPIOPinTypeGPIOOutput(port_A, GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4); 
  GPIOPinTypeGPIOOutput(port_C, GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7); 
  GPIOPinTypeGPIOOutput(port_D, GPIO_PIN_6); 
  GPIOPinTypeGPIOOutput(port_E, GPIO_PIN_0); 
  GPIOPinTypeGPIOOutput(port_F, GPIO_PIN_4); 
  GPIOPinTypeGPIOInput(port_F, GPIO_PIN_2 | GPIO_PIN_3);
  
  //Timer Configuration
  TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);
  TimerLoadSet(TIMER0_BASE, TIMER_A, frequency);
  TimerControlEvent(TIMER0_BASE, TIMER_A, TIMER_EVENT_POS_EDGE);
  TimerEnable(TIMER0_BASE, TIMER_A);

  
  //Enable pin for interrupt
  GPIOIntEnable(GPIO_PORTF_BASE, (GPIO_INT_PIN_2 | GPIO_INT_PIN_3));
  
  //Set ISR
  GPIOIntRegister(GPIO_PORTF_BASE, the_taco_meter);
  
  //Set interrupt type
  GPIOIntTypeSet(GPIO_PORTF_BASE, (GPIO_PIN_2 | GPIO_PIN_3) , GPIO_BOTH_EDGES);
  
  //Initialize the display
  initializeDisplay();
  
  
  //RS High
  GPIOPinWrite(port_C, GPIO_PIN_5, pin_5);
  write_string("Speed = #### RPM");

  
  while(1) { 
    taco_display(); 
  }

}
Beispiel #22
0
void Button_init(void)
{
	ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY;
    HWREG(GPIO_PORTF_BASE + GPIO_O_CR) = 0x01;
    HWREG(GPIO_PORTF_BASE + GPIO_O_AFSEL) &= ~0x01;

    ROM_GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_0 | GPIO_PIN_4);
    ROM_GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_0 | GPIO_PIN_4, GPIO_STRENGTH_8MA_SC, GPIO_PIN_TYPE_STD_WPU);
    ROM_GPIOIntTypeSet(GPIO_PORTF_BASE, GPIO_PIN_0 | GPIO_PIN_4, GPIO_FALLING_EDGE);
	GPIOIntRegister(GPIO_PORTF_BASE, &ButtonsISR);
	ROM_IntEnable(INT_GPIOF);
	GPIOIntEnable(GPIO_PORTF_BASE, GPIO_PIN_0 | GPIO_PIN_4);
	GPIOIntClear(GPIO_PORTF_BASE, GPIO_PIN_0 | GPIO_PIN_4);
}
Beispiel #23
0
 int main(){
	  SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);

	  SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
	  SysCtlDelay(3);

	  GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_1);
	  GPIOPadConfigSet(GPIO_PORTF_BASE,GPIO_PIN_1,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU);
	  GPIOIntTypeSet(GPIO_PORTF_BASE,GPIO_PIN_1,GPIO_BOTH_EDGES);
	  GPIOIntRegister(GPIO_PORTF_BASE,PortFIntHandler);
	  GPIOIntEnable(GPIO_PORTF_BASE, GPIO_INT_PIN_1);

	  int i;
	  for( i=0; i < size; i++)
	    values[i] = 0;
	  SysTickbegin();
	  SPIInit();
	  SendData(values,size);
	  Wait(1000);


	  while(1){
		  int i;
		  Policia();
		  PadraoInit=0;
		  MudaPadrao = 0;


		  for(i=0; i < 3 && MudaPadrao==0; i++)
			  Pattern3();
		  	  PadraoInit=0;
		  	  MudaPadrao = 0;

		  Ambulancia();
		  PadraoInit=0;
		  MudaPadrao = 0;

		  for(i=0; i < 3 && MudaPadrao==0; i++)
			  Pattern2();
		  	  PadraoInit=0;
		  	  MudaPadrao = 0;

		  Pattern4();
	  	  PadraoInit=0;
	  	  MudaPadrao = 0;
	  }
}
Beispiel #24
0
// Main
void main(void) {
	mainSetup();
	IntMasterEnable();

	GPIOIntRegister(GPIO_PORTJ_BASE, interruptHandler);
	GPIOIntTypeSet(GPIO_PORTJ_BASE, GPIO_PIN_0, GPIO_FALLING_EDGE);
	GPIOIntEnable(GPIO_PORTJ_BASE, GPIO_PIN_0);
	//GPIOIntTypeSet(GPIO_PORTJ_BASE, GPIO_PIN_1, GPIO_FALLING_EDGE);
	//GPIOIntEnable(GPIO_PORTJ_BASE, GPIO_PIN_1);

	SysTickEnable();
	SysTickPeriodSet(currentFreq);
	SysTickIntRegister(timerstep);
	SysTickIntEnable();

	while (true);
}
Beispiel #25
0
void gpiob_ini(void)
{
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);

	//GPIOPinTypeGPIOInput(GPIO_PORTB_BASE,GPIO_PIN_1);

	GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_1, GPIO_STRENGTH_2MA,

			GPIO_PIN_TYPE_STD_WPD);



	GPIOIntTypeSet(GPIO_PORTB_BASE, GPIO_PIN_1,
			GPIO_BOTH_EDGES);
	IntMasterEnable();                                              //全局中断使能
	IntEnable(INT_GPIOB);                                           //使能串口0中断
	GPIOIntEnable(GPIO_PORTB_BASE, GPIO_INT_PIN_1);          //使能串口0接收中断和接收超时中断

}
Beispiel #26
0
//jykim_080730_default_interrupt_disable_head++
void InterruptControl(void) {
	/*Timer Interrupt Setting*/
	if (TIMER_INT_ENABLE) {
		OpenRiscEnableTimerInt(TIMER_INT_PERIOD_VALUE);//(0xfff : 4096 clk)
	} else {
		OpenRiscDisableTimerInt();
	}

	/*Extenal Interrupt Setting*/
	IntDisable(0xffffffff);
	IntEnable(INTERRUPT_CONTROL_VALUE);

	//090408_jykim_dvp_handshaking_head+
	//GPIO Interrupt Enable
	if (INTERRUPT_CONTROL_VALUE & AHB2APB_GPIO_INT_BIT) {
		GPIOIntEnable(GPIO14 | GPIO15);
	}
	//090408_jykim_dvp_handshaking_tail+
}
/**
 * /fn InitializeLedUserSwitch
 * /brief Initialize led D1 und USR SW1.
 * /return void.
 */
static void InitializeLedUserSwitch() {
	uint32_t strength;
	uint32_t pinType;
	Hwi_Params buttonHWIParams;
	Hwi_Handle buttonHwi;
	Error_Block eb;

	// enable port N
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
	// LED2
	GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_0);

	/* set pin gpio port to output */
	GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_1);
	/*configure pad as standard pin with default output current*/
	GPIOPadConfigGet(GPIO_PORTN_BASE, GPIO_PIN_1, &strength, &pinType);
	GPIOPadConfigSet(GPIO_PORTN_BASE, GPIO_PIN_1, strength, GPIO_PIN_TYPE_STD);

	/* turn off led 1 */
	GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_1, 0);

	/* configure switch 1 with pull up as input on GPIO_PIN_0 as pull-up pin */
	GPIOPinTypeGPIOInput(GPIO_PORTJ_BASE, GPIO_PIN_0);
	GPIOPadConfigGet(GPIO_PORTJ_BASE, GPIO_PIN_0, &strength, &pinType);
	GPIOPadConfigSet(GPIO_PORTJ_BASE, GPIO_PIN_0, strength,
	GPIO_PIN_TYPE_STD_WPU);

	Error_init(&eb);
	Hwi_Params_init(&buttonHWIParams);
	buttonHWIParams.arg = 0;
	buttonHWIParams.enableInt = false;

	buttonHwi = Hwi_create(INT_GPIOJ_TM4C129, ButtonFunction, &buttonHWIParams,
			&eb);

	if (buttonHwi == NULL) {
		System_abort("Button Hardware interrupt create failed.");
	}
	Hwi_enableInterrupt(INT_GPIOJ_TM4C129);
	GPIOIntEnable(GPIO_PORTJ_BASE, GPIO_INT_PIN_0);

}
Beispiel #28
0
void SystickIntHandler(){
	//Samples the voltage on pin 3
	if (GPIOPinRead(GPIOA1_BASE, 0x10)){
		//modify the bitsequence using logic AND
		//Use bitwise operation here to save memory. Another option is to use an aray
		bitsequence = bitsequence | (1LL << (64-index));
	}
	//Increments the next index of the bit in bitsequence to be modified
	index++;
	//Clear the GPIO interrupt
	GPIOIntClear(GPIOA1_BASE, 0x10);
	//Enables the GPIO interrupt
	GPIOIntEnable(GPIOA1_BASE, 0x10);
	if(index == 60)
	{
		//If 60 bits have been written, it's time to check what number on the remote the bit sequence reprensent.
		SysTickDisable();
		GPIOIntDisable(GPIOA1_BASE, 0x10);
	}
}
Beispiel #29
0
/*****************************************************************************
** Function name:		SetRemoteWakeupSource
**
** Descriptions:		Set Remote Wakeup Source
**
** parameters:			None
** Returned value:		None
** 
*****************************************************************************/
void SetRemoteWakeupSource (void)
{
 /* Enable AHB clock to the GPIO domain. */
  LPC_SYSCON->SYSAHBCLKCTRL |= (1<<6);

  /* Enable AHB clock to the FlexInt, GroupedInt domain. */
  LPC_SYSCON->SYSAHBCLKCTRL |= ((1<<19) | (1<<23) | (1<<24));

  /* Route p0.1 to FLEX0 */
  LPC_SYSCON->PINTSEL[0] = 1;	/* P0.1  */

  /* use port0_1 as input event, interrupt test. */
  GPIOSetDir( PORT0, 1, 0 );
  /* INT0, edge trigger, falling edge. */
  GPIOSetInterrupt( 0, 0, 0 );
  GPIOIntEnable( 0, 0 );

  NVIC_EnableIRQ(FLEX_INT0_IRQn);
  return;
}
Beispiel #30
0
int main(void) {

    SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
    
    //Set up the general purpose I/Os
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);    
    SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);//1024hz = 15625

    //Set up the input/output pins
    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2 | GPIO_PIN_1);
    GPIOPinTypeGPIOInput(GPIO_PORTC_BASE, GPIO_PIN_5 | GPIO_PIN_6);
    
    //Set up the interrupt pins
    GPIOIntEnable(GPIO_PORTC_BASE, GPIO_INT_PIN_5 | GPIO_INT_PIN_6);
    GPIOIntRegister(GPIO_PORTC_BASE, interrupt_handler);
    GPIOIntTypeSet(GPIO_PORTC_BASE, (GPIO_PIN_5 | GPIO_PIN_6), GPIO_RISING_EDGE);

    //Just a quick toggle to make sure code is working
    toggle();
  
    //Timer Configuration
    TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);
    TimerLoadSet(TIMER0_BASE, TIMER_A, frequency);
    TimerControlEvent(TIMER0_BASE, TIMER_A, TIMER_EVENT_POS_EDGE);
    TimerEnable(TIMER0_BASE, TIMER_A);

    //Timer Interrupt Enable
    TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
    TimerIntRegister(TIMER0_BASE, TIMER_A, timer_interrupt);

    //Loop forever
    while(1){
          
      // if(TimerValueGet(TIMER0_BASE, TIMER_A) == 0){
      //           GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, pin_data);
      //           pin_data^=0x04;
      //     }
         }
}