Beispiel #1
1
int main(void)
{
	volatile uint32_t ui32Load;
	volatile uint32_t ui32PWMClock;
	volatile uint8_t ui8Adjust;
	ui8Adjust = 254;

	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);

	GPIOPinTypePWM(GPIO_PORTF_BASE, GPIO_PIN_1);
	GPIOPinConfigure(GPIO_PF1_M1PWM5);

	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);

	ui32PWMClock = SysCtlClockGet() / 64;
	ui32Load = (ui32PWMClock / PWM_FREQUENCY) - 1;
	PWMGenConfigure(PWM1_BASE, PWM_GEN_2, PWM_GEN_MODE_DOWN);
	PWMGenPeriodSet(PWM1_BASE, PWM_GEN_2, ui32Load);

	PWMPulseWidthSet(PWM1_BASE, PWM_OUT_5, ui8Adjust * ui32Load / 1000);
	PWMOutputState(PWM1_BASE, PWM_OUT_5_BIT, true);
	PWMGenEnable(PWM1_BASE, PWM_GEN_2);

	while(1)
	{

		if(GPIOPinRead(GPIO_PORTF_BASE,GPIO_PIN_4)==0x00)
		{
			ui8Adjust--;
			if (ui8Adjust < 10)
			{
				ui8Adjust = 10;
			}
			PWMPulseWidthSet(PWM1_BASE, PWM_OUT_5, ui8Adjust * ui32Load / 1000);
		}

		if(GPIOPinRead(GPIO_PORTF_BASE,GPIO_PIN_0)==0x00)
		{
			ui8Adjust++;
			if (ui8Adjust > 254)
			{
				ui8Adjust = 254;
			}
			PWMPulseWidthSet(PWM1_BASE, PWM_OUT_5, ui8Adjust * ui32Load / 1000);
		}

		SysCtlDelay(100000);
	}

}
//*****************************************************************************
//
//! Enable the SSI component of the OLED display driver.
//!
//! \param ulFrequency specifies the SSI Clock Frequency to be used.
//!
//! This function initializes the SSI interface to the OLED display.
//!
//! This function is contained in <tt>osram128x64x4.c</tt>, with
//! <tt>osram128x64x4.h</tt> containing the API definition for use by
//! applications.
//!
//! \return None.
//
//*****************************************************************************
void
OSRAM128x64x4Disable(void)
{
    unsigned long ulTemp;

    //
    // Indicate that the OSRAM driver can no longer use the SSI Port.
    //
    g_bSSIEnabled = false;

    //
    // Drain the receive fifo.
    //
    while(SSIDataNonBlockingGet(SSI0_BASE, &ulTemp) != 0)
    {
    }

    //
    // Disable the SSI port.
    //
    SSIDisable(SSI0_BASE);

    //
    // Disable SSI control of the FSS pin.
    //
    GPIODirModeSet(GPIO_PORTA_BASE, GPIO_PIN_3, GPIO_DIR_MODE_OUT);
    GPIOPadConfigSet(GPIO_PORTA_BASE, GPIO_PIN_3, GPIO_STRENGTH_8MA,
                     GPIO_PIN_TYPE_STD_WPU);
    GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_3, GPIO_PIN_3);

}
Beispiel #3
0
/************************************************************************************//**
** \brief     Initializes the microcontroller. 
** \return    none.
**
****************************************************************************************/
static void Init(void)
{
  /* set the clocking to run at 50MHz from the PLL */
  SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);
#if (BOOT_COM_UART_ENABLE > 0)
  #if (BOOT_COM_UART_CHANNEL_INDEX == 0)
  /* enable and configure UART0 related peripherals and pins */
  SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
  GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
  #endif
#elif (BOOT_FILE_LOGGING_ENABLE > 0)
  /* log info strings to UART during firmware updates from local file storage */
  /* enable and configure UART0 related peripherals and pins */
  SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
  GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
  /* enable the UART0 peripheral */
  SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
  /* configure the UART0 baudrate and communication parameters */
  UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 57600,
                      (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | 
                      UART_CONFIG_PAR_NONE));
