//----------------------------------------------------------------------------
///
/// \file   app_shared.h
///
/// \brief  Json structures for testing mode 'shared'
///
/// \date   20180910
/// \author Maximilian Seesslen <mes@seesslen.net>
///
//----------------------------------------------------------------------------


const char *boardButtons = R"(
{
   "name": "A Button",
   "peripheries": [
      { "type": "GPIO", "periphery": "PB3", "irqs": "IrqA"},
      { "type": "GPIO", "periphery": "PB4", "irqs": "IrqB IrqD"},
      { "type": "GPIO", "periphery": "PB5", "irqs": "IrqC"},
      {
         "type": "BUTTON", "name": "BUTTON", "mode": "fabricate",
         "consumes": [
            { "type": "GPIO", "name": "SW" }
         ]
      }
   ]
})";

const char *boardSingleSpi = R"(
{
   "name": "Single shared SPI",
   "include": "tests.json",
   "peripheries": [
      { "type": "GPIO", "periphery": "PB3"},
      { "type": "GPIO", "periphery": "PB5"},
      { "type": "GPIO", "periphery": "PB4"},
      { "type": "SPI", "periphery": "SPI1", "name": "Spi1", "mode": "shared",
         "consumes": [
            { "periphery": "PB3",   "name": "SCK" },
            { "periphery": "PB5",   "name": "MOSI" },
            { "periphery": "PB4",   "name": "MISO" }
         ]
      },
      {
         "type": "GDISPLAY_SHARED", "name": "GDISPLAY_SHARED", "mode": "fabricate",
         "consumes": [
             { "type": "SPI",   "name": "spi", "mode": "shared" }
         ]
      },
      {
        "type": "GDISPLAY_EXCLUSIVE", "name": "GDISPLAY_EXCLUSIVE", "mode": "fabricate",
        "consumes": [
            { "type": "SPI",   "name": "spi" }
        ]
      }
   ]
})";

const char *boardDualSpi = R"(
{
   "name": "Single shared SPI",
   "peripheries": [
      { "type": "GPIO", "periphery": "PB3"},
      { "type": "GPIO", "periphery": "PB5"},
      { "type": "GPIO", "periphery": "PB4"},
      { "type": "GPIO", "periphery": "PA3"},
      { "type": "GPIO", "periphery": "PA5"},
      { "type": "GPIO", "periphery": "PA4"},
      { "type": "SPI", "periphery": "SPI1", "name": "Spi1", "mode": "shared",
         "consumes": [
            { "periphery": "PB3",   "name": "SCK" },
            { "periphery": "PB5",   "name": "MOSI" },
            { "periphery": "PB4",   "name": "MISO" }
         ]
      },
      { "type": "SPI", "periphery": "SPI2", "name": "Spi2", "mode": "shared",
         "consumes": [
            { "periphery": "PA3",   "name": "SCK" },
            { "periphery": "PA5",   "name": "MOSI" },
            { "periphery": "PA4",   "name": "MISO" }
         ]
      },
      {
         "type": "GDISPLAY_SHARED", "name": "GDISPLAY_SHARED", "mode": "fabricate",
         "consumes": [
             { "type": "SPI",   "name": "spi", "mode": "shared" }
         ]
      },
      {
        "type": "GDISPLAY_EXCLUSIVE", "name": "GDISPLAY_EXCLUSIVE", "mode": "fabricate",
        "consumes": [
            { "type": "SPI",   "name": "spi" }
        ]
      }
   ]
})";

const char *boardSpiI2c = R"(
{
   "name": "Single shared SPI",
   "peripheries": [
      { "type": "GPIO", "periphery": "PA3"},
      { "type": "GPIO", "periphery": "PA4"},
      { "type": "GPIO", "periphery": "PA5"},
      { "type": "GPIO", "periphery": "PA6"},
      { "type": "SPI", "periphery": "SPI2", "name": "Spi2", "mode": "shared",
         "consumes": [
            { "periphery": "PA3",   "name": "SCK" },
            { "periphery": "PA5",   "name": "MOSI" },
            { "periphery": "PA4",   "name": "MISO" }
         ]
      },
      {
         "type": "I2C", "periphery": "I2C1.a", "irqs": "", "mode": "shared",
         "consumes": [
             { "periphery": "PA6",   "name": "SCL" },
             { "periphery": "PA5",   "name": "SDA" }
         ]
      },
      {
         "type": "GDISPLAY", "name": "GDISPLAY_SHARED", "mode": "fabricate",
         "consumes": [
            { "type": "SPI",   "name": "spi", "mode": "shared" }
         ]
      }
   ]
})";

