Exemplo n.º 1
0
int
hal_gpio_toggle(int pin)
{
    GPIO_TogglePinsOutput(s_gpioBases[GPIO_PORT(pin)], 1 << GPIO_INDEX(pin));

    return 0;
}
Exemplo n.º 2
0
/*!
 * @brief Interrupt service fuction of switch.
 *
 * This function toggles the LED
 */
void BOARD_SW_IRQ_HANDLER(void)
{
    /* Clear external interrupt flag. */
    GPIO_ClearPinsInterruptFlags(BOARD_SW_GPIO, 1U << BOARD_SW_GPIO_PIN);
    /* Change state of button. */
    g_ButtonPress = true;
    /* Toggle LED. */
    GPIO_TogglePinsOutput(BOARD_LED_GPIO, 1U << BOARD_LED_GPIO_PIN);
}
Exemplo n.º 3
0
void vTimerCallback(TimerHandle_t xTimer) {
  if (xSemaphoreTake(semLED, 0 /*portMAX_DELAY*/)==pdPASS) { /* block on semaphore */
    led++;
    if (led==3) { /* wrap */
      led = 0;
    }
    /* clear all LEDs */
    GPIO_SetPinsOutput(GPIOA, 1<<1u);
    GPIO_SetPinsOutput(GPIOA, 1<<2u);
    GPIO_SetPinsOutput(GPIOD, 1<<5u);
  }
  if (led==0) { /* red */
    GPIO_TogglePinsOutput(GPIOA, 1<<1u); /* toggle RED LED */
  } else if (led==1) { /* green */
    GPIO_TogglePinsOutput(GPIOA, 1<<2u); /* toggle GREEN LED */
  } else if (led==2) { /* blue */
    GPIO_TogglePinsOutput(GPIOD, 1<<5u); /* toggle BLUE LED */
  }
}
Exemplo n.º 4
0
int main(void) {
    BOARD_InitPins();
    BOARD_BootClockRUN();
    BOARD_InitDebugConsole();

    GPIO_PinInit(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PIN, \
        &(gpio_pin_config_t){kGPIO_DigitalOutput, 0u});
    GPIO_PinInit(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PIN, \
        &(gpio_pin_config_t){kGPIO_DigitalOutput, 0u});
    GPIO_PinInit(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PIN, \
        &(gpio_pin_config_t){kGPIO_DigitalOutput, 0u});

    GPIO_SetPinsOutput(BOARD_LED_RED_GPIO, 1u << BOARD_LED_RED_GPIO_PIN);
    GPIO_SetPinsOutput(BOARD_LED_GREEN_GPIO, 1u << BOARD_LED_GREEN_GPIO_PIN);
    GPIO_SetPinsOutput(BOARD_LED_BLUE_GPIO, 1u << BOARD_LED_BLUE_GPIO_PIN);

    for(;;) {
        GPIO_TogglePinsOutput(BOARD_LED_BLUE_GPIO, 1u << BOARD_LED_BLUE_GPIO_PIN);
        delay();
    }
}