#endif
#if (BOOT_COM_USB_ENABLE > 0)
  /* enable the GPIO peripheral used for USB, and configure the USB pins */
  SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
  SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOL);
  GPIOPinTypeUSBAnalog(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);
  GPIOPinTypeUSBAnalog(GPIO_PORTL_BASE, GPIO_PIN_6 | GPIO_PIN_7);
#endif  
  /* enable the GPIO port to which the SELECT button is connected */
  SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOM);
  /* configure the SELECT button pin as an input with pull-up */
  GPIODirModeSet(GPIO_PORTM_BASE, GPIO_PIN_4, GPIO_DIR_MODE_IN);
  GPIOPadConfigSet(GPIO_PORTM_BASE, GPIO_PIN_4, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
} /*** end of Init ***/
void speakerInit()
{
	 //
	 // Enable the GPIO Port H.
	 //
	 SysCtlPeripheralEnable( SYSCTL_PERIPH_GPIOH );
	 //
	 // Configure GPIO_H to drive the Speaker.
	 //
	 GPIOPinTypeGPIOOutput( GPIO_PORTH_BASE, GPIO_PIN_1 | GPIO_PIN_0 );
	 GPIOPadConfigSet( GPIO_PORTH_BASE,GPIO_PIN_1 | GPIO_PIN_0,GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU );
	 //
	 // Set PortH<0> ON and PortH<1> OFF.
	 //
	 GPIOPinWrite( GPIO_PORTH_BASE, GPIO_PIN_1 | GPIO_PIN_0, 0x01 );
	 //
	 // The initial time to execute is Delta SysTicks from now.
	 //
	speakerDelta1 = (SYSTICK_FREQUENCY/(2*buzzFreq1));
	speakerDelta2 = (SYSTICK_FREQUENCY/(2*buzzFreq2));
	freq= speakerDelta1;
	speakerNext = sysTickCount + freq;


}
Beispiel #5
0
//*****************************************************************************
//
//! Enable the SSI component of the OLED display driver.
//!
//! This function initializes the SSI interface to the OLED display.
//!
//! \return None.
//
//*****************************************************************************
void
RIT128x96x4Disable(void)
{
    unsigned long ulTemp;

    //
    // Indicate that the RIT driver can no longer use the SSI Port.
    //
    HWREGBITW(&g_ulSSIFlags, FLAG_SSI_ENABLED) = 0;

    //
    // Drain the receive fifo.
    //
    while(SSIDataGetNonBlocking(SSI0_BASE, &ulTemp) != 0)
    {
    }

    //
    // Disable the SSI port.
    //
    SSIDisable(SSI0_BASE);

    //
    // Disable SSI control of the FSS pin.
    //
    GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_3);
    GPIOPadConfigSet(GPIO_PORTA_BASE, GPIO_PIN_3, GPIO_STRENGTH_8MA,
                     GPIO_PIN_TYPE_STD_WPU);
    GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_3, GPIO_PIN_3);
}
Beispiel #6
0
//*****************************************************************************
//
//! Enable the SSI component of the OLED display driver.
//!
//! \param ulFrequency specifies the SSI Clock Frequency to be used.
//!
//! This function initializes the SSI interface to the OLED display.
//!
//! \return None.
//
//*****************************************************************************
void
RIT128x96x4Enable(unsigned long ulFrequency)
{
    //
    // Disable the SSI port.
    //
    SSIDisable(SSI0_BASE);

    //
    // Configure the SSI0 port for master mode.
    //
    SSIConfigSetExpClk(SSI0_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_3,
                       SSI_MODE_MASTER, ulFrequency, 8);

    //
    // (Re)Enable SSI control of the FSS pin.
    //
    GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_3);
    GPIOPadConfigSet(GPIO_PORTA_BASE, GPIO_PIN_3, GPIO_STRENGTH_8MA,
                     GPIO_PIN_TYPE_STD_WPU);

    //
    // Enable the SSI port.
    //
    SSIEnable(SSI0_BASE);

    //
    // Indicate that the RIT driver can use the SSI Port.
    //
    HWREGBITW(&g_ulSSIFlags, FLAG_SSI_ENABLED) = 1;
}
Beispiel #7
0
lswitch::lswitch(memory_address_t lswitch_base, memory_address_t lswitch_pin,
                 semaphore *sem, utimer_t timer_id, subtimer_t timer_subtimer,
                 uint32_t switch_interrupt, uint32_t interrupt_mask, bool start) {

    base = lswitch_base;
    pin = lswitch_pin;

    ctlsys::enable_periph(base);
    GPIOPinTypeGPIOInput(base, pin);
    GPIODirModeSet(base, pin, GPIO_DIR_MODE_IN);

    if ((base == GPIO_PORTF_BASE) && (pin & GPIO_PIN_0)) {
        HWREG(base + GPIO_O_LOCK) = GPIO_LOCK_KEY;
        HWREG(base + GPIO_O_CR) = 0x01;
        HWREG(base + GPIO_O_LOCK) = 0;

        GPIOPadConfigSet(base, pin, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
    }

    /* other solution: timer scoreboard */
    this->tim = timer(timer_id, timer_subtimer, TIMER_CFG_ONE_SHOT, SysCtlClockGet() / 50,
                      ctlsys::timer_timeout_from_subtimer(timer_subtimer));

    GPIOIntTypeSet(base, pin, switch_interrupt);
    IntEnable(interrupt_mask);

    this->sem = sem;
    *(this->sem) = semaphore();

    if (start) {
        this->start();
    }
}
Beispiel #8
0
// *************** GPIO_Init *************** 
void GPIO_Init( GPIO_PORT_T port, GPIO_PIN_T pins, unsigned long dir_mode,
	     		unsigned long strength, unsigned long pin_type )
{
	if( 0 == GPIO_PortStatusFlag[port] )
	{
    	SysCtlPeripheralEnable( GPIO_Peripheral[port] );
		GPIO_PortStatusFlag[port] = 1;
	}
	
	switch ( pin_type )
	{
		case CCP:
		{
			GPIOPinTypeTimer ( GPIO_PortBase[port], pins );
			break;
		}

		case PWM:
		{
			break;
		}

		default:
		{
			// regular GPIOs
			GPIOPadConfigSet( GPIO_PortBase[port], pins, strength, pin_type );	   
    		GPIODirModeSet( GPIO_PortBase[port], pins, dir_mode );
			break;
		}
	}			  
}
Beispiel #9
0
//*****************************************************************************
//
//! Initializes the GPIO pins used by the board pushbuttons.
//!
//! This function must be called during application initialization to
//! configure the GPIO pins to which the pushbuttons are attached.  It enables
//! the port used by the buttons and configures each button GPIO as an input
//! with a weak pull-up.
//!
//! \return None.
//
//*****************************************************************************
void ButtonsInit(void) {
	//
	// Enable the GPIO port to which the pushbuttons are connected.
	//
	SysCtlPeripheralEnable(BUTTONS_GPIO_PERIPH);
	//
	// 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(BUTTONS_GPIO_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY_DD;
	HWREG(BUTTONS_GPIO_BASE + GPIO_O_CR) |= 0x01;
	HWREG(BUTTONS_GPIO_BASE + GPIO_O_LOCK) = 0;
	//
	// Set each of the button GPIO pins as an input with a pull-up.
	//
	GPIODirModeSet(BUTTONS_GPIO_BASE, ALL_BUTTONS, GPIO_DIR_MODE_IN);
	GPIOPadConfigSet(BUTTONS_GPIO_BASE, ALL_BUTTONS, GPIO_STRENGTH_2MA,
	GPIO_PIN_TYPE_STD_WPU);
	//
	// Initialize the debounced button state with the current state read from
	// the GPIO bank.
	//
	g_ucButtonStates = GPIOPinRead(BUTTONS_GPIO_BASE, ALL_BUTTONS);
}
Beispiel #10
0
void buttonSetup() {
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ);
	GPIOPinTypeGPIOInput(GPIO_PORTJ_BASE, GPIO_PIN_0);
	GPIOPadConfigSet(GPIO_PORTJ_BASE, GPIO_PIN_0, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
	//GPIOPinTypeGPIOInput(GPIO_PORTJ_BASE, GPIO_PIN_1);
	//GPIOPadConfigSet(GPIO_PORTJ_BASE, GPIO_PIN_1, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
}
Beispiel #11
0
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 );
  
}
Beispiel #12
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 );
}
extern void Task_HeaterOn( void *pvParameters ) {

	//
	//	Enable (power-on) PortG
	//
	SysCtlPeripheralEnable( SYSCTL_PERIPH_GPIOG );

	//
	// Enable the GPIO Port N.
	//
	SysCtlPeripheralEnable( SYSCTL_PERIPH_GPION );

	//
    // Configure GPIO_G to drive the HeaterOn_H.
    //
    GPIOPinTypeGPIOOutput( GPIO_PORTG_BASE, GPIO_PIN_0 );
    GPIOPadConfigSet( GPIO_PORTG_BASE,
    					GPIO_PIN_0, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD );

	//
	// Configure GPIO_N to drive the Status LED.
	//
	GPIOPinTypeGPIOOutput( GPIO_PORTN_BASE, GPIO_PIN_0 );
	GPIOPadConfigSet( GPIO_PORTN_BASE,
						GPIO_PIN_0, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD );

	while ( 1 ) {

	  OffTime_mS = (TimeBase_mS - OnTime_mS);

        //
        // Set HeaterOn_H and D2 for OnTime_mS.
        //
        GPIOPinWrite( GPIO_PORTG_BASE, GPIO_PIN_0, 0x01 );
        GPIOPinWrite( GPIO_PORTN_BASE, GPIO_PIN_0, 0x01 );
        //Could seta global variable to control this amount of time
		vTaskDelay( ( OnTime_mS * configTICK_RATE_HZ ) / TimeBase_mS );

        //
        // Turn-off HeaterOn_H and D2 for 750 mS.
        //
        GPIOPinWrite( GPIO_PORTG_BASE, GPIO_PIN_0, 0x00 );
        GPIOPinWrite( GPIO_PORTN_BASE, GPIO_PIN_0, 0x00 );
        //Could seta global variable to control this amount of time
		vTaskDelay( ( OffTime_mS * configTICK_RATE_HZ ) / TimeBase_mS );
	}
}
Beispiel #14
0
void SCCBInit(unsigned long setbase,
			unsigned char setscl,
			unsigned char setsda
			){
//	memset(&SCCBMaster, 0, sizeof(SCCBMaster));
    SCCBMaster.currentBit=0;
    SCCBMaster.GpioBase=setbase;
    SCCBMaster.sclGpio=setscl;
    SCCBMaster.sdaGpio=setsda;
    SCCBMaster.state=SCCB_DONE;

    //MAP_GPIOPinTypeI2C(GPIO_PORTA_BASE,GPIO_PIN_6|GPIO_PIN_7);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);



	GPIODirModeSet(SCCBMaster.GpioBase,SCCBMaster.sclGpio, GPIO_DIR_MODE_OUT);
    GPIOPadConfigSet(SCCBMaster.GpioBase,SCCBMaster.sclGpio,GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_OD);

    //
    // Set the SCL pin high.
    //
    GPIOPinWrite(SCCBMaster.GpioBase, SCCBMaster.sclGpio,255);

    //
    // Configure the SDA pin.
    //
    GPIODirModeSet(SCCBMaster.GpioBase,SCCBMaster.sdaGpio,GPIO_DIR_MODE_OUT);
    GPIOPadConfigSet(SCCBMaster.GpioBase ,SCCBMaster.sdaGpio,GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_OD);

    //
    // Set the SDA pin high.
    //
    GPIOPinWrite(SCCBMaster.GpioBase, SCCBMaster.sdaGpio,255);
    //
    // Configure the timer to generate an interrupt at a rate of 40KHz.  This
    // will result in a I2C rate of 100 KHz.
    // TODO: change this to whichever timer you are using.
    // TODO: change this to whichever I2C rate you require.
    //
    TimerConfigure(TIMER0_BASE, TIMER_CFG_32_BIT_PER);
    TimerLoadSet(TIMER0_BASE, TIMER_A, SysCtlClockGet() / 400000);
//    TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
//    TimerEnable(TIMER0_BASE, TIMER_A);
//    IntEnable(INT_TIMER0A);
}
Beispiel #15
0
// Functions
void ledSetup() {
	uint32_t ui32Strength;
	uint32_t ui32PinType;
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);

	GPIOPadConfigGet(GPIO_PORTN_BASE, GPIO_PIN_1, &ui32Strength, &ui32PinType);
	GPIOPadConfigSet(GPIO_PORTN_BASE, GPIO_PIN_1, ui32Strength, GPIO_PIN_TYPE_STD);
	GPIOPadConfigSet(GPIO_PORTN_BASE, GPIO_PIN_0, ui32Strength, GPIO_PIN_TYPE_STD);
	GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_0, ui32Strength, GPIO_PIN_TYPE_STD);
	GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_4, ui32Strength, GPIO_PIN_TYPE_STD);

	GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_1);
	GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_0);
	GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_0);
	GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_4);
}
Beispiel #16
0
/*
    Set up I2C pins and clock slow/fast
    rate400 true = 400KHz, false 100KHz
*/
void MasterI2C0Init(int rate400)
{
    //I2CMasterEnable(I2C0_MASTER_BASE);  // causes fault
    //
    // Enable the I2C and GPIO port B blocks as they are needed by this driver.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);

	//Setup Mux
	GPIOPinConfigure(GPIO_PB2_I2C0SCL);    
	GPIOPinConfigure(GPIO_PB3_I2C0SDA);

	GPIOPinTypeI2C(GPIO_PORTB_BASE, GPIO_PIN_2 | GPIO_PIN_3); //Set up direction
	
	//Reconfigure for correct operation
	GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_2, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
	GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_3, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_OD);

	//
    // Configure the I2C SCL and SDA pins for I2C operation.
    //
	//GPIOPinTypeI2CSCL(GPIO_PORTB_BASE, GPIO_PIN_2);
	//GPIOPinTypeI2C(GPIO_PORTB_BASE, GPIO_PIN_3);	

	
    //
    // Initialize the I2C master.
    //
    I2CMasterInitExpClk(I2C0_MASTER_BASE, SysCtlClockGet(), true);
	SysCtlDelay(10000);  // delay mandatory here - otherwise portion of SlaveAddrSet() lost!  
    // Register interrupt handler
    // or we could just edit the startup.c file
    //I2CIntRegister(I2C0_MASTER_BASE,I2C0IntHandler);
    //
    // Enable the I2C interrupt.
    //
    IntEnable(INT_I2C0);   // already done via I2CIntRegister
    
    I2CMasterIntEnableEx(I2C0_MASTER_BASE,I2C_MASTER_INT_DATA | I2C_MASTER_INT_TIMEOUT);
	
    //
    // Enable the I2C master interrupt.
    //
    I2CMasterIntEnable(I2C0_MASTER_BASE);
}
Beispiel #17
0
int rt_hw_luminaryif_init(void)
{
	rt_err_t result;
	unsigned long ulUser0, ulUser1;

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

	/* 	
	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);

	FlashUserSet(0x12345678, 0x12345678);
	/* Configure the hardware MAC address */
	FlashUserGet(&ulUser0, &ulUser1);
	if((ulUser0 == 0xffffffff) || (ulUser1 == 0xffffffff))
	{
		rt_kprintf("Fatal error in geting MAC address\n");
	}

	/* init rt-thread device interface */
	luminaryif_dev_entry.parent.parent.init		= luminaryif_init;
	luminaryif_dev_entry.parent.parent.open	= luminaryif_open;
	luminaryif_dev_entry.parent.parent.close	= luminaryif_close;
	luminaryif_dev_entry.parent.parent.read	= luminaryif_read;
	luminaryif_dev_entry.parent.parent.write	= luminaryif_write;
	luminaryif_dev_entry.parent.parent.control	= luminaryif_control;
	luminaryif_dev_entry.parent.eth_rx		= luminaryif_rx;
	luminaryif_dev_entry.parent.eth_tx			= luminaryif_tx;
	
	/* 
	Convert the 24/24 split MAC address from NV ram into a 32/16 split MAC
	address needed to program the hardware registers, then program the MAC
	address into the Ethernet Controller registers. 
	*/
	luminaryif_dev_entry.dev_addr[0] = ((ulUser0 >>  0) & 0xff);
	luminaryif_dev_entry.dev_addr[1] = ((ulUser0 >>  8) & 0xff);
	luminaryif_dev_entry.dev_addr[2] = ((ulUser0 >> 16) & 0xff);
	luminaryif_dev_entry.dev_addr[3] = ((ulUser1 >>  0) & 0xff);
	luminaryif_dev_entry.dev_addr[4] = ((ulUser1 >>  8) & 0xff);
	luminaryif_dev_entry.dev_addr[5] = ((ulUser1 >> 16) & 0xff);

	/* Program the hardware with it's MAC address (for filtering). */
	EthernetMACAddrSet(ETH_BASE, luminaryif_dev_entry.dev_addr);	
	
	rt_sem_init(&tx_sem, "emac", 1, RT_IPC_FLAG_FIFO);

	result = eth_device_init(&(luminaryif_dev->parent), "E0");
	
	return result;
}
Beispiel #18
0
/* Initialize the StatusData task values */
void initializeKeyPadTask() {

      SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);  
      SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); 

         
         
	 GPIOPadConfigSet(GPIO_PORTE_BASE, GPIO_PIN_0, GPIO_STRENGTH_2MA,
     GPIO_PIN_TYPE_STD_WPU);
	 GPIODirModeSet(GPIO_PORTE_BASE, GPIO_PIN_0, GPIO_DIR_MODE_IN);
	 
	 GPIOPadConfigSet(GPIO_PORTD_BASE, GPIO_PIN_4, GPIO_STRENGTH_2MA,
     GPIO_PIN_TYPE_STD);
	 GPIODirModeSet(GPIO_PORTD_BASE, GPIO_PIN_4, GPIO_DIR_MODE_IN);
	 
	 GPIOPadConfigSet(GPIO_PORTD_BASE, GPIO_PIN_5, GPIO_STRENGTH_2MA,
     GPIO_PIN_TYPE_STD);
	 GPIODirModeSet(GPIO_PORTD_BASE, GPIO_PIN_5, GPIO_DIR_MODE_IN);
	 
	 GPIOPadConfigSet(GPIO_PORTD_BASE, GPIO_PIN_6, GPIO_STRENGTH_2MA,
     GPIO_PIN_TYPE_STD);
	 GPIODirModeSet(GPIO_PORTD_BASE, GPIO_PIN_6, GPIO_DIR_MODE_IN);
	 
	 GPIOPadConfigSet(GPIO_PORTD_BASE, GPIO_PIN_7, GPIO_STRENGTH_2MA,
     GPIO_PIN_TYPE_STD);
	 GPIODirModeSet(GPIO_PORTD_BASE, GPIO_PIN_7, GPIO_DIR_MODE_IN);

	 //for ack switch
	 /* GPIOPadConfigSet(GPIO_PORTE_BASE, GPIO_PIN_3, GPIO_STRENGTH_2MA,
     GPIO_PIN_TYPE_STD_WPU);
	 GPIODirModeSet(GPIO_PORTE_BASE, GPIO_PIN_3, GPIO_DIR_MODE_IN);*/

	 

  // Load data
  data.mode = &(global.mode);
  data.measurementSelection = &(global.measurementSelection);  
  data.scroll = &(global.scroll);
  data.alarmAcknowledge = &(global.alarmAcknowledge);
  data.select = &(global.select);

  // Load TCB
  keyPadTask.runTaskFunction = &keyPadRunFunction;
  keyPadTask.taskDataPtr = &data;
}
Beispiel #19
0
        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 );
                SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |        SYSCTL_XTAL_8MHZ);

                /*         Enable Port F for Ethernet LEDs
                LED0        Bit 3   Output
                LED1        Bit 2   Output */
                // Enable the peripherals used by this example.
                SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);        //UART1
                SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);        //UART1 pins
                SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);        //Select button


                /* Enable peripherals */
                SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
                GPIODirModeSet( GPIO_PORTF_BASE, (LED | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3), GPIO_DIR_MODE_HW );
                GPIOPadConfigSet( GPIO_PORTF_BASE, (LED | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 ), GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD );
                // Enable the GPIO pin to read the select button.
                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);

                // Set GPIO D2 and D3 as UART pins.
                GPIOPinTypeUART(GPIO_PORTD_BASE, GPIO_PIN_2 | GPIO_PIN_3);
                //GPIOPinTypeUART(GPIO_PORTD_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);


                // Configure the UART for 57,600, 8-N-1 operation.
                UARTConfigSetExpClk(UART1_BASE, 8000000, 57600,
                (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
                UART_CONFIG_PAR_NONE));
                //Enable the UART interrupt.
                //UARTIntEnable(UART1_BASE, UART_INT_RX | UART_INT_RT);
                UARTEnable(UART1_BASE);
                /* Configure push buttons as inputs */
                GPIOPadConfigSet(GPIO_PORTE_BASE, BUTTON, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
                GPIODirModeSet  (GPIO_PORTE_BASE, BUTTON, GPIO_DIR_MODE_IN);
        }
