/***********************************************************************************************************************
 * This file was generated by the MCUXpresso Config Tools. Any manual edits made to this file
 * will be overwritten if the respective MCUXpresso Config Tools is used to update this file.
 **********************************************************************************************************************/

/* clang-format off */
/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
!!GlobalInfo
product: Peripherals v14.0
processor: LPC54616J512
package_id: LPC54616J512BD100
mcu_data: ksdk2_0
processor_version: 15.0.1
functionalGroups:
- name: BOARD_InitPeripherals
  UUID: 16d81a14-653b-45b9-b560-00d93273e611
  called_from_default_init: true
  selectedCore: core0
 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/

/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
component:
- type: 'system'
- type_id: 'system_54b53072540eeeb8f8e9343e71f28176'
- global_system_definitions:
  - user_definitions: ''
  - user_includes: ''
  - global_init: ''
 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/

/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
component:
- type: 'uart_cmsis_common'
- type_id: 'uart_cmsis_common_9cb8e302497aa696fdbb5a4fd622c2a8'
- global_USART_CMSIS_common:
  - quick_selection: 'default'
 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/

/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
component:
- type: 'gpio_adapter_common'
- type_id: 'gpio_adapter_common_57579b9ac814fe26bf95df0a384c36b6'
- global_gpio_adapter_common:
  - quick_selection: 'default'
 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
/* clang-format on */

/***********************************************************************************************************************
 * Included files
 **********************************************************************************************************************/
#include "peripherals.h"

/***********************************************************************************************************************
 * BOARD_InitPeripherals functional group
 **********************************************************************************************************************/
/***********************************************************************************************************************
 * NVIC initialization code
 **********************************************************************************************************************/
/* clang-format off */
/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
instance:
- name: 'NVIC'
- type: 'nvic'
- mode: 'general'
- custom_name_enabled: 'false'
- type_id: 'nvic_57b5eef3774cc60acaede6f5b8bddc67'
- functional_group: 'BOARD_InitPeripherals'
- peripheral: 'NVIC'
- config_sets:
  - nvic:
    - interrupt_table: []
    - interrupts: []
 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
/* clang-format on */

/* Empty initialization function (commented out)
static void NVIC_init(void) {
} */

/***********************************************************************************************************************
 * CAN0 initialization code
 **********************************************************************************************************************/
