/*
 * Copyright (c) 2019, Erich Styger
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include "leds.h"
#include "McuLED.h"
#include "board.h" /* defines the BOARD_LED_ macros */

/* USR_LED_L: PTD0
 * USR_LED_R: PTA13
 */
#define LED_R_GPIO      GPIOD
#define LED_R_PORT      PORTD
#define LED_R_PIN       0U

#define LED_L_GPIO      GPIOA
#define LED_L_PORT      PORTA
#define LED_L_PIN       13U

McuLED_Handle_t LEDS_Left, LEDS_Right;

void LEDS_Deinit(void) {
  LEDS_Left = McuLED_DeinitLed(LEDS_Left);
  LEDS_Right = McuLED_DeinitLed(LEDS_Right);
}

void LEDS_Init(void) {
  McuLED_Config_t config;

  /* initialize LEDs */
  McuLED_GetDefaultConfig(&config);
  config.isLowActive = true;

  config.hw.gpio = LED_L_GPIO;
  config.hw.port = LED_L_PORT;
  config.hw.pin = LED_L_PIN;
  LEDS_Left = McuLED_InitLed(&config);

  config.hw.gpio = LED_R_GPIO;
  config.hw.port = LED_R_PORT;
  config.hw.pin = LED_R_PIN;
  LEDS_Right = McuLED_InitLed(&config);
}
