/***********************************************************************************************************************
 * 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 v5.0
processor: MK64FN1M0xxx12
package_id: MK64FN1M0VLL12
mcu_data: ksdk2_0
processor_version: 0.0.20
board: FRDM-K64F
functionalGroups:
- name: BOARD_InitPeripherals
  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'
- global_system_definitions: []
 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
/* clang-format on */

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

/***********************************************************************************************************************
 * BOARD_InitPeripherals functional group
 **********************************************************************************************************************/
/***********************************************************************************************************************
 * USB_1 initialization code
 **********************************************************************************************************************/
/* clang-format off */
/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
instance:
- name: 'USB_1'
- type: 'usb'
- mode: 'device'
- type_id: 'usb_e7971d25631a360e2da78a4fcd2653f5'
- functional_group: 'BOARD_InitPeripherals'
- peripheral: 'USB0'
- config_sets:
  - deviceSetting:
    - vendor_id: '0x1FC9'
    - product_id: '0x00A0'
    - manufacturer_string: 'NXP'
    - product_string: 'Keyboard'
    - self_powered: 'false'
    - max_power: '100'
    - interfaces:
      - 0:
        - interface_class: 'kClassHid'
        - setting_hid:
          - interface_name: 'HID Keyboard'
          - implementation: 'kImplementationKeyboard'
          - subclass: 'kSubclassBootInterface'
          - protocol: 'kProtocolKeyboard'
          - endpoints:
            - 0:
              - direction: 'kIn'
              - transfer_type: 'kInterrupt'
              - max_packet_size_fs: 'k8'
              - polling_interval_fs: '4'
          - report_descriptor:
            - 0:
              - type: 'kUsage_Page'
              - value: '0x01'
              - remarks: 'Usage Page (Generic Desktop)'
            - 1:
              - type: 'kUsage'
              - value: '0x06'
              - remarks: 'Usage (Keyboard)'
            - 2:
              - type: 'kCollection'
              - value: '0x01'
              - remarks: 'Collection (Application)'
            - 3:
              - type: 'kReport_Size'
              - value: '0x01'
              - remarks: 'Report Size (1U)'
            - 4:
              - type: 'kReport_Count'
              - value: '0x08'
              - remarks: 'Report Count (8U)'
            - 5:
              - type: 'kUsage_Page'
              - value: '0x07'
              - remarks: 'Usage Page(Key Codes)'
            - 6:
              - type: 'kUsage_Minimum'
              - value: '0xE0'
              - remarks: 'Usage Minimum (224U)'
            - 7:
              - type: 'kUsage_Maximum'
              - value: '0xE7'
              - remarks: 'Usage Maximum (231U)'
            - 8:
              - type: 'kLogical_Minimum'
              - value: '0x00'
              - remarks: 'Logical Minimum (0U)'
            - 9:
              - type: 'kLogical_Maximum'
              - value: '0x01'
              - remarks: 'Logical Maximum (1U)'
            - 10:
              - type: 'kReport_Count'
              - value: '0x01'
              - remarks: 'Report Count (1U)'
            - 11:
              - type: 'kReport_Size'
              - value: '0x08'
              - remarks: 'Report Size (8U)'
            - 12:
              - type: 'kInput'
              - value: '0x02'
              - remarks: 'Input(Constant), Reserved byte'
            - 13:
              - type: 'kReport_Count'
              - value: '0x05'
              - remarks: 'Report Count (5U)'
            - 14:
              - type: 'kReport_Size'
              - value: '0x01'
              - remarks: 'Report Size (1U)'
            - 15:
              - type: 'kUsage_Page'
              - value: '0x08'
              - remarks: 'Usage Page (Page# for LEDs)'
            - 16:
              - type: 'kUsage_Minimum'
              - value: '0x01'
              - remarks: 'Usage Minimum (1U)'
            - 17:
              - type: 'kUsage_Maximum'
              - value: '0x05'
              - remarks: 'Usage Maximum (5U)'
            - 18:
              - type: 'kOutput'
              - value: '0x02'
              - remarks: 'Output (Data, Variable, Absolute) LED report'
            - 19:
              - type: 'kReport_Count'
              - value: '0x01'
              - remarks: 'Report Count (1U)'
            - 20:
              - type: 'kReport_Size'
              - value: '0x03'
              - remarks: 'Report Size (3U)'
            - 21:
              - type: 'kOutput'
              - value: '0x03'
              - remarks: 'Output (Constant), LED report padding'
            - 22:
              - type: 'kReport_Count'
              - value: '0x06'
              - remarks: 'Report Count (6U)'
            - 23:
              - type: 'kReport_Size'
              - value: '0x08'
              - remarks: 'Report Size (8U)'
            - 24:
              - type: 'kLogical_Minimum'
              - value: '0x00'
              - remarks: 'Logical Minimum (0U)'
            - 25:
              - type: 'kLogical_Maximum'
              - value: '0xFF'
              - remarks: 'Logical Maximum (255U)'
            - 26:
              - type: 'kUsage_Page'
              - value: '0x07'
              - remarks: 'Usage Page (Key Codes)'
            - 27:
              - type: 'kUsage_Minimum'
              - value: '0x00'
              - remarks: 'Usage Minimum (0U)'
            - 28:
              - type: 'kUsage_Maximum'
              - value: '0xFF'
              - remarks: 'Usage Maximum (255U)'
            - 29:
              - type: 'kInput'
              - value: '0x00'
              - remarks: 'Input(Data, Array), Key arrays(6U bytes)'
            - 30:
              - type: 'kEnd_Collection'
              - remarks: ''
          - quick_selection: 'QS_INTERFACE_HID_KEYBOARD'
      - 1:
        - interface_class: 'kClassCic'
        - setting_cic:
          - interface_name: 'CIC VCOM'
          - implementation: 'kImplementationCicVcom'
          - subclass: 'kSubclassAcm'
          - protocol: 'kProtocolNone'
          - endpoints:
            - 0:
              - direction: 'kIn'
              - transfer_type: 'kInterrupt'
              - max_packet_size_fs: 'k16'
              - polling_interval_fs: '8'
          - data_interface_count: '1'
          - quick_selection: 'QS_INTERFACE_CIC_VCOM'
      - 2:
        - interface_class: 'kClassDic'
        - setting_dic:
          - interface_name: 'DIC VCOM'
          - implementation: 'kImplementationDicVcom'
          - subclass: 'kSubclassNone'
          - protocol: 'kProtocolNone'
          - endpoints:
            - 0:
              - direction: 'kIn'
              - transfer_type: 'kBulk'
              - max_packet_size_fs: 'k64'
              - polling_interval_fs: '0'
            - 1:
              - direction: 'kOut'
              - transfer_type: 'kBulk'
              - max_packet_size_fs: 'k64'
              - polling_interval_fs: '0'
          - quick_selection: 'QS_INTERFACE_DIC_VCOM'
 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
