start with USB CDC echo example

this is the Atmel START USB CDC Echo example project for the
SAM E54 Xplained Pro board using an Atmel ATSAME54P20A
microcontroller.
Atmel START information:
- Version: 1.4.1810 (Dec 18, 2018, 5:52 AM GMT+1)
- Server: 1.4.93
- Content version: 1.0.1340

This will serve as basis for the sysmoOCTSIM project

A jenkins contrib script has also been added to the
osmo-ccid-firmware project to build the sysmoOCTSIM firmware

Change-Id: I356de75e7b730d63fb819248e71d36f785932199
diff --git a/sysmoOCTSIM/hal/include/hal_atomic.h b/sysmoOCTSIM/hal/include/hal_atomic.h
new file mode 100644
index 0000000..82151fc
--- /dev/null
+++ b/sysmoOCTSIM/hal/include/hal_atomic.h
@@ -0,0 +1,120 @@
+/**
+ * \file
+ *
+ * \brief Critical sections related functionality declaration.
+ *
+ * Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Subject to your compliance with these terms, you may use Microchip
+ * software and any derivatives exclusively with Microchip products.
+ * It is your responsibility to comply with third party license terms applicable
+ * to your use of third party software (including open source software) that
+ * may accompany Microchip software.
+ *
+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE.  TO THE FULLEST EXTENT
+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
+ *
+ * \asf_license_stop
+ *
+ */
+
+#ifndef _HAL_ATOMIC_H_INCLUDED
+#define _HAL_ATOMIC_H_INCLUDED
+
+#include <compiler.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \addtogroup doc_driver_hal_helper_atomic
+ *
+ *@{
+ */
+
+/**
+ * \brief Type for the register holding global interrupt enable flag
+ */
+typedef uint32_t hal_atomic_t;
+
+/**
+ * \brief Helper macro for entering critical sections
+ *
+ * This macro is recommended to be used instead of a direct call
+ * hal_enterCritical() function to enter critical
+ * sections. No semicolon is required after the macro.
+ *
+ * \section atomic_usage Usage Example
+ * \code
+ * CRITICAL_SECTION_ENTER()
+ * Critical code
+ * CRITICAL_SECTION_LEAVE()
+ * \endcode
+ */
+#define CRITICAL_SECTION_ENTER()                                                                                       \
+	{                                                                                                                  \
+		volatile hal_atomic_t __atomic;                                                                                \
+		atomic_enter_critical(&__atomic);
+
+/**
+ * \brief Helper macro for leaving critical sections
+ *
+ * This macro is recommended to be used instead of a direct call
+ * hal_leaveCritical() function to leave critical
+ * sections. No semicolon is required after the macro.
+ */
+#define CRITICAL_SECTION_LEAVE()                                                                                       \
+	atomic_leave_critical(&__atomic);                                                                                  \
+	}
+
+/**
+ * \brief Disable interrupts, enter critical section
+ *
+ * Disables global interrupts. Supports nested critical sections,
+ * so that global interrupts are only re-enabled
+ * upon leaving the outermost nested critical section.
+ *
+ * \param[out] atomic The pointer to a variable to store the value of global
+ * interrupt enable flag
+ */
+void atomic_enter_critical(hal_atomic_t volatile *atomic);
+
+/**
+ * \brief Exit atomic section
+ *
+ * Enables global interrupts. Supports nested critical sections,
+ * so that global interrupts are only re-enabled
+ * upon leaving the outermost nested critical section.
+ *
+ * \param[in] atomic The pointer to a variable, which stores the latest stored
+ * value of the global interrupt enable flag
+ */
+void atomic_leave_critical(hal_atomic_t volatile *atomic);
+
+/**
+ * \brief Retrieve the current driver version
+ *
+ * \return Current driver version.
+ */
+uint32_t atomic_get_version(void);
+/**@}*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _HAL_ATOMIC_H_INCLUDED */
diff --git a/sysmoOCTSIM/hal/include/hal_cache.h b/sysmoOCTSIM/hal/include/hal_cache.h
new file mode 100644
index 0000000..071486b
--- /dev/null
+++ b/sysmoOCTSIM/hal/include/hal_cache.h
@@ -0,0 +1,96 @@
+/**
+ * \file
+ *
+ * \brief HAL cache functionality implementation.
+ *
+ * Copyright (c)2018 Microchip Technology Inc. and its subsidiaries.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Subject to your compliance with these terms, you may use Microchip
+ * software and any derivatives exclusively with Microchip products.
+ * It is your responsibility to comply with third party license terms applicable
+ * to your use of third party software (including open source software) that
+ * may accompany Microchip software.
+ *
+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS".  NO WARRANTIES,
+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE.  TO THE FULLEST EXTENT
+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit <a href="https://www.microchip.com/support/">Microchip Support</a>
+ */
+
+#ifndef HAL_CACHE_H_
+#define HAL_CACHE_H_
+
+#include <hpl_cmcc.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \brief Enable cache module
+ *
+ * \param[in] pointer pointing to the starting address of cache module
+ *
+ * \return status of operation
+ */
+int32_t cache_enable(const void *hw);
+
+/**
+ * \brief Disable cache module
+ *
+ * \param[in] pointer pointing to the starting address of cache module
+ *
+ * \return status of operation
+ */
+int32_t cache_disable(const void *hw);
+
+/**
+ * \brief Initialize cache module
+ *
+ * This function initialize cache module configuration.
+ *
+ * \return status of operation
+ */
+int32_t cache_init(void);
+
+/**
+ * \brief Configure cache module
+ *
+ * \param[in] pointer pointing to the starting address of cache module
+ * \param[in] cache configuration structure pointer
+ *
+ * \return status of operation
+ */
+int32_t cache_configure(const void *hw, struct _cache_cfg *cache);
+
+/**
+ * \brief Invalidate entire cache entries
+ *
+ * \param[in] pointer pointing to the starting address of cache module
+ *
+ * \return status of operation
+ */
+int32_t cache_invalidate_all(const void *hw);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* HAL_CACHE_H_ */
diff --git a/sysmoOCTSIM/hal/include/hal_delay.h b/sysmoOCTSIM/hal/include/hal_delay.h
new file mode 100644
index 0000000..9d4aa5c
--- /dev/null
+++ b/sysmoOCTSIM/hal/include/hal_delay.h
@@ -0,0 +1,89 @@
+/**
+ * \file
+ *
+ * \brief HAL delay related functionality declaration.
+ *
+ * Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Subject to your compliance with these terms, you may use Microchip
+ * software and any derivatives exclusively with Microchip products.
+ * It is your responsibility to comply with third party license terms applicable
+ * to your use of third party software (including open source software) that
+ * may accompany Microchip software.
+ *
+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE.  TO THE FULLEST EXTENT
+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
+ *
+ * \asf_license_stop
+ *
+ */
+
+#include <hpl_irq.h>
+#include <hpl_reset.h>
+#include <hpl_sleep.h>
+
+#ifndef _HAL_DELAY_H_INCLUDED
+#define _HAL_DELAY_H_INCLUDED
+
+#include <compiler.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \addtogroup doc_driver_hal_delay Delay Driver
+ *
+ *@{
+ */
+
+/**
+ * \brief Initialize Delay driver
+ *
+ * \param[in] hw The pointer to hardware instance
+ */
+void delay_init(void *const hw);
+
+/**
+ * \brief Perform delay in us
+ *
+ * This function performs delay for the given amount of microseconds.
+ *
+ * \param[in] us The amount delay in us
+ */
+void delay_us(const uint16_t us);
+
+/**
+ * \brief Perform delay in ms
+ *
+ * This function performs delay for the given amount of milliseconds.
+ *
+ * \param[in] ms The amount delay in ms
+ */
+void delay_ms(const uint16_t ms);
+
+/**
+ * \brief Retrieve the current driver version
+ *
+ * \return Current driver version.
+ */
+uint32_t delay_get_version(void);
+
+/**@}*/
+#ifdef __cplusplus
+}
+#endif
+#endif /* _HAL_DELAY_H_INCLUDED */
diff --git a/sysmoOCTSIM/hal/include/hal_gpio.h b/sysmoOCTSIM/hal/include/hal_gpio.h
new file mode 100644
index 0000000..fbfa2d4
--- /dev/null
+++ b/sysmoOCTSIM/hal/include/hal_gpio.h
@@ -0,0 +1,201 @@
+/**
+ * \file
+ *
+ * \brief Port
+ *
+ * Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Subject to your compliance with these terms, you may use Microchip
+ * software and any derivatives exclusively with Microchip products.
+ * It is your responsibility to comply with third party license terms applicable
+ * to your use of third party software (including open source software) that
+ * may accompany Microchip software.
+ *
+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE.  TO THE FULLEST EXTENT
+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
+ *
+ * \asf_license_stop
+ */
+#ifndef _HAL_GPIO_INCLUDED_
+#define _HAL_GPIO_INCLUDED_
+
+#include <hpl_gpio.h>
+#include <utils_assert.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \brief Set gpio pull mode
+ *
+ * Set pin pull mode, non existing pull modes throws an fatal assert
+ *
+ * \param[in] pin       The pin number for device
+ * \param[in] pull_mode GPIO_PULL_DOWN = Pull pin low with internal resistor
+ *                      GPIO_PULL_UP   = Pull pin high with internal resistor
+ *                      GPIO_PULL_OFF  = Disable pin pull mode
+ */
+static inline void gpio_set_pin_pull_mode(const uint8_t pin, const enum gpio_pull_mode pull_mode)
+{
+	_gpio_set_pin_pull_mode((enum gpio_port)GPIO_PORT(pin), pin & 0x1F, pull_mode);
+}
+
+/**
+ * \brief Set pin function
+ *
+ * Select which function a pin will be used for
+ *
+ * \param[in] pin       The pin number for device
+ * \param[in] function  The pin function is given by a 32-bit wide bitfield
+ *                      found in the header files for the device
+ *
+ */
+static inline void gpio_set_pin_function(const uint32_t pin, uint32_t function)
+{
+	_gpio_set_pin_function(pin, function);
+}
+
+/**
+ * \brief Set port data direction
+ *
+ * Select if the pin data direction is input, output or disabled.
+ * If disabled state is not possible, this function throws an assert.
+ *
+ * \param[in] port      Ports are grouped into groups of maximum 32 pins,
+ *                      GPIO_PORTA = group 0, GPIO_PORTB = group 1, etc
+ * \param[in] mask      Bit mask where 1 means apply direction setting to the
+ *                      corresponding pin
+ * \param[in] direction GPIO_DIRECTION_IN  = Data direction in
+ *                      GPIO_DIRECTION_OUT = Data direction out
+ *                      GPIO_DIRECTION_OFF = Disables the pin
+ *                      (low power state)
+ */
+static inline void gpio_set_port_direction(const enum gpio_port port, const uint32_t mask,
+                                           const enum gpio_direction direction)
+{
+	_gpio_set_direction(port, mask, direction);
+}
+
+/**
+ * \brief Set gpio data direction
+ *
+ * Select if the pin data direction is input, output or disabled.
+ * If disabled state is not possible, this function throws an assert.
+ *
+ * \param[in] pin       The pin number for device
+ * \param[in] direction GPIO_DIRECTION_IN  = Data direction in
+ *                      GPIO_DIRECTION_OUT = Data direction out
+ *                      GPIO_DIRECTION_OFF = Disables the pin
+ *                      (low power state)
+ */
+static inline void gpio_set_pin_direction(const uint8_t pin, const enum gpio_direction direction)
+{
+	_gpio_set_direction((enum gpio_port)GPIO_PORT(pin), 1U << GPIO_PIN(pin), direction);
+}
+
+/**
+ * \brief Set port level
+ *
+ * Sets output level on the pins defined by the bit mask
+ *
+ * \param[in] port  Ports are grouped into groups of maximum 32 pins,
+ *                  GPIO_PORTA = group 0, GPIO_PORTB = group 1, etc
+ * \param[in] mask  Bit mask where 1 means apply port level to the corresponding
+ *                  pin
+ * \param[in] level true  = Pin levels set to "high" state
+ *                  false = Pin levels set to "low" state
+ */
+static inline void gpio_set_port_level(const enum gpio_port port, const uint32_t mask, const bool level)
+{
+	_gpio_set_level(port, mask, level);
+}
+
+/**
+ * \brief Set gpio level
+ *
+ * Sets output level on a pin
+ *
+ * \param[in] pin       The pin number for device
+ * \param[in] level true  = Pin level set to "high" state
+ *                  false = Pin level set to "low" state
+ */
+static inline void gpio_set_pin_level(const uint8_t pin, const bool level)
+{
+	_gpio_set_level((enum gpio_port)GPIO_PORT(pin), 1U << GPIO_PIN(pin), level);
+}
+
+/**
+ * \brief Toggle out level on pins
+ *
+ * Toggle the pin levels on pins defined by bit mask
+ *
+ * \param[in] port  Ports are grouped into groups of maximum 32 pins,
+ *                  GPIO_PORTA = group 0, GPIO_PORTB = group 1, etc
+ * \param[in] mask  Bit mask where 1 means toggle pin level to the corresponding
+ *                  pin
+ */
+static inline void gpio_toggle_port_level(const enum gpio_port port, const uint32_t mask)
+{
+	_gpio_toggle_level(port, mask);
+}
+
+/**
+ * \brief Toggle output level on pin
+ *
+ * Toggle the pin levels on pins defined by bit mask
+ *
+ * \param[in] pin       The pin number for device
+ */
+static inline void gpio_toggle_pin_level(const uint8_t pin)
+{
+	_gpio_toggle_level((enum gpio_port)GPIO_PORT(pin), 1U << GPIO_PIN(pin));
+}
+
+/**
+ * \brief Get input level on pins
+ *
+ * Read the input level on pins connected to a port
+ *
+ * \param[in] port  Ports are grouped into groups of maximum 32 pins,
+ *                  GPIO_PORTA = group 0, GPIO_PORTB = group 1, etc
+ */
+static inline uint32_t gpio_get_port_level(const enum gpio_port port)
+{
+	return _gpio_get_level(port);
+}
+
+/**
+ * \brief Get level on pin
+ *
+ * Reads the level on pins connected to a port
+ *
+ * \param[in] pin       The pin number for device
+ */
+static inline bool gpio_get_pin_level(const uint8_t pin)
+{
+	return (bool)(_gpio_get_level((enum gpio_port)GPIO_PORT(pin)) & (0x01U << GPIO_PIN(pin)));
+}
+/**
+ * \brief Get current driver version
+ */
+uint32_t gpio_get_version(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/sysmoOCTSIM/hal/include/hal_init.h b/sysmoOCTSIM/hal/include/hal_init.h
new file mode 100644
index 0000000..d7bc6fe
--- /dev/null
+++ b/sysmoOCTSIM/hal/include/hal_init.h
@@ -0,0 +1,72 @@
+/**
+ * \file
+ *
+ * \brief HAL initialization related functionality declaration.
+ *
+ * Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Subject to your compliance with these terms, you may use Microchip
+ * software and any derivatives exclusively with Microchip products.
+ * It is your responsibility to comply with third party license terms applicable
+ * to your use of third party software (including open source software) that
+ * may accompany Microchip software.
+ *
+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE.  TO THE FULLEST EXTENT
+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
+ *
+ * \asf_license_stop
+ *
+ */
+
+#ifndef _HAL_INIT_H_INCLUDED
+#define _HAL_INIT_H_INCLUDED
+
+#include <hpl_init.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \addtogroup doc_driver_hal_helper_init Init Driver
+ *
+ *@{
+ */
+
+/**
+ * \brief Initialize the hardware abstraction layer
+ *
+ * This function calls the various initialization functions.
+ * Currently the following initialization functions are supported:
+ *  - System clock initialization
+ */
+static inline void init_mcu(void)
+{
+	_init_chip();
+}
+
+/**
+ * \brief Retrieve the current driver version
+ *
+ * \return Current driver version.
+ */
+uint32_t init_get_version(void);
+
+/**@}*/
+#ifdef __cplusplus
+}
+#endif
+#endif /* _HAL_INIT_H_INCLUDED */
diff --git a/sysmoOCTSIM/hal/include/hal_io.h b/sysmoOCTSIM/hal/include/hal_io.h
new file mode 100644
index 0000000..f50401d
--- /dev/null
+++ b/sysmoOCTSIM/hal/include/hal_io.h
@@ -0,0 +1,110 @@
+/**
+ * \file
+ *
+ * \brief I/O related functionality declaration.
+ *
+ * Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Subject to your compliance with these terms, you may use Microchip
+ * software and any derivatives exclusively with Microchip products.
+ * It is your responsibility to comply with third party license terms applicable
+ * to your use of third party software (including open source software) that
+ * may accompany Microchip software.
+ *
+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE.  TO THE FULLEST EXTENT
+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
+ *
+ * \asf_license_stop
+ *
+ */
+
+#ifndef _HAL_IO_INCLUDED
+#define _HAL_IO_INCLUDED
+
+/**
+ * \addtogroup doc_driver_hal_helper_io I/O Driver
+ *
+ *@{
+ */
+
+#include <compiler.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \brief I/O descriptor
+ *
+ * The I/O descriptor forward declaration.
+ */
+struct io_descriptor;
+
+/**
+ * \brief I/O write function pointer type
+ */
+typedef int32_t (*io_write_t)(struct io_descriptor *const io_descr, const uint8_t *const buf, const uint16_t length);
+
+/**
+ * \brief I/O read function pointer type
+ */
+typedef int32_t (*io_read_t)(struct io_descriptor *const io_descr, uint8_t *const buf, const uint16_t length);
+
+/**
+ * \brief I/O descriptor
+ */
+struct io_descriptor {
+	io_write_t write; /*! The write function pointer. */
+	io_read_t  read;  /*! The read function pointer. */
+};
+
+/**
+ * \brief I/O write interface
+ *
+ * This function writes up to \p length of bytes to a given I/O descriptor.
+ * It returns the number of bytes actually write.
+ *
+ * \param[in] descr  An I/O descriptor to write
+ * \param[in] buf    The buffer pointer to story the write data
+ * \param[in] length The number of bytes to write
+ *
+ * \return The number of bytes written
+ */
+int32_t io_write(struct io_descriptor *const io_descr, const uint8_t *const buf, const uint16_t length);
+
+/**
+ * \brief I/O read interface
+ *
+ * This function reads up to \p length bytes from a given I/O descriptor, and
+ * stores it in the buffer pointed to by \p buf. It returns the number of bytes
+ * actually read.
+ *
+ * \param[in] descr  An I/O descriptor to read
+ * \param[in] buf    The buffer pointer to story the read data
+ * \param[in] length The number of bytes to read
+ *
+ * \return The number of bytes actually read. This number can be less than the
+ *         requested length. E.g., in a driver that uses ring buffer for
+ *         reception, it may depend on the availability of data in the
+ *         ring buffer.
+ */
+int32_t io_read(struct io_descriptor *const io_descr, uint8_t *const buf, const uint16_t length);
+
+#ifdef __cplusplus
+}
+#endif
+/**@}*/
+#endif /* _HAL_IO_INCLUDED */
diff --git a/sysmoOCTSIM/hal/include/hal_sleep.h b/sysmoOCTSIM/hal/include/hal_sleep.h
new file mode 100644
index 0000000..b90ef6a
--- /dev/null
+++ b/sysmoOCTSIM/hal/include/hal_sleep.h
@@ -0,0 +1,74 @@
+/**
+ * \file
+ *
+ * \brief Sleep related functionality declaration.
+ *
+ * Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Subject to your compliance with these terms, you may use Microchip
+ * software and any derivatives exclusively with Microchip products.
+ * It is your responsibility to comply with third party license terms applicable
+ * to your use of third party software (including open source software) that
+ * may accompany Microchip software.
+ *
+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE.  TO THE FULLEST EXTENT
+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
+ *
+ * \asf_license_stop
+ *
+ */
+
+#ifndef _HAL_SLEEP_H_INCLUDED
+#define _HAL_SLEEP_H_INCLUDED
+
+#include <hpl_sleep.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \addtogroup doc_driver_hal_helper_sleep
+ *
+ *@{
+ */
+
+/**
+ * \brief Set the sleep mode of the device and put the MCU to sleep
+ *
+ * For an overview of which systems are disabled in sleep for the different
+ * sleep modes, see the data sheet.
+ *
+ * \param[in] mode Sleep mode to use
+ *
+ * \return The status of a sleep request
+ * \retval -1 The requested sleep mode was invalid or not available
+ * \retval  0 The operation completed successfully, returned after leaving the
+ *            sleep
+ */
+int sleep(const uint8_t mode);
+
+/**
+ * \brief Retrieve the current driver version
+ *
+ * \return Current driver version.
+ */
+uint32_t sleep_get_version(void);
+/**@}*/
+#ifdef __cplusplus
+}
+#endif
+#endif /* _HAL_SLEEP_H_INCLUDED */
diff --git a/sysmoOCTSIM/hal/include/hal_usb_device.h b/sysmoOCTSIM/hal/include/hal_usb_device.h
new file mode 100644
index 0000000..7e19f68
--- /dev/null
+++ b/sysmoOCTSIM/hal/include/hal_usb_device.h
@@ -0,0 +1,295 @@
+/**
+ * \file
+ *
+ * \brief SAM USB device HAL
+ *
+ * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Subject to your compliance with these terms, you may use Microchip
+ * software and any derivatives exclusively with Microchip products.
+ * It is your responsibility to comply with third party license terms applicable
+ * to your use of third party software (including open source software) that
+ * may accompany Microchip software.
+ *
+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE.  TO THE FULLEST EXTENT
+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
+ *
+ * \asf_license_stop
+ *
+ */
+
+#ifndef _HAL_USB_DEVICE_H_INCLUDED
+#define _HAL_USB_DEVICE_H_INCLUDED
+
+#include <hpl_usb_device.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \addtogroup doc_driver_hal_usb_device
+ *
+ * @{
+ */
+
+/** USB device endpoint status structure. */
+struct usb_d_ep_status {
+	/** Endpoint address, including direction. */
+	uint8_t ep;
+	/** Endpoint transfer status code that triggers the callback.
+	 *  \ref usb_xfer_code. */
+	uint8_t code;
+	/** Endpoint error, if \c code is \ref USB_TRANS_ERROR. */
+	uint8_t error;
+	/** Transfer state, \ref usb_ep_state. */
+	uint8_t state;
+	/** Transfer count. */
+	uint32_t count;
+	/** Transfer size. */
+	uint32_t size;
+};
+
+/** Prototype function for callback that is invoked on USB device SOF. */
+typedef void (*usb_d_sof_cb_t)(void);
+
+/** Prototype function for callback that is invoked on USB device events. */
+typedef void (*usb_d_event_cb_t)(const enum usb_event event, const uint32_t param);
+
+/** USB device callbacks. */
+struct usb_d_callbacks {
+	/** Callback that is invoked on SOF. */
+	usb_d_sof_cb_t sof;
+	/** Callback that is invoked on USB RESET/WAKEUP/RESUME/SUSPEND. */
+	usb_d_event_cb_t event;
+};
+
+/** Callback that is invoked when setup packet is received.
+ *  Return \c true if request has been handled, or control endpoint will
+ *  stall IN/OUT transactions.
+ */
+typedef bool (*usb_d_ep_cb_setup_t)(const uint8_t ep, const uint8_t *req);
+
+/** Callback that is invoked when buffer is done without error, but last packet
+ *  is full size packet without ZLP.
+ *  Return \c true if more data has been requested.
+ */
+typedef bool (*usb_d_ep_cb_more_t)(const uint8_t ep, const uint32_t count);
+
+/** Callback that is invoked when all data is finished, including background
+ *  transfer, or error happens.
+ *  In control transfer data stage, return value is checked,
+ *  return \c false if no error happens.
+ */
+typedef bool (*usb_d_ep_cb_xfer_t)(const uint8_t ep, const enum usb_xfer_code code, void *param);
+
+/**
+ *  \brief Initialize the USB device driver
+ *  \return Operation status.
+ *  \retval 0 Success.
+ *  \retval <0 Error code.
+ */
+int32_t usb_d_init(void);
+
+/**
+ *  \brief Deinitialize the USB device driver
+ */
+void usb_d_deinit(void);
+
+/**
+ *  \brief Register the USB device callback
+ *  \param[in] type The callback type to register.
+ *  \param[in] func The callback function, NULL to disable callback.
+ */
+void usb_d_register_callback(const enum usb_d_cb_type type, const FUNC_PTR func);
+
+/**
+ *  \brief Enable the USB device driver
+ *  \return Operation status.
+ *  \retval 0 Success.
+ *  \retval <0 Error code.
+ */
+int32_t usb_d_enable(void);
+
+/**
+ *  \brief Disable the USB device driver
+ */
+void usb_d_disable(void);
+
+/**
+ *  \brief Attach the USB device
+ */
+void usb_d_attach(void);
+
+/**
+ *  \brief Detach the USB device
+ */
+void usb_d_detach(void);
+
+/**
+ *  \brief Retrieve current USB working speed.
+ *  \return USB Speed. See \ref usb_speed.
+ */
+enum usb_speed usb_d_get_speed(void);
+
+/**
+ *  \brief Retrieve current USB frame number.
+ *  \return Frame number.
+ */
+uint16_t usb_d_get_frame_num(void);
+
+/**
+ *  \brief Retrieve current USB micro frame number.
+ *  \return Micro frame number inside a frame (0~7).
+ *          0 if not available (not HS).
+ */
+uint8_t usb_d_get_uframe_num(void);
+
+/**
+ *  \brief Set the USB address that is used.
+ *  \param[in] addr The address to set.
+ */
+void usb_d_set_address(const uint8_t addr);
+
+/**
+ *  \brief Send remote wakeup to host
+ *  \return Operation status.
+ */
+void usb_d_send_remotewakeup(void);
+
+/**
+ *  \brief Initialize the endpoint 0.
+ *
+ *  Note that endpoint 0 must be initialized as control endpoint.
+ *
+ *  \param[in] max_pkt_size Max. packet size of EP0.
+ *  \return Operation status.
+ *  \retval 0 Success.
+ *  \retval <0 Error code.
+ */
+int32_t usb_d_ep0_init(const uint8_t max_pkt_size);
+
+/**
+ *  \brief Initialize the endpoint.
+ *
+ *  \param[in] ep The endpoint address.
+ *  \param[in] attr The endpoint attributes.
+ *  \param[in] max_pkt_size Max. packet size of EP0.
+ *  \return Operation status.
+ *  \retval 0 Success.
+ *  \retval <0 Error code.
+ */
+int32_t usb_d_ep_init(const uint8_t ep, const uint8_t attr, const uint16_t max_pkt_size);
+
+/**
+ *  \brief Disable and deinitialize the endpoint.
+ *  \param[in] ep The endpoint address to deinitialize.
+ */
+void usb_d_ep_deinit(const uint8_t ep);
+
+/**
+ *  \brief Register the USB device endpoint callback on initialized endpoint.
+ *
+ *  \param[in] ep The endpoint address.
+ *  \param[in] type The callback type to register.
+ *  \param[in] func The callback function, NULL to disable callback.
+ */
+void usb_d_ep_register_callback(const uint8_t ep, const enum usb_d_ep_cb_type type, const FUNC_PTR func);
+
+/**
+ *  \brief Enabled the initialized endpoint.
+ *
+ *  Setup request will be monitored after enabling a control endpoint.
+ *
+ *  \param[in] ep The endpoint address.
+ *  \return Operation status.
+ *  \retval 0 Success.
+ *  \retval <0 Error code.
+ */
+int32_t usb_d_ep_enable(const uint8_t ep);
+
+/**
+ *  \brief Disable the initialized endpoint.
+ *  \param[in] ep The endpoint address.
+ */
+void usb_d_ep_disable(const uint8_t ep);
+
+/**
+ *  \brief Get request data pointer to access received setup request packet
+ *  \param[in] ep The endpoint address.
+ *  \return Pointer to the request data.
+ *  \retval NULL The endpoint is not a control endpoint.
+ */
+uint8_t *usb_d_ep_get_req(const uint8_t ep);
+
+/**
+ *  \brief Endpoint transfer.
+ *
+ *  For control endpoints, start the transfer according to the direction in the bmRequest
+ *  type, and finish with STATUS stage.
+ *  For non-control endpoints, the transfer will be unique direction. Defined by
+ *  bit 8 of the endpoint address.
+ *
+ *  \param[in] xfer Pointer to the transfer description.
+ *  \return Operation status.
+ *  \retval 0 Success.
+ *  \retval <0 Error code.
+ */
+int32_t usb_d_ep_transfer(const struct usb_d_transfer *xfer);
+
+/**
+ *  \brief Abort an on-going transfer on a specific endpoint.
+ *
+ *  \param[in] ep The endpoint address.
+ */
+void usb_d_ep_abort(const uint8_t ep);
+
+/**
+ *  \brief Retrieve the endpoint status.
+ *
+ *  \param[in] ep The endpoint address.
+ *  \param[out] stat Pointer to the buffer to fill the status description.
+ *
+ *  \return Endpoint status.
+ *  \retval 1 Busy.
+ *  \retval 0 Idle.
+ *  \retval <0 Error code.
+ */
+int32_t usb_d_ep_get_status(const uint8_t ep, struct usb_d_ep_status *stat);
+
+/**
+ *  \brief Endpoint halt control.
+ *
+ *  \param[in] ep The endpoint address.
+ *  \param[in] ctrl Control code (SET/CLEAR/GET).
+ *
+ *  \return Operation status or HALT state (if \c ctrl is \ref USB_EP_HALT_GET).
+ */
+int32_t usb_d_ep_halt(const uint8_t ep, const enum usb_ep_halt_ctrl ctrl);
+
+/** \brief Retrieve the current driver version
+ *
+ *  \return Current driver version.
+ */
+uint32_t usb_d_get_version(void);
+
+/**@}*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _HAL_USB_DEVICE_H_INCLUDED */
diff --git a/sysmoOCTSIM/hal/include/hpl_cmcc.h b/sysmoOCTSIM/hal/include/hpl_cmcc.h
new file mode 100644
index 0000000..cb26091
--- /dev/null
+++ b/sysmoOCTSIM/hal/include/hpl_cmcc.h
@@ -0,0 +1,277 @@
+/**
+ * \file
+ *
+ * \brief Generic CMCC(Cortex M Cache Controller) related functionality.
+ *
+ * Copyright (c)2018 Microchip Technology Inc. and its subsidiaries.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Subject to your compliance with these terms, you may use Microchip
+ * software and any derivatives exclusively with Microchip products.
+ * It is your responsibility to comply with third party license terms applicable
+ * to your use of third party software (including open source software) that
+ * may accompany Microchip software.
+ *
+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS".  NO WARRANTIES,
+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE.  TO THE FULLEST EXTENT
+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit <a href="https://www.microchip.com/support/">Microchip Support</a>
+ */
+
+#ifndef HPL_CMCC_H_
+#define HPL_CMCC_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <stdbool.h>
+
+/**
+ * \Cache driver MACROS
+ */
+#define CMCC_DISABLE 0U
+#define CMCC_ENABLE 1U
+#define IS_CMCC_DISABLED 0U
+#define IS_CMCC_ENABLED 1U
+#define CMCC_WAY_NOS 4U
+#define CMCC_LINE_NOS 64U
+#define CMCC_MONITOR_DISABLE 0U
+
+/**
+ * \brief Cache size configurations
+ */
+enum conf_cache_size { CONF_CSIZE_1KB = 0u, CONF_CSIZE_2KB, CONF_CSIZE_4KB };
+
+/**
+ * \brief Way Numbers
+ */
+enum way_num_index { WAY0 = 1u, WAY1 = 2u, WAY2 = 4u, WAY3 = 8 };
+
+/**
+ * \brief Cache monitor configurations
+ */
+enum conf_cache_monitor { CYCLE_COUNT = 0u, IHIT_COUNT, DHIT_COUNT };
+
+/**
+ * \brief Cache configuration structure
+ */
+struct _cache_cfg {
+	enum conf_cache_size cache_size;
+	bool                 data_cache_disable;
+	bool                 inst_cache_disable;
+	bool                 gclk_gate_disable;
+};
+
+/**
+ * \brief Cache enable status
+ */
+static inline bool _is_cache_enabled(const void *hw)
+{
+	return (hri_cmcc_get_SR_CSTS_bit(hw) == IS_CMCC_ENABLED ? true : false);
+}
+
+/**
+ * \brief Cache disable status
+ */
+static inline bool _is_cache_disabled(const void *hw)
+{
+	return (hri_cmcc_get_SR_CSTS_bit(hw) == IS_CMCC_DISABLED ? true : false);
+}
+
+/**
+ * \brief Cache enable
+ */
+static inline int32_t _cmcc_enable(const void *hw)
+{
+	int32_t return_value;
+
+	if (_is_cache_disabled(hw)) {
+		hri_cmcc_write_CTRL_reg(hw, CMCC_CTRL_CEN);
+		return_value = _is_cache_enabled(hw) == true ? ERR_NONE : ERR_FAILURE;
+	} else {
+		return_value = ERR_NO_CHANGE;
+	}
+
+	return return_value;
+}
+
+/**
+ * \brief Cache disable
+ */
+static inline int32_t _cmcc_disable(const void *hw)
+{
+	hri_cmcc_write_CTRL_reg(hw, (CMCC_DISABLE << CMCC_CTRL_CEN_Pos));
+	while (!(_is_cache_disabled(hw)))
+		;
+
+	return ERR_NONE;
+}
+
+/**
+ * \brief Initialize Cache Module
+ *
+ * This function initialize low level cmcc module configuration.
+ *
+ * \return initialize status
+ */
+int32_t _cmcc_init(void);
+
+/**
+ * \brief Configure CMCC module
+ *
+ * \param[in] pointer pointing to the starting address of CMCC module
+ * \param[in] cache configuration structure pointer
+ *
+ * \return status of operation
+ */
+int32_t _cmcc_configure(const void *hw, struct _cache_cfg *cache_ctrl);
+
+/**
+ * \brief Enable data cache in CMCC module
+ *
+ * \param[in] pointer pointing to the starting address of CMCC module
+ * \param[in] boolean 1 -> Enable the data cache, 0 -> disable the data cache
+ *
+ * \return status of operation
+ */
+int32_t _cmcc_enable_data_cache(const void *hw, bool value);
+
+/**
+ * \brief Enable instruction cache in CMCC module
+ *
+ * \param[in] pointer pointing to the starting address of CMCC module
+ * \param[in] boolean 1 -> Enable the inst cache, 0 -> disable the inst cache
+ *
+ * \return status of operation
+ */
+int32_t _cmcc_enable_inst_cache(const void *hw, bool value);
+
+/**
+ * \brief Enable clock gating in CMCC module
+ *
+ * \param[in] pointer pointing to the starting address of CMCC module
+ * \param[in] boolean 1 -> Enable the clock gate, 0 -> disable the clock gate
+ *
+ * \return status of operation
+ */
+int32_t _cmcc_enable_clock_gating(const void *hw, bool value);
+
+/**
+ * \brief Configure the cache size in CMCC module
+ *
+ * \param[in] pointer pointing to the starting address of CMCC module
+ * \param[in] element from cache size configuration enumerator
+ *				0->1K, 1->2K, 2->4K(default)
+ *
+ * \return status of operation
+ */
+int32_t _cmcc_configure_cache_size(const void *hw, enum conf_cache_size size);
+
+/**
+ * \brief Lock the mentioned WAY in CMCC module
+ *
+ * \param[in] pointer pointing to the starting address of CMCC module
+ * \param[in] element from "way_num_index" enumerator
+ *
+ * \return status of operation
+ */
+int32_t _cmcc_lock_way(const void *hw, enum way_num_index);
+
+/**
+ * \brief Unlock the mentioned WAY in CMCC module
+ *
+ * \param[in] pointer pointing to the starting address of CMCC module
+ * \param[in] element from "way_num_index" enumerator
+ *
+ * \return status of operation
+ */
+int32_t _cmcc_unlock_way(const void *hw, enum way_num_index);
+
+/**
+ * \brief Invalidate the mentioned cache line in CMCC module
+ *
+ * \param[in] pointer pointing to the starting address of CMCC module
+ * \param[in] element from "way_num" enumerator (valid arg is 0-3)
+ * \param[in] line number (valid arg is 0-63 as each way will have 64 lines)
+ *
+ * \return status of operation
+ */
+int32_t _cmcc_invalidate_by_line(const void *hw, uint8_t way_num, uint8_t line_num);
+
+/**
+ * \brief Invalidate entire cache entries in CMCC module
+ *
+ * \param[in] pointer pointing to the starting address of CMCC module
+ *
+ * \return status of operation
+ */
+int32_t _cmcc_invalidate_all(const void *hw);
+
+/**
+ * \brief Configure cache monitor in CMCC module
+ *
+ * \param[in] pointer pointing to the starting address of CMCC module
+ * \param[in] element from cache monitor configurations enumerator
+ *
+ * \return status of operation
+ */
+int32_t _cmcc_configure_monitor(const void *hw, enum conf_cache_monitor monitor_cfg);
+
+/**
+ * \brief Enable cache monitor in CMCC module
+ *
+ * \param[in] pointer pointing to the starting address of CMCC module
+ *
+ * \return status of operation
+ */
+int32_t _cmcc_enable_monitor(const void *hw);
+
+/**
+ * \brief Disable cache monitor in CMCC module
+ *
+ * \param[in] pointer pointing to the starting address of CMCC module
+ *
+ * \return status of operation
+ */
+int32_t _cmcc_disable_monitor(const void *hw);
+
+/**
+ * \brief Reset cache monitor in CMCC module
+ *
+ * \param[in] pointer pointing to the starting address of CMCC module
+ *
+ * \return status of operation
+ */
+int32_t _cmcc_reset_monitor(const void *hw);
+
+/**
+ * \brief Get cache monitor event counter value from CMCC module
+ *
+ * \param[in] pointer pointing to the starting address of CMCC module
+ *
+ * \return event counter value
+ */
+uint32_t _cmcc_get_monitor_event_count(const void *hw);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* HPL_CMCC_H_ */
diff --git a/sysmoOCTSIM/hal/include/hpl_core.h b/sysmoOCTSIM/hal/include/hpl_core.h
new file mode 100644
index 0000000..9324c43
--- /dev/null
+++ b/sysmoOCTSIM/hal/include/hpl_core.h
@@ -0,0 +1,56 @@
+/**
+ * \file
+ *
+ * \brief CPU core related functionality declaration.
+ *
+ * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Subject to your compliance with these terms, you may use Microchip
+ * software and any derivatives exclusively with Microchip products.
+ * It is your responsibility to comply with third party license terms applicable
+ * to your use of third party software (including open source software) that
+ * may accompany Microchip software.
+ *
+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE.  TO THE FULLEST EXTENT
+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
+ *
+ * \asf_license_stop
+ *
+ */
+
+#ifndef _HPL_CORE_H_INCLUDED
+#define _HPL_CORE_H_INCLUDED
+
+/**
+ * \addtogroup HPL Core
+ *
+ * \section hpl_core_rev Revision History
+ * - v1.0.0 Initial Release
+ *
+ *@{
+ */
+
+#include "hpl_core_port.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+/**@}*/
+#endif /* _HPL_CORE_H_INCLUDED */
diff --git a/sysmoOCTSIM/hal/include/hpl_delay.h b/sysmoOCTSIM/hal/include/hpl_delay.h
new file mode 100644
index 0000000..a0f1ac8
--- /dev/null
+++ b/sysmoOCTSIM/hal/include/hpl_delay.h
@@ -0,0 +1,97 @@
+/**
+ * \file
+ *
+ * \brief Delay related functionality declaration.
+ *
+ * Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Subject to your compliance with these terms, you may use Microchip
+ * software and any derivatives exclusively with Microchip products.
+ * It is your responsibility to comply with third party license terms applicable
+ * to your use of third party software (including open source software) that
+ * may accompany Microchip software.
+ *
+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE.  TO THE FULLEST EXTENT
+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
+ *
+ * \asf_license_stop
+ *
+ */
+
+#ifndef _HPL_DELAY_H_INCLUDED
+#define _HPL_DELAY_H_INCLUDED
+
+/**
+ * \addtogroup HPL Delay
+ *
+ * \section hpl_delay_rev Revision History
+ * - v1.0.0 Initial Release
+ *
+ *@{
+ */
+
+#ifndef _UNIT_TEST_
+#include <compiler.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \name HPL functions
+ */
+//@{
+
+/**
+ * \brief Initialize delay functionality
+ *
+ * \param[in] hw The pointer to hardware instance
+ */
+void _delay_init(void *const hw);
+
+/**
+ * \brief Retrieve the amount of cycles to delay for the given amount of us
+ *
+ * \param[in] us The amount of us to delay for
+ *
+ * \return The amount of cycles
+ */
+uint32_t _get_cycles_for_us(const uint16_t us);
+
+/**
+ * \brief Retrieve the amount of cycles to delay for the given amount of ms
+ *
+ * \param[in] ms The amount of ms to delay for
+ *
+ * \return The amount of cycles
+ */
+uint32_t _get_cycles_for_ms(const uint16_t ms);
+
+/**
+ * \brief Delay loop to delay n number of cycles
+ *
+ * \param[in] hw The pointer to hardware instance
+ * \param[in] cycles The amount of cycles to delay for
+ */
+void _delay_cycles(void *const hw, uint32_t cycles);
+//@}
+
+#ifdef __cplusplus
+}
+#endif
+/**@}*/
+#endif /* _HPL_DELAY_H_INCLUDED */
diff --git a/sysmoOCTSIM/hal/include/hpl_dma.h b/sysmoOCTSIM/hal/include/hpl_dma.h
new file mode 100644
index 0000000..1e08434
--- /dev/null
+++ b/sysmoOCTSIM/hal/include/hpl_dma.h
@@ -0,0 +1,176 @@
+/**
+ * \file
+ *
+ * \brief DMA related functionality declaration.
+ *
+ * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Subject to your compliance with these terms, you may use Microchip
+ * software and any derivatives exclusively with Microchip products.
+ * It is your responsibility to comply with third party license terms applicable
+ * to your use of third party software (including open source software) that
+ * may accompany Microchip software.
+ *
+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE.  TO THE FULLEST EXTENT
+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
+ *
+ * \asf_license_stop
+ *
+ */
+
+#ifndef _HPL_DMA_H_INCLUDED
+#define _HPL_DMA_H_INCLUDED
+
+/**
+ * \addtogroup HPL DMA
+ *
+ * \section hpl_dma_rev Revision History
+ * - v1.0.0 Initial Release
+ *
+ *@{
+ */
+
+#include <compiler.h>
+#include <hpl_irq.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct _dma_resource;
+
+/**
+ * \brief DMA callback types
+ */
+enum _dma_callback_type { DMA_TRANSFER_COMPLETE_CB, DMA_TRANSFER_ERROR_CB };
+
+/**
+ * \brief DMA interrupt callbacks
+ */
+struct _dma_callbacks {
+	void (*transfer_done)(struct _dma_resource *resource);
+	void (*error)(struct _dma_resource *resource);
+};
+
+/**
+ * \brief DMA resource structure
+ */
+struct _dma_resource {
+	struct _dma_callbacks dma_cb;
+	void *                back;
+};
+
+/**
+ * \brief Initialize DMA
+ *
+ * This function does low level DMA configuration.
+ *
+ * \return initialize status
+ */
+int32_t _dma_init(void);
+
+/**
+ * \brief Set destination address
+ *
+ * \param[in] channel DMA channel to set destination address for
+ * \param[in] dst Destination address
+ *
+ * \return setting status
+ */
+int32_t _dma_set_destination_address(const uint8_t channel, const void *const dst);
+
+/**
+ * \brief Set source address
+ *
+ * \param[in] channel DMA channel to set source address for
+ * \param[in] src Source address
+ *
+ * \return setting status
+ */
+int32_t _dma_set_source_address(const uint8_t channel, const void *const src);
+
+/**
+ * \brief Set next descriptor address
+ *
+ * \param[in] current_channel Current DMA channel to set next descriptor address
+ * \param[in] next_channel Next DMA channel used as next descriptor
+ *
+ * \return setting status
+ */
+int32_t _dma_set_next_descriptor(const uint8_t current_channel, const uint8_t next_channel);
+
+/**
+ * \brief Enable/disable source address incrementation during DMA transaction
+ *
+ * \param[in] channel DMA channel to set source address for
+ * \param[in] enable True to enable, false to disable
+ *
+ * \return status of operation
+ */
+int32_t _dma_srcinc_enable(const uint8_t channel, const bool enable);
+
+/**
+ * \brief Enable/disable Destination address incrementation during DMA transaction
+ *
+ * \param[in] channel DMA channel to set destination address for
+ * \param[in] enable True to enable, false to disable
+ *
+ * \return status of operation
+ */
+int32_t _dma_dstinc_enable(const uint8_t channel, const bool enable);
+/**
+ * \brief Set the amount of data to be transfered per transaction
+ *
+ * \param[in] channel DMA channel to set data amount for
+ * \param[in] amount Data amount
+ *
+ * \return status of operation
+ */
+int32_t _dma_set_data_amount(const uint8_t channel, const uint32_t amount);
+
+/**
+ * \brief Trigger DMA transaction on the given channel
+ *
+ * \param[in] channel DMA channel to trigger transaction on
+ *
+ * \return status of operation
+ */
+int32_t _dma_enable_transaction(const uint8_t channel, const bool software_trigger);
+
+/**
+ * \brief Retrieves DMA resource structure
+ *
+ * \param[out] resource The resource to be retrieved
+ * \param[in] channel DMA channel to retrieve structure for
+ *
+ * \return status of operation
+ */
+int32_t _dma_get_channel_resource(struct _dma_resource **resource, const uint8_t channel);
+
+/**
+ * \brief Enable/disable DMA interrupt
+ *
+ * \param[in] channel DMA channel to enable/disable interrupt for
+ * \param[in] type The type of interrupt to disable/enable if applicable
+ * \param[in] state Enable or disable
+ */
+void _dma_set_irq_state(const uint8_t channel, const enum _dma_callback_type type, const bool state);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* HPL_DMA_H_INCLUDED */
diff --git a/sysmoOCTSIM/hal/include/hpl_gpio.h b/sysmoOCTSIM/hal/include/hpl_gpio.h
new file mode 100644
index 0000000..5cdd387
--- /dev/null
+++ b/sysmoOCTSIM/hal/include/hpl_gpio.h
@@ -0,0 +1,185 @@
+/**
+ * \file
+ *
+ * \brief Port related functionality declaration.
+ *
+ * Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Subject to your compliance with these terms, you may use Microchip
+ * software and any derivatives exclusively with Microchip products.
+ * It is your responsibility to comply with third party license terms applicable
+ * to your use of third party software (including open source software) that
+ * may accompany Microchip software.
+ *
+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE.  TO THE FULLEST EXTENT
+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
+ *
+ * \asf_license_stop
+ *
+ */
+
+#ifndef _HPL_GPIO_H_INCLUDED
+#define _HPL_GPIO_H_INCLUDED
+
+/**
+ * \addtogroup HPL Port
+ *
+ * \section hpl_port_rev Revision History
+ * - v1.0.0 Initial Release
+ *
+ *@{
+ */
+
+#include <compiler.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+/**
+ * \brief Macros for the pin and port group, lower 5
+ * bits stands for pin number in the group, higher 3
+ * bits stands for port group
+ */
+#define GPIO_PIN(n) (((n)&0x1Fu) << 0)
+#define GPIO_PORT(n) ((n) >> 5)
+#define GPIO(port, pin) ((((port)&0x7u) << 5) + ((pin)&0x1Fu))
+#define GPIO_PIN_FUNCTION_OFF 0xffffffff
+
+/**
+ * \brief PORT pull mode settings
+ */
+enum gpio_pull_mode { GPIO_PULL_OFF, GPIO_PULL_UP, GPIO_PULL_DOWN };
+
+/**
+ * \brief PORT direction settins
+ */
+enum gpio_direction { GPIO_DIRECTION_OFF, GPIO_DIRECTION_IN, GPIO_DIRECTION_OUT };
+
+/**
+ * \brief PORT group abstraction
+ */
+
+enum gpio_port { GPIO_PORTA, GPIO_PORTB, GPIO_PORTC, GPIO_PORTD, GPIO_PORTE };
+
+/**
+ * \name HPL functions
+ */
+//@{
+/**
+ * \brief Port initialization function
+ *
+ * Port initialization function should setup the port module based
+ * on a static configuration file, this function should normally
+ * not be called directly, but is a part of hal_init()
+ */
+void _gpio_init(void);
+
+/**
+ * \brief Set direction on port with mask
+ *
+ * Set data direction for each pin, or disable the pin
+ *
+ * \param[in] port      Ports are grouped into groups of maximum 32 pins,
+ *                      GPIO_PORTA = group 0, GPIO_PORTB = group 1, etc
+ * \param[in] mask      Bit mask where 1 means apply direction setting to the
+ *                      corresponding pin
+ * \param[in] direction GPIO_DIRECTION_OFF  = set pin direction to input
+ *                      and disable input buffer to disable the pin
+ *                      GPIO_DIRECTION_IN   = set pin direction to input
+ *                      and enable input buffer to enable the pin
+ *                      GPIO_DIRECTION_OUT  = set pin direction to output
+ *                      and disable input buffer
+ */
+static inline void _gpio_set_direction(const enum gpio_port port, const uint32_t mask,
+                                       const enum gpio_direction direction);
+
+/**
+ * \brief Set output level on port with mask
+ *
+ * Sets output state on pin to high or low with pin masking
+ *
+ * \param[in] port  Ports are grouped into groups of maximum 32 pins,
+ *                  GPIO_PORTA = group 0, GPIO_PORTB = group 1, etc
+ * \param[in] mask  Bit mask where 1 means apply direction setting to
+ *                  the corresponding pin
+ * \param[in] level true  = pin level is set to 1
+ *                  false = pin level is set to 0
+ */
+static inline void _gpio_set_level(const enum gpio_port port, const uint32_t mask, const bool level);
+
+/**
+ * \brief Change output level to the opposite with mask
+ *
+ * Change pin output level to the opposite with pin masking
+ *
+ * \param[in] port  Ports are grouped into groups of maximum 32 pins,
+ *                  GPIO_PORTA = group 0, GPIO_PORTB = group 1, etc
+ * \param[in] mask  Bit mask where 1 means apply direction setting to
+ *                  the corresponding pin
+ */
+static inline void _gpio_toggle_level(const enum gpio_port port, const uint32_t mask);
+
+/**
+ * \brief Get input levels on all port pins
+ *
+ * Get input level on all port pins, will read IN register if configured to
+ * input and OUT register if configured as output
+ *
+ * \param[in] port  Ports are grouped into groups of maximum 32 pins,
+ *                  GPIO_PORTA = group 0, GPIO_PORTB = group 1, etc
+ */
+static inline uint32_t _gpio_get_level(const enum gpio_port port);
+
+/**
+ * \brief Set pin pull mode
+ *
+ * Set pull mode on a single pin
+ *
+ * \notice This function will automatically change pin direction to input
+ *
+ * \param[in] port      Ports are grouped into groups of maximum 32 pins,
+ *                      GPIO_PORTA = group 0, GPIO_PORTB = group 1, etc
+ * \param[in] pin       The pin in the group that pull mode should be selected
+ *                      for
+ * \param[in] pull_mode GPIO_PULL_OFF  = pull resistor on pin is disabled
+ *                      GPIO_PULL_DOWN = pull resistor on pin will pull pin
+ *                      level to ground level
+ *                      GPIO_PULL_UP   = pull resistor on pin will pull pin
+ *                      level to VCC
+ */
+static inline void _gpio_set_pin_pull_mode(const enum gpio_port port, const uint8_t pin,
+                                           const enum gpio_pull_mode pull_mode);
+
+/**
+ * \brief Set gpio function
+ *
+ * Select which function a gpio is used for
+ *
+ * \param[in] gpio     The gpio to set function for
+ * \param[in] function The gpio function is given by a 32-bit wide bitfield
+ *                     found in the header files for the device
+ *
+ */
+static inline void _gpio_set_pin_function(const uint32_t gpio, const uint32_t function);
+
+#include <hpl_gpio_base.h>
+//@}
+
+#ifdef __cplusplus
+}
+#endif
+/**@}*/
+#endif /* _HPL_GPIO_H_INCLUDED */
diff --git a/sysmoOCTSIM/hal/include/hpl_init.h b/sysmoOCTSIM/hal/include/hpl_init.h
new file mode 100644
index 0000000..71bf49c
--- /dev/null
+++ b/sysmoOCTSIM/hal/include/hpl_init.h
@@ -0,0 +1,124 @@
+/**
+ * \file
+ *
+ * \brief Init related functionality declaration.
+ *
+ * Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Subject to your compliance with these terms, you may use Microchip
+ * software and any derivatives exclusively with Microchip products.
+ * It is your responsibility to comply with third party license terms applicable
+ * to your use of third party software (including open source software) that
+ * may accompany Microchip software.
+ *
+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE.  TO THE FULLEST EXTENT
+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
+ *
+ * \asf_license_stop
+ *
+ */
+
+#ifndef _HPL_INIT_H_INCLUDED
+#define _HPL_INIT_H_INCLUDED
+
+/**
+ * \addtogroup HPL Init
+ *
+ * \section hpl_init_rev Revision History
+ * - v1.0.0 Initial Release
+ *
+ *@{
+ */
+
+#include <compiler.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \name HPL functions
+ */
+//@{
+/**
+ * \brief Initializes clock sources
+ */
+void _sysctrl_init_sources(void);
+
+/**
+ * \brief Initializes Power Manager
+ */
+void _pm_init(void);
+
+/**
+ * \brief Initialize generators
+ */
+void _gclk_init_generators(void);
+
+/**
+ * \brief Initialize 32 kHz clock sources
+ */
+void _osc32kctrl_init_sources(void);
+
+/**
+ * \brief Initialize clock sources
+ */
+void _oscctrl_init_sources(void);
+
+/**
+ * \brief Initialize clock sources that need input reference clocks
+ */
+void _sysctrl_init_referenced_generators(void);
+
+/**
+ * \brief Initialize clock sources that need input reference clocks
+ */
+void _oscctrl_init_referenced_generators(void);
+
+/**
+ * \brief Initialize master clock generator
+ */
+void _mclk_init(void);
+
+/**
+ * \brief Initialize clock generator
+ */
+void _lpmcu_misc_regs_init(void);
+
+/**
+ * \brief Initialize clock generator
+ */
+void _pmc_init(void);
+
+/**
+ * \brief Set performance level
+ *
+ * \param[in] level The performance level to set
+ */
+void _set_performance_level(const uint8_t level);
+
+/**
+ * \brief Initialize the chip
+ */
+void _init_chip(void);
+
+//@}
+
+#ifdef __cplusplus
+}
+#endif
+/**@}*/
+#endif /* _HPL_INIT_H_INCLUDED */
diff --git a/sysmoOCTSIM/hal/include/hpl_irq.h b/sysmoOCTSIM/hal/include/hpl_irq.h
new file mode 100644
index 0000000..2894944
--- /dev/null
+++ b/sysmoOCTSIM/hal/include/hpl_irq.h
@@ -0,0 +1,116 @@
+/**
+ * \file
+ *
+ * \brief IRQ related functionality declaration.
+ *
+ * Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Subject to your compliance with these terms, you may use Microchip
+ * software and any derivatives exclusively with Microchip products.
+ * It is your responsibility to comply with third party license terms applicable
+ * to your use of third party software (including open source software) that
+ * may accompany Microchip software.
+ *
+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE.  TO THE FULLEST EXTENT
+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
+ *
+ * \asf_license_stop
+ *
+ */
+
+#ifndef _HPL_IRQ_H_INCLUDED
+#define _HPL_IRQ_H_INCLUDED
+
+/**
+ * \addtogroup HPL IRQ
+ *
+ * \section hpl_irq_rev Revision History
+ * - v1.0.0 Initial Release
+ *
+ *@{
+ */
+
+#include <compiler.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \brief IRQ descriptor
+ */
+struct _irq_descriptor {
+	void (*handler)(void *parameter);
+	void *parameter;
+};
+
+/**
+ * \name HPL functions
+ */
+//@{
+/**
+ * \brief Retrieve current IRQ number
+ *
+ * \return The current IRQ number
+ */
+uint8_t _irq_get_current(void);
+
+/**
+ * \brief Disable the given IRQ
+ *
+ * \param[in] n The number of IRQ to disable
+ */
+void _irq_disable(uint8_t n);
+
+/**
+ * \brief Set the given IRQ
+ *
+ * \param[in] n The number of IRQ to set
+ */
+void _irq_set(uint8_t n);
+
+/**
+ * \brief Clear the given IRQ
+ *
+ * \param[in] n The number of IRQ to clear
+ */
+void _irq_clear(uint8_t n);
+
+/**
+ * \brief Enable the given IRQ
+ *
+ * \param[in] n The number of IRQ to enable
+ */
+void _irq_enable(uint8_t n);
+
+/**
+ * \brief Register IRQ handler
+ *
+ * \param[in] number The number registered IRQ
+ * \param[in] irq The pointer to irq handler to register
+ *
+ * \return The status of IRQ handler registering
+ * \retval -1 Passed parameters were invalid
+ * \retval 0 The registering is completed successfully
+ */
+void _irq_register(const uint8_t number, struct _irq_descriptor *const irq);
+//@}
+
+#ifdef __cplusplus
+}
+#endif
+/**@}*/
+#endif /* _HPL_IRQ_H_INCLUDED */
diff --git a/sysmoOCTSIM/hal/include/hpl_missing_features.h b/sysmoOCTSIM/hal/include/hpl_missing_features.h
new file mode 100644
index 0000000..7071db2
--- /dev/null
+++ b/sysmoOCTSIM/hal/include/hpl_missing_features.h
@@ -0,0 +1,37 @@
+/**
+ * \file
+ *
+ * \brief Family-dependent missing features expected by HAL
+ *
+ * Copyright (c) 2016-2018 Microchip Technology Inc. and its subsidiaries.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Subject to your compliance with these terms, you may use Microchip
+ * software and any derivatives exclusively with Microchip products.
+ * It is your responsibility to comply with third party license terms applicable
+ * to your use of third party software (including open source software) that
+ * may accompany Microchip software.
+ *
+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE.  TO THE FULLEST EXTENT
+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
+ *
+ * \asf_license_stop
+ *
+ */
+
+#ifndef _HPL_MISSING_FEATURES
+#define _HPL_MISSING_FEATURES
+
+#endif /* _HPL_MISSING_FEATURES */
diff --git a/sysmoOCTSIM/hal/include/hpl_ramecc.h b/sysmoOCTSIM/hal/include/hpl_ramecc.h
new file mode 100644
index 0000000..d79d514
--- /dev/null
+++ b/sysmoOCTSIM/hal/include/hpl_ramecc.h
@@ -0,0 +1,100 @@
+/**
+ * \file
+ *
+ * \brief RAMECC related functionality declaration.
+ *
+ * Copyright (c) 2016-2018 Microchip Technology Inc. and its subsidiaries.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Subject to your compliance with these terms, you may use Microchip
+ * software and any derivatives exclusively with Microchip products.
+ * It is your responsibility to comply with third party license terms applicable
+ * to your use of third party software (including open source software) that
+ * may accompany Microchip software.
+ *
+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE.  TO THE FULLEST EXTENT
+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
+ *
+ * \asf_license_stop
+ *
+ */
+
+#ifndef _HPL_RAMECC_H_INCLUDED
+#define _HPL_RAMECC_H_INCLUDED
+
+/**
+ * \addtogroup HPL RAMECC
+ *
+ * \section hpl_ramecc_rev Revision History
+ * - v1.0.0 Initial Release
+ *
+ *@{
+ */
+
+#include <compiler.h>
+#include <hpl_irq.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \brief RAMECC callback type
+ */
+typedef void (*ramecc_cb_t)(const uint32_t data);
+
+/**
+ * \brief RAMECC callback types
+ */
+enum _ramecc_callback_type { RAMECC_DUAL_ERROR_CB, RAMECC_SINGLE_ERROR_CB };
+
+/**
+ * \brief RAMECC interrupt callbacks
+ */
+struct _ramecc_callbacks {
+	ramecc_cb_t dual_bit_err;
+	ramecc_cb_t single_bit_err;
+};
+
+/**
+ * \brief RAMECC device structure
+ */
+struct _ramecc_device {
+	struct _ramecc_callbacks ramecc_cb;
+	struct _irq_descriptor   irq;
+};
+
+/**
+ * \brief Initialize RAMECC
+ *
+ * This function does low level RAMECC configuration.
+ *
+ * \return initialize status
+ */
+int32_t _ramecc_init(void);
+
+/**
+ * \brief Register RAMECC callback
+ *
+ * \param[in] type The type of callback
+ * \param[in] cb A callback function
+ */
+void _ramecc_register_callback(const enum _ramecc_callback_type type, ramecc_cb_t cb);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _HPL_RAMECC_H_INCLUDED */
diff --git a/sysmoOCTSIM/hal/include/hpl_reset.h b/sysmoOCTSIM/hal/include/hpl_reset.h
new file mode 100644
index 0000000..d627ea6
--- /dev/null
+++ b/sysmoOCTSIM/hal/include/hpl_reset.h
@@ -0,0 +1,93 @@
+/**
+ * \file
+ *
+ * \brief Reset related functionality declaration.
+ *
+ * Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Subject to your compliance with these terms, you may use Microchip
+ * software and any derivatives exclusively with Microchip products.
+ * It is your responsibility to comply with third party license terms applicable
+ * to your use of third party software (including open source software) that
+ * may accompany Microchip software.
+ *
+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE.  TO THE FULLEST EXTENT
+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
+ *
+ * \asf_license_stop
+ *
+ */
+
+#ifndef _HPL_RESET_H_INCLUDED
+#define _HPL_RESET_H_INCLUDED
+
+/**
+ * \addtogroup HPL Reset
+ *
+ * \section hpl_reset_rev Revision History
+ * - v1.0.0 Initial Release
+ *
+ *@{
+ */
+
+#ifndef _UNIT_TEST_
+#include <compiler.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \brief Reset reason enumeration
+ *
+ * The list of possible reset reasons.
+ */
+enum reset_reason {
+	RESET_REASON_POR    = 1,
+	RESET_REASON_BOD12  = 2,
+	RESET_REASON_BOD33  = 4,
+	RESET_REASON_NVM    = 8,
+	RESET_REASON_EXT    = 16,
+	RESET_REASON_WDT    = 32,
+	RESET_REASON_SYST   = 64,
+	RESET_REASON_BACKUP = 128
+};
+
+/**
+ * \name HPL functions
+ */
+//@{
+/**
+ * \brief Retrieve the reset reason
+ *
+ * Retrieves the reset reason of the last MCU reset.
+ *
+ *\return An enum value indicating the reason of the last reset.
+ */
+enum reset_reason _get_reset_reason(void);
+
+/**
+ * \brief Reset MCU
+ */
+void _reset_mcu(void);
+//@}
+
+#ifdef __cplusplus
+}
+#endif
+/**@}*/
+#endif /* _HPL_RESET_H_INCLUDED */
diff --git a/sysmoOCTSIM/hal/include/hpl_sleep.h b/sysmoOCTSIM/hal/include/hpl_sleep.h
new file mode 100644
index 0000000..6731ec3
--- /dev/null
+++ b/sysmoOCTSIM/hal/include/hpl_sleep.h
@@ -0,0 +1,88 @@
+/**
+ * \file
+ *
+ * \brief Sleep related functionality declaration.
+ *
+ * Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Subject to your compliance with these terms, you may use Microchip
+ * software and any derivatives exclusively with Microchip products.
+ * It is your responsibility to comply with third party license terms applicable
+ * to your use of third party software (including open source software) that
+ * may accompany Microchip software.
+ *
+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE.  TO THE FULLEST EXTENT
+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
+ *
+ * \asf_license_stop
+ *
+ */
+
+#ifndef _HPL_SLEEP_H_INCLUDED
+#define _HPL_SLEEP_H_INCLUDED
+
+/**
+ * \addtogroup HPL Sleep
+ *
+ * \section hpl_sleep_rev Revision History
+ * - v1.0.0 Initial Release
+ *
+ *@{
+ */
+
+#ifndef _UNIT_TEST_
+#include <compiler.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \name HPL functions
+ */
+//@{
+/**
+ * \brief Set the sleep mode for the device
+ *
+ * This function sets the sleep mode for the device.
+ * For an overview of which systems are disabled in sleep for the different
+ * sleep modes see datasheet.
+ *
+ * \param[in] mode Sleep mode to use
+ *
+ * \return the status of a sleep request
+ * \retval -1 The requested sleep mode was invalid
+ * \retval  0 The operation completed successfully, sleep mode is set
+ */
+int32_t _set_sleep_mode(const uint8_t mode);
+
+/**
+ * \brief Reset MCU
+ */
+void _reset_mcu(void);
+
+/**
+ * \brief Put MCU to sleep
+ */
+void _go_to_sleep(void);
+//@}
+
+#ifdef __cplusplus
+}
+#endif
+/**@}*/
+#endif /* _HPL_SLEEP_H_INCLUDED */
diff --git a/sysmoOCTSIM/hal/include/hpl_usb.h b/sysmoOCTSIM/hal/include/hpl_usb.h
new file mode 100644
index 0000000..2e165d7
--- /dev/null
+++ b/sysmoOCTSIM/hal/include/hpl_usb.h
@@ -0,0 +1,270 @@
+/**
+ * \file
+ *
+ * \brief SAM USB HPL
+ *
+ * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Subject to your compliance with these terms, you may use Microchip
+ * software and any derivatives exclusively with Microchip products.
+ * It is your responsibility to comply with third party license terms applicable
+ * to your use of third party software (including open source software) that
+ * may accompany Microchip software.
+ *
+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE.  TO THE FULLEST EXTENT
+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
+ *
+ * \asf_license_stop
+ *
+ */
+
+#ifndef _HPL_USB_H_INCLUDED
+#define _HPL_USB_H_INCLUDED
+
+#include <compiler.h>
+#include <utils.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** \name USB Spec definitions */
+/*@{*/
+
+/** Return 8-bit unsigned USB data. */
+#define USB_GET_U8(addr, offset) (((uint8_t *)(addr))[(offset)])
+
+/** Return 16-bit unsigned USB data. */
+#define USB_GET_U16(addr, offset) ((((uint8_t *)(addr))[(offset) + 0] << 0) + (((uint8_t *)(addr))[(offset) + 1] << 8))
+
+/** Return 32-bit unsigned USB data. */
+#define USB_GET_U32(addr, offset)                                                                                      \
+	((((uint8_t *)(addr))[(offset) + 0] << 0) + (((uint8_t *)(addr))[(offset) + 1] << 8)                               \
+	 + (((uint8_t *)(addr))[(offset) + 2] << 16) + (((uint8_t *)(addr))[(offset) + 3] << 32))
+
+/** Offset of bmRequestType in USB request buffer. */
+#define USB_bmRequestType_Offset 0
+
+/** Offset of bRequest in USB request buffer. */
+#define USB_bRequest_Offset 1
+
+/** Offset of wValue in USB request buffer. */
+#define USB_wValue_Offset 2
+
+/** Offset of wIndex in USB request buffer. */
+#define USB_wIndex_Offset 4
+
+/** Offset of wLength in USB request buffer. */
+#define USB_wLength_Offset 6
+
+/** Get value of bmRequestType from USB request. */
+#define USB_GET_bmRequestType(req) USB_GET_U8((req), USB_bmRequestType_Offset)
+
+/** Get value of bRequest from USB request. */
+#define USB_GET_bRequest(req) USB_GET_U8((req), USB_bRequest_Offset)
+
+/** Get value of wValue from USB request. */
+#define USB_GET_wValue(req) USB_GET_U16((req), USB_wValue_Offset)
+
+/** Get value of wIndex from USB request. */
+#define USB_GET_wIndex(req) USB_GET_U16((req), USB_wIndex_Offset)
+
+/** Get value of wLength from USB request. */
+#define USB_GET_wLength(req) USB_GET_U16((req), USB_wLength_Offset)
+
+/** USB request IN indication of bmRequestType. */
+#define USB_REQ_TYPE_IN 0x80u
+
+/** USB endpoint number mask of bEndpointAddress. */
+#define USB_EP_N_MASK 0x0Fu
+
+/** USB endpoint direction bit of bEndpointAddress. */
+#define USB_EP_DIR 0x80u
+
+/** Get USB endpoint direction from endpoint address. */
+#define USB_EP_GET_DIR(ep_addr) ((ep_addr)&USB_EP_DIR)
+
+/** Get USB endpoint number from endpoint address. */
+#define USB_EP_GET_N(ep_addr) ((ep_addr)&USB_EP_N_MASK)
+
+/** Transfer type in EP descriptor bmAttributes: Control. */
+#define USB_EP_XTYPE_CTRL 0x0
+
+/** Transfer type in EP descriptor bmAttributes: Isochronous. */
+#define USB_EP_XTYPE_ISOCH 0x1
+
+/** Transfer type in EP descriptor bmAttributes: Bulk. */
+#define USB_EP_XTYPE_BULK 0x2
+
+/** Transfer type in EP descriptor bmAttributes: Interrupt. */
+#define USB_EP_XTYPE_INTERRUPT 0x3
+
+/** Transfer type mask in EP descriptor bmAttributes. */
+#define USB_EP_XTYPE_MASK 0x3u
+
+/*@}*/
+
+/** \name USB status codes
+ *@{
+ */
+/** USB operation is done successfully. */
+#define USB_OK 0
+/** USB (endpoint) is busy. */
+#define USB_BUSY 1
+/** USB (endpoint) is halted. */
+#define USB_HALTED 2
+
+/** General error. */
+#define USB_ERROR 0x10
+/** Operation is denied by hardware (e.g., syncing). */
+#define USB_ERR_DENIED 0x11
+/** Input parameter error. */
+#define USB_ERR_PARAM 0x12
+/** Functionality is not supported (e.g., initialize endpoint without cache to be control). */
+#define USB_ERR_FUNC 0x13
+/** Re-initialize, re-enable ... */
+#define USB_ERR_REDO 0x14
+/** Not enough resource (memory, endpoints ...). */
+#define USB_ERR_ALLOC_FAIL 0x15
+/*@}*/
+
+/** USB speed. */
+enum usb_speed {
+	/** USB Low Speed. */
+	USB_SPEED_LS,
+	/** USB Full Speed. */
+	USB_SPEED_FS,
+	/** USB High Speed. */
+	USB_SPEED_HS,
+	/** USB Super Speed. */
+	USB_SPEED_SS
+};
+
+/** USB transaction type. */
+enum usb_trans_type {
+	/** USB SETUP transaction. */
+	USB_TRANS_SETUP,
+	/** USB IN transaction. */
+	USB_TRANS_IN,
+	/** USB OUT transaction. */
+	USB_TRANS_OUT
+};
+
+/** USB events that generates the device callbacks. */
+enum usb_event {
+	/** USB VBus changed, with parameter as present/not present. */
+	USB_EV_VBUS,
+	/** USB RESET detected on bus. */
+	USB_EV_RESET,
+	/** USB wakeup. */
+	USB_EV_WAKEUP,
+	/** USB LPM suspend, with parameter as \ref usb_lpm_attributes. */
+	USB_EV_LPM_SUSPEND,
+	/** USB suspend. */
+	USB_EV_SUSPEND,
+	/** USB error, with parameter as error code. */
+	USB_EV_ERROR,
+	/** Number of USB event types. */
+	USB_EV_N
+};
+
+/** Control action for USB device endpoint stall. */
+enum usb_ep_stall_ctrl {
+	/** Clear stall of the endpoint. */
+	USB_EP_STALL_CLR,
+	/** Stall the endpoint. */
+	USB_EP_STALL_SET,
+	/** Return the stall status. */
+	USB_EP_STALL_GET
+};
+
+/** Control action for USB device endpoint halt. */
+enum usb_ep_halt_ctrl {
+	/** Clear halt of the endpoint. */
+	USB_EP_HALT_CLR = USB_EP_STALL_CLR,
+	/** Stall the endpoint. */
+	USB_EP_HALT_SET = USB_EP_STALL_SET,
+	/** Return the halt status. */
+	USB_EP_HALT_GET = USB_EP_STALL_GET
+};
+
+/** USB transactions status codes. */
+enum usb_trans_code {
+	/** TX or RX has been done without error. */
+	USB_TRANS_DONE,
+	/** The endpoint is stalled. */
+	USB_TRANS_STALL,
+	/** The endpoint transactions are aborted (cancel, control setup/status). */
+	USB_TRANS_ABORT,
+	/** The endpoint transactions are aborted by reset/disable. */
+	USB_TRANS_RESET,
+	/** Error is reported on the endpoint. */
+	USB_TRANS_ERROR
+};
+
+/** Transfer status codes. */
+enum usb_xfer_code {
+	/** Transfer is done without error, for ctrl it means status packet done. */
+	USB_XFER_DONE,
+	/** For control transfer only, data stage is done without error. */
+	USB_XFER_DATA,
+	/** Endpoint stall is set. */
+	USB_XFER_HALT,
+	/** Endpoint stall is cleared. */
+	USB_XFER_UNHALT,
+	/** Transfer is aborted. */
+	USB_XFER_ABORT,
+	/** Transfer is aborted because endpoint reset/disable. */
+	USB_XFER_RESET,
+	/** There was an error. */
+	USB_XFER_ERROR
+};
+
+/** USB endpoint errors. */
+enum usb_ep_error {
+	/** No error. */
+	USB_EP_NO_ERROR,
+	/** CRC error. */
+	USB_EP_ERR_CRC,
+	/** Endpoint transfer overflow. */
+	USB_EP_ERR_OVERFLOW,
+	/** Other endpoint errors. */
+	USB_EP_ERR_GENERAL
+};
+
+/** Endpoint transfer state. */
+enum usb_ep_state {
+	/** Endpoint is disabled. */
+	USB_EP_S_DISABLED,
+	/** Endpoint is not busy. */
+	USB_EP_S_IDLE,
+	/** Control transfer only, endpoint is transferring setup packet. */
+	USB_EP_S_X_SETUP,
+	/** Endpoint is transferring data. */
+	USB_EP_S_X_DATA,
+	/** Control transfer only, endpoint is in status stage. */
+	USB_EP_S_X_STATUS,
+	/** Endpoint is halted. */
+	USB_EP_S_HALTED,
+	/** Endpoint error. */
+	USB_EP_S_ERROR
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _HPL_USB_H_INCLUDED */
diff --git a/sysmoOCTSIM/hal/include/hpl_usb_device.h b/sysmoOCTSIM/hal/include/hpl_usb_device.h
new file mode 100644
index 0000000..43dd17f
--- /dev/null
+++ b/sysmoOCTSIM/hal/include/hpl_usb_device.h
@@ -0,0 +1,377 @@
+/**
+ * \file
+ *
+ * \brief SAM USB HPL
+ *
+ * Copyright (c) 2016-2018 Microchip Technology Inc. and its subsidiaries.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Subject to your compliance with these terms, you may use Microchip
+ * software and any derivatives exclusively with Microchip products.
+ * It is your responsibility to comply with third party license terms applicable
+ * to your use of third party software (including open source software) that
+ * may accompany Microchip software.
+ *
+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE.  TO THE FULLEST EXTENT
+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
+ *
+ * \asf_license_stop
+ *
+ */
+
+#ifndef _HPL_USB_DEVICE_H_INCLUDED
+#define _HPL_USB_DEVICE_H_INCLUDED
+
+#include <hpl_usb.h>
+#include "hpl_usb_config.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** USB Device callback type. */
+enum usb_d_cb_type {
+	/** USB device SOF callback. */
+	USB_D_CB_SOF,
+	/** USB device events callbacks. */
+	USB_D_CB_EVENT,
+	/** Number of types of USB device callback types. */
+	USB_D_CB_N
+};
+
+/** USB Device endpoint callback type. */
+enum usb_d_ep_cb_type {
+	/** USB device endpoint setup callback. */
+	USB_D_EP_CB_SETUP,
+	/** USB device endpoint more data callback. */
+	USB_D_EP_CB_MORE,
+	/** USB device endpoint transaction done or error callback. */
+	USB_D_EP_CB_XFER,
+	/** Number of types of USB device endpoint callback types. */
+	USB_D_EP_CB_N
+};
+
+/** Control action for USB device LPM handshake. */
+enum usb_d_lpm_ctrl {
+	/** No LPM handshake, not supported. */
+	USB_D_LPM_DISABLE,
+	/** ACK the LPM transaction. */
+	USB_D_LPM_ACK,
+	/** NYET the LPM transaction. */
+	USB_D_LPM_NYET
+};
+
+/**
+ *  USB device transfer descriptor.
+ */
+struct usb_d_transfer {
+	/** Pointer to data buffer to transfer.
+	 *  Note that it's recommended that the buffer is 32-bit aligned since
+	 *  some of USB peripheral require this.
+	 */
+	uint8_t *buf;
+	/** Transfer size, in number of bytes.
+	 *  Note that it's recommended that the buffer size is 32-bit aligned
+	 *  (modeled by 4) since some of USB peripheral require this.
+	 */
+	uint32_t size;
+	/** Endpoint address. */
+	uint8_t ep;
+	/** Append ZLP for IN transfer, wait ZLP for OUT transfer. */
+	uint8_t zlp;
+};
+
+/** USB device transactions status structure. */
+struct usb_d_trans_status {
+	/** Total data size. */
+	uint32_t size;
+	/** Total transfered data count. */
+	uint32_t count;
+	/** Endpoint address. */
+	uint8_t ep;
+	/** Endpoint type - CTRL/ISO/INT/BULK. */
+	uint8_t xtype : 2;
+	/** Transactions state, busy or not. */
+	uint8_t busy : 1;
+	/** Transactions state, setup received or not. */
+	uint8_t setup : 1;
+	/** Transactions state, stall or not. */
+	uint8_t stall : 1;
+	/** Transactions direction. */
+	uint8_t dir : 1;
+};
+
+/** Prototype function for callback that is invoked on USB device SOF. */
+typedef void (*_usb_d_dev_sof_cb_t)(void);
+
+/** Prototype function for callback that is invoked on USB device events. */
+typedef void (*_usb_d_dev_event_cb_t)(const enum usb_event, const uint32_t param);
+
+/** HPL USB device callbacks. */
+struct _usb_d_dev_callbacks {
+	/** Callback that is invoked on SOF. */
+	_usb_d_dev_sof_cb_t sof;
+	/** Callback that is invoked on USB RESET/WAKEUP/RESUME/SUSPEND. */
+	_usb_d_dev_event_cb_t event;
+};
+
+/** USB device endpoint callbacks. */
+enum usb_d_dev_ep_cb_type {
+	/** Setup packet is received. */
+	USB_D_DEV_EP_CB_SETUP,
+	/** Try to require more data. */
+	USB_D_DEV_EP_CB_MORE,
+	/** Transaction done OK/ERROR. */
+	USB_D_DEV_EP_CB_DONE,
+	/** Number of device endpoint callbacks. */
+	USB_D_DEV_EP_CB_N
+};
+
+/**
+ *  Callback that is invoked when control SETUP packet has bee received.
+ *  \ref _usb_d_dev_ep_read_req() must be invoked to read setup data, and allow
+ *  IN/OUT transactions on control endpoint.
+ */
+typedef void (*_usb_d_dev_ep_cb_setup_t)(const uint8_t ep);
+
+/** Callback that is invoked when buffer is done, but last packet is full size
+ *  packet without ZLP. Return \c true if more data has been requested. */
+typedef bool (*_usb_d_dev_ep_cb_more_t)(const uint8_t ep, const uint32_t transfered);
+
+/** Callback that is invoked when all data is finished, including background
+ *  transfer, or error happens. */
+typedef void (*_usb_d_dev_ep_cb_done_t)(const uint8_t ep, const int32_t code, const uint32_t transfered);
+
+/** Callbacks for HPL USB device endpoint. */
+struct _usb_d_dev_ep_callbacks {
+	/** Callback that is invoked when SETUP packet is received.
+	 *  \ref _usb_d_dev_ep_read_req() must be invoked to read setup data, and
+	 *  allow IN/OUT transactions on control endpoint.
+	 */
+	_usb_d_dev_ep_cb_setup_t setup;
+	/** Callback that is invoked to check if buffer is NULL and more data is
+	 *  required.
+	 *  It's called when last packet is full size packet, without
+	 *  auto ZLP enabled.
+	 *  It could be called when background transfer is still in progress.
+	 */
+	_usb_d_dev_ep_cb_more_t more;
+	/** Callback that is invoked when transaction is done, including background
+	 *  transfer, or error occurs.
+	 */
+	_usb_d_dev_ep_cb_done_t done;
+};
+
+/**
+ * \brief Initialize the USB device instance
+ * \return Operation result status.
+ * \retval 0 Success.
+ * \retval <0 Error code.
+ */
+int32_t _usb_d_dev_init(void);
+
+/**
+ * \brief Deinitialize the USB device instance
+ * \return Operation result status.
+ * \retval 0 Success.
+ * \retval <0 Error code.
+ */
+void _usb_d_dev_deinit(void);
+
+/**
+ * \brief Register callback to handle USB device events
+ * \param[in] type Callback type. See \ref usb_d_cb_type.
+ * \param[in] func Pointer to callback function.
+ *         Refer to \ref _usb_d_dev_callbacks for the prototypes.
+ */
+void _usb_d_dev_register_callback(const enum usb_d_cb_type type, const FUNC_PTR func);
+
+/**
+ * \brief Register callback to handle USB device endpoint events
+ * \param[in] type Callback type. See \ref usb_d_dev_ep_cb_type.
+ * \param[in] func Pointer to callback function.
+ *         Refer to \ref _usb_d_dev_ep_callbacks for the prototypes.
+ */
+void _usb_d_dev_register_ep_callback(const enum usb_d_dev_ep_cb_type type, const FUNC_PTR func);
+
+/**
+ * \brief Enable the USB device
+ * \return Operation result status.
+ * \retval 0 Success.
+ * \retval <0 Error code.
+ */
+int32_t _usb_d_dev_enable(void);
+
+/**
+ * \brief Disable the USB device
+ * \return Operation result status.
+ * \retval 0 Success.
+ * \retval <0 Error code.
+ */
+int32_t _usb_d_dev_disable(void);
+
+/**
+ * \brief Attach the USB device
+ */
+void _usb_d_dev_attach(void);
+
+/**
+ * \brief Detach the USB device
+ */
+void _usb_d_dev_detach(void);
+
+/**
+ * \brief Send the USB device remote wakeup to host
+ */
+void _usb_d_dev_send_remotewakeup(void);
+
+/**
+ * \brief Get the USB device working speed
+ * \return USB speed. See \ref usb_speed.
+ */
+enum usb_speed _usb_d_dev_get_speed(void);
+
+/**
+ * \brief Set the USB device address
+ * \param[in] addr Address to be used.
+ */
+void _usb_d_dev_set_address(const uint8_t addr);
+
+/**
+ * \brief Get the USB device address
+ * \return Address that is used.
+ */
+uint8_t _usb_d_dev_get_address(void);
+
+/**
+ * \brief Get the USB device frame number
+ * \return The frame number.
+ */
+uint16_t _usb_d_dev_get_frame_n(void);
+
+/**
+ * \brief Get the USB device micro frame number
+ * \return The micro frame number inside one frame (0~7).
+ */
+uint8_t _usb_d_dev_get_uframe_n(void);
+
+/**
+ * \brief Initialize and enable the USB device default endpoint 0
+ * \param[in] max_pkt_siz Max endpoint size.
+ * \return Operation result status.
+ * \retval 0 Success.
+ * \retval <0 Error code.
+ */
+int32_t _usb_d_dev_ep0_init(const uint8_t max_pkt_siz);
+
+/**
+ * \brief Initialize and enable the USB device endpoint
+ * \param[in] ep Endpoint address,
+ *               see endpoint descriptor details in USB spec.
+ * \param[in] attr Endpoint attributes,
+ *                 see endpoint descriptor details in USB spec.
+ * \param[in] max_pkt_siz Endpoint size,
+ *                        see endpoint descriptor details in USB spec.
+ * \return Operation result status.
+ * \retval 0 Success.
+ * \retval <0 Error code.
+ */
+int32_t _usb_d_dev_ep_init(const uint8_t ep, const uint8_t attr, uint16_t max_pkt_siz);
+
+/**
+ * \brief Disable and deinitialize the USB device endpoint
+
+ * \param[in] ep The endpoint to deinitialize.
+ */
+void _usb_d_dev_ep_deinit(const uint8_t ep);
+
+/**
+ * \brief Enable the endpoint
+ * \param[in] ep The endpoint to enable.
+ * \return Operation result status.
+ * \retval 0 Success.
+ * \retval <0 Error code.
+ */
+int32_t _usb_d_dev_ep_enable(const uint8_t ep);
+
+/**
+ * \brief Disable the endpoint
+ * \param[in] ep The endpoint to disable.
+ */
+void _usb_d_dev_ep_disable(const uint8_t ep);
+
+/**
+ * \brief Set/Clear/Get USB device endpoint stall status
+ * \param[in] ep Endpoint address.
+ * \param[in] ctrl Operation selector. See \ref usb_ep_stall_ctrl.
+ * \return Operation result or stall status.
+ * \retval 0 Success or not stall.
+ * \retval 1 Endpoint is stalled.
+ * \retval -1 error.
+ */
+int32_t _usb_d_dev_ep_stall(const uint8_t ep, const enum usb_ep_stall_ctrl ctrl);
+
+/**
+ * \brief Read setup request data from specific endpoint
+ * \param[in] ep Endpoint address.
+ * \param[out] req_buf Pointer to buffer to locate the setup packet.
+ * \return Number of bytes or error code.
+ * \retval <0 error code.
+ * \retval 0 No setup packet ready for read.
+ * \retval >0 Size of bytes read, and ready to start IN/OUT. Note that if
+ *         this number is over 8, only first 8 bytes will be copied.
+ */
+int32_t _usb_d_dev_ep_read_req(const uint8_t ep, uint8_t *req_buf);
+
+/**
+ * \brief Start USB device transfer
+ *
+ * On different USB peripheral hardware the transaction buffer address and size
+ * may have different constraints. E.g., some hardware may require input address
+ * 32-bit aligned, and input size 32-bit aligned. Refer to the corresponding
+ * hardware usage reference documents.
+ * The constraints are checked in implementation, with error code returned.
+ *
+ * \param[in] trans Pointer to the transaction description.
+ * \return Operation result status.
+ * \retval 1 Busy.
+ * \retval 0 Success.
+ * \retval <0 Error code.
+ */
+int32_t _usb_d_dev_ep_trans(const struct usb_d_transfer *trans);
+
+/**
+ * \brief Abort pending USB device transaction on specific endpoint
+ * \param[in] ep Endpoint address to abort.
+ */
+void _usb_d_dev_ep_abort(const uint8_t ep);
+
+/**
+ * \brief Retrieve endpoint status.
+ * \param[in] ep Endpoint address.
+ * \param[out] stat Pointer to buffer to fill status description.
+ * \return Status.
+ * \retval 2 Packet writing.
+ * \retval 1 Busy.
+ * \retval 0 Ready.
+ * \retval <0 Error code.
+ */
+int32_t _usb_d_dev_ep_get_status(const uint8_t ep, struct usb_d_trans_status *stat);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _HPL_USB_DEVICE_H_INCLUDED */
diff --git a/sysmoOCTSIM/hal/include/hpl_usb_host.h b/sysmoOCTSIM/hal/include/hpl_usb_host.h
new file mode 100644
index 0000000..635950b
--- /dev/null
+++ b/sysmoOCTSIM/hal/include/hpl_usb_host.h
@@ -0,0 +1,618 @@
+/**
+ * \file
+ *
+ * \brief SAM USB host HPL
+ *
+ * Copyright (c) 2016-2018 Microchip Technology Inc. and its subsidiaries.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Subject to your compliance with these terms, you may use Microchip
+ * software and any derivatives exclusively with Microchip products.
+ * It is your responsibility to comply with third party license terms applicable
+ * to your use of third party software (including open source software) that
+ * may accompany Microchip software.
+ *
+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE.  TO THE FULLEST EXTENT
+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
+ *
+ * \asf_license_stop
+ *
+ */
+
+#ifndef _HPL_USB_HOST_H_INCLUDED
+#define _HPL_USB_HOST_H_INCLUDED
+
+#include <hpl_usb.h>
+#include <hpl_irq.h>
+#include "hpl_usb_config.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** Driver version */
+#define USB_H_VERSION 0x00000001
+
+/**
+ * @brief      USB HCD callback types
+ */
+enum usb_h_cb_type {
+	/** SOF generated */
+	USB_H_CB_SOF,
+	/** Root Hub change detected */
+	USB_H_CB_ROOTHUB_CHANGE,
+	/** Number of USB HCD callback types */
+	USB_H_CB_N
+};
+
+/**
+ * @brief      USB HCD resource strategy
+ */
+enum usb_h_rsc_strategy {
+	/** Normal resource allocation, e.g.,
+	 *  1 bank for interrupt endpoint,
+	 *  2 bank for bulk endpoint and normal iso endpoint,
+	 *  3 bank for iso high bandwidth endpoint.
+	 */
+	USB_H_RSC_NORMAL = false,
+	/** Minimal resource allocation, e.g., only 1 bank for bulk endpoints */
+	USB_H_RSC_MINIMAL = true
+};
+
+/**
+ * @brief      USB HCD pipe states
+ */
+enum usb_h_pipe_state {
+	/** Pipe is free to allocate */
+	USB_H_PIPE_S_FREE = 0x00,
+	/** Pipe is in configuration */
+	USB_H_PIPE_S_CFG = 0x01,
+	/** Pipe is allocated and idle */
+	USB_H_PIPE_S_IDLE = 0x02,
+	/** Pipe in control setup stage */
+	USB_H_PIPE_S_SETUP = 0x03,
+	/** Pipe in data IN stage */
+	USB_H_PIPE_S_DATI = 0x05,
+	/** Pipe in data OUT stage */
+	USB_H_PIPE_S_DATO = 0x06,
+	/** Pipe in data IN ZLP stage */
+	USB_H_PIPE_S_ZLPI = 0x07,
+	/** Pipe in data OUT ZLP stage */
+	USB_H_PIPE_S_ZLPO = 0x08,
+	/** Pipe in control status IN stage */
+	USB_H_PIPE_S_STATI = 0x09,
+	/** Pipe in control status OUT stage */
+	USB_H_PIPE_S_STATO = 0x0A,
+	/** Taken by physical pipe (in process) */
+	USB_H_PIPE_S_TAKEN = 0x10
+};
+
+/**
+ * @brief      USB HCD status code
+ */
+enum usb_h_status {
+	/** OK */
+	USB_H_OK = ERR_NONE,
+	/** Busy */
+	USB_H_BUSY = ERR_BUSY,
+	/** Denied */
+	USB_H_DENIED = ERR_DENIED,
+	/** Timeout */
+	USB_H_TIMEOUT = ERR_TIMEOUT,
+	/** Abort */
+	USB_H_ABORT = ERR_ABORTED,
+	/** Stall protocol */
+	USB_H_STALL = ERR_PROTOCOL,
+	/** Transfer reset by pipe re-configure */
+	USB_H_RESET = ERR_REQ_FLUSHED,
+	/** Argument error */
+	USB_H_ERR_ARG = ERR_INVALID_ARG,
+	/** Operation not supported */
+	USB_H_ERR_UNSP_OP = ERR_UNSUPPORTED_OP,
+	/** No resource */
+	USB_H_ERR_NO_RSC = ERR_NO_RESOURCE,
+	/** Not initialized */
+	USB_H_ERR_NOT_INIT = ERR_NOT_INITIALIZED,
+	/** Some general error */
+	USB_H_ERR = ERR_IO
+};
+
+/** Forward declare for pipe structure */
+struct usb_h_pipe;
+
+/** Forward declare for driver descriptor structure */
+struct usb_h_desc;
+
+/**
+ * \brief Prototyping USB HCD callback of SOF
+ */
+typedef void (*usb_h_cb_sof_t)(struct usb_h_desc *drv);
+
+/**
+ * \brief Prototyping USB HCD callback of root hub changing.
+ * According to the bitmap size, max port number is 31.
+ */
+typedef void (*usb_h_cb_roothub_t)(struct usb_h_desc *drv, uint8_t port, uint8_t ftr);
+
+/**
+ * Prototyping USB HCD callback of pipe transfer done.
+ * For control pipe, it's forced to call even if there is no transfer
+ * in progress, since the pipe size could be changed at run time.
+ */
+typedef void (*usb_h_pipe_cb_xfer_t)(struct usb_h_pipe *pipe);
+
+/** Access to max packet size of a pipe */
+#define usb_h_pipe_max_pkt_size(p) (p->max_pkt_size)
+
+/** Access to device address of a pipe */
+#define usb_h_pipe_dev_addr(p) (p->dev)
+
+/** Access to endpoint address of a pipe */
+#define usb_h_pipe_ep_addr(p) (p->ep)
+
+/** Access to state of a pipe */
+#define usb_h_pipe_state(p) (p->x.general.state)
+
+/** Access to status of a pipe */
+#define usb_h_pipe_status(p) (p->x.general.status)
+
+/**
+ * @brief      USB Host Controller device structure
+ */
+struct usb_h_desc {
+	/** Pointer to hardware base */
+	void *hw;
+	/** Pointer to private data for Host Controller driver */
+	void *prvt;
+	/** Interrupt handling descriptor */
+	struct _irq_descriptor irq;
+	/** Callback of SOF */
+	usb_h_cb_sof_t sof_cb;
+	/** Callback of root hub change */
+	usb_h_cb_roothub_t rh_cb;
+#if CONF_USB_H_INST_OWNER_SP
+	/** Extension for the driver owner (upper layer user) */
+	void *owner;
+#endif
+};
+
+/**
+ * @brief      Transfer descriptor for control transfer
+ *
+ * Timing in USB 2.0 spec.:
+ * - 9.2.6.1 : USB sets an upper limit of 5 seconds as the upper limit for any
+ *             command to be processed.
+ * - 9.2.6.3 : if a device receives a SetAddress() request, the device must be
+ *             able to complete processing of the request and be able to
+ *             successfully complete the Status stage of the request within
+ *             50 ms.
+ *             After successful completion of the Status stage, the device is
+ *             allowed a SetAddress() recovery interval of 2 ms. At the end of
+ *             this interval, the device must be able to accept Setup packets
+ *             addressed to the new address.
+ * - 9.2.6.4 : For standard device requests that require no Data stage, a device
+ *             must be able to complete the request and be able to successfully
+ *             complete the Status stage of the request within 50 ms of receipt
+ *             of the request. This limitation applies to requests to the
+ *             device, interface, or endpoint.
+ *             For standard device requests that require data stage transfer to
+ *             the host, the device must be able to return the first data packet
+ *             to the host within 500 ms of receipt of the request. For
+ *             subsequent data packets, if any, the device must be able to
+ *             return them within 500 ms of successful completion of the
+ *             transmission of the previous packet. The device must then be
+ *             able to successfully complete the status stage within 50 ms after
+ *             returning the last data packet.
+ *             For standard device requests that require a data stage transfer
+ *             to the device, the 5-second limit applies.
+ * - 9.2.6.5 : Unless specifically exempted in the class document, all
+ *             class-specific requests must meet the timing limitations for
+ *             standard device requests.
+ *
+ * Conclusion:
+ * 1. Whole request with data: 5 seconds
+ * 2. Whole request without data: 50 ms
+ * 3. Data packets: 500 ms
+ */
+struct usb_h_ctrl_xfer {
+	/** Pointer to transfer data */
+	uint8_t *data;
+	/** Pointer to setup packet */
+	uint8_t *setup;
+	/** Expected transfer size */
+	uint16_t size;
+	/** Transfer count */
+	uint16_t count;
+	/** Timeout for request, -1 if disable timeout */
+	int16_t req_timeout;
+	/** Timeout between packets
+	 *  (500ms for data and 50ms for status), -1 if disabled */
+	int16_t pkt_timeout;
+	/** Packet size during transfer (<= allocate max packet size) */
+	uint16_t pkt_size;
+
+	/** Transfer state */
+	uint8_t state;
+	/** Last transfer status */
+	int8_t status;
+};
+
+/**
+ * @brief      Transfer descriptor for bulk / interrupt / iso transfer
+ */
+struct usb_h_bulk_int_iso_xfer {
+	/** Expected transfer size */
+	uint32_t size;
+	/** Transfer count */
+	uint32_t count;
+	/** Pointer to transfer data */
+	uint8_t *data;
+	/** Reserved */
+	uint16_t reserved[3];
+
+	/** Transfer state */
+	uint8_t state;
+	/** Last transfer status */
+	int8_t status;
+};
+
+/**
+ * @brief      Transfer descriptor for periodic high bandwidth transfer
+ */
+struct usb_h_high_bw_xfer {
+	/** Expected transfer size */
+	uint32_t size;
+	/** Transfer count */
+	uint32_t count;
+	/** Pointer to transfer data */
+	uint8_t *data;
+	/** Micro frame packet sizes */
+	uint16_t pkt_size[3];
+
+	/** Transfer state */
+	uint8_t state;
+	/** Last transfer status */
+	int8_t status;
+};
+
+/**
+ * @brief General transfer descriptor
+ */
+struct usb_h_xfer {
+	/** Reserved for different transfer */
+	union {
+		uint16_t u16[9];
+		uint8_t  u8[18];
+	} reserved;
+	/** Transfer state */
+	uint8_t state;
+	/** Last transfer status */
+	int8_t status;
+};
+
+/**
+ * @brief      USB Host Controller Driver Pipe structure
+ */
+struct usb_h_pipe {
+	/** Pointer to the USB Host Controller Driver */
+	struct usb_h_desc *hcd;
+	/** Pointer to the callback for transfer done */
+	usb_h_pipe_cb_xfer_t done;
+#if CONF_USB_H_INST_OWNER_SP
+	/** Pointer to the pipe owner */
+	void *owner;
+#endif
+
+	/** Endpoint max packet size (bits 10..0) */
+	uint16_t max_pkt_size;
+	/** Device address */
+	uint8_t dev;
+	/** Endpoint address */
+	uint8_t ep;
+
+	/** Endpoint interval */
+	uint8_t interval;
+	/** Endpoint type: Control, Isochronous, Bulk or Interrupt */
+	uint8_t type;
+	/** Current toggle (driver dependent) */
+	uint8_t toggle;
+	/** Endpoint number of banks (HW dependent) */
+	uint8_t bank : 2;
+	/** Transfer speed (HW dependent) */
+	uint8_t speed : 2;
+	/** High bandwidth periodic out */
+	uint8_t high_bw_out : 1;
+	/** Uses DMA (on transfer) */
+	uint8_t dma : 1;
+	/** Transfer ZLP support */
+	uint8_t zlp : 1;
+	/** Transfer periodic */
+	uint8_t periodic_start : 1;
+
+	/** Transfer status */
+	union {
+		/** General transfer info */
+		struct usb_h_xfer general;
+		/** Control transfer status */
+		struct usb_h_ctrl_xfer ctrl;
+		/** Bulk interrupt iso transfer status */
+		struct usb_h_bulk_int_iso_xfer bii;
+		/** Periodic high bandwidth transfer status */
+		struct usb_h_high_bw_xfer hbw;
+	} x;
+};
+
+/**
+ * @brief      USB HCD Initialization
+ *
+ * @param      drv     Pointer to the HCD driver instance
+ * @param[in]  hw      Pointer to hardware base
+ * @param[in]  prvt    The private driver data (implement specific)
+ *
+ * @return     Operation result status
+ * @retval     ERR_DENIED Hardware has been enabled
+ * @retval     ERR_NONE Operation done successfully
+ */
+int32_t _usb_h_init(struct usb_h_desc *drv, void *hw, void *prvt);
+
+/**
+ * @brief      USB HCD de-initialization
+ *
+ * @param      drv   The driver
+ */
+void _usb_h_deinit(struct usb_h_desc *drv);
+
+/**
+ * @brief      USB HCD enable
+ *
+ * @param      drv   The driver
+ */
+void _usb_h_enable(struct usb_h_desc *drv);
+
+/**
+ * @brief      USB HCD disable
+ *
+ * @param      drv   The driver
+ */
+void _usb_h_disable(struct usb_h_desc *drv);
+
+/**
+ * @brief      Register callbacks for USB HCD
+ *
+ * @param      drv   The driver
+ * @param[in]  type  The callback type
+ * @param[in]  cb    The callback function entry
+ *
+ * @return     Operation result status
+ * @retval     ERR_INVALID_ARG Argument error
+ * @retval     ERR_NONE Operation done successfully
+ */
+int32_t _usb_h_register_callback(struct usb_h_desc *drv, enum usb_h_cb_type type, FUNC_PTR cb);
+
+/**
+ * @brief      Return current frame number
+ *
+ * @param      drv   The driver
+ *
+ * @return     current frame number
+ */
+uint16_t _usb_h_get_frame_n(struct usb_h_desc *drv);
+
+/**
+ * @brief      Return current micro frame number
+ *
+ * @param      drv   The driver
+ *
+ * @return     current micro frame number
+ */
+uint8_t _usb_h_get_microframe_n(struct usb_h_desc *drv);
+
+/**
+ * @brief Suspend the USB bus
+ *
+ * @param drv The driver
+ */
+void _usb_h_suspend(struct usb_h_desc *drv);
+
+/**
+ * @brief Resume the USB bus
+ *
+ * @param drv The driver
+ */
+void _usb_h_resume(struct usb_h_desc *drv);
+
+/* Root hub related APIs */
+
+/**
+ * \brief Reset the root hub port
+ *
+ * \param[in,out] drv  Pointer to the USB HCD driver
+ * \param[in]     port Root hub port, ignored if there is only one port
+ */
+void _usb_h_rh_reset(struct usb_h_desc *drv, uint8_t port);
+
+/**
+ * \brief Suspend the root hub port
+ *
+ * \param[in,out] drv  Pointer to the USB HCD driver
+ * \param[in]     port Root hub port, ignored if there is only one port
+ */
+void _usb_h_rh_suspend(struct usb_h_desc *drv, uint8_t port);
+
+/**
+ * \brief Resume the root hub port
+ *
+ * \param[in,out] drv  Pointer to the USB HCD driver
+ * \param[in]     port Root hub port, ignored if there is only one port
+ */
+void _usb_h_rh_resume(struct usb_h_desc *drv, uint8_t port);
+
+/**
+ * \brief Root hub or port feature status check
+ *
+ * Check USB Spec. for hub status and feature selectors.
+ *
+ * \param[in] drv  Pointer to the USB HCD driver
+ * \param[in] port Set to 0 to get hub status, otherwise to get port status
+ * \param[in] ftr  Hub feature/status selector
+ *                 (0: connection, 2: suspend, 4: reset, 9: LS, 10: HS)
+ *
+ * \return     \c true if the status bit is 1
+ */
+bool _usb_h_rh_check_status(struct usb_h_desc *drv, uint8_t port, uint8_t ftr);
+
+/* Pipe transfer functions */
+
+/**
+ * @brief      Allocate a pipe for USB host communication
+ *
+ * @param      drv           The USB HCD driver
+ * @param[in]  dev           The device address
+ * @param[in]  ep            The endpoint address
+ * @param[in]  max_pkt_size  The endpoint maximum packet size
+ * @param[in]  attr          The endpoint attribute
+ * @param[in]  interval      The endpoint interval
+ *                           (bInterval of USB Endpoint Descriptor)
+ * @param[in]  speed         The transfer speed of the endpoint
+ * @param[in]  minimum_rsc   Minimum the resource usage, \sa usb_h_rsc_strategy
+ *
+ * @return     Pointer to allocated pipe structure instance
+ * @retval     NULL allocation fail
+ */
+struct usb_h_pipe *_usb_h_pipe_allocate(struct usb_h_desc *drv, uint8_t dev, uint8_t ep, uint16_t max_pkt_size,
+                                        uint8_t attr, uint8_t interval, uint8_t speed, bool minimum_rsc);
+
+/**
+ * @brief      Free an allocated pipe
+ *
+ * @param      pipe  The pipe
+ *
+ * @return     Operation result status
+ * @retval     ERR_BUSY Pipe is busy, use \ref _usb_h_pipe_abort to abort
+ * @retval     ERR_NONE Operation done successfully
+ */
+int32_t _usb_h_pipe_free(struct usb_h_pipe *pipe);
+
+/**
+ * @brief      Modify parameters of an allocated control pipe
+ *
+ * @param      pipe          The pipe
+ * @param[in]  dev           The device address
+ * @param[in]  ep            The endpoint address
+ * @param[in]  max_pkt_size  The maximum packet size, must be equal or
+ *                           less than allocated size
+ * @param[in]  speed         The working speed
+ *
+ * @return     Operation result status
+ * @retval     ERR_NOT_INITIALIZED Pipe is not allocated
+ * @retval     ERR_BUSY Pipe is busy transferring
+ * @retval     ERR_INVALID_ARG Argument error
+ * @retval     ERR_UNSUPPORTED_OP Pipe is not control pipe
+ * @retval     ERR_NONE Operation done successfully
+ */
+int32_t _usb_h_pipe_set_control_param(struct usb_h_pipe *pipe, uint8_t dev, uint8_t ep, uint16_t max_pkt_size,
+                                      uint8_t speed);
+
+/**
+ * @brief      Register transfer callback on a pipe
+ *
+ * @param      pipe  The pipe
+ * @param[in]  cb    Transfer callback function
+ *
+ * @return     Operation result status
+ * @retval     ERR_INVALID_ARG Argument error
+ * @retval     ERR_NONE Operation done successfully
+ */
+int32_t _usb_h_pipe_register_callback(struct usb_h_pipe *pipe, usb_h_pipe_cb_xfer_t cb);
+
+/**
+ * @brief      Issue a control transfer (request) on a pipe
+ *
+ * \note When there is data stage, timeout between data packets is 500ms, the
+ *       timeout between last data packet and the status packet is 50ms.
+ *
+ * @param         pipe    The pipe
+ * @param[in]     setup   Pointer to the setup packet
+ * @param[in,out] data    Pointer to the data buffer
+ * @param[in]     length  The data length
+ * @param[in]     timeout Timeout for whole request in ms
+ *
+ * @return     Operation result status
+ * @retval     ERR_NOT_INITIALIZED Pipe is not allocated
+ * @retval     ERR_BUSY Pipe is busy transferring
+ * @retval     ERR_INVALID_ARG Argument error
+ * @retval     ERR_UNSUPPORTED_OP Pipe is not control pipe
+ * @retval     ERR_NONE Operation done successfully
+ */
+int32_t _usb_h_control_xfer(struct usb_h_pipe *pipe, uint8_t *setup, uint8_t *data, uint16_t length, int16_t timeout);
+
+/**
+ * @brief      Issue a bulk / interrupt / iso transfer on a pipe
+ *
+ * @param         pipe     The pipe
+ * @param[in,out] data     Pointer to the data buffer
+ * @param[in]     length   The data length
+ * @param[in]     auto_zlp Auto append ZLP for OUT
+ *
+ * @return     Operation result status
+ * @retval     ERR_NOT_INITIALIZED Pipe is not allocated
+ * @retval     ERR_BUSY Pipe is busy transferring
+ * @retval     ERR_INVALID_ARG Argument error
+ * @retval     ERR_UNSUPPORTED_OP Pipe is control pipe
+ * @retval     ERR_NONE Operation done successfully
+ */
+int32_t _usb_h_bulk_int_iso_xfer(struct usb_h_pipe *pipe, uint8_t *data, uint32_t length, bool auto_zlp);
+
+/**
+ * @brief      Issue a periodic high bandwidth output on a pipe
+ *
+ * @param         pipe             The pipe
+ * @param[in,out] data             Pointer to the data buffer
+ * @param[in]     length           The data length
+ * @param[in]     trans_pkt_size   The transaction packet sizes in a micro frame,
+ *                                 0 to use endpoint max packet size
+ *
+ * @return     Operation result status
+ * @retval     ERR_NOT_INITIALIZED Pipe is not allocated
+ * @retval     ERR_BUSY Pipe is busy transferring
+ * @retval     ERR_INVALID_ARG Argument error
+ * @retval     ERR_UNSUPPORTED_OP Pipe is not high bandwidth periodic pipe, or
+ *                                DMA feature not enabled, or
+ *                                high bandwidth not enabled
+ * @retval     ERR_NONE Operation done successfully
+ */
+int32_t _usb_h_high_bw_out(struct usb_h_pipe *pipe, uint8_t *data, uint32_t length, uint16_t trans_pkt_size[3]);
+
+/**
+ * @brief      Check if pipe is busy transferring
+ *
+ * @param      pipe  The pipe
+ *
+ * @return     \c true if pipe is busy
+ */
+bool _usb_h_pipe_is_busy(struct usb_h_pipe *pipe);
+
+/**
+ * @brief      Abort pending transfer on a pipe
+ *
+ * @param      pipe  The pipe
+ */
+void _usb_h_pipe_abort(struct usb_h_pipe *pipe);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _HPL_USB_HOST_H_INCLUDED */