/* clang-format off */
/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
instance:
- name: 'CAN0'
- type: 'mcan'
- mode: 'interrupts'
- custom_name_enabled: 'false'
- type_id: 'mcan_adadbdd1c85d1f042225de02d2c42c05'
- functional_group: 'BOARD_InitPeripherals'
- peripheral: 'CAN0'
- config_sets:
  - interruptsCfg:
    - txBufferInterruptSources:
      - txBufferInterruptSources_L:
        - 0: 'disabled'
        - 1: 'disabled'
        - 2: 'disabled'
        - 3: 'disabled'
        - 4: 'disabled'
        - 5: 'disabled'
        - 6: 'disabled'
        - 7: 'disabled'
        - 8: 'disabled'
        - 9: 'disabled'
        - 10: 'disabled'
        - 11: 'disabled'
        - 12: 'disabled'
        - 13: 'disabled'
        - 14: 'disabled'
        - 15: 'disabled'
      - txBufferInterruptSources_H:
        - 0: 'disabled'
        - 1: 'disabled'
        - 2: 'disabled'
        - 3: 'disabled'
        - 4: 'disabled'
        - 5: 'disabled'
        - 6: 'disabled'
        - 7: 'disabled'
        - 8: 'disabled'
        - 9: 'disabled'
        - 10: 'disabled'
        - 11: 'disabled'
        - 12: 'disabled'
        - 13: 'disabled'
        - 14: 'disabled'
        - 15: 'disabled'
    - interrupts:
      - 0:
        - interrupts: ''
        - enable_irq: 'false'
        - interrupt_line:
          - IRQn: 'CAN0_IRQ0_IRQn'
          - enable_interrrupt: 'enabled'
          - enable_priority: 'false'
          - priority: '0'
          - enable_custom_name: 'false'
      - 1:
        - interrupts: ''
        - enable_irq: 'false'
        - interrupt_line:
          - IRQn: 'CAN0_IRQ1_IRQn'
          - enable_interrrupt: 'enabled'
          - enable_priority: 'false'
          - priority: '0'
          - enable_custom_name: 'false'
    - quick_selection: 'default'
  - fsl_mcan:
    - mcanConfig:
      - clockSource: 'FunctionClock'
      - clockSourceFreq: 'ClocksTool_DefaultInit'
      - baudRateA: '500000'
      - baudRateD: '1000000'
      - enableCanfdNormal: 'false'
      - enableCanfdSwitch: 'false'
      - loopBackBusMonMode: 'kMCAN_disabled'
      - setNormalOperation: 'true'
      - nominalBitTiming:
        - seg1: '11'
        - seg2: '4'
        - rJumpwidth: '4'
        - bitTime: []
      - dataBitTiming:
        - seg1: '11'
        - seg2: '4'
        - rJumpwidth: '4'
        - bitTime: []
      - timingConfig: []
    - messagesConfig:
      - enable_custom_name: 'false'
      - allocateRAM: 'true'
      - stdFilter:
        - listSize: '1'
        - remFrame: 'kMCAN_rejectFrame'
        - nmFrame: 'kMCAN_reject0'
      - extFilter:
        - listSize: '0'
        - remFrame: 'kMCAN_rejectFrame'
        - nmFrame: 'kMCAN_reject0'
      - rxFifo0:
        - elementSize: '1'
        - watermark: '0'
        - opmode: 'kMCAN_FifoBlocking'
        - datafieldSize: 'kMCAN_8ByteDatafield'
      - rxFifo1:
        - elementSize: '0'
        - watermark: '0'
        - opmode: 'kMCAN_FifoBlocking'
        - datafieldSize: 'kMCAN_8ByteDatafield'
      - rxBuffer:
        - elementSize: '0'
        - datafieldSize: 'kMCAN_8ByteDatafield'
      - txFifo:
        - elementSize: '0'
        - watermark: '0'
      - txBuffer:
        - dedicatedSize: '1'
        - fqSize: '0'
        - mode: 'kMCAN_txFifo'
        - datafieldSize: 'kMCAN_8ByteDatafield'
    - stdFilters: []
    - extFilters: []
    - quick_selection: 'default'
 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
/* clang-format on */
const mcan_config_t CAN0_config = {
  .baudRateA = 500000UL,
  .baudRateD = 1000000UL,
  .enableCanfdNormal = false,
  .enableCanfdSwitch = false,
  .enableLoopBackInt = false,
  .enableLoopBackExt = false,
  .enableBusMon = false,
  .timingConfig = {
    .preDivider = 6,
    .rJumpwidth = 3,
    .seg1 = 10,
    .seg2 = 3,
    .datapreDivider = 2,
    .datarJumpwidth = 3,
    .dataseg1 = 10,
    .dataseg2 = 3
  }
};
/* Allocation of the Message RAM in memory that is alligned to 16 bits. */
SDK_ALIGN(uint32_t CAN0_RAM_BASE_ADDRESS[CAN0_MESSAGE_RAM_SIZE], CAN0_BASE_ADDRESS_ALIGN_SIZE);
const mcan_frame_filter_config_t CAN0_std_filter_config = {
  .address = 0,
  .listSize = 1UL,
  .idFormat = kMCAN_FrameIDStandard,
  .remFrame = kMCAN_rejectFrame,
  .nmFrame = kMCAN_reject0
};
const mcan_frame_filter_config_t CAN0_ext_filter_config = {
  .address = 4,
  .listSize = 0UL,
  .idFormat = kMCAN_FrameIDExtend,
  .remFrame = kMCAN_rejectFrame,
  .nmFrame = kMCAN_reject0
};
const mcan_rx_fifo_config_t CAN0_rx_fifo0_config = {
  .address = 4,
  .elementSize = 1UL,
  .watermark = 0UL,
  .opmode = kMCAN_FifoBlocking,
  .datafieldSize = kMCAN_8ByteDatafield
};
const mcan_rx_fifo_config_t CAN0_rx_fifo1_config = {
  .address = 20,
  .elementSize = 0UL,
  .watermark = 0UL,
  .opmode = kMCAN_FifoBlocking,
  .datafieldSize = kMCAN_8ByteDatafield
};
const mcan_rx_buffer_config_t CAN0_rx_buffers_config = {
  .address = 20,
  .datafieldSize = kMCAN_8ByteDatafield
};
const mcan_tx_fifo_config_t CAN0_tx_event_fifo_config = {
  .address = 20,
  .elementSize = 0UL,
  .watermark = 0UL
};
const mcan_tx_buffer_config_t CAN0_tx_buffers_config = {
  .address = 20,
  .dedicatedSize = 1UL,
  .fqSize = 0UL,
  .mode = kMCAN_txFifo,
  .datafieldSize = kMCAN_8ByteDatafield
};