/* clang-format on */

void USB_1_init(void) {
  USB_DeviceApplicationInit();
}

/***********************************************************************************************************************
 * GPIO_1 initialization code
 **********************************************************************************************************************/
/* clang-format off */
/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
instance:
- name: 'GPIO_1'
- type: 'gpio'
- mode: 'GPIO'
- type_id: 'gpio_be9de87e5addb6b0f416d9acbab34797'
- functional_group: 'BOARD_InitPeripherals'
- peripheral: 'GPIOC'
- config_sets:
  - fsl_gpio:
    - enable_irq: 'true'
    - port_interrupt:
      - IRQn: 'PORTC_IRQn'
      - enable_priority: 'false'
      - enable_custom_name: 'false'
 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
/* clang-format on */

void GPIO_1_init(void) {
  /* Make sure, the clock gate for port C is enabled (e. g. in pin_mux.c) */
  /* Enable interrupt PORTC_IRQn request in the NVIC */
  EnableIRQ(PORTC_IRQn);
}

/***********************************************************************************************************************
 * UART_1 initialization code
 **********************************************************************************************************************/
/* clang-format off */
/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
instance:
- name: 'UART_1'
- type: 'uart'
- mode: 'polling'
- type_id: 'uart_cd31a12aa8c79051fda42cc851a27c37'
- functional_group: 'BOARD_InitPeripherals'
- peripheral: 'UART0'
- config_sets:
  - uartConfig_t:
    - uartConfig:
      - clockSource: 'BusInterfaceClock'
      - clockSourceFreq: 'GetFreq'
      - baudRate_Bps: '115200'
      - parityMode: 'kUART_ParityDisabled'
      - stopBitCount: 'kUART_OneStopBit'
      - txFifoWatermark: '0'
      - rxFifoWatermark: '1'
      - idleType: 'kUART_IdleTypeStartBit'
      - enableTx: 'true'
      - enableRx: 'true'
    - quick_selection: 'QuickSelection1'
 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
