//
// WARNING: DO NOT EDIT THIS FILE
//   This file has been generated from the target's JSON hardware description
//


static const stm32_switch_t _switch_defs[] = {
  {
    "SA",
    GPIOD,
    LL_GPIO_PIN_0,
    nullptr, 0,
    SWITCH_HW_2POS, SWITCH_HW_INVERTED
  },
  {
    "SB",
    GPIOE,
    LL_GPIO_PIN_2,
    nullptr, 0,
    SWITCH_HW_2POS, SWITCH_HW_INVERTED
  },
  {
    "SC",
    GPIOD,
    LL_GPIO_PIN_1,
    GPIOD,
    LL_GPIO_PIN_2,
    SWITCH_HW_3POS, 0
  },
  {
    "SD",
    GPIOE,
    LL_GPIO_PIN_1,
    GPIOE,
    LL_GPIO_PIN_0,
    SWITCH_HW_3POS, 0
  },
  {
    "SE",
    GPIOD,
    LL_GPIO_PIN_3,
    nullptr, 0,
    SWITCH_HW_2POS, 0
  },
  {
    "SF",
    GPIOB,
    LL_GPIO_PIN_5,
    nullptr, 0,
    SWITCH_HW_2POS, 0
  },
  {
    "SG",
    GPIOD,
    LL_GPIO_PIN_15,
    nullptr, 0,
    SWITCH_HW_2POS, 0
  },
  {
    "SH",
    GPIOF,
    LL_GPIO_PIN_0,
    nullptr, 0,
    SWITCH_HW_2POS, 0
  },
  {
    "SI",
    GPIOG,
    LL_GPIO_PIN_11,
    nullptr, 0,
    SWITCH_HW_2POS, 0
  },
  {
    "SJ",
    GPIOG,
    LL_GPIO_PIN_14,
    nullptr, 0,
    SWITCH_HW_2POS, 0
  },
  {
    "SW1",
    GPIOE,
    LL_GPIO_PIN_10,
    nullptr, 0,
    SWITCH_HW_2POS, 0
  },
  {
    "SW2",
    GPIOE,
    LL_GPIO_PIN_8,
    nullptr, 0,
    SWITCH_HW_2POS, 0
  },
  {
    "SW3",
    GPIOE,
    LL_GPIO_PIN_12,
    nullptr, 0,
    SWITCH_HW_2POS, 0
  },
  {
    "SW4",
    GPIOE,
    LL_GPIO_PIN_13,
    nullptr, 0,
    SWITCH_HW_2POS, 0
  },
  {
    "SW5",
    GPIOE,
    LL_GPIO_PIN_14,
    nullptr, 0,
    SWITCH_HW_2POS, 0
  },
  {
    "SW6",
    GPIOE,
    LL_GPIO_PIN_15,
    nullptr, 0,
    SWITCH_HW_2POS, 0
  },
};

static const stm32_switch_t* const _switch_offsets[] = {
  _switch_defs,
  _switch_defs + 10,
};

static inline void _init_switches()
{
  LL_GPIO_InitTypeDef pinInit;
  LL_GPIO_StructInit(&pinInit);
  pinInit.Mode = LL_GPIO_MODE_INPUT;
  pinInit.Pull = LL_GPIO_PULL_UP;
  stm32_gpio_enable_clock(GPIOB);
  pinInit.Pin = LL_GPIO_PIN_5;
  LL_GPIO_Init(GPIOB, &pinInit);
  stm32_gpio_enable_clock(GPIOD);
  pinInit.Pin = LL_GPIO_PIN_0|LL_GPIO_PIN_1|LL_GPIO_PIN_2|LL_GPIO_PIN_3|LL_GPIO_PIN_15;
  LL_GPIO_Init(GPIOD, &pinInit);
  stm32_gpio_enable_clock(GPIOE);
  pinInit.Pin = LL_GPIO_PIN_2|LL_GPIO_PIN_1|LL_GPIO_PIN_0|LL_GPIO_PIN_10|LL_GPIO_PIN_8|LL_GPIO_PIN_12|LL_GPIO_PIN_13|LL_GPIO_PIN_14|LL_GPIO_PIN_15;
  LL_GPIO_Init(GPIOE, &pinInit);
  stm32_gpio_enable_clock(GPIOF);
  pinInit.Pin = LL_GPIO_PIN_0;
  LL_GPIO_Init(GPIOF, &pinInit);
  stm32_gpio_enable_clock(GPIOG);
  pinInit.Pin = LL_GPIO_PIN_11|LL_GPIO_PIN_14;
  LL_GPIO_Init(GPIOG, &pinInit);
}

constexpr uint8_t n_switches = 10;
constexpr uint8_t n_fct_switches = 6;

constexpr swconfig_t _switch_default_config = (swconfig_t)0
    | ((swconfig_t)SWITCH_2POS << (0 * SW_CFG_BITS))
    | ((swconfig_t)SWITCH_2POS << (1 * SW_CFG_BITS))
    | ((swconfig_t)SWITCH_3POS << (2 * SW_CFG_BITS))
    | ((swconfig_t)SWITCH_3POS << (3 * SW_CFG_BITS))
    | ((swconfig_t)SWITCH_2POS << (4 * SW_CFG_BITS))
    | ((swconfig_t)SWITCH_2POS << (5 * SW_CFG_BITS))
    | ((swconfig_t)SWITCH_TOGGLE << (6 * SW_CFG_BITS))
    | ((swconfig_t)SWITCH_TOGGLE << (7 * SW_CFG_BITS))
    | ((swconfig_t)SWITCH_TOGGLE << (8 * SW_CFG_BITS))
    | ((swconfig_t)SWITCH_TOGGLE << (9 * SW_CFG_BITS))
;

const switch_display_pos_t _switch_display[] = {
    { 0, 0 },
    { 1, 0 },
    { 0, 1 },
    { 1, 1 },
    { 0, 2 },
    { 1, 2 },
    { 0, 3 },
    { 1, 3 },
    { 0, 4 },
    { 1, 4 },
};
