示例#1
0
void main(void)
	{
	SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);

	GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_1);
	GPIOPinTypeGPIOInput(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);

	GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_0); /* led */

    GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_1, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
    GPIOPadConfigSet(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);

	GPIOIntTypeSet(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3, GPIO_RISING_EDGE);
	GPIOIntTypeSet(GPIO_PORTF_BASE, GPIO_PIN_1, GPIO_RISING_EDGE);

	GPIOPinIntEnable(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);
	GPIOPinIntEnable(GPIO_PORTF_BASE, GPIO_PIN_1);

	IntMasterEnable();
    IntEnable(INT_GPIOE);
    IntEnable(INT_GPIOF);
    GPIOPinIntClear(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);
    GPIOPinIntClear(GPIO_PORTF_BASE, GPIO_PIN_1);
    while(1)
    	{
    	}
	}
// *****************************************************************************
void initYaw (void)
{
    // Register the handler for Port F into the vector table
    GPIOPortIntRegister (GPIO_PORTF_BASE, YawChangeIntHandler);

    // Enable and configure the port and pin used:  input on PF5: Pin 27 & PF7: Pin 29
    SysCtlPeripheralEnable (SYSCTL_PERIPH_GPIOF);
    GPIOPadConfigSet (GPIO_PORTF_BASE, GPIO_PIN_5 | GPIO_PIN_7, GPIO_STRENGTH_2MA,
       GPIO_PIN_TYPE_STD_WPU);

    // Set up the pin change interrupt (both edges)
    GPIOIntTypeSet (GPIO_PORTF_BASE, GPIO_PIN_5 | GPIO_PIN_7, GPIO_BOTH_EDGES);

    // Enable the pin change interrupt
    GPIOPinIntEnable (GPIO_PORTF_BASE, GPIO_PIN_5 | GPIO_PIN_7);
    IntEnable (INT_GPIOF);	// Note: INT_GPIOF defined in inc/hw_ints.h

    //Registering Port D into the vector Table (Refwewnce point)
    GPIOPortIntRegister (GPIO_PORTD_BASE, referencePosIntHandler);

    GPIOPadConfigSet (GPIO_PORTD_BASE, GPIO_PIN_0, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
	//
	// Set up the pin change interrupt (both edges)
    GPIOIntTypeSet (GPIO_PORTD_BASE, GPIO_PIN_0, GPIO_BOTH_EDGES);
    //
    // Enable the pin change interrupt for PD0
    GPIOPinIntEnable (GPIO_PORTD_BASE, GPIO_PIN_0);

}
void setup(void){
	//Enable the driver layer
	SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
	                       SYSCTL_XTAL_16MHZ);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

	//Pinout connections:
	//
	GPIOPinTypeGPIOInput(GPIO_PORTA_BASE,GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7);
	GPIOPadConfigSet(GPIO_PORTA_BASE, GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7, GPIO_STRENGTH_2MA,
	                     GPIO_PIN_TYPE_STD_WPU);
	GPIOIntTypeSet(GPIO_PORTA_BASE, GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7,GPIO_FALLING_EDGE);
	GPIOPinTypeGPIOInput(GPIO_PORTB_BASE,GPIO_PIN_4);
	GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_4, GPIO_STRENGTH_2MA,
		                     GPIO_PIN_TYPE_STD_WPU);
	GPIOIntTypeSet(GPIO_PORTB_BASE,GPIO_PIN_4,GPIO_FALLING_EDGE);
	GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE,GPIO_PIN_5|GPIO_PIN_4);
	GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE,GPIO_PIN_1|GPIO_PIN_0);
	GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE,GPIO_PIN_2|GPIO_PIN_1|GPIO_PIN_3);

	GPIOPinIntEnable(GPIO_PORTA_BASE, GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7);
	GPIOPinIntEnable(GPIO_PORTB_BASE,GPIO_PIN_4);
	IntMasterEnable();
	IntEnable(INT_GPIOA);
	IntEnable(INT_GPIOB);
	GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_0, 0);
	GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_1, 0);
	GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_4, 0);
	GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_5, 0);

}
示例#4
0
// *************** GPIO_SetInterruptTask *************** 					
void GPIO_SetInterruptTask( GPIO_PORT_T port, GPIO_PIN_T pins,
                            unsigned long int_type, unsigned long priority, 
							void (*task)( void ) )
{
	unsigned long port_base = GPIO_PortBase[port];

	// Set the interrupt task for the specified port and pins
	if     ( pins & 0x01 ) GPIO_PinISR[port][0] = task;
	else if( pins & 0x02 ) GPIO_PinISR[port][1] = task; 
	else if( pins & 0x04 ) GPIO_PinISR[port][2] = task;
	else if( pins & 0x08 ) GPIO_PinISR[port][3] = task;
	else if( pins & 0x10 ) GPIO_PinISR[port][4] = task;
	else if( pins & 0x20 ) GPIO_PinISR[port][5] = task;
	else if( pins & 0x40 ) GPIO_PinISR[port][6] = task;
	else if( pins & 0x80 ) GPIO_PinISR[port][7] = task;

	// Set the event type and priority, and clear the interrupt
	IntPrioritySet( GPIO_IntAssignment[port], priority );	 
	GPIOIntTypeSet( port_base, pins, int_type );
	GPIOPinIntClear( port_base, pins);

	// Enable interrupts
	IntEnable( GPIO_IntAssignment[port] );
 	GPIOPinIntEnable( port_base, pins );
}
示例#5
0
/******** Transceiver_receiveMessage *****************************************
// dequeue transceiver packet
// Input: 
//	  *pkt - pointer to received message 
// Output: status
// ------------------------------------------------------------------------*/
unsigned char Transceiver_ReceiveMessage ( TransceiverPacket *pkt )
{
	unsigned char rx[TRANSCEIVER_MAX_PAYLOAD];
	unsigned char index;
	unsigned char status = SUCCESS;

	GPIOPinIntDisable ( nrf24l01_IRQ_IOREGISTER, nrf24l01_IRQ_PIN );
	if ( pdPASS == xQueueReceive(Transceiver_RX_Queue, rx, (portTickType)0) )
	{
		pkt->srcID = rx[SOURCE_ID_INDEX];
		pkt->destID = rx[DEST_ID_INDEX];
		pkt->msgID = rx[MSG_ID_INDEX];
		pkt->dataSize = rx[DATA_SIZE_INDEX];
		for ( index = 0; index < pkt->dataSize; index++ )
		{
			pkt->data[index] = rx[index+PACKET_HEADER_SIZE];
		}
		Debug_NetworkTransceiver_PrintPacket(pkt);
	}
	else
	{
		// empty queue
		status = ERROR_QUEUE_EMPTY;
		Debug_Printf ("Transceiver_ReceiveMessage 0x%x\n", status);
		if ( EmptyQueueCallBack != NULL )
			xTaskCreate( Transceiver_EmptyQueueCallBack, ( signed portCHAR * ) "Transceiver_EmptyQueueCallBack", 
				 DEFAULT_STACK_SIZE, NULL, DEFAULT_PRIORITY, NULL );
	}

	GPIOPinIntEnable ( nrf24l01_IRQ_IOREGISTER, nrf24l01_IRQ_PIN );

	return status;
}
示例#6
0
//ISR INIT
void ctl_buttons_isr_init(CTL_ISR_FN_t fn)
{
int en; int32u proba;
en=ctl_global_interrupts_set(0);
buttons_isr=fn;
SysCtlPeripheralEnable(PUSHBUTTON_PERIPH);
//UNLOCKOLNI KELL A PF0 REGISZTERT MERT NMI-RE VAN ALLITVA
HWREG(PUSHBUTTON_PORT + GPIO_O_LOCK) = GPIO_LOCK_KEY_DD;
HWREG(PUSHBUTTON_PORT + GPIO_O_CR) |= 0x01;
HWREG(PUSHBUTTON_PORT + GPIO_O_LOCK) = 0;

GPIODirModeSet(PUSHBUTTON_PORT, LEFT_SWITCH | RIGHT_SWITCH , GPIO_DIR_MODE_IN);
GPIOPadConfigSet(PUSHBUTTON_PORT,LEFT_SWITCH | RIGHT_SWITCH , GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
GPIOPinIntDisable(PUSHBUTTON_PORT, LEFT_SWITCH | RIGHT_SWITCH);
if((GPIOPinIntStatus(PUSHBUTTON_PORT, 1)) == LEFT_SWITCH )
{
 GPIOPinIntClear(PUSHBUTTON_PORT, LEFT_SWITCH );
}
if((GPIOPinIntStatus(PUSHBUTTON_PORT, 1)) == RIGHT_SWITCH )
{
 GPIOPinIntClear(PUSHBUTTON_PORT, RIGHT_SWITCH );
}
ctl_set_priority(PUSHBUTTON_IRQ_PRIORITY, 1);
ctl_unmask_isr(PUSHBUTTON_IRQ_PRIORITY);
ctl_global_interrupts_set(en);
GPIOIntTypeSet(PUSHBUTTON_PORT, LEFT_SWITCH | RIGHT_SWITCH , GPIO_BOTH_EDGES); //GPIO_BOTH_EDGES
GPIOPinIntEnable(PUSHBUTTON_PORT, LEFT_SWITCH | RIGHT_SWITCH );
}
示例#7
0
文件: main.c 项目: gluker/sonar
void hw_init(void){
	SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);

	f_cpu = SysCtlClockGet();
	SysTickPeriodSet(0xffffffff);
	SysTickEnable();
//	UARTStdioInit();

	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
	GPIODirModeSet(SONAR_PORT, TRIG_PIN, GPIO_DIR_MODE_OUT);
	GPIODirModeSet(SONAR_PORT, SERVO_PIN, GPIO_DIR_MODE_OUT);

	GPIOPinTypeGPIOInput(SONAR_PORT, ECHO_PIN);
	GPIOIntTypeSet(SONAR_PORT, ECHO_PIN, GPIO_RISING_EDGE);
	GPIOPinIntEnable(SONAR_PORT,ECHO_PIN);
	IntEnable(INT_GPIOD);

	//Timer configuration
	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
	TimerConfigure(TIMER0_BASE, TIMER_CFG_A_PERIODIC);
	const long timer_match = (f_cpu/1000000)*10;
	const long timer_out = (f_cpu/1000)*80;
	TimerLoadSet(TIMER0_BASE, TIMER_A, timer_out);
	TimerMatchSet(TIMER0_BASE, TIMER_A, timer_match);
	TimerEnable(TIMER0_BASE, TIMER_A);
	TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
	TimerIntClear(TIMER0_BASE,TIMER_A);
	IntEnable(INT_TIMER0A);

	IntMasterEnable();

}
示例#8
0
void GPIO_PortF_IntHandler(void) {
	GPIOPinIntClear(GPIO_PORTF_BASE, GPIO_PIN_4);
	GPIOPinIntDisable(GPIO_PORTF_BASE, GPIO_PIN_4);
	Encoder_Count++;
	GPIOPinIntEnable(GPIO_PORTF_BASE, GPIO_PIN_4);

}
示例#9
0
/**
 * Configures the used button as input source
 * Registers gpio_c interrupt..
 */