const char *boardFabricate = R"(
{
   "name": "fabricated nonsense",
   "peripheries": [
      { "type": "NC", "name": "NC", "mode": "fabricate" }
   ]
})";

const char *boardDma = R"(
{
   "name": "fabricated nonsense",
   "peripheries": [
      {   "type": "DMA", "name": "inherit",
         "provides" : [
             { "type": "DMACH", "periphery": "DMA1CH1",   "name": "Dma Channel 1", "irq": "foooo" },
             { "type": "DMACH", "periphery": "DMA1CH2",   "name": "Dma Channel 2", "irq": "foooo" },
             { "type": "DMACH", "periphery": "DMA1CH3",   "name": "Dma Channel 3", "irq": "foooo" },
             { "type": "DMACH", "periphery": "DMA1CH4",   "name": "Dma Channel 4", "irq": "foooo" },
             { "type": "DMACH", "periphery": "DMA1CH5",   "name": "Dma Channel 5", "irq": "foooo" },
             { "type": "DMACH", "periphery": "DMA1CH6",   "name": "Dma Channel 6", "irq": "foooo" },
             { "type": "DMACH", "periphery": "DMA1CH7",   "name": "Dma Channel 7", "irq": "foooo" },
             { "type": "DMACH", "periphery": "DMA1CH8",   "name": "Dma Channel 8", "irq": "foooo" }
         ]
      }
   ]
})";

const char *appButtons =
R"({
   "name": "Button",
   "periphery": [
      { "type": "BUTTON", "name": "sw1", "useIrq": "yes" },
      { "type": "BUTTON", "name": "sw2", "useIrq": "yes" }
   ]
})";


const char *appDualDisplayShared =
R"({
   "name": "DualDisplay",
   "periphery": [
      { "type": "GDISPLAY_SHARED", "name": "nh1", "prefered_mi": "GDISPLAY B_SPI1 PB0 PB1", "class": "CGraphicDisplayNh" },
      { "type": "GDISPLAY_SHARED", "name": "nh2", "prefered_mi": "GDISPLAY B_SPI1 PB0 PB1", "class": "CGraphicDisplayNh" }
   ]
})";

const char *appDualDisplayExclusive =
R"({
   "name": "DualDisplay",
   "periphery": [
      { "type": "GDISPLAY_EXCLUSIVE", "name": "nh3", "prefered_mi": "GDISPLAY B_SPI1 PB0 PB1", "class": "CGraphicDisplayNh" },
      { "type": "GDISPLAY_EXCLUSIVE", "name": "nh4", "prefered_mi": "GDISPLAY B_SPI1 PB0 PB1", "class": "CGraphicDisplayNh" }
   ]
})";

const char *appDualDisplayUnsharedShared =
R"({
   "name": "DualDisplay",
   "periphery": [
      { "type": "GDISPLAY_EXCLUSIVE", "name": "nh5", "prefered_mi": "GDISPLAY B_SPI1 PB0 PB1", "class": "CGraphicDisplayNh" },
      { "type": "GDISPLAY_SHARED", "name": "nh6", "prefered_mi": "GDISPLAY B_SPI1 PB0 PB1", "class": "CGraphicDisplayNh" }
   ]
})";

const char *appDualDisplayShEx =
R"({
   "name": "DualDisplay",
   "periphery": [
      { "type": "GDISPLAY_SHARED", "name": "nh7", "prefered_mi": "GDISPLAY B_SPI1 PB0 PB1", "class": "CGraphicDisplayNh" },
      { "type": "GDISPLAY_EXCLUSIVE", "name": "nh8", "prefered_mi": "GDISPLAY B_SPI1 PB0 PB1", "class": "CGraphicDisplayNh" }
   ]
})";


