예제 #1
0
파일: gpio.c 프로젝트: JKLLBF/firmware
//*****************************************************************************
//
//! Configures output pin(s) for use by the UART peripheral
//!
//! \param ui32Port is the base address of the GPIO port.
//! \param ui8Pins is the bit-packed representation of the pin(s).
//!
//! The UART output pins must be properly configured for the UART peripheral to
//! function correctly.  This function provides a typical configuration for
//! those pin(s); other configurations might work as well depending upon the
//! board setup (for example, using the on-chip pull-ups).
//!
//! The pin(s) are specified using a bit-packed byte, where each bit that is
//! set identifies the pin to be accessed, and where bit 0 of the byte
//! represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on.
//!
//! \note This function cannot be used to turn any pin into a UART pin; but only
//! configures a UART pin for proper operation.
//!
//! \return None
//
//*****************************************************************************
void
GPIOPinTypeUARTOutput(uint32_t ui32Port, uint8_t ui8Pins)
{
    //
    // Check the arguments.
    //
    ASSERT(GPIOBaseValid(ui32Port));
    ASSERT(!((ui32Port == GPIO_C_BASE) && ((ui8Pins & 0xf) > 0)));

    //
    // Make the pin(s) be peripheral controlled.
    //
    GPIODirModeSet(ui32Port, ui8Pins, GPIO_DIR_MODE_HW);

    //
    // Set the pad(s) to output enable.
    //
    IOCPadConfigSet(ui32Port, ui8Pins, IOC_OVERRIDE_OE);
}
void
GPIOPinTypeComparator(unsigned long ulPort, unsigned char ucPins)
{
    //
    // Check the arguments.
    //
    ASSERT((ulPort == GPIO_PORTA_BASE) || (ulPort == GPIO_PORTB_BASE) ||
           (ulPort == GPIO_PORTC_BASE) || (ulPort == GPIO_PORTD_BASE) ||
           (ulPort == GPIO_PORTE_BASE));

    //
    // Make the pin(s) be inputs.
    //
    GPIODirModeSet(ulPort, ucPins, GPIO_DIR_MODE_IN);

    //
    // Set the pad(s) for analog operation.
    //
    GPIOPadConfigSet(ulPort, ucPins, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_ANALOG);
}
void
GPIOPinTypeI2C(unsigned long ulPort, unsigned char ucPins)
{
    //
    // Check the arguments.
    //
    ASSERT((ulPort == GPIO_PORTA_BASE) || (ulPort == GPIO_PORTB_BASE) ||
           (ulPort == GPIO_PORTC_BASE) || (ulPort == GPIO_PORTD_BASE) ||
           (ulPort == GPIO_PORTE_BASE));

    //
    // Make the pin(s) be peripheral controlled.
    //
    GPIODirModeSet(ulPort, ucPins, GPIO_DIR_MODE_HW);

    //
    // Set the pad(s) for open-drain operation with a weak pull-up.
    //
    GPIOPadConfigSet(ulPort, ucPins, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_OD_WPU);
}
void
GPIOPinTypeSSI(unsigned long ulPort, unsigned char ucPins)
{
    //
    // Check the arguments.
    //
    ASSERT((ulPort == GPIO_PORTA_BASE) || (ulPort == GPIO_PORTB_BASE) ||
           (ulPort == GPIO_PORTC_BASE) || (ulPort == GPIO_PORTD_BASE) ||
           (ulPort == GPIO_PORTE_BASE));

    //
    // Make the pin(s) be peripheral controlled.
    //
    GPIODirModeSet(ulPort, ucPins, GPIO_DIR_MODE_HW);

    //
    // Set the pad(s) for standard push-pull operation.
    //
    GPIOPadConfigSet(ulPort, ucPins, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
}
예제 #5
0
//*****************************************************************************
//
//! Initializes the dynamic braking control routines.
//!
//! This function initializes the ADC module and the control routines,
//! preparing them to monitor currents and voltages on the motor drive.
//!
//! \return None.
//
//*****************************************************************************
void
BrakeInit(void)
{
    //
    // Configure the brake control pin as an output and make it be high to
    // disable the dynamic brake.
    //
    GPIODirModeSet(PIN_BRAKE_PORT, PIN_BRAKE_PIN, GPIO_DIR_MODE_OUT);
    GPIOPinWrite(PIN_BRAKE_PORT, PIN_BRAKE_PIN, PIN_BRAKE_PIN);

    //
    // The initial brake state is off.
    //
    g_ulBrakeState = STATE_BRAKE_OFF;

    //
    // The initial brake count is zero.
    //
    g_ulBrakeCount = 0;
}
예제 #6
0
파일: main.c 프로젝트: peterliu2/FreeRTOS
void prvSetupHardware( void )
{
    /* If running on Rev A2 silicon, turn the LDO voltage up to 2.75V.  This is
    a workaround to allow the PLL to operate reliably. */
    if( DEVICE_IS_REVA2 ) {
        SysCtlLDOSet( SYSCTL_LDO_2_75V );
    }

    /* Set the clocking to run from the PLL at 50 MHz */
    SysCtlClockSet( SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ );

    /* 	Enable Port F for Ethernet LEDs
    	LED0        Bit 3   Output
    	LED1        Bit 2   Output */
    SysCtlPeripheralEnable( SYSCTL_PERIPH_GPIOF );
    GPIODirModeSet( GPIO_PORTF_BASE, (GPIO_PIN_2 | GPIO_PIN_3), GPIO_DIR_MODE_HW );
    GPIOPadConfigSet( GPIO_PORTF_BASE, (GPIO_PIN_2 | GPIO_PIN_3 ), GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD );

    vParTestInitialise();
}
예제 #7
0
static void vSerialInit( void )
{
	/* Enable the UART.  GPIOA has already been initialised. */
	SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);

	/* Set GPIO A0 and A1 as peripheral function.  They are used to output the
	UART signals. */
	GPIODirModeSet( GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1, GPIO_DIR_MODE_HW );

	/* Configure the UART for 8-N-1 operation. */
	UARTConfigSet( UART0_BASE, mainBAUD_RATE, UART_CONFIG_WLEN_8 | UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_ONE );

	/* We dont want to use the fifo.  This is for test purposes to generate
	as many interrupts as possible. */
	HWREG( UART0_BASE + UART_O_LCR_H ) &= ~mainFIFO_SET;

	/* Enable both Rx and Tx interrupts. */
	HWREG( UART0_BASE + UART_O_IM ) |= ( UART_INT_TX | UART_INT_RX );
	IntEnable( INT_UART0 );
}
예제 #8
0
//---------------------------------------------------------------------------
// hardware_init()
//
// inits GPIO pins for toggling the LED
//---------------------------------------------------------------------------
void hardware_init(void)
{

	//Set CPU Clock to 40MHz. 400MHz PLL/2 = 200 DIV 5 = 40MHz
	SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);

	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);

	GPIOPinTypeADC(GPIO_PORTD_BASE, GPIO_PIN_0);            // Configuring PD0 as ADC input (channel 1)     CH7 ADC0
	GPIOPinTypeADC(GPIO_PORTD_BASE, GPIO_PIN_1);

	SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC1);

	ADCSequenceConfigure(ADC0_BASE,	1, ADC_TRIGGER_PROCESSOR, 0);
	ADCSequenceConfigure(ADC1_BASE,	1, ADC_TRIGGER_PROCESSOR, 0);

	ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ADC_CTL_CH7);
	ADCSequenceStepConfigure(ADC0_BASE, 1, 1, ADC_CTL_CH7);
	ADCSequenceStepConfigure(ADC0_BASE, 1, 2, ADC_CTL_CH7);
	ADCSequenceStepConfigure(ADC0_BASE, 1, 3, ADC_CTL_CH7 | ADC_CTL_IE | ADC_CTL_END);

	ADCSequenceStepConfigure(ADC1_BASE, 1, 0, ADC_CTL_CH6);
	ADCSequenceStepConfigure(ADC1_BASE, 1, 1, ADC_CTL_CH6);
	ADCSequenceStepConfigure(ADC1_BASE, 1, 2, ADC_CTL_CH6);
	ADCSequenceStepConfigure(ADC1_BASE, 1, 3, ADC_CTL_CH6 | ADC_CTL_IE | ADC_CTL_END);

	ADCSequenceEnable(ADC0_BASE, 1);
	ADCSequenceEnable(ADC1_BASE, 1);
	ADCIntClear(ADC0_BASE, 1);
	ADCIntClear(ADC1_BASE, 1);

	/* Configure Buzzer pin as output */
	 GPIOPinTypeGPIOOutput(GPIO_PORTC_BASE, GPIO_PIN_4);
	 GPIODirModeSet(GPIO_PORTC_BASE,GPIO_PIN_4,GPIO_DIR_MODE_OUT);
	/* Send a high output on buzzer to turn it off(inverted logic, refer
	schematic) */
	GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_4,0x10);

}
예제 #9
0
/*FUNCTION*-------------------------------------------------------
*
* Function Name : ledInit
* Comments      :
*END*-----------------------------------------------------------*/
int ledInit(){

    /* Enabling functional clocks for GPIO1 instance. */
    GPIO1_ModuleClkConfig();
 
    /* Selecting GPIO1[23] pin for use. */
    /*GPIOPinMuxSetup(CONTROL_CONF_GPMC_A(7), CONTROL_CONF_MUXMODE(7));*/
    GetGPIOPinName();
    /* Enabling the GPIO module. */
    GPIOModuleEnable(GPIO_INSTANCE_ADDRESS);

    /* Resetting the GPIO module. */
    GPIOModuleReset(GPIO_INSTANCE_ADDRESS);

    /* Setting the GPIO pin as an output pin. */
    GPIODirModeSet(GPIO_INSTANCE_ADDRESS,
               GPIO_INSTANCE_PIN_NUMBER,
               DIR_OUTPUT);
    
    return(0);

}
예제 #10
0
static void Init(void)
{
	// if already passed initialization, return
	if(isInitialized)
		return;

	// enable peripheral clock
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);

	// setup multiplexer
	GPIODirModeSet(GPIO_PORTB_BASE, GPIO_PIN_7, GPIO_DIR_MODE_OUT);
	GPIOPadConfigSet( GPIO_PORTB_BASE, GPIO_PIN_7, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD );
	GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_7, 0xFF);


	// set gpio pins to hardware used mode
	GPIOPinTypeUART(SERIALPORT_PORT_BASE, SERIALPORT_PINS);
	GPIOIntTypeSet(SERIALPORT_PORT_BASE, SERIALPORT_PINS, GPIO_DIR_MODE_HW);

	// initialization complete
	isInitialized = true;
}
예제 #11
0
void setup(){

	SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);
	SysCtlPWMClockSet(SYSCTL_PWMDIV_64);

	SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM1);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);

	ROM_GPIOPinTypePWM(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);
	ROM_GPIOPinConfigure(GPIO_PF1_M1PWM5);
	ROM_GPIOPinConfigure(GPIO_PF2_M1PWM6);
	ROM_GPIOPinConfigure(GPIO_PF3_M1PWM7);

	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;

	GPIODirModeSet(GPIO_PORTF_BASE, GPIO_PIN_4|GPIO_PIN_0, GPIO_DIR_MODE_IN);
	GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_4|GPIO_PIN_0, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);



}
예제 #12
0
void configWakeGpio()
{
	/* Enabling the GPIO module. */
	GPIOModuleEnable(GPIO_WAKE_INSTANCE);
	
	/* Perform a module reset of the GPIO module. */
    //GPIOModuleReset(GPIO_WAKE_INSTANCE);
	
	/* Set the specified pin as an Input pin. */
    GPIODirModeSet(GPIO_WAKE_INSTANCE,
                   GPIO_WAKE_PIN_NUM,
                   GPIO_DIR_INPUT);
				   
	GPIOIntTypeSet(GPIO_WAKE_INSTANCE,
					GPIO_WAKE_PIN_NUM,
					GPIO_INT_TYPE_BOTH_EDGE);
					
	HWREG(GPIO_WAKE_INSTANCE + 0x34) = 0x40000000;
	HWREG(GPIO_WAKE_INSTANCE + 0x38) = 0x40000000;
	
	HWREG(GPIO_WAKE_INSTANCE + 0x44) = 0x40000000;
	
}
예제 #13
0
int main(void)
{
    /* unsigned int count = 0; */

    /* Configuring the functional clock for GPIO0 instance. */
    GPIO0ModuleClkConfig();

    /* Doing a pin multiplexing and selecting GPIO0[7] for use. */    
    GPIO0Pin7PinMuxSetup();

    /* Enabling the GPIO module. */
    GPIOModuleEnable(SOC_GPIO_0_REGS);

    /* Resetting the GPIO module. */
    GPIOModuleReset(SOC_GPIO_0_REGS);

    /* Configuring GPIO0[7] pin as an output pin. */ 
    GPIODirModeSet(SOC_GPIO_0_REGS,
                   GPIO_INSTANCE_PIN_NUMBER,
                   GPIO_DIR_OUTPUT);
    while(1)
    {
        /* Driving GPIO0[7] pin to logic HIGH. */    
        GPIOPinWrite(SOC_GPIO_0_REGS,
                     GPIO_INSTANCE_PIN_NUMBER,
                     GPIO_PIN_HIGH);

        Delay(0xFFFFF);

        /* Driving GPIO0[7] pin to logic LOW. */
        GPIOPinWrite(SOC_GPIO_0_REGS,
                     GPIO_INSTANCE_PIN_NUMBER,
                     GPIO_PIN_LOW);
        
        Delay(0xFFFFF);
    }
}
예제 #14
0
//*****************************************************************************
void PinMuxConfig(void)
{
    //
    // Enable Peripheral Clocks 
    //
    PRCMPeripheralClkEnable(PRCM_UARTA0, PRCM_RUN_MODE_CLK);
    PRCMPeripheralClkEnable(PRCM_GPIOA2, PRCM_RUN_MODE_CLK);

    //
    // Configure PIN_55 for UART0 UART0_TX
    //
    PinTypeUART(PIN_55, PIN_MODE_3);

    //
    // Configure PIN_57 for UART0 UART0_RX
    //
    PinTypeUART(PIN_57, PIN_MODE_3);

    //
    // Configure PIN_08 for GPIO Input
    //
    PinTypeGPIO(PIN_08, PIN_MODE_0, false);
    GPIODirModeSet(GPIOA2_BASE, 0x2, GPIO_DIR_MODE_IN);
}
예제 #15
0
void vSerialInit( void )
{
	/* Create the queue used to communicate between the UART ISR and the Comms
	Rx task. */
	xCommsQueue = xQueueCreate( commsRX_QUEUE_LEN, sizeof( portCHAR ) );

	/* Enable the UART.  GPIOA has already been initialised. */
	SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);

	/* Set GPIO A0 and A1 as peripheral function.  They are used to output the
	UART signals. */
	GPIODirModeSet( GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1, GPIO_DIR_MODE_HW );

	/* Configure the UART for 8-N-1 operation. */
	UARTConfigSet( UART0_BASE, commsBAUD_RATE, UART_CONFIG_WLEN_8 | UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_ONE );

	/* We dont want to use the fifo.  This is for test purposes to generate
	as many interrupts as possible. */
	HWREG( UART0_BASE + UART_O_LCR_H ) &= ~commsFIFO_SET;

	/* Enable both Rx and Tx interrupts. */
	HWREG( UART0_BASE + UART_O_IM ) |= ( UART_INT_TX | UART_INT_RX );
	IntEnable( INT_UART0 );
}
예제 #16
0
void SCCBTick(void){
	static unsigned char quarter=0;
 	if(SCCBMaster.state==SCCB_READ){
		switch(quarter){
			case 0:

				break;
			case 1:
				GPIOPinWrite(SCCBMaster.GpioBase, SCCBMaster.sclGpio,0);
				break;
			case 2:
//acknowledge byte
				if(SCCBMaster.currentBit<2){
					GPIODirModeSet(SCCBMaster.GpioBase,SCCBMaster.sdaGpio,GPIO_DIR_MODE_OUT);
					GPIOPinWrite(SCCBMaster.GpioBase, SCCBMaster.sdaGpio,0);
				}
				else{
					SCCBMaster.byteRegister=SCCBMaster.byteRegister<<1;
					if(GPIOPinRead(SCCBMaster.GpioBase,SCCBMaster.sdaGpio)){
						SCCBMaster.byteRegister++;
					}
				}
				break;
			case 3:
				GPIOPinWrite(SCCBMaster.GpioBase, SCCBMaster.sclGpio,SCCBMaster.sclGpio);
				if(SCCBMaster.currentBit==1)quarter=0;
				SCCBMaster.currentBit--;
				break;
		}

	}

	else{

		switch(quarter){
			case 0:
				//first bit sda goes low
				//
				break;
			case 1:
				//clock goes low
				GPIOPinWrite(SCCBMaster.GpioBase, SCCBMaster.sclGpio,0);
				break;
			case 2:
				//read/write bit to write
				if(SCCBMaster.currentBit==1){
					GPIOPinWrite(SCCBMaster.GpioBase, SCCBMaster.sdaGpio,0);
				}
				else{
					GPIOPinWrite(SCCBMaster.GpioBase, SCCBMaster.sdaGpio,SCCBMaster.byteRegister&256?SCCBMaster.sdaGpio:0);
				}
				break;
			case 3:
				//clock goes high
				GPIOPinWrite(SCCBMaster.GpioBase, SCCBMaster.sclGpio,255);
				//last bit is finished
				SCCBMaster.byteRegister=SCCBMaster.byteRegister<<1;
				if(SCCBMaster.currentBit==1)quarter=0;
				SCCBMaster.currentBit--;
				break;
		}
	}
	quarter++;
	if(quarter>3)quarter=0;
}
예제 #17
0
	/**
	 * Set pin mode to input
	 */
	void DigitalIOPin::Input(void)
	{
		GPIODirModeSet(this->port, this->pin, GPIO_DIR_MODE_IN);
	}