static void CAN0_init(void) {
  /* MCAN initialization */
  MCAN_Init(CAN0_PERIPHERAL, &CAN0_config, CAN0_CLOCK_SOURCE);
  /* Message RAM initialization */
  memset(CAN0_RAM_BASE_ADDRESS, 0,CAN0_MESSAGE_RAM_SIZE * sizeof(uint32_t));
  MCAN_SetMsgRAMBase(CAN0_PERIPHERAL, (uint32_t)CAN0_RAM_BASE_ADDRESS);
  /* Configuration of the standard filter list */
  MCAN_SetFilterConfig(CAN0_PERIPHERAL, &CAN0_std_filter_config);
  /* Configuration of the extended filter list */
  MCAN_SetFilterConfig(CAN0_PERIPHERAL, &CAN0_ext_filter_config);
  /* Configuration of Rx FIFO 0 */
  MCAN_SetRxFifo0Config(CAN0_PERIPHERAL, &CAN0_rx_fifo0_config);
  /* Configuration of Rx FIFO 1 */
  MCAN_SetRxFifo1Config(CAN0_PERIPHERAL, &CAN0_rx_fifo1_config);
  /* Configuration of Rx buffers */
  MCAN_SetRxBufferConfig(CAN0_PERIPHERAL, &CAN0_rx_buffers_config);
  /* Configuration of Tx event FIFO */
  MCAN_SetTxEventFifoConfig(CAN0_PERIPHERAL, &CAN0_tx_event_fifo_config);
  /* Configuration of Tx buffers and FIFO/Queue */
  MCAN_SetTxBufferConfig(CAN0_PERIPHERAL, &CAN0_tx_buffers_config);
  /* Setting of the CAN normal mode to start communication */
  MCAN_EnterNormalMode(CAN0_PERIPHERAL);
}

/***********************************************************************************************************************
 * CAN1 initialization code
 **********************************************************************************************************************/