const char *appDualDisplaySharedExclusive =
R"({
   "name": "DualDisplay",
   "periphery": [
      { "type": "GDISPLAY_SHARED", "name": "nh7", "prefered_mi": "GDISPLAY B_SPI1 PB0 PB1", "class": "CGraphicDisplayNh" },
      { "type": "GDISPLAY_SHARED", "name": "nh8", "prefered_mi": "GDISPLAY B_SPI1 PB0 PB1", "class": "CGraphicDisplayNh", "mode": "exclusive" }
   ]
})";

const char *appSpiI2C =
R"({
   "name": "DualDisplay",
   "periphery": [
      { "type": "I2C", "name": "i2c", "mode": "shared" },
      { "type": "SPI", "name": "spi", "mode": "shared" }
   ]
})";

const char *appDisplayI2C =
R"({
   "name": "DualDisplay",
   "periphery": [
      { "type": "GDISPLAY", "name": "display" },
      { "type": "I2C", "name": "i2c", "mode": "shared" }
   ]
})";

const char *appFabricate =
R"({
   "name": "DualDisplay",
   "periphery": [
      { "type": "NC", "name": "nc1" },
      { "type": "NC", "name": "nc2" },
      { "type": "NC", "name": "nc3" },
      { "type": "NC", "name": "nc4" }
   ]
})";

const char *appDma =
R"({
   "name": "Dma",
   "periphery": [
      { "type": "DMA", "name": "dma1" },
      { "type": "DMACH", "name": "dmach1" },
      { "type": "DMACH", "name": "dmach2" },
      { "type": "DMACH", "name": "dmach3" }
   ]
})";


const char *boardSingleGpio = R"(
{
   "name": "Single shared SPI",
   "include": "tests.json",
   "peripheries": [
      { "type": "GPIO", "periphery": "PA1"}
   ]
})";


const char *appSingleGpio =
R"({
   "name": "SingleGpio",
   "periphery": [
      { "type": "GPIO", "name": "pin1" }
   ]
})";


const char *boardSinglePwm = R"(
{
   "name": "Single shared SPI",
   "peripheries": [
      { "type": "GPIO",   "periphery": "PB4",  "pin": "D12", "irqs": "EXTI4_IRQHandler" },
      { "type": "TIMER",   "periphery": "TIM3", "irqs": "TIM3_IRQHandler", "mode": "shared" },
      {
         "type": "PWM",
         "consumes": [
            { "periphery": "PB4",     "name": "TIM3_CH1_OUT" },
            { "periphery": "TIM3",    "name": "TIM3_CH1_TIMER", "irqs": "yes", "useIrq": "yes", "mode": "shared" }
         ],
         "arguments": [ { "value": "eTimerChannel1", "position": 3 } ]
     },
     {
        "type": "PWM",
        "consumes": [
           { "periphery": "TIM3",    "name": "TIM3_CH1_TIMER", "irqs": "yes", "useIrq": "yes", "mode": "shared" },
           { "periphery": "PB9",     "name": "TIM3_CH1_OUT" }
        ],
        "arguments": [ { "value": "eTimerChannel1", "position": 3 } ]
    }
   ]
})";

const char *appSinglePwm =
R"({
   "name": "SinglePwm",
   "periphery": [
      { "type": "PWM", "name": "fooo" }
   ]
})";


