Esempio n. 1
0
int main()
{
	SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);

	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI2);
	GPIOPinConfigure(GPIO_PB4_SSI2CLK);
	GPIOPinConfigure(GPIO_PB7_SSI2TX);
	GPIOPinTypeSSI(GPIO_PORTB_BASE,GPIO_PIN_4|GPIO_PIN_7);
	SSIConfigSetExpClk(SSI2_BASE,SysCtlClockGet(),SSI_FRF_MOTO_MODE_0,SSI_MODE_MASTER,2000000,8);
	SSIEnable(SSI2_BASE);

	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
	GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_2|GPIO_PIN_3);
	GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_2,0);
	GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_3,0);

	GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_6);
	GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_6,0);

	while(1)
	{
		SSIDataPut(SSI2_BASE,0xAA);
		latch();
		SysCtlDelay(SysCtlClockGet()/10);

		SSIDataPut(SSI2_BASE,0x55);
		latch();
		SysCtlDelay(SysCtlClockGet()/10);
	}
}
Esempio n. 2
0
/*
 *  ======== EK_TM4C123GXL_initGPIO ========
 */
void EK_TM4C123GXL_initGPIO(void)
{
    /* Setup the LED GPIO pins used */
    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1); /* EK_TM4C123GXL_LED_RED */
    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2); /* EK_TM4C123GXL_LED_GREEN */
    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_3); /* EK_TM4C123GXL_LED_BLUE */

    /* Setup the button GPIO pins used */
    GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_4);  /* EK_TM4C123GXL_GPIO_SW1 */
    GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_4, GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD_WPU);

    /* PF0 requires unlocking before configuration */
    HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY;
    HWREG(GPIO_PORTF_BASE + GPIO_O_CR) |= GPIO_PIN_0;
    GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_0);  /* EK_TM4C123GXL_GPIO_SW2 */
    GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_0, GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD_WPU);
    HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = GPIO_LOCK_M;

    /* Once GPIO_init is called, GPIO_config cannot be changed */
    GPIO_init();

    GPIO_write(EK_TM4C123GXL_LED_RED, EK_TM4C123GXL_LED_OFF);
    GPIO_write(EK_TM4C123GXL_LED_GREEN, EK_TM4C123GXL_LED_OFF);
    GPIO_write(EK_TM4C123GXL_LED_BLUE, EK_TM4C123GXL_LED_OFF);
}
Esempio n. 3
0
void Board::init() // initialize the board specifics
{
	//
	// Enable lazy stacking for interrupt handlers.  This allows floating-point
	// instructions to be used within interrupt handlers, but at the expense of
	// extra stack usage.
	//
	FPUEnable();
	FPULazyStackingEnable();
	//
	// Set the clocking to run from the PLL at 50MHz
	//
	ROM_SysCtlClockSet(
	SYSCTL_SYSDIV_1 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
	IntMasterEnable(); // Enable interrupts to the processor.
	// Set up the period for the SysTick timer for 1 mS.
	SysTickPeriodSet(SysCtlClockGet() / 1000);
	SysTickIntEnable(); // Enable the SysTick Interrupt.
	SysTickEnable(); // Enable SysTick.
	/*	//
	 // Enable lazy stacking for interrupt handlers.  This allows floating-point
	 // instructions to be used within interrupt handlers, but at the expense of
	 // extra stack usage.
	 FPUEnable();
	 FPULazyStackingEnable();
	 SysCtlClockSet(
	 SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN
	 | SYSCTL_XTAL_16MHZ); // Set the clocking to run directly from the crystal.
	 IntMasterEnable(); // Enable interrupts to the processor.*/

	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); // Enable the GPIO port that is used for the on-board LED.
	GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2); // Enable the GPIO pins for the LED (PF2).
	GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1);
	GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_3);

	/*	SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); // Enable the peripherals used by this example.
	 SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
	 IntMasterEnable(); // Enable processor interrupts.
	 // Set up the period for the SysTick timer for 1 mS.
	 SysTickPeriodSet(SysCtlClockGet() / 1000);
	 SysTickIntEnable(); // Enable the SysTick Interrupt.
	 SysTickEnable(); // Enable SysTick.

	 GPIOPinConfigure(GPIO_PA0_U0RX); // Set GPIO A0 and A1 as UART pins.
	 GPIOPinConfigure(GPIO_PA1_U0TX);
	 GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);

	 UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200,
	 (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); // Configure the UART for 115,200, 8-N-1 operation.
	 IntEnable(INT_UART0);
	 UARTFIFODisable(UART0_BASE);
	 //	UARTFIFOLevelSet(UART0_BASE, UART_FIFO_TX1_8, UART_FIFO_RX1_8);
	 UARTFlowControlSet(UART0_BASE, UART_FLOWCONTROL_NONE);
	 UARTIntDisable(UART0_BASE, UART_INT_RT);
	 UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_TX); // Enable the UART interrupt.*/
	Board::setLedOn(Board::LED_GREEN, false);
	Board::setLedOn(Board::LED_RED, false);
	Board::setLedOn(Board::LED_BLUE, false);
	AdcInit();
}
Esempio n. 4
0
void exec3(void)
{
	//RGBInit(TRUE);
    // Enable the GPIO Port and Timer for each LED
    SysCtlPeripheralEnable(RED_GPIO_PERIPH);
    SysCtlPeripheralEnable(GREEN_GPIO_PERIPH);
    SysCtlPeripheralEnable(BLUE_GPIO_PERIPH);

    // Reconfigure each LED's GPIO pad for timer control
    GPIOPadConfigSet(GREEN_GPIO_BASE, GREEN_GPIO_PIN, GPIO_STRENGTH_8MA_SC, GPIO_PIN_TYPE_STD);
    GPIOPinTypeGPIOOutput(GREEN_GPIO_BASE, GREEN_GPIO_PIN);

    GPIOPadConfigSet(BLUE_GPIO_BASE, BLUE_GPIO_PIN, GPIO_STRENGTH_8MA_SC, GPIO_PIN_TYPE_STD);
    GPIOPinTypeGPIOOutput(BLUE_GPIO_BASE, BLUE_GPIO_PIN);

    GPIOPadConfigSet(RED_GPIO_BASE, RED_GPIO_PIN, GPIO_STRENGTH_8MA_SC, GPIO_PIN_TYPE_STD);
    GPIOPinTypeGPIOOutput(RED_GPIO_BASE, RED_GPIO_PIN);

	while(1)
	{
		GPIOPinWrite(BLUE_GPIO_BASE, BLUE_GPIO_PIN, BLUE_GPIO_PIN);
		DelayTask(100);
		GPIOPinWrite(BLUE_GPIO_BASE, BLUE_GPIO_PIN, 0);
		DelayTask(100);
	}
}
/**************************************************************************************************
 * @fn          MAC_RfFrontendSetup
 *
 * @brief       Setup RF frontend.
 *
 * @param       none
 *
 * @return      none
 **************************************************************************************************
 */