/* clang-format on */
const uart_config_t UART_1_config = {
  .baudRate_Bps = 115200,
  .parityMode = kUART_ParityDisabled,
  .stopBitCount = kUART_OneStopBit,
  .txFifoWatermark = 0,
  .rxFifoWatermark = 1,
  .idleType = kUART_IdleTypeStartBit,
  .enableTx = true,
  .enableRx = true
};

void UART_1_init(void) {
  UART_Init(UART_1_PERIPHERAL, &UART_1_config, UART_1_CLOCK_SOURCE);
}

/***********************************************************************************************************************
 * UART_2 initialization code
 **********************************************************************************************************************/
/* clang-format off */
/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
instance:
- name: 'UART_2'
- type: 'uart'
- mode: 'polling'
- type_id: 'uart_cd31a12aa8c79051fda42cc851a27c37'
- functional_group: 'BOARD_InitPeripherals'
- peripheral: 'UART1'
- config_sets:
  - uartConfig_t:
    - uartConfig:
      - clockSource: 'BusInterfaceClock'
      - clockSourceFreq: 'GetFreq'
      - baudRate_Bps: '115200'
      - parityMode: 'kUART_ParityDisabled'
      - stopBitCount: 'kUART_OneStopBit'
      - txFifoWatermark: '0'
      - rxFifoWatermark: '1'
      - idleType: 'kUART_IdleTypeStartBit'
      - enableTx: 'true'
      - enableRx: 'true'
    - quick_selection: 'QuickSelection1'
 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
/* clang-format on */
const uart_config_t UART_2_config = {
  .baudRate_Bps = 115200,
  .parityMode = kUART_ParityDisabled,
  .stopBitCount = kUART_OneStopBit,
  .txFifoWatermark = 0,
  .rxFifoWatermark = 1,
  .idleType = kUART_IdleTypeStartBit,
  .enableTx = true,
  .enableRx = true
};

void UART_2_init(void) {
  UART_Init(UART_2_PERIPHERAL, &UART_2_config, UART_2_CLOCK_SOURCE);
}

/***********************************************************************************************************************
 * UART_3 initialization code
 **********************************************************************************************************************/
/* clang-format off */
/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
instance:
- name: 'UART_3'
- type: 'uart'
- mode: 'polling'
- type_id: 'uart_cd31a12aa8c79051fda42cc851a27c37'
- functional_group: 'BOARD_InitPeripherals'
- peripheral: 'UART2'
- config_sets:
  - uartConfig_t:
    - uartConfig:
      - clockSource: 'BusInterfaceClock'
      - clockSourceFreq: 'GetFreq'
      - baudRate_Bps: '115200'
      - parityMode: 'kUART_ParityDisabled'
      - stopBitCount: 'kUART_OneStopBit'
      - txFifoWatermark: '0'
      - rxFifoWatermark: '1'
      - idleType: 'kUART_IdleTypeStartBit'
      - enableTx: 'true'
      - enableRx: 'true'
    - quick_selection: 'QuickSelection1'
 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
/* clang-format on */
const uart_config_t UART_3_config = {
  .baudRate_Bps = 115200,
  .parityMode = kUART_ParityDisabled,
  .stopBitCount = kUART_OneStopBit,
  .txFifoWatermark = 0,
  .rxFifoWatermark = 1,
  .idleType = kUART_IdleTypeStartBit,
  .enableTx = true,
  .enableRx = true
};

void UART_3_init(void) {
  UART_Init(UART_3_PERIPHERAL, &UART_3_config, UART_3_CLOCK_SOURCE);
}

/***********************************************************************************************************************
 * Initialization functions
 **********************************************************************************************************************/
void BOARD_InitPeripherals(void)
{
  /* Initialize components */
  USB_1_init();
  GPIO_1_init();
  UART_1_init();
  UART_2_init();
  UART_3_init();
}

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