/* clang-format off */
/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
instance:
- name: 'CAN1'
- type: 'mcan'
- mode: 'interrupts'
- custom_name_enabled: 'false'
- type_id: 'mcan_adadbdd1c85d1f042225de02d2c42c05'
- functional_group: 'BOARD_InitPeripherals'
- peripheral: 'CAN1'
- config_sets:
  - interruptsCfg:
    - txBufferInterruptSources:
      - txBufferInterruptSources_L:
        - 0: 'disabled'
        - 1: 'disabled'
        - 2: 'disabled'
        - 3: 'disabled'
        - 4: 'disabled'
        - 5: 'disabled'
        - 6: 'disabled'
        - 7: 'disabled'
        - 8: 'disabled'
        - 9: 'disabled'
        - 10: 'disabled'
        - 11: 'disabled'
        - 12: 'disabled'
        - 13: 'disabled'
        - 14: 'disabled'
        - 15: 'disabled'
      - txBufferInterruptSources_H:
        - 0: 'disabled'
        - 1: 'disabled'
        - 2: 'disabled'
        - 3: 'disabled'
        - 4: 'disabled'
        - 5: 'disabled'
        - 6: 'disabled'
        - 7: 'disabled'
        - 8: 'disabled'
        - 9: 'disabled'
        - 10: 'disabled'
        - 11: 'disabled'
        - 12: 'disabled'
        - 13: 'disabled'
        - 14: 'disabled'
        - 15: 'disabled'
    - interrupts:
      - 0:
        - interrupts: ''
        - enable_irq: 'false'
        - interrupt_line:
          - IRQn: 'CAN1_IRQ0_IRQn'
          - enable_interrrupt: 'enabled'
          - enable_priority: 'false'
          - priority: '0'
          - enable_custom_name: 'false'
      - 1:
        - interrupts: ''
        - enable_irq: 'false'
        - interrupt_line:
          - IRQn: 'CAN1_IRQ1_IRQn'
          - enable_interrrupt: 'enabled'
          - enable_priority: 'false'
          - priority: '0'
          - enable_custom_name: 'false'
    - quick_selection: 'default'
  - fsl_mcan:
    - mcanConfig:
      - clockSource: 'FunctionClock'
      - clockSourceFreq: 'ClocksTool_DefaultInit'
      - baudRateA: '500000'
      - baudRateD: '1000000'
      - enableCanfdNormal: 'false'
      - enableCanfdSwitch: 'false'
      - loopBackBusMonMode: 'kMCAN_disabled'
      - setNormalOperation: 'true'
      - nominalBitTiming:
        - seg1: '11'
        - seg2: '4'
        - rJumpwidth: '4'
        - bitTime: []
      - dataBitTiming:
        - seg1: '11'
        - seg2: '4'
        - rJumpwidth: '4'
        - bitTime: []
      - timingConfig: []
    - messagesConfig:
      - enable_custom_name: 'false'
      - allocateRAM: 'true'
      - stdFilter:
        - listSize: '1'
        - remFrame: 'kMCAN_rejectFrame'
        - nmFrame: 'kMCAN_reject0'
      - extFilter:
        - listSize: '0'
        - remFrame: 'kMCAN_rejectFrame'
        - nmFrame: 'kMCAN_reject0'
      - rxFifo0:
        - elementSize: '1'
        - watermark: '0'
        - opmode: 'kMCAN_FifoBlocking'
        - datafieldSize: 'kMCAN_8ByteDatafield'
      - rxFifo1:
        - elementSize: '0'
        - watermark: '0'
        - opmode: 'kMCAN_FifoBlocking'
        - datafieldSize: 'kMCAN_8ByteDatafield'
      - rxBuffer:
        - elementSize: '0'
        - datafieldSize: 'kMCAN_8ByteDatafield'
      - txFifo:
        - elementSize: '0'
        - watermark: '0'
      - txBuffer:
        - dedicatedSize: '1'
        - fqSize: '0'
        - mode: 'kMCAN_txFifo'
        - datafieldSize: 'kMCAN_8ByteDatafield'
    - stdFilters: []
    - extFilters: []
    - quick_selection: 'default'
 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
/* clang-format on */
const mcan_config_t CAN1_config = {
  .baudRateA = 500000UL,
  .baudRateD = 1000000UL,
  .enableCanfdNormal = false,
  .enableCanfdSwitch = false,
  .enableLoopBackInt = false,
  .enableLoopBackExt = false,
  .enableBusMon = false,
  .timingConfig = {
    .preDivider = 6,
    .rJumpwidth = 3,
    .seg1 = 10,
    .seg2 = 3,
    .datapreDivider = 2,
    .datarJumpwidth = 3,
    .dataseg1 = 10,
    .dataseg2 = 3
  }
};
/* Allocation of the Message RAM in memory that is alligned to 16 bits. */
SDK_ALIGN(uint32_t CAN1_RAM_BASE_ADDRESS[CAN1_MESSAGE_RAM_SIZE], CAN1_BASE_ADDRESS_ALIGN_SIZE);
const mcan_frame_filter_config_t CAN1_std_filter_config = {
  .address = 0,
  .listSize = 1UL,
  .idFormat = kMCAN_FrameIDStandard,
  .remFrame = kMCAN_rejectFrame,
  .nmFrame = kMCAN_reject0
};
const mcan_frame_filter_config_t CAN1_ext_filter_config = {
  .address = 4,
  .listSize = 0UL,
  .idFormat = kMCAN_FrameIDExtend,
  .remFrame = kMCAN_rejectFrame,
  .nmFrame = kMCAN_reject0
};
const mcan_rx_fifo_config_t CAN1_rx_fifo0_config = {
  .address = 4,
  .elementSize = 1UL,
  .watermark = 0UL,
  .opmode = kMCAN_FifoBlocking,
  .datafieldSize = kMCAN_8ByteDatafield
};
const mcan_rx_fifo_config_t CAN1_rx_fifo1_config = {
  .address = 20,
  .elementSize = 0UL,
  .watermark = 0UL,
  .opmode = kMCAN_FifoBlocking,
  .datafieldSize = kMCAN_8ByteDatafield
};
const mcan_rx_buffer_config_t CAN1_rx_buffers_config = {
  .address = 20,
  .datafieldSize = kMCAN_8ByteDatafield
};
const mcan_tx_fifo_config_t CAN1_tx_event_fifo_config = {
  .address = 20,
  .elementSize = 0UL,
  .watermark = 0UL
};
const mcan_tx_buffer_config_t CAN1_tx_buffers_config = {
  .address = 20,
  .dedicatedSize = 1UL,
  .fqSize = 0UL,
  .mode = kMCAN_txFifo,
  .datafieldSize = kMCAN_8ByteDatafield
};