예제 #18
0
void softwareControlEthernetLeds()
{
    GPIODirModeSet(GPIO_PORTF_BASE, GPIO_PIN_2 | GPIO_PIN_3, GPIO_DIR_MODE_OUT);
}
예제 #19
0
/** Initializes Ports/Pins: sets direction, interrupts, pullup/pulldown resistors etc. */
void portInit()
{
    //Configure SPI port
    //PRECONDITIONS: GPIO PORTS HAVE BEEN ENABLED & PINS WERE CONFIGURED: PC4, PD5 as outputs; PD6 as input
    //SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);  //FOR Module Control ????
    //SysCtlDelay(10); //delay by (3 * 10) 30 clock cycles

    /* Port A
     * PA0      U0Rx (Only for USB UART - N/A if using RS-232)
     * PA1      U0Tx (Only for USB UART - N/A if using RS-232)
     * PA2      SSI0CLK
     * PA3      SSI0 ChipSelect for OLED screen on LM3S6965 board (NOT USED in our application - leave as input in case R25 mistakenly populated)
     * PA4      SSI0Rx (MISO)
     * PA5      SSI0Tx (MOSI)
     * PA6      USB Sleep input
     * PA7
     */
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    SysCtlDelay(10); //delay by (3 * 10) 30 clock cycles
    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
    SysCtlDelay(10); //delay by (3 * 10) 30 clock cycles
    /* SSI */
    GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_4 | GPIO_PIN_5);
    GPIOPadConfigSet(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_4 | GPIO_PIN_5, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
    SysCtlDelay(10); //delay by (3 * 10) 30 clock cycles
    /* Inputs */
    GPIOPinTypeGPIOInput(GPIO_PORTA_BASE, GPIO_PIN_6);
    GPIOPinTypeGPIOInput(GPIO_PORTA_BASE, GPIO_PIN_3);
    /* UART */
    GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
    // If interrupts are desired, then enable interrupts on this UART
    IntEnable(INT_UART0);
    UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT);
    UARTStdioInit(0);  //configures this UART0 as the uart to use for UARTprintf

    /* Port B
     * Pb0      Internal LED1 - "D2" Blue
     * Pb1      Internal LED2 - "D3" Green
     * Pb2		I2C SCL (connected to EEPROM)
     * Pb3		I2C SDA (connected to EEPROM)
     * Pb4      Spare 1 (on header)
     * Pb5      Status LED - Green
     * Pb6      Status LED - Red
     * Pb7      TRSTn - not used
     */
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    SysCtlDelay(10); //delay by (3 * 10) 30 clock cycles
    /* Outputs */
    GPIOPadConfigSet(GPIO_PORTB_BASE, (GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_5 | GPIO_PIN_6), GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD);
    GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, (GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_5 | GPIO_PIN_6));  //configure LEDs

    // I2C:
#ifdef HAL_I2C
    GPIOPinTypeI2C(GPIO_PORTB_BASE, GPIO_PIN_2 | GPIO_PIN_3);
    delayMs(2);
#endif

    /* Port C
     * PC0      JTAG TCK
     * PC1      JTAG TMS
     * PC2      JTAG TDI
     * PC3      JTAG TD0
     * PC4      Module Chip Select
     * PC5      SPI Flash Chip Select
     * PC6      USB RTS (not used)
     * PC7      USB CTS (not used)
     */
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
    SysCtlDelay(10); //delay by (3 * 10) 30 clock cycles
    /* Outputs */
    GPIOPinTypeGPIOOutput(GPIO_PORTC_BASE, (GPIO_PIN_4 | GPIO_PIN_5));
    //GPIOPadConfigSet(GPIO_PORTC_BASE, (GPIO_PIN_4 | GPIO_PIN_5), GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD);


    /* Port D
     * PD0      Spare 0
     * PD1
     * PD2      Spare Rx
     * PD3      Spare Tx
     * PD4
     * PD5      Module Reset
     * PD6      SRDY
     * PD7
     */
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);  //FOR Module CONTROL
    SysCtlDelay(10); //delay by (3 * 10) 30 clock cycles
    /* Outputs */
    GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_5);
    //GPIOPadConfigSet(GPIO_PORTD_BASE, GPIO_PIN_5, GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD);
    /* Inputs */
    GPIOPinTypeGPIOInput(GPIO_PORTD_BASE, GPIO_PIN_6);


    RADIO_OFF();
    SPI_SS_CLEAR();

    /* Port E
     * PE0      Spare
     * PE1      Spare
     * PE2      Spare
     * PE3      Internal button
     */
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
    SysCtlDelay(10); //delay by (3 * 10) 30 clock cycles
    /* Inputs */
    GPIOPadConfigSet(GPIO_PORTE_BASE, GPIO_PIN_3 , GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD_WPD);
    GPIODirModeSet(GPIO_PORTE_BASE, GPIO_PIN_3, GPIO_DIR_MODE_IN);
    GPIOIntTypeSet(GPIO_PORTE_BASE, GPIO_PIN_3, GPIO_RISING_EDGE); // Make button a falling-edge triggered interrupt
    GPIOPinIntEnable(GPIO_PORTE_BASE, GPIO_PIN_3);                  // Enable the interrupt on this pin
    GPIOPinIntClear(GPIO_PORTE_BASE, GPIO_PIN_3);                   //Clear interrupts
    IntEnable(INT_GPIOE);                                           //enable interrupt 18

    /* Port F
     * PF0      Internal LED0 - "D1" Red
     * PF1      External button
     * PF2		Ethernet LED1 (Rx or Tx Activity)
     * PF3		Ethernet LED0 (Link Ok)
     */
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    SysCtlDelay(10); //delay by (3 * 10) 30 clock cycles
    /* Outputs */
    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_0);  //configure LED
    /* Inputs */
    GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_1 , GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD_WPD);
    GPIODirModeSet(GPIO_PORTF_BASE, GPIO_PIN_1, GPIO_DIR_MODE_IN);
    GPIOIntTypeSet(GPIO_PORTF_BASE, GPIO_PIN_1, GPIO_RISING_EDGE); // Make button a falling-edge triggered interrupt
    GPIOPinIntEnable(GPIO_PORTF_BASE, GPIO_PIN_1);                  // Enable the interrupt on this pin
    GPIOPinIntClear(GPIO_PORTF_BASE, GPIO_PIN_1);                   //Clear interrupts
    IntEnable(INT_GPIOF);                                           //enable interrupt 18
    /* Ethernet LEDs */
    GPIODirModeSet(GPIO_PORTF_BASE, GPIO_PIN_2 | GPIO_PIN_3, GPIO_DIR_MODE_HW);
    GPIOPadConfigSet(GPIO_PORTF_BASE,GPIO_PIN_2|GPIO_PIN_3,GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);

    return;

    /* Port G
     * PG0      UART2 Rx
     * PG1      UART2 Tx
     */
