コード例 #1
0
ファイル: Wire.cpp プロジェクト: fughilli/NATCAR2015
//Initialize as a master
void TwoWire::begin(void)
{

  if(i2cModule == NOT_ACTIVE) {
      i2cModule = BOOST_PACK_WIRE;
  }

  SysCtlPeripheralEnable(g_uli2cPeriph[i2cModule]);

  //Configure GPIO pins for I2C operation
  GPIOPinConfigure(g_uli2cConfig[i2cModule][0]);
  GPIOPinConfigure(g_uli2cConfig[i2cModule][1]);
  GPIOPinTypeI2C(g_uli2cBase[i2cModule], g_uli2cSDAPins[i2cModule]);
  GPIOPinTypeI2CSCL(g_uli2cBase[i2cModule], g_uli2cSCLPins[i2cModule]);
  I2CMasterInitExpClk(MASTER_BASE, F_CPU, false);//max bus speed=400kHz for gyroscope

  //force a stop condition
  if(!GPIOPinRead(g_uli2cBase[i2cModule], g_uli2cSCLPins[i2cModule]))
      forceStop();

  //Handle any startup issues by pulsing SCL
  if(I2CMasterBusBusy(MASTER_BASE) || I2CMasterErr(MASTER_BASE)
    || !GPIOPinRead(g_uli2cBase[i2cModule], g_uli2cSCLPins[i2cModule])){
      uint8_t doI = 0;
        GPIOPinTypeGPIOOutput(g_uli2cBase[i2cModule], g_uli2cSCLPins[i2cModule]);
        unsigned long mask = 0;
        do{
            for(unsigned long i = 0; i < 10 ; i++) {
                SysCtlDelay(F_CPU/100000/3);//100Hz=desired frequency, delay iteration=3 cycles
                mask = (i%2) ? g_uli2cSCLPins[i2cModule] : 0;
                GPIOPinWrite(g_uli2cBase[i2cModule], g_uli2cSCLPins[i2cModule], mask);
            }
            doI++;
        }while(I2CMasterBusBusy(MASTER_BASE) && doI < 100);

        GPIOPinTypeI2CSCL(g_uli2cBase[i2cModule], g_uli2cSCLPins[i2cModule]);
        if(!GPIOPinRead(g_uli2cBase[i2cModule], g_uli2cSCLPins[i2cModule]))
            forceStop();

  }

}
コード例 #2
0
ファイル: led.c プロジェクト: jancpp/Classwork-Resume
/*
 *  The initialization and execution functions for this task
 */