static void CAN1_init(void) {
  /* MCAN initialization */
  MCAN_Init(CAN1_PERIPHERAL, &CAN1_config, CAN1_CLOCK_SOURCE);
  /* Message RAM initialization */
  memset(CAN1_RAM_BASE_ADDRESS, 0,CAN1_MESSAGE_RAM_SIZE * sizeof(uint32_t));
  MCAN_SetMsgRAMBase(CAN1_PERIPHERAL, (uint32_t)CAN1_RAM_BASE_ADDRESS);
  /* Configuration of the standard filter list */
  MCAN_SetFilterConfig(CAN1_PERIPHERAL, &CAN1_std_filter_config);
  /* Configuration of the extended filter list */
  MCAN_SetFilterConfig(CAN1_PERIPHERAL, &CAN1_ext_filter_config);
  /* Configuration of Rx FIFO 0 */
  MCAN_SetRxFifo0Config(CAN1_PERIPHERAL, &CAN1_rx_fifo0_config);
  /* Configuration of Rx FIFO 1 */
  MCAN_SetRxFifo1Config(CAN1_PERIPHERAL, &CAN1_rx_fifo1_config);
  /* Configuration of Rx buffers */
  MCAN_SetRxBufferConfig(CAN1_PERIPHERAL, &CAN1_rx_buffers_config);
  /* Configuration of Tx event FIFO */
  MCAN_SetTxEventFifoConfig(CAN1_PERIPHERAL, &CAN1_tx_event_fifo_config);
  /* Configuration of Tx buffers and FIFO/Queue */
  MCAN_SetTxBufferConfig(CAN1_PERIPHERAL, &CAN1_tx_buffers_config);
  /* Setting of the CAN normal mode to start communication */
  MCAN_EnterNormalMode(CAN1_PERIPHERAL);
}

/***********************************************************************************************************************
 * ADC0 initialization code
 **********************************************************************************************************************/
/* clang-format off */
/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
instance:
- name: 'ADC0'
- type: 'lpc_adc'
- mode: 'ADC'
- custom_name_enabled: 'false'
- type_id: 'lpc_adc_d74172b5bd0591c0d32a6c93c043a67f'
- functional_group: 'BOARD_InitPeripherals'
- peripheral: 'ADC0'
- config_sets:
  - fsl_adc:
    - doSelfCalibration: 'false'
    - enableTempSensor: 'false'
    - adcConfig:
      - clockMode: 'kADC_ClockSynchronousMode'
      - clockSourceFreq: 'ClocksTool_DefaultInit'
      - clockDividerNumber: '0'
      - resolution: 'kADC_Resolution6bit'
      - sampleTimeNumber: '0'
      - enableBypassCalibration: 'false'
    - thresholdConfig:
      - ADC_SetThreshold0: 'false'
      - thresholdSettingsPair0:
        - lowValue: '0'
        - highValue: '0'
      - ADC_SetThreshold1: 'false'
      - thresholdSettingsPair1:
        - lowValue: '0'
        - highValue: '0'
    - enableSeqConfigurationA: 'false'
    - adcConvSeqConfigA:
      - enableHighPriority: 'false'
      - adcConvSeqConfig:
        - triggerMaskM: '0U'
        - triggerPolarity: 'kADC_TriggerPolarityNegativeEdge'
        - enableSyncBypass: 'false'
        - enableSingleStep: 'false'
        - interruptMode: 'kADC_InterruptForEachConversion'
    - enableSeqConfigurationB: 'false'
    - adcConvSeqConfigB:
      - enableHighPriority: 'false'
      - adcConvSeqConfig:
        - triggerMaskM: '0U'
        - triggerPolarity: 'kADC_TriggerPolarityNegativeEdge'
        - enableSyncBypass: 'false'
        - enableSingleStep: 'false'
        - interruptMode: 'kADC_InterruptForEachConversion'
    - channels: []
    - interrupt_sel: ''
    - enable_irq_seqA: 'false'
    - adc_interrupt_seqA:
      - IRQn: 'ADC0_SEQA_IRQn'
      - enable_interrrupt: 'enabled'
      - enable_priority: 'false'
      - priority: '0'
      - enable_custom_name: 'false'
    - enable_irq_seqB: 'false'
    - adc_interrupt_seqB:
      - IRQn: 'ADC0_SEQB_IRQn'
      - enable_interrrupt: 'enabled'
      - enable_priority: 'false'
      - priority: '0'
      - enable_custom_name: 'false'
    - enable_irq_thcmp: 'false'
    - adc_interrupt_thcmp:
      - IRQn: 'ADC0_THCMP_IRQn'
      - enable_interrrupt: 'enabled'
      - enable_priority: 'false'
      - priority: '0'
      - enable_custom_name: 'false'
 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
