Ejemplo n.º 1
0
int main(void)
{
	// 
	// Device configuration: PLL is used, crystal of 16 MHz, main clock is the source clock
	// System clock divider = 4
	//
	ROM_SysCtlClockSet(SYSCTL_SYSDIV_4|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);

	ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
	//
	// PF2 as output (blue led)
	// 
	ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, LED_RED|LED_BLUE|LED_GREEN);
	ButtonsInit(); // Init buttons

	// Loop
	while(1)
	{
		In = ROM_GPIOPinRead(BUTTONS_GPIO_BASE, RIGHT_BUTTON); // Read PORTF 0
		if (In==0){
			ROM_GPIOPinWrite(GPIO_PORTF_BASE, LED_BLUE, LED_BLUE); // Turn on LED BLUE
			ROM_GPIOPinWrite(GPIO_PORTF_BASE, LED_RED, 0);
		}
		else {
			ROM_GPIOPinWrite(GPIO_PORTF_BASE, LED_RED, LED_RED); // Turn on LED RED
			ROM_GPIOPinWrite(GPIO_PORTF_BASE, LED_BLUE, 0);
		}
	}
}
Ejemplo n.º 2
0
void readSingleBlock(unsigned char *buf, unsigned int addr) {
    ROM_GPIOPinWrite(LED_BASE, BUSY_LED, BUSY_LED);
    unsigned char r = sendCommand(CMD17, addr);
    if(r != 0x00){
#ifdef __UART_DEBUG
        UARTprintf("Recieved error 0x%02x for CMD17(0x%02x)!\n",r,addr);
#endif
        errorAndHang();
    }
    // read in what we've requested
    do
        r = tradeByte(0xff);
    while (r == 0xff);
    
    if(r != 0xfe) {
#ifdef __UART_DEBUG
        UARTprintf("Invalid data token read, recieved %02x\n",r);
#endif
        errorAndHang();
    }
    for(int i = 0; i < 512; i++)
       buf[i] = tradeByte(0xff);
    while(tradeByte(0xff) != 0xff);
    ROM_GPIOPinWrite(LED_BASE, BUSY_LED, 0);
}
Ejemplo n.º 3
0
void writeSingleBlock(unsigned char *buf, unsigned int addr) {
    ROM_GPIOPinWrite(LED_BASE, BUSY_LED, BUSY_LED);
    unsigned char r = sendCommand(CMD24, addr);
    if(r != 0x00){
#ifdef __UART_DEBUG
        UARTprintf("Recieved error 0x%02x for CMD24(0x%02x)!\n",r,addr);
#endif
        errorAndHang();
    }

    // block start token
    tradeByte(0xfe);

    // push out data packet
    for(int i = 0; i < 512; i++)
        tradeByte(buf[i]);

    // CRC dummy bytes
    r = tradeByte(0xff);
    r = tradeByte(0xff);
    
    // card is now busy, wait for it to stop
    while(tradeByte(0xff) != 0xff);
    ROM_GPIOPinWrite(LED_BASE, BUSY_LED, 0);
}
Ejemplo n.º 4
0
void board_toggle_led(led_t led) {
	uint32_t port;

	switch (led) {
		case RED:
			port = ROM_GPIOPinRead(LED_RED_PORTBASE, LED_RED);
			port ^=LED_RED;
			ROM_GPIOPinWrite(LED_RED_PORTBASE, LED_RED, port);
			break;

		case BLUE:
			port = ROM_GPIOPinRead(LED_BLUE_PORTBASE, LED_BLUE);
			port ^=LED_BLUE;
			ROM_GPIOPinWrite(LED_BLUE_PORTBASE, LED_BLUE, port);
			break;

		case GREEN:
			port = ROM_GPIOPinRead(LED_GREEN_PORTBASE, LED_GREEN);
			port ^=LED_GREEN;
			ROM_GPIOPinWrite(LED_GREEN_PORTBASE, LED_GREEN, port);
			break;
		default:
			break;
	}
}
Ejemplo n.º 5
0
// Fonction qui initialise le LCD
void init_lcd(void) {
	// Enable ports on board
	ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
	// Configure pins
	ROM_GPIOPadConfigSet(GPIO_PORTE_BASE, 0xFF, GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD_WPD);
	// Enable data as output
	ROM_GPIOPinTypeGPIOOutput(GPIO_PORTJ_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2);
	ROM_GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, 0xFF); // Toutes les pins
	// Default values of pins to zero
	ROM_GPIOPinWrite(GPIO_PORTJ_BASE, LCD_RS | LCD_RW | LCD_E, 0x00);
	ROM_GPIOPinWrite(GPIO_PORTE_BASE, 0xFF, 0x00);
	// Set LCD to 2line mode
	wait();
	ROM_GPIOPinWrite(GPIO_PORTJ_BASE, LCD_RS | LCD_RW, LCD_RS_Instruction | LCD_RW_Write);
	ROM_GPIOPinWrite(GPIO_PORTJ_BASE, LCD_E, LCD_E);
	ROM_GPIOPinWrite(GPIO_PORTE_BASE, 0xFF, 0x38);
	ROM_GPIOPinWrite(GPIO_PORTJ_BASE, LCD_E, 0);
	// Activate cursor blinking
	wait();
	ROM_GPIOPinWrite(GPIO_PORTJ_BASE, LCD_RS | LCD_RW, LCD_RS_Instruction | LCD_RW_Write);
	ROM_GPIOPinWrite(GPIO_PORTJ_BASE, LCD_E, LCD_E);
	ROM_GPIOPinWrite(GPIO_PORTE_BASE, 0xFF, 0x0F);
	ROM_GPIOPinWrite(GPIO_PORTJ_BASE, LCD_E, 0);
	// Clear LCD
	clear();
}
Ejemplo n.º 6
0
//*****************************************************************************
//
// This is the handler for INT_GPIOA.  It simply saves the interrupt sequence
// number.
//
//*****************************************************************************
void
IntGPIOa(void)
{
    //
    // Set PE1 high to indicate entry to this interrupt handler.
    //
    ROM_GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_1, GPIO_PIN_1);

    //
    // Put the current interrupt state on the display.
    //
    DisplayIntStatus();

    //
    // Wait two seconds.
    //
    Delay(2);

    //
    // Save and increment the interrupt sequence number.
    //
    g_ui32GPIOa = g_ui32Index++;

    //
    // Set PE1 low to indicate exit from this interrupt handler.
    //
    ROM_GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_1, 0);
}
Ejemplo n.º 7
0
//Fonction qui écrit le charactère "mychar" en mémoire du LCD
void write_char(char mychar) {
	wait();
	ROM_GPIOPinWrite(GPIO_PORTJ_BASE, LCD_RS | LCD_RW, LCD_RS_Display | LCD_RW_Write);
	ROM_GPIOPinWrite(GPIO_PORTJ_BASE, LCD_E, LCD_E);
	ROM_GPIOPinWrite(GPIO_PORTE_BASE, 0xFF, mychar);
	ROM_GPIOPinWrite(GPIO_PORTJ_BASE, LCD_E, 0);
}
static void Config_PWM(void)
{
	ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
	ROM_GPIOPinConfigure(GPIO_PB6_T0CCP0);
	ROM_GPIOPinConfigure(GPIO_PB2_T3CCP0);
	ROM_GPIOPinTypeTimer(GPIO_PORTB_BASE, GPIO_PIN_2 | GPIO_PIN_6);

	// Configure timer
	ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
	ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER3);

	ROM_TimerConfigure(TIMER0_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_PWM);
	ROM_TimerLoadSet(TIMER0_BASE, TIMER_A, DEFAULT);
	ROM_TimerMatchSet(TIMER0_BASE, TIMER_A, DEFAULT); // PWM
	ROM_TimerEnable(TIMER0_BASE, TIMER_A);

	ROM_TimerConfigure(TIMER3_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_PWM);
	ROM_TimerLoadSet(TIMER3_BASE, TIMER_A, DEFAULT);
	ROM_TimerMatchSet(TIMER3_BASE, TIMER_A, DEFAULT); // PWM
	ROM_TimerControlLevel(TIMER3_BASE, TIMER_A, true);
	ROM_TimerEnable(TIMER3_BASE, TIMER_A);

	ROM_SysCtlPeripheralEnable(DRV_ENABLE_LEFT_CHN_PERIPHERAL);
	ROM_SysCtlPeripheralEnable(DRV_ENABLE_RIGHT_CHN_PERIPHERAL);
	ROM_GPIOPinTypeGPIOOutput(DRV_ENABLE_LEFT_CHN_PORT, DRV_ENABLE_LEFT_CHN_PIN);
	ROM_GPIOPinTypeGPIOOutput(DRV_ENABLE_RIGHT_CHN_PORT, DRV_ENABLE_RIGHT_CHN_PIN);
	ROM_GPIOPinWrite(DRV_ENABLE_LEFT_CHN_PORT, DRV_ENABLE_LEFT_CHN_PIN, 0);
	ROM_GPIOPinWrite(DRV_ENABLE_RIGHT_CHN_PORT, DRV_ENABLE_RIGHT_CHN_PIN, 0);
}
Ejemplo n.º 9
0
//*****************************************************************************
//
// Waits until a program/erase operation has completed.
//
//*****************************************************************************
static void
MX66L51235FWait(void)
{
    uint8_t ui8Status;

    //
    // Loop until the requested operation has completed.
    //
    do {
        //
        // Assert the chip select to the MX66L51235F.
        //
        ROM_GPIOPinWrite(GPIO_PORTQ_BASE, GPIO_PIN_1, 0);

        //
        // Read the status register.
        //
        ui8Status = ROM_SPIFlashReadStatus(SSI3_BASE);

        //
        // De-assert the chip select to the MX66L51235F.
        //
        ROM_GPIOPinWrite(GPIO_PORTQ_BASE, GPIO_PIN_1, GPIO_PIN_1);
    } while(ui8Status & 1);
}
// Triggered every SERVO_TIMER_RESOLUTION microseconds
void TimerIntHandlerServos(void) {
    // Clear the interrupt
    ROM_TimerIntClear(SERVO_TIMER, SERVO_TIMER_TRIGGER);
    
    // SERVO_TIMER_RESOLUTION microseconds have passed, increment each counter by that
    // to determine how long to set the pin high for
    g_pulseTime += SERVO_TIMER_RESOLUTION;

    if(g_pulseTime > SERVO_PERIOD) {
        g_pulseTime = 0;
    }

    // Loop through al servo configs and see if they need to be set low yet
    uint8_t i;
    for(i=0; i<SERVO_MAX_COUNT; i++) {
        servo_t *servo = &g_servos[i];
        
        if(servo->state & SERVO_STATE_ENABLED) {
            if(g_pulseTime >= servo->value) {
                // End of pulse, set low
                ROM_GPIOPinWrite(servo->port, servo->pin, 0);
            } else  {
                // Beginning of pulse, set high
                ROM_GPIOPinWrite(servo->port, servo->pin, servo->pin);
            }
        }
    }
}
Ejemplo n.º 11
0
void motor_enable()
{
  ROM_GPIOPinWrite( MOTOR_XENPORT, MOTOR_XEN, 0 );
  ROM_GPIOPinWrite( MOTOR_YENPORT, MOTOR_YEN, 0 );
  ROM_GPIOPinWrite( MOTOR_ZENPORT, MOTOR_ZEN, 0 );
  ROM_GPIOPinWrite( MOTOR_EENPORT, MOTOR_EEN, 0 );
  motors_enabled = true;
}
Ejemplo n.º 12
0
void motor_disable() 
{
  ROM_GPIOPinWrite( MOTOR_XENPORT, MOTOR_XEN, MOTOR_XEN );
  ROM_GPIOPinWrite( MOTOR_YENPORT, MOTOR_YEN, MOTOR_YEN );
  ROM_GPIOPinWrite( MOTOR_ZENPORT, MOTOR_ZEN, MOTOR_ZEN );
  ROM_GPIOPinWrite( MOTOR_EENPORT, MOTOR_EEN, MOTOR_EEN );
  motors_enabled = false;
}
Ejemplo n.º 13
0
void motor_unstep() 
{
  ROM_GPIOPinWrite(LED_PORT, LED_R | LED_G | LED_B, 0 );
  ROM_GPIOPinWrite( MOTOR_XSTEPPORT, MOTOR_XPIN, 0);
  ROM_GPIOPinWrite( MOTOR_YSTEPPORT, MOTOR_YPIN, 0);
  ROM_GPIOPinWrite( MOTOR_ZSTEPPORT, MOTOR_ZPIN, 0);
  ROM_GPIOPinWrite( MOTOR_ESTEPPORT, MOTOR_EPIN, 0);

}
Ejemplo n.º 14
0
//*****************************************************************************
//
// Writes the extended address register, allowing the full contents of the
// MX66L51235F to be accessed.
//
//*****************************************************************************
static void
MX66L51235FWriteEAR(uint32_t ui32Addr)
{
    //
    // See if the extended address register needs to be written.
    //
    if((ui32Addr & 0xff000000) == (g_ui32MX66L51235FAddr & 0xff000000)) {
        //
        // The extended address register does not need to be changed, so return
        // without doing anything.
        //
        return;
    }

    //
    // Save the new value of the extended address register.
    //
    g_ui32MX66L51235FAddr = ui32Addr;

    //
    // Enable program/erase of the SPI flash.
    //
    MX66L51235FWriteEnable();

    //
    // Assert the chip select to the MX66L51235F.
    //
    ROM_GPIOPinWrite(GPIO_PORTQ_BASE, GPIO_PIN_1, 0);

    //
    // Set the SSI module into write-only mode.
    //
    ROM_SSIAdvModeSet(SSI3_BASE, SSI_ADV_MODE_WRITE);

    //
    // Send the sector erase command.
    //
    ROM_SSIDataPut(SSI3_BASE, 0xc5);

    //
    // Send the address of the sector to be erased, marking the last byte of
    // the address as the end of the frame.
    //
    ROM_SSIAdvDataPutFrameEnd(SSI3_BASE, (ui32Addr >> 24) & 0xff);

    //
    // Wait until the command has been completely transmitted.
    //
    while(ROM_SSIBusy(SSI3_BASE)) {
    }

    //
    // De-assert the chip select to the MX66L51235F.
    //
    ROM_GPIOPinWrite(GPIO_PORTQ_BASE, GPIO_PIN_1, GPIO_PIN_1);
}
Ejemplo n.º 15
0
void lcd_init() {
	ROM_SysCtlPeripheralEnable(LCD_PORTENABLE);
	ROM_GPIOPinTypeGPIOOutput(LCD_PORT, (LCD_RS | LCD_E | LCD_D4 | LCD_D5 | LCD_D6 | LCD_D7));

	// Please refer to the HLCD_D44780 datasheet for how these initializations work!
	ROM_SysCtlDelay(ROM_SysCtlClockGet()/3/2);

	ROM_GPIOPinWrite(LCD_PORT, LCD_RS,  0x00);

	ROM_GPIOPinWrite(LCD_PORT, LCD_D4 | LCD_D5 | LCD_D6 | LCD_D7,  0x30);
	ROM_GPIOPinWrite(LCD_PORT, LCD_E, 0x02);ROM_SysCtlDelay((20e-6)*ROM_SysCtlClockGet()/3); ROM_GPIOPinWrite(LCD_PORT, LCD_E, 0x00);

	ROM_SysCtlDelay((50e-3)*ROM_SysCtlClockGet()/3);

	ROM_GPIOPinWrite(LCD_PORT, LCD_D4 | LCD_D5 | LCD_D6 | LCD_D7,  0x30);
	ROM_GPIOPinWrite(LCD_PORT, LCD_E, 0x02);ROM_SysCtlDelay((20e-6)*ROM_SysCtlClockGet()/3);ROM_GPIOPinWrite(LCD_PORT, LCD_E, 0x00);

	ROM_SysCtlDelay((50e-3)*ROM_SysCtlClockGet()/3);

	ROM_GPIOPinWrite(LCD_PORT, LCD_D4 | LCD_D5 | LCD_D6 | LCD_D7,  0x30);
	ROM_GPIOPinWrite(LCD_PORT, LCD_E, 0x02);ROM_SysCtlDelay((20e-6)*ROM_SysCtlClockGet()/3); ROM_GPIOPinWrite(LCD_PORT, LCD_E, 0x00);

	ROM_SysCtlDelay((10e-3)*ROM_SysCtlClockGet()/3);

	ROM_GPIOPinWrite(LCD_PORT, LCD_D4 | LCD_D5 | LCD_D6 | LCD_D7,  0x20);
	ROM_GPIOPinWrite(LCD_PORT, LCD_E, 0x02);ROM_SysCtlDelay((20e-6)*ROM_SysCtlClockGet()/3); ROM_GPIOPinWrite(LCD_PORT, LCD_E, 0x00);

	ROM_SysCtlDelay((10e-3)*ROM_SysCtlClockGet()/3);

	lcd_command(LCD_CLEARDISPLAY);	// Clear the screen.
	lcd_command(0x06);	// Cursor moves right.
	lcd_command(LCD_DISPLAYCONTROL | LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF);	// Don't show any cursor, turn on LCD.
}
Ejemplo n.º 16
0
void system_Enable_BoostCircuit(bool Enable)
{
	if (Enable)
	{
		ROM_GPIOPinWrite(BOOST_ENABLE_PORT, BOOST_ENABLE_PIN, 0xff);
	}
	else
	{
		ROM_GPIOPinWrite(BOOST_ENABLE_PORT, BOOST_ENABLE_PIN, 0x00);
	}
}
Ejemplo n.º 17
0
/*turn off selected leds*/
void led_off(u32 led)
{
  if (led == LED_2)
    ROM_GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1, 0);

  if (led == LED_1)
    ROM_GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_3, 0);

  if (led == LED_3)
    ROM_GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0);
}
Ejemplo n.º 18
0
//Fonction qui effectue un "Clear" sur le LCD et qui met les nom des équipiers sur la ligne du haut.
void clear(void) {
	// Clear LCD
	wait();
	ROM_GPIOPinWrite(GPIO_PORTJ_BASE, LCD_RS | LCD_RW, LCD_RS_Instruction | LCD_RW_Write);
	ROM_GPIOPinWrite(GPIO_PORTJ_BASE, LCD_E, LCD_E);
	ROM_GPIOPinWrite(GPIO_PORTE_BASE, 0xFF, 0x01);
	ROM_GPIOPinWrite(GPIO_PORTJ_BASE, LCD_E, 0);
	// Write names
	write_position();
	// Reset counter
	nbrchar = 0;
}
Ejemplo n.º 19
0
 int main()
 {
 ROM_SysCtlClockSet(SYSCTL_SYSDIV_4|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
 ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
 ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, LED_RED|LED_BLUE|LED_GREEN);
 for (;;) {
 // set the red LED pin high, others low
 ROM_GPIOPinWrite(GPIO_PORTF_BASE, LED_RED|LED_GREEN|LED_BLUE, LED_RED);
 ROM_SysCtlDelay(4000000);
 ROM_GPIOPinWrite(GPIO_PORTF_BASE, LED_RED|LED_GREEN|LED_BLUE, 0);
 ROM_SysCtlDelay(5000000);
 }
 }