const char *boardSingleDac =
R"({
   "name": "SingleDac",
   "peripheries": [
      {
         "type": "TIMER",   "periphery": "TIM6", "irqs": "TIM6_DAC1_IRQHandler TIM6_DAC1_IRQHandler_tim", "mode": "shared"
      },
      {
         "type": "GPIO",   "periphery": "PA4",  "pin": "A3", "irqs": "EXTI4_IRQHandler"
      },
      {
         "type": "DMA", "name": "inherit",
          "provides" : [
              { "type": "DMACH", "periphery": "DMA1CH1",   "name": "Dma Channel 1", "irq": "foooo" },
              { "type": "DMACH", "periphery": "DMA1CH2",   "name": "Dma Channel 2", "irq": "foooo" },
              { "type": "DMACH", "periphery": "DMA1CH3",   "name": "Dma Channel 3", "irq": "foooo" },
              { "type": "DMACH", "periphery": "DMA1CH4",   "name": "Dma Channel 4", "irq": "foooo" },
              { "type": "DMACH", "periphery": "DMA1CH5",   "name": "Dma Channel 5", "irq": "foooo" },
              { "type": "DMACH", "periphery": "DMA1CH6",   "name": "Dma Channel 6", "irq": "foooo" },
              { "type": "DMACH", "periphery": "DMA1CH7",   "name": "Dma Channel 7", "irq": "foooo" },
              { "type": "DMACH", "periphery": "DMA1CH8",   "name": "Dma Channel 8", "irq": "foooo" }
          ]
      },
      {
         "type": "DAC", "periphery": "DAC1", "irqs": "TIM6_DAC1_IRQHandler TIM6_DAC1_IRQHandler_dac DMA1_Channel3_IRQHandler",
         "consumes": [
           { "periphery": "DMA1CH3", "name": "LeftDma", "irqs": "Fooo" },
           { "periphery": "TIM6",    "name": "LeftTimer", "mode": "shared" }
         ]
       },
      {
          "type": "DAC_LINE", "name": "DAC_LINE1",
          "consumes": [
              { "periphery": "DAC1",    "mode": "shared" },
              { "periphery": "PA4" }
          ]
      }
   ]
})";


const char *appSingleDac =
R"({
   "name": "SingleDac",
   "periphery": [
      { "type": "DMA", "name": "fooo" },
      { "type": "DAC_LINE", "name": "fooo" }
   ]
})";


const char *boardSingleAdc =
R"({
   "name": "SingleAdc",
   "peripheries": [
      {
         "type": "GPIO",   "periphery": "PA4",  "pin": "A3", "irqs": "EXTI4_IRQHandler"
      },
      {
         "type": "ADC", "periphery": "ADC1", "irqs": "", "mode": "shared"
       },
      {
          "type": "ADC_LINE", "name": "ADC_LINE1",
          "consumes": [
              { "periphery": "ADC1",    "mode": "shared" },
              { "periphery": "PA4" }
          ]
      }
   ]
})";


const char *appSingleAdc =
R"({
   "name": "SingleAdc",
   "periphery": [
      { "type": "ADC_LINE", "name": "fooo" }
   ]
})";


const char *board2Gpios =
R"({
   "name": "two_gpios",
   "peripheries": [
      { "type": "GPIO",   "periphery": "PA1",  "pin": "A1", "irqs": "EXTI4_IRQHandler" },
      { "type": "GPIO",   "periphery": "PA2",  "pin": "A2", "irqs": "EXTI4_IRQHandler" },
      {
          "type": "BUTTON", "name": "BUTTON", "mode": "fabricate",
          "consumes": [   { "type": "GPIO", "name": "SW",  "useIrq": "yes" }   ]
      }
   ]
})";


const char *app2GpiosPrefered =
R"({
   "name": "SingleAdc",
   "periphery": [
      { "type": "BUTTON", "name": "B1", "prefered_two_gpios": "GPIO PA1" },
      { "type": "BUTTON", "name": "B2", "prefered_two_gpios": "GPIO PA2" }
   ]
})";