#ifdef USE_UART2
    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART2);
    SysCtlDelay(10); //delay by (3 * 10) 30 clock cycles
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
    SysCtlDelay(10); //delay by (3 * 10) 30 clock cycles

    GPIOPinTypeUART(GPIO_PORTG_BASE, GPIO_PIN_0 | GPIO_PIN_1);
    // Configure the UART for 115,200, 8-N-1 operation.
    //UARTConfigSetExpClk(UART2_BASE, SysCtlClockGet(), 115200,
    //		(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
    // Enable the UART interrupt.
    IntEnable(INT_UART2);

    UARTIntEnable(UART2_BASE, UART_INT_RX | UART_INT_RT);
    //UARTStdioInit(2);  //configures this UART0 as the uart to use for UARTprintf
#else
    //SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    /* already done in port A
    GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);

    // If interrupts are desired, then enable interrupts on this UART
    IntEnable(INT_UART0);
    UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT);
    UARTStdioInit(0);  //configures this UART0 as the uart to use for UARTprintf
    */
#endif

}
예제 #20
0
파일: ui.c 프로젝트: VENGEL/StellarisWare
//*****************************************************************************
//
//! Initializes the user interface.
//!
//! This function initializes the user interface modules (on-board and serial),
//! preparing them to operate and control the motor drive.
//!
//! \return None.
//
//*****************************************************************************
void
UIInit(void)
{
    unsigned long ulSysTickVal;

    //
    // Enable the GPIO peripherals needed for the button and LEDs
    //
    SysCtlPeripheralEnable(USER_BUTTON_GPIO_PERIPH);
    SysCtlPeripheralEnable(LED_GPIO_PERIPH);

    //
    // Set up button GPIO as input, and LEDs as outputs, and turn them off
    //
    GPIODirModeSet(USER_BUTTON_PORT, USER_BUTTON_PIN, GPIO_DIR_MODE_IN);
    GPIODirModeSet(STATUS_LED_PORT, STATUS_LED_PIN, GPIO_DIR_MODE_OUT);
    GPIODirModeSet(MODE_LED_PORT, MODE_LED_PIN, GPIO_DIR_MODE_OUT);
    GPIOPinWrite(STATUS_LED_PORT, STATUS_LED_PIN, 0);
    GPIOPinWrite(MODE_LED_PORT, MODE_LED_PIN, 0);

    //
    // Set up the LED blinking function
    //
    BlinkInit(STATUS_LED, STATUS_LED_PORT, STATUS_LED_PIN);
    BlinkInit(MODE_LED, MODE_LED_PORT, MODE_LED_PIN);
    BlinkStart(MODE_LED, UI_INT_RATE / 2, UI_INT_RATE / 2, eUIMode + 1);

    //
    // Enable the ADC peripheral, needed for potentiometer
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
    SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_ADC0);

    //
    // Set the ADC to run at the maximum rate of 500 ksamples.
    //
    HWREG(SYSCTL_RCGC0) |= 0x00000200;
    HWREG(SYSCTL_SCGC0) |= 0x00000200;

    //
    // Program sequencer for collecting ADC sample for potentiometer
    // position, bus voltage, and temperature sensor.
    //
    ADCSequenceConfigure(ADC0_BASE, UI_ADC_SEQUENCER, ADC_TRIGGER_PROCESSOR,
                         UI_ADC_PRIORITY);
    ADCSequenceStepConfigure(ADC0_BASE, UI_ADC_SEQUENCER, 0, POT_ADC_CHAN);
    ADCSequenceStepConfigure(ADC0_BASE, UI_ADC_SEQUENCER, 1, BUSV_ADC_CHAN);
    ADCSequenceStepConfigure(ADC0_BASE, UI_ADC_SEQUENCER, 2,
                             ADC_CTL_TS | ADC_CTL_END);
    ADCSequenceEnable(ADC0_BASE, UI_ADC_SEQUENCER);
    ADCProcessorTrigger(ADC0_BASE, UI_ADC_SEQUENCER);   // take initial sample

    //
    // initialize the lower level,
    // positioner, which handles computing all the motion control
    //
    StepperInit();

    //
    // Get a pointer to the stepper status.
    //
    pStepperStatus = StepperGetMotorStatus();

    //
    // Force an update of all the parameters (sets defaults).
    //
    UISetPWMFreq();
    UISetChopperBlanking();
    UISetMotorParms();
    UISetControlMode();
    UISetDecayMode();
    UISetStepMode();
    UISetFixedOnTime();

    //
    // Initialize the flash parameter block driver.
    //
    FlashPBInit(FLASH_PB_START, FLASH_PB_END, FLASH_PB_SIZE);

    //
    // Initialize the serial user interface.
    //
    UISerialInit();
    IntPrioritySet(INT_UART0, UI_SER_INT_PRI);

    //
    // Make sure that the UART doesnt get put to sleep
    //
    SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UART0);

    //
    // Initialize the on-board user interface.
    //
    UIOnboardInit(GPIOPinRead(USER_BUTTON_PORT, USER_BUTTON_PIN), 0);

    //
    // Initialize the processor usage routine.
    //
    CPUUsageInit(SysCtlClockGet(), UI_INT_RATE, 2);

    //
    // Configure SysTick to provide a periodic user interface interrupt.
    //
    SysTickPeriodSet(SysCtlClockGet() / UI_INT_RATE);
    SysTickIntEnable();
    SysTickEnable();
    IntPrioritySet(FAULT_SYSTICK, SYSTICK_INT_PRI);

    //
    // A delay is needed to let the current sense line discharge after
    // reset, before the current fault parameter is configured.  The
    // two loops below let the systick roll around once before proceeding.
    //
    ulSysTickVal = SysTickValueGet();

    //
    // Wait for systick to reach 0 and roll over to top.
    //
    while(SysTickValueGet() <= ulSysTickVal)
    {
    }

    //
    // Wait for systick to get back to the starting value.
    //
    while(SysTickValueGet() > ulSysTickVal)
    {
    }

    //
    // Now set the current fault parameter (after the delay above).
    //
    UISetFaultParms();

    //
    // Load stored parameters from flash, if any are available.
    //
    UIParamLoad();
}
예제 #21
0
void hardwareControlEthernetLeds()
{
    GPIODirModeSet(GPIO_PORTF_BASE, GPIO_PIN_2 | GPIO_PIN_3, GPIO_DIR_MODE_HW);
}
예제 #22
0
/*----------------------------------------------------------------------------
  Ethernet Device initialize
 *----------------------------------------------------------------------------*/