/**
 * @brief Control Hbridge
 */
void speed_Enable_Hbridge(bool Enable)
{
	if (Enable)
	{
		ROM_GPIOPinWrite(DRV_ENABLE_LEFT_CHN_PORT, DRV_ENABLE_LEFT_CHN_PIN, DRV_ENABLE_LEFT_CHN_PIN);
		ROM_GPIOPinWrite(DRV_ENABLE_RIGHT_CHN_PORT, DRV_ENABLE_RIGHT_CHN_PIN, DRV_ENABLE_RIGHT_CHN_PIN);
	}
	else
	{
		ROM_GPIOPinWrite(DRV_ENABLE_LEFT_CHN_PORT, DRV_ENABLE_LEFT_CHN_PIN, 0);
		ROM_GPIOPinWrite(DRV_ENABLE_RIGHT_CHN_PORT, DRV_ENABLE_RIGHT_CHN_PIN, 0);
	}
}
Ejemplo n.º 21
0
static inline void shift_bit(shiftbrite* sb, uint16_t val) {
  if( val )
  {
      ROM_GPIOPinWrite( sb->data_pin.port, sb->data_pin.pin, sb->data_pin.pin );
  }
  else
  {
      ROM_GPIOPinWrite( sb->data_pin.port, sb->data_pin.pin, ~sb->data_pin.pin );
  }
  ROM_SysCtlDelay(5);
  pulse(sb->clock_pin);

}
Ejemplo n.º 22
0
//*****************************************************************************
//
//! Toggle one or both of the EVALBOT LEDs.
//!
//! \param eLED indicates the LED or LEDs to toggle.  Valid values are \e
//!        LED_1, \e LED_2 or \e BOTH_LEDS.
//!
//! This function may be used to toggle either one or both of the LEDs on the
//! EVALBOT.  If the LED is currently lit, it will be turned off and vice verse.
//! Callers must ensure that they have previously called LEDsInit().
//!
//! \return None.
//
//*****************************************************************************
void
LED_Toggle (tLED eLED)
{
    //
    // Check for invalid parameter values.
    //
    ASSERT((eLED == BOTH_LEDS) || (eLED == LED_1) || (eLED == LED_2));

    //
    // Which LED are we to toggle?
    //
    switch (eLED)
    {
        //
        // Toggle both LEDs.
        //
        case BOTH_LEDS:
        {
            ROM_GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_4 | GPIO_PIN_5,
                      ~ROM_GPIOPinRead(GPIO_PORTF_BASE,
                                       GPIO_PIN_4 | GPIO_PIN_5));
             break;
        }

        //
        // Toggle LED 1.
        //
        case LED_1:
        {
            ROM_GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_4,
                             ~ROM_GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_4));
            break;
        }

        //
        // Toggle LED 2.
        //
        case LED_2:
        {
            ROM_GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_5,
                             ~ROM_GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_5));
            break;
        }

        //
        // An invalid value was passed.
        //
        default:
            break;
    }
}
Ejemplo n.º 23
0
// Fonction qui gère le temps de traitement du LCD
void wait(void) {
	// Change pin type
	ROM_GPIOPinTypeGPIOInput(GPIO_PORTE_BASE, 0xFF); // Toutes les pins
	//Read busy flag until it's 0
	volatile unsigned long busyflag;
	do {
		ROM_GPIOPinWrite(GPIO_PORTJ_BASE, LCD_RS | LCD_RW, LCD_RS_Instruction | LCD_RW_Read);
		ROM_GPIOPinWrite(GPIO_PORTJ_BASE, LCD_E, LCD_E);
		busyflag = ROM_GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_7);
		ROM_GPIOPinWrite(GPIO_PORTJ_BASE, LCD_E, 0);
	} while(busyflag == 128);
	// Restore pin type
	ROM_GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, 0xFF); // Toutes les pins
}
void signalUnhandleError(void)
{
	while (1)
	{
		ROM_GPIOPinWrite(LED_PORT_BASE, LED_ALL, LED_RED);
		ROM_SysCtlDelay(2000000);

		ROM_GPIOPinWrite(LED_PORT_BASE, LED_ALL, LED_GREEN);
		ROM_SysCtlDelay(2000000);

		ROM_GPIOPinWrite(LED_PORT_BASE, LED_ALL, LED_BLUE);
		ROM_SysCtlDelay(2000000);
	}
}
Ejemplo n.º 25
0
//*****************************************************************************
//
//! Turn one or both of the EVALBOT LEDs on.
//!
//! \param eLED indicates the LED or LEDs to turn on.  Valid values are \e
//!        LED_1, \e LED_2 or \e BOTH_LEDS.
//!
//! This function may be used to light either one or both of the LEDs on the
//! EVALBOT.  Callers must ensure that they have previously called LEDsInit().
//!
//! \return None.
//
//*****************************************************************************
void
LED_On(tLED eLED)
{
    //
    // Check for invalid parameter values.
    //
    ASSERT((eLED == BOTH_LEDS) || (eLED == LED_1) || (eLED == LED_2));

    //
    // Which LED are we to turn on?
    //
    switch (eLED)
    {
        //
        // Turn both LEDs on.
        //
        case BOTH_LEDS:
        {
            ROM_GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_4 | GPIO_PIN_5,
                             GPIO_PIN_4 | GPIO_PIN_5);
            break;
        }

        //
        // Turn LED 1 on.
        //
        case LED_1:
        {
            ROM_GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_4, GPIO_PIN_4);
            break;
        }

        //
        // Turn LED 2 on.
        //
        case LED_2:
        {
            ROM_GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_5, GPIO_PIN_5);
            break;
        }

        //
        // An invalid LED value was passed.
        //
        default:
            break;
    }
}
Ejemplo n.º 26
0
// Main ----------------------------------------------------------------------------------------------
int main(void){

	// Enable lazy stacking
	ROM_FPULazyStackingEnable();

	// Set the system clock to run at 40Mhz off PLL with external crystal as reference.
	ROM_SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);

	// Initialize the UART and write status.
	ConfigureUART();
	UARTprintf("ISL29023 Example\n");

	// Enable LEDs
	ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
	ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, LED_RED|LED_BLUE|LED_GREEN);

	// Enable I2C3
	ConfigureI2C3();

	// Create struct
	tISL29023 islSensHub;

	// Create print variables
	uint32_t printValue[2];

	ISL29023ChangeSettings(ISL29023_COMMANDII_RANGE64k, ISL29023_COMMANDII_RES16, &islSensHub);

	while(1){
		// Get ALS
		ISL29023GetALS(&islSensHub);
		FloatToPrint(islSensHub.alsVal, printValue);
		UARTprintf("ALS: %d.%03d |.| ",printValue[0],printValue[1]);

		// Get IR
		ISL29023GetIR(&islSensHub);
		FloatToPrint(islSensHub.irVal, printValue);
		UARTprintf("IR: %d.%03d\n",printValue[0],printValue[1]);

		// Blink LED
		ROM_GPIOPinWrite(GPIO_PORTF_BASE, LED_RED|LED_GREEN|LED_BLUE, LED_GREEN);
		ROM_SysCtlDelay(ROM_SysCtlClockGet()/3/10);	// Delay for 100ms (1/10s) :: ClockGet()/3 = 1second
		ROM_GPIOPinWrite(GPIO_PORTF_BASE, LED_RED|LED_GREEN|LED_BLUE, 0);

		// Delay for second
		ROM_SysCtlDelay(ROM_SysCtlClockGet()/3);
	}

}
Ejemplo n.º 27
0
//*****************************************************************************
//
// Initialize the IO used in this demo
//
//*****************************************************************************
void
io_init(void)
{
    //
    // Configure Port F0 for as an output for the status LED.
    //
    ROM_GPIOPinTypeGPIOOutput(LED_PORT_BASE, LED_PIN);

    //
    // Initialize LED to OFF (0)
    //
    ROM_GPIOPinWrite(LED_PORT_BASE, LED_PIN, 0);

    //
    // Enable the peripherals used by this example.
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2);

    //
    // Configure the timer used to pace the animation.
    //
    ROM_TimerConfigure(TIMER2_BASE, TIMER_CFG_PERIODIC);

    //
    // Setup the interrupts for the timer timeouts.
    //
    ROM_IntEnable(INT_TIMER2A);
    ROM_TimerIntEnable(TIMER2_BASE, TIMER_TIMA_TIMEOUT);

    //
    // Set the timer for the current animation speed.  This enables the
    // timer as a side effect.
    //
    io_set_timer(g_ulAnimSpeed);
}
//*****************************************************************************
//
// The interrupt handler for the watchdog.  This feeds the dog (so that the
// processor does not get reset) and winks the LED connected to GPIO B3.
//
//*****************************************************************************
void
WatchdogIntHandler(void)
{
    //
    // If we have been told to stop feeding the watchdog, return immediately
    // without clearing the interrupt.  This will cause the system to reset
    // next time the watchdog interrupt fires.
    //
    if(!g_bFeedWatchdog)
    {
        return;
    }

    //
    // Clear the watchdog interrupt.
    //
    ROM_WatchdogIntClear(WATCHDOG0_BASE);

    //
    // Invert the GPIO PN0 value.
    //
    ROM_GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0,
                     (ROM_GPIOPinRead(GPIO_PORTN_BASE, GPIO_PIN_0) ^
                                     GPIO_PIN_0));
}
Ejemplo n.º 29
0
int8_t CMD_set_test(uint8_t argc, uint8_t **argv) {
	if(argc == 1){
		// Turn red LED on.
		ROM_GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_3|GPIO_PIN_2, GPIO_PIN_2);
	}
	return 0;
}
Ejemplo n.º 30
0
void Init_LED()
{
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_4);    //配置PF4为数值输出
    ROM_GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_4, GPIO_PIN_4);    //PF4,输出高电平

}