void LEDInit() {
    // Enable GPIO Port G and configure it to drive the Status LED
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
    // The Status LED is attached to G<2> (Port G pin 2) it must be set as output
    GPIOPinTypeGPIOOutput(GPIO_PORTG_BASE, GPIO_PIN_2);
    /*
     * Start G<2> signal HIGH so the LED is lit at the start
     * The GPIOPinWrite function requires the Port and pins as the first arguments
     * 		the third argument has to be a bit-packed byte that represents the
     * 		desired state of the given pins.
     * 		The least-significant-bit of this byte (bit 0) represents pin 0 on the specified port,
     * 		the next LSB (bit 1) represents pin 1 and so on...
     * 	To write pin G<2> HIGH we have to pass the value 0x04 (or the constant representing the pin),
     * 	For example, if we wanted pin G<1> HIGH =>
     * 			GPIOPinWrite(GPIO_PORTG_BASE, GPIO_PIN_1, GPIO_PIN_1)
     * 		and if we wanted pin G<7> LOW =>
     * 			GPIOPinWrite(GPIO_PORTG_BASE, GPIO_PIN_7, 0x00)
     * 	The function can be used to write multiple pins as well,
     * 		if we wanted pins G<1> and G<2> HIGH =>
     * 			GPIOPinWrite(GPIO_PORTG_BASE, (GPIO_PIN_1 | GPIO_PIN_2), (GPIO_PIN_1 | GPIO_PIN_2))
     * 			or G<1> HIGH and G<2> LOW =>
     * 			GPIOPinWrite(GPIO_PORTG_BASE, (GPIO_PIN_1 | GPIO_PIN_2), GPIO_PIN_1)
     * 		the pin arguments are combined with a bit-wise OR operation
     * 		and the desired signal value given is a bit-wise OR'ing of the individual pin values.
     */
    // This sets G<2> to LOW
    GPIOPinWrite(GPIO_PORTG_BASE, GPIO_PIN_2, 0x00);
    /*
     * NOTICE the way numerical values are written here,
     * 		for instance 0x00 = 0, the prefix 0x tells the compiler that the
     * 		number is written in hexadecimal notation.
     * 			So, 0x02 = 2, 0x0F = 15, and 0x10 = 16
     *
     * 		Likewise binary values can be given with the prefix 0b
     * 			So, 0b0 = 0, 0b10 = 2, and 0b111 = 7
     *
     * 		These notations can make the code easier to understand in some cases
     */
    printf("%ul", sysTickCount);
    // Initialize the first execution time for the task by adding to the current SysTickCount
    timeToExec = sysTickCount + delay;
}
コード例 #3
0
//  The LED task definition
void LEDTask(void *pvParameters) {
	// FreeRTOS uses function definitions to define tasks
	// The first part of each task is the initializations steps for that task

	// Enable Port G which is connected to the LED
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
    // The Status LED is attached to G<2> (Port G pin 2) it must be set as output
    GPIOPinTypeGPIOOutput(GPIO_PORTG_BASE, GPIO_PIN_2);
    /*
     * Start G<2> signal HIGH so the LED is lit at the start
     * The GPIOPinWrite function requires the Port and pins as the first arguments
     * 		the third argument has to be a bit-packed byte that represents the
     * 		desired state of the given pins.
     * 		The least-significant-bit of this byte (bit 0) represents pin 0 on the specified port,
     * 		the next LSB (bit 1) represents pin 1 and so on...
     * 	To write pin G<2> HIGH we have to pass the value 0x04,
     * 		if we wanted pin G<1> HIGH => GPIOPinWrite(GPIO_PORTG_BASE, GPIO_PIN_1, 0x02)
     * 		and if we wanted pin G<7> HIGH => GPIOPinWrite(GPIO_PORTG_BASE, GPIO_PIN_7, 0x80)
     * 	The function can be used to write multiple pins as well,
     * 		if we wanted pins G<1> and G<2> HIGH =>
     * 			write GPIOPinWrite(GPIO_PORTG_BASE, (GPIO_PIN_1 | GPIO_PIN_2), 0x06)
     * 		the pin arguments are combined with a bit-wise OR operation
     * 		and the desired signal value given is a bit-wise OR'ing of the individual pin values.
     */
    // This sets G<2> to LOW
    GPIOPinWrite(GPIO_PORTG_BASE, GPIO_PIN_2, 0x00);

    // FreeRTOS task definitions also require an infinite loop to house execution steps
    while(true) {
        /*
         *  Toggle the LED.
         *  First pin G<2> is read and that value is XOR'd with the constant value GPIO_PIN_2
         *  	so that the bit representing G<2> is toggled
         *  	to either 0x00 or 0x04 depending on its current state
         *  	then the new value is written back to G<2>
         */
        GPIOPinWrite(GPIO_PORTG_BASE, GPIO_PIN_2, GPIOPinRead(GPIO_PORTG_BASE, GPIO_PIN_2) ^ GPIO_PIN_2);

        //	Advance next execution time for the LED task
        vTaskDelay(ONE_MS * 250.0);
	}
}
コード例 #4
0
int main() {

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

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

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

  
  while(1) { 
    taco_display(); 
  }

}
コード例 #5
0
void CommutationControllerClass::configurePeripherals(uint32_t channel)
{
	channel ? initAsTimer1() : initAsTimer0();

	// Enable the timer peripheral
	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER);
	// Ensure the timer is disabled
	TimerDisable(TIMER_BASE, TIMER_A);
	// Configure the timer as a periodic up counter
	TimerConfigure(TIMER_BASE, TIMER_CFG_PERIODIC_UP);
	// Ensure the timer interrupt is disabled
	TimerIntDisable(TIMER_BASE, TIMER_TIMA_TIMEOUT);
	// Clear the interrupt now it is disabled
	TimerIntClear(TIMER_BASE, TIMER_TIMA_TIMEOUT);
	// Register one of the two static interrupt handlers to the peripheral
	TimerIntRegister(TIMER_BASE, TIMER_A, channel ? ISR1Static : ISR0Static);
	// Set the interrupt priority
	IntPrioritySet(INT_TIMERnA_TM4C123, 0); // @TODO - What should this actually be?

}
コード例 #6
0
void hwInitWatchdog(long intervalMilliseconds) {
	if (SysCtlPeripheralPresent(SYSCTL_PERIPH_WDOG)){
		SysCtlPeripheralEnable(SYSCTL_PERIPH_WDOG);

		WatchdogUnlock(WATCHDOG_BASE);			// unlock WD register

		WatchdogResetEnable(WATCHDOG_BASE);		// enable reset capability on second timeout
		/* watchdog resets the system on the second timeout!
		 * -> so we have to divide the time by 2
		 * -> on the first time-out only an interrupt is generated
		 */
		glWDLoad = (SysCtlClockGet()/1000) * (intervalMilliseconds/2);
		WatchdogReloadSet(WATCHDOG_BASE, glWDLoad);
		WatchdogStallEnable(WATCHDOG_BASE); 	// stops the watchdog during debug break
		WatchdogIntUnregister(WATCHDOG_BASE); 	// mask interrupt -> interrupts are not seen and handled by processor
		WatchdogEnable(WATCHDOG_BASE);

		WatchdogLock(WATCHDOG_BASE);			// lock WD register
	}
}
コード例 #7
0
ファイル: main.c プロジェクト: dirk-brandewie/freertos
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
ファイル: 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();
}
コード例 #9
0
ファイル: EKS_LM4F232.c プロジェクト: konnexio2003/SZIMETESZT
/*
 *  ======== 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();
}
コード例 #10
0
ファイル: bsp.c プロジェクト: saiyn/web
void bsp_pwm0_init(void)
{
	/*Enable device*/
  SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);
	/*Set clock divider*/
  PWMClockSet(PWM0_BASE,PWM_SYSCLK_DIV_64);
	/*Enable PWM pin*/
  GPIOPinConfigure(LCD_PWM_CHANNEL);
  GPIOPinTypePWM(LCD_PWM_PORT, LCD_PWM_PIN);
	/*Configure PWM generator*/
  PWMGenConfigure(PWM0_BASE, PWM_GEN_0,(PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC));
	/*Set PWM timer period*/
  PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0,gSysClock/10000);
	/*Set width for PWM0*/
  PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0, 50*PWMGenPeriodGet(PWM0_BASE,PWM_GEN_0)/100);
	/*Enable output*/
  PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT, 0);
  /*Enable Generator*/
  PWMGenEnable(PWM0_BASE, PWM_GEN_0);
}
コード例 #11
0
ファイル: main.c プロジェクト: Ribster/iwasz-sandbox
void uartStdioConfig (uint32_t ui32PortNum, uint32_t ui32Baud, uint32_t ui32SrcClock)
{
        // Check the arguments.
        ASSERT((ui32PortNum == 0) || (ui32PortNum == 1) || (ui32PortNum == 2));

        // Check to make sure the UART peripheral is present.
        if (!SysCtlPeripheralPresent(SYSCTL_PERIPH_UART0)) {
                return;
        }

        // Enable the UART peripheral for use.
        SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);

        // Configure the UART for 115200, n, 8, 1
        UARTConfigSetExpClk(UART0_BASE, ui32SrcClock, ui32Baud, (UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_ONE |
        UART_CONFIG_WLEN_8));

        // Enable the UART operation.
        UARTEnable(UART0_BASE);
}
コード例 #12
0
ファイル: timebase.c プロジェクト: ellingjp/ee472
void initializeTimebase() {
  // Enable it
  SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
  
  // Configure TimerA as periodic
  TimerConfigure(TIMER0_BASE, TIMER_CFG_A_PERIODIC);
    
  // Determine minor cycle
  TimerLoadSet(TIMER0_BASE, TIMER_A, (SysCtlClockGet() / 1000) * MINOR_CYCLE );
  
  // Enable Interrupt
  TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);

  // Enable the intterupt (again?)
  IntEnable(INT_TIMER0A);
  
  // Enable the timer
  TimerEnable(TIMER0_BASE, TIMER_A);

}
コード例 #13
0
ファイル: main.c プロジェクト: nikitawanjale/Lab03_T03_a
/*****************************************************************************
Main function performs init and manages system.

Called automatically after the system and compiler pre-init sequences.
*****************************************************************************/
int main(void)
{
	//To set the clock frequency to be 40MHz.
	SysCtlClockSet(SYSCTL_SYSDIV_16|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);

	//Enable GPIO peripheral
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
	GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);

	//create a while(1) loop to send a “1” and “0” to the selected GPIO pin, with an
	//equal delay between the two.
	while(1)
	{
		GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1| GPIO_PIN_2| GPIO_PIN_3, ui8PinData);
		SysCtlDelay(2000000);
		GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3,0x00);
		SysCtlDelay(2000000);
		if(ui8PinData==2) {ui8PinData=8;} else {ui8PinData=ui8PinData/2;}
	}
}
コード例 #14
0
void tempSensInit() {
	SysCtlPeripheralEnable(TEMP_SENS_ADC_PERIPH) ;
	SysCtlDelay(3) ;

	ADCSequenceConfigure(
			TEMP_SENS_ADC_BASE,
			TEMP_SENS_SEQ_NUM,
			ADC_TRIGGER_PROCESSOR,	// triggered by mcu
			3 ) ; 					// 3 - The lowest priority

	ADCSequenceStepConfigure(
			TEMP_SENS_ADC_BASE,
			TEMP_SENS_SEQ_NUM,
			TEMP_SENS_STEP_NUM,
			ADC_CTL_TS | ADC_CTL_IE | ADC_CTL_END) ;
	// Temperature sensor | interrupt enable | only one step

	ADCSequenceEnable(TEMP_SENS_ADC_BASE, TEMP_SENS_SEQ_NUM) ;
	ADCIntClear(TEMP_SENS_ADC_BASE, TEMP_SENS_SEQ_NUM) ;
}
コード例 #15
0
ファイル: blink.c プロジェクト: rixth/tiva-dev
//*****************************************************************************
//
// Main 'C' Language entry point.  Toggle an LED using TivaWare.
// See http://www.ti.com/tm4c123g-launchpad/project0 for more information and
// tutorial videos.
//
//*****************************************************************************
int
main(void)
{
    //
    // Setup the system clock to run at 50 Mhz from PLL with crystal reference
    //
    SysCtlClockSet(SYSCTL_SYSDIV_4|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|
                    SYSCTL_OSC_MAIN);

    //
    // Enable and configure the GPIO port for the LED operation.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, RED_LED|BLUE_LED|GREEN_LED);

    //
    // Loop Forever
    //
    while(1)
    {
        //
        // Turn on the LED
        //
        GPIOPinWrite(GPIO_PORTF_BASE, RED_LED|BLUE_LED|GREEN_LED, RED_LED);

        //
        // Delay for a bit
        //
        SysCtlDelay(2000000);

        //
        // Turn on the LED
        //
        GPIOPinWrite(GPIO_PORTF_BASE, RED_LED|BLUE_LED|GREEN_LED, BLUE_LED);

        //
        // Delay for a bit
        //
        SysCtlDelay(2000000);
    }
}
コード例 #16
0
void Confige_1115_B(unsigned int channel)
{
	SysCtlPeripheralEnable(IIC_PERIPH);
	SDA_B_Out;
	SCL_B_Out;
	SCL_B_H;
	SDA_B_H;

	unsigned char i=0;
	unsigned char Initdata[4]={0};

	switch (channel) {
		case 0:
			Initdata[2] = 0xc2;
			break;
		case 1:
			Initdata[2] = 0xd2;
			break;
		case 2:
			Initdata[2] = 0xe2;
			break;
		case 3:
			Initdata[2] = 0xf2;
			break;
		default:
			break;
	}

	Initdata[0] =0x90; // 地址 + 写命令
	Initdata[1] =0x01; // 指向配置寄存器
	Initdata[3] =0xe3;
	/* Initdata[3] =0x03; // 配置字低字节 */

	startB();
	for(i=0;i<4;i++)
	{
		Send1byteB(Initdata[i]);
	}

	stopB();
}
コード例 #17
0
ファイル: io.c プロジェクト: cmonr/PAL
tPin IO_Init(tPin pin)
{
    // Check if object already exists
    if (pins[pin].isInit == true)
        return ERR;

    // Figure out internal variables
    pins[pin].port = _ports[pin >> 3];
    pins[pin].offset = 1 << (pin & 0x07);

    // Default Pin Values
    pins[pin].state = HiZ;

    // Enable Port
    SysCtlPeripheralEnable(pins[pin].port.periph);

    // Pin initialized
    pins[pin].isInit = true;

    return pin;
}
コード例 #18
0
void TimerBegin_ms(void)
{
	uint32_t ui32Period = 40000;				// 1ms delay
	//uint32_t ui32Period = 40000000;			// 1s
	//uint32_t ui32Period = 10000000;			// 0.25 s
	//uint32_t ui32Period = 40;				// 1us delay
	/*
	 * PLL = 400MHz. It is divied by 2 before prescaling, 400/2 = 200 MHz. Divide by 5 => 200/5 = 40MHz; Divide by 2.5 => 200/2.5 = 80MHz.
	 * Refer sysctl.h (line 221 onwards) to know various supported division factor.
	 */

	SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN); //SYSDIV_5 is 40MHz; SYSDIV_2_5 is 80MHz
	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);	// enable Timer 0
	TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);		// timer0 configure mode as periodic - down counting
	TimerLoadSet(TIMER0_BASE, TIMER_A, ui32Period -1);		// Load value from which counting will start
	IntEnable(INT_TIMER0A);									// Enable Tiemr0A interrupt
	TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);		// Enable timer interrupt source - Timer A timeout interrupt
	IntMasterEnable();										// Enable Interrupt
	TimerEnable(TIMER0_BASE, TIMER_A);						// Enable Timer

}
コード例 #19
0
void Communication_setup(){
	//MRDY_pin_setup   PA_6
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
	GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE,GPIO_PIN_6);
	GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_6,GPIO_PIN_6);

	//SRDY_pin_setup   PA_7
	//Attach POLL to SRDY Interrupt
	INT_SRDY_Setup();
	SPI_init();