const char *boardPwmPrefered =
R"({
   "name": "pwm_prefered",
   "peripheries": [
      {
          "type": "PWM", "name": "PWM_TIM1_PA8",
          "consumes": [
              { "periphery": "PA8",     "name": "TIM1_CH1" },
              { "periphery": "TIM1",    "name": "TIM1_PWM", "irqs": "yes", "mode": "shared" }
          ],
          "arguments": [ { "value": "eTimerChannel1", "position": 3 } ]
      },
      {
          "type": "PWM", "name": "PWM_TIM1_PA9",
          "consumes": [
              { "periphery": "PA9",     "name": "TIM1_CH1" },
              { "periphery": "TIM1",    "name": "TIM1_PWM", "irqs": "yes", "mode": "shared" }
          ],
          "arguments": [ { "value": "eTimerChannel1", "position": 3 } ]
      },
      {
         "type": "GPIO",   "periphery": "PA8",  "pin": "A8", "irqs": "EXTI4_IRQHandler"
      },
      {
         "type": "GPIO",   "periphery": "PA9",  "pin": "A9", "irqs": "EXTI4_IRQHandler"
      },
      {
         "type": "TIMER",   "periphery": "TIM1", "irqs": "TIM6_DAC1_IRQHandler TIM6_DAC1_IRQHandler_tim", "mode": "shared"
      }
   ]
})";


const char *appPwmPrefered =
R"({
   "name": "pwm_prefered",
   "periphery": [
      { "type": "PWM", "name": "B1", "prefered_test": "PWM_TIM1_PA9 PA9 TIM1" },
      { "type": "PWM", "name": "B2", "prefered_test": "PWM_TIM1_PA8 PA8 TIM1" }
   ]
})";


const char *boardEadisplayPrefered =
R"({
   "name": "eadisplay_prefered",
   "peripheries": [
      {
          "type": "SPI", "name": "SPI1.a",
          "consumes": [
              { "periphery": "PA5",     "name": "CLK" },
              { "periphery": "PA7",     "name": "MOSI" },
              { "periphery": "PA6",     "name": "MISO" }
          ]
      },
      {
          "type": "EADISPLAY", "name": "EADISPLAY",
          "consumes": [
              { "type": "SPI",     "mode": "shared" },
              { "type": "GPIO",     "name": "CS" },
              { "type": "GPIO",    "name": "RS" }
          ]
      },
      { "type": "GPIO",   "periphery": "PA5" },
      { "type": "GPIO",   "periphery": "PA6" },
      { "type": "GPIO",   "periphery": "PA7" },
      { "type": "GPIO",   "periphery": "PF0" },
      { "type": "GPIO",   "periphery": "PF1" }
   ]
})";


const char *appEadisplayPrefered =
R"({
   "name": "eadisplay_prefered",
   "periphery": [
      { "type": "EADISPLAY", "name": "DIsplay", "prefered_test": "EADISPLAY SPI1.a PA5 PA7 PA6 PF0 PF1" }
   ]
})";


const char *board2EadisplayPrefered =
R"({
   "name": "eadisplay_prefered",
   "peripheries": [
      {
          "type": "SPI", "name": "SPI1.a", "mode": "shared",
          "consumes": [
              { "periphery": "PA5",     "name": "CLK" },
              { "periphery": "PA7",     "name": "MOSI" },
              { "periphery": "PA6",     "name": "MISO" }
          ]
      },
      {
          "type": "EADISPLAY", "name": "EADISPLAY", "mode": "fabricate",
          "consumes": [
              { "type": "SPI",     "mode": "shared" },
              { "type": "GPIO",     "name": "CS" },
              { "type": "GPIO",    "name": "RS" }
          ]
      },
      { "type": "GPIO",   "periphery": "PA5" },
      { "type": "GPIO",   "periphery": "PA6" },
      { "type": "GPIO",   "periphery": "PA7" },
      { "type": "GPIO",   "periphery": "PF0" },
      { "type": "GPIO",   "periphery": "PF1" },
      { "type": "GPIO",   "periphery": "PF2" },
      { "type": "GPIO",   "periphery": "PF3" }
   ]
})";


const char *app2EadisplayPrefered =
R"({
   "name": "eadisplay_prefered",
   "periphery": [
      { "type": "EADISPLAY", "name": "DIsplay1", "prefered_test": "EADISPLAY SPI1.a PA5 PA7 PA6 PF0 PF1" },
      { "type": "EADISPLAY", "name": "DIsplay2", "prefered_test": "EADISPLAY SPI1.a PA5 PA7 PA6 PF2 PF3" }
   ]
})";



//---fin-----------------------------------------------------------------------