void MAC_RfFrontendSetup(void)
{
  GPIOPinTypeGPIOOutput(GPIO_C_BASE, GPIO_PIN_3);
  GPIOPinTypeGPIOOutput(GPIO_C_BASE, GPIO_PIN_2);

  /* CC2591 HGM pin control configuration.
   *   PD2 -> HGM
   */
  HAL_PA_LNA_RX_HGM();

  /* Raises the CCA threshold to about -70 dBm input level.
   */
  CCACTRL0 = CCA_THR_HGM;

  /* Select power register value table and RSSI adjustment value table */
  #if (defined MAC_RUNTIME_CC2591 && defined MAC_RUNTIME_CC2590)
  /* Select power register value table and RSSI adjustment value table.
   * Note that this file selected CC2591. The file has to be modified
   * if the target board has CC2590 instead.
   */
  MAC_SetRadioRegTable(MAC_CC2591_TX_PWR_TABLE_IDX, MAC_CC2591_HGM_RSSI_ADJ_IDX);

  #elif defined (MAC_RUNTIME_CC2591) || defined (MAC_RUNTIME_CC2590)
  /* Select power register value table and RSSI adjustment value table */
  MAC_SetRadioRegTable(MAC_CC259X_TX_PWR_TABLE_IDX, MAC_CC259X_HGM_RSSI_ADJ_IDX);

  #elif defined (HAL_PA_LNA) || defined (HAL_PA_LNA_CC2590)
  /* No need to do anything here because by default macRadioDefsRefTableId = 0 hence,
   * automatically setup for HGM. However if you want LGM modify this file and call
   * MAC_SetRadioRegTable(0,  MAC_PA_LNA_LGM_RSSI_ADJ_IDX);
   */
  #endif
}
Esempio n. 6
0
void STEP_Init(struct STEP_Motor* stMotorHandle)
{
	// Enable Port for Motor Control
	SysCtlPeripheralEnable(stMotorHandle->ui32STEP_BaseAddress);

	// Enable Port for Motor Control "Enable"
	SysCtlPeripheralEnable(STEP_ENABLE_PERIPH);

	// Disable NMI for PD7 if it will be used
	if( (stMotorHandle->ui32STEP_BaseAddress == SYSCTL_PERIPH_GPIOD) && ( (stMotorHandle->ui32STEP_DirPin == GPIO_PIN_7) || (stMotorHandle->ui32STEP_MovePin == GPIO_PIN_7) ) )
	{
		HWREG(GPIO_PORTD_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY;
		HWREG(GPIO_PORTD_BASE + GPIO_O_CR) |= 0x80;
		HWREG(GPIO_PORTD_BASE + GPIO_O_LOCK) = 0;
	}

	// Init Stepper Motor Pins - Direction
	GPIOPinTypeGPIOOutput(stMotorHandle->ui32STEP_Port, stMotorHandle->ui32STEP_DirPin);

	// Init Stepper Motor Pins - Movement (toggle for step)
	GPIOPinTypeGPIOOutput(stMotorHandle->ui32STEP_Port, stMotorHandle->ui32STEP_MovePin);

	// Init Stepper Motor Pins - Enable
	GPIOPinTypeGPIOOutput(STEP_ENABLE_PORT, STEP_ENABLE_PIN);
}
Esempio n. 7
0
/*
 *  ======== EK_TM4C123GXL_initGPIO ========
 */
void EK_TM4C123GXL_initGPIO(void) {

	GPIOPadConfigSet(GPIO_PORTA_BASE,GPIO_PIN_2,GPIO_STRENGTH_8MA,GPIO_PIN_TYPE_STD_WPD);
	GPIOPadConfigSet(GPIO_PORTA_BASE,GPIO_PIN_3,GPIO_STRENGTH_8MA,GPIO_PIN_TYPE_STD_WPD);

	GPIOPinTypeGPIOInput(GPIO_PORTA_BASE, GPIO_PIN_2); /* ENC_A */
	GPIOPinTypeGPIOInput(GPIO_PORTA_BASE, GPIO_PIN_3); /* ENC_B */
	GPIOIntTypeSet(GPIO_PORTA_BASE,GPIO_PIN_2,GPIO_INT_BOTH_EDGES);

	GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_2); /* Load cell clock*/
	GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_3); /* Load cell data*/


	GPIOPinTypeGPIOInput(GPIO_PORTD_BASE, GPIO_PIN_0); /* Test Button 1*/
	GPIOPinTypeGPIOInput(GPIO_PORTD_BASE, GPIO_PIN_1); /* Test Button 2*/
	GPIOPinTypeGPIOInput(GPIO_PORTD_BASE, GPIO_PIN_2); /* Test Button 3*/

	/* Setup the LED GPIO pins used */
	GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1); /* Test led 2 */
	GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2); /* Test led 3 */


	/* PF0 requires unlocking before configuration */
	HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY;
	HWREG(GPIO_PORTF_BASE + GPIO_O_CR) |= GPIO_PIN_0;
	GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_0); /* Test led 1 */

	HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = GPIO_LOCK_M;

	/* Once GPIO_init is called, GPIO_config cannot be changed */
	GPIO_init();


}
Esempio n. 8
0
/*
 *  ======== EK_TM4C123GXL_initWiFi ========
 */