void button_init(){
	GPIOPinTypeGPIOInput(BSP_BUTTON_BASE, BSP_USER_BUTTON);
	GPIOIntTypeSet(BSP_BUTTON_BASE,BSP_USER_BUTTON,GPIO_FALLING_EDGE);
	GPIOPortIntRegister(BSP_BUTTON_BASE,GPIO_C_Isr_Handler);
	GPIOPinIntClear(BSP_BUTTON_BASE, BSP_USER_BUTTON);
	GPIOPinIntEnable(BSP_BUTTON_BASE, BSP_USER_BUTTON);
}
示例#10
0
int init_spi(void)
{
  #if CFG_CC3000_SPI_PORT == 1
    ssp1Init();
  #else
    ssp0Init();
  #endif

  /* Set VBAT EN pin to output */
  LPC_GPIO->DIR[CFG_CC3000_EN_PORT] |= (1 << CFG_CC3000_EN_PIN);
  LPC_GPIO->SET[CFG_CC3000_EN_PORT]  = (1 << CFG_CC3000_EN_PIN);
  delay(100);

  /* Set CS pin to output */
  LPC_GPIO->DIR[CFG_CC3000_CS_PORT] |= (1 << CFG_CC3000_CS_PIN);
  CC3000_DEASSERT_CS;

  /* Set interrupt/gpio pin to input */
  LPC_GPIO->DIR[CFG_CC3000_IRQ_PORT]  &= ~(1 << CFG_CC3000_IRQ_PIN);

  /* Channel 2, sense (0=edge, 1=level), polarity (0=low/falling, 1=high/rising) */
  GPIOSetPinInterrupt( 2, CFG_CC3000_IRQ_PORT, CFG_CC3000_IRQ_PIN, 0, 1 );

  /* Enable interrupt 2 on falling edge */
  GPIOPinIntEnable( 2, 0 );

  return(ESUCCESS);
}
示例#11
0
void GpioIn::enableInterrupts(void)
{
    // Clear the interrupt
    GPIOPinIntClear(gpio_.port, gpio_.pin);

    // Enable the interrupt
    GPIOPinIntEnable(gpio_.port, gpio_.pin);
}
示例#12
0
/******** Transceiver_SendMessage *******************************************
// unpack transceiver packet and send out
// Input:
//    pkt - transceiver packet to be sent 
// Output: status
// ------------------------------------------------------------------------*/
unsigned char Transceiver_SendMessage ( TransceiverPacket pkt )
{
	unsigned char tx[TRANSCEIVER_MAX_PAYLOAD];
	unsigned char index, length;
	unsigned char status = SUCCESS;

	// validate packet
	Debug_NetworkTransceiver_PrintPacket(&pkt);

	if ( MAX_DATA_SIZE < pkt.dataSize )
	{
		status = ERROR_INVALID_PAKCET;
		Debug_Printf ("Transceiver_SendMessage: Error 0x%x\n", status);
		goto exit;
	}

	// unpack transceiver packet
	tx[SOURCE_ID_INDEX] = pkt.srcID;
	tx[DEST_ID_INDEX] = pkt.destID;
	tx[MSG_ID_INDEX] = pkt.msgID;
	tx[DATA_SIZE_INDEX] = pkt.dataSize;
	length = DATA_INDEX;
	for ( index = 0; index < pkt.dataSize; index++,length++ )
	{
		tx[length] = pkt.data[index];
	}

	Debug_NetworkTransceiver_PrintPayload(tx);

	// lock transceiver
	while ( xSemaphoreTake(Transceiver_Mutex, portMAX_DELAY) != pdTRUE );
	GPIOPinIntDisable ( nrf24l01_IRQ_IOREGISTER, nrf24l01_IRQ_PIN );

	nrf24l01_set_as_tx();
	nrf24l01_write_tx_payload ( tx, TRANSCEIVER_MAX_PAYLOAD, true );

	//wait until the packet has been sent or the maximum number of retries has been active
	while( !( nrf24l01_irq_pin_active() && (nrf24l01_irq_tx_ds_active()||nrf24l01_irq_max_rt_active()) ) );
	if ( nrf24l01_irq_max_rt_active() )	
	{
		// hit maximum number of retries
		nrf24l01_flush_tx();
		status = ERROR_MAX_RETRIES;
		Debug_Printf ("Transceiver_SendMessage: Error 0x%x\n", status);
	}

	// reset transceiver
	nrf24l01_irq_clear_all();
	nrf24l01_set_as_rx(true);
	Delay_US(130);

	//unlock transceiver
	GPIOPinIntEnable ( nrf24l01_IRQ_IOREGISTER, nrf24l01_IRQ_PIN );
	while ( xSemaphoreGive(Transceiver_Mutex) != pdTRUE );

exit:
	return status;
}
示例#13
0
void
initHW(void)
{
  volatile unsigned long ulLoop;

  //initHW();

  SysCtlClockSet(
      SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ);

  // Enable the ports
  SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
  SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);

  // Inputs :
  // PE0 : Up button
  // PE1 : Down button
  // PE2 : Left button
  // PE3 : Right button
  // PF1 : Select button
  //
  GPIODirModeSet(GPIO_PORTE_BASE,
      GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3, GPIO_DIR_MODE_IN);
  GPIOPadConfigSet(GPIO_PORTE_BASE,
      GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3, GPIO_STRENGTH_2MA,
      GPIO_PIN_TYPE_STD_WPU);

  GPIODirModeSet(GPIO_PORTF_BASE, GPIO_PIN_1, GPIO_DIR_MODE_IN);
  GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_1, GPIO_STRENGTH_2MA,
      GPIO_PIN_TYPE_STD_WPU);

  // Outputs:
  // PF0 : Status LED
  GPIODirModeSet(GPIO_PORTF_BASE, GPIO_PIN_0, GPIO_DIR_MODE_OUT);
  GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_0, GPIO_STRENGTH_2MA,
      GPIO_PIN_TYPE_STD);
  GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0, 1);

  // Enable edge triggered interrupt on select button
  // Clear the interrupt just in case
  GPIOIntTypeSet(GPIO_PORTF_BASE, GPIO_PIN_1, GPIO_FALLING_EDGE);
  GPIOPinIntEnable(GPIO_PORTF_BASE, GPIO_PIN_1 );

  SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_GPIOF);


  // Enable the interrupt for port F
  IntEnable(INT_GPIOF);

  // Global interrupt enable
  IntMasterEnable();


  // a short delay to ensure stable IO before running the rest of the program
  for (ulLoop = 0; ulLoop < 200; ulLoop++)
    {
    }
}
示例#14
0
文件: vs.c 项目: Bob4ik888/WebRadio
void vs_play(void)
{
  if(vs_request() && vs_playing)
  {
    GPIOPinIntEnable(GPIO_PORTA_BASE, GPIO_PIN_1); //enable dreq irq
  }

  return;
}
示例#15
0
//GPIO³õʼ»¯
void initMotor()
{
    //³õʼ»¯ÍâÉè¶Ë¿Ú
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
    
    //µç»úÕý·´×ª¿ØÖƶ˿ÚÅäÖÃ
    GPIODirModeSet(GPIO_PORTD_BASE,  MOTOR_R0 | MOTOR_R1, GPIO_DIR_MODE_OUT);
    GPIOPadConfigSet(GPIO_PORTD_BASE, MOTOR_R0 | MOTOR_R1, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD);
    
    GPIODirModeSet(GPIO_PORTG_BASE,  MOTOR_L0 | MOTOR_L1, GPIO_DIR_MODE_OUT);
    GPIOPadConfigSet(GPIO_PORTG_BASE, MOTOR_L0 | MOTOR_L1, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD);

    //±àÂëÆ÷ÖжÏÉèÖã¬Ï½µÑØ´¥·¢    
    GPIODirModeSet(GPIO_PORTG_BASE, CODE_L, GPIO_DIR_MODE_IN); 
    GPIOPadConfigSet(GPIO_PORTG_BASE, CODE_L, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
    GPIOIntTypeSet(GPIO_PORTG_BASE, CODE_L, GPIO_FALLING_EDGE);
    GPIOPinIntEnable(GPIO_PORTG_BASE, CODE_L);
    
    GPIODirModeSet(GPIO_PORTD_BASE, CODE_R, GPIO_DIR_MODE_IN); 
    GPIOPadConfigSet(GPIO_PORTD_BASE, CODE_R, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
    GPIOIntTypeSet(GPIO_PORTD_BASE, CODE_R, GPIO_FALLING_EDGE);
    GPIOPinIntEnable(GPIO_PORTD_BASE, CODE_R);
    
    /*
    HWREG(GPIO_PORTB_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY_DD;
    // Set the commit register for PB7 to allow changing the function
    HWREG(GPIO_PORTB_BASE + GPIO_O_CR) = 0x80;
    // Enable the alternate function for PB7 (NMI)
    HWREG(GPIO_PORTB_BASE + GPIO_O_AFSEL) |= 0x80;
    // Turn on the digital enable for PB7
    HWREG(GPIO_PORTB_BASE + GPIO_O_DEN) |= 0x80;
    
    
    GPIODirModeSet(GPIO_PORTB_BASE,GPIO_PIN_7,GPIO_DIR_MODE_IN); 
    GPIOPadConfigSet(GPIO_PORTB_BASE,GPIO_PIN_7,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD);
    GPIOIntTypeSet( GPIO_PORTB_BASE,GPIO_PIN_7,GPIO_FALLING_EDGE ); 
    // Relock the commit register
    HWREG(GPIO_PORTB_BASE + GPIO_O_LOCK) = 0;
    */
    
    IntEnable(INT_GPIOD);
    IntEnable(INT_GPIOG);
}
示例#16
0
void InitializeEncoders(tBoolean invert0, tBoolean invert1)
{
	// enable and configure the GPIO pins
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);	// enable the peripheral
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);	// enable the peripheral
	GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_4 | GPIO_PIN_6);	// configure pins as inputs
	GPIOPinTypeGPIOInput(GPIO_PORTC_BASE, GPIO_PIN_5 | GPIO_PIN_6);	// configure pins as inputs
	
	// enable and configure the interrupts
	IntEnable(INT_GPIOB);					// enable interrupts for the periph
	IntEnable(INT_GPIOC);					// enable interrupts for the periph
	GPIOIntTypeSet(GPIO_PORTB_BASE, GPIO_PIN_4 | GPIO_PIN_6, GPIO_BOTH_EDGES);	// configure the interrupts
	GPIOIntTypeSet(GPIO_PORTC_BASE, GPIO_PIN_5 | GPIO_PIN_6, GPIO_BOTH_EDGES);	// configure the interrupts
	GPIOPinIntEnable(GPIO_PORTB_BASE, GPIO_PIN_4 | GPIO_PIN_6);	// enable the interrupt for the pins
	GPIOPinIntEnable(GPIO_PORTC_BASE, GPIO_PIN_5 | GPIO_PIN_6);	// enable the interrupt for the pins
	
	dir0 = invert0 ? -1 : 1;
	dir1 = invert1 ? -1 : 1;
}
示例#17
0
int
main(void)
{

	
		
	//set clock	
	SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
                   SYSCTL_XTAL_8MHZ);


   
        

     //PB1
     SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
     GPIOPadConfigSet(GPIO_PORTB_BASE,GPIO_PIN_1,GPIO_STRENGTH_4MA,GPIO_PIN_TYPE_STD);
     GPIODirModeSet(GPIO_PORTB_BASE,GPIO_PIN_1,GPIO_DIR_MODE_IN);
     GPIOPortIntRegister(GPIO_PORTB_BASE, PortBIntHandler);
     GPIOIntTypeSet(GPIO_PORTB_BASE, GPIO_PIN_1, GPIO_BOTH_EDGES);
     GPIOPinIntEnable(GPIO_PORTB_BASE, GPIO_PIN_1);

        
    // Status
                SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    GPIOPadConfigSet(GPIO_PORTF_BASE,GPIO_PIN_2,GPIO_STRENGTH_4MA,GPIO_PIN_TYPE_STD);
        GPIODirModeSet(GPIO_PORTF_BASE,GPIO_PIN_2,GPIO_DIR_MODE_OUT);  

    //UART
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
    GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
    UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 9600,
    (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
                   UART_CONFIG_PAR_NONE));
    IntEnable(INT_UART0);
    UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT);
   
    IntPrioritySet(INT_UART0, 0x7F);
                
    IntPrioritySet(INT_GPIOB,0x80);
    IntMasterEnable();
    SysTickIntRegister(SysTickHandler);                  
    SysTickPeriodSet(SysCtlClockGet()/10000);   // 0.1ms
    SysTickIntEnable();
    waitTime = 0;                   // initialize
    waitTime2 = 0;
    SysTickEnable();
    while(1)
    {
 

    }
    
}
示例#18
0
/***********************************************************************************
* @fn      halRfRxInterruptConfig
*
* @brief   Enable RX interrupt.
*
* @param   none
*
* @return  none
*/
void halRfRxInterruptConfig(ISR_FUNC_PTR pfISR)
{
//	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
//	GPIOPinTypeGPIOInput(GPIO_PORTD_BASE, GPIO_PIN_1);				/* Default pin is Push-pull.*/
	GPIOPadConfigSet(GPIO_PORTD_BASE, GPIO_PIN_0, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPD);
	GPIOIntTypeSet(GPIO_PORTD_BASE, GPIO_PIN_0, GPIO_RISING_EDGE);	/* Rising edge is active.*/
	GPIOPortIntRegister(GPIO_PORTD_BASE, pfISR);
	GPIOPinIntEnable(GPIO_PORTD_BASE, GPIO_PIN_0);
	
    CLEAR_EXC_RX_FRM_DONE();										/* And clear the exception.*/
}
示例#19
0
void flipPancake(void) {
	GPIOPinIntDisable(GPIO_PORTA_BASE, GPIO_PIN_2);
	WaitUS(2000);
	GPIOPinIntClear(GPIO_PORTA_BASE, GPIO_PIN_2);
	if(!GPIOPinRead(GPIO_PORTA_BASE,GPIO_PIN_2))
	{
		UARTprintf("Triggered.\n");
		SetServoPosition(PANCAKE_POSITION,100*pancake);
		pancake = !pancake;
	}
	GPIOPinIntEnable(GPIO_PORTA_BASE, GPIO_PIN_2);
}
void intButton (void)
{
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
	// Register the handler for Port B into the vector table
	GPIOPortIntRegister (GPIO_PORTB_BASE, ButtPressIntHandler);

	//Initialising for buttons
	GPIOPinTypeGPIOInput (GPIO_PORTB_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6);
	GPIOPadConfigSet (GPIO_PORTB_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
	GPIOIntTypeSet (GPIO_PORTB_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6, GPIO_FALLING_EDGE);
	GPIOPinIntEnable (GPIO_PORTB_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6);

}
示例#21
0
void SonarInit()
{
  SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2);
  GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE,GPIO_PIN_7);
  GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_7, 0);
  TimerConfigure(TIMER2_BASE, TIMER_CFG_32_BIT_PER);
  GPIOIntTypeSet(GPIO_PORTD_BASE, GPIO_PIN_7,GPIO_RISING_EDGE);
  GPIOPinIntEnable(GPIO_PORTD_BASE,GPIO_PIN_7);

  SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
  GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE,GPIO_PIN_4);
  GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_4, 0);
  
}
示例#22
0
void deployJames(bool on) {
	if(on)
	{
		//GPIOPinWrite(GPIO_PORTA_BASE, JAMES_POSITION, 0x00);
		GPIOPinIntEnable(GPIO_PORTA_BASE, TRIGGER_POSITION);
		shooting = true;
	}
	else
	{
		//SetServoPosition2(JAMES_Position2,255);
		//GPIOPinWrite(GPIO_PORTA_BASE, JAMES_POSITION, 0xff);
		GPIOPinIntDisable(GPIO_PORTA_BASE, TRIGGER_POSITION);
		shooting = false;
	}
}
// *******************************************************
// Initializes all five buttons and enables the respective ISR.
void ButtonInit (void)
{

	unsigned char ucPin = UP_B | DOWN_B | LEFT_B | RIGHT_B | SELECT_B;

	short i = 0;
	for (i = UP; i <= SELECT; i++)
	{
		button_t* button = &buttonPointer[i];
	    // Set the button_t values
	    button->iState = BUT_OUT; // enable button
	    //button->uiCntIn = 0;
	    //button->uiCntOut = 0;
	    button->ucPin = i;
	}

	//Enable GPIO module for decoder
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIO_B);

	// setup  input pins
	GPIODirModeSet(PORT_BASE_B, ucPin, GPIO_DIR_MODE_IN);

	// disable internal pullups on decoder pins
	//GPIOPadConfigSet(PORT_BASE_B, ucPin,
	//		GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);


	GPIOPinTypeGPIOInput(PORT_BASE_B, ucPin);