/* clang-format on */
const adc_config_t ADC0configStruct = {
  .clockMode = kADC_ClockSynchronousMode,
  .clockDividerNumber = 0UL,
  .resolution = kADC_Resolution6bit,
  .sampleTimeNumber = 0UL,
  .enableBypassCalibration = false
};

static void ADC0_init(void) {
  /* Initialize ADC0 peripheral */
  ADC_Init(ADC0_PERIPHERAL, &ADC0configStruct);
}

/***********************************************************************************************************************
 * FLEXCOMM0 initialization code
 **********************************************************************************************************************/
/* clang-format off */
/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
instance:
- name: 'FLEXCOMM0'
- type: 'flexcomm_usart'
- mode: 'polling'
- custom_name_enabled: 'false'
- type_id: 'flexcomm_usart_af6b92423b2c384096121979731b5f28'
- functional_group: 'BOARD_InitPeripherals'
- peripheral: 'FLEXCOMM0'
- config_sets:
  - usartConfig_t:
    - usartConfig:
      - clockSource: 'FXCOMFunctionClock'
      - clockSourceFreq: 'ClocksTool_DefaultInit'
      - baudRate_Bps: '115200'
      - syncMode: 'kUSART_SyncModeDisabled'
      - parityMode: 'kUSART_ParityDisabled'
      - stopBitCount: 'kUSART_OneStopBit'
      - bitCountPerChar: 'kUSART_8BitsPerChar'
      - loopback: 'false'
      - txWatermark: 'kUSART_TxFifo0'
      - rxWatermark: 'kUSART_RxFifo1'
      - enableMatchAddress: 'false'
      - matchAddressConfig:
        - matchAddress: '0'
        - addressMode: 'automatic'
      - enableRx: 'true'
      - enableTx: 'true'
      - enableHardwareFlowControl: 'false'
      - enableRTS: 'false'
      - clockPolarity: 'kUSART_RxSampleOnFallingEdge'
      - enableContinuousSCLK: 'false'
    - quick_selection: 'QuickSelection1'
 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
/* clang-format on */
const usart_config_t FLEXCOMM0_config = {
  .baudRate_Bps = 115200UL,
  .syncMode = kUSART_SyncModeDisabled,
  .parityMode = kUSART_ParityDisabled,
  .stopBitCount = kUSART_OneStopBit,
  .bitCountPerChar = kUSART_8BitsPerChar,
  .loopback = false,
  .txWatermark = kUSART_TxFifo0,
  .rxWatermark = kUSART_RxFifo1,
  .enableRx = true,
  .enableTx = true,
  .enableHardwareFlowControl = false,
  .enableMode32k = false,
  .clockPolarity = kUSART_RxSampleOnFallingEdge,
  .enableContinuousSCLK = false
};

static void FLEXCOMM0_init(void) {
  USART_Init(FLEXCOMM0_PERIPHERAL, &FLEXCOMM0_config, FLEXCOMM0_CLOCK_SOURCE);
}

/***********************************************************************************************************************
 * FLEXCOMM1 initialization code
 **********************************************************************************************************************/