void EK_TM4C123GXL_initWiFi(void)
{
    /* Configure SSI2 */
    SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI2);
    GPIOPinConfigure(GPIO_PB4_SSI2CLK);
    GPIOPinConfigure(GPIO_PB6_SSI2RX);
    GPIOPinConfigure(GPIO_PB7_SSI2TX);
    GPIOPinTypeSSI(GPIO_PORTB_BASE, GPIO_PIN_4 | GPIO_PIN_6 | GPIO_PIN_7);

    /* Configure IRQ pin */
    GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_2);
    GPIOIntTypeSet(GPIO_PORTB_BASE, GPIO_PIN_2, GPIO_FALLING_EDGE);

    /* Configure EN pin */
    GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_5);
    GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_5, 0);

    /* Configure CS pin */
    GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, GPIO_PIN_0);
    GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_0, 0);

    /* Call necessary SPI init functions */
    SPI_init();
    EK_TM4C123GXL_initDMA();

    /* Initialize WiFi driver */
    WiFi_init();
}
Esempio n. 9
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);  

  
  //Start specific Pin Ports
  GPIOPinTypeGPIOOutput(port_A, GPIO_PIN_5 |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_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_6 | GPIO_PIN_5); 
  GPIOPinTypeGPIOOutput(port_E, GPIO_PIN_0); 
  GPIOPinTypeGPIOOutput(port_F, GPIO_PIN_4); 
  
  //Input Pins
  GPIOPinTypeGPIOInput(port_F, GPIO_PIN_2 | GPIO_PIN_3);
  
  //Initialize the display
  initializeDisplay();
  
  //Write phrases
  write_phrases();

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

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

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

}
Esempio n. 11
0
File: main.c Progetto: nemo1992/9DOF
int main(void)
{
  My_Init();
  Init_Timer();
  Init_I2C();
  Init_Sensors();
  SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
  GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1);
    /////////////////////////////////
  SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
  		SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
  		GPIOPinConfigure(GPIO_PA0_U0RX);
  		GPIOPinConfigure(GPIO_PA1_U0TX);
  		GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
  		SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); //enable GPIO port for LED
  		GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2); //enable pin for LED PF2
  		UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200,
  				(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
  		IntMasterEnable(); //enable processor interrupts
  		IntEnable(INT_UART0); //enable the UART interrupt
  		UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT); //only enable RX and TX interrupts