static int EthDev_Init (void) {
  int regv,tout;

  SysCtlPeripheralEnable (SYSCTL_PERIPH_ETH);        /* Enable and Reset the Ethernet Controller */
  SysCtlPeripheralReset (SYSCTL_PERIPH_ETH);

  SysCtlPeripheralEnable (SYSCTL_PERIPH_GPIOF);      /* Enable Port F for Ethernet LEDs */
  GPIODirModeSet  (GPIO_PORTF_BASE, (GPIO_PIN_2|GPIO_PIN_3), GPIO_DIR_MODE_HW);
  GPIOPadConfigSet(GPIO_PORTF_BASE, (GPIO_PIN_2|GPIO_PIN_3), GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);

  pEMAC->IEN   = 0;                                  /* Disable all Ethernet Interrupts */
  pEMAC->ISR   = INT_ALL;
  pEMAC->MCDIV = 10;                                 /* Set MII interface clock (max. 2.5MHz) */
  pEMAC->MADR  = PHY_DEF_ADR;                        /* set the PHY address */

  phy_Wr (PHY_REG_CTRL, 0x8000);

  /* Wait for hardware reset to end. */
  for (tout = 0x20000; ; tout--) {
    regv = phy_Rd (PHY_REG_CTRL);
    if (regv < 0 || tout == 0) {
       /* Error */
       return (-1);
    }
    if (!(regv & 0x8000)) {
       /* Reset complete. */
       break;
    }
  }

  switch (ETH.Mode) {
    case EthDev_MODE_AUTO:
      phy_Wr (PHY_REG_CTRL, PHY_AUTO_NEG);
      break;

    case EthDev_MODE_10M_FULL:
      phy_Wr (PHY_REG_CTRL, PHY_10M_FULL);
      break;

    case EthDev_MODE_10M_HALF:
      phy_Wr (PHY_REG_CTRL, PHY_10M_HALF);
      break;

    case EthDev_MODE_100M_FULL:
      phy_Wr (PHY_REG_CTRL, PHY_100M_FULL);
      break;

    case EthDev_MODE_100M_HALF:
      phy_Wr (PHY_REG_CTRL, PHY_100M_HALF);
      break;

    default:
       return (-1);
  }

  /* Configure TX/RX Control Registers, enable Multicast. */
  pEMAC->RXCTL = RXCTL_BAD_CRC | RXCTL_RST_FIFO;

  pEMAC->TXCTL = TXCTL_PAD_EN  | TXCTL_CRC_EN;

  /* Set the Ethernet MAC Address registers */
  pEMAC->IAR1   = ((unsigned int)ETH.HwAddr[5] << 8)  |
                   (unsigned int)ETH.HwAddr[4];
  pEMAC->IAR0   = ((unsigned int)ETH.HwAddr[3] << 24) |
                  ((unsigned int)ETH.HwAddr[2] << 16) |
                  ((unsigned int)ETH.HwAddr[1] << 8)  |
                   (unsigned int)ETH.HwAddr[0];

  pEMAC->RXCTL |= RXCTL_RX_EN;                       /* Enable the Ethernet Controller */
  pEMAC->TXCTL |= TXCTL_TX_EN;

  pEMAC->IEN    = INT_RX;
  IntEnable (INT_ETH);

  Status.Link = EthDev_LINK_DOWN;
  return (0);
}
/*
 *  ======== SENSORTAG_CC2650_initGPIO ========
 */