/*
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
	GPIOPinTypeGPIOInput(GPIO_PORTA_BASE,GPIO_PIN_7);
	GPIOPadConfigSet(GPIO_PORTA_BASE,GPIO_PIN_7,GPIO_STRENGTH_4MA,GPIO_PIN_TYPE_STD_WPU);
*/


}
コード例 #20
0
ファイル: bsp.c プロジェクト: saiyn/web
void bsp_pwm_for_sense_init(void)
{
  /*Enable device*/
  SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);
  /*Set clock divider*/
  PWMClockSet(PWM0_BASE,PWM_SYSCLK_DIV_1);  
  /*Enable PWM pin*/
  GPIOPinConfigure(GPIO_PK5_M0PWM7);
  GPIOPinTypePWM(SENSE_THRES_PORT, SENSE_THRES_PIN);
  /*Configure PWM generator*/
  PWMGenConfigure(PWM0_BASE, PWM_GEN_3,(PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC));
  /*Set PWM timer period*/
  PWMGenPeriodSet(PWM0_BASE, PWM_GEN_3,gSysClock/1000000);   
  /*Set width for PWM0*/
  PWMPulseWidthSet(PWM0_BASE, PWM_OUT_7, 1*PWMGenPeriodGet(PWM0_BASE,PWM_GEN_3)/5);
  /*ensable output*/
  PWMOutputState(PWM0_BASE, PWM_OUT_7_BIT, 1);
  /*Enable Generator*/
  PWMGenEnable(PWM0_BASE, PWM_GEN_3);
	
}
コード例 #21
0
int main(void)
{
	//Do setup
	setup();
	ledPinConfig();
	switchPinConfig();
	//Enable timer
	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
	TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);

	uint32_t ui32Period;

	ui32Period = (SysCtlClockGet() / 100) / 2;
	TimerLoadSet(TIMER0_BASE, TIMER_A, ui32Period -1);

	IntEnable(INT_TIMER0A);
	TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
	IntMasterEnable();

	TimerEnable(TIMER0_BASE, TIMER_A);
	GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, led);

	while(1)
	{
		//vode for automode
		if(mode)
		{
			SysCtlDelay(autoDelay*200000);
			if(led == 2) led = 10;
			else if(led == 10) led = 8;
			else if(led == 8) led = 12;
			else if(led == 12) led = 4;
			else if (led == 4) led = 6;
			else if(led == 6) led = 2;
			GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 , led);
		}
	}


}
コード例 #22
0
ファイル: pwm.c プロジェクト: enso622/Rasware2013
// Module initialization function called internally
// Requires a pwm signal to use
static void InitializePWMModule(tPWMModule *mod, tPWM *pwm) {
    // Use either timer A (shift 0) or timer B (shift 8)
    int tshift = (mod->TIMER == TIMER_A) ? 0 : 8;

    // We take the period from the pwm signal
    mod->period = pwm->period;

    // Then we setup the initial cycle
    pwm->up.target = 0;
    pwm->up.timing = pwm->period / 2;
    pwm->down.target = pwm->period / 2;
    pwm->down.timing = pwm->period / 2;

    // Connect the linked list
    pwm->up.prev = pwm->up.next = &pwm->down;
    pwm->down.next = pwm->down.prev = &pwm->up;

    // And we set the start of the cycle
    mod->event = &pwm->up;
    
    
    // Enable the timer
    SysCtlPeripheralEnable(mod->PERIPH);
    
    // We only need half a timer, so keep the configuration of the second half
    // Configure the timer for one shot usage
    TimerConfigure(mod->BASE, TIMER_CFG_SPLIT_PAIR |
                              *mod->CFG_R |
                              (TIMER_TIMA_TIMEOUT << tshift));
    
    // Setup the timer
    TimerLoadSet(mod->BASE, mod->TIMER, pwm->up.timing);
    // This is a bit hacky and assumes the order of pwm modules
    // By editing the config register both timers are disabled
    TimerEnable(mod->BASE, mod->TIMER | TIMER_A);
    
    // Enable the interrupt
    IntEnable(mod->INT);
    TimerIntEnable(mod->BASE, TIMER_TIMA_TIMEOUT << tshift);
}
コード例 #23
0
ファイル: uartstdio.c プロジェクト: art1/FloatSat-Project-G9
//*****************************************************************************
//
//! Initialize UART console.
//!
//! \param ulPortNum is the number of UART port to use for the serial console
//! (0-2)
//!
//! This function will initialize the specified serial port to be used as a
//! serial console.  The serial parameters will be set to 115200, 8-N-1.
//!
//! This function must be called prior to using any of the other UART console
//! functions: UARTprintf() or UARTgets().  In order for this function to work
//! correctly, SysCtlClockSet() must be called prior to calling this function.
//!
//! This function is contained in <tt>utils/uartstdio.c</tt>, with
//! <tt>utils/uartstdio.h</tt> containing the API definition for use by
//! applications.
//!
//! \return None.
//
//*****************************************************************************
void
UARTStdioInit(unsigned long ulPortNum)
{
    //
    // Check the arguments.
    //
    ASSERT((ulPortNum == 0) || (ulPortNum == 1) ||
           (ulPortNum == 2));

    //
    // Check to make sure the UART peripheral is present.
    //
    if(!SysCtlPeripheralPresent(g_ulUartPeriph[ulPortNum]))
    {
        return;
    }

    //
    // Select the base address of the UART.
    //
    g_ulBase = g_ulUartBase[ulPortNum];

    //
    // Enable the UART peripheral for use.
    //
    SysCtlPeripheralEnable(g_ulUartPeriph[ulPortNum]);

    //
    // Configure the UART for 115200, n, 8, 1
    //
    UARTConfigSetExpClk(g_ulBase, SysCtlClockGet(), 115200,
                        (UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_ONE |
                         UART_CONFIG_WLEN_8));

    //
    // Enable the UART operation.
    //
    UARTEnable(g_ulBase);
}
コード例 #24
0
ファイル: RF22.c プロジェクト: igbt6/MeteoStation
////////////////////////////////TIMER////////////////////////////////
//Configures Timer4A as a 32-bit periodic timer [HW Dependent]
static void RF22_TimerInit()
{
    SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER4);

    TimerConfigure(TIMER4_BASE, TIMER_CFG_32_BIT_PER_UP);
    // Set the Timer4A load value to 1ms.
    TimerLoadSet(TIMER4_BASE, TIMER_A, SysCtlClockGet() / 1000); //1 [ms]

    // Configure the Timer interrupt for timer timeout.
    TimerIntEnable(TIMER4_BASE, TIMER_TIMA_TIMEOUT);

    // Set Low interrupt priority for Timer
    IntPrioritySet(INT_TIMER4A, 3);

    // Enable the Timer interrupt on the processor (NVIC).
    IntEnable(INT_TIMER4A);

    _time_counter = 0;

    // Enable Timer.
    TimerEnable(TIMER4_BASE, TIMER_A);
}
コード例 #25
0
ファイル: main.c プロジェクト: BooRan/Auto_Water_TM4
/*****************************************************
 * 	Function: init_IntTempSensor
 *	Description: Initializes internal temperature
 *			sensor and general timer 1
 *			Uses ADC0 Module and TIMER1
 *	Input: NONE
 *	Output: NONE
 *****************************************************/