/////////////////////////////////
  Kalman_Sim_initialize();

  while(1)
  {
    Read_Accelerometer();
    Calculate_Acc();
    Read_Compass();
    Compass_Heading();
    Calculate_Compass();
    Read_Gyro();
    Calculate_Gyro();

    fgyro[0]    = sen_data.gyro_x;
    fgyro[1]	= sen_data.gyro_y;
    fgyro[2]	= sen_data.gyro_z;

    facc[0]     = sen_data.accel_x;
    facc[1]	= sen_data.accel_y;
    facc[2]	= sen_data.accel_z;

    fmag[0]     = sen_data.magnetom_x;
    fmag[1]	= sen_data.magnetom_y;
    fmag[2]	= sen_data.magnetom_z;


    Kalman_Sim_step();

    data[0]=Out1[0];
    data[1]=Out1[1];
    data[2]=Out1[2];



      Timer_CyRun();

  }
}
Esempio n. 12
0
/**
 * Configures the antenna using a RF switch
 * INT is the internal antenna (chip) configured through ANT1_SEL (V1)
 * EXT is the external antenna (connector) configured through ANT2_SEL (V2)
 */
void antenna_init(void) {
    // Configure the ANT1 and ANT2 GPIO as output
    GPIOPinTypeGPIOOutput(BSP_RADIO_BASE, BSP_RADIO_INT);
    GPIOPinTypeGPIOOutput(BSP_RADIO_BASE, BSP_RADIO_EXT);

    // By default the chip antenna is selected as the default
    GPIOPinWrite(BSP_RADIO_BASE, BSP_RADIO_INT, BSP_RADIO_INT);
    GPIOPinWrite(BSP_RADIO_BASE, BSP_RADIO_EXT, ~BSP_RADIO_EXT);
}
Esempio n. 13
0
void control_init() {
  //// laser control
  // Setup Timer0 for a 488.28125Hz "phase correct PWM" wave (assuming a 16Mhz clock)
  // Timer0 can pwm either PD5 (OC0B) or PD6 (OC0A), we use PD6
  // TCCR0A and TCCR0B are the registers to setup Timer0
  // see chapter "8-bit Timer/Counter0 with PWM" in Atmga328 specs
  // OCR0A sets the duty cycle 0-255 corresponding to 0-100%
  // also see: http://arduino.cc/en/Tutorial/SecretsOfArduinoPWM

	GPIOPinTypeGPIOOutput(LASER_EN_PORT, LASER_EN_MASK);
	GPIOPinWrite(LASER_EN_PORT, LASER_EN_MASK, LASER_EN_INVERT);

	// Configure timer
	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
	TimerConfigure(LASER_TIMER, TIMER_CFG_SPLIT_PAIR|TIMER_CFG_A_PWM|TIMER_CFG_B_ONE_SHOT);
	TimerControlLevel(LASER_TIMER, TIMER_A, 1);

	// PPI = PWMfreq/(feedrate/MM_PER_INCH/60)

	// Set PPI Pulse timer
	ppi_cycles = SysCtlClockGet() / 1000 * CONFIG_LASER_PPI_PULSE_MS;
	ppi_divider = ppi_cycles >> 16;
	ppi_cycles /= (ppi_divider + 1);
	TimerPrescaleSet(LASER_TIMER, TIMER_B, ppi_divider);
	TimerLoadSet(LASER_TIMER, TIMER_B, ppi_cycles);

	// Setup ISR
	TimerIntRegister(LASER_TIMER, TIMER_B, laser_isr);
	TimerIntEnable(LASER_TIMER, TIMER_TIMB_TIMEOUT);
    IntPrioritySet(INT_TIMER0B, CONFIG_LASER_PRIORITY);

	// Set PWM refresh rate
	laser_cycles = SysCtlClockGet() / CONFIG_LASER_PWM_FREQ; /*Hz*/
	laser_divider = laser_cycles >> 16;
	laser_cycles /= (laser_divider + 1);

	// Setup Laser PWM Timer
	TimerPrescaleSet(LASER_TIMER, TIMER_A, laser_divider);
	TimerLoadSet(LASER_TIMER, TIMER_A, laser_cycles);
	TimerPrescaleMatchSet(LASER_TIMER, TIMER_A, laser_divider);
	laser_intensity = 0;

	// Set default value
	control_laser_intensity(0);
	control_laser(0, 0);

	TimerEnable(LASER_TIMER, TIMER_A);

	// ToDo: Map the timer ccp pin sensibly
	GPIOPinConfigure(GPIO_PB6_T0CCP0);
	GPIOPinTypeTimer(LASER_PORT, (1 << LASER_BIT));

	//// air and aux assist control
	GPIOPinTypeGPIOOutput(ASSIST_PORT, ASSIST_MASK);
	control_air_assist(false);
	control_aux1_assist(false);
}
//Function to configure LCD port
void lcd_port_config (void)
{

	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);	// data pins

	GPIOPinTypeGPIOOutput(GPIO_PORTC_BASE, (GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6));	// PC4 RS; PC5 RW; PC6 EN
	GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, (GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7));	// 8 bit interfacing
}
int main(void)
{

	SysCtlClockSet(SYSCTL_SYSDIV_4|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); // Enable the GPIO A ports
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); // Enable the GPIO E ports
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);

	GPIOPinConfigure(GPIO_PB6_M0PWM0);
	GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_6);

	GPIOPinConfigure(GPIO_PB7_M0PWM1);
	GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_7);

	PWMGenConfigure(PWM0_BASE, PWM_GEN_0, PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC);
	PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, 6400000);
	PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0, PWMGenPeriodGet(PWM0_BASE, PWM_GEN_0) / 1.25);
	PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT, true);
	PWMGenEnable(PWM0_BASE, PWM_GEN_0);

	PWMGenConfigure(PWM0_BASE, PWM_GEN_1, PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC);
	PWMGenPeriodSet(PWM0_BASE, PWM_GEN_1, 6400000);
	PWMPulseWidthSet(PWM0_BASE, PWM_OUT_1, PWMGenPeriodGet(PWM0_BASE, PWM_GEN_1) / 1.25);
	PWMOutputState(PWM0_BASE, PWM_OUT_1_BIT, true);
	PWMGenEnable(PWM0_BASE, PWM_GEN_1);


	GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_6|GPIO_PIN_7); // Set pin 7 as the output port
	GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, GPIO_PIN_1|GPIO_PIN_2);
	GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_5);


	GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_6|GPIO_PIN_7,64); // Give '1' to pin 7
	GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_1|GPIO_PIN_2,4);
	while(1)
	{
		GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_6|GPIO_PIN_7,64); // Give '1' to pin 7
		GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_1|GPIO_PIN_2,4);
		SysCtlDelay(4000000*10);
		GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_6|GPIO_PIN_7,0); // Give '1' to pin 7
	    GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_1|GPIO_PIN_2,0);
	    GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_5,32);
	    SysCtlDelay(400000);
	    GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_5,0);
		GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_6|GPIO_PIN_7,128); // Give '1' to pin 7
		GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_1|GPIO_PIN_2,2);
		SysCtlDelay(4000000*10);
		GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_6|GPIO_PIN_7,0); // Give '1' to pin 7
		GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_1|GPIO_PIN_2,0);
		GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_5,32);
		SysCtlDelay(400000);
		GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_5,0);

	}
}
Esempio n. 16
0
void IoPortInit(void)
{
	//
	// Enable the GPIO block.
	//
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
	//SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
	//SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
	//SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
	//SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
	//SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOH);
     SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ);

	     // 要解锁只需要在配置GPIO前加入下面代码就可以了:

   // Unlock GPIO Commit GPIOAFSEL

   HWREG(GPIO_PORTB_BASE + GPIO_O_LOCK) = 0x4C4F434B;
  

   // Manually Write CR Register for PB7

   HWREG(GPIO_PORTB_BASE + GPIO_O_CR) |= (1 << 7);

 //  HWREG(GPIO_PORTB_BASE + GPIO_O_LOCK) = 0x1;

	//
	// Set GPIO D7 as an output.  This drives an LED on the board that will
	// toggle when a watchdog interrupt is processed.
	//
	GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, PIN_AD7705_RST|PIN_AD7705_CS|PIN_AD7705_DIN|PIN_AD7705_SCLK);//
	GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, PIN_AD7367_ADDR|PIN_AD7367_CNVST|PIN_AD7367_CS|PIN_AD7367_SCLK);
	//GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, PIN_200X|PIN_2KX | PIN_20KX |PIN_3X);
	GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, PIN_JUN|PIN_JUX|PIN_JRTG|PIN_JUNX);
	//GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, PIN_20N  | PIN_200N |  PIN_2KN );
	//GPIOPinTypeGPIOOutput(GPIO_PORTG_BASE, PIN_20KN |PIN_NX  | PIN_filterPASS|PIN_3N |PIN_ADC_ADDR|PIN_ADC_RANGE0);
    //GPIOPinTypeGPIOOutput(GPIO_PORTH_BASE, PIN_CE6963|PIN_CD6963|PIN_RD6963|PIN_WR6963);
    GPIOPinTypeGPIOOutput(GPIO_PORTJ_BASE, PIN_JR);

	GPIOPinTypeGPIOInput(GPIO_PORTA_BASE, PIN_AD7705_DRDY|PIN_AD7705_DOUT);//
	GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, PIN_AD7367_DOUTB|PIN_AD7367_BUSY);