/* clang-format off */
/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
instance:
- name: 'FLEXCOMM1'
- type: 'flexcomm_i2c'
- mode: 'I2C_Polling'
- custom_name_enabled: 'false'
- type_id: 'flexcomm_i2c_c8597948f61bd571ab263ea4330b9dd6'
- functional_group: 'BOARD_InitPeripherals'
- peripheral: 'FLEXCOMM1'
- config_sets:
  - fsl_i2c:
    - i2c_mode: 'kI2C_Master'
    - clockSource: 'FXCOMFunctionClock'
    - clockSourceFreq: 'ClocksTool_DefaultInit'
    - i2c_master_config:
      - enableMaster: 'true'
      - baudRate_Bps: '100000'
      - enableTimeout: 'false'
      - timeout_Ms: '35'
    - quick_selection: 'QS_I2C_Master'
 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
/* clang-format on */
const i2c_master_config_t FLEXCOMM1_config = {
  .enableMaster = true,
  .baudRate_Bps = 100000UL,
  .enableTimeout = false,
  .timeout_Ms = 35U
};

static void FLEXCOMM1_init(void) {
  /* Initialization function */
  I2C_MasterInit(FLEXCOMM1_PERIPHERAL, &FLEXCOMM1_config, FLEXCOMM1_CLOCK_SOURCE);
}

/***********************************************************************************************************************
 * FLEXCOMM2 initialization code
 **********************************************************************************************************************/
/* clang-format off */
/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
instance:
- name: 'FLEXCOMM2'
- type: 'flexcomm_spi'
- mode: 'SPI_Polling'
- custom_name_enabled: 'false'
- type_id: 'flexcomm_spi_b6bbc4b9dd1d40a58bb9821123930d3a'
- functional_group: 'BOARD_InitPeripherals'
- peripheral: 'FLEXCOMM2'
- config_sets:
  - fsl_spi:
    - spi_mode: 'kSPI_Master'
    - clockSource: 'FXCOMFunctionClock'
    - clockSourceFreq: 'ClocksTool_DefaultInit'
    - spi_master_config:
      - enableLoopback: 'false'
      - enableMaster: 'true'
      - polarity: 'kSPI_ClockPolarityActiveHigh'
      - phase: 'kSPI_ClockPhaseFirstEdge'
      - direction: 'kSPI_MsbFirst'
      - baudRate_Bps: '500000'
      - dataWidth: 'kSPI_Data8Bits'
      - sselNum: 'kSPI_Ssel0'
      - sselPol_set: ''
      - txWatermark: 'kSPI_TxFifo0'
      - rxWatermark: 'kSPI_RxFifo1'
      - delayConfig:
        - preDelay: '0'
        - postDelay: '0'
        - frameDelay: '0'
        - transferDelay: '0'
    - quick_selection: 'QS_SPI_1'
 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
/* clang-format on */
const spi_master_config_t FLEXCOMM2_config = {
  .enableLoopback = false,
  .enableMaster = true,
  .polarity = kSPI_ClockPolarityActiveHigh,
  .phase = kSPI_ClockPhaseFirstEdge,
  .direction = kSPI_MsbFirst,
  .baudRate_Bps = 500000UL,
  .dataWidth = kSPI_Data8Bits,
  .sselNum = kSPI_Ssel0,
  .sselPol = kSPI_SpolActiveAllLow,
  .txWatermark = kSPI_TxFifo0,
  .rxWatermark = kSPI_RxFifo1,
  .delayConfig = {
    .preDelay = 0U,
    .postDelay = 0U,
    .frameDelay = 0U,
    .transferDelay = 0U
  }
};

static void FLEXCOMM2_init(void) {
  /* Initialization function */
  SPI_MasterInit(FLEXCOMM2_PERIPHERAL, &FLEXCOMM2_config, FLEXCOMM2_CLOCK_SOURCE);
}

/***********************************************************************************************************************
 * Initialization functions
 **********************************************************************************************************************/
void BOARD_InitPeripherals(void)
{
  /* Initialize components */
  CAN0_init();
  CAN1_init();
  ADC0_init();
  FLEXCOMM0_init();
  FLEXCOMM1_init();
  FLEXCOMM2_init();
}

/***********************************************************************************************************************
 * BOARD_InitBootPeripherals function
 **********************************************************************************************************************/
void BOARD_InitBootPeripherals(void)
{
  BOARD_InitPeripherals();
}