void init_IntTempSensor(void)
{
	// Enable clock to ADC0
	SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);

	// Configure hardware over-sampling to take 64 samples per step
	// With 4 steps on 64 samples -> 256 samples
	ADCHardwareOversampleConfigure(ADC0_BASE, 64);

	// Configure sequence to trigger on processor trigger
	ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_PROCESSOR, 0);

	// Configure steps 0-3 to read internal temperature sensor
	// Configure step 3 to end conversion
	ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ADC_CTL_TS);
	ADCSequenceStepConfigure(ADC0_BASE, 0, 1, ADC_CTL_TS);
	ADCSequenceStepConfigure(ADC0_BASE, 0, 2, ADC_CTL_TS);
	ADCSequenceStepConfigure(ADC0_BASE, 0, 3, ADC_CTL_TS|ADC_CTL_IE|ADC_CTL_END);

	// Enable sequence
	ADCSequenceEnable(ADC0_BASE, 0);
}
コード例 #26
0
ファイル: main.c プロジェクト: hocarm/TIVA-CCS-Tutorial
//Chuong trinh chinh
int main(void) {

	//Khai bao bien shift co nhiem vu dich bit
	uint8_t shift = GPIO_PIN_1;
	//Khoi tao clock he thong
	SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN); //De hien ra nhac code ban co the an ctr+space
	//Kich hoat ngoai vi
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);	//Kich hoat port F
	// Cau hinh output xuat LED
	GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1 |GPIO_PIN_2 | GPIO_PIN_3); //O day su dung pin 1 2 3 cho 3 led RGB tren kit
	while(1)
	{
		//Bat LED do
		GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1 |GPIO_PIN_2 | GPIO_PIN_3, shift);
		SysCtlDelay(1000000);							//Delay
		//Dich bit sang trai voi y nghia bat LED xanh
		shift <<= 1;
		//Kiem tra neu LED xanh la sang thi quay tro lai LED do
		if(shift > GPIO_PIN_3)
			shift = GPIO_PIN_1;
	}
}
コード例 #27
0
ファイル: board.c プロジェクト: 8bitgeek/caribou-rtos
void early_init()
{
#if defined(ACCUTRON_ACCTRX) // Building for Accutron CommTrax PCB?
	#if defined(PART_LM3S8C62)
		SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_6MHZ);
	#elif defined(PART_LM3S8962)
		SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_6MHZ);
	#else
		#error No PART_LM3Sxxxx defined
	#endif