//    GPIOPinTypeGPIOInput(GPIO_PORTC_BASE,PIN_ADC_BUSY);
//	GPIOPinTypeGPIOInput(GPIO_PORTD_BASE, PIN_KEY1 | PIN_KEY2 | PIN_KEY3 | PIN_KEY4);
//    GPIOPinTypeGPIOInput(GPIO_PORTE_BASE, PIN_keyback| PIN_keydown|PIN_keyprint|PIN_keyset|PIN_keystart|PIN_keyup);
//	GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, PIN_ISP2);
//	GPIOPinTypeGPIOInput(GPIO_PORTG_BASE, PIN_ADC_DOUTA );
//	GPIOPinTypeGPIOInput(GPIO_PORTH_BASE, );

//	GpioIntInit();

//	Led1Write(0);
//	Led2Write(0);
	
}
void initLEDs()
{
	  SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
		SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
	  GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_0|GPIO_PIN_1);
		GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_0|GPIO_PIN_4);
	  GPIOPinWrite(GPIO_PORTN_BASE,GPIO_PIN_0, PIN_LOW);
	  GPIOPinWrite(GPIO_PORTN_BASE,GPIO_PIN_1, PIN_LOW);
		GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_0, PIN_LOW);
	  GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_4, PIN_LOW);
}
Esempio n. 18
0
void ConfigDRV_Enable()
{
	SysCtlPeripheralEnable(DRV_ENABLE_LEFT_CHN_PERIPHERAL);
	SysCtlPeripheralEnable(DRV_ENABLE_RIGHT_CHN_PERIPHERAL);
	GPIOPinTypeGPIOOutput(DRV_ENABLE_LEFT_CHN_PORT, DRV_ENABLE_LEFT_CHN_PIN);
	GPIOPinTypeGPIOOutput(DRV_ENABLE_RIGHT_CHN_PORT, DRV_ENABLE_RIGHT_CHN_PIN);
//	GPIOPinTypeGPIOOutputOD(DRV_ENABLE_RIGHT_CHN_PORT,DRV_ENABLE_LEFT_CHN_PIN  | DRV_ENABLE_RIGHT_CHN_PIN);
	//	Turn off DRV when start
	GPIOPinWrite(DRV_ENABLE_LEFT_CHN_PORT, DRV_ENABLE_LEFT_CHN_PIN, 0);
	GPIOPinWrite(DRV_ENABLE_RIGHT_CHN_PORT, DRV_ENABLE_RIGHT_CHN_PIN, 0);
}
Esempio n. 19
0
void led_init(){

	/* PF0 requires unlocking before configuration */
	HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY;
	HWREG(GPIO_PORTF_BASE + GPIO_O_CR) |= GPIO_PIN_0;
	GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_0);
	HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = GPIO_LOCK_M;

	GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_7);
	GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1);
}
Esempio n. 20
0
//***********************************************//
//MP3_pin_init 
//Prototype: void MP3_pin_init(void)
//Description: initial pins for communicate with vs1011e.
//Returns: None.
//***********************************************//
void MP3_pin_init()
{
	GPIOPinTypeGPIOOutput(MP3_CS);              // Configure MP3_CS as output
	deselect_MP3();							              // Deselect MP3_CS
	GPIOPinTypeGPIOOutput(MP3_RST);               // Configure MP3_RST as output
	GPIOPinWrite(MP3_RST,MP3_RST_PIN);               // Set MP3_RST pin
	
	GPIOPinTypeGPIOOutput(BSYNC);               // Configure BSYNC as output
	clear_BSYNC();		
	GPIOPinTypeGPIOInput(DREQPIN);                  // Configure DREQ as input
	GPIOPadConfigSet(DREQPIN, GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU);
}
Esempio n. 21
0
//Initilisation des ports et pins pour transmettre des commandes aux moteurs
void initMotorCommand(void){
	GPIOPadConfigSet(GPIO_PORTD_BASE, GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7, GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD_WPD);
	GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7);
	GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7, 0xF0);
	GPIOPadConfigSet(GPIO_PORTC_BASE, GPIO_PIN_5 | GPIO_PIN_7, GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD_WPD);
	GPIOPinTypeGPIOOutput(GPIO_PORTC_BASE,GPIO_PIN_5 | GPIO_PIN_7);
	GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_5 | GPIO_PIN_7, 0xA0);
	GPIOPadConfigSet(GPIO_PORTE_BASE,GPIO_PIN_4 | GPIO_PIN_5, GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD_WPD);
	GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, GPIO_PIN_4 | GPIO_PIN_5);
	GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_4 | GPIO_PIN_5, 0x30);
	
}
Esempio n. 22
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_GPIOB);
		SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
		SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
		SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);

		//Removing Locks From Switch
					LOCK_F=0x4C4F434B;
					CR_F=GPIO_PIN_0|GPIO_PIN_4;

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

	GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7);
		GPIOPinTypeGPIOOutput(GPIO_PORTC_BASE, GPIO_PIN_4 | GPIO_PIN_6);
		GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_3);
		GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_5);
		GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_0);
		//GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7);

		GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_4,0x10);

}
Esempio n. 23
0
File: Base.c Progetto: ilabmp/micro
void Init_GPIO() {
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
	GPIOPinTypeGPIOInput(GPIO_PORTD_BASE, GPIO_PIN_6);
	GPIOPinTypeGPIOInput(GPIO_PORTD_BASE, GPIO_PIN_7);
	GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_4);
	GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_5);
	GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_4);
	GPIOPinTypeGPIOOutput(GPIO_PORTG_BASE, GPIO_PIN_0);
}
Esempio n. 24
0
void SonarInit()
{
  SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2);
  GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE,GPIO_PIN_7);
  GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_7, 0);
  TimerConfigure(TIMER2_BASE, TIMER_CFG_32_BIT_PER);
  GPIOIntTypeSet(GPIO_PORTD_BASE, GPIO_PIN_7,GPIO_RISING_EDGE);
  GPIOPinIntEnable(GPIO_PORTD_BASE,GPIO_PIN_7);

  SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
  GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE,GPIO_PIN_4);
  GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_4, 0);
  
}
Esempio n. 25
0
static void gpio_init(void)
{
    /* Set GPIOs as output */
    GPIOPinTypeGPIOOutput(GPIO_A_BASE, 0xFF);
    GPIOPinTypeGPIOOutput(GPIO_B_BASE, 0xFF);
    GPIOPinTypeGPIOOutput(GPIO_C_BASE, 0xFF);
    GPIOPinTypeGPIOOutput(GPIO_D_BASE, 0xFF);

    /* Initialize GPIOs to low */
    GPIOPinWrite(GPIO_A_BASE, 0xFF, 0x00);
    GPIOPinWrite(GPIO_B_BASE, 0xFF, 0x00);
    GPIOPinWrite(GPIO_C_BASE, 0xFF, 0x00);
    GPIOPinWrite(GPIO_D_BASE, 0xFF, 0x00);
}
Esempio n. 26
0
File: Mdc.c Progetto: saiyn/OSAL
/*0->output 1->input*/
void mdc_gpio_set_dir(mdc_slot_t slot, uint8 dir)
{
	switch(slot){
		 case SLOT_1:
			 if(dir == 0){
				 GPIOPinTypeGPIOOutput(GPIO1M0_PORT, GPIO1M0_PIN);
				 GPIOPinTypeGPIOOutput(GPIO2M0_PORT, GPIO2M0_PIN);
				 GPIOPinTypeGPIOOutput(GPIO3M0_PORT, GPIO3M0_PIN);
				 GPIOPinTypeGPIOOutput(GPIO4M0_PORT, GPIO4M0_PIN);
			 }else{
				 GPIOPinTypeGPIOInput(GPIO1M0_PORT, GPIO1M0_PIN);
				 GPIOPinTypeGPIOInput(GPIO2M0_PORT, GPIO2M0_PIN);
				 GPIOPinTypeGPIOInput(GPIO3M0_PORT, GPIO3M0_PIN);
				 GPIOPinTypeGPIOInput(GPIO4M0_PORT, GPIO4M0_PIN);
			 }
			 break;
		 
		 case SLOT_2:
			 if(dir == 0){
				 GPIOPinTypeGPIOOutput(GPIO1M1_PORT, GPIO1M1_PIN);
				 GPIOPinTypeGPIOOutput(GPIO2M1_PORT, GPIO2M1_PIN);
				 GPIOPinTypeGPIOOutput(GPIO3M1_PORT, GPIO3M1_PIN);
				 GPIOPinTypeGPIOOutput(GPIO4M1_PORT, GPIO4M1_PIN);
			 }else{
				 GPIOPinTypeGPIOInput(GPIO1M1_PORT, GPIO1M1_PIN);
				 GPIOPinTypeGPIOInput(GPIO2M1_PORT, GPIO2M1_PIN);
				 GPIOPinTypeGPIOInput(GPIO3M1_PORT, GPIO3M1_PIN);
				 GPIOPinTypeGPIOInput(GPIO4M1_PORT, GPIO4M1_PIN);
			 }
			 break;
		 
		 default:
			 break;
	 }
}
Esempio n. 27
0
void initLCD() {

	// -- paramra LED test
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
	GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, 0x0F);
	GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_3,  0x0F );

	SysCtlPeripheralEnable(LCDPORTENABLE);

	// -- paramra port A as control
	SysCtlPeripheralEnable(LCDCTRLENABLE);

	GPIOPinTypeGPIOOutput(LCDPORT,
				0xff);

	// -- paramra port A as control
	GPIOPinTypeGPIOOutput(LCDCTRL,
					0xff);

	// Please refer to the HD44780 datasheet for how these initializations work!
	SysCtlDelay((500e-3)*CLKSPEED/3);

	GPIOPinWrite(LCDCTRL, RS,  0x00 );

	GPIOPinWrite(LCDPORT, D4 | D5 | D6 | D7,  0x30 );
	GPIOPinWrite(LCDCTRL, E, 0x10);SysCtlDelay((20e-6)*CLKSPEED/3); GPIOPinWrite(LCDCTRL, E, 0x00);

	SysCtlDelay((50e-3)*CLKSPEED/3);

	GPIOPinWrite(LCDPORT, D4 | D5 | D6 | D7,  0x30 );
	GPIOPinWrite(LCDCTRL, E, 0x10);SysCtlDelay((20e-6)*CLKSPEED/3);GPIOPinWrite(LCDCTRL, E, 0x00);

	SysCtlDelay((50e-3)*CLKSPEED/3);

	GPIOPinWrite(LCDPORT, D4 | D5 | D6 | D7,  0x30 );
	GPIOPinWrite(LCDCTRL, E, 0x10);SysCtlDelay((20e-6)*CLKSPEED/3); GPIOPinWrite(LCDCTRL, E, 0x00);

	SysCtlDelay((10e-3)*CLKSPEED/3);

	GPIOPinWrite(LCDPORT, D4 | D5 | D6 | D7,  0x20 );
	GPIOPinWrite(LCDCTRL, E, 0x10);SysCtlDelay((20e-6)*CLKSPEED/3); GPIOPinWrite(LCDCTRL, E, 0x00);

	SysCtlDelay((10e-3)*CLKSPEED/3);

	LCDCommand(0x01);	// Clear the screen.
	LCDCommand(0x06);	// Cursor moves right.
	LCDCommand(0x0f);	// Cursor blinking, turn on LCD.


}
Esempio n. 28
0
int main() {

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



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

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

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


  //Set ISR
  GPIOIntRegister(GPIO_PORTF_BASE, scroll_button_isr);

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

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


  ROM_SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_GPIOF);
  ROM_SysCtlPeripheralClockGating(true);

  //Initialize the display
  initializeDisplay();


  //Write phrases
  write_phrases();


}
Esempio n. 29
0
File: lcd.c Progetto: rgrosko/TCCPos
void LCD_Init (void)
{
	int i;

	// Habilita GPIOA e GPIOC
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);

	// Programa como saída
	GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2 | GPIO_PIN_3);

	// Programa como saída
	GPIOPinTypeGPIOOutput(GPIO_PORTC_BASE, GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7);

	// Programa como saída
	GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_6);

	// EN=1
	GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_3, 0x08);

	// RS=0
	GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0x00);

	for(i=0;i<3;i++)
	{
		// Escreve 0x30 no Data (PC7-PC4)
		GPIOPinWrite(GPIO_PORTC_BASE , GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7, 0x30);

		// Dá um pulso no EN
		LCD_EN_Pulse();

		// Delay de ~5ms
		SysCtlDelay(83333);
	}

	// Escreve 0x20 no Data (PC7-PC4)
	GPIOPinWrite(GPIO_PORTC_BASE , GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7, 0x20);

	// Dá um pulso no EN
	LCD_EN_Pulse();

	// Delay de ~5ms
	SysCtlDelay(83333);

	// Envia as instruções 0x01, 0x06 e 0x0c (ver lcd1.pdf pág3)
	LCD_Inst(0x01);	// Clear display
	LCD_Inst(0x06);	// Increment, Display Shift Off
	LCD_Inst(0x0c);	// Display On, Cursor Underline Off, Cursor Blink Off
}
Esempio n. 30
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(); 
  }

}