Beispiel #20
0
void init(){
	// Init OLED
  RIT128x96x4Init(1000000);
	
	// Set the clock to 50 MHz
	SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ);
	
	// Select
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);	
	GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_1);
	GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_1, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
	
	// Navigation Switches
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
	GPIOPinTypeGPIOInput(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);
	GPIOPadConfigSet(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
	
	// CAN Connection
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_CAN0);
	GPIOPinTypeCAN(GPIO_PORTD_BASE, GPIO_PIN_0 | GPIO_PIN_1);
	CANInit(CAN0_BASE);
	CANBitRateSet(CAN0_BASE, 8000000, 250000);
	CANIntEnable(CAN0_BASE, CAN_INT_MASTER);
	IntEnable(INT_CAN0);
	CANEnable(CAN0_BASE);
	
	// CAN Objects
	transmit.ulMsgID= 0x200;
	transmit.ulMsgIDMask= 0;
	transmit.ulMsgLen= 2*sizeof(unsigned long);
	
	// IR Receiver
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);	
	GPIOPinTypeTimer(GPIO_PORTD_BASE, GPIO_PIN_4);
	
	// Timer
	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);	
	TimerConfigure(TIMER0_BASE, TIMER_CFG_A_CAP_TIME);
	TimerControlEvent(TIMER0_BASE, TIMER_A, TIMER_EVENT_NEG_EDGE);
	TimerLoadSet(TIMER0_BASE, TIMER_A, TIME_WIDTH);
	TimerIntEnable(TIMER0_BASE, TIMER_CAPA_EVENT | TIMER_TIMA_TIMEOUT);
	TimerEnable(TIMER0_BASE, TIMER_A);
	IntEnable(INT_TIMER0A);
}
void INT_SRDY_Setup(){
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
	//GPIODirModeSet(SYSCTL_PERIPH_GPIOA, GPIO_PIN_7, GPIO_DIR_MODE_IN);
	GPIOPinTypeGPIOInput(GPIO_PORTA_BASE,GPIO_PIN_7);
	GPIOPadConfigSet(GPIO_PORTA_BASE, GPIO_PIN_7, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
	GPIOIntTypeSet(GPIO_PORTA_BASE, GPIO_PIN_7, GPIO_RISING_EDGE);
	GPIOIntRegister(GPIO_PORTA_BASE, POLL);

}
Beispiel #22
0
int main(void) {
	volatile unsigned long ulLoop;

	SysCtlClockSet(
			SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN
					| SYSCTL_XTAL_8MHZ);

	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);

	for (ulLoop = 0; ulLoop < 2000; ulLoop++) {
	}

	//
	// Enable the GPIO pin for the LED (PF0).  Set the direction as output, and
	// enable the GPIO pin for digital function.
	//

	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);

	// Start the OLED display and write a message on it

	RIT128x96x4Init(ulSSI_FREQUENCY);
	RIT128x96x4StringDraw("Hello Out there :)", 0, 0, mainFULL_SCALE);

	//
	// Loop forever.
	//
	while (1) {
		//
		// Turn on the LED.
		//
		GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0, GPIO_PIN_0);
		// GPIO_PORTF_DATA_R |= 0x01;

		//
		// Delay for a bit.
		//
		for (ulLoop = 0; ulLoop < 200000; ulLoop++) {
		}

		//
		// Turn off the LED.
		//
		GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0, 0);

		//
		// Delay for a bit.
		//
		for (ulLoop = 0; ulLoop < 200000; ulLoop++) {
		}
	}

	return 0;
}
Beispiel #23
0
//*************************************************//
//initSSI 
//Prototype: void initSSI(void)
//Description: init SPI module for communicate with vs1011e.
//Returns: None.
//*************************************************//
void initSSI(void)
{
	SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
	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_8MA, GPIO_PIN_TYPE_STD_WPU);
	SSIConfigSetExpClk(SSI0_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 2000000, 8);
	SSIEnable(SSI0_BASE);
}
Beispiel #24
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);
}
Beispiel #25
0
void initHW(void)
{
	volatile unsigned long ulLoop;
	volatile int event;

	motor_init();//! Hardware set up for motor control over pwm start up

	//SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ);
	SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ);//set to use osc its better for pwm


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

	// Inputs :
	// PF1 : Select button
	// PE0 : Up button
	// PE1 : Down button
	// PE2 : Left button
	// PE3 : Right 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, 0);
	//!:H-birdges outputs off set too off at start
	GPIODirModeSet(GPIO_PORTF_BASE, GPIO_PIN_2 |GPIO_PIN_3, GPIO_DIR_MODE_OUT);
	GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_2 |GPIO_PIN_3, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
	GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2 |GPIO_PIN_3, 0);//! 0 is off set to GPIO_PIN_2 |GPIO_PIN_3 to make on


  // a short delay to ensure stable IO before running the rest of the program
  for (ulLoop = 0; ulLoop < 200; ulLoop++)
    {
    }
}
Beispiel #26
0
void pin_setup(void)
{
	SysCtlClockSet(SYSCTL_SYSDIV_2_5| SYSCTL_USE_PLL | SYSCTL_OSC_INT | SYSCTL_XTAL_16MHZ);

	    // Pin F4 setup
	    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);        // Enable port F
	    GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_4);  // Init PF4 as input
	    GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_4, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);  // Enable weak pullup resistor for PF4

}
Beispiel #27
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());
	}
}
/**
 * /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 #29
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);

  // a short delay to ensure stable IO before running the rest of the program
  for (ulLoop = 0; ulLoop < 200; ulLoop++)
    {
    }
}
Beispiel #30
0
/*
 *  ======== EKS_LM4F232_initSDSPI ========
 */
Void EKS_LM4F232_initSDSPI(Void)
{
    /* Enable the peripherals used by the SD Card */
    SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI2);

    /* Configure pad settings */
    GPIOPadConfigSet(GPIO_PORTH_BASE,
            GPIO_PIN_4 | GPIO_PIN_7,
            GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD);

    GPIOPadConfigSet(GPIO_PORTH_BASE,
            GPIO_PIN_6,
            GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD_WPU);

    GPIOPadConfigSet(GPIO_PORTH_BASE,
            GPIO_PIN_5,
            GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD);

    SDSPI_init();
}