#else
	#if defined(PART_LM3S8C62)
		SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ);
	#elif defined(PART_LM3S8962)
		SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ);
	#else
		#error No PART_LM3Sxxxx defined
	#endif
#endif

#if defined(IRQ_DEBUG)
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
	// Debug 0
	GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_0);
	GPIOPadConfigSet(GPIO_PORTD_BASE, GPIO_PIN_0, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD);
	// Debug 1
	GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_1);
	GPIOPadConfigSet(GPIO_PORTD_BASE, GPIO_PIN_1, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD);
	// Debug 2
	GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_4);
	GPIOPadConfigSet(GPIO_PORTD_BASE, GPIO_PIN_4, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD);
	// Debug 3
	GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_5);
	GPIOPadConfigSet(GPIO_PORTD_BASE, GPIO_PIN_5, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD);
	// Debug 4
	GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_6);
	GPIOPadConfigSet(GPIO_PORTD_BASE, GPIO_PIN_6, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD);
#endif
}
コード例 #28
0
void Timer1_Init(unsigned int frequency)
{
	uint32_t ui32Period; //desired clock period

	// before calling any peripheral specific driverLib function we must enable the clock to that peripheral!!!
	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);

	/*
	 * Timer 1 as a 32-bit timer in periodic mode.
	 * TIMER1_BASE is the start of the timer registers for Timer0 in the peripheral section of the memory map.
	 */
	TimerConfigure(TIMER1_BASE, TIMER_CFG_PERIODIC);

	/*
	 * desired frequency = x Hz
	 * duty cycle = 50% (interrupt at 1/2 of the desired period)
	 */
	ui32Period = (SysCtlClockGet() / frequency) / 2;

	/*
	 * load calculated period into the Timer’s Interval Load register using the TimerLoadSet
	 * you have to subtract one from the timer period since the interrupt fires at the zero count
	 */
	TimerLoadSet(TIMER1_BASE, TIMER_A, ui32Period -1);

	// Enable triggering
	TimerControlTrigger(TIMER1_BASE, TIMER_A, true);


	/*** INTERRUPT ENABLE ***/

	IntEnable(INT_TIMER1A); // enables the specific vector associated with Timer0A
	TimerIntEnable(TIMER1_BASE, TIMER_TIMA_TIMEOUT); //enables a specific event within the timer to generate an interrupt.(timeout of Timer 0A)