Void SENSORTAG_CC2650_initGPIO(Void)
{
	Bits32 pin;
  
	/* Power up the GPIO module. */
	GPIO_open();

  /* Setup the LED1 (red) GPIO pin. */
	pin = gpioHWAttrs[SENSORTAG_CC2650_LED1].pin;
  IOCPortConfigureSet(PIN2IOID(pin), IOC_PORT_GPIO, IOC_STD_OUTPUT);
  GPIODirModeSet(pin, GPIO_DIR_MODE_OUT);
  
  /* Setup the LED2 (green) GPIO pin. */
	pin = gpioHWAttrs[SENSORTAG_CC2650_LED2].pin;
  IOCPortConfigureSet(PIN2IOID(pin), IOC_PORT_GPIO, IOC_STD_OUTPUT);
  GPIODirModeSet(pin, GPIO_DIR_MODE_OUT);

  /* Setup the Button1 GPIO pin. */
	pin = gpioHWAttrs[SENSORTAG_CC2650_BUTTON1].pin;
  IOCPortConfigureSet(PIN2IOID(pin), IOC_PORT_GPIO, IOC_STD_INPUT);
  GPIODirModeSet(pin, GPIO_DIR_MODE_IN);
  IOCIOPortPullSet(PIN2IOID(pin), IOC_IOPULL_UP);
  
  /* Setup the Button2 GPIO pin. */
	pin = gpioHWAttrs[SENSORTAG_CC2650_BUTTON2].pin;
  IOCPortConfigureSet(PIN2IOID(pin), IOC_PORT_GPIO, IOC_STD_INPUT);
  GPIODirModeSet(pin, GPIO_DIR_MODE_IN);
  IOCIOPortPullSet(PIN2IOID(pin), IOC_IOPULL_UP);

  /* Setup the Reed relay GPIO pin. */
	pin = gpioHWAttrs[SENSORTAG_CC2650_REED_INT].pin;
  IOCPortConfigureSet(PIN2IOID(pin), IOC_PORT_GPIO, IOC_STD_INPUT);
  GPIODirModeSet(pin, GPIO_DIR_MODE_IN);
  IOCIOPortPullSet(PIN2IOID(pin), IOC_IOPULL_DOWN);

  /* Setup the FLASH_CS pin. */
	pin = gpioHWAttrs[SENSORTAG_CC2650_FLASH_CS].pin;
  IOCPortConfigureSet(PIN2IOID(pin), IOC_PORT_GPIO, IOC_STD_OUTPUT);
  GPIODirModeSet(pin, GPIO_DIR_MODE_OUT);
  IOCIOPortPullSet(PIN2IOID(pin), IOC_NO_IOPULL);

  /* Setup the BUZZER_EN pin. */
	pin = gpioHWAttrs[SENSORTAG_CC2650_BUZZER_EN].pin;
  IOCPortConfigureSet(PIN2IOID(pin), IOC_PORT_GPIO, IOC_STD_OUTPUT);
  GPIODirModeSet(pin, GPIO_DIR_MODE_OUT);

  /* Setup the MPU_POWER GPIO pin. */
	pin = gpioHWAttrs[SENSORTAG_CC2650_MPU_POWER].pin;
  IOCPortConfigureSet(PIN2IOID(pin), IOC_PORT_GPIO, IOC_STD_OUTPUT);
  GPIODirModeSet(pin, GPIO_DIR_MODE_OUT);

  /* Setup the MPU_INT GPIO pin. */
	pin = gpioHWAttrs[SENSORTAG_CC2650_MPU_INT].pin;
  IOCPortConfigureSet(PIN2IOID(pin), IOC_PORT_GPIO, IOC_STD_INPUT);
  GPIODirModeSet(pin, GPIO_DIR_MODE_IN);
  IOCIOPortPullSet(PIN2IOID(pin), IOC_IOPULL_DOWN);

  /* Setup the TMP_RDY GPIO pin. */
	pin = gpioHWAttrs[SENSORTAG_CC2650_TMP_RDY].pin;
  IOCPortConfigureSet(PIN2IOID(pin), IOC_PORT_GPIO, IOC_STD_INPUT);
  GPIODirModeSet(pin, GPIO_DIR_MODE_IN);

  /* Once GPIO_init is called, GPIO_config cannot be changed */
  GPIO_init();
  
  /* Set some of the IO pins */
  GPIO_write(SENSORTAG_CC2650_LED1, SENSORTAG_CC2650_LED_OFF);
  GPIO_write(SENSORTAG_CC2650_LED2, SENSORTAG_CC2650_LED_OFF);
  GPIO_write(SENSORTAG_CC2650_MPU_POWER, SENSORTAG_CC2650_MPU_POWER_ON);
  GPIO_write(SENSORTAG_CC2650_MIC_POWER, SENSORTAG_CC2650_MIC_POWER_OFF);
  GPIO_write(SENSORTAG_CC2650_FLASH_CS, SENSORTAG_CC2650_FLASH_CS_OFF);
}
예제 #24
0
int DS2401_Funcs_get(void)
{
	GPIODirModeSet(GPIOA0_BASE, GPIO_PIN_5, GPIO_DIR_MODE_IN);
	return	GPIOPinRead(GPIOA0_BASE, GPIO_PIN_5) / GPIO_PIN_5;
}
예제 #25
0
//*****************************************************************************
//
// Demonstrate the use of the boot loader.
//
//*****************************************************************************
int
main(void)
{
    //
    // Set the clocking to run directly from the crystal.
    //
    SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
                   SYSCTL_XTAL_8MHZ);

    //
    // Enable the UART and GPIO modules.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);

    //
    // Make the UART pins be peripheral controlled.
    //
    GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);

    //
    // Configure the UART for 115,200, 8-N-1 operation.
    //
    UARTConfigSetExpClk(UART0_BASE, 8000000, 115200,
                        (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
                         UART_CONFIG_PAR_NONE));

    //
    // Initialize the OLED display.
    //
    RIT128x96x4Init(1000000);

    //
    // Indicate what is happening.
    //
    RIT128x96x4StringDraw("Boot Loader Demo Two", 4, 20, 15);
    RIT128x96x4StringDraw("Press the select", 16, 44, 15);
    RIT128x96x4StringDraw("button to start the", 6, 52, 15);
    RIT128x96x4StringDraw("boot loader.", 28, 60, 15);

    //
    // Enable the GPIO pin to read the select button.
    //
    GPIODirModeSet(GPIO_PORTG_BASE, GPIO_PIN_4, GPIO_DIR_MODE_IN);
    GPIOPadConfigSet(GPIO_PORTG_BASE, GPIO_PIN_4, GPIO_STRENGTH_2MA,
                     GPIO_PIN_TYPE_STD_WPU);

    //
    // Wait until the select button has been pressed.
    //
    while(GPIOPinRead(GPIO_PORTG_BASE, GPIO_PIN_4) != 0)
    {
    }

    //
    // Drain any data that may be in the UART fifo.
    //
    while(UARTCharsAvail(UART0_BASE))
    {
        UARTCharGet(UART0_BASE);
    }

    //
    // Indicate that the boot loader is being called.
    //
    RIT128x96x4StringDraw("The boot loader is", 10, 36, 15);
    RIT128x96x4StringDraw(" now running and ", 12, 44, 15);
    RIT128x96x4StringDraw(" awaiting an update ", 4, 52, 15);
    RIT128x96x4StringDraw("over UART0 at", 24, 60, 15);
    RIT128x96x4StringDraw("115,200, 8-N-1.", 18, 68, 15);

    //
    // Call the boot loader so that it will listen for an update on the UART.
    //
    (*((void (*)(void))(*(unsigned long *)0x2c)))();

    //
    // The boot loader should take control, so this should never be reached.
    // Just in case, loop forever.
    //
    while(1)
    {
    }
}
예제 #26
0
//*****************************************************************************
//
// Configures all pins associated with the Extended Peripheral Interface (EPI).
//
// \param eDaughter identifies the attached daughter board (if any).
//
// This function configures all pins forming part of the EPI on the device and
// configures the EPI peripheral appropriately for whichever hardware we
// detect is connected to it. On exit, the EPI peripheral is enabled and all
// pins associated with the interface are configured as EPI signals. Drive
// strength is set to 8mA for all pins.
//
//*****************************************************************************
static void
EPIPinConfigSet(void)
{
    //
    // Enable the EPI peripheral
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_EPI0);

    //
    // Configure the EPI pins that are to be used on this board.
    //
#if (EPI_PORTA_PINS != 0x00)
    GPIOPadConfigSet(GPIO_PORTA_BASE, EPI_PORTA_PINS, GPIO_STRENGTH_8MA,
                     GPIO_PIN_TYPE_STD_WPU);
    GPIODirModeSet(GPIO_PORTA_BASE, EPI_PORTA_PINS, GPIO_DIR_MODE_HW);
#endif
#if (EPI_PORTC_PINS != 0x00)
    GPIOPadConfigSet(GPIO_PORTC_BASE, EPI_PORTC_PINS, GPIO_STRENGTH_8MA,
                     GPIO_PIN_TYPE_STD_WPU);
    GPIODirModeSet(GPIO_PORTC_BASE, EPI_PORTC_PINS, GPIO_DIR_MODE_HW);