#ifdef REAL_BUTTONS_
	// want this if you're using the real buttons
	GPIOPadConfigSet(PORT_BASE_B, ucPin,
			GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
#endif /* */
	//GPIOIntTypeSet(PORT_BASE_B, ucPin, GPIO_RISING_EDGE);
	//GPIOIntTypeSet(GPIO_PORTG_BASE, PIN_2, GPIO_BOTH_EDGES);
	GPIOIntTypeSet(PORT_BASE_B, ucPin , GPIO_FALLING_EDGE);
	//GPIOIntTypeSet(GPIO_PORTF_BASE, PIN_1 | PIN_2 , GPIO_BOTH_EDGES);

	GPIOPortIntRegister(PORT_BASE_B, buttonISR);

	//IntPrioritySet( INT_GPIO_B , 0);

	GPIOPinIntEnable(PORT_BASE_B, ucPin);
	//GPIOPinIntEnable(GPIO_PORTF_BASE, PIN_2);


}
//*****************************************************************************
//
// Initializes the speed sensing routines.
//
// This function will initialize the peripherals used determine the speed of
// the motor's rotor.
//
// \return None.
//
//*****************************************************************************
void
SpeedSenseInit(void)
{
    //
    // Configure the encoder A pin for use by the QEI block.  Even though this
    // pin is now used to drive the QEI block, its state is still visible to
    // the GPIO block.
    // Encoder B and Index pins are not used, but should be configured here,
    // for test support.
    //
    GPIOPinTypeQEI(PIN_ENCA_PORT, PIN_ENCA_PIN);
    GPIOPinTypeQEI(PIN_ENCB_PORT, PIN_ENCB_PIN);
    GPIOPinTypeQEI(PIN_INDEX_PORT, PIN_INDEX_PIN);

    //
    // A GPIO interrupt should be generated on rising edges of the encoder A
    // pin.
    //
    GPIOIntTypeSet(PIN_ENCA_PORT, PIN_ENCA_PIN, GPIO_RISING_EDGE);

    //
    // Enable the encoder A pin GPIO interrupt.
    //
    GPIOPinIntEnable(PIN_ENCA_PORT, PIN_ENCA_PIN);
    IntEnable(INT_GPIOC);

    //
    // Configure the QEI block for capturing the velocity of the encoder A pin
    // (which it does by counting the number of edges during a fixed time
    // period).
    //
    QEIConfigure(QEI0_BASE, (QEI_CONFIG_CAPTURE_A | QEI_CONFIG_NO_RESET |
                             QEI_CONFIG_CLOCK_DIR | QEI_CONFIG_NO_SWAP), 0);
    QEIVelocityConfigure(QEI0_BASE, QEI_VELDIV_1, SYSTEM_CLOCK / QEI_INT_RATE);

    //
    // Enable the QEI block and the velocity capture.
    //
    QEIEnable(QEI0_BASE);
    QEIVelocityEnable(QEI0_BASE);

    //
    // Enable the QEI velocity interrupt.
    //
    QEIIntEnable(QEI0_BASE, QEI_INTTIMER);
    IntEnable(INT_QEI0);
}
示例#25
0
文件: OS.c 项目: tach4455/EE345M
//******** OS_AddDownTask ***************
// add a background task to run whenever the Down arror button is pushed
// Inputs: pointer to a void/void background function
//         priority 0 is highest, 5 is lowest
// Outputs: 1 if successful, 0 if this thread can not be added
// It is assumed user task will run to completion and return
// This task can not spin block loop sleep or kill
// It can call issue OS_Signal, it can call OS_AddThread
// This task does not have a Thread ID
// In lab 2, this function can be ignored
// In lab 3, this command will be called will be called 0 or 1 times
// In lab 3, there will be up to four background threads, and this priority field
//           determines the relative priority of these four threads
int OS_AddDownTask(void(*task)(void), unsigned long priority) {

  long status;
  status = StartCritical();

  gButtonThreadDownPt = task;
  gButtonThreadDownPriority = priority;

  // Enabling interrupts
  GPIOPinIntClear(GPIO_PORTE_BASE,GPIO_PIN_1);
  GPIOPinIntEnable(GPIO_PORTE_BASE, GPIO_PIN_1);
  IntPrioritySet(INT_GPIOE, (priority << 5));
  IntEnable(INT_GPIOE);

  EndCritical(status);
  return 1;
}
示例#26
0
void initQEI(void){
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC); //PhA sur C4 et PhB sur C6
	SysCtlPeripheralEnable(SYSCTL_PERIPH_QEI0);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); //PhA sur E3 et PhB sur E2
	SysCtlPeripheralEnable(SYSCTL_PERIPH_QEI1);
	
	//init QEI0 du micro pour moteur 0
    GPIOPinConfigure(GPIO_PC4_PHA0);
    GPIOPinConfigure(GPIO_PC6_PHB0);
	GPIOPinTypeQEI(GPIO_PORTC_BASE, GPIO_PIN_4);  //Ph A
    GPIOPinTypeQEI(GPIO_PORTC_BASE, GPIO_PIN_6);  //Ph B
    QEIDisable(QEI0_BASE);
	QEIConfigure(QEI0_BASE, (QEI_CONFIG_CAPTURE_A_B | QEI_CONFIG_NO_RESET|
	QEI_CONFIG_QUADRATURE | QEI_CONFIG_NO_SWAP), 1000000); //64 counts par révolution de moteur avec un ratio 100:1 
	QEIEnable(QEI0_BASE);
	QEIPositionSet(QEI0_BASE,0);
	QEIVelocityDisable(QEI0_BASE);
	QEIVelocityConfigure (QEI0_BASE, QEI_VELDIV_1, ROM_SysCtlClockGet()*dt);
	QEIVelocityEnable(QEI0_BASE);
	
	//init QEI1 du micro pour moteur 1
    GPIOPinConfigure(GPIO_PE3_PHA1);
    GPIOPinConfigure(GPIO_PE2_PHB1);
	GPIOPinTypeQEI(GPIO_PORTE_BASE, GPIO_PIN_3);  //Ph A
    GPIOPinTypeQEI(GPIO_PORTE_BASE, GPIO_PIN_2);  //Ph B
    QEIDisable(QEI1_BASE);
	QEIConfigure(QEI1_BASE, (QEI_CONFIG_CAPTURE_A_B | QEI_CONFIG_NO_RESET|
	QEI_CONFIG_QUADRATURE | QEI_CONFIG_NO_SWAP), 1000000); //64 counts par révolution de moteur avec un ratio 100:1 
	QEIEnable(QEI1_BASE);
	QEIPositionSet(QEI1_BASE,0);
	QEIVelocityDisable(QEI1_BASE);
	QEIVelocityConfigure (QEI1_BASE, QEI_VELDIV_1, ROM_SysCtlClockGet()*dt);
	QEIVelocityEnable(QEI1_BASE);
	
	//init decodeur fait a la mitaine pour moteur 2 et 3 (pins J4 et J5 pour moteur 2, J6 et J7 pour moteur 3)
	GPIOPadConfigSet(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_6 | GPIO_PIN_7, GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD_WPD);
	GPIOPinTypeGPIOInput(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_6 | GPIO_PIN_7);
	GPIOIntTypeSet(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_6 | GPIO_PIN_7, GPIO_BOTH_EDGES);
	GPIOPinIntEnable(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_6 | GPIO_PIN_7);
	IntEnable(INT_GPIOE);
	
	position_m0 = 0;
	position_m1 = 0;
	position_m2 = 0;
	position_m3 = 0;
}
示例#27
0
int main(void)
{
	/* Set the clocking to directly run from the crystal at 8MHz */
	SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ);

	/* Set the clock for the GPIO Port C and E */
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);

	/* Set the type of the GPIO Pin */
	GPIOPinTypeGPIOOutput(GPIO_PORTC_BASE, GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7);
	GPIOPinTypeGPIOInput(GPIO_PORTE_BASE, GPIO_PIN_0);
	
	/*Configure GPIO pad with internal pull-up enabled*/
	GPIOPadConfigSet(GPIO_PORTE_BASE, GPIO_PIN_0, GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU);

	/* GPIO Pins 5, 6, 7 on PORT C initialized to 1
	 * All LEDs off.
	 * */
	GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7, GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7);
	
	/*Register Interrupt to call Interrupt Handler*/
	GPIOPortIntRegister(GPIO_PORTE_BASE, Pin_Int);

	/*Clear interrupt register*/
	GPIOPinIntClear(GPIO_PORTE_BASE, GPIO_PIN_0);

	/*Set interrupt triggering sequence*/
	GPIOIntTypeSet(GPIO_PORTE_BASE, GPIO_PIN_0, GPIO_FALLING_EDGE);

	/*Enable interrupts on selected pin*/
	GPIOPinIntEnable(GPIO_PORTE_BASE, GPIO_PIN_0);

	/*Enable interrupts on selected port*/
	IntEnable(INT_GPIOE);

	/*Enable global interrupts*/
	IntMasterEnable();
	
	while(1)
    {
		
    }

}
示例#28
0
void Enable_INT_Pin(void)
{
	// Enables pin clock
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);

	// Init pin as GPIO, with pull-up enabled
	PORTD_PCR4 = (uint32_t)((PORTD_PCR4 & (uint32_t)~(uint32_t)(
				  PORT_PCR_ISF_MASK |
				  PORT_PCR_MUX(0x06)
				 )) | (uint32_t)(
				  PORT_PCR_MUX(0x01) | PORT_PCR_PS_MASK | PORT_PCR_PE_MASK
				 ));

	// Enable interrupt as falling edge
	GPIOPinIntEnable(GPIOD_BASE, GPIO_PIN_4, GPIO_FALLING_EDGE);

	// Enable INT
	xIntEnable(INT_PORTD);
}
/******** Debug_NetworkTransceiver_FullQueue *******************************
// FAILED - test failure on receiving more packets than queue size
// Input: none
// Output: none
// ------------------------------------------------------------------------*/
void Debug_NetworkTransceiver_FullQueue ( void )
{
    unsigned char status;
    unsigned char tx[TRANSCEIVER_MAX_PAYLOAD];

    Transceiver_SetCallBack ( FULL_QUEUE_CALL_BACK, Dummy_FullQueueCallBack );

    GPIOPinIntDisable ( nrf24l01_IRQ_IOREGISTER, nrf24l01_IRQ_PIN );
    while ( pdPASS == xQueueSend(Transceiver_RX_Queue, tx, (portTickType)0) );
    GPIOPinIntEnable ( nrf24l01_IRQ_IOREGISTER, nrf24l01_IRQ_PIN );

    UARTprintf ( "Queue is full. Turn on transmitter and send a packet now...5>" );
    Delay_S(1);
    UARTprintf ( "4>" );
    Delay_S(1);
    UARTprintf ( "3>" );
    Delay_S(1);
    UARTprintf ( "2>" );
    Delay_S(1);
    UARTprintf ( "1>" );
    Delay_S(1);
    UARTprintf ( "0\n" );
    Delay_S(1);

    switch ( testID )
    {
    case '0':
        xTaskCreate( Debug_NetworkTransceiver_EmptyQueue, ( signed portCHAR * ) "Debug_NetworkTransceiver_EmptyQueue",
                     DEFAULT_STACK_SIZE, NULL, DEFAULT_PRIORITY, NULL );
        break;

    case '7':
        break;

    default:
        Delay_S ( 1 );
        xTaskCreate( Debug_NetworkTransceiver, ( signed portCHAR * ) "Debug_NetworkTransceiver",
                     DEFAULT_STACK_SIZE, NULL, DEFAULT_PRIORITY, NULL );
        break;
    }

    vTaskDelete ( NULL );
}
示例#30
0
void Sonar_Init(void) {
	// initialize gpio
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
	GPIOPinTypeGPIOInput (GPIO_PORTD_BASE, GPIO_PIN_3);
	GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_2);
	
	GPIOIntTypeSet(GPIO_PORTD_BASE, GPIO_PIN_3, GPIO_BOTH_EDGES);
	GPIOPinIntEnable(GPIO_PORTD_BASE, GPIO_PIN_3);
	IntEnable(INT_GPIOD);
	
	//initialize timer
	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2);
	TimerConfigure(TIMER2_BASE, TIMER_CFG_32_BIT_OS);
	
	IntEnable(INT_TIMER2A);
	TimerIntEnable(TIMER2_BASE, TIMER_TIMA_TIMEOUT);
	
	status = READY;
}