//	IntMasterEnable(); //master interrupt enable API for all interrupts.

	/* TIMER ENABLE */
	TimerEnable(TIMER1_BASE, TIMER_A);

}
コード例 #29
0
/*
 *  ======== EK_TM4C123GXL_initDMA ========
 */
void EK_TM4C123GXL_initDMA(void) {
	Error_Block eb;
	Hwi_Params hwiParams;

	if (!DMA_initialized) {

		Error_init(&eb);

		Hwi_Params_init(&hwiParams);
		Hwi_construct(&(hwiStruct), INT_UDMAERR, EK_TM4C123GXL_errorDMAHwi,
				&hwiParams, &eb);
		if (Error_check(&eb)) {
			System_abort("Couldn't create DMA error hwi");
		}

		SysCtlPeripheralEnable(SYSCTL_PERIPH_UDMA);
		uDMAEnable();
		uDMAControlBaseSet(EK_TM4C123GXL_DMAControlTable);

		DMA_initialized = true;
	}
}
コード例 #30
0
ファイル: protocol.c プロジェクト: RoelandK/GRBL_LM4F120H5QR
void protocol_init() 
{
  char_counter = 0; // Reset line input
  iscomment = false;
  report_init_message(); // Welcome message

#ifdef PART_LM4F120H5QR // code for ARM
  SysCtlPeripheralEnable( PINOUT_PERIPH ); ///Enable the GPIO module for PINOUT port
  SysCtlDelay(26); ///give time delay 1 microsecond for GPIO module to start

  GPIOPinTypeGPIOInput( PINOUT_PORT, PINOUT_MASK ); // Set as input pins
  GPIOPadConfigSet( PINOUT_PORT, PINOUT_MASK, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); //Enable weak pull-ups
  GPIOPortIntRegister( PINOUT_PORT, pinout_interrupt ); //register a call-back funcion for interrupt
  GPIOIntTypeSet( PINOUT_PORT, PINOUT_MASK, GPIO_BOTH_EDGES ); // Enable specific pins of the Pin Change Interrupt
  GPIOPinIntEnable( PINOUT_PORT, PINOUT_MASK ); // Enable Pin Change Interrupt
#else // code for AVR
  PINOUT_DDR &= ~(PINOUT_MASK); // Set as input pins
  PINOUT_PORT |= PINOUT_MASK; // Enable internal pull-up resistors. Normal high operation.
  PINOUT_PCMSK |= PINOUT_MASK;   // Enable specific pins of the Pin Change Interrupt
  PCICR |= (1 << PINOUT_INT);   // Enable Pin Change Interrupt
#endif
}