#endif
#if EPI_PORTE_PINS
    GPIOPadConfigSet(GPIO_PORTE_BASE, EPI_PORTE_PINS, GPIO_STRENGTH_8MA,
                     GPIO_PIN_TYPE_STD_WPU);
    GPIODirModeSet(GPIO_PORTE_BASE, EPI_PORTE_PINS, GPIO_DIR_MODE_HW);
#endif
#if EPI_PORTF_PINS
    GPIOPadConfigSet(GPIO_PORTF_BASE, EPI_PORTF_PINS, GPIO_STRENGTH_8MA,
                     GPIO_PIN_TYPE_STD_WPU);
    GPIODirModeSet(GPIO_PORTF_BASE, EPI_PORTF_PINS, GPIO_DIR_MODE_HW);
#endif
#if EPI_PORTG_PINS
    GPIOPadConfigSet(GPIO_PORTG_BASE, EPI_PORTG_PINS, GPIO_STRENGTH_8MA,
                     GPIO_PIN_TYPE_STD_WPU);
    GPIODirModeSet(GPIO_PORTG_BASE, EPI_PORTG_PINS, GPIO_DIR_MODE_HW);
#endif
#if EPI_PORTJ_PINS
    GPIOPadConfigSet(GPIO_PORTJ_BASE, EPI_PORTJ_PINS, GPIO_STRENGTH_8MA,
                     GPIO_PIN_TYPE_STD_WPU);
    GPIODirModeSet(GPIO_PORTJ_BASE, EPI_PORTJ_PINS, GPIO_DIR_MODE_HW);
#endif

#if (EPI_PORTB_PINS != 0x00)
    GPIOPadConfigSet(GPIO_PORTB_BASE, EPI_PORTB_PINS, GPIO_STRENGTH_8MA,
                     GPIO_PIN_TYPE_STD_WPU);
    GPIODirModeSet(GPIO_PORTB_BASE, EPI_PORTB_PINS,
                   GPIO_DIR_MODE_HW);
#endif
#if (EPI_PORTD_PINS != 0x00)
    GPIOPadConfigSet(GPIO_PORTD_BASE, EPI_PORTD_PINS, GPIO_STRENGTH_8MA,
                     GPIO_PIN_TYPE_STD_WPU);
    GPIODirModeSet(GPIO_PORTD_BASE, EPI_PORTD_PINS,
                   GPIO_DIR_MODE_HW);
#endif
#if EPI_PORTH_PINS
    GPIOPadConfigSet(GPIO_PORTH_BASE, EPI_PORTH_PINS,GPIO_STRENGTH_8MA,
                     GPIO_PIN_TYPE_STD_WPU);
    GPIODirModeSet(GPIO_PORTH_BASE, EPI_PORTH_PINS,
                   GPIO_DIR_MODE_HW);
#endif

    //
    // Set the EPI operating mode for the Flash/SRAM/LCD daughter board.
    // The values used here set the EPI to run at the system clock rate and
    // will allow the board memories and LCD interface to be timed correctly
    // as long as the system clock is no higher than 50MHz.
    //
    EPIModeSet(EPI0_BASE, EPI_MODE_HB8);
    EPIDividerSet(EPI0_BASE, 0);
    EPIConfigHB8Set(EPI0_BASE, (EPI_HB8_MODE_ADMUX | EPI_HB8_WRWAIT_1 |
                    EPI_HB8_RDWAIT_1 | EPI_HB8_WORD_ACCESS), 0);
    EPIAddressMapSet(EPI0_BASE, (EPI_ADDR_RAM_SIZE_256MB |
                     EPI_ADDR_RAM_BASE_6) );
}
예제 #27
0
//*****************************************************************************
//
// This function prepares the quadrature encoder module for capturing the
// position and speed of the motor.
//
//*****************************************************************************
void
Encoder_Init(unsigned long ulBase)
{

	if(ulBase == QEI0_BASE) // J6 PITCH Encoder 
	{
		//
		// Enable the peripherals QEI example.
		//	
		SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
		SysCtlPeripheralEnable(SYSCTL_PERIPH_QEI0); 
	
	    // unlock GPIO PD7
	    GPIO_PORTD_LOCK_R = GPIO_LOCK_KEY;
		GPIO_PORTD_CR_R = GPIO_PIN_7;

		//Enable GPIO for QEI0
		//PD3-> IDX0 				
		//PD6-> PHA0
		//PD7-> PHB0 
		GPIOPinConfigure(GPIO_PD3_IDX0);		
		GPIOPinConfigure(GPIO_PD6_PHA0);	
		GPIOPinConfigure(GPIO_PD7_PHB0);

		GPIOPinTypeQEI(QEI_PITCH_PHA_PORT,QEI_PITCH_PHA_PIN); 
		GPIOPinTypeQEI(QEI_PITCH_PHB_PORT,QEI_PITCH_PHB_PIN);
		GPIOPinTypeQEI(QEI_PITCH_INDEX_PORT,QEI_PITCH_INDEX_PIN);
		
		
		// Set D 0 and 1 to alternative use 
		GPIODirModeSet(GPIO_PORTD_BASE, GPIO_PIN_3, GPIO_DIR_MODE_HW);//GPIO_DIR_MODE_HW	
		GPIODirModeSet(GPIO_PORTD_BASE, GPIO_PIN_6, GPIO_DIR_MODE_HW); 
		GPIODirModeSet(GPIO_PORTD_BASE, GPIO_PIN_7, GPIO_DIR_MODE_HW); 
		

		//
		// Configure the QEI module.
		//
		QEIConfigure(QEI0_BASE,
						 (QEI_CONFIG_NO_RESET | QEI_CONFIG_CAPTURE_A_B |
						  QEI_CONFIG_QUADRATURE | QEI_CONFIG_NO_SWAP), QEI0_POSCNT_MAX-1);
		
		
		//Set to 0 
		QEIPositionSet(QEI0_BASE, 0);

		QEIVelocityConfigure(QEI0_BASE, QEI_VELDIV_1, 500000); //Configure the Velocity capture Module //500000 is 10ms at 50MHz 

		QEIVelocityEnable(QEI0_BASE);	//Enable the Velocity capture Module	
		
		QEIIntEnable(QEI0_BASE, QEI_INTDIR | QEI_INTINDEX);   //Enable Interrupt when the Timer is reach 0 on Valocity capture mode 
		
		QEIEnable(QEI0_BASE);
				
		//
		// Configure the encoder input to generate an interrupt on every rising
		// edge.
		//
		//GPIOIntTypeSet(QEI_PITCH_PHA_PORT, QEI_PITCH_PHA_PIN, GPIO_RISING_EDGE);
		//GPIOPinIntEnable(QEI_PITCH_PHA_PORT, QEI_PITCH_PHA_PIN);
		//IntEnable(QEI_PITCH_PHA_INT);			

		//Interrupt Enable 
		//IntEnable(INT_QEI1); 

			
	}
	else
	if(ulBase == QEI1_BASE)		// J8 ROLL Encoder 
	{

		//
		// Enable the peripherals QEI example.
		//	
		SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
		SysCtlPeripheralEnable(SYSCTL_PERIPH_QEI1); 

		//Enable GPIO for QEI1 
		//PC4-> IDX0 				
		//PC5-> PHA0
		//PC6-> PHB0 
		GPIOPinConfigure(GPIO_PC4_IDX1);		
		GPIOPinConfigure(GPIO_PC5_PHA1);	
		GPIOPinConfigure(GPIO_PC6_PHB1);		
			
		GPIOPinTypeQEI(QEI_ROLL_PHA_PORT,QEI_ROLL_PHA_PIN); 
		GPIOPinTypeQEI(QEI_ROLL_PHB_PORT,QEI_ROLL_PHB_PIN);
		GPIOPinTypeQEI(QEI_ROLL_INDEX_PORT,QEI_ROLL_INDEX_PIN);
		
		
		// Set F 0 and 1 to alternative use 
		GPIODirModeSet(GPIO_PORTC_BASE, GPIO_PIN_4, GPIO_DIR_MODE_HW);//GPIO_DIR_MODE_HW	
		GPIODirModeSet(GPIO_PORTC_BASE, GPIO_PIN_5, GPIO_DIR_MODE_HW); 
		GPIODirModeSet(GPIO_PORTC_BASE, GPIO_PIN_6, GPIO_DIR_MODE_HW); 
		

		//
		// Configure the QEI module.
		//
		QEIConfigure(QEI1_BASE,
						 (QEI_CONFIG_NO_RESET | QEI_CONFIG_CAPTURE_A_B |
						  QEI_CONFIG_QUADRATURE | QEI_CONFIG_SWAP), QEI1_POSCNT_MAX-1);
		
		
		//Set to 0 
		QEIPositionSet(QEI1_BASE, 0);

		QEIVelocityConfigure(QEI1_BASE, QEI_VELDIV_1, 500000); //Configure the Velocity capture Module //500000 is 10ms at 50MHz 

		QEIVelocityEnable(QEI1_BASE);	//Enable the Velocity capture Module	
		
		QEIIntEnable(QEI1_BASE, QEI_INTDIR | QEI_INTINDEX);   //Enable Interrupt when the Timer is reach 0 on Valocity capture mode 
		
		QEIEnable(QEI1_BASE);
				
		//
		// Configure the encoder input to generate an interrupt on every rising
		// edge.
		//
		//GPIOIntTypeSet(QEI_ROLL_PHA_PORT, QEI_ROLL_PHA_PIN, GPIO_RISING_EDGE);
		//GPIOPinIntEnable(QEI_ROLL_PHA_PORT, QEI_ROLL_PHA_PIN);
		//IntEnable(QEI_ROLL_PHA_INT);			

		//Interrupt Enable 
		//IntEnable(INT_QEI1); 

	}
}
예제 #28
0
void vParTestInitialise( void )
{
    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, 0 );
}
예제 #29
0
	/**
	 * Set pin mode to output
	 */
	void DigitalIOPin::Output(void)
	{
		GPIODirModeSet(this->port, this->pin, GPIO_DIR_MODE_OUT);
	}
예제 #30
0
//*****************************************************************************
//
// Configures all pins associated with the Extended Peripheral Interface (EPI).
//
// \param eDaughter identifies the attached daughter board (if any).
//
// This function configures all pins forming part of the EPI on the device and
// configures the EPI peripheral appropriately for whichever hardware we
// detect is connected to it. On exit, the EPI peripheral is enabled and all
// pins associated with the interface are configured as EPI signals. Drive
// strength is set to 8mA.
//
//*****************************************************************************
static void
EPIPinConfigSet(tDaughterIDInfo *psInfo)
{
    unsigned long ulLoop, ulClk, ulNsPerTick, ulRefresh;
    unsigned char pucPins[NUM_GPIO_PORTS];

    //
    // Enable the EPI peripheral
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_EPI0);

    //
    // Clear our pin bit mask array.
    //
    for(ulLoop = 0; ulLoop < NUM_GPIO_PORTS; ulLoop++)
    {
        pucPins[ulLoop] = 0;
    }

    //
    // Determine the pin bit masks for the EPI pins for each GPIO port.
    //
    for(ulLoop = 0; ulLoop < NUM_EPI_SIGNALS; ulLoop++)
    {
        //
        // Is this EPI signal required?
        //
        if(psInfo->ulEPIPins & (1 << ulLoop))
        {
            //
            // Yes - set the appropriate bit in our pin bit mask array.
            //
            pucPins[g_psEPIPinInfo[ulLoop].ucPortIndex] |=
                (1 << g_psEPIPinInfo[ulLoop].ucPin);
        }
    }

    //
    // At this point, pucPins contains bit masks for each GPIO port with 1s in
    // the positions of every required EPI signal.  Now we need to configure
    // those pins appropriately.  Cycle through each port configuring EPI pins
    // in any port which contains them.
    //
    for(ulLoop = 0; ulLoop < NUM_GPIO_PORTS; ulLoop++)
    {
        //
        // Are there any EPI pins used in this port?
        //
        if(pucPins[ulLoop])
        {
            //
            // Yes - configure the EPI pins.
            //
            GPIOPadConfigSet(g_pulGPIOBase[ulLoop], pucPins[ulLoop],
                             GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD_WPU);
            GPIODirModeSet(g_pulGPIOBase[ulLoop], pucPins[ulLoop],
                           GPIO_DIR_MODE_HW);
        }
    }

    //
    // Now set the EPI operating mode for the daughter board detected.  We need
    // to determine some timing information based on the ID block we have and
    // also the current system clock.
    //
    ulClk = SysCtlClockGet();
    ulNsPerTick = 1000000000/ulClk;

    //
    // If the EPI is not disabled (the daughter board may, for example, want
    // to use all the pins for GPIO), configure the interface as required.
    //
    if(psInfo->ucEPIMode != EPI_MODE_DISABLE)
    {
        //
        // Set the EPI clock divider to ensure a basic EPI clock rate no faster
        // than defined via the ucRate0nS and ucRate1nS fields in the info
        // structure.
        //
        EPIDividerSet(EPI0_BASE, CalcEPIDivider(psInfo, ulNsPerTick));

        //
        // Set the basic EPI operating mode based on the value from the info
        // structure.
        //
        EPIModeSet(EPI0_BASE, psInfo->ucEPIMode);

        //
        // Carry out mode-dependent configuration.
        //
        switch(psInfo->ucEPIMode)
        {
            //
            // The daughter board must be configured for SDRAM operation.
            //
            case EPI_MODE_SDRAM:
            {
                //
                // Work out the SDRAM configuration settings based on the
                // supplied ID structure and system clock rate.
                //
                ulLoop = SDRAMConfigGet(psInfo, ulClk, &ulRefresh);

                //
                // Set the SDRAM configuration.
                //
                EPIConfigSDRAMSet(EPI0_BASE, ulLoop, ulRefresh);
                break;
            }

            //
            // The daughter board must be configured for HostBus8 operation.
            //
            case EPI_MODE_HB8:
            {
                //
                // Determine the number of read and write wait states required
                // to meet the supplied access timing.
                //
                ulLoop = HB8ConfigGet(psInfo);

                //
                // Set the HostBus8 configuration.
                //
                EPIConfigHB8Set(EPI0_BASE, ulLoop, psInfo->ucMaxWait);
                break;
            }

            //
            // The daughter board must be configured for Non-Moded/General
            // Purpose operation.
            //
            case EPI_MODE_GENERAL:
            {
                EPIConfigGPModeSet(EPI0_BASE, psInfo->ulConfigFlags,
                                   psInfo->ucFrameCount, psInfo->ucMaxWait);
                break;
            }
        }

        //
        // Set the EPI address mapping.
        //
        EPIAddressMapSet(EPI0_BASE, psInfo->ucAddrMap);
    }
}