diff --git a/.gitignore b/.gitignore
index 3ec700458d0a455ed748bb4a6a498a844ae197b8..42240bd35d4a9a631d16da728aa59d45f6f15453 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,7 +9,7 @@ Make.dep
.*.swp
core
.gdbinit
-cscope.out
+/cscope.*
/.config
/.config.old
/.version
diff --git a/ChangeLog b/ChangeLog
index 7c4a4b0098112bfdce303cb259392be88c35a267..f541f393d56955cf23c8c4ff8e176b030e154b63 100755
--- a/ChangeLog
+++ b/ChangeLog
@@ -12483,7 +12483,7 @@
to unregister a signal handler (2016-08-01).
* configs/sim: Add simulator-based test support for apps/examples/gpio
2016-08-01).
- * drivers/sensors: Add KXJT9 Accelerometer driver from the Motorola
+ * drivers/sensors: Add KXTJ9 Accelerometer driver from the Motorola
Moto Z MDK (2016-08-02).
* arch/arm/sim: Add a simulated I/O Expander driver (2016-08-03).
* configs/sim: Add logic to set the simulated I/O expander for testing
diff --git a/Documentation/README.html b/Documentation/README.html
index d3c0315bc4f553119f5edb6a3d4fecccabd7941a..2f9ba9066b2bedd32dd1fd55febfa091a51aabe2 100644
--- a/Documentation/README.html
+++ b/Documentation/README.html
@@ -8,7 +8,7 @@
NuttX README Files
- Last Updated: February 14, 2017
+ Last Updated: February 19, 2017
|
@@ -287,6 +287,8 @@ nuttx/
| | `- README.txt
| |- twr-k60n512/
| | `- README.txt
+ | |- twr-k64f120m/
+ | | `- README.txt
| |- "u-blox-c027/
| | `- README.txt
| |- ubw32/
diff --git a/Kconfig b/Kconfig
index 188f9d007b0250190c5f380d186ec0e96e56f2b2..4d7949d4e31da4417ff62727a53eb865291c86c2 100644
--- a/Kconfig
+++ b/Kconfig
@@ -859,21 +859,21 @@ config DEBUG_IRQ
if DEBUG_IRQ
config DEBUG_IRQ_ERROR
- bool "DMA Error Output"
+ bool "Interrupt Controller Error Output"
default n
depends on DEBUG_ERROR
---help---
Enable interrupt controller error output to SYSLOG.
config DEBUG_IRQ_WARN
- bool "DMA Warnings Output"
+ bool "Interrupt Controller Warnings Output"
default n
depends on DEBUG_WARN
---help---
Enable interrupt controller warning output to SYSLOG.
config DEBUG_IRQ_INFO
- bool "DMA Informational Output"
+ bool "Interrupt Controller Informational Output"
default n
depends on DEBUG_INFO
---help---
@@ -1277,7 +1277,7 @@ endif # DEBUG_RTC
config DEBUG_MEMCARD
bool "Memory Card Driver Debug Features"
default n
- depends on MMCSD_SDIO
+ depends on MMCSD
---help---
Enable MMC/SD memory card Driver debug features.
diff --git a/README.txt b/README.txt
index 1a0d2620a522ba83b92ccecb3efe0648e1897d1e..ed3d41c30f8420f294941b1eb721d996ca277999 100644
--- a/README.txt
+++ b/README.txt
@@ -1671,6 +1671,8 @@ nuttx/
| | `- README.txt
| |- twr-k60n512/
| | `- README.txt
+ | |- twr-k64f120m/
+ | | `- README.txt
| |- u-blox-co27/
| | `- README.txt
| |- ubw32/
diff --git a/ReleaseNotes b/ReleaseNotes
index e7d50a4053256e739f5b955e2cc465a9e91e0e0a..f7dc36cdd4ff6cb293525fdaa5ca6ff02fc9481b 100644
--- a/ReleaseNotes
+++ b/ReleaseNotes
@@ -11813,7 +11813,7 @@ Additional new features and extended functionality:
* Sensor Drivers:
- - Add KXJT9 Accelerometer driver from the Motorola Moto Z MDK.
+ - Add KXTJ9 Accelerometer driver from the Motorola Moto Z MDK.
- Add MFRC522 RFID ISO14443 and Mifare transceiver driver. From Alan
Carvalho de Assis.
- Add driver for the LIS3MDL 3 axis magnetometer. From Alexander
diff --git a/TODO b/TODO
index e3efaa81df68a31952b0467a11ce5bd64e7eccfb..e3457de5d8d92aafd713496710ba2f5653211329 100644
--- a/TODO
+++ b/TODO
@@ -1,4 +1,4 @@
-NuttX TODO List (Last updated February 12, 2017)
+NuttX TODO List (Last updated March 4, 2017)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This file summarizes known NuttX bugs, limitations, inconsistencies with
@@ -19,7 +19,7 @@ nuttx/:
(8) Kernel/Protected Build
(3) C++ Support
(6) Binary loaders (binfmt/)
- (12) Network (net/, drivers/net)
+ (13) Network (net/, drivers/net)
(4) USB (drivers/usbdev, drivers/usbhost)
(0) Other drivers (drivers/)
(12) Libraries (libc/, libm/)
@@ -438,7 +438,7 @@ o pthreads (sched/pthreads)
serve as cancellation points. They are, however, simple wrappers around nanosleep
which is a true cancellation point.
NOTE 02: system() is actually implemented in apps/ as part of NSH. It cannot be
- a cancellation point either.
+ a cancellation point.
NOTE 03: sigpause() is a user-space function in the C library and cannot serve as
cancellation points. It is, however, a simple wrapper around sigsuspend()
which is a true cancellation point.
@@ -1032,6 +1032,39 @@ o Network (net/, drivers/net)
Status: Open
Priority: Low
+ Title: ETHERNET WITH MULTIPLE LPWORK THREADS
+ Description: Recently, Ethernet drivers were modified to support multiple
+ work queue structures. The question was raised: "My only
+ reservation would be, how would this interact in the case of having CONFIG_STM32_ETHMAC_LPWORK and CONFIG_SCHED_LPNTHREADS
+ > 1? Can it be guaranteed that one work item won't be
+ interrupted and execution switched to another? I think so but
+ am not 100% confident."
+
+ I suspect that you right. There are probably vulnerabilities
+ in the CONFIG_STM32_ETHMAC_LPWORK with CONFIG_SCHED_LPNTHREADS
+ > 1 case. But that really doesn't depend entirely upon the
+ change to add more work queue structures. Certainly with only
+ work queue structure you would have concurrent Ethernet
+ operations in that multiple LP threads; just because the work
+ structure is available, does not mean that there is not dequeued
+ work in progress. The multiple structures probably widens the
+ window for that concurrency, but does not create it.
+
+ The current Ethernet designs depend upon a single work queue to
+ serialize data. In the case of muliple LP threads, some
+ additional mechanism would have to be added to enforce that
+ serialization.
+
+ NOTE: Most drivers will call net_lock() and net_unlock() around
+ the critical portions of the driver work. In that case, all work
+ will be properly serialized. This issue only applies to drivers
+ that may perform operations that require protection outside of
+ the net_lock'ed region. Sometimes, this may require extending
+ the netlock() to be beginning of the driver work function.
+
+ Status: Open
+ Priority: High if you happen to be using Ethernet in this configuration.
+
o USB (drivers/usbdev, drivers/usbhost)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/arch/Kconfig b/arch/Kconfig
index f57f510355f755f744c0ec1ff367c5911517910e..6fac6fd310b679ec458384978ddab7e298c78faf 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -621,6 +621,44 @@ config ARCH_RAMVECTORS
If ARCH_RAMVECTORS is defined, then the architecture will support
modifiable vectors in a RAM-based vector table.
+config ARCH_MINIMAL_VECTORTABLE
+ bool "Minimal RAM usage for vector table"
+ default n
+ ---help---
+ Use a minimum amount of RAM for the vector table.
+
+ Instead of allowing irq_attach() to work for all interrupt vectors,
+ restrict to only working for a select few (defined in your board
+ configuration). This can dramatically reduce the amount of RAM used
+ be your vector table.
+
+ To use this setting, you must have a file in your board config that
+ provides:
+
+ #include
+ const irq_mapped_t g_irqmap[NR_IRQS] =
+ {
+ ... IRQ to index mapping values ...
+ };
+
+ This table is index by the hardware IRQ number and provides a value
+ in the range of 0 to CONFIG_ARCH_NUSER_INTERRUPTS that is the new,
+ mapped index into the vector table. Unused, unmapped interrupts
+ should be set to IRQMAPPED_MAX. So, for example, if g_irqmap[37]
+ == 24, then the hardware interrupt vector 37 will be mapped to the
+ interrupt vector table at index 24. if g_irqmap[42] ==
+ IRQMAPPED_MAX, then hardware interrupt vector 42 is not used and
+ if it occurs will result in an unexpected interrupt crash.
+
+config ARCH_NUSER_INTERRUPTS
+ int "Number of interrupts"
+ default 0
+ depends on ARCH_MINIMAL_VECTORTABLE
+ ---help---
+ If CONFIG_ARCH_MINIMAL_VECTORTABLE is defined, then this setting
+ defines the actual number of valid, mapped interrupts in g_irqmap.
+ This number will be the new size of the OS vector table
+
comment "Board Settings"
config BOARD_LOOPSPERMSEC
diff --git a/arch/arm/include/kinetis/chip.h b/arch/arm/include/kinetis/chip.h
index 2da386c3daab3fd436fc9097d1da3eb38b16e1a3..5c6cc76a0822deb212292e76d37e72dc737e7d55 100644
--- a/arch/arm/include/kinetis/chip.h
+++ b/arch/arm/include/kinetis/chip.h
@@ -43,6 +43,8 @@
#include
#include
+#include
+#include
/************************************************************************************
* Pre-processor Definitions
@@ -1425,7 +1427,8 @@
# define KINETIS_NUSBDEV 1 /* One USB device controller */
# define KINETIS_NSDHC 1 /* SD host controller */
# define KINETIS_NI2C 4 /* Four I2C modules */
-# define KINETIS_NUART 5 /* Five UART modues */
+# define KINETIS_NUART 5 /* Five UART modules */
+# define KINETIS_NLPUART 1 /* One LPUART modules */
# define KINETIS_NSPI 3 /* Three SPI modules */
# define KINETIS_NCAN 2 /* Two CAN controllers */
# define KINETIS_NI2S 1 /* One I2S modules */
diff --git a/arch/arm/include/kinetis/kinetis_mcg.h b/arch/arm/include/kinetis/kinetis_mcg.h
index 7b46c686322f34ef993e1958a2209994afa7adb1..bca6b18883685629929e957abd2643176b3337e4 100644
--- a/arch/arm/include/kinetis/kinetis_mcg.h
+++ b/arch/arm/include/kinetis/kinetis_mcg.h
@@ -76,7 +76,7 @@
* KINETIS_MCG_HAS_PLL_INTERNAL_MODE - Has PEI mode or PBI mode
* KINETIS_MCG_HAS_RESET_IS_BLPI - Has Reset clock mode is BLPI
*
- * MCD Register Configuration
+ * MCG Register Configuration
*
* KINETIS_MCG_HAS_C1 - SoC has C1 Register
* KINETIS_MCG_HAS_C1_IREFS - SoC has C1[IREFS]
@@ -289,7 +289,7 @@
# undef KINETIS_MCG_HAS_PLL_INTERNAL_MODE /* Has PEI mode or PBI mode */
# undef KINETIS_MCG_HAS_RESET_IS_BLPI /* Has Reset clock mode is BLPI */
-/* MCD Register Configuration */
+/* MCG Register Configuration */
# define KINETIS_MCG_HAS_C1 1 /* SoC has C1 Register */
# define KINETIS_MCG_HAS_C1_IREFS 1 /* SoC has C1[IREFS] */
@@ -371,7 +371,7 @@
# undef KINETIS_MCG_HAS_PLL_INTERNAL_MODE /* Has PEI mode or PBI mode */
# undef KINETIS_MCG_HAS_RESET_IS_BLPI /* Has Reset clock mode is BLPI */
-/* MCD Register Configuration */
+/* MCG Register Configuration */
# define KINETIS_MCG_HAS_C1 1 /* SoC has C1 Register */
# define KINETIS_MCG_HAS_C1_IREFS 1 /* SoC has C1[IREFS] */
@@ -448,7 +448,7 @@
/* Verified to Document Number: Document Number: K66P144M180SF5RMV2 Rev. 2, May 2015 */
-# define KINETIS_MCG_VERSION KINETIS_K_MCG_VERSION_06
+# define KINETIS_MCG_VERSION KINETIS_MCG_VERSION_06
/* MCG Configuration Parameters */
@@ -463,7 +463,7 @@
# undef KINETIS_MCG_HAS_PLL_INTERNAL_MODE /* Has PEI mode or PBI mode */
# undef KINETIS_MCG_HAS_RESET_IS_BLPI /* Has Reset clock mode is BLPI */
-/* MCD Register Configuration */
+/* MCG Register Configuration */
# define KINETIS_MCG_HAS_C1 1 /* SoC has C1 Register */
# define KINETIS_MCG_HAS_C1_IREFS 1 /* SoC has C1[IREFS] */
@@ -544,7 +544,7 @@
# undef KINETIS_MCG_HAS_PLL_INTERNAL_MODE /* Has PEI mode or PBI mode */
# undef KINETIS_MCG_HAS_RESET_IS_BLPI /* Has Reset clock mode is BLPI */
-/* MCD Register Configuration */
+/* MCG Register Configuration */
# define KINETIS_MCG_HAS_C1 1 /* SoC has C1 Register */
# define KINETIS_MCG_HAS_C1_IREFS 1 /* SoC has C1[IREFS] */
diff --git a/arch/arm/include/kinetis/kinetis_pmc.h b/arch/arm/include/kinetis/kinetis_pmc.h
new file mode 100644
index 0000000000000000000000000000000000000000..03bc8958426d38b07d1d5646e66b2561456f973f
--- /dev/null
+++ b/arch/arm/include/kinetis/kinetis_pmc.h
@@ -0,0 +1,324 @@
+/************************************************************************************
+ * arch/arm/include/kinetis/kinetis_pmc.h
+ *
+ * Copyright (C) 2017 Gregory Nutt. All rights reserved.
+ * Authors: Gregory Nutt
+ * David Sidrane
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ************************************************************************************/
+
+#ifndef __ARCH_ARM_INCLUDE_KINETIS_KINETIS_PMC_H
+#define __ARCH_ARM_INCLUDE_KINETIS_KINETIS_PMC_H
+
+/************************************************************************************
+ * Included Files
+ ************************************************************************************/
+
+#include
+
+/************************************************************************************
+ * Pre-processor Definitions
+ ************************************************************************************/
+
+/* Note: It is envisioned that in the long term as a chip is added. The author of
+ * the new chip definitions will either find the exact configuration in an existing
+ * chip define and add the new chip to it Or add the PMC feature configuration
+ * #defines to the chip ifdef list below. In either case the author should mark
+ * it as "Verified to Document Number:" taken from the reference manual.
+ *
+ * To maintain backward compatibility to the version of NuttX prior to
+ * 2/22/2017, the catch all KINETIS_PMC_VERSION_UKN configuration is assigned
+ * to all the chips that did not have any conditional compilation based on
+ * KINETIS_K64 or KINETIS_K66. This is a "No worse" than the original code solution.
+ * N.B. Each original chip "if"definitions have been left intact so that the
+ * complete legacy definitions prior to 2/22/2017 may be filled in completely when
+ * vetted.
+ */
+
+/* PMC Register Configuration
+ *
+ * KINETIS_PMC_HAS_REGSC - SoC has REGSC Register
+ * KINETIS_PMC_HAS_REGSC_ACKISO - SoC has REGSC[ACKISO]
+ * KINETIS_PMC_HAS_REGSC_VLPRS - SoC has REGSC[VLPRS]
+ * KINETIS_PMC_HAS_REGSC_VLPO - SoC has REGSC[VLPO]
+ * KINETIS_PMC_HAS_REGSC_REGFPM - SoC has REGSC[REGFPM]
+ * KINETIS_PMC_HAS_REGSC_BGEN - SoC has REGSC[BGEN]
+ * KINETIS_PMC_HAS_REGSC_TRAMPO - SoC has REGSC[TRAMPO]
+ * KINETIS_PMC_HAS_REGSC_REGONS - SoC has REGSC[REGONS]
+ */
+
+/* Describe the version of the PMC
+ *
+ * These defines are not related to any NXP reference but are merely
+ * a way to label the versions we are using
+ */
+
+#define KINETIS_PMC_VERSION_UKN -1 /* What was in nuttx prior to 2/22/2017 */
+#define KINETIS_PMC_VERSION_01 1 /* Verified Document Number: K60P144M150SF3RM Rev. 3, November 2014 */
+#define KINETIS_PMC_VERSION_04 4 /* Verified to Document Numbers:
+ * K20P64M72SF1RM Rev. 1.1, Dec 2012
+ * K64P144M120SF5RM Rev. 2, January 2014
+ * K66P144M180SF5RMV2 Rev. 2, May 2015 */
+
+/* MK20DX/DN---VLH5
+ *
+ * ------------- ------ --- ------- ------ ------- ------ ----- ----
+ * PART NUMBER CPU PIN PACKAGE TOTAL PROGRAM EEPROM SRAM GPIO
+ * FREQ CNT FLASH FLASH
+ * ------------- ------ --- ------- ------ ------- ------ ----- ----
+ * MK20DN32VLH5 50 MHz 64 LQFP 32 KB 32 KB — 8 KB 40
+ * MK20DX32VLH5 50 MHz 64 LQFP 64 KB 32 KB 2 KB 8 KB 40
+ * MK20DN64VLH5 50 MHz 64 LQFP 64 KB 64 KB — 16 KB 40
+ * MK20DX64VLH5 50 MHz 64 LQFP 96 KB 64 KB 2 KB 16 KB 40
+ * MK20DN128VLH5 50 MHz 64 LQFP 128 KB 128 KB — 16 KB 40
+ * MK20DX128VLH5 50 MHz 64 LQFP 160 KB 128 KB 2 KB 16 KB 40
+ */
+
+#if defined(CONFIG_ARCH_CHIP_MK20DN32VLH5) || \
+ defined(CONFIG_ARCH_CHIP_MK20DX32VLH5) || \
+ defined(CONFIG_ARCH_CHIP_MK20DN64VLH5) || \
+ defined(CONFIG_ARCH_CHIP_MK20DX64VLH5) || \
+ defined(CONFIG_ARCH_CHIP_MK20DN128VLH5) || \
+ defined(CONFIG_ARCH_CHIP_MK20DX128VLH5)
+
+# define KINETIS_PMC_VERSION KINETIS_PMC_VERSION_UKN
+
+/* MK20DX---VLH7
+ *
+ * ------------- ------ --- ------- ------ ------- ------ ----- ----
+ * PART NUMBER CPU PIN PACKAGE TOTAL PROGRAM EEPROM SRAM GPIO
+ * FREQ CNT FLASH FLASH
+ * ------------- ------ --- ------- ------ ------- ------ ----- ----
+ * MK20DX64VLH7 72 MHz 64 LQFP 96 KB 64 KB 2 KB 16 KB 40
+ * MK20DX128VLH7 72 MHz 64 LQFP 160 KB 128 KB 2 KB 32 KB 40
+ * MK20DX256VLH7 72 MHz 64 LQFP 288 KB 256 KB 2 KB 64 KB 40
+ * ------------- ------ --- ------- ------ ------- ------ ----- ----
+ */
+
+#elif defined(CONFIG_ARCH_CHIP_MK20DX64VLH7) || defined(CONFIG_ARCH_CHIP_MK20DX128VLH7) || \
+ defined(CONFIG_ARCH_CHIP_MK20DX256VLH7)
+
+/* Verified to Document Number: K20P64M72SF1RM Rev. 1.1, Dec 2012 */
+
+# define KINETIS_PMC_VERSION KINETIS_PMC_VERSION_04
+
+/* PMC Register Configuration */
+
+# define KINETIS_PMC_HAS_REGSC 1 /* SoC has REGSC Register */
+# define KINETIS_PMC_HAS_REGSC_ACKISO 1 /* SoC has REGSC[ACKISO] */
+# undef KINETIS_PMC_HAS_REGSC_VLPRS /* SoC has REGSC[VLPRS] */
+# undef KINETIS_PMC_HAS_REGSC_VLPO /* SoC has REGSC[VLPO] */
+# undef KINETIS_PMC_HAS_REGSC_REGFPM /* SoC has REGSC[REGFPM] */
+# define KINETIS_PMC_HAS_REGSC_BGEN 1 /* SoC has REGSC[BGEN] */
+# undef KINETIS_PMC_HAS_REGSC_TRAMPO /* SoC has REGSC[TRAMPO] */
+# define KINETIS_PMC_HAS_REGSC_REGONS 1 /* SoC has REGSC[REGONS] */
+
+#elif defined(CONFIG_ARCH_CHIP_MK40X64VFX50) || defined(CONFIG_ARCH_CHIP_MK40X64VLH50) || \
+ defined(CONFIG_ARCH_CHIP_MK40X64VLK50) || defined(CONFIG_ARCH_CHIP_MK40X64VMB50)
+
+# define KINETIS_PMC_VERSION KINETIS_PMC_VERSION_UKN
+
+#elif defined(CONFIG_ARCH_CHIP_MK40X128VFX50) || defined(CONFIG_ARCH_CHIP_MK40X128VLH50) || \
+ defined(CONFIG_ARCH_CHIP_MK40X128VLK50) || defined(CONFIG_ARCH_CHIP_MK40X128VMB50) || \
+ defined(CONFIG_ARCH_CHIP_MK40X128VLL50) || defined(CONFIG_ARCH_CHIP_MK40X128VML50) || \
+ defined(CONFIG_ARCH_CHIP_MK40X128VFX72) || defined(CONFIG_ARCH_CHIP_MK40X128VLH72) || \
+ defined(CONFIG_ARCH_CHIP_MK40X128VLK72) || defined(CONFIG_ARCH_CHIP_MK40X128VMB72) || \
+ defined(CONFIG_ARCH_CHIP_MK40X128VLL72) || defined(CONFIG_ARCH_CHIP_MK40X128VML72)
+
+# define KINETIS_PMC_VERSION KINETIS_PMC_VERSION_UKN
+
+#elif defined(CONFIG_ARCH_CHIP_MK40X256VLK72) || defined(CONFIG_ARCH_CHIP_MK40X256VMB72) || \
+ defined(CONFIG_ARCH_CHIP_MK40X256VLL72) || defined(CONFIG_ARCH_CHIP_MK40X256VML72)
+
+# define KINETIS_PMC_VERSION KINETIS_PMC_VERSION_UKN
+
+#elif defined(CONFIG_ARCH_CHIP_MK40X128VLQ100) || defined(CONFIG_ARCH_CHIP_MK40X128VMD100)
+
+# define KINETIS_PMC_VERSION KINETIS_PMC_VERSION_UKN
+
+#elif defined(CONFIG_ARCH_CHIP_MK40X256VLQ100) || defined(CONFIG_ARCH_CHIP_MK40X256VMD100)
+
+# define KINETIS_PMC_VERSION KINETIS_PMC_VERSION_UKN
+
+#elif defined(CONFIG_ARCH_CHIP_MK40N512VLK100) || defined(CONFIG_ARCH_CHIP_MK40N512VMB100) || \
+ defined(CONFIG_ARCH_CHIP_MK40N512VLL100) || defined(CONFIG_ARCH_CHIP_MK40N512VML100) || \
+ defined(CONFIG_ARCH_CHIP_MK40N512VLQ100) || defined(CONFIG_ARCH_CHIP_MK40N512VMD100)
+
+# define KINETIS_PMC_VERSION KINETIS_PMC_VERSION_UKN
+
+#elif defined(CONFIG_ARCH_CHIP_MK60N256VLL100)
+
+# define KINETIS_PMC_VERSION KINETIS_PMC_VERSION_UKN
+
+#elif defined(CONFIG_ARCH_CHIP_MK60X256VLL100)
+
+# define KINETIS_PMC_VERSION KINETIS_PMC_VERSION_UKN
+
+#elif defined(CONFIG_ARCH_CHIP_MK60N512VLL100)
+
+# define KINETIS_PMC_VERSION KINETIS_PMC_VERSION_UKN
+
+#elif defined(CONFIG_ARCH_CHIP_MK60N256VML100)
+
+# define KINETIS_PMC_VERSION KINETIS_PMC_VERSION_UKN
+
+#elif defined(CONFIG_ARCH_CHIP_MK60X256VML100)
+
+# define KINETIS_PMC_VERSION KINETIS_PMC_VERSION_UKN
+
+#elif defined(CONFIG_ARCH_CHIP_MK60N512VML100)
+
+# define KINETIS_PMC_VERSION KINETIS_PMC_VERSION_UKN
+
+#elif defined(CONFIG_ARCH_CHIP_MK60N256VLQ100)
+
+# define KINETIS_PMC_VERSION KINETIS_PMC_VERSION_UKN
+
+#elif defined(CONFIG_ARCH_CHIP_MK60X256VLQ100)
+
+# define KINETIS_PMC_VERSION KINETIS_PMC_VERSION_UKN
+
+#elif defined(CONFIG_ARCH_CHIP_MK60N512VLQ100)
+
+# define KINETIS_PMC_VERSION KINETIS_PMC_VERSION_UKN
+
+#elif defined(CONFIG_ARCH_CHIP_MK60N256VMD100)
+
+# define KINETIS_PMC_VERSION KINETIS_PMC_VERSION_UKN
+
+#elif defined(CONFIG_ARCH_CHIP_MK60X256VMD100)
+
+# define KINETIS_PMC_VERSION KINETIS_PMC_VERSION_UKN
+
+#elif defined(CONFIG_ARCH_CHIP_MK60N512VMD100)
+
+# define KINETIS_PMC_VERSION KINETIS_PMC_VERSION_UKN
+
+#elif defined(CONFIG_ARCH_CHIP_MK60FN1M0VLQ12)
+
+/* Verified to Document Number: K60P144M100SF2V2RM Rev. 2 Jun 2012 */
+
+# define KINETIS_PMC_VERSION KINETIS_PMC_VERSION_01
+
+/* PMC Register Configuration */
+
+# define KINETIS_PMC_HAS_REGSC 1 /* SoC has REGSC Register */
+# define KINETIS_PMC_HAS_REGSC_ACKISO 1 /* SoC has REGSC[ACKISO] */
+# undef KINETIS_PMC_HAS_REGSC_VLPRS /* SoC has REGSC[VLPRS] */
+# undef KINETIS_PMC_HAS_REGSC_VLPO /* SoC has REGSC[VLPO] */
+# undef KINETIS_PMC_HAS_REGSC_REGFPM /* SoC has REGSC[REGFPM] */
+# undef KINETIS_PMC_HAS_REGSC_BGEN /* SoC has REGSC[BGEN] */
+# undef KINETIS_PMC_HAS_REGSC_TRAMPO /* SoC has REGSC[TRAMPO] */
+# define KINETIS_PMC_HAS_REGSC_REGONS 1 /* SoC has REGSC[REGONS] */
+
+#elif defined(CONFIG_ARCH_CHIP_MK64FN1M0VLL12) || defined(CONFIG_ARCH_CHIP_MK64FX512VLL12) || \
+ defined(CONFIG_ARCH_CHIP_MK64FX512VDC12) || defined(CONFIG_ARCH_CHIP_MK64FN1M0VDC12) || \
+ defined(CONFIG_ARCH_CHIP_MK64FX512VLQ12) || defined(CONFIG_ARCH_CHIP_MK64FN1M0VLQ12) || \
+ defined(CONFIG_ARCH_CHIP_MK64FX512VMD12) || defined(CONFIG_ARCH_CHIP_MK64FN1M0VMD12)
+
+/* Verified to Document Number: K64P144M120SF5RM Rev. 2, January 2014 */
+
+# define KINETIS_PMC_VERSION KINETIS_PMC_VERSION_04
+
+/* PMC Register Configuration */
+
+# define KINETIS_PMC_HAS_REGSC 1 /* SoC has REGSC Register */
+# define KINETIS_PMC_HAS_REGSC_ACKISO 1 /* SoC has REGSC[ACKISO] */
+# undef KINETIS_PMC_HAS_REGSC_VLPRS /* SoC has REGSC[VLPRS] */
+# undef KINETIS_PMC_HAS_REGSC_VLPO /* SoC has REGSC[VLPO] */
+# undef KINETIS_PMC_HAS_REGSC_REGFPM /* SoC has REGSC[REGFPM] */
+# define KINETIS_PMC_HAS_REGSC_BGEN 1 /* SoC has REGSC[BGEN] */
+# undef KINETIS_PMC_HAS_REGSC_TRAMPO /* SoC has REGSC[TRAMPO] */
+# define KINETIS_PMC_HAS_REGSC_REGONS 1 /* SoC has REGSC[REGONS] */
+
+/* MK66F N/X 1M0/2M0 V MD/LQ 18
+ *
+ * --------------- ------- --- ------- ------- ------ ------ ------ -----
+ * PART NUMBER CPU PIN PACKAGE TOTAL PROGRAM EEPROM SRAM GPIO
+ * FREQ CNT FLASH FLASH
+ * --------------- ------- --- ------- ------- ------ ------ ------ -----
+ * MK66FN2M0VMD18 180 MHz 144 MAPBGA 2 MB — — KB 260 KB 100
+ * MK66FX1M0VMD18 180 MHz 144 MAPBGA 1.25 MB 1 MB 4 KB 256 KB 100
+ * MK66FN2M0VLQ18 180 MHz 144 LQFP 2 MB — — KB 260 KB 100
+ * MK66FX1M0VLQ18 180 MHz 144 LQFP 1.25 MB 1 MB 4 KB 256 KB 100
+ */
+
+#elif defined(CONFIG_ARCH_CHIP_MK66FN2M0VMD18) || defined(CONFIG_ARCH_CHIP_MK66FX1M0VMD18) || \
+ defined(CONFIG_ARCH_CHIP_MK66FN2M0VLQ18) || defined(CONFIG_ARCH_CHIP_MK66FX1M0VLQ18)
+
+/* Verified to Document Number: Document Number: K66P144M180SF5RMV2 Rev. 2, May 2015 */
+
+# define KINETIS_PMC_VERSION KINETIS_PMC_VERSION_04
+
+/* PMC Register Configuration */
+
+# define KINETIS_PMC_HAS_REGSC 1 /* SoC has REGSC Register */
+# define KINETIS_PMC_HAS_REGSC_ACKISO 1 /* SoC has REGSC[ACKISO] */
+# undef KINETIS_PMC_HAS_REGSC_VLPRS /* SoC has REGSC[VLPRS] */
+# undef KINETIS_PMC_HAS_REGSC_VLPO /* SoC has REGSC[VLPO] */
+# undef KINETIS_PMC_HAS_REGSC_REGFPM /* SoC has REGSC[REGFPM] */
+# define KINETIS_PMC_HAS_REGSC_BGEN 1 /* SoC has REGSC[BGEN] */
+# undef KINETIS_PMC_HAS_REGSC_TRAMPO /* SoC has REGSC[TRAMPO] */
+# define KINETIS_PMC_HAS_REGSC_REGONS 1 /* SoC has REGSC[REGONS] */
+
+#else
+# error "Unsupported Kinetis chip"
+#endif
+
+/* Use the catch all configuration for the PMC based on the implementations in nuttx prior 2/3/2017 */
+
+#if KINETIS_PMC_VERSION == KINETIS_PMC_VERSION_UKN
+
+/* PMC Register Configuration */
+
+# define KINETIS_PMC_HAS_REGSC 1 /* SoC has REGSC Register */
+# undef KINETIS_PMC_HAS_REGSC_ACKISO /* SoC has REGSC[ACKISO] */
+# define KINETIS_PMC_HAS_REGSC_VLPRS 1 /* SoC has REGSC[VLPRS] */
+# undef KINETIS_PMC_HAS_REGSC_VLPO /* SoC has REGSC[VLPO] */
+# undef KINETIS_PMC_HAS_REGSC_REGFPM /* SoC has REGSC[REGFPM] */
+# undef KINETIS_PMC_HAS_REGSC_BGEN /* SoC has REGSC[BGEN] */
+# define KINETIS_PMC_HAS_REGSC_TRAMPO 1 /* SoC has REGSC[TRAMPO] */
+# define KINETIS_PMC_HAS_REGSC_REGONS 1 /* SoC has REGSC[REGONS] */
+
+#endif
+
+#if !defined(KINETIS_PMC_VERSION)
+# error "No KINETIS_PMC_VERSION defined!"
+#endif
+
+#if defined(KINETIS_PMC_HAS_C5_PRDIV)
+# define KINETIS_PMC_C5_PRDIV_MASK ((1 << (KINETIS_PMC_C5_PRDIV_BITS))-1)
+#endif
+
+#if defined(KINETIS_PMC_HAS_C7_OSCSEL)
+# define KINETIS_PMC_C7_OSCSEL_MASK ((1 << (KINETIS_PMC_C7_OSCSEL_BITS))-1)
+#endif
+
+#endif /* __ARCH_ARM_INCLUDE_KINETIS_KINETIS_PMC_H */
diff --git a/arch/arm/include/kinetis/kinetis_sim.h b/arch/arm/include/kinetis/kinetis_sim.h
new file mode 100644
index 0000000000000000000000000000000000000000..224e8b0d787835c6f74b7f2e6855f6dfdff251f7
--- /dev/null
+++ b/arch/arm/include/kinetis/kinetis_sim.h
@@ -0,0 +1,1322 @@
+/************************************************************************************
+ * arch/arm/include/kinetis/kinetis_sim.h
+ *
+ * Copyright (C) 2017 Gregory Nutt. All rights reserved.
+ * Authors: Gregory Nutt
+ * David Sidrane
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ************************************************************************************/
+
+#ifndef __ARCH_ARM_INCLUDE_KINETIS_KINETIS_SIM_H
+#define __ARCH_ARM_INCLUDE_KINETIS_KINETIS_SIM_H
+
+/************************************************************************************
+ * Included Files
+ ************************************************************************************/
+
+#include
+
+/************************************************************************************
+ * Pre-processor Definitions
+ ************************************************************************************/
+
+/* Note: It is envisioned that in the long term as a chip is added. The author of
+ * the new chip definitions will either find the exact configuration in an existing
+ * chip define and add the new chip to it Or add the SIM feature configuration
+ * #defines to the chip ifdef list below. In either case the author should mark
+ * it as "Verified to Document Number:" taken from the reference manual.
+ *
+ * To maintain backward compatibility to the version of NuttX prior to
+ * 2/16/2017, the catch all KINETIS_SIM_VERSION_UKN configuration is assigned
+ * to all the chips that did not have any conditional compilation based on
+ * KINETIS_K64 or KINETIS_K66. This is a "No worse" than the original code solution.
+ * N.B. Each original chip "if"definitions have been left intact so that the
+ * complete legacy definitions prior to 2/16/2017 may be filled in completely when
+ * vetted.
+ */
+
+/* SIM Register Configuration
+ *
+ * KINETIS_SIM_HAS_SOPT1 - SoC has SOPT1 Register
+ * KINETIS_SIM_HAS_SOPT1_OSC32KOUT - SoC has SOPT1[OSC32KOUT]
+ * KINETIS_SIM_HAS_SOPT1_OSC32KSEL - SoC has SOPT1[OSC32KSEL]
+ * KINETIS_SIM_HAS_SOPT1_OSC32KSEL_BITS - SoC has n bits SOPT1[OSC32KSEL]
+ * KINETIS_SIM_HAS_SOPT1_RAMSIZE - SoC has SOPT1[RAMSIZE]
+ * KINETIS_SIM_HAS_SOPT1_USBREGEN - SoC has SOPT1[USBREGEN]
+ * KINETIS_SIM_HAS_SOPT1_USBSSTBY - SoC has SOPT1[USBSSTBY]
+ * KINETIS_SIM_HAS_SOPT1_USBVSTBY - SoC has SOPT1[USBVSTBY]
+ * KINETIS_SIM_HAS_SOPT1CFG - SoC has SOPT1CFG Register
+ * KINETIS_SIM_HAS_SOPT1CFG_URWE - SoC has SOPT1CFG[URWE]
+ * KINETIS_SIM_HAS_SOPT1CFG_USSWE - SoC has SOPT1CFG[USSWE]
+ * KINETIS_SIM_HAS_SOPT1CFG_UVSWE - SoC has SOPT1CFG[UVSWE]
+ * KINETIS_SIM_HAS_USBPHYCTL - SoC has USBPHYCTL Register
+ * KINETIS_SIM_HAS_USBPHYCTL_USB3VOUTTRG - SoC has USBPHYCTL[USB3VOUTTRG]
+ * KINETIS_SIM_HAS_USBPHYCTL_USBDISILIM - SoC has USBPHYCTL[USBDISILIM]
+ * KINETIS_SIM_HAS_USBPHYCTL_USBVREGPD - SoC has USBPHYCTL[USBVREGPD]
+ * KINETIS_SIM_HAS_USBPHYCTL_USBVREGSEL - SoC has USBPHYCTL[USBVREGSEL]
+ * KINETIS_SIM_HAS_SOPT2 - SoC has SOPT2 Register
+ * KINETIS_SIM_HAS_SOPT2_CMTUARTPAD - SoC has SOPT2[CMTUARTPAD]
+ * KINETIS_SIM_HAS_SOPT2_FBSL - SoC has SOPT2[FBSL]
+ * KINETIS_SIM_HAS_SOPT2_FLEXIOSRC - SoC has SOPT2[FLEXIOSRC]
+ * KINETIS_SIM_HAS_SOPT2_LPUARTSRC - SoC has SOPT2[LPUARTSRC]
+ * KINETIS_SIM_HAS_SOPT2_PLLFLLSEL - SoC has SOPT2[PLLFLLSEL]
+ * KINETIS_SIM_HAS_SOPT2_PLLFLLSEL_BITS - SoC has n bits SOPT2[PLLFLLSEL]
+ * KINETIS_SIM_HAS_SOPT2_PTD7PAD - SoC has SOPT2[PTD7PAD]
+ * KINETIS_SIM_HAS_SOPT2_RMIISRC - SoC has SOPT2[RMIISRC]
+ * KINETIS_SIM_HAS_SOPT2_RTCCLKOUTSEL - SoC has SOPT2[RTCCLKOUTSEL]
+ * KINETIS_SIM_HAS_SOPT2_CLKOUTSEL - SoC has SOPT2[CLKOUTSEL]
+ * KINETIS_SIM_HAS_SOPT2_SDHCSRC - SoC has SOPT2[SDHCSRC]
+ * KINETIS_SIM_HAS_SOPT2_NFCSRC - SoC has SOPT2[NFCSRC]
+ * KINETIS_SIM_HAS_SOPT2_I2SSRC - SoC has SOPT2[I2SSRC]
+ * KINETIS_SIM_HAS_SOPT2_TIMESRC - SoC has SOPT2[TIMESRC]
+ * KINETIS_SIM_HAS_SOPT2_TPMSRC - SoC has SOPT2[TPMSRC]
+ * KINETIS_SIM_HAS_SOPT2_USBFSRC - SoC has SOPT2[USBFSRC]
+ * KINETIS_SIM_HAS_SOPT2_TRACECLKSEL - SoC has SOPT2[TRACECLKSEL]
+ * KINETIS_SIM_HAS_SOPT2_USBREGEN - SoC has SOPT2[USBREGEN]
+ * KINETIS_SIM_HAS_SOPT2_USBSLSRC - SoC has SOPT2[USBSLSRC]
+ * KINETIS_SIM_HAS_SOPT2_USBHSRC - SoC has SOPT2[USBHSRC]
+ * KINETIS_SIM_HAS_SOPT2_USBSRC - SoC has SOPT2[USBSRC]
+ * KINETIS_SIM_HAS_SOPT2_MCGCLKSEL - SoC has SOPT2[MCGCLKSEL]
+ * KINETIS_SIM_HAS_SOPT4 - SoC has SOPT4 Register
+ * KINETIS_SIM_HAS_SOPT4_FTM0FLT0 - SoC has SOPT4[FTM0FLT0]
+ * KINETIS_SIM_HAS_SOPT4_FTM0FLT1 - SoC has SOPT4[FTM0FLT1]
+ * KINETIS_SIM_HAS_SOPT4_FTM0FLT2 - SoC has SOPT4[FTM0FLT2]
+ * KINETIS_SIM_HAS_SOPT4_FTM0FLT3 - SoC has SOPT4[FTM0FLT3]
+ * KINETIS_SIM_HAS_SOPT4_FTM0TRG0SRC - SoC has SOPT4[FTM0TRG0SRC]
+ * KINETIS_SIM_HAS_SOPT4_FTM0TRG1SRC - SoC has SOPT4[FTM0TRG1SRC]
+ * KINETIS_SIM_HAS_SOPT4_FTM1CH0SRC - SoC has SOPT4[FTM1CH0SRC] 1, 3 if SOF
+ * KINETIS_SIM_HAS_SOPT4_FTM1FLT0 - SoC has SOPT4[FTM1FLT0]
+ * KINETIS_SIM_HAS_SOPT4_FTM1FLT1 - SoC has SOPT4[FTM1FLT1]
+ * KINETIS_SIM_HAS_SOPT4_FTM1FLT2 - SoC has SOPT4[FTM1FLT2]
+ * KINETIS_SIM_HAS_SOPT4_FTM1FLT3 - SoC has SOPT4[FTM1FLT3]
+ * KINETIS_SIM_HAS_SOPT4_FTM2CH0SRC - SoC has SOPT4[FTM2CH0SRC]
+ * KINETIS_SIM_HAS_SOPT4_FTM2CH1SRC - SoC has SOPT4[FTM2CH1SRC]
+ * KINETIS_SIM_HAS_SOPT4_FTM2FLT0 - SoC has SOPT4[FTM2FLT0]
+ * KINETIS_SIM_HAS_SOPT4_FTM2FLT1 - SoC has SOPT4[FTM2FLT1]
+ * KINETIS_SIM_HAS_SOPT4_FTM2FLT2 - SoC has SOPT4[FTM2FLT2]
+ * KINETIS_SIM_HAS_SOPT4_FTM2FLT3 - SoC has SOPT4[FTM2FLT3]
+ * KINETIS_SIM_HAS_SOPT4_FTM3CH0SRC - SoC has SOPT4[FTM3CH0SRC]
+ * KINETIS_SIM_HAS_SOPT4_FTM3FLT0 - SoC has SOPT4[FTM3FLT0]
+ * KINETIS_SIM_HAS_SOPT4_FTM3FLT1 - SoC has SOPT4[FTM3FLT1]
+ * KINETIS_SIM_HAS_SOPT4_FTM3FLT2 - SoC has SOPT4[FTM3FLT2]
+ * KINETIS_SIM_HAS_SOPT4_FTM3FLT3 - SoC has SOPT4[FTM3FLT3]
+ * KINETIS_SIM_HAS_SOPT4_FTM3TRG0SRC - SoC has SOPT4[FTM3TRG0SRC]
+ * KINETIS_SIM_HAS_SOPT4_FTM3TRG1SRC - SoC has SOPT4[FTM3TRG1SRC]
+ * KINETIS_SIM_HAS_SOPT4_TPM0CLKSEL - SoC has SOPT4[TPM0CLKSEL]
+ * KINETIS_SIM_HAS_SOPT4_TPM1CH0SRC - SoC has SOPT4[TPM1CH0SRC]
+ * KINETIS_SIM_HAS_SOPT4_TPM1CLKSEL - SoC has SOPT4[TPM1CLKSEL]
+ * KINETIS_SIM_HAS_SOPT4_TPM2CH0SRC - SoC has SOPT4[TPM2CH0SRC]
+ * KINETIS_SIM_HAS_SOPT4_TPM2CLKSEL - SoC has SOPT4[TPM2CLKSEL]
+ * KINETIS_SIM_HAS_SOPT5 - SoC has SOPT5 Register
+ * KINETIS_SIM_HAS_SOPT5_LPUART0RXSRC - SoC has SOPT5[LPUART0RXSRC]
+ * KINETIS_SIM_HAS_SOPT5_LPUART0TXSRC - SoC has SOPT5[LPUART0TXSRC]
+ * KINETIS_SIM_HAS_SOPT6 - SoC has SOPT6 Register
+ * KINETIS_SIM_HAS_SOPT6_MCC - SoC has SOPT6[MCC]
+ * KINETIS_SIM_HAS_SOPT6_PCR - SoC has SOPT6[PCR]
+ * KINETIS_SIM_HAS_SOPT6_RSTFLTSEL - SoC has SOPT6[RSTFLTSEL]
+ * KINETIS_SIM_HAS_SOPT6_RSTFLTEN - SoC has SOPT6[RSTFLTEN]
+ * KINETIS_SIM_HAS_SOPT7 - SoC has SOPT7 Register
+ * KINETIS_SIM_HAS_SOPT7_ADC0ALTTRGSEL - SoC has SOPT7[ADC0ALTTRGSEL]
+ * KINETIS_SIM_HAS_SOPT7_ADC1ALTTRGSEL - SoC has SOPT7[ADC1ALTTRGSEL]
+ * KINETIS_SIM_HAS_SOPT7_ADC0PRETRGSEL - SoC has SOPT7[ADC0PRETRGSEL]
+ * KINETIS_SIM_HAS_SOPT7_ADC1PRETRGSEL - SoC has SOPT7[ADC1PRETRGSEL]
+ * KINETIS_SIM_HAS_SOPT7_ADC2PRETRGSEL - SoC has SOPT7[ADC2PRETRGSEL]
+ * KINETIS_SIM_HAS_SOPT7_ADC3PRETRGSEL - SoC has SOPT7[ADC3PRETRGSEL]
+ * KINETIS_SIM_HAS_SOPT7_ADC0TRGSEL - SoC has n SOPT7[ADC0TRGSEL]
+ * KINETIS_SIM_HAS_SOPT7_ADC1TRGSEL - SoC has n SOPT7[ADC1TRGSEL]
+ * KINETIS_SIM_HAS_SOPT7_ADC2TRGSEL - SoC has n SOPT7[ADC2TRGSEL]
+ * KINETIS_SIM_HAS_SOPT7_ADC3TRGSEL - SoC has n SOPT7[ADC3TRGSEL]
+ * KINETIS_SIM_SOPT7_ADC0ALTTRGEN - SoC has ADC0 alternate trigger enable
+ * KINETIS_SIM_SOPT7_ADC1ALTTRGEN - SoC has ADC1 alternate trigger enable
+ * KINETIS_SIM_SOPT7_ADC2ALTTRGEN - SoC has ADC2 alternate trigger enable
+ * KINETIS_SIM_SOPT7_ADC3ALTTRGEN - SoC has ADC3 alternate trigger enable
+ * KINETIS_SIM_HAS_SOPT8 - SoC has SOPT8 Register
+ * KINETIS_SIM_HAS_SOPT8_FTM0SYNCBIT - SoC has SOPT8[FTM0SYNCBIT]
+ * KINETIS_SIM_HAS_SOPT8_FTM1SYNCBIT - SoC has SOPT8[FTM1SYNCBIT]
+ * KINETIS_SIM_HAS_SOPT8_FTM2SYNCBIT - SoC has SOPT8[FTM2SYNCBIT]
+ * KINETIS_SIM_HAS_SOPT8_FTM3SYNCBIT - SoC has SOPT8[FTM3SYNCBIT]
+ * KINETIS_SIM_HAS_SOPT8_FTM0OCH0SRC - SoC has SOPT8[FTM0OCH0SRC]
+ * KINETIS_SIM_HAS_SOPT8_FTM0OCH1SRC - SoC has SOPT8[FTM0OCH1SRC]
+ * KINETIS_SIM_HAS_SOPT8_FTM0OCH2SRC - SoC has SOPT8[FTM0OCH2SRC]
+ * KINETIS_SIM_HAS_SOPT8_FTM0OCH3SRC - SoC has SOPT8[FTM0OCH3SRC]
+ * KINETIS_SIM_HAS_SOPT8_FTM0OCH4SRC - SoC has SOPT8[FTM0OCH4SRC]
+ * KINETIS_SIM_HAS_SOPT8_FTM0OCH5SRC - SoC has SOPT8[FTM0OCH5SRC]
+ * KINETIS_SIM_HAS_SOPT8_FTM0OCH6SRC - SoC has SOPT8[FTM0OCH6SRC]
+ * KINETIS_SIM_HAS_SOPT8_FTM0OCH7SRC - SoC has SOPT8[FTM0OCH7SRC]
+ * KINETIS_SIM_HAS_SOPT8_FTM3OCH0SRC - SoC has SOPT8[FTM3OCH0SRC]
+ * KINETIS_SIM_HAS_SOPT8_FTM3OCH1SRC - SoC has SOPT8[FTM3OCH1SRC]
+ * KINETIS_SIM_HAS_SOPT8_FTM3OCH2SRC - SoC has SOPT8[FTM3OCH2SRC]
+ * KINETIS_SIM_HAS_SOPT8_FTM3OCH3SRC - SoC has SOPT8[FTM3OCH3SRC]
+ * KINETIS_SIM_HAS_SOPT8_FTM3OCH4SRC - SoC has SOPT8[FTM3OCH4SRC]
+ * KINETIS_SIM_HAS_SOPT8_FTM3OCH5SRC - SoC has SOPT8[FTM3OCH5SRC]
+ * KINETIS_SIM_HAS_SOPT8_FTM3OCH6SRC - SoC has SOPT8[FTM3OCH6SRC]
+ * KINETIS_SIM_HAS_SOPT8_FTM3OCH7SRC - SoC has SOPT8[FTM3OCH7SRC]
+ * KINETIS_SIM_HAS_SOPT9 - SoC has SOPT9 Register
+ * KINETIS_SIM_HAS_SOPT9_TPM1CH0SRC - SoC has SOPT9[TPM1CH0SRC]
+ * KINETIS_SIM_HAS_SOPT9_TPM2CH0SRC - SoC has SOPT9[TPM2CH0SRC]
+ * KINETIS_SIM_HAS_SOPT9_TPM1CLKSEL - SoC has SOPT9[TPM1CLKSEL]
+ * KINETIS_SIM_HAS_SOPT9_TPM2CLKSEL - SoC has SOPT9[TPM2CLKSEL]
+ * KINETIS_SIM_HAS_SDID - SoC has SDID Register
+ * KINETIS_SIM_HAS_SDID_DIEID - SoC has SDID[DIEID]
+ * KINETIS_SIM_HAS_SDID_FAMID - SoC has SDID[FAMID]
+ * KINETIS_SIM_HAS_SDID_FAMILYID - SoC has SDID[FAMILYID]
+ * KINETIS_SIM_HAS_SDID_SERIESID - SoC has SDID[SERIESID]
+ * KINETIS_SIM_HAS_SDID_SRAMSIZE - SoC has SDID[SRAMSIZE]
+ * KINETIS_SIM_HAS_SDID_SUBFAMID - SoC has SDID[SUBFAMID]
+ * KINETIS_SIM_HAS_SCGC1 - SoC has _SCGC1 Register
+ * KINETIS_SIM_HAS_SCGC1_UART5 - SoC has SCGC1[UART5]
+ * KINETIS_SIM_HAS_SCGC1_UART4 - SoC has SCGC1[UART4]
+ * KINETIS_SIM_HAS_SCGC1_I2C3 - SoC has SCGC1[I2C3]
+ * KINETIS_SIM_HAS_SCGC1_I2C2 - SoC has SCGC1[I2C2]
+ * KINETIS_SIM_HAS_SCGC1_OSC1 - SoC has SCGC1[OSC1]
+ * KINETIS_SIM_HAS_SCGC2 - SoC has SCGC2 Register
+ * KINETIS_SIM_HAS_SCGC2_ENET - SoC has SCGC2[ENET]
+ * KINETIS_SIM_HAS_SCGC2_LPUART0 - SoC has SCGC2[LPUART0]
+ * KINETIS_SIM_HAS_SCGC2_TPM1 - SoC has SCGC2[TPM1]
+ * KINETIS_SIM_HAS_SCGC2_TPM2 - SoC has SCGC2[TPM2]
+ * KINETIS_SIM_HAS_SCGC3 - SoC has SCGC3 Register
+ * KINETIS_SIM_HAS_SCGC3 - SoC has SCGC3 Register
+ * KINETIS_SIM_HAS_SCGC3_RNGA - SoC has SCGC3[RNGA]
+ * KINETIS_SIM_HAS_SCGC3_USBHS - SoC has SCGC3[USBHS]
+ * KINETIS_SIM_HAS_SCGC3_USBHSPHY - SoC has SCGC3[USBHSPHY]
+ * KINETIS_SIM_HAS_SCGC3_USBHSDCD - SoC has SCGC3[USBHSDCD]
+ * KINETIS_SIM_HAS_SCGC3_FLEXCAN1 - SoC has SCGC3[FLEXCAN1]
+ * KINETIS_SIM_HAS_SCGC3_NFC - SoC has SCGC3[NFC]
+ * KINETIS_SIM_HAS_SCGC3_SPI2 - SoC has SCGC3[SPI2]
+ * KINETIS_SIM_HAS_SCGC3_SAI1 - SoC has SCGC3[SAI1]
+ * KINETIS_SIM_HAS_SCGC3_SDHC - SoC has SCGC3[SDHC]
+ * KINETIS_SIM_HAS_SCGC3_FTM2 - SoC has SCGC3[FTM2]
+ * KINETIS_SIM_HAS_SCGC3_FTM3 - SoC has SCGC3[FTM3]
+ * KINETIS_SIM_HAS_SCGC3_ADC1 - SoC has SCGC3[ADC1]
+ * KINETIS_SIM_HAS_SCGC3_ADC3 - SoC has SCGC3[ADC3]
+ * KINETIS_SIM_HAS_SCGC3_SLCD - SoC has SCGC3[SLCD]
+ * KINETIS_SIM_HAS_SCGC4 - SoC has SCGC4 Register
+ * KINETIS_SIM_HAS_SCGC4_LLWU - SoC has SCGC4[LLWU] clock gate
+ * KINETIS_SIM_HAS_SCGC4_UART0 - SoC has SCGC4[UART0]
+ * KINETIS_SIM_HAS_SCGC4_UART1 - SoC has SCGC4[UART1]
+ * KINETIS_SIM_HAS_SCGC4_UART2 - SoC has SCGC4[UART2]
+ * KINETIS_SIM_HAS_SCGC4_UART3 - SoC has SCGC4[UART3]
+ * KINETIS_SIM_HAS_SCGC5 - SoC has _SCGC5 Register
+ * KINETIS_SIM_HAS_SCGC5_REGFILE - SoC has SCGC5[REGFILE]
+ * KINETIS_SIM_HAS_SCGC5_TSI - SoC has SCGC5[TSI]
+ * KINETIS_SIM_HAS_SCGC5_PORTF - SoC has SCGC5[PORTf]
+ * KINETIS_SIM_HAS_SCGC6 - SoC has SCGC6 Register
+ * KINETIS_SIM_HAS_SCGC6_FTFL - SoC has SCGC6[FTFL]
+ * KINETIS_SIM_HAS_SCGC6_DMAMUX1 - SoC has SCGC6[DEMUX1]
+ * KINETIS_SIM_HAS_SCGC6_USBHS - SoC has SCGC6[USBHS]
+ * KINETIS_SIM_HAS_SCGC6_RNGA - SoC has SCGC6[RNGA]
+ * KINETIS_SIM_HAS_SCGC6_FTM2 - SoC has SCGC6[FTM2]
+ * KINETIS_SIM_HAS_SCGC6_ADC2 - SoC has SCGC6[ADC2]
+ * KINETIS_SIM_HAS_SCGC6_DAC0 - SoC has SCGC6[DAC0]
+ * KINETIS_SIM_HAS_SCGC7 - SoC has SCGC7 Register
+ * KINETIS_SIM_HAS_SCGC7_FLEXBUS - SoC has SCGC7[FLEXBUS]
+ * KINETIS_SIM_HAS_SCGC7_DMA - SoC has SCGC7[DMS]
+ * KINETIS_SIM_HAS_SCGC7_MPU - SoC has SCGC7[MPU]
+ * KINETIS_SIM_HAS_SCGC7_SDRAMC - SoC has SCGC7[SDRAMC]
+ * KINETIS_SIM_HAS_CLKDIV1 - SoC has CLKDIV1 Register
+ * KINETIS_SIM_HAS_CLKDIV1_OUTDIV2 - SoC has CLKDIV1[OUTDIV2]
+ * KINETIS_SIM_HAS_CLKDIV1_OUTDIV3 - SoC has CLKDIV1[OUTDIV3]
+ * KINETIS_SIM_HAS_CLKDIV1_OUTDIV4 - SoC has CLKDIV1[OUTDIV4]
+ * KINETIS_SIM_HAS_CLKDIV1_OUTDIV5 - SoC has CLKDIV1[OUTDIV5]
+ * KINETIS_SIM_HAS_CLKDIV2 - SoC has CLKDIV2 Register
+ * KINETIS_SIM_HAS_CLKDIV2_USBDIV - SoC has CLKDIV2[USBDIV]
+ * KINETIS_SIM_HAS_CLKDIV2_USBFRAC - SoC has CLKDIV2[USBFRAC]
+ * KINETIS_SIM_HAS_CLKDIV2_I2SDIV - SoC has CLKDIV2[I2SDIV]
+ * KINETIS_SIM_HAS_CLKDIV2_I2SFRAC - SoC has CLKDIV2[I2SFRAC]
+ * KINETIS_SIM_HAS_CLKDIV2_USBHSDIV - SoC has CLKDIV2[USBHSDIV]
+ * KINETIS_SIM_HAS_CLKDIV2_USBHSFRAC - SoC has CLKDIV2[USBHSFRAC]
+ * KINETIS_SIM_HAS_FCFG1 - SoC has FCFG1 Register
+ * KINETIS_SIM_HAS_FCFG1_DEPART - SoC has FCFG1[DEPART]
+ * KINETIS_SIM_HAS_FCFG1_EESIZE - SoC has FCFG1[EESIZE]
+ * KINETIS_SIM_HAS_FCFG1_FLASHDIS - SoC has FCFG1[FLASHDIS]
+ * KINETIS_SIM_HAS_FCFG1_FLASHDOZE - SoC has FCFG1[FLASHDOZE]
+ * KINETIS_SIM_HAS_FCFG1_FTFDIS - SoC has FCFG1[FTFDIS]
+ * KINETIS_SIM_HAS_FCFG1_NVMSIZE - SoC has FCFG1[NVMSIZE]
+ * KINETIS_SIM_HAS_FCFG2 - SoC has FCFG2 Register
+ * KINETIS_SIM_HAS_FCFG2_MAXADDR0 - SoC has n bit of FCFG2[MAXADDR0]
+ * KINETIS_SIM_HAS_FCFG2_MAXADDR1 - SoC has n bit of FCFG2[MAXADDR1]
+ * KINETIS_SIM_HAS_FCFG2_PFLSH - SoC has FCFG2[PFLSH]
+ * KINETIS_SIM_HAS_FCFG2_SWAPPFLSH - SoC has FCFG2[SWAPPFLSH]
+ * KINETIS_SIM_HAS_UIDH - SoC has UIDH Register
+ * KINETIS_SIM_HAS_UIDMH - SoC has UIDMH Register
+ * KINETIS_SIM_HAS_UIDML - SoC has UIDML Register
+ * KINETIS_SIM_HAS_UIDL - SoC has UIDL Register
+ * KINETIS_SIM_HAS_CLKDIV3 - SoC has CLKDIV3 Register
+ * KINETIS_SIM_HAS_CLKDIV3_PLLFLLDIV - SoC has CLKDIV3[PLLFLLDIV]
+ * KINETIS_SIM_HAS_CLKDIV3_PLLFLLFRAC - SoC has CLKDIV3[PLLFLLFRAC]
+ * KINETIS_SIM_HAS_CLKDIV4 - SoC has CLKDIV4 Register
+ * KINETIS_SIM_HAS_CLKDIV4_TRACEDIV - SoC has CLKDIV4[TRACEDIV]
+ * KINETIS_SIM_HAS_CLKDIV4_TRACEFRAC - SoC has CLKDIV4[TRACEFRAC]
+ * KINETIS_SIM_HAS_CLKDIV4_NFCEDIV - SoC has CLKDIV4[NFCDIV]
+ * KINETIS_SIM_HAS_CLKDIV4_NFCFRAC - SoC has CLKDIV4[NFCFRAC]
+ * KINETIS_SIM_HAS_MCR - SoC has MCR Register
+ */
+
+/* Describe the version of the SIM
+ *
+ * These defines are not related to any NXP reference but are merely
+ * a way to label the versions we are using
+ */
+
+#define KINETIS_SIM_VERSION_UKN -1 /* What was in nuttx prior to 2/16/2017 */
+#define KINETIS_SIM_VERSION_01 1 /* Verified Document Number: K60P144M150SF3RM Rev. 3, November 2014 */
+#define KINETIS_SIM_VERSION_04 4 /* Verified to Document Number: K64P144M120SF5RM Rev. 2, January 2014 */
+#define KINETIS_SIM_VERSION_06 6 /* Verified to Document Number: K66P144M180SF5RMV2 Rev. 2, May 2015 */
+
+/* MK20DX/DN---VLH5
+ *
+ * ------------- ------ --- ------- ------ ------- ------ ----- ----
+ * PART NUMBER CPU PIN PACKAGE TOTAL PROGRAM EEPROM SRAM GPIO
+ * FREQ CNT FLASH FLASH
+ * ------------- ------ --- ------- ------ ------- ------ ----- ----
+ * MK20DN32VLH5 50 MHz 64 LQFP 32 KB 32 KB — 8 KB 40
+ * MK20DX32VLH5 50 MHz 64 LQFP 64 KB 32 KB 2 KB 8 KB 40
+ * MK20DN64VLH5 50 MHz 64 LQFP 64 KB 64 KB — 16 KB 40
+ * MK20DX64VLH5 50 MHz 64 LQFP 96 KB 64 KB 2 KB 16 KB 40
+ * MK20DN128VLH5 50 MHz 64 LQFP 128 KB 128 KB — 16 KB 40
+ * MK20DX128VLH5 50 MHz 64 LQFP 160 KB 128 KB 2 KB 16 KB 40
+ */
+
+#if defined(CONFIG_ARCH_CHIP_MK20DN32VLH5) || \
+ defined(CONFIG_ARCH_CHIP_MK20DX32VLH5) || \
+ defined(CONFIG_ARCH_CHIP_MK20DN64VLH5) || \
+ defined(CONFIG_ARCH_CHIP_MK20DX64VLH5) || \
+ defined(CONFIG_ARCH_CHIP_MK20DN128VLH5) || \
+ defined(CONFIG_ARCH_CHIP_MK20DX128VLH5)
+
+# define KINETIS_SIM_VERSION KINETIS_SIM_VERSION_UKN
+
+/* MK20DX---VLH7
+ *
+ * ------------- ------ --- ------- ------ ------- ------ ----- ----
+ * PART NUMBER CPU PIN PACKAGE TOTAL PROGRAM EEPROM SRAM GPIO
+ * FREQ CNT FLASH FLASH
+ * ------------- ------ --- ------- ------ ------- ------ ----- ----
+ * MK20DX64VLH7 72 MHz 64 LQFP 96 KB 64 KB 2 KB 16 KB 40
+ * MK20DX128VLH7 72 MHz 64 LQFP 160 KB 128 KB 2 KB 32 KB 40
+ * MK20DX256VLH7 72 MHz 64 LQFP 288 KB 256 KB 2 KB 64 KB 40
+ * ------------- ------ --- ------- ------ ------- ------ ----- ----
+ */
+
+#elif defined(CONFIG_ARCH_CHIP_MK20DX64VLH7) || defined(CONFIG_ARCH_CHIP_MK20DX128VLH7) || \
+ defined(CONFIG_ARCH_CHIP_MK20DX256VLH7)
+
+# define KINETIS_SIM_VERSION KINETIS_SIM_VERSION_UKN
+
+#elif defined(CONFIG_ARCH_CHIP_MK40X64VFX50) || defined(CONFIG_ARCH_CHIP_MK40X64VLH50) || \
+ defined(CONFIG_ARCH_CHIP_MK40X64VLK50) || defined(CONFIG_ARCH_CHIP_MK40X64VMB50)
+
+# define KINETIS_SIM_VERSION KINETIS_SIM_VERSION_UKN
+
+#elif defined(CONFIG_ARCH_CHIP_MK40X128VFX50) || defined(CONFIG_ARCH_CHIP_MK40X128VLH50) || \
+ defined(CONFIG_ARCH_CHIP_MK40X128VLK50) || defined(CONFIG_ARCH_CHIP_MK40X128VMB50) || \
+ defined(CONFIG_ARCH_CHIP_MK40X128VLL50) || defined(CONFIG_ARCH_CHIP_MK40X128VML50) || \
+ defined(CONFIG_ARCH_CHIP_MK40X128VFX72) || defined(CONFIG_ARCH_CHIP_MK40X128VLH72) || \
+ defined(CONFIG_ARCH_CHIP_MK40X128VLK72) || defined(CONFIG_ARCH_CHIP_MK40X128VMB72) || \
+ defined(CONFIG_ARCH_CHIP_MK40X128VLL72) || defined(CONFIG_ARCH_CHIP_MK40X128VML72)
+
+# define KINETIS_SIM_VERSION KINETIS_SIM_VERSION_UKN
+
+#elif defined(CONFIG_ARCH_CHIP_MK40X256VLK72) || defined(CONFIG_ARCH_CHIP_MK40X256VMB72) || \
+ defined(CONFIG_ARCH_CHIP_MK40X256VLL72) || defined(CONFIG_ARCH_CHIP_MK40X256VML72)
+
+# define KINETIS_SIM_VERSION KINETIS_SIM_VERSION_UKN
+
+#elif defined(CONFIG_ARCH_CHIP_MK40X128VLQ100) || defined(CONFIG_ARCH_CHIP_MK40X128VMD100)
+
+# define KINETIS_SIM_VERSION KINETIS_SIM_VERSION_UKN
+
+#elif defined(CONFIG_ARCH_CHIP_MK40X256VLQ100) || defined(CONFIG_ARCH_CHIP_MK40X256VMD100)
+
+# define KINETIS_SIM_VERSION KINETIS_SIM_VERSION_UKN
+
+#elif defined(CONFIG_ARCH_CHIP_MK40N512VLK100) || defined(CONFIG_ARCH_CHIP_MK40N512VMB100) || \
+ defined(CONFIG_ARCH_CHIP_MK40N512VLL100) || defined(CONFIG_ARCH_CHIP_MK40N512VML100) || \
+ defined(CONFIG_ARCH_CHIP_MK40N512VLQ100) || defined(CONFIG_ARCH_CHIP_MK40N512VMD100)
+
+# define KINETIS_SIM_VERSION KINETIS_SIM_VERSION_UKN
+
+#elif defined(CONFIG_ARCH_CHIP_MK60N256VLL100)
+
+# define KINETIS_SIM_VERSION KINETIS_SIM_VERSION_UKN
+
+#elif defined(CONFIG_ARCH_CHIP_MK60X256VLL100)
+
+# define KINETIS_SIM_VERSION KINETIS_SIM_VERSION_UKN
+
+#elif defined(CONFIG_ARCH_CHIP_MK60N512VLL100)
+
+# define KINETIS_SIM_VERSION KINETIS_SIM_VERSION_UKN
+
+#elif defined(CONFIG_ARCH_CHIP_MK60N256VML100)
+
+# define KINETIS_SIM_VERSION KINETIS_SIM_VERSION_UKN
+
+#elif defined(CONFIG_ARCH_CHIP_MK60X256VML100)
+
+# define KINETIS_SIM_VERSION KINETIS_SIM_VERSION_UKN
+
+#elif defined(CONFIG_ARCH_CHIP_MK60N512VML100)
+
+# define KINETIS_SIM_VERSION KINETIS_SIM_VERSION_UKN
+
+#elif defined(CONFIG_ARCH_CHIP_MK60N256VLQ100)
+
+# define KINETIS_SIM_VERSION KINETIS_SIM_VERSION_UKN
+
+#elif defined(CONFIG_ARCH_CHIP_MK60X256VLQ100)
+
+# define KINETIS_SIM_VERSION KINETIS_SIM_VERSION_UKN
+
+#elif defined(CONFIG_ARCH_CHIP_MK60N512VLQ100)
+
+# define KINETIS_SIM_VERSION KINETIS_SIM_VERSION_UKN
+
+#elif defined(CONFIG_ARCH_CHIP_MK60N256VMD100)
+
+# define KINETIS_SIM_VERSION KINETIS_SIM_VERSION_UKN
+
+#elif defined(CONFIG_ARCH_CHIP_MK60X256VMD100)
+
+# define KINETIS_SIM_VERSION KINETIS_SIM_VERSION_UKN
+
+#elif defined(CONFIG_ARCH_CHIP_MK60N512VMD100)
+
+# define KINETIS_SIM_VERSION KINETIS_SIM_VERSION_UKN
+
+#elif defined(CONFIG_ARCH_CHIP_MK60FN1M0VLQ12)
+
+/* Verified to Document Number: K60P144M100SF2V2RM Rev. 2 Jun 2012 */
+
+# define KINETIS_SIM_VERSION KINETIS_SIM_VERSION_01
+
+/* SIM Register Configuration */
+
+# define KINETIS_SIM_HAS_SOPT1 1 /* SoC has SOPT1 Register */
+# undef KINETIS_SIM_HAS_SOPT1_OSC32KOUT /* SoC has SOPT1[OSC32KOUT] */
+# define KINETIS_SIM_HAS_SOPT1_OSC32KSEL 1 /* SoC has SOPT1[OSC32KSEL] */
+# define KINETIS_SIM_HAS_SOPT1_OSC32KSEL_BITS 1 /* SoC has 1 bit SOPT1[OSC32KSEL] */
+# define KINETIS_SIM_HAS_SOPT1_RAMSIZE 1 /* SoC has SOPT1[RAMSIZE] */
+# define KINETIS_SIM_HAS_SOPT1_USBREGEN 1 /* SoC has SOPT1[USBREGEN] */
+# define KINETIS_SIM_HAS_SOPT1_USBSSTBY 1 /* SoC has SOPT1[USBSSTBY] */
+# define KINETIS_SIM_HAS_SOPT1_USBVSTBY 1 /* SoC has SOPT1[USBVSTBY] */
+# define KINETIS_SIM_HAS_SOPT1CFG /* SoC has SOPT1CFG Register */
+# define KINETIS_SIM_HAS_SOPT1CFG_URWE 1 /* SoC has SOPT1CFG[URWE] */
+# define KINETIS_SIM_HAS_SOPT1CFG_USSWE 1 /* SoC has SOPT1CFG[USSWE] */
+# define KINETIS_SIM_HAS_SOPT1CFG_UVSWE 1 /* SoC has SOPT1CFG[UVSWE] */
+# undef KINETIS_SIM_HAS_USBPHYCTL /* SoC has USBPHYCTL Register */
+# undef KINETIS_SIM_HAS_USBPHYCTL_USB3VOUTTRG /* SoC has USBPHYCTL[USB3VOUTTRG] */
+# undef KINETIS_SIM_HAS_USBPHYCTL_USBDISILIM /* SoC has USBPHYCTL[USBDISILIM] */
+# undef KINETIS_SIM_HAS_USBPHYCTL_USBVREGPD /* SoC has USBPHYCTL[USBVREGPD] */
+# undef KINETIS_SIM_HAS_USBPHYCTL_USBVREGSEL /* SoC has USBPHYCTL[USBVREGSEL] */
+# define KINETIS_SIM_HAS_SOPT2 1 /* SoC has SOPT2 Register */
+# define KINETIS_SIM_HAS_SOPT2_FBSL 1 /* SoC has SOPT2[FBSL] */
+# define KINETIS_SIM_HAS_SOPT2_CMTUARTPAD 1 /* SoC has SOPT2[CMTUARTPAD] */
+# define KINETIS_SIM_HAS_SOPT2_FLEXIOSRC 1 /* SoC has SOPT2[FLEXIOSRC] */
+# undef KINETIS_SIM_HAS_SOPT2_LPUARTSRC /* SoC has SOPT2[LPUARTSRC] */
+# define KINETIS_SIM_HAS_SOPT2_PLLFLLSEL 1 /* SoC has SOPT2[PLLFLLSEL] */
+# define KINETIS_SIM_HAS_SOPT2_PLLFLLSEL_BITS 2 /* SoC has 2 bits of SOPT2[PLLFLLSEL] */
+# undef KINETIS_SIM_HAS_SOPT2_PTD7PAD /* SoC has SOPT2[PTD7PAD] */
+# undef KINETIS_SIM_HAS_SOPT2_RMIISRC /* SoC has SOPT2[RMIISRC] */
+# define KINETIS_SIM_HAS_SOPT2_RTCCLKOUTSEL 1 /* SoC has SOPT2[RTCCLKOUTSEL] */
+# define KINETIS_SIM_HAS_SOPT2_CLKOUTSEL 1 /* SoC has SOPT2[CLKOUTSEL] */
+# define KINETIS_SIM_HAS_SOPT2_SDHCSRC 1 /* SoC has SOPT2[SDHCSRC] */
+# define KINETIS_SIM_HAS_SOPT2_NFCSRC 1 /* SoC has SOPT2[NFCSRC] */
+# undef KINETIS_SIM_HAS_SOPT2_I2SSRC /* SoC has SOPT2[I2SSRC] */
+# define KINETIS_SIM_HAS_SOPT2_TIMESRC 1 /* SoC has SOPT2[TIMESRC] */
+# undef KINETIS_SIM_HAS_SOPT2_TPMSRC /* SoC has SOPT2[TPMSRC] */
+# define KINETIS_SIM_HAS_SOPT2_USBFSRC 1 /* SoC has SOPT2[USBFSRC] */
+# define KINETIS_SIM_HAS_SOPT2_TRACECLKSEL 1 /* SoC has SOPT2[TRACECLKSEL] */
+# undef KINETIS_SIM_HAS_SOPT2_USBREGEN /* SoC has SOPT2[USBREGEN] */
+# undef KINETIS_SIM_HAS_SOPT2_USBSLSRC /* SoC has SOPT2[USBSLSRC] */
+# define KINETIS_SIM_HAS_SOPT2_USBHSRC 1 /* SoC has SOPT2[USBHSRC] */
+# define KINETIS_SIM_HAS_SOPT2_USBSRC 1 /* SoC has SOPT2[USBSRC] */
+# undef KINETIS_SIM_HAS_SOPT2_MCGCLKSEL /* SoC has SOPT2[MCGCLKSEL] */
+# define KINETIS_SIM_HAS_SOPT4 1 /* SoC has SOPT4 Register */
+# define KINETIS_SIM_HAS_SOPT4_FTM0FLT0 1 /* SoC has SOPT4[FTM0FLT0] */
+# define KINETIS_SIM_HAS_SOPT4_FTM0FLT1 1 /* SoC has SOPT4[FTM0FLT1] */
+# define KINETIS_SIM_HAS_SOPT4_FTM0FLT2 1 /* SoC has SOPT4[FTM0FLT2] */
+# define KINETIS_SIM_HAS_SOPT4_FTM0FLT3 1 /* SoC has SOPT4[FTM0FLT3] */
+# define KINETIS_SIM_HAS_SOPT4_FTM0TRG0SRC 1 /* SoC has SOPT4[FTM0TRG0SRC] */
+# define KINETIS_SIM_HAS_SOPT4_FTM0TRG1SRC 1 /* SoC has SOPT4[FTM0TRG1SRC] */
+# define KINETIS_SIM_HAS_SOPT4_FTM1CH0SRC 3 /* SoC has SOPT4[FTM1CH0SRC] 1, 3 if SOF */
+# define KINETIS_SIM_HAS_SOPT4_FTM1FLT0 1 /* SoC has SOPT4[FTM1FLT0] */
+# define KINETIS_SIM_HAS_SOPT4_FTM1FLT1 1 /* SoC has SOPT4[FTM1FLT1] */
+# define KINETIS_SIM_HAS_SOPT4_FTM1FLT2 1 /* SoC has SOPT4[FTM1FLT2] */
+# define KINETIS_SIM_HAS_SOPT4_FTM1FLT3 1 /* SoC has SOPT4[FTM1FLT3] */
+# define KINETIS_SIM_HAS_SOPT4_FTM2CH0SRC 1 /* SoC has SOPT4[FTM2CH0SRC] */
+# undef KINETIS_SIM_HAS_SOPT4_FTM2CH1SRC /* SoC has SOPT4[FTM2CH1SRC] */
+# define KINETIS_SIM_HAS_SOPT4_FTM2FLT0 1 /* SoC has SOPT4[FTM2FLT0] */
+# define KINETIS_SIM_HAS_SOPT4_FTM2FLT1 1 /* SoC has SOPT4[FTM2FLT1] */
+# define KINETIS_SIM_HAS_SOPT4_FTM2FLT2 1 /* SoC has SOPT4[FTM2FLT2] */
+# define KINETIS_SIM_HAS_SOPT4_FTM2FLT3 1 /* SoC has SOPT4[FTM2FLT3] */
+# define KINETIS_SIM_HAS_SOPT4_FTM3CH0SRC 1 /* SoC has SOPT4[FTM3CH0SRC] */
+# define KINETIS_SIM_HAS_SOPT4_FTM3FLT0 1 /* SoC has SOPT4[FTM3FLT0] */
+# define KINETIS_SIM_HAS_SOPT4_FTM3FLT1 1 /* SoC has SOPT4[FTM3FLT1] */
+# define KINETIS_SIM_HAS_SOPT4_FTM3FLT2 1 /* SoC has SOPT4[FTM3FLT2] */
+# define KINETIS_SIM_HAS_SOPT4_FTM3FLT3 1 /* SoC has SOPT4[FTM3FLT3] */
+# define KINETIS_SIM_HAS_SOPT4_FTM3TRG0SRC 1 /* SoC has SOPT4[FTM3TRG0SRC] */
+# define KINETIS_SIM_HAS_SOPT4_FTM3TRG1SRC 1 /* SoC has SOPT4[FTM3TRG1SRC] */
+# define KINETIS_SIM_HAS_SOPT4_TPM0CLKSEL 1 /* SoC has SOPT4[TPM0CLKSEL] */
+# define KINETIS_SIM_HAS_SOPT4_TPM1CH0SRC 1 /* SoC has SOPT4[TPM1CH0SRC] */
+# define KINETIS_SIM_HAS_SOPT4_TPM1CLKSEL 1 /* SoC has SOPT4[TPM1CLKSEL] */
+# define KINETIS_SIM_HAS_SOPT4_TPM2CH0SRC 1 /* SoC has SOPT4[TPM2CH0SRC] */
+# define KINETIS_SIM_HAS_SOPT4_TPM2CLKSEL 1 /* SoC has SOPT4[TPM2CLKSEL] */
+# define KINETIS_SIM_HAS_SOPT5 1 /* SoC has SOPT5 Register */
+# undef KINETIS_SIM_HAS_SOPT5_LPUART0RXSRC /* SoC has SOPT5[LPUART0RXSRC] */
+# undef KINETIS_SIM_HAS_SOPT5_LPUART0TXSRC /* SoC has SOPT5[LPUART0TXSRC] */
+# define KINETIS_SIM_HAS_SOPT6 1 /* SoC has SOPT6 Register */
+# define KINETIS_SIM_HAS_SOPT6_MCC 1 /* SoC has SOPT6[MCC] */
+# define KINETIS_SIM_HAS_SOPT6_PCR 1 /* SoC has SOPT6[PCR] */
+# undef KINETIS_SIM_HAS_SOPT6_RSTFLTSEL /* SoC has SOPT6[RSTFLTSEL] */
+# undef KINETIS_SIM_HAS_SOPT6_RSTFLTEN /* SoC has SOPT6[RSTFLTEN] */
+# define KINETIS_SIM_HAS_SOPT7 1 /* SoC has SOPT7 Register */
+# define KINETIS_SIM_HAS_SOPT7_ADC0ALTTRGSEL 1 /* SoC has SOPT7[ADC0ALTTRGSEL] */
+# define KINETIS_SIM_HAS_SOPT7_ADC1ALTTRGSEL 1 /* SoC has SOPT7[ADC1ALTTRGSEL] */
+# define KINETIS_SIM_HAS_SOPT7_ADC0PRETRGSEL 1 /* SoC has SOPT7[ADC0PRETRGSEL] */
+# define KINETIS_SIM_HAS_SOPT7_ADC1PRETRGSEL 1 /* SoC has SOPT7[ADC1PRETRGSEL] */
+# define KINETIS_SIM_HAS_SOPT7_ADC2PRETRGSEL 1 /* SoC has SOPT7[ADC2PRETRGSEL] */
+# define KINETIS_SIM_HAS_SOPT7_ADC3PRETRGSEL 1 /* SoC has SOPT7[ADC3PRETRGSEL] */
+# define KINETIS_SIM_HAS_SOPT7_ADC0TRGSEL 15 /* SoC has 15 SOPT7[ADC0TRGSEL] */
+# define KINETIS_SIM_HAS_SOPT7_ADC1TRGSEL 15 /* SoC has 15 SOPT7[ADC1TRGSEL] */
+# define KINETIS_SIM_HAS_SOPT7_ADC2TRGSEL 15 /* SoC has 15 SOPT7[ADC2TRGSEL] */
+# define KINETIS_SIM_HAS_SOPT7_ADC3TRGSEL 15 /* SoC has 15 SOPT7[ADC3TRGSEL] */
+# define KINETIS_SIM_SOPT7_ADC0ALTTRGEN 1 /* ADC0 alternate trigger enable */
+# define KINETIS_SIM_SOPT7_ADC1ALTTRGEN 1 /* ADC1 alternate trigger enable */
+# define KINETIS_SIM_SOPT7_ADC2ALTTRGEN 1 /* ADC2 alternate trigger enable */
+# define KINETIS_SIM_SOPT7_ADC3ALTTRGEN 1 /* ADC3 alternate trigger enable */
+# undef KINETIS_SIM_HAS_SOPT8 /* SoC has SOPT8 Register */
+# undef KINETIS_SIM_HAS_SOPT8_FTM0SYNCBIT /* SoC has SOPT8[FTM0SYNCBIT] */
+# undef KINETIS_SIM_HAS_SOPT8_FTM1SYNCBIT /* SoC has SOPT8[FTM1SYNCBIT] */
+# undef KINETIS_SIM_HAS_SOPT8_FTM2SYNCBIT /* SoC has SOPT8[FTM2SYNCBIT] */
+# undef KINETIS_SIM_HAS_SOPT8_FTM3SYNCBIT /* SoC has SOPT8[FTM3SYNCBIT] */
+# undef KINETIS_SIM_HAS_SOPT8_FTM0OCH0SRC /* SoC has SOPT8[FTM0OCH0SRC] */
+# undef KINETIS_SIM_HAS_SOPT8_FTM0OCH1SRC /* SoC has SOPT8[FTM0OCH1SRC] */
+# undef KINETIS_SIM_HAS_SOPT8_FTM0OCH2SRC /* SoC has SOPT8[FTM0OCH2SRC] */
+# undef KINETIS_SIM_HAS_SOPT8_FTM0OCH3SRC /* SoC has SOPT8[FTM0OCH3SRC] */
+# undef KINETIS_SIM_HAS_SOPT8_FTM0OCH4SRC /* SoC has SOPT8[FTM0OCH4SRC] */
+# undef KINETIS_SIM_HAS_SOPT8_FTM0OCH5SRC /* SoC has SOPT8[FTM0OCH5SRC] */
+# undef KINETIS_SIM_HAS_SOPT8_FTM0OCH6SRC /* SoC has SOPT8[FTM0OCH6SRC] */
+# undef KINETIS_SIM_HAS_SOPT8_FTM0OCH7SRC /* SoC has SOPT8[FTM0OCH7SRC] */
+# undef KINETIS_SIM_HAS_SOPT8_FTM3OCH0SRC /* SoC has SOPT8[FTM3OCH0SRC] */
+# undef KINETIS_SIM_HAS_SOPT8_FTM3OCH1SRC /* SoC has SOPT8[FTM3OCH1SRC] */
+# undef KINETIS_SIM_HAS_SOPT8_FTM3OCH2SRC /* SoC has SOPT8[FTM3OCH2SRC] */
+# undef KINETIS_SIM_HAS_SOPT8_FTM3OCH3SRC /* SoC has SOPT8[FTM3OCH3SRC] */
+# undef KINETIS_SIM_HAS_SOPT8_FTM3OCH4SRC /* SoC has SOPT8[FTM3OCH4SRC] */
+# undef KINETIS_SIM_HAS_SOPT8_FTM3OCH5SRC /* SoC has SOPT8[FTM3OCH5SRC] */
+# undef KINETIS_SIM_HAS_SOPT8_FTM3OCH6SRC /* SoC has SOPT8[FTM3OCH6SRC] */
+# undef KINETIS_SIM_HAS_SOPT8_FTM3OCH7SRC /* SoC has SOPT8[FTM3OCH7SRC] */
+# undef KINETIS_SIM_HAS_SOPT9 /* SoC has SOPT9 Register */
+# undef KINETIS_SIM_HAS_SOPT9_TPM1CH0SRC /* SoC has SOPT9[TPM1CH0SRC] */
+# undef KINETIS_SIM_HAS_SOPT9_TPM2CH0SRC /* SoC has SOPT9[TPM2CH0SRC] */
+# undef KINETIS_SIM_HAS_SOPT9_TPM1CLKSEL /* SoC has SOPT9[TPM1CLKSEL] */
+# undef KINETIS_SIM_HAS_SOPT9_TPM2CLKSEL /* SoC has SOPT9[TPM2CLKSEL] */
+# define KINETIS_SIM_HAS_SDID 1 /* SoC has SDID Register */
+# undef KINETIS_SIM_HAS_SDID_DIEID /* SoC has SDID[DIEID] */
+# define KINETIS_SIM_HAS_SDID_FAMID 1 /* SoC has SDID[FAMID] */
+# undef KINETIS_SIM_HAS_SDID_FAMILYID /* SoC has SDID[FAMILYID] */
+# undef KINETIS_SIM_HAS_SDID_SERIESID /* SoC has SDID[SERIESID] */
+# undef KINETIS_SIM_HAS_SDID_SRAMSIZE /* SoC has SDID[SRAMSIZE] */
+# undef KINETIS_SIM_HAS_SDID_SUBFAMID /* SoC has SDID[SUBFAMID] */
+# define KINETIS_SIM_HAS_SCGC1 1 /* SoC has _SCGC1 Register */
+# define KINETIS_SIM_HAS_SCGC1_UART5 1 /* SoC has SCGC1[UART5] */
+# define KINETIS_SIM_HAS_SCGC1_UART4 1 /* SoC has SCGC1[UART4] */
+# undef KINETIS_SIM_HAS_SCGC1_I2C3 /* SoC has SCGC1[I2C3] */
+# undef KINETIS_SIM_HAS_SCGC1_I2C2 /* SoC has SCGC1[I2C2] */
+# define KINETIS_SIM_HAS_SCGC1_OSC1 1 /* SoC has SCGC1[OSC1] */
+# define KINETIS_SIM_HAS_SCGC2 1 /* SoC has _SCGC2 Register */
+# define KINETIS_SIM_HAS_SCGC2 1 /* SoC has SCGC2 Register */
+# define KINETIS_SIM_HAS_SCGC2_ENET 1 /* SoC has SCGC2[ENET] */
+# undef KINETIS_SIM_HAS_SCGC2_LPUART0 /* SoC has SCGC2[LPUART0] */
+# undef KINETIS_SIM_HAS_SCGC2_TPM1 /* SoC has SCGC2[TPM1] */
+# undef KINETIS_SIM_HAS_SCGC2_TPM2 /* SoC has SCGC2[TPM2] */
+# define KINETIS_SIM_HAS_SCGC3 1 /* SoC has SCGC3 Register */
+# define KINETIS_SIM_HAS_SCGC3_RNGA 1 /* SoC has SCGC3[RNGA] */
+# undef KINETIS_SIM_HAS_SCGC3_USBHS /* SoC has SCGC3[USBHS] */
+# undef KINETIS_SIM_HAS_SCGC3_USBHSPHY /* SoC has SCGC3[USBHSPHY] */
+# undef KINETIS_SIM_HAS_SCGC3_USBHSDCD /* SoC has SCGC3[USBHSDCD] */
+# define KINETIS_SIM_HAS_SCGC3_FLEXCAN1 1 /* SoC has SCGC3[FLEXCAN1] */
+# define KINETIS_SIM_HAS_SCGC3_NFC 1 /* SoC has SCGC3[NFC] */
+# define KINETIS_SIM_HAS_SCGC3_SPI2 1 /* SoC has SCGC3[SPI2] */
+# define KINETIS_SIM_HAS_SCGC3_SAI1 1 /* SoC has SCGC3[SAI1] */
+# define KINETIS_SIM_HAS_SCGC3_SDHC 1 /* SoC has SCGC3[SDHC] */
+# define KINETIS_SIM_HAS_SCGC3_FTM2 1 /* SoC has SCGC3[FTM2] */
+# define KINETIS_SIM_HAS_SCGC3_FTM3 1 /* SoC has SCGC3[FTM3] */
+# define KINETIS_SIM_HAS_SCGC3_ADC1 1 /* SoC has SCGC3[ADC1] */
+# define KINETIS_SIM_HAS_SCGC3_ADC3 1 /* SoC has SCGC3[ADC3] */
+# undef KINETIS_SIM_HAS_SCGC3_SLCD /* SoC has SCGC3[SLCD] */
+# define KINETIS_SIM_HAS_SCGC4 1 /* SoC has SCGC4 Register */
+# define KINETIS_SIM_HAS_SCGC4_LLWU 1 /* SoC has SCGC4[LLWU] clock gate */
+# define KINETIS_SIM_HAS_SCGC4_UART0 1 /* SoC has SCGC4[UART0] */
+# define KINETIS_SIM_HAS_SCGC4_UART1 1 /* SoC has SCGC4[UART1] */
+# define KINETIS_SIM_HAS_SCGC4_UART2 1 /* SoC has SCGC4[UART2] */
+# define KINETIS_SIM_HAS_SCGC4_UART3 1 /* SoC has SCGC4[UART3] */
+# define KINETIS_SIM_HAS_SCGC5 1 /* SoC has _SCGC5 Register */
+# undef KINETIS_SIM_HAS_SCGC5_REGFILE /* SoC has SCGC5[REGFILE] */
+# define KINETIS_SIM_HAS_SCGC5_TSI 1 /* SoC has SCGC5[TSI] */
+# define KINETIS_SIM_HAS_SCGC5_PORTF 1 /* SoC has SCGC5[PORTF] */
+# define KINETIS_SIM_HAS_SCGC6 1 /* SoC has SCGC6 Register */
+# undef KINETIS_SIM_HAS_SCGC6_FTFL /* SoC has SCGC6[FTFL] */
+# define KINETIS_SIM_HAS_SCGC6_DMAMUX1 1 /* SoC has SCGC6[DEMUX1] */
+# define KINETIS_SIM_HAS_SCGC6_USBHS 1 /* SoC has SCGC6[USBHS] */
+# define KINETIS_SIM_HAS_SCGC6_RNGA 1 /* SoC has SCGC6[RNGA] */
+# undef KINETIS_SIM_HAS_SCGC6_FTM2 /* SoC has SCGC6[FTM2] */
+# define KINETIS_SIM_HAS_SCGC6_ADC2 1 /* SoC has SCGC6[ADC2] */
+# undef KINETIS_SIM_HAS_SCGC6_DAC0 /* SoC has SCGC6[DAC0] */
+# define KINETIS_SIM_HAS_SCGC7 1 /* SoC has SCGC7 Register */
+# define KINETIS_SIM_HAS_SCGC7_FLEXBUS 1 /* SoC has SCGC7[FLEXBUS] */
+# define KINETIS_SIM_HAS_SCGC7_DMA 1 /* SoC has SCGC7[DMS] */
+# define KINETIS_SIM_HAS_SCGC7_MPU 1 /* SoC has SCGC7[MPU] */
+# undef KINETIS_SIM_HAS_SCGC7_SDRAMC /* SoC has SCGC7[SDRAMC] */
+# define KINETIS_SIM_HAS_CLKDIV1 1 /* SoC has CLKDIV1 Register */
+# define KINETIS_SIM_HAS_CLKDIV1_OUTDIV2 1 /* SoC has CLKDIV1[OUTDIV2] */
+# define KINETIS_SIM_HAS_CLKDIV1_OUTDIV3 1 /* SoC has CLKDIV1[OUTDIV3] */
+# define KINETIS_SIM_HAS_CLKDIV1_OUTDIV4 1 /* SoC has CLKDIV1[OUTDIV4] */
+# undef KINETIS_SIM_HAS_CLKDIV1_OUTDIV5 /* SoC has CLKDIV1[OUTDIV5] */
+# define KINETIS_SIM_HAS_CLKDIV2 1 /* SoC has CLKDIV2 Register */
+# define KINETIS_SIM_HAS_CLKDIV2_USBDIV 1 /* SoC has CLKDIV2[USBDIV] */
+# define KINETIS_SIM_HAS_CLKDIV2_USBFRAC 1 /* SoC has CLKDIV2[USBFRAC] */
+# undef KINETIS_SIM_HAS_CLKDIV2_USBFSDIV /* SoC has CLKDIV2[USBFSDIV] */
+# undef KINETIS_SIM_HAS_CLKDIV2_USBFSFRAC /* SoC has CLKDIV2[USBFSFRAC] */
+# define KINETIS_SIM_HAS_CLKDIV2_USBHSDIV 1 /* SoC has CLKDIV2[USBHSDIV] */
+# define KINETIS_SIM_HAS_CLKDIV2_USBHSFRAC 1 /* SoC has CLKDIV2[USBHSFRAC] */
+# undef KINETIS_SIM_HAS_CLKDIV2_I2SDIV /* SoC has CLKDIV2[I2SDIV] */
+# undef KINETIS_SIM_HAS_CLKDIV2_I2SFRAC /* SoC has CLKDIV2[I2SFRAC] */
+# define KINETIS_SIM_HAS_FCFG1 1 /* SoC has FCFG1 Register */
+# define KINETIS_SIM_HAS_FCFG1_DEPART 1 /* SoC has FCFG1[DEPART] */
+# define KINETIS_SIM_HAS_FCFG1_EESIZE 1 /* SoC has FCFG1[EESIZE] */
+# undef KINETIS_SIM_HAS_FCFG1_FLASHDIS /* SoC has FCFG1[FLASHDIS] */
+# undef KINETIS_SIM_HAS_FCFG1_FLASHDOZE /* SoC has FCFG1[FLASHDOZE] */
+# define KINETIS_SIM_HAS_FCFG1_FTFDIS 1 /* SoC has FCFG1[FTFDIS] */
+# define KINETIS_SIM_HAS_FCFG1_NVMSIZE 1 /* SoC has FCFG1[NVMSIZE] */
+# define KINETIS_SIM_HAS_FCFG2 1 /* SoC has FCFG2 Register */
+# define KINETIS_SIM_HAS_FCFG2_MAXADDR0 6 /* SoC has n bit of FCFG2[MAXADDR0] */
+# define KINETIS_SIM_HAS_FCFG2_MAXADDR1 6 /* SoC has n bit of FCFG2[MAXADDR1] */
+# define KINETIS_SIM_HAS_FCFG2_PFLSH 1 /* SoC has FCFG2[PFLSH] */
+# define KINETIS_SIM_HAS_FCFG2_SWAPPFLSH 1 /* SoC has FCFG2[SWAPPFLSH] */
+# define KINETIS_SIM_HAS_UIDH 1 /* SoC has UIDH Register */
+# define KINETIS_SIM_HAS_UIDMH 1 /* SoC has UIDMH Register */
+# define KINETIS_SIM_HAS_UIDML 1 /* SoC has UIDML Register */
+# define KINETIS_SIM_HAS_UIDL 1 /* SoC has UIDL Register */
+# undef KINETIS_SIM_HAS_CLKDIV3 /* SoC has CLKDIV3 Register */
+# undef KINETIS_SIM_HAS_CLKDIV3_PLLFLLDIV /* SoC has CLKDIV3[PLLFLLDIV] */
+# undef KINETIS_SIM_HAS_CLKDIV3_PLLFLLFRAC /* SoC has CLKDIV3[PLLFLLFRAC] */
+# define KINETIS_SIM_HAS_CLKDIV4 1 /* SoC has CLKDIV4 Register */
+# define KINETIS_SIM_HAS_CLKDIV4_TRACEDIV 1 /* SoC has CLKDIV4[TRACEDIV] */
+# define KINETIS_SIM_HAS_CLKDIV4_TRACEFRAC 1 /* SoC has CLKDIV4[TRACEFRAC] */
+# define KINETIS_SIM_HAS_CLKDIV4_NFCDIV 1 /* SoC has CLKDIV4[NFCDIV] */
+# define KINETIS_SIM_HAS_CLKDIV4_NFCFRAC 1 /* SoC has CLKDIV4[NFCFRAC] */
+# define KINETIS_SIM_HAS_MCR 1 /* SoC has MCR Register */
+
+#elif defined(CONFIG_ARCH_CHIP_MK64FN1M0VLL12) || defined(CONFIG_ARCH_CHIP_MK64FX512VLL12) || \
+ defined(CONFIG_ARCH_CHIP_MK64FX512VDC12) || defined(CONFIG_ARCH_CHIP_MK64FN1M0VDC12) || \
+ defined(CONFIG_ARCH_CHIP_MK64FX512VLQ12) || defined(CONFIG_ARCH_CHIP_MK64FN1M0VLQ12) || \
+ defined(CONFIG_ARCH_CHIP_MK64FX512VMD12) || defined(CONFIG_ARCH_CHIP_MK64FN1M0VMD12)
+
+/* Verified to Document Number: K64P144M120SF5RM Rev. 2, January 2014 */
+
+# define KINETIS_SIM_VERSION KINETIS_SIM_VERSION_04
+
+/* SIM Register Configuration */
+
+# define KINETIS_SIM_HAS_SOPT1 1 /* SoC has SOPT1 Register */
+# undef KINETIS_SIM_HAS_SOPT1_OSC32KOUT /* SoC has SOPT1[OSC32KOUT] */
+# define KINETIS_SIM_HAS_SOPT1_OSC32KSEL 1 /* SoC has SOPT1[OSC32KSEL] */
+# define KINETIS_SIM_HAS_SOPT1_OSC32KSEL_BITS 2 /* SoC has 2 bits of SOPT1[OSC32KSEL] */
+# define KINETIS_SIM_HAS_SOPT1_RAMSIZE 1 /* SoC has SOPT1[RAMSIZE] */
+# define KINETIS_SIM_HAS_SOPT1_USBREGEN 1 /* SoC has SOPT1[USBREGEN] */
+# define KINETIS_SIM_HAS_SOPT1_USBSSTBY 1 /* SoC has SOPT1[USBSSTBY] */
+# define KINETIS_SIM_HAS_SOPT1_USBVSTBY 1 /* SoC has SOPT1[USBVSTBY] */
+# define KINETIS_SIM_HAS_SOPT1CFG /* SoC has SOPT1CFG Register */
+# define KINETIS_SIM_HAS_SOPT1CFG_URWE 1 /* SoC has SOPT1CFG[URWE] */
+# define KINETIS_SIM_HAS_SOPT1CFG_USSWE 1 /* SoC has SOPT1CFG[USSWE] */
+# define KINETIS_SIM_HAS_SOPT1CFG_UVSWE 1 /* SoC has SOPT1CFG[UVSWE] */
+# undef KINETIS_SIM_HAS_USBPHYCTL /* SoC has USBPHYCTL Register */
+# undef KINETIS_SIM_HAS_USBPHYCTL_USB3VOUTTRG /* SoC has USBPHYCTL[USB3VOUTTRG] */
+# undef KINETIS_SIM_HAS_USBPHYCTL_USBDISILIM /* SoC has USBPHYCTL[USBDISILIM] */
+# undef KINETIS_SIM_HAS_USBPHYCTL_USBVREGPD /* SoC has USBPHYCTL[USBVREGPD] */
+# undef KINETIS_SIM_HAS_USBPHYCTL_USBVREGSEL /* SoC has USBPHYCTL[USBVREGSEL] */
+# define KINETIS_SIM_HAS_SOPT2 1 /* SoC has SOPT2 Register */
+# define KINETIS_SIM_HAS_SOPT2_FBSL 1 /* SoC has SOPT2[FBSL] */
+# undef KINETIS_SIM_HAS_SOPT2_CMTUARTPAD /* SoC has SOPT2[CMTUARTPAD] */
+# define KINETIS_SIM_HAS_SOPT2_FLEXIOSRC 1 /* SoC has SOPT2[FLEXIOSRC] */
+# undef KINETIS_SIM_HAS_SOPT2_LPUARTSRC /* SoC has SOPT2[LPUARTSRC] */
+# define KINETIS_SIM_HAS_SOPT2_PLLFLLSEL 1 /* SoC has SOPT2[PLLFLLSEL] */
+# define KINETIS_SIM_HAS_SOPT2_PLLFLLSEL_BITS 2 /* SoC has 2 bits of SOPT2[PLLFLLSEL] */
+# define KINETIS_SIM_HAS_SOPT2_PTD7PAD 1 /* SoC has SOPT2[PTD7PAD] */
+# define KINETIS_SIM_HAS_SOPT2_RMIISRC 1 /* SoC has SOPT2[RMIISRC] */
+# define KINETIS_SIM_HAS_SOPT2_RTCCLKOUTSEL 1 /* SoC has SOPT2[RTCCLKOUTSEL] */
+# define KINETIS_SIM_HAS_SOPT2_CLKOUTSEL 1 /* SoC has SOPT2[CLKOUTSEL] */
+# define KINETIS_SIM_HAS_SOPT2_SDHCSRC 1 /* SoC has SOPT2[SDHCSRC] */
+# undef KINETIS_SIM_HAS_SOPT2_NFCSRC /* SoC has SOPT2[NFCSRC] */
+# undef KINETIS_SIM_HAS_SOPT2_I2SSRC /* SoC has SOPT2[I2SSRC] */
+# define KINETIS_SIM_HAS_SOPT2_TIMESRC 1 /* SoC has SOPT2[TIMESRC] */
+# undef KINETIS_SIM_HAS_SOPT2_TPMSRC /* SoC has SOPT2[TPMSRC] */
+# undef KINETIS_SIM_HAS_SOPT2_USBFSRC /* SoC has SOPT2[USBFSRC] */
+# define KINETIS_SIM_HAS_SOPT2_TRACECLKSEL 1 /* SoC has SOPT2[TRACECLKSEL] */
+# undef KINETIS_SIM_HAS_SOPT2_USBREGEN /* SoC has SOPT2[USBREGEN] */
+# undef KINETIS_SIM_HAS_SOPT2_USBSLSRC /* SoC has SOPT2[USBSLSRC] */
+# undef KINETIS_SIM_HAS_SOPT2_USBHSRC /* SoC has SOPT2[USBHSRC] */
+# define KINETIS_SIM_HAS_SOPT2_USBSRC 1 /* SoC has SOPT2[USBSRC] */
+# undef KINETIS_SIM_HAS_SOPT2_MCGCLKSEL /* SoC has SOPT2[MCGCLKSEL] */
+# define KINETIS_SIM_HAS_SOPT4 1 /* SoC has SOPT4 Register */
+# define KINETIS_SIM_HAS_SOPT4_FTM0FLT0 1 /* SoC has SOPT4[FTM0FLT0] */
+# define KINETIS_SIM_HAS_SOPT4_FTM0FLT1 1 /* SoC has SOPT4[FTM0FLT1] */
+# define KINETIS_SIM_HAS_SOPT4_FTM0FLT2 1 /* SoC has SOPT4[FTM0FLT2] */
+# undef KINETIS_SIM_HAS_SOPT4_FTM0FLT3 /* SoC has SOPT4[FTM0FLT3] */
+# define KINETIS_SIM_HAS_SOPT4_FTM0TRG0SRC 1 /* SoC has SOPT4[FTM0TRG0SRC] */
+# define KINETIS_SIM_HAS_SOPT4_FTM0TRG1SRC 1 /* SoC has SOPT4[FTM0TRG1SRC] */
+# define KINETIS_SIM_HAS_SOPT4_FTM1CH0SRC 3 /* SoC has SOPT4[FTM1CH0SRC] 1, 3 if SOF */
+# define KINETIS_SIM_HAS_SOPT4_FTM1FLT0 1 /* SoC has SOPT4[FTM1FLT0] */
+# define KINETIS_SIM_HAS_SOPT4_FTM1FLT1 1 /* SoC has SOPT4[FTM1FLT1] */
+# define KINETIS_SIM_HAS_SOPT4_FTM1FLT2 1 /* SoC has SOPT4[FTM1FLT2] */
+# define KINETIS_SIM_HAS_SOPT4_FTM1FLT3 1 /* SoC has SOPT4[FTM1FLT3] */
+# define KINETIS_SIM_HAS_SOPT4_FTM2CH0SRC 1 /* SoC has SOPT4[FTM2CH0SRC] */
+# undef KINETIS_SIM_HAS_SOPT4_FTM2CH1SRC /* SoC has SOPT4[FTM2CH1SRC] */
+# define KINETIS_SIM_HAS_SOPT4_FTM2FLT0 1 /* SoC has SOPT4[FTM2FLT0] */
+# define KINETIS_SIM_HAS_SOPT4_FTM2FLT1 1 /* SoC has SOPT4[FTM2FLT1] */
+# define KINETIS_SIM_HAS_SOPT4_FTM2FLT2 1 /* SoC has SOPT4[FTM2FLT2] */
+# define KINETIS_SIM_HAS_SOPT4_FTM2FLT3 1 /* SoC has SOPT4[FTM2FLT3] */
+# define KINETIS_SIM_HAS_SOPT4_FTM3CH0SRC 1 /* SoC has SOPT4[FTM3CH0SRC] */
+# define KINETIS_SIM_HAS_SOPT4_FTM3FLT0 1 /* SoC has SOPT4[FTM3FLT0] */
+# define KINETIS_SIM_HAS_SOPT4_FTM3FLT1 1 /* SoC has SOPT4[FTM3FLT1] */
+# define KINETIS_SIM_HAS_SOPT4_FTM3FLT2 1 /* SoC has SOPT4[FTM3FLT2] */
+# define KINETIS_SIM_HAS_SOPT4_FTM3FLT3 1 /* SoC has SOPT4[FTM3FLT3] */
+# define KINETIS_SIM_HAS_SOPT4_FTM3TRG0SRC 1 /* SoC has SOPT4[FTM3TRG0SRC] */
+# define KINETIS_SIM_HAS_SOPT4_FTM3TRG1SRC 1 /* SoC has SOPT4[FTM3TRG1SRC] */
+# define KINETIS_SIM_HAS_SOPT4_TPM0CLKSEL 1 /* SoC has SOPT4[TPM0CLKSEL] */
+# define KINETIS_SIM_HAS_SOPT4_TPM1CH0SRC 1 /* SoC has SOPT4[TPM1CH0SRC] */
+# define KINETIS_SIM_HAS_SOPT4_TPM1CLKSEL 1 /* SoC has SOPT4[TPM1CLKSEL] */
+# define KINETIS_SIM_HAS_SOPT4_TPM2CH0SRC 1 /* SoC has SOPT4[TPM2CH0SRC] */
+# define KINETIS_SIM_HAS_SOPT4_TPM2CLKSEL 1 /* SoC has SOPT4[TPM2CLKSEL] */
+# define KINETIS_SIM_HAS_SOPT5 1 /* SoC has SOPT5 Register */
+# undef KINETIS_SIM_HAS_SOPT5_LPUART0RXSRC /* SoC has SOPT5[LPUART0RXSRC] */
+# undef KINETIS_SIM_HAS_SOPT5_LPUART0TXSRC /* SoC has SOPT5[LPUART0TXSRC] */
+# undef KINETIS_SIM_HAS_SOPT6 /* SoC has SOPT6 Register */
+# undef KINETIS_SIM_HAS_SOPT6_MCC /* SoC has SOPT6[MCC] */
+# undef KINETIS_SIM_HAS_SOPT6_PCR /* SoC has SOPT6[PCR] */
+# undef KINETIS_SIM_HAS_SOPT6_RSTFLTSEL /* SoC has SOPT6[RSTFLTSEL] */
+# undef KINETIS_SIM_HAS_SOPT6_RSTFLTEN /* SoC has SOPT6[RSTFLTEN] */
+# define KINETIS_SIM_HAS_SOPT7 1 /* SoC has SOPT7 Register */
+# define KINETIS_SIM_HAS_SOPT7_ADC0ALTTRGSEL 1 /* SoC has SOPT7[ADC0ALTTRGSEL] */
+# define KINETIS_SIM_HAS_SOPT7_ADC1ALTTRGSEL 1 /* SoC has SOPT7[ADC1ALTTRGSEL] */
+# define KINETIS_SIM_HAS_SOPT7_ADC0PRETRGSEL 1 /* SoC has SOPT7[ADC0PRETRGSEL] */
+# define KINETIS_SIM_HAS_SOPT7_ADC1PRETRGSEL 1 /* SoC has SOPT7[ADC1PRETRGSEL] */
+# undef KINETIS_SIM_HAS_SOPT7_ADC2PRETRGSEL /* SoC has SOPT7[ADC2PRETRGSEL] */
+# undef KINETIS_SIM_HAS_SOPT7_ADC3PRETRGSEL /* SoC has SOPT7[ADC3PRETRGSEL] */
+# define KINETIS_SIM_HAS_SOPT7_ADC0TRGSEL 14 /* SoC has 10 SOPT7[ADC0TRGSEL] */
+# define KINETIS_SIM_HAS_SOPT7_ADC1TRGSEL 14 /* SoC has 10 SOPT7[ADC1TRGSEL] */
+# undef KINETIS_SIM_HAS_SOPT7_ADC2TRGSEL /* SoC has 10 SOPT7[ADC2TRGSEL] */
+# undef KINETIS_SIM_HAS_SOPT7_ADC3TRGSEL /* SoC has 10 SOPT7[ADC3TRGSEL] */
+# define KINETIS_SIM_SOPT7_ADC0ALTTRGEN 1 /* ADC0 alternate trigger enable */
+# define KINETIS_SIM_SOPT7_ADC1ALTTRGEN 1 /* ADC1 alternate trigger enable */
+# undef KINETIS_SIM_SOPT7_ADC2ALTTRGEN /* ADC2 alternate trigger enable */
+# undef KINETIS_SIM_SOPT7_ADC3ALTTRGEN /* ADC3 alternate trigger enable */
+# undef KINETIS_SIM_HAS_SOPT8 /* SoC has SOPT8 Register */
+# undef KINETIS_SIM_HAS_SOPT8_FTM0SYNCBIT /* SoC has SOPT8[FTM0SYNCBIT] */
+# undef KINETIS_SIM_HAS_SOPT8_FTM1SYNCBIT /* SoC has SOPT8[FTM1SYNCBIT] */
+# undef KINETIS_SIM_HAS_SOPT8_FTM2SYNCBIT /* SoC has SOPT8[FTM2SYNCBIT] */
+# undef KINETIS_SIM_HAS_SOPT8_FTM3SYNCBIT /* SoC has SOPT8[FTM3SYNCBIT] */
+# undef KINETIS_SIM_HAS_SOPT8_FTM0OCH0SRC /* SoC has SOPT8[FTM0OCH0SRC] */
+# undef KINETIS_SIM_HAS_SOPT8_FTM0OCH1SRC /* SoC has SOPT8[FTM0OCH1SRC] */
+# undef KINETIS_SIM_HAS_SOPT8_FTM0OCH2SRC /* SoC has SOPT8[FTM0OCH2SRC] */
+# undef KINETIS_SIM_HAS_SOPT8_FTM0OCH3SRC /* SoC has SOPT8[FTM0OCH3SRC] */
+# undef KINETIS_SIM_HAS_SOPT8_FTM0OCH4SRC /* SoC has SOPT8[FTM0OCH4SRC] */
+# undef KINETIS_SIM_HAS_SOPT8_FTM0OCH5SRC /* SoC has SOPT8[FTM0OCH5SRC] */
+# undef KINETIS_SIM_HAS_SOPT8_FTM0OCH6SRC /* SoC has SOPT8[FTM0OCH6SRC] */
+# undef KINETIS_SIM_HAS_SOPT8_FTM0OCH7SRC /* SoC has SOPT8[FTM0OCH7SRC] */
+# undef KINETIS_SIM_HAS_SOPT8_FTM3OCH0SRC /* SoC has SOPT8[FTM3OCH0SRC] */
+# undef KINETIS_SIM_HAS_SOPT8_FTM3OCH1SRC /* SoC has SOPT8[FTM3OCH1SRC] */
+# undef KINETIS_SIM_HAS_SOPT8_FTM3OCH2SRC /* SoC has SOPT8[FTM3OCH2SRC] */
+# undef KINETIS_SIM_HAS_SOPT8_FTM3OCH3SRC /* SoC has SOPT8[FTM3OCH3SRC] */
+# undef KINETIS_SIM_HAS_SOPT8_FTM3OCH4SRC /* SoC has SOPT8[FTM3OCH4SRC] */
+# undef KINETIS_SIM_HAS_SOPT8_FTM3OCH5SRC /* SoC has SOPT8[FTM3OCH5SRC] */
+# undef KINETIS_SIM_HAS_SOPT8_FTM3OCH6SRC /* SoC has SOPT8[FTM3OCH6SRC] */
+# undef KINETIS_SIM_HAS_SOPT8_FTM3OCH7SRC /* SoC has SOPT8[FTM3OCH7SRC] */
+# undef KINETIS_SIM_HAS_SOPT9 /* SoC has SOPT9 Register */
+# undef KINETIS_SIM_HAS_SOPT9_TPM1CH0SRC /* SoC has SOPT9[TPM1CH0SRC] */
+# undef KINETIS_SIM_HAS_SOPT9_TPM2CH0SRC /* SoC has SOPT9[TPM2CH0SRC] */
+# undef KINETIS_SIM_HAS_SOPT9_TPM1CLKSEL /* SoC has SOPT9[TPM1CLKSEL] */
+# undef KINETIS_SIM_HAS_SOPT9_TPM2CLKSEL /* SoC has SOPT9[TPM2CLKSEL] */
+# define KINETIS_SIM_HAS_SDID 1 /* SoC has SDID Register */
+# define KINETIS_SIM_HAS_SDID_DIEID 1 /* SoC has SDID[DIEID] */
+# define KINETIS_SIM_HAS_SDID_FAMID 1 /* SoC has SDID[FAMID] */
+# define KINETIS_SIM_HAS_SDID_FAMILYID 1 /* SoC has SDID[FAMILYID] */
+# define KINETIS_SIM_HAS_SDID_SERIESID 1 /* SoC has SDID[SERIESID] */
+# undef KINETIS_SIM_HAS_SDID_SRAMSIZE /* SoC has SDID[SRAMSIZE] */
+# define KINETIS_SIM_HAS_SDID_SUBFAMID 1 /* SoC has SDID[SUBFAMID] */
+# define KINETIS_SIM_HAS_SCGC1 1 /* SoC has _SCGC1 Register */
+# define KINETIS_SIM_HAS_SCGC1_UART5 1 /* SoC has SCGC1[UART5] */
+# define KINETIS_SIM_HAS_SCGC1_UART4 1 /* SoC has SCGC1[UART4] */
+# undef KINETIS_SIM_HAS_SCGC1_I2C3 /* SoC has SCGC1[I2C3] */
+# define KINETIS_SIM_HAS_SCGC1_I2C2 1 /* SoC has SCGC1[I2C2] */
+# undef KINETIS_SIM_HAS_SCGC1_OSC1 /* SoC has SCGC1[OSC1] */
+# define KINETIS_SIM_HAS_SCGC2 1 /* SoC has _SCGC2 Register */
+# define KINETIS_SIM_HAS_SCGC2 1 /* SoC has SCGC2 Register */
+# define KINETIS_SIM_HAS_SCGC2_ENET 1 /* SoC has SCGC2[ENET] */
+# undef KINETIS_SIM_HAS_SCGC2_LPUART0 /* SoC has SCGC2[LPUART0] */
+# undef KINETIS_SIM_HAS_SCGC2_TPM1 /* SoC has SCGC2[TPM1] */
+# undef KINETIS_SIM_HAS_SCGC2_TPM2 /* SoC has SCGC2[TPM2] */
+# define KINETIS_SIM_HAS_SCGC3 1 /* SoC has SCGC3 Register */
+# define KINETIS_SIM_HAS_SCGC3_RNGA 1 /* SoC has SCGC3[RNGA] */
+# undef KINETIS_SIM_HAS_SCGC3_USBHS /* SoC has SCGC3[USBHS] */
+# undef KINETIS_SIM_HAS_SCGC3_USBHSPHY /* SoC has SCGC3[USBHSPHY] */
+# undef KINETIS_SIM_HAS_SCGC3_USBHSDCD /* SoC has SCGC3[USBHSDCD] */
+# undef KINETIS_SIM_HAS_SCGC3_FLEXCAN1 /* SoC has SCGC3[FLEXCAN1] */
+# undef KINETIS_SIM_HAS_SCGC3_NFC /* SoC has SCGC3[NFC] */
+# define KINETIS_SIM_HAS_SCGC3_SPI2 1 /* SoC has SCGC3[SPI2] */
+# undef KINETIS_SIM_HAS_SCGC3_SAI1 /* SoC has SCGC3[SAI1] */
+# define KINETIS_SIM_HAS_SCGC3_SDHC 1 /* SoC has SCGC3[SDHC] */
+# define KINETIS_SIM_HAS_SCGC3_FTM2 1 /* SoC has SCGC3[FTM2] */
+# define KINETIS_SIM_HAS_SCGC3_FTM3 1 /* SoC has SCGC3[FTM3] */
+# define KINETIS_SIM_HAS_SCGC3_ADC1 1 /* SoC has SCGC3[ADC1] */
+# undef KINETIS_SIM_HAS_SCGC3_ADC3 /* SoC has SCGC3[ADC3] */
+# undef KINETIS_SIM_HAS_SCGC3_SLCD /* SoC has SCGC3[SLCD] */
+# define KINETIS_SIM_HAS_SCGC4 1 /* SoC has SCGC4 Register */
+# undef KINETIS_SIM_HAS_SCGC4_LLWU /* SoC has SCGC4[LLWU] clock gate */
+# define KINETIS_SIM_HAS_SCGC4_UART0 1 /* SoC has SCGC4[UART0] */
+# define KINETIS_SIM_HAS_SCGC4_UART1 1 /* SoC has SCGC4[UART1] */
+# define KINETIS_SIM_HAS_SCGC4_UART2 1 /* SoC has SCGC4[UART2] */
+# define KINETIS_SIM_HAS_SCGC4_UART3 1 /* SoC has SCGC4[UART3] */
+# define KINETIS_SIM_HAS_SCGC5 1 /* SoC has _SCGC5 Register */
+# undef KINETIS_SIM_HAS_SCGC5_REGFILE /* SoC has SCGC5[REGFILE] */
+# undef KINETIS_SIM_HAS_SCGC5_TSI /* SoC has SCGC5[TSI] */
+# undef KINETIS_SIM_HAS_SCGC5_PORTF /* SoC has SCGC5[PORTF] */
+# define KINETIS_SIM_HAS_SCGC6 1 /* SoC has SCGC6 Register */
+# define KINETIS_SIM_HAS_SCGC6_FTFL 1 /* SoC has SCGC6[FTFL] */
+# undef KINETIS_SIM_HAS_SCGC6_DMAMUX1 /* SoC has SCGC6[DEMUX1] */
+# undef KINETIS_SIM_HAS_SCGC6_USBHS /* SoC has SCGC6[USBHS] */
+# define KINETIS_SIM_HAS_SCGC6_RNGA 1 /* SoC has SCGC6[RNGA] */
+# define KINETIS_SIM_HAS_SCGC6_FTM2 1 /* SoC has SCGC6[FTM2] */
+# undef KINETIS_SIM_HAS_SCGC6_ADC2 /* SoC has SCGC6[ADC2] */
+# define KINETIS_SIM_HAS_SCGC6_DAC0 1 /* SoC has SCGC6[DAC0] */
+# define KINETIS_SIM_HAS_SCGC7 1 /* SoC has SCGC7 Register */
+# define KINETIS_SIM_HAS_SCGC7_FLEXBUS 1 /* SoC has SCGC7[FLEXBUS] */
+# define KINETIS_SIM_HAS_SCGC7_DMA 1 /* SoC has SCGC7[DMS] */
+# define KINETIS_SIM_HAS_SCGC7_MPU 1 /* SoC has SCGC7[MPU] */
+# undef KINETIS_SIM_HAS_SCGC7_SDRAMC /* SoC has SCGC7[SDRAMC] */
+# define KINETIS_SIM_HAS_CLKDIV1 1 /* SoC has CLKDIV1 Register */
+# define KINETIS_SIM_HAS_CLKDIV1_OUTDIV2 1 /* SoC has CLKDIV1[OUTDIV2] */
+# define KINETIS_SIM_HAS_CLKDIV1_OUTDIV3 1 /* SoC has CLKDIV1[OUTDIV3] */
+# define KINETIS_SIM_HAS_CLKDIV1_OUTDIV4 1 /* SoC has CLKDIV1[OUTDIV4] */
+# undef KINETIS_SIM_HAS_CLKDIV1_OUTDIV5 /* SoC has CLKDIV1[OUTDIV5] */
+# define KINETIS_SIM_HAS_CLKDIV2 1 /* SoC has CLKDIV2 Register */
+# define KINETIS_SIM_HAS_CLKDIV2_USBDIV 1 /* SoC has CLKDIV2[USBDIV] */
+# define KINETIS_SIM_HAS_CLKDIV2_USBFRAC 1 /* SoC has CLKDIV2[USBFRAC] */
+# undef KINETIS_SIM_HAS_CLKDIV2_USBFSDIV /* SoC has CLKDIV2[USBFSDIV] */
+# undef KINETIS_SIM_HAS_CLKDIV2_USBFSFRAC /* SoC has CLKDIV2[USBFSFRAC] */
+# undef KINETIS_SIM_HAS_CLKDIV2_USBHSDIV /* SoC has CLKDIV2[USBHSDIV] */
+# undef KINETIS_SIM_HAS_CLKDIV2_USBHSFRAC /* SoC has CLKDIV2[USBHSFRAC] */
+# undef KINETIS_SIM_HAS_CLKDIV2_I2SDIV /* SoC has CLKDIV2[I2SDIV] */
+# undef KINETIS_SIM_HAS_CLKDIV2_I2SFRAC /* SoC has CLKDIV2[I2SFRAC] */
+# define KINETIS_SIM_HAS_FCFG1 1 /* SoC has FCFG1 Register */
+# define KINETIS_SIM_HAS_FCFG1_DEPART 1 /* SoC has FCFG1[DEPART] */
+# define KINETIS_SIM_HAS_FCFG1_EESIZE 1 /* SoC has FCFG1[EESIZE] */
+# define KINETIS_SIM_HAS_FCFG1_FLASHDIS 1 /* SoC has FCFG1[FLASHDIS] */
+# define KINETIS_SIM_HAS_FCFG1_FLASHDOZE 1 /* SoC has FCFG1[FLASHDOZE] */
+# undef KINETIS_SIM_HAS_FCFG1_FTFDIS /* SoC has FCFG1[FTFDIS] */
+# define KINETIS_SIM_HAS_FCFG1_NVMSIZE 1 /* SoC has FCFG1[NVMSIZE] */
+# define KINETIS_SIM_HAS_FCFG2 1 /* SoC has FCFG2 Register */
+# define KINETIS_SIM_HAS_FCFG2_MAXADDR0 7 /* SoC has n bit of FCFG2[MAXADDR0] */
+# define KINETIS_SIM_HAS_FCFG2_MAXADDR1 7 /* SoC has n bit of FCFG2[MAXADDR1] */
+# define KINETIS_SIM_HAS_FCFG2_PFLSH 1 /* SoC has FCFG2[PFLSH] */
+# undef KINETIS_SIM_HAS_FCFG2_SWAPPFLSH /* SoC has FCFG2[SWAPPFLSH] */
+# define KINETIS_SIM_HAS_UIDH 1 /* SoC has UIDH Register */
+# define KINETIS_SIM_HAS_UIDMH 1 /* SoC has UIDMH Register */
+# define KINETIS_SIM_HAS_UIDML 1 /* SoC has UIDML Register */
+# define KINETIS_SIM_HAS_UIDL 1 /* SoC has UIDL Register */
+# undef KINETIS_SIM_HAS_CLKDIV3 /* SoC has CLKDIV3 Register */
+# undef KINETIS_SIM_HAS_CLKDIV3_PLLFLLDIV /* SoC has CLKDIV3[PLLFLLDIV] */
+# undef KINETIS_SIM_HAS_CLKDIV3_PLLFLLFRAC /* SoC has CLKDIV3[PLLFLLFRAC] */
+# undef KINETIS_SIM_HAS_CLKDIV4 /* SoC has CLKDIV4 Register */
+# undef KINETIS_SIM_HAS_CLKDIV4_TRACEDIV /* SoC has CLKDIV4[TRACEDIV] */
+# undef KINETIS_SIM_HAS_CLKDIV4_TRACEFRAC /* SoC has CLKDIV4[TRACEFRAC] */
+# undef KINETIS_SIM_HAS_CLKDIV4_NFCDIV /* SoC has CLKDIV4[NFCDIV] */
+# undef KINETIS_SIM_HAS_CLKDIV4_NFCFRAC /* SoC has CLKDIV4[NFCFRAC] */
+# undef KINETIS_SIM_HAS_MCR /* SoC has MCR Register */
+
+/* MK66F N/X 1M0/2M0 V MD/LQ 18
+ *
+ * --------------- ------- --- ------- ------- ------ ------ ------ -----
+ * PART NUMBER CPU PIN PACKAGE TOTAL PROGRAM EEPROM SRAM GPIO
+ * FREQ CNT FLASH FLASH
+ * --------------- ------- --- ------- ------- ------ ------ ------ -----
+ * MK66FN2M0VMD18 180 MHz 144 MAPBGA 2 MB — — KB 260 KB 100
+ * MK66FX1M0VMD18 180 MHz 144 MAPBGA 1.25 MB 1 MB 4 KB 256 KB 100
+ * MK66FN2M0VLQ18 180 MHz 144 LQFP 2 MB — — KB 260 KB 100
+ * MK66FX1M0VLQ18 180 MHz 144 LQFP 1.25 MB 1 MB 4 KB 256 KB 100
+ */
+
+#elif defined(CONFIG_ARCH_CHIP_MK66FN2M0VMD18) || defined(CONFIG_ARCH_CHIP_MK66FX1M0VMD18) || \
+ defined(CONFIG_ARCH_CHIP_MK66FN2M0VLQ18) || defined(CONFIG_ARCH_CHIP_MK66FX1M0VLQ18)
+
+/* Verified to Document Number: Document Number: K66P144M180SF5RMV2 Rev. 2, May 2015 */
+
+# define KINETIS_SIM_VERSION KINETIS_SIM_VERSION_06
+
+/* SIM Register Configuration */
+
+# define KINETIS_SIM_HAS_SOPT1 1 /* SoC has SOPT1 Register */
+# undef KINETIS_SIM_HAS_SOPT1_OSC32KOUT /* SoC has SOPT1[OSC32KOUT] */
+# define KINETIS_SIM_HAS_SOPT1_OSC32KSEL 1 /* SoC has SOPT1[OSC32KSEL] */
+# define KINETIS_SIM_HAS_SOPT1_OSC32KSEL_BITS 2 /* SoC has 1 bit SOPT1[OSC32KSEL] */
+# define KINETIS_SIM_HAS_SOPT1_RAMSIZE 1 /* SoC has SOPT1[RAMSIZE] */
+# define KINETIS_SIM_HAS_SOPT1_USBREGEN 1 /* SoC has SOPT1[USBREGEN] */
+# define KINETIS_SIM_HAS_SOPT1_USBSSTBY 1 /* SoC has SOPT1[USBSSTBY] */
+# define KINETIS_SIM_HAS_SOPT1_USBVSTBY 1 /* SoC has SOPT1[USBVSTBY] */
+# define KINETIS_SIM_HAS_SOPT1CFG /* SoC has SOPT1CFG Register */
+# define KINETIS_SIM_HAS_SOPT1CFG_URWE 1 /* SoC has SOPT1CFG[URWE] */
+# define KINETIS_SIM_HAS_SOPT1CFG_USSWE 1 /* SoC has SOPT1CFG[USSWE] */
+# define KINETIS_SIM_HAS_SOPT1CFG_UVSWE 1 /* SoC has SOPT1CFG[UVSWE] */
+# define KINETIS_SIM_HAS_USBPHYCTL 1 /* SoC has USBPHYCTL Register */
+# define KINETIS_SIM_HAS_USBPHYCTL_USB3VOUTTRG 1 /* SoC has USBPHYCTL[USB3VOUTTRG] */
+# define KINETIS_SIM_HAS_USBPHYCTL_USBDISILIM 1 /* SoC has USBPHYCTL[USBDISILIM] */
+# define KINETIS_SIM_HAS_USBPHYCTL_USBVREGPD 1 /* SoC has USBPHYCTL[USBVREGPD] */
+# define KINETIS_SIM_HAS_USBPHYCTL_USBVREGSEL 1 /* SoC has USBPHYCTL[USBVREGSEL] */
+# define KINETIS_SIM_HAS_SOPT2 1 /* SoC has SOPT2 Register */
+# define KINETIS_SIM_HAS_SOPT2_FBSL 1 /* SoC has SOPT2[FBSL] */
+# undef KINETIS_SIM_HAS_SOPT2_CMTUARTPAD /* SoC has SOPT2[CMTUARTPAD] */
+# define KINETIS_SIM_HAS_SOPT2_FLEXIOSRC 1 /* SoC has SOPT2[FLEXIOSRC] */
+# define KINETIS_SIM_HAS_SOPT2_LPUARTSRC 1 /* SoC has SOPT2[LPUARTSRC] */
+# define KINETIS_SIM_HAS_SOPT2_PLLFLLSEL 1 /* SoC has SOPT2[PLLFLLSEL] */
+# define KINETIS_SIM_HAS_SOPT2_PLLFLLSEL_BITS 2 /* SoC has 2 bits of SOPT2[PLLFLLSEL] */
+# undef KINETIS_SIM_HAS_SOPT2_PTD7PAD /* SoC has SOPT2[PTD7PAD] */
+# define KINETIS_SIM_HAS_SOPT2_RMIISRC 1 /* SoC has SOPT2[RMIISRC] */
+# define KINETIS_SIM_HAS_SOPT2_RTCCLKOUTSEL 1 /* SoC has SOPT2[RTCCLKOUTSEL] */
+# define KINETIS_SIM_HAS_SOPT2_CLKOUTSEL 1 /* SoC has SOPT2[CLKOUTSEL] */
+# define KINETIS_SIM_HAS_SOPT2_SDHCSRC 1 /* SoC has SOPT2[SDHCSRC] */
+# undef KINETIS_SIM_HAS_SOPT2_NFCSRC /* SoC has SOPT2[NFCSRC] */
+# undef KINETIS_SIM_HAS_SOPT2_I2SSRC /* SoC has SOPT2[I2SSRC] */
+# define KINETIS_SIM_HAS_SOPT2_TIMESRC 1 /* SoC has SOPT2[TIMESRC] */
+# define KINETIS_SIM_HAS_SOPT2_TPMSRC 1 /* SoC has SOPT2[TPMSRC] */
+# undef KINETIS_SIM_HAS_SOPT2_USBFSRC /* SoC has SOPT2[USBFSRC] */
+# define KINETIS_SIM_HAS_SOPT2_TRACECLKSEL 1 /* SoC has SOPT2[TRACECLKSEL] */
+# define KINETIS_SIM_HAS_SOPT2_USBREGEN 1 /* SoC has SOPT2[USBREGEN] */
+# define KINETIS_SIM_HAS_SOPT2_USBSLSRC 1 /* SoC has SOPT2[USBSLSRC] */
+# undef KINETIS_SIM_HAS_SOPT2_USBHSRC /* SoC has SOPT2[USBHSRC] */
+# define KINETIS_SIM_HAS_SOPT2_USBSRC 1 /* SoC has SOPT2[USBSRC] */
+# undef KINETIS_SIM_HAS_SOPT2_MCGCLKSEL /* SoC has SOPT2[MCGCLKSEL] */
+# define KINETIS_SIM_HAS_SOPT4 1 /* SoC has SOPT4 Register */
+# define KINETIS_SIM_HAS_SOPT4_FTM0FLT0 1 /* SoC has SOPT4[FTM0FLT0] */
+# define KINETIS_SIM_HAS_SOPT4_FTM0FLT1 1 /* SoC has SOPT4[FTM0FLT1] */
+# define KINETIS_SIM_HAS_SOPT4_FTM0FLT2 1 /* SoC has SOPT4[FTM0FLT2] */
+# define KINETIS_SIM_HAS_SOPT4_FTM0FLT3 1 /* SoC has SOPT4[FTM0FLT3] */
+# define KINETIS_SIM_HAS_SOPT4_FTM0TRG0SRC 1 /* SoC has SOPT4[FTM0TRG0SRC] */
+# define KINETIS_SIM_HAS_SOPT4_FTM0TRG1SRC 1 /* SoC has SOPT4[FTM0TRG1SRC] */
+# define KINETIS_SIM_HAS_SOPT4_FTM1CH0SRC 3 /* SoC has SOPT4[FTM1CH0SRC] 1, 3 if SOF */
+# define KINETIS_SIM_HAS_SOPT4_FTM1FLT0 1 /* SoC has SOPT4[FTM1FLT0] */
+# define KINETIS_SIM_HAS_SOPT4_FTM1FLT1 1 /* SoC has SOPT4[FTM1FLT1] */
+# define KINETIS_SIM_HAS_SOPT4_FTM1FLT2 1 /* SoC has SOPT4[FTM1FLT2] */
+# define KINETIS_SIM_HAS_SOPT4_FTM1FLT3 1 /* SoC has SOPT4[FTM1FLT3] */
+# define KINETIS_SIM_HAS_SOPT4_FTM2CH0SRC 1 /* SoC has SOPT4[FTM2CH0SRC] */
+# define KINETIS_SIM_HAS_SOPT4_FTM2CH1SRC 1 /* SoC has SOPT4[FTM2CH1SRC] */
+# define KINETIS_SIM_HAS_SOPT4_FTM2FLT0 1 /* SoC has SOPT4[FTM2FLT0] */
+# define KINETIS_SIM_HAS_SOPT4_FTM2FLT1 1 /* SoC has SOPT4[FTM2FLT1] */
+# define KINETIS_SIM_HAS_SOPT4_FTM2FLT2 1 /* SoC has SOPT4[FTM2FLT2] */
+# define KINETIS_SIM_HAS_SOPT4_FTM2FLT3 1 /* SoC has SOPT4[FTM2FLT3] */
+# define KINETIS_SIM_HAS_SOPT4_FTM3CH0SRC 1 /* SoC has SOPT4[FTM3CH0SRC] */
+# define KINETIS_SIM_HAS_SOPT4_FTM3FLT0 1 /* SoC has SOPT4[FTM3FLT0] */
+# define KINETIS_SIM_HAS_SOPT4_FTM3FLT1 1 /* SoC has SOPT4[FTM3FLT1] */
+# define KINETIS_SIM_HAS_SOPT4_FTM3FLT2 1 /* SoC has SOPT4[FTM3FLT2] */
+# define KINETIS_SIM_HAS_SOPT4_FTM3FLT3 1 /* SoC has SOPT4[FTM3FLT3] */
+# define KINETIS_SIM_HAS_SOPT4_FTM3TRG0SRC 1 /* SoC has SOPT4[FTM3TRG0SRC] */
+# define KINETIS_SIM_HAS_SOPT4_FTM3TRG1SRC 1 /* SoC has SOPT4[FTM3TRG1SRC] */
+# define KINETIS_SIM_HAS_SOPT4_TPM0CLKSEL 1 /* SoC has SOPT4[TPM0CLKSEL] */
+# define KINETIS_SIM_HAS_SOPT4_TPM1CH0SRC 1 /* SoC has SOPT4[TPM1CH0SRC] */
+# define KINETIS_SIM_HAS_SOPT4_TPM1CLKSEL 1 /* SoC has SOPT4[TPM1CLKSEL] */
+# define KINETIS_SIM_HAS_SOPT4_TPM2CH0SRC 1 /* SoC has SOPT4[TPM2CH0SRC] */
+# define KINETIS_SIM_HAS_SOPT4_TPM2CLKSEL 1 /* SoC has SOPT4[TPM2CLKSEL] */
+# define KINETIS_SIM_HAS_SOPT5 1 /* SoC has SOPT5 Register */
+# define KINETIS_SIM_HAS_SOPT5_LPUART0RXSRC 1 /* SoC has SOPT5[LPUART0RXSRC] */
+# define KINETIS_SIM_HAS_SOPT5_LPUART0TXSRC 1 /* SoC has SOPT5[LPUART0TXSRC] */
+# undef KINETIS_SIM_HAS_SOPT6 /* SoC has SOPT6 Register */
+# undef KINETIS_SIM_HAS_SOPT6_MCC /* SoC has SOPT6[MCC] */
+# undef KINETIS_SIM_HAS_SOPT6_PCR /* SoC has SOPT6[PCR] */
+# undef KINETIS_SIM_HAS_SOPT6_RSTFLTSEL /* SoC has SOPT6[RSTFLTSEL] */
+# undef KINETIS_SIM_HAS_SOPT6_RSTFLTEN /* SoC has SOPT6[RSTFLTEN] */
+# define KINETIS_SIM_HAS_SOPT7 1 /* SoC has SOPT7 Register */
+# define KINETIS_SIM_HAS_SOPT7_ADC0ALTTRGSEL 1 /* SoC has SOPT7[ADC0ALTTRGSEL] */
+# define KINETIS_SIM_HAS_SOPT7_ADC1ALTTRGSEL 1 /* SoC has SOPT7[ADC1ALTTRGSEL] */
+# define KINETIS_SIM_HAS_SOPT7_ADC0PRETRGSEL 1 /* SoC has SOPT7[ADC0PRETRGSEL] */
+# define KINETIS_SIM_HAS_SOPT7_ADC1PRETRGSEL 1 /* SoC has SOPT7[ADC1PRETRGSEL] */
+# undef KINETIS_SIM_HAS_SOPT7_ADC2PRETRGSEL /* SoC has SOPT7[ADC2PRETRGSEL] */
+# undef KINETIS_SIM_HAS_SOPT7_ADC3PRETRGSEL /* SoC has SOPT7[ADC3PRETRGSEL] */
+# define KINETIS_SIM_HAS_SOPT7_ADC0TRGSEL 15 /* SoC has 10 SOPT7[ADC0TRGSEL] */
+# define KINETIS_SIM_HAS_SOPT7_ADC1TRGSEL 15 /* SoC has 10 SOPT7[ADC1TRGSEL] */
+# undef KINETIS_SIM_HAS_SOPT7_ADC2TRGSEL /* SoC has 10 SOPT7[ADC2TRGSEL] */
+# undef KINETIS_SIM_HAS_SOPT7_ADC3TRGSEL /* SoC has 10 SOPT7[ADC3TRGSEL] */
+# define KINETIS_SIM_SOPT7_ADC0ALTTRGEN 1 /* ADC0 alternate trigger enable */
+# define KINETIS_SIM_SOPT7_ADC1ALTTRGEN 1 /* ADC1 alternate trigger enable */
+# undef KINETIS_SIM_SOPT7_ADC2ALTTRGEN /* ADC2 alternate trigger enable */
+# undef KINETIS_SIM_SOPT7_ADC3ALTTRGEN /* ADC3 alternate trigger enable */
+# define KINETIS_SIM_HAS_SOPT8 1 /* SoC has SOPT8 Register */
+# define KINETIS_SIM_HAS_SOPT8_FTM0SYNCBIT 1 /* SoC has SOPT8[FTM0SYNCBIT] */
+# define KINETIS_SIM_HAS_SOPT8_FTM1SYNCBIT 1 /* SoC has SOPT8[FTM1SYNCBIT] */
+# define KINETIS_SIM_HAS_SOPT8_FTM2SYNCBIT 1 /* SoC has SOPT8[FTM2SYNCBIT] */
+# define KINETIS_SIM_HAS_SOPT8_FTM3SYNCBIT 1 /* SoC has SOPT8[FTM3SYNCBIT] */
+# define KINETIS_SIM_HAS_SOPT8_FTM0OCH0SRC 1 /* SoC has SOPT8[FTM0OCH0SRC] */
+# define KINETIS_SIM_HAS_SOPT8_FTM0OCH1SRC 1 /* SoC has SOPT8[FTM0OCH1SRC] */
+# define KINETIS_SIM_HAS_SOPT8_FTM0OCH2SRC 1 /* SoC has SOPT8[FTM0OCH2SRC] */
+# define KINETIS_SIM_HAS_SOPT8_FTM0OCH3SRC 1 /* SoC has SOPT8[FTM0OCH3SRC] */
+# define KINETIS_SIM_HAS_SOPT8_FTM0OCH4SRC 1 /* SoC has SOPT8[FTM0OCH4SRC] */
+# define KINETIS_SIM_HAS_SOPT8_FTM0OCH5SRC 1 /* SoC has SOPT8[FTM0OCH5SRC] */
+# define KINETIS_SIM_HAS_SOPT8_FTM0OCH6SRC 1 /* SoC has SOPT8[FTM0OCH6SRC] */
+# define KINETIS_SIM_HAS_SOPT8_FTM0OCH7SRC 1 /* SoC has SOPT8[FTM0OCH7SRC] */
+# define KINETIS_SIM_HAS_SOPT8_FTM3OCH0SRC 1 /* SoC has SOPT8[FTM3OCH0SRC] */
+# define KINETIS_SIM_HAS_SOPT8_FTM3OCH1SRC 1 /* SoC has SOPT8[FTM3OCH1SRC] */
+# define KINETIS_SIM_HAS_SOPT8_FTM3OCH2SRC 1 /* SoC has SOPT8[FTM3OCH2SRC] */
+# define KINETIS_SIM_HAS_SOPT8_FTM3OCH3SRC 1 /* SoC has SOPT8[FTM3OCH3SRC] */
+# define KINETIS_SIM_HAS_SOPT8_FTM3OCH4SRC 1 /* SoC has SOPT8[FTM3OCH4SRC] */
+# define KINETIS_SIM_HAS_SOPT8_FTM3OCH5SRC 1 /* SoC has SOPT8[FTM3OCH5SRC] */
+# define KINETIS_SIM_HAS_SOPT8_FTM3OCH6SRC 1 /* SoC has SOPT8[FTM3OCH6SRC] */
+# define KINETIS_SIM_HAS_SOPT8_FTM3OCH7SRC 1 /* SoC has SOPT8[FTM3OCH7SRC] */
+# define KINETIS_SIM_HAS_SOPT9 1 /* SoC has SOPT9 Register */
+# define KINETIS_SIM_HAS_SOPT9_TPM1CH0SRC 1 /* SoC has SOPT9[TPM1CH0SRC] */
+# define KINETIS_SIM_HAS_SOPT9_TPM2CH0SRC 1 /* SoC has SOPT9[TPM2CH0SRC] */
+# define KINETIS_SIM_HAS_SOPT9_TPM1CLKSEL 1 /* SoC has SOPT9[TPM1CLKSEL] */
+# define KINETIS_SIM_HAS_SOPT9_TPM2CLKSEL 1 /* SoC has SOPT9[TPM2CLKSEL] */
+# define KINETIS_SIM_HAS_SDID 1 /* SoC has SDID Register */
+# define KINETIS_SIM_HAS_SDID_DIEID 1 /* SoC has SDID[DIEID] */
+# define KINETIS_SIM_HAS_SDID_FAMID 1 /* SoC has SDID[FAMID] */
+# define KINETIS_SIM_HAS_SDID_FAMILYID 1 /* SoC has SDID[FAMILYID] */
+# define KINETIS_SIM_HAS_SDID_SERIESID 1 /* SoC has SDID[SERIESID] */
+# undef KINETIS_SIM_HAS_SDID_SRAMSIZE /* SoC has SDID[SRAMSIZE] */
+# define KINETIS_SIM_HAS_SDID_SUBFAMID 1 /* SoC has SDID[SUBFAMID] */
+# define KINETIS_SIM_HAS_SCGC1 1 /* SoC has _SCGC1 Register */
+# undef KINETIS_SIM_HAS_SCGC1_UART5 /* SoC has SCGC1[UART5] */
+# define KINETIS_SIM_HAS_SCGC1_UART4 1 /* SoC has SCGC1[UART4] */
+# define KINETIS_SIM_HAS_SCGC1_I2C3 1 /* SoC has SCGC1[I2C3] */
+# define KINETIS_SIM_HAS_SCGC1_I2C2 1 /* SoC has SCGC1[I2C2] */
+# undef KINETIS_SIM_HAS_SCGC1_OSC1 /* SoC has SCGC1[OSC1] */
+# define KINETIS_SIM_HAS_SCGC2 1 /* SoC has _SCGC2 Register */
+# define KINETIS_SIM_HAS_SCGC2 1 /* SoC has SCGC2 Register */
+# define KINETIS_SIM_HAS_SCGC2_ENET 1 /* SoC has SCGC2[ENET] */
+# define KINETIS_SIM_HAS_SCGC2_LPUART0 1 /* SoC has SCGC2[LPUART0] */
+# define KINETIS_SIM_HAS_SCGC2_TPM1 1 /* SoC has SCGC2[TPM1] */
+# define KINETIS_SIM_HAS_SCGC2_TPM2 1 /* SoC has SCGC2[TPM2] */
+# define KINETIS_SIM_HAS_SCGC3 1 /* SoC has SCGC3 Register */
+# define KINETIS_SIM_HAS_SCGC3_RNGA 1 /* SoC has SCGC3[RNGA] */
+# define KINETIS_SIM_HAS_SCGC3_USBHS 1 /* SoC has SCGC3[USBHS] */
+# define KINETIS_SIM_HAS_SCGC3_USBHSPHY 1 /* SoC has SCGC3[USBHSPHY] */
+# define KINETIS_SIM_HAS_SCGC3_USBHSDCD 1 /* SoC has SCGC3[USBHSDCD] */
+# define KINETIS_SIM_HAS_SCGC3_FLEXCAN1 1 /* SoC has SCGC3[FLEXCAN1] */
+# undef KINETIS_SIM_HAS_SCGC3_NFC /* SoC has SCGC3[NFC] */
+# define KINETIS_SIM_HAS_SCGC3_SPI2 1 /* SoC has SCGC3[SPI2] */
+# undef KINETIS_SIM_HAS_SCGC3_SAI1 /* SoC has SCGC3[SAI1] */
+# define KINETIS_SIM_HAS_SCGC3_SDHC 1 /* SoC has SCGC3[SDHC] */
+# define KINETIS_SIM_HAS_SCGC3_FTM2 1 /* SoC has SCGC3[FTM2] */
+# define KINETIS_SIM_HAS_SCGC3_FTM3 1 /* SoC has SCGC3[FTM3] */
+# define KINETIS_SIM_HAS_SCGC3_ADC1 1 /* SoC has SCGC3[ADC1] */
+# undef KINETIS_SIM_HAS_SCGC3_ADC3 /* SoC has SCGC3[ADC3] */
+# undef KINETIS_SIM_HAS_SCGC3_SLCD /* SoC has SCGC3[SLCD] */
+# define KINETIS_SIM_HAS_SCGC4 1 /* SoC has SCGC4 Register */
+# undef KINETIS_SIM_HAS_SCGC4_LLWU /* SoC has SCGC4[LLWU] clock gate */
+# define KINETIS_SIM_HAS_SCGC4_UART0 1 /* SoC has SCGC4[UART0] */
+# define KINETIS_SIM_HAS_SCGC4_UART1 1 /* SoC has SCGC4[UART1] */
+# define KINETIS_SIM_HAS_SCGC4_UART2 1 /* SoC has SCGC4[UART2] */
+# define KINETIS_SIM_HAS_SCGC4_UART3 1 /* SoC has SCGC4[UART3] */
+# define KINETIS_SIM_HAS_SCGC5 1 /* SoC has _SCGC5 Register */
+# undef KINETIS_SIM_HAS_SCGC5_REGFILE /* SoC has SCGC5[REGFILE] */
+# define KINETIS_SIM_HAS_SCGC5_TSI 1 /* SoC has SCGC5[TSI] */
+# undef KINETIS_SIM_HAS_SCGC5_PORTF /* SoC has SCGC5[PORTF] */
+# define KINETIS_SIM_HAS_SCGC6 1 /* SoC has SCGC6 Register */
+# define KINETIS_SIM_HAS_SCGC6_FTFL 1 /* SoC has SCGC6[FTFL] */
+# undef KINETIS_SIM_HAS_SCGC6_DMAMUX1 /* SoC has SCGC6[DEMUX1] */
+# undef KINETIS_SIM_HAS_SCGC6_USBHS /* SoC has SCGC6[USBHS] */
+# define KINETIS_SIM_HAS_SCGC6_RNGA 1 /* SoC has SCGC6[RNGA] */
+# define KINETIS_SIM_HAS_SCGC6_FTM2 1 /* SoC has SCGC6[FTM2] */
+# undef KINETIS_SIM_HAS_SCGC6_ADC2 /* SoC has SCGC6[ADC2] */
+# define KINETIS_SIM_HAS_SCGC6_DAC0 1 /* SoC has SCGC6[DAC0] */
+# define KINETIS_SIM_HAS_SCGC7 1 /* SoC has SCGC7 Register */
+# define KINETIS_SIM_HAS_SCGC7_FLEXBUS 1 /* SoC has SCGC7[FLEXBUS] */
+# define KINETIS_SIM_HAS_SCGC7_DMA 1 /* SoC has SCGC7[DMS] */
+# define KINETIS_SIM_HAS_SCGC7_MPU 1 /* SoC has SCGC7[MPU] */
+# define KINETIS_SIM_HAS_SCGC7_SDRAMC 1 /* SoC has SCGC7[SDRAMC] */
+# define KINETIS_SIM_HAS_CLKDIV1 1 /* SoC has CLKDIV1 Register */
+# define KINETIS_SIM_HAS_CLKDIV1_OUTDIV2 1 /* SoC has CLKDIV1[OUTDIV2] */
+# define KINETIS_SIM_HAS_CLKDIV1_OUTDIV3 1 /* SoC has CLKDIV1[OUTDIV3] */
+# define KINETIS_SIM_HAS_CLKDIV1_OUTDIV4 1 /* SoC has CLKDIV1[OUTDIV4] */
+# undef KINETIS_SIM_HAS_CLKDIV1_OUTDIV5 /* SoC has CLKDIV1[OUTDIV5] */
+# define KINETIS_SIM_HAS_CLKDIV2 1 /* SoC has CLKDIV2 Register */
+# define KINETIS_SIM_HAS_CLKDIV2_USBDIV 1 /* SoC has CLKDIV2[USBDIV] */
+# define KINETIS_SIM_HAS_CLKDIV2_USBFRAC 1 /* SoC has CLKDIV2[USBFRAC] */
+# undef KINETIS_SIM_HAS_CLKDIV2_USBFSDIV /* SoC has CLKDIV2[USBFSDIV] */
+# undef KINETIS_SIM_HAS_CLKDIV2_USBFSFRAC /* SoC has CLKDIV2[USBFSFRAC] */
+# undef KINETIS_SIM_HAS_CLKDIV2_USBHSDIV /* SoC has CLKDIV2[USBHSDIV] */
+# undef KINETIS_SIM_HAS_CLKDIV2_USBHSFRAC /* SoC has CLKDIV2[USBHSFRAC] */
+# undef KINETIS_SIM_HAS_CLKDIV2_I2SDIV /* SoC has CLKDIV2[I2SDIV] */
+# undef KINETIS_SIM_HAS_CLKDIV2_I2SFRAC /* SoC has CLKDIV2[I2SFRAC] */
+# define KINETIS_SIM_HAS_FCFG1 1 /* SoC has FCFG1 Register */
+# define KINETIS_SIM_HAS_FCFG1_DEPART 1 /* SoC has FCFG1[DEPART] */
+# define KINETIS_SIM_HAS_FCFG1_EESIZE 1 /* SoC has FCFG1[EESIZE] */
+# define KINETIS_SIM_HAS_FCFG1_FLASHDIS 1 /* SoC has FCFG1[FLASHDIS] */
+# define KINETIS_SIM_HAS_FCFG1_FLASHDOZE 1 /* SoC has FCFG1[FLASHDOZE] */
+# undef KINETIS_SIM_HAS_FCFG1_FTFDIS /* SoC has FCFG1[FTFDIS] */
+# define KINETIS_SIM_HAS_FCFG1_NVMSIZE 1 /* SoC has FCFG1[NVMSIZE] */
+# define KINETIS_SIM_HAS_FCFG2 1 /* SoC has FCFG2 Register */
+# define KINETIS_SIM_HAS_FCFG2_MAXADDR0 7 /* SoC has n bit of FCFG2[MAXADDR0] */
+# define KINETIS_SIM_HAS_FCFG2_MAXADDR1 7 /* SoC has n bit of FCFG2[MAXADDR1] */
+# define KINETIS_SIM_HAS_FCFG2_PFLSH 1 /* SoC has FCFG2[PFLSH] */
+# define KINETIS_SIM_HAS_FCFG2_SWAPPFLSH 1 /* SoC has FCFG2[SWAPPFLSH] */
+# define KINETIS_SIM_HAS_UIDH 1 /* SoC has UIDH Register */
+# define KINETIS_SIM_HAS_UIDMH 1 /* SoC has UIDMH Register */
+# define KINETIS_SIM_HAS_UIDML 1 /* SoC has UIDML Register */
+# define KINETIS_SIM_HAS_UIDL 1 /* SoC has UIDL Register */
+# define KINETIS_SIM_HAS_CLKDIV3 1 /* SoC has CLKDIV3 Register */
+# define KINETIS_SIM_HAS_CLKDIV3_PLLFLLDIV 1 /* SoC has CLKDIV3[PLLFLLDIV] */
+# define KINETIS_SIM_HAS_CLKDIV3_PLLFLLFRAC 1 /* SoC has CLKDIV3[PLLFLLFRAC] */
+# define KINETIS_SIM_HAS_CLKDIV4 1 /* SoC has CLKDIV4 Register */
+# define KINETIS_SIM_HAS_CLKDIV4_TRACEDIV 1 /* SoC has CLKDIV4[TRACEDIV] */
+# define KINETIS_SIM_HAS_CLKDIV4_TRACEFRAC 1 /* SoC has CLKDIV4[TRACEFRAC] */
+# undef KINETIS_SIM_HAS_CLKDIV4_NFCDIV /* SoC has CLKDIV4[NFCDIV] */
+# undef KINETIS_SIM_HAS_CLKDIV4_NFCFRAC /* SoC has CLKDIV4[NFCFRAC] */
+# undef KINETIS_SIM_HAS_MCR /* SoC has MCR Register */
+#else
+# error "Unsupported Kinetis chip"
+#endif
+
+/* Use the catch all configuration for the SIM based on the implementations in nuttx prior 2/16/2017 */
+
+#if KINETIS_SIM_VERSION == KINETIS_SIM_VERSION_UKN
+
+/* SIM Register Configuration */
+
+# define KINETIS_SIM_HAS_SOPT1 1 /* SoC has SOPT1 Register */
+# undef KINETIS_SIM_HAS_SOPT1_OSC32KOUT /* SoC has SOPT1[OSC32KOUT] */
+# define KINETIS_SIM_HAS_SOPT1_OSC32KSEL 1 /* SoC has SOPT1[OSC32KSEL] */
+# define KINETIS_SIM_HAS_SOPT1_OSC32KSEL_BITS 1 /* SoC has 1 bit SOPT1[OSC32KSEL] */
+# define KINETIS_SIM_HAS_SOPT1_RAMSIZE 1 /* SoC has SOPT1[RAMSIZE] */
+# define KINETIS_SIM_HAS_SOPT1_USBREGEN 1 /* SoC has SOPT1[USBREGEN] */
+# define KINETIS_SIM_HAS_SOPT1_USBSSTBY 1 /* SoC has SOPT1[USBSSTBY] */
+# undef KINETIS_SIM_HAS_SOPT1_USBVSTBY /* SoC has SOPT1[USBVSTBY] */
+# undef KINETIS_SIM_HAS_SOPT1CFG /* SoC has SOPT1CFG Register */
+# undef KINETIS_SIM_HAS_SOPT1CFG_URWE /* SoC has SOPT1CFG[URWE] */
+# undef KINETIS_SIM_HAS_SOPT1CFG_USSWE /* SoC has SOPT1CFG[USSWE] */
+# undef KINETIS_SIM_HAS_SOPT1CFG_UVSWE /* SoC has SOPT1CFG[UVSWE] */
+# undef KINETIS_SIM_HAS_USBPHYCTL /* SoC has USBPHYCTL Register */
+# undef KINETIS_SIM_HAS_USBPHYCTL_USB3VOUTTRG /* SoC has USBPHYCTL[USB3VOUTTRG] */
+# undef KINETIS_SIM_HAS_USBPHYCTL_USBDISILIM /* SoC has USBPHYCTL[USBDISILIM] */
+# undef KINETIS_SIM_HAS_USBPHYCTL_USBVREGPD /* SoC has USBPHYCTL[USBVREGPD] */
+# undef KINETIS_SIM_HAS_USBPHYCTL_USBVREGSEL /* SoC has USBPHYCTL[USBVREGSEL] */
+# define KINETIS_SIM_HAS_SOPT2 1 /* SoC has SOPT2 Register */
+# define KINETIS_SIM_HAS_SOPT2_CMTUARTPAD 1 /* SoC has SOPT2[CMTUARTPAD] */
+# define KINETIS_SIM_HAS_SOPT2_FBSL 1 /* SoC has SOPT2[FBSL] */
+# undef KINETIS_SIM_HAS_SOPT2_FLEXIOSRC /* SoC has SOPT2[FLEXIOSRC] */
+# undef KINETIS_SIM_HAS_SOPT2_LPUARTSRC /* SoC has SOPT2[LPUARTSRC] */
+# define KINETIS_SIM_HAS_SOPT2_PLLFLLSEL 1 /* SoC has SOPT2[PLLFLLSEL] */
+# define KINETIS_SIM_HAS_SOPT2_PLLFLLSEL_BITS 1 /* SoC has 1 bit of SOPT2[PLLFLLSEL] */
+# undef KINETIS_SIM_HAS_SOPT2_PTD7PAD /* SoC has SOPT2[PTD7PAD] */
+# undef KINETIS_SIM_HAS_SOPT2_RMIISRC /* SoC has SOPT2[RMIISRC] */
+# undef KINETIS_SIM_HAS_SOPT2_RTCCLKOUTSEL /* SoC has SOPT2[RTCCLKOUTSEL] */
+# undef KINETIS_SIM_HAS_SOPT2_CLKOUTSEL /* SoC has SOPT2[CLKOUTSEL] */
+# define KINETIS_SIM_HAS_SOPT2_SDHCSRC 1 /* SoC has SOPT2[SDHCSRC] */
+# define KINETIS_SIM_HAS_SOPT2_TIMESRC 1 /* SoC has SOPT2[TIMESRC] */
+# undef KINETIS_SIM_HAS_SOPT2_TPMSRC /* SoC has SOPT2[TPMSRC] */
+# undef KINETIS_SIM_HAS_SOPT2_USBFSRC /* SoC has SOPT2[USBFSRC] */
+# define KINETIS_SIM_HAS_SOPT2_I2SSRC 1 /* SoC has SOPT2[I2SSRC] */
+# define KINETIS_SIM_HAS_SOPT2_TRACECLKSEL 1 /* SoC has SOPT2[TRACECLKSEL] */
+# undef KINETIS_SIM_HAS_SOPT2_USBREGEN /* SoC has SOPT2[USBREGEN] */
+# undef KINETIS_SIM_HAS_SOPT2_USBSLSRC /* SoC has SOPT2[USBSLSRC] */
+# undef KINETIS_SIM_HAS_SOPT2_USBHSRC /* SoC has SOPT2[USBHSRC] */
+# define KINETIS_SIM_HAS_SOPT2_USBSRC 1 /* SoC has SOPT2[USBSRC] */
+# define KINETIS_SIM_HAS_SOPT2_MCGCLKSEL 1 /* SoC has SOPT2[MCGCLKSEL] */
+# define KINETIS_SIM_HAS_SOPT4 1 /* SoC has SOPT4 Register */
+# define KINETIS_SIM_HAS_SOPT4_FTM0FLT0 1 /* SoC has SOPT4[FTM0FLT0] */
+# define KINETIS_SIM_HAS_SOPT4_FTM0FLT1 1 /* SoC has SOPT4[FTM0FLT1] */
+# define KINETIS_SIM_HAS_SOPT4_FTM0FLT2 1 /* SoC has SOPT4[FTM0FLT2] */
+# undef KINETIS_SIM_HAS_SOPT4_FTM0FLT3 /* SoC has SOPT4[FTM0FLT3] */
+# undef KINETIS_SIM_HAS_SOPT4_FTM0TRG0SRC /* SoC has SOPT4[FTM0TRG0SRC] */
+# undef KINETIS_SIM_HAS_SOPT4_FTM0TRG1SRC /* SoC has SOPT4[FTM0TRG1SRC] */
+# define KINETIS_SIM_HAS_SOPT4_FTM1CH0SRC 1 /* SoC has SOPT4[FTM1CH0SRC] No OF */
+# undef KINETIS_SIM_HAS_SOPT4_FTM1FLT0 /* SoC has SOPT4[FTM1FLT0] */
+# undef KINETIS_SIM_HAS_SOPT4_FTM1FLT1 /* SoC has SOPT4[FTM1FLT1] */
+# undef KINETIS_SIM_HAS_SOPT4_FTM1FLT2 /* SoC has SOPT4[FTM1FLT2] */
+# undef KINETIS_SIM_HAS_SOPT4_FTM1FLT3 /* SoC has SOPT4[FTM1FLT3] */
+# define KINETIS_SIM_HAS_SOPT4_FTM2CH0SRC 1 /* SoC has SOPT4[FTM2CH0SRC] */
+# undef KINETIS_SIM_HAS_SOPT4_FTM2CH1SRC /* SoC has SOPT4[FTM2CH1SRC] */
+# undef KINETIS_SIM_HAS_SOPT4_FTM2FLT0 /* SoC has SOPT4[FTM2FLT0] */
+# undef KINETIS_SIM_HAS_SOPT4_FTM2FLT1 /* SoC has SOPT4[FTM2FLT1] */
+# undef KINETIS_SIM_HAS_SOPT4_FTM2FLT2 /* SoC has SOPT4[FTM2FLT2] */
+# undef KINETIS_SIM_HAS_SOPT4_FTM2FLT3 /* SoC has SOPT4[FTM2FLT3] */
+# undef KINETIS_SIM_HAS_SOPT4_FTM3CH0SRC /* SoC has SOPT4[FTM3CH0SRC] */
+# undef KINETIS_SIM_HAS_SOPT4_FTM3FLT0 /* SoC has SOPT4[FTM3FLT0] */
+# undef KINETIS_SIM_HAS_SOPT4_FTM3FLT1 /* SoC has SOPT4[FTM3FLT1] */
+# undef KINETIS_SIM_HAS_SOPT4_FTM3FLT2 /* SoC has SOPT4[FTM3FLT2] */
+# undef KINETIS_SIM_HAS_SOPT4_FTM3FLT3 /* SoC has SOPT4[FTM3FLT3] */
+# undef KINETIS_SIM_HAS_SOPT4_FTM3TRG0SRC /* SoC has SOPT4[FTM3TRG0SRC] */
+# undef KINETIS_SIM_HAS_SOPT4_FTM3TRG1SRC /* SoC has SOPT4[FTM3TRG1SRC] */
+# undef KINETIS_SIM_HAS_SOPT4_TPM0CLKSEL /* SoC has SOPT4[TPM0CLKSEL] */
+# undef KINETIS_SIM_HAS_SOPT4_TPM1CH0SRC /* SoC has SOPT4[TPM1CH0SRC] */
+# undef KINETIS_SIM_HAS_SOPT4_TPM1CLKSEL /* SoC has SOPT4[TPM1CLKSEL] */
+# undef KINETIS_SIM_HAS_SOPT4_TPM2CH0SRC /* SoC has SOPT4[TPM2CH0SRC] */
+# undef KINETIS_SIM_HAS_SOPT4_TPM2CLKSEL /* SoC has SOPT4[TPM2CLKSEL] */
+# define KINETIS_SIM_HAS_SOPT5 /* SoC has SOPT5 Register */
+# undef KINETIS_SIM_HAS_SOPT5_LPUART0RXSRC /* SoC has SOPT5[LPUART0RXSRC] */
+# undef KINETIS_SIM_HAS_SOPT5_LPUART0TXSRC /* SoC has SOPT5[LPUART0TXSRC] */
+# define KINETIS_SIM_HAS_SOPT6 1 /* SoC has SOPT6 Register */
+# undef KINETIS_SIM_HAS_SOPT6_MCC /* SoC has SOPT6[MCC] */
+# undef KINETIS_SIM_HAS_SOPT6_PCR /* SoC has SOPT6[PCR] */
+# define KINETIS_SIM_HAS_SOPT6_RSTFLTSEL 1 /* SoC has SOPT6[RSTFLTSEL] */
+# define KINETIS_SIM_HAS_SOPT6_RSTFLTEN 1 /* SoC has SOPT6[RSTFLTEN] */
+# define KINETIS_SIM_HAS_SOPT7 1 /* SoC has SOPT7 Register */
+# define KINETIS_SIM_HAS_SOPT7_ADC0ALTTRGSEL 1 /* SoC has SOPT7[ADC0ALTTRGSEL] */
+# define KINETIS_SIM_HAS_SOPT7_ADC1ALTTRGSEL 1 /* SoC has SOPT7[ADC1ALTTRGSEL] */
+# define KINETIS_SIM_HAS_SOPT7_ADC0PRETRGSEL 1 /* SoC has SOPT7[ADC0PRETRGSEL] */
+# define KINETIS_SIM_HAS_SOPT7_ADC1PRETRGSEL 1 /* SoC has SOPT7[ADC1PRETRGSEL] */
+# undef KINETIS_SIM_HAS_SOPT7_ADC2PRETRGSEL /* SoC has SOPT7[ADC2PRETRGSEL] */
+# undef KINETIS_SIM_HAS_SOPT7_ADC3PRETRGSEL /* SoC has SOPT7[ADC3PRETRGSEL] */
+# define KINETIS_SIM_HAS_SOPT7_ADC0TRGSEL 14 /* SoC has 10 SOPT7[ADC0TRGSEL] */
+# define KINETIS_SIM_HAS_SOPT7_ADC1TRGSEL 14 /* SoC has 10 SOPT7[ADC1TRGSEL] */
+# undef KINETIS_SIM_HAS_SOPT7_ADC2TRGSEL /* SoC has 10 SOPT7[ADC2TRGSEL] */
+# undef KINETIS_SIM_HAS_SOPT7_ADC3TRGSEL /* SoC has 10 SOPT7[ADC3TRGSEL] */
+# define KINETIS_SIM_SOPT7_ADC0ALTTRGEN 1 /* ADC0 alternate trigger enable */
+# define KINETIS_SIM_SOPT7_ADC1ALTTRGEN 1 /* ADC1 alternate trigger enable */
+# undef KINETIS_SIM_SOPT7_ADC2ALTTRGEN /* ADC2 alternate trigger enable */
+# undef KINETIS_SIM_SOPT7_ADC3ALTTRGEN /* ADC3 alternate trigger enable */
+# undef KINETIS_SIM_HAS_SOPT8 /* SoC has SOPT8 Register */
+# undef KINETIS_SIM_HAS_SOPT9 /* SoC has SOPT9 Register */
+# define KINETIS_SIM_HAS_SDID 1 /* SoC has SDID Register */
+# undef KINETIS_SIM_HAS_SDID_DIEID /* SoC has SDID[DIEID] */
+# define KINETIS_SIM_HAS_SDID_FAMID 1 /* SoC has SDID[FAMID] */
+# undef KINETIS_SIM_HAS_SDID_FAMILYID /* SoC has SDID[FAMILYID] */
+# undef KINETIS_SIM_HAS_SDID_SERIESID /* SoC has SDID[SERIESID] */
+# undef KINETIS_SIM_HAS_SDID_SRAMSIZE /* SoC has SDID[SRAMSIZE] */
+# undef KINETIS_SIM_HAS_SDID_SUBFAMID /* SoC has SDID[SUBFAMID] */
+# define KINETIS_SIM_HAS_SCGC1 1 /* SoC has SCGC1 Register */
+# define KINETIS_SIM_HAS_SCGC1_UART5 1 /* SoC has SCGC1[UART5] */
+# define KINETIS_SIM_HAS_SCGC1_UART4 1 /* SoC has SCGC1[UART4] */
+# undef KINETIS_SIM_HAS_SCGC1_I2C3 /* SoC has SCGC1[I2C3] */
+# undef KINETIS_SIM_HAS_SCGC1_I2C2 /* SoC has SCGC1[I2C2] */
+# undef KINETIS_SIM_HAS_SCGC1_OSC1 /* SoC has SCGC1[OSC1] */
+# define KINETIS_SIM_HAS_SCGC2 1 /* SoC has SCGC2 Register */
+# define KINETIS_SIM_HAS_SCGC2_ENET 1 /* SoC has SCGC2[ENET] */
+# undef KINETIS_SIM_HAS_SCGC2_LPUART0 /* SoC has SCGC2[LPUART0] */
+# undef KINETIS_SIM_HAS_SCGC2_TPM1 /* SoC has SCGC2[TPM1] */
+# undef KINETIS_SIM_HAS_SCGC2_TPM2 /* SoC has SCGC2[TPM2] */
+# define KINETIS_SIM_HAS_SCGC3 1 /* SoC has SCGC3 Register */
+# define KINETIS_SIM_HAS_SCGC3_RNGA 1 /* SoC has SCGC3[RNGA] */
+# undef KINETIS_SIM_HAS_SCGC3_USBHS /* SoC has SCGC3[USBHS] */
+# undef KINETIS_SIM_HAS_SCGC3_USBHSPHY /* SoC has SCGC3[USBHSPHY] */
+# undef KINETIS_SIM_HAS_SCGC3_USBHSDCD /* SoC has SCGC3[USBHSDCD] */
+# define KINETIS_SIM_HAS_SCGC3_FLEXCAN1 1 /* SoC has SCGC3[FLEXCAN1] */
+# undef KINETIS_SIM_HAS_SCGC3_NFC /* SoC has SCGC3[NFC] */
+# define KINETIS_SIM_HAS_SCGC3_SPI2 1 /* SoC has SCGC3[SPI2] */
+# undef KINETIS_SIM_HAS_SCGC3_SAI1 /* SoC has SCGC3[SAI1] */
+# define KINETIS_SIM_HAS_SCGC3_SDHC 1 /* SoC has SCGC3[SDHC] */
+# define KINETIS_SIM_HAS_SCGC3_FTM2 1 /* SoC has SCGC3[FTM2] */
+# define KINETIS_SIM_HAS_SCGC3_FTM3 1 /* SoC has SCGC3[FTM3] */
+# define KINETIS_SIM_HAS_SCGC3_ADC1 1 /* SoC has SCGC3[ADC1] */
+# undef KINETIS_SIM_HAS_SCGC3_ADC3 /* SoC has SCGC3[ADC3] */
+# define KINETIS_SIM_HAS_SCGC3_SLCD 1 /* SoC has SCGC3[SLCD] */
+# define KINETIS_SIM_HAS_SCGC4 1 /* SoC has SCGC4 Register */
+# define KINETIS_SIM_HAS_SCGC4_LLWU 1 /* SoC has SCGC4[LLWU] clock gate */
+# define KINETIS_SIM_HAS_SCGC4_UART0 1 /* SoC has SCGC4[UART0] */
+# define KINETIS_SIM_HAS_SCGC4_UART1 1 /* SoC has SCGC4[UART1] */
+# define KINETIS_SIM_HAS_SCGC4_UART2 1 /* SoC has SCGC4[UART2] */
+# define KINETIS_SIM_HAS_SCGC4_UART3 1 /* SoC has SCGC4[UART3] */
+# define KINETIS_SIM_HAS_SCGC5 1 /* SoC has SCGC5 Register */
+# define KINETIS_SIM_HAS_SCGC5_REGFILE 1 /* SoC has SCGC5[REGFILE] */
+# define KINETIS_SIM_HAS_SCGC5_TSI 1 /* SoC has SCGC5[TSI] */
+# undef KINETIS_SIM_HAS_SCGC5_PORTF /* SoC has SCGC5[PORTF] */
+# define KINETIS_SIM_HAS_SCGC6 1 /* SoC has SCGC6 Register */
+# define KINETIS_SIM_HAS_SCGC6_FTFL 1 /* SoC has SCGC6[FTFL] */
+# undef KINETIS_SIM_HAS_SCGC6_DMAMUX1 /* SoC has SCGC6[DEMUX1] */
+# undef KINETIS_SIM_HAS_SCGC6_USBHS /* SoC has SCGC6[USBHS] */
+# undef KINETIS_SIM_HAS_SCGC6_RNGA /* SoC has SCGC6[RNGA] */
+# undef KINETIS_SIM_HAS_SCGC6_FTM2 /* SoC has SCGC6[FTM2] */
+# undef KINETIS_SIM_HAS_SCGC6_ADC2 /* SoC has SCGC6[ADC2] */
+# undef KINETIS_SIM_HAS_SCGC6_DAC0 /* SoC has SCGC6[DAC0] */
+# define KINETIS_SIM_HAS_SCGC7 1 /* SoC has SCGC7 Register */
+# define KINETIS_SIM_HAS_SCGC7_FLEXBUS 1 /* SoC has SCGC7[FLEXBUS] */
+# define KINETIS_SIM_HAS_SCGC7_DMA 1 /* SoC has SCGC7[DMS] */
+# define KINETIS_SIM_HAS_SCGC7_MPU 1 /* SoC has SCGC7[MPU] */
+# undef KINETIS_SIM_HAS_SCGC7_SDRAMC /* SoC has SCGC7[SDRAMC] */
+# define KINETIS_SIM_HAS_CLKDIV1 1 /* SoC has CLKDIV1 Register */
+# define KINETIS_SIM_HAS_CLKDIV1_OUTDIV2 1 /* SoC has CLKDIV1[OUTDIV2] */
+# define KINETIS_SIM_HAS_CLKDIV1_OUTDIV3 1 /* SoC has CLKDIV1[OUTDIV3] */
+# define KINETIS_SIM_HAS_CLKDIV1_OUTDIV4 1 /* SoC has CLKDIV1[OUTDIV4] */
+# undef KINETIS_SIM_HAS_CLKDIV1_OUTDIV5 /* SoC has CLKDIV1[OUTDIV5] */
+# define KINETIS_SIM_HAS_CLKDIV2 1 /* SoC has CLKDIV2 Register */
+# define KINETIS_SIM_HAS_CLKDIV2_USBDIV 1 /* SoC has CLKDIV2[USBDIV] */
+# define KINETIS_SIM_HAS_CLKDIV2_USBFRAC 1 /* SoC has CLKDIV2[USBFRAC] */
+# undef KINETIS_SIM_HAS_CLKDIV2_USBFSDIV /* SoC has CLKDIV2[USBFSDIV] */
+# undef KINETIS_SIM_HAS_CLKDIV2_USBFSFRAC /* SoC has CLKDIV2[USBFSFRAC] */
+# undef KINETIS_SIM_HAS_CLKDIV2_USBHSDIV /* SoC has CLKDIV2[USBHSDIV] */
+# undef KINETIS_SIM_HAS_CLKDIV2_USBHSFRAC /* SoC has CLKDIV2[USBHSFRAC] */
+# define KINETIS_SIM_HAS_CLKDIV2_I2SDIV 1 /* SoC has CLKDIV2[I2SDIV] */
+# define KINETIS_SIM_HAS_CLKDIV2_I2SFRAC 1 /* SoC has CLKDIV2[I2SFRAC] */
+# define KINETIS_SIM_HAS_FCFG1 1 /* SoC has FCFG1 Register */
+# define KINETIS_SIM_HAS_FCFG1_DEPART 1 /* SoC has FCFG1[DEPART] */
+# define KINETIS_SIM_HAS_FCFG1_EESIZE 1 /* SoC has FCFG1[EESIZE] */
+# undef KINETIS_SIM_HAS_FCFG1_FLASHDIS /* SoC has FCFG1[FLASHDIS] */
+# undef KINETIS_SIM_HAS_FCFG1_FLASHDOZE /* SoC has FCFG1[FLASHDOZE] */
+# undef KINETIS_SIM_HAS_FCFG1_FTFDIS /* SoC has FCFG1[FTFDIS] */
+# define KINETIS_SIM_HAS_FCFG1_NVMSIZE 1 /* SoC has FCFG1[NVMSIZE] */
+# define KINETIS_SIM_HAS_FCFG2 1 /* SoC has FCFG2 Register */
+# define KINETIS_SIM_HAS_FCFG2_MAXADDR0 6 /* SoC has n bit of FCFG2[MAXADDR0] */
+# define KINETIS_SIM_HAS_FCFG2_MAXADDR1 6 /* SoC has n bit of FCFG2[MAXADDR1] */
+# define KINETIS_SIM_HAS_FCFG2_PFLSH 1 /* SoC has FCFG2[PFLSH] */
+# define KINETIS_SIM_HAS_FCFG2_SWAPPFLSH 1 /* SoC has FCFG2[SWAPPFLSH] */
+# define KINETIS_SIM_HAS_UIDH 1 /* SoC has UIDH Register */
+# define KINETIS_SIM_HAS_UIDMH 1 /* SoC has UIDMH Register */
+# define KINETIS_SIM_HAS_UIDML 1 /* SoC has UIDML Register */
+# define KINETIS_SIM_HAS_UIDL 1 /* SoC has UIDL Register */
+# undef KINETIS_SIM_HAS_CLKDIV3 /* SoC has CLKDIV3 Register */
+# undef KINETIS_SIM_HAS_CLKDIV3_PLLFLLDIV /* SoC has CLKDIV3[PLLFLLDIV] */
+# undef KINETIS_SIM_HAS_CLKDIV3_PLLFLLFRAC /* SoC has CLKDIV3[PLLFLLFRAC] */
+# undef KINETIS_SIM_HAS_CLKDIV4 /* SoC has CLKDIV4 Register */
+# undef KINETIS_SIM_HAS_CLKDIV4_TRACEDIV /* SoC has CLKDIV4[TRACEDIV] */
+# undef KINETIS_SIM_HAS_CLKDIV4_TRACEFRAC /* SoC has CLKDIV4[TRACEFRAC] */
+# undef KINETIS_SIM_HAS_CLKDIV4_NFCDIV /* SoC has CLKDIV4[NFCDIV] */
+# undef KINETIS_SIM_HAS_CLKDIV4_NFCFRAC /* SoC has CLKDIV4[NFCFRAC] */
+# undef KINETIS_SIM_HAS_MCR /* SoC has MCR Register */
+#endif
+
+#if !defined(KINETIS_SIM_VERSION)
+# error "No KINETIS_SIM_VERSION defined!"
+#endif
+
+#if defined(KINETIS_SIM_HAS_SOPT1_OSC32KSEL)
+# define KINETIS_SIM_SOPT1_OSC32KSEL_MASK ((1 << (KINETIS_SIM_HAS_SOPT1_OSC32KSEL_BITS))-1)
+#endif
+
+#if defined(KINETIS_SIM_HAS_SOPT2_PLLFLLSEL)
+# define KINETIS_SIM_SOPT2_PLLFLLSEL_MASK ((1 << (KINETIS_SIM_HAS_SOPT2_PLLFLLSEL_BITS))-1)
+#endif
+
+#if defined(KINETIS_SIM_HAS_FCFG2_MAXADDR0)
+# define KINETIS_SIM_FCFG2_MAXADDR0_MASK ((1 << (KINETIS_SIM_HAS_FCFG2_MAXADDR0))-1)
+#endif
+
+#if defined(KINETIS_SIM_HAS_FCFG2_MAXADDR1)
+# define KINETIS_SIM_FCFG2_MAXADDR1_MASK ((1 << (KINETIS_SIM_HAS_FCFG2_MAXADDR1))-1)
+#endif
+
+#endif /* __ARCH_ARM_INCLUDE_KINETIS_KINETIS_SIM_H */
diff --git a/arch/arm/include/stm32/chip.h b/arch/arm/include/stm32/chip.h
index 137383bb0936d701539b9ba1a2045e3149eb21ec..0844c5a09fb5b9d888891b414b79680eafd2b15d 100644
--- a/arch/arm/include/stm32/chip.h
+++ b/arch/arm/include/stm32/chip.h
@@ -1,7 +1,7 @@
/************************************************************************************
* arch/arm/include/stm32/chip.h
*
- * Copyright (C) 2009, 2011-2014 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2009, 2011-2014, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
*
* Redistribution and use in source and binary forms, with or without
@@ -86,6 +86,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */
# define STM32_NFSMC 0 /* No FSMC */
@@ -126,6 +127,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */
# define STM32_NFSMC 0 /* No FSMC */
@@ -166,6 +168,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */
# define STM32_NFSMC 0 /* No FSMC */
@@ -206,6 +209,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */
# define STM32_NFSMC 0 /* No FSMC */
@@ -246,6 +250,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */
# define STM32_NFSMC 0 /* No FSMC */
@@ -286,6 +291,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */
# define STM32_NFSMC 0 /* No FSMC */
@@ -404,6 +410,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */
# define STM32_NFSMC 0 /* No FSMC */
@@ -442,6 +449,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */
# define STM32_NFSMC 0 /* FSMC */
@@ -483,6 +491,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */
# define STM32_NFSMC 0 /* FSMC */
@@ -522,6 +531,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */
# define STM32_NFSMC 1 /* FSMC */
@@ -600,6 +610,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */
# define STM32_NFSMC 0 /* FSMC */
@@ -638,6 +649,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */
# define STM32_NFSMC 0 /* No FSMC */
@@ -676,6 +688,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */
# define STM32_NFSMC 0 /* No FSMC */
@@ -714,6 +727,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */
# define STM32_NFSMC 0 /* No FSMC */
@@ -757,6 +771,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx */
# define STM32_NFSMC 1 /* FSMC */
@@ -798,6 +813,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */
# define STM32_NFSMC 1 /* FSMC */
@@ -839,6 +855,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */
# define STM32_NFSMC 1 /* FSMC */
@@ -878,6 +895,7 @@
# define CONFIG_STM32_CONNECTIVITYLINE 1 /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx */
# define STM32_NFSMC 1 /* FSMC */
@@ -915,6 +933,7 @@
# define CONFIG_STM32_CONNECTIVITYLINE 1 /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx */
# define STM32_NFSMC 1 /* FSMC */
@@ -952,6 +971,7 @@
# define CONFIG_STM32_CONNECTIVITYLINE 1 /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx */
# define STM32_NFSMC 1 /* FSMC */
@@ -991,6 +1011,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# define CONFIG_STM32_STM32F20XX 1 /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx */
# define STM32_NFSMC 0 /* No FSMC */
@@ -1029,6 +1050,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# define CONFIG_STM32_STM32F20XX 1 /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx */
# define STM32_NFSMC 1 /* FSMC */
@@ -1067,6 +1089,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# define CONFIG_STM32_STM32F20XX 1 /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx */
# define STM32_NFSMC 1 /* FSMC */
@@ -1097,7 +1120,7 @@
/* Part Numbering: STM32Fssscfxxx
*
* Where
- * sss = 302/303 or 372/373
+ * sss = 302/303, 334 or 372/373
* c = C (48pins) R (68 pins) V (100 pins)
* c = K (32 pins), C (48 pins), R (68 pins), V (100 pins)
* f = 6 (32KB FLASH), 8 (64KB FLASH), B (128KB FLASH), C (256KB FLASH)
@@ -1154,6 +1177,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# define CONFIG_STM32_STM32F30XX 1 /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx */
# define STM32_NFSMC 0 /* No FSMC */
@@ -1194,6 +1218,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# define CONFIG_STM32_STM32F30XX 1 /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx */
# define STM32_NFSMC 0 /* No FSMC */
@@ -1234,6 +1259,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# define CONFIG_STM32_STM32F30XX 1 /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx */
# define STM32_NFSMC 0 /* No FSMC */
@@ -1274,6 +1300,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# define CONFIG_STM32_STM32F30XX 1 /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx */
# define STM32_NFSMC 0 /* No FSMC */
@@ -1314,6 +1341,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# define CONFIG_STM32_STM32F30XX 1 /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx */
# define STM32_NFSMC 0 /* No FSMC */
@@ -1354,6 +1382,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# define CONFIG_STM32_STM32F30XX 1 /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx */
# define STM32_NFSMC 0 /* No FSMC */
@@ -1394,6 +1423,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# define CONFIG_STM32_STM32F30XX 1 /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx */
# define STM32_NFSMC 0 /* No FSMC */
@@ -1434,6 +1464,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# define CONFIG_STM32_STM32F30XX 1 /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx */
# define STM32_NFSMC 0 /* No FSMC */
@@ -1474,6 +1505,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# define CONFIG_STM32_STM32F30XX 1 /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx */
# define STM32_NFSMC 0 /* No FSMC */
@@ -1502,6 +1534,138 @@
# define STM32_NRNG 0 /* (0) No random number generator (RNG) */
# define STM32_NDCMI 0 /* (0) No digital camera interface (DCMI) */
+#elif defined(CONFIG_ARCH_CHIP_STM32F334K4) || defined(CONFIG_ARCH_CHIP_STM32F334K6) || defined(CONFIG_ARCH_CHIP_STM32F334K8)
+# undef CONFIG_STM32_STM32L15XX /* STM32L151xx and STM32L152xx family */
+# undef CONFIG_STM32_ENERGYLITE /* STM32L EnergyLite family */
+# undef CONFIG_STM32_STM32F10XX /* STM32F10xxx family */
+# undef CONFIG_STM32_LOWDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */
+# undef CONFIG_STM32_MEDIUMDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
+# undef CONFIG_STM32_MEDIUMPLUSDENSITY /* STM32L15xxC w/ 32/256 Kbytes */
+# undef CONFIG_STM32_HIGHDENSITY /* STM32F100x, STM32F101x, and STM32F103x w/ 256/512 Kbytes */
+# undef CONFIG_STM32_VALUELINE /* STM32F100x */
+# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
+# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
+# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# define CONFIG_STM32_STM32F33XX 1 /* STM32F33xxx family */
+# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
+# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx */
+# define STM32_NFSMC 0 /* No FSMC */
+
+# define STM32_HRTIM 1 /* (1) High-resolution timer 16-bit, 10 channels: HRTIM1 */
+# define STM32_NATIM 1 /* (1) Advanced 16-bit timers with DMA: TIM1*/
+# define STM32_NGTIM 5 /* (1) 16-bit general timers with DMA: TIM3
+ * (1) 32-bit general timers with DMA: TIM2
+ * (3) 16-bit general timers count-up timers with DMA: TIM15-17 */
+# define STM32_NGTIMNDMA 0 /* All timers have DMA */
+# define STM32_NBTIM 2 /* (2) Basic timers: TIM6 and TIM7 */
+# define STM32_NDMA 1 /* (2) DMA1 (7 channels) */
+# define STM32_NSPI 1 /* (3) SPI1 */
+# define STM32_NI2S 0 /* (0) I2S1 */
+# define STM32_NUSART 2 /* (2) USART1-2 */
+# define STM32_NI2C 1 /* (2) I2C1 */
+# define STM32_NCAN 1 /* (1) CAN1 */
+# define STM32_NSDIO 0 /* (0) No SDIO */
+# define STM32_NLCD 0 /* (0) No LCD */
+# define STM32_NUSBOTG 0 /* (0) No USB */
+# define STM32_NGPIO 25 /* GPIOA-F */
+# define STM32_NADC 2 /* (3) 12-bit ADC1-2 */
+# define STM32_NDAC 2 /* (2) 12-bit DAC1-2 */
+# define STM32_NCMP 2 /* (2) Ultra-fast analog comparators: COMP2 and COMP4 */
+# define STM32_NPGA 1 /* (1) Operational amplifiers: OPAMP */
+# define STM32_NCAPSENSE 14 /* (14) No capacitive sensing channels */
+# define STM32_NCRC 1 /* (1) CRC calculation unit */
+# define STM32_NETHERNET 0 /* (0) No Ethernet MAC */
+# define STM32_NRNG 0 /* (0) No random number generator (RNG) */
+# define STM32_NDCMI 0 /* (0) No digital camera interface (DCMI) */
+
+#elif defined(CONFIG_ARCH_CHIP_STM32F334C4) || defined(CONFIG_ARCH_CHIP_STM32F334C6) || defined(CONFIG_ARCH_CHIP_STM32F334C8)
+# undef CONFIG_STM32_STM32L15XX /* STM32L151xx and STM32L152xx family */
+# undef CONFIG_STM32_ENERGYLITE /* STM32L EnergyLite family */
+# undef CONFIG_STM32_STM32F10XX /* STM32F10xxx family */
+# undef CONFIG_STM32_LOWDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */
+# undef CONFIG_STM32_MEDIUMDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
+# undef CONFIG_STM32_MEDIUMPLUSDENSITY /* STM32L15xxC w/ 32/256 Kbytes */
+# undef CONFIG_STM32_HIGHDENSITY /* STM32F100x, STM32F101x, and STM32F103x w/ 256/512 Kbytes */
+# undef CONFIG_STM32_VALUELINE /* STM32F100x */
+# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
+# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
+# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# define CONFIG_STM32_STM32F33XX 1 /* STM32F33xxx family */
+# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
+# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx */
+# define STM32_NFSMC 0 /* No FSMC */
+
+# define STM32_HRTIM 1 /* (1) High-resolution timer 16-bit, 10 channels: HRTIM1 */
+# define STM32_NATIM 1 /* (1) Advanced 16-bit timers with DMA: TIM1*/
+# define STM32_NGTIM 5 /* (1) 16-bit general timers with DMA: TIM3
+ * (1) 32-bit general timers with DMA: TIM2
+ * (3) 16-bit general timers count-up timers with DMA: TIM15-17 */
+# define STM32_NGTIMNDMA 0 /* All timers have DMA */
+# define STM32_NBTIM 2 /* (2) Basic timers: TIM6 and TIM7 */
+# define STM32_NDMA 1 /* (2) DMA1 (7 channels) */
+# define STM32_NSPI 1 /* (3) SPI1 */
+# define STM32_NI2S 0 /* (0) I2S1 */
+# define STM32_NUSART 3 /* (2) USART1-3 */
+# define STM32_NI2C 1 /* (2) I2C1 */
+# define STM32_NCAN 1 /* (1) CAN1 */
+# define STM32_NSDIO 0 /* (0) No SDIO */
+# define STM32_NLCD 0 /* (0) No LCD */
+# define STM32_NUSBOTG 0 /* (0) No USB */
+# define STM32_NGPIO 37 /* GPIOA-F */
+# define STM32_NADC 3 /* (3) 12-bit ADC1-3 */
+# define STM32_NDAC 2 /* (2) 12-bit DAC1-2 */
+# define STM32_NCMP 3 /* (3) Ultra-fast analog comparators: COMP2, COMP4 and COMP6 */
+# define STM32_NPGA 1 /* (1) Operational amplifiers: OPAMP */
+# define STM32_NCAPSENSE 17 /* (17) No capacitive sensing channels */
+# define STM32_NCRC 1 /* (1) CRC calculation unit */
+# define STM32_NETHERNET 0 /* (0) No Ethernet MAC */
+# define STM32_NRNG 0 /* (0) No random number generator (RNG) */
+# define STM32_NDCMI 0 /* (0) No digital camera interface (DCMI) */
+
+#elif defined(CONFIG_ARCH_CHIP_STM32F334R4) || defined(CONFIG_ARCH_CHIP_STM32F334R6) || defined(CONFIG_ARCH_CHIP_STM32F334R8)
+# undef CONFIG_STM32_STM32L15XX /* STM32L151xx and STM32L152xx family */
+# undef CONFIG_STM32_ENERGYLITE /* STM32L EnergyLite family */
+# undef CONFIG_STM32_STM32F10XX /* STM32F10xxx family */
+# undef CONFIG_STM32_LOWDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */
+# undef CONFIG_STM32_MEDIUMDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
+# undef CONFIG_STM32_MEDIUMPLUSDENSITY /* STM32L15xxC w/ 32/256 Kbytes */
+# undef CONFIG_STM32_HIGHDENSITY /* STM32F100x, STM32F101x, and STM32F103x w/ 256/512 Kbytes */
+# undef CONFIG_STM32_VALUELINE /* STM32F100x */
+# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
+# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
+# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# define CONFIG_STM32_STM32F33XX 1 /* STM32F33xxx family */
+# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
+# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx */
+# define STM32_NFSMC 0 /* No FSMC */
+
+# define STM32_HRTIM 1 /* (1) High-resolution timer 16-bit, 10 channels: HRTIM1 */
+# define STM32_NATIM 1 /* (1) Advanced 16-bit timers with DMA: TIM1*/
+# define STM32_NGTIM 5 /* (1) 16-bit general timers with DMA: TIM3
+ * (1) 32-bit general timers with DMA: TIM2
+ * (3) 16-bit general timers count-up timers with DMA: TIM15-17 */
+# define STM32_NGTIMNDMA 0 /* All timers have DMA */
+# define STM32_NBTIM 2 /* (2) Basic timers: TIM6 and TIM7 */
+# define STM32_NDMA 1 /* (2) DMA1 (7 channels) */
+# define STM32_NSPI 1 /* (3) SPI1 */
+# define STM32_NI2S 0 /* (0) I2S1 */
+# define STM32_NUSART 3 /* (2) USART1-3 */
+# define STM32_NI2C 1 /* (2) I2C1 */
+# define STM32_NCAN 1 /* (1) CAN1 */
+# define STM32_NSDIO 0 /* (0) No SDIO */
+# define STM32_NLCD 0 /* (0) No LCD */
+# define STM32_NUSBOTG 0 /* (0) No USB */
+# define STM32_NGPIO 51 /* GPIOA-F */
+# define STM32_NADC 3 /* (3) 12-bit ADC1-3 */
+# define STM32_NDAC 2 /* (3) 12-bit DAC1-2 */
+# define STM32_NCMP 3 /* (3) Ultra-fast analog comparators: COMP2, COMP4 and COMP6 */
+# define STM32_NPGA 1 /* (1) Operational amplifiers: OPAMP */
+# define STM32_NCAPSENSE 18 /* (18) No capacitive sensing channels */
+# define STM32_NCRC 1 /* (1) CRC calculation unit */
+# define STM32_NETHERNET 0 /* (0) No Ethernet MAC */
+# define STM32_NRNG 0 /* (0) No random number generator (RNG) */
+# define STM32_NDCMI 0 /* (0) No digital camera interface (DCMI) */
+
#elif defined(CONFIG_ARCH_CHIP_STM32F373C8) || defined(CONFIG_ARCH_CHIP_STM32F373CB) || defined(CONFIG_ARCH_CHIP_STM32F373CC)
# undef CONFIG_STM32_STM32L15XX /* STM32L151xx and STM32L152xx family */
# undef CONFIG_STM32_ENERGYLITE /* STM32L EnergyLite vamily */
@@ -1513,6 +1677,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# define CONFIG_STM32_STM32F37XX 1 /* STM32F37xxx family */
# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx */
# define STM32_NFSMC 0 /* No FSMC */
@@ -1558,6 +1723,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx and STM32407xx */
# define STM32_NFSMC 0 /* No FSMC */
@@ -1596,6 +1762,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx and STM32407xx */
# define STM32_NFSMC 0 /* No FSMC */
@@ -1634,6 +1801,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx and STM32407xx */
# define STM32_NFSMC 0 /* No FSMC */
@@ -1672,6 +1840,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx and STM32407xx */
# define STM32_NFSMC 0 /* No FSMC */
@@ -1710,6 +1879,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx and STM32407xx */
# define STM32_NFSMC 1 /* FSMC */
@@ -1748,6 +1918,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx and STM32407xx */
# define STM32_NFSMC 1 /* FSMC */
@@ -1786,6 +1957,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx and STM32407xx */
# define STM32_NFSMC 1 /* FSMC */
@@ -1824,6 +1996,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx and STM32407xx */
# define STM32_NFSMC 1 /* FSMC */
@@ -1862,6 +2035,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx and STM32407xx */
# define STM32_NFSMC 1 /* FSMC */
@@ -1900,6 +2074,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx and STM32407xx */
# define STM32_NFSMC 1 /* FSMC */
@@ -1938,6 +2113,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx and STM32407xx */
# define STM32_NFSMC 1 /* FSMC */
@@ -1976,6 +2152,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx and STM32407xx */
# define STM32_NFSMC 1 /* FSMC */
@@ -2014,6 +2191,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx, STM32407xx and STM32F427/437 */
# define STM32_NFSMC 1 /* FSMC */
@@ -2052,6 +2230,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx, STM32407xx and STM32F427/437 */
# define STM32_NFSMC 1 /* FSMC */
@@ -2090,6 +2269,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx, STM32407xx and STM32F427/437 */
# define STM32_NFSMC 1 /* FSMC */
@@ -2128,6 +2308,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx, STM32407xx and STM32F427/437 */
# define STM32_NFSMC 1 /* FSMC */
@@ -2166,6 +2347,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx, STM32407xx and STM32F427/437/429/439 */
# define STM32_NFSMC 1 /* FSMC */
@@ -2204,6 +2386,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx, STM32407xx and STM32F427/437 */
# define STM32_NFSMC 1 /* FSMC */
@@ -2242,6 +2425,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx, STM32407xx and STM32F427/437 STM32F466 */
# define STM32_NFSMC 0 /* FSMC */
@@ -2280,6 +2464,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx, STM32407xx and STM32F427/437 STM32F466 */
# define STM32_NFSMC 0 /* FSMC */
@@ -2318,6 +2503,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx, STM32407xx and STM32F427/437 STM32F466 */
# define STM32_NFSMC 1 /* FSMC */
@@ -2356,6 +2542,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx, STM32407xx and STM32F427/437 STM32F466 */
# define STM32_NFSMC 1 /* FSMC */
@@ -2394,6 +2581,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx, STM32407xx and STM32F427/437 */
# define STM32_NFSMC 1 /* FSMC */
@@ -2435,6 +2623,7 @@
# undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */
# undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */
# undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */
+# undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */
# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx, STM32407xx and STM32F427/437 */
# define STM32_NFSMC 1 /* FSMC */
diff --git a/arch/arm/include/stm32/dma2d.h b/arch/arm/include/stm32/dma2d.h
index 349944148f93158f1c2b80f11a6187693b2ffd6e..be807de31dca8b917cad700529c7d6da46568c57 100644
--- a/arch/arm/include/stm32/dma2d.h
+++ b/arch/arm/include/stm32/dma2d.h
@@ -1,5 +1,5 @@
/****************************************************************************
- * arch/arm/src/include/stm32/dma2d.h
+ * arch/arm/include/stm32/dma2d.h
*
* Copyright (C) 2015 Marco Krahl. All rights reserved.
* Author: Marco Krahl
@@ -345,7 +345,7 @@ struct dma2d_layer_s
*
****************************************************************************/
-FAR struct dma2d_layer_s * up_dma2dgetlayer(int lid);
+FAR struct dma2d_layer_s *up_dma2dgetlayer(int lid);
/****************************************************************************
* Name: up_dma2dcreatelayer
diff --git a/arch/arm/include/stm32/irq.h b/arch/arm/include/stm32/irq.h
index 2c9b188f0258348928741b88bba8f1a61546d46a..ed369355a14f5576168ee5be11872976bdd211e0 100644
--- a/arch/arm/include/stm32/irq.h
+++ b/arch/arm/include/stm32/irq.h
@@ -1,7 +1,7 @@
/************************************************************************************
- * arch/arm/include/stm32s/irq.h
+ * arch/arm/include/stm32/irq.h
*
- * Copyright (C) 2009, 2012 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2009, 2012, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
*
* Redistribution and use in source and binary forms, with or without
@@ -85,6 +85,8 @@
# include
#elif defined(CONFIG_STM32_STM32F30XX)
# include
+#elif defined(CONFIG_STM32_STM32F33XX)
+# include
#elif defined(CONFIG_STM32_STM32F37XX)
# include
#elif defined(CONFIG_STM32_STM32F40XX)
diff --git a/arch/arm/include/stm32/ltdc.h b/arch/arm/include/stm32/ltdc.h
index 70f978058aa6fa13a6f791c99fb80b6781837272..704b578a9965f4cdd9218f5caddf52bb0a8c74ff 100644
--- a/arch/arm/include/stm32/ltdc.h
+++ b/arch/arm/include/stm32/ltdc.h
@@ -1,5 +1,5 @@
/****************************************************************************
- * arch/arm/src/include/stm32/ltdc.h
+ * arch/arm/include/stm32/ltdc.h
*
* Copyright (C) 2014-2015 Marco Krahl. All rights reserved.
* Author: Marco Krahl
diff --git a/arch/arm/include/stm32/stm32f10xxx_irq.h b/arch/arm/include/stm32/stm32f10xxx_irq.h
index beed4952541de0e89a5f46c27ed19cb22ec47ba7..e56df1338e93ae326dcb9e882234ffbad42c2af5 100644
--- a/arch/arm/include/stm32/stm32f10xxx_irq.h
+++ b/arch/arm/include/stm32/stm32f10xxx_irq.h
@@ -1,5 +1,5 @@
/************************************************************************************
- * arch/arm/include/stm32s/stm32f10xxx_irq.h
+ * arch/arm/include/stm32/stm32f10xxx_irq.h
*
* Copyright (C) 2009, 2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
diff --git a/arch/arm/include/stm32/stm32f20xxx_irq.h b/arch/arm/include/stm32/stm32f20xxx_irq.h
index 43a2e218eb9ca9c329692e457834dbbe45b88867..1c5bc9480e15b43b715c5ca3aa4e006eefa63069 100644
--- a/arch/arm/include/stm32/stm32f20xxx_irq.h
+++ b/arch/arm/include/stm32/stm32f20xxx_irq.h
@@ -1,5 +1,5 @@
/****************************************************************************************************
- * arch/arm/include/stm32s/stm32f20xxx_irq.h
+ * arch/arm/include/stm32/stm32f20xxx_irq.h
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
diff --git a/arch/arm/include/stm32/stm32f30xxx_irq.h b/arch/arm/include/stm32/stm32f30xxx_irq.h
index 74c8a279a65ecfad11406d4ee14b0b4b57ee416b..f109c8b85d7899cedff414af9c14eb1f958550d3 100644
--- a/arch/arm/include/stm32/stm32f30xxx_irq.h
+++ b/arch/arm/include/stm32/stm32f30xxx_irq.h
@@ -1,5 +1,5 @@
/****************************************************************************************************
- * arch/arm/include/stm32s/stm32f30xxx_irq.h
+ * arch/arm/include/stm32/stm32f30xxx_irq.h
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
diff --git a/arch/arm/include/stm32/stm32f33xxx_irq.h b/arch/arm/include/stm32/stm32f33xxx_irq.h
new file mode 100644
index 0000000000000000000000000000000000000000..7170959ec93f8734ec49c4a40e5112b350756941
--- /dev/null
+++ b/arch/arm/include/stm32/stm32f33xxx_irq.h
@@ -0,0 +1,185 @@
+/****************************************************************************************************
+ * arch/arm/include/stm32/stm32f33xxx_irq.h
+ *
+ * Copyright (C) 2017 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ * Modified for STM32F334 by Mateusz Szafoni
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************************************/
+
+/* This file should never be included directed but, rather, only indirectly through nuttx/irq.h */
+
+#ifndef __ARCH_ARM_INCLUDE_STM32_STM32F33XXX_IRQ_H
+#define __ARCH_ARM_INCLUDE_STM32_STM32F33XXX_IRQ_H
+
+/****************************************************************************************************
+ * Included Files
+ ****************************************************************************************************/
+
+#include
+#include
+
+/****************************************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************************************/
+
+/* IRQ numbers. The IRQ number corresponds vector number and hence map directly to
+ * bits in the NVIC. This does, however, waste several words of memory in the IRQ
+ * to handle mapping tables.
+ *
+ * Processor Exceptions (vectors 0-15). These common definitions can be found
+ * in nuttx/arch/arm/include/stm32/irq.h
+ *
+ * External interrupts (vectors >= 16)
+ */
+
+#define STM32_IRQ_WWDG (STM32_IRQ_FIRST+0) /* 0: Window Watchdog interrupt */
+#define STM32_IRQ_PVD (STM32_IRQ_FIRST+1) /* 1: PVD through EXTI Line detection interrupt */
+#define STM32_IRQ_TAMPER (STM32_IRQ_FIRST+2) /* 2: Tamper interrupt, or */
+#define STM32_IRQ_TIMESTAMP (STM32_IRQ_FIRST+2) /* 2: Time stamp interrupt */
+#define STM32_IRQ_RTC_WKUP (STM32_IRQ_FIRST+3) /* 3: RTC global interrupt */
+#define STM32_IRQ_FLASH (STM32_IRQ_FIRST+4) /* 4: Flash global interrupt */
+#define STM32_IRQ_RCC (STM32_IRQ_FIRST+5) /* 5: RCC global interrupt */
+#define STM32_IRQ_EXTI0 (STM32_IRQ_FIRST+6) /* 6: EXTI Line 0 interrupt */
+#define STM32_IRQ_EXTI1 (STM32_IRQ_FIRST+7) /* 7: EXTI Line 1 interrupt */
+#define STM32_IRQ_EXTI2 (STM32_IRQ_FIRST+8) /* 8: EXTI Line 2 interrupt, or */
+#define STM32_IRQ_TSC (STM32_IRQ_FIRST+8) /* 8: TSC interrupt */
+#define STM32_IRQ_EXTI3 (STM32_IRQ_FIRST+9) /* 9: EXTI Line 3 interrupt */
+#define STM32_IRQ_EXTI4 (STM32_IRQ_FIRST+10) /* 10: EXTI Line 4 interrupt */
+#define STM32_IRQ_DMA1CH1 (STM32_IRQ_FIRST+11) /* 11: DMA1 channel 1 global interrupt */
+#define STM32_IRQ_DMA1CH2 (STM32_IRQ_FIRST+12) /* 12: DMA1 channel 2 global interrupt */
+#define STM32_IRQ_DMA1CH3 (STM32_IRQ_FIRST+13) /* 13: DMA1 channel 3 global interrupt */
+#define STM32_IRQ_DMA1CH4 (STM32_IRQ_FIRST+14) /* 14: DMA1 channel 4 global interrupt */
+#define STM32_IRQ_DMA1CH5 (STM32_IRQ_FIRST+15) /* 15: DMA1 channel 5 global interrupt */
+#define STM32_IRQ_DMA1CH6 (STM32_IRQ_FIRST+16) /* 16: DMA1 channel 6 global interrupt */
+#define STM32_IRQ_DMA1CH7 (STM32_IRQ_FIRST+17) /* 17: DMA1 channel 7 global interrupt */
+#define STM32_IRQ_ADC12 (STM32_IRQ_FIRST+18) /* 18: ADC1/ADC2 global interrupt */
+#define STM32_IRQ_CAN1TX (STM32_IRQ_FIRST+19) /* 19: CAN1 TX interrupts */
+#define STM32_IRQ_CAN1RX0 (STM32_IRQ_FIRST+20) /* 20: CAN1 RX0 interrupts*/
+#define STM32_IRQ_CAN1RX1 (STM32_IRQ_FIRST+21) /* 21: CAN1 RX1 interrupt */
+#define STM32_IRQ_CAN1SCE (STM32_IRQ_FIRST+22) /* 22: CAN1 SCE interrupt */
+#define STM32_IRQ_EXTI95 (STM32_IRQ_FIRST+23) /* 23: EXTI Line[9:5] interrupts */
+#define STM32_IRQ_TIM1BRK (STM32_IRQ_FIRST+24) /* 24: TIM1 Break interrupt, or */
+#define STM32_IRQ_TIM15 (STM32_IRQ_FIRST+24) /* 24: TIM15 global interrupt */
+#define STM32_IRQ_TIM1UP (STM32_IRQ_FIRST+25) /* 25: TIM1 Update interrupt, or */
+#define STM32_IRQ_TIM16 (STM32_IRQ_FIRST+25) /* 25: TIM16 global interrupt */
+#define STM32_IRQ_TIM1TRGCOM (STM32_IRQ_FIRST+26) /* 26: TIM1 Trigger and Commutation interrupts, or */
+#define STM32_IRQ_TIM17 (STM32_IRQ_FIRST+26) /* 26: TIM17 global interrupt */
+#define STM32_IRQ_TIM1CC (STM32_IRQ_FIRST+27) /* 27: TIM1 Capture Compare interrupt */
+#define STM32_IRQ_TIM2 (STM32_IRQ_FIRST+28) /* 28: TIM2 global interrupt */
+#define STM32_IRQ_TIM3 (STM32_IRQ_FIRST+29) /* 29: TIM3 global interrupt */
+#define STM32_IRQ_RESERVED30 (STM32_IRQ_FIRST+30) /* 30: Reserved */
+#define STM32_IRQ_I2C1EV (STM32_IRQ_FIRST+31) /* 31: I2C1 event interrupt */
+#define STM32_IRQ_I2C1ER (STM32_IRQ_FIRST+32) /* 32: I2C1 error interrupt */
+#define STM32_IRQ_RESERVED33 (STM32_IRQ_FIRST+33) /* 33: Reserved */
+#define STM32_IRQ_RESERVED34 (STM32_IRQ_FIRST+34) /* 34: Reserved */
+#define STM32_IRQ_SPI1 (STM32_IRQ_FIRST+35) /* 35: SPI1 global interrupt */
+#define STM32_IRQ_RESERVED36 (STM32_IRQ_FIRST+36) /* 36: Reserved */
+#define STM32_IRQ_USART1 (STM32_IRQ_FIRST+37) /* 37: USART1 global interrupt */
+#define STM32_IRQ_USART2 (STM32_IRQ_FIRST+38) /* 38: USART2 global interrupt */
+#define STM32_IRQ_USART3 (STM32_IRQ_FIRST+39) /* 39: USART3 global interrupt */
+#define STM32_IRQ_EXTI1510 (STM32_IRQ_FIRST+40) /* 40: EXTI Line[15:10] interrupts */
+#define STM32_IRQ_RTCALRM (STM32_IRQ_FIRST+41) /* 41: RTC alarm through EXTI line interrupt */
+#define STM32_IRQ_RESERVED42 (STM32_IRQ_FIRST+42) /* 42: Reserved */
+#define STM32_IRQ_RESERVED43 (STM32_IRQ_FIRST+43) /* 43: Reserved */
+#define STM32_IRQ_RESERVED44 (STM32_IRQ_FIRST+44) /* 44: Reserved */
+#define STM32_IRQ_RESERVED45 (STM32_IRQ_FIRST+45) /* 45: Reserved */
+#define STM32_IRQ_RESERVED46 (STM32_IRQ_FIRST+46) /* 46: Reserved */
+#define STM32_IRQ_RESERVED47 (STM32_IRQ_FIRST+47) /* 47: Reserved */
+#define STM32_IRQ_RESERVED48 (STM32_IRQ_FIRST+48) /* 48: Reserved */
+#define STM32_IRQ_RESERVED49 (STM32_IRQ_FIRST+49) /* 49: Reserved */
+#define STM32_IRQ_RESERVED50 (STM32_IRQ_FIRST+50) /* 50: Reserved */
+#define STM32_IRQ_RESERVED51 (STM32_IRQ_FIRST+51) /* 51: Reserved */
+#define STM32_IRQ_RESERVED52 (STM32_IRQ_FIRST+52) /* 52: Reserved */
+#define STM32_IRQ_RESERVED53 (STM32_IRQ_FIRST+53) /* 53: Reserved */
+#define STM32_IRQ_TIM6 (STM32_IRQ_FIRST+54) /* 54: TIM6 global interrupt, or */
+#define STM32_IRQ_DAC1 (STM32_IRQ_FIRST+54) /* 54: DAC1 underrun error interrupts */
+#define STM32_IRQ_TIM7 (STM32_IRQ_FIRST+55) /* 55: TIM7 global interrupt, or */
+#define STM32_IRQ_DAC2 (STM32_IRQ_FIRST+54) /* 55: DAC2 underrun error interrupts */
+#define STM32_IRQ_RESERVED56 (STM32_IRQ_FIRST+56) /* 56: Reserved */
+#define STM32_IRQ_RESERVED57 (STM32_IRQ_FIRST+57) /* 57: Reserved */
+#define STM32_IRQ_RESERVED58 (STM32_IRQ_FIRST+58) /* 58: Reserved */
+#define STM32_IRQ_RESERVED59 (STM32_IRQ_FIRST+59) /* 59: Reserved */
+#define STM32_IRQ_RESERVED60 (STM32_IRQ_FIRST+60) /* 60: Reserved */
+#define STM32_IRQ_RESERVED61 (STM32_IRQ_FIRST+61) /* 61: Reserved */
+#define STM32_IRQ_RESERVED62 (STM32_IRQ_FIRST+62) /* 62: Reserved */
+#define STM32_IRQ_RESERVED63 (STM32_IRQ_FIRST+63) /* 63: Reserved */
+#define STM32_IRQ_COMP2 (STM32_IRQ_FIRST+64) /* 64: COMP2 interrupts, or */
+#define STM32_IRQ_EXTI2129 (STM32_IRQ_FIRST+64) /* 64: EXTI Lines 21, 22 and 29 interrupts */
+#define STM32_IRQ_COMP46 (STM32_IRQ_FIRST+65) /* 65: COMP4 & COMP6 interrupts, or */
+#define STM32_IRQ_EXTI3012 (STM32_IRQ_FIRST+65) /* 65: EXTI Lines 30, 31 and 32 interrupts */
+#define STM32_IRQ_RESERVED66 (STM32_IRQ_FIRST+66) /* 66: Reserved */
+#define STM32_IRQ_HRTIMTM (STM32_IRQ_FIRST+67) /* 67: HRTIM master timer interrupt */
+#define STM32_IRQ_HRTIMTA (STM32_IRQ_FIRST+68) /* 68: HRTIM timer A interrupt */
+#define STM32_IRQ_HRTIMTB (STM32_IRQ_FIRST+69) /* 69: HRTIM timer B interrupt */
+#define STM32_IRQ_HRTIMTC (STM32_IRQ_FIRST+70) /* 70: HRTIM timer C interrupt */
+#define STM32_IRQ_HRTIMTD (STM32_IRQ_FIRST+71) /* 71: HRTIM timer D interrupt */
+#define STM32_IRQ_HRTIMTE (STM32_IRQ_FIRST+72) /* 72: HRTIM timer E interrupt */
+#define STM32_IRQ_HRTIMFLT (STM32_IRQ_FIRST+73) /* 73: HRTIM fault interrupt */
+#define STM32_IRQ_RESERVED74 (STM32_IRQ_FIRST+74) /* 74: Reserved */
+#define STM32_IRQ_RESERVED75 (STM32_IRQ_FIRST+75) /* 75: Reserved */
+#define STM32_IRQ_RESERVED76 (STM32_IRQ_FIRST+76) /* 76: Reserved */
+#define STM32_IRQ_RESERVED77 (STM32_IRQ_FIRST+77) /* 77: Reserved */
+#define STM32_IRQ_RESERVED78 (STM32_IRQ_FIRST+78) /* 78: Reserved */
+#define STM32_IRQ_RESERVED79 (STM32_IRQ_FIRST+79) /* 79: Reserved */
+#define STM32_IRQ_RESERVED80 (STM32_IRQ_FIRST+80) /* 80: Reserved */
+#define STM32_IRQ_FPU (STM32_IRQ_FIRST+81) /* 81: FPU global interrupt */
+
+#define NR_VECTORS (STM32_IRQ_FIRST+82)
+#define NR_IRQS (STM32_IRQ_FIRST+82)
+
+/****************************************************************************************************
+ * Public Types
+ ****************************************************************************************************/
+
+/****************************************************************************************************
+ * Public Data
+****************************************************************************************************/
+
+#ifndef __ASSEMBLY__
+#ifdef __cplusplus
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+/****************************************************************************************************
+ * Public Functions
+ ****************************************************************************************************/
+
+#undef EXTERN
+#ifdef __cplusplus
+}
+#endif
+#endif
+
+#endif /* __ARCH_ARM_INCLUDE_STM32F30XXX_IRQ_H */
diff --git a/arch/arm/include/stm32/stm32f37xxx_irq.h b/arch/arm/include/stm32/stm32f37xxx_irq.h
index 22456683bc3bcaae51a78028f9a0395f1d9a6946..4f8a431bf9d3a60650cbbbcaf48c170192d345e6 100644
--- a/arch/arm/include/stm32/stm32f37xxx_irq.h
+++ b/arch/arm/include/stm32/stm32f37xxx_irq.h
@@ -1,5 +1,5 @@
/****************************************************************************************************
- * arch/arm/include/stm32s/stm32f37xxx_irq.h
+ * arch/arm/include/stm32/stm32f37xxx_irq.h
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
diff --git a/arch/arm/include/stm32/stm32f40xxx_irq.h b/arch/arm/include/stm32/stm32f40xxx_irq.h
index b0499b6ba32bf3285545fb89bdc95e743345d0d6..64df1a6fe5752554ceb31090e22eaed3b6f3af7d 100644
--- a/arch/arm/include/stm32/stm32f40xxx_irq.h
+++ b/arch/arm/include/stm32/stm32f40xxx_irq.h
@@ -1,5 +1,5 @@
/****************************************************************************************************
- * arch/arm/include/stm32s/stm32f40xxx_irq.h
+ * arch/arm/include/stm32/stm32f40xxx_irq.h
*
* Copyright (C) 2009, 2014-2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2016 Omni Hoverboards Inc. All rights reserved.
diff --git a/arch/arm/include/stm32/stm32l15xxx_irq.h b/arch/arm/include/stm32/stm32l15xxx_irq.h
index ca692932f9be8e49f9be0bc23a7f844a3f4f0bba..d0c1380c8783149d36af1ebb0a6bd741564bffb1 100644
--- a/arch/arm/include/stm32/stm32l15xxx_irq.h
+++ b/arch/arm/include/stm32/stm32l15xxx_irq.h
@@ -1,5 +1,5 @@
/****************************************************************************************************
- * arch/arm/include/stm32s/stm32l15xxx_irq.h
+ * arch/arm/include/stm32/stm32l15xxx_irq.h
* For STM32L100xx, STM32L151xx, STM32L152xx and STM32L162xx advanced ARM-based 32-bit MCUs
*
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
diff --git a/arch/arm/src/a1x/a1x_serial.c b/arch/arm/src/a1x/a1x_serial.c
index 7dae40aa997d827feaba429f65fb27fef106f7cb..ec8de5e0090507c7175fe96dd1ed9f423a5c2c61 100644
--- a/arch/arm/src/a1x/a1x_serial.c
+++ b/arch/arm/src/a1x/a1x_serial.c
@@ -93,7 +93,6 @@ struct up_dev_s
uint32_t uartbase; /* Base address of UART registers */
uint32_t baud; /* Configured baud */
uint32_t ier; /* Saved IER value */
- xcpt_t handler; /* UART interrupt handler */
uint8_t irq; /* IRQ associated with this UART */
uint8_t parity; /* 0=none, 1=odd, 2=even */
uint8_t bits; /* Number of bits (7 or 8) */
@@ -108,31 +107,7 @@ static int up_setup(struct uart_dev_s *dev);
static void up_shutdown(struct uart_dev_s *dev);
static int up_attach(struct uart_dev_s *dev);
static void up_detach(struct uart_dev_s *dev);
-static int uart_interrupt(struct uart_dev_s *dev);
-#ifdef CONFIG_A1X_UART0
-static int uart0_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_A1X_UART1
-static int uart1_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_A1X_UART2
-static int uart2_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_A1X_UART3
-static int uart3_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_A1X_UART4
-static int uart4_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_A1X_UART5
-static int uart5_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_A1X_UART6
-static int uart6_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_A1X_UART7
-static int uart7_interrupt(int irq, void *context);
-#endif
+static int uart_interrupt(int irq, void *context, void *arg);
static int up_ioctl(struct file *filep, int cmd, unsigned long arg);
static int up_receive(struct uart_dev_s *dev, uint32_t *status);
static void up_rxint(struct uart_dev_s *dev, bool enable);
@@ -214,7 +189,6 @@ static struct up_dev_s g_uart0priv =
{
.uartbase = A1X_UART0_VADDR,
.baud = CONFIG_UART0_BAUD,
- .handler = uart0_interrupt,
.irq = A1X_IRQ_UART0,
.parity = CONFIG_UART0_PARITY,
.bits = CONFIG_UART0_BITS,
@@ -245,7 +219,6 @@ static struct up_dev_s g_uart1priv =
{
.uartbase = A1X_UART1_VADDR,
.baud = CONFIG_UART1_BAUD,
- .handler = uart1_interrupt,
.irq = A1X_IRQ_UART1,
.parity = CONFIG_UART1_PARITY,
.bits = CONFIG_UART1_BITS,
@@ -276,7 +249,6 @@ static struct up_dev_s g_uart2priv =
{
.uartbase = A1X_UART2_VADDR,
.baud = CONFIG_UART2_BAUD,
- .handler = uart2_interrupt,
.irq = A1X_IRQ_UART2,
.parity = CONFIG_UART2_PARITY,
.bits = CONFIG_UART2_BITS,
@@ -307,7 +279,6 @@ static struct up_dev_s g_uart3priv =
{
.uartbase = A1X_UART3_VADDR,
.baud = CONFIG_UART3_BAUD,
- .handler = uart3_interrupt,
.irq = A1X_IRQ_UART3,
.parity = CONFIG_UART3_PARITY,
.bits = CONFIG_UART3_BITS,
@@ -338,7 +309,6 @@ static struct up_dev_s g_uart4priv =
{
.uartbase = A1X_UART4_VADDR,
.baud = CONFIG_UART4_BAUD,
- .handler = uart4_interrupt,
.irq = A1X_IRQ_UART4,
.parity = CONFIG_UART4_PARITY,
.bits = CONFIG_UART4_BITS,
@@ -369,7 +339,6 @@ static struct up_dev_s g_uart5priv =
{
.uartbase = A1X_UART5_VADDR,
.baud = CONFIG_UART5_BAUD,
- .handler = uart5_interrupt,
.irq = A1X_IRQ_UART5,
.parity = CONFIG_UART5_PARITY,
.bits = CONFIG_UART5_BITS,
@@ -400,7 +369,6 @@ static struct up_dev_s g_uart6priv =
{
.uartbase = A1X_UART6_VADDR,
.baud = CONFIG_UART6_BAUD,
- .handler = uart6_interrupt,
.irq = A1X_IRQ_UART6,
.parity = CONFIG_UART6_PARITY,
.bits = CONFIG_UART6_BITS,
@@ -431,7 +399,6 @@ static struct up_dev_s g_uart7priv =
{
.uartbase = A1X_UART7_VADDR,
.baud = CONFIG_UART7_BAUD,
- .handler = uart7_interrupt,
.irq = A1X_IRQ_UART7,
.parity = CONFIG_UART7_PARITY,
.bits = CONFIG_UART7_BITS,
@@ -1068,7 +1035,7 @@ static int up_attach(struct uart_dev_s *dev)
/* Attach and enable the IRQ */
- ret = irq_attach(priv->irq, priv->handler);
+ ret = irq_attach(priv->irq, uart_interrupt, priv);
if (ret == OK)
{
/* Enable the interrupt (RX and TX interrupts are still disabled
@@ -1110,12 +1077,14 @@ static void up_detach(struct uart_dev_s *dev)
*
****************************************************************************/
-static int uart_interrupt(struct uart_dev_s *dev)
+static int uart_interrupt(int irq, void *context, void *arg)
{
- struct up_dev_s *priv;
- uint32_t status;
- int passes;
+ struct uart_dev_s *dev = (struct uart_dev_s *)arg;
+ struct up_dev_s *priv = (struct up_dev_s *)arg;
+ uint32_t status;
+ int passes;
+ DEBUGASSERT(dev != NULL && dev->priv != NULL);
priv = (struct up_dev_s *)dev->priv;
/* Loop until there are no characters to be transferred or,
@@ -1201,62 +1170,6 @@ static int uart_interrupt(struct uart_dev_s *dev)
return OK;
}
-#ifdef CONFIG_A1X_UART0
-static int uart0_interrupt(int irq, void *context)
-{
- return uart_interrupt(&g_uart0port);
-}
-#endif
-
-#ifdef CONFIG_A1X_UART1
-static int uart1_interrupt(int irq, void *context)
-{
- return uart_interrupt(&g_uart1port);
-}
-#endif
-
-#ifdef CONFIG_A1X_UART2
-static int uart2_interrupt(int irq, void *context)
-{
- return uart_interrupt(&g_uart2port);
-}
-#endif
-
-#ifdef CONFIG_A1X_UART3
-static int uart3_interrupt(int irq, void *context)
-{
- return uart_interrupt(&g_uart3port);
-}
-#endif
-
-#ifdef CONFIG_A1X_UART4
-static int uart4_interrupt(int irq, void *context)
-{
- return uart_interrupt(&g_uart4port);
-}
-#endif
-
-#ifdef CONFIG_A1X_UART5
-static int uart5_interrupt(int irq, void *context)
-{
- return uart_interrupt(&g_uart5port);
-}
-#endif
-
-#ifdef CONFIG_A1X_UART6
-static int uart6_interrupt(int irq, void *context)
-{
- return uart_interrupt(&g_uart6port);
-}
-#endif
-
-#ifdef CONFIG_A1X_UART7
-static int uart7_interrupt(int irq, void *context)
-{
- return uart_interrupt(&g_uart7port);
-}
-#endif
-
/****************************************************************************
* Name: up_ioctl
*
diff --git a/arch/arm/src/a1x/a1x_timerisr.c b/arch/arm/src/a1x/a1x_timerisr.c
index 04407d1051179d4a04cc730870346701cc513e68..d5ef7508f418f5fec56a8e38186fd50cd7234581 100644
--- a/arch/arm/src/a1x/a1x_timerisr.c
+++ b/arch/arm/src/a1x/a1x_timerisr.c
@@ -82,7 +82,7 @@
*
****************************************************************************/
-static int a1x_timerisr(int irq, uint32_t *regs)
+static int a1x_timerisr(int irq, uint32_t *regs, void *arg)
{
/* Only a TIMER0 interrupt is expected here */
@@ -138,7 +138,7 @@ void arm_timer_initialize(void)
/* Attach the timer interrupt vector */
- (void)irq_attach(A1X_IRQ_TIMER0, (xcpt_t)a1x_timerisr);
+ (void)irq_attach(A1X_IRQ_TIMER0, (xcpt_t)a1x_timerisr, NULL);
/* Enable interrupts from the TIMER 0 port */
diff --git a/arch/arm/src/armv6-m/up_hardfault.c b/arch/arm/src/armv6-m/up_hardfault.c
index b3c24d885151cf63fd6dd50179bc890c622dea98..6b4f69760e19327fb4fb3bf72e496290ef256e28 100644
--- a/arch/arm/src/armv6-m/up_hardfault.c
+++ b/arch/arm/src/armv6-m/up_hardfault.c
@@ -75,7 +75,7 @@
*
****************************************************************************/
-int up_hardfault(int irq, FAR void *context)
+int up_hardfault(int irq, FAR void *context, FAR void *arg)
{
uint32_t *regs = (uint32_t *)context;
@@ -115,7 +115,7 @@ int up_hardfault(int irq, FAR void *context)
if (insn == INSN_SVC0)
{
hfinfo("Forward SVCall\n");
- return up_svcall(irq, context);
+ return up_svcall(irq, context, NULL);
}
}
diff --git a/arch/arm/src/armv6-m/up_svcall.c b/arch/arm/src/armv6-m/up_svcall.c
index 1cd7e3a33b058a55747d143080c9610ae4fbc779..fd61de1906f7a6dbf464e0048981d44216b85e99 100644
--- a/arch/arm/src/armv6-m/up_svcall.c
+++ b/arch/arm/src/armv6-m/up_svcall.c
@@ -130,7 +130,7 @@ static void dispatch_syscall(void)
*
****************************************************************************/
-int up_svcall(int irq, FAR void *context)
+int up_svcall(int irq, FAR void *context, FAR void *arg)
{
uint32_t *regs = (uint32_t *)context;
uint32_t cmd;
diff --git a/arch/arm/src/armv7-a/arm_cpupause.c b/arch/arm/src/armv7-a/arm_cpupause.c
index 6f92343c1492d4590043c8187104476b48559589..8a1499c29761cc4acfa98b48696e7db45188bdb0 100644
--- a/arch/arm/src/armv7-a/arm_cpupause.c
+++ b/arch/arm/src/armv7-a/arm_cpupause.c
@@ -202,7 +202,7 @@ int up_cpu_paused(int cpu)
*
****************************************************************************/
-int arm_pause_handler(int irq, FAR void *context)
+int arm_pause_handler(int irq, FAR void *context, FAR void *arg)
{
int cpu = this_cpu();
diff --git a/arch/arm/src/armv7-a/arm_cpustart.c b/arch/arm/src/armv7-a/arm_cpustart.c
index d63c035db68f1d5c7af0e0d0ad07d7dc1a59c55e..3226153f5c188719e76ac95da412d11078cb1488 100644
--- a/arch/arm/src/armv7-a/arm_cpustart.c
+++ b/arch/arm/src/armv7-a/arm_cpustart.c
@@ -103,7 +103,7 @@ static inline void arm_registerdump(FAR struct tcb_s *tcb)
*
****************************************************************************/
-int arm_start_handler(int irq, FAR void *context)
+int arm_start_handler(int irq, FAR void *context, FAR void *arg)
{
FAR struct tcb_s *tcb = this_task();
diff --git a/arch/arm/src/armv7-a/arm_gicv2.c b/arch/arm/src/armv7-a/arm_gicv2.c
index dce0b621ed98f1096d1e55d3df108739daf3aa19..ec32fa5271072f011e78732f7514b125f2abfe95 100644
--- a/arch/arm/src/armv7-a/arm_gicv2.c
+++ b/arch/arm/src/armv7-a/arm_gicv2.c
@@ -124,8 +124,8 @@ void arm_gic0_initialize(void)
#ifdef CONFIG_SMP
/* Attach SGI interrupt handlers. This attaches the handler for all CPUs. */
- DEBUGVERIFY(irq_attach(GIC_IRQ_SGI1, arm_start_handler));
- DEBUGVERIFY(irq_attach(GIC_IRQ_SGI2, arm_pause_handler));
+ DEBUGVERIFY(irq_attach(GIC_IRQ_SGI1, arm_start_handler, NULL));
+ DEBUGVERIFY(irq_attach(GIC_IRQ_SGI2, arm_pause_handler, NULL));
#endif
arm_gic_dump("Exit arm_gic0_initialize", true, 0);
diff --git a/arch/arm/src/armv7-a/gic.h b/arch/arm/src/armv7-a/gic.h
index 8774065135069c3cc747a2eeca47d89e8e876e6e..8c882ad6ddc2c8711c978f0885c83fe11b8a9afa 100644
--- a/arch/arm/src/armv7-a/gic.h
+++ b/arch/arm/src/armv7-a/gic.h
@@ -759,7 +759,7 @@ uint32_t *arm_decodeirq(uint32_t *regs);
****************************************************************************/
#ifdef CONFIG_SMP
-int arm_start_handler(int irq, FAR void *context);
+int arm_start_handler(int irq, FAR void *context, FAR void *arg);
#endif
/****************************************************************************
@@ -783,7 +783,7 @@ int arm_start_handler(int irq, FAR void *context);
****************************************************************************/
#ifdef CONFIG_SMP
-int arm_pause_handler(int irq, FAR void *context);
+int arm_pause_handler(int irq, FAR void *context, FAR void *arg);
#endif
/****************************************************************************
diff --git a/arch/arm/src/armv7-m/up_hardfault.c b/arch/arm/src/armv7-m/up_hardfault.c
index fe133cc4f3782fe2e96aadbac49daf970f32f9b3..a68996836e17e68d5cbb42b4a76f5d34b3e4ba76 100644
--- a/arch/arm/src/armv7-m/up_hardfault.c
+++ b/arch/arm/src/armv7-m/up_hardfault.c
@@ -80,7 +80,7 @@
*
****************************************************************************/
-int up_hardfault(int irq, FAR void *context)
+int up_hardfault(int irq, FAR void *context, FAR void *arg)
{
#if defined(CONFIG_DEBUG_HARDFAULT) || !defined(CONFIG_ARMV7M_USEBASEPRI)
uint32_t *regs = (uint32_t *)context;
@@ -124,7 +124,7 @@ int up_hardfault(int irq, FAR void *context)
if (insn == INSN_SVC0)
{
hfalert("Forward SVCall\n");
- return up_svcall(irq, context);
+ return up_svcall(irq, context, arg);
}
}
#endif
diff --git a/arch/arm/src/armv7-m/up_memfault.c b/arch/arm/src/armv7-m/up_memfault.c
index f883209b769ed75e256c320e25a81fb513c0f7bd..f4f642e4defc21856c9fc75676bdeb85dc5e91b5 100644
--- a/arch/arm/src/armv7-m/up_memfault.c
+++ b/arch/arm/src/armv7-m/up_memfault.c
@@ -77,7 +77,7 @@
*
****************************************************************************/
-int up_memfault(int irq, FAR void *context)
+int up_memfault(int irq, FAR void *context, FAR void *arg)
{
/* Dump some memory management fault info */
diff --git a/arch/arm/src/armv7-m/up_svcall.c b/arch/arm/src/armv7-m/up_svcall.c
index 8e78de3a4329cfbb117dab28455b2f94922882ce..e16a6f104c2dd841df3fe1b6d41cf3e9cf45c2ab 100644
--- a/arch/arm/src/armv7-m/up_svcall.c
+++ b/arch/arm/src/armv7-m/up_svcall.c
@@ -125,7 +125,7 @@ static void dispatch_syscall(void)
*
****************************************************************************/
-int up_svcall(int irq, FAR void *context)
+int up_svcall(int irq, FAR void *context, FAR void *arg)
{
uint32_t *regs = (uint32_t *)context;
uint32_t cmd;
diff --git a/arch/arm/src/c5471/c5471_ethernet.c b/arch/arm/src/c5471/c5471_ethernet.c
index a163cecaabe482c65e383be8fb72411705ed7d29..03ddbe33837179b224215d5e7b10c658beacfc6d 100644
--- a/arch/arm/src/c5471/c5471_ethernet.c
+++ b/arch/arm/src/c5471/c5471_ethernet.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/c5471/c5471_ethernet.c
*
- * Copyright (C) 2007, 2009-2010, 2014-2015 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2009-2010, 2014-2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
*
* Based one a C5471 Linux driver and released under this BSD license with
@@ -312,7 +312,8 @@ struct c5471_driver_s
bool c_bifup; /* true:ifup false:ifdown */
WDOG_ID c_txpoll; /* TX poll timer */
WDOG_ID c_txtimeout; /* TX timeout timer */
- struct work_s c_work; /* For deferring work to the work queue */
+ struct work_s c_irqwork; /* For deferring interrupt work to the work queue */
+ struct work_s c_pollwork; /* For deferring poll work to the work queue */
/* Note: According to the C547x documentation: "The software has to maintain
* two pointers to the current RX-CPU and TX-CPU descriptors. At init time,
@@ -401,7 +402,7 @@ static void c5471_txstatus(struct c5471_driver_s *priv);
static void c5471_txdone(struct c5471_driver_s *priv);
static void c5471_interrupt_work(FAR void *arg);
-static int c5471_interrupt(int irq, FAR void *context);
+static int c5471_interrupt(int irq, FAR void *context, FAR void *arg);
/* Watchdog timer expirations */
@@ -1634,7 +1635,7 @@ static void c5471_interrupt_work(FAR void *arg)
*
****************************************************************************/
-static int c5471_interrupt(int irq, FAR void *context)
+static int c5471_interrupt(int irq, FAR void *context, FAR void *arg)
{
#if CONFIG_C5471_NET_NINTERFACES == 1
register struct c5471_driver_s *priv = &g_c5471[0];
@@ -1660,13 +1661,9 @@ static int c5471_interrupt(int irq, FAR void *context)
wd_cancel(priv->c_txtimeout);
}
- /* Cancel any pending poll work */
-
- work_cancel(ETHWORK, &priv->c_work);
-
/* Schedule to perform the interrupt processing on the worker thread. */
- work_queue(ETHWORK, &priv->c_work, c5471_interrupt_work, priv, 0);
+ work_queue(ETHWORK, &priv->c_irqwork, c5471_interrupt_work, priv, 0);
return OK;
}
@@ -1740,15 +1737,11 @@ static void c5471_txtimeout_expiry(int argc, wdparm_t arg, ...)
up_disable_irq(C5471_IRQ_ETHER);
- /* Cancel any pending poll or interrupt work. This will have no effect
- * on work that has already been started.
+ /* Schedule to perform the TX timeout processing on the worker thread,
+ * canceling any pending IRQ work.
*/
- work_cancel(ETHWORK, &priv->c_work);
-
- /* Schedule to perform the TX timeout processing on the worker thread. */
-
- work_queue(ETHWORK, &priv->c_work, c5471_txtimeout_work, priv, 0);
+ work_queue(ETHWORK, &priv->c_irqwork, c5471_txtimeout_work, priv, 0);
}
/****************************************************************************
@@ -1813,25 +1806,9 @@ static void c5471_poll_expiry(int argc, wdparm_t arg, ...)
{
struct c5471_driver_s *priv = (struct c5471_driver_s *)arg;
- /* Is our single work structure available? It may not be if there are
- * pending interrupt actions.
- */
-
- if (work_available(&priv->c_work))
- {
- /* Schedule to perform the interrupt processing on the worker thread. */
-
- work_queue(ETHWORK, &priv->c_work, c5471_poll_work, priv, 0);
- }
- else
- {
- /* No.. Just re-start the watchdog poll timer, missing one polling
- * cycle.
- */
+ /* Schedule to perform the interrupt processing on the worker thread. */
- (void)wd_start(priv->c_txpoll, C5471_WDDELAY, c5471_poll_expiry,
- 1, arg);
- }
+ work_queue(ETHWORK, &priv->c_pollwork, c5471_poll_work, priv, 0);
}
/****************************************************************************
@@ -2023,11 +2000,11 @@ static int c5471_txavail(FAR struct net_driver_s *dev)
* availability action.
*/
- if (work_available(&priv->c_work))
+ if (work_available(&priv->c_pollwork))
{
/* Schedule to serialize the poll on the worker thread. */
- work_queue(ETHWORK, &priv->c_work, c5471_txavail_work, priv, 0);
+ work_queue(ETHWORK, &priv->c_pollwork, c5471_txavail_work, priv, 0);
}
return OK;
@@ -2449,7 +2426,7 @@ void up_netinitialize(void)
{
/* Attach the IRQ to the driver */
- if (irq_attach(C5471_IRQ_ETHER, c5471_interrupt))
+ if (irq_attach(C5471_IRQ_ETHER, c5471_interrupt, NULL))
{
/* We could not attach the ISR to the ISR */
diff --git a/arch/arm/src/c5471/c5471_serial.c b/arch/arm/src/c5471/c5471_serial.c
index 935bc46871de9100e78b1c337d3a7f9f2b754f9c..44d0dc7fd250d0b5e62204d6528faf25cff8f3a2 100644
--- a/arch/arm/src/c5471/c5471_serial.c
+++ b/arch/arm/src/c5471/c5471_serial.c
@@ -108,7 +108,7 @@ static int up_setup(struct uart_dev_s *dev);
static void up_shutdown(struct uart_dev_s *dev);
static int up_attach(struct uart_dev_s *dev);
static void up_detach(struct uart_dev_s *dev);
-static int up_interrupt(int irq, void *context);
+static int up_interrupt(int irq, void *context, void *arg);
static int up_ioctl(struct file *filep, int cmd, unsigned long arg);
static int up_receive(struct uart_dev_s *dev, unsigned int *status);
static void up_rxint(struct uart_dev_s *dev, bool enable);
@@ -491,7 +491,7 @@ static int up_attach(struct uart_dev_s *dev)
/* Attach and enable the IRQ */
- ret = irq_attach(priv->irq, up_interrupt);
+ ret = irq_attach(priv->irq, up_interrupt, dev);
if (ret == OK)
{
/* Enable the interrupt (RX and TX interrupts are still disabled
@@ -534,24 +534,13 @@ static void up_detach(struct uart_dev_s *dev)
*
****************************************************************************/
-static int up_interrupt(int irq, void *context)
+static int up_interrupt(int irq, void *context, void *arg)
{
- struct uart_dev_s *dev = NULL;
+ struct uart_dev_s *dev = (struct uart_dev_s *)arg;
struct up_dev_s *priv;
volatile uint32_t cause;
- if (g_irdapriv.irq == irq)
- {
- dev = &g_irdaport;
- }
- else if (g_modempriv.irq == irq)
- {
- dev = &g_modemport;
- }
- else
- {
- PANIC();
- }
+ DEBUGASSERT(dev != NULL && dev->priv != NULL);
priv = (struct up_dev_s *)dev->priv;
cause = up_inserial(priv, UART_ISR_OFFS) & 0x0000003f;
diff --git a/arch/arm/src/c5471/c5471_timerisr.c b/arch/arm/src/c5471/c5471_timerisr.c
index 1720a13bf92179c4b028bd25211a61f39778e71c..3933e5252bb6a106cc6fa181e1318b71e9178b3f 100644
--- a/arch/arm/src/c5471/c5471_timerisr.c
+++ b/arch/arm/src/c5471/c5471_timerisr.c
@@ -82,7 +82,7 @@
*
****************************************************************************/
-static int c5471_timerisr(int irq, uint32_t *regs)
+static int c5471_timerisr(int irq, uint32_t *regs, FAR void *arg)
{
/* Process timer interrupt */
@@ -118,6 +118,6 @@ void arm_timer_initialize(void)
/* Attach and enable the timer interrupt */
- irq_attach(C5471_IRQ_SYSTIMER, (xcpt_t)c5471_timerisr);
+ irq_attach(C5471_IRQ_SYSTIMER, (xcpt_t)c5471_timerisr, NULL);
up_enable_irq(C5471_IRQ_SYSTIMER);
}
diff --git a/arch/arm/src/c5471/c5471_watchdog.c b/arch/arm/src/c5471/c5471_watchdog.c
index d1381f45d46d217e635fe48cfc751bf6a1c2fc65..baa7dd77496224d8fbecbfe9aadad9ffe4406841 100644
--- a/arch/arm/src/c5471/c5471_watchdog.c
+++ b/arch/arm/src/c5471/c5471_watchdog.c
@@ -95,7 +95,7 @@
static inline unsigned int wdt_prescaletoptv(unsigned int prescale);
static int wdt_setusec(uint32_t usec);
-static int wdt_interrupt(int irq, void *context);
+static int wdt_interrupt(int irq, void *context, FAR void *arg);
static int wdt_open(struct file *filep);
static int wdt_close(struct file *filep);
@@ -232,7 +232,7 @@ static int wdt_setusec(uint32_t usec)
* Name: wdt_interrupt
****************************************************************************/
-static int wdt_interrupt(int irq, void *context)
+static int wdt_interrupt(int irq, void *context, FAR void *arg)
{
wdinfo("expired\n");
@@ -382,7 +382,7 @@ int up_wdtinit(void)
/* Request the interrupt. */
- ret = irq_attach(C5471_IRQ_WATCHDOG, wdt_interrupt);
+ ret = irq_attach(C5471_IRQ_WATCHDOG, wdt_interrupt, NULL);
if (ret)
{
unregister_driver("/dev/wdt");
diff --git a/arch/arm/src/common/up_internal.h b/arch/arm/src/common/up_internal.h
index a634c86df6537eb83bbb50ca3d74ef8171239bd9..31d264828d395d72b60661364a0761d40c1d4d7c 100644
--- a/arch/arm/src/common/up_internal.h
+++ b/arch/arm/src/common/up_internal.h
@@ -374,13 +374,13 @@ uint32_t *up_doirq(int irq, uint32_t *regs);
/* Exception Handlers */
-int up_svcall(int irq, FAR void *context);
-int up_hardfault(int irq, FAR void *context);
+int up_svcall(int irq, FAR void *context, FAR void *arg);
+int up_hardfault(int irq, FAR void *context, FAR void *arg);
# if defined(CONFIG_ARCH_CORTEXM3) || defined(CONFIG_ARCH_CORTEXM4) || \
defined(CONFIG_ARCH_CORTEXM7)
-int up_memfault(int irq, FAR void *context);
+int up_memfault(int irq, FAR void *context, FAR void *arg);
# endif /* CONFIG_ARCH_CORTEXM3,4,7 */
diff --git a/arch/arm/src/dm320/dm320_serial.c b/arch/arm/src/dm320/dm320_serial.c
index 19e5c9d7bdf2d319a1a9130c82d7eede212a4f01..964e8923f07ca6f696a1fda4de2491fdf22d9a68 100644
--- a/arch/arm/src/dm320/dm320_serial.c
+++ b/arch/arm/src/dm320/dm320_serial.c
@@ -1,8 +1,7 @@
/****************************************************************************
* arch/arm/src/dm320/dm320_serial.c
- * arch/arm/src/chip/dm320_serial.c
*
- * Copyright (C) 2007-2009, 2012-2013 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2009, 2012-2013, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
*
* Redistribution and use in source and binary forms, with or without
@@ -89,7 +88,7 @@ static int up_setup(struct uart_dev_s *dev);
static void up_shutdown(struct uart_dev_s *dev);
static int up_attach(struct uart_dev_s *dev);
static void up_detach(struct uart_dev_s *dev);
-static int up_interrupt(int irq, void *context);
+static int up_interrupt(int irq, void *context, void *arg);
static int up_ioctl(struct file *filep, int cmd, unsigned long arg);
static int up_receive(struct uart_dev_s *dev, uint32_t *status);
static void up_rxint(struct uart_dev_s *dev, bool enable);
@@ -430,7 +429,7 @@ static int up_attach(struct uart_dev_s *dev)
/* Attach and enable the IRQ */
- ret = irq_attach(priv->irq, up_interrupt);
+ ret = irq_attach(priv->irq, up_interrupt, dev);
if (ret == OK)
{
/* Enable the interrupt (RX and TX interrupts are still disabled
@@ -472,25 +471,14 @@ static void up_detach(struct uart_dev_s *dev)
*
****************************************************************************/
-static int up_interrupt(int irq, void *context)
+static int up_interrupt(int irq, void *context, void *arg)
{
- struct uart_dev_s *dev = NULL;
+ struct uart_dev_s *dev = (struct uart_dev_s *)arg;
struct up_dev_s *priv;
uint16_t status;
int passes = 0;
- if (g_uart1priv.irq == irq)
- {
- dev = &g_uart1port;
- }
- else if (g_uart0priv.irq == irq)
- {
- dev = &g_uart0port;
- }
- else
- {
- PANIC();
- }
+ DEBUGASSERT(dev != NULL && dev->priv != NULL);
priv = (struct up_dev_s *)dev->priv;
/* Loop until there are no characters to be transferred or,
diff --git a/arch/arm/src/dm320/dm320_timerisr.c b/arch/arm/src/dm320/dm320_timerisr.c
index 33ed932666c446be6d7348350f3844bd24b7897e..735af0460dad4c15fd3f2d2fe6f1e7f34817c9fc 100644
--- a/arch/arm/src/dm320/dm320_timerisr.c
+++ b/arch/arm/src/dm320/dm320_timerisr.c
@@ -109,7 +109,7 @@
*
****************************************************************************/
-static int dm320_timerisr(int irq, uint32_t *regs)
+static int dm320_timerisr(int irq, uint32_t *regs, FAR void *arg)
{
/* Process timer interrupt */
@@ -147,7 +147,7 @@ void arm_timer_initialize(void)
/* Attach and enable the timer interrupt */
- irq_attach(DM320_IRQ_SYSTIMER, (xcpt_t)dm320_timerisr);
+ irq_attach(DM320_IRQ_SYSTIMER, (xcpt_t)dm320_timerisr, NULL);
up_enable_irq(DM320_IRQ_SYSTIMER);
}
diff --git a/arch/arm/src/dm320/dm320_usbdev.c b/arch/arm/src/dm320/dm320_usbdev.c
index df25123b09ec08ed7062a6572bd1448877386802..18dce86dbf164c93689ae1f9dbd7e57abd3abc99 100644
--- a/arch/arm/src/dm320/dm320_usbdev.c
+++ b/arch/arm/src/dm320/dm320_usbdev.c
@@ -309,8 +309,8 @@ static void dm320_dispatchrequest(struct dm320_usbdev_s *priv,
const struct usb_ctrlreq_s *ctrl);
static inline void dm320_ep0setup(struct dm320_usbdev_s *priv);
static inline uint32_t dm320_highestpriinterrupt(int intstatus);
-static int dm320_ctlrinterrupt(int irq, FAR void *context);
-static int dm320_attachinterrupt(int irq, FAR void *context);
+static int dm320_ctlrinterrupt(int irq, FAR void *context, FAR void *arg);
+static int dm320_attachinterrupt(int irq, FAR void *context, FAR void *arg);
/* Initialization operations */
@@ -1513,7 +1513,7 @@ static inline uint32_t dm320_highestpriinterrupt(int intstatus)
*
****************************************************************************/
-static int dm320_ctlrinterrupt(int irq, FAR void *context)
+static int dm320_ctlrinterrupt(int irq, FAR void *context, FAR void *arg)
{
struct dm320_usbdev_s *priv = &g_usbdev;
struct dm320_ep_s *privep ;
@@ -1680,7 +1680,7 @@ static int dm320_ctlrinterrupt(int irq, FAR void *context)
*
****************************************************************************/
-static int dm320_attachinterrupt(int irq, FAR void *context)
+static int dm320_attachinterrupt(int irq, FAR void *context, FAR void *arg)
{
struct dm320_usbdev_s *priv = &g_usbdev;
uint16_t gio;
@@ -2438,7 +2438,7 @@ void up_usbinitialize(void)
/* Attach host attach GIO interrupt */
- if (irq_attach(IRQ_USBATTACH, dm320_attachinterrupt) != 0)
+ if (irq_attach(IRQ_USBATTACH, dm320_attachinterrupt, NULL) != 0)
{
usbtrace(TRACE_DEVERROR(DM320_TRACEERR_ATTACHIRQREG), 0);
goto errout;
@@ -2448,7 +2448,7 @@ void up_usbinitialize(void)
* enabled when the driver is bound
*/
- if (irq_attach(DM320_IRQ_USB1, dm320_ctlrinterrupt) != 0)
+ if (irq_attach(DM320_IRQ_USB1, dm320_ctlrinterrupt, NULL) != 0)
{
usbtrace(TRACE_DEVERROR(DM320_TRACEERR_COREIRQREG), 0);
goto errout;
diff --git a/arch/arm/src/efm32/efm32_adc.c b/arch/arm/src/efm32/efm32_adc.c
index c9e339e6ea27e8495b2eafddd16892bb0cf14873..e79c2a61ef53b568ffbc67e4557d9e62e2e87f06 100644
--- a/arch/arm/src/efm32/efm32_adc.c
+++ b/arch/arm/src/efm32/efm32_adc.c
@@ -123,7 +123,7 @@ static void adc_hw_reset(struct efm32_dev_s *priv, bool reset);
/* ADC Interrupt Handler */
-static int adc_interrupt(FAR struct adc_dev_s *dev);
+static int adc_interrupt(int irq, FAR void *context, FAR struct adc_dev_s *dev);
/* ADC Driver Methods */
@@ -1072,7 +1072,7 @@ static int adc_setup(FAR struct adc_dev_s *dev)
/* Attach the ADC interrupt */
- ret = irq_attach(priv->irq, priv->isr);
+ ret = irq_attach(priv->irq, priv->isr, dev);
if (ret == OK)
{
/* Make sure that the ADC device is in the powered up, reset state */
@@ -1180,7 +1180,7 @@ static int adc_ioctl(FAR struct adc_dev_s *dev, int cmd, unsigned long arg)
*
****************************************************************************/
-static int adc_interrupt(FAR struct adc_dev_s *dev)
+static int adc_interrupt(int irq, FAR void *context, FAR struct adc_dev_s *dev)
{
FAR struct efm32_dev_s *priv = (FAR struct efm32_dev_s *)dev->ad_priv;
uint32_t adcsr;
diff --git a/arch/arm/src/efm32/efm32_dma.c b/arch/arm/src/efm32/efm32_dma.c
index 4bf901500b604b5498b2f9bdbef98625c4dc0f97..d568626b2958d9718dc0aec45fe5df70461997cf 100644
--- a/arch/arm/src/efm32/efm32_dma.c
+++ b/arch/arm/src/efm32/efm32_dma.c
@@ -204,7 +204,7 @@ efm32_get_descriptor(struct dma_channel_s *dmach, bool alt)
*
****************************************************************************/
-static int efm32_dmac_interrupt(int irq, void *context)
+static int efm32_dmac_interrupt(int irq, void *context, FAR void *arg)
{
struct dma_channel_s *dmach;
unsigned int chndx;
@@ -297,7 +297,7 @@ void weak_function up_dmainitialize(void)
/* Attach DMA interrupt vector */
- (void)irq_attach(EFM32_IRQ_DMA, efm32_dmac_interrupt);
+ (void)irq_attach(EFM32_IRQ_DMA, efm32_dmac_interrupt, NULL);
/* Enable the DMA controller */
diff --git a/arch/arm/src/efm32/efm32_gpioirq.c b/arch/arm/src/efm32/efm32_gpioirq.c
index 8c3527e9f55d2cfcaac2b6c4cbcd3108a898292e..1b317582811bda574e17982282ae53998d34831e 100644
--- a/arch/arm/src/efm32/efm32_gpioirq.c
+++ b/arch/arm/src/efm32/efm32_gpioirq.c
@@ -133,7 +133,7 @@ static int efm32_gpio_interrupt(uint32_t mask, void *context)
*
************************************************************************************/
-static int efm32_even_interrupt(int irq, void *context)
+static int efm32_even_interrupt(int irq, void *context, FAR void *arg)
{
return efm32_gpio_interrupt(0x00005555, context);
}
@@ -146,7 +146,7 @@ static int efm32_even_interrupt(int irq, void *context)
*
************************************************************************************/
-static int efm32_odd_interrupt(int irq, void *context)
+static int efm32_odd_interrupt(int irq, void *context, FAR void *arg)
{
return efm32_gpio_interrupt(0x0000aaaa, context);
}
@@ -173,8 +173,8 @@ void efm32_gpioirqinitialize(void)
/* Attach the even and odd interrupt handlers */
- DEBUGVERIFY(irq_attach(EFM32_IRQ_GPIO_EVEN, efm32_even_interrupt));
- DEBUGVERIFY(irq_attach(EFM32_IRQ_GPIO_ODD, efm32_odd_interrupt));
+ DEBUGVERIFY(irq_attach(EFM32_IRQ_GPIO_EVEN, efm32_even_interrupt, NULL));
+ DEBUGVERIFY(irq_attach(EFM32_IRQ_GPIO_ODD, efm32_odd_interrupt, NULL));
/* Enable GPIO even and odd interrupts at the NVIC */
diff --git a/arch/arm/src/efm32/efm32_i2c.c b/arch/arm/src/efm32/efm32_i2c.c
index 1c10e5b14c151ef42d11fa4f952a40d481a2ffee..59ad3aa2f840ac2ba12c71d2eead750b54b06472 100644
--- a/arch/arm/src/efm32/efm32_i2c.c
+++ b/arch/arm/src/efm32/efm32_i2c.c
@@ -220,7 +220,7 @@ struct efm32_i2c_config_s
uint32_t scl_pin; /* GPIO configuration for SCL as SCL */
uint32_t sda_pin; /* GPIO configuration for SDA as SDA */
#ifndef CONFIG_I2C_POLLED
- int (*isr) (int, void *); /* Interrupt handler */
+ int (*isr) (int, void *, void *); /* Interrupt handler */
uint32_t irq; /* Event IRQ */
#endif
};
@@ -298,10 +298,10 @@ static int efm32_i2c_isr(struct efm32_i2c_priv_s *priv);
#ifndef CONFIG_I2C_POLLED
#ifdef CONFIG_EFM32_I2C0
-static int efm32_i2c0_isr(int irq, void *context);
+static int efm32_i2c0_isr(int irq, void *context, FAR void *arg);
#endif
#ifdef CONFIG_EFM32_I2C1
-static int efm32_i2c1_isr(int irq, void *context);
+static int efm32_i2c1_isr(int irq, void *context, FAR void *arg);
#endif
#endif /* !CONFIG_I2C_POLLED */
@@ -1290,7 +1290,7 @@ done:
****************************************************************************/
#ifdef CONFIG_EFM32_I2C0
-static int efm32_i2c0_isr(int irq, void *context)
+static int efm32_i2c0_isr(int irq, void *context, FAR void *arg)
{
return efm32_i2c_isr(&efm32_i2c0_priv);
}
@@ -1305,7 +1305,7 @@ static int efm32_i2c0_isr(int irq, void *context)
****************************************************************************/
#ifdef CONFIG_EFM32_I2C1
-static int efm32_i2c1_isr(int irq, void *context)
+static int efm32_i2c1_isr(int irq, void *context, FAR void *arg)
{
return efm32_i2c_isr(&efm32_i2c1_priv);
}
@@ -1389,7 +1389,7 @@ static int efm32_i2c_init(FAR struct efm32_i2c_priv_s *priv)
/* Attach ISRs */
#ifndef CONFIG_I2C_POLLED
- irq_attach(priv->config->irq, priv->config->isr);
+ irq_attach(priv->config->irq, priv->config->isr, NULL);
up_enable_irq(priv->config->irq);
#endif
diff --git a/arch/arm/src/efm32/efm32_irq.c b/arch/arm/src/efm32/efm32_irq.c
index db5992dea7b57f620fbbfb75c7e815a2a947db12..859860d0725bf907f686a8acdb76956f029f6672 100644
--- a/arch/arm/src/efm32/efm32_irq.c
+++ b/arch/arm/src/efm32/efm32_irq.c
@@ -163,7 +163,7 @@ static void efm32_dumpnvic(const char *msg, int irq)
****************************************************************************/
#ifdef CONFIG_DEBUG_FEATURES
-static int efm32_nmi(int irq, FAR void *context)
+static int efm32_nmi(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! NMI received\n");
@@ -171,7 +171,7 @@ static int efm32_nmi(int irq, FAR void *context)
return 0;
}
-static int efm32_busfault(int irq, FAR void *context)
+static int efm32_busfault(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Bus fault received: %08x\n", getreg32(NVIC_CFAULTS));
@@ -179,7 +179,7 @@ static int efm32_busfault(int irq, FAR void *context)
return 0;
}
-static int efm32_usagefault(int irq, FAR void *context)
+static int efm32_usagefault(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Usage fault received: %08x\n", getreg32(NVIC_CFAULTS));
@@ -187,7 +187,7 @@ static int efm32_usagefault(int irq, FAR void *context)
return 0;
}
-static int efm32_pendsv(int irq, FAR void *context)
+static int efm32_pendsv(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! PendSV received\n");
@@ -195,7 +195,7 @@ static int efm32_pendsv(int irq, FAR void *context)
return 0;
}
-static int efm32_dbgmonitor(int irq, FAR void *context)
+static int efm32_dbgmonitor(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Debug Monitor received\n");
@@ -203,7 +203,7 @@ static int efm32_dbgmonitor(int irq, FAR void *context)
return 0;
}
-static int efm32_reserved(int irq, FAR void *context)
+static int efm32_reserved(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Reserved interrupt\n");
@@ -382,8 +382,8 @@ void up_irqinitialize(void)
* under certain conditions.
*/
- irq_attach(EFM32_IRQ_SVCALL, up_svcall);
- irq_attach(EFM32_IRQ_HARDFAULT, up_hardfault);
+ irq_attach(EFM32_IRQ_SVCALL, up_svcall, NULL);
+ irq_attach(EFM32_IRQ_HARDFAULT, up_hardfault, NULL);
/* Set the priority of the SVCall interrupt */
@@ -396,22 +396,22 @@ void up_irqinitialize(void)
*/
#ifdef CONFIG_ARM_MPU
- irq_attach(EFM32_IRQ_MEMFAULT, up_memfault);
+ irq_attach(EFM32_IRQ_MEMFAULT, up_memfault, NULL);
up_enable_irq(EFM32_IRQ_MEMFAULT);
#endif
/* Attach all other processor exceptions (except reset and sys tick) */
#ifdef CONFIG_DEBUG_FEATURES
- irq_attach(EFM32_IRQ_NMI, efm32_nmi);
+ irq_attach(EFM32_IRQ_NMI, efm32_nmi, NULL);
#ifndef CONFIG_ARM_MPU
- irq_attach(EFM32_IRQ_MEMFAULT, up_memfault);
+ irq_attach(EFM32_IRQ_MEMFAULT, up_memfault, NULL);
#endif
- irq_attach(EFM32_IRQ_BUSFAULT, efm32_busfault);
- irq_attach(EFM32_IRQ_USAGEFAULT, efm32_usagefault);
- irq_attach(EFM32_IRQ_PENDSV, efm32_pendsv);
- irq_attach(EFM32_IRQ_DBGMONITOR, efm32_dbgmonitor);
- irq_attach(EFM32_IRQ_RESERVED, efm32_reserved);
+ irq_attach(EFM32_IRQ_BUSFAULT, efm32_busfault, NULL);
+ irq_attach(EFM32_IRQ_USAGEFAULT, efm32_usagefault, NULL);
+ irq_attach(EFM32_IRQ_PENDSV, efm32_pendsv, NULL);
+ irq_attach(EFM32_IRQ_DBGMONITOR, efm32_dbgmonitor, NULL);
+ irq_attach(EFM32_IRQ_RESERVED, efm32_reserved, NULL);
#endif
efm32_dumpnvic("initial", NR_VECTORS);
diff --git a/arch/arm/src/efm32/efm32_leserial.c b/arch/arm/src/efm32/efm32_leserial.c
index 8a5de9378880d1ccffa5f89d037a6b1165536a9f..de8d157c8ab54a1d36c2f4563806684af7de6acb 100644
--- a/arch/arm/src/efm32/efm32_leserial.c
+++ b/arch/arm/src/efm32/efm32_leserial.c
@@ -134,7 +134,6 @@
struct efm32_config_s
{
uintptr_t uartbase; /* Base address of UART registers */
- xcpt_t handler; /* Interrupt handler */
uint32_t baud; /* Configured baud */
uint8_t irq; /* IRQ associated with this LEUART (for enable) */
uint8_t parity; /* 0=none, 1=odd, 2=even */
@@ -163,13 +162,7 @@ static int efm32_setup(struct uart_dev_s *dev);
static void efm32_shutdown(struct uart_dev_s *dev);
static int efm32_attach(struct uart_dev_s *dev);
static void efm32_detach(struct uart_dev_s *dev);
-static int efm32_interrupt(struct uart_dev_s *dev);
-#if defined(CONFIG_EFM32_LEUART0)
-static int efm32_leuart0_interrupt(int irq, void *context);
-#endif
-#if defined(CONFIG_EFM32_LEUART1)
-static int efm32_leuart1_interrupt(int irq, void *context);
-#endif
+static int efm32_interrupt(int irq, void *context, FAR void *arg);
static int efm32_ioctl(struct file *filep, int cmd, unsigned long arg);
static int efm32_receive(struct uart_dev_s *dev, uint32_t *status);
static void efm32_rxint(struct uart_dev_s *dev, bool enable);
@@ -219,7 +212,6 @@ static char g_leuart1txbuffer[CONFIG_LEUART1_TXBUFSIZE];
static const struct efm32_config_s g_leuart0config =
{
.uartbase = EFM32_LEUART0_BASE,
- .handler = efm32_leuart0_interrupt,
.baud = CONFIG_LEUART0_BAUD,
.irq = EFM32_IRQ_LEUART0,
.parity = CONFIG_LEUART0_PARITY,
@@ -255,7 +247,6 @@ static struct uart_dev_s g_leuart0port =
static struct efm32_config_s g_leuart1config =
{
.uartbase = EFM32_LEUART1_BASE,
- .handler = efm32_leuart1_interrupt,
.baud = CONFIG_LEUART1_BAUD,
.irq = EFM32_IRQ_LEUART1,
.parity = CONFIG_LEUART1_PARITY,
@@ -429,7 +420,7 @@ static int efm32_attach(struct uart_dev_s *dev)
* disabled in the C2 register.
*/
- ret = irq_attach(config->irq, config->handler);
+ ret = irq_attach(config->irq, efm32_interrupt, dev);
if (ret >= 0)
{
up_enable_irq(config->irq);
@@ -471,12 +462,14 @@ static void efm32_detach(struct uart_dev_s *dev)
*
****************************************************************************/
-static int efm32_interrupt(struct uart_dev_s *dev)
+static int efm32_interrupt(int irq, void *context, FAR void *arg)
{
- struct efm32_leuart_s *priv = (struct efm32_leuart_s *)dev->priv;
+ struct uart_dev_s *dev = (struct uart_dev_s *)arg;
+ struct efm32_leuart_s *priv;
uint32_t intflags;
- DEBUGASSERT(priv);
+ DEBUGASSERT(dev != NULL && dev->priv != NULL);
+ priv = (struct efm32_leuart_s *)dev->priv;
/* Read the interrupt flags register */
@@ -534,20 +527,6 @@ static int efm32_interrupt(struct uart_dev_s *dev)
return OK;
}
-#if defined(CONFIG_EFM32_LEUART0)
-static int efm32_leuart0_interrupt(int irq, void *context)
-{
- return efm32_interrupt(&g_leuart0port);
-}
-#endif
-
-#if defined(CONFIG_EFM32_LEUART1)
-static int efm32_leuart1_interrupt(int irq, void *context)
-{
- return efm32_interrupt(&g_leuart1port);
-}
-#endif
-
/****************************************************************************
* Name: efm32_ioctl
*
diff --git a/arch/arm/src/efm32/efm32_pwm.c b/arch/arm/src/efm32/efm32_pwm.c
index f07a3eed4b78794bde0766a296ffda896238edf5..180fe04e00c15cdffc145c72f20847faca43aa30 100644
--- a/arch/arm/src/efm32/efm32_pwm.c
+++ b/arch/arm/src/efm32/efm32_pwm.c
@@ -133,19 +133,7 @@ static int pwm_timer(FAR struct efm32_pwmtimer_s *priv,
defined(CONFIG_EFM32_TIMER2_PWM) || \
defined(CONFIG_EFM32_TIMER3_PWM) \
)
-static int pwm_interrupt(struct efm32_pwmtimer_s *priv);
-#if defined(CONFIG_EFM32_TIMER0_PWM)
-static int pwm_timer0_interrupt(int irq, void *context);
-#endif
-#if defined(CONFIG_EFM32_TIMER1_PWM)
-static int pwm_timer1_interrupt(int irq, void *context);
-#endif
-#if defined(CONFIG_EFM32_TIMER2_PWM)
-static int pwm_timer2_interrupt(int irq, void *context);
-#endif
-#if defined(CONFIG_EFM32_TIMER3_PWM)
-static int pwm_timer3_interrupt(int irq, void *context);
-#endif
+static int pwm_interrupt(int irq, void *context, FAR void *arg);
static uint8_t pwm_pulsecount(uint32_t count);
#endif
@@ -446,7 +434,7 @@ static int pwm_timer(FAR struct efm32_pwmtimer_s *priv,
* Handle timer interrupts.
*
* Input parameters:
- * priv - A reference to the lower half PWM driver state structure
+ * Standard interrupt handler arguments.
*
* Returned Value:
* Zero on success; a negated errno value on failure
@@ -459,12 +447,15 @@ static int pwm_timer(FAR struct efm32_pwmtimer_s *priv,
defined(CONFIG_EFM32_TIMER3_PWM) \
)
#warning "not yet implemented"
-static int pwm_interrupt(struct efm32_pwmtimer_s *priv)
+static int pwm_interrupt(int irq, void *context, FAR void *arg)
{
/* TODO pwm_interrupt */
#if 0
+ struct efm32_pwmtimer_s *priv = (struct efm32_pwmtimer_s *)arg;
uint32_t regval;
+ DEBUGASSERT(priv != NULL);
+
/* Verify that this is an update interrupt. Nothing else is expected. */
regval = pwm_getreg(priv, STM32_ATIM_SR_OFFSET);
@@ -532,48 +523,6 @@ static int pwm_interrupt(struct efm32_pwmtimer_s *priv)
}
#endif
-/****************************************************************************
- * Name: pwm_timer1/3_interrupt
- *
- * Description:
- * Handle timer 1..3 interrupts.
- *
- * Input parameters:
- * Standard NuttX interrupt inputs
- *
- * Returned Value:
- * Zero on success; a negated errno value on failure
- *
- ****************************************************************************/
-
-#if defined(CONFIG_PWM_PULSECOUNT) && defined(CONFIG_EFM32_TIMER0_PWM)
-static int pwm_timer0_interrupt(int irq, void *context)
-{
- return pwm_interrupt(&g_pwm0dev);
-}
-#endif
-
-#if defined(CONFIG_PWM_PULSECOUNT) && defined(CONFIG_EFM32_TIMER1_PWM)
-static int pwm_timer1_interrupt(int irq, void *context)
-{
- return pwm_interrupt(&g_pwm1dev);
-}
-#endif
-
-#if defined(CONFIG_PWM_PULSECOUNT) && defined(CONFIG_EFM32_TIMER2_PWM)
-static int pwm_timer2_interrupt(int irq, void *context)
-{
- return pwm_interrupt(&g_pwm2dev);
-}
-#endif
-
-#if defined(CONFIG_PWM_PULSECOUNT) && defined(CONFIG_EFM32_TIMER3_PWM)
-static int pwm_timer3_interrupt(int irq, void *context)
-{
- return pwm_interrupt(&g_pwm3dev);
-}
-#endif
-
/****************************************************************************
* Name: pwm_pulsecount
*
@@ -866,50 +815,22 @@ FAR struct pwm_lowerhalf_s *efm32_pwminitialize(int timer)
#ifdef CONFIG_EFM32_TIMER0_PWM
case 0:
lower = &g_pwm0dev;
-
- /* Attach but disable the TIM1 update interrupt */
-
-#ifdef CONFIG_PWM_PULSECOUNT
- irq_attach(lower->irq, pwm_timer0_interrupt);
- up_disable_irq(lower->irq);
-#endif
break;
#endif
#ifdef CONFIG_EFM32_TIMER1_PWM
case 1:
lower = &g_pwm1dev;
-
- /* Attach but disable the TIM1 update interrupt */
-
-#ifdef CONFIG_PWM_PULSECOUNT
- irq_attach(lower->irq, pwm_timer0_interrupt);
- up_disable_irq(lower->irq);
-#endif
break;
#endif
#ifdef CONFIG_EFM32_TIMER2_PWM
case 2:
lower = &g_pwm2dev;
-
- /* Attach but disable the TIM1 update interrupt */
-
-#ifdef CONFIG_PWM_PULSECOUNT
- irq_attach(lower->irq, pwm_timer2_interrupt);
- up_disable_irq(lower->irq);
-#endif
break;
#endif
#ifdef CONFIG_EFM32_TIMER3_PWM
case 3:
lower = &g_pwm3dev;
-
- /* Attach but disable the TIM1 update interrupt */
-
-#ifdef CONFIG_PWM_PULSECOUNT
- irq_attach(lower->irq, pwm_timer3_interrupt);
- up_disable_irq(lower->irq);
-#endif
break;
#endif
@@ -918,6 +839,13 @@ FAR struct pwm_lowerhalf_s *efm32_pwminitialize(int timer)
return NULL;
}
+ /* Attach but disable the timer update interrupt */
+
+#ifdef CONFIG_PWM_PULSECOUNT
+ irq_attach(lower->irq, pwm_interrupt, lower);
+ up_disable_irq(lower->irq);
+#endif
+
return (FAR struct pwm_lowerhalf_s *)lower;
}
diff --git a/arch/arm/src/efm32/efm32_rtc_burtc.c b/arch/arm/src/efm32/efm32_rtc_burtc.c
index 52c8811ae50b1dd0ac3a07015339380e4d1a8f26..d0028b6a11f73e3d3499c23e40d4087e7b63cfe7 100644
--- a/arch/arm/src/efm32/efm32_rtc_burtc.c
+++ b/arch/arm/src/efm32/efm32_rtc_burtc.c
@@ -175,7 +175,7 @@ volatile bool g_rtc_enabled = false;
*
************************************************************************************/
-static int efm32_rtc_burtc_interrupt(int irq, void *context)
+static int efm32_rtc_burtc_interrupt(int irq, void *context, FAR void *arg)
{
uint32_t source = getreg32(EFM32_BURTC_IF);
@@ -378,7 +378,7 @@ int up_rtc_initialize(void)
/* Configure RTC interrupt to catch overflow and alarm interrupts. */
- irq_attach(EFM32_IRQ_BURTC, efm32_rtc_burtc_interrupt);
+ irq_attach(EFM32_IRQ_BURTC, efm32_rtc_burtc_interrupt, NULL);
up_enable_irq(EFM32_IRQ_BURTC);
g_rtc_enabled = true;
diff --git a/arch/arm/src/efm32/efm32_serial.c b/arch/arm/src/efm32/efm32_serial.c
index 52848fcd03d67af9589a519370860a9f4ed18dda..a13bfe4d588e83060639af5feec52905dcd13ad6 100644
--- a/arch/arm/src/efm32/efm32_serial.c
+++ b/arch/arm/src/efm32/efm32_serial.c
@@ -220,8 +220,6 @@
struct efm32_config_s
{
uintptr_t uartbase; /* Base address of UART registers */
- xcpt_t rxhandler; /* RX interrupt handler */
- xcpt_t txhandler; /* TX interrupt handler */
uint32_t baud; /* Configured baud */
uint8_t rxirq; /* RX IRQ associated with this UART (for enable) */
uint8_t txirq; /* TX IRQ associated with this UART (for enable) */
@@ -257,38 +255,8 @@ static int efm32_setup(struct uart_dev_s *dev);
static void efm32_shutdown(struct uart_dev_s *dev);
static int efm32_attach(struct uart_dev_s *dev);
static void efm32_detach(struct uart_dev_s *dev);
-static int efm32_rxinterrupt(struct uart_dev_s *dev);
-#if defined(CONFIG_EFM32_USART0_ISUART)
-static int efm32_usart0_rxinterrupt(int irq, void *context);
-#endif
-#if defined(CONFIG_EFM32_USART1_ISUART)
-static int efm32_usart1_rxinterrupt(int irq, void *context);
-#endif
-#if defined(CONFIG_EFM32_USART2_ISUART)
-static int efm32_usart2_rxinterrupt(int irq, void *context);
-#endif
-#if defined(CONFIG_EFM32_UART0)
-static int efm32_uart0_rxinterrupt(int irq, void *context);
-#endif
-#if defined(CONFIG_EFM32_UART1)
-static int efm32_uart1_rxinterrupt(int irq, void *context);
-#endif
-static int efm32_txinterrupt(struct uart_dev_s *dev);
-#if defined(CONFIG_EFM32_USART0_ISUART)
-static int efm32_usart0_txinterrupt(int irq, void *context);
-#endif
-#if defined(CONFIG_EFM32_USART1_ISUART)
-static int efm32_usart1_txinterrupt(int irq, void *context);
-#endif
-#if defined(CONFIG_EFM32_USART2_ISUART)
-static int efm32_usart2_txinterrupt(int irq, void *context);
-#endif
-#if defined(CONFIG_EFM32_UART0)
-static int efm32_uart0_txinterrupt(int irq, void *context);
-#endif
-#if defined(CONFIG_EFM32_UART1)
-static int efm32_uart1_txinterrupt(int irq, void *context);
-#endif
+static int efm32_rxinterrupt(int irq, void *context, void *arg);
+static int efm32_txinterrupt((int irq, void *context, void *arg);
static int efm32_ioctl(struct file *filep, int cmd, unsigned long arg);
static int efm32_receive(struct uart_dev_s *dev, uint32_t *status);
static void efm32_rxint(struct uart_dev_s *dev, bool enable);
@@ -350,8 +318,6 @@ static char g_uart1txbuffer[CONFIG_UART1_TXBUFSIZE];
static const struct efm32_usart_s g_usart0config =
{
.uartbase = EFM32_USART0_BASE,
- .rxhandler = efm32_usart0_rxinterrupt,
- .txhandler = efm32_usart0_txinterrupt,
.baud = CONFIG_USART0_BAUD,
.rxirq = EFM32_IRQ_USART0_RX,
.txirq = EFM32_IRQ_USART0_TX,
@@ -388,8 +354,6 @@ static struct uart_dev_s g_usart0port =
static struct efm32_config_s g_usart1config =
{
.uartbase = EFM32_USART1_BASE,
- .rxhandler = efm32_usart1_rxinterrupt,
- .txhandler = efm32_usart1_txinterrupt,
.baud = CONFIG_USART1_BAUD,
.rxirq = EFM32_IRQ_USART1_RX,
.txirq = EFM32_IRQ_USART1_TX,
@@ -426,8 +390,6 @@ static struct uart_dev_s g_usart1port =
static struct efm32_config_s g_usart2config =
{
.uartbase = EFM32_USART2_BASE,
- .rxhandler = efm32_usart2_rxinterrupt,
- .txhandler = efm32_usart2_txinterrupt,
.baud = CONFIG_USART2_BAUD,
.rxirq = EFM32_IRQ_USART2_RX,
.txirq = EFM32_IRQ_USART2_TX,
@@ -464,8 +426,6 @@ static struct uart_dev_s g_usart2port =
static struct efm32_config_s g_uart0config =
{
.uartbase = EFM32_UART0_BASE,
- .rxhandler = efm32_uart0_rxinterrupt,
- .txhandler = efm32_uart0_txinterrupt,
.baud = CONFIG_UART0_BAUD,
.rxirq = EFM32_IRQ_UART0_RX,
.txirq = EFM32_IRQ_UART0_TX,
@@ -502,8 +462,6 @@ static struct uart_dev_s g_uart0port =
static struct efm32_usart_s g_uart1config =
{
.uartbase = EFM32_UART1_BASE,
- .rxhandler = efm32_uart1_rxinterrupt,
- .txhandler = efm32_uart1_txinterrupt,
.baud = CONFIG_UART1_BAUD,
.rxirq = EFM32_IRQ_UART1_RX,
.txirq = EFM32_IRQ_UART1_TX,
@@ -689,13 +647,13 @@ static int efm32_attach(struct uart_dev_s *dev)
* disabled in the C2 register.
*/
- ret = irq_attach(config->rxirq, config->rxhandler);
+ ret = irq_attach(config->rxirq, efm32_rxinterrupt, dev);
if (ret < 0)
{
return ret;
}
- ret = irq_attach(config->txirq, config->txhandler);
+ ret = irq_attach(config->txirq, efm32_txinterrupt, dev);
if (ret < 0)
{
irq_detach(config->rxirq);
@@ -742,12 +700,14 @@ static void efm32_detach(struct uart_dev_s *dev)
*
****************************************************************************/
-static int efm32_rxinterrupt(struct uart_dev_s *dev)
+static int efm32_rxinterrupt(int irq, void *context, void *arg)
{
- struct efm32_usart_s *priv = (struct efm32_usart_s *)dev->priv;
+ struct uart_dev_s *dev = (struct uart_dev_s *)arg;
+ struct efm32_usart_s *priv;
uint32_t intflags;
- DEBUGASSERT(priv);
+ DEBUGASSERT(dev != NULL && dev->priv != NULL);
+ priv = (struct efm32_usart_s *)dev->priv;
/* Read the interrupt flags register */
@@ -787,41 +747,6 @@ static int efm32_rxinterrupt(struct uart_dev_s *dev)
return OK;
}
-#if defined(CONFIG_EFM32_USART0_ISUART)
-static int efm32_usart0_rxinterrupt(int irq, void *context)
-{
- return efm32_rxinterrupt(&g_usart0port);
-}
-#endif
-
-#if defined(CONFIG_EFM32_USART1_ISUART)
-static int efm32_usart1_rxinterrupt(int irq, void *context)
-{
- return efm32_rxinterrupt(&g_usart1port);
-}
-#endif
-
-#if defined(CONFIG_EFM32_USART2_ISUART)
-static int efm32_usart2_rxinterrupt(int irq, void *context)
-{
- return efm32_rxinterrupt(&g_usart2port);
-}
-#endif
-
-#if defined(CONFIG_EFM32_UART0)
-static int efm32_uart0_rxinterrupt(int irq, void *context)
-{
- return efm32_rxinterrupt(&g_uart0port);
-}
-#endif
-
-#if defined(CONFIG_EFM32_UART1)
-static int efm32_uart1_rxinterrupt(int irq, void *context)
-{
- return efm32_rxinterrupt(&g_uart1port);
-}
-#endif
-
/****************************************************************************
* Name: efm32_txinterrupt
*
@@ -830,12 +755,14 @@ static int efm32_uart1_rxinterrupt(int irq, void *context)
*
****************************************************************************/
-static int efm32_txinterrupt(struct uart_dev_s *dev)
+static int efm32_txinterrupt((int irq, void *context, void *arg)
{
- struct efm32_usart_s *priv = (struct efm32_usart_s *)dev->priv;
+ struct uart_dev_s *dev = (struct uart_dev_s *)arg;
+ struct efm32_usart_s *priv;
uint32_t intflags;
- DEBUGASSERT(priv);
+ DEBUGASSERT(dev != NULL && dev->priv != NULL);
+ priv = (struct efm32_usart_s *)dev->priv;
/* Read the interrupt flags register */
@@ -870,41 +797,6 @@ static int efm32_txinterrupt(struct uart_dev_s *dev)
return OK;
}
-#if defined(CONFIG_EFM32_USART0_ISUART)
-static int efm32_usart0_txinterrupt(int irq, void *context)
-{
- return efm32_txinterrupt(&g_usart0port);
-}
-#endif
-
-#if defined(CONFIG_EFM32_USART1_ISUART)
-static int efm32_usart1_txinterrupt(int irq, void *context)
-{
- return efm32_txinterrupt(&g_usart1port);
-}
-#endif
-
-#if defined(CONFIG_EFM32_USART2_ISUART)
-static int efm32_usart2_txinterrupt(int irq, void *context)
-{
- return efm32_txinterrupt(&g_usart2port);
-}
-#endif
-
-#if defined(CONFIG_EFM32_UART0)
-static int efm32_uart0_txinterrupt(int irq, void *context)
-{
- return efm32_txinterrupt(&g_uart0port);
-}
-#endif
-
-#if defined(CONFIG_EFM32_UART1)
-static int efm32_uart1_txinterrupt(int irq, void *context)
-{
- return efm32_txinterrupt(&g_uart1port);
-}
-#endif
-
/****************************************************************************
* Name: efm32_ioctl
*
diff --git a/arch/arm/src/efm32/efm32_timerisr.c b/arch/arm/src/efm32/efm32_timerisr.c
index 095143482b798b5ca2a121567c031d8d158c1f1e..2fdd5a6661fb00605ea4970e0e33cb57b0d7a8cf 100644
--- a/arch/arm/src/efm32/efm32_timerisr.c
+++ b/arch/arm/src/efm32/efm32_timerisr.c
@@ -86,7 +86,7 @@
*
****************************************************************************/
-static int efm32_timerisr(int irq, uint32_t *regs)
+static int efm32_timerisr(int irq, uint32_t *regs, FAR void *arg)
{
/* Process timer interrupt */
@@ -125,7 +125,7 @@ void arm_timer_initialize(void)
/* Attach the timer interrupt vector */
- (void)irq_attach(EFM32_IRQ_SYSTICK, (xcpt_t)efm32_timerisr);
+ (void)irq_attach(EFM32_IRQ_SYSTICK, (xcpt_t)efm32_timerisr, NULL);
/* Enable SysTick interrupts */
diff --git a/arch/arm/src/efm32/efm32_usbdev.c b/arch/arm/src/efm32/efm32_usbdev.c
index 26753dd3ff4d64965a3cf95552148658e8c10c83..8f598342806bbe3208d25836d231cb3a5b3d3ee2 100644
--- a/arch/arm/src/efm32/efm32_usbdev.c
+++ b/arch/arm/src/efm32/efm32_usbdev.c
@@ -574,7 +574,7 @@ static inline void efm32_otginterrupt(FAR struct efm32_usbdev_s *priv);
/* First level interrupt processing */
-static int efm32_usbinterrupt(int irq, FAR void *context);
+static int efm32_usbinterrupt(int irq, FAR void *context, FAR void *arg);
/* Endpoint operations *********************************************************/
/* Global OUT NAK controls */
@@ -3498,7 +3498,7 @@ static inline void efm32_otginterrupt(FAR struct efm32_usbdev_s *priv)
*
****************************************************************************/
-static int efm32_usbinterrupt(int irq, FAR void *context)
+static int efm32_usbinterrupt(int irq, FAR void *context, FAR void *arg)
{
/* At present, there is only a single OTG FS device support. Hence it is
* pre-allocated as g_otgfsdev. However, in most code, the private data
@@ -5485,7 +5485,7 @@ void up_usbinitialize(void)
/* Attach the OTG FS interrupt handler */
- ret = irq_attach(EFM32_IRQ_USB, efm32_usbinterrupt);
+ ret = irq_attach(EFM32_IRQ_USB, efm32_usbinterrupt, NULL);
if (ret < 0)
{
uerr("ERROR: irq_attach failed\n", ret);
diff --git a/arch/arm/src/efm32/efm32_usbhost.c b/arch/arm/src/efm32/efm32_usbhost.c
index be9bbccf23fe10af9a40d80f3cb5466981424aed..3d5a6888baa5714910b3f13233b14c349693628a 100644
--- a/arch/arm/src/efm32/efm32_usbhost.c
+++ b/arch/arm/src/efm32/efm32_usbhost.c
@@ -417,7 +417,7 @@ static inline void efm32_gint_ipxfrisr(FAR struct efm32_usbhost_s *priv);
/* First level, global interrupt handler */
-static int efm32_gint_isr(int irq, FAR void *context);
+static int efm32_gint_isr(int irq, FAR void *context, FAR void *arg);
/* Interrupt controls */
@@ -3495,7 +3495,7 @@ static inline void efm32_gint_ipxfrisr(FAR struct efm32_usbhost_s *priv)
*
****************************************************************************/
-static int efm32_gint_isr(int irq, FAR void *context)
+static int efm32_gint_isr(int irq, FAR void *context, FAR void *arg)
{
/* At present, there is only support for a single OTG FS host. Hence it is
* pre-allocated as g_usbhost. However, in most code, the private data
@@ -5374,7 +5374,7 @@ FAR struct usbhost_connection_s *efm32_usbhost_initialize(int controller)
/* Attach USB host controller interrupt handler */
- if (irq_attach(EFM32_IRQ_USB, efm32_gint_isr) != 0)
+ if (irq_attach(EFM32_IRQ_USB, efm32_gint_isr, NULL) != 0)
{
usbhost_trace1(USBHOST_TRACE1_IRQATTACH, 0);
return NULL;
diff --git a/arch/arm/src/imx1/imx_serial.c b/arch/arm/src/imx1/imx_serial.c
index e3826192b22433a46464f3b70086c537a682af32..ebe996e81b4794b9c38fcd41a64eefaacdc208c4 100644
--- a/arch/arm/src/imx1/imx_serial.c
+++ b/arch/arm/src/imx1/imx_serial.c
@@ -112,7 +112,7 @@ static void up_shutdown(struct uart_dev_s *dev);
static int up_attach(struct uart_dev_s *dev);
static void up_detach(struct uart_dev_s *dev);
static inline struct uart_dev_s *up_mapirq(int irq);
-static int up_interrupt(int irq, void *context);
+static int up_interrupt(int irq, void *context, FAR void *arg);
static int up_ioctl(struct file *filep, int cmd, unsigned long arg);
static int up_receive(struct uart_dev_s *dev, uint32_t *status);
static void up_rxint(struct uart_dev_s *dev, bool enable);
@@ -753,13 +753,13 @@ static int up_attach(struct uart_dev_s *dev)
/* Attach and enable the IRQ */
#if defined(CONFIG_ARCH_CHIP_IMX1) || defined(CONFIG_ARCH_CHIP_IMXL)
- ret = irq_attach(priv->rxirq, up_interrupt);
+ ret = irq_attach(priv->rxirq, up_interrupt, NULL);
if (ret < 0)
{
return ret;
}
- ret = irq_attach(priv->txirq, up_interrupt);
+ ret = irq_attach(priv->txirq, up_interrupt, NULL);
if (ret < 0)
{
irq_detach(priv->rxirq);
@@ -772,7 +772,7 @@ static int up_attach(struct uart_dev_s *dev)
up_enable_irq(priv->txirq);
#else
- ret = irq_attach(priv->irq, up_interrupt);
+ ret = irq_attach(priv->irq, up_interrupt, NULL);
if (ret == OK)
{
/* Enable the interrupt (RX and TX interrupts are still disabled
@@ -877,7 +877,7 @@ static inline struct uart_dev_s *up_mapirq(int irq)
*
****************************************************************************/
-static int up_interrupt(int irq, void *context)
+static int up_interrupt(int irq, void *context, FAR void *arg)
{
struct uart_dev_s *dev;
struct up_dev_s *priv;
diff --git a/arch/arm/src/imx1/imx_spi.c b/arch/arm/src/imx1/imx_spi.c
index d63c65ed2ea1edfd62e17b151ba1f85b6aafc118..695d6b358f8ca3feb64a2a62646042196c68bcd6 100644
--- a/arch/arm/src/imx1/imx_spi.c
+++ b/arch/arm/src/imx1/imx_spi.c
@@ -165,7 +165,7 @@ static int spi_transfer(struct imx_spidev_s *priv, const void *txbuffer,
#ifndef CONFIG_SPI_POLLWAIT
static inline struct imx_spidev_s *spi_mapirq(int irq);
-static int spi_interrupt(int irq, void *context);
+static int spi_interrupt(int irq, void *context, FAR void *arg, FAR void *arg);
#endif
/* SPI methods */
@@ -653,7 +653,7 @@ static inline struct imx_spidev_s *spi_mapirq(int irq)
****************************************************************************/
#ifndef CONFIG_SPI_POLLWAIT
-static int spi_interrupt(int irq, void *context)
+static int spi_interrupt(int irq, void *context, FAR void *arg, FAR void *arg)
{
struct imx_spidev_s *priv = spi_mapirq(irq);
int ntxd;
@@ -1168,7 +1168,7 @@ FAR struct spi_dev_s *imx_spibus_initialize(int port)
/* Attach the interrupt */
#ifndef CONFIG_SPI_POLLWAIT
- irq_attach(priv->irq, (xcpt_t)spi_interrupt);
+ irq_attach(priv->irq, (xcpt_t)spi_interrupt, NULL);
#endif
/* Enable SPI */
diff --git a/arch/arm/src/imx1/imx_timerisr.c b/arch/arm/src/imx1/imx_timerisr.c
index c18f72efabd5723719ed5a6c8ca5bf9fd5567c7d..2b021e085652af8d87dc439fccec86876900ea7b 100644
--- a/arch/arm/src/imx1/imx_timerisr.c
+++ b/arch/arm/src/imx1/imx_timerisr.c
@@ -64,7 +64,7 @@
*
****************************************************************************/
-static int imx_timerisr(int irq, uint32_t *regs)
+static int imx_timerisr(int irq, uint32_t *regs, FAR void *arg)
{
uint32_t tstat;
int ret = -EIO;
@@ -150,7 +150,7 @@ void arm_timer_initialize(void)
/* Attach and enable the timer interrupt */
- irq_attach(IMX_IRQ_SYSTIMER, (xcpt_t)imx_timerisr);
+ irq_attach(IMX_IRQ_SYSTIMER, (xcpt_t)imx_timerisr, NULL);
up_enable_irq(IMX_IRQ_SYSTIMER);
}
diff --git a/arch/arm/src/imx6/imx_ecspi.c b/arch/arm/src/imx6/imx_ecspi.c
index 15c602a7c962ee4348889eec7602ace4bb5ef927..0199419681764cd3683b49619f9763d3794d7b52 100644
--- a/arch/arm/src/imx6/imx_ecspi.c
+++ b/arch/arm/src/imx6/imx_ecspi.c
@@ -186,7 +186,6 @@ struct imx_spidev_s
uint8_t spindx; /* SPI index */
#ifndef CONFIG_SPI_POLLWAIT
uint8_t irq; /* SPI IRQ number */
- xcpt_t handler; /* ECSPI interrupt handler */
#endif
/* Per SPI callouts to board-specific logic */
@@ -223,22 +222,7 @@ static int spi_transfer(struct imx_spidev_s *priv, const void *txbuffer,
/* Interrupt handling */
#ifndef CONFIG_SPI_POLLWAIT
-static int spi_interrupt(struct imx_spidev_s *priv);
-#ifdef CONFIG_IMX6_ECSPI1
-static int ecspi1_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_IMX6_ECSPI2
-static int ecspi2_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_IMX6_ECSPI3
-static int ecspi3_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_IMX6_ECSPI4
-static int ecspi4_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_IMX6_ECSPI5
-static int ecspi5_interrupt(int irq, void *context);
-#endif
+static int spi_interrupt(int irq, void *context, FAR void *arg);
#endif
/* SPI methods */
@@ -307,7 +291,6 @@ static struct imx_spidev_s g_spidev[] =
.spindx = SPI1_NDX,
#ifndef CONFIG_SPI_POLLWAIT
.irq = IMX_IRQ_ECSPI1,
- .handler = ecspi1_interrupt,
#endif
.select = imx_spi1select,
.status = imx_spi1status,
@@ -324,7 +307,6 @@ static struct imx_spidev_s g_spidev[] =
.spindx = SPI2_NDX,
#ifndef CONFIG_SPI_POLLWAIT
.irq = IMX_IRQ_ECSPI2,
- .handler = ecspi2_interrupt,
#endif
.select = imx_spi2select,
.status = imx_spi2status,
@@ -341,7 +323,6 @@ static struct imx_spidev_s g_spidev[] =
.spindx = SPI3_NDX,
#ifndef CONFIG_SPI_POLLWAIT
.irq = IMX_IRQ_ECSPI3,
- .handler = ecspi3_interrupt,
#endif
.select = imx_spi3select,
.status = imx_spi3status,
@@ -358,7 +339,6 @@ static struct imx_spidev_s g_spidev[] =
.spindx = SPI4_NDX,
#ifndef CONFIG_SPI_POLLWAIT
.irq = IMX_IRQ_ECSPI4,
- .handler = ecspi4_interrupt,
#endif
.select = imx_spi4select,
.status = imx_spi4status,
@@ -375,7 +355,6 @@ static struct imx_spidev_s g_spidev[] =
.spindx = SPI5_NDX,
#ifndef CONFIG_SPI_POLLWAIT
.irq = IMX_IRQ_ECSPI5,
- .handler = ecspi5_interrupt,
#endif
.select = imx_spi5select,
.status = imx_spi5status,
@@ -759,8 +738,9 @@ static int spi_transfer(struct imx_spidev_s *priv, const void *txbuffer,
****************************************************************************/
#ifndef CONFIG_SPI_POLLWAIT
-static int spi_interrupt(struct imx_spidev_s *priv)
+static int spi_interrupt(int irq, void *context, FAR void *arg)
{
+ struct imx_spidev_s *priv = (struct imx_spidev_s *)arg;
int ntxd;
DEBUGASSERT(priv != NULL);
@@ -790,57 +770,6 @@ static int spi_interrupt(struct imx_spidev_s *priv)
}
#endif
-/****************************************************************************
- * Name: ecspiN_interrupt, N=1..5
- *
- * Description:
- * Individual ECPSI interrupt handlers.
- *
- * Input Parameters:
- * Standard interrupt handler inputs
- *
- * Returned Value:
- * 0: success, <0:Negated error number on failure
- *
- ****************************************************************************/
-
-#ifndef CONFIG_SPI_POLLWAIT
-#ifdef CONFIG_IMX6_ECSPI1
-static int ecspi1_interrupt(int irq, void *context)
-{
- return spi_interrupt(&g_spidev[SPI1_NDX]);
-}
-#endif
-
-#ifdef CONFIG_IMX6_ECSPI2
-static int ecspi2_interrupt(int irq, void *context)
-{
- return spi_interrupt(&g_spidev[SPI2_NDX]);
-}
-#endif
-
-#ifdef CONFIG_IMX6_ECSPI3
-static int ecspi3_interrupt(int irq, void *context)
-{
- return spi_interrupt(&g_spidev[SPI3_NDX]);
-}
-#endif
-
-#ifdef CONFIG_IMX6_ECSPI4
-static int ecspi4_interrupt(int irq, void *context)
-{
- return spi_interrupt(&g_spidev[SPI4_NDX]);
-}
-#endif
-
-#ifdef CONFIG_IMX6_ECSPI5
-static int ecspi5_interrupt(int irq, void *context)
-{
- return spi_interrupt(&g_spidev[SPI5_NDX]);
-}
-#endif
-#endif
-
/****************************************************************************
* Name: spi_lock
*
@@ -1425,7 +1354,7 @@ FAR struct spi_dev_s *imx_spibus_initialize(int port)
/* Attach the interrupt */
#ifndef CONFIG_SPI_POLLWAIT
- DEBUGVERIFY(irq_attach(priv->irq, priv->handler));
+ DEBUGVERIFY(irq_attach(priv->irq, spi_interrupt, priv));
#endif
/* Enable SPI */
diff --git a/arch/arm/src/imx6/imx_serial.c b/arch/arm/src/imx6/imx_serial.c
index a34d2f988adb1418456740d5d5c67aaaed2dc3b0..8ae64136b5257aeb5ba8b94a2fb80de896dea6e9 100644
--- a/arch/arm/src/imx6/imx_serial.c
+++ b/arch/arm/src/imx6/imx_serial.c
@@ -199,7 +199,6 @@
struct imx_uart_s
{
- xcpt_t handler; /* Interrupt handler */
uint32_t uartbase; /* Base address of UART registers */
uint32_t baud; /* Configured baud */
uint32_t ucr1; /* Saved UCR1 value */
@@ -229,24 +228,7 @@ static int imx_setup(struct uart_dev_s *dev);
static void imx_shutdown(struct uart_dev_s *dev);
static int imx_attach(struct uart_dev_s *dev);
static void imx_detach(struct uart_dev_s *dev);
-
-static int imx_interrupt(struct uart_dev_s *dev);
-#ifdef CONFIG_IMX6_UART1
-static int imx_uart1_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_IMX6_UART2
-static int imx_uart2_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_IMX6_UART3
-static int imx_uart3_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_IMX6_UART4
-static int imx_uart4_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_IMX6_UART5
-static int imx_uart5_interrupt(int irq, void *context);
-#endif
-
+static int imx_interrupt(int irq, void *context, FAR void *arg);
static int imx_ioctl(struct file *filep, int cmd, unsigned long arg);
static int imx_receive(struct uart_dev_s *dev, uint32_t *status);
static void imx_rxint(struct uart_dev_s *dev, bool enable);
@@ -317,7 +299,6 @@ static char g_uart5txbuffer[CONFIG_UART5_TXBUFSIZE];
#ifdef CONFIG_IMX6_UART1
static struct imx_uart_s g_uart1priv =
{
- .handler = imx_uart1_interrupt,
.uartbase = IMX_UART1_VBASE,
.baud = CONFIG_UART1_BAUD,
.irq = IMX_IRQ_UART1,
@@ -348,7 +329,6 @@ static struct uart_dev_s g_uart1port =
#ifdef CONFIG_IMX6_UART2
static struct imx_uart_s g_uart2priv =
{
- .handler = imx_uart2_interrupt,
.uartbase = IMX_UART2_VBASE,
.baud = CONFIG_UART2_BAUD,
.irq = IMX_IRQ_UART2,
@@ -377,7 +357,6 @@ static struct uart_dev_s g_uart2port =
#ifdef CONFIG_IMX6_UART3
static struct imx_uart_s g_uart3priv =
{
- .handler = imx_uart3_interrupt,
.uartbase = IMX_UART3_REGISTER_BASE,
.baud = IMX_UART3_VBASE,
.irq = IMX_IRQ_UART3,
@@ -406,7 +385,6 @@ static struct uart_dev_s g_uart3port =
#ifdef CONFIG_IMX6_UART4
static struct imx_uart_s g_uart4priv =
{
- .handler = imx_uart4_interrupt,
.uartbase = IMX_UART4_REGISTER_BASE,
.baud = IMX_UART4_VBASE,
.irq = IMX_IRQ_UART4,
@@ -435,7 +413,6 @@ static struct uart_dev_s g_uart4port =
#ifdef CONFIG_IMX6_UART5
static struct imx_uart_s g_uart5priv =
{
- .handler = imx_uart5_interrupt,
.uartbase = IMX_UART5_REGISTER_BASE,
.baud = IMX_UART5_VBASE,
.irq = IMX_IRQ_UART5,
@@ -618,7 +595,7 @@ static int imx_attach(struct uart_dev_s *dev)
/* Attach and enable the IRQ */
- ret = irq_attach(priv->irq, priv->handler);
+ ret = irq_attach(priv->irq, imx_interrupt, priv);
if (ret == OK)
{
/* Configure as a (high) level interrupt */
@@ -663,12 +640,16 @@ static void imx_detach(struct uart_dev_s *dev)
*
****************************************************************************/
-static int imx_interrupt(struct uart_dev_s *dev)
+static int imx_interrupt(int irq, void *context, FAR void *arg)
{
- struct imx_uart_s *priv = (struct imx_uart_s *)dev->priv;
+ struct uart_dev_s *dev = (struct uart_dev_s *)arg;
+ struct imx_uart_s *priv;
uint32_t usr1;
int passes = 0;
+ DEBUGASSERT(dev != NULL && dev->priv != NULL);
+ priv = (struct imx_uart_s *)dev->priv;
+
/* Loop until there are no characters to be transferred or,
* until we have been looping for a long time.
*/
@@ -710,46 +691,6 @@ static int imx_interrupt(struct uart_dev_s *dev)
}
}
-/****************************************************************************
- * Name: imx_uart[n]_interrupt
- *
- * Description:
- * UART-specific interrupt handlers just transfer control to the common
- * UART interrupt handler, passing the relevant driver state structure.
- *
- ****************************************************************************/
-
-#ifdef CONFIG_IMX6_UART1
-static int imx_uart1_interrupt(int irq, void *context)
-{
- return imx_interrupt(&g_uart1port);
-}
-#endif
-#ifdef CONFIG_IMX6_UART2
-static int imx_uart2_interrupt(int irq, void *context)
-{
- return imx_interrupt(&g_uart2port);
-}
-#endif
-#ifdef CONFIG_IMX6_UART3
-static int imx_uart3_interrupt(int irq, void *context)
-{
- return imx_interrupt(&g_uart3port);
-}
-#endif
-#ifdef CONFIG_IMX6_UART4
-static int imx_uart4_interrupt(int irq, void *context)
-{
- return imx_interrupt(&g_uart4port);
-}
-#endif
-#ifdef CONFIG_IMX6_UART5
-static int imx_uart5_interrupt(int irq, void *context)
-{
- return imx_interrupt(&g_uart5port);
-}
-#endif
-
/****************************************************************************
* Name: imx_ioctl
*
diff --git a/arch/arm/src/imx6/imx_timerisr.c b/arch/arm/src/imx6/imx_timerisr.c
index dbfc878eb89a0cdd938d3d44bafa936f988b09a8..36cd8cced00fe9df360da1ef46fe94909cb38789 100644
--- a/arch/arm/src/imx6/imx_timerisr.c
+++ b/arch/arm/src/imx6/imx_timerisr.c
@@ -130,7 +130,7 @@ static void imx_output_compare(uint32_t sr, uint32_t of)
*
****************************************************************************/
-static int imx_timerisr(int irq, uint32_t *regs)
+static int imx_timerisr(int irq, uint32_t *regs, FAR void *arg)
{
/* Sample the SR (once) */
@@ -260,7 +260,7 @@ void arm_timer_initialize(void)
/* Attach the timer interrupt vector */
- (void)irq_attach(IMX_IRQ_GPT, (xcpt_t)imx_timerisr);
+ (void)irq_attach(IMX_IRQ_GPT, (xcpt_t)imx_timerisr, NULL);
/* Enable all three GPT output compare interrupts */
diff --git a/arch/arm/src/kinetis/Kconfig b/arch/arm/src/kinetis/Kconfig
index 04d0df453bee14ed3e930bcaaae02ee8c93d7ee0..271921a9ef6a5f720d50c5ba9c134375ec69bc3f 100644
--- a/arch/arm/src/kinetis/Kconfig
+++ b/arch/arm/src/kinetis/Kconfig
@@ -220,27 +220,60 @@ config ARCH_CHIP_MK66FN2M0VLQ18
endchoice
+# These "hidden" settings determine is a peripheral option is available for
+# the selection MCU
+
+config KINETIS_HAVE_UART5
+ bool
+ default n
+
+config KINETIS_HAVE_LPUART0
+ bool
+ default n
+
+config KINETIS_HAVE_LPUART1
+ bool
+ default n
+
+# When there are multiple instances of a device, these "hidden" settings
+# will automatically be selected and will represent the 'OR' of the
+# instances selected.
+
+config KINETIS_LPUART
+ bool
+ default n
+
+config KINETIS_UART
+ bool
+ default n
+ select MCU_SERIAL
+
# Chip families
config ARCH_FAMILY_K20
bool
default n
+ select KINETIS_HAVE_UART5
config ARCH_FAMILY_K40
bool
default n
+ select KINETIS_HAVE_UART5
config ARCH_FAMILY_K60
bool
default n
+ select KINETIS_HAVE_UART5
config ARCH_FAMILY_K64
bool
default n
+ select KINETIS_HAVE_UART5
config ARCH_FAMILY_K66
bool
default n
+ select KINETIS_HAVE_LPUART0
menu "Kinetis Peripheral Support"
@@ -280,6 +313,7 @@ config KINETIS_UART0
bool "UART0"
default n
select UART0_SERIALDRIVER
+ select KINETIS_UART
---help---
Support UART0
@@ -287,6 +321,7 @@ config KINETIS_UART1
bool "UART1"
default n
select UART1_SERIALDRIVER
+ select KINETIS_UART
---help---
Support UART1
@@ -294,6 +329,7 @@ config KINETIS_UART2
bool "UART2"
default n
select UART2_SERIALDRIVER
+ select KINETIS_UART
---help---
Support UART2
@@ -301,6 +337,7 @@ config KINETIS_UART3
bool "UART3"
default n
select UART3_SERIALDRIVER
+ select KINETIS_UART
---help---
Support UART3
@@ -308,16 +345,37 @@ config KINETIS_UART4
bool "UART4"
default n
select UART4_SERIALDRIVER
+ select KINETIS_UART
---help---
Support UART4
config KINETIS_UART5
bool "UART5"
default n
+ depends on KINETIS_HAVE_UART5
select UART5_SERIALDRIVER
+ select KINETIS_UART
---help---
Support UART5
+config KINETIS_LPUART0
+ bool "Low power LPUART0"
+ default n
+ depends on KINETIS_HAVE_LPUART0
+ select OTHER_UART_SERIALDRIVER
+ select KINETIS_LPUART
+ ---help---
+ Support the low power UART0
+
+config KINETIS_LPUART1
+ bool "Low power LPUART1"
+ default n
+ depends on KINETIS_HAVE_LPUART1
+ select OTHER_UART_SERIALDRIVER
+ select KINETIS_LPUART
+ ---help---
+ Support the low power UART1
+
config KINETIS_ENET
bool "Ethernet"
default n
@@ -574,10 +632,11 @@ config KINETIS_FTM0_PWM
---help---
Reserve timer 0 for use by PWM
- Timer devices may be used for different purposes. One special purpose is
- to generate modulated outputs for such things as motor control. If KINETIS_FTM0
- is defined then THIS following may also be defined to indicate that
- the timer is intended to be used for pulsed output modulation.
+ Timer devices may be used for different purposes. One special
+ purpose is to generate modulated outputs for such things as motor
+ control. If KINETIS_FTM0 is defined then THIS following may also be
+ defined to indicate that the timer is intended to be used for pulsed
+ output modulation.
config KINETIS_FTM0_CHANNEL
int "FTM0 PWM Output Channel"
@@ -839,6 +898,10 @@ config KINETIS_SD4BIT_FREQ
endif
endmenu # Kinetis SDHC Configuration
+#
+# MCU serial peripheral driver?
+#
+
menu "Kinetis UART Configuration"
config KINETIS_UARTFIFOS
@@ -847,3 +910,179 @@ config KINETIS_UARTFIFOS
depends on KINETIS_UART0
endmenu # Kinetis UART Configuration
+
+menu "Kinetis LPUART0 Configuration"
+ depends on KINETIS_LPUART0
+
+config LPUART0_RXBUFSIZE
+ int "Receive buffer size"
+ default 256
+ ---help---
+ Characters are buffered as they are received. This specifies
+ the size of the receive buffer.
+
+config LPUART0_TXBUFSIZE
+ int "Transmit buffer size"
+ default 256
+ ---help---
+ Characters are buffered before being sent. This specifies
+ the size of the transmit buffer.
+
+config LPUART0_BAUD
+ int "BAUD rate"
+ default 115200
+ ---help---
+ The configured BAUD of the UART.
+
+config LPUART0_BITS
+ int "Character size"
+ default 8
+ ---help---
+ The number of bits. Must be either 7 or 8.
+
+config LPUART0_PARITY
+ int "Parity setting"
+ range 0 2
+ default 0
+ ---help---
+ 0=no parity, 1=odd parity, 2=even parity
+
+config LPUART0_2STOP
+ int "use 2 stop bits"
+ default 0
+ ---help---
+ 1=Two stop bits
+
+config LPUART0_IFLOWCONTROL
+ bool "LPUART0 RTS flow control"
+ default n
+ select SERIAL_IFLOWCONTROL
+ ---help---
+ Enable LPUART0 RTS flow control
+
+config LPUART0_OFLOWCONTROL
+ bool "LPUART0 CTS flow control"
+ default n
+ select SERIAL_OFLOWCONTROL
+ ---help---
+ Enable LPUART0 CTS flow control
+
+config LPUART0_DMA
+ bool "LPUART0 DMA support"
+ default n
+ select SERIAL_DMA
+ ---help---
+ Enable DMA transfers on LPUART0
+
+endmenu # Kinetis LPUART0 Configuration
+
+menu "Kinetis LPUART1 Configuration"
+ depends on KINETIS_LPUART1
+
+config LPUART1_RXBUFSIZE
+ int "Receive buffer size"
+ default 256
+ ---help---
+ Characters are buffered as they are received. This specifies
+ the size of the receive buffer.
+
+config LPUART1_TXBUFSIZE
+ int "Transmit buffer size"
+ default 256
+ ---help---
+ Characters are buffered before being sent. This specifies
+ the size of the transmit buffer.
+
+config LPUART1_BAUD
+ int "BAUD rate"
+ default 115200
+ ---help---
+ The configured BAUD of the UART.
+
+config LPUART1_BITS
+ int "Character size"
+ default 8
+ ---help---
+ The number of bits. Must be either 7 or 8.
+
+config LPUART1_PARITY
+ int "Parity setting"
+ range 0 2
+ default 0
+ ---help---
+ 0=no parity, 1=odd parity, 2=even parity
+
+config LPUART1_2STOP
+ int "use 2 stop bits"
+ default 0
+ ---help---
+ 1=Two stop bits
+
+config LPUART1_IFLOWCONTROL
+ bool "LPUART1 RTS flow control"
+ default n
+ select SERIAL_IFLOWCONTROL
+ ---help---
+ Enable LPUART1 RTS flow control
+
+config LPUART1_OFLOWCONTROL
+ bool "LPUART1 CTS flow control"
+ default n
+ select SERIAL_OFLOWCONTROL
+ ---help---
+ Enable LPUART1 CTS flow control
+
+config LPUART1_DMA
+ bool "LPUART1 DMA support"
+ default n
+ select SERIAL_DMA
+ ---help---
+ Enable DMA transfers on LPUART1
+
+endmenu # Kinetis LPUART1 Configuration
+
+choice
+ prompt "Kinetis LPUART Serial Console"
+ default NO_LPUART_SERIAL_CONSOLE
+ depends on DEV_CONSOLE && KINETIS_LPUART
+
+config LPUART0_SERIAL_CONSOLE
+ bool "Use LPUART0 as the serial console"
+ depends on KINETIS_LPUART0
+ select OTHER_SERIAL_CONSOLE
+ ---help---
+ Use the LPUART0 device as the serial console
+
+config LPUART1_SERIAL_CONSOLE
+ bool "Use LPUART1 as the serial console"
+ depends on KINETIS_LPUART1
+ select OTHER_SERIAL_CONSOLE
+ ---help---
+ Use the LPUART1 device as the serial console
+
+config NO_LPUART_SERIAL_CONSOLE
+ bool "No LPUART serial console"
+ ---help---
+ No serial LPUART based console OR some other serial device provides
+ the serial console
+
+endchoice # Kinetis LPUART Serial Console
+
+config KINETIS_MERGE_TTY
+ bool "Kinetis Merge TTY names for LPUARTS"
+ default n
+ depends on KINETIS_LPUART
+ ---help---
+ Enable the merging of the TTY names when both LPUARTs and UARTs
+ are defined. When enabled, all both LPUARTS and UART types will be
+ listed as dev/ttySn. When disabled, LPUARTS willbe listed as
+ /dev/ttyLPn and UARTs as /dev/ttySn see also (KINETS_LPUART_LOWEST)
+
+config KINETS_LPUART_LOWEST
+ bool "Kinetis Order ttySn LPUARTs before UARTS"
+ default n
+ depends on KINETIS_LPUART && KINETIS_UART
+ depends on KINETIS_MERGE_TTY
+ ---help---
+ Used with KINETIS_MERGE_TTY, will set the order of ttySn assignments
+ Enabled will order the LPUART's before the UARTS.
diff --git a/arch/arm/src/kinetis/Make.defs b/arch/arm/src/kinetis/Make.defs
index bd4eed06484a641225e9c096baed6fdad0e51024..6ee494c6526c29590b3fa14d2686f54f8a64c8bc 100644
--- a/arch/arm/src/kinetis/Make.defs
+++ b/arch/arm/src/kinetis/Make.defs
@@ -113,7 +113,8 @@ CHIP_ASRCS =
CHIP_CSRCS = kinetis_allocateheap.c kinetis_clockconfig.c
CHIP_CSRCS += kinetis_clrpend.c kinetis_idle.c kinetis_irq.c
CHIP_CSRCS += kinetis_lowputc.c kinetis_pin.c kinetis_pingpio.c
-CHIP_CSRCS += kinetis_serial.c kinetis_start.c kinetis_uid.c kinetis_wdog.c
+CHIP_CSRCS += kinetis_serialinit.c kinetis_serial.c
+CHIP_CSRCS += kinetis_start.c kinetis_uid.c kinetis_wdog.c
CHIP_CSRCS += kinetis_cfmconfig.c
# Configuration-dependent Kinetis files
@@ -162,6 +163,10 @@ ifeq ($(CONFIG_I2C),y)
CHIP_CSRCS += kinetis_i2c.c
endif
+ifeq ($(CONFIG_KINETIS_LPUART),y)
+CHIP_CSRCS += kinetis_lpserial.c
+endif
+
ifeq ($(CONFIG_RTC),y)
CHIP_CSRCS += kinetis_rtc.c
ifeq ($(CONFIG_RTC_DRIVER),y)
diff --git a/arch/arm/src/kinetis/chip/kinetis_llwu.h b/arch/arm/src/kinetis/chip/kinetis_llwu.h
index ae5c6c8b04c1edf2e7031037505af25869e55b51..c4abaa74ddf66b0dfd674ce3e65df503420ec299 100644
--- a/arch/arm/src/kinetis/chip/kinetis_llwu.h
+++ b/arch/arm/src/kinetis/chip/kinetis_llwu.h
@@ -232,7 +232,9 @@
/* LLWU Control and Status Register */
-#define LLWU_CS_ACKISO (1 << 7) /* Bit 7: Acknowledge Isolation */
+#if !defined(KINETIS_PMC_HAS_REGSC_ACKISO)
+# define LLWU_CS_ACKISO (1 << 7) /* Bit 7: Acknowledge Isolation */
+#endif
/* Bits 2-6: Reserved */
#define LLWU_CS_FLTEP (1 << 1) /* Bit 1: Digital Filter on External Pin */
#define LLWU_CS_FLTR (1 << 0) /* Bit 0: Digital Filter on RESET Pin */
diff --git a/arch/arm/src/kinetis/chip/kinetis_lpuart.h b/arch/arm/src/kinetis/chip/kinetis_lpuart.h
new file mode 100644
index 0000000000000000000000000000000000000000..eafd18f122c38c00cf189944d852d91ee483b06d
--- /dev/null
+++ b/arch/arm/src/kinetis/chip/kinetis_lpuart.h
@@ -0,0 +1,222 @@
+/****************************************************************************************************
+ * arch/arm/src/kinetis/chip/kinetis_lpuart.h
+ *
+ * Copyright (C) 2017 Gregory Nutt. All rights reserved.
+ * Authors: Gregory Nutt
+ * David Sidrane
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************************************/
+
+#ifndef __ARCH_ARM_SRC_KINETIS_CHIP_KINETIS_LPUART_H
+#define __ARCH_ARM_SRC_KINETIS_CHIP_KINETIS_LPUART_H
+
+/****************************************************************************************************
+ * Included Files
+ ****************************************************************************************************/
+
+#include
+
+#include "chip.h"
+
+/****************************************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************************************/
+
+/* Register Offsets *********************************************************************************/
+
+#define KINETIS_LPUART_BAUD_OFFSET 0x0000 /* Low Power UART Baud Rate Register */
+#define KINETIS_LPUART_STAT_OFFSET 0x0004 /* Low Power UART Status Register */
+#define KINETIS_LPUART_CTRL_OFFSET 0x0008 /* Low Power UART Control Register */
+#define KINETIS_LPUART_DATA_OFFSET 0x000c /* Low Power UART Data Register */
+#define KINETIS_LPUART_MATCH_OFFSET 0x000c /* Low Power UART Match Address Register */
+#define KINETIS_LPUART_MODIR_OFFSET 0x000c /* Low Power UART Modem IrDA Register */
+
+/* Register Addresses *******************************************************************************/
+
+#define KINETIS_LPUART0_BAUD (KINETIS_LPUART0_BASE+KINETIS_LPUART_BAUD_OFFSET)
+#define KINETIS_LPUART0_STAT (KINETIS_LPUART0_BASE+KINETIS_LPUART_STAT_OFFSET)
+#define KINETIS_LPUART0_CTRL (KINETIS_LPUART0_BASE+KINETIS_LPUART_CTRL_OFFSET)
+#define KINETIS_LPUART0_DATA (KINETIS_LPUART0_BASE+KINETIS_LPUART_DATA_OFFSET)
+#define KINETIS_LPUART0_MATCH (KINETIS_LPUART0_BASE+KINETIS_LPUART_MATCH_OFFSET)
+#define KINETIS_LPUART0_MODIR (KINETIS_LPUART0_BASE+KINETIS_LPUART_MODIR_OFFSET)
+
+/* Register Bit Definitions *************************************************************************/
+
+/* Low Power UART Baud Rate Register */
+
+#define LPUART_BAUD_SBR_SHIFT (0) /* Bits 0-12: Baud Rate Modulo Divisor */
+#define LPUART_BAUD_SBR_MASK (0x1fff << LPUART_BAUD_SBR_SHIFT)
+# define LPUART_BAUD_SBR(n) (((n) & 0x1fff) << LPUART_BAUD_SBR_SHIFT) /* n= 1..8191*/
+#define LPUART_BAUD_SBNS (1 << 13) /* Bit 13: Stop Bit Number Select */
+#define LPUART_BAUD_RXEDGIE (1 << 14) /* Bit 14: RX Input Active Edge Interrupt Enable */
+#define LPUART_BAUD_LBKDIE (1 << 15) /* Bit 15: LIN Break Detect Interrupt Enable */
+#define LPUART_BAUD_RESYNCDIS (1 << 16) /* Bit 16: Resynchronizations Disable */
+#define LPUART_BAUD_BOTHEDGE (1 << 17) /* Bit 17: Both Edge Sampling */
+#define LPUART_BAUD_MATCFG_SHIFT (18) /* Bits 18-19: Match Configuration */
+#define LPUART_BAUD_MATCFG_MASK (3 << LPUART_BAUD_MATCFG_SHIFT)
+# define LPUART_BAUD_MATCFG_AMW (0 << LPUART_BAUD_MATCFG_SHIFT) /* Address Match Wakeup */
+# define LPUART_BAUD_MATCFG_IMW (1 << LPUART_BAUD_MATCFG_SHIFT) /* Idle Match Wakeup */
+# define LPUART_BAUD_MATCFG_MONOFF (2 << LPUART_BAUD_MATCFG_SHIFT) /* Match On and Match Off */
+# define LPUART_BAUD_MATCFG_RWU (3 << LPUART_BAUD_MATCFG_SHIFT) /* Enables RWU on Data Match and Match On/Off for transmitter CTS input */
+ /* Bit 20: Reserved */
+#define LPUART_BAUD_RDMAE (1 << 21) /* Bit 21: Receiver Full DMA Enable */
+ /* Bit 22: Reserved */
+#define LPUART_BAUD_TDMAE (1 << 23) /* Bit 23: Transmitter DMA Enable */
+#define LPUART_BAUD_OSR_SHIFT (24) /* Bits 24-28: Over Sampling Ratio */
+#define LPUART_BAUD_OSR_MASK (0x1f << LPUART_BAUD_OSR_SHIFT)
+#define LPUART_BAUD_OSR(n) ((((n)-1) & 0x1f) << LPUART_BAUD_OSR_SHIFT) /* n=4..32 */
+#define LPUART_BAUD_M10 (1 << 29) /* Bit 29: 10-bit Mode select */
+#define LPUART_BAUD_MAEN2 (1 << 30) /* Bit 30: Match Address Mode Enable 2 */
+#define LPUART_BAUD_MAEN1 (1 << 31) /* Bit 31: Match Address Mode Enable 1 */
+
+/* Low Power UART Status Register */
+
+ /* Bits 0-13: Reserved */
+#define LPUART_STAT_MA2F (1 << 14) /* Match 2 Flag */
+#define LPUART_STAT_MA1F (1 << 15) /* Match 1 Flag */
+#define LPUART_STAT_PF (1 << 16) /* Parity Error Flag */
+#define LPUART_STAT_FE (1 << 17) /* Framing Error Flag */
+#define LPUART_STAT_NF (1 << 18) /* Noise Flag */
+#define LPUART_STAT_OR (1 << 19) /* Receiver Overrun Flag */
+#define LPUART_STAT_IDLE (1 << 20) /* Idle Line Flag */
+#define LPUART_STAT_RDRF (1 << 21) /* Receive Data Register Full Flag */
+#define LPUART_STAT_TC (1 << 22) /* Transmission Complete Flag */
+#define LPUART_STAT_TDRE (1 << 23) /* Transmit Data Register Empty Flag */
+#define LPUART_STAT_RAF (1 << 24) /* Receiver Active Flag */
+#define LPUART_STAT_LBKDE (1 << 25) /* LIN Break Detection Enable */
+#define LPUART_STAT_BRK13 (1 << 26) /* Break Character Generation Length */
+#define LPUART_STAT_RWUID (1 << 27) /* Receive Wake Up Idle Detect */
+#define LPUART_STAT_RXINV (1 << 28) /* Receive Data Inversion */
+#define LPUART_STAT_MSBF (1 << 29) /* MSB First */
+#define LPUART_STAT_RXEDGIF (1 << 30) /* LPUART_RX Pin Active Edge Interrupt Flag */
+#define LPUART_STAT_LBKDIF (1 << 31) /* LIN Break Detect Interrupt Flag */
+
+/* Low Power UART Control Register */
+
+#define LPUART_CTRL_PT (1 << 0) /* Bit 0: Parity Type */
+#define LPUART_CTRL_PE (1 << 1) /* Bit 1: Parity Enable */
+#define LPUART_CTRL_ILT (1 << 2) /* Bit 2: Idle Line Type Select */
+#define LPUART_CTRL_WAKE (1 << 3) /* Bit 3: Receiver Wakeup Method Select */
+#define LPUART_CTRL_M (1 << 4) /* Bit 4: 9-Bit or 8-Bit Mode Select */
+#define LPUART_CTRL_RSRC (1 << 5) /* Bit 5: Receiver Source Select */
+#define LPUART_CTRL_DOZEEN (1 << 6) /* Bit 6: Doze Enable */
+#define LPUART_CTRL_LOOPS (1 << 7) /* Bit 7: Loop Mode Select */
+#define LPUART_CTRL_IDLECFG_SHIFT (8) /* Bits 8-10: Idle Configuration */
+#define LPUART_CTRL_IDLECFG_MASK (3 << LPUART_CTRL_IDLECFG_SHIFT)
+# define LPUART_CTRL_IDLECFG_1 (0 << LPUART_CTRL_IDLECFG_SHIFT) /* 1 idle character */
+# define LPUART_CTRL_IDLECFG_2 (1 << LPUART_CTRL_IDLECFG_SHIFT) /* 2 idle characters */
+# define LPUART_CTRL_IDLECFG_4 (2 << LPUART_CTRL_IDLECFG_SHIFT) /* 4 idle characters */
+# define LPUART_CTRL_IDLECFG_8 (3 << LPUART_CTRL_IDLECFG_SHIFT) /* 8 idle characters */
+# define LPUART_CTRL_IDLECFG_16 (4 << LPUART_CTRL_IDLECFG_SHIFT) /* 16 idle characters */
+# define LPUART_CTRL_IDLECFG_32 (5 << LPUART_CTRL_IDLECFG_SHIFT) /* 32 idle characters */
+# define LPUART_CTRL_IDLECFG_64 (6 << LPUART_CTRL_IDLECFG_SHIFT) /* 64 idle characters */
+# define LPUART_CTRL_IDLECFG_128 (7 << LPUART_CTRL_IDLECFG_SHIFT) /* 128 idle characters */
+ /* Bits 11-13: Reserved */
+#define LPUART_CTRL_MA2IE (1 << 14) /* Bit 14: Match 2 Interrupt Enable */
+#define LPUART_CTRL_MA1IE (1 << 15) /* Bit 15: Match 1 Interrupt Enable */
+#define LPUART_CTRL_SBK (1 << 16) /* Bit 16: Send Break */
+#define LPUART_CTRL_RWU (1 << 17) /* Bit 17: Receiver Wakeup Control */
+#define LPUART_CTRL_RE (1 << 18) /* Bit 18: Receiver Enable */
+#define LPUART_CTRL_TE (1 << 19) /* Bit 19: Transmitter Enable */
+#define LPUART_CTRL_ILIE (1 << 20) /* Bit 20: Idle Line Interrupt Enable */
+#define LPUART_CTRL_RIE (1 << 21) /* Bit 21: Receiver Interrupt Enable */
+#define LPUART_CTRL_TCIE (1 << 22) /* Bit 22: Transmission Complete Interrupt Enable for */
+#define LPUART_CTRL_TIE (1 << 23) /* Bit 23: Transmit Interrupt Enable */
+#define LPUART_CTRL_PEIE (1 << 24) /* Bit 24: Parity Error Interrupt Enable */
+#define LPUART_CTRL_FEIE (1 << 25) /* Bit 25: Framing Error Interrupt Enable */
+#define LPUART_CTRL_NEIE (1 << 26) /* Bit 26: Noise Error Interrupt Enable */
+#define LPUART_CTRL_ORIE (1 << 27) /* Bit 27: Overrun Interrupt Enable */
+#define LPUART_CTRL_TXINV (1 << 28) /* Bit 28: Transmit Data Inversion */
+#define LPUART_CTRL_TXDIR (1 << 29) /* Bit 29: LPUART_TX Pin Direction in Single-Wire Mode */
+#define LPUART_CTRL_R9T8 (1 << 30) /* Bit 30: Receive Bit 9 / Transmit Bit 8 */
+#define LPUART_CTRL_R8T9 (1 << 31) /* Bit 31: Receive Bit 8 / Transmit Bit 9 */
+
+/* Low Power UART Data Register */
+
+#define LPUART_DATA_SHIFT (0) /* Bits 0-9: Read receive/ write transmit data */
+#define LPUART_DATA_MASK (0x3ff << LPUART_DATA_SHIFT)
+#define LPUART_DATA8(n) (((n) & 0xff) << LPUART_DATA_SHIFT)
+#define LPUART_DATA9(n) (((n) & 0x1ff) << LPUART_DATA_SHIFT)
+#define LPUART_DATA10(n) (((n) & 0x3ff) << LPUART_DATA_SHIFT)
+#define LPUART_DATA_R0T0 (1 << 0) /* Bit 0: Read receive data buffer 0 or write transmit data buffer 0 */
+#define LPUART_DATA_R1T1 (1 << 1) /* Bit 1: Read receive data buffer 1 or write transmit data buffer 1 */
+#define LPUART_DATA_R2T2 (1 << 2) /* Bit 2: Read receive data buffer 2 or write transmit data buffer 2 */
+#define LPUART_DATA_R3T3 (1 << 3) /* Bit 3: Read receive data buffer 3 or write transmit data buffer 3 */
+#define LPUART_DATA_R4T4 (1 << 4) /* Bit 4: Read receive data buffer 4 or write transmit data buffer 4 */
+#define LPUART_DATA_R5T5 (1 << 5) /* Bit 5: Read receive data buffer 5 or write transmit data buffer 5 */
+#define LPUART_DATA_R6T6 (1 << 6) /* Bit 6: Read receive data buffer 6 or write transmit data buffer 6 */
+#define LPUART_DATA_R7T7 (1 << 7) /* Bit 7: Read receive data buffer 7 or write transmit data buffer 7 */
+#define LPUART_DATA_R8T8 (1 << 8) /* Bit 8: Read receive data buffer 8 or write transmit data buffer 8 */
+#define LPUART_DATA_R9T9 (1 << 9) /* Bit 9: Read receive data buffer 9 or write transmit data buffer 9 */
+ /* Bit 10: Reserved */
+#define LPUART_DATA_IDLINE (1 << 11) /* Bit 11: Idle Line */
+#define LPUART_DATA_RXEMPT (1 << 12) /* Bit 12: Receive Buffer Empty */
+#define LPUART_DATA_FRETSC (1 << 13) /* Bit 13: Frame Error / Transmit Special Character */
+#define LPUART_DATA_PARITYE (1 << 14) /* Bit 14: The current received dataword contained in DATA[R9:R0] was received with a parity error */
+#define LPUART_DATA_NOISY (1 << 15) /* Bit 15: The current received dataword contained in DATA[R9:R0] was received with noise */
+ /* Bits 16-31: This field is reserved */
+
+/* Low Power UART Match Address Register */
+
+#define LPUART_MATCH_MA1_SHIFT (0) /* Bits 0-9: Match Address 1 */
+#define LPUART_MATCH_MA1_MASK (0x3ff << LPUART_MATCH_MA1_SHIFT)
+ /* Bits 10-15: Reserved */
+#define LPUART_MATCH_MA2_SHIFT (16) /* Bits 16-25: Match Address 2 */
+#define LPUART_MATCH_MA2_MASK (0x3ff << LPUART_MATCH_MA2_SHIFT)
+ /* Bits 26-31: Reserved */
+
+/* Low Power UART Modem IrDA Register */
+
+#define LPUART_MODIR_TXCTSE (1 << 0) /* Bit 0: Transmitter clear-to-send enable */
+#define LPUART_MODIR_TXRTSE (1 << 1) /* Bit 1: Transmitter request-to-send enable */
+#define LPUART_MODIR_TXRTSPOL (1 << 2) /* Bit 2: Transmitter request-to-send polarity */
+#define LPUART_MODIR_RXRTSE (1 << 3) /* Bit 3: Receiver request-to-send enable */
+#define LPUART_MODIR_TXCTSC (1 << 4) /* Bit 4: Transmit CTS Configuration */
+#define LPUART_MODIR_TXCTSSRC (1 << 5) /* Bit 5: Transmit CTS Source */
+ /* Bits 6-15: Reserved */
+#define LPUART_MODIR_TNP_SHIFT (16) /* Bits 16-17: Transmitter narrow pulse */
+#define LPUART_MODIR_TNP_MASK (3 << LPUART_MODIR_TNP_SHIFT)
+# define LPUART_MODIR_TNP(n) (((n)-1) << LPUART_MODIR_TNP_SHIFT) /* n=1-4 */
+#define LPUART_MODIR_IREN (1 << 18) /* Bit 18: Infrared enable */
+ /* Bits 19-31: Reserved */
+
+/****************************************************************************************************
+ * Public Types
+ ****************************************************************************************************/
+
+/****************************************************************************************************
+ * Public Data
+ ****************************************************************************************************/
+
+/****************************************************************************************************
+ * Public Functions
+ ****************************************************************************************************/
+
+#endif /* __ARCH_ARM_SRC_KINETIS_CHIP_KINETIS_LPUART_H */
diff --git a/arch/arm/src/kinetis/chip/kinetis_pmc.h b/arch/arm/src/kinetis/chip/kinetis_pmc.h
index c0ffe575b3615a691239db95ba764631c63dd686..be346bf67fe154d0cc48fa3c8a718f34dffc84bc 100644
--- a/arch/arm/src/kinetis/chip/kinetis_pmc.h
+++ b/arch/arm/src/kinetis/chip/kinetis_pmc.h
@@ -78,22 +78,33 @@
#define PMC_LVDSC2_LVWV_SHIFT (0) /* Bits 0-1: Low-Voltage Warning Voltage Select */
#define PMC_LVDSC2_LVWV_MASK (3 << PMC_LVDSC2_LVWV_SHIFT)
-# define PMC_LVDSC2_LVWV_ LOW (0 << PMC_LVDSC2_LVWV_SHIFT) /* Low trip point selected (VLVW = VLVW1H/L) */
-# define PMC_LVDSC2_LVWV_ MID1 (1 << PMC_LVDSC2_LVWV_SHIFT) /* Mid 1 trip point selected (VLVW = VLVW2H/L) */
-# define PMC_LVDSC2_LVWV_ MID2 (2 << PMC_LVDSC2_LVWV_SHIFT) /* Mid 2 trip point selected (VLVW = VLVW3H/L) */
-# define PMC_LVDSC2_LVWV_ HIGH (3 << PMC_LVDSC2_LVWV_SHIFT) /* High trip point selected (VLVW = VLVW4H/L) */
+# define PMC_LVDSC2_LVWV_LOW (0 << PMC_LVDSC2_LVWV_SHIFT) /* Low trip point selected (VLVW = VLVW1H/L) */
+# define PMC_LVDSC2_LVWV_MID1 (1 << PMC_LVDSC2_LVWV_SHIFT) /* Mid 1 trip point selected (VLVW = VLVW2H/L) */
+# define PMC_LVDSC2_LVWV_MID2 (2 << PMC_LVDSC2_LVWV_SHIFT) /* Mid 2 trip point selected (VLVW = VLVW3H/L) */
+# define PMC_LVDSC2_LVWV_HIGH (3 << PMC_LVDSC2_LVWV_SHIFT) /* High trip point selected (VLVW = VLVW4H/L) */
/* Bits 2-4: Reserved */
#define PMC_LVDSC2_LVWIE (1 << 5) /* Bit 5: Low-Voltage Warning Interrupt Enable */
#define PMC_LVDSC2_LVWACK (1 << 6) /* Bit 6: Low-Voltage Warning Acknowledge */
#define PMC_LVDSC2_LVWF (1 << 7) /* Bit 7: Low-Voltage Warning Flag */
/* Regulator Status and Control Register */
-
#define PMC_REGSC_BGBE (1 << 0) /* Bit 0: Bandgap Buffer Enable */
/* Bit 1: Reserved */
-#define PMC_REGSC_REGONS (1 << 2) /* Bit 2: Regulator in Run Regulation Status */
-#define PMC_REGSC_VLPRS (1 << 3) /* Bit 3: Very Low Power Run Status */
-#define PMC_REGSC_TRAMPO (1 << 4) /* Bit 4: For devices with FlexNVM: Traditional RAM Power Option */
+#if defined(KINETIS_PMC_HAS_REGSC_REGONS)
+# define PMC_REGSC_REGONS (1 << 2) /* Bit 2: Regulator in Run Regulation Status */
+#endif
+#if defined(KINETIS_PMC_HAS_REGSC_ACKISO)
+# define PMC_REGSC_ACKISO (1 << 3) /* Bit 3: Acknowledge Isolation */
+#endif
+#if defined(KINETIS_PMC_HAS_REGSC_VLPRS)
+# define PMC_REGSC_VLPRS (1 << 3) /* Bit 3: Very Low Power Run Status */
+#endif
+#if defined(KINETIS_PMC_HAS_REGSC_BGEN)
+# define PMC_REGSC_BGEN (1 << 4) /* Bit 4: Bandgap Enable In VLPx Operation */
+#endif
+#if defined(KINETIS_PMC_HAS_REGSC_TRAMPO)
+# define PMC_REGSC_TRAMPO (1 << 4) /* Bit 4: For devices with FlexNVM: Traditional RAM Power Option */
+#endif
/* Bits 5-7: Reserved */
/************************************************************************************
diff --git a/arch/arm/src/kinetis/chip/kinetis_sim.h b/arch/arm/src/kinetis/chip/kinetis_sim.h
index 4898c5896046557d080aacf544dc3311793c1276..3e6cb6a6efb709c19036429963baf371e7cbc33a 100644
--- a/arch/arm/src/kinetis/chip/kinetis_sim.h
+++ b/arch/arm/src/kinetis/chip/kinetis_sim.h
@@ -51,513 +51,1264 @@
/* Register Offsets *****************************************************************/
-#define KINETIS_SIM_SOPT1_OFFSET 0x0000 /* System Options Register 1 */
-#define KINETIS_SIM_SOPT2_OFFSET 0x0004 /* System Options Register 2 */
-#define KINETIS_SIM_SOPT4_OFFSET 0x000c /* System Options Register 4 */
-#define KINETIS_SIM_SOPT5_OFFSET 0x0010 /* System Options Register 5 */
-#define KINETIS_SIM_SOPT6_OFFSET 0x0014 /* System Options Register 6 */
-#define KINETIS_SIM_SOPT7_OFFSET 0x0018 /* System Options Register 7 */
-#define KINETIS_SIM_SDID_OFFSET 0x0024 /* System Device Identification Register */
-#define KINETIS_SIM_SCGC1_OFFSET 0x0028 /* System Clock Gating Control Register 1 */
-#define KINETIS_SIM_SCGC2_OFFSET 0x002c /* System Clock Gating Control Register 2 */
-#define KINETIS_SIM_SCGC3_OFFSET 0x0030 /* System Clock Gating Control Register 3 */
-#define KINETIS_SIM_SCGC4_OFFSET 0x0034 /* System Clock Gating Control Register 4 */
-#define KINETIS_SIM_SCGC5_OFFSET 0x0038 /* System Clock Gating Control Register 5 */
-#define KINETIS_SIM_SCGC6_OFFSET 0x003c /* System Clock Gating Control Register 6 */
-#define KINETIS_SIM_SCGC7_OFFSET 0x0040 /* System Clock Gating Control Register 7 */
-#define KINETIS_SIM_CLKDIV1_OFFSET 0x0044 /* System Clock Divider Register 1 */
-#define KINETIS_SIM_CLKDIV2_OFFSET 0x0048 /* System Clock Divider Register 2 */
-#define KINETIS_SIM_FCFG1_OFFSET 0x004c /* Flash Configuration Register 1 */
-#define KINETIS_SIM_FCFG2_OFFSET 0x0050 /* Flash Configuration Register 2 */
-#define KINETIS_SIM_UIDH_OFFSET 0x0054 /* Unique Identification Register High */
-#define KINETIS_SIM_UIDMH_OFFSET 0x0058 /* Unique Identification Register Mid-High */
-#define KINETIS_SIM_UIDML_OFFSET 0x005c /* Unique Identification Register Mid Low */
-#define KINETIS_SIM_UIDL_OFFSET 0x0060 /* Unique Identification Register Low */
+#define KINETIS_SIM_SOPT1_OFFSET 0x0000 /* System Options Register 1 */
+#if defined (KINETIS_SIM_HAS_SOPT1CFG)
+# define KINETIS_SIM_SOPT1CFG_OFFSET 0x0004 /* SOPT1 Configuration Register */
+#endif
+#if defined(KINETIS_SIM_HAS_USBPHYCTL)
+# define KINETIS_SIM_USBPHYCTL_OFFSET 0x0008 /* USB PHY Control Register */
+#endif
+#define KINETIS_SIM_SOPT2_OFFSET 0x0004 /* System Options Register 2 */
+#define KINETIS_SIM_SOPT4_OFFSET 0x000c /* System Options Register 4 */
+#define KINETIS_SIM_SOPT5_OFFSET 0x0010 /* System Options Register 5 */
+#define KINETIS_SIM_SOPT6_OFFSET 0x0014 /* System Options Register 6 */
+#define KINETIS_SIM_SOPT7_OFFSET 0x0018 /* System Options Register 7 */
+#if defined(KINETIS_SIM_HAS_SOPT8)
+# define KINETIS_SIM_SOPT8_OFFSET 0x001c /* System Options Register 8 */
+#endif
+#if defined(KINETIS_SIM_HAS_SOPT9)
+# define KINETIS_SIM_SOPT9_OFFSET 0x0020 /* System Options Register 9 */
+#endif
+#define KINETIS_SIM_SDID_OFFSET 0x0024 /* System Device Identification Register */
+#define KINETIS_SIM_SCGC1_OFFSET 0x0028 /* System Clock Gating Control Register 1 */
+#define KINETIS_SIM_SCGC2_OFFSET 0x002c /* System Clock Gating Control Register 2 */
+#define KINETIS_SIM_SCGC3_OFFSET 0x0030 /* System Clock Gating Control Register 3 */
+#define KINETIS_SIM_SCGC4_OFFSET 0x0034 /* System Clock Gating Control Register 4 */
+#define KINETIS_SIM_SCGC5_OFFSET 0x0038 /* System Clock Gating Control Register 5 */
+#define KINETIS_SIM_SCGC6_OFFSET 0x003c /* System Clock Gating Control Register 6 */
+#define KINETIS_SIM_SCGC7_OFFSET 0x0040 /* System Clock Gating Control Register 7 */
+#define KINETIS_SIM_CLKDIV1_OFFSET 0x0044 /* System Clock Divider Register 1 */
+#define KINETIS_SIM_CLKDIV2_OFFSET 0x0048 /* System Clock Divider Register 2 */
+#define KINETIS_SIM_FCFG1_OFFSET 0x004c /* Flash Configuration Register 1 */
+#define KINETIS_SIM_FCFG2_OFFSET 0x0050 /* Flash Configuration Register 2 */
+#define KINETIS_SIM_UIDH_OFFSET 0x0054 /* Unique Identification Register High */
+#define KINETIS_SIM_UIDMH_OFFSET 0x0058 /* Unique Identification Register Mid-High */
+#define KINETIS_SIM_UIDML_OFFSET 0x005c /* Unique Identification Register Mid Low */
+#define KINETIS_SIM_UIDL_OFFSET 0x0060 /* Unique Identification Register Low */
+#if defined(KINETIS_SIM_HAS_CLKDIV3)
+# define KINETIS_SIM_CLKDIV3_OFFSET 0x0064 /* System Clock Divider Register 3 */
+#endif
+#if defined(KINETIS_SIM_HAS_CLKDIV4)
+# define KINETIS_SIM_CLKDIV4_OFFSET 0x0068 /* System Clock Divider Register 4 */
+#endif
/* Register Addresses ***************************************************************/
-/* NOTE: The SIM_SOPT1 register is located at a different base address than the
- * other SIM registers.
+/* NOTE: The SIM_SOPT1, SIM_SOPT1CFG and SIM_USBPHYCTL registers are located at a
+ * different base address than the other SIM registers.
*/
-#define KINETIS_SIM_SOPT1 (KINETIS_SIMLP_BASE+KINETIS_SIM_SOPT1_OFFSET)
-#define KINETIS_SIM_SOPT2 (KINETIS_SIM_BASE+KINETIS_SIM_SOPT2_OFFSET)
-#define KINETIS_SIM_SOPT4 (KINETIS_SIM_BASE+KINETIS_SIM_SOPT4_OFFSET)
-#define KINETIS_SIM_SOPT5 (KINETIS_SIM_BASE+KINETIS_SIM_SOPT5_OFFSET)
-#define KINETIS_SIM_SOPT6 (KINETIS_SIM_BASE+KINETIS_SIM_SOPT6_OFFSET)
-#define KINETIS_SIM_SOPT7 (KINETIS_SIM_BASE+KINETIS_SIM_SOPT7_OFFSET)
-#define KINETIS_SIM_SDID (KINETIS_SIM_BASE+KINETIS_SIM_SDID_OFFSET)
-#define KINETIS_SIM_SCGC1 (KINETIS_SIM_BASE+KINETIS_SIM_SCGC1_OFFSET)
-#define KINETIS_SIM_SCGC2 (KINETIS_SIM_BASE+KINETIS_SIM_SCGC2_OFFSET)
-#define KINETIS_SIM_SCGC3 (KINETIS_SIM_BASE+KINETIS_SIM_SCGC3_OFFSET)
-#define KINETIS_SIM_SCGC4 (KINETIS_SIM_BASE+KINETIS_SIM_SCGC4_OFFSET)
-#define KINETIS_SIM_SCGC5 (KINETIS_SIM_BASE+KINETIS_SIM_SCGC5_OFFSET)
-#define KINETIS_SIM_SCGC6 (KINETIS_SIM_BASE+KINETIS_SIM_SCGC6_OFFSET)
-#define KINETIS_SIM_SCGC7 (KINETIS_SIM_BASE+KINETIS_SIM_SCGC7_OFFSET)
-#define KINETIS_SIM_CLKDIV1 (KINETIS_SIM_BASE+KINETIS_SIM_CLKDIV1_OFFSET)
-#define KINETIS_SIM_CLKDIV2 (KINETIS_SIM_BASE+KINETIS_SIM_CLKDIV2_OFFSET)
-#define KINETIS_SIM_FCFG1 (KINETIS_SIM_BASE+KINETIS_SIM_FCFG1_OFFSET)
-#define KINETIS_SIM_FCFG2 (KINETIS_SIM_BASE+KINETIS_SIM_FCFG2_OFFSET)
-#define KINETIS_SIM_UIDH (KINETIS_SIM_BASE+KINETIS_SIM_UIDH_OFFSET)
-#define KINETIS_SIM_UIDMH (KINETIS_SIM_BASE+KINETIS_SIM_UIDMH_OFFSET)
-#define KINETIS_SIM_UIDML (KINETIS_SIM_BASE+KINETIS_SIM_UIDML_OFFSET)
-#define KINETIS_SIM_UIDL (KINETIS_SIM_BASE+KINETIS_SIM_UIDL_OFFSET)
+#define KINETIS_SIM_SOPT1 (KINETIS_SIMLP_BASE+KINETIS_SIM_SOPT1_OFFSET)
+#if defined(KINETIS_SIM_HAS_SOPT1CFG)
+# define KINETIS_SIM_SOPT1CFG (KINETIS_SIMLP_BASE+KINETIS_SIM_SOPT1CFG_OFFSET)
+#endif
+#if defined(KINETIS_SIM_HAS_USBPHYCTL)
+# define KINETIS_SIM_USBPHYCTL (KINETIS_SIMLP_BASE+KINETIS_SIM_USBPHYCTL_OFFSET)
+#endif
+#define KINETIS_SIM_SOPT2 (KINETIS_SIM_BASE+KINETIS_SIM_SOPT2_OFFSET)
+#define KINETIS_SIM_SOPT4 (KINETIS_SIM_BASE+KINETIS_SIM_SOPT4_OFFSET)
+#define KINETIS_SIM_SOPT5 (KINETIS_SIM_BASE+KINETIS_SIM_SOPT5_OFFSET)
+#define KINETIS_SIM_SOPT6 (KINETIS_SIM_BASE+KINETIS_SIM_SOPT6_OFFSET)
+#define KINETIS_SIM_SOPT7 (KINETIS_SIM_BASE+KINETIS_SIM_SOPT7_OFFSET)
+#if defined(KINETIS_SIM_HAS_SOPT8)
+# define KINETIS_SIM_SOPT8 (KINETIS_SIM_BASE+KINETIS_SIM_SOPT8_OFFSET)
+#endif
+#if defined(KINETIS_SIM_HAS_SOPT9)
+# define KINETIS_SIM_SOPT9 (KINETIS_SIM_BASE+KINETIS_SIM_SOPT8_OFFSET)
+#endif
+#define KINETIS_SIM_SDID (KINETIS_SIM_BASE+KINETIS_SIM_SDID_OFFSET)
+#define KINETIS_SIM_SCGC1 (KINETIS_SIM_BASE+KINETIS_SIM_SCGC1_OFFSET)
+#define KINETIS_SIM_SCGC2 (KINETIS_SIM_BASE+KINETIS_SIM_SCGC2_OFFSET)
+#define KINETIS_SIM_SCGC3 (KINETIS_SIM_BASE+KINETIS_SIM_SCGC3_OFFSET)
+#define KINETIS_SIM_SCGC4 (KINETIS_SIM_BASE+KINETIS_SIM_SCGC4_OFFSET)
+#define KINETIS_SIM_SCGC5 (KINETIS_SIM_BASE+KINETIS_SIM_SCGC5_OFFSET)
+#define KINETIS_SIM_SCGC6 (KINETIS_SIM_BASE+KINETIS_SIM_SCGC6_OFFSET)
+#define KINETIS_SIM_SCGC7 (KINETIS_SIM_BASE+KINETIS_SIM_SCGC7_OFFSET)
+#define KINETIS_SIM_CLKDIV1 (KINETIS_SIM_BASE+KINETIS_SIM_CLKDIV1_OFFSET)
+#define KINETIS_SIM_CLKDIV2 (KINETIS_SIM_BASE+KINETIS_SIM_CLKDIV2_OFFSET)
+#define KINETIS_SIM_FCFG1 (KINETIS_SIM_BASE+KINETIS_SIM_FCFG1_OFFSET)
+#define KINETIS_SIM_FCFG2 (KINETIS_SIM_BASE+KINETIS_SIM_FCFG2_OFFSET)
+#define KINETIS_SIM_UIDH (KINETIS_SIM_BASE+KINETIS_SIM_UIDH_OFFSET)
+#define KINETIS_SIM_UIDMH (KINETIS_SIM_BASE+KINETIS_SIM_UIDMH_OFFSET)
+#define KINETIS_SIM_UIDML (KINETIS_SIM_BASE+KINETIS_SIM_UIDML_OFFSET)
+#define KINETIS_SIM_UIDL (KINETIS_SIM_BASE+KINETIS_SIM_UIDL_OFFSET)
+#if defined(KINETIS_SIM_HAS_CLKDIV3)
+# define KINETIS_SIM_CLKDIV3 (KINETIS_SIM_BASE+KINETIS_SIM_CLKDIV3_OFFSET)
+#endif
+#if defined(KINETIS_SIM_HAS_CLKDIV4)
+# define KINETIS_SIM_CLKDIV4 (KINETIS_SIM_BASE+KINETIS_SIM_CLKDIV4_OFFSET)
+#endif
/* Register Bit Definitions *********************************************************/
/* System Options Register 1 */
- /* Bits 0-11: Reserved */
-#define SIM_SOPT1_RAMSIZE_SHIFT (12) /* Bits 12-15: RAM size */
-#define SIM_SOPT1_RAMSIZE_MASK (15 << SIM_SOPT1_RAMSIZE_SHIFT)
-# define SIM_SOPT1_RAMSIZE_32KB (5 << SIM_SOPT1_RAMSIZE_SHIFT) /* 32 KBytes */
-# define SIM_SOPT1_RAMSIZE_64KB (7 << SIM_SOPT1_RAMSIZE_SHIFT) /* 64 KBytes */
-# define SIM_SOPT1_RAMSIZE_96KB (8 << SIM_SOPT1_RAMSIZE_SHIFT) /* 96 KBytes */
-# define SIM_SOPT1_RAMSIZE_128KB (9 << SIM_SOPT1_RAMSIZE_SHIFT) /* 128 KBytes */
- /* Bits 16-18: Reserved */
-#define SIM_SOPT1_OSC32KSEL (1 << 19) /* Bit 19: 32K oscillator clock select */
- /* Bits 20-22: Reserved */
-#define SIM_SOPT1_MS (1 << 23) /* Bit 23: EzPort chip select pin state */
- /* Bits 24-29: Reserved */
-#define SIM_SOPT1_USBSTBY (1 << 30) /* Bit 30: USB voltage regulator in standby mode */
-#define SIM_SOPT1_USBREGEN (1 << 31) /* Bit 31: USB voltage regulator enable */
+ /* Bits 0-11: Reserved */
+#if defined(KINETIS_SIM_HAS_SOPT1_RAMSIZE)
+# define SIM_SOPT1_RAMSIZE_SHIFT (12) /* Bits 12-15: RAM size */
+# define SIM_SOPT1_RAMSIZE_MASK (15 << SIM_SOPT1_RAMSIZE_SHIFT)
+# define SIM_SOPT1_RAMSIZE_32KB (5 << SIM_SOPT1_RAMSIZE_SHIFT) /* 32 KBytes */
+# define SIM_SOPT1_RAMSIZE_64KB (7 << SIM_SOPT1_RAMSIZE_SHIFT) /* 64 KBytes */
+# define SIM_SOPT1_RAMSIZE_96KB (8 << SIM_SOPT1_RAMSIZE_SHIFT) /* 96 KBytes */
+# define SIM_SOPT1_RAMSIZE_128KB (9 << SIM_SOPT1_RAMSIZE_SHIFT) /* 128 KBytes */
+# define SIM_SOPT1_RAMSIZE_256KB (10 << SIM_SOPT1_RAMSIZE_SHIFT) /* 256 KBytes */
+#endif
+ /* Bits 16-18: Reserved */
+#if defined(KINETIS_SIM_HAS_SOPT1_OSC32KSEL)
+# define SIM_SOPT1_OSC32KSEL_SHIFT (20-KINETIS_SIM_HAS_SOPT1_OSC32KSEL_BITS) /* Bit 19 or 18: 32K oscillator clock select */
+# define SIM_SOPT1_OSC32KSEL_MASK (KINETIS_SIM_SOPT1_OSC32KSEL_MASK << SIM_SOPT1_OSC32KSEL_SHIFT)
+# define SIM_SOPT1_OSC32KSEL(n) ((((n) & KINETIS_SIM_SOPT1_OSC32KSEL_MASK)) << SIM_SOPT1_OSC32KSEL_SHIFT)
+# if KINETIS_SIM_HAS_SOPT1_OSC32KSEL_BITS == 1
+# define SIM_SOPT1_OSC32KSEL_OSC32KCLK (((0 & KINETIS_SIM_SOPT1_OSC32KSEL_MASK)) << SIM_SOPT1_OSC32KSEL_SHIFT)
+# define SIM_SOPT1_OSC32KSEL_RTC (((1 & KINETIS_SIM_SOPT1_OSC32KSEL_MASK)) << SIM_SOPT1_OSC32KSEL_SHIFT)
+# endif
+# if KINETIS_SIM_HAS_SOPT1_OSC32KSEL_BITS == 2
+# define SIM_SOPT1_OSC32KSEL_OSC32KCLK (((0 & KINETIS_SIM_SOPT1_OSC32KSEL_MASK)) << SIM_SOPT1_OSC32KSEL_SHIFT)
+# define SIM_SOPT1_OSC32KSEL_RTC (((2 & KINETIS_SIM_SOPT1_OSC32KSEL_MASK)) << SIM_SOPT1_OSC32KSEL_SHIFT)
+# define SIM_SOPT1_OSC32KSEL_LPO1KZ (((3 & KINETIS_SIM_SOPT1_OSC32KSEL_MASK)) << SIM_SOPT1_OSC32KSEL_SHIFT)
+# endif
+#endif
+ /* Bits 20-28: Reserved */
+#if defined(KINETIS_SIM_HAS_SOPT1_USBVSTBY)
+ /* Bits 24-28: Reserved */
+# define SIM_SOPT1_USBVSTBY (1 << 29) /* Bit 29: USB voltage regulator in standby mode during VLPR and VLPW modes */
+#endif
+#if defined(KINETIS_SIM_HAS_SOPT1_USBSSTBY)
+# define SIM_SOPT1_USBSTBY (1 << 30) /* Bit 30: USB voltage regulator in standby mode */
+#endif
+#if defined(KINETIS_SIM_HAS_SOPT1_USBREGEN)
+# define SIM_SOPT1_USBREGEN (1 << 31) /* Bit 31: USB voltage regulator enable */
+#endif
+
+#if defined(KINETIS_SIM_HAS_SOPT1CFG)
+/* SOPT1 Configuration Register */
+
+ /* Bits 0-22: Reserved */
+# if defined(KINETIS_SIM_HAS_SOPT1CFG_URWE)
+# define SIM_SOPT1CFG_URWE (1 << 24) /* Bit 24: USB voltage regulator enable write enable */
+# endif
+# if defined(KINETIS_SIM_HAS_SOPT1CFG_USSWE)
+# define SIM_SOPT1CFG_USSWE (1 << 25) /* Bit 25: USB voltage regulator VLP standby write enable */
+# endif
+# if defined(KINETIS_SIM_HAS_SOPT1CFG_UVSWE)
+# define SIM_SOPT1CFG_UVSWE (1 << 26) /* Bit 26: USB voltage regulator stop standby write enable */
+# endif
+ /* Bits 27-31: Reserved */
+#endif
+
+
+#if defined(KINETIS_SIM_HAS_USBPHYCTL)
+/* USB PHY Control Register */
+
+ /* Bits 0-7: Reserved */
+# if defined(KINETIS_SIM_HAS_USBPHYCTL_USBVREGSEL)
+# define SIM_USBPHYCTL_USBVREGSEL (1 << 8) /* Bit 8: Selects the default input voltage source */
+# endif
+# if defined(KINETIS_SIM_HAS_USBPHYCTL_USBVREGPD)
+# define SIM_USBPHYCTL_USBVREGPD (1 << 9) /* Bit 9: Enables the pulldown on the output of the USB Regulator */
+# endif
+ /* Bits 10-19: Reserved */
+# if defined(KINETIS_SIM_HAS_USBPHYCTL_USB3VOUTTRG)
+# define SIM_USBPHYCTL_USB3VOUTTRG_SHIFT (20) /* Bit 20-22: USB 3.3V Output Target */
+# define SIM_USBPHYCTL_USB3VOUTTRG_MASK (7 << SIM_USBPHYCTL_USB3VOUTTRG_SHIFT)
+# define SIM_USBPHYCTL_USB3VOUTTRG_2V733 (0 << SIM_USBPHYCTL_USB3VOUTTRG_SHIFT) /* 2.733V */
+# define SIM_USBPHYCTL_USB3VOUTTRG_3V020 (1 << SIM_USBPHYCTL_USB3VOUTTRG_SHIFT) /* 3.020V */
+# define SIM_USBPHYCTL_USB3VOUTTRG_3V074 (2 << SIM_USBPHYCTL_USB3VOUTTRG_SHIFT) /* 3.074V */
+# define SIM_USBPHYCTL_USB3VOUTTRG_3V130 (3 << SIM_USBPHYCTL_USB3VOUTTRG_SHIFT) /* 3.130V */
+# define SIM_USBPHYCTL_USB3VOUTTRG_3V188 (4 << SIM_USBPHYCTL_USB3VOUTTRG_SHIFT) /* 3.188V */
+# define SIM_USBPHYCTL_USB3VOUTTRG_3V248 (5 << SIM_USBPHYCTL_USB3VOUTTRG_SHIFT) /* 3.248V */
+# define SIM_USBPHYCTL_USB3VOUTTRG_3V310 (6 << SIM_USBPHYCTL_USB3VOUTTRG_SHIFT) /* 3.310V (default) */
+# define SIM_USBPHYCTL_USB3VOUTTRG_3V662 (7 << SIM_USBPHYCTL_USB3VOUTTRG_SHIFT) /* 3.662V (For Freescale use only, not for customer use) */
+# endif
+# if defined(KINETIS_SIM_HAS_USBPHYCTL_USBDISILIM)
+# define SIM_USBPHYCTL_USBDISILIM (1 << 23) /* Bit 23: USB Disable Inrush Current Limit */
+# endif
+ /* Bits 24-31: Reserved */
+#endif
/* System Options Register 2 */
-#define SIM_SOPT2_MCGCLKSEL (1 << 0) /* Bit 0: MCG clock select */
- /* Bits 1-7: Reserved */
-#define SIM_SOPT2_FBSL_SHIFT (8) /* Bits 8-9: FlexBus security level */
-#define SIM_SOPT2_FBSL_MASK (3 << SIM_SOPT2_FBSL_SHIFT)
-# define SIM_SOPT2_FBSL_NONE (0 << SIM_SOPT2_FBSL_SHIFT) /* All off-chip accesses disallowed */
-# define SIM_SOPT2_FBSL_DATA (2 << SIM_SOPT2_FBSL_SHIFT) /* Off-chip data accesses are allowed */
-# define SIM_SOPT2_FBSL_ALL (3 << SIM_SOPT2_FBSL_SHIFT) /* All Off-chip accesses allowed */
- /* Bit 10: Reserved */
-#define SIM_SOPT2_CMTUARTPAD (1 << 11) /* Bit 11: CMT/UART pad drive strength */
-#define SIM_SOPT2_TRACECLKSEL (1 << 12) /* Bit 12: Debug trace clock select */
- /* Bits 13-15: Reserved */
-#define SIM_SOPT2_PLLFLLSEL (1 << 16) /* Bit 16: PLL/FLL clock select */
- /* Bit 17: Reserved */
-#define SIM_SOPT2_USBSRC (1 << 18) /* Bit 18: USB clock source select */
- /* Bit 19: Reserved */
-#if defined(KINETIS_K60) || defined(KINETIS_K64) || defined(KINETIS_K66)
-# define SIM_SOPT2_RMIISRC_SHIFT (19) /* Bit 19: RMII clock source select */
-# define SIM_SOPT2_RMIISRC_EXTAL (0 << SIM_SOPT2_RMIISRC_SHIFT) /* EXTAL clock */
-# define SIM_SOPT2_RMIISRC_EXTBYP (1 << SIM_SOPT2_RMIISRC_SHIFT) /* External bypass clock (ENET_1588_CLKIN) */
-# define SIM_SOPT2_TIMESRC_SHIFT (20) /* Bit 20-21: IEEE 1588 timestamp clock source select (K60) */
-# define SIM_SOPT2_TIMESRC_MASK (3 << SIM_SOPT2_TIMESRC_SHIFT)
-# define SIM_SOPT2_TIMESRC_CORE (0 << SIM_SOPT2_TIMESRC_SHIFT) /* Core/system clock */
-# define SIM_SOPT2_TIMESRC_PLLSEL (1 << SIM_SOPT2_TIMESRC_SHIFT) /* MCGFLLCLK,MCGPLLCLK,IRC48M,USB1 PFD
- clock as selected by SOPT2[PLLFLLSEL] */
-# define SIM_SOPT2_TIMESRC_OSCERCLK (2 << SIM_SOPT2_TIMESRC_SHIFT) /* OSCERCLK clock */
-# define SIM_SOPT2_TIMESRC_EXTBYP (0 << SIM_SOPT2_TIMESRC_SHIFT) /* External bypass clock (ENET_1588_CLKIN) */
-#endif
- /* Bits 12-23: Reserved */
-#define SIM_SOPT2_I2SSRC_SHIFT (24) /* Bits 24-25: I2S master clock source select */
-#define SIM_SOPT2_I2SSRC_MASK (3 << SIM_SOPT2_I2SSRC_SHIFT)
-# define SIM_SOPT2_I2SCSRC_CORE (0 << SIM_SOPT2_I2SSRC_SHIFT) /* Core/system clock / I2S fractional divider*/
-# define SIM_SOPT2_I2SCSRC_MCGCLK (1 << SIM_SOPT2_I2SSRC_SHIFT) /* MCGPLLCLK/MCGFLLCLK clock/ I2S fractional divider */
-# define SIM_SOPT2_I2SCSRC_OCSERCLK (2 << SIM_SOPT2_I2SSRC_SHIFT) /* OSCERCLK clock */
-# define SIM_SOPT2_I2SCSRC_EXTBYP (3 << SIM_SOPT2_I2SSRC_SHIFT) /* External bypass clock (I2S0_CLKIN) */
- /* Bits 26-27: Reserved */
-#define SIM_SOPT2_SDHCSRC_SHIFT (28) /* Bits 28-29: SDHC clock source select*/
-#define SIM_SOPT2_SDHCSRC_MASK (3 << SIM_SOPT2_SDHCSRC_SHIFT)
-# define SIM_SOPT2_SDHCSRC_CORE (0 << SIM_SOPT2_SDHCSRC_SHIFT) /* Core/system clock */
-# define SIM_SOPT2_SDHCSRC_MCGCLK (1 << SIM_SOPT2_SDHCSRC_SHIFT) /* MCGPLLCLK/MCGFLLCLK clock */
-# define SIM_SOPT2_SDHCSRC_OCSERCLK (2 << SIM_SOPT2_SDHCSRC_SHIFT) /* OSCERCLK clock */
-# define SIM_SOPT2_SDHCSRC_EXTBYP (3 << SIM_SOPT2_SDHCSRC_SHIFT) /* External bypass clock (SDHC0_CLKIN) */ /* Bits 30-31: Reserved */
+#if defined(KINETIS_SIM_HAS_SOPT2)
+# if defined(KINETIS_SIM_HAS_SOPT2_MCGCLKSEL)
+# define SIM_SOPT2_MCGCLKSEL (1 << 0) /* Bit 0: MCG clock select */
+# endif
+# if defined(KINETIS_SIM_HAS_SOPT2_USBSLSRC)
+# define SIM_SOPT2_USBSLSRC (1 << 0) /* Bit 0: USB Slow Clock Source */
+# endif
+# if defined(KINETIS_SIM_HAS_SOPT2_USBREGEN)
+# define SIM_SOPT2_USBREGEN (1 << 1) /* Bit 1: USB PHY PLL Regulator Enable */
+# endif
+ /* Bits 2-3: Reserved */
+# if defined(KINETIS_SIM_HAS_SOPT2_USBHSRC)
+# define SIM_SOPT2_USBSHSRC_SHIFT (2) /* Bit 2-3: USB HS clock source select */
+# define SIM_SOPT2_USBSHSRC_MASK (3 << SIM_SOPT2_USBSHSRC_SHIFT)
+# define SIM_SOPT2_USBSHSRC_BUSCLK (0 << SIM_SOPT2_USBSHSRC_SHIFT)
+# define SIM_SOPT2_USBSHSRC_MCGPLL0CLK (1 << SIM_SOPT2_USBSHSRC_SHIFT)
+# define SIM_SOPT2_USBSHSRC_MCGPLL1CLK (2 << SIM_SOPT2_USBSHSRC_SHIFT)
+# define SIM_SOPT2_USBSHSRC_OSC0ERCLK (3 << SIM_SOPT2_USBSHSRC_SHIFT)
+# endif
+# if defined(KINETIS_SIM_HAS_SOPT2_RTCCLKOUTSEL)
+# define SIM_SOPT2_RTCCLKOUTSEL (1 << 4) /* Bit 4: RTC clock out select */
+# endif
+# if defined(KINETIS_SIM_HAS_SOPT2_CLKOUTSEL)
+# define SIM_SOPT2_CLKOUTSEL_SHIFT (5) /* Bits 5-7: CLKOUT select */
+# define SIM_SOPT2_CLKOUTSEL_MASK (7 << SIM_SOPT2_CLKOUTSEL_SHIFT)
+# define SIM_SOPT2_CLKOUTSEL_FBCLKOUT (0 << SIM_SOPT2_CLKOUTSEL_SHIFT)
+# define SIM_SOPT2_CLKOUTSEL_FLSHCLK (2 << SIM_SOPT2_CLKOUTSEL_SHIFT)
+# define SIM_SOPT2_CLKOUTSEL_LPO1KHZ (3 << SIM_SOPT2_CLKOUTSEL_SHIFT)
+# define SIM_SOPT2_CLKOUTSEL_MCGIRCLK (4 << SIM_SOPT2_CLKOUTSEL_SHIFT)
+# define SIM_SOPT2_CLKOUTSEL_RTC32768KHZ (5 << SIM_SOPT2_CLKOUTSEL_SHIFT)
+# define SIM_SOPT2_CLKOUTSEL_OSCERCLK0 (6 << SIM_SOPT2_CLKOUTSEL_SHIFT)
+# define SIM_SOPT2_CLKOUTSEL_IRC48MHZ (7 << SIM_SOPT2_CLKOUTSEL_SHIFT)
+# endif
+# if defined(KINETIS_SIM_HAS_SOPT2_FBSL)
+# define SIM_SOPT2_FBSL_SHIFT (8) /* Bits 8-9: FlexBus security level */
+# define SIM_SOPT2_FBSL_MASK (3 << SIM_SOPT2_FBSL_SHIFT)
+# define SIM_SOPT2_FBSL_NONE (0 << SIM_SOPT2_FBSL_SHIFT) /* All off-chip accesses disallowed */
+# define SIM_SOPT2_FBSL_DATA (2 << SIM_SOPT2_FBSL_SHIFT) /* Off-chip data accesses are allowed */
+# define SIM_SOPT2_FBSL_ALL (3 << SIM_SOPT2_FBSL_SHIFT) /* All Off-chip accesses allowed */
+# endif
+ /* Bit 10: Reserved */
+# if defined(KINETIS_SIM_HAS_SOPT2_CMTUARTPAD)
+# define SIM_SOPT2_CMTUARTPAD (1 << 11) /* Bit 11: CMT/UART pad drive strength */
+# endif
+# if defined(KINETIS_SIM_HAS_SOPT2_PTD7PAD)
+# define SIM_SOPT2_PTD7PAD (1 << 11) /* Bit 11: PTD7P pad drive strength */
+# endif
+# if defined(KINETIS_SIM_HAS_SOPT2_TRACECLKSEL)
+# define SIM_SOPT2_TRACECLKSEL (1 << 12) /* Bit 12: Debug trace clock select */
+# endif
+ /* Bits 13-15: Reserved */
+# if defined(KINETIS_SIM_HAS_SOPT2_PLLFLLSEL)
+# define SIM_SOPT2_PLLFLLSEL_SHIFT (16) /* Bits 16-[17]: PLL/FLL clock select */
+# define SIM_SOPT2_PLLFLLSEL_MASK (KINETIS_SIM_SOPT2_PLLFLLSEL_MASK << SIM_SOPT2_PLLFLLSEL_SHIFT)
+# define SIM_SOPT2_PLLFLLSEL(n) (((n) & KINETIS_SIM_SOPT2_PLLFLLSEL_MASK) << SIM_SOPT2_PLLFLLSEL_SHIFT)
+# define SIM_SOPT2_PLLFLLSEL_MCGFLLCLK ((0 & KINETIS_SIM_SOPT2_PLLFLLSEL_MASK) << SIM_SOPT2_PLLFLLSEL_SHIFT)
+# define SIM_SOPT2_PLLFLLSEL_MCGPLLCLK ((1 & KINETIS_SIM_SOPT2_PLLFLLSEL_MASK) << SIM_SOPT2_PLLFLLSEL_SHIFT)
+# if KINETIS_SIM_HAS_SOPT2_PLLFLLSEL_BITS > 1
+# define SIM_SOPT2_PLLFLLSEL_USB1PFD ((2 & KINETIS_SIM_SOPT2_PLLFLLSEL_MASK) << SIM_SOPT2_PLLFLLSEL_SHIFT)
+# define SIM_SOPT2_PLLFLLSEL_IRC48MHZ ((3 & KINETIS_SIM_SOPT2_PLLFLLSEL_MASK) << SIM_SOPT2_PLLFLLSEL_SHIFT)
+# endif
+# endif
+ /* Bit 17: Reserved */
+# if defined(KINETIS_SIM_HAS_SOPT2_USBSRC)
+# define SIM_SOPT2_USBSRC (1 << 18) /* Bit 18: USB clock source select */
+# endif
+ /* Bit 19: Reserved */
+# if defined(KINETIS_SIM_HAS_SOPT2_RMIISRC)
+# define SIM_SOPT2_RMIISRC_SHIFT (19) /* Bit 19: RMII clock source select */
+# define SIM_SOPT2_RMIISRC_EXTAL (0 << SIM_SOPT2_RMIISRC_SHIFT) /* EXTAL clock */
+# define SIM_SOPT2_RMIISRC_EXTBYP (1 << SIM_SOPT2_RMIISRC_SHIFT) /* External bypass clock (ENET_1588_CLKIN) */
+# endif
+# if defined(KINETIS_SIM_HAS_SOPT2_TIMESRC)
+# define SIM_SOPT2_TIMESRC_SHIFT (20) /* Bit 20-21: IEEE 1588 timestamp clock source select */
+# define SIM_SOPT2_TIMESRC_MASK (3 << SIM_SOPT2_TIMESRC_SHIFT)
+# define SIM_SOPT2_TIMESRC_CORE (0 << SIM_SOPT2_TIMESRC_SHIFT) /* Core/system clock */
+# define SIM_SOPT2_TIMESRC_PLLSEL (1 << SIM_SOPT2_TIMESRC_SHIFT) /* MCGFLLCLK,MCGPLLCLK,IRC48M,USB1 PFD
+ clock as selected by SOPT2[PLLFLLSEL] */
+# define SIM_SOPT2_TIMESRC_OSCERCLK (2 << SIM_SOPT2_TIMESRC_SHIFT) /* OSCERCLK clock */
+# define SIM_SOPT2_TIMESRC_EXTBYP (3 << SIM_SOPT2_TIMESRC_SHIFT) /* External bypass clock (ENET_1588_CLKIN) */
+# endif
+# if defined(KINETIS_SIM_HAS_SOPT2_FLEXIOSRC)
+ /* TBD */
+# endif
+ /* Bits 22-23: Reserved */
+# if defined(KINETIS_SIM_HAS_SOPT2_USBFSRC)
+# define SIM_SOPT2_USBFSRC_SHIFT (22) /* Bits 22-23: USB FS clock source select */
+# define SIM_SOPT2_USBFSRC_MASK (3 << SIM_SOPT2_USBFSRC_SHIFT)
+# define SIM_SOPT2_USBFSRC_MCGCLK (0 << SIM_SOPT2_USBFSRC_SHIFT) /* MCGFLLCLK,MCGPLLCLK clock as selected by SOPT2[PLLFLLSEL] */
+# define SIM_SOPT2_USBFSRC_MCGPLL0CLK (1 << SIM_SOPT2_USBFSRC_SHIFT) /* MCGPLL0CLK clock */
+# define SIM_SOPT2_USBFSRC_MCGPLL1CLK (2 << SIM_SOPT2_USBFSRC_SHIFT) /* MCGPLL1CLK clock */
+# define SIM_SOPT2_USBFSRC_OCS0ERCLK (3 << SIM_SOPT2_USBFSRC_SHIFT) /* OSC0ERCLK clock */
+# endif
+# if defined(KINETIS_SIM_HAS_SOPT2_TPMSRC)
+# define SIM_SOPT2_TPMSRC_SHIFT (24) /* Bits 24-25: TPM clock source select */
+# define SIM_SOPT2_TPMSRC_MASK (3 << SIM_SOPT2_TPMSRC_SHIFT)
+# define SIM_SOPT2_TPMSRC_CORE (0 << SIM_SOPT2_TPMSRC_SHIFT) /* Clock disabled */
+# define SIM_SOPT2_TPMSRC_MCGCLK (1 << SIM_SOPT2_TPMSRC_SHIFT) /* MCGFLLCLK,MCGPLLCLK,IRC48M,USB1 PFD
+ clock as selected by SOPT2[PLLFLLSEL] and then
+ divided by the PLLFLLCLK fractional divider
+ as configured by SIM_CLKDIV3[PLLFLLFRAC, PLLFLLDIV] */
+# define SIM_SOPT2_TPMSRC_OCSERCLK (2 << SIM_SOPT2_TPMSRC_SHIFT) /* OSCERCLK clock */
+# define SIM_SOPT2_TPMSRC_EXTBYP (3 << SIM_SOPT2_TPMSRC_SHIFT) /* MCGIRCLK clock */
+# endif
+# if defined(KINETIS_SIM_HAS_SOPT2_I2SSRC)
+# define SIM_SOPT2_I2SSRC_SHIFT (24) /* Bits 24-25: I2S master clock source select */
+# define SIM_SOPT2_I2SSRC_MASK (3 << SIM_SOPT2_I2SSRC_SHIFT)
+# define SIM_SOPT2_I2SCSRC_CORE (0 << SIM_SOPT2_I2SSRC_SHIFT) /* Core/system clock / I2S fractional divider */
+# define SIM_SOPT2_I2SCSRC_MCGCLK (1 << SIM_SOPT2_I2SSRC_SHIFT) /* MCGPLLCLK/MCGFLLCLK clock/ I2S fractional divider */
+# define SIM_SOPT2_I2SCSRC_OCSERCLK (2 << SIM_SOPT2_I2SSRC_SHIFT) /* OSCERCLK clock */
+# define SIM_SOPT2_I2SCSRC_EXTBYP (3 << SIM_SOPT2_I2SSRC_SHIFT) /* External bypass clock (I2S0_CLKIN) */
+# endif
+ /* Bits 26-27: Reserved */
+# if defined(KINETIS_SIM_HAS_SOPT2_LPUARTSRC)
+# define SIM_SOPT2_LPUARTSRC_SHIFT (26) /* Bits 26-27: LPUART clock source select */
+# define SIM_SOPT2_LPUARTSRC_MASK (3 << SIM_SOPT2_LPUARTSRC_SHIFT)
+# define SIM_SOPT2_LPUARTSRC_CORE (0 << SIM_SOPT2_LPUARTSRC_SHIFT) /* Clock disabled */
+# define SIM_SOPT2_LPUARTSRC_MCGCLK (1 << SIM_SOPT2_LPUARTSRC_SHIFT) /* MCGFLLCLK,MCGPLLCLK,IRC48M,USB1 PFD
+ clock as selected by SOPT2[PLLFLLSEL] and then
+ divided by the PLLFLLCLK fractional divider
+ as configured by SIM_CLKDIV3[PLLFLLFRAC, PLLFLLDIV] */
+# define SIM_SOPT2_LPUARTSRC_OCSERCLK (2 << SIM_SOPT2_LPUARTSRC_SHIFT) /* OSCERCLK clock */
+# define SIM_SOPT2_LPUARTSRC_EXTBYP (3 << SIM_SOPT2_LPUARTSRC_SHIFT) /* MCGIRCLK clock */
+# endif
+# if defined(KINETIS_SIM_HAS_SOPT2_SDHCSRC)
+# define SIM_SOPT2_SDHCSRC_SHIFT (28) /* Bits 28-29: SDHC clock source select */
+# define SIM_SOPT2_SDHCSRC_MASK (3 << SIM_SOPT2_SDHCSRC_SHIFT)
+# define SIM_SOPT2_SDHCSRC_CORE (0 << SIM_SOPT2_SDHCSRC_SHIFT) /* Core/system clock */
+# define SIM_SOPT2_SDHCSRC_MCGCLK (1 << SIM_SOPT2_SDHCSRC_SHIFT) /* MCGPLLCLK/MCGFLLCLK clock */
+# define SIM_SOPT2_SDHCSRC_OCSERCLK (2 << SIM_SOPT2_SDHCSRC_SHIFT) /* OSCERCLK clock */
+# define SIM_SOPT2_SDHCSRC_EXTBYP (3 << SIM_SOPT2_SDHCSRC_SHIFT) /* External bypass clock (SDHC0_CLKIN) */
+ /* Bits 30-31: Reserved */
+# endif
+ /* Bits 30-31: Reserved */
+# if defined(KINETIS_SIM_HAS_SOPT2_NFCSRC)
+# define SIM_SOPT2_NFCSRC_SHIFT (30) /* Bits 30-31: NFC Flash clock source select */
+# define SIM_SOPT2_NFCSRC_MASK (3 << SIM_SOPT2_NFCSRC_SHIFT)
+# define SIM_SOPT2_NFCSRC_BUS (0 << SIM_SOPT2_NFCSRC_SHIFT) /* BUS clock */
+# define SIM_SOPT2_NFCSRC_MCGPLL0CLK (1 << SIM_SOPT2_NFCSRC_SHIFT) /* MCGPLL0CLK clock */
+# define SIM_SOPT2_NFCSRC_MCGPLL1CLK (2 << SIM_SOPT2_NFCSRC_SHIFT) /* MCGPLL1CLK clock */
+# define SIM_SOPT2_NFCSRC_OCS0ERCLK (3 << SIM_SOPT2_NFCSRC_SHIFT) /* OSC0ERCLK clock */
+# endif
+#endif
/* System Options Register 4 */
-#define SIM_SOPT4_FTM0FLT0 (1 << 0) /* Bit 0: FTM0 Fault 0 Select */
-#define SIM_SOPT4_FTM0FLT1 (1 << 1) /* Bit 1: FTM0 Fault 1 Select */
-#define SIM_SOPT4_FTM0FLT2 (1 << 2) /* Bit 2: FTM0 Fault 2 Select */
- /* Bit 3: Reserved */
-#define SIM_SOPT4_FTM1FLT0 (1 << 4) /* Bit 4: FTM1 Fault 0 Select */
- /* Bits 5-7: Reserved */
-#define SIM_SOPT4_FTM2FLT0 (1 << 8) /* Bit 8: FTM2 Fault 0 Select */
- /* Bits 9-17: Reserved */
-#if defined(CONFIG_KINETIS_FTM3)
- /* Bits 9-11,13-17: Reserved */
-# define SIM_SOPT4_FTM3FLT0 (1 << 12) /* Bit 12: FTM3 Fault 0 Select */
-#endif
-#define SIM_SOPT4_FTM1CH0SRC_SHIFT (18) /* Bits 18-19: FTM1 channel 0 input capture source select */
-#define SIM_SOPT4_FTM1CH0SRC_MASK (3 << SIM_SOPT4_FTM1CH0SRC_SHIFT)
-# define SIM_SOPT4_FTM1CH0SRC_CH0 (0 << SIM_SOPT4_FTM1CH0SRC_SHIFT) /* FTM1_CH0 signal */
-# define SIM_SOPT4_FTM1CH0SRC_CMP0 (1 << SIM_SOPT4_FTM1CH0SRC_SHIFT) /* CMP0 output */
-# define SIM_SOPT4_FTM1CH0SRC_CMP1 (2 << SIM_SOPT4_FTM1CH0SRC_SHIFT) /* CMP1 output */
-#define SIM_SOPT4_FTM2CH0SRC_SHIFT (20) /* Bits 20-21: FTM2 channel 0 input capture source select */
-#define SIM_SOPT4_FTM2CH0SRC_MASK (3 << SIM_SOPT4_FTM2CH0SRC_SHIFT)
-# define SIM_SOPT4_FTM2CH0SRC_CH0 (0 << SIM_SOPT4_FTM2CH0SRC_SHIFT) /* FTM2_CH0 signal */
-# define SIM_SOPT4_FTM2CH0SRC_CMP0 (1 << SIM_SOPT4_FTM2CH0SRC_SHIFT) /* CMP0 output */
-# define SIM_SOPT4_FTM2CH0SRC_CMP1 (2 << SIM_SOPT4_FTM2CH0SRC_SHIFT) /* CMP1 output */
- /* Bits 22-23: Reserved */
-#define SIM_SOPT4_FTM0CLKSEL (1 << 24) /* Bit 24: FlexTimer 0 External Clock Pin Select */
-#define SIM_SOPT4_FTM1CLKSEL (1 << 25) /* Bit 25: FTM1 External Clock Pin Select */
-#define SIM_SOPT4_FTM2CLKSEL (1 << 26) /* Bit 26: FlexTimer 2 External Clock Pin Select */
- /* Bits 27-31: Reserved */
-#if defined(CONFIG_KINETIS_FTM3)
-# define SIM_SOPT4_FTM3CLKSEL (1 << 27) /* Bit 27: FlexTimer 3 External Clock Pin Select */
-# define SIM_SOPT4_FTM3TRG0SRC (1 << 30) /* Bit 30: FlexTimer 3 Hardware Trigger 0 Source Select */
-# define SIM_SOPT4_FTM3TRG1SRC (1 << 31) /* Bit 31: FlexTimer 3 Hardware Trigger 1 Source Select */
+#define SIM_SOPT4_FTM0FLT0 (1 << 0) /* Bit 0: FTM0 Fault 0 Select */
+#define SIM_SOPT4_FTM0FLT1 (1 << 1) /* Bit 1: FTM0 Fault 1 Select */
+#define SIM_SOPT4_FTM0FLT2 (1 << 2) /* Bit 2: FTM0 Fault 2 Select */
+ /* Bit 3: Reserved */
+#if defined(KINETIS_SIM_HAS_SOPT4_FTM0FLT3)
+# define SIM_SOPT4_FTM0FLT3 (1 << 3) /* Bit 3: FTM0 Fault 3 Select */
+#endif
+#define SIM_SOPT4_FTM1FLT0 (1 << 4) /* Bit 4: FTM1 Fault 0 Select */
+ /* Bits 5-7: Reserved */
+#define SIM_SOPT4_FTM2FLT0 (1 << 8) /* Bit 8: FTM2 Fault 0 Select */
+ /* Bits 9-17: Reserved */
+#if defined(KINETIS_SIM_HAS_SOPT4_FTM3FLT0)
+ /* Bits 9-11,13-17: Reserved */
+# define SIM_SOPT4_FTM3FLT0 (1 << 12) /* Bit 12: FTM3 Fault 0 Select */
+#endif
+#if defined(KINETIS_SIM_HAS_SOPT4_FTM1CH0SRC)
+# define SIM_SOPT4_FTM1CH0SRC_SHIFT (18) /* Bits 18-19: FTM1 channel 0 input capture source select */
+# define SIM_SOPT4_FTM1CH0SRC_MASK (3 << SIM_SOPT4_FTM1CH0SRC_SHIFT)
+# define SIM_SOPT4_FTM1CH0SRC_CH0 (0 << SIM_SOPT4_FTM1CH0SRC_SHIFT) /* FTM1_CH0 signal */
+# define SIM_SOPT4_FTM1CH0SRC_CMP0 (1 << SIM_SOPT4_FTM1CH0SRC_SHIFT) /* CMP0 output */
+# define SIM_SOPT4_FTM1CH0SRC_CMP1 (2 << SIM_SOPT4_FTM1CH0SRC_SHIFT) /* CMP1 output */
+# if KINETIS_SIM_HAS_SOPT4_FTM1CH0SRC > 2
+# define SIM_SOPT4_FTM1CH0SRC_USBSOF (3 << SIM_SOPT4_FTM1CH0SRC_SHIFT) /* USB start of frame pulse */
+# endif
+#endif
+#if defined(KINETIS_SIM_HAS_SOPT4_FTM2CH0SRC)
+# define SIM_SOPT4_FTM2CH0SRC_SHIFT (20) /* Bits 20-21: FTM2 channel 0 input capture source select */
+# define SIM_SOPT4_FTM2CH0SRC_MASK (3 << SIM_SOPT4_FTM2CH0SRC_SHIFT)
+# define SIM_SOPT4_FTM2CH0SRC_CH0 (0 << SIM_SOPT4_FTM2CH0SRC_SHIFT) /* FTM2_CH0 signal */
+# define SIM_SOPT4_FTM2CH0SRC_CMP0 (1 << SIM_SOPT4_FTM2CH0SRC_SHIFT) /* CMP0 output */
+# define SIM_SOPT4_FTM2CH0SRC_CMP1 (2 << SIM_SOPT4_FTM2CH0SRC_SHIFT) /* CMP1 output */
+#endif
+ /* Bits 22-23: Reserved */
+#if defined(KINETIS_SIM_HAS_SOPT4_FTM2CH1SRC)
+ /* Bit 23: Reserved */
+ #define SIM_SOPT4_FTM2CH1SRC (1 << 22) /* Bit 22: FTM2 channel 1 input capture source select */
+#endif
+#define SIM_SOPT4_FTM0CLKSEL (1 << 24) /* Bit 24: FlexTimer 0 External Clock Pin Select */
+#define SIM_SOPT4_FTM1CLKSEL (1 << 25) /* Bit 25: FTM1 External Clock Pin Select */
+#define SIM_SOPT4_FTM2CLKSEL (1 << 26) /* Bit 26: FlexTimer 2 External Clock Pin Select */
+ /* Bits 27-31: Reserved */
+#if defined(KINETIS_SIM_HAS_SOPT4_FTM3TRG1SRC) || defined(KINETIS_SIM_HAS_SOPT4_FTM3TRG0SRC)
+# define SIM_SOPT4_FTM3CLKSEL (1 << 27) /* Bit 27: FlexTimer 3 External Clock Pin Select */
+#endif
+#if defined(KINETIS_SIM_HAS_SOPT4_FTM0TRG0SRC)
+ /* Bits 27,30-31: Reserved */
+# define SIM_SOPT4_FTM0TRG0SRC (1 << 28) /* Bit 28: FlexTimer 0 Hardware Trigger 0 Source Select */
+#endif
+#if defined(KINETIS_SIM_HAS_SOPT4_FTM0TRG1SRC)
+ /* Bits 27,30-31: Reserved */
+# define SIM_SOPT4_FTM0TRG1SRC (1 << 29) /* Bit 29: FlexTimer 0 Hardware Trigger 1 Source Select */
+#endif
+#if defined(KINETIS_SIM_HAS_SOPT4_FTM3TRG0SRC)
+# define SIM_SOPT4_FTM3TRG0SRC (1 << 30) /* Bit 30: FlexTimer 3 Hardware Trigger 0 Source Select */
+#endif
+#if defined(KINETIS_SIM_HAS_SOPT4_FTM3TRG1SRC)
+# define SIM_SOPT4_FTM3TRG1SRC (1 << 31) /* Bit 31: FlexTimer 3 Hardware Trigger 1 Source Select */
#endif
/* System Options Register 5 */
-#define SIM_SOPT5_UART0TXSRC_SHIFT (0) /* Bits 0-1: UART 0 transmit data source select */
-#define SIM_SOPT5_UART0TXSRC_MASK (3 << SIM_SOPT5_UART0TXSRC_SHIFT)
-# define SIM_SOPT5_UART0TXSRC_TX (0 << SIM_SOPT5_UART0TXSRC_SHIFT) /* UART0_TX pin */
-# define SIM_SOPT5_UART0TXSRC_FTM1 (1 << SIM_SOPT5_UART0TXSRC_SHIFT) /* UART0_TX modulated with FTM1 ch0 output */
-# define SIM_SOPT5_UART0TXSRC_FTM2 (2 << SIM_SOPT5_UART0TXSRC_SHIFT) /* UART0_TX modulated with FTM2 ch0 output */
-#define SIM_SOPT5_UART0RXSRC_SHIFT (2) /* Bits 2-3: UART 0 receive data source select */
-#define SIM_SOPT5_UART0RXSRC_MASK (3 << SIM_SOPT5_UART0RXSRC_SHIFT)
-# define SIM_SOPT5_UART0RXSRC_RX (0 << SIM_SOPT5_UART0RXSRC_SHIFT) /* UART0_RX pin */
-# define SIM_SOPT5_UART0RXSRC_CMP0 (1 << SIM_SOPT5_UART0RXSRC_SHIFT) /* CMP0 */
-# define SIM_SOPT5_UART0RXSRC_CMP1 (2 << SIM_SOPT5_UART0RXSRC_SHIFT) /* CMP1 */
-#define SIM_SOPT5_UART1TXSRC_SHIFT (4) /* Bits 4-5: UART 1 transmit data source select */
-#define SIM_SOPT5_UART1TXSRC_MASK (3 << SIM_SOPT5_UART1TXSRC_SHIFT)
-# define SIM_SOPT5_UART1TXSRC_TX (0 << SIM_SOPT5_UART1TXSRC_SHIFT) /* UART1_TX pin */
-# define SIM_SOPT5_UART1TXSRC_FTM1 (1 << SIM_SOPT5_UART1TXSRC_SHIFT) /* UART1_TX modulated with FTM1 ch0 output */
-# define SIM_SOPT5_UART1TXSRC_FTM2 (2 << SIM_SOPT5_UART1TXSRC_SHIFT) /* UART1_TX modulated with FTM2 ch0 output */
-#define SIM_SOPT5_UART1RXSRC_SHIFT (6) /* Bits 6-7: UART 1 receive data source select */
-#define SIM_SOPT5_UART1RXSRC_MASK (3 << SIM_SOPT5_UART1RXSRC_SHIFT)
-# define SIM_SOPT5_UART1RXSRC_RX (0 << SIM_SOPT5_UART1RXSRC_SHIFT) /* UART1_RX pin */
-# define SIM_SOPT5_UART1RXSRC_CMP0 (1 << SIM_SOPT5_UART1RXSRC_SHIFT) /* CMP0 */
-# define SIM_SOPT5_UART1RXSRC_CMP1 (2 << SIM_SOPT5_UART1RXSRC_SHIFT) /* CMP1 */
- /* Bits 8-31: Reserved */
+#define SIM_SOPT5_UART0TXSRC_SHIFT (0) /* Bits 0-1: UART 0 transmit data source select */
+#define SIM_SOPT5_UART0TXSRC_MASK (3 << SIM_SOPT5_UART0TXSRC_SHIFT)
+# define SIM_SOPT5_UART0TXSRC_TX (0 << SIM_SOPT5_UART0TXSRC_SHIFT) /* UART0_TX pin */
+# define SIM_SOPT5_UART0TXSRC_FTM1 (1 << SIM_SOPT5_UART0TXSRC_SHIFT) /* UART0_TX modulated with FTM1 ch0 output */
+# define SIM_SOPT5_UART0TXSRC_FTM2 (2 << SIM_SOPT5_UART0TXSRC_SHIFT) /* UART0_TX modulated with FTM2 ch0 output */
+#define SIM_SOPT5_UART0RXSRC_SHIFT (2) /* Bits 2-3: UART 0 receive data source select */
+#define SIM_SOPT5_UART0RXSRC_MASK (3 << SIM_SOPT5_UART0RXSRC_SHIFT)
+# define SIM_SOPT5_UART0RXSRC_RX (0 << SIM_SOPT5_UART0RXSRC_SHIFT) /* UART0_RX pin */
+# define SIM_SOPT5_UART0RXSRC_CMP0 (1 << SIM_SOPT5_UART0RXSRC_SHIFT) /* CMP0 */
+# define SIM_SOPT5_UART0RXSRC_CMP1 (2 << SIM_SOPT5_UART0RXSRC_SHIFT) /* CMP1 */
+#define SIM_SOPT5_UART1TXSRC_SHIFT (4) /* Bits 4-5: UART 1 transmit data source select */
+#define SIM_SOPT5_UART1TXSRC_MASK (3 << SIM_SOPT5_UART1TXSRC_SHIFT)
+# define SIM_SOPT5_UART1TXSRC_TX (0 << SIM_SOPT5_UART1TXSRC_SHIFT) /* UART1_TX pin */
+# define SIM_SOPT5_UART1TXSRC_FTM1 (1 << SIM_SOPT5_UART1TXSRC_SHIFT) /* UART1_TX modulated with FTM1 ch0 output */
+# define SIM_SOPT5_UART1TXSRC_FTM2 (2 << SIM_SOPT5_UART1TXSRC_SHIFT) /* UART1_TX modulated with FTM2 ch0 output */
+#define SIM_SOPT5_UART1RXSRC_SHIFT (6) /* Bits 6-7: UART 1 receive data source select */
+#define SIM_SOPT5_UART1RXSRC_MASK (3 << SIM_SOPT5_UART1RXSRC_SHIFT)
+# define SIM_SOPT5_UART1RXSRC_RX (0 << SIM_SOPT5_UART1RXSRC_SHIFT) /* UART1_RX pin */
+# define SIM_SOPT5_UART1RXSRC_CMP0 (1 << SIM_SOPT5_UART1RXSRC_SHIFT) /* CMP0 */
+# define SIM_SOPT5_UART1RXSRC_CMP1 (2 << SIM_SOPT5_UART1RXSRC_SHIFT) /* CMP1 */
+ /* Bits 8-31: Reserved */
+#if defined(KINETIS_SIM_HAS_SOPT5_LPUART0TXSRC)
+ /* Bits 8-15, 18-31: Reserved */
+# define SIM_SOPT5_LPUART0TXSRC_SHIFT (16) /* Bit 16: LPUART0 transmit data source select */
+# define SIM_SOPT5_LPUART0TXSRC_MASK (3 << SIM_SOPT5_LPUART0TXSRC_SHIFT)
+# define SIM_SOPT5_LPUART0TXSRC_TX (0 << SIM_SOPT5_LPUART0TXSRC_SHIFT) /* LPUART0_TX pin */
+# define SIM_SOPT5_LPUART0TXSRC_TXTMP1CH0 (1 << SIM_SOPT5_LPUART0TXSRC_SHIFT) /* LPUART0_TX pin modulated with TPM1 channel 0 output */
+# define SIM_SOPT5_LPUART0TXSRC_TXTMP2CH0 (2 << SIM_SOPT5_LPUART0TXSRC_SHIFT) /* LPUART0_TX pin modulated with TPM2 channel 0 output */
+#endif
+ /* Bits 8-15, 18-31: Reserved */
+#if defined(KINETIS_SIM_HAS_SOPT5_LPUART0RXSRC)
+ /* Bits 8-15, 20-31: Reserved */
+# define SIM_SOPT5_LPUART0RXSRC_SHIFT (18) /* Bit 18: LPUART0 receive data source select */
+# define SIM_SOPT5_LPUART0RXSRC_MASK (3 << SIM_SOPT5_LPUART0RXSRC_SHIFT)
+# define SIM_SOPT5_LPUART0RXSRC_TX (0 << SIM_SOPT5_LPUART0RXSRC_SHIFT) /* LPUART0_RX pin */
+# define SIM_SOPT5_LPUART0RXSRC_TXTMP1CH0 (1 << SIM_SOPT5_LPUART0RXSRC_SHIFT) /* CMP0 output */
+# define SIM_SOPT5_LPUART0RXSRC_TXTMP2CH0 (2 << SIM_SOPT5_LPUART0RXSRC_SHIFT) /* CMP1 output */
+#endif
+
+#if defined(KINETIS_SIM_HAS_SOPT6)
/* System Options Register 6 */
- /* Bits 0-23: Reserved */
-#define SIM_SOPT6_RSTFLTSEL_SHIFT (24) /* Bits 24-28: Reset pin filter select */
-#define SIM_SOPT6_RSTFLTSEL_MASK (31 << SIM_SOPT6_RSTFLTSEL_SHIFT)
-# define SIM_SOPT6_RSTFLTSEL(n) ((uint32_t)((n)-1) << SIM_SOPT6_RSTFLTSEL_SHIFT) /* n=1..32 */
-#define SIM_SOPT6_RSTFLTEN_SHIFT (29) /* Bits 29-31: Reset pin filter enable */
-#define SIM_SOPT6_RSTFLTEN_MASK (7 << SIM_SOPT6_RSTFLTEN_SHIFT)
-#define SIM_SOPT6_RSTFLTEN_DISABLED (0 << SIM_SOPT6_RSTFLTEN_SHIFT) /* All filtering disabled */
-# define SIM_SOPT6_RSTFLTEN_BUSCLK1 (1 << SIM_SOPT6_RSTFLTEN_SHIFT) /* Bus clock filter enabled (normal); LPO clock filter enabled (stop) */
-# define SIM_SOPT6_RSTFLTEN_LPO1 (2 << SIM_SOPT6_RSTFLTEN_SHIFT) /* LPO clock filter enabled */
-# define SIM_SOPT6_RSTFLTEN_BUSCLK2 (3 << SIM_SOPT6_RSTFLTEN_SHIFT) /* Bus clock filter enabled (normal); All filtering disabled (stop) */
-# define SIM_SOPT6_RSTFLTEN_LPO2 (4 << SIM_SOPT6_RSTFLTEN_SHIFT) /* PO clock filter enabled (normal); All filtering disabled (stop) */
+
+ /* Bits 0-23: Reserved */
+# if defined(KINETIS_SIM_HAS_SOPT6_MCC)
+ /* Bits 16-23: Reserved */
+# define SIM_SOPT6_MCC_SHIFT (0) /* Bits 0-15: NFC hold cycle in case FlexBus request while NFC is granted */
+# define SIM_SOPT6_MCC_MASK (0xffff << SIM_SOPT6_MCC_SHIFT)
+# define SIM_SOPT6_MCC(n) (((n) & 0xffff) << SIM_SOPT6_MCC_SHIFT)
+# endif
+ /* Bits 16-23: Reserved */
+# if defined(KINETIS_SIM_HAS_SOPT6_PCR)
+ /* Bits 20-23: Reserved */
+# define SIM_SOPT6_PCR_SHIFT (16) /* Bits 16-19: FlexBus hold cycles before FlexBus can release bus to NFC or to IDLE */
+# define SIM_SOPT6_PCR_MASK (7 << SIM_SOPT6_PCR_SHIFT)
+# define SIM_SOPT6_PCR(n) (((n) & 7) << SIM_SOPT6_PCR_SHIFT)
+# endif
+# if defined(KINETIS_SIM_HAS_SOPT6_RSTFLTSEL)
+# define SIM_SOPT6_RSTFLTSEL_SHIFT (24) /* Bits 24-28: Reset pin filter select */
+# define SIM_SOPT6_RSTFLTSEL_MASK (31 << SIM_SOPT6_RSTFLTSEL_SHIFT)
+# define SIM_SOPT6_RSTFLTSEL(n) ((uint32_t)((n)-1) << SIM_SOPT6_RSTFLTSEL_SHIFT) /* n=1..32 */
+# endif
+# if defined(KINETIS_SIM_HAS_SOPT6_RSTFLTEN)
+# define SIM_SOPT6_RSTFLTEN_SHIFT (29) /* Bits 29-31: Reset pin filter enable */
+# define SIM_SOPT6_RSTFLTEN_MASK (7 << SIM_SOPT6_RSTFLTEN_SHIFT)
+# define SIM_SOPT6_RSTFLTEN_DISABLED (0 << SIM_SOPT6_RSTFLTEN_SHIFT) /* All filtering disabled */
+# define SIM_SOPT6_RSTFLTEN_BUSCLK1 (1 << SIM_SOPT6_RSTFLTEN_SHIFT) /* Bus clock filter enabled (normal); LPO clock filter enabled (stop) */
+# define SIM_SOPT6_RSTFLTEN_LPO1 (2 << SIM_SOPT6_RSTFLTEN_SHIFT) /* LPO clock filter enabled */
+# define SIM_SOPT6_RSTFLTEN_BUSCLK2 (3 << SIM_SOPT6_RSTFLTEN_SHIFT) /* Bus clock filter enabled (normal); All filtering disabled (stop) */
+# define SIM_SOPT6_RSTFLTEN_LPO2 (4 << SIM_SOPT6_RSTFLTEN_SHIFT) /* PO clock filter enabled (normal); All filtering disabled (stop) */
+# endif
+#endif
/* System Options Register 7 */
-#define SIM_SOPT7_ADC0TRGSEL_SHIFT (0) /* Bits 0-3: ADC0 trigger select */
-#define SIM_SOPT7_ADC0TRGSEL_MASK (15 << SIM_SOPT7_ADC0TRGSEL_SHIFT)
-# define SIM_SOPT7_ADC0TRGSEL_PDB (0 << SIM_SOPT7_ADC0TRGSEL_SHIFT) /* PDB external trigger (PDB0_EXTRG) */
-# define SIM_SOPT7_ADC0TRGSEL_CMP0 (1 << SIM_SOPT7_ADC0TRGSEL_SHIFT) /* High speed comparator 0 output */
-# define SIM_SOPT7_ADC0TRGSEL_CMP1 (2 << SIM_SOPT7_ADC0TRGSEL_SHIFT) /* High speed comparator 1 output */
-# define SIM_SOPT7_ADC0TRGSEL_CMP2 (3 << SIM_SOPT7_ADC0TRGSEL_SHIFT) /* High speed comparator 2 output */
-# define SIM_SOPT7_ADC0TRGSEL_PIT0 (4 << SIM_SOPT7_ADC0TRGSEL_SHIFT) /* PIT trigger 0 */
-# define SIM_SOPT7_ADC0TRGSEL_PIT1 (5 << SIM_SOPT7_ADC0TRGSEL_SHIFT) /* PIT trigger 1 */
-# define SIM_SOPT7_ADC0TRGSEL_PIT2 (6 << SIM_SOPT7_ADC0TRGSEL_SHIFT) /* PIT trigger 2 */
-# define SIM_SOPT7_ADC0TRGSEL_PIT3 (7 << SIM_SOPT7_ADC0TRGSEL_SHIFT) /* PIT trigger 3 */
-# define SIM_SOPT7_ADC0TRGSEL_FTM0 (8 << SIM_SOPT7_ADC0TRGSEL_SHIFT) /* FTM0 trigger */
-# define SIM_SOPT7_ADC0TRGSEL_FTM1 (9 << SIM_SOPT7_ADC0TRGSEL_SHIFT) /* FTM1 trigger */
-# define SIM_SOPT7_ADC0TRGSEL_FTM2 (10 << SIM_SOPT7_ADC0TRGSEL_SHIFT) /* FTM2 trigger */
-#if defined(CONFIG_KINETIS_FTM3)
-# define SIM_SOPT7_ADC0TRGSEL_FTM3 (11 << SIM_SOPT7_ADC0TRGSEL_SHIFT) /* FTM3 trigger */
-#endif
-# define SIM_SOPT7_ADC0TRGSEL_ALARM (12 << SIM_SOPT7_ADC0TRGSEL_SHIFT) /* RTC alarm */
-# define SIM_SOPT7_ADC0TRGSEL_SECS (13 << SIM_SOPT7_ADC0TRGSEL_SHIFT) /* RTC seconds */
-# define SIM_SOPT7_ADC0TRGSEL_LPTMR (14 << SIM_SOPT7_ADC0TRGSEL_SHIFT) /* Low-power timer trigger */
-#define SIM_SOPT7_ADC0PRETRGSEL (1 << 4) /* Bit 4: ADC0 pretrigger select */
- /* Bits 5-6: Reserved */
-#define SIM_SOPT7_ADC0ALTTRGEN (1 << 7) /* Bit 7: ADC0 alternate trigger enable */
-#define SIM_SOPT7_ADC1TRGSEL_SHIFT (8) /* Bits 8-11: ADC1 trigger select */
-#define SIM_SOPT7_ADC1TRGSEL_MASK (15 << SIM_SOPT7_ADC1TRGSEL_SHIFT)
-# define SIM_SOPT7_ADC1TRGSEL_PDB (0 << SIM_SOPT7_ADC1TRGSEL_SHIFT) /* PDB external trigger (PDB0_EXTRG) */
-# define SIM_SOPT7_ADC1TRGSEL_CMP0 (1 << SIM_SOPT7_ADC1TRGSEL_SHIFT) /* High speed comparator 0 output */
-# define SIM_SOPT7_ADC1TRGSEL_CMP1 (2 << SIM_SOPT7_ADC1TRGSEL_SHIFT) /* High speed comparator 1 output */
-# define SIM_SOPT7_ADC1TRGSEL_CMP2 (3 << SIM_SOPT7_ADC1TRGSEL_SHIFT) /* High speed comparator 2 output */
-# define SIM_SOPT7_ADC1TRGSEL_PIT0 (4 << SIM_SOPT7_ADC1TRGSEL_SHIFT) /* PIT trigger 0 */
-# define SIM_SOPT7_ADC1TRGSEL_PIT1 (5 << SIM_SOPT7_ADC1TRGSEL_SHIFT) /* PIT trigger 1 */
-# define SIM_SOPT7_ADC1TRGSEL_PIT2 (6 << SIM_SOPT7_ADC1TRGSEL_SHIFT) /* PIT trigger 2 */
-# define SIM_SOPT7_ADC1TRGSEL_PIT3 (7 << SIM_SOPT7_ADC1TRGSEL_SHIFT) /* PIT trigger 3 */
-# define SIM_SOPT7_ADC1TRGSEL_FTM0 (8 << SIM_SOPT7_ADC1TRGSEL_SHIFT) /* FTM0 trigger */
-# define SIM_SOPT7_ADC1TRGSEL_FTM1 (9 << SIM_SOPT7_ADC1TRGSEL_SHIFT) /* FTM1 trigger */
-# define SIM_SOPT7_ADC1TRGSEL_FTM2 (10 << SIM_SOPT7_ADC1TRGSEL_SHIFT) /* FTM2 trigger */
-# define SIM_SOPT7_ADC1TRGSEL_ALARM (12 << SIM_SOPT7_ADC1TRGSEL_SHIFT) /* RTC alarm */
-#if defined(CONFIG_KINETIS_FTM3)
-# define SIM_SOPT7_ADC1TRGSEL_FTM3 (11 << SIM_SOPT7_ADC1TRGSEL_SHIFT) /* FTM3 trigger */
-#endif
-# define SIM_SOPT7_ADC1TRGSEL_SECS (13 << SIM_SOPT7_ADC1TRGSEL_SHIFT) /* RTC seconds */
-# define SIM_SOPT7_ADC1TRGSEL_LPTMR (14 << SIM_SOPT7_ADC1TRGSEL_SHIFT) /* Low-power timer trigger */
-#define SIM_SOPT7_ADC1PRETRGSEL (1 << 12) /* Bit 12: ADC1 pre-trigger select */
- /* Bits 13-14: Reserved */
-#define SIM_SOPT7_ADC1ALTTRGEN (1 << 15) /* Bit 15: ADC1 alternate trigger enable */
- /* Bits 16-31: Reserved */
+#if defined(KINETIS_SIM_HAS_SOPT7_ADC0TRGSEL)
+# define SIM_SOPT7_ADC0TRGSEL_SHIFT (0) /* Bits 0-3: ADC0 trigger select */
+# define SIM_SOPT7_ADC0TRGSEL_MASK (15 << SIM_SOPT7_ADC0TRGSEL_SHIFT)
+# define SIM_SOPT7_ADC0TRGSEL_PDB (0 << SIM_SOPT7_ADC0TRGSEL_SHIFT) /* PDB external trigger (PDB0_EXTRG) */
+# define SIM_SOPT7_ADC0TRGSEL_CMP0 (1 << SIM_SOPT7_ADC0TRGSEL_SHIFT) /* High speed comparator 0 output */
+# define SIM_SOPT7_ADC0TRGSEL_CMP1 (2 << SIM_SOPT7_ADC0TRGSEL_SHIFT) /* High speed comparator 1 output */
+# define SIM_SOPT7_ADC0TRGSEL_CMP2 (3 << SIM_SOPT7_ADC0TRGSEL_SHIFT) /* High speed comparator 2 output */
+# define SIM_SOPT7_ADC0TRGSEL_PIT0 (4 << SIM_SOPT7_ADC0TRGSEL_SHIFT) /* PIT trigger 0 */
+# define SIM_SOPT7_ADC0TRGSEL_PIT1 (5 << SIM_SOPT7_ADC0TRGSEL_SHIFT) /* PIT trigger 1 */
+# define SIM_SOPT7_ADC0TRGSEL_PIT2 (6 << SIM_SOPT7_ADC0TRGSEL_SHIFT) /* PIT trigger 2 */
+# define SIM_SOPT7_ADC0TRGSEL_PIT3 (7 << SIM_SOPT7_ADC0TRGSEL_SHIFT) /* PIT trigger 3 */
+# define SIM_SOPT7_ADC0TRGSEL_FTM0 (8 << SIM_SOPT7_ADC0TRGSEL_SHIFT) /* FTM0 trigger */
+# define SIM_SOPT7_ADC0TRGSEL_FTM1 (9 << SIM_SOPT7_ADC0TRGSEL_SHIFT) /* FTM1 trigger */
+# define SIM_SOPT7_ADC0TRGSEL_FTM2 (10 << SIM_SOPT7_ADC0TRGSEL_SHIFT) /* FTM2 trigger */
+# if KINETIS_SIM_HAS_SOPT7_ADC0TRGSEL > 10 && defined(KINETIS_SIM_HAS_SOPT4_FTM3CH0SRC)
+# define SIM_SOPT7_ADC0TRGSEL_FTM3 (11 << SIM_SOPT7_ADC0TRGSEL_SHIFT) /* FTM3 trigger */
+# endif
+# if KINETIS_SIM_HAS_SOPT7_ADC0TRGSEL > 11
+# define SIM_SOPT7_ADC0TRGSEL_ALARM (12 << SIM_SOPT7_ADC0TRGSEL_SHIFT) /* RTC alarm */
+# endif
+# if KINETIS_SIM_HAS_SOPT7_ADC0TRGSEL > 12
+# define SIM_SOPT7_ADC0TRGSEL_SECS (13 << SIM_SOPT7_ADC0TRGSEL_SHIFT) /* RTC seconds */
+# endif
+# if KINETIS_SIM_HAS_SOPT7_ADC0TRGSEL > 13
+# define SIM_SOPT7_ADC0TRGSEL_LPTMR (14 << SIM_SOPT7_ADC0TRGSEL_SHIFT) /* Low-power timer trigger */
+# endif
+# if KINETIS_SIM_HAS_SOPT7_ADC0TRGSEL > 14
+# define SIM_SOPT7_ADC0TRGSEL_TPM1CH0 (15 << SIM_SOPT7_ADC0TRGSEL_SHIFT) /* TPM1 channel 0 (A pretrigger) and channel 1 (B pretrigger) */
+# endif
+#endif
+#if defined(KINETIS_SIM_HAS_SOPT7_ADC0PRETRGSEL)
+# define SIM_SOPT7_ADC0PRETRGSEL (1 << 4) /* Bit 4: ADC0 pretrigger select */
+#endif
+ /* Bits 5-6: Reserved */
+#if defined(KINETIS_SIM_SOPT7_ADC0ALTTRGEN)
+# define SIM_SOPT7_ADC0ALTTRGEN (1 << 7) /* Bit 7: ADC0 alternate trigger enable */
+#endif
+
+#if defined(KINETIS_SIM_HAS_SOPT7_ADC1TRGSEL)
+# define SIM_SOPT7_ADC1TRGSEL_SHIFT (8) /* Bits 8-11: ADC1 trigger select */
+# define SIM_SOPT7_ADC1TRGSEL_MASK (15 << SIM_SOPT7_ADC1TRGSEL_SHIFT)
+# define SIM_SOPT7_ADC1TRGSEL_PDB (0 << SIM_SOPT7_ADC1TRGSEL_SHIFT) /* PDB external trigger (PDB0_EXTRG) */
+# define SIM_SOPT7_ADC1TRGSEL_CMP0 (1 << SIM_SOPT7_ADC1TRGSEL_SHIFT) /* High speed comparator 0 output */
+# define SIM_SOPT7_ADC1TRGSEL_CMP1 (2 << SIM_SOPT7_ADC1TRGSEL_SHIFT) /* High speed comparator 1 output */
+# define SIM_SOPT7_ADC1TRGSEL_CMP2 (3 << SIM_SOPT7_ADC1TRGSEL_SHIFT) /* High speed comparator 2 output */
+# define SIM_SOPT7_ADC1TRGSEL_PIT0 (4 << SIM_SOPT7_ADC1TRGSEL_SHIFT) /* PIT trigger 0 */
+# define SIM_SOPT7_ADC1TRGSEL_PIT1 (5 << SIM_SOPT7_ADC1TRGSEL_SHIFT) /* PIT trigger 1 */
+# define SIM_SOPT7_ADC1TRGSEL_PIT2 (6 << SIM_SOPT7_ADC1TRGSEL_SHIFT) /* PIT trigger 2 */
+# define SIM_SOPT7_ADC1TRGSEL_PIT3 (7 << SIM_SOPT7_ADC1TRGSEL_SHIFT) /* PIT trigger 3 */
+# define SIM_SOPT7_ADC1TRGSEL_FTM0 (8 << SIM_SOPT7_ADC1TRGSEL_SHIFT) /* FTM0 trigger */
+# define SIM_SOPT7_ADC1TRGSEL_FTM1 (9 << SIM_SOPT7_ADC1TRGSEL_SHIFT) /* FTM1 trigger */
+# define SIM_SOPT7_ADC1TRGSEL_FTM2 (10 << SIM_SOPT7_ADC1TRGSEL_SHIFT) /* FTM2 trigger */
+# define SIM_SOPT7_ADC1TRGSEL_ALARM (12 << SIM_SOPT7_ADC1TRGSEL_SHIFT) /* RTC alarm */
+# if KINETIS_SIM_HAS_SOPT7_ADC1TRGSEL > 10 && defined(KINETIS_SIM_HAS_SOPT4_FTM3CH0SRC)
+# define SIM_SOPT7_ADC1TRGSEL_FTM3 (11 << SIM_SOPT7_ADC1TRGSEL_SHIFT) /* FTM3 trigger */
+# endif
+# if KINETIS_SIM_HAS_SOPT7_ADC1TRGSEL > 11
+# define SIM_SOPT7_ADC1TRGSEL_ALARM (12 << SIM_SOPT7_ADC1TRGSEL_SHIFT) /* RTC alarm */
+# endif
+# if KINETIS_SIM_HAS_SOPT7_ADC1TRGSEL > 12
+# define SIM_SOPT7_ADC1TRGSEL_SECS (13 << SIM_SOPT7_ADC1TRGSEL_SHIFT) /* RTC seconds */
+# endif
+# if KINETIS_SIM_HAS_SOPT7_ADC1TRGSEL > 13
+# define SIM_SOPT7_ADC1TRGSEL_LPTMR (14 << SIM_SOPT7_ADC1TRGSEL_SHIFT) /* Low-power timer trigger */
+# endif
+# if KINETIS_SIM_HAS_SOPT7_ADC1TRGSEL > 14
+# define SIM_SOPT7_ADC1TRGSEL_TPM2CH0 (15 << SIM_SOPT7_ADC1TRGSEL_SHIFT) /* TPM2 channel 0 (A pretrigger) and channel 1 (B pretrigger) */
+# endif
+#endif
+#if defined(KINETIS_SIM_HAS_SOPT7_ADC1PRETRGSEL)
+# define SIM_SOPT7_ADC1PRETRGSEL (1 << 12) /* Bit 12: ADC1 pre-trigger select */
+#endif
+ /* Bits 13-14: Reserved */
+#if defined(KINETIS_SIM_SOPT7_ADC1ALTTRGEN)
+# define SIM_SOPT7_ADC1ALTTRGEN (1 << 15) /* Bit 15: ADC1 alternate trigger enable */
+#endif
+ /* Bits 16-31: Reserved */
+#if defined(KINETIS_SIM_HAS_SOPT7_ADC2TRGSEL)
+# define SIM_SOPT7_ADC2TRGSEL_SHIFT (16) /* Bits 16-19: ADC2 trigger select */
+# define SIM_SOPT7_ADC2TRGSEL_MASK (15 << SIM_SOPT7_ADC2TRGSEL_SHIFT)
+# define SIM_SOPT7_ADC2TRGSEL_PDB (0 << SIM_SOPT7_ADC2TRGSEL_SHIFT) /* PDB external trigger (PDB0_EXTRG) */
+# define SIM_SOPT7_ADC2TRGSEL_CMP0 (1 << SIM_SOPT7_ADC2TRGSEL_SHIFT) /* High speed comparator 0 output */
+# define SIM_SOPT7_ADC2TRGSEL_CMP1 (2 << SIM_SOPT7_ADC2TRGSEL_SHIFT) /* High speed comparator 1 output */
+# define SIM_SOPT7_ADC2TRGSEL_CMP2 (3 << SIM_SOPT7_ADC2TRGSEL_SHIFT) /* High speed comparator 2 output */
+# define SIM_SOPT7_ADC2TRGSEL_PIT0 (4 << SIM_SOPT7_ADC2TRGSEL_SHIFT) /* PIT trigger 0 */
+# define SIM_SOPT7_ADC2TRGSEL_PIT1 (5 << SIM_SOPT7_ADC2TRGSEL_SHIFT) /* PIT trigger 1 */
+# define SIM_SOPT7_ADC2TRGSEL_PIT2 (6 << SIM_SOPT7_ADC2TRGSEL_SHIFT) /* PIT trigger 2 */
+# define SIM_SOPT7_ADC2TRGSEL_PIT3 (7 << SIM_SOPT7_ADC2TRGSEL_SHIFT) /* PIT trigger 3 */
+# define SIM_SOPT7_ADC2TRGSEL_FTM0 (8 << SIM_SOPT7_ADC2TRGSEL_SHIFT) /* FTM0 trigger */
+# define SIM_SOPT7_ADC2TRGSEL_FTM1 (9 << SIM_SOPT7_ADC2TRGSEL_SHIFT) /* FTM1 trigger */
+# define SIM_SOPT7_ADC2TRGSEL_FTM2 (10 << SIM_SOPT7_ADC2TRGSEL_SHIFT) /* FTM2 trigger */
+# if KINETIS_SIM_HAS_SOPT7_ADC2TRGSEL > 10 && defined(KINETIS_SIM_HAS_SOPT4_FTM3CH0SRC)
+# define SIM_SOPT7_ADC2TRGSEL_FTM3 (11 << SIM_SOPT7_ADC2TRGSEL_SHIFT) /* FTM3 trigger */
+# endif
+# if KINETIS_SIM_HAS_SOPT7_ADC2TRGSEL > 11
+# define SIM_SOPT7_ADC2TRGSEL_ALARM (12 << SIM_SOPT7_ADC2TRGSEL_SHIFT) /* RTC alarm */
+# endif
+# if KINETIS_SIM_HAS_SOPT7_ADC2TRGSEL > 12
+# define SIM_SOPT7_ADC2TRGSEL_SECS (13 << SIM_SOPT7_ADC2TRGSEL_SHIFT) /* RTC seconds */
+# endif
+# if KINETIS_SIM_HAS_SOPT7_ADC2TRGSEL > 13
+# define SIM_SOPT7_ADC2TRGSEL_LPTMR (14 << SIM_SOPT7_ADC2TRGSEL_SHIFT) /* Low-power timer trigger */
+# endif
+# if KINETIS_SIM_HAS_SOPT7_ADC2TRGSEL > 14
+# define SIM_SOPT7_ADC2TRGSEL_CMP3 (15 << SIM_SOPT7_ADC2TRGSEL_SHIFT) /* High speed comparator 3 asynchronous interrupt */
+# endif
+#endif
+#if defined(KINETIS_SIM_HAS_SOPT7_ADC2PRETRGSEL)
+# define SIM_SOPT7_ADC2PRETRGSEL (1 << 20) /* Bit 20: ADC2 pretrigger select */
+#endif
+ /* Bits 21-22: Reserved */
+#if defined(KINETIS_SIM_SOPT7_ADC2ALTTRGEN)
+# define SIM_SOPT7_ADC2ALTTRGEN (1 << 23) /* Bit 23: ADC2 alternate trigger enable */
+#endif
+ /* Bits 23-27: Reserved */
+#if defined(KINETIS_SIM_HAS_SOPT7_ADC3TRGSEL)
+# define SIM_SOPT7_ADC3TRGSEL_SHIFT (24) /* Bits 24-27: ADC3 trigger select */
+# define SIM_SOPT7_ADC3TRGSEL_MASK (15 << SIM_SOPT7_ADC3TRGSEL_SHIFT)
+# define SIM_SOPT7_ADC3TRGSEL_PDB (0 << SIM_SOPT7_ADC3TRGSEL_SHIFT) /* PDB external trigger (PDB0_EXTRG) */
+# define SIM_SOPT7_ADC3TRGSEL_CMP0 (1 << SIM_SOPT7_ADC3TRGSEL_SHIFT) /* High speed comparator 0 output */
+# define SIM_SOPT7_ADC3TRGSEL_CMP1 (2 << SIM_SOPT7_ADC3TRGSEL_SHIFT) /* High speed comparator 1 output */
+# define SIM_SOPT7_ADC3TRGSEL_CMP2 (3 << SIM_SOPT7_ADC3TRGSEL_SHIFT) /* High speed comparator 2 output */
+# define SIM_SOPT7_ADC3TRGSEL_PIT0 (4 << SIM_SOPT7_ADC3TRGSEL_SHIFT) /* PIT trigger 0 */
+# define SIM_SOPT7_ADC3TRGSEL_PIT1 (5 << SIM_SOPT7_ADC3TRGSEL_SHIFT) /* PIT trigger 1 */
+# define SIM_SOPT7_ADC3TRGSEL_PIT2 (6 << SIM_SOPT7_ADC3TRGSEL_SHIFT) /* PIT trigger 2 */
+# define SIM_SOPT7_ADC3TRGSEL_PIT3 (7 << SIM_SOPT7_ADC3TRGSEL_SHIFT) /* PIT trigger 3 */
+# define SIM_SOPT7_ADC3TRGSEL_FTM0 (8 << SIM_SOPT7_ADC3TRGSEL_SHIFT) /* FTM0 trigger */
+# define SIM_SOPT7_ADC3TRGSEL_FTM1 (9 << SIM_SOPT7_ADC3TRGSEL_SHIFT) /* FTM1 trigger */
+# define SIM_SOPT7_ADC3TRGSEL_FTM2 (10 << SIM_SOPT7_ADC3TRGSEL_SHIFT) /* FTM2 trigger */
+# if KINETIS_SIM_HAS_SOPT7_ADC3TRGSEL > 10 && defined(KINETIS_SIM_HAS_SOPT4_FTM3CH0SRC)
+# define SIM_SOPT7_ADC3TRGSEL_FTM3 (11 << SIM_SOPT7_ADC3TRGSEL_SHIFT) /* FTM3 trigger */
+# endif
+# if KINETIS_SIM_HAS_SOPT7_ADC3TRGSEL > 11
+# define SIM_SOPT7_ADC3TRGSEL_ALARM (12 << SIM_SOPT7_ADC3TRGSEL_SHIFT) /* RTC alarm */
+# endif
+# if KINETIS_SIM_HAS_SOPT7_ADC3TRGSEL > 12
+# define SIM_SOPT7_ADC3TRGSEL_SECS (13 << SIM_SOPT7_ADC3TRGSEL_SHIFT) /* RTC seconds */
+# endif
+# if KINETIS_SIM_HAS_SOPT7_ADC3TRGSEL > 13
+# define SIM_SOPT7_ADC3TRGSEL_LPTMR (14 << SIM_SOPT7_ADC3TRGSEL_SHIFT) /* Low-power timer trigger */
+# endif
+# if KINETIS_SIM_HAS_SOPT7_ADC3TRGSEL > 14
+# define SIM_SOPT7_ADC3TRGSEL_CMP3 (15 << SIM_SOPT7_ADC3TRGSEL_SHIFT) /* High speed comparator 3 asynchronous interrupt */
+# endif
+#endif
+#if defined(KINETIS_SIM_HAS_SOPT7_ADC3PRETRGSEL)
+# define SIM_SOPT7_ADC3PRETRGSEL (1 << 28) /* Bit 28: ADC3 pretrigger select */
+#endif
+ /* Bits 29-30: Reserved */
+#if defined(KINETIS_SIM_SOPT7_ADC3ALTTRGEN)
+# define SIM_SOPT7_ADC3ALTTRGEN (1 << 31) /* Bit 31: ADC3 alternate trigger enable */
+#endif
+
+#if defined(KINETIS_SIM_HAS_SOPT8)
+/* System Options Register 8 */
+
+# if defined(KINETIS_SIM_HAS_SOPT8_FTM0SYNCBIT)
+# define SIM_SOPT8_FTM0SYNCBIT (1 << 0) /* Bit 0: FTM0 Hardware Trigger 0 Software Synchronization */
+# endif
+# if defined(KINETIS_SIM_HAS_SOPT8_FTM1SYNCBIT)
+# define SIM_SOPT8_FTM1SYNCBIT (1 << 1) /* Bit 1: FTM1 Hardware Trigger 0 Software Synchronization */
+# endif
+# if defined(KINETIS_SIM_HAS_SOPT8_FTM2SYNCBIT)
+# define SIM_SOPT8_FTM2SYNCBIT (1 << 2) /* Bit 2: FTM2 Hardware Trigger 0 Software Synchronization */
+# endif
+# if defined(KINETIS_SIM_HAS_SOPT8_FTM3SYNCBIT)
+# define SIM_SOPT8_FTM3SYNCBIT (1 << 3) /* Bit 3: FTM3 Hardware Trigger 0 Software Synchronization */
+# endif
+ /* Bits 4-15: Reserved */
+# if defined(KINETIS_SIM_HAS_SOPT8_FTM0OCH0SRC)
+# define SIM_SOPT8_FTM0OCH0SRC (1 << 16) /* Bit 16: FTM0 channel 0 output source */
+# endif
+# if defined(KINETIS_SIM_HAS_SOPT8_FTM0OCH1SRC)
+# define SIM_SOPT8_FTM0OCH1SRC (1 << 17) /* Bit 17: FTM0 channel 1 output source */
+# endif
+# if defined(KINETIS_SIM_HAS_SOPT8_FTM0OCH2SRC)
+# define SIM_SOPT8_FTM0OCH2SRC (1 << 18) /* Bit 18: FTM0 channel 2 output source */
+# endif
+# if defined(KINETIS_SIM_HAS_SOPT8_FTM0OCH3SRC)
+# define SIM_SOPT8_FTM0OCH3SRC (1 << 19) /* Bit 19: FTM0 channel 3 output source */
+# endif
+# if defined(KINETIS_SIM_HAS_SOPT8_FTM0OCH4SRC)
+# define SIM_SOPT8_FTM0OCH4SRC (1 << 20) /* Bit 20: FTM0 channel 4 output source */
+# endif
+# if defined(KINETIS_SIM_HAS_SOPT8_FTM0OCH5SRC)
+# define SIM_SOPT8_FTM0OCH5SRC (1 << 21) /* Bit 21: FTM0 channel 5 output source */
+# endif
+# if defined(KINETIS_SIM_HAS_SOPT8_FTM0OCH6SRC)
+# define SIM_SOPT8_FTM0OCH6SRC (1 << 22) /* Bit 22: FTM0 channel 6 output source */
+# endif
+# if defined(KINETIS_SIM_HAS_SOPT8_FTM0OCH7SRC)
+# define SIM_SOPT8_FTM0OCH7SRC (1 << 23) /* Bit 23: FTM0 channel 7 output source */
+# endif
+# if defined(KINETIS_SIM_HAS_SOPT8_FTM3OCH0SRC)
+# define SIM_SOPT8_FTM3OCH0SRC (1 << 24) /* Bit 24: FTM3 channel 0 output source */
+# endif
+# if defined(KINETIS_SIM_HAS_SOPT8_FTM3OCH1SRC)
+# define SIM_SOPT8_FTM3OCH1SRC (1 << 25) /* Bit 25: FTM3 channel 1 output source */
+# endif
+# if defined(KINETIS_SIM_HAS_SOPT8_FTM3OCH2SRC)
+# define SIM_SOPT8_FTM3OCH2SRC (1 << 26) /* Bit 26: FTM3 channel 2 output source */
+# endif
+# if defined(KINETIS_SIM_HAS_SOPT8_FTM3OCH3SRC)
+# define SIM_SOPT8_FTM3OCH3SRC (1 << 27) /* Bit 27: FTM3 channel 3 output source */
+# endif
+# if defined(KINETIS_SIM_HAS_SOPT8_FTM3OCH4SRC)
+# define SIM_SOPT8_FTM3OCH4SRC (1 << 28) /* Bit 28: FTM3 channel 4 output source */
+# endif
+# if defined(KINETIS_SIM_HAS_SOPT8_FTM3OCH5SRC)
+# define SIM_SOPT8_FTM3OCH5SRC (1 << 29) /* Bit 29: FTM3 channel 5 output source */
+# endif
+# if defined(KINETIS_SIM_HAS_SOPT8_FTM3OCH6SRC)
+# define SIM_SOPT8_FTM3OCH6SRC (1 << 30) /* Bit 30: FTM3 channel 6 output source */
+# endif
+# if defined(KINETIS_SIM_HAS_SOPT8_FTM3OCH7SRC)
+# define SIM_SOPT8_FTM3OCH7SRC (1 << 31) /* Bit 31: FTM3 channel 7 output source */
+# endif
+#endif
+
+#if defined(KINETIS_SIM_HAS_SOPT9)
+/* System Options Register 9 */
+
+ /* Bits 0-17: Reserved */
+# if defined(KINETIS_SIM_HAS_SOPT9_TPM1CH0SRC)
+# define SIM_SOPT9_TPM1CH0SRC_SHIFT (18) /* Bits 18-19: TPM1 channel 0 input capture source select */
+# define SIM_SOPT9_TPM1CH0SRC_MASK (3 << SIM_SOPT9_TPM1CH0SRC_SHIFT)
+# define SIM_SOPT9_TPM1CH0SRC_TMP1CH0 (0 << SIM_SOPT9_TPM1CH0SRC_SHIFT)
+# define SIM_SOPT9_TPM1CH0SRC_CMP0 (1 << SIM_SOPT9_TPM1CH0SRC_SHIFT)
+# define SIM_SOPT9_TPM1CH0SRC_CMP1 (2 << SIM_SOPT9_TPM1CH0SRC_SHIFT)
+# endif
+# if defined(KINETIS_SIM_HAS_SOPT9_TPM2CH0SRC)
+# define SIM_SOPT9_TPM2CH0SRC_SHIFT (20) /* Bits 20-21 TPM2 channel 0 input capture source select */
+# define SIM_SOPT9_TPM2CH0SRC_MASK (3 << SIM_SOPT9_TPM2CH0SRC_SHIFT)
+# define SIM_SOPT9_TPM2CH0SRC_TMP1CH0 (0 << SIM_SOPT9_TPM2CH0SRC_SHIFT)
+# define SIM_SOPT9_TPM2CH0SRC_CMP0 (1 << SIM_SOPT9_TPM2CH0SRC_SHIFT)
+# define SIM_SOPT9_TPM2CH0SRC_CMP1 (2 << SIM_SOPT9_TPM2CH0SRC_SHIFT)
+# endif
+ /* Bits 22-24: Reserved */
+# if defined(KINETIS_SIM_HAS_SOPT9_TPM1CLKSEL)
+# define SIM_SOPT9_TPM1CLKSEL (1 << 25) /* Bit 25: TPM1 External Clock Pin Select */
+# endif
+# if defined(KINETIS_SIM_HAS_SOPT9_TPM2CLKSEL)
+# define SIM_SOPT9_TPM2CLKSEL (1 << 26) /* Bit 26: TPM2 External Clock Pin Select */
+# endif
+ /* Bits 27-31: Reserved */
+#endif
+
/* System Device Identification Register */
-#define SIM_SDID_PINID_SHIFT (0) /* Bits 0-3: Pincount identification */
-#define SIM_SDID_PINID_MASK (15 << SIM_SDID_PINID_SHIFT)
-# define SIM_SDID_PINID_32PIN (2 << SIM_SDID_PINID_SHIFT) /* 32-pin */
-# define SIM_SDID_PINID_48PIN (4 << SIM_SDID_PINID_SHIFT) /* 48-pin */
-# define SIM_SDID_PINID_64PIN (5 << SIM_SDID_PINID_SHIFT) /* 64-pin */
-# define SIM_SDID_PINID_80PIN (6 << SIM_SDID_PINID_SHIFT) /* 80-pin */
-# define SIM_SDID_PINID_81PIN (7 << SIM_SDID_PINID_SHIFT) /* 81-pin */
-# define SIM_SDID_PINID_100PIN (8 << SIM_SDID_PINID_SHIFT) /* 100-pin */
-# define SIM_SDID_PINID_121PIN (9 << SIM_SDID_PINID_SHIFT) /* 121-pin */
-# define SIM_SDID_PINID_144PIN (10 << SIM_SDID_PINID_SHIFT) /* 144-pin */
-# define SIM_SDID_PINID_196PIN (12 << SIM_SDID_PINID_SHIFT) /* 196-pin */
-# define SIM_SDID_PINID_256PIN (14 << SIM_SDID_PINID_SHIFT) /* 256-pin */
-#define SIM_SDID_FAMID_SHIFT (4) /* Bits 4-6: Kinetis family identification */
-#define SIM_SDID_FAMID_MASK (7 << SIM_SDID_FAMID_SHIFT)
-# define SIM_SDID_FAMID_K10 (0 << SIM_SDID_FAMID_SHIFT) /* K10 */
-# define SIM_SDID_FAMID_K20 (1 << SIM_SDID_FAMID_SHIFT)) /* K20 */
-# define SIM_SDID_FAMID_K30 (2 << SIM_SDID_FAMID_SHIFT)) /* K30 */
-# define SIM_SDID_FAMID_K40 (3 << SIM_SDID_FAMID_SHIFT)) /* K40 */
-# define SIM_SDID_FAMID_K60 (4 << SIM_SDID_FAMID_SHIFT)) /* K60 */
-# define SIM_SDID_FAMID_K70 (5 << SIM_SDID_FAMID_SHIFT)) /* K70 */
-# define SIM_SDID_FAMID_K50 (6 << SIM_SDID_FAMID_SHIFT)) /* K50 and K52 */
-# define SIM_SDID_FAMID_K51 (7 << SIM_SDID_FAMID_SHIFT)) /* K51 and K53 */
- /* Bits 7-11: Reserved */
-#define SIM_SDID_REVID_SHIFT (12) /* Bits 12-15: Device revision number */
-#define SIM_SDID_REVID_MASK (15 << SIM_SDID_REVID_SHIFT)
- /* Bits 16-31: Reserved */
+#define SIM_SDID_PINID_SHIFT (0) /* Bits 0-3: Pincount identification */
+#define SIM_SDID_PINID_MASK (15 << SIM_SDID_PINID_SHIFT)
+# define SIM_SDID_PINID_32PIN (2 << SIM_SDID_PINID_SHIFT) /* 32-pin */
+# define SIM_SDID_PINID_48PIN (4 << SIM_SDID_PINID_SHIFT) /* 48-pin */
+# define SIM_SDID_PINID_64PIN (5 << SIM_SDID_PINID_SHIFT) /* 64-pin */
+# define SIM_SDID_PINID_80PIN (6 << SIM_SDID_PINID_SHIFT) /* 80-pin */
+# define SIM_SDID_PINID_81PIN (7 << SIM_SDID_PINID_SHIFT) /* 81-pin */
+# define SIM_SDID_PINID_100PIN (8 << SIM_SDID_PINID_SHIFT) /* 100-pin */
+# define SIM_SDID_PINID_121PIN (9 << SIM_SDID_PINID_SHIFT) /* 121-pin */
+# define SIM_SDID_PINID_144PIN (10 << SIM_SDID_PINID_SHIFT) /* 144-pin */
+# define SIM_SDID_PINID_196PIN (12 << SIM_SDID_PINID_SHIFT) /* 196-pin */
+# define SIM_SDID_PINID_256PIN (14 << SIM_SDID_PINID_SHIFT) /* 256-pin */
+#if defined(KINETIS_SIM_HAS_SDID_FAMID)
+# if !defined(KINETIS_SIM_HAS_SDID_FAMILYID)
+# define SIM_SDID_FAMID_SHIFT (4) /* Bits 4-6: Kinetis family identification */
+# define SIM_SDID_FAMID_MASK (7 << SIM_SDID_FAMID_SHIFT)
+# define SIM_SDID_FAMID_K10 (0 << SIM_SDID_FAMID_SHIFT) /* K10 */
+# define SIM_SDID_FAMID_K20 (1 << SIM_SDID_FAMID_SHIFT)) /* K20 */
+# define SIM_SDID_FAMID_K30 (2 << SIM_SDID_FAMID_SHIFT)) /* K30 */
+# define SIM_SDID_FAMID_K40 (3 << SIM_SDID_FAMID_SHIFT)) /* K40 */
+# define SIM_SDID_FAMID_K60 (4 << SIM_SDID_FAMID_SHIFT)) /* K60 */
+# define SIM_SDID_FAMID_K70 (5 << SIM_SDID_FAMID_SHIFT)) /* K70 */
+# define SIM_SDID_FAMID_K50 (6 << SIM_SDID_FAMID_SHIFT)) /* K50 and K52 */
+# define SIM_SDID_FAMID_K51 (7 << SIM_SDID_FAMID_SHIFT)) /* K51 and K53 */
+# else
+# define SIM_SDID_FAMID_K1X (0 << SIM_SDID_FAMID_SHIFT) /* K1X */
+# define SIM_SDID_FAMID_K2X (1 << SIM_SDID_FAMID_SHIFT)) /* K2X */
+# define SIM_SDID_FAMID_K3X (2 << SIM_SDID_FAMID_SHIFT)) /* K3X */
+# define SIM_SDID_FAMID_K4X (3 << SIM_SDID_FAMID_SHIFT)) /* K4X */
+# define SIM_SDID_FAMID_K6X (4 << SIM_SDID_FAMID_SHIFT)) /* K6X */
+# define SIM_SDID_FAMID_K7X (5 << SIM_SDID_FAMID_SHIFT)) /* K7X */
+# endif
+#endif
+ /* Bits 7-11: Reserved */
+#if defined(KINETIS_SIM_HAS_SDID_DIEID)
+# define SIM_SDID_DIEID_SHIFT (7) /* Bits 7-11: Device Die ID */
+# define SIM_SDID_DIEID_MASK (31 < SIM_SDID_DIEID_SHIFT)
+#endif
+
+#define SIM_SDID_REVID_SHIFT (12) /* Bits 12-15: Device revision number */
+#define SIM_SDID_REVID_MASK (15 << SIM_SDID_REVID_SHIFT)
+ /* Bits 16-31: Reserved */
+#if defined(KINETIS_SIM_HAS_SDID_SRAMSIZE)
+# define SIM_SDID_SRAMSIZE_SHIFT (16) /* Bits 16-19: SRAM Size */
+# define SIM_SDID_SRAMSIZE_MASK (15 < SIM_SDID_SRAMSIZE_SHIFT)
+#endif
+#if defined(KINETIS_SIM_HAS_SDID_SERIESID)
+# define SIM_SDID_SERIESID_SHIFT (20) /* Bits 20-23: Kinetis Series ID */
+# define SIM_SDID_SERIESID_MASK (15 << SIM_SDID_SERIESID_SHIFT)
+# define SIM_SDID_SERIESID_K (0 << SIM_SDID_SERIESID_SHIFT) /* Kinetis K series */
+# define SIM_SDID_SERIESID_L (1 << SIM_SDID_SERIESID_SHIFT) /* Kinetis L series */
+# define SIM_SDID_SERIESID_W (5 << SIM_SDID_SERIESID_SHIFT) /* Kinetis W series */
+# define SIM_SDID_SERIESID_V (6 << SIM_SDID_SERIESID_SHIFT) /* Kinetis V series */
+#endif
+#if defined(KINETIS_SIM_HAS_SDID_SUBFAMID)
+# define SIM_SDID_SUBFAMID_SHIFT (24) /* Bits 24-27: Kinetis Sub-Family ID */
+# define SIM_SDID_SUBFAMID_MASK (15 << SIM_SDID_SUBFAMID_SHIFT)
+# define SIM_SDID_SUBFAMID_KX0 (0 << SIM_SDID_SUBFAMID_SHIFT) /* Kx0 Subfamily */
+# define SIM_SDID_SUBFAMID_KX1 (1 << SIM_SDID_SUBFAMID_SHIFT) /* Kx1 Subfamily (tamper detect) */
+# define SIM_SDID_SUBFAMID_KX2 (2 << SIM_SDID_SUBFAMID_SHIFT) /* Kx2 Subfamily */
+# define SIM_SDID_SUBFAMID_KX3 (3 << SIM_SDID_SUBFAMID_SHIFT) /* Kx3 Subfamily (tamper detect) */
+# define SIM_SDID_SUBFAMID_KX4 (4 << SIM_SDID_SUBFAMID_SHIFT) /* Kx4 Subfamily */
+# define SIM_SDID_SUBFAMID_KX5 (5 << SIM_SDID_SUBFAMID_SHIFT) /* Kx5 Subfamily (tamper detect) */
+# define SIM_SDID_SUBFAMID_KX6 (6 << SIM_SDID_SUBFAMID_SHIFT) /* Kx6 Subfamily */
+#endif
+#if defined(KINETIS_SIM_HAS_SDID_FAMILYID)
+# define SIM_SDID_FAMILYID_SHIFT (28) /* Bits 28-31: Kinetis Family ID */
+# define SIM_SDID_FAMILYID_MASK (15 << SIM_SDID_FAMILYID_SHIFT)
+# define SIM_SDID_FAMILYID_K0X (0 << SIM_SDID_FAMILYID_SHIFT) /* K0x Family */
+# define SIM_SDID_FAMILYID_K1X (1 << SIM_SDID_FAMILYID_SHIFT) /* K1x Family */
+# define SIM_SDID_FAMILYID_K2X (2 << SIM_SDID_FAMILYID_SHIFT) /* K2x Family */
+# define SIM_SDID_FAMILYID_K3X (3 << SIM_SDID_FAMILYID_SHIFT) /* K3x Family */
+# define SIM_SDID_FAMILYID_K4X (4 << SIM_SDID_FAMILYID_SHIFT) /* K4x Family */
+# define SIM_SDID_FAMILYID_K6X (6 << SIM_SDID_FAMILYID_SHIFT) /* K6x Family */
+# define SIM_SDID_FAMILYID_K7X (7 << SIM_SDID_FAMILYID_SHIFT) /* K7x Family */
+# define SIM_SDID_FAMILYID_K8X (8 << SIM_SDID_FAMILYID_SHIFT) /* K8x Family */
+#endif
+
+
/* System Clock Gating Control Register 1 */
- /* Bits 0-9: Reserved */
-#define SIM_SCGC1_UART4 (1 << 10) /* Bit 10: UART4 Clock Gate Control */
-#define SIM_SCGC1_UART5 (1 << 11) /* Bit 11: UART5 Clock Gate Control */
- /* Bits 12-31: Reserved */
+
+#if defined(KINETIS_SIM_HAS_SCGC1)
+ /* Bits 0-9: Reserved */
+# if defined(KINETIS_SIM_HAS_SCGC1_OSC1)
+ /* Bits 0-4: Reserved */
+# define SIM_SCGC1_OSC1 (1 << 5) /* OSC1 clock gate control */
+# endif
+ /* Bits 6-9: Reserved */
+# if defined(KINETIS_SIM_HAS_SCGC1_I2C2)
+# define SIM_SCGC1_I2C2 (1 << 6) /* Bit 6: I2C2 Clock Gate Control */
+# endif
+ /* Bits 7-9: Reserved */
+# if defined(KINETIS_SIM_HAS_SCGC1_I2C3)
+# define SIM_SCGC1_I2C3 (1 << 7) /* Bit 7: I2C3 Clock Gate Control */
+# endif
+# if defined(KINETIS_SIM_HAS_SCGC1_UART4)
+# define SIM_SCGC1_UART4 (1 << 10) /* Bit 10: UART4 Clock Gate Control */
+# endif
+# if defined(KINETIS_SIM_HAS_SCGC1_UART5)
+# define SIM_SCGC1_UART5 (1 << 11) /* Bit 11: UART5 Clock Gate Control */
+# endif
+ /* Bits 12-31: Reserved */
+#endif
+
+#if defined(KINETIS_SIM_HAS_SCGC2)
/* System Clock Gating Control Register 2 */
-#if defined(KINETIS_NENET) && KINETIS_NENET > 0
-# define SIM_SCGC2_ENET (1 << 0) /* Bit 0: ENET Clock Gate Control (K60) */
+# if defined(KINETIS_SIM_HAS_SCGC2_ENET) && defined(KINETIS_NENET) && KINETIS_NENET > 0
+# define SIM_SCGC2_ENET (1 << 0) /* Bit 0: ENET Clock Gate Control */
+# endif
+# if defined(KINETIS_SIM_HAS_SCGC2_LPUART0)
+# define SIM_SCGC2_LPUART0 (1 << 4) /* Bit 4: LPUART0 Clock Gate Control */
+# endif
+# if defined(KINETIS_SIM_HAS_SCGC2_TPM1)
+# define SIM_SCGC2_TPM1 (1 << 9) /* Bit 9: TPM1 Clock Gate Control */
+# endif
+# if defined(KINETIS_SIM_HAS_SCGC2_TPM2)
+# define SIM_SCGC2_TPM2 (1 << 10) /* Bit 10: TPM2 Clock Gate Control */
+# endif
+# define SIM_SCGC2_DAC0 (1 << 12) /* Bit 12: DAC0 Clock Gate Control */
+# define SIM_SCGC2_DAC1 (1 << 13) /* Bit 13: DAC1 Clock Gate Control */
+ /* Bits 14-31: Reserved */
#endif
- /* Bits 1-11: Reserved */
-#define SIM_SCGC2_DAC0 (1 << 12) /* Bit 12: DAC0 Clock Gate Control */
-#define SIM_SCGC2_DAC1 (1 << 13) /* Bit 13: DAC1 Clock Gate Control */
- /* Bits 14-31: Reserved */
+
+#if defined(KINETIS_SIM_HAS_SCGC3)
/* System Clock Gating Control Register 3 */
-#if defined(KINETIS_NRNG) && KINETIS_NRNG > 0
-# define SIM_SCGC3_RNGB (1 << 0) /* Bit 0: RNGB Clock Gate Control (K60) */
-#endif
- /* Bits 1-3: Reserved */
-#define SIM_SCGC3_FLEXCAN1 (1 << 4) /* Bit 4: FlexCAN1 Clock Gate Control */
- /* Bits 5-11: Reserved */
-#define SIM_SCGC3_SPI2 (1 << 12) /* Bit 12: SPI2 Clock Gate Control */
- /* Bits 13-16: Reserved */
-#define SIM_SCGC3_SDHC (1 << 17) /* Bit 17: SDHC Clock Gate Control */
- /* Bits 18-23: Reserved */
-#define SIM_SCGC3_FTM2 (1 << 24) /* Bit 24: FTM2 Clock Gate Control */
- /* Bits 25-26: Reserved */
-#if defined(CONFIG_KINETIS_FTM3)
-# define SIM_SCGC3_FTM3 (1 << 25) /* Bit 25: FTM3 Clock Gate Control */
-#endif
-#define SIM_SCGC3_ADC1 (1 << 27) /* Bit 27: ADC1 Clock Gate Control */
- /* Bits 28-29: Reserved */
-#if defined(KINETIS_NSLCD) && KINETIS_NSLCD > 0
-# define SIM_SCGC3_SLCD (1 << 30) /* Bit 30: Segment LCD Clock Gate Control (K40) */
-#endif
- /* Bit 31: Reserved */
+# if defined(KINETIS_SIM_HAS_SCGC3_RNGA) && defined(KINETIS_NRNG) && KINETIS_NRNG > 0
+# define SIM_SCGC3_RNGA (1 << 0) /* Bit 0: RNGB Clock Gate Control */
+# endif
+# if defined(KINETIS_SIM_HAS_SCGC3_USBHS)
+# define SIM_SCGC3_USBHS (1 << 1) /* Bit 1: USBHS Clock Gate Control */
+# endif
+# if defined(KINETIS_SIM_HAS_SCGC3_USBHSPHY)
+# define SIM_SCGC3_USBHSPHY (1 << 2) /* Bit 2: USBHS PHY Clock Gate Control */
+# endif
+# if defined(KINETIS_SIM_HAS_SCGC3_USBHSDCD)
+# define SIM_SCGC3_USBHSDCD (1 << 3) /* Bit 3: USBHS DCD Clock Gate Control */
+# endif
+ /* Bits 5-11: Reserved */
+# if defined(KINETIS_SIM_HAS_SCGC3_FLEXCAN1)
+# define SIM_SCGC3_FLEXCAN1 (1 << 4) /* Bit 4: FlexCAN1 Clock Gate Control */
+# endif
+# if defined(KINETIS_SIM_HAS_SCGC3_NFC)
+# define SIM_SCGC3_FLEXCAN1 (1 << 8) /* Bit 8: NFC Clock Gate Control */
+# endif
+# if defined(KINETIS_SIM_HAS_SCGC3_SPI2)
+# define SIM_SCGC3_SPI2 (1 << 12) /* Bit 12: SPI2 Clock Gate Control */
+# endif
+ /* Bits 13-14: Reserved */
+# if defined(KINETIS_SIM_HAS_SCGC3_SAI1)
+# define SIM_SCGC3_SAI1 (1 << 15) /* Bit 15: SAI1 clock Gate control */
+# endif
+ /* Bit 16: Reserved */
+# if defined(KINETIS_SIM_HAS_SCGC3_SDHC)
+# define SIM_SCGC3_SDHC (1 << 17) /* Bit 17: SDHC Clock Gate Control */
+# endif
+ /* Bits 18-23: Reserved */
+# if defined(KINETIS_SIM_HAS_SCGC3_FTM2)
+# define SIM_SCGC3_FTM2 (1 << 24) /* Bit 24: FTM2 Clock Gate Control */
+# endif
+# if defined(KINETIS_SIM_HAS_SCGC3_FTM3) && defined(KINETIS_SIM_HAS_SOPT4_FTM3CH0SRC)
+# define SIM_SCGC3_FTM3 (1 << 25) /* Bit 25: RFTM3 Clock Gate Control */
+# endif
+ /* Bit 26: Reserved */
+# if defined(KINETIS_SIM_HAS_SCGC3_ADC1)
+# define SIM_SCGC3_ADC1 (1 << 27) /* Bit 27: ADC1 Clock Gate Control */
+# endif
+# if defined(KINETIS_SIM_HAS_SCGC3_ADC3)
+# define SIM_SCGC3_ADC3 (1 << 28) /* Bit 28: ADC3 Clock Gate Control */
+# endif
+ /* Bit 29: Reserved */
+# if defined(KINETIS_SIM_HAS_SCGC3_SLCD) && defined(KINETIS_NSLCD) && KINETIS_NSLCD > 0
+# define SIM_SCGC3_SLCD (1 << 30) /* Bit 30: Segment LCD Clock Gate Control */
+# endif
+ /* Bit 31: Reserved */
+#endif
+
/* System Clock Gating Control Register 4 */
- /* Bit 0: Reserved */
-#define SIM_SCGC4_EWM (1 << 1) /* Bit 1: EWM Clock Gate Control */
-#define SIM_SCGC4_CMT (1 << 2) /* Bit 2: CMT Clock Gate Control */
- /* Bits 3-5: Reserved */
-#define SIM_SCGC4_I2C0 (1 << 6) /* Bit 6: I2C0 Clock Gate Control */
-#define SIM_SCGC4_I2C1 (1 << 7) /* Bit 7: I2C1 Clock Gate Control */
- /* Bits 8-9: Reserved */
-#define SIM_SCGC4_UART0 (1 << 10) /* Bit 10: UART0 Clock Gate Control */
-#define SIM_SCGC4_UART1 (1 << 11) /* Bit 11: UART1 Clock Gate Control */
-#define SIM_SCGC4_UART2 (1 << 12) /* Bit 12: UART2 Clock Gate Control */
-#define SIM_SCGC4_UART3 (1 << 13) /* Bit 13: UART3 Clock Gate Control */
- /* Bits 14-17: Reserved */
-#define SIM_SCGC4_USBOTG (1 << 18) /* Bit 18: USB Clock Gate Control */
-#define SIM_SCGC4_CMP (1 << 19) /* Bit 19: Comparator Clock Gate Control */
-#define SIM_SCGC4_VREF (1 << 20) /* Bit 20: VREF Clock Gate Control */
- /* Bits 21-17: Reserved */
-#define SIM_SCGC4_LLWU (1 << 28) /* Bit 28: LLWU Clock Gate Control */
+
+ /* Bit 0: Reserved */
+#define SIM_SCGC4_EWM (1 << 1) /* Bit 1: EWM Clock Gate Control */
+#define SIM_SCGC4_CMT (1 << 2) /* Bit 2: CMT Clock Gate Control */
+ /* Bits 3-5: Reserved */
+#define SIM_SCGC4_I2C0 (1 << 6) /* Bit 6: I2C0 Clock Gate Control */
+#define SIM_SCGC4_I2C1 (1 << 7) /* Bit 7: I2C1 Clock Gate Control */
+ /* Bits 8-9: Reserved */
+#if defined(KINETIS_SIM_HAS_SCGC4_UART0)
+# define SIM_SCGC4_UART0 (1 << 10) /* Bit 10: UART0 Clock Gate Control */
+#endif
+#if defined(KINETIS_SIM_HAS_SCGC4_UART1)
+# define SIM_SCGC4_UART1 (1 << 11) /* Bit 11: UART1 Clock Gate Control */
+#endif
+#if defined(KINETIS_SIM_HAS_SCGC4_UART2)
+# define SIM_SCGC4_UART2 (1 << 12) /* Bit 12: UART2 Clock Gate Control */
+#endif
+#if defined(KINETIS_SIM_HAS_SCGC4_UART3)
+# define SIM_SCGC4_UART3 (1 << 13) /* Bit 13: UART3 Clock Gate Control */
+#endif
+ /* Bits 14-17: Reserved */
+#define SIM_SCGC4_USBOTG (1 << 18) /* Bit 18: USB Clock Gate Control */
+#define SIM_SCGC4_CMP (1 << 19) /* Bit 19: Comparator Clock Gate Control */
+#define SIM_SCGC4_VREF (1 << 20) /* Bit 20: VREF Clock Gate Control */
+ /* Bits 21-17: Reserved */
+#if defined(KINETIS_SIM_HAS_SCGC4_LLWU)
+# define SIM_SCGC4_LLWU (1 << 28) /* Bit 28: LLWU Clock Gate Control */
+#endif
/* Bits 29-31: Reserved */
+
/* System Clock Gating Control Register 5 */
-#define SIM_SCGC5_LPTIMER (1 << 0) /* Bit 0: Low Power Timer Clock Gate Control */
-#define SIM_SCGC5_REGFILE (1 << 1) /* Bit 1: Register File Clock Gate Control */
- /* Bits 2-4: Reserved */
-#define SIM_SCGC5_TSI (1 << 5) /* Bit 5: TSI Clock Gate Control */
- /* Bits 6-8: Reserved */
-#define SIM_SCGC5_PORTA (1 << 9) /* Bit 9: Port A Clock Gate Control */
-#define SIM_SCGC5_PORTB (1 << 10) /* Bit 10: Port B Clock Gate Control */
-#define SIM_SCGC5_PORTC (1 << 11) /* Bit 11: Port C Clock Gate Control */
-#define SIM_SCGC5_PORTD (1 << 12) /* Bit 12: Port D Clock Gate Control */
-#define SIM_SCGC5_PORTE (1 << 13) /* Bit 13: Port E Clock Gate Control */
+#define SIM_SCGC5_LPTIMER (1 << 0) /* Bit 0: Low Power Timer Clock Gate Control */
+#if defined(KINETIS_SIM_HAS_SCGC5_REGFILE)
+# define SIM_SCGC5_REGFILE (1 << 1) /* Bit 1: Register File Clock Gate Control */
+#endif
+ /* Bits 2-4: Reserved */
+#if defined(KINETIS_SIM_HAS_SCGC5_TSI)
+# define SIM_SCGC5_TSI (1 << 5) /* Bit 5: TSI Clock Gate Control */
+#endif
+ /* Bits 6-8: Reserved */
+#define SIM_SCGC5_PORTA (1 << 9) /* Bit 9: Port A Clock Gate Control */
+#define SIM_SCGC5_PORTB (1 << 10) /* Bit 10: Port B Clock Gate Control */
+#define SIM_SCGC5_PORTC (1 << 11) /* Bit 11: Port C Clock Gate Control */
+#define SIM_SCGC5_PORTD (1 << 12) /* Bit 12: Port D Clock Gate Control */
+#define SIM_SCGC5_PORTE (1 << 13) /* Bit 13: Port E Clock Gate Control */
+#if defined(KINETIS_SIM_HAS_SCGC5_PORTF)
+# define SIM_SCGC5_PORTF (1 << 14) /* Bit 14: Port F Clock Gate Control */
+#endif
/* Bits 14-31: Reserved */
/* System Clock Gating Control Register 6 */
+#if defined(KINETIS_SIM_HAS_SCGC6_FTFL)
+# define SIM_SCGC6_FTFL (1 << 0) /* Bit 0: Flash Memory Clock Gate Control */
+#endif
+#define SIM_SCGC6_DMAMUX0 (1 << 1) /* Bit 1: DMA Mux 0 Clock Gate Control */
+ /* Bits 2-3: Reserved */
+#if defined(KINETIS_SIM_HAS_SCGC6_DMAMUX1)
+# define SIM_SCGC6_DMAMUX1 (1 << 2) /* Bit 2: DMA Mux 1 Clock Gate Control */
+#endif
+#define SIM_SCGC6_FLEXCAN0 (1 << 4) /* Bit 4: FlexCAN0 Clock Gate Control */
+ /* Bits 5-9: Reserved */
-#define SIM_SCGC6_FTFL (1 << 0) /* Bit 0: Flash Memory Clock Gate Control */
-#define SIM_SCGC6_DMAMUX (1 << 1) /* Bit 1: DMA Mux Clock Gate Control */
- /* Bits 2-3: Reserved */
-#define SIM_SCGC6_FLEXCAN0 (1 << 4) /* Bit 4: FlexCAN0 Clock Gate Control */
- /* Bits 5-11: Reserved */
-#define SIM_SCGC6_SPI0 (1 << 12) /* Bit 12: SPI0 Clock Gate Control */
-#define SIM_SCGC6_SPI1 (1 << 13) /* Bit 13: SPI1 Clock Gate Control */
- /* Bit 14: Reserved */
-#define SIM_SCGC6_I2S (1 << 15) /* Bit 15: I2S Clock Gate Control */
- /* Bits 16-17: Reserved */
-#define SIM_SCGC6_CRC (1 << 18) /* Bit 18: CRC Clock Gate Control */
- /* Bits 19-20: Reserved */
-#define SIM_SCGC6_USBDCD (1 << 21) /* Bit 21: USB DCD Clock Gate Control */
-#define SIM_SCGC6_PDB (1 << 22) /* Bit 22: PDB Clock Gate Control */
-#define SIM_SCGC6_PIT (1 << 23) /* Bit 23: PIT Clock Gate Control */
-#define SIM_SCGC6_FTM0 (1 << 24) /* Bit 24: FTM0 Clock Gate Control */
-#define SIM_SCGC6_FTM1 (1 << 25) /* Bit 25: FTM1 Clock Gate Control */
- /* Bit 26: Reserved */
-#define SIM_SCGC6_ADC0 (1 << 27) /* Bit 27: ADC0 Clock Gate Control */
- /* Bit 28: Reserved */
-#define SIM_SCGC6_RTC (1 << 29) /* Bit 29: RTC Clock Gate Control */
- /* Bits 30-31: Reserved */
+#if defined(KINETIS_SIM_HAS_SCGC6_RNGA)
+# define SIM_SCGC6_RNGA (1 << 9) /* Bit 9: SPI0 Clock Gate Control */
+#endif
+ /* Bits 10-11: Reserved */
+#define SIM_SCGC6_SPI0 (1 << 12) /* Bit 12: SPI0 Clock Gate Control */
+#define SIM_SCGC6_SPI1 (1 << 13) /* Bit 13: SPI1 Clock Gate Control */
+ /* Bit 14: Reserved */
+#define SIM_SCGC6_I2S (1 << 15) /* Bit 15: I2S Clock Gate Control */
+ /* Bits 16-17: Reserved */
+#define SIM_SCGC6_CRC (1 << 18) /* Bit 18: CRC Clock Gate Control */
+ /* Bits 19-20: Reserved */
+#if defined(KINETIS_SIM_HAS_SCGC6_USBHS)
+# define SIM_SCGC6_USBHS (1 << 20) /* Bit 20: USB HS Clock Gate Control */
+#endif
+#define SIM_SCGC6_USBDCD (1 << 21) /* Bit 21: USB DCD Clock Gate Control */
+#define SIM_SCGC6_PDB (1 << 22) /* Bit 22: PDB Clock Gate Control */
+#define SIM_SCGC6_PIT (1 << 23) /* Bit 23: PIT Clock Gate Control */
+#define SIM_SCGC6_FTM0 (1 << 24) /* Bit 24: FTM0 Clock Gate Control */
+#define SIM_SCGC6_FTM1 (1 << 25) /* Bit 25: FTM1 Clock Gate Control */
+ /* Bit 26: Reserved */
+#if defined(KINETIS_SIM_HAS_SCGC6_FTM2)
+# define SIM_SCGC6_FTM2 (1 << 26) /* Bit 26: FTM2 Clock Gate Control */
+#endif
+#define SIM_SCGC6_ADC0 (1 << 27) /* Bit 27: ADC0 Clock Gate Control */
+ /* Bit 28: Reserved */
+#if defined(KINETIS_SIM_HAS_SCGC6_ADC2)
+# define SIM_SCGC6_ADC2 (1 << 28) /* Bit 28: ADC2 Clock Gate Control */
+#endif
+#define SIM_SCGC6_RTC (1 << 29) /* Bit 29: RTC Clock Gate Control */
+ /* Bits 30-31: Reserved */
+#if defined(KINETIS_SIM_HAS_SCGC6_DAC0)
+# define SIM_SCGC6_DAC0 (1 << 31) /* Bit 31: RTC Clock Gate Control */
+#endif
+
+#if defined(KINETIS_SIM_HAS_SCGC7)
/* System Clock Gating Control Register 7 */
-#define SIM_SCGC7_FLEXBUS (1 << 0) /* Bit 0: FlexBus Clock Gate Control */
-#define SIM_SCGC7_DMA (1 << 1) /* Bit 1: DMA Clock Gate Control */
-#define SIM_SCGC7_MPU (1 << 2) /* Bit 2: MPU Clock Gate Control */
- /* Bits 3-31: Reserved */
+# if defined(KINETIS_SIM_HAS_SCGC7_FLEXBUS)
+# define SIM_SCGC7_FLEXBUS (1 << 0) /* Bit 0: FlexBus Clock Gate Control */
+# endif
+# if defined(KINETIS_SIM_HAS_SCGC7_DMA)
+# define SIM_SCGC7_DMA (1 << 1) /* Bit 1: DMA Clock Gate Control */
+# endif
+# if defined(KINETIS_SIM_HAS_SCGC7_MPU)
+# define SIM_SCGC7_MPU (1 << 2) /* Bit 2: MPU Clock Gate Control */
+# endif
+# if defined(KINETIS_SIM_HAS_SCGC7_SDRAMC)
+# define SIM_SCGC7_SDRAMC (1 << 3) /* Bit 3: SDRAMC Clock Gate Control */
+# endif
+ /* Bits 4-31: Reserved */
+# endif
+
/* System Clock Divider Register 1 */
- /* Bits 0-15: Reserved */
-#define SIM_CLKDIV1_OUTDIV4_SHIFT (16) /* Bits 16-19: Clock 4 output divider value */
-#define SIM_CLKDIV1_OUTDIV4_MASK (15 << SIM_CLKDIV1_OUTDIV4_SHIFT)
-# define SIM_CLKDIV1_OUTDIV4(n) ((uint32_t)((n)-1) << SIM_CLKDIV1_OUTDIV4_SHIFT) /* n=1..16 */
-# define SIM_CLKDIV1_OUTDIV4_1 (0 << SIM_CLKDIV1_OUTDIV4_SHIFT) /* Divide by 1 */
-# define SIM_CLKDIV1_OUTDIV4_2 (1 << SIM_CLKDIV1_OUTDIV4_SHIFT) /* Divide by 2 */
-# define SIM_CLKDIV1_OUTDIV4_3 (2 << SIM_CLKDIV1_OUTDIV4_SHIFT) /* Divide by 3 */
-# define SIM_CLKDIV1_OUTDIV4_4 (3 << SIM_CLKDIV1_OUTDIV4_SHIFT) /* Divide by 4 */
-# define SIM_CLKDIV1_OUTDIV4_5 (4 << SIM_CLKDIV1_OUTDIV4_SHIFT) /* Divide by 5 */
-# define SIM_CLKDIV1_OUTDIV4_6 (5 << SIM_CLKDIV1_OUTDIV4_SHIFT) /* Divide by 6 */
-# define SIM_CLKDIV1_OUTDIV4_7 (6 << SIM_CLKDIV1_OUTDIV4_SHIFT) /* Divide by 7 */
-# define SIM_CLKDIV1_OUTDIV4_8 (7 << SIM_CLKDIV1_OUTDIV4_SHIFT) /* Divide by 8 */
-# define SIM_CLKDIV1_OUTDIV4_9 (8 << SIM_CLKDIV1_OUTDIV4_SHIFT) /* Divide by 9 */
-# define SIM_CLKDIV1_OUTDIV4_10 (9 << SIM_CLKDIV1_OUTDIV4_SHIFT) /* Divide by 10 */
-# define SIM_CLKDIV1_OUTDIV4_11 (10 << SIM_CLKDIV1_OUTDIV4_SHIFT) /* Divide by 11 */
-# define SIM_CLKDIV1_OUTDIV4_12 (11 << SIM_CLKDIV1_OUTDIV4_SHIFT) /* Divide by 12 */
-# define SIM_CLKDIV1_OUTDIV4_13 (12 << SIM_CLKDIV1_OUTDIV4_SHIFT) /* Divide by 13 */
-# define SIM_CLKDIV1_OUTDIV4_14 (13 << SIM_CLKDIV1_OUTDIV4_SHIFT) /* Divide by 14 */
-# define SIM_CLKDIV1_OUTDIV4_15 (14 << SIM_CLKDIV1_OUTDIV4_SHIFT) /* Divide by 15 */
-# define SIM_CLKDIV1_OUTDIV4_16 (15 << SIM_CLKDIV1_OUTDIV4_SHIFT) /* Divide by 16 */
-#define SIM_CLKDIV1_OUTDIV3_SHIFT (20) /* Bits 20-23: Clock 3 output divider value */
-#define SIM_CLKDIV1_OUTDIV3_MASK (15 << SIM_CLKDIV1_OUTDIV3_SHIFT)
-# define SIM_CLKDIV1_OUTDIV3(n) ((uint32_t)((n)-1) << SIM_CLKDIV1_OUTDIV3_SHIFT) /* n=1..16 */
-# define SIM_CLKDIV1_OUTDIV3_1 (0 << SIM_CLKDIV1_OUTDIV3_SHIFT) /* Divide by 1 */
-# define SIM_CLKDIV1_OUTDIV3_2 (1 << SIM_CLKDIV1_OUTDIV3_SHIFT) /* Divide by 2 */
-# define SIM_CLKDIV1_OUTDIV3_3 (2 << SIM_CLKDIV1_OUTDIV3_SHIFT) /* Divide by 3 */
-# define SIM_CLKDIV1_OUTDIV3_4 (3 << SIM_CLKDIV1_OUTDIV3_SHIFT) /* Divide by 4 */
-# define SIM_CLKDIV1_OUTDIV3_5 (4 << SIM_CLKDIV1_OUTDIV3_SHIFT) /* Divide by 5 */
-# define SIM_CLKDIV1_OUTDIV3_6 (5 << SIM_CLKDIV1_OUTDIV3_SHIFT) /* Divide by 6 */
-# define SIM_CLKDIV1_OUTDIV3_7 (6 << SIM_CLKDIV1_OUTDIV3_SHIFT) /* Divide by 7 */
-# define SIM_CLKDIV1_OUTDIV3_8 (7 << SIM_CLKDIV1_OUTDIV3_SHIFT) /* Divide by 8 */
-# define SIM_CLKDIV1_OUTDIV3_9 (8 << SIM_CLKDIV1_OUTDIV3_SHIFT) /* Divide by 9 */
-# define SIM_CLKDIV1_OUTDIV3_10 (9 << SIM_CLKDIV1_OUTDIV3_SHIFT) /* Divide by 10 */
-# define SIM_CLKDIV1_OUTDIV3_11 (10 << SIM_CLKDIV1_OUTDIV3_SHIFT) /* Divide by 11 */
-# define SIM_CLKDIV1_OUTDIV3_12 (11 << SIM_CLKDIV1_OUTDIV3_SHIFT) /* Divide by 12 */
-# define SIM_CLKDIV1_OUTDIV3_13 (12 << SIM_CLKDIV1_OUTDIV3_SHIFT) /* Divide by 13 */
-# define SIM_CLKDIV1_OUTDIV3_14 (13 << SIM_CLKDIV1_OUTDIV3_SHIFT) /* Divide by 14 */
-# define SIM_CLKDIV1_OUTDIV3_15 (14 << SIM_CLKDIV1_OUTDIV3_SHIFT) /* Divide by 15 */
-# define SIM_CLKDIV1_OUTDIV3_16 (15 << SIM_CLKDIV1_OUTDIV3_SHIFT) /* Divide by 16 */
-#define SIM_CLKDIV1_OUTDIV2_SHIFT (24) /* Bits 24-27: Clock 2 output divider value */
-#define SIM_CLKDIV1_OUTDIV2_MASK (15 << SIM_CLKDIV1_OUTDIV2_SHIFT)
-# define SIM_CLKDIV1_OUTDIV2(n) ((uint32_t)((n)-1) << SIM_CLKDIV1_OUTDIV2_SHIFT) /* n=1..16 */
-# define SIM_CLKDIV1_OUTDIV2_1 (0 << SIM_CLKDIV1_OUTDIV2_SHIFT) /* Divide by 1 */
-# define SIM_CLKDIV1_OUTDIV2_2 (1 << SIM_CLKDIV1_OUTDIV2_SHIFT) /* Divide by 2 */
-# define SIM_CLKDIV1_OUTDIV2_3 (2 << SIM_CLKDIV1_OUTDIV2_SHIFT) /* Divide by 3 */
-# define SIM_CLKDIV1_OUTDIV2_4 (3 << SIM_CLKDIV1_OUTDIV2_SHIFT) /* Divide by 4 */
-# define SIM_CLKDIV1_OUTDIV2_5 (4 << SIM_CLKDIV1_OUTDIV2_SHIFT) /* Divide by 5 */
-# define SIM_CLKDIV1_OUTDIV2_6 (5 << SIM_CLKDIV1_OUTDIV2_SHIFT) /* Divide by 6 */
-# define SIM_CLKDIV1_OUTDIV2_7 (6 << SIM_CLKDIV1_OUTDIV2_SHIFT) /* Divide by 7 */
-# define SIM_CLKDIV1_OUTDIV2_8 (7 << SIM_CLKDIV1_OUTDIV2_SHIFT) /* Divide by 8 */
-# define SIM_CLKDIV1_OUTDIV2_9 (8 << SIM_CLKDIV1_OUTDIV2_SHIFT) /* Divide by 9 */
-# define SIM_CLKDIV1_OUTDIV2_10 (9 << SIM_CLKDIV1_OUTDIV2_SHIFT) /* Divide by 10 */
-# define SIM_CLKDIV1_OUTDIV2_11 (10 << SIM_CLKDIV1_OUTDIV2_SHIFT) /* Divide by 11 */
-# define SIM_CLKDIV1_OUTDIV2_12 (11 << SIM_CLKDIV1_OUTDIV2_SHIFT) /* Divide by 12 */
-# define SIM_CLKDIV1_OUTDIV2_13 (12 << SIM_CLKDIV1_OUTDIV2_SHIFT) /* Divide by 13 */
-# define SIM_CLKDIV1_OUTDIV2_14 (13 << SIM_CLKDIV1_OUTDIV2_SHIFT) /* Divide by 14 */
-# define SIM_CLKDIV1_OUTDIV2_15 (14 << SIM_CLKDIV1_OUTDIV2_SHIFT) /* Divide by 15 */
-# define SIM_CLKDIV1_OUTDIV2_16 (15 << SIM_CLKDIV1_OUTDIV2_SHIFT) /* Divide by 16 */
-#define SIM_CLKDIV1_OUTDIV1_SHIFT (28) /* Bits 28-31: Clock 1 output divider value */
-#define SIM_CLKDIV1_OUTDIV1_MASK (15 << SIM_CLKDIV1_OUTDIV1_SHIFT)
-# define SIM_CLKDIV1_OUTDIV1(n) ((uint32_t)((n)-1) << SIM_CLKDIV1_OUTDIV1_SHIFT) /* n=1..16 */
-# define SIM_CLKDIV1_OUTDIV1_1 (0 << SIM_CLKDIV1_OUTDIV1_SHIFT) /* Divide by 1 */
-# define SIM_CLKDIV1_OUTDIV1_2 (1 << SIM_CLKDIV1_OUTDIV1_SHIFT) /* Divide by 2 */
-# define SIM_CLKDIV1_OUTDIV1_3 (2 << SIM_CLKDIV1_OUTDIV1_SHIFT) /* Divide by 3 */
-# define SIM_CLKDIV1_OUTDIV1_4 (3 << SIM_CLKDIV1_OUTDIV1_SHIFT) /* Divide by 4 */
-# define SIM_CLKDIV1_OUTDIV1_5 (4 << SIM_CLKDIV1_OUTDIV1_SHIFT) /* Divide by 5 */
-# define SIM_CLKDIV1_OUTDIV1_6 (5 << SIM_CLKDIV1_OUTDIV1_SHIFT) /* Divide by 6 */
-# define SIM_CLKDIV1_OUTDIV1_7 (6 << SIM_CLKDIV1_OUTDIV1_SHIFT) /* Divide by 7 */
-# define SIM_CLKDIV1_OUTDIV1_8 (7 << SIM_CLKDIV1_OUTDIV1_SHIFT) /* Divide by 8 */
-# define SIM_CLKDIV1_OUTDIV1_9 (8 << SIM_CLKDIV1_OUTDIV1_SHIFT) /* Divide by 9 */
-# define SIM_CLKDIV1_OUTDIV1_10 (9 << SIM_CLKDIV1_OUTDIV1_SHIFT) /* Divide by 10 */
-# define SIM_CLKDIV1_OUTDIV1_11 (10 << SIM_CLKDIV1_OUTDIV1_SHIFT) /* Divide by 11 */
-# define SIM_CLKDIV1_OUTDIV1_12 (11 << SIM_CLKDIV1_OUTDIV1_SHIFT) /* Divide by 12 */
-# define SIM_CLKDIV1_OUTDIV1_13 (12 << SIM_CLKDIV1_OUTDIV1_SHIFT) /* Divide by 13 */
-# define SIM_CLKDIV1_OUTDIV1_14 (13 << SIM_CLKDIV1_OUTDIV1_SHIFT) /* Divide by 14 */
-# define SIM_CLKDIV1_OUTDIV1_15 (14 << SIM_CLKDIV1_OUTDIV1_SHIFT) /* Divide by 15 */
-# define SIM_CLKDIV1_OUTDIV1_16 (15 << SIM_CLKDIV1_OUTDIV1_SHIFT) /* Divide by 16 */
+
+#if defined(KINETIS_SIM_HAS_CLKDIV1_OUTDIV5)
+ /* Bits 0-15: Reserved */
+#endif
+#if defined(KINETIS_SIM_HAS_CLKDIV1_OUTDIV4)
+# define SIM_CLKDIV1_OUTDIV4_SHIFT (16) /* Bits 16-19: Clock 4 output divider value */
+# define SIM_CLKDIV1_OUTDIV4_MASK (15 << SIM_CLKDIV1_OUTDIV4_SHIFT)
+# define SIM_CLKDIV1_OUTDIV4(n) ((uint32_t)((n)-1) << SIM_CLKDIV1_OUTDIV4_SHIFT) /* n=1..16 */
+# define SIM_CLKDIV1_OUTDIV4_1 (0 << SIM_CLKDIV1_OUTDIV4_SHIFT) /* Divide by 1 */
+# define SIM_CLKDIV1_OUTDIV4_2 (1 << SIM_CLKDIV1_OUTDIV4_SHIFT) /* Divide by 2 */
+# define SIM_CLKDIV1_OUTDIV4_3 (2 << SIM_CLKDIV1_OUTDIV4_SHIFT) /* Divide by 3 */
+# define SIM_CLKDIV1_OUTDIV4_4 (3 << SIM_CLKDIV1_OUTDIV4_SHIFT) /* Divide by 4 */
+# define SIM_CLKDIV1_OUTDIV4_5 (4 << SIM_CLKDIV1_OUTDIV4_SHIFT) /* Divide by 5 */
+# define SIM_CLKDIV1_OUTDIV4_6 (5 << SIM_CLKDIV1_OUTDIV4_SHIFT) /* Divide by 6 */
+# define SIM_CLKDIV1_OUTDIV4_7 (6 << SIM_CLKDIV1_OUTDIV4_SHIFT) /* Divide by 7 */
+# define SIM_CLKDIV1_OUTDIV4_8 (7 << SIM_CLKDIV1_OUTDIV4_SHIFT) /* Divide by 8 */
+# define SIM_CLKDIV1_OUTDIV4_9 (8 << SIM_CLKDIV1_OUTDIV4_SHIFT) /* Divide by 9 */
+# define SIM_CLKDIV1_OUTDIV4_10 (9 << SIM_CLKDIV1_OUTDIV4_SHIFT) /* Divide by 10 */
+# define SIM_CLKDIV1_OUTDIV4_11 (10 << SIM_CLKDIV1_OUTDIV4_SHIFT) /* Divide by 11 */
+# define SIM_CLKDIV1_OUTDIV4_12 (11 << SIM_CLKDIV1_OUTDIV4_SHIFT) /* Divide by 12 */
+# define SIM_CLKDIV1_OUTDIV4_13 (12 << SIM_CLKDIV1_OUTDIV4_SHIFT) /* Divide by 13 */
+# define SIM_CLKDIV1_OUTDIV4_14 (13 << SIM_CLKDIV1_OUTDIV4_SHIFT) /* Divide by 14 */
+# define SIM_CLKDIV1_OUTDIV4_15 (14 << SIM_CLKDIV1_OUTDIV4_SHIFT) /* Divide by 15 */
+# define SIM_CLKDIV1_OUTDIV4_16 (15 << SIM_CLKDIV1_OUTDIV4_SHIFT) /* Divide by 16 */
+#endif
+#if defined(KINETIS_SIM_HAS_CLKDIV1_OUTDIV3)
+# define SIM_CLKDIV1_OUTDIV3_SHIFT (20) /* Bits 20-23: Clock 3 output divider value */
+# define SIM_CLKDIV1_OUTDIV3_MASK (15 << SIM_CLKDIV1_OUTDIV3_SHIFT)
+# define SIM_CLKDIV1_OUTDIV3(n) ((uint32_t)((n)-1) << SIM_CLKDIV1_OUTDIV3_SHIFT) /* n=1..16 */
+# define SIM_CLKDIV1_OUTDIV3_1 (0 << SIM_CLKDIV1_OUTDIV3_SHIFT) /* Divide by 1 */
+# define SIM_CLKDIV1_OUTDIV3_2 (1 << SIM_CLKDIV1_OUTDIV3_SHIFT) /* Divide by 2 */
+# define SIM_CLKDIV1_OUTDIV3_3 (2 << SIM_CLKDIV1_OUTDIV3_SHIFT) /* Divide by 3 */
+# define SIM_CLKDIV1_OUTDIV3_4 (3 << SIM_CLKDIV1_OUTDIV3_SHIFT) /* Divide by 4 */
+# define SIM_CLKDIV1_OUTDIV3_5 (4 << SIM_CLKDIV1_OUTDIV3_SHIFT) /* Divide by 5 */
+# define SIM_CLKDIV1_OUTDIV3_6 (5 << SIM_CLKDIV1_OUTDIV3_SHIFT) /* Divide by 6 */
+# define SIM_CLKDIV1_OUTDIV3_7 (6 << SIM_CLKDIV1_OUTDIV3_SHIFT) /* Divide by 7 */
+# define SIM_CLKDIV1_OUTDIV3_8 (7 << SIM_CLKDIV1_OUTDIV3_SHIFT) /* Divide by 8 */
+# define SIM_CLKDIV1_OUTDIV3_9 (8 << SIM_CLKDIV1_OUTDIV3_SHIFT) /* Divide by 9 */
+# define SIM_CLKDIV1_OUTDIV3_10 (9 << SIM_CLKDIV1_OUTDIV3_SHIFT) /* Divide by 10 */
+# define SIM_CLKDIV1_OUTDIV3_11 (10 << SIM_CLKDIV1_OUTDIV3_SHIFT) /* Divide by 11 */
+# define SIM_CLKDIV1_OUTDIV3_12 (11 << SIM_CLKDIV1_OUTDIV3_SHIFT) /* Divide by 12 */
+# define SIM_CLKDIV1_OUTDIV3_13 (12 << SIM_CLKDIV1_OUTDIV3_SHIFT) /* Divide by 13 */
+# define SIM_CLKDIV1_OUTDIV3_14 (13 << SIM_CLKDIV1_OUTDIV3_SHIFT) /* Divide by 14 */
+# define SIM_CLKDIV1_OUTDIV3_15 (14 << SIM_CLKDIV1_OUTDIV3_SHIFT) /* Divide by 15 */
+# define SIM_CLKDIV1_OUTDIV3_16 (15 << SIM_CLKDIV1_OUTDIV3_SHIFT) /* Divide by 16 */
+#endif
+#if defined(KINETIS_SIM_HAS_CLKDIV1_OUTDIV2)
+# define SIM_CLKDIV1_OUTDIV2_SHIFT (24) /* Bits 24-27: Clock 2 output divider value */
+# define SIM_CLKDIV1_OUTDIV2_MASK (15 << SIM_CLKDIV1_OUTDIV2_SHIFT)
+# define SIM_CLKDIV1_OUTDIV2(n) ((uint32_t)((n)-1) << SIM_CLKDIV1_OUTDIV2_SHIFT) /* n=1..16 */
+# define SIM_CLKDIV1_OUTDIV2_1 (0 << SIM_CLKDIV1_OUTDIV2_SHIFT) /* Divide by 1 */
+# define SIM_CLKDIV1_OUTDIV2_2 (1 << SIM_CLKDIV1_OUTDIV2_SHIFT) /* Divide by 2 */
+# define SIM_CLKDIV1_OUTDIV2_3 (2 << SIM_CLKDIV1_OUTDIV2_SHIFT) /* Divide by 3 */
+# define SIM_CLKDIV1_OUTDIV2_4 (3 << SIM_CLKDIV1_OUTDIV2_SHIFT) /* Divide by 4 */
+# define SIM_CLKDIV1_OUTDIV2_5 (4 << SIM_CLKDIV1_OUTDIV2_SHIFT) /* Divide by 5 */
+# define SIM_CLKDIV1_OUTDIV2_6 (5 << SIM_CLKDIV1_OUTDIV2_SHIFT) /* Divide by 6 */
+# define SIM_CLKDIV1_OUTDIV2_7 (6 << SIM_CLKDIV1_OUTDIV2_SHIFT) /* Divide by 7 */
+# define SIM_CLKDIV1_OUTDIV2_8 (7 << SIM_CLKDIV1_OUTDIV2_SHIFT) /* Divide by 8 */
+# define SIM_CLKDIV1_OUTDIV2_9 (8 << SIM_CLKDIV1_OUTDIV2_SHIFT) /* Divide by 9 */
+# define SIM_CLKDIV1_OUTDIV2_10 (9 << SIM_CLKDIV1_OUTDIV2_SHIFT) /* Divide by 10 */
+# define SIM_CLKDIV1_OUTDIV2_11 (10 << SIM_CLKDIV1_OUTDIV2_SHIFT) /* Divide by 11 */
+# define SIM_CLKDIV1_OUTDIV2_12 (11 << SIM_CLKDIV1_OUTDIV2_SHIFT) /* Divide by 12 */
+# define SIM_CLKDIV1_OUTDIV2_13 (12 << SIM_CLKDIV1_OUTDIV2_SHIFT) /* Divide by 13 */
+# define SIM_CLKDIV1_OUTDIV2_14 (13 << SIM_CLKDIV1_OUTDIV2_SHIFT) /* Divide by 14 */
+# define SIM_CLKDIV1_OUTDIV2_15 (14 << SIM_CLKDIV1_OUTDIV2_SHIFT) /* Divide by 15 */
+# define SIM_CLKDIV1_OUTDIV2_16 (15 << SIM_CLKDIV1_OUTDIV2_SHIFT) /* Divide by 16 */
+#endif
+#define SIM_CLKDIV1_OUTDIV1_SHIFT (28) /* Bits 28-31: Clock 1 output divider value */
+#define SIM_CLKDIV1_OUTDIV1_MASK (15 << SIM_CLKDIV1_OUTDIV1_SHIFT)
+# define SIM_CLKDIV1_OUTDIV1(n) ((uint32_t)((n)-1) << SIM_CLKDIV1_OUTDIV1_SHIFT) /* n=1..16 */
+# define SIM_CLKDIV1_OUTDIV1_1 (0 << SIM_CLKDIV1_OUTDIV1_SHIFT) /* Divide by 1 */
+# define SIM_CLKDIV1_OUTDIV1_2 (1 << SIM_CLKDIV1_OUTDIV1_SHIFT) /* Divide by 2 */
+# define SIM_CLKDIV1_OUTDIV1_3 (2 << SIM_CLKDIV1_OUTDIV1_SHIFT) /* Divide by 3 */
+# define SIM_CLKDIV1_OUTDIV1_4 (3 << SIM_CLKDIV1_OUTDIV1_SHIFT) /* Divide by 4 */
+# define SIM_CLKDIV1_OUTDIV1_5 (4 << SIM_CLKDIV1_OUTDIV1_SHIFT) /* Divide by 5 */
+# define SIM_CLKDIV1_OUTDIV1_6 (5 << SIM_CLKDIV1_OUTDIV1_SHIFT) /* Divide by 6 */
+# define SIM_CLKDIV1_OUTDIV1_7 (6 << SIM_CLKDIV1_OUTDIV1_SHIFT) /* Divide by 7 */
+# define SIM_CLKDIV1_OUTDIV1_8 (7 << SIM_CLKDIV1_OUTDIV1_SHIFT) /* Divide by 8 */
+# define SIM_CLKDIV1_OUTDIV1_9 (8 << SIM_CLKDIV1_OUTDIV1_SHIFT) /* Divide by 9 */
+# define SIM_CLKDIV1_OUTDIV1_10 (9 << SIM_CLKDIV1_OUTDIV1_SHIFT) /* Divide by 10 */
+# define SIM_CLKDIV1_OUTDIV1_11 (10 << SIM_CLKDIV1_OUTDIV1_SHIFT) /* Divide by 11 */
+# define SIM_CLKDIV1_OUTDIV1_12 (11 << SIM_CLKDIV1_OUTDIV1_SHIFT) /* Divide by 12 */
+# define SIM_CLKDIV1_OUTDIV1_13 (12 << SIM_CLKDIV1_OUTDIV1_SHIFT) /* Divide by 13 */
+# define SIM_CLKDIV1_OUTDIV1_14 (13 << SIM_CLKDIV1_OUTDIV1_SHIFT) /* Divide by 14 */
+# define SIM_CLKDIV1_OUTDIV1_15 (14 << SIM_CLKDIV1_OUTDIV1_SHIFT) /* Divide by 15 */
+# define SIM_CLKDIV1_OUTDIV1_16 (15 << SIM_CLKDIV1_OUTDIV1_SHIFT) /* Divide by 16 */
/* System Clock Divider Register 2 */
-#define SIM_CLKDIV2_USBFRAC (1 << 0) /* Bit 0: USB clock divider fraction */
-#define SIM_CLKDIV2_USBDIV_SHIFT (1) /* Bits 1-3: USB clock divider divisor */
-#define SIM_CLKDIV2_USBDIV_MASK (7 << SIM_CLKDIV2_USBDIV_SHIFT)
- /* Bits 4-7: Reserved */
-#define SIM_CLKDIV2_I2SFRAC_SHIFT (8) /* Bits 8-15: I2S clock divider fraction */
-#define SIM_CLKDIV2_I2SFRAC_MASK (0xff << SIM_CLKDIV2_I2SFRAC_SHIFT)
- /* Bits 16-19: Reserved */
-#define SIM_CLKDIV2_I2SDIV_SHIFT (20) /* Bits 20-31: I2S clock divider value */
-#define SIM_CLKDIV2_I2SDIV_MASK (0xfff << SIM_CLKDIV2_I2SDIV_SHIFT)
+#if defined(KINETIS_SIM_HAS_CLKDIV2_USBFRAC)
+# define SIM_CLKDIV2_USBFRAC_SHIFT (0) /* Bit 0: USB clock divider fraction */
+# define SIM_CLKDIV2_USBFRAC_MASK (1 << SIM_CLKDIV2_USBFRAC_SHIFT)
+# define SIM_CLKDIV2_USBFRAC(n) ((((n)-1) & 1) << SIM_CLKDIV2_USBFRAC_SHIFT) /* n=1..2 */
+#endif
+#if defined(KINETIS_SIM_HAS_CLKDIV2_USBDIV)
+# define SIM_CLKDIV2_USBDIV_SHIFT (1) /* Bits 1-3: USB clock divider divisor */
+# define SIM_CLKDIV2_USBDIV_MASK (7 << SIM_CLKDIV2_USBDIV_SHIFT)
+# define SIM_CLKDIV2_USBDIV(n) ((((n)-1) & 7) << SIM_CLKDIV2_USBDIV_SHIFT) /* n=1..8 */
+#endif
+ /* Bits 4-7: Reserved */
+#if defined(KINETIS_SIM_HAS_CLKDIV2_USBHSFRAC)
+# define SIM_CLKDIV2_USBHSFRAC_SHIFT (8) /* Bit 8: USB HS clock divider fraction */
+# define SIM_CLKDIV2_USBHSFRAC_MASK (1 << SIM_CLKDIV2_USBHSFRAC_SHIFT)
+# define SIM_CLKDIV2_USBHSFRAC(n) ((((n)-1) & 1) << SIM_CLKDIV2_USBHSFRAC_SHIFT) /* n=1..2 */
+#endif
+#if defined(KINETIS_SIM_HAS_CLKDIV2_USBHSDIV)
+# define SIM_CLKDIV2_USBHSDIV_SHIFT (9) /* Bits 1-3: USB HS clock divider divisor */
+# define SIM_CLKDIV2_USBHSDIV_MASK (7 << SIM_CLKDIV2_USBHSDIV_SHIFT)
+# define SIM_CLKDIV2_USBHSDIV(n) ((((n)-1) & 7) << SIM_CLKDIV2_USBHSDIV_SHIFT) /* n=1..8 */
+#endif
+#if defined(KINETIS_SIM_HAS_CLKDIV2_I2SFRAC)
+# define SIM_CLKDIV2_I2SFRAC_SHIFT (8) /* Bits 8-15: I2S clock divider fraction */
+# define SIM_CLKDIV2_I2SFRAC_MASK (0xff << SIM_CLKDIV2_I2SFRAC_SHIFT)
+#endif
+ /* Bits 16-19: Reserved */
+#if defined(KINETIS_SIM_HAS_CLKDIV2_I2SDIV)
+# define SIM_CLKDIV2_I2SDIV_SHIFT (20) /* Bits 20-31: I2S clock divider value */
+# define SIM_CLKDIV2_I2SDIV_MASK (0xfff << SIM_CLKDIV2_I2SDIV_SHIFT)
+#endif
/* Flash Configuration Register 1 */
- /* Bits 0-7: Reserved */
-#define SIM_FCFG1_DEPART_SHIFT (8) /* Bits 8-11: FlexNVM partition */
-#define SIM_FCFG1_DEPART_MASK (15 << SIM_FCFG1_DEPART_SHIFT)
- /* Bits 12-15: Reserved */
-#define SIM_FCFG1_EESIZE_SHIFT (16) /* Bits 16-19: EEPROM size*/
-#define SIM_FCFG1_EESIZE_MASK (15 << SIM_FCFG1_EESIZE_SHIFT)
-# define SIM_FCFG1_EESIZE_4KB (2 << SIM_FCFG1_EESIZE_SHIFT) /* 4 KB */
-# define SIM_FCFG1_EESIZE_2KB (3 << SIM_FCFG1_EESIZE_SHIFT) /* 2 KB */
-# define SIM_FCFG1_EESIZE_1KB (4 << SIM_FCFG1_EESIZE_SHIFT) /* 1 KB */
-# define SIM_FCFG1_EESIZE_512B (5 << SIM_FCFG1_EESIZE_SHIFT) /* 512 Bytes */
-# define SIM_FCFG1_EESIZE_256B (6 << SIM_FCFG1_EESIZE_SHIFT) /* 256 Bytes */
-# define SIM_FCFG1_EESIZE_128B (7 << SIM_FCFG1_EESIZE_SHIFT) /* 128 Bytes */
-# define SIM_FCFG1_EESIZE_64B (8 << SIM_FCFG1_EESIZE_SHIFT) /* 64 Bytes */
-# define SIM_FCFG1_EESIZE_32B (9 << SIM_FCFG1_EESIZE_SHIFT) /* 32 Bytes */
-# define SIM_FCFG1_EESIZE_NONE (15 << SIM_FCFG1_EESIZE_SHIFT) /* 0 Bytes */
- /* Bits 20-23: Reserved */
-#if defined(KINETIS_K40) || defined(KINETIS_K64)
-# define SIM_FCFG1_PFSIZE_SHIFT (24) /* Bits 24-27: Program flash size (K40) */
-# define SIM_FCFG1_PFSIZE_MASK (15 << SIM_FCFG1_PFSIZE_SHIFT)
-# define SIM_FCFG1_PFSIZE_128KB (7 << SIM_FCFG1_PFSIZE_SHIFT) /* 128KB program flash, 4KB protection region */
-# define SIM_FCFG1_PFSIZE_256KB (9 << SIM_FCFG1_PFSIZE_SHIFT) /* 256KB program flash, 8KB protection region */
-# define SIM_FCFG1_PFSIZE_512KB (11 << SIM_FCFG1_PFSIZE_SHIFT) /* 512KB program flash, 16KB protection region */
-# define SIM_FCFG1_PFSIZE_512KB2 (15 << SIM_FCFG1_PFSIZE_SHIFT) /* 512KB program flash, 16KB protection region */
-# define SIM_FCFG1_NVMSIZE_SHIFT (28) /* Bits 28-31: FlexNVM size (K40)*/
-# define SIM_FCFG1_NVMSIZE_MASK (15 << SIM_FCFG1_NVMSIZE_SHIFT)
-# define SIM_FCFG1_NVMSIZE_NONE (0 << SIM_FCFG1_NVMSIZE_SHIFT) /* 0KB FlexNVM */
-# define SIM_FCFG1_NVMSIZE_128KB (7 << SIM_FCFG1_NVMSIZE_SHIFT) /* 128KB FlexNVM, 16KB protection region */
-# define SIM_FCFG1_NVMSIZE_256KB (9 << SIM_FCFG1_NVMSIZE_SHIFT) /* 256KB FlexNVM, 32KB protection region */
-# define SIM_FCFG1_NVMSIZE_256KB2 (15 << SIM_FCFG1_NVMSIZE_SHIFT) /* 256KB FlexNVM, 32KB protection region */
-#endif
-
-#ifdef KINETIS_K60
-# define SIM_FCFG1_FSIZE_SHIFT (24) /* Bits 24-31: Flash size (K60)*/
-# define SIM_FCFG1_FSIZE_MASK (0xff << SIM_FCFG1_FSIZE_SHIFT)
-# define SIM_FCFG1_FSIZE_32KB (2 << SIM_FCFG1_FSIZE_SHIFT) /* 32KB program flash, 1KB protection region */
-# define SIM_FCFG1_FSIZE_64KB (4 << SIM_FCFG1_FSIZE_SHIFT) /* 64KB program flash, 2KB protection region */
-# define SIM_FCFG1_FSIZE_128KB (6 << SIM_FCFG1_FSIZE_SHIFT) /* 128KB program flash, 4KB protection region */
-# define SIM_FCFG1_FSIZE_256KB (8 << SIM_FCFG1_FSIZE_SHIFT) /* 256KB program flash, 8KB protection region */
-# define SIM_FCFG1_FSIZE_512KB (12 << SIM_FCFG1_FSIZE_SHIFT) /* 512KB program flash, 16KB protection region */
+
+#if defined(KINETIS_SIM_HAS_FCFG1_FTFDIS)
+# define SIM_FCFG1_FTFDIS (1 << 0) /* Bit 0: Disable FTFE */
+#endif
+#if defined(KINETIS_SIM_HAS_FCFG1_FLASHDIS)
+# define SIM_FCFG1_FLASHDIS (1 << 0) /* Bit 0: Flash Disable */
+#endif
+#if defined(KINETIS_SIM_HAS_FCFG1_FLASHDOZE)
+# define SIM_FCFG1_FLASHDOZE (1 << 1) /* Bit 1: Flash Doze */
+#endif
+ /* Bits 0-7: Reserved */
+#if defined(KINETIS_SIM_HAS_FCFG1_DEPART)
+# define SIM_FCFG1_DEPART_SHIFT (8) /* Bits 8-11: FlexNVM partition */
+# define SIM_FCFG1_DEPART_MASK (15 << SIM_FCFG1_DEPART_SHIFT)
+#endif
+ /* Bits 12-15: Reserved */
+#if defined(KINETIS_SIM_HAS_FCFG1_EESIZE)
+# define SIM_FCFG1_EESIZE_SHIFT (16) /* Bits 16-19: EEPROM size */
+# define SIM_FCFG1_EESIZE_MASK (15 << SIM_FCFG1_EESIZE_SHIFT)
+# define SIM_FCFG1_EESIZE_16KB (0 << SIM_FCFG1_EESIZE_SHIFT) /* 16 KB */
+# define SIM_FCFG1_EESIZE_8KB (1 << SIM_FCFG1_EESIZE_SHIFT) /* 8 KB */
+# define SIM_FCFG1_EESIZE_4KB (2 << SIM_FCFG1_EESIZE_SHIFT) /* 4 KB */
+# define SIM_FCFG1_EESIZE_2KB (3 << SIM_FCFG1_EESIZE_SHIFT) /* 2 KB */
+# define SIM_FCFG1_EESIZE_1KB (4 << SIM_FCFG1_EESIZE_SHIFT) /* 1 KB */
+# define SIM_FCFG1_EESIZE_512B (5 << SIM_FCFG1_EESIZE_SHIFT) /* 512 Bytes */
+# define SIM_FCFG1_EESIZE_256B (6 << SIM_FCFG1_EESIZE_SHIFT) /* 256 Bytes */
+# define SIM_FCFG1_EESIZE_128B (7 << SIM_FCFG1_EESIZE_SHIFT) /* 128 Bytes */
+# define SIM_FCFG1_EESIZE_64B (8 << SIM_FCFG1_EESIZE_SHIFT) /* 64 Bytes */
+# define SIM_FCFG1_EESIZE_32B (9 << SIM_FCFG1_EESIZE_SHIFT) /* 32 Bytes */
+# define SIM_FCFG1_EESIZE_NONE (15 << SIM_FCFG1_EESIZE_SHIFT) /* 0 Bytes */
+#endif
+ /* Bits 20-23: Reserved */
+#define SIM_FCFG1_PFSIZE_SHIFT (24) /* Bits 24-27: Program flash size */
+#define SIM_FCFG1_PFSIZE_MASK (15 << SIM_FCFG1_PFSIZE_SHIFT)
+# if defined(KINETIS_K40)
+# define SIM_FCFG1_PFSIZE_128KB (7 << SIM_FCFG1_PFSIZE_SHIFT) /* 128KB program flash, 4KB protection region */
+# define SIM_FCFG1_PFSIZE_256KB (9 << SIM_FCFG1_PFSIZE_SHIFT) /* 256KB program flash, 8KB protection region */
+# define SIM_FCFG1_PFSIZE_512KB (11 << SIM_FCFG1_PFSIZE_SHIFT) /* 512KB program flash, 16KB protection region */
+# define SIM_FCFG1_PFSIZE_512KB2 (15 << SIM_FCFG1_PFSIZE_SHIFT) /* 512KB program flash, 16KB protection region */
+# endif
+# if defined(KINETIS_K60)
+# define SIM_FCFG1_PFSIZE_512KB (11 << SIM_FCFG1_PFSIZE_SHIFT) /* 512 KB, 16 KB protection size */
+# define SIM_FCFG1_PFSIZE_1024KB (13 << SIM_FCFG1_PFSIZE_SHIFT) /* 1024 KB, 32 KB protection size */
+# define SIM_FCFG1_PFSIZE_2048KB (15 << SIM_FCFG1_PFSIZE_SHIFT) /* 1024 KB, 32 KB protection size */
+# endif
+# if defined(KINETIS_K64) || defined(KINETIS_K66)
+# define SIM_FCFG1_PFSIZE_32KB (3 << SIM_FCFG1_PFSIZE_SHIFT) /* 32 KB of program flash memory */
+# define SIM_FCFG1_PFSIZE_64KB (5 << SIM_FCFG1_PFSIZE_SHIFT) /* 64 KB of program flash memory */
+# define SIM_FCFG1_PFSIZE_128KB (7 << SIM_FCFG1_PFSIZE_SHIFT) /* 128 KB of program flash memory */
+# define SIM_FCFG1_PFSIZE_256KB (9 << SIM_FCFG1_PFSIZE_SHIFT) /* 256 KB of program flash memory */
+# define SIM_FCFG1_PFSIZE_512KB (11 << SIM_FCFG1_PFSIZE_SHIFT) /* 512 KB of program flash memory */
+# define SIM_FCFG1_PFSIZE_1024KB (13 << SIM_FCFG1_PFSIZE_SHIFT) /* 1024 KB of program flash memory */
+# define SIM_FCFG1_PFSIZE_2048KB (15 << SIM_FCFG1_PFSIZE_SHIFT) /* 2048 KB of program flash memory */
+# endif
+
+#if defined(KINETIS_SIM_HAS_FCFG1_NVMSIZE)
+# define SIM_FCFG1_NVMSIZE_SHIFT (28) /* Bits 28-31: FlexNVM size */
+# define SIM_FCFG1_NVMSIZE_MASK (15 << SIM_FCFG1_NVMSIZE_SHIFT)
+# define SIM_FCFG1_NVMSIZE_NONE (0 << SIM_FCFG1_NVMSIZE_SHIFT) /* 0KB FlexNVM */
+# define SIM_FCFG1_NVMSIZE_128KB (7 << SIM_FCFG1_NVMSIZE_SHIFT) /* 128KB FlexNVM, 16KB protection region */
+# define SIM_FCFG1_NVMSIZE_256KB (9 << SIM_FCFG1_NVMSIZE_SHIFT) /* 256KB FlexNVM, 32KB protection region */
+# define SIM_FCFG1_NVMSIZE_256KB2 (15 << SIM_FCFG1_NVMSIZE_SHIFT) /* 256KB FlexNVM, 32KB protection region */
#endif
/* Flash Configuration Register 2 */
/* Bits 0-15: Reserved */
-#define SIM_FCFG2_MAXADDR1_SHIFT (16) /* Bits 16-21: Max address block 1 */
-#define SIM_FCFG2_MAXADDR1_MASK (nn << SIM_FCFG2_MAXADDR1_SHIFT)
- /* Bit 22: Reserved */
-#define SIM_FCFG2_PFLSH (1 << 23) /* Bit 23: Program flash */
-#define SIM_FCFG2_MAXADDR0_SHIFT (24) /* Bits 24-29: Max address block 0 */
-#define SIM_FCFG2_MAXADDR0_MASK (nn << SIM_FCFG2_MAXADDR0_SHIFT)
- /* Bit 30: Reserved */
-#define SIM_FCFG2_SWAPPFLSH (1 << 31) /* Bit 31: Swap program flash */
+#if (KINETIS_SIM_HAS_FCFG2_MAXADDR1)
+# define SIM_FCFG2_MAXADDR1_SHIFT (16) /* Bits 16-[21|22]: Max address block 1 */
+# define SIM_FCFG2_MAXADDR1_MASK (KINETIS_SIM_FCFG2_MAXADDR1_MASK << SIM_FCFG2_MAXADDR1_SHIFT)
+# define SIM_FCFG2_MAXADDR1(n) (((n) & KINETIS_SIM_FCFG2_MAXADDR1_MASK) << SIM_FCFG2_MAXADDR1_SHIFT)
+#endif
+ /* Bit 22: Reserved */
+#if defined(KINETIS_SIM_HAS_FCFG2_PFLSH)
+# define SIM_FCFG2_PFLSH (1 << 23) /* Bit 23: Program flash */
+#endif
+#if defined(KINETIS_SIM_HAS_FCFG2_MAXADDR0)
+# define SIM_FCFG2_MAXADDR0_SHIFT (24) /* Bits 24-[29|30]: Max address block 0 */
+# define SIM_FCFG2_MAXADDR0_MASK (KINETIS_SIM_FCFG2_MAXADDR0_MASK << SIM_FCFG2_MAXADDR0_SHIFT)
+# define SIM_FCFG2_MAXADDR0(n) (((n) & KINETIS_SIM_FCFG2_MAXADDR0_MASK) << SIM_FCFG2_MAXADDR0_SHIFT)
+ /* Bit 30: Reserved */
+#endif
+#if defined(KINETIS_SIM_HAS_FCFG2_SWAPPFLSH)
+# define SIM_FCFG2_SWAPPFLSH (1 << 31) /* Bit 31: Swap program flash */
+#endif
/* Unique Identification Register High. 32-bit Unique Identification. */
/* Unique Identification Register Mid-High. 32-bit Unique Identification. */
/* Unique Identification Register Mid Low. 32-bit Unique Identification. */
/* Unique Identification Register Low. 32-bit Unique Identification. */
+#if defined(KINETIS_SIM_HAS_CLKDIV3)
+/* System Clock Divider Register 3 */
+
+# if defined(KINETIS_SIM_HAS_CLKDIV3_PLLFLLFRAC)
+# define SIM_CLKDIV3_PLLFLLFRAC_SHIFT (0) /* Bit 0: PLLFLL clock divider fraction */
+# define SIM_CLKDIV3_PLLFLLFRAC_MASK (1 << SIM_CLKDIV3_PLLFLLFRAC_SHIFT)
+# define SIM_CLKDIV3_PLLFLLFRAC(n) ((((n)-1) & 1) << SIM_CLKDIV3_PLLFLLFRAC_SHIFT) /* n=1..2 */
+# endif
+# if defined(KINETIS_SIM_HAS_CLKDIV3_PLLFLLDIV)
+# define SIM_CLKDIV3_PLLFLLDIV_SHIFT (1) /* Bits 1-3: PLLFLL clock divider divisor */
+# define SIM_CLKDIV3_PLLFLLDIV_MASK (7 << SIM_CLKDIV3_PLLFLLDIV_SHIFT)
+# define SIM_CLKDIV3_PLLFLLDIV(n) ((((n)-1) & 7) << SIM_CLKDIV3_PLLFLLDIV_SHIFT) /* n=1..8 */
+# endif
+#endif
+#if defined(KINETIS_SIM_HAS_CLKDIV4)
+/* System Clock Divider Register 4 */
+
+# if defined(KINETIS_SIM_HAS_CLKDIV4_TRACEFRAC)
+# define SIM_CLKDIV4_TRACEFRAC_SHIFTS (0) /* Bit 0: Trace clock divider fraction */
+# define SIM_CLKDIV4_TRACEFRAC_MASK (1 << SIM_CLKDIV4_TRACEFRAC_SHIFTS)
+# define SIM_CLKDIV4_TRACEFRAC(n) ((((n)-1) & 1) << SIM_CLKDIV4_TRACEFRAC_SHIFTS) /* n=1..2 */
+# endif
+# if defined(KINETIS_SIM_HAS_CLKDIV4_TRACEDIV)
+# define SIM_CLKDIV4_TRACEDIV_SHIFT (1) /* Bits 1-3: Trace clock divider divisor */
+# define SIM_CLKDIV4_TRACEDIV_MASK (7 << SIM_CLKDIV3_TRACEDIV_SHIFT)
+# define SIM_CLKDIV4_TRACEDIV(n) ((((n)-1) & 7) << SIM_CLKDIV4_TRACEDIV_SHIFT) /* n=1..8 */
+# endif
+# if defined(KINETIS_SIM_HAS_CLKDIV4_NFCFRAC)
+# define SIM_CLKDIV4_NFCFRAC_SHIFT (24) /* Bits 24-26: NFC clock divider fraction */
+# define SIM_CLKDIV4_NFCFRAC_MASK (7 << SIM_CLKDIV4_NFCFRAC_SHIFT)
+# define SIM_CLKDIV4_NFCFRAC(n) ((((n)-1) & 7) << SIM_CLKDIV4_NFCFRAC_SHIFT) /* n=1..8 */
+# endif
+# if defined(KINETIS_SIM_HAS_CLKDIV4_NFCDIV)
+# define SIM_CLKDIV4_NFCDIV_SHIFT (27) /* Bits 27-31: NFC clock divider divisor */
+# define SIM_CLKDIV4_NFCDIV_MASK (31 << SIM_CLKDIV3_NFCDIV_SHIFT)
+# define SIM_CLKDIV4_NFCDIV(n) ((((n)-1) & 31) << SIM_CLKDIV4_NFCDIV_SHIFT) /* n=1..32 */
+# endif
+#endif
+
+#if defined(KINETIS_SIM_HAS_MCR)
+/* Misc Control Register */
+
+ /* Bits 0-28: Reserved */
+# define SIM_MCR_PDBLOOP (1<< 29) /* Bit 29: PDB Loop Mode */
+ /* Bit 30: Reserved */
+# define SIM_MCR_TRACECLKDIS (1<< 31) /* Bit 31: Trace clock disable. */
+#endif
+
/************************************************************************************
* Public Types
************************************************************************************/
diff --git a/arch/arm/src/kinetis/chip/kinetis_uart.h b/arch/arm/src/kinetis/chip/kinetis_uart.h
index 537332ee78644febc3f678add0b43675fffa0b85..d7296ce7066de26b513823a294f4f3ba105e8c3b 100644
--- a/arch/arm/src/kinetis/chip/kinetis_uart.h
+++ b/arch/arm/src/kinetis/chip/kinetis_uart.h
@@ -1,8 +1,9 @@
/************************************************************************************
* arch/arm/src/kinetis/chip/kinetis_uart.h
*
- * Copyright (C) 2011, 2016 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt
+ * Copyright (C) 2011, 2016-2017 Gregory Nutt. All rights reserved.
+ * Authors: Gregory Nutt
+ * David Sidrane
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -293,7 +294,7 @@
#define UART_BDH_SBR_SHIFT (0) /* Bits 0-4: MS Bits 8-13 of the UART Baud Rate Bits */
#define UART_BDH_SBR_MASK (31 << UART_BDH_SBR_SHIFT)
- /* Bit 5: Reserved */
+#define UART_BDH_SBNS (1 << 5) /* Bit 5: Stop Bit Number Select */
#define UART_BDH_RXEDGIE (1 << 6) /* Bit 6: RxD Input Active Edge Interrupt Enable */
#define UART_BDH_LBKDIE (1 << 7) /* Bit 7: LIN Break Detect Interrupt Enable */
diff --git a/arch/arm/src/kinetis/kinetis.h b/arch/arm/src/kinetis/kinetis.h
index b4832274c33c838a76ebece7c4a2b8b6870d067c..a2bf6ddf7dab70d4cbafab0fe62d7894a9db950e 100644
--- a/arch/arm/src/kinetis/kinetis.h
+++ b/arch/arm/src/kinetis/kinetis.h
@@ -1,8 +1,9 @@
/************************************************************************************
* arch/arm/src/kinetis/kinetis.h
*
- * Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt
+ * Copyright (C) 2011, 2013, 2017 Gregory Nutt. All rights reserved.
+ * Authors: Gregory Nutt
+ * David Sidrane
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -340,6 +341,48 @@ extern "C"
void kinetis_clockconfig(void);
+/****************************************************************************
+ * Name: kinetis_earlyserialinit
+ *
+ * Description:
+ * Performs the low level UART/LPUART initialization early in debug so that
+ * the serial console will be available during bootup. This must be called
+ * before up_serialinit.
+ *
+ ****************************************************************************/
+
+#ifdef USE_EARLYSERIALINIT
+void kinetis_earlyserialinit(void);
+#endif
+
+/****************************************************************************
+ * Name: kinetis_uart_earlyserialinit
+ *
+ * Description:
+ * Performs the low level UART initialization early in debug so that the
+ * serial console will be available during bootup. This must be called
+ * before up_serialinit.
+ *
+ ****************************************************************************/
+
+#ifdef USE_EARLYSERIALINIT
+void kinetis_uart_earlyserialinit(void);
+#endif
+
+/****************************************************************************
+ * Name: kinetis_lpuart_earlyserialinit
+ *
+ * Description:
+ * Performs the low level LPUART initialization early in debug so that the
+ * serial console will be available during bootup. This must be called
+ * before up_serialinit.
+ *
+ ****************************************************************************/
+
+#ifdef USE_EARLYSERIALINIT
+void kinetis_lpuart_earlyserialinit(void);
+#endif
+
/************************************************************************************
* Name: kinetis_lowsetup
*
@@ -352,6 +395,44 @@ void kinetis_clockconfig(void);
void kinetis_lowsetup(void);
+/****************************************************************************
+ * Name: kinetis_uart_serialinit
+ *
+ * Description:
+ * Register all UART based serial console and serial ports. This assumes
+ * that kinetis_earlyserialinit was called previously.
+ *
+ * Input Parameters:
+ * first: - First TTY number to assign
+ *
+ * Returns Value:
+ * The next TTY number available for assignment
+ *
+ ****************************************************************************/
+
+#ifdef HAVE_UART_DEVICE
+unsigned int kinetis_uart_serialinit(unsigned int first);
+#endif
+
+/****************************************************************************
+ * Name: kinetis_lpuart_serialinit
+ *
+ * Description:
+ * Register all LPUART based serial console and serial ports. This assumes
+ * that kinetis_earlyserialinit was called previously.
+ *
+ * Input Parameters:
+ * first: - First TTY number to assign
+ *
+ * Returns Value:
+ * The next TTY number available for assignment
+ *
+ ****************************************************************************/
+
+#ifdef HAVE_LPUART_DEVICE
+unsigned int kinetis_lpuart_serialinit(unsigned int first);
+#endif
+
/****************************************************************************
* Name: kinetis_uartreset
*
@@ -364,6 +445,18 @@ void kinetis_lowsetup(void);
void kinetis_uartreset(uintptr_t uart_base);
#endif
+/****************************************************************************
+ * Name: kinetis_lpuartreset
+ *
+ * Description:
+ * Reset a UART.
+ *
+ ****************************************************************************/
+
+#ifdef HAVE_LPUART_DEVICE
+void kinetis_lpuartreset(uintptr_t uart_base);
+#endif
+
/****************************************************************************
* Name: kinetis_uartconfigure
*
@@ -374,7 +467,22 @@ void kinetis_uartreset(uintptr_t uart_base);
#ifdef HAVE_UART_DEVICE
void kinetis_uartconfigure(uintptr_t uart_base, uint32_t baud, uint32_t clock,
- unsigned int parity, unsigned int nbits);
+ unsigned int parity, unsigned int nbits,
+ unsigned int stop2);
+#endif
+
+/****************************************************************************
+ * Name: kinetis_lpuartconfigure
+ *
+ * Description:
+ * Configure a UART as a RS-232 UART.
+ *
+ ****************************************************************************/
+
+#ifdef HAVE_LPUART_DEVICE
+void kinetis_lpuartconfigure(uintptr_t uart_base, uint32_t baud, uint32_t clock,
+ unsigned int parity, unsigned int nbits,
+ unsigned int stop2);
#endif
/************************************************************************************
@@ -404,7 +512,7 @@ int kinetis_pinconfig(uint32_t cfgset);
* Configure the digital filter associated with a port. The digital filter
* capabilities of the PORT module are available in all digital pin muxing modes.
*
- * Input parmeters:
+ * Input Parameters:
* port - See KINETIS_PORTn definitions in kinetis_port.h
* lpo - true: Digital Filters are clocked by the bus clock
* false: Digital Filters are clocked by the 1 kHz LPO clock
@@ -460,17 +568,17 @@ void kinetis_pinirqinitialize(void);
* 3. Call kinetis_pinirqenable() to enable interrupts on the pin.
*
* Parameters:
- * - pinset: Pin configuration
- * - pinisr: Pin interrupt service routine
+ * pinset - Pin configuration
+ * pinisr - Pin interrupt service routine
+ * arg - An argument that will be provided to the interrupt service routine.
*
- * Returns:
- * The previous value of the interrupt handler function pointer. This value may,
- * for example, be used to restore the previous handler when multiple handlers are
- * used.
+ * Return Value:
+ * Zero (OK) is returned on success; a negated errno value is returned on any
+ * failure to indicate the nature of the failure.
*
************************************************************************************/
-xcpt_t kinetis_pinirqattach(uint32_t pinset, xcpt_t pinisr);
+int kinetis_pinirqattach(uint32_t pinset, xcpt_t pinisr, void *arg);
/************************************************************************************
* Name: kinetis_pinirqenable
@@ -555,7 +663,7 @@ void kinetis_clrpend(int irq);
* Description:
* Initialize SDIO for operation.
*
- * Input Parameters:
+ * Input parameters:
* slotno - Not used.
*
* Returned Values:
diff --git a/arch/arm/src/kinetis/kinetis_clockconfig.c b/arch/arm/src/kinetis/kinetis_clockconfig.c
index 8080fbd11b3fc4b34d637c284e0107e5c179d0ad..b954f33be2e4fd75b1074fb5b85540349c3d511e 100644
--- a/arch/arm/src/kinetis/kinetis_clockconfig.c
+++ b/arch/arm/src/kinetis/kinetis_clockconfig.c
@@ -2,7 +2,8 @@
* arch/arm/src/kinetis/kinetis_clockconfig.c
*
* Copyright (C) 2011, 2016-2017 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt
+ * Authors: Gregory Nutt
+ * David Sidrane
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -45,6 +46,7 @@
#include "chip/kinetis_mcg.h"
#include "chip/kinetis_sim.h"
#include "chip/kinetis_fmc.h"
+#include "chip/kinetis_pmc.h"
#include "chip/kinetis_llwu.h"
#include "chip/kinetis_pinmux.h"
@@ -191,7 +193,10 @@ static inline void kinesis_portclocks(void)
void kinetis_pllconfig(void)
{
+#if defined(SIM_SCGC4_LLWU) || defined(BOARD_SOPT2_PLLFLLSEL) || \
+ defined(BOARD_SIM_CLKDIV3_FREQ)
uint32_t regval32;
+#endif
uint8_t regval8;
#if defined(BOARD_MCG_C2)
@@ -228,16 +233,25 @@ void kinetis_pllconfig(void)
MCG_C2_RANGE_VHIGH | MCG_C2_EREFS, KINETIS_MCG_C2);
# endif
#endif /* defined(BOARD_MCG_C2) */
-
+#if defined(SIM_SCGC4_LLWU)
/* Released latched state of oscillator and GPIO */
regval32 = getreg32(KINETIS_SIM_SCGC4);
regval32 |= SIM_SCGC4_LLWU;
putreg32(regval32, KINETIS_SIM_SCGC4);
+#endif
+#if defined(LLWU_CS_ACKISO)
regval8 = getreg8(KINETIS_LLWU_CS);
regval8 |= LLWU_CS_ACKISO;
putreg8(regval8, KINETIS_LLWU_CS);
+#endif
+
+#if defined(PMC_REGSC_ACKISO)
+ regval8 = getreg8(KINETIS_PMC_REGSC);
+ regval8 |= PMC_REGSC_ACKISO;
+ putreg8(regval8, KINETIS_PMC_REGSC);
+#endif
/* Select external oscillator and Reference Divider and clear IREFS to
* start the external oscillator.
@@ -334,6 +348,37 @@ void kinetis_pllconfig(void)
while ((getreg8(KINETIS_MCG_S) & MCG_S_CLKST_MASK) != MCG_S_CLKST_PLL);
/* We are now running in PLL Engaged External (PEE) mode. */
+
+ /* Do we have BOARD_SOPT2_PLLFLLSEL */
+
+#if defined(BOARD_SOPT2_PLLFLLSEL)
+ /* Set up the SOPT2[PLLFLLSEL] */
+
+ regval32 = getreg32(KINETIS_SIM_SOPT2);
+ regval32 &= ~SIM_SOPT2_PLLFLLSEL_MASK;
+ regval32 |= BOARD_SOPT2_PLLFLLSEL;
+ putreg32(regval32, KINETIS_SIM_SOPT2);
+#endif
+
+#if defined(BOARD_SIM_CLKDIV2_FREQ)
+ /* Set up the SIM_CLKDIV2[USBFRAC, USBDIV] */
+
+ regval32 = getreg32(KINETIS_SIM_CLKDIV2);
+ regval32 &= ~(SIM_CLKDIV2_USBFRAC_MASK | SIM_CLKDIV2_USBDIV_MASK);
+ regval32 |= (SIM_CLKDIV2_USBFRAC(BOARD_SIM_CLKDIV2_USBFRAC) |
+ SIM_CLKDIV2_USBDIV(BOARD_SIM_CLKDIV2_USBDIV));
+ putreg32(regval32, KINETIS_SIM_CLKDIV2);
+#endif
+
+#if defined(BOARD_SIM_CLKDIV3_FREQ)
+ /* Set up the SIM_CLKDIV3 [PLLFLLFRAC, PLLFLLDIV] */
+
+ regval32 = getreg32(KINETIS_SIM_CLKDIV3);
+ regval32 &= ~(SIM_CLKDIV3_PLLFLLFRAC_MASK | SIM_CLKDIV3_PLLFLLDIV_MASK);
+ regval32 |= (SIM_CLKDIV3_PLLFLLFRAC(BOARD_SIM_CLKDIV3_PLLFLLFRAC) |
+ SIM_CLKDIV3_PLLFLLDIV(BOARD_SIM_CLKDIV3_PLLFLLDIV));
+ putreg32(regval32, KINETIS_SIM_CLKDIV3);
+#endif
}
/****************************************************************************
diff --git a/arch/arm/src/kinetis/kinetis_config.h b/arch/arm/src/kinetis/kinetis_config.h
index daa15e5ff69133b3114ac706b4d51fce1fcf2893..732dd403c438085c2a046b521748f9e12493ffae 100644
--- a/arch/arm/src/kinetis/kinetis_config.h
+++ b/arch/arm/src/kinetis/kinetis_config.h
@@ -1,8 +1,9 @@
/************************************************************************************
* arch/arm/src/kinetis/kinetis_config.h
*
- * Copyright (C) 2011 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt
+ * Copyright (C) 2011, 2017 Gregory Nutt. All rights reserved.
+ * Authors: Gregory Nutt
+ * David Sidrane
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -50,7 +51,11 @@
************************************************************************************/
/* Configuration *********************************************************************/
-/* Make that no unsupported UARTs are enabled */
+/* Make sure that no unsupported UARTs are enabled */
+
+#ifndef KINETIS_NLPUART
+# define KINETIS_NLPUART 0
+#endif
#ifndef KINETIS_NISO7816
# define KINETIS_NISO7816 0
@@ -75,7 +80,11 @@
# endif
#endif
-/* Are any UARTs enabled? */
+#if KINETIS_NLPUART < 1
+# undef CONFIG_KINETIS_LPUART0
+#endif
+
+/* Are any UARTs or LPUARTs enabled? */
#undef HAVE_UART_DEVICE
#if defined(CONFIG_KINETIS_UART0) || defined(CONFIG_KINETIS_UART1) || \
@@ -84,60 +93,138 @@
# define HAVE_UART_DEVICE 1
#endif
+#undef HAVE_LPUART_DEVICE
+#if defined(CONFIG_KINETIS_LPUART0) || defined(CONFIG_KINETIS_LPUART1)
+# define HAVE_LPUART_DEVICE 1
+#endif
+
/* Is there a serial console? There should be at most one defined. It could be on
* any UARTn, n=0,1,2,3,4,5
*/
-#if defined(CONFIG_UART0_SERIAL_CONSOLE) && defined(CONFIG_KINETIS_UART0)
-# undef CONFIG_UART1_SERIAL_CONSOLE
-# undef CONFIG_UART2_SERIAL_CONSOLE
-# undef CONFIG_UART3_SERIAL_CONSOLE
-# undef CONFIG_UART4_SERIAL_CONSOLE
-# undef CONFIG_UART5_SERIAL_CONSOLE
-# define HAVE_SERIAL_CONSOLE 1
-#elif defined(CONFIG_UART1_SERIAL_CONSOLE) && defined(CONFIG_KINETIS_UART1)
-# undef CONFIG_UART0_SERIAL_CONSOLE
-# undef CONFIG_UART2_SERIAL_CONSOLE
-# undef CONFIG_UART3_SERIAL_CONSOLE
-# undef CONFIG_UART4_SERIAL_CONSOLE
-# undef CONFIG_UART5_SERIAL_CONSOLE
-# define HAVE_SERIAL_CONSOLE 1
-#elif defined(CONFIG_UART2_SERIAL_CONSOLE) && defined(CONFIG_KINETIS_UART2)
-# undef CONFIG_UART0_SERIAL_CONSOLE
-# undef CONFIG_UART1_SERIAL_CONSOLE
-# undef CONFIG_UART3_SERIAL_CONSOLE
-# undef CONFIG_UART4_SERIAL_CONSOLE
-# undef CONFIG_UART5_SERIAL_CONSOLE
-# define HAVE_SERIAL_CONSOLE 1
-#elif defined(CONFIG_UART3_SERIAL_CONSOLE) && defined(CONFIG_KINETIS_UART3)
-# undef CONFIG_UART0_SERIAL_CONSOLE
-# undef CONFIG_UART1_SERIAL_CONSOLE
-# undef CONFIG_UART2_SERIAL_CONSOLE
-# undef CONFIG_UART4_SERIAL_CONSOLE
-# undef CONFIG_UART5_SERIAL_CONSOLE
-# define HAVE_SERIAL_CONSOLE 1
-#elif defined(CONFIG_UART4_SERIAL_CONSOLE) && defined(CONFIG_KINETIS_UART4)
-# undef CONFIG_UART0_SERIAL_CONSOLE
-# undef CONFIG_UART1_SERIAL_CONSOLE
-# undef CONFIG_UART2_SERIAL_CONSOLE
-# undef CONFIG_UART3_SERIAL_CONSOLE
-# undef CONFIG_UART5_SERIAL_CONSOLE
-# define HAVE_SERIAL_CONSOLE 1
-#elif defined(CONFIG_UART5_SERIAL_CONSOLE) && defined(CONFIG_KINETIS_UART5)
-# undef CONFIG_UART0_SERIAL_CONSOLE
-# undef CONFIG_UART1_SERIAL_CONSOLE
-# undef CONFIG_UART2_SERIAL_CONSOLE
-# undef CONFIG_UART3_SERIAL_CONSOLE
-# undef CONFIG_UART4_SERIAL_CONSOLE
-# define HAVE_SERIAL_CONSOLE 1
+#undef HAVE_UART_CONSOLE
+#undef HAVE_LPUART_CONSOLE
+
+#if defined(CONFIG_CONSOLE_SYSLOG)
+# undef CONFIG_UART0_SERIAL_CONSOLE
+# undef CONFIG_UART1_SERIAL_CONSOLE
+# undef CONFIG_UART2_SERIAL_CONSOLE
+# undef CONFIG_UART3_SERIAL_CONSOLE
+# undef CONFIG_UART4_SERIAL_CONSOLE
+# undef CONFIG_UART5_SERIAL_CONSOLE
+# undef CONFIG_LPUART0_SERIAL_CONSOLE
+# undef CONFIG_LPUART1_SERIAL_CONSOLE
#else
-# undef CONFIG_UART0_SERIAL_CONSOLE
-# undef CONFIG_UART1_SERIAL_CONSOLE
-# undef CONFIG_UART2_SERIAL_CONSOLE
-# undef CONFIG_UART3_SERIAL_CONSOLE
-# undef CONFIG_UART4_SERIAL_CONSOLE
-# undef CONFIG_UART5_SERIAL_CONSOLE
-# undef HAVE_SERIAL_CONSOLE
+# if defined(CONFIG_UART0_SERIAL_CONSOLE) && defined(CONFIG_KINETIS_UART0)
+# undef CONFIG_UART1_SERIAL_CONSOLE
+# undef CONFIG_UART2_SERIAL_CONSOLE
+# undef CONFIG_UART3_SERIAL_CONSOLE
+# undef CONFIG_UART4_SERIAL_CONSOLE
+# undef CONFIG_UART5_SERIAL_CONSOLE
+# undef CONFIG_LPUART0_SERIAL_CONSOLE
+# undef CONFIG_LPUART1_SERIAL_CONSOLE
+# define HAVE_UART_CONSOLE 1
+# elif defined(CONFIG_UART1_SERIAL_CONSOLE) && defined(CONFIG_KINETIS_UART1)
+# undef CONFIG_UART0_SERIAL_CONSOLE
+# undef CONFIG_UART2_SERIAL_CONSOLE
+# undef CONFIG_UART3_SERIAL_CONSOLE
+# undef CONFIG_UART4_SERIAL_CONSOLE
+# undef CONFIG_UART5_SERIAL_CONSOLE
+# undef CONFIG_LPUART0_SERIAL_CONSOLE
+# undef CONFIG_LPUART1_SERIAL_CONSOLE
+# define HAVE_UART_CONSOLE 1
+# elif defined(CONFIG_UART2_SERIAL_CONSOLE) && defined(CONFIG_KINETIS_UART2)
+# undef CONFIG_UART0_SERIAL_CONSOLE
+# undef CONFIG_UART1_SERIAL_CONSOLE
+# undef CONFIG_UART3_SERIAL_CONSOLE
+# undef CONFIG_UART4_SERIAL_CONSOLE
+# undef CONFIG_UART5_SERIAL_CONSOLE
+# undef CONFIG_LPUART0_SERIAL_CONSOLE
+# undef CONFIG_LPUART1_SERIAL_CONSOLE
+# define HAVE_UART_CONSOLE 1
+# elif defined(CONFIG_UART3_SERIAL_CONSOLE) && defined(CONFIG_KINETIS_UART3)
+# undef CONFIG_UART0_SERIAL_CONSOLE
+# undef CONFIG_UART1_SERIAL_CONSOLE
+# undef CONFIG_UART2_SERIAL_CONSOLE
+# undef CONFIG_UART4_SERIAL_CONSOLE
+# undef CONFIG_UART5_SERIAL_CONSOLE
+# undef CONFIG_LPUART0_SERIAL_CONSOLE
+# undef CONFIG_LPUART1_SERIAL_CONSOLE
+# define HAVE_UART_CONSOLE 1
+# elif defined(CONFIG_UART4_SERIAL_CONSOLE) && defined(CONFIG_KINETIS_UART4)
+# undef CONFIG_UART0_SERIAL_CONSOLE
+# undef CONFIG_UART1_SERIAL_CONSOLE
+# undef CONFIG_UART2_SERIAL_CONSOLE
+# undef CONFIG_UART3_SERIAL_CONSOLE
+# undef CONFIG_UART5_SERIAL_CONSOLE
+# undef CONFIG_LPUART0_SERIAL_CONSOLE
+# undef CONFIG_LPUART1_SERIAL_CONSOLE
+# define HAVE_UART_CONSOLE 1
+# elif defined(CONFIG_UART5_SERIAL_CONSOLE) && defined(CONFIG_KINETIS_UART5)
+# undef CONFIG_UART0_SERIAL_CONSOLE
+# undef CONFIG_UART1_SERIAL_CONSOLE
+# undef CONFIG_UART2_SERIAL_CONSOLE
+# undef CONFIG_UART3_SERIAL_CONSOLE
+# undef CONFIG_UART4_SERIAL_CONSOLE
+# undef CONFIG_LPUART0_SERIAL_CONSOLE
+# undef CONFIG_LPUART1_SERIAL_CONSOLE
+# define HAVE_UART_CONSOLE 1
+# elif defined(CONFIG_LPUART0_SERIAL_CONSOLE) && defined(CONFIG_KINETIS_LPUART0)
+# undef CONFIG_UART0_SERIAL_CONSOLE
+# undef CONFIG_UART1_SERIAL_CONSOLE
+# undef CONFIG_UART2_SERIAL_CONSOLE
+# undef CONFIG_UART3_SERIAL_CONSOLE
+# undef CONFIG_UART4_SERIAL_CONSOLE
+# undef CONFIG_UART5_SERIAL_CONSOLE
+# undef CONFIG_LPUART1_SERIAL_CONSOLE
+# define HAVE_LPUART_CONSOLE 1
+# elif defined(CONFIG_LPUART1_SERIAL_CONSOLE) && defined(CONFIG_KINETIS_LPUART1)
+# undef CONFIG_UART0_SERIAL_CONSOLE
+# undef CONFIG_UART1_SERIAL_CONSOLE
+# undef CONFIG_UART2_SERIAL_CONSOLE
+# undef CONFIG_UART3_SERIAL_CONSOLE
+# undef CONFIG_UART4_SERIAL_CONSOLE
+# undef CONFIG_UART5_SERIAL_CONSOLE
+# undef CONFIG_LPUART0_SERIAL_CONSOLE
+# define HAVE_LPUART_CONSOLE 1
+# else
+# ifdef CONFIG_DEV_CONSOLE
+# warning "No valid CONFIG_[LP]UART[n]_SERIAL_CONSOLE Setting"
+# endif
+# undef CONFIG_UART0_SERIAL_CONSOLE
+# undef CONFIG_UART1_SERIAL_CONSOLE
+# undef CONFIG_UART2_SERIAL_CONSOLE
+# undef CONFIG_UART3_SERIAL_CONSOLE
+# undef CONFIG_UART4_SERIAL_CONSOLE
+# undef CONFIG_UART5_SERIAL_CONSOLE
+# undef CONFIG_LPUART0_SERIAL_CONSOLE
+# undef CONFIG_LPUART1_SERIAL_CONSOLE
+# endif
+#endif
+
+/* Which version of up_putc() should be built?
+ *
+ * --------------------+-------------------+-----------------+------------------
+ * HAVE_UART_DEVICE && HAVE_UART_DEVICE HAVE_LPUART_DEVICE
+ * HAVE_LPUART_DEVICE (only) (only)
+ * --------------------+-------------------+-----------------+------------------
+ * HAVE_UART_CONSOLE kinetis_serial kinetis_serial (impossible)
+ * HAVE_LPUART_CONSOLE kinetis_lpserial (impossible) kinetis_lpserial
+ * No serial console kinetis_serial kinetis_serial kinetis_lpserial
+ * --------------------+-------------------+-----------------+------------------
+ */
+
+#undef HAVE_UART_PUTC
+#undef HAVE_LPUART_PUTC
+
+#if defined(HAVE_LPUART_CONSOLE)
+# define HAVE_LPUART_PUTC 1
+#elif defined(HAVE_UART_CONSOLE)
+# define HAVE_UART_PUTC 1
+#elif defined(HAVE_UART_DEVICE)
+# define HAVE_UART_PUTC 1
+#elif defined(HAVE_LPUART_DEVICE)
+# define HAVE_LPUART_PUTC 1
#endif
/* Check UART flow control (Not yet supported) */
@@ -148,6 +235,8 @@
# undef CONFIG_UART3_FLOWCONTROL
# undef CONFIG_UART4_FLOWCONTROL
# undef CONFIG_UART5_FLOWCONTROL
+# undef CONFIG_LPUART0_FLOWCONTROL
+# undef CONFIG_LPUART1_FLOWCONTROL
/* UART FIFO support is not fully implemented.
*
@@ -183,6 +272,12 @@
#ifndef CONFIG_KINETIS_UART5PRIO
# define CONFIG_KINETIS_UART5PRIO NVIC_SYSH_PRIORITY_DEFAULT
#endif
+#ifndef CONFIG_KINETIS_LPUART0PRIO
+# define CONFIG_KINETIS_LPUART0PRIO NVIC_SYSH_PRIORITY_DEFAULT
+#endif
+#ifndef CONFIG_KINETIS_LPUART1PRIO
+# define CONFIG_KINETIS_LPUART1PRIO NVIC_SYSH_PRIORITY_DEFAULT
+#endif
/* Ethernet controller configuration */
@@ -197,8 +292,8 @@
# define CONFIG_ENET_PHYADDR 1
#endif
-#ifndef CONFIG_ENET_NETHIFS
-# define CONFIG_ENET_NETHIFS 1
+#ifndef CONFIG_ENETNETHIFS
+# define CONFIG_ENETNETHIFS 1
#endif
/* EMAC Default Interrupt Priorities */
diff --git a/arch/arm/src/kinetis/kinetis_dma.h b/arch/arm/src/kinetis/kinetis_dma.h
index bea264983342d8d06a968b7095d54035605fc520..38f03f87a36b86ae6053921485990d6711be33f4 100644
--- a/arch/arm/src/kinetis/kinetis_dma.h
+++ b/arch/arm/src/kinetis/kinetis_dma.h
@@ -1,5 +1,5 @@
/****************************************************************************
- * arch/arm/src/kenetis/kinetis_dma.h
+ * arch/arm/src/kinetis/kinetis_dma.h
*
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Authors: Gregory Nutt
diff --git a/arch/arm/src/kinetis/kinetis_enet.c b/arch/arm/src/kinetis/kinetis_enet.c
index b1d83352a6910366e5d0d862c621780b41bf6b1a..694b155734c5ef900e01cdc00e4e9ea41362f586 100644
--- a/arch/arm/src/kinetis/kinetis_enet.c
+++ b/arch/arm/src/kinetis/kinetis_enet.c
@@ -127,6 +127,7 @@
#define KINETIS_TXTIMEOUT (60*CLK_TCK)
#define MII_MAXPOLLS (0x1ffff)
#define LINK_WAITUS (500*1000)
+#define LINK_NLOOPS (10)
/* PHY definitions.
*
@@ -156,34 +157,31 @@
# define BOARD_PHYID1 MII_PHYID1_KSZ8041
# define BOARD_PHYID2 MII_PHYID2_KSZ8041
# define BOARD_PHY_STATUS MII_KSZ8041_PHYCTRL2
-# define BOARD_PHY_ISDUPLEX(s) (((s) & (4 << MII_PHYCTRL2_MODE_SHIFT)) != 0)
-# define BOARD_PHY_10BASET(s) (((s) & (1 << MII_PHYCTRL2_MODE_SHIFT)) != 0)
-# define BOARD_PHY_100BASET(s) (((s) & (2 << MII_PHYCTRL2_MODE_SHIFT)) != 0)
#elif defined(CONFIG_ETH0_PHY_KSZ8081)
# define BOARD_PHY_NAME "KSZ8081"
# define BOARD_PHYID1 MII_PHYID1_KSZ8081
# define BOARD_PHYID2 MII_PHYID2_KSZ8081
# define BOARD_PHY_STATUS MII_KSZ8081_PHYCTRL2
-# define BOARD_PHY_ISDUPLEX(s) (((s) & (4 << MII_PHYCTRL2_MODE_SHIFT)) != 0)
-# define BOARD_PHY_10BASET(s) (((s) & (1 << MII_PHYCTRL2_MODE_SHIFT)) != 0)
-# define BOARD_PHY_100BASET(s) (((s) & (2 << MII_PHYCTRL2_MODE_SHIFT)) != 0)
#else
# error "Unrecognized or missing PHY selection"
#endif
-/* Estimate the hold time to use based on the peripheral (bus) clock:
+#define BOARD_PHY_10BASET(s) (((s) & (1 << MII_PHYCTRL2_MODE_SHIFT)) != 0)
+#define BOARD_PHY_100BASET(s) (((s) & (2 << MII_PHYCTRL2_MODE_SHIFT)) != 0)
+#define BOARD_PHY_ISDUPLEX(s) (((s) & (4 << MII_PHYCTRL2_MODE_SHIFT)) != 0)
+
+/* Estimate the MII_SPEED in order to get an MDC close to 2.5MHz,
+ based on the internal module (ENET) clock:
*
- * HOLD_TIME = (2*BUS_FREQ_MHZ)/5 + 1
- * = (BUS_FREQ)/2500000 + 1
+ * MII_SPEED = ENET_FREQ/5000000 -1
*
- * For example, if BUS_FREQ_MHZ=48 (MHz):
+ * For example, if ENET_FREQ_MHZ=120 (MHz):
*
- * HOLD_TIME = 48Mhz, hold time clocks
- * = 48000000/2500000 + 1
- * = 20
+ * MII_SPEED = 120000000/5000000 -1
+ * = 23
*/
-#define KINETIS_MII_SPEED (BOARD_BUS_FREQ/2500000 + 1)
+#define KINETIS_MII_SPEED (BOARD_CORECLK_FREQ/5000000 - 1)
#if KINETIS_MII_SPEED > 63
# error "KINETIS_MII_SPEED is out-of-range"
#endif
@@ -211,7 +209,6 @@
# define SIM_SOPT2_RMIISRC SIM_SOPT2_RMIISRC_EXTBYP
#endif
-
/****************************************************************************
* Private Types
****************************************************************************/
@@ -228,7 +225,8 @@ struct kinetis_driver_s
uint8_t phyaddr; /* Selected PHY address */
WDOG_ID txpoll; /* TX poll timer */
WDOG_ID txtimeout; /* TX timeout timer */
- struct work_s work; /* For deferring work to the work queue */
+ struct work_s irqwork; /* For deferring interrupt work to the work queue */
+ struct work_s pollwork; /* For deferring poll work to the work queue */
struct enet_desc_s *txdesc; /* A pointer to the list of TX descriptor */
struct enet_desc_s *rxdesc; /* A pointer to the list of RX descriptors */
@@ -287,7 +285,7 @@ static void kinetis_receive(FAR struct kinetis_driver_s *priv);
static void kinetis_txdone(FAR struct kinetis_driver_s *priv);
static void kinetis_interrupt_work(FAR void *arg);
-static int kinetis_interrupt(int irq, FAR void *context);
+static int kinetis_interrupt(int irq, FAR void *context, FAR void *arg);
/* Watchdog timer expirations */
@@ -924,7 +922,7 @@ static void kinetis_interrupt_work(FAR void *arg)
*
****************************************************************************/
-static int kinetis_interrupt(int irq, FAR void *context)
+static int kinetis_interrupt(int irq, FAR void *context, FAR void *arg)
{
register FAR struct kinetis_driver_s *priv = &g_enet[0];
@@ -949,13 +947,9 @@ static int kinetis_interrupt(int irq, FAR void *context)
wd_cancel(priv->txtimeout);
}
- /* Cancel any pending poll work */
-
- work_cancel(ETHWORK, &priv->work);
-
/* Schedule to perform the interrupt processing on the worker thread. */
- work_queue(ETHWORK, &priv->work, kinetis_interrupt_work, priv, 0);
+ work_queue(ETHWORK, &priv->irqwork, kinetis_interrupt_work, priv, 0);
return OK;
}
@@ -1031,15 +1025,11 @@ static void kinetis_txtimeout_expiry(int argc, uint32_t arg, ...)
up_disable_irq(KINETIS_IRQ_EMACRX);
up_disable_irq(KINETIS_IRQ_EMACMISC);
- /* Cancel any pending poll or interrupt work. This will have no effect
- * on work that has already been started.
+ /* Schedule to perform the TX timeout processing on the worker thread,
+ * canceling any pending interrupt work.
*/
- work_cancel(ETHWORK, &priv->work);
-
- /* Schedule to perform the TX timeout processing on the worker thread. */
-
- work_queue(ETHWORK, &priv->work, kinetis_txtimeout_work, priv, 0);
+ work_queue(ETHWORK, &priv->irqwork, kinetis_txtimeout_work, priv, 0);
}
/****************************************************************************
@@ -1107,25 +1097,9 @@ static void kinetis_polltimer_expiry(int argc, uint32_t arg, ...)
{
FAR struct kinetis_driver_s *priv = (FAR struct kinetis_driver_s *)arg;
- /* Is our single work structure available? It may not be if there are
- * pending interrupt actions.
- */
-
- if (work_available(&priv->work))
- {
- /* Schedule to perform the interrupt processing on the worker thread. */
+ /* Schedule to perform the poll processing on the worker thread. */
- work_queue(ETHWORK, &priv->work, kinetis_poll_work, priv, 0);
- }
- else
- {
- /* No.. Just re-start the watchdog poll timer, missing one polling
- * cycle.
- */
-
- (void)wd_start(priv->txpoll, KINETIS_WDDELAY, kinetis_polltimer_expiry,
- 1, (wdparm_t)arg);
- }
+ work_queue(ETHWORK, &priv->pollwork, kinetis_poll_work, priv, 0);
}
/****************************************************************************
@@ -1383,11 +1357,11 @@ static int kinetis_txavail(struct net_driver_s *dev)
* availability action.
*/
- if (work_available(&priv->work))
+ if (work_available(&priv->pollwork))
{
/* Schedule to serialize the poll on the worker thread. */
- work_queue(ETHWORK, &priv->work, kinetis_txavail_work, priv, 0);
+ work_queue(ETHWORK, &priv->pollwork, kinetis_txavail_work, priv, 0);
}
return OK;
@@ -1602,7 +1576,7 @@ static int kinetis_writemii(struct kinetis_driver_s *priv, uint8_t phyaddr,
}
/****************************************************************************
- * Function: kinetis_writemii
+ * Function: kinetis_reademii
*
* Description:
* Read a 16-bit value from a PHY register.
@@ -1761,15 +1735,14 @@ static inline int kinetis_initphy(struct kinetis_driver_s *priv)
/* Start auto negotiation */
- ninfo("%s: Start autonegotiation...\n", BOARD_PHY_NAME);
+ ninfo("%s: Start Autonegotiation...\n", BOARD_PHY_NAME);
kinetis_writemii(priv, phyaddr, MII_MCR,
(MII_MCR_ANRESTART | MII_MCR_ANENABLE));
- /* Wait (potentially forever) for auto negotiation to complete */
+ /* Wait for auto negotiation to complete */
- do
+ for (retries = 0; retries < LINK_NLOOPS; retries++)
{
- usleep(LINK_WAITUS);
ret = kinetis_readmii(priv, phyaddr, MII_MSR, &phydata);
if (ret < 0)
{
@@ -1777,24 +1750,45 @@ static inline int kinetis_initphy(struct kinetis_driver_s *priv)
BOARD_PHY_NAME, ret);
return ret;
}
+
+ if (phydata & MII_MSR_ANEGCOMPLETE)
+ {
+ break;
+ }
+
+ usleep(LINK_WAITUS);
}
- while ((phydata & MII_MSR_ANEGCOMPLETE) == 0);
- ninfo("%s: Autonegotiation complete\n", BOARD_PHY_NAME);
- ninfo("%s: MII_MSR: %04x\n", BOARD_PHY_NAME, phydata);
+ if (phydata & MII_MSR_ANEGCOMPLETE)
+ {
+ ninfo("%s: Autonegotiation complete\n", BOARD_PHY_NAME);
+ ninfo("%s: MII_MSR: %04x\n", BOARD_PHY_NAME, phydata);
+ }
+ else
+ {
+ /* TODO: Autonegotitation has right now failed. Maybe the Eth cable is not connected.
+ PHY chip have mechanisms to configure link OK. We should leave autconf on,
+ and find a way to re-configure MCU whenever the link is ready. */
+
+ ninfo("%s: Autonegotiation failed [%d] (is cable plugged-in ?), default to 10Mbs mode\n", \
+ BOARD_PHY_NAME, retries);
+
+ /* Stop auto negotiation */
+
+ kinetis_writemii(priv, phyaddr, MII_MCR, 0);
+ }
- /* When we get here we have a link - Find the negotiated speed and duplex. */
+ /* When we get here we have a (negotiated) speed and duplex. */
phydata = 0;
ret = kinetis_readmii(priv, phyaddr, BOARD_PHY_STATUS, &phydata);
if (ret < 0)
{
- nerr("ERROR: Failed to read %s BOARD_PHY_STATUS{%02x]: %d\n",
+ nerr("ERROR: Failed to read %s BOARD_PHY_STATUS[%02x]: %d\n",
BOARD_PHY_NAME, BOARD_PHY_STATUS, ret);
return ret;
}
-
ninfo("%s: BOARD_PHY_STATUS: %04x\n", BOARD_PHY_NAME, phydata);
/* Set up the transmit and receive control registers based on the
@@ -1802,7 +1796,7 @@ static inline int kinetis_initphy(struct kinetis_driver_s *priv)
*/
#ifdef CONFIG_KINETIS_ENETUSEMII
- rcr = ENET_RCR_MII_MODE | ENET_RCR_CRCFWD |
+ rcr = ENET_RCR_CRCFWD |
CONFIG_NET_ETH_MTU << ENET_RCR_MAX_FL_SHIFT |
ENET_RCR_MII_MODE;
#else
@@ -1839,7 +1833,7 @@ static inline int kinetis_initphy(struct kinetis_driver_s *priv)
ninfo("%s: 10 Base-T\n", BOARD_PHY_NAME);
rcr |= ENET_RCR_RMII_10T;
}
- else if (!BOARD_PHY_100BASET(phydata))
+ else if (BOARD_PHY_100BASET(phydata))
{
/* 100 Mbps */
@@ -1847,7 +1841,7 @@ static inline int kinetis_initphy(struct kinetis_driver_s *priv)
}
else
{
- /* This might happen if autonegotiation did not complete(?) */
+ /* This might happen if Autonegotiation did not complete(?) */
nerr("ERROR: Neither 10- nor 100-BaseT reported: PHY STATUS=%04x\n",
phydata);
@@ -1994,6 +1988,11 @@ static void kinetis_reset(struct kinetis_driver_s *priv)
int kinetis_netinitialize(int intf)
{
struct kinetis_driver_s *priv;
+#ifdef CONFIG_NET_ETHERNET
+ uint32_t uidl;
+ uint32_t uidml;
+ uint8_t *mac;
+#endif
uint32_t regval;
/* Get the interface structure associated with this interface number. */
@@ -2075,7 +2074,7 @@ int kinetis_netinitialize(int intf)
/* Attach the Ethernet MAC IEEE 1588 timer interrupt handler */
#if 0
- if (irq_attach(KINETIS_IRQ_EMACTMR, kinetis_tmrinterrupt))
+ if (irq_attach(KINETIS_IRQ_EMACTMR, kinetis_tmrinterrupt, NULL))
{
/* We could not attach the ISR to the interrupt */
@@ -2086,7 +2085,7 @@ int kinetis_netinitialize(int intf)
/* Attach the Ethernet MAC transmit interrupt handler */
- if (irq_attach(KINETIS_IRQ_EMACTX, kinetis_interrupt))
+ if (irq_attach(KINETIS_IRQ_EMACTX, kinetis_interrupt, NULL))
{
/* We could not attach the ISR to the interrupt */
@@ -2096,7 +2095,7 @@ int kinetis_netinitialize(int intf)
/* Attach the Ethernet MAC receive interrupt handler */
- if (irq_attach(KINETIS_IRQ_EMACRX, kinetis_interrupt))
+ if (irq_attach(KINETIS_IRQ_EMACRX, kinetis_interrupt, NULL))
{
/* We could not attach the ISR to the interrupt */
@@ -2106,7 +2105,7 @@ int kinetis_netinitialize(int intf)
/* Attach the Ethernet MAC error and misc interrupt handler */
- if (irq_attach(KINETIS_IRQ_EMACMISC, kinetis_interrupt))
+ if (irq_attach(KINETIS_IRQ_EMACMISC, kinetis_interrupt, NULL))
{
/* We could not attach the ISR to the interrupt */
@@ -2134,6 +2133,28 @@ int kinetis_netinitialize(int intf)
priv->txpoll = wd_create(); /* Create periodic poll timer */
priv->txtimeout = wd_create(); /* Create TX timeout timer */
+#ifdef CONFIG_NET_ETHERNET
+ /* Determine a semi-unique MAC address from MCU UID
+ * We use UID Low and Mid Low registers to get 64 bits, from which we keep
+ * 48 bits. We then force unicast and locally administered bits (b0 and b1,
+ * 1st octet)
+ */
+
+ uidl = getreg32(KINETIS_SIM_UIDL);
+ uidml = getreg32(KINETIS_SIM_UIDML);
+ mac = priv->dev.d_mac.ether_addr_octet;
+
+ uidml |= 0x00000200;
+ uidml &= 0x0000FEFF;
+
+ mac[0] = (uidml & 0x0000ff00) >> 8;
+ mac[1] = (uidml & 0x000000ff);
+ mac[2] = (uidl & 0xff000000) >> 24;
+ mac[3] = (uidl & 0x00ff0000) >> 16;
+ mac[4] = (uidl & 0x0000ff00) >> 8;
+ mac[5] = (uidl & 0x000000ff);
+#endif
+
/* Put the interface in the down state. This usually amounts to resetting
* the device and/or calling kinetis_ifdown().
*/
diff --git a/arch/arm/src/kinetis/kinetis_i2c.c b/arch/arm/src/kinetis/kinetis_i2c.c
index 337e24b4d39de0a3eff8ae123d376e38ce01246d..6350b18f3469672a6c8f9bd58b41274cad2f3dd0 100644
--- a/arch/arm/src/kinetis/kinetis_i2c.c
+++ b/arch/arm/src/kinetis/kinetis_i2c.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/kinetis/kinetis_i2c.c
*
- * Copyright (C) 2016 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2016-2017 Gregory Nutt. All rights reserved.
* Author: Matias v01d
*
* Redistribution and use in source and binary forms, with or without
@@ -129,16 +129,7 @@ static void kinetis_i2c_setfrequency(struct kinetis_i2cdev_s *priv,
uint32_t frequency);
static int kinetis_i2c_start(struct kinetis_i2cdev_s *priv);
static void kinetis_i2c_stop(struct kinetis_i2cdev_s *priv);
-static int kinetis_i2c_interrupt(struct kinetis_i2cdev_s *priv);
-#ifdef CONFIG_KINETIS_I2C0
-static int kinetis_i2c0_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_KINETIS_I2C1
-static int kinetis_i2c1_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_KINETIS_I2C2
-static int kinetis_i2c2_interrupt(int irq, void *context);
-#endif
+static int kinetis_i2c_interrupt(int irq, void *context, void *arg);
static void kinetis_i2c_timeout(int argc, uint32_t arg, ...);
static void kinetis_i2c_setfrequency(struct kinetis_i2cdev_s *priv,
uint32_t frequency);
@@ -638,14 +629,17 @@ void kinetis_i2c_nextmsg(struct kinetis_i2cdev_s *priv)
*
****************************************************************************/
-static int kinetis_i2c_interrupt(struct kinetis_i2cdev_s *priv)
+static int kinetis_i2c_interrupt(int irq, void *context, void *arg)
{
+ struct kinetis_i2cdev_s *priv = (struct kinetis_i2cdev_s *)arg;
struct i2c_msg_s *msg;
uint32_t state;
int regval;
int dummy;
UNUSED(dummy);
+ DEBUGASSERT(priv != NULL);
+
/* Get current state */
state = kinetis_i2c_getreg(priv, KINETIS_I2C_S_OFFSET);
@@ -811,38 +805,6 @@ static int kinetis_i2c_interrupt(struct kinetis_i2cdev_s *priv)
return OK;
}
-/****************************************************************************
- * Name: kinetis_i2cN_interrupt
- *
- * Description:
- * The I2CN interrupt handlers
- *
- ****************************************************************************/
-
-#ifdef CONFIG_KINETIS_I2C0
-static int kinetis_i2c0_interrupt(int irq, void *context)
-{
- i2cinfo("I2C0 Interrupt...\n");
- return kinetis_i2c_interrupt(&g_i2c0_dev);
-}
-#endif
-
-#ifdef CONFIG_KINETIS_I2C1
-static int kinetis_i2c1_interrupt(int irq, void *context)
-{
- i2cinfo("I2C1 Interrupt...\n");
- return kinetis_i2c_interrupt(&g_i2c1_dev);
-}
-#endif
-
-#ifdef CONFIG_KINETIS_I2C2
-static int kinetis_i2c2_interrupt(int irq, void *context)
-{
- i2cinfo("I2C2 Interrupt...\n");
- return kinetis_i2c_interrupt(&g_i2c2_dev);
-}
-#endif
-
/****************************************************************************
* Name: kinetis_i2c_transfer
*
@@ -988,7 +950,6 @@ static int kinetis_i2c_reset(struct i2c_master_s *dev)
struct i2c_master_s *kinetis_i2cbus_initialize(int port)
{
struct kinetis_i2cdev_s *priv;
- xcpt_t handler;
i2cinfo("port=%d\n", port);
@@ -1011,8 +972,6 @@ struct i2c_master_s *kinetis_i2cbus_initialize(int port)
priv->irqid = KINETIS_IRQ_I2C0;
priv->basefreq = BOARD_BUS_FREQ;
- handler = kinetis_i2c0_interrupt;
-
/* Enable clock */
regval = getreg32(KINETIS_SIM_SCGC4);
@@ -1038,8 +997,6 @@ struct i2c_master_s *kinetis_i2cbus_initialize(int port)
priv->irqid = KINETIS_IRQ_I2C1;
priv->basefreq = BOARD_BUS_FREQ;
- handler = kinetis_i2c1_interrupt;
-
/* Enable clock */
regval = getreg32(KINETIS_SIM_SCGC4);
@@ -1065,8 +1022,6 @@ struct i2c_master_s *kinetis_i2cbus_initialize(int port)
priv->irqid = KINETIS_IRQ_I2C2;
priv->basefreq = BOARD_BUS_FREQ;
- handler = kinetis_i2c2_interrupt;
-
/* Enable clock */
regval = getreg32(KINETIS_SIM_SCGC4);
@@ -1124,7 +1079,7 @@ struct i2c_master_s *kinetis_i2cbus_initialize(int port)
/* Attach Interrupt Handler */
- irq_attach(priv->irqid, handler);
+ irq_attach(priv->irqid, kinetis_i2c_interrupt, priv);
/* Enable Interrupt Handler */
diff --git a/arch/arm/src/kinetis/kinetis_irq.c b/arch/arm/src/kinetis/kinetis_irq.c
index 7830d8756e2f899b603203c4193d1bca88f5a468..f75085d7b552df4c0356741cc4101b0d6d748341 100644
--- a/arch/arm/src/kinetis/kinetis_irq.c
+++ b/arch/arm/src/kinetis/kinetis_irq.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * arch/arm/src/lpc17/kinetis_irq.c
+ * arch/arm/src/kinetis/kinetis_irq.c
*
* Copyright (C) 2011, 2013-2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
@@ -170,7 +170,7 @@ static void kinetis_dumpnvic(const char *msg, int irq)
****************************************************************************/
#ifdef CONFIG_DEBUG_FEATURES
-static int kinetis_nmi(int irq, FAR void *context)
+static int kinetis_nmi(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! NMI received\n");
@@ -178,7 +178,7 @@ static int kinetis_nmi(int irq, FAR void *context)
return 0;
}
-static int kinetis_busfault(int irq, FAR void *context)
+static int kinetis_busfault(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Bus fault recived\n");
@@ -186,7 +186,7 @@ static int kinetis_busfault(int irq, FAR void *context)
return 0;
}
-static int kinetis_usagefault(int irq, FAR void *context)
+static int kinetis_usagefault(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Usage fault received\n");
@@ -194,7 +194,7 @@ static int kinetis_usagefault(int irq, FAR void *context)
return 0;
}
-static int kinetis_pendsv(int irq, FAR void *context)
+static int kinetis_pendsv(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! PendSV received\n");
@@ -202,7 +202,7 @@ static int kinetis_pendsv(int irq, FAR void *context)
return 0;
}
-static int kinetis_dbgmonitor(int irq, FAR void *context)
+static int kinetis_dbgmonitor(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Debug Monitor received\n");
@@ -210,7 +210,7 @@ static int kinetis_dbgmonitor(int irq, FAR void *context)
return 0;
}
-static int kinetis_reserved(int irq, FAR void *context)
+static int kinetis_reserved(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Reserved interrupt\n");
@@ -398,8 +398,8 @@ void up_irqinitialize(void)
* under certain conditions.
*/
- irq_attach(KINETIS_IRQ_SVCALL, up_svcall);
- irq_attach(KINETIS_IRQ_HARDFAULT, up_hardfault);
+ irq_attach(KINETIS_IRQ_SVCALL, up_svcall, NULL);
+ irq_attach(KINETIS_IRQ_HARDFAULT, up_hardfault, NULL);
/* Set the priority of the SVCall interrupt */
@@ -415,22 +415,22 @@ void up_irqinitialize(void)
*/
#ifdef CONFIG_ARM_MPU
- irq_attach(KINETIS_IRQ_MEMFAULT, up_memfault);
+ irq_attach(KINETIS_IRQ_MEMFAULT, up_memfault, NULL);
up_enable_irq(KINETIS_IRQ_MEMFAULT);
#endif
/* Attach all other processor exceptions (except reset and sys tick) */
#ifdef CONFIG_DEBUG_FEATURES
- irq_attach(KINETIS_IRQ_NMI, kinetis_nmi);
+ irq_attach(KINETIS_IRQ_NMI, kinetis_nmi, NULL);
#ifndef CONFIG_ARM_MPU
- irq_attach(KINETIS_IRQ_MEMFAULT, up_memfault);
+ irq_attach(KINETIS_IRQ_MEMFAULT, up_memfault, NULL);
#endif
- irq_attach(KINETIS_IRQ_BUSFAULT, kinetis_busfault);
- irq_attach(KINETIS_IRQ_USAGEFAULT, kinetis_usagefault);
- irq_attach(KINETIS_IRQ_PENDSV, kinetis_pendsv);
- irq_attach(KINETIS_IRQ_DBGMONITOR, kinetis_dbgmonitor);
- irq_attach(KINETIS_IRQ_RESERVED, kinetis_reserved);
+ irq_attach(KINETIS_IRQ_BUSFAULT, kinetis_busfault, NULL);
+ irq_attach(KINETIS_IRQ_USAGEFAULT, kinetis_usagefault, NULL);
+ irq_attach(KINETIS_IRQ_PENDSV, kinetis_pendsv, NULL);
+ irq_attach(KINETIS_IRQ_DBGMONITOR, kinetis_dbgmonitor, NULL);
+ irq_attach(KINETIS_IRQ_RESERVED, kinetis_reserved, NULL);
#endif
kinetis_dumpnvic("initial", NR_IRQS);
diff --git a/arch/arm/src/kinetis/kinetis_lowputc.c b/arch/arm/src/kinetis/kinetis_lowputc.c
index ec85713c9331564ff3c7a2c6baed916ef561faff..31bb32f697b936efb4bce26878539827a5ffb587 100644
--- a/arch/arm/src/kinetis/kinetis_lowputc.c
+++ b/arch/arm/src/kinetis/kinetis_lowputc.c
@@ -1,8 +1,9 @@
/****************************************************************************
* arch/arm/src/kinetis/kinetis_lowputc.c
*
- * Copyright (C) 2011 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt
+ * Copyright (C) 2011, 2017 Gregory Nutt. All rights reserved.
+ * Authors: Gregory Nutt
+ * David Sidrane
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -50,6 +51,7 @@
#include "kinetis_config.h"
#include "kinetis.h"
#include "chip/kinetis_uart.h"
+#include "chip/kinetis_lpuart.h"
#include "chip/kinetis_sim.h"
#include "chip/kinetis_pinmux.h"
@@ -59,57 +61,84 @@
/* Select UART parameters for the selected console */
-#if defined(CONFIG_UART0_SERIAL_CONSOLE)
-# define CONSOLE_BASE KINETIS_UART0_BASE
-# define CONSOLE_FREQ BOARD_CORECLK_FREQ
-# define CONSOLE_BAUD CONFIG_UART0_BAUD
-# define CONSOLE_BITS CONFIG_UART0_BITS
-# define CONSOLE_PARITY CONFIG_UART0_PARITY
-#elif defined(CONFIG_UART1_SERIAL_CONSOLE)
-# define CONSOLE_BASE KINETIS_UART1_BASE
-# define CONSOLE_FREQ BOARD_CORECLK_FREQ
-# define CONSOLE_BAUD CONFIG_UART1_BAUD
-# define CONSOLE_BITS CONFIG_UART1_BITS
-# define CONSOLE_PARITY CONFIG_UART1_PARITY
-#elif defined(CONFIG_UART2_SERIAL_CONSOLE)
-# define CONSOLE_BASE KINETIS_UART2_BASE
-# define CONSOLE_FREQ BOARD_BUS_FREQ
-# define CONSOLE_BAUD CONFIG_UART2_BAUD
-# define CONSOLE_BITS CONFIG_UART2_BITS
-# define CONSOLE_PARITY CONFIG_UART2_PARITY
-#elif defined(CONFIG_UART3_SERIAL_CONSOLE)
-# define CONSOLE_BASE KINETIS_UART3_BASE
-# define CONSOLE_FREQ BOARD_BUS_FREQ
-# define CONSOLE_BAUD CONFIG_UART3_BAUD
-# define CONSOLE_BITS CONFIG_UART3_BITS
-# define CONSOLE_PARITY CONFIG_UART3_PARITY
-#elif defined(CONFIG_UART4_SERIAL_CONSOLE)
-# define CONSOLE_BASE KINETIS_UART4_BASE
-# define CONSOLE_FREQ BOARD_BUS_FREQ
-# define CONSOLE_BAUD CONFIG_UART4_BAUD
-# define CONSOLE_BITS CONFIG_UART4_BITS
-# define CONSOLE_PARITY CONFIG_UART4_PARITY
-#elif defined(CONFIG_UART5_SERIAL_CONSOLE)
-# define CONSOLE_BASE KINETIS_UART5_BASE
-# define CONSOLE_FREQ BOARD_BUS_FREQ
-# define CONSOLE_BAUD CONFIG_UART5_BAUD
-# define CONSOLE_BITS CONFIG_UART5_BITS
-# define CONSOLE_PARITY CONFIG_UART5_PARITY
-#elif defined(HAVE_SERIAL_CONSOLE)
-# error "No CONFIG_UARTn_SERIAL_CONSOLE Setting"
-#endif
-
-/****************************************************************************
- * Private Types
- ****************************************************************************/
-
-/****************************************************************************
- * Private Function Prototypes
- ****************************************************************************/
+#if defined(HAVE_UART_CONSOLE)
+# if defined(CONFIG_UART0_SERIAL_CONSOLE)
+# define CONSOLE_BASE KINETIS_UART0_BASE
+# define CONSOLE_FREQ BOARD_CORECLK_FREQ
+# define CONSOLE_BAUD CONFIG_UART0_BAUD
+# define CONSOLE_BITS CONFIG_UART0_BITS
+# define CONSOLE_2STOP CONFIG_UART0_2STOP
+# define CONSOLE_PARITY CONFIG_UART0_PARITY
+# elif defined(CONFIG_UART1_SERIAL_CONSOLE)
+# define CONSOLE_BASE KINETIS_UART1_BASE
+# define CONSOLE_FREQ BOARD_CORECLK_FREQ
+# define CONSOLE_BAUD CONFIG_UART1_BAUD
+# define CONSOLE_BITS CONFIG_UART1_BITS
+# define CONSOLE_2STOP CONFIG_UART1_2STOP
+# define CONSOLE_PARITY CONFIG_UART1_PARITY
+# elif defined(CONFIG_UART2_SERIAL_CONSOLE)
+# define CONSOLE_BASE KINETIS_UART2_BASE
+# define CONSOLE_FREQ BOARD_BUS_FREQ
+# define CONSOLE_BAUD CONFIG_UART2_BAUD
+# define CONSOLE_BITS CONFIG_UART2_BITS
+# define CONSOLE_2STOP CONFIG_UART2_2STOP
+# define CONSOLE_PARITY CONFIG_UART2_PARITY
+# elif defined(CONFIG_UART3_SERIAL_CONSOLE)
+# define CONSOLE_BASE KINETIS_UART3_BASE
+# define CONSOLE_FREQ BOARD_BUS_FREQ
+# define CONSOLE_BAUD CONFIG_UART3_BAUD
+# define CONSOLE_BITS CONFIG_UART3_BITS
+# define CONSOLE_2STOP CONFIG_UART3_2STOP
+# define CONSOLE_PARITY CONFIG_UART3_PARITY
+# elif defined(CONFIG_UART4_SERIAL_CONSOLE)
+# define CONSOLE_BASE KINETIS_UART4_BASE
+# define CONSOLE_FREQ BOARD_BUS_FREQ
+# define CONSOLE_BAUD CONFIG_UART4_BAUD
+# define CONSOLE_BITS CONFIG_UART4_BITS
+# define CONSOLE_2STOP CONFIG_UART4_2STOP
+# define CONSOLE_PARITY CONFIG_UART4_PARITY
+# elif defined(CONFIG_UART5_SERIAL_CONSOLE)
+# define CONSOLE_BASE KINETIS_UART5_BASE
+# define CONSOLE_FREQ BOARD_BUS_FREQ
+# define CONSOLE_BAUD CONFIG_UART5_BAUD
+# define CONSOLE_BITS CONFIG_UART5_BITS
+# define CONSOLE_2STOP CONFIG_UART5_2STOP
+# define CONSOLE_PARITY CONFIG_UART5_PARITY
+# elif defined(HAVE_UART_CONSOLE)
+# error "No CONFIG_UARTn_SERIAL_CONSOLE Setting"
+# endif
+#elif defined(HAVE_LPUART_CONSOLE)
+# if defined(CONFIG_LPUART0_SERIAL_CONSOLE)
+# define CONSOLE_BASE KINETIS_LPUART0_BASE
+# define CONSOLE_FREQ BOARD_LPUART0_FREQ
+# define CONSOLE_BAUD CONFIG_LPUART0_BAUD
+# define CONSOLE_PARITY CONFIG_LPUART0_PARITY
+# define CONSOLE_BITS CONFIG_LPUART0_BITS
+# define CONSOLE_2STOP CONFIG_LPUART0_2STOP
+# elif defined(CONFIG_LPUART1_SERIAL_CONSOLE)
+# define CONSOLE_BASE KINETIS_LPUART1_BASE
+# define CONSOLE_FREQ BOARD_LPUART1_FREQ
+# define CONSOLE_BAUD CONFIG_LPUART1_BAUD
+# define CONSOLE_PARITY CONFIG_LPUART1_PARITY
+# define CONSOLE_BITS CONFIG_LPUART1_BITS
+# define CONSOLE_2STOP CONFIG_LPUART1_2STOP
+# else
+# error "No LPUART console is selected"
+# endif
+#endif /* HAVE_UART_CONSOLE */
-/****************************************************************************
- * Public Data
- ****************************************************************************/
+#if defined(HAVE_LPUART_CONSOLE)
+# if ((CONSOLE_FREQ / (CONSOLE_BAUD * 32)) > (LPUART_BAUD_SBR_MASK >> LPUART_BAUD_SBR_SHIFT))
+# error "LPUART Console: Baud rate not obtainable with this input clock!"
+# endif
+# define LPUART_BAUD_INIT (LPUART_BAUD_SBR_MASK | LPUART_BAUD_SBNS | \
+ LPUART_BAUD_RXEDGIE | LPUART_BAUD_LBKDIE | \
+ LPUART_BAUD_RESYNCDIS |LPUART_BAUD_BOTHEDGE | \
+ LPUART_BAUD_MATCFG_MASK | LPUART_BAUD_RDMAE | \
+ LPUART_BAUD_TDMAE | LPUART_BAUD_OSR_MASK | \
+ LPUART_BAUD_M10 | LPUART_BAUD_MAEN2 | \
+ LPUART_BAUD_MAEN2)
+#endif
/****************************************************************************
* Private Data
@@ -120,13 +149,12 @@
*/
#ifdef CONFIG_KINETIS_UARTFIFOS
-static uint8_t g_sizemap[8] = {1, 4, 8, 16, 32, 64, 128, 0};
+static uint8_t g_sizemap[8] =
+{
+ 1, 4, 8, 16, 32, 64, 128, 0
+};
#endif
-/****************************************************************************
- * Private Functions
- ****************************************************************************/
-
/****************************************************************************
* Public Functions
****************************************************************************/
@@ -141,20 +169,20 @@ static uint8_t g_sizemap[8] = {1, 4, 8, 16, 32, 64, 128, 0};
void up_lowputc(char ch)
{
-#if defined HAVE_UART_DEVICE && defined HAVE_SERIAL_CONSOLE
-#ifdef CONFIG_KINETIS_UARTFIFOS
+#if defined(HAVE_UART_CONSOLE)
+# ifdef CONFIG_KINETIS_UARTFIFOS
/* Wait until there is space in the TX FIFO: Read the number of bytes
* currently in the FIFO and compare that to the size of the FIFO. If
* there are fewer bytes in the FIFO than the size of the FIFO, then we
* are able to transmit.
*/
-# error "Missing logic"
-#else
+# error "Missing logic"
+# else
/* Wait until the transmit data register is "empty" (TDRE). This state
* depends on the TX watermark setting and may not mean that the transmit
* buffer is truly empty. It just means that we can now add another
- * characterto the transmit buffer without exceeding the watermark.
+ * character to the transmit buffer without exceeding the watermark.
*
* NOTE: UART0 has an 8-byte deep FIFO; the other UARTs have no FIFOs
* (1-deep). There appears to be no way to know when the FIFO is not
@@ -167,11 +195,18 @@ void up_lowputc(char ch)
*/
while ((getreg8(CONSOLE_BASE+KINETIS_UART_S1_OFFSET) & UART_S1_TDRE) == 0);
-#endif
+# endif
/* Then write the character to the UART data register */
putreg8((uint8_t)ch, CONSOLE_BASE+KINETIS_UART_D_OFFSET);
+
+#elif defined(HAVE_LPUART_CONSOLE)
+ while ((getreg32(CONSOLE_BASE + KINETIS_LPUART_STAT_OFFSET) & LPUART_STAT_TDRE) == 0);
+
+ /* Then send the character */
+
+ putreg32((uint32_t)ch, CONSOLE_BASE + KINETIS_LPUART_DATA_OFFSET);
#endif
}
@@ -180,92 +215,131 @@ void up_lowputc(char ch)
*
* Description:
* This performs basic initialization of the UART used for the serial
- * console. Its purpose is to get the console output availabe as soon
+ * console. Its purpose is to get the console output available as soon
* as possible.
*
****************************************************************************/
void kinetis_lowsetup(void)
{
-#ifdef HAVE_UART_DEVICE
+#if defined(HAVE_UART_DEVICE) ||defined(HAVE_LUART_DEVICE)
uint32_t regval;
+#endif
+#ifdef HAVE_UART_DEVICE
/* Enable peripheral clocking for all enabled UARTs. Clocking for UARTs
* 0-3 is enabled in the SCGC4 register.
*/
-#if defined(CONFIG_KINETIS_UART0) || defined(CONFIG_KINETIS_UART1) || \
- defined(CONFIG_KINETIS_UART2) || defined(CONFIG_KINETIS_UART3)
+# if defined(CONFIG_KINETIS_UART0) || defined(CONFIG_KINETIS_UART1) || \
+ defined(CONFIG_KINETIS_UART2) || defined(CONFIG_KINETIS_UART3)
regval = getreg32(KINETIS_SIM_SCGC4);
-# ifdef CONFIG_KINETIS_UART0
+# ifdef CONFIG_KINETIS_UART0
regval |= SIM_SCGC4_UART0;
-# endif
-# ifdef CONFIG_KINETIS_UART1
+# endif
+# ifdef CONFIG_KINETIS_UART1
regval |= SIM_SCGC4_UART1;
-# endif
-# ifdef CONFIG_KINETIS_UART2
+# endif
+# ifdef CONFIG_KINETIS_UART2
regval |= SIM_SCGC4_UART2;
-# endif
-# ifdef CONFIG_KINETIS_UART3
+# endif
+# ifdef CONFIG_KINETIS_UART3
regval |= SIM_SCGC4_UART3;
-# endif
+# endif
putreg32(regval, KINETIS_SIM_SCGC4);
-#endif
+# endif
/* Clocking for UARTs 4-5 is enabled in the SCGC1 register. */
-#if defined(CONFIG_KINETIS_UART4) || defined(CONFIG_KINETIS_UART5)
+# if defined(CONFIG_KINETIS_UART4) || defined(CONFIG_KINETIS_UART5)
regval = getreg32(KINETIS_SIM_SCGC1);
-# ifdef CONFIG_KINETIS_UART4
+# ifdef CONFIG_KINETIS_UART4
regval |= SIM_SCGC1_UART4;
-# endif
-# ifdef CONFIG_KINETIS_UART5
+# endif
+# ifdef CONFIG_KINETIS_UART5
regval |= SIM_SCGC1_UART5;
-# endif
+# endif
putreg32(regval, KINETIS_SIM_SCGC1);
-#endif
+# endif
/* Configure UART pins for the all enabled UARTs */
-#ifdef CONFIG_KINETIS_UART0
+# ifdef CONFIG_KINETIS_UART0
kinetis_pinconfig(PIN_UART0_TX);
kinetis_pinconfig(PIN_UART0_RX);
-#endif
-#ifdef CONFIG_KINETIS_UART1
+# endif
+# ifdef CONFIG_KINETIS_UART1
kinetis_pinconfig(PIN_UART1_TX);
kinetis_pinconfig(PIN_UART1_RX);
-#endif
-#ifdef CONFIG_KINETIS_UART2
+# endif
+# ifdef CONFIG_KINETIS_UART2
kinetis_pinconfig(PIN_UART2_TX);
kinetis_pinconfig(PIN_UART2_RX);
-#endif
-#ifdef CONFIG_KINETIS_UART3
+# endif
+# ifdef CONFIG_KINETIS_UART3
kinetis_pinconfig(PIN_UART3_TX);
kinetis_pinconfig(PIN_UART3_RX);
-#endif
-#ifdef CONFIG_KINETIS_UART4
+# endif
+# ifdef CONFIG_KINETIS_UART4
kinetis_pinconfig(PIN_UART4_TX);
kinetis_pinconfig(PIN_UART4_RX);
-#endif
-#ifdef CONFIG_KINETIS_UART5
+# endif
+# ifdef CONFIG_KINETIS_UART5
kinetis_pinconfig(PIN_UART5_TX);
kinetis_pinconfig(PIN_UART5_RX);
-#endif
+# endif
/* Configure the console (only) now. Other UARTs will be configured
* when the serial driver is opened.
*/
-#if defined(HAVE_SERIAL_CONSOLE) && !defined(CONFIG_SUPPRESS_UART_CONFIG)
+# if defined(HAVE_UART_CONSOLE) && !defined(CONFIG_SUPPRESS_UART_CONFIG)
- kinetis_uartconfigure(CONSOLE_BASE, CONSOLE_BAUD, CONSOLE_FREQ,
- CONSOLE_PARITY, CONSOLE_BITS);
-#endif
+ kinetis_uartconfigure(CONSOLE_BASE, CONSOLE_BAUD, CONSOLE_FREQ, \
+ CONSOLE_PARITY, CONSOLE_BITS, CONSOLE_2STOP);
+# endif
#endif /* HAVE_UART_DEVICE */
+
+#ifdef HAVE_LPUART_DEVICE
+
+ /* Clocking Source for LPUARTs 0 selected in SIM_SOPT2 */
+
+# if defined(CONFIG_KINETIS_LPUART0)
+ regval = getreg32(KINETIS_SIM_SOPT2);
+ regval &= ~(SIM_SOPT2_LPUARTSRC_MASK);
+ regval |= BOARD_LPUART0_CLKSRC;
+ putreg32(regval, KINETIS_SIM_SOPT2);
+
+ /* Clocking for LPUARTs 0-1 is enabled in the SCGC2 register. */
+
+ regval = getreg32(KINETIS_SIM_SCGC2);
+ regval |= SIM_SCGC2_LPUART0;
+ putreg32(regval, KINETIS_SIM_SCGC2);
+
+# endif
+
+ /* Configure UART pins for the all enabled UARTs */
+
+# ifdef CONFIG_KINETIS_LPUART0
+ kinetis_pinconfig(PIN_LPUART0_TX);
+ kinetis_pinconfig(PIN_LPUART0_RX);
+# endif
+
+# ifdef CONFIG_KINETIS_LPUART1
+ kinetis_pinconfig(PIN_LPUART1_TX);
+ kinetis_pinconfig(PIN_LPUART1_RX);
+# endif
+
+# if defined(HAVE_LPUART_CONSOLE) && !defined(CONFIG_SUPPRESS_LPUART_CONFIG)
+
+ kinetis_lpuartconfigure(CONSOLE_BASE, CONSOLE_BAUD, CONSOLE_FREQ, \
+ CONSOLE_PARITY, CONSOLE_BITS, CONSOLE_2STOP);
+# endif
+#endif /* HAVE_LPUART_DEVICE */
}
/****************************************************************************
@@ -289,6 +363,27 @@ void kinetis_uartreset(uintptr_t uart_base)
}
#endif
+/****************************************************************************
+ * Name: kinetis_lpuartreset
+ *
+ * Description:
+ * Reset a UART.
+ *
+ ****************************************************************************/
+
+#ifdef HAVE_LPUART_DEVICE
+void kinetis_lpuartreset(uintptr_t uart_base)
+{
+ uint32_t regval;
+
+ /* Just disable the transmitter and receiver */
+
+ regval = getreg32(uart_base+KINETIS_LPUART_CTRL_OFFSET);
+ regval &= ~(LPUART_CTRL_RE | LPUART_CTRL_TE);
+ putreg32(regval, uart_base+KINETIS_LPUART_CTRL_OFFSET);
+}
+#endif
+
/****************************************************************************
* Name: kinetis_uartconfigure
*
@@ -300,7 +395,7 @@ void kinetis_uartreset(uintptr_t uart_base)
#ifdef HAVE_UART_DEVICE
void kinetis_uartconfigure(uintptr_t uart_base, uint32_t baud,
uint32_t clock, unsigned int parity,
- unsigned int nbits)
+ unsigned int nbits, unsigned int stop2)
{
uint32_t sbr;
uint32_t brfa;
@@ -362,11 +457,16 @@ void kinetis_uartconfigure(uintptr_t uart_base, uint32_t baud,
sbr = clock / (baud << 4);
DEBUGASSERT(sbr < 0x2000);
- /* Save the new baud divisor, retaining other bits in the UARTx_BDH
- * register.
+ /* Save the new baud divisor and stop bits, retaining other bits in the
+ * UARTx_BDH register.
*/
- regval = getreg8(uart_base+KINETIS_UART_BDH_OFFSET) & UART_BDH_SBR_MASK;
+ regval = getreg8(uart_base+KINETIS_UART_BDH_OFFSET);
+ regval &= ~(UART_BDH_SBR_MASK | UART_BDH_SBNS);
+ if (stop2)
+ {
+ regval |= UART_BDH_SBNS;
+ }
tmp = sbr >> 8;
regval |= (((uint8_t)tmp) << UART_BDH_SBR_SHIFT) & UART_BDH_SBR_MASK;
putreg8(regval, uart_base+KINETIS_UART_BDH_OFFSET);
@@ -378,7 +478,7 @@ void kinetis_uartconfigure(uintptr_t uart_base, uint32_t baud,
* The fractional divider, BRFA, is a 5 bit fractional value that is
* logically added to the SBR:
*
- * UART baud rate = clock / (16 (SBR + BRFD))
+ * UART baud rate = clock / (16 � (SBR + BRFD))
*
* The BRFA the remainder. This will be a non-negative value since the SBR
* was calculated by truncation.
@@ -411,6 +511,7 @@ void kinetis_uartconfigure(uintptr_t uart_base, uint32_t baud,
{
depth = (3 * depth) >> 2;
}
+
putreg8(depth , uart_base+KINETIS_UART_RWFIFO_OFFSET);
depth = g_sizemap[(regval & UART_PFIFO_TXFIFOSIZE_MASK) >> UART_PFIFO_TXFIFOSIZE_SHIFT];
@@ -418,6 +519,7 @@ void kinetis_uartconfigure(uintptr_t uart_base, uint32_t baud,
{
depth = (depth >> 2);
}
+
putreg8(depth, uart_base+KINETIS_UART_TWFIFO_OFFSET);
/* Enable RX and TX FIFOs */
@@ -442,9 +544,176 @@ void kinetis_uartconfigure(uintptr_t uart_base, uint32_t baud,
/* Now we can (re-)enable the transmitter and receiver */
- regval = getreg8(uart_base+KINETIS_UART_C2_OFFSET);
+ regval = getreg8(uart_base+KINETIS_UART_C2_OFFSET);
regval |= (UART_C2_RE | UART_C2_TE);
putreg8(regval, uart_base+KINETIS_UART_C2_OFFSET);
}
#endif
+/****************************************************************************
+ * Name: kinetis_lpuartconfigure
+ *
+ * Description:
+ * Configure a LPUART as a RS-232 UART.
+ *
+ ****************************************************************************/
+
+#ifdef HAVE_LPUART_DEVICE
+void kinetis_lpuartconfigure(uintptr_t uart_base, uint32_t baud,
+ uint32_t clock, unsigned int parity,
+ unsigned int nbits, unsigned int stop2)
+{
+ uint32_t sbrreg;
+ uint32_t osrreg;
+ uint32_t sbr;
+ uint32_t osr;
+ uint32_t actual_baud;
+ uint32_t current_baud;
+ uint32_t baud_error;
+ uint32_t min_baud_error;
+ uint32_t regval;
+
+ /* General note: LPART block input clock can be sourced by
+ * SIM_CLKDIV3[PLLFLLFRAC, PLLFLLDIV] since this can be shared with TPM, we
+ * would ideally want to maximize the input frequency. This also helps to
+ * maximize the oversampling.
+ *
+ * We would like to maximize oversample and minimize the baud rate error
+ *
+ * USART baud is generated according to:
+ *
+ * baud = clock / (SBR[0:12] * (OSR +1 ))
+ *
+ * Or, equivalently:
+ *
+ * SBR = clock / (baud * (OSR + 1))
+ * OSR = clock / (baud * SBR) -1
+ *
+ * SBR must be 1..8191
+ * OSR must be 3..31 (macro value 4..32)
+ */
+
+ min_baud_error = baud;
+ sbrreg = 0;
+ osrreg = 0;
+
+ /* While maximizing OSR look for a SBR that minimizes the difference
+ * between actual baud and requested baud rate
+ */
+
+ for (osr = 32; osr >= 4; osr--)
+ {
+ sbr = clock / (baud * osr);
+
+ /* Ensure the minimum SBR */
+
+ if (sbr == 0)
+ {
+ sbr++;
+ }
+
+ /* Calculate the actual baud rate */
+
+ current_baud = clock / (sbr * osr);
+
+ /* look at the deviation of current baud to requested */
+
+ baud_error = current_baud - baud;
+ if (baud_error <= min_baud_error)
+ {
+ min_baud_error = baud_error;
+ actual_baud = current_baud;
+ sbrreg = sbr;
+ osrreg = osr;
+ }
+ }
+
+ UNUSED(actual_baud);
+ DEBUGASSERT(actual_baud-baud < (baud /100) * 2);
+ DEBUGASSERT(sbrreg != 0 && sbrreg < 8192);
+ DEBUGASSERT(osrreg != 0);
+
+ /* Disable the transmitter and receiver throughout the reconfiguration */
+
+ regval = getreg32(uart_base+KINETIS_LPUART_CTRL_OFFSET);
+ regval &= ~(LPUART_CTRL_RE | LPUART_CTRL_TE);
+ putreg32(regval, uart_base+KINETIS_LPUART_CTRL_OFFSET);
+
+ /* Reset the BAUD register */
+
+ regval = getreg32(uart_base+KINETIS_LPUART_BAUD_OFFSET);
+ regval &= ~(LPUART_BAUD_INIT);
+
+ /* Set the Baud rate, nbits and stop bits */
+
+ regval |= LPUART_BAUD_OSR(osrreg);
+ regval |= LPUART_BAUD_SBR(sbrreg);
+
+ /* Set the 10 bit mode */
+
+ if (nbits == 10)
+ {
+ regval |= LPUART_BAUD_M10;
+ }
+
+ /* Set the 2 stop bit mode */
+
+ if (stop2)
+ {
+ regval |= LPUART_BAUD_SBNS;
+ }
+
+ /* BOTHEDG needs to be turned on for 4X-7X */
+
+ if (osrreg >= 4 && osrreg <= 7)
+ {
+ regval |= LPUART_BAUD_BOTHEDGE;
+ }
+
+ putreg32(regval, uart_base+KINETIS_LPUART_BAUD_OFFSET);
+
+ /* Configure number of bits and parity */
+
+ regval = 0;
+
+ /* Check for odd parity */
+
+ if (parity == 1)
+ {
+ regval |= (LPUART_CTRL_PE | LPUART_CTRL_PT); /* Enable + odd parity type */
+ }
+
+ /* Check for even parity */
+
+ else if (parity == 2)
+ {
+ regval |= LPUART_CTRL_PE; /* Enable (even parity default) */
+ }
+
+ /* The only other option is no parity */
+
+ else
+ {
+ DEBUGASSERT(parity == 0);
+ }
+
+ /* Check for 9-bit operation */
+
+ if (nbits == 9)
+ {
+ regval |= LPUART_CTRL_M;
+ }
+
+ /* The only other option is 8-bit operation */
+
+ else
+ {
+ DEBUGASSERT(nbits == 8);
+ }
+
+ /* Now we can (re-)enable the transmitter and receiver */
+
+ regval |= (LPUART_CTRL_RE | LPUART_CTRL_TE);
+ putreg32(regval, uart_base+KINETIS_LPUART_CTRL_OFFSET);
+}
+#endif
diff --git a/arch/arm/src/kinetis/kinetis_lpserial.c b/arch/arm/src/kinetis/kinetis_lpserial.c
new file mode 100644
index 0000000000000000000000000000000000000000..2980f18b8d445bed636c513d7fe7bcaf625e2bc5
--- /dev/null
+++ b/arch/arm/src/kinetis/kinetis_lpserial.c
@@ -0,0 +1,911 @@
+/****************************************************************************
+ * arch/arm/src/kinetis/kinetis_lpserial.c
+ *
+ * Copyright (C) 2017 Gregory Nutt. All rights reserved.
+ * Authors: Gregory Nutt
+ * David Sidrane
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+
+#include
+
+#include "up_arch.h"
+#include "up_internal.h"
+
+#include "kinetis_config.h"
+#include "chip.h"
+#include "chip/kinetis_lpuart.h"
+#include "kinetis.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* Some sanity checks *******************************************************/
+/* Is there at least one LPUART enabled and configured as a RS-232 device? */
+
+#ifndef HAVE_LPUART_DEVICE
+# warning "No LPUARTs enabled"
+#endif
+
+/* If we are not using the serial driver for the console, then we still must
+ * provide some minimal implementation of up_putc.
+ */
+
+#if defined(HAVE_LPUART_DEVICE) && defined(USE_SERIALDRIVER)
+
+/* Which LPUART with be tty0/console and which tty1? The console will always
+ * be ttyS0. If there is no console then will use the lowest numbered LPUART.
+ */
+
+/* First pick the console and ttys0. This could be any of LPUART0-1 */
+
+#if defined(CONFIG_LPUART0_SERIAL_CONSOLE)
+# define CONSOLE_DEV g_lpuart0port /* LPUART0 is console */
+# define TTYS0_DEV g_lpuart0port /* LPUART0 is ttyS0 */
+# define LPUART0_ASSIGNED 1
+#elif defined(CONFIG_LPUART1_SERIAL_CONSOLE)
+# define CONSOLE_DEV g_lpuart1port /* LPUART1 is console */
+# define TTYS0_DEV g_lpuart1port /* LPUART1 is ttyS0 */
+# define LPUART1_ASSIGNED 1
+#else
+# undef CONSOLE_DEV /* No console */
+# if defined(CONFIG_KINETIS_LPUART0)
+# define TTYS0_DEV g_lpuart0port /* LPUART0 is ttyS0 */
+# define LPUART0_ASSIGNED 1
+# elif defined(CONFIG_KINETIS_LPUART1)
+# define TTYS0_DEV g_lpuart1port /* LPUART1 is ttyS0 */
+# define LPUART1_ASSIGNED 1
+# endif
+#endif
+
+/* Pick ttys1. This could be any of LPUART0-1 excluding the console LPUART. */
+
+#if defined(CONFIG_KINETIS_LPUART0) && !defined(LPUART0_ASSIGNED)
+# define TTYS1_DEV g_lpuart0port /* LPUART0 is ttyS1 */
+# define LPUART0_ASSIGNED 1
+#elif defined(CONFIG_KINETIS_LPUART1) && !defined(LPUART1_ASSIGNED)
+# define TTYS1_DEV g_lpuart1port /* LPUART1 is ttyS1 */
+# define LPUART1_ASSIGNED 1
+#endif
+
+#define LPUART_CTRL_ERROR_INTS (LPUART_CTRL_ORIE | LPUART_CTRL_FEIE | \
+ LPUART_CTRL_NEIE | LPUART_CTRL_PEIE)
+
+#define LPUART_CTRL_RX_INTS LPUART_CTRL_RIE
+
+#define LPUART_CTRL_TX_INTS LPUART_CTRL_TIE
+
+#define LPUART_CTRL_ALL_INTS (LPUART_CTRL_TX_INTS | LPUART_CTRL_RX_INTS | \
+ LPUART_CTRL_MA1IE | LPUART_CTRL_MA1IE | \
+ LPUART_CTRL_ILIE | LPUART_CTRL_TCIE)
+
+#define LPUART_STAT_ERRORS (LPUART_STAT_OR | LPUART_STAT_FE | \
+ LPUART_STAT_PF | LPUART_STAT_NF)
+
+
+/* The LPUART does not have an common set of aligned bits for the interrupt
+ * enable and the status. So map the ctrl to the stat bits
+ */
+
+#define LPUART_CTRL_TR_INTS (LPUART_CTRL_TX_INTS | LPUART_CTRL_RX_INTS)
+#define LPUART_CTRL2STAT(c) ((((c) & LPUART_CTRL_ERROR_INTS) >> 8) | \
+ ((c) & (LPUART_CTRL_TR_INTS)))
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct kinetis_dev_s
+{
+ uintptr_t uartbase; /* Base address of LPUART registers */
+ uint32_t baud; /* Configured baud */
+ uint32_t clock; /* Clocking frequency of the LPUART module */
+ uint32_t ie; /* Interrupts enabled */
+ uint8_t irq; /* IRQ associated with this LPUART (for enable) */
+ uint8_t irqprio; /* Interrupt priority */
+ uint8_t parity; /* 0=none, 1=odd, 2=even */
+ uint8_t bits; /* Number of bits (8 or 9) */
+ uint8_t stop2; /* Use 2 stop bits */
+};
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+static int kinetis_setup(struct uart_dev_s *dev);
+static void kinetis_shutdown(struct uart_dev_s *dev);
+static int kinetis_attach(struct uart_dev_s *dev);
+static void kinetis_detach(struct uart_dev_s *dev);
+static int kinetis_interrupt(int irq, void *context, void *arg);
+static int kinetis_ioctl(struct file *filep, int cmd, unsigned long arg);
+static int kinetis_receive(struct uart_dev_s *dev, uint32_t *status);
+static void kinetis_rxint(struct uart_dev_s *dev, bool enable);
+static bool kinetis_rxavailable(struct uart_dev_s *dev);
+static void kinetis_send(struct uart_dev_s *dev, int ch);
+static void kinetis_txint(struct uart_dev_s *dev, bool enable);
+static bool kinetis_txready(struct uart_dev_s *dev);
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static const struct uart_ops_s g_lpuart_ops =
+{
+ .setup = kinetis_setup,
+ .shutdown = kinetis_shutdown,
+ .attach = kinetis_attach,
+ .detach = kinetis_detach,
+ .ioctl = kinetis_ioctl,
+ .receive = kinetis_receive,
+ .rxint = kinetis_rxint,
+ .rxavailable = kinetis_rxavailable,
+#ifdef CONFIG_SERIAL_IFLOWCONTROL
+ .rxflowcontrol = NULL,
+#endif
+ .send = kinetis_send,
+ .txint = kinetis_txint,
+ .txready = kinetis_txready,
+ .txempty = kinetis_txready,
+};
+
+/* I/O buffers */
+
+#ifdef CONFIG_KINETIS_LPUART0
+static char g_lpuart0rxbuffer[CONFIG_LPUART0_RXBUFSIZE];
+static char g_lpuart0txbuffer[CONFIG_LPUART0_TXBUFSIZE];
+#endif
+#ifdef CONFIG_KINETIS_LPUART1
+static char g_lpuart1rxbuffer[CONFIG_LPUART1_RXBUFSIZE];
+static char g_lpuart1txbuffer[CONFIG_LPUART1_TXBUFSIZE];
+#endif
+
+/* This describes the state of the Kinetis LPUART0 port. */
+
+#ifdef CONFIG_KINETIS_LPUART0
+static struct kinetis_dev_s g_lpuart0priv =
+{
+ .uartbase = KINETIS_LPUART0_BASE,
+ .clock = BOARD_LPUART0_FREQ,
+ .baud = CONFIG_LPUART0_BAUD,
+ .irq = KINETIS_IRQ_LPUART0,
+ .irqprio = CONFIG_KINETIS_LPUART0PRIO,
+ .parity = CONFIG_LPUART0_PARITY,
+ .bits = CONFIG_LPUART0_BITS,
+ .stop2 = CONFIG_LPUART0_2STOP,
+};
+
+static uart_dev_t g_lpuart0port =
+{
+ .recv =
+ {
+ .size = CONFIG_LPUART0_RXBUFSIZE,
+ .buffer = g_lpuart0rxbuffer,
+ },
+ .xmit =
+ {
+ .size = CONFIG_LPUART0_TXBUFSIZE,
+ .buffer = g_lpuart0txbuffer,
+ },
+ .ops = &g_lpuart_ops,
+ .priv = &g_lpuart0priv,
+};
+#endif
+
+/* This describes the state of the Kinetis LPUART1 port. */
+
+#ifdef CONFIG_KINETIS_LPUART1
+static struct kinetis_dev_s g_lpuart1priv =
+{
+ .uartbase = KINETIS_LPUART1_BASE,
+ .clock = BOARD_CORECLK_FREQ,
+ .baud = BOARD_LPUART1_FREQ,
+ .irq = KINETIS_IRQ_LPUART1,
+ .irqprio = CONFIG_KINETIS_LPUART1PRIO,
+ .parity = CONFIG_LPUART1_PARITY,
+ .bits = CONFIG_LPUART1_BITS,
+ .stop2 = CONFIG_LPUART1_2STOP,
+};
+
+static uart_dev_t g_lpuart1port =
+{
+ .recv =
+ {
+ .size = CONFIG_LPUART1_RXBUFSIZE,
+ .buffer = g_lpuart1rxbuffer,
+ },
+ .xmit =
+ {
+ .size = CONFIG_LPUART1_TXBUFSIZE,
+ .buffer = g_lpuart1txbuffer,
+ },
+ .ops = &g_lpuart_ops,
+ .priv = &g_lpuart1priv,
+};
+#endif
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: kinetis_serialin
+ ****************************************************************************/
+
+static inline uint32_t kinetis_serialin(struct kinetis_dev_s *priv,
+ int offset)
+{
+ return getreg32(priv->uartbase + offset);
+}
+
+/****************************************************************************
+ * Name: kinetis_serialout
+ ****************************************************************************/
+
+static inline void kinetis_serialout(struct kinetis_dev_s *priv, int offset,
+ uint32_t value)
+{
+ putreg32(value, priv->uartbase + offset);
+}
+
+/****************************************************************************
+ * Name: kinetis_setuartint
+ ****************************************************************************/
+
+static void kinetis_setuartint(struct kinetis_dev_s *priv)
+{
+ irqstate_t flags;
+ uint32_t regval;
+
+ /* Re-enable/re-disable interrupts corresponding to the state of bits in ie */
+
+ flags = enter_critical_section();
+ regval = kinetis_serialin(priv, KINETIS_LPUART_CTRL_OFFSET);
+ regval &= ~LPUART_CTRL_ALL_INTS;
+ regval |= priv->ie;
+ kinetis_serialout(priv, KINETIS_LPUART_CTRL_OFFSET, regval);
+ leave_critical_section(flags);
+}
+
+/****************************************************************************
+ * Name: kinetis_restoreuartint
+ ****************************************************************************/
+
+static void kinetis_restoreuartint(struct kinetis_dev_s *priv, uint32_t ie)
+{
+ irqstate_t flags;
+
+ /* Re-enable/re-disable interrupts corresponding to the state of bits in ie */
+
+ flags = enter_critical_section();
+ priv->ie = ie & LPUART_CTRL_ALL_INTS;
+ kinetis_setuartint(priv);
+ leave_critical_section(flags);
+}
+
+/****************************************************************************
+ * Name: kinetis_disableuartint
+ ****************************************************************************/
+
+static void kinetis_disableuartint(struct kinetis_dev_s *priv, uint32_t *ie)
+{
+ irqstate_t flags;
+
+ flags = enter_critical_section();
+ if (ie)
+ {
+ *ie = priv->ie;
+ }
+
+ kinetis_restoreuartint(priv, 0);
+ leave_critical_section(flags);
+}
+
+/****************************************************************************
+ * Name: kinetis_setup
+ *
+ * Description:
+ * Configure the LPUART baud, bits, parity, etc. This method is called the
+ * first time that the serial port is opened.
+ *
+ ****************************************************************************/
+
+static int kinetis_setup(struct uart_dev_s *dev)
+{
+#ifndef CONFIG_SUPPRESS_LPUART_CONFIG
+ struct kinetis_dev_s *priv = (struct kinetis_dev_s *)dev->priv;
+
+ /* Configure the LPUART as an RS-232 UART */
+
+ kinetis_lpuartconfigure(priv->uartbase, priv->baud, priv->clock,
+ priv->parity, priv->bits, priv->stop2);
+#endif
+
+ /* Make sure that all interrupts are disabled */
+
+ kinetis_restoreuartint(priv, 0);
+
+#ifdef CONFIG_ARCH_IRQPRIO
+ /* Set up the interrupt priority */
+
+ up_prioritize_irq(priv->irq, priv->irqprio);
+#endif
+
+ return OK;
+}
+
+/****************************************************************************
+ * Name: kinetis_shutdown
+ *
+ * Description:
+ * Disable the LPUART. This method is called when the serial
+ * port is closed
+ *
+ ****************************************************************************/
+
+static void kinetis_shutdown(struct uart_dev_s *dev)
+{
+ struct kinetis_dev_s *priv = (struct kinetis_dev_s *)dev->priv;
+
+ /* Disable interrupts */
+
+ kinetis_restoreuartint(priv, 0);
+
+ /* Reset hardware and disable Rx and Tx */
+
+ kinetis_lpuartreset(priv->uartbase);
+}
+
+/****************************************************************************
+ * Name: kinetis_attach
+ *
+ * Description:
+ * Configure the LPUART to operation in interrupt driven mode. This
+ * method is called when the serial port is opened. Normally, this is
+ * just after the the setup() method is called, however, the serial
+ * console may operate in a non-interrupt driven mode during the boot phase.
+ *
+ * RX and TX interrupts are not enabled when by the attach method (unless
+ * the hardware supports multiple levels of interrupt enabling). The RX
+ * and TX interrupts are not enabled until the txint() and rxint() methods
+ * are called.
+ *
+ ****************************************************************************/
+
+static int kinetis_attach(struct uart_dev_s *dev)
+{
+ struct kinetis_dev_s *priv = (struct kinetis_dev_s *)dev->priv;
+ int ret;
+
+ /* Attach and enable the IRQ(s). The interrupts are (probably) still
+ * disabled in the LPUART_CTRL register.
+ */
+
+ ret = irq_attach(priv->irq, kinetis_interrupt, dev);
+ if (ret == OK)
+ {
+ up_enable_irq(priv->irq);
+ }
+
+ return ret;
+}
+
+/****************************************************************************
+ * Name: kinetis_detach
+ *
+ * Description:
+ * Detach LPUART interrupts. This method is called when the serial port
+ * is closed normally just before the shutdown method is called. The
+ * exception is the serial console which is never shutdown.
+ *
+ ****************************************************************************/
+
+static void kinetis_detach(struct uart_dev_s *dev)
+{
+ struct kinetis_dev_s *priv = (struct kinetis_dev_s *)dev->priv;
+
+ /* Disable interrupts */
+
+ kinetis_restoreuartint(priv, 0);
+ up_disable_irq(priv->irq);
+
+ /* Detach from the interrupt(s) */
+
+ irq_detach(priv->irq);
+}
+
+/****************************************************************************
+ * Name: kinetis_interrupts
+ *
+ * Description:
+ * This is the LPUART status interrupt handler. It will be invoked when
+ * an interrupt received on the 'irq' It should call uart_transmitchars
+ * or uart_receivechar to perform the appropriate data transfers. The
+ * interrupt handling logic must be able to map the 'irq' number into the
+ * Appropriate uart_dev_s structure in order to call these functions.
+ *
+ ****************************************************************************/
+
+static int kinetis_interrupt(int irq, void *context, void *arg)
+{
+ struct uart_dev_s *dev = (struct uart_dev_s *)arg;
+ struct kinetis_dev_s *priv;
+ uint32_t stat;
+ uint32_t ctrl;
+
+ DEBUGASSERT(dev != NULL && dev->priv != NULL);
+ priv = (struct kinetis_dev_s *)dev->priv;
+
+ /* Read status register and qualify it with STAT bit corresponding CTRL IE bits */
+
+ stat = kinetis_serialin(priv, KINETIS_LPUART_STAT_OFFSET);
+ ctrl = kinetis_serialin(priv, KINETIS_LPUART_CTRL_OFFSET);
+ stat &= LPUART_CTRL2STAT(ctrl);
+ do
+ {
+
+ /* Handle errors. This interrupt may be caused by:
+ *
+ * OR: Receiver Overrun Flag. To clear OR, when STAT read with OR set,
+ * write STAT with OR set;
+ * FE: Framing error. To clear FE, when STAT read with FE set, read the
+ * data to discard it and write STAT with FE set;
+ * NF: Noise flag. To clear NF, when STAT read with EE set, read the
+ * data to discard it and write STAT with NE set;
+ * PF: Parity error flag. To clear PF, when STAT read with PE set, read
+ * the data to discard it and write STAT with PE set;
+ */
+
+ if (stat & LPUART_STAT_ERRORS)
+ {
+
+ /* Only Overrun error does not need a read operation */
+
+ if ((stat & LPUART_STAT_OR) != LPUART_STAT_OR)
+ {
+ (void) kinetis_serialin(priv, KINETIS_LPUART_DATA_OFFSET);
+ }
+
+ /* Reset any Errors */
+
+ kinetis_serialout(priv, KINETIS_LPUART_STAT_OFFSET, stat & LPUART_STAT_ERRORS);
+ return OK;
+ }
+
+ /* Handle incoming, receive bytes
+ *
+ * Check if the receive data register is full (RDRF).
+ *
+ * The RDRF status indication is cleared when the data is read from
+ * the RX data register.
+ */
+
+ if (stat & LPUART_STAT_RDRF)
+ {
+ uart_recvchars(dev);
+ }
+
+ /* Handle outgoing, transmit bytes
+ *
+ * Check if the transmit data register is "empty."
+ *
+ * The TDRE status indication is cleared when the data is written to
+ * the TX data register.
+ */
+
+ if (stat & LPUART_STAT_TDRE)
+ {
+ uart_xmitchars(dev);
+ }
+
+ /* Read status register and requalify it with STAT bit corresponding CTRL IE bits */
+
+ stat = kinetis_serialin(priv, KINETIS_LPUART_STAT_OFFSET);
+ ctrl = kinetis_serialin(priv, KINETIS_LPUART_CTRL_OFFSET);
+ stat &= LPUART_CTRL2STAT(ctrl);
+ } while(stat != 0);
+
+ return OK;
+}
+
+/****************************************************************************
+ * Name: kinetis_ioctl
+ *
+ * Description:
+ * All ioctl calls will be routed through this method
+ *
+ ****************************************************************************/
+
+static int kinetis_ioctl(struct file *filep, int cmd, unsigned long arg)
+{
+#if 0 /* Reserved for future growth */
+ struct inode *inode;
+ struct uart_dev_s *dev;
+ struct kinetis_dev_s *priv;
+ int ret = OK;
+
+ DEBUGASSERT(filep, filep->f_inode);
+ inode = filep->f_inode;
+ dev = inode->i_private;
+
+ DEBUGASSERT(dev, dev->priv);
+ priv = (struct kinetis_dev_s *)dev->priv;
+
+ switch (cmd)
+ {
+ case xxx: /* Add commands here */
+ break;
+
+ default:
+ ret = -ENOTTY;
+ break;
+ }
+
+ return ret;
+#else
+ return -ENOTTY;
+#endif
+}
+
+/****************************************************************************
+ * Name: kinetis_receive
+ *
+ * Description:
+ * Called (usually) from the interrupt level to receive one
+ * character from the LPUART. Error bits associated with the
+ * receipt are provided in the return 'status'.
+ *
+ ****************************************************************************/
+
+static int kinetis_receive(struct uart_dev_s *dev, uint32_t *status)
+{
+ struct kinetis_dev_s *priv = (struct kinetis_dev_s *)dev->priv;
+ uint32_t regval;
+ int data;
+
+ /* Get error status information:
+ *
+ * OR: Receiver Overrun Flag. To clear OR, when STAT read with OR set,
+ * write STAT with OR set;
+ * FE: Framing error. To clear FE, when STAT read with FE set, read the
+ * data to discard it and write STAT with FE set;
+ * NF: Noise flag. To clear NF, when STAT read with EE set, read the
+ * data to discard it and write STAT with NE set;
+ * PF: Parity error flag. To clear PF, when STAT read with PE set, read
+ * the data to discard it and write STAT with PE set;
+ */
+
+ regval = kinetis_serialin(priv, KINETIS_LPUART_STAT_OFFSET);
+
+ /* Return status information */
+
+ if (status)
+ {
+ *status = regval;
+ }
+
+ /* Then return the actual received byte. Read DATA. Then if
+ * there were any errors write 1 to them to clear the RX errors.
+ */
+
+ data = (int)kinetis_serialin(priv, KINETIS_LPUART_DATA_OFFSET);
+ regval &= LPUART_STAT_ERRORS;
+ if (regval)
+ {
+ kinetis_serialout(priv, KINETIS_LPUART_STAT_OFFSET, regval);
+ }
+
+ return data;
+}
+
+/****************************************************************************
+ * Name: kinetis_rxint
+ *
+ * Description:
+ * Call to enable or disable RX interrupts
+ *
+ ****************************************************************************/
+
+static void kinetis_rxint(struct uart_dev_s *dev, bool enable)
+{
+ struct kinetis_dev_s *priv = (struct kinetis_dev_s *)dev->priv;
+ irqstate_t flags;
+
+ flags = enter_critical_section();
+ if (enable)
+ {
+ /* Receive an interrupt when their is anything in the Rx data register
+ * (or an Rx related error occurs).
+ */
+
+#ifndef CONFIG_SUPPRESS_SERIAL_INTS
+ priv->ie |= (LPUART_CTRL_RX_INTS | LPUART_CTRL_ERROR_INTS);
+ kinetis_setuartint(priv);
+#endif
+ }
+ else
+ {
+ priv->ie &= ~(LPUART_CTRL_RX_INTS | LPUART_CTRL_ERROR_INTS);
+ kinetis_setuartint(priv);
+ }
+
+ leave_critical_section(flags);
+}
+
+/****************************************************************************
+ * Name: kinetis_rxavailable
+ *
+ * Description:
+ * Return true if the receive register is not empty
+ *
+ ****************************************************************************/
+
+static bool kinetis_rxavailable(struct uart_dev_s *dev)
+{
+ struct kinetis_dev_s *priv = (struct kinetis_dev_s *)dev->priv;
+
+ /* Return true if the receive data register is full (RDRF).
+ */
+
+ return (kinetis_serialin(priv, KINETIS_LPUART_STAT_OFFSET) & LPUART_STAT_RDRF) != 0;
+}
+
+/****************************************************************************
+ * Name: kinetis_send
+ *
+ * Description:
+ * This method will send one byte on the LPUART.
+ *
+ ****************************************************************************/
+
+static void kinetis_send(struct uart_dev_s *dev, int ch)
+{
+ struct kinetis_dev_s *priv = (struct kinetis_dev_s *)dev->priv;
+ kinetis_serialout(priv, KINETIS_LPUART_DATA_OFFSET, ch);
+}
+
+/****************************************************************************
+ * Name: kinetis_txint
+ *
+ * Description:
+ * Call to enable or disable TX interrupts
+ *
+ ****************************************************************************/
+
+static void kinetis_txint(struct uart_dev_s *dev, bool enable)
+{
+ struct kinetis_dev_s *priv = (struct kinetis_dev_s *)dev->priv;
+ irqstate_t flags;
+
+ flags = enter_critical_section();
+ if (enable)
+ {
+ /* Enable the TX interrupt */
+
+#ifndef CONFIG_SUPPRESS_SERIAL_INTS
+ priv->ie |= LPUART_CTRL_TX_INTS;
+ kinetis_setuartint(priv);
+
+ /* Fake a TX interrupt here by just calling uart_xmitchars() with
+ * interrupts disabled (note this may recurse).
+ */
+
+ uart_xmitchars(dev);
+#endif
+ }
+ else
+ {
+ /* Disable the TX interrupt */
+
+ priv->ie &= ~LPUART_CTRL_TX_INTS;
+ kinetis_setuartint(priv);
+ }
+
+ leave_critical_section(flags);
+}
+
+/****************************************************************************
+ * Name: kinetis_txready
+ *
+ * Description:
+ * Return true if the transmit data register is empty
+ *
+ ****************************************************************************/
+
+static bool kinetis_txready(struct uart_dev_s *dev)
+{
+ struct kinetis_dev_s *priv = (struct kinetis_dev_s *)dev->priv;
+
+ /* Return true if the transmit data register is "empty." */
+
+ return (kinetis_serialin(priv, KINETIS_LPUART_STAT_OFFSET) & LPUART_STAT_TDRE) != 0;
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: kinetis_lpuart_earlyserialinit
+ *
+ * Description:
+ * Performs the low level LPUART initialization early in debug so that the
+ * serial console will be available during bootup. This must be called
+ * before up_serialinit. NOTE: This function depends on GPIO pin
+ * configuration performed in kinetis_lowsetup() and main clock initialization
+ * performed in up_clkinitialize().
+ *
+ ****************************************************************************/
+
+void kinetis_lpuart_earlyserialinit(void)
+{
+ /* Disable interrupts from all LPUARTS. The console is enabled in
+ * kinetis_setup()
+ */
+
+ kinetis_restoreuartint(TTYS0_DEV.priv, 0);
+#ifdef TTYS1_DEV
+ kinetis_restoreuartint(TTYS1_DEV.priv, 0);
+#endif
+
+ /* Configuration whichever one is the console */
+
+#ifdef HAVE_LPUART_CONSOLE
+ CONSOLE_DEV.isconsole = true;
+ kinetis_setup(&CONSOLE_DEV);
+#endif
+}
+
+/****************************************************************************
+ * Name: kinetis_lpuart_serialinit
+ *
+ * Description:
+ * Register serial console and serial ports. This assumes
+ * that up_earlyserialinit was called previously.
+ *
+ * Input Parameters:
+ * first: - First TTY number to assign
+ *
+ * Returns Value:
+ * The next TTY number available for assignment
+ *
+ ****************************************************************************/
+
+unsigned int kinetis_lpuart_serialinit(unsigned int first)
+{
+#if defined(CONFIG_KINETIS_MERGE_TTY)
+ char devname[] = "/dev/ttySx";
+#endif
+
+/* Register the console */
+
+#ifdef HAVE_LPUART_CONSOLE
+ (void)uart_register("/dev/console", &CONSOLE_DEV);
+#endif
+#if !defined(CONFIG_KINETIS_MERGE_TTY)
+ /* Register all LPUARTs as LPn devices */
+
+ (void)uart_register("/dev/ttyLP0", &TTYS0_DEV);
+# ifdef TTYS1_DEV
+ (void)uart_register("/dev/ttyLP1", &TTYS1_DEV);
+# endif
+#else
+ devname[(sizeof(devname)/sizeof(devname[0]))-2] = '0' + first++;
+ (void)uart_register(devname, &TTYS0_DEV);
+# ifdef TTYS1_DEV
+ devname[(sizeof(devname)/sizeof(devname[0]))-2] = '0' + first++;
+ (void)uart_register(devname, &TTYS1_DEV);
+# endif
+#endif
+ return first;
+}
+
+/****************************************************************************
+ * Name: up_putc
+ *
+ * Description:
+ * Provide priority, low-level access to support OS debug writes
+ *
+ ****************************************************************************/
+
+#ifdef HAVE_LPUART_PUTC
+int up_putc(int ch)
+{
+#ifdef HAVE_LPUART_CONSOLE
+ struct kinetis_dev_s *priv = (struct kinetis_dev_s *)CONSOLE_DEV.priv;
+ uint32_t ie;
+
+ kinetis_disableuartint(priv, &ie);
+
+ /* Check for LF */
+
+ if (ch == '\n')
+ {
+ /* Add CR */
+
+ up_lowputc('\r');
+ }
+
+ up_lowputc(ch);
+ kinetis_restoreuartint(priv, ie);
+#endif
+ return ch;
+}
+#endif
+
+#else /* USE_SERIALDRIVER */
+
+/****************************************************************************
+ * Name: up_putc
+ *
+ * Description:
+ * Provide priority, low-level access to support OS debug writes
+ *
+ ****************************************************************************/
+
+#ifdef HAVE_LPUART_PUTC
+int up_putc(int ch)
+{
+#ifdef HAVE_LPUART_CONSOLE
+ /* Check for LF */
+
+ if (ch == '\n')
+ {
+ /* Add CR */
+
+ up_lowputc('\r');
+ }
+
+ up_lowputc(ch);
+#endif
+ return ch;
+}
+#endif
+
+#endif /* HAVE_LPUART_DEVICE && USE_SERIALDRIVER) */
diff --git a/arch/arm/src/kinetis/kinetis_pinirq.c b/arch/arm/src/kinetis/kinetis_pinirq.c
index cc5933e715af6b6a79698f79f0b5e07d3cc8452e..f40be80a8e44cadd302da347df4a194cf10e9588 100644
--- a/arch/arm/src/kinetis/kinetis_pinirq.c
+++ b/arch/arm/src/kinetis/kinetis_pinirq.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/kinetis/kinetis_pinirq.c
*
- * Copyright (C) 2011, 2013, 2016 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2011, 2013, 2016-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
*
* Redistribution and use in source and binary forms, with or without
@@ -41,6 +41,7 @@
#include
#include
+#include
#include
#include
@@ -73,6 +74,12 @@
* Private Types
****************************************************************************/
+struct kinetis_pinirq_s
+{
+ xcpt_t handler;
+ void *arg;
+};
+
/****************************************************************************
* Private Data
****************************************************************************/
@@ -84,19 +91,19 @@
*/
#ifdef CONFIG_KINETIS_PORTAINTS
-static xcpt_t g_portaisrs[32];
+static struct kinetis_pinirq_s g_portaisrs[32];
#endif
#ifdef CONFIG_KINETIS_PORTBINTS
-static xcpt_t g_portbisrs[32];
+static struct kinetis_pinirq_s g_portbisrs[32];
#endif
#ifdef CONFIG_KINETIS_PORTCINTS
-static xcpt_t g_portcisrs[32];
+static struct kinetis_pinirq_s g_portcisrs[32];
#endif
#ifdef CONFIG_KINETIS_PORTDINTS
-static xcpt_t g_portdisrs[32];
+static struct kinetis_pinirq_s g_portdisrs[32];
#endif
#ifdef CONFIG_KINETIS_PORTEINTS
-static xcpt_t g_porteisrs[32];
+static struct kinetis_pinirq_s g_porteisrs[32];
#endif
/****************************************************************************
@@ -113,7 +120,7 @@ static xcpt_t g_porteisrs[32];
#ifdef HAVE_PORTINTS
static int kinetis_portinterrupt(int irq, FAR void *context,
- uintptr_t addr, xcpt_t *isrtab)
+ uintptr_t addr, struct kinetis_pinirq_s *isrtab)
{
uint32_t isfr = getreg32(addr);
int i;
@@ -136,11 +143,14 @@ static int kinetis_portinterrupt(int irq, FAR void *context,
* interrupt handler for the pin.
*/
- if (isrtab[i])
+ if (isrtab[i].handler != NULL)
{
+ xcpt_t handler = isrtab[i].handler;
+ void *arg = isrtab[i].arg;
+
/* There is a registered interrupt handler... invoke it */
- (void)isrtab[i](irq, context);
+ (void)handler(irq, context, arg);
}
/* Writing a one to the ISFR register will clear the pending
@@ -169,31 +179,31 @@ static int kinetis_portinterrupt(int irq, FAR void *context,
****************************************************************************/
#ifdef CONFIG_KINETIS_PORTAINTS
-static int kinetis_portainterrupt(int irq, FAR void *context)
+static int kinetis_portainterrupt(int irq, FAR void *context, FAR void *arg)
{
return kinetis_portinterrupt(irq, context, KINETIS_PORTA_ISFR, g_portaisrs);
}
#endif
#ifdef CONFIG_KINETIS_PORTBINTS
-static int kinetis_portbinterrupt(int irq, FAR void *context)
+static int kinetis_portbinterrupt(int irq, FAR void *context, FAR void *arg)
{
return kinetis_portinterrupt(irq, context, KINETIS_PORTB_ISFR, g_portbisrs);
}
#endif
#ifdef CONFIG_KINETIS_PORTCINTS
-static int kinetis_portcinterrupt(int irq, FAR void *context)
+static int kinetis_portcinterrupt(int irq, FAR void *context, FAR void *arg)
{
return kinetis_portinterrupt(irq, context, KINETIS_PORTC_ISFR, g_portcisrs);
}
#endif
#ifdef CONFIG_KINETIS_PORTDINTS
-static int kinetis_portdinterrupt(int irq, FAR void *context)
+static int kinetis_portdinterrupt(int irq, FAR void *context, FAR void *arg)
{
return kinetis_portinterrupt(irq, context, KINETIS_PORTD_ISFR, g_portdisrs);
}
#endif
#ifdef CONFIG_KINETIS_PORTEINTS
-static int kinetis_porteinterrupt(int irq, FAR void *context)
+static int kinetis_porteinterrupt(int irq, FAR void *context, FAR void *arg)
{
return kinetis_portinterrupt(irq, context, KINETIS_PORTE_ISFR, g_porteisrs);
}
@@ -215,27 +225,27 @@ static int kinetis_porteinterrupt(int irq, FAR void *context)
void kinetis_pinirqinitialize(void)
{
#ifdef CONFIG_KINETIS_PORTAINTS
- (void)irq_attach(KINETIS_IRQ_PORTA, kinetis_portainterrupt);
+ (void)irq_attach(KINETIS_IRQ_PORTA, kinetis_portainterrupt, NULL);
putreg32(0xffffffff, KINETIS_PORTA_ISFR);
up_enable_irq(KINETIS_IRQ_PORTA);
#endif
#ifdef CONFIG_KINETIS_PORTBINTS
- (void)irq_attach(KINETIS_IRQ_PORTB, kinetis_portbinterrupt);
+ (void)irq_attach(KINETIS_IRQ_PORTB, kinetis_portbinterrupt, NULL);
putreg32(0xffffffff, KINETIS_PORTB_ISFR);
up_enable_irq(KINETIS_IRQ_PORTB);
#endif
#ifdef CONFIG_KINETIS_PORTCINTS
- (void)irq_attach(KINETIS_IRQ_PORTC, kinetis_portcinterrupt);
+ (void)irq_attach(KINETIS_IRQ_PORTC, kinetis_portcinterrupt, NULL);
putreg32(0xffffffff, KINETIS_PORTC_ISFR);
up_enable_irq(KINETIS_IRQ_PORTC);
#endif
#ifdef CONFIG_KINETIS_PORTDINTS
- (void)irq_attach(KINETIS_IRQ_PORTD, kinetis_portdinterrupt);
+ (void)irq_attach(KINETIS_IRQ_PORTD, kinetis_portdinterrupt, NULL);
putreg32(0xffffffff, KINETIS_PORTD_ISFR);
up_enable_irq(KINETIS_IRQ_PORTD);
#endif
#ifdef CONFIG_KINETIS_PORTEINTS
- (void)irq_attach(KINETIS_IRQ_PORTE, kinetis_porteinterrupt);
+ (void)irq_attach(KINETIS_IRQ_PORTE, kinetis_porteinterrupt, NULL);
putreg32(0xffffffff, KINETIS_PORTE_ISFR);
up_enable_irq(KINETIS_IRQ_PORTE);
#endif
@@ -253,22 +263,21 @@ void kinetis_pinirqinitialize(void)
* 3. Call kinetis_pinirqenable() to enable interrupts on the pin.
*
* Parameters:
- * - pinset: Pin configuration
- * - pinisr: Pin interrupt service routine
+ * pinset - Pin configuration
+ * pinisr - Pin interrupt service routine
+ * arg - An argument that will be provided to the interrupt service routine.
*
* Returns:
- * The previous value of the interrupt handler function pointer. This
- * value may, for example, be used to restore the previous handler whe
- * multiple handlers are used.
+ * Zero (OK) is returned on success; a negated errno value is returned on any
+ * failure to indicate the nature of the failure.
*
- ****************************************************************************/
+ ************************************************************************************/
-xcpt_t kinetis_pinirqattach(uint32_t pinset, xcpt_t pinisr)
+int kinetis_pinirqattach(uint32_t pinset, xcpt_t pinisr, void *arg)
{
#ifdef HAVE_PORTINTS
- xcpt_t *isrtab;
- xcpt_t oldisr;
- irqstate_t flags;
+ struct kinetis_pinirq_s *isrtab;
+ irqstate_t flags;
unsigned int port;
unsigned int pin;
@@ -317,20 +326,20 @@ xcpt_t kinetis_pinirqattach(uint32_t pinset, xcpt_t pinisr)
#endif
default:
leave_critical_section(flags);
- return NULL;
+ return -EINVAL;
}
/* Get the old PIN ISR and set the new PIN ISR */
- oldisr = isrtab[pin];
- isrtab[pin] = pinisr;
+ isrtab[pin].handler = pinisr;
+ isrtab[pin].arg = arg;
/* And return the old PIN isr address */
leave_critical_section(flags);
- return oldisr;
+ return OK;
#else
- return NULL;
+ return -ENOSYS;
#endif /* HAVE_PORTINTS */
}
diff --git a/arch/arm/src/kinetis/kinetis_rtc.c b/arch/arm/src/kinetis/kinetis_rtc.c
index 19db2796b44cb71a5f8ca888f9e0c125e21e6188..824a72245d667d55b142d1bc4bf4ca513db91af4 100644
--- a/arch/arm/src/kinetis/kinetis_rtc.c
+++ b/arch/arm/src/kinetis/kinetis_rtc.c
@@ -172,7 +172,7 @@ static void rtc_dumptime(FAR struct tm *tp, FAR const char *msg)
****************************************************************************/
#if defined(CONFIG_RTC_ALARM)
-static int kinetis_rtc_interrupt(int irq, void *context)
+static int kinetis_rtc_interrupt(int irq, void *context, FAR void *arg)
{
uint16_t rtc_sr;
@@ -279,7 +279,7 @@ int up_rtc_irq_attach(void)
* KINETIS_IRQ_RTCS is a separate interrupt for seconds if needed
*/
- irq_attach(KINETIS_IRQ_RTC, kinetis_rtc_interrupt);
+ irq_attach(KINETIS_IRQ_RTC, kinetis_rtc_interrupt, NULL);
up_enable_irq(KINETIS_IRQ_RTC);
}
diff --git a/arch/arm/src/kinetis/kinetis_sdhc.c b/arch/arm/src/kinetis/kinetis_sdhc.c
index f9708256c623bd4499b431cd26bb1e03e8f14c37..a1d1e847c5eccb261f68cfd6aaefea6e69a62ebb 100644
--- a/arch/arm/src/kinetis/kinetis_sdhc.c
+++ b/arch/arm/src/kinetis/kinetis_sdhc.c
@@ -271,7 +271,7 @@ static void kinetis_endtransfer(struct kinetis_dev_s *priv, sdio_eventset_t wkup
/* Interrupt Handling *******************************************************/
-static int kinetis_interrupt(int irq, void *context);
+static int kinetis_interrupt(int irq, void *context, FAR void *arg);
/* SDIO interface methods ***************************************************/
@@ -1065,7 +1065,7 @@ static void kinetis_endtransfer(struct kinetis_dev_s *priv, sdio_eventset_t wkup
*
****************************************************************************/
-static int kinetis_interrupt(int irq, void *context)
+static int kinetis_interrupt(int irq, void *context, FAR void *arg)
{
struct kinetis_dev_s *priv = &g_sdhcdev;
uint32_t enabled;
@@ -1681,7 +1681,7 @@ static int kinetis_attach(FAR struct sdio_dev_s *dev)
/* Attach the SDIO interrupt handler */
- ret = irq_attach(KINETIS_IRQ_SDHC, kinetis_interrupt);
+ ret = irq_attach(KINETIS_IRQ_SDHC, kinetis_interrupt, NULL);
if (ret == OK)
{
diff --git a/arch/arm/src/kinetis/kinetis_serial.c b/arch/arm/src/kinetis/kinetis_serial.c
index 94966f72a2727e2cac93ec2098f931a1401e669e..63873ecab5fc9ae67c4ff593fef61c7ef5ad2c3f 100644
--- a/arch/arm/src/kinetis/kinetis_serial.c
+++ b/arch/arm/src/kinetis/kinetis_serial.c
@@ -1,8 +1,9 @@
/****************************************************************************
- * arch/mips/src/kinetis/kinetis_serial.c
+ * arch/arm/src/kinetis/kinetis_serial.c
*
- * Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt
+ * Copyright (C) 2011-2012, 2017 Gregory Nutt. All rights reserved.
+ * Authors: Gregory Nutt
+ * David Sidrane
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -76,7 +77,7 @@
* provide some minimal implementation of up_putc.
*/
-#ifdef USE_SERIALDRIVER
+#if defined(HAVE_UART_DEVICE) && defined(USE_SERIALDRIVER)
/* Which UART with be tty0/console and which tty1-4? The console will always
* be ttyS0. If there is no console then will use the lowest numbered UART.
@@ -240,6 +241,7 @@ struct up_dev_s
uint8_t ie; /* Interrupts enabled */
uint8_t parity; /* 0=none, 1=odd, 2=even */
uint8_t bits; /* Number of bits (8 or 9) */
+ uint8_t stop2; /* Use 2 stop bits */
};
/****************************************************************************
@@ -251,9 +253,9 @@ static void up_shutdown(struct uart_dev_s *dev);
static int up_attach(struct uart_dev_s *dev);
static void up_detach(struct uart_dev_s *dev);
#ifdef CONFIG_DEBUG_FEATURES
-static int up_interrupt(int irq, void *context);
+static int up_interrupt(int irq, void *context, FAR void *arg);
#endif
-static int up_interrupts(int irq, void *context);
+static int up_interrupts(int irq, void *context, FAR void *arg);
static int up_ioctl(struct file *filep, int cmd, unsigned long arg);
static int up_receive(struct uart_dev_s *dev, uint32_t *status);
static void up_rxint(struct uart_dev_s *dev, bool enable);
@@ -334,6 +336,7 @@ static struct up_dev_s g_uart0priv =
.irqprio = CONFIG_KINETIS_UART0PRIO,
.parity = CONFIG_UART0_PARITY,
.bits = CONFIG_UART0_BITS,
+ .stop2 = CONFIG_UART0_2STOP,
};
static uart_dev_t g_uart0port =
@@ -368,6 +371,7 @@ static struct up_dev_s g_uart1priv =
.irqprio = CONFIG_KINETIS_UART1PRIO,
.parity = CONFIG_UART1_PARITY,
.bits = CONFIG_UART1_BITS,
+ .stop2 = CONFIG_UART1_2STOP,
};
static uart_dev_t g_uart1port =
@@ -402,6 +406,7 @@ static struct up_dev_s g_uart2priv =
.irqprio = CONFIG_KINETIS_UART2PRIO,
.parity = CONFIG_UART2_PARITY,
.bits = CONFIG_UART2_BITS,
+ .stop2 = CONFIG_UART2_2STOP,
};
static uart_dev_t g_uart2port =
@@ -436,6 +441,7 @@ static struct up_dev_s g_uart3priv =
.irqprio = CONFIG_KINETIS_UART3PRIO,
.parity = CONFIG_UART3_PARITY,
.bits = CONFIG_UART3_BITS,
+ .stop2 = CONFIG_UART3_2STOP,
};
static uart_dev_t g_uart3port =
@@ -470,6 +476,7 @@ static struct up_dev_s g_uart4priv =
.irqprio = CONFIG_KINETIS_UART4PRIO,
.parity = CONFIG_UART4_PARITY,
.bits = CONFIG_UART4_BITS,
+ .stop2 = CONFIG_UART4_2STOP,
};
static uart_dev_t g_uart4port =
@@ -504,6 +511,7 @@ static struct up_dev_s g_uart5priv =
.irqprio = CONFIG_KINETIS_UART5PRIO,
.parity = CONFIG_UART5_PARITY,
.bits = CONFIG_UART5_BITS,
+ .stop2 = CONFIG_UART5_2STOP,
};
static uart_dev_t g_uart5port =
@@ -615,7 +623,7 @@ static int up_setup(struct uart_dev_s *dev)
/* Configure the UART as an RS-232 UART */
kinetis_uartconfigure(priv->uartbase, priv->baud, priv->clock,
- priv->parity, priv->bits);
+ priv->parity, priv->bits, priv->stop2);
#endif
/* Make sure that all interrupts are disabled */
@@ -680,11 +688,11 @@ static int up_attach(struct uart_dev_s *dev)
* disabled in the C2 register.
*/
- ret = irq_attach(priv->irqs, up_interrupts);
+ ret = irq_attach(priv->irqs, up_interrupts, dev);
#ifdef CONFIG_DEBUG_FEATURES
if (ret == OK)
{
- ret = irq_attach(priv->irqe, up_interrupt);
+ ret = irq_attach(priv->irqe, up_interrupt, dev);
}
#endif
@@ -739,60 +747,14 @@ static void up_detach(struct uart_dev_s *dev)
****************************************************************************/
#ifdef CONFIG_DEBUG_FEATURES
-static int up_interrupt(int irq, void *context)
+static int up_interrupt(int irq, void *context, FAR void *arg)
{
- struct uart_dev_s *dev = NULL;
+ struct uart_dev_s *dev = (struct uart_dev_s *)arg;
struct up_dev_s *priv;
uint8_t regval;
-#ifdef CONFIG_KINETIS_UART0
- if (g_uart0priv.irqe == irq)
- {
- dev = &g_uart0port;
- }
- else
-#endif
-#ifdef CONFIG_KINETIS_UART1
- if (g_uart1priv.irqe == irq)
- {
- dev = &g_uart1port;
- }
- else
-#endif
-#ifdef CONFIG_KINETIS_UART2
- if (g_uart2priv.irqe == irq)
- {
- dev = &g_uart2port;
- }
- else
-#endif
-#ifdef CONFIG_KINETIS_UART3
- if (g_uart3priv.irqe == irq)
- {
- dev = &g_uart3port;
- }
- else
-#endif
-#ifdef CONFIG_KINETIS_UART4
- if (g_uart4priv.irqe == irq)
- {
- dev = &g_uart4port;
- }
- else
-#endif
-#ifdef CONFIG_KINETIS_UART5
- if (g_uart5priv.irqe == irq)
- {
- dev = &g_uart5port;
- }
- else
-#endif
- {
- PANIC();
- }
-
+ DEBUGASSERT(dev != NULL && dev->priv != NULL);
priv = (struct up_dev_s *)dev->priv;
- DEBUGASSERT(priv);
/* Handle error interrupts. This interrupt may be caused by:
*
@@ -827,9 +789,9 @@ static int up_interrupt(int irq, void *context)
*
****************************************************************************/
-static int up_interrupts(int irq, void *context)
+static int up_interrupts(int irq, void *context, FAR void *arg)
{
- struct uart_dev_s *dev = NULL;
+ struct uart_dev_s *dev = (struct uart_dev_s *)arg;
struct up_dev_s *priv;
int passes;
#ifdef CONFIG_KINETIS_UARTFIFOS
@@ -839,53 +801,8 @@ static int up_interrupts(int irq, void *context)
#endif
bool handled;
-#ifdef CONFIG_KINETIS_UART0
- if (g_uart0priv.irqs == irq)
- {
- dev = &g_uart0port;
- }
- else
-#endif
-#ifdef CONFIG_KINETIS_UART1
- if (g_uart1priv.irqs == irq)
- {
- dev = &g_uart1port;
- }
- else
-#endif
-#ifdef CONFIG_KINETIS_UART2
- if (g_uart2priv.irqs == irq)
- {
- dev = &g_uart2port;
- }
- else
-#endif
-#ifdef CONFIG_KINETIS_UART3
- if (g_uart3priv.irqs == irq)
- {
- dev = &g_uart3port;
- }
- else
-#endif
-#ifdef CONFIG_KINETIS_UART4
- if (g_uart4priv.irqs == irq)
- {
- dev = &g_uart4port;
- }
- else
-#endif
-#ifdef CONFIG_KINETIS_UART5
- if (g_uart5priv.irqs == irq)
- {
- dev = &g_uart5port;
- }
- else
-#endif
- {
- PANIC();
- }
+ DEBUGASSERT(dev != NULL && dev->priv != NULL);
priv = (struct up_dev_s *)dev->priv;
- DEBUGASSERT(priv);
/* Loop until there are no characters to be transferred or,
* until we have been looping for a long time.
@@ -1071,9 +988,9 @@ static void up_rxint(struct uart_dev_s *dev, bool enable)
{
#ifdef CONFIG_DEBUG_FEATURES
# warning "Revisit: How are errors enabled?"
- priv->ie |= UART_C2_RIE;
+ priv->ie &= ~UART_C2_RIE;
#else
- priv->ie |= UART_C2_RIE;
+ priv->ie &= ~UART_C2_RIE;
#endif
up_setuartint(priv);
}
@@ -1220,7 +1137,7 @@ static bool up_txempty(struct uart_dev_s *dev)
****************************************************************************/
/****************************************************************************
- * Name: up_earlyserialinit
+ * Name: kinetis_uart_earlyserialinit
*
* Description:
* Performs the low level UART initialization early in debug so that the
@@ -1231,7 +1148,8 @@ static bool up_txempty(struct uart_dev_s *dev)
*
****************************************************************************/
-void up_earlyserialinit(void)
+#if defined(USE_EARLYSERIALINIT)
+void kinetis_uart_earlyserialinit(void)
{
/* Disable interrupts from all UARTS. The console is enabled in
* pic32mx_consoleinit()
@@ -1256,47 +1174,63 @@ void up_earlyserialinit(void)
/* Configuration whichever one is the console */
-#ifdef HAVE_SERIAL_CONSOLE
+#ifdef HAVE_UART_CONSOLE
CONSOLE_DEV.isconsole = true;
up_setup(&CONSOLE_DEV);
#endif
}
+#endif
/****************************************************************************
- * Name: up_serialinit
+ * Name: kinetis_uart_serialinit
*
* Description:
* Register serial console and serial ports. This assumes
* that up_earlyserialinit was called previously.
*
+ * Input Parameters:
+ * first: - First TTY number to assign
+ *
+ * Returns Value:
+ * The next TTY number available for assignment
+ *
****************************************************************************/
-void up_serialinit(void)
+unsigned int kinetis_uart_serialinit(unsigned int first)
{
+ char devname[] = "/dev/ttySx";
+
/* Register the console */
-#ifdef HAVE_SERIAL_CONSOLE
+#ifdef HAVE_UART_CONSOLE
(void)uart_register("/dev/console", &CONSOLE_DEV);
#endif
/* Register all UARTs */
- (void)uart_register("/dev/ttyS0", &TTYS0_DEV);
+ devname[(sizeof(devname)/sizeof(devname[0]))-2] = '0' + first++;
+ (void)uart_register(devname, &TTYS0_DEV);
#ifdef TTYS1_DEV
- (void)uart_register("/dev/ttyS1", &TTYS1_DEV);
+ devname[(sizeof(devname)/sizeof(devname[0]))-2] = '0' + first++;
+ (void)uart_register(devname, &TTYS1_DEV);
#endif
#ifdef TTYS2_DEV
- (void)uart_register("/dev/ttyS2", &TTYS2_DEV);
+ devname[(sizeof(devname)/sizeof(devname[0]))-2] = '0' + first++;
+ (void)uart_register(devname, &TTYS2_DEV);
#endif
#ifdef TTYS3_DEV
- (void)uart_register("/dev/ttyS3", &TTYS3_DEV);
+ devname[(sizeof(devname)/sizeof(devname[0]))-2] = '0' + first++;
+ (void)uart_register(devname, &TTYS3_DEV);
#endif
#ifdef TTYS4_DEV
- (void)uart_register("/dev/ttyS4", &TTYS4_DEV);
+ devname[(sizeof(devname)/sizeof(devname[0]))-2] = '0' + first++;
+ (void)uart_register(devname, &TTYS4_DEV);
#endif
#ifdef TTYS5_DEV
- (void)uart_register("/dev/ttyS5", &TTYS5_DEV);
+ devname[(sizeof(devname)/sizeof(devname[0]))-2] = '0' + first++;
+ (void)uart_register(devname, &TTYS5_DEV);
#endif
+ return first;
}
/****************************************************************************
@@ -1307,9 +1241,10 @@ void up_serialinit(void)
*
****************************************************************************/
+#ifdef HAVE_UART_PUTC
int up_putc(int ch)
{
-#ifdef HAVE_SERIAL_CONSOLE
+#ifdef HAVE_UART_CONSOLE
struct up_dev_s *priv = (struct up_dev_s *)CONSOLE_DEV.priv;
uint8_t ie;
@@ -1329,6 +1264,7 @@ int up_putc(int ch)
#endif
return ch;
}
+#endif
#else /* USE_SERIALDRIVER */
@@ -1340,9 +1276,10 @@ int up_putc(int ch)
*
****************************************************************************/
+#ifdef HAVE_UART_PUTC
int up_putc(int ch)
{
-#ifdef HAVE_SERIAL_CONSOLE
+#ifdef HAVE_UART_CONSOLE
/* Check for LF */
if (ch == '\n')
@@ -1356,6 +1293,7 @@ int up_putc(int ch)
#endif
return ch;
}
+#endif
-#endif /* USE_SERIALDRIVER */
+#endif /* HAVE_UART_DEVICE && USE_SERIALDRIVER) */
diff --git a/arch/arm/src/kinetis/kinetis_serialinit.c b/arch/arm/src/kinetis/kinetis_serialinit.c
new file mode 100644
index 0000000000000000000000000000000000000000..09d7f342c88a1052251a3b96cc0d12a8ba1adae1
--- /dev/null
+++ b/arch/arm/src/kinetis/kinetis_serialinit.c
@@ -0,0 +1,128 @@
+/****************************************************************************
+ * arch/arm/src/kinetis/kinetis_serialinit.c
+ *
+ * Copyright (C) 2017 Gregory Nutt. All rights reserved.
+ * Authors: Gregory Nutt
+ * David Sidrane
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include
+
+#include
+
+#include "kinetis_config.h"
+#include "kinetis.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#if !defined(HAVE_UART_DEVICE) && !defined(HAVE_LPUART_DEVICE)
+# undef CONFIG_KINETS_LPUART_LOWEST
+#endif
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: kinetis_earlyserialinit
+ *
+ * Description:
+ * Performs the low level UART and LPUART initialization early in debug
+ * so that the serial console will be available during bootup. This must
+ * be called before up_serialinit. NOTE: This function depends on GPIO
+ * pin configuration performed in up_consoleinit() and main clock
+ * initialization performed in up_clkinitialize().
+ *
+ ****************************************************************************/
+
+#ifdef defined(USE_EARLYSERIALINIT)
+void kinetis_earlyserialinit(void)
+{
+#if defined(HAVE_UART_DEVICE)
+ /* Initialize UART drivers */
+
+ kinetis_uart_earlyserialinit();
+#endif
+
+#if defined(HAVE_LPUART_DEVICE)
+ /* Initialize LPUART drivers */
+
+ kinetis_lpuart_earlyserialinit();
+#endif
+}
+#endif
+
+#ifdef USE_SERIALDRIVER
+
+/****************************************************************************
+ * Name: up_serialinit
+ *
+ * Description:
+ * Register all the serial console and serial ports. This assumes
+ * that kinetis_earlyserialinit was called previously.
+ *
+ ****************************************************************************/
+
+void up_serialinit(void)
+{
+#if defined(HAVE_UART_DEVICE) ||defined(HAVE_LUART_DEVICE)
+ uint32_t start = 0;
+#endif
+
+ /* Register the console and drivers */
+
+#if defined(HAVE_LPUART_DEVICE) && defined(CONFIG_KINETS_LPUART_LOWEST)
+ /* Register LPUART drivers in starting positions */
+
+ start = kinetis_lpuart_serialinit(start);
+#endif
+
+#if defined(HAVE_UART_DEVICE)
+ /* Register UART drivers */
+
+ start = kinetis_uart_serialinit(start);
+#endif
+
+#if defined(HAVE_LPUART_DEVICE) && !defined(CONFIG_KINETS_LPUART_LOWEST)
+ /* Register LPUART drivers in last positions */
+
+ start = kinetis_lpuart_serialinit(start);
+#endif
+
+}
+#endif /* USE_SERIALDRIVER */
+
diff --git a/arch/arm/src/kinetis/kinetis_start.c b/arch/arm/src/kinetis/kinetis_start.c
index 7f209b1351b2abaa35c1f6f0432369d1e5f19dae..6747ce24e88661cf1f4d3604f2da3fed69ee3389 100644
--- a/arch/arm/src/kinetis/kinetis_start.c
+++ b/arch/arm/src/kinetis/kinetis_start.c
@@ -63,7 +63,7 @@
****************************************************************************/
#ifdef CONFIG_ARCH_FPU
-static inline void stm32_fpuconfig(void);
+static inline void kinetis_fpuconfig(void);
#endif
#ifdef CONFIG_STACK_COLORATION
static void go_os_start(void *pv, unsigned int nbytes)
@@ -128,7 +128,7 @@ void __start(void) __attribute__ ((no_instrument_function));
#endif
/****************************************************************************
- * Name: stm32_fpuconfig
+ * Name: kinetis_fpuconfig
*
* Description:
* Configure the FPU. Relative bit settings:
@@ -153,7 +153,7 @@ void __start(void) __attribute__ ((no_instrument_function));
#ifdef CONFIG_ARCH_FPU
#if defined(CONFIG_ARMV7M_CMNVECTOR) && !defined(CONFIG_ARMV7M_LAZYFPU)
-static inline void stm32_fpuconfig(void)
+static inline void kinetis_fpuconfig(void)
{
uint32_t regval;
@@ -183,7 +183,7 @@ static inline void stm32_fpuconfig(void)
#else
-static inline void stm32_fpuconfig(void)
+static inline void kinetis_fpuconfig(void)
{
uint32_t regval;
@@ -214,7 +214,7 @@ static inline void stm32_fpuconfig(void)
#endif
#else
-# define stm32_fpuconfig()
+# define kinetis_fpuconfig()
#endif
/****************************************************************************
@@ -327,10 +327,10 @@ void __start(void)
* can get debug output as soon as possible (This depends on clock
* configuration).
*/
- stm32_fpuconfig();
+ kinetis_fpuconfig();
kinetis_lowsetup();
#ifdef USE_EARLYSERIALINIT
- up_earlyserialinit();
+ kinetis_earlyserialinit();
#endif
/* For the case of the separate user-/kernel-space build, perform whatever
diff --git a/arch/arm/src/kinetis/kinetis_timerisr.c b/arch/arm/src/kinetis/kinetis_timerisr.c
index 48e411dcf5a6dd49c93b769426cf5fe91b6bfed1..44f7e3e9be564ee3e1f46e0c0c7c68a17cb1deb6 100644
--- a/arch/arm/src/kinetis/kinetis_timerisr.c
+++ b/arch/arm/src/kinetis/kinetis_timerisr.c
@@ -90,7 +90,7 @@
*
****************************************************************************/
-static int kinetis_timerisr(int irq, uint32_t *regs)
+static int kinetis_timerisr(int irq, uint32_t *regs, FAR void *arg)
{
/* Process timer interrupt */
@@ -139,7 +139,7 @@ void arm_timer_initialize(void)
/* Attach the timer interrupt vector */
- (void)irq_attach(KINETIS_IRQ_SYSTICK, (xcpt_t)kinetis_timerisr);
+ (void)irq_attach(KINETIS_IRQ_SYSTICK, (xcpt_t)kinetis_timerisr, NULL);
/* Enable SysTick interrupts */
diff --git a/arch/arm/src/kinetis/kinetis_usbdev.c b/arch/arm/src/kinetis/kinetis_usbdev.c
index 231fc01430316ac13a235b23a356d31e2012bf90..c550fbd3252a60135ef66380f5b439bb8da65cb6 100644
--- a/arch/arm/src/kinetis/kinetis_usbdev.c
+++ b/arch/arm/src/kinetis/kinetis_usbdev.c
@@ -133,8 +133,6 @@
#define KHCI_ENDP_BIT(ep) (1 << (ep))
#define KHCI_ENDP_ALLSET 0xffff
-#define SIM_CLKDIV2_USBDIV(n) (uint32_t)(((n) & 0x07) << 1)
-
/* BDT Table Indexing. The BDT is addressed in the hardware as follows:
*
* Bits 9-31: These come the BDT address bits written into the BDTP3,
@@ -564,7 +562,7 @@ static void khci_ep0outcomplete(struct khci_usbdev_s *priv);
static void khci_ep0incomplete(struct khci_usbdev_s *priv);
static void khci_ep0transfer(struct khci_usbdev_s *priv,
uint16_t ustat);
-static int khci_interrupt(int irq, void *context);
+static int khci_interrupt(int irq, void *context, FAR void *arg);
/* Endpoint helpers *********************************************************/
@@ -2715,7 +2713,7 @@ static void khci_ep0transfer(struct khci_usbdev_s *priv, uint16_t ustat)
* Name: khci_interrupt
****************************************************************************/
-static int khci_interrupt(int irq, void *context)
+static int khci_interrupt(int irq, void *context, FAR void *arg)
{
/* For now there is only one USB controller, but we will always refer to
* it using a pointer to make any future ports to multiple USB controllers
@@ -4395,33 +4393,24 @@ void up_usbinitialize(void)
* it using a pointer to make any future ports to multiple USB controllers
* easier.
*/
-#if 1
- /* 1: Select clock source */
+
+ /* Select clock source:
+ * SIM_SOPT2[PLLFLLSEL] and SIM_CLKDIV2[USBFRAC, USBDIV] will have been
+ * configured in kinetis_pllconfig. So here we select between USB_CLKIN
+ * or the output of SIM_CLKDIV2[USBFRAC, USBDIV]
+ */
regval = getreg32(KINETIS_SIM_SOPT2);
- regval |= SIM_SOPT2_PLLFLLSEL | SIM_SOPT2_USBSRC;
+ regval &= ~(SIM_SOPT2_USBSRC);
+ regval |= BOARD_USB_CLKSRC;
putreg32(regval, KINETIS_SIM_SOPT2);
- regval = getreg32(KINETIS_SIM_CLKDIV2);
-#if defined(CONFIG_TEENSY_3X_OVERCLOCK)
- /* (USBFRAC + 0)/(USBDIV + 1) = (1 + 0)/(1 + 1) = 1/2 for 96Mhz clock */
-
- regval = SIM_CLKDIV2_USBDIV(1);
-#else
- /* 72Mhz */
-
- regval = SIM_CLKDIV2_USBDIV(2) | SIM_CLKDIV2_USBFRAC;
-#endif
- putreg32(regval, KINETIS_SIM_CLKDIV2);
-
/* 2: Gate USB clock */
regval = getreg32(KINETIS_SIM_SCGC4);
regval |= SIM_SCGC4_USBOTG;
putreg32(regval, KINETIS_SIM_SCGC4);
-#endif
-
usbtrace(TRACE_DEVINIT, 0);
/* Initialize the driver state structure */
@@ -4442,7 +4431,7 @@ void up_usbinitialize(void)
* them when we need them later.
*/
- if (irq_attach(KINETIS_IRQ_USBOTG, khci_interrupt) != 0)
+ if (irq_attach(KINETIS_IRQ_USBOTG, khci_interrupt, NULL) != 0)
{
usbtrace(TRACE_DEVERROR(KHCI_TRACEERR_IRQREGISTRATION),
(uint16_t)KINETIS_IRQ_USBOTG);
diff --git a/arch/arm/src/kl/kl_gpio.h b/arch/arm/src/kl/kl_gpio.h
index 0024e67608686b7ca892cd80b648054ea7a1a0ea..4a81acd27e46ce2c5f8f00d050c307fa7e96140c 100644
--- a/arch/arm/src/kl/kl_gpio.h
+++ b/arch/arm/src/kl/kl_gpio.h
@@ -355,7 +355,7 @@ void kl_gpiowrite(uint32_t pinset, bool value);
bool kl_gpioread(uint32_t pinset);
/************************************************************************************
- * Name: kl_pinirqattach
+ * Name: kl_gpioirqattach
*
* Description:
* Attach a pin interrupt handler. The normal initalization sequence is:
@@ -368,15 +368,15 @@ bool kl_gpioread(uint32_t pinset);
* Parameters:
* - pinset: Pin configuration
* - pinisr: Pin interrupt service routine
+ * - pinarg: The argument that will accompany the pin interrupt
*
* Returns:
- * The previous value of the interrupt handler function pointer. This value may,
- * for example, be used to restore the previous handler when multiple handlers are
- * used.
+ * Zero (OK) is returned on success; On any failure, a negated errno value is
+ * returned to indicate the nature of the failure.
*
************************************************************************************/
-xcpt_t kl_gpioirqattach(uint32_t pinset, xcpt_t pinisr);
+int kl_gpioirqattach(uint32_t pinset, xcpt_t pinisr, void *pinarg);
/************************************************************************************
* Name: kl_gpioirqenable
diff --git a/arch/arm/src/kl/kl_gpioirq.c b/arch/arm/src/kl/kl_gpioirq.c
index 61331343ccd404672977b3f8f174967b7947a013..38f30c0870f1e9f29895ef9744e6e1b1460a75d3 100644
--- a/arch/arm/src/kl/kl_gpioirq.c
+++ b/arch/arm/src/kl/kl_gpioirq.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/kl/kl_gpioirq.c
*
- * Copyright (C) 2014 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2014, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
*
* Redistribution and use in source and binary forms, with or without
@@ -68,7 +68,7 @@
#endif
#if defined(CONFIG_KL_PORTBINTS) || defined(CONFIG_KL_PORTCINTS) || \
- defined(CONFIG_KL_PORTEINTS)
+ defined(CONFIG_KL_PORTEINTS)
# error Kinetis KL25 only supports interrupt on PORTA or PORTD
#endif
@@ -76,6 +76,12 @@
* Private Types
****************************************************************************/
+struct g_portisrs_s
+{
+ xcpt_t handler; /* Interrupt handler entry point */
+ void *arg; /* The argument that accompanies the interrupt handler */
+};
+
/****************************************************************************
* Private Data
****************************************************************************/
@@ -87,11 +93,11 @@
*/
#ifdef CONFIG_KL_PORTAINTS
-static xcpt_t g_portaisrs[32];
+static struct g_portisrs_s g_portaisrs[32];
#endif
#ifdef CONFIG_KL_PORTDINTS
-static xcpt_t g_portdisrs[32];
+static struct g_portisrs_s g_portdisrs[32];
#endif
/****************************************************************************
@@ -131,11 +137,14 @@ static int kl_portinterrupt(int irq, FAR void *context,
* interrupt handler for the pin.
*/
- if (isrtab[i])
+ if (isrtab[i].handler != NULL)
{
+ xcpt_t handler = irstab[i].handler;
+ void *arg = irstab[i].arg;
+
/* There is a registered interrupt handler... invoke it */
- (void)isrtab[i](irq, context);
+ (void)handler(irq, context, arg);
}
/* Writing a one to the ISFR register will clear the pending
@@ -164,14 +173,14 @@ static int kl_portinterrupt(int irq, FAR void *context,
****************************************************************************/
#ifdef CONFIG_KL_PORTAINTS
-static int kl_portainterrupt(int irq, FAR void *context)
+static int kl_portainterrupt(int irq, FAR void *context, FAR void *arg)
{
return kl_portinterrupt(irq, context, KL_PORTA_ISFR, g_portaisrs);
}
#endif
#ifdef CONFIG_KL_PORTDINTS
-static int kl_portdinterrupt(int irq, FAR void *context)
+static int kl_portdinterrupt(int irq, FAR void *context, FAR void *arg)
{
return kl_portinterrupt(irq, context, KL_PORTD_ISFR, g_portdisrs);
}
@@ -193,13 +202,13 @@ static int kl_portdinterrupt(int irq, FAR void *context)
void kl_gpioirqinitialize(void)
{
#ifdef CONFIG_KL_PORTAINTS
- (void)irq_attach(KL_IRQ_PORTA, kl_portainterrupt);
+ (void)irq_attach(KL_IRQ_PORTA, kl_portainterrupt, NULL);
putreg32(0xffffffff, KL_PORTA_ISFR);
up_enable_irq(KL_IRQ_PORTA);
#endif
#ifdef CONFIG_KL_PORTDINTS
- (void)irq_attach(KL_IRQ_PORTD, kl_portdinterrupt);
+ (void)irq_attach(KL_IRQ_PORTD, kl_portdinterrupt, NULL);
putreg32(0xffffffff, KL_PORTD_ISFR);
up_enable_irq(KL_IRQ_PORTD);
#endif
@@ -219,20 +228,20 @@ void kl_gpioirqinitialize(void)
* Parameters:
* - pinset: Pin configuration
* - pinisr: Pin interrupt service routine
+ * - pinarg: The argument that will accompany the pin interrupt
*
* Returns:
- * The previous value of the interrupt handler function pointer. This
- * value may, for example, be used to restore the previous handler when
- * multiple handlers are used.
+ * Returns:
+ * Zero (OK) is returned on success; On any failure, a negated errno value is
+ * returned to indicate the nature of the failure.
*
- ****************************************************************************/
+ ************************************************************************************/
-xcpt_t kl_gpioirqattach(uint32_t pinset, xcpt_t pinisr)
+int kl_gpioirqattach(uint32_t pinset, xcpt_t pinisr, void *pinarg)
{
#ifdef HAVE_PORTINTS
- xcpt_t *isrtab;
- xcpt_t oldisr;
- irqstate_t flags;
+ struct g_portisrs_s *isrtab;
+ irqstate_t flags;
unsigned int port;
unsigned int pin;
@@ -271,16 +280,16 @@ xcpt_t kl_gpioirqattach(uint32_t pinset, xcpt_t pinisr)
/* Get the old PIN ISR and set the new PIN ISR */
- oldisr = isrtab[pin];
- isrtab[pin] = pinisr;
+ isrtab[pin].handler = pinisr;
+ isrtab[pin].arg = pinarg;
/* And return the old PIN isr address */
leave_critical_section(flags);
- return oldisr;
+ return OK;
#else
- return NULL;
+ return -ENOSYS;
#endif /* HAVE_PORTINTS */
}
diff --git a/arch/arm/src/kl/kl_irq.c b/arch/arm/src/kl/kl_irq.c
index 94628f26bf7179fdd81ea7ca787541749e6ece94..f8466ac4f50738b014d8f1282c7a55ea621c5644 100644
--- a/arch/arm/src/kl/kl_irq.c
+++ b/arch/arm/src/kl/kl_irq.c
@@ -138,7 +138,7 @@ static void kl_dumpnvic(const char *msg, int irq)
****************************************************************************/
#ifdef CONFIG_DEBUG_FEATURES
-static int kl_nmi(int irq, FAR void *context)
+static int kl_nmi(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! NMI received\n");
@@ -146,7 +146,7 @@ static int kl_nmi(int irq, FAR void *context)
return 0;
}
-static int kl_pendsv(int irq, FAR void *context)
+static int kl_pendsv(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! PendSV received\n");
@@ -154,7 +154,7 @@ static int kl_pendsv(int irq, FAR void *context)
return 0;
}
-static int kl_reserved(int irq, FAR void *context)
+static int kl_reserved(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Reserved interrupt\n");
@@ -231,15 +231,15 @@ void up_irqinitialize(void)
* under certain conditions.
*/
- irq_attach(KL_IRQ_SVCALL, up_svcall);
- irq_attach(KL_IRQ_HARDFAULT, up_hardfault);
+ irq_attach(KL_IRQ_SVCALL, up_svcall, NULL);
+ irq_attach(KL_IRQ_HARDFAULT, up_hardfault, NULL);
/* Attach all other processor exceptions (except reset and sys tick) */
#ifdef CONFIG_DEBUG_FEATURES
- irq_attach(KL_IRQ_NMI, kl_nmi);
- irq_attach(KL_IRQ_PENDSV, kl_pendsv);
- irq_attach(KL_IRQ_RESERVED, kl_reserved);
+ irq_attach(KL_IRQ_NMI, kl_nmi, NULL);
+ irq_attach(KL_IRQ_PENDSV, kl_pendsv, NULL);
+ irq_attach(KL_IRQ_RESERVED, kl_reserved, NULL);
#endif
kl_dumpnvic("initial", NR_IRQS);
diff --git a/arch/arm/src/kl/kl_serial.c b/arch/arm/src/kl/kl_serial.c
index fab56a34d5eaeda4f1bb5b0fbcfaa3cf6787dbd1..a35328345ee43e5e5544936b1984d619ed1b7e9b 100644
--- a/arch/arm/src/kl/kl_serial.c
+++ b/arch/arm/src/kl/kl_serial.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/kl/kl_serial.c
*
- * Copyright (C) 2013-2012, 2016 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2013-2012, 2016-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
*
* Redistribution and use in source and binary forms, with or without
@@ -171,7 +171,7 @@ static int up_setup(struct uart_dev_s *dev);
static void up_shutdown(struct uart_dev_s *dev);
static int up_attach(struct uart_dev_s *dev);
static void up_detach(struct uart_dev_s *dev);
-static int up_interrupts(int irq, void *context);
+static int up_interrupts(int irq, void *context, void *arg);
static int up_ioctl(struct file *filep, int cmd, unsigned long arg);
static int up_receive(struct uart_dev_s *dev, uint32_t *status);
static void up_rxint(struct uart_dev_s *dev, bool enable);
@@ -455,7 +455,7 @@ static int up_attach(struct uart_dev_s *dev)
* disabled in the C2 register.
*/
- ret = irq_attach(priv->irq, up_interrupts);
+ ret = irq_attach(priv->irq, up_interrupts, dev);
if (ret == OK)
{
up_enable_irq(priv->irq);
@@ -500,40 +500,16 @@ static void up_detach(struct uart_dev_s *dev)
*
****************************************************************************/
-static int up_interrupts(int irq, void *context)
+static int up_interrupts(int irq, void *context, void *arg)
{
- struct uart_dev_s *dev = NULL;
+ struct uart_dev_s *dev = (struct uart_dev_s *)arg;
struct up_dev_s *priv;
int passes;
uint8_t s1;
bool handled;
-#ifdef CONFIG_KL_UART0
- if (g_uart0priv.irq == irq)
- {
- dev = &g_uart0port;
- }
- else
-#endif
-#ifdef CONFIG_KL_UART1
- if (g_uart1priv.irq == irq)
- {
- dev = &g_uart1port;
- }
- else
-#endif
-#ifdef CONFIG_KL_UART2
- if (g_uart2priv.irq == irq)
- {
- dev = &g_uart2port;
- }
- else
-#endif
- {
- PANIC();
- }
+ DEBUGASSERT(dev != NULL && dev->priv != NULL);
priv = (struct up_dev_s *)dev->priv;
- DEBUGASSERT(priv);
/* Loop until there are no characters to be transferred or,
* until we have been looping for a long time.
diff --git a/arch/arm/src/kl/kl_timerisr.c b/arch/arm/src/kl/kl_timerisr.c
index bf406102753620b56e97ed227a3d5e684bd6cf90..eed3f5d9bafcbd92bdfeb697a1f7565577e75e49 100644
--- a/arch/arm/src/kl/kl_timerisr.c
+++ b/arch/arm/src/kl/kl_timerisr.c
@@ -105,7 +105,7 @@
*
****************************************************************************/
-static int kl_timerisr(int irq, uint32_t *regs)
+static int kl_timerisr(int irq, uint32_t *regs, FAR void *arg)
{
/* Process timer interrupt */
@@ -143,7 +143,7 @@ void arm_timer_initialize(void)
/* Attach the timer interrupt vector */
- (void)irq_attach(KL_IRQ_SYSTICK, (xcpt_t)kl_timerisr);
+ (void)irq_attach(KL_IRQ_SYSTICK, (xcpt_t)kl_timerisr, NULL);
/* Enable SysTick interrupts. "The CLKSOURCE bit in SysTick Control and
* Status register selects either the core clock (when CLKSOURCE = 1) or
diff --git a/arch/arm/src/lpc11xx/lpc11_gpioint.c b/arch/arm/src/lpc11xx/lpc11_gpioint.c
index 8aaefed14978676be72020bd9e9b107d6da46487..5327b9e9ff8c1a064328e7da38bcced7c66c2d8b 100644
--- a/arch/arm/src/lpc11xx/lpc11_gpioint.c
+++ b/arch/arm/src/lpc11xx/lpc11_gpioint.c
@@ -402,7 +402,7 @@ static void lpc11_gpiodemux(uint32_t intbase, uint32_t intmask,
*
****************************************************************************/
-static int lpc11_gpiointerrupt(int irq, void *context)
+static int lpc11_gpiointerrupt(int irq, void *context, FAR void *arg)
{
/* Get the GPIO interrupt status */
@@ -468,7 +468,7 @@ void lpc11_gpioirqinitialize(void)
* position in the NVIC with External Interrupt 3
*/
- (void)irq_attach(LPC11_IRQ_EINT3, lpc11_gpiointerrupt);
+ (void)irq_attach(LPC11_IRQ_EINT3, lpc11_gpiointerrupt, NULL);
up_enable_irq(LPC11_IRQ_EINT3);
#elif defined(LPC178x)
@@ -476,7 +476,7 @@ void lpc11_gpioirqinitialize(void)
* GPIO2.
*/
- (void)irq_attach(LPC11_IRQ_GPIO, lpc11_gpiointerrupt);
+ (void)irq_attach(LPC11_IRQ_GPIO, lpc11_gpiointerrupt, NULL);
up_enable_irq(LPC11_IRQ_GPIO);
#endif
diff --git a/arch/arm/src/lpc11xx/lpc11_i2c.c b/arch/arm/src/lpc11xx/lpc11_i2c.c
index b8f91daee714dbc0b2884cbed37be4f1ab33b2cd..b9d2d107434463813edd4686f3d028a0977838a6 100644
--- a/arch/arm/src/lpc11xx/lpc11_i2c.c
+++ b/arch/arm/src/lpc11xx/lpc11_i2c.c
@@ -129,7 +129,7 @@ struct lpc11_i2cdev_s
static int lpc11_i2c_start(struct lpc11_i2cdev_s *priv);
static void lpc11_i2c_stop(struct lpc11_i2cdev_s *priv);
-static int lpc11_i2c_interrupt(int irq, FAR void *context);
+static int lpc11_i2c_interrupt(int irq, FAR void *context, void *arg);
static void lpc11_i2c_timeout(int argc, uint32_t arg, ...);
static void lpc11_i2c_setfrequency(struct lpc11_i2cdev_s *priv,
uint32_t frequency);
@@ -304,7 +304,7 @@ static int lpc11_i2c_transfer(FAR struct i2c_master_s *dev,
}
/****************************************************************************
- * Name: lpc11_i2c_interrupt
+ * Name: lpc11_stopnext
*
* Description:
* Check if we need to issue STOP at the next message
@@ -334,36 +334,13 @@ static void lpc11_stopnext(struct lpc11_i2cdev_s *priv)
*
****************************************************************************/
-static int lpc11_i2c_interrupt(int irq, FAR void *context)
+static int lpc11_i2c_interrupt(int irq, FAR void *context, void *arg)
{
- struct lpc11_i2cdev_s *priv;
+ struct lpc11_i2cdev_s *priv = (struct lpc11_i2cdev_s *)arg;
struct i2c_msg_s *msg;
uint32_t state;
-#ifdef CONFIG_LPC11_I2C0
- if (irq == LPC11_IRQ_I2C0)
- {
- priv = &g_i2c0dev;
- }
- else
-#endif
-#ifdef CONFIG_LPC11_I2C1
- if (irq == LPC11_IRQ_I2C1)
- {
- priv = &g_i2c1dev;
- }
- else
-#endif
-#ifdef CONFIG_LPC11_I2C2
- if (irq == LPC11_IRQ_I2C2)
- {
- priv = &g_i2c2dev;
- }
- else
-#endif
- {
- PANIC();
- }
+ DEBUGASSERT(priv != NULL);
/* Reference UM10360 19.10.5 */
@@ -603,7 +580,7 @@ struct i2c_master_s *lpc11_i2cbus_initialize(int port)
/* Attach Interrupt Handler */
- irq_attach(priv->irqid, lpc11_i2c_interrupt);
+ irq_attach(priv->irqid, lpc11_i2c_interrupt, priv);
/* Enable Interrupt Handler */
diff --git a/arch/arm/src/lpc11xx/lpc11_irq.c b/arch/arm/src/lpc11xx/lpc11_irq.c
index 4399c5820031c8d3e8f85744603e2a0f57d1b939..df2fde8405ce37f798fef9a115eb25e3d7b042a3 100644
--- a/arch/arm/src/lpc11xx/lpc11_irq.c
+++ b/arch/arm/src/lpc11xx/lpc11_irq.c
@@ -134,7 +134,7 @@ static void lpc11_dumpnvic(const char *msg, int irq)
****************************************************************************/
#ifdef CONFIG_DEBUG_FEATURES
-static int lpc11_nmi(int irq, FAR void *context)
+static int lpc11_nmi(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! NMI received\n");
@@ -142,7 +142,7 @@ static int lpc11_nmi(int irq, FAR void *context)
return 0;
}
-static int lpc11_pendsv(int irq, FAR void *context)
+static int lpc11_pendsv(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! PendSV received\n");
@@ -150,7 +150,7 @@ static int lpc11_pendsv(int irq, FAR void *context)
return 0;
}
-static int lpc11_reserved(int irq, FAR void *context)
+static int lpc11_reserved(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Reserved interrupt\n");
@@ -227,15 +227,15 @@ void up_irqinitialize(void)
* under certain conditions.
*/
- irq_attach(LPC11_IRQ_SVCALL, up_svcall);
- irq_attach(LPC11_IRQ_HARDFAULT, up_hardfault);
+ irq_attach(LPC11_IRQ_SVCALL, up_svcall, NULL);
+ irq_attach(LPC11_IRQ_HARDFAULT, up_hardfault, NULL);
/* Attach all other processor exceptions (except reset and sys tick) */
#ifdef CONFIG_DEBUG_FEATURES
- irq_attach(LPC11_IRQ_NMI, lpc11_nmi);
- irq_attach(LPC11_IRQ_PENDSV, lpc11_pendsv);
- irq_attach(LPC11_IRQ_RESERVED, lpc11_reserved);
+ irq_attach(LPC11_IRQ_NMI, lpc11_nmi, NULL);
+ irq_attach(LPC11_IRQ_PENDSV, lpc11_pendsv, NULL);
+ irq_attach(LPC11_IRQ_RESERVED, lpc11_reserved, NULL);
#endif
lpc11_dumpnvic("initial", NR_IRQS);
diff --git a/arch/arm/src/lpc11xx/lpc11_serial.c b/arch/arm/src/lpc11xx/lpc11_serial.c
index 55c05ac51724716cc7d38f9c99ee63263dfb6397..cbef799afe9d434f097f70d0412e602db196dc75 100644
--- a/arch/arm/src/lpc11xx/lpc11_serial.c
+++ b/arch/arm/src/lpc11xx/lpc11_serial.c
@@ -104,7 +104,7 @@ static int up_setup(struct uart_dev_s *dev);
static void up_shutdown(struct uart_dev_s *dev);
static int up_attach(struct uart_dev_s *dev);
static void up_detach(struct uart_dev_s *dev);
-static int up_interrupt(int irq, void *context);
+static int up_interrupt(int irq, void *context, void *arg);
static int up_ioctl(struct file *filep, int cmd, unsigned long arg);
static int up_receive(struct uart_dev_s *dev, uint32_t *status);
static void up_rxint(struct uart_dev_s *dev, bool enable);
@@ -515,7 +515,7 @@ static int up_attach(struct uart_dev_s *dev)
/* Attach and enable the IRQ */
- ret = irq_attach(priv->irq, up_interrupt);
+ ret = irq_attach(priv->irq, up_interrupt, dev);
if (ret == OK)
{
/* Enable the interrupt (RX and TX interrupts are still disabled
@@ -557,24 +557,14 @@ static void up_detach(struct uart_dev_s *dev)
*
****************************************************************************/
-static int up_interrupt(int irq, void *context)
+static int up_interrupt(int irq, void *context, void *arg)
{
- struct uart_dev_s *dev = NULL;
+ struct uart_dev_s *dev = (struct uart_dev_s *)arg;
struct up_dev_s *priv;
uint32_t status;
int passes;
-#ifdef CONFIG_LPC11_UART0
- if (g_uart0priv.irq == irq)
- {
- dev = &g_uart0port;
- }
- else
-#endif
- {
- PANIC();
- }
-
+ DEBUGASSERT(dev != NULL && dev->priv != NULL);
priv = (struct up_dev_s *)dev->priv;
/* Loop until there are no characters to be transferred or,
diff --git a/arch/arm/src/lpc11xx/lpc11_timerisr.c b/arch/arm/src/lpc11xx/lpc11_timerisr.c
index b5054c79ca2bf068e91d99e6d253bc3b9719b023..f334b625820cb4a8c3fe26cb2f4804c127255469 100644
--- a/arch/arm/src/lpc11xx/lpc11_timerisr.c
+++ b/arch/arm/src/lpc11xx/lpc11_timerisr.c
@@ -105,7 +105,7 @@
*
****************************************************************************/
-static int lpc11_timerisr(int irq, uint32_t *regs)
+static int lpc11_timerisr(int irq, uint32_t *regs, FAR void *arg)
{
/* Process timer interrupt */
@@ -143,7 +143,7 @@ void arm_timer_initialize(void)
/* Attach the timer interrupt vector */
- (void)irq_attach(LPC11_IRQ_SYSTICK, (xcpt_t)lpc11_timerisr);
+ (void)irq_attach(LPC11_IRQ_SYSTICK, (xcpt_t)lpc11_timerisr, NULL);
/* Enable SysTick interrupts. "The CLKSOURCE bit in SysTick Control and
* Status register selects either the core clock (when CLKSOURCE = 1) or
diff --git a/arch/arm/src/lpc17xx/lpc176x_rtc.c b/arch/arm/src/lpc17xx/lpc176x_rtc.c
index 8e04d2f2eba7e41f674cf0326182c0bbeaf44251..825491596851371e7492dd6b2380a2a3dcd711a4 100644
--- a/arch/arm/src/lpc17xx/lpc176x_rtc.c
+++ b/arch/arm/src/lpc17xx/lpc176x_rtc.c
@@ -227,7 +227,7 @@ static int rtc_resume(void)
************************************************************************************/
#ifdef CONFIG_RTC_ALARM
-static int rtc_interrupt(int irq, void *context)
+static int rtc_interrupt(int irq, void *context, FAR void *arg)
{
#warning "Missing logic"
return OK;
@@ -262,7 +262,7 @@ int up_rtc_initialize(void)
/* Attach the RTC interrupt handler */
#ifdef CONFIG_RTC_ALARM
- ret = irq_attach(LPC17_IRQ_RTC, rtc_interrupt);
+ ret = irq_attach(LPC17_IRQ_RTC, rtc_interrupt, NULL);
if (ret == OK)
{
up_enable_irq(LPC17_IRQ_RTC);
diff --git a/arch/arm/src/lpc17xx/lpc17_adc.c b/arch/arm/src/lpc17xx/lpc17_adc.c
index 490b25bf800cf0a19656b759ff0225f18f1a1e98..54d059331524e2793c4070f3d39514f80c045551 100644
--- a/arch/arm/src/lpc17xx/lpc17_adc.c
+++ b/arch/arm/src/lpc17xx/lpc17_adc.c
@@ -112,7 +112,7 @@ static int adc_setup(FAR struct adc_dev_s *dev);
static void adc_shutdown(FAR struct adc_dev_s *dev);
static void adc_rxint(FAR struct adc_dev_s *dev, bool enable);
static int adc_ioctl(FAR struct adc_dev_s *dev, int cmd, unsigned long arg);
-static int adc_interrupt(int irq, void *context);
+static int adc_interrupt(int irq, void *context, FAR void *arg);
/****************************************************************************
* Private Data
@@ -304,7 +304,7 @@ static int adc_setup(FAR struct adc_dev_s *dev)
FAR struct up_dev_s *priv = (FAR struct up_dev_s *)dev->ad_priv;
int i;
- int ret = irq_attach(priv->irq, adc_interrupt);
+ int ret = irq_attach(priv->irq, adc_interrupt, NULL);
if (ret == OK)
{
for (i = 0; i < 8; i++)
@@ -406,7 +406,7 @@ static int adc_ioctl(FAR struct adc_dev_s *dev, int cmd, unsigned long arg)
*
****************************************************************************/
-static int adc_interrupt(int irq, void *context)
+static int adc_interrupt(int irq, void *context, FAR void *arg)
{
#ifndef CONFIG_ADC_BURSTMODE
#ifdef CONFIG_ADC_CHANLIST
diff --git a/arch/arm/src/lpc17xx/lpc17_can.c b/arch/arm/src/lpc17xx/lpc17_can.c
index f961bef5493959da9ebdbd3ee4810e20e2489e17..11ac88cc04debf2557f3aee6b5276a6d2e157001 100644
--- a/arch/arm/src/lpc17xx/lpc17_can.c
+++ b/arch/arm/src/lpc17xx/lpc17_can.c
@@ -217,7 +217,7 @@ static bool can_txempty(FAR struct can_dev_s *dev);
/* CAN interrupts */
static void can_interrupt(FAR struct can_dev_s *dev);
-static int can12_interrupt(int irq, void *context);
+static int can12_interrupt(int irq, void *context, FAR void *arg);
/* Initialization */
@@ -543,7 +543,7 @@ static int can_setup(FAR struct can_dev_s *dev)
caninfo("CAN%d\n", priv->port);
- ret = irq_attach(LPC17_IRQ_CAN, can12_interrupt);
+ ret = irq_attach(LPC17_IRQ_CAN, can12_interrupt, NULL);
if (ret == OK)
{
up_enable_irq(LPC17_IRQ_CAN);
@@ -1045,7 +1045,7 @@ static void can_interrupt(FAR struct can_dev_s *dev)
*
****************************************************************************/
-static int can12_interrupt(int irq, void *context)
+static int can12_interrupt(int irq, void *context, FAR void *arg)
{
/* Handle CAN1/2 interrupts */
diff --git a/arch/arm/src/lpc17xx/lpc17_ethernet.c b/arch/arm/src/lpc17xx/lpc17_ethernet.c
index fa9b65a95f5aada65923915789761a0e096d8067..42e046aea1cacd1d4ec680c3b93f5482e70f57f0 100644
--- a/arch/arm/src/lpc17xx/lpc17_ethernet.c
+++ b/arch/arm/src/lpc17xx/lpc17_ethernet.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/lpc17xx/lpc17_ethernet.c
*
- * Copyright (C) 2010-2015 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2010-2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
*
* Redistribution and use in source and binary forms, with or without
@@ -335,7 +335,7 @@ static void lpc17_response(struct lpc17_driver_s *priv);
static void lpc17_txdone_work(FAR void *arg);
static void lpc17_rxdone_work(FAR void *arg);
-static int lpc17_interrupt(int irq, void *context);
+static int lpc17_interrupt(int irq, void *context, FAR void *arg);
/* Watchdog timer expirations */
@@ -1123,7 +1123,7 @@ static void lpc17_txdone_work(FAR void *arg)
*
****************************************************************************/
-static int lpc17_interrupt(int irq, void *context)
+static int lpc17_interrupt(int irq, void *context, FAR void *arg)
{
register struct lpc17_driver_s *priv;
uint32_t status;
@@ -1221,11 +1221,9 @@ static int lpc17_interrupt(int irq, void *context)
priv->lp_inten &= ~ETH_RXINTS;
lpc17_putreg(priv->lp_inten, LPC17_ETH_INTEN);
- /* Cancel any pending RX done work */
-
- work_cancel(ETHWORK, &priv->lp_rxwork);
-
- /* Schedule RX-related work to be performed on the work thread */
+ /* Schedule RX-related work to be performed on the work thread,
+ * perhaps cancelling any pending RX work.
+ */
work_queue(ETHWORK, &priv->lp_rxwork, (worker_t)lpc17_rxdone_work,
priv, 0);
@@ -1283,17 +1281,10 @@ static int lpc17_interrupt(int irq, void *context)
work_cancel(ETHWORK, &priv->lp_txwork);
- /* Then make sure that the TX poll timer is running (if it is
- * already running, the following would restart it). This is
- * necessary to avoid certain race conditions where the polling
- * sequence can be interrupted.
+ /* Schedule TX-related work to be performed on the work thread,
+ * perhaps cancelling any pending TX work.
*/
- (void)wd_start(priv->lp_txpoll, LPC17_WDDELAY, lpc17_poll_expiry,
- 1, priv);
-
- /* Schedule TX-related work to be performed on the work thread */
-
work_queue(ETHWORK, &priv->lp_txwork, (worker_t)lpc17_txdone_work,
priv, 0);
}
@@ -1480,24 +1471,9 @@ static void lpc17_poll_expiry(int argc, uint32_t arg, ...)
DEBUGASSERT(arg);
- /* Is our single work structure available? It may not be if there are
- * pending interrupt actions.
- */
-
- if (work_available(&priv->lp_pollwork))
- {
- /* Schedule to perform the interrupt processing on the worker thread. */
-
- work_queue(ETHWORK, &priv->lp_pollwork, lpc17_poll_work, priv, 0);
- }
- else
- {
- /* No.. Just re-start the watchdog poll timer, missing one polling
- * cycle.
- */
+ /* Schedule to perform the interrupt processing on the worker thread. */
- (void)wd_start(priv->lp_txpoll, LPC17_WDDELAY, lpc17_poll_expiry, 1, arg);
- }
+ work_queue(ETHWORK, &priv->lp_pollwork, lpc17_poll_work, priv, 0);
}
/****************************************************************************
@@ -3095,9 +3071,9 @@ static inline int lpc17_ethinitialize(int intf)
/* Attach the IRQ to the driver */
#if CONFIG_LPC17_NINTERFACES > 1
- ret = irq_attach(priv->irq, lpc17_interrupt);
+ ret = irq_attach(priv->irq, lpc17_interrupt, NULL);
#else
- ret = irq_attach(LPC17_IRQ_ETH, lpc17_interrupt);
+ ret = irq_attach(LPC17_IRQ_ETH, lpc17_interrupt, NULL);
#endif
if (ret != 0)
{
diff --git a/arch/arm/src/lpc17xx/lpc17_gpdma.c b/arch/arm/src/lpc17xx/lpc17_gpdma.c
index 2eb2edf16ab125ea0868f5ba8815ee92b5c465f8..8fba6cbaad4f2fa3b82e40639387683e7d553ca7 100644
--- a/arch/arm/src/lpc17xx/lpc17_gpdma.c
+++ b/arch/arm/src/lpc17xx/lpc17_gpdma.c
@@ -190,7 +190,7 @@ static void lpc17_dmadone(struct lpc17_dmach_s *dmach)
*
****************************************************************************/
-static int gpdma_interrupt(int irq, FAR void *context)
+static int gpdma_interrupt(int irq, FAR void *context, FAR void *arg)
{
struct lpc17_dmach_s *dmach;
uint32_t regval;
@@ -315,7 +315,7 @@ void weak_function up_dmainitialize(void)
/* Attach and enable the common interrupt handler */
- ret = irq_attach(LPC17_IRQ_GPDMA, gpdma_interrupt);
+ ret = irq_attach(LPC17_IRQ_GPDMA, gpdma_interrupt, NULL);
if (ret == OK)
{
up_enable_irq(LPC17_IRQ_GPDMA);
diff --git a/arch/arm/src/lpc17xx/lpc17_gpioint.c b/arch/arm/src/lpc17xx/lpc17_gpioint.c
index 0c1ca613625b2ae110ff0369724eae64253b7c0e..fded5b5b51c88d2dd96b758a966645ae3befff01 100644
--- a/arch/arm/src/lpc17xx/lpc17_gpioint.c
+++ b/arch/arm/src/lpc17xx/lpc17_gpioint.c
@@ -402,7 +402,7 @@ static void lpc17_gpiodemux(uint32_t intbase, uint32_t intmask,
*
****************************************************************************/
-static int lpc17_gpiointerrupt(int irq, void *context)
+static int lpc17_gpiointerrupt(int irq, void *context, FAR void *arg)
{
/* Get the GPIO interrupt status */
@@ -468,7 +468,7 @@ void lpc17_gpioirqinitialize(void)
* position in the NVIC with External Interrupt 3
*/
- (void)irq_attach(LPC17_IRQ_EINT3, lpc17_gpiointerrupt);
+ (void)irq_attach(LPC17_IRQ_EINT3, lpc17_gpiointerrupt, NULL);
up_enable_irq(LPC17_IRQ_EINT3);
#elif defined(LPC178x)
@@ -476,7 +476,7 @@ void lpc17_gpioirqinitialize(void)
* GPIO2.
*/
- (void)irq_attach(LPC17_IRQ_GPIO, lpc17_gpiointerrupt);
+ (void)irq_attach(LPC17_IRQ_GPIO, lpc17_gpiointerrupt, NULL);
up_enable_irq(LPC17_IRQ_GPIO);
#endif
diff --git a/arch/arm/src/lpc17xx/lpc17_i2c.c b/arch/arm/src/lpc17xx/lpc17_i2c.c
index 554659818f5f926646d7760ef553b47c8d008ff0..30763fe177ac27c2fdfd1af72807fbb0c4b8978b 100644
--- a/arch/arm/src/lpc17xx/lpc17_i2c.c
+++ b/arch/arm/src/lpc17xx/lpc17_i2c.c
@@ -129,7 +129,7 @@ struct lpc17_i2cdev_s
static int lpc17_i2c_start(struct lpc17_i2cdev_s *priv);
static void lpc17_i2c_stop(struct lpc17_i2cdev_s *priv);
-static int lpc17_i2c_interrupt(int irq, FAR void *context);
+static int lpc17_i2c_interrupt(int irq, FAR void *context, void *arg);
static void lpc17_i2c_timeout(int argc, uint32_t arg, ...);
static void lpc17_i2c_setfrequency(struct lpc17_i2cdev_s *priv,
uint32_t frequency);
@@ -304,7 +304,7 @@ static int lpc17_i2c_transfer(FAR struct i2c_master_s *dev,
}
/****************************************************************************
- * Name: lpc17_i2c_interrupt
+ * Name: lpc17_stopnext
*
* Description:
* Check if we need to issue STOP at the next message
@@ -334,36 +334,13 @@ static void lpc17_stopnext(struct lpc17_i2cdev_s *priv)
*
****************************************************************************/
-static int lpc17_i2c_interrupt(int irq, FAR void *context)
+static int lpc17_i2c_interrupt(int irq, FAR void *context, void *arg)
{
- struct lpc17_i2cdev_s *priv;
+ struct lpc17_i2cdev_s *priv = (struct lpc17_i2cdev_s *)arg;
struct i2c_msg_s *msg;
uint32_t state;
-#ifdef CONFIG_LPC17_I2C0
- if (irq == LPC17_IRQ_I2C0)
- {
- priv = &g_i2c0dev;
- }
- else
-#endif
-#ifdef CONFIG_LPC17_I2C1
- if (irq == LPC17_IRQ_I2C1)
- {
- priv = &g_i2c1dev;
- }
- else
-#endif
-#ifdef CONFIG_LPC17_I2C2
- if (irq == LPC17_IRQ_I2C2)
- {
- priv = &g_i2c2dev;
- }
- else
-#endif
- {
- PANIC();
- }
+ DEBUGASSERT(priv != NULL);
/* Reference UM10360 19.10.5 */
@@ -608,7 +585,7 @@ struct i2c_master_s *lpc17_i2cbus_initialize(int port)
/* Attach Interrupt Handler */
- irq_attach(priv->irqid, lpc17_i2c_interrupt);
+ irq_attach(priv->irqid, lpc17_i2c_interrupt, priv);
/* Enable Interrupt Handler */
diff --git a/arch/arm/src/lpc17xx/lpc17_irq.c b/arch/arm/src/lpc17xx/lpc17_irq.c
index ac8fb8855cd54bb14c7e0e8ab7391dfc2990880b..01475fe57224ce9c5dde67f04d241cc7efe01f31 100644
--- a/arch/arm/src/lpc17xx/lpc17_irq.c
+++ b/arch/arm/src/lpc17xx/lpc17_irq.c
@@ -149,7 +149,7 @@ static void lpc17_dumpnvic(const char *msg, int irq)
****************************************************************************/
#ifdef CONFIG_DEBUG_FEATURES
-static int lpc17_nmi(int irq, FAR void *context)
+static int lpc17_nmi(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! NMI received\n");
@@ -157,7 +157,7 @@ static int lpc17_nmi(int irq, FAR void *context)
return 0;
}
-static int lpc17_busfault(int irq, FAR void *context)
+static int lpc17_busfault(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Bus fault recived\n");
@@ -165,7 +165,7 @@ static int lpc17_busfault(int irq, FAR void *context)
return 0;
}
-static int lpc17_usagefault(int irq, FAR void *context)
+static int lpc17_usagefault(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Usage fault received\n");
@@ -173,7 +173,7 @@ static int lpc17_usagefault(int irq, FAR void *context)
return 0;
}
-static int lpc17_pendsv(int irq, FAR void *context)
+static int lpc17_pendsv(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! PendSV received\n");
@@ -181,7 +181,7 @@ static int lpc17_pendsv(int irq, FAR void *context)
return 0;
}
-static int lpc17_dbgmonitor(int irq, FAR void *context)
+static int lpc17_dbgmonitor(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Debug Monitor received\n");
@@ -189,7 +189,7 @@ static int lpc17_dbgmonitor(int irq, FAR void *context)
return 0;
}
-static int lpc17_reserved(int irq, FAR void *context)
+static int lpc17_reserved(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Reserved interrupt\n");
@@ -371,8 +371,8 @@ void up_irqinitialize(void)
* under certain conditions.
*/
- irq_attach(LPC17_IRQ_SVCALL, up_svcall);
- irq_attach(LPC17_IRQ_HARDFAULT, up_hardfault);
+ irq_attach(LPC17_IRQ_SVCALL, up_svcall, NULL);
+ irq_attach(LPC17_IRQ_HARDFAULT, up_hardfault, NULL);
/* Set the priority of the SVCall interrupt */
@@ -388,22 +388,22 @@ void up_irqinitialize(void)
*/
#ifdef CONFIG_ARM_MPU
- irq_attach(LPC17_IRQ_MEMFAULT, up_memfault);
+ irq_attach(LPC17_IRQ_MEMFAULT, up_memfault, NULL);
up_enable_irq(LPC17_IRQ_MEMFAULT);
#endif
/* Attach all other processor exceptions (except reset and sys tick) */
#ifdef CONFIG_DEBUG_FEATURES
- irq_attach(LPC17_IRQ_NMI, lpc17_nmi);
+ irq_attach(LPC17_IRQ_NMI, lpc17_nmi, NULL);
#ifndef CONFIG_ARM_MPU
- irq_attach(LPC17_IRQ_MEMFAULT, up_memfault);
+ irq_attach(LPC17_IRQ_MEMFAULT, up_memfault, NULL);
#endif
- irq_attach(LPC17_IRQ_BUSFAULT, lpc17_busfault);
- irq_attach(LPC17_IRQ_USAGEFAULT, lpc17_usagefault);
- irq_attach(LPC17_IRQ_PENDSV, lpc17_pendsv);
- irq_attach(LPC17_IRQ_DBGMONITOR, lpc17_dbgmonitor);
- irq_attach(LPC17_IRQ_RESERVED, lpc17_reserved);
+ irq_attach(LPC17_IRQ_BUSFAULT, lpc17_busfault, NULL);
+ irq_attach(LPC17_IRQ_USAGEFAULT, lpc17_usagefault, NULL);
+ irq_attach(LPC17_IRQ_PENDSV, lpc17_pendsv, NULL);
+ irq_attach(LPC17_IRQ_DBGMONITOR, lpc17_dbgmonitor, NULL);
+ irq_attach(LPC17_IRQ_RESERVED, lpc17_reserved, NULL);
#endif
lpc17_dumpnvic("initial", LPC17_IRQ_NIRQS);
diff --git a/arch/arm/src/lpc17xx/lpc17_pwm.c b/arch/arm/src/lpc17xx/lpc17_pwm.c
index c284934570c5b8bde8741025052ba207cca0d616..df3be30a74a95a79911ea2983c238f66a6764b7a 100644
--- a/arch/arm/src/lpc17xx/lpc17_pwm.c
+++ b/arch/arm/src/lpc17xx/lpc17_pwm.c
@@ -350,7 +350,7 @@ static int pwm_interrupt(struct lpc17_pwmtimer_s *priv)
*
****************************************************************************/
-static int pwm_tim1interrupt(int irq, void *context)
+static int pwm_tim1interrupt(int irq, void *context, FAR void *arg)
{
return pwm_interrupt(&g_pwm1dev);
}
diff --git a/arch/arm/src/lpc17xx/lpc17_sdcard.c b/arch/arm/src/lpc17xx/lpc17_sdcard.c
index adf268f9d47bae74411f51e78be0101da270ce9c..56ab0965780cbb8992d69b855a7c5289ca62ad04 100644
--- a/arch/arm/src/lpc17xx/lpc17_sdcard.c
+++ b/arch/arm/src/lpc17xx/lpc17_sdcard.c
@@ -345,7 +345,7 @@ static void lpc17_endtransfer(struct lpc17_dev_s *priv, sdio_eventset_t wkupeven
/* Interrupt Handling *******************************************************/
-static int lpc17_interrupt(int irq, void *context);
+static int lpc17_interrupt(int irq, void *context, FAR void *arg);
/* SD Card Interface Methods ************************************************/
@@ -1203,7 +1203,7 @@ static void lpc17_endtransfer(struct lpc17_dev_s *priv, sdio_eventset_t wkupeven
*
****************************************************************************/
-static int lpc17_interrupt(int irq, void *context)
+static int lpc17_interrupt(int irq, void *context, FAR void *arg)
{
struct lpc17_dev_s *priv = &g_scard_dev;
uint32_t enabled;
@@ -1642,7 +1642,7 @@ static int lpc17_attach(FAR struct sdio_dev_s *dev)
/* Attach the SD card interrupt handler */
- ret = irq_attach(LPC17_IRQ_MCI, lpc17_interrupt);
+ ret = irq_attach(LPC17_IRQ_MCI, lpc17_interrupt, NULL);
if (ret == OK)
{
diff --git a/arch/arm/src/lpc17xx/lpc17_serial.c b/arch/arm/src/lpc17xx/lpc17_serial.c
index 7062c521f484b095a367934d9af96372b88aebcc..9c13a06d4a1986fdb323619b63eac69945ed8724 100644
--- a/arch/arm/src/lpc17xx/lpc17_serial.c
+++ b/arch/arm/src/lpc17xx/lpc17_serial.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/lpc17xx/lpc17_serial.c
*
- * Copyright (C) 2010-2013 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2010-2013, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
*
* Redistribution and use in source and binary forms, with or without
@@ -104,7 +104,7 @@ static int up_setup(struct uart_dev_s *dev);
static void up_shutdown(struct uart_dev_s *dev);
static int up_attach(struct uart_dev_s *dev);
static void up_detach(struct uart_dev_s *dev);
-static int up_interrupt(int irq, void *context);
+static int up_interrupt(int irq, void *context, void *arg);
static int up_ioctl(struct file *filep, int cmd, unsigned long arg);
static int up_receive(struct uart_dev_s *dev, uint32_t *status);
static void up_rxint(struct uart_dev_s *dev, bool enable);
@@ -999,7 +999,7 @@ static int up_attach(struct uart_dev_s *dev)
/* Attach and enable the IRQ */
- ret = irq_attach(priv->irq, up_interrupt);
+ ret = irq_attach(priv->irq, up_interrupt, dev);
if (ret == OK)
{
/* Enable the interrupt (RX and TX interrupts are still disabled
@@ -1041,44 +1041,14 @@ static void up_detach(struct uart_dev_s *dev)
*
****************************************************************************/
-static int up_interrupt(int irq, void *context)
+static int up_interrupt(int irq, void *context, void *arg)
{
- struct uart_dev_s *dev = NULL;
+ struct uart_dev_s *dev = (struct uart_dev_s *)arg;
struct up_dev_s *priv;
uint32_t status;
int passes;
-#ifdef CONFIG_LPC17_UART0
- if (g_uart0priv.irq == irq)
- {
- dev = &g_uart0port;
- }
- else
-#endif
-#ifdef CONFIG_LPC17_UART1
- if (g_uart1priv.irq == irq)
- {
- dev = &g_uart1port;
- }
- else
-#endif
-#ifdef CONFIG_LPC17_UART2
- if (g_uart2priv.irq == irq)
- {
- dev = &g_uart2port;
- }
- else
-#endif
-#ifdef CONFIG_LPC17_UART3
- if (g_uart3priv.irq == irq)
- {
- dev = &g_uart3port;
- }
- else
-#endif
- {
- PANIC();
- }
+ DEBUGASSERT(dev != NULL && dev->priv != NULL);
priv = (struct up_dev_s *)dev->priv;
/* Loop until there are no characters to be transferred or,
diff --git a/arch/arm/src/lpc17xx/lpc17_timerisr.c b/arch/arm/src/lpc17xx/lpc17_timerisr.c
index 4f6d318642b7da1f4f9af88a66cce30c9534f91a..bb98e712ae302f33a56811bb5bd83a772a009a8e 100644
--- a/arch/arm/src/lpc17xx/lpc17_timerisr.c
+++ b/arch/arm/src/lpc17xx/lpc17_timerisr.c
@@ -91,7 +91,7 @@
*
****************************************************************************/
-static int lpc17_timerisr(int irq, uint32_t *regs)
+static int lpc17_timerisr(int irq, uint32_t *regs, void *arg)
{
/* Process timer interrupt */
@@ -135,7 +135,7 @@ void arm_timer_initialize(void)
/* Attach the timer interrupt vector */
- (void)irq_attach(LPC17_IRQ_SYSTICK, (xcpt_t)lpc17_timerisr);
+ (void)irq_attach(LPC17_IRQ_SYSTICK, (xcpt_t)lpc17_timerisr, NULL);
/* Enable SysTick interrupts */
diff --git a/arch/arm/src/lpc17xx/lpc17_usbdev.c b/arch/arm/src/lpc17xx/lpc17_usbdev.c
index ca4d5f90d803456e10d95c415d41de0d3ed2eadd..5bcf3735b705e93fa72865d2b5884b8bf5530d61 100644
--- a/arch/arm/src/lpc17xx/lpc17_usbdev.c
+++ b/arch/arm/src/lpc17xx/lpc17_usbdev.c
@@ -421,7 +421,7 @@ static void lpc17_dispatchrequest(struct lpc17_usbdev_s *priv,
static inline void lpc17_ep0setup(struct lpc17_usbdev_s *priv);
static inline void lpc17_ep0dataoutinterrupt(struct lpc17_usbdev_s *priv);
static inline void lpc17_ep0dataininterrupt(struct lpc17_usbdev_s *priv);
-static int lpc17_usbinterrupt(int irq, FAR void *context);
+static int lpc17_usbinterrupt(int irq, FAR void *context, FAR void *arg);
#ifdef CONFIG_LPC17_USBDEV_DMA
static int lpc17_dmasetup(struct lpc17_usbdev_s *priv, uint8_t epphy,
@@ -2051,7 +2051,7 @@ static inline void lpc17_ep0dataininterrupt(struct lpc17_usbdev_s *priv)
*
****************************************************************************/
-static int lpc17_usbinterrupt(int irq, FAR void *context)
+static int lpc17_usbinterrupt(int irq, FAR void *context, FAR void *arg)
{
struct lpc17_usbdev_s *priv = &g_usbdev;
struct lpc17_ep_s *privep ;
@@ -3321,7 +3321,7 @@ void up_usbinitialize(void)
/* Attach USB controller interrupt handler */
- if (irq_attach(LPC17_IRQ_USB, lpc17_usbinterrupt) != 0)
+ if (irq_attach(LPC17_IRQ_USB, lpc17_usbinterrupt, NULL) != 0)
{
usbtrace(TRACE_DEVERROR(LPC17_TRACEERR_IRQREGISTRATION),
(uint16_t)LPC17_IRQ_USB);
diff --git a/arch/arm/src/lpc17xx/lpc17_usbhost.c b/arch/arm/src/lpc17xx/lpc17_usbhost.c
index e81f9f676ef33d0505cafd74c9bcc73035ab2fc3..42825b021322c652e1a14814994ac8ab7cabe2ce 100644
--- a/arch/arm/src/lpc17xx/lpc17_usbhost.c
+++ b/arch/arm/src/lpc17xx/lpc17_usbhost.c
@@ -347,7 +347,7 @@ static int lpc17_ctrltd(struct lpc17_usbhost_s *priv, struct lpc17_ed_s *ed,
/* Interrupt handling **********************************************************/
-static int lpc17_usbinterrupt(int irq, void *context);
+static int lpc17_usbinterrupt(int irq, void *context, FAR void *arg);
/* USB host controller operations **********************************************/
@@ -1633,7 +1633,7 @@ errout_with_xfrinfo:
*
****************************************************************************/
-static int lpc17_usbinterrupt(int irq, void *context)
+static int lpc17_usbinterrupt(int irq, void *context, FAR void *arg)
{
struct lpc17_usbhost_s *priv = &g_usbhost;
struct lpc17_ed_s *ed;
@@ -3844,7 +3844,7 @@ struct usbhost_connection_s *lpc17_usbhost_initialize(int controller)
/* Attach USB host controller interrupt handler */
- if (irq_attach(LPC17_IRQ_USB, lpc17_usbinterrupt) != 0)
+ if (irq_attach(LPC17_IRQ_USB, lpc17_usbinterrupt, NULL) != 0)
{
uerr("ERROR: Failed to attach IRQ\n");
return NULL;
diff --git a/arch/arm/src/lpc214x/lpc214x_serial.c b/arch/arm/src/lpc214x/lpc214x_serial.c
index e1b3511f9ca45dfa2eef6f85718a832aba4d08ae..92675a538be971ee9c5731128b1bfbcd2e4d3ecd 100644
--- a/arch/arm/src/lpc214x/lpc214x_serial.c
+++ b/arch/arm/src/lpc214x/lpc214x_serial.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/lpc214x/lpc214x_serial.c
*
- * Copyright (C) 2007-2009, 2012-2013 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2009, 2012-2013, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
*
* Redistribution and use in source and binary forms, with or without
@@ -88,7 +88,7 @@ static int up_setup(struct uart_dev_s *dev);
static void up_shutdown(struct uart_dev_s *dev);
static int up_attach(struct uart_dev_s *dev);
static void up_detach(struct uart_dev_s *dev);
-static int up_interrupt(int irq, void *context);
+static int up_interrupt(int irq, void *context, void *arg);
static int up_ioctl(struct file *filep, int cmd, unsigned long arg);
static int up_receive(struct uart_dev_s *dev, uint32_t *status);
static void up_rxint(struct uart_dev_s *dev, bool enable);
@@ -413,7 +413,7 @@ static int up_attach(struct uart_dev_s *dev)
/* Attach and enable the IRQ */
- ret = irq_attach(priv->irq, up_interrupt);
+ ret = irq_attach(priv->irq, up_interrupt, dev);
if (ret == OK)
{
/* Enable the interrupt (RX and TX interrupts are still disabled
@@ -456,25 +456,14 @@ static void up_detach(struct uart_dev_s *dev)
*
****************************************************************************/
-static int up_interrupt(int irq, void *context)
+static int up_interrupt(int irq, void *context, void *arg)
{
- struct uart_dev_s *dev = NULL;
+ struct uart_dev_s *dev = (struct uart_dev_s *)arg;
struct up_dev_s *priv;
uint8_t status;
int passes;
- if (g_uart1priv.irq == irq)
- {
- dev = &g_uart1port;
- }
- else if (g_uart0priv.irq == irq)
- {
- dev = &g_uart0port;
- }
- else
- {
- PANIC();
- }
+ DEBUGASSERT(dev != NULL && dev->priv != NULL);
priv = (struct up_dev_s *)dev->priv;
/* Loop until there are no characters to be transferred or,
diff --git a/arch/arm/src/lpc214x/lpc214x_timerisr.c b/arch/arm/src/lpc214x/lpc214x_timerisr.c
index 027dfa6e7e616e80a2197f5f455edbf6ad56c594..1d756d37d64ce3c6d972fb3f725d373ec9d7bf5e 100644
--- a/arch/arm/src/lpc214x/lpc214x_timerisr.c
+++ b/arch/arm/src/lpc214x/lpc214x_timerisr.c
@@ -87,7 +87,7 @@
#ifdef CONFIG_VECTORED_INTERRUPTS
static int lpc214x_timerisr(uint32_t *regs)
#else
-static int lpc214x_timerisr(int irq, uint32_t *regs)
+static int lpc214x_timerisr(int irq, uint32_t *regs, void *arg)
#endif
{
/* Process timer interrupt */
@@ -157,7 +157,7 @@ void arm_timer_initialize(void)
up_attach_vector(LPC214X_IRQ_SYSTIMER, LPC214X_SYSTIMER_VEC,
(vic_vector_t)lpc214x_timerisr);
#else
- (void)irq_attach(LPC214X_IRQ_SYSTIMER, (xcpt_t)lpc214x_timerisr);
+ (void)irq_attach(LPC214X_IRQ_SYSTIMER, (xcpt_t)lpc214x_timerisr, NULL);
#endif
/* And enable the timer interrupt */
diff --git a/arch/arm/src/lpc214x/lpc214x_usbdev.c b/arch/arm/src/lpc214x/lpc214x_usbdev.c
index 636c7391251bb145d0e7a9a68e0e6410fafa8279..c39324dc5ae7c0610d8823ccfee11aae4c313c1a 100644
--- a/arch/arm/src/lpc214x/lpc214x_usbdev.c
+++ b/arch/arm/src/lpc214x/lpc214x_usbdev.c
@@ -428,7 +428,7 @@ static void lpc214x_dispatchrequest(struct lpc214x_usbdev_s *priv,
static inline void lpc214x_ep0setup(struct lpc214x_usbdev_s *priv);
static inline void lpc214x_ep0dataoutinterrupt(struct lpc214x_usbdev_s *priv);
static inline void lpc214x_ep0dataininterrupt(struct lpc214x_usbdev_s *priv);
-static int lpc214x_usbinterrupt(int irq, FAR void *context);
+static int lpc214x_usbinterrupt(int irq, FAR void *context, FAR void *arg);
#ifdef CONFIG_LPC214X_USBDEV_DMA
static int lpc214x_dmasetup(struct lpc214x_usbdev_s *priv, uint8_t epphy,
@@ -2014,7 +2014,7 @@ static inline void lpc214x_ep0dataininterrupt(struct lpc214x_usbdev_s *priv)
*
****************************************************************************/
-static int lpc214x_usbinterrupt(int irq, FAR void *context)
+static int lpc214x_usbinterrupt(int irq, FAR void *context, FAR void *arg)
{
struct lpc214x_usbdev_s *priv = &g_usbdev;
struct lpc214x_ep_s *privep ;
@@ -3235,7 +3235,7 @@ void up_usbinitialize(void)
/* Attach USB controller interrupt handler */
- if (irq_attach(LPC214X_USB_IRQ, lpc214x_usbinterrupt) != 0)
+ if (irq_attach(LPC214X_USB_IRQ, lpc214x_usbinterrupt, NULL) != 0)
{
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_IRQREGISTRATION),
(uint16_t)LPC214X_USB_IRQ);
diff --git a/arch/arm/src/lpc2378/lpc23xx_i2c.c b/arch/arm/src/lpc2378/lpc23xx_i2c.c
index 5de046a39f92f319b703ce28457ca0cbecc2fa1e..8191179f110eaa411de90fcb3dfc7fd99dc6bbbb 100644
--- a/arch/arm/src/lpc2378/lpc23xx_i2c.c
+++ b/arch/arm/src/lpc2378/lpc23xx_i2c.c
@@ -134,7 +134,7 @@ struct lpc2378_i2cdev_s
static int lpc2378_i2c_start(struct lpc2378_i2cdev_s *priv);
static void lpc2378_i2c_stop(struct lpc2378_i2cdev_s *priv);
-static int lpc2378_i2c_interrupt(int irq, FAR void *context);
+static int lpc2378_i2c_interrupt(int irq, FAR void *context, FAR void *arg);
static void lpc2378_i2c_timeout(int argc, uint32_t arg, ...);
static void lpc2378_i2c_setfrequency(struct lpc2378_i2cdev_s *priv,
uint32_t frequency);
@@ -296,36 +296,13 @@ static void lpc2378_stopnext(struct lpc2378_i2cdev_s *priv)
*
****************************************************************************/
-static int lpc2378_i2c_interrupt(int irq, FAR void *context)
+static int lpc2378_i2c_interrupt(int irq, FAR void *context, FAR void *arg)
{
- struct lpc2378_i2cdev_s *priv;
+ struct lpc2378_i2cdev_s *priv = (struct lpc2378_i2cdev_s *)arg;
struct i2c_msg_s *msg;
uint32_t state;
-#ifdef CONFIG_LPC2378_I2C0
- if (irq == I2C0_IRQ)
- {
- priv = &g_i2c0dev;
- }
- else
-#endif
-#ifdef CONFIG_LPC2378_I2C1
- if (irq == I2C1_IRQ)
- {
- priv = &g_i2c1dev;
- }
- else
-#endif
-#ifdef CONFIG_LPC2378_I2C2
- if (irq == I2C2_IRQ)
- {
- priv = &g_i2c2dev;
- }
- else
-#endif
- {
- PANIC();
- }
+ DEBUGASSERT(priv != NULL);
/* Reference UM10360 19.10.5 */
@@ -619,7 +596,7 @@ struct i2c_master_s *lpc2378_i2cbus_initialize(int port)
/* Attach Interrupt Handler */
- irq_attach(priv->irqid, lpc2378_i2c_interrupt);
+ irq_attach(priv->irqid, lpc2378_i2c_interrupt, priv);
/* Enable Interrupt Handler */
diff --git a/arch/arm/src/lpc2378/lpc23xx_serial.c b/arch/arm/src/lpc2378/lpc23xx_serial.c
index 48e322ec15adf7545c81b12abf4ca7c286c80d92..c927b07a2c0f6a5827817f6f01c643f87d3bd537 100644
--- a/arch/arm/src/lpc2378/lpc23xx_serial.c
+++ b/arch/arm/src/lpc2378/lpc23xx_serial.c
@@ -96,7 +96,7 @@ static int up_setup(struct uart_dev_s *dev);
static void up_shutdown(struct uart_dev_s *dev);
static int up_attach(struct uart_dev_s *dev);
static void up_detach(struct uart_dev_s *dev);
-static int up_interrupt(int irq, void *context);
+static int up_interrupt(int irq, void *context, void *arg);
static int up_ioctl(struct file *filep, int cmd, unsigned long arg);
static int up_receive(struct uart_dev_s *dev, uint32_t * status);
static void up_rxint(struct uart_dev_s *dev, bool enable);
@@ -533,7 +533,7 @@ static int up_attach(struct uart_dev_s *dev)
/* Attach and enable the IRQ */
- ret = irq_attach(priv->irq, up_interrupt);
+ ret = irq_attach(priv->irq, up_interrupt, dev);
if (ret == OK)
{
/* Enable the interrupt (RX and TX interrupts are still disabled in the
@@ -581,25 +581,14 @@ static void up_detach(struct uart_dev_s *dev)
*
****************************************************************************/
-static int up_interrupt(int irq, void *context)
+static int up_interrupt(int irq, void *context, void *arg)
{
- struct uart_dev_s *dev = NULL;
+ struct uart_dev_s *dev = (struct uart_dev_s *)arg;
struct up_dev_s *priv;
uint8_t status;
int passes;
- if (g_uart0priv.irq == irq)
- {
- dev = &g_uart0port;
- }
- else if (g_uart2priv.irq == irq)
- {
- dev = &g_uart2port;
- }
- else
- {
- PANIC();
- }
+ DEBUGASSERT(dev != NULL && dev->priv != NULL);
priv = (struct up_dev_s *)dev->priv;
/* Loop until there are no characters to be transferred or, until we have
diff --git a/arch/arm/src/lpc2378/lpc23xx_timerisr.c b/arch/arm/src/lpc2378/lpc23xx_timerisr.c
index 6d85b07c0f26617d1d73ece58f817ff088576f42..1cbd4b650de545d249097912745128286cc4ece2 100644
--- a/arch/arm/src/lpc2378/lpc23xx_timerisr.c
+++ b/arch/arm/src/lpc2378/lpc23xx_timerisr.c
@@ -96,7 +96,7 @@
#ifdef CONFIG_VECTORED_INTERRUPTS
static int lpc23xx_timerisr(uint32_t * regs)
#else
-static int lpc23xx_timerisr(int irq, uint32_t * regs)
+static int lpc23xx_timerisr(int irq, uint32_t * regs, FAR void *arg)
#endif
{
static uint32_t tick;
@@ -189,7 +189,7 @@ void arm_timer_initialize(void)
#ifdef CONFIG_VECTORED_INTERRUPTS
up_attach_vector(IRQ_SYSTIMER, ???, (vic_vector_t) lpc23xx_timerisr);
#else
- (void)irq_attach(IRQ_SYSTIMER, (xcpt_t)lpc23xx_timerisr);
+ (void)irq_attach(IRQ_SYSTIMER, (xcpt_t)lpc23xx_timerisr, NULL);
#ifdef CONFIG_ARCH_IRQPRIO
up_prioritize_irq(IRQ_SYSTIMER, PRIORITY_HIGHEST);
#endif
diff --git a/arch/arm/src/lpc31xx/lpc31_cgudrvr.h b/arch/arm/src/lpc31xx/lpc31_cgudrvr.h
index 47a2e3917facff4cc17035eed122866235f42b70..8fbe96b88bf2b09fea47e9750f4c0472be2d921c 100644
--- a/arch/arm/src/lpc31xx/lpc31_cgudrvr.h
+++ b/arch/arm/src/lpc31xx/lpc31_cgudrvr.h
@@ -672,7 +672,7 @@ void lpc31_setfdiv(enum lpc31_domainid_e dmnid, enum lpc31_clockid_e clkid,
*
**************************************************************************************************/
-void lpc31_pllconfig(const struct lpc31_pllconfig_s * const cfg);
+void lpc31_pllconfig(const struct lpc31_pllconfig_s *const cfg);
/**********************************************************************************************
* Name: lpc31_hp0pllconfig
diff --git a/arch/arm/src/lpc31xx/lpc31_ehci.c b/arch/arm/src/lpc31xx/lpc31_ehci.c
index 345ec24dc632b3a73a5b3253cca8501d9e99ee98..475c4dea89d25df97bdeaf4aa8817e6e2f9dbebe 100644
--- a/arch/arm/src/lpc31xx/lpc31_ehci.c
+++ b/arch/arm/src/lpc31xx/lpc31_ehci.c
@@ -514,7 +514,7 @@ static inline void lpc31_portsc_bottomhalf(void);
static inline void lpc31_syserr_bottomhalf(void);
static inline void lpc31_async_advance_bottomhalf(void);
static void lpc31_ehci_bottomhalf(FAR void *arg);
-static int lpc31_ehci_interrupt(int irq, FAR void *context);
+static int lpc31_ehci_interrupt(int irq, FAR void *context, FAR void *arg);
/* USB Host Controller Operations **********************************************/
@@ -3357,7 +3357,7 @@ static void lpc31_ehci_bottomhalf(FAR void *arg)
*
****************************************************************************/
-static int lpc31_ehci_interrupt(int irq, FAR void *context)
+static int lpc31_ehci_interrupt(int irq, FAR void *context, FAR void *arg)
{
uint32_t usbsts;
uint32_t pending;
@@ -5282,7 +5282,7 @@ FAR struct usbhost_connection_s *lpc31_ehci_initialize(int controller)
/* Interrupt Configuration ***************************************************/
- ret = irq_attach(LPC31_IRQ_USBOTG, lpc31_ehci_interrupt);
+ ret = irq_attach(LPC31_IRQ_USBOTG, lpc31_ehci_interrupt, NULL);
if (ret != 0)
{
usbhost_trace1(EHCI_TRACE1_IRQATTACH_FAILED, LPC31_IRQ_USBOTG);
diff --git a/arch/arm/src/lpc31xx/lpc31_i2c.c b/arch/arm/src/lpc31xx/lpc31_i2c.c
index 1f27c4d1ff2987b15a157c1d0321e188c7698ed3..8d79ac56e3d2b3906913480ac8c3fb9c9d9f96aa 100644
--- a/arch/arm/src/lpc31xx/lpc31_i2c.c
+++ b/arch/arm/src/lpc31xx/lpc31_i2c.c
@@ -3,7 +3,7 @@
*
* Author: David Hewson
*
- * Copyright (C) 2010-2011, 2014, 2016 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2010-2011, 2014, 2016-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
*
* Redistribution and use in source and binary forms, with or without
@@ -112,7 +112,7 @@ static struct lpc31_i2cdev_s i2cdevices[2];
* Private Function Prototypes
****************************************************************************/
-static int i2c_interrupt(int irq, FAR void *context);
+static int i2c_interrupt(int irq, FAR void *context, FAR void *arg);
static void i2c_progress(struct lpc31_i2cdev_s *priv);
static void i2c_timeout(int argc, uint32_t arg, ...);
static void i2c_hwreset(struct lpc31_i2cdev_s *priv);
@@ -184,18 +184,12 @@ static void i2c_setfrequency(struct lpc31_i2cdev_s *priv, uint32_t frequency)
*
****************************************************************************/
-static int i2c_interrupt(int irq, FAR void *context)
+static int i2c_interrupt(int irq, FAR void *context, FAR void *arg)
{
- if (irq == LPC31_IRQ_I2C0)
- {
- i2c_progress(&i2cdevices[0]);
- }
-
- if (irq == LPC31_IRQ_I2C1)
- {
- i2c_progress(&i2cdevices[1]);
- }
+ struct lpc31_i2cdev_s *priv = (struct lpc31_i2cdev_s *)arg;
+ DEBUGASSERT(priv != NULL);
+ i2c_progress(priv);
return OK;
}
@@ -585,7 +579,7 @@ struct i2c_master_s *lpc31_i2cbus_initialize(int port)
/* Attach Interrupt Handler */
- irq_attach(priv->irqid, i2c_interrupt);
+ irq_attach(priv->irqid, i2c_interrupt, priv);
/* Enable Interrupt Handler */
diff --git a/arch/arm/src/lpc31xx/lpc31_serial.c b/arch/arm/src/lpc31xx/lpc31_serial.c
index bf5ac8cd5869fc895fc8245e7290b621cec4a8ab..fa5f3b4563fcd8d4dc10eebddbda04f2f9defb1a 100644
--- a/arch/arm/src/lpc31xx/lpc31_serial.c
+++ b/arch/arm/src/lpc31xx/lpc31_serial.c
@@ -88,7 +88,7 @@ static int up_setup(struct uart_dev_s *dev);
static void up_shutdown(struct uart_dev_s *dev);
static int up_attach(struct uart_dev_s *dev);
static void up_detach(struct uart_dev_s *dev);
-static int up_interrupt(int irq, void *context);
+static int up_interrupt(int irq, void *context, FAR void *arg);
static int up_ioctl(struct file *filep, int cmd, unsigned long arg);
static int up_receive(struct uart_dev_s *dev, uint32_t *status);
static void up_rxint(struct uart_dev_s *dev, bool enable);
@@ -444,7 +444,7 @@ static int up_attach(struct uart_dev_s *dev)
/* Attach and enable the IRQ */
- ret = irq_attach(LPC31_IRQ_UART, up_interrupt);
+ ret = irq_attach(LPC31_IRQ_UART, up_interrupt, NULL);
if (ret == OK)
{
/* Enable the interrupt (RX and TX interrupts are still disabled
@@ -482,7 +482,7 @@ static void up_detach(struct uart_dev_s *dev)
*
****************************************************************************/
-static int up_interrupt(int irq, void *context)
+static int up_interrupt(int irq, void *context, FAR void *arg)
{
struct uart_dev_s *dev = &g_uartport;
uint8_t status;
diff --git a/arch/arm/src/lpc31xx/lpc31_timerisr.c b/arch/arm/src/lpc31xx/lpc31_timerisr.c
index ab01f01ced3b0a3f07e8604d0a6a60fb2648aa24..9a4932b7a6901b2d45e2863a7afb7fbf5a21467f 100644
--- a/arch/arm/src/lpc31xx/lpc31_timerisr.c
+++ b/arch/arm/src/lpc31xx/lpc31_timerisr.c
@@ -66,7 +66,7 @@
*
****************************************************************************/
-static int lpc31_timerisr(int irq, uint32_t *regs)
+static int lpc31_timerisr(int irq, uint32_t *regs, void *arg)
{
/* Clear the lattched timer interrupt (Writing any value to the CLEAR register
* clears the interrupt generated by the counter timer
@@ -135,7 +135,7 @@ void arm_timer_initialize(void)
/* Attach the timer interrupt vector */
- (void)irq_attach(LPC31_IRQ_TMR0, (xcpt_t)lpc31_timerisr);
+ (void)irq_attach(LPC31_IRQ_TMR0, (xcpt_t)lpc31_timerisr, NULL);
/* Clear any latched timer interrupt (Writing any value to the CLEAR register
* clears the latched interrupt generated by the counter timer)
diff --git a/arch/arm/src/lpc31xx/lpc31_usbdev.c b/arch/arm/src/lpc31xx/lpc31_usbdev.c
index 1cc9ec0d38b146be0ac6d260a63aa0b8257bdc8e..90f877a1897769ec715b8d1b060b73a548213321 100644
--- a/arch/arm/src/lpc31xx/lpc31_usbdev.c
+++ b/arch/arm/src/lpc31xx/lpc31_usbdev.c
@@ -396,7 +396,7 @@ static void lpc31_ep0complete(struct lpc31_usbdev_s *priv, uint8_t epphy)
static void lpc31_ep0nak(struct lpc31_usbdev_s *priv, uint8_t epphy);
static bool lpc31_epcomplete(struct lpc31_usbdev_s *priv, uint8_t epphy);
-static int lpc31_usbinterrupt(int irq, FAR void *context);
+static int lpc31_usbinterrupt(int irq, FAR void *context, FAR void *arg);
/* Endpoint operations *********************************************************/
@@ -1677,7 +1677,7 @@ bool lpc31_epcomplete(struct lpc31_usbdev_s *priv, uint8_t epphy)
*
****************************************************************************/
-static int lpc31_usbinterrupt(int irq, FAR void *context)
+static int lpc31_usbinterrupt(int irq, FAR void *context, FAR void *arg)
{
struct lpc31_usbdev_s *priv = &g_usbdev;
uint32_t disr, portsc1, n;
@@ -2572,7 +2572,7 @@ void up_usbinitialize(void)
/* Attach USB controller interrupt handler */
- if (irq_attach(LPC31_IRQ_USBOTG, lpc31_usbinterrupt) != 0)
+ if (irq_attach(LPC31_IRQ_USBOTG, lpc31_usbinterrupt, NULL) != 0)
{
usbtrace(TRACE_DEVERROR(LPC31_TRACEERR_IRQREGISTRATION),
(uint16_t)LPC31_IRQ_USBOTG);
diff --git a/arch/arm/src/lpc43xx/lpc43_adc.c b/arch/arm/src/lpc43xx/lpc43_adc.c
index 2a9db4297d9c121deb015a6db25b21898d1ee3d7..42bfbac817b096e718b314b0a572725bf1aee2e4 100644
--- a/arch/arm/src/lpc43xx/lpc43_adc.c
+++ b/arch/arm/src/lpc43xx/lpc43_adc.c
@@ -141,7 +141,7 @@ static int adc_setup(FAR struct adc_dev_s *dev);
static void adc_shutdown(FAR struct adc_dev_s *dev);
static void adc_rxint(FAR struct adc_dev_s *dev, bool enable);
static int adc_ioctl(FAR struct adc_dev_s *dev, int cmd, unsigned long arg);
-static int adc_interrupt(int irq, void *context);
+static int adc_interrupt(int irq, void *context, FAR void *arg);
/****************************************************************************
* Private Data
@@ -351,7 +351,7 @@ static int adc_setup(FAR struct adc_dev_s *dev)
{
FAR struct up_dev_s *priv = (FAR struct up_dev_s *)dev->ad_priv;
- int ret = irq_attach(priv->irq, adc_interrupt);
+ int ret = irq_attach(priv->irq, adc_interrupt, NULL);
if (ret == OK)
{
up_enable_irq(priv->irq);
@@ -457,7 +457,7 @@ static int adc_ioctl(FAR struct adc_dev_s *dev, int cmd, unsigned long arg)
*
****************************************************************************/
-static int adc_interrupt(int irq, void *context)
+static int adc_interrupt(int irq, void *context, FAR void *arg)
{
FAR struct up_dev_s *priv = (FAR struct up_dev_s *)g_adcdev.ad_priv;
diff --git a/arch/arm/src/lpc43xx/lpc43_dac.c b/arch/arm/src/lpc43xx/lpc43_dac.c
index 51b7000def9c1df808a41d6bca37f802cf7c0634..0a81e41b2c5f49f82155e01f9743072994e6a9ec 100644
--- a/arch/arm/src/lpc43xx/lpc43_dac.c
+++ b/arch/arm/src/lpc43xx/lpc43_dac.c
@@ -89,7 +89,7 @@ static void dac_shutdown(FAR struct dac_dev_s *dev);
static void dac_txint(FAR struct dac_dev_s *dev, bool enable);
static int dac_send(FAR struct dac_dev_s *dev, FAR struct dac_msg_s *msg);
static int dac_ioctl(FAR struct dac_dev_s *dev, int cmd, unsigned long arg);
-static int dac_interrupt(int irq, void *context);
+static int dac_interrupt(int irq, void *context, FAR void *arg);
/****************************************************************************
* Private Data
@@ -177,7 +177,7 @@ static int dac_ioctl(FAR struct dac_dev_s *dev, int cmd, unsigned long arg)
return 0;
}
-static int dac_interrupt(int irq, void *context)
+static int dac_interrupt(int irq, void *context, FAR void *arg)
{
}
diff --git a/arch/arm/src/lpc43xx/lpc43_ehci.c b/arch/arm/src/lpc43xx/lpc43_ehci.c
index 2893369cedef1ef084af542faf75c6d8d2ed28a9..5af61fa9394394de44212814d05ce3621bfa6e46 100644
--- a/arch/arm/src/lpc43xx/lpc43_ehci.c
+++ b/arch/arm/src/lpc43xx/lpc43_ehci.c
@@ -505,7 +505,7 @@ static inline void lpc43_portsc_bottomhalf(void);
static inline void lpc43_syserr_bottomhalf(void);
static inline void lpc43_async_advance_bottomhalf(void);
static void lpc43_ehci_bottomhalf(FAR void *arg);
-static int lpc43_ehci_interrupt(int irq, FAR void *context);
+static int lpc43_ehci_interrupt(int irq, FAR void *context, FAR void *arg);
/* USB Host Controller Operations **********************************************/
@@ -3194,7 +3194,7 @@ static void lpc43_ehci_bottomhalf(FAR void *arg)
*
****************************************************************************/
-static int lpc43_ehci_interrupt(int irq, FAR void *context)
+static int lpc43_ehci_interrupt(int irq, FAR void *context, FAR void *arg)
{
uint32_t usbsts;
uint32_t pending;
@@ -5089,7 +5089,7 @@ FAR struct usbhost_connection_s *lpc43_ehci_initialize(int controller)
/* Interrupt Configuration ***************************************************/
- ret = irq_attach(LPC43M4_IRQ_USB0, lpc43_ehci_interrupt);
+ ret = irq_attach(LPC43M4_IRQ_USB0, lpc43_ehci_interrupt, NULL);
if (ret != 0)
{
usbhost_trace1(EHCI_TRACE1_IRQATTACH_FAILED, LPC43M4_IRQ_USB0);
diff --git a/arch/arm/src/lpc43xx/lpc43_ethernet.c b/arch/arm/src/lpc43xx/lpc43_ethernet.c
index f6f666c7ca55efe7fce83ca1884c349c25b93e13..c69b815b99dffe14e337cdd2ab70ece20b43e38b 100644
--- a/arch/arm/src/lpc43xx/lpc43_ethernet.c
+++ b/arch/arm/src/lpc43xx/lpc43_ethernet.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/lpc43/lpc43_eth.c
*
- * Copyright (C) 2011-2015 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2011-2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
*
* Redistribution and use in source and binary forms, with or without
@@ -519,7 +519,8 @@ struct lpc43_ethmac_s
uint8_t fduplex : 1; /* Full (vs. half) duplex */
WDOG_ID txpoll; /* TX poll timer */
WDOG_ID txtimeout; /* TX timeout timer */
- struct work_s work; /* For deferring work to the work queue */
+ struct work_s irqwork; /* For deferring work to the work queue */
+ struct work_s pollwork; /* For deferring work to the work queue */
/* This holds the information visible to the NuttX network */
@@ -594,7 +595,7 @@ static void lpc43_freeframe(FAR struct lpc43_ethmac_s *priv);
static void lpc43_txdone(FAR struct lpc43_ethmac_s *priv);
static void lpc43_interrupt_work(FAR void *arg);
-static int lpc43_interrupt(int irq, FAR void *context);
+static int lpc43_interrupt(int irq, FAR void *context, FAR void *arg);
/* Watchdog timer expirations */
@@ -1866,14 +1867,6 @@ static void lpc43_txdone(FAR struct lpc43_ethmac_s *priv)
wd_cancel(priv->txtimeout);
- /* Then make sure that the TX poll timer is running (if it is already
- * running, the following would restart it). This is necessary to
- * avoid certain race conditions where the polling sequence can be
- * interrupted.
- */
-
- (void)wd_start(priv->txpoll, LPC43_WDDELAY, lpc43_poll_expiry, 1, priv);
-
/* And disable further TX interrupts. */
lpc43_disableint(priv, ETH_DMAINT_TI);
@@ -2004,7 +1997,7 @@ static void lpc43_interrupt_work(FAR void *arg)
*
****************************************************************************/
-static int lpc43_interrupt(int irq, FAR void *context)
+static int lpc43_interrupt(int irq, FAR void *context, FAR void *arg)
{
FAR struct lpc43_ethmac_s *priv = &g_lpc43ethmac;
uint32_t dmasr;
@@ -2033,13 +2026,9 @@ static int lpc43_interrupt(int irq, FAR void *context)
wd_cancel(priv->txtimeout);
}
- /* Cancel any pending poll work */
-
- work_cancel(ETHWORK, &priv->work);
-
/* Schedule to perform the interrupt processing on the worker thread. */
- work_queue(ETHWORK, &priv->work, lpc43_interrupt_work, priv, 0);
+ work_queue(ETHWORK, &priv->irqwork, lpc43_interrupt_work, priv, 0);
}
return OK;
@@ -2114,15 +2103,11 @@ static void lpc43_txtimeout_expiry(int argc, uint32_t arg, ...)
up_disable_irq(LPC43M4_IRQ_ETHERNET);
- /* Cancel any pending poll or interrupt work. This will have no effect
- * on work that has already been started.
+ /* Schedule to perform the TX timeout processing on the worker thread,
+ * perhaps cancelling any pending IRQ processing.
*/
- work_cancel(ETHWORK, &priv->work);
-
- /* Schedule to perform the TX timeout processing on the worker thread. */
-
- work_queue(ETHWORK, &priv->work, lpc43_txtimeout_work, priv, 0);
+ work_queue(ETHWORK, &priv->irqwork, lpc43_txtimeout_work, priv, 0);
}
/****************************************************************************
@@ -2219,25 +2204,9 @@ static void lpc43_poll_expiry(int argc, uint32_t arg, ...)
{
FAR struct lpc43_ethmac_s *priv = (FAR struct lpc43_ethmac_s *)arg;
- /* Is our single work structure available? It may not be if there are
- * pending interrupt actions.
- */
-
- if (work_available(&priv->work))
- {
- /* Schedule to perform the interrupt processing on the worker thread. */
+ /* Schedule to perform the interrupt processing on the worker thread. */
- work_queue(ETHWORK, &priv->work, lpc43_poll_work, priv, 0);
- }
- else
- {
- /* No.. Just re-start the watchdog poll timer, missing one polling
- * cycle.
- */
-
- (void)wd_start(priv->txpoll, LPC43_WDDELAY, lpc43_poll_expiry, 1,
- (uint32_t)priv);
- }
+ work_queue(ETHWORK, &priv->pollwork, lpc43_poll_work, priv, 0);
}
/****************************************************************************
@@ -2406,11 +2375,11 @@ static int lpc43_txavail(struct net_driver_s *dev)
* availability action.
*/
- if (work_available(&priv->work))
+ if (work_available(&priv->pollwork))
{
/* Schedule to serialize the poll on the worker thread. */
- work_queue(ETHWORK, &priv->work, lpc43_txavail_work, priv, 0);
+ work_queue(ETHWORK, &priv->pollwork, lpc43_txavail_work, priv, 0);
}
return OK;
@@ -3861,7 +3830,7 @@ static inline int lpc43_ethinitialize(void)
/* Attach the IRQ to the driver */
- if (irq_attach(LPC43M4_IRQ_ETHERNET, lpc43_interrupt))
+ if (irq_attach(LPC43M4_IRQ_ETHERNET, lpc43_interrupt, NULL))
{
/* We could not attach the ISR to the interrupt */
diff --git a/arch/arm/src/lpc43xx/lpc43_gpdma.c b/arch/arm/src/lpc43xx/lpc43_gpdma.c
index ab2942189cd45708ea6d77ded671d97a3e15ad28..22c5213c2ef2586dbf9bbf7983bfdb60d9034a98 100644
--- a/arch/arm/src/lpc43xx/lpc43_gpdma.c
+++ b/arch/arm/src/lpc43xx/lpc43_gpdma.c
@@ -190,7 +190,7 @@ static void lpc43_dmadone(struct lpc43_dmach_s *dmach)
*
****************************************************************************/
-static int gpdma_interrupt(int irq, FAR void *context)
+static int gpdma_interrupt(int irq, FAR void *context, FAR void *arg)
{
struct lpc43_dmach_s *dmach;
uint32_t regval;
@@ -315,7 +315,7 @@ void weak_function up_dmainitialize(void)
/* Attach and enable the common interrupt handler */
- ret = irq_attach(LPC43M4_IRQ_DMA, gpdma_interrupt);
+ ret = irq_attach(LPC43M4_IRQ_DMA, gpdma_interrupt, NULL);
if (ret == OK)
{
up_enable_irq(LPC43M4_IRQ_DMA);
diff --git a/arch/arm/src/lpc43xx/lpc43_i2c.c b/arch/arm/src/lpc43xx/lpc43_i2c.c
index 49a77bb8b5114787ede6c2bae31d8abf4acbec28..2c8fcb63bee3161d9a2722f3cde266458fce24d6 100644
--- a/arch/arm/src/lpc43xx/lpc43_i2c.c
+++ b/arch/arm/src/lpc43xx/lpc43_i2c.c
@@ -130,7 +130,7 @@ static struct lpc43_i2cdev_s g_i2c1dev;
static int lpc43_i2c_start(struct lpc43_i2cdev_s *priv);
static void lpc43_i2c_stop(struct lpc43_i2cdev_s *priv);
-static int lpc43_i2c_interrupt(int irq, FAR void *context);
+static int lpc43_i2c_interrupt(int irq, FAR void *context, FAR void *arg);
static void lpc43_i2c_timeout(int argc, uint32_t arg, ...);
static void lpc43_i2c_setfrequency(struct lpc43_i2cdev_s *priv,
uint32_t frequency);
@@ -277,29 +277,13 @@ void lpc32_i2c_nextmsg(struct lpc43_i2cdev_s *priv)
*
****************************************************************************/
-static int lpc43_i2c_interrupt(int irq, FAR void *context)
+static int lpc43_i2c_interrupt(int irq, FAR void *context, FAR void *arg)
{
- struct lpc43_i2cdev_s *priv;
+ struct lpc43_i2cdev_s *priv = (struct lpc43_i2cdev_s *)arg;
struct i2c_msg_s *msg;
uint32_t state;
-#ifdef CONFIG_LPC43_I2C0
- if (irq == LPC43M0_IRQ_I2C0)
- {
- priv = &g_i2c0dev;
- }
- else
-#endif
-#ifdef CONFIG_LPC43_I2C1
- if (irq == LPC43_IRQ_I2C1)
- {
- priv = &g_i2c1dev;
- }
- else
-#endif
- {
- PANIC();
- }
+ DEBUGASSERT(priv != NULL);
/* Reference UM10360 19.10.5 */
@@ -558,7 +542,7 @@ struct i2c_master_s *lpc43_i2cbus_initialize(int port)
/* Attach Interrupt Handler */
- irq_attach(priv->irqid, lpc43_i2c_interrupt);
+ irq_attach(priv->irqid, lpc43_i2c_interrupt, priv);
/* Enable Interrupt Handler */
diff --git a/arch/arm/src/lpc43xx/lpc43_irq.c b/arch/arm/src/lpc43xx/lpc43_irq.c
index 09680bd9e9107f3d6e045c52079a42c51694ba6d..d51a8e48f71eaf0b54cfb13493519e2e906ccd67 100644
--- a/arch/arm/src/lpc43xx/lpc43_irq.c
+++ b/arch/arm/src/lpc43xx/lpc43_irq.c
@@ -154,7 +154,7 @@ static void lpc43_dumpnvic(const char *msg, int irq)
****************************************************************************/
#ifdef CONFIG_DEBUG_FEATURES
-static int lpc43_nmi(int irq, FAR void *context)
+static int lpc43_nmi(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! NMI received\n");
@@ -162,7 +162,7 @@ static int lpc43_nmi(int irq, FAR void *context)
return 0;
}
-static int lpc43_busfault(int irq, FAR void *context)
+static int lpc43_busfault(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Bus fault recived\n");
@@ -170,7 +170,7 @@ static int lpc43_busfault(int irq, FAR void *context)
return 0;
}
-static int lpc43_usagefault(int irq, FAR void *context)
+static int lpc43_usagefault(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Usage fault received\n");
@@ -178,7 +178,7 @@ static int lpc43_usagefault(int irq, FAR void *context)
return 0;
}
-static int lpc43_pendsv(int irq, FAR void *context)
+static int lpc43_pendsv(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! PendSV received\n");
@@ -186,7 +186,7 @@ static int lpc43_pendsv(int irq, FAR void *context)
return 0;
}
-static int lpc43_dbgmonitor(int irq, FAR void *context)
+static int lpc43_dbgmonitor(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Debug Monitor received\n");
@@ -194,7 +194,7 @@ static int lpc43_dbgmonitor(int irq, FAR void *context)
return 0;
}
-static int lpc43_reserved(int irq, FAR void *context)
+static int lpc43_reserved(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Reserved interrupt\n");
@@ -364,8 +364,8 @@ void up_irqinitialize(void)
* under certain conditions.
*/
- irq_attach(LPC43_IRQ_SVCALL, up_svcall);
- irq_attach(LPC43_IRQ_HARDFAULT, up_hardfault);
+ irq_attach(LPC43_IRQ_SVCALL, up_svcall, NULL);
+ irq_attach(LPC43_IRQ_HARDFAULT, up_hardfault, NULL);
/* Set the priority of the SVCall interrupt */
@@ -381,22 +381,22 @@ void up_irqinitialize(void)
*/
#ifdef CONFIG_ARM_MPU
- irq_attach(LPC43_IRQ_MEMFAULT, up_memfault);
+ irq_attach(LPC43_IRQ_MEMFAULT, up_memfault, NULL);
up_enable_irq(LPC43_IRQ_MEMFAULT);
#endif
/* Attach all other processor exceptions (except reset and sys tick) */
#ifdef CONFIG_DEBUG_FEATURES
- irq_attach(LPC43_IRQ_NMI, lpc43_nmi);
+ irq_attach(LPC43_IRQ_NMI, lpc43_nmi, NULL);
#ifndef CONFIG_ARM_MPU
- irq_attach(LPC43_IRQ_MEMFAULT, up_memfault);
+ irq_attach(LPC43_IRQ_MEMFAULT, up_memfault, NULL);
#endif
- irq_attach(LPC43_IRQ_BUSFAULT, lpc43_busfault);
- irq_attach(LPC43_IRQ_USAGEFAULT, lpc43_usagefault);
- irq_attach(LPC43_IRQ_PENDSV, lpc43_pendsv);
- irq_attach(LPC43_IRQ_DBGMONITOR, lpc43_dbgmonitor);
- irq_attach(LPC43_IRQ_RESERVED, lpc43_reserved);
+ irq_attach(LPC43_IRQ_BUSFAULT, lpc43_busfault, NULL);
+ irq_attach(LPC43_IRQ_USAGEFAULT, lpc43_usagefault, NULL);
+ irq_attach(LPC43_IRQ_PENDSV, lpc43_pendsv, NULL);
+ irq_attach(LPC43_IRQ_DBGMONITOR, lpc43_dbgmonitor, NULL);
+ irq_attach(LPC43_IRQ_RESERVED, lpc43_reserved, NULL);
#endif
lpc43_dumpnvic("initial", LPC43M4_IRQ_NIRQS);
diff --git a/arch/arm/src/lpc43xx/lpc43_rit.c b/arch/arm/src/lpc43xx/lpc43_rit.c
index c0bf633256f7de2a191967f33fb94c09649c50ba..c39e4b7a3830850657be26460f77095de8a53bc1 100644
--- a/arch/arm/src/lpc43xx/lpc43_rit.c
+++ b/arch/arm/src/lpc43xx/lpc43_rit.c
@@ -86,7 +86,7 @@ struct timespec g_ts;
* Private Functions
****************************************************************************/
-static int lpc43_RIT_isr(int irq, FAR void *context)
+static int lpc43_RIT_isr(int irq, FAR void *context, FAR void *arg)
{
irqstate_t flags;
@@ -166,7 +166,7 @@ void arm_timer_initialize(void)
/* Set up the IRQ here */
- irq_attach(LPC43M4_IRQ_RITIMER, lpc43_RIT_isr);
+ irq_attach(LPC43M4_IRQ_RITIMER, lpc43_RIT_isr, NULL);
/* Compute how many seconds per tick we have on the main clock. If it is
* 204MHz for example, then there should be about 4.90ns per tick
diff --git a/arch/arm/src/lpc43xx/lpc43_serial.c b/arch/arm/src/lpc43xx/lpc43_serial.c
index 7fb42ee0353d2a6d11cc8ed77785bc4ac3badf9e..bf3e9613bfbd36eefa73e0d12692add61740611c 100644
--- a/arch/arm/src/lpc43xx/lpc43_serial.c
+++ b/arch/arm/src/lpc43xx/lpc43_serial.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/lpc43xx/lpc43_serial.c
*
- * Copyright (C) 2012-2013, 2016 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2012-2013, 2016-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
*
* Redistribution and use in source and binary forms, with or without
@@ -106,7 +106,7 @@ static int up_setup(struct uart_dev_s *dev);
static void up_shutdown(struct uart_dev_s *dev);
static int up_attach(struct uart_dev_s *dev);
static void up_detach(struct uart_dev_s *dev);
-static int up_interrupt(int irq, void *context);
+static int up_interrupt(int irq, void *context, void *arg);
static int up_ioctl(struct file *filep, int cmd, unsigned long arg);
#ifdef HAVE_RS485
static inline int up_set_rs485_mode(struct up_dev_s *priv,
@@ -661,7 +661,7 @@ static int up_attach(struct uart_dev_s *dev)
/* Attach and enable the IRQ */
- ret = irq_attach(priv->irq, up_interrupt);
+ ret = irq_attach(priv->irq, up_interrupt, dev);
if (ret == OK)
{
/* Enable the interrupt (RX and TX interrupts are still disabled
@@ -702,44 +702,14 @@ static void up_detach(struct uart_dev_s *dev)
*
****************************************************************************/
-static int up_interrupt(int irq, void *context)
+static int up_interrupt(int irq, void *context, void *arg)
{
- struct uart_dev_s *dev = NULL;
+ struct uart_dev_s *dev = (struct uart_dev_s *)arg;
struct up_dev_s *priv;
uint32_t status;
int passes;
-#ifdef CONFIG_LPC43_USART0
- if (g_usart0priv.irq == irq)
- {
- dev = &g_usart0port;
- }
- else
-#endif
-#ifdef CONFIG_LPC43_UART1
- if (g_uart1priv.irq == irq)
- {
- dev = &g_uart1port;
- }
- else
-#endif
-#ifdef CONFIG_LPC43_USART2
- if (g_usart2priv.irq == irq)
- {
- dev = &g_usart2port;
- }
- else
-#endif
-#ifdef CONFIG_LPC43_USART3
- if (g_usart3priv.irq == irq)
- {
- dev = &g_usart3port;
- }
- else
-#endif
- {
- PANIC();
- }
+ DEBUGASSERT(dev != NULL && dev->priv != NULL);
priv = (struct up_dev_s *)dev->priv;
/* Loop until there are no characters to be transferred or,
diff --git a/arch/arm/src/lpc43xx/lpc43_tickless_rit.c b/arch/arm/src/lpc43xx/lpc43_tickless_rit.c
index ce0f7d6375956c96a79100eef545dfbeb78128a8..cacfb47c91b0a6a3c955dda7b7cc0c7f34b09968 100644
--- a/arch/arm/src/lpc43xx/lpc43_tickless_rit.c
+++ b/arch/arm/src/lpc43xx/lpc43_tickless_rit.c
@@ -536,7 +536,7 @@ static inline void lpc43_tl_alarm(uint32_t curr)
/* Interrupt handler */
-static int lpc43_tl_isr(int irq, FAR void *context)
+static int lpc43_tl_isr(int irq, FAR void *context, FAR void *arg)
{
lpc43_tl_sync_up();
@@ -624,7 +624,7 @@ void arm_timer_initialize(void)
lpc43_tl_set_reset_on_match(false);
lpc43_tl_clear_interrupt();
- irq_attach(LPC43M4_IRQ_RITIMER, lpc43_tl_isr);
+ irq_attach(LPC43M4_IRQ_RITIMER, lpc43_tl_isr, NULL);
up_enable_irq(LPC43M4_IRQ_RITIMER);
lpc43_tl_init_timer_vars();
diff --git a/arch/arm/src/lpc43xx/lpc43_timer.c b/arch/arm/src/lpc43xx/lpc43_timer.c
index 0d8b35c9110b222fc7fe20c1bf3676dae4314ed0..decc110dd49998f13405d6b8e049fe1497d5e766 100644
--- a/arch/arm/src/lpc43xx/lpc43_timer.c
+++ b/arch/arm/src/lpc43xx/lpc43_timer.c
@@ -113,7 +113,7 @@ static void lpc43_putreg(uint32_t val, uint32_t addr);
/* Interrupt handling *******************************************************/
-static int lpc43_interrupt(int irq, FAR void *context);
+static int lpc43_interrupt(int irq, FAR void *context, FAR void *arg);
/* "Lower half" driver methods **********************************************/
@@ -336,7 +336,7 @@ void tmr_clk_disable(uint16_t tmrid)
*
****************************************************************************/
-static int lpc43_interrupt(int irq, FAR void *context)
+static int lpc43_interrupt(int irq, FAR void *context, FAR void *arg)
{
uint8_t chan_int = 0x0f;
FAR struct lpc43_lowerhalf_s *priv = &g_tmrdevs[irq-LPC43M4_IRQ_TIMER0];
@@ -757,7 +757,7 @@ void lpc43_tmrinitialize(FAR const char *devpath, int irq)
priv->ops = &g_tmrops;
- (void)irq_attach(irq, lpc43_interrupt);
+ (void)irq_attach(irq, lpc43_interrupt, NULL);
/* Enable NVIC interrupt. */
diff --git a/arch/arm/src/lpc43xx/lpc43_timerisr.c b/arch/arm/src/lpc43xx/lpc43_timerisr.c
index 8b02b4c0991e674c5a8998d87cb17b72dd37c32d..a76cd54dc362f9cc994b23952e4c436ad5690e2a 100644
--- a/arch/arm/src/lpc43xx/lpc43_timerisr.c
+++ b/arch/arm/src/lpc43xx/lpc43_timerisr.c
@@ -90,7 +90,7 @@
*
****************************************************************************/
-static int lpc43_timerisr(int irq, uint32_t *regs)
+static int lpc43_timerisr(int irq, uint32_t *regs, void *arg)
{
/* Process timer interrupt */
@@ -134,7 +134,7 @@ void arm_timer_initialize(void)
/* Attach the timer interrupt vector */
- (void)irq_attach(LPC43_IRQ_SYSTICK, (xcpt_t)lpc43_timerisr);
+ (void)irq_attach(LPC43_IRQ_SYSTICK, (xcpt_t)lpc43_timerisr, NULL);
/* Enable SysTick interrupts */
diff --git a/arch/arm/src/lpc43xx/lpc43_usb0dev.c b/arch/arm/src/lpc43xx/lpc43_usb0dev.c
index c583dd30a1854a803bcbd1506dab1fa5121d5bb3..26bb600270b1c726c68ff0a11d1cef867da44438 100644
--- a/arch/arm/src/lpc43xx/lpc43_usb0dev.c
+++ b/arch/arm/src/lpc43xx/lpc43_usb0dev.c
@@ -415,7 +415,7 @@ static void lpc43_ep0complete(struct lpc43_usbdev_s *priv, uint8_t epphy)
static void lpc43_ep0nak(struct lpc43_usbdev_s *priv, uint8_t epphy);
static bool lpc43_epcomplete(struct lpc43_usbdev_s *priv, uint8_t epphy);
-static int lpc43_usbinterrupt(int irq, FAR void *context);
+static int lpc43_usbinterrupt(int irq, FAR void *context, FAR void *arg);
/* Endpoint operations *********************************************************/
@@ -1766,7 +1766,7 @@ bool lpc43_epcomplete(struct lpc43_usbdev_s *priv, uint8_t epphy)
*
****************************************************************************/
-static int lpc43_usbinterrupt(int irq, FAR void *context)
+static int lpc43_usbinterrupt(int irq, FAR void *context, FAR void *arg)
{
struct lpc43_usbdev_s *priv = &g_usbdev;
uint32_t disr, portsc1, n;
@@ -2722,7 +2722,7 @@ void up_usbinitialize(void)
/* Attach USB controller interrupt handler */
- irq_attach(LPC43M4_IRQ_USB0, lpc43_usbinterrupt);
+ irq_attach(LPC43M4_IRQ_USB0, lpc43_usbinterrupt, NULL);
up_enable_irq(LPC43M4_IRQ_USB0);
leave_critical_section(flags);
diff --git a/arch/arm/src/moxart/moxart_irq.c b/arch/arm/src/moxart/moxart_irq.c
index 31ed83c80fbd7e4f30676dde8401e6c18fee3097..b81baeab21bf5c67bb464cc2243d30bfa6ac2be0 100644
--- a/arch/arm/src/moxart/moxart_irq.c
+++ b/arch/arm/src/moxart/moxart_irq.c
@@ -138,7 +138,7 @@ void up_irqinitialize(void)
/* Setup UART shared interrupt */
- irq_attach(CONFIG_UART_MOXA_SHARED_IRQ, uart_decodeirq);
+ irq_attach(CONFIG_UART_MOXA_SHARED_IRQ, uart_decodeirq, NULL);
up_enable_irq(CONFIG_UART_MOXA_SHARED_IRQ);
/* And finally, enable interrupts */
diff --git a/arch/arm/src/moxart/moxart_timer.c b/arch/arm/src/moxart/moxart_timer.c
index 1b281f05dd0963de0fde5108048c5e4b29d84632..afc79e4d513405f9bbaff026f5d8bfd5211c325b 100644
--- a/arch/arm/src/moxart/moxart_timer.c
+++ b/arch/arm/src/moxart/moxart_timer.c
@@ -98,7 +98,7 @@ static uint32_t cmp = BOARD_32KOSC_FREQUENCY / 100;
*
****************************************************************************/
-static int moxart_timerisr(int irq, uint32_t *regs)
+static int moxart_timerisr(int irq, uint32_t *regs, void *arg)
{
uint32_t state;
@@ -148,7 +148,7 @@ void arm_timer_initialize(void)
/* Attach and enable the timer interrupt */
- irq_attach(IRQ_SYSTIMER, (xcpt_t)moxart_timerisr);
+ irq_attach(IRQ_SYSTIMER, (xcpt_t)moxart_timerisr, NULL);
up_enable_irq(IRQ_SYSTIMER);
ftintc010_set_trig_mode(IRQ_SYSTIMER, 1);
ftintc010_set_trig_level(IRQ_SYSTIMER, 0);
diff --git a/arch/arm/src/nuc1xx/nuc_irq.c b/arch/arm/src/nuc1xx/nuc_irq.c
index 66f6d78044d7993b62f0dc63cfd566a17ca2d015..6fc6db1d2f5629ada2e7a8b44b8ba2465b2ebe92 100644
--- a/arch/arm/src/nuc1xx/nuc_irq.c
+++ b/arch/arm/src/nuc1xx/nuc_irq.c
@@ -138,7 +138,7 @@ static void nuc_dumpnvic(const char *msg, int irq)
****************************************************************************/
#ifdef CONFIG_DEBUG_FEATURES
-static int nuc_nmi(int irq, FAR void *context)
+static int nuc_nmi(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! NMI received\n");
@@ -146,7 +146,7 @@ static int nuc_nmi(int irq, FAR void *context)
return 0;
}
-static int nuc_pendsv(int irq, FAR void *context)
+static int nuc_pendsv(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! PendSV received\n");
@@ -154,7 +154,7 @@ static int nuc_pendsv(int irq, FAR void *context)
return 0;
}
-static int nuc_reserved(int irq, FAR void *context)
+static int nuc_reserved(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Reserved interrupt\n");
@@ -231,15 +231,15 @@ void up_irqinitialize(void)
* under certain conditions.
*/
- irq_attach(NUC_IRQ_SVCALL, up_svcall);
- irq_attach(NUC_IRQ_HARDFAULT, up_hardfault);
+ irq_attach(NUC_IRQ_SVCALL, up_svcall, NULL);
+ irq_attach(NUC_IRQ_HARDFAULT, up_hardfault, NULL);
/* Attach all other processor exceptions (except reset and sys tick) */
#ifdef CONFIG_DEBUG_FEATURES
- irq_attach(NUC_IRQ_NMI, nuc_nmi);
- irq_attach(NUC_IRQ_PENDSV, nuc_pendsv);
- irq_attach(NUC_IRQ_RESERVED, nuc_reserved);
+ irq_attach(NUC_IRQ_NMI, nuc_nmi, NULL);
+ irq_attach(NUC_IRQ_PENDSV, nuc_pendsv, NULL);
+ irq_attach(NUC_IRQ_RESERVED, nuc_reserved, NULL);
#endif
nuc_dumpnvic("initial", NR_IRQS);
diff --git a/arch/arm/src/nuc1xx/nuc_serial.c b/arch/arm/src/nuc1xx/nuc_serial.c
index a098db77ce35c7cb69b9d561db051121a1da4f73..0932cfaf99d3dbc155b5220f8aafe6cdcf399494 100644
--- a/arch/arm/src/nuc1xx/nuc_serial.c
+++ b/arch/arm/src/nuc1xx/nuc_serial.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/nuc1xx/nuc_serial.c
*
- * Copyright (C) 2013 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2013, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
*
* Redistribution and use in source and binary forms, with or without
@@ -101,7 +101,7 @@ static int up_setup(struct uart_dev_s *dev);
static void up_shutdown(struct uart_dev_s *dev);
static int up_attach(struct uart_dev_s *dev);
static void up_detach(struct uart_dev_s *dev);
-static int up_interrupt(int irq, void *context);
+static int up_interrupt(int irq, void *context, void *arg);
static int up_ioctl(struct file *filep, int cmd, unsigned long arg);
static int up_receive(struct uart_dev_s *dev, uint32_t *status);
static void up_rxint(struct uart_dev_s *dev, bool enable);
@@ -568,7 +568,7 @@ static int up_attach(struct uart_dev_s *dev)
/* Attach and enable the IRQ */
- ret = irq_attach(priv->irq, up_interrupt);
+ ret = irq_attach(priv->irq, up_interrupt, dev);
if (ret == OK)
{
/* Enable the interrupt (RX and TX interrupts are still disabled
@@ -610,9 +610,9 @@ static void up_detach(struct uart_dev_s *dev)
*
****************************************************************************/
-static int up_interrupt(int irq, void *context)
+static int up_interrupt(int irq, void *context, void *arg)
{
- struct uart_dev_s *dev = NULL;
+ struct uart_dev_s *dev = (struct uart_dev_s *)arg;
struct nuc_dev_s *priv;
uint32_t isr;
uint32_t regval;
@@ -620,30 +620,7 @@ static int up_interrupt(int irq, void *context)
bool rxto;
bool rxfe;
-#ifdef CONFIG_NUC_UART0
- if (g_uart0priv.irq == irq)
- {
- dev = &g_uart0port;
- }
- else
-#endif
-#ifdef CONFIG_NUC_UART1
- if (g_uart1priv.irq == irq)
- {
- dev = &g_uart1port;
- }
- else
-#endif
-#ifdef CONFIG_NUC_UART2
- if (g_uart2priv.irq == irq)
- {
- dev = &g_uart2port;
- }
- else
-#endif
- {
- PANIC();
- }
+ DEBUGASSERT(dev != NULL && dev->priv != NULL);
priv = (struct nuc_dev_s *)dev->priv;
/* Loop until there are no characters to be transferred or,
diff --git a/arch/arm/src/nuc1xx/nuc_timerisr.c b/arch/arm/src/nuc1xx/nuc_timerisr.c
index c32dcc66c038848bd17c30eced037737ade3e8a5..02b99ba9ae7d68784e3cba30753e6d0bcf1bce2b 100644
--- a/arch/arm/src/nuc1xx/nuc_timerisr.c
+++ b/arch/arm/src/nuc1xx/nuc_timerisr.c
@@ -156,7 +156,7 @@ static inline void nuc_lock(void)
*
****************************************************************************/
-static int nuc_timerisr(int irq, uint32_t *regs)
+static int nuc_timerisr(int irq, uint32_t *regs, void *arg)
{
/* Process timer interrupt */
@@ -226,7 +226,7 @@ void arm_timer_initialize(void)
/* Attach the timer interrupt vector */
- (void)irq_attach(NUC_IRQ_SYSTICK, (xcpt_t)nuc_timerisr);
+ (void)irq_attach(NUC_IRQ_SYSTICK, (xcpt_t)nuc_timerisr, NULL);
/* Enable SysTick interrupts. We need to select the core clock here if
* we are not using one of the alternative clock sources above.
diff --git a/arch/arm/src/sam34/sam4cm_cpupause.c b/arch/arm/src/sam34/sam4cm_cpupause.c
index daf6fd76b4e53808a061c157056d3ea70424f731..f2587811276144e520be94c6a9baad5aa5af40f1 100644
--- a/arch/arm/src/sam34/sam4cm_cpupause.c
+++ b/arch/arm/src/sam34/sam4cm_cpupause.c
@@ -203,7 +203,7 @@ int up_cpu_paused(int cpu)
*
****************************************************************************/
-int arm_pause_handler(int irq, void *c)
+int arm_pause_handler(int irq, void *c, FAR void *arg)
{
int cpu = up_cpu_index();
diff --git a/arch/arm/src/sam34/sam4cm_cpustart.c b/arch/arm/src/sam34/sam4cm_cpustart.c
index f8544abf7fcd58c21965b28f416f126f52c092e1..3f6a4c6a19473dbdc6e592c763837b76d228dbc3 100644
--- a/arch/arm/src/sam34/sam4cm_cpustart.c
+++ b/arch/arm/src/sam34/sam4cm_cpustart.c
@@ -80,7 +80,7 @@
****************************************************************************/
volatile static spinlock_t g_cpu1_boot;
-extern int arm_pause_handler(int irq, void *c);
+extern int arm_pause_handler(int irq, void *c, FAR void *arg);
/****************************************************************************
* Name: cpu1_boot
@@ -120,7 +120,7 @@ static void cpu1_boot(void)
/* Enable : write-only */
putreg32(0x1, SAM_IPC1_IECR);
- irq_attach(SAM_IRQ_IPC1, arm_pause_handler);
+ irq_attach(SAM_IRQ_IPC1, arm_pause_handler, NULL);
up_enable_irq(SAM_IRQ_IPC1);
}
@@ -229,7 +229,7 @@ int up_cpu_start(int cpu)
sam_ipc0_enableclk();
putreg32(0x1, SAM_IPC0_ICCR); /* clear : write-only */
putreg32(0x1, SAM_IPC0_IECR); /* enable : write-only */
- irq_attach(SAM_IRQ_IPC0, arm_pause_handler);
+ irq_attach(SAM_IRQ_IPC0, arm_pause_handler, NULL);
up_enable_irq(SAM_IRQ_IPC0);
spin_lock(&g_cpu1_boot);
diff --git a/arch/arm/src/sam34/sam4cm_tc.c b/arch/arm/src/sam34/sam4cm_tc.c
index d10ac3310128523837b66015e77000a9ad0b6f4d..c366118f4d02a56397a2a45c1a6ec27912de1cab 100644
--- a/arch/arm/src/sam34/sam4cm_tc.c
+++ b/arch/arm/src/sam34/sam4cm_tc.c
@@ -147,8 +147,7 @@ static inline void sam_chan_putreg(struct sam_chan_s *chan,
/* Interrupt Handling *******************************************************/
-static int sam_tc_interrupt(struct sam_chan_s *tc);
-static int sam_raw_interrupt(int irq, void *context);
+static int sam_tc_interrupt(int irq, void *context, FAR void *arg);
/* Initialization ***********************************************************/
@@ -535,14 +534,17 @@ static inline void sam_chan_putreg(struct sam_chan_s *chan, unsigned int offset,
*
****************************************************************************/
-static int sam_tc_interrupt(struct sam_chan_s *chan)
+static int sam_tc_interrupt(int irq, void *context, FAR void *arg)
{
+ struct sam_chan_s *chan = (struct sam_chan_s *)arg;
uint32_t sr;
uint32_t imr;
uint32_t pending;
/* Process interrupts */
+ DEBUGASSERT(chan != NULL);
+
/* Get the interrupt status for this channel */
sr = sam_chan_getreg(chan, SAM_TC_SR_OFFSET);
@@ -575,41 +577,10 @@ static int sam_tc_interrupt(struct sam_chan_s *chan)
return OK;
}
-/****************************************************************************
- * Name: sam_raw_interrupt
- *
- * Description:
- * Timer block interrupt handlers
- *
- * Input Parameters:
- * irq
- * context
- *
- * Returned Value:
- *
- ****************************************************************************/
-
-static int sam_raw_interrupt(int irq, void *context)
-{
- int i;
- struct sam_chan_s *chan;
-
- for (i = 0; i < ENABLED_CHANNELS; i++)
- {
- chan = &g_channels[i];
-
- if (chan->irq == irq)
- {
- return sam_tc_interrupt(chan);
- }
- }
-
- return OK;
-}
-
/****************************************************************************
* Initialization
****************************************************************************/
+
/****************************************************************************
* Name: sam_tc_mckdivider
*
@@ -816,7 +787,7 @@ static inline struct sam_chan_s *sam_tc_initialize(int channel)
/* Attach the timer interrupt handler and enable the timer interrupts */
- (void)irq_attach(chan->irq, sam_raw_interrupt);
+ (void)irq_attach(chan->irq, sam_tc_interrupt, chan);
up_enable_irq(chan->irq);
/* Now the channel is initialized */
diff --git a/arch/arm/src/sam34/sam4s_gpio.h b/arch/arm/src/sam34/sam4s_gpio.h
index 34ffc0aa314f3156917846a1279b53219304ee67..082fad42a997809e39a0fa809ac2098c612d6be4 100644
--- a/arch/arm/src/sam34/sam4s_gpio.h
+++ b/arch/arm/src/sam34/sam4s_gpio.h
@@ -83,11 +83,11 @@
#define GPIO_CFG_SHIFT (12) /* Bits 12-16: GPIO configuration bits */
#define GPIO_CFG_MASK (31 << GPIO_CFG_SHIFT)
# define GPIO_CFG_DEFAULT (0 << GPIO_CFG_SHIFT) /* Default, no attribute */
-# define GPIO_CFG_PULLUP (1 << GPIO_CFG_SHIFT) /* Bit 11: Internal pull-up */
-# define GPIO_CFG_PULLDOWN (2 << GPIO_CFG_SHIFT) /* Bit 11: Internal pull-down */
-# define GPIO_CFG_DEGLITCH (4 << GPIO_CFG_SHIFT) /* Bit 12: Internal glitch filter */
-# define GPIO_CFG_OPENDRAIN (8 << GPIO_CFG_SHIFT) /* Bit 13: Open drain */
-# define GPIO_CFG_SCHMITT (16 << GPIO_CFG_SHIFT) /* Bit 13: Schmitt trigger */
+# define GPIO_CFG_PULLUP (1 << GPIO_CFG_SHIFT) /* Bit 12: Internal pull-up */
+# define GPIO_CFG_PULLDOWN (2 << GPIO_CFG_SHIFT) /* Bit 13: Internal pull-down */
+# define GPIO_CFG_DEGLITCH (4 << GPIO_CFG_SHIFT) /* Bit 14: Internal glitch filter */
+# define GPIO_CFG_OPENDRAIN (8 << GPIO_CFG_SHIFT) /* Bit 15: Open drain */
+# define GPIO_CFG_SCHMITT (16 << GPIO_CFG_SHIFT) /* Bit 16: Schmitt trigger */
/* Additional interrupt modes:
*
@@ -99,7 +99,7 @@
# define _GIO_INT_AIM (1 << 10) /* Bit 10: Additional Interrupt modes */
# define _GPIO_INT_LEVEL (1 << 9) /* Bit 9: Level detection interrupt */
# define _GPIO_INT_EDGE (0) /* (vs. Edge detection interrupt) */
-# define _GPIO_INT_RH (1 << 8) /* Bit 9: Rising edge/High level detection interrupt */
+# define _GPIO_INT_RH (1 << 8) /* Bit 8: Rising edge/High level detection interrupt */
# define _GPIO_INT_FL (0) /* (vs. Falling edge/Low level detection interrupt) */
# define GPIO_INT_HIGHLEVEL (_GIO_INT_AIM | _GPIO_INT_LEVEL | _GPIO_INT_RH)
diff --git a/arch/arm/src/sam34/sam_dmac.c b/arch/arm/src/sam34/sam_dmac.c
index 7cf1cff349991acae896bab29e2cf5f9a94ae548..6cd36cacf820bdb5b7413c093fc8379f6e7388f2 100644
--- a/arch/arm/src/sam34/sam_dmac.c
+++ b/arch/arm/src/sam34/sam_dmac.c
@@ -1276,7 +1276,7 @@ static void sam_dmaterminate(struct sam_dma_s *dmach, int result)
*
****************************************************************************/
-static int sam_dmainterrupt(int irq, void *context)
+static int sam_dmainterrupt(int irq, void *context, FAR void *arg)
{
struct sam_dma_s *dmach;
unsigned int chndx;
@@ -1370,7 +1370,7 @@ void weak_function up_dmainitialize(void)
/* Attach DMA interrupt vector */
- (void)irq_attach(SAM_IRQ_DMAC, sam_dmainterrupt);
+ (void)irq_attach(SAM_IRQ_DMAC, sam_dmainterrupt, NULL);
/* Enable the IRQ at the NVIC (still disabled at the DMA controller) */
diff --git a/arch/arm/src/sam34/sam_emac.c b/arch/arm/src/sam34/sam_emac.c
index 7ce3b0c316516b033a0b8759bb333da1096f8e29..c5db8c01a441abe4babecd138ea7e3a1dbc42205 100644
--- a/arch/arm/src/sam34/sam_emac.c
+++ b/arch/arm/src/sam34/sam_emac.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/sam34/sam_emac.c
*
- * Copyright (C) 2014-2015 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2014-2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
*
* This logic derives from the SAM34D3 Ethernet driver.
@@ -270,7 +270,8 @@ struct sam_emac_s
uint8_t ifup : 1; /* true:ifup false:ifdown */
WDOG_ID txpoll; /* TX poll timer */
WDOG_ID txtimeout; /* TX timeout timer */
- struct work_s work; /* For deferring work to the work queue */
+ struct work_s irqwork; /* For deferring interrupt work to the work queue */
+ struct work_s pollwork; /* For deferring poll work to the work queue */
/* This holds the information visible to the NuttX network */
@@ -381,7 +382,7 @@ static void sam_receive(struct sam_emac_s *priv);
static void sam_txdone(struct sam_emac_s *priv);
static void sam_interrupt_work(FAR void *arg);
-static int sam_emac_interrupt(int irq, void *context);
+static int sam_emac_interrupt(int irq, void *context, FAR void *arg);
/* Watchdog timer expirations */
@@ -1614,7 +1615,7 @@ static void sam_interrupt_work(FAR void *arg)
*
****************************************************************************/
-static int sam_emac_interrupt(int irq, void *context)
+static int sam_emac_interrupt(int irq, void *context, FAR void *arg)
{
struct sam_emac_s *priv = &g_emac;
@@ -1643,24 +1644,12 @@ static int sam_emac_interrupt(int irq, void *context)
* expiration and the deferred interrupt processing.
*/
- wd_cancel(priv->txtimeout);
-
- /* Make sure that the TX poll timer is running (if it is already
- * running, the following would restart it). This is necessary to
- * avoid certain race conditions where the polling sequence can be
- * interrupted.
- */
-
- (void)wd_start(priv->txpoll, SAM_WDDELAY, sam_poll_expiry, 1, priv);
+ wd_cancel(priv->txtimeout);
}
- /* Cancel any pending poll work */
-
- work_cancel(ETHWORK, &priv->work);
-
/* Schedule to perform the interrupt processing on the worker thread. */
- work_queue(ETHWORK, &priv->work, sam_interrupt_work, priv, 0);
+ work_queue(ETHWORK, &priv->irqwork, sam_interrupt_work, priv, 0);
return OK;
}
@@ -1731,15 +1720,9 @@ static void sam_txtimeout_expiry(int argc, uint32_t arg, ...)
up_disable_irq(SAM_IRQ_EMAC);
- /* Cancel any pending poll or interrupt work. This will have no effect
- * on work that has already been started.
- */
-
- work_cancel(ETHWORK, &priv->work);
-
/* Schedule to perform the TX timeout processing on the worker thread. */
- work_queue(ETHWORK, &priv->work, sam_txtimeout_work, priv, 0);
+ work_queue(ETHWORK, &priv->irqwork, sam_txtimeout_work, priv, 0);
}
/****************************************************************************
@@ -1804,24 +1787,9 @@ static void sam_poll_expiry(int argc, uint32_t arg, ...)
{
FAR struct sam_emac_s *priv = (FAR struct sam_emac_s *)arg;
- /* Is our single work structure available? It may not be if there are
- * pending interrupt actions.
- */
-
- if (work_available(&priv->work))
- {
- /* Schedule to perform the interrupt processing on the worker thread. */
-
- work_queue(ETHWORK, &priv->work, sam_poll_work, priv, 0);
- }
- else
- {
- /* No.. Just re-start the watchdog poll timer, missing one polling
- * cycle.
- */
+ /* Schedule to perform the interrupt processing on the worker thread. */
- (void)wd_start(priv->txpoll, SAM_WDDELAY, sam_poll_expiry, 1, arg);
- }
+ work_queue(ETHWORK, &priv->pollwork, sam_poll_work, priv, 0);
}
/****************************************************************************
@@ -2012,11 +1980,11 @@ static int sam_txavail(struct net_driver_s *dev)
* availability action.
*/
- if (work_available(&priv->work))
+ if (work_available(&priv->pollwork))
{
/* Schedule to serialize the poll on the worker thread. */
- work_queue(ETHWORK, &priv->work, sam_txavail_work, priv, 0);
+ work_queue(ETHWORK, &priv->pollwork, sam_txavail_work, priv, 0);
}
return OK;
@@ -3700,7 +3668,7 @@ void up_netinitialize(void)
* the interface is in the 'up' state.
*/
- ret = irq_attach(SAM_IRQ_EMAC, sam_emac_interrupt);
+ ret = irq_attach(SAM_IRQ_EMAC, sam_emac_interrupt, NULL);
if (ret < 0)
{
nerr("ERROR: Failed to attach the handler to the IRQ%d\n", SAM_IRQ_EMAC);
diff --git a/arch/arm/src/sam34/sam_gpioirq.c b/arch/arm/src/sam34/sam_gpioirq.c
index 4367e81463498a37a2076a7f32e595e8073a9cf3..e6091ee511075aafae89da0a14056db427ef5b66 100644
--- a/arch/arm/src/sam34/sam_gpioirq.c
+++ b/arch/arm/src/sam34/sam_gpioirq.c
@@ -210,42 +210,42 @@ static int sam_gpiointerrupt(uint32_t base, int irq0, void *context)
}
#ifdef CONFIG_SAM34_GPIOA_IRQ
-static int sam_gpioainterrupt(int irq, void *context)
+static int sam_gpioainterrupt(int irq, void *context, FAR void *arg)
{
return sam_gpiointerrupt(SAM_PIOA_BASE, SAM_IRQ_PA0, context);
}
#endif
#ifdef CONFIG_SAM34_GPIOB_IRQ
-static int sam_gpiobinterrupt(int irq, void *context)
+static int sam_gpiobinterrupt(int irq, void *context, FAR void *arg)
{
return sam_gpiointerrupt(SAM_PIOB_BASE, SAM_IRQ_PB0, context);
}
#endif
#ifdef CONFIG_SAM34_GPIOC_IRQ
-static int sam_gpiocinterrupt(int irq, void *context)
+static int sam_gpiocinterrupt(int irq, void *context, FAR void *arg)
{
return sam_gpiointerrupt(SAM_PIOC_BASE, SAM_IRQ_PC0, context);
}
#endif
#ifdef CONFIG_SAM34_GPIOD_IRQ
-static int sam_gpiodinterrupt(int irq, void *context)
+static int sam_gpiodinterrupt(int irq, void *context, FAR void *arg)
{
return sam_gpiointerrupt(SAM_PIOD_BASE, SAM_IRQ_PD0, context);
}
#endif
#ifdef CONFIG_SAM34_GPIOE_IRQ
-static int sam_gpioeinterrupt(int irq, void *context)
+static int sam_gpioeinterrupt(int irq, void *context, FAR void *arg)
{
return sam_gpiointerrupt(SAM_PIOE_BASE, SAM_IRQ_PE0, context);
}
#endif
#ifdef CONFIG_SAM34_GPIOF_IRQ
-static int sam_gpiofinterrupt(int irq, void *context)
+static int sam_gpiofinterrupt(int irq, void *context, FAR void *arg)
{
return sam_gpiointerrupt(SAM_PIOF_BASE, SAM_IRQ_PF0, context);
}
@@ -280,7 +280,7 @@ void sam_gpioirqinitialize(void)
/* Attach and enable the GPIOA IRQ */
- (void)irq_attach(SAM_IRQ_PIOA, sam_gpioainterrupt);
+ (void)irq_attach(SAM_IRQ_PIOA, sam_gpioainterrupt, NULL);
up_enable_irq(SAM_IRQ_PIOA);
#endif
@@ -298,7 +298,7 @@ void sam_gpioirqinitialize(void)
/* Attach and enable the GPIOB IRQ */
- (void)irq_attach(SAM_IRQ_PIOB, sam_gpiobinterrupt);
+ (void)irq_attach(SAM_IRQ_PIOB, sam_gpiobinterrupt, NULL);
up_enable_irq(SAM_IRQ_PIOB);
#endif
@@ -316,7 +316,7 @@ void sam_gpioirqinitialize(void)
/* Attach and enable the GPIOC IRQ */
- (void)irq_attach(SAM_IRQ_PIOC, sam_gpiocinterrupt);
+ (void)irq_attach(SAM_IRQ_PIOC, sam_gpiocinterrupt, NULL);
up_enable_irq(SAM_IRQ_PIOC);
#endif
@@ -334,7 +334,7 @@ void sam_gpioirqinitialize(void)
/* Attach and enable the GPIOC IRQ */
- (void)irq_attach(SAM_IRQ_PIOD, sam_gpiodinterrupt);
+ (void)irq_attach(SAM_IRQ_PIOD, sam_gpiodinterrupt, NULL);
up_enable_irq(SAM_IRQ_PIOD);
#endif
@@ -352,7 +352,7 @@ void sam_gpioirqinitialize(void)
/* Attach and enable the GPIOE IRQ */
- (void)irq_attach(SAM_IRQ_PIOE, sam_gpioeinterrupt);
+ (void)irq_attach(SAM_IRQ_PIOE, sam_gpioeinterrupt, NULL);
up_enable_irq(SAM_IRQ_PIOE);
#endif
@@ -370,7 +370,7 @@ void sam_gpioirqinitialize(void)
/* Attach and enable the GPIOF IRQ */
- (void)irq_attach(SAM_IRQ_PIOF, sam_gpiofinterrupt);
+ (void)irq_attach(SAM_IRQ_PIOF, sam_gpiofinterrupt, NULL);
up_enable_irq(SAM_IRQ_PIOF);
#endif
}
diff --git a/arch/arm/src/sam34/sam_hsmci.c b/arch/arm/src/sam34/sam_hsmci.c
index 2e831c0cb97576eb7d8826bf299d473819ab06a0..e59d558fe4e40bdc6fd715dd17a105a8a0edba35 100644
--- a/arch/arm/src/sam34/sam_hsmci.c
+++ b/arch/arm/src/sam34/sam_hsmci.c
@@ -463,7 +463,7 @@ static void sam_notransfer(struct sam_dev_s *priv);
/* Interrupt Handling *******************************************************/
-static int sam_interrupt(int irq, void *context);
+static int sam_interrupt(int irq, void *context, FAR void *arg);
/* SDIO interface methods ***************************************************/
@@ -1248,7 +1248,7 @@ static void sam_notransfer(struct sam_dev_s *priv)
*
****************************************************************************/
-static int sam_interrupt(int irq, void *context)
+static int sam_interrupt(int irq, void *context, FAR void *arg)
{
struct sam_dev_s *priv = &g_sdiodev;
uint32_t sr;
@@ -1638,7 +1638,7 @@ static int sam_attach(FAR struct sdio_dev_s *dev)
/* Attach the HSMCI interrupt handler */
- ret = irq_attach(SAM_IRQ_HSMCI, sam_interrupt);
+ ret = irq_attach(SAM_IRQ_HSMCI, sam_interrupt, NULL);
if (ret == OK)
{
diff --git a/arch/arm/src/sam34/sam_irq.c b/arch/arm/src/sam34/sam_irq.c
index 0b3286d0cac6ded7967d028eb74f9bbfbb2b946d..eb6b174705990c95184462f0a59fc926ab79e8f7 100644
--- a/arch/arm/src/sam34/sam_irq.c
+++ b/arch/arm/src/sam34/sam_irq.c
@@ -178,7 +178,7 @@ static void sam_dumpnvic(const char *msg, int irq)
****************************************************************************/
#ifdef CONFIG_DEBUG_FEATURES
-static int sam_nmi(int irq, FAR void *context)
+static int sam_nmi(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! NMI received\n");
@@ -186,7 +186,7 @@ static int sam_nmi(int irq, FAR void *context)
return 0;
}
-static int sam_busfault(int irq, FAR void *context)
+static int sam_busfault(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Bus fault received: %08x\n", getreg32(NVIC_CFAULTS));
@@ -194,7 +194,7 @@ static int sam_busfault(int irq, FAR void *context)
return 0;
}
-static int sam_usagefault(int irq, FAR void *context)
+static int sam_usagefault(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Usage fault received: %08x\n", getreg32(NVIC_CFAULTS));
@@ -202,7 +202,7 @@ static int sam_usagefault(int irq, FAR void *context)
return 0;
}
-static int sam_pendsv(int irq, FAR void *context)
+static int sam_pendsv(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! PendSV received\n");
@@ -210,7 +210,7 @@ static int sam_pendsv(int irq, FAR void *context)
return 0;
}
-static int sam_dbgmonitor(int irq, FAR void *context)
+static int sam_dbgmonitor(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Debug Monitor received\n");
@@ -218,7 +218,7 @@ static int sam_dbgmonitor(int irq, FAR void *context)
return 0;
}
-static int sam_reserved(int irq, FAR void *context)
+static int sam_reserved(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Reserved interrupt\n");
@@ -439,8 +439,8 @@ void up_irqinitialize(void)
* under certain conditions.
*/
- irq_attach(SAM_IRQ_SVCALL, up_svcall);
- irq_attach(SAM_IRQ_HARDFAULT, up_hardfault);
+ irq_attach(SAM_IRQ_SVCALL, up_svcall, NULL);
+ irq_attach(SAM_IRQ_HARDFAULT, up_hardfault, NULL);
/* Set the priority of the SVCall interrupt */
@@ -456,22 +456,22 @@ void up_irqinitialize(void)
*/
#ifdef CONFIG_ARM_MPU
- irq_attach(SAM_IRQ_MEMFAULT, up_memfault);
+ irq_attach(SAM_IRQ_MEMFAULT, up_memfault, NULL);
up_enable_irq(SAM_IRQ_MEMFAULT);
#endif
/* Attach all other processor exceptions (except reset and sys tick) */
#ifdef CONFIG_DEBUG_FEATURES
- irq_attach(SAM_IRQ_NMI, sam_nmi);
+ irq_attach(SAM_IRQ_NMI, sam_nmi, NULL);
#ifndef CONFIG_ARM_MPU
- irq_attach(SAM_IRQ_MEMFAULT, up_memfault);
+ irq_attach(SAM_IRQ_MEMFAULT, up_memfault, NULL);
#endif
- irq_attach(SAM_IRQ_BUSFAULT, sam_busfault);
- irq_attach(SAM_IRQ_USAGEFAULT, sam_usagefault);
- irq_attach(SAM_IRQ_PENDSV, sam_pendsv);
- irq_attach(SAM_IRQ_DBGMONITOR, sam_dbgmonitor);
- irq_attach(SAM_IRQ_RESERVED, sam_reserved);
+ irq_attach(SAM_IRQ_BUSFAULT, sam_busfault, NULL);
+ irq_attach(SAM_IRQ_USAGEFAULT, sam_usagefault, NULL);
+ irq_attach(SAM_IRQ_PENDSV, sam_pendsv, NULL);
+ irq_attach(SAM_IRQ_DBGMONITOR, sam_dbgmonitor, NULL);
+ irq_attach(SAM_IRQ_RESERVED, sam_reserved, NULL);
#endif
sam_dumpnvic("initial", SAM_IRQ_NIRQS);
diff --git a/arch/arm/src/sam34/sam_rtc.c b/arch/arm/src/sam34/sam_rtc.c
index c4c548cc9f987152aa3c23e0b31309b89e2d89a7..83739923ce81e731c59aebcc7946ecc73066eaba 100644
--- a/arch/arm/src/sam34/sam_rtc.c
+++ b/arch/arm/src/sam34/sam_rtc.c
@@ -264,7 +264,7 @@ static void rtc_worker(FAR void *arg)
************************************************************************************/
#ifdef CONFIG_RTC_ALARM
-static int rtc_interrupt(int irq, void *context)
+static int rtc_interrupt(int irq, void *context, FAR void *arg)
{
int ret;
@@ -364,7 +364,7 @@ int up_rtc_initialize(void)
#ifdef CONFIG_RTC_ALARM
/* Then attach the ALARM interrupt handler */
- irq_attach(SAM_IRQ_RTC, rtc_interrupt);
+ irq_attach(SAM_IRQ_RTC, rtc_interrupt, NULL);
/* Should RTC alarm interrupt be enabled at the peripheral? Let's assume so
* for now. Let's say yes if the time is valid and a valid alarm has been
diff --git a/arch/arm/src/sam34/sam_rtt.c b/arch/arm/src/sam34/sam_rtt.c
index f29e7ac8ee79c3275aa32419d5afbe9971b5396f..7978b01bf38467eb798dea642ecf91f37766eb12 100644
--- a/arch/arm/src/sam34/sam_rtt.c
+++ b/arch/arm/src/sam34/sam_rtt.c
@@ -116,7 +116,7 @@ static void sam34_putreg(uint32_t val, uint32_t addr);
/* Interrupt handling *******************************************************/
-static int sam34_interrupt(int irq, FAR void *context);
+static int sam34_interrupt(int irq, FAR void *context, FAR void *arg);
/* "Lower half" driver methods **********************************************/
@@ -275,12 +275,12 @@ static void sam34_putreg(uint32_t val, uint32_t addr)
*
****************************************************************************/
-static int sam34_interrupt(int irq, FAR void *context)
+static int sam34_interrupt(int irq, FAR void *context, FAR void *arg)
{
- FAR struct sam34_lowerhalf_s *priv = &g_tcdev;
+ FAR struct sam34_lowerhalf_s *priv = (FAR struct sam34_lowerhalf_s *)arg;
tmrinfo("Entry\n");
- DEBUGASSERT(irq == SAM_IRQ_RTT);
+ DEBUGASSERT(priv != NULL);
/* Check if the interrupt is really pending */
@@ -650,7 +650,7 @@ void sam_rttinitialize(FAR const char *devpath)
priv->ops = &g_tcops;
- (void)irq_attach(SAM_IRQ_RTT, sam34_interrupt);
+ (void)irq_attach(SAM_IRQ_RTT, sam34_interrupt, priv);
/* Enable NVIC interrupt. */
diff --git a/arch/arm/src/sam34/sam_serial.c b/arch/arm/src/sam34/sam_serial.c
index 36043e9deb8753611e84f7747b271fd775aeeb09..60f074dbf537483859eca789a153b646ecc1e5a0 100644
--- a/arch/arm/src/sam34/sam_serial.c
+++ b/arch/arm/src/sam34/sam_serial.c
@@ -370,7 +370,7 @@ static int up_setup(struct uart_dev_s *dev);
static void up_shutdown(struct uart_dev_s *dev);
static int up_attach(struct uart_dev_s *dev);
static void up_detach(struct uart_dev_s *dev);
-static int up_interrupt(int irq, void *context);
+static int up_interrupt(int irq, void *context, void *arg);
static int up_ioctl(struct file *filep, int cmd, unsigned long arg);
static int up_receive(struct uart_dev_s *dev, uint32_t *status);
static void up_rxint(struct uart_dev_s *dev, bool enable);
@@ -872,7 +872,7 @@ static int up_attach(struct uart_dev_s *dev)
/* Attach and enable the IRQ */
- ret = irq_attach(priv->irq, up_interrupt);
+ ret = irq_attach(priv->irq, up_interrupt, dev);
if (ret == OK)
{
/* Enable the interrupt (RX and TX interrupts are still disabled
@@ -913,61 +913,16 @@ static void up_detach(struct uart_dev_s *dev)
*
****************************************************************************/
-static int up_interrupt(int irq, void *context)
+static int up_interrupt(int irq, void *context, void *arg)
{
- struct uart_dev_s *dev = NULL;
+ struct uart_dev_s *dev = (struct uart_dev_s *)arg;
struct up_dev_s *priv;
uint32_t pending;
uint32_t imr;
int passes;
bool handled;
-#ifdef CONFIG_SAM34_UART0
- if (g_uart0priv.irq == irq)
- {
- dev = &g_uart0port;
- }
- else
-#endif
-#ifdef CONFIG_SAM34_UART1
- if (g_uart1priv.irq == irq)
- {
- dev = &g_uart1port;
- }
- else
-#endif
-#ifdef CONFIG_SAM34_USART0
- if (g_usart0priv.irq == irq)
- {
- dev = &g_usart0port;
- }
- else
-#endif
-#ifdef CONFIG_SAM34_USART1
- if (g_usart1priv.irq == irq)
- {
- dev = &g_usart1port;
- }
- else
-#endif
-#ifdef CONFIG_SAM34_USART2
- if (g_usart2priv.irq == irq)
- {
- dev = &g_usart2port;
- }
- else
-#endif
-#ifdef CONFIG_SAM34_USART3
- if (g_usart3priv.irq == irq)
- {
- dev = &g_usart3port;
- }
- else
-#endif
- {
- PANIC();
- }
-
+ DEBUGASSERT(dev != NULL && dev->priv != NULL);
priv = (struct up_dev_s *)dev->priv;
/* Loop until there are no characters to be transferred or, until we have
diff --git a/arch/arm/src/sam34/sam_tc.c b/arch/arm/src/sam34/sam_tc.c
index 4a1b2abf79d6e093ac48e34cf24ea6d9b67ab813..1faab8b159f170cdff8b24429ca733d0c0c16917 100644
--- a/arch/arm/src/sam34/sam_tc.c
+++ b/arch/arm/src/sam34/sam_tc.c
@@ -115,7 +115,7 @@ static void sam34_putreg(uint32_t val, uint32_t addr);
/* Interrupt handling *******************************************************/
-static int sam34_interrupt(int irq, FAR void *context);
+static int sam34_interrupt(int irq, FAR void *context, FAR void *arg);
/* "Lower half" driver methods **********************************************/
@@ -255,7 +255,7 @@ static void sam34_putreg(uint32_t val, uint32_t addr)
*
****************************************************************************/
-static int sam34_interrupt(int irq, FAR void *context)
+static int sam34_interrupt(int irq, FAR void *context, FAR void *arg)
{
FAR struct sam34_lowerhalf_s *priv = &g_tcdevs[irq-SAM_IRQ_TC0];
@@ -647,7 +647,7 @@ void sam_tcinitialize(FAR const char *devpath, int irq)
priv->ops = &g_tcops;
- (void)irq_attach(irq, sam34_interrupt);
+ (void)irq_attach(irq, sam34_interrupt, NULL);
/* Enable NVIC interrupt. */
diff --git a/arch/arm/src/sam34/sam_timerisr.c b/arch/arm/src/sam34/sam_timerisr.c
index 00dde9aa7cf313f9398bcf4c3d79ccfc73ab3f23..46661de57b556d35ace8c3e18f166404c7292bc6 100644
--- a/arch/arm/src/sam34/sam_timerisr.c
+++ b/arch/arm/src/sam34/sam_timerisr.c
@@ -112,7 +112,7 @@
*
****************************************************************************/
-static int sam_timerisr(int irq, uint32_t *regs)
+static int sam_timerisr(int irq, uint32_t *regs, void *arg)
{
/* Process timer interrupt */
@@ -163,7 +163,7 @@ void arm_timer_initialize(void)
/* Attach the timer interrupt vector */
- (void)irq_attach(SAM_IRQ_SYSTICK, (xcpt_t)sam_timerisr);
+ (void)irq_attach(SAM_IRQ_SYSTICK, (xcpt_t)sam_timerisr, NULL);
/* Enable SysTick interrupts */
diff --git a/arch/arm/src/sam34/sam_twi.c b/arch/arm/src/sam34/sam_twi.c
index 1ed9c03f6474368d59fdc9f4bf34dfbec7002428..7242f4744d63ef691b1e78a39f39c44fb264fc45 100644
--- a/arch/arm/src/sam34/sam_twi.c
+++ b/arch/arm/src/sam34/sam_twi.c
@@ -162,13 +162,7 @@ static inline void twi_putrel(struct twi_dev_s *priv, unsigned int offset,
static int twi_wait(struct twi_dev_s *priv);
static void twi_wakeup(struct twi_dev_s *priv, int result);
-static int twi_interrupt(struct twi_dev_s *priv);
-#ifdef CONFIG_SAM34_TWI0
-static int twi0_interrupt(int irq, FAR void *context);
-#endif
-#ifdef CONFIG_SAM34_TWI1
-static int twi1_interrupt(int irq, FAR void *context);
-#endif
+static int twi_interrupt(int irq, FAR void *context, FAR void *arg);
static void twi_timeout(int argc, uint32_t arg, ...);
static void twi_startread(struct twi_dev_s *priv, struct i2c_msg_s *msg);
@@ -436,14 +430,17 @@ static void twi_wakeup(struct twi_dev_s *priv, int result)
*
****************************************************************************/
-static int twi_interrupt(struct twi_dev_s *priv)
+static int twi_interrupt(int irq, FAR void *context, FAR void *arg);
{
+ struct twi_dev_s *priv = (struct twi_dev_s *)arg;
struct i2c_msg_s *msg;
uint32_t sr;
uint32_t imr;
uint32_t pending;
uint32_t regval;
+ DEBUGASSERT(priv != NULL);
+
/* Retrieve masked interrupt status */
sr = twi_getrel(priv, SAM_TWI_SR_OFFSET);
@@ -554,20 +551,6 @@ static int twi_interrupt(struct twi_dev_s *priv)
return OK;
}
-#ifdef CONFIG_SAM34_TWI0
-static int twi0_interrupt(int irq, FAR void *context)
-{
- return twi_interrupt(&g_twi0);
-}
-#endif
-
-#ifdef CONFIG_SAM34_TWI1
-static int twi1_interrupt(int irq, FAR void *context)
-{
- return twi_interrupt(&g_twi1);
-}
-#endif
-
/****************************************************************************
* Name: twi_timeout
*
@@ -910,7 +893,6 @@ static void twi_hw_initialize(struct twi_dev_s *priv, unsigned int pid,
struct i2c_master_s *sam_i2cbus_initialize(int bus)
{
struct twi_dev_s *priv;
- xcpt_t handler;
irqstate_t flags;
uint32_t frequency;
unsigned int pid;
@@ -938,9 +920,8 @@ struct i2c_master_s *sam_i2cbus_initialize(int bus)
sam_configgpio(GPIO_TWI0_CK);
sam_configgpio(GPIO_TWI0_D);
- /* Select the interrupt handler, TWI frequency, and peripheral ID */
+ /* Select the TWI frequency, and peripheral ID */
- handler = twi0_interrupt;
frequency = CONFIG_SAM34_TWI0_FREQUENCY;
pid = SAM_PID_TWI0;
}
@@ -965,9 +946,8 @@ struct i2c_master_s *sam_i2cbus_initialize(int bus)
sam_configgpio(GPIO_TWI1_CK);
sam_configgpio(GPIO_TWI1_D);
- /* Select the interrupt handler, TWI frequency, and peripheral ID */
+ /* Select the TWI frequency, and peripheral ID */
- handler = twi1_interrupt;
frequency = CONFIG_SAMA5_TWI1_FREQUENCY;
pid = SAM_PID_TWI1;
}
@@ -1006,7 +986,7 @@ struct i2c_master_s *sam_i2cbus_initialize(int bus)
/* Attach Interrupt Handler */
- irq_attach(priv->irq, handler);
+ irq_attach(priv->irq, twi_interrupt, priv);
/* Enable Interrupts */
diff --git a/arch/arm/src/sam34/sam_udp.c b/arch/arm/src/sam34/sam_udp.c
index 9e644c7631e35b64015ca223e747ee08c2426117..839a7bfdbad5d016cbc0d06d561843038de685e1 100644
--- a/arch/arm/src/sam34/sam_udp.c
+++ b/arch/arm/src/sam34/sam_udp.c
@@ -395,7 +395,7 @@ static void sam_ep0_setup(struct sam_usbdev_s *priv);
static void sam_ep_bankinterrupt(struct sam_usbdev_s *priv,
struct sam_ep_s *privep, uint32_t csr, int bank);
static void sam_ep_interrupt(struct sam_usbdev_s *priv, int epno);
-static int sam_udp_interrupt(int irq, void *context);
+static int sam_udp_interrupt(int irq, void *context, FAR void *arg);
/* Endpoint helpers *********************************************************/
@@ -2218,7 +2218,7 @@ static void sam_ep_interrupt(struct sam_usbdev_s *priv, int epno)
*
****************************************************************************/
-static int sam_udp_interrupt(int irq, void *context)
+static int sam_udp_interrupt(int irq, void *context, FAR void *arg)
{
/* For now there is only one USB controller, but we will always refer to
* it using a pointer to make any future ports to multiple UDP controllers
@@ -3915,7 +3915,7 @@ void up_usbinitialize(void)
* them when we need them later.
*/
- if (irq_attach(SAM_IRQ_UDP, sam_udp_interrupt) != 0)
+ if (irq_attach(SAM_IRQ_UDP, sam_udp_interrupt, NULL) != 0)
{
usbtrace(TRACE_DEVERROR(SAM_TRACEERR_IRQREGISTRATION),
(uint16_t)SAM_IRQ_UDP);
diff --git a/arch/arm/src/sam34/sam_wdt.c b/arch/arm/src/sam34/sam_wdt.c
index a75f63097bd74ba39f33fb10203d322b4ae3d316..cf88b37fec1e515a2865e2eccbc152c6ded95302 100644
--- a/arch/arm/src/sam34/sam_wdt.c
+++ b/arch/arm/src/sam34/sam_wdt.c
@@ -118,7 +118,7 @@ static void sam34_putreg(uint32_t val, uint32_t addr);
/* Interrupt handling *******************************************************/
-static int sam34_interrupt(int irq, FAR void *context);
+static int sam34_interrupt(int irq, FAR void *context, FAR void *arg);
/* "Lower half" driver methods **********************************************/
@@ -256,7 +256,7 @@ static void sam34_putreg(uint32_t val, uint32_t addr)
*
****************************************************************************/
-static int sam34_interrupt(int irq, FAR void *context)
+static int sam34_interrupt(int irq, FAR void *context, FAR void *arg)
{
FAR struct sam34_lowerhalf_s *priv = &g_wdgdev;
uint16_t regval;
@@ -275,7 +275,7 @@ static int sam34_interrupt(int irq, FAR void *context)
* upon return.
*/
- priv->handler(irq, context);
+ priv->handler(irq, context, NULL);
}
/* The EWI interrupt is cleared by the WDT_SR register. */
@@ -681,7 +681,7 @@ void sam_wdtinitialize(FAR const char *devpath)
/* Attach our EWI interrupt handler (But don't enable it yet) */
- (void)irq_attach(SAM_IRQ_WDT, sam34_interrupt);
+ (void)irq_attach(SAM_IRQ_WDT, sam34_interrupt, NULL);
/* Select an arbitrary initial timeout value. But don't start the watchdog
* yet. NOTE: If the "Hardware watchdog" feature is enabled through the
diff --git a/arch/arm/src/sama5/sam_adc.c b/arch/arm/src/sama5/sam_adc.c
index dcf82b1f6d9c5f72bf7f7edd4dac7ead2e629e09..2f9e4ee406efe1bbdbc1bdf5e9db0319dfa74c3d 100644
--- a/arch/arm/src/sama5/sam_adc.c
+++ b/arch/arm/src/sama5/sam_adc.c
@@ -1,7 +1,7 @@
/************************************************************************************
* arch/arm/src/sama5/sam_adc.c
*
- * Copyright (C) 2013, 2014 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2013, 2014, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
*
* References:
@@ -65,6 +65,7 @@
#include
#include
#include
+#include
#include "up_internal.h"
#include "up_arch.h"
@@ -447,7 +448,7 @@ static void sam_adc_dmastart(struct sam_adc_s *priv);
static void sam_adc_endconversion(void *arg);
#endif
-static int sam_adc_interrupt(int irq, void *context);
+static int sam_adc_interrupt(int irq, void *context, FAR void *arg);
/* ADC methods */
@@ -906,7 +907,7 @@ static void sam_adc_endconversion(void *arg)
*
****************************************************************************/
-static int sam_adc_interrupt(int irq, void *context)
+static int sam_adc_interrupt(int irq, void *context, FAR void *arg)
{
struct sam_adc_s *priv = &g_adcpriv;
uint32_t isr;
@@ -2109,7 +2110,7 @@ struct adc_dev_s *sam_adc_initialize(void)
/* Attach the ADC interrupt */
- ret = irq_attach(SAM_IRQ_ADC, sam_adc_interrupt);
+ ret = irq_attach(SAM_IRQ_ADC, sam_adc_interrupt, NULL);
if (ret < 0)
{
aerr("ERROR: Failed to attach IRQ %d: %d\n", SAM_IRQ_ADC, ret);
diff --git a/arch/arm/src/sama5/sam_can.c b/arch/arm/src/sama5/sam_can.c
index f801e6e8341f9f14908d95b7b4b94152d673c877..4020055e89a5f1c5609f27fd6215bdb2b0f1e40f 100644
--- a/arch/arm/src/sama5/sam_can.c
+++ b/arch/arm/src/sama5/sam_can.c
@@ -150,7 +150,6 @@ struct sam_config_s
uint8_t port; /* CAN port number (1 or 2) */
uint8_t pid; /* CAN periperal ID/IRQ number */
uint8_t nrecvmb; /* Number of receive mailboxes */
- xcpt_t handler; /* CAN interrupt handler */
uintptr_t base; /* Base address of the CAN control registers */
uint32_t baud; /* Configured baud */
pio_pinset_t rxpinset; /* RX pin configuration */
@@ -225,13 +224,7 @@ static inline void can_rxinterrupt(FAR struct can_dev_s *dev, int mbndx,
uint32_t msr);
static inline void can_txinterrupt(FAR struct can_dev_s *dev, int mbndx);
static inline void can_mbinterrupt(FAR struct can_dev_s *dev, int mbndx);
-static void can_interrupt(FAR struct can_dev_s *dev);
-#ifdef CONFIG_SAMA5_CAN0
-static int can0_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_SAMA5_CAN1
-static int can1_interrupt(int irq, void *context);
-#endif
+static void can_interrupt(int irq, void *context, FAR void *arg);
/* Hardware initialization */
@@ -265,7 +258,6 @@ static const struct sam_config_s g_can0const =
.port = 0,
.pid = SAM_PID_CAN0,
.nrecvmb = CONFIG_SAMA5_CAN0_NRECVMB,
- .handler = can0_interrupt,
.base = SAM_CAN0_VBASE,
.baud = CONFIG_SAMA5_CAN0_BAUD,
.rxpinset = PIO_CAN0_RX,
@@ -301,7 +293,6 @@ static const struct sam_config_s g_can1const =
.port = 1,
.pid = SAM_PID_CAN1,
.nrecvmb = CONFIG_SAMA5_CAN1_NRECVMB,
- .handler = can1_interrupt,
.base = SAM_CAN1_VBASE,
.baud = CONFIG_SAMA5_CAN1_BAUD,
.rxpinset = PIO_CAN1_RX,
@@ -860,7 +851,7 @@ static int can_setup(FAR struct can_dev_s *dev)
/* Attach the CAN interrupt handler */
- ret = irq_attach(config->pid, config->handler);
+ ret = irq_attach(config->pid, can_interrupt, dev);
if (ret < 0)
{
canerr("ERROR: Failed to attach CAN%d IRQ (%d)", config->port, config->pid);
@@ -1437,21 +1428,24 @@ static inline void can_mbinterrupt(FAR struct can_dev_s *dev, int mbndx)
* Common CAN interrupt handler
*
* Input Parameters:
- * priv - CAN-specific private data
+ * Standard interrupt handler inputs
*
* Returned Value:
* None
*
****************************************************************************/
-static void can_interrupt(FAR struct can_dev_s *dev)
+static void can_interrupt(int irq, void *context, FAR void *arg)
{
- FAR struct sam_can_s *priv = dev->cd_priv;
+ FAR struct can_dev_s *dev = (FAR struct can_dev_s *)arg;
+ FAR struct sam_can_s *priv;
uint32_t sr;
uint32_t imr;
uint32_t pending;
- DEBUGASSERT(priv && priv->config);
+ DEBUGASSERT(dev != NULL);
+ FAR struct sam_can_s *priv = dev->cd_priv;
+ DEBUGASSERT(priv != NULL && priv->config != NULL);
/* Get the set of pending interrupts.
*
@@ -1520,52 +1514,6 @@ static void can_interrupt(FAR struct can_dev_s *dev)
}
}
-/****************************************************************************
- * Name: can0_interrupt
- *
- * Description:
- * CAN0 interrupt handler
- *
- * Input Parameters:
- * irq - The IRQ number of the interrupt.
- * context - The register state save array at the time of the interrupt.
- *
- * Returned Value:
- * Zero on success; a negated errno on failure
- *
- ****************************************************************************/
-
-#ifdef CONFIG_SAMA5_CAN0
-static int can0_interrupt(int irq, void *context)
-{
- can_interrupt(&g_can0dev);
- return OK;
-}
-#endif
-
-/****************************************************************************
- * Name: can0_interrupt
- *
- * Description:
- * CAN0 interrupt handler
- *
- * Input Parameters:
- * irq - The IRQ number of the interrupt.
- * context - The register state save array at the time of the interrupt.
- *
- * Returned Value:
- * Zero on success; a negated errno on failure
- *
- ****************************************************************************/
-
-#ifdef CONFIG_SAMA5_CAN1
-static int can1_interrupt(int irq, void *context)
-{
- can_interrupt(&g_can1dev);
- return OK;
-}
-#endif
-
/****************************************************************************
* Name: can_bittiming
*
diff --git a/arch/arm/src/sama5/sam_dbgu.c b/arch/arm/src/sama5/sam_dbgu.c
index 877e1db82dce5213477c9586ff01442147245b35..65242b88188d1df2962fcad90868565203ae3cf5 100644
--- a/arch/arm/src/sama5/sam_dbgu.c
+++ b/arch/arm/src/sama5/sam_dbgu.c
@@ -91,7 +91,7 @@ static int dbgu_setup(struct uart_dev_s *dev);
static void dbgu_shutdown(struct uart_dev_s *dev);
static int dbgu_attach(struct uart_dev_s *dev);
static void dbgu_detach(struct uart_dev_s *dev);
-static int dbgu_interrupt(int irq, void *context);
+static int dbgu_interrupt(int irq, void *context, FAR void *arg);
static int dbgu_ioctl(struct file *filep, int cmd, unsigned long arg);
static int dbgu_receive(struct uart_dev_s *dev, uint32_t *status);
static void dbgu_rxint(struct uart_dev_s *dev, bool enable);
@@ -287,7 +287,7 @@ static int dbgu_attach(struct uart_dev_s *dev)
/* Attach and enable the IRQ */
- ret = irq_attach(SAM_IRQ_DBGU, dbgu_interrupt);
+ ret = irq_attach(SAM_IRQ_DBGU, dbgu_interrupt, NULL);
if (ret == OK)
{
/* Enable the interrupt (RX and TX interrupts are still disabled
@@ -328,7 +328,7 @@ static void dbgu_detach(struct uart_dev_s *dev)
*
****************************************************************************/
-static int dbgu_interrupt(int irq, void *context)
+static int dbgu_interrupt(int irq, void *context, FAR void *arg)
{
struct uart_dev_s *dev = &g_dbgu_port;
struct dbgu_dev_s *priv = (struct dbgu_dev_s *)dev->priv;
diff --git a/arch/arm/src/sama5/sam_dmac.c b/arch/arm/src/sama5/sam_dmac.c
index e3a813c1b211889c8887ad86766e94e7fadc319b..a1002395db985a3a994726f7dfd870f01c9f8afd 100644
--- a/arch/arm/src/sama5/sam_dmac.c
+++ b/arch/arm/src/sama5/sam_dmac.c
@@ -1785,12 +1785,15 @@ static void sam_dmaterminate(struct sam_dmach_s *dmach, int result)
*
****************************************************************************/
-static int sam_dmac_interrupt(struct sam_dmac_s *dmac)
+static int sam_dmac_interrupt(int irq, void *context, FAR void *arg)
{
+ struct sam_dmac_s *dmac = (struct sam_dmac_s *)arg;
struct sam_dmach_s *dmach;
unsigned int chndx;
uint32_t regval;
+ DEBUGASSERT(dmac != NULL);
+
/* Get the DMAC status register value. Ignore all masked interrupt
* status bits.
*/
@@ -1849,28 +1852,6 @@ static int sam_dmac_interrupt(struct sam_dmac_s *dmac)
return OK;
}
-/****************************************************************************
- * Name: sam_dmac0_interrupt and sam_dmac1_interrupt
- *
- * Description:
- * DMA interrupt handler
- *
- ****************************************************************************/
-
-#ifdef CONFIG_SAMA5_DMAC0
-static int sam_dmac0_interrupt(int irq, void *context)
-{
- return sam_dmac_interrupt(&g_dmac0);
-}
-#endif
-
-#ifdef CONFIG_SAMA5_DMAC1
-static int sam_dmac1_interrupt(int irq, void *context)
-{
- return sam_dmac_interrupt(&g_dmac1);
-}
-#endif
-
/****************************************************************************
* Name: sam_dmainitialize
*
@@ -1928,7 +1909,7 @@ void weak_function up_dmainitialize(void)
/* Attach DMA interrupt vector */
- (void)irq_attach(SAM_IRQ_DMAC0, sam_dmac0_interrupt);
+ (void)irq_attach(SAM_IRQ_DMAC0, sam_dmac_interrupt, &g_dmac0);
/* Initialize the controller */
@@ -1948,7 +1929,7 @@ void weak_function up_dmainitialize(void)
/* Attach DMA interrupt vector */
- (void)irq_attach(SAM_IRQ_DMAC1, sam_dmac1_interrupt);
+ (void)irq_attach(SAM_IRQ_DMAC1, sam_dmac_interrupt, &g_dmac1);
/* Initialize the controller */
diff --git a/arch/arm/src/sama5/sam_ehci.c b/arch/arm/src/sama5/sam_ehci.c
index 6065a04d50da88f3a103102232c2d2faf4363417..d84f1c2dbc41f50e1c26c63c190f35c574a94bcf 100644
--- a/arch/arm/src/sama5/sam_ehci.c
+++ b/arch/arm/src/sama5/sam_ehci.c
@@ -388,7 +388,7 @@ static inline void sam_portsc_bottomhalf(void);
static inline void sam_syserr_bottomhalf(void);
static inline void sam_async_advance_bottomhalf(void);
static void sam_ehci_bottomhalf(FAR void *arg);
-static int sam_ehci_tophalf(int irq, FAR void *context);
+static int sam_ehci_tophalf(int irq, FAR void *context, FAR void *arg);
/* USB Host Controller Operations **********************************************/
@@ -3167,7 +3167,7 @@ static void sam_ehci_bottomhalf(FAR void *arg)
*
****************************************************************************/
-static int sam_ehci_tophalf(int irq, FAR void *context)
+static int sam_ehci_tophalf(int irq, FAR void *context, FAR void *arg)
{
uint32_t usbsts;
uint32_t pending;
@@ -3228,15 +3228,15 @@ static int sam_ehci_tophalf(int irq, FAR void *context)
****************************************************************************/
#ifdef CONFIG_SAMA5_OHCI
-static int sam_uhphs_interrupt(int irq, FAR void *context)
+static int sam_uhphs_interrupt(int irq, FAR void *context, FAR void *arg)
{
int ohci;
int ehci;
/* Provide the interrupting event to both the EHCI and OHCI top half */
- ohci = sam_ohci_tophalf(irq, context);
- ehci = sam_ehci_tophalf(irq, context);
+ ohci = sam_ohci_tophalf(irq, context, arg);
+ ehci = sam_ehci_tophalf(irq, context, arg);
/* Return OK only if both handlers returned OK */
@@ -5098,9 +5098,9 @@ FAR struct usbhost_connection_s *sam_ehci_initialize(int controller)
*/
#ifdef CONFIG_SAMA5_OHCI
- ret = irq_attach(SAM_IRQ_UHPHS, sam_uhphs_interrupt);
+ ret = irq_attach(SAM_IRQ_UHPHS, sam_uhphs_interrupt, NULL);
#else
- ret = irq_attach(SAM_IRQ_UHPHS, sam_ehci_tophalf);
+ ret = irq_attach(SAM_IRQ_UHPHS, sam_ehci_tophalf, NULL);
#endif
if (ret != 0)
{
diff --git a/arch/arm/src/sama5/sam_emaca.c b/arch/arm/src/sama5/sam_emaca.c
index 29bd28c5a75df54010dd92087d8bb527b891bd06..92e18b160ae1126bf66cfa4ea77f928b42f86305 100644
--- a/arch/arm/src/sama5/sam_emaca.c
+++ b/arch/arm/src/sama5/sam_emaca.c
@@ -4,7 +4,7 @@
* 10/100 Base-T Ethernet driver for the SAMA5D3. Denoted as 'A' to
* distinguish it from the SAMA5D4 EMAC driver.
*
- * Copyright (C) 2013-2016 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2013-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
*
* References:
@@ -275,7 +275,8 @@ struct sam_emac_s
uint8_t ifup : 1; /* true:ifup false:ifdown */
WDOG_ID txpoll; /* TX poll timer */
WDOG_ID txtimeout; /* TX timeout timer */
- struct work_s work; /* For deferring work to the work queue */
+ struct work_s irqwork; /* For deferring interrupt work to the work queue */
+ struct work_s pollwork; /* For deferring poll work to the work queue */
/* This holds the information visible to the NuttX network */
@@ -386,7 +387,7 @@ static void sam_receive(struct sam_emac_s *priv);
static void sam_txdone(struct sam_emac_s *priv);
static void sam_interrupt_work(FAR void *arg);
-static int sam_emac_interrupt(int irq, void *context);
+static int sam_emac_interrupt(int irq, void *context, FAR void *arg);
/* Watchdog timer expirations */
@@ -1653,7 +1654,7 @@ static void sam_interrupt_work(FAR void *arg)
*
****************************************************************************/
-static int sam_emac_interrupt(int irq, void *context)
+static int sam_emac_interrupt(int irq, void *context, FAR void *arg)
{
struct sam_emac_s *priv = &g_emac;
uint32_t tsr;
@@ -1681,24 +1682,12 @@ static int sam_emac_interrupt(int irq, void *context)
* expiration and the deferred interrupt processing.
*/
- wd_cancel(priv->txtimeout);
-
- /* Make sure that the TX poll timer is running (if it is already
- * running, the following would restart it). This is necessary to
- * avoid certain race conditions where the polling sequence can be
- * interrupted.
- */
-
- (void)wd_start(priv->txpoll, SAM_WDDELAY, sam_poll_expiry, 1, priv);
+ wd_cancel(priv->txtimeout);
}
- /* Cancel any pending poll work */
-
- work_cancel(ETHWORK, &priv->work);
-
/* Schedule to perform the interrupt processing on the worker thread. */
- work_queue(ETHWORK, &priv->work, sam_interrupt_work, priv, 0);
+ work_queue(ETHWORK, &priv->irqwork, sam_interrupt_work, priv, 0);
return OK;
}
@@ -1767,15 +1756,9 @@ static void sam_txtimeout_expiry(int argc, uint32_t arg, ...)
up_disable_irq(SAM_IRQ_EMAC);
- /* Cancel any pending poll or interrupt work. This will have no effect
- * on work that has already been started.
- */
-
- work_cancel(ETHWORK, &priv->work);
-
/* Schedule to perform the TX timeout processing on the worker thread. */
- work_queue(ETHWORK, &priv->work, sam_txtimeout_work, priv, 0);
+ work_queue(ETHWORK, &priv->irqwork, sam_txtimeout_work, priv, 0);
}
/****************************************************************************
@@ -1840,24 +1823,9 @@ static void sam_poll_expiry(int argc, uint32_t arg, ...)
{
FAR struct sam_emac_s *priv = (FAR struct sam_emac_s *)arg;
- /* Is our single work structure available? It may not be if there are
- * pending interrupt actions.
- */
-
- if (work_available(&priv->work))
- {
- /* Schedule to perform the interrupt processing on the worker thread. */
-
- work_queue(ETHWORK, &priv->work, sam_poll_work, priv, 0);
- }
- else
- {
- /* No.. Just re-start the watchdog poll timer, missing one polling
- * cycle.
- */
+ /* Schedule to perform the interrupt processing on the worker thread. */
- (void)wd_start(priv->txpoll, SAM_WDDELAY, sam_poll_expiry, 1, arg);
- }
+ work_queue(ETHWORK, &priv->pollwork, sam_poll_work, priv, 0);
}
/****************************************************************************
@@ -2048,11 +2016,11 @@ static int sam_txavail(struct net_driver_s *dev)
* availability action.
*/
- if (work_available(&priv->work))
+ if (work_available(&priv->pollwork))
{
/* Schedule to serialize the poll on the worker thread. */
- work_queue(ETHWORK, &priv->work, sam_txavail_work, priv, 0);
+ work_queue(ETHWORK, &priv->pollwork, sam_txavail_work, priv, 0);
}
return OK;
@@ -3744,7 +3712,7 @@ int sam_emac_initialize(void)
* the interface is in the 'up' state.
*/
- ret = irq_attach(SAM_IRQ_EMAC, sam_emac_interrupt);
+ ret = irq_attach(SAM_IRQ_EMAC, sam_emac_interrupt, NULL);
if (ret < 0)
{
nerr("ERROR: Failed to attach the handler to the IRQ%d\n", SAM_IRQ_EMAC);
diff --git a/arch/arm/src/sama5/sam_emacb.c b/arch/arm/src/sama5/sam_emacb.c
index 44b477cb7ba08db0ea5d8884c32e9fb196b0eb4a..3fd2f903fbbafc705b5f55db426e730875a946c1 100644
--- a/arch/arm/src/sama5/sam_emacb.c
+++ b/arch/arm/src/sama5/sam_emacb.c
@@ -8,7 +8,7 @@
* separate (mostly because the 'B' driver needs to support two EMAC blocks.
* But the 'B' driver should replace the 'A' driver someday.
*
- * Copyright (C) 2014-2015 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2014-2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
*
* This logic derives from the SAM4E Ethernet driver which, in turn, derived
@@ -349,7 +349,6 @@ struct sam_emacattr_s
/* Basic hardware information */
uint32_t base; /* EMAC Register base address */
- xcpt_t handler; /* EMAC interrupt handler */
uint8_t emac; /* EMACn, n=0 or 1 */
uint8_t irq; /* EMAC interrupt number */
@@ -413,7 +412,8 @@ struct sam_emac_s
uint8_t ifup : 1; /* true:ifup false:ifdown */
WDOG_ID txpoll; /* TX poll timer */
WDOG_ID txtimeout; /* TX timeout timer */
- struct work_s work; /* For deferring work to the work queue */
+ struct work_s irqwork; /* For deferring interrupt work to the work queue */
+ struct work_s pollwork; /* For deferring poll work to the work queue */
/* This holds the information visible to the NuttX network */
@@ -481,13 +481,7 @@ static void sam_receive(struct sam_emac_s *priv);
static void sam_txdone(struct sam_emac_s *priv);
static void sam_interrupt_work(FAR void *arg);
-static int sam_emac_interrupt(struct sam_emac_s *priv);
-#ifdef CONFIG_SAMA5_EMAC0
-static int sam_emac0_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_SAMA5_EMAC1
-static int sam_emac1_interrupt(int irq, void *context);
-#endif
+static int sam_emac_interrupt(int irq, void *context, FAR void *arg);
/* Watchdog timer expirations */
@@ -633,7 +627,6 @@ static const struct sam_emacattr_s g_emac0_attr =
/* Basic hardware information */
.base = SAM_EMAC0_VBASE,
- .handler = sam_emac0_interrupt,
.emac = EMAC0_INTF,
.irq = SAM_IRQ_EMAC0,
@@ -714,7 +707,6 @@ static const struct sam_emacattr_s g_emac1_attr =
/* Basic hardware information */
.base = SAM_EMAC1_VBASE,
- .handler = sam_emac1_interrupt,
.emac = EMAC1_INTF,
.irq = SAM_IRQ_EMAC1,
@@ -2012,7 +2004,7 @@ static void sam_interrupt_work(FAR void *arg)
* Common hardware interrupt handler
*
* Parameters:
- * priv - Reference to the EMAC private state structure
+ * Standard interrupt handler inputs
*
* Returned Value:
* OK on success
@@ -2021,10 +2013,13 @@ static void sam_interrupt_work(FAR void *arg)
*
****************************************************************************/
-static int sam_emac_interrupt(struct sam_emac_s *priv)
+static int sam_emac_interrupt(int irq, void *context, FAR void *arg)
{
+ struct sam_emac_s *priv = (struct sam_emac_s *)arg;
uint32_t tsr;
+ DEBUGASSERT(priv != NULL);
+
/* Disable further Ethernet interrupts. Because Ethernet interrupts are
* also disabled if the TX timeout event occurs, there can be no race
* condition here.
@@ -2048,58 +2043,15 @@ static int sam_emac_interrupt(struct sam_emac_s *priv)
* expiration and the deferred interrupt processing.
*/
- wd_cancel(priv->txtimeout);
-
- /* Make sure that the TX poll timer is running (if it is already
- * running, the following would restart it). This is necessary to
- * avoid certain race conditions where the polling sequence can be
- * interrupted.
- */
-
- (void)wd_start(priv->txpoll, SAM_WDDELAY, sam_poll_expiry, 1, priv);
+ wd_cancel(priv->txtimeout);
}
- /* Cancel any pending poll work */
-
- work_cancel(ETHWORK, &priv->work);
-
/* Schedule to perform the interrupt processing on the worker thread. */
- work_queue(ETHWORK, &priv->work, sam_interrupt_work, priv, 0);
+ work_queue(ETHWORK, &priv->irqwork, sam_interrupt_work, priv, 0);
return OK;
}
-/****************************************************************************
- * Function: sam_emac0/1_interrupt
- *
- * Description:
- * EMAC hardware interrupt handler
- *
- * Parameters:
- * irq - Number of the IRQ that generated the interrupt
- * context - Interrupt register state save info (architecture-specific)
- *
- * Returned Value:
- * OK on success
- *
- * Assumptions:
- *
- ****************************************************************************/
-
-#ifdef CONFIG_SAMA5_EMAC0
-static int sam_emac0_interrupt(int irq, void *context)
-{
- return sam_emac_interrupt(&g_emac0);
-}
-#endif
-
-#ifdef CONFIG_SAMA5_EMAC1
-static int sam_emac1_interrupt(int irq, void *context)
-{
- return sam_emac_interrupt(&g_emac1);
-}
-#endif
-
/****************************************************************************
* Function: sam_txtimeout_work
*
@@ -2165,15 +2117,9 @@ static void sam_txtimeout_expiry(int argc, uint32_t arg, ...)
up_disable_irq(priv->attr->irq);
- /* Cancel any pending poll or interrupt work. This will have no effect
- * on work that has already been started.
- */
-
- work_cancel(ETHWORK, &priv->work);
-
/* Schedule to perform the TX timeout processing on the worker thread. */
- work_queue(ETHWORK, &priv->work, sam_txtimeout_work, priv, 0);
+ work_queue(ETHWORK, &priv->irqwork, sam_txtimeout_work, priv, 0);
}
/****************************************************************************
@@ -2238,24 +2184,9 @@ static void sam_poll_expiry(int argc, uint32_t arg, ...)
{
FAR struct sam_emac_s *priv = (FAR struct sam_emac_s *)arg;
- /* Is our single work structure available? It may not be if there are
- * pending interrupt actions.
- */
-
- if (work_available(&priv->work))
- {
- /* Schedule to perform the interrupt processing on the worker thread. */
-
- work_queue(ETHWORK, &priv->work, sam_poll_work, priv, 0);
- }
- else
- {
- /* No.. Just re-start the watchdog poll timer, missing one polling
- * cycle.
- */
+ /* Schedule to perform the interrupt processing on the worker thread. */
- (void)wd_start(priv->txpoll, SAM_WDDELAY, sam_poll_expiry, 1, arg);
- }
+ work_queue(ETHWORK, &priv->pollwork, sam_poll_work, priv, 0);
}
/****************************************************************************
@@ -2454,11 +2385,11 @@ static int sam_txavail(struct net_driver_s *dev)
* availability action.
*/
- if (work_available(&priv->work))
+ if (work_available(&priv->pollwork))
{
/* Schedule to serialize the poll on the worker thread. */
- work_queue(ETHWORK, &priv->work, sam_txavail_work, priv, 0);
+ work_queue(ETHWORK, &priv->pollwork, sam_txavail_work, priv, 0);
}
return OK;
@@ -4470,7 +4401,7 @@ int sam_emac_initialize(int intf)
* the interface is in the 'up' state.
*/
- ret = irq_attach(priv->attr->irq, priv->attr->handler);
+ ret = irq_attach(priv->attr->irq, sam_emac_interrupt, priv);
if (ret < 0)
{
nerr("ERROR: Failed to attach the handler to the IRQ%d\n", priv->attr->irq);
diff --git a/arch/arm/src/sama5/sam_flexcom_serial.c b/arch/arm/src/sama5/sam_flexcom_serial.c
index c0d4693ac86cdfcb076126102063cf38b8fd60f4..b476b931143ebc19d55f81a898605346e3fe31a5 100644
--- a/arch/arm/src/sama5/sam_flexcom_serial.c
+++ b/arch/arm/src/sama5/sam_flexcom_serial.c
@@ -216,7 +216,6 @@
struct flexus_dev_s
{
- xcpt_t handler; /* Interrupt handler */
uint32_t usartbase; /* Base address of USART registers */
uint32_t baud; /* Configured baud */
uint32_t sr; /* Saved status bits */
@@ -233,23 +232,7 @@ struct flexus_dev_s
* Private Function Prototypes
****************************************************************************/
-static int flexus_interrupt(struct uart_dev_s *dev);
-#ifdef CONFIG_USART0_SERIALDRIVER
-static int flexus0_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_USART1_SERIALDRIVER
-static int flexus1_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_USART2_SERIALDRIVER
-static int flexus2_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_USART3_SERIALDRIVER
-static int flexus3_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_USART4_SERIALDRIVER
-static int flexus4_interrupt(int irq, void *context);
-#endif
-
+static int flexus_interrupt(int irq, void *context, FAR void *arg);
static int flexus_setup(struct uart_dev_s *dev);
static void flexus_shutdown(struct uart_dev_s *dev);
static int flexus_attach(struct uart_dev_s *dev);
@@ -314,7 +297,6 @@ static char g_flexus4txbuffer[CONFIG_USART4_TXBUFSIZE];
#ifdef CONFIG_USART0_SERIALDRIVER
static struct flexus_dev_s g_flexus0priv =
{
- .handler = flexus0_interrupt,
.usartbase = SAM_FLEXCOM0_VBASE,
.baud = CONFIG_USART0_BAUD,
.irq = SAM_IRQ_FLEXCOM0,
@@ -348,7 +330,6 @@ static uart_dev_t g_flexus0port =
#ifdef CONFIG_USART1_SERIALDRIVER
static struct flexus_dev_s g_flexus1priv =
{
- .handler = flexus1_interrupt,
.usartbase = SAM_FLEXCOM1_VBASE,
.baud = CONFIG_USART1_BAUD,
.irq = SAM_IRQ_FLEXCOM1,
@@ -382,7 +363,6 @@ static uart_dev_t g_flexus1port =
#ifdef CONFIG_USART2_SERIALDRIVER
static struct flexus_dev_s g_flexus2priv =
{
- .handler = flexus2_interrupt,
.usartbase = SAM_FLEXCOM2_VBASE,
.baud = CONFIG_USART2_BAUD,
.irq = SAM_IRQ_FLEXCOM2,
@@ -416,7 +396,6 @@ static uart_dev_t g_flexus2port =
#ifdef CONFIG_USART3_SERIALDRIVER
static struct flexus_dev_s g_flexus3priv =
{
- .handler = flexus3_interrupt,
.usartbase = SAM_FLEXCOM3_VBASE,
.baud = CONFIG_USART3_BAUD,
.irq = SAM_IRQ_FLEXCOM3,
@@ -450,7 +429,6 @@ static uart_dev_t g_flexus3port =
#ifdef CONFIG_USART4_SERIALDRIVER
static struct flexus_dev_s g_flexus4priv =
{
- .handler = flexus4_interrupt,
.usartbase = SAM_FLEXCOM4_VBASE,
.baud = CONFIG_USART4_BAUD,
.irq = SAM_IRQ_FLEXCOM4,
@@ -549,13 +527,14 @@ static void flexus_disableallints(struct flexus_dev_s *priv, uint32_t *imr)
*
****************************************************************************/
-static int flexus_interrupt(struct uart_dev_s *dev)
+static int flexus_interrupt(int irq, void *context, FAR void *arg)
{
- struct flexus_dev_s *priv;
- uint32_t pending;
- uint32_t imr;
- int passes;
- bool handled;
+ struct uart_dev_s *dev = (struct uart_dev_s *)arg;
+ struct flexus_dev_s *priv;
+ uint32_t pending;
+ uint32_t imr;
+ int passes;
+ bool handled;
DEBUGASSERT(dev != NULL && dev->priv != NULL);
priv = (struct flexus_dev_s *)dev->priv;
@@ -603,47 +582,6 @@ static int flexus_interrupt(struct uart_dev_s *dev)
return OK;
}
-/****************************************************************************
- * Name: flexus*_interrupt
- *
- * Description:
- * This is the specific UART/USART interrupt handler. These simply map
- * the interrupt to the device-specific data and passes control to the
- * common interrupt handler.
- *
- ****************************************************************************/
-
-#ifdef CONFIG_USART0_SERIALDRIVER
-static int flexus0_interrupt(int irq, void *context)
-{
- return flexus_interrupt(&g_flexus0port);
-}
-#endif
-#ifdef CONFIG_USART1_SERIALDRIVER
-static int flexus1_interrupt(int irq, void *context)
-{
- return flexus_interrupt(&g_flexus1port);
-}
-#endif
-#ifdef CONFIG_USART2_SERIALDRIVER
-static int flexus2_interrupt(int irq, void *context)
-{
- return flexus_interrupt(&g_flexus2port);
-}
-#endif
-#ifdef CONFIG_USART3_SERIALDRIVER
-static int flexus3_interrupt(int irq, void *context)
-{
- return flexus_interrupt(&g_flexus3port);
-}
-#endif
-#ifdef CONFIG_USART4_SERIALDRIVER
-static int flexus4_interrupt(int irq, void *context)
-{
- return flexus_interrupt(&g_flexus4port);
-}
-#endif
-
/****************************************************************************
* Name: flexus_setup
*
@@ -803,7 +741,7 @@ static int flexus_attach(struct uart_dev_s *dev)
/* Attach and enable the IRQ */
- ret = irq_attach(priv->irq, priv->handler);
+ ret = irq_attach(priv->irq, flexus_interrupt, dev);
if (ret == OK)
{
/* Enable the interrupt (RX and TX interrupts are still disabled
diff --git a/arch/arm/src/sama5/sam_gmac.c b/arch/arm/src/sama5/sam_gmac.c
index da6b320d523214e64efae094d105d042ef92f215..a3d296b349515c9ae0a2c4dfa79095d67a59c045 100644
--- a/arch/arm/src/sama5/sam_gmac.c
+++ b/arch/arm/src/sama5/sam_gmac.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/sama5/sam_gmac.c
*
- * Copyright (C) 2013-2016 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2013-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
*
* References:
@@ -201,7 +201,8 @@ struct sam_gmac_s
uint8_t ifup : 1; /* true:ifup false:ifdown */
WDOG_ID txpoll; /* TX poll timer */
WDOG_ID txtimeout; /* TX timeout timer */
- struct work_s work; /* For deferring work to the work queue */
+ struct work_s irqwork; /* For deferring interrupt work to the work queue */
+ struct work_s pollwork; /* For deferring poll work to the work queue */
/* This holds the information visible to the NuttX network */
@@ -311,7 +312,7 @@ static void sam_receive(struct sam_gmac_s *priv);
static void sam_txdone(struct sam_gmac_s *priv);
static void sam_interrupt_work(FAR void *arg);
-static int sam_gmac_interrupt(int irq, void *context);
+static int sam_gmac_interrupt(int irq, void *context, FAR void *arg);
/* Watchdog timer expirations */
@@ -1605,7 +1606,7 @@ static void sam_interrupt_work(FAR void *arg)
*
****************************************************************************/
-static int sam_gmac_interrupt(int irq, void *context)
+static int sam_gmac_interrupt(int irq, void *context, FAR void *arg)
{
struct sam_gmac_s *priv = &g_gmac;
uint32_t tsr;
@@ -1633,24 +1634,12 @@ static int sam_gmac_interrupt(int irq, void *context)
* expiration and the deferred interrupt processing.
*/
- wd_cancel(priv->txtimeout);
-
- /* Make sure that the TX poll timer is running (if it is already
- * running, the following would restart it). This is necessary to
- * avoid certain race conditions where the polling sequence can be
- * interrupted.
- */
-
- (void)wd_start(priv->txpoll, SAM_WDDELAY, sam_poll_expiry, 1, priv);
+ wd_cancel(priv->txtimeout);
}
- /* Cancel any pending poll work */
-
- work_cancel(ETHWORK, &priv->work);
-
/* Schedule to perform the interrupt processing on the worker thread. */
- work_queue(ETHWORK, &priv->work, sam_interrupt_work, priv, 0);
+ work_queue(ETHWORK, &priv->irqwork, sam_interrupt_work, priv, 0);
return OK;
}
@@ -1719,15 +1708,9 @@ static void sam_txtimeout_expiry(int argc, uint32_t arg, ...)
up_disable_irq(SAM_IRQ_GMAC);
- /* Cancel any pending poll or interrupt work. This will have no effect
- * on work that has already been started.
- */
-
- work_cancel(ETHWORK, &priv->work);
-
/* Schedule to perform the TX timeout processing on the worker thread. */
- work_queue(ETHWORK, &priv->work, sam_txtimeout_work, priv, 0);
+ work_queue(ETHWORK, &priv->irqwork, sam_txtimeout_work, priv, 0);
}
/****************************************************************************
@@ -1792,24 +1775,9 @@ static void sam_poll_expiry(int argc, uint32_t arg, ...)
{
FAR struct sam_gmac_s *priv = (FAR struct sam_gmac_s *)arg;
- /* Is our single work structure available? It may not be if there are
- * pending interrupt actions.
- */
-
- if (work_available(&priv->work))
- {
- /* Schedule to perform the interrupt processing on the worker thread. */
-
- work_queue(ETHWORK, &priv->work, sam_poll_work, priv, 0);
- }
- else
- {
- /* No.. Just re-start the watchdog poll timer, missing one polling
- * cycle.
- */
+ /* Schedule to perform the interrupt processing on the worker thread. */
- (void)wd_start(priv->txpoll, SAM_WDDELAY, sam_poll_expiry, 1, arg);
- }
+ work_queue(ETHWORK, &priv->pollwork, sam_poll_work, priv, 0);
}
/****************************************************************************
@@ -2003,11 +1971,11 @@ static int sam_txavail(struct net_driver_s *dev)
* availability action.
*/
- if (work_available(&priv->work))
+ if (work_available(&priv->pollwork))
{
/* Schedule to serialize the poll on the worker thread. */
- work_queue(ETHWORK, &priv->work, sam_txavail_work, priv, 0);
+ work_queue(ETHWORK, &priv->pollwork, sam_txavail_work, priv, 0);
}
return OK;
@@ -3816,7 +3784,7 @@ int sam_gmac_initialize(void)
* the interface is in the 'up' state.
*/
- ret = irq_attach(SAM_IRQ_GMAC, sam_gmac_interrupt);
+ ret = irq_attach(SAM_IRQ_GMAC, sam_gmac_interrupt, NULL);
if (ret < 0)
{
nerr("ERROR: Failed to attach the handler to the IRQ%d\n", SAM_IRQ_GMAC);
diff --git a/arch/arm/src/sama5/sam_hsmci.c b/arch/arm/src/sama5/sam_hsmci.c
index a76e471319e9d642ad2cb320e63479b0c0a5d7e9..3aa006d87227119ae15e9bbd91b948cb599272ad 100644
--- a/arch/arm/src/sama5/sam_hsmci.c
+++ b/arch/arm/src/sama5/sam_hsmci.c
@@ -436,17 +436,17 @@ struct sam_dev_s
/* Debug stuff */
#ifdef CONFIG_SAMA5_HSMCI_REGDEBUG
- bool wrlast; /* Last was a write */
- uint32_t addrlast; /* Last address */
- uint32_t vallast; /* Last value */
- int ntimes; /* Number of times */
+ bool wrlast; /* Last was a write */
+ uint32_t addrlast; /* Last address */
+ uint32_t vallast; /* Last value */
+ int ntimes; /* Number of times */
#endif
/* Register logging support */
#if defined(CONFIG_SAMA5_HSMCI_CMDDEBUG) && defined(CONFIG_SAMA5_HSMCI_XFRDEBUG)
- bool xfrinitialized;
- bool cmdinitialized;
+ bool xfrinitialized;
+ bool cmdinitialized;
#endif
#ifdef CONFIG_SAMA5_HSMCI_XFRDEBUG
uint8_t smplset;
@@ -537,16 +537,7 @@ static void sam_notransfer(struct sam_dev_s *priv);
/* Interrupt Handling *******************************************************/
-static int sam_hsmci_interrupt(struct sam_dev_s *priv);
-#ifdef CONFIG_SAMA5_HSMCI0
-static int sam_hsmci0_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_SAMA5_HSMCI1
-static int sam_hsmci1_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_SAMA5_HSMCI2
-static int sam_hsmci2_interrupt(int irq, void *context);
-#endif
+static int sam_hsmci_interrupt(int irq, void *context, void *arg);
/* SDIO interface methods ***************************************************/
@@ -1512,12 +1503,15 @@ static void sam_notransfer(struct sam_dev_s *priv)
*
****************************************************************************/
-static int sam_hsmci_interrupt(struct sam_dev_s *priv)
+static int sam_hsmci_interrupt(int irq, void *context, void *arg)
{
+ struct sam_dev_s *priv = (struct sam_dev_s *)arg;
uint32_t sr;
uint32_t enabled;
uint32_t pending;
+ DEBUGASSERT(priv != NULL);
+
/* Loop while there are pending interrupts. */
for (; ; )
@@ -1661,42 +1655,6 @@ static int sam_hsmci_interrupt(struct sam_dev_s *priv)
return OK;
}
-/****************************************************************************
- * Name: sam_hsmci0_interrupt, sam_hsmci1_interrupt, and sam_hsmci2_interrupt
- *
- * Description:
- * HSMCI interrupt handler
- *
- * Input Parameters:
- * irq - IRQ number of the interrupts
- * context - Saved machine context at the time of the interrupt
- *
- * Returned Value:
- * None
- *
- ****************************************************************************/
-
-#ifdef CONFIG_SAMA5_HSMCI0
-static int sam_hsmci0_interrupt(int irq, void *context)
-{
- return sam_hsmci_interrupt(&g_hsmci0);
-}
-#endif
-
-#ifdef CONFIG_SAMA5_HSMCI1
-static int sam_hsmci1_interrupt(int irq, void *context)
-{
- return sam_hsmci_interrupt(&g_hsmci1);
-}
-#endif
-
-#ifdef CONFIG_SAMA5_HSMCI2
-static int sam_hsmci2_interrupt(int irq, void *context)
-{
- return sam_hsmci_interrupt(&g_hsmci2);
-}
-#endif
-
/****************************************************************************
* SDIO Interface Methods
****************************************************************************/
@@ -1947,7 +1905,6 @@ static void sam_clock(FAR struct sdio_dev_s *dev, enum sdio_clock_e rate)
static int sam_attach(FAR struct sdio_dev_s *dev)
{
struct sam_dev_s *priv = (struct sam_dev_s *)dev;
- xcpt_t handler;
int irq;
int ret;
@@ -1956,24 +1913,21 @@ static int sam_attach(FAR struct sdio_dev_s *dev)
#ifdef CONFIG_SAMA5_HSMCI0
if (priv->hsmci == 0)
{
- handler = sam_hsmci0_interrupt;
- irq = SAM_IRQ_HSMCI0;
+ irq = SAM_IRQ_HSMCI0;
}
else
#endif
#ifdef CONFIG_SAMA5_HSMCI1
if (priv->hsmci == 1)
{
- handler = sam_hsmci1_interrupt;
- irq = SAM_IRQ_HSMCI1;
+ irq = SAM_IRQ_HSMCI1;
}
else
#endif
#ifdef CONFIG_SAMA5_HSMCI2
if (priv->hsmci == 2)
{
- handler = sam_hsmci2_interrupt;
- irq = SAM_IRQ_HSMCI2;
+ irq = SAM_IRQ_HSMCI2;
}
else
#endif
@@ -1984,7 +1938,7 @@ static int sam_attach(FAR struct sdio_dev_s *dev)
/* Attach the HSMCI interrupt handler */
- ret = irq_attach(irq, handler);
+ ret = irq_attach(irq, sam_hsmci_interrupt, priv);
if (ret == OK)
{
diff --git a/arch/arm/src/sama5/sam_nand.c b/arch/arm/src/sama5/sam_nand.c
index 1ac8e2a9ba6fa5f3278b291ce6ba996ccee2595c..05182120d93c847bf86a8654395e460cf0e5ba07 100644
--- a/arch/arm/src/sama5/sam_nand.c
+++ b/arch/arm/src/sama5/sam_nand.c
@@ -181,7 +181,7 @@ static void nand_wait_nfcbusy(struct sam_nandcs_s *priv);
#endif
static uint32_t nand_nfc_poll(void);
#ifdef CONFIG_SAMA5_NAND_HSMCINTERRUPTS
-static int hsmc_interrupt(int irq, void *context);
+static int hsmc_interrupt(int irq, void *context, FAR void *arg);
#endif
/* DMA Helpers */
@@ -1059,7 +1059,7 @@ static uint32_t nand_nfc_poll(void)
****************************************************************************/
#ifdef CONFIG_SAMA5_NAND_HSMCINTERRUPTS
-static int hsmc_interrupt(int irq, void *context)
+static int hsmc_interrupt(int irq, void *context, FAR void *arg)
{
uint32_t sr = nand_nfc_poll();
uint32_t imr = nand_getreg(SAM_HSMC_IMR);
@@ -2992,7 +2992,7 @@ struct mtd_dev_s *sam_nand_initialize(int cs)
#ifdef CONFIG_SAMA5_NAND_HSMCINTERRUPTS
/* Attach the CAN interrupt handler */
- ret = irq_attach(SAM_IRQ_HSMC, hsmc_interrupt);
+ ret = irq_attach(SAM_IRQ_HSMC, hsmc_interrupt, NULL);
if (ret < 0)
{
ferr("ERROR: Failed to attach HSMC IRQ (%d)", SAM_IRQ_HSMC);
diff --git a/arch/arm/src/sama5/sam_ohci.c b/arch/arm/src/sama5/sam_ohci.c
index b4a6b03f92d1b24ec2cb46dc17699c8ec0537065..f6907d1b0f2274602b25f65898566be20edd3b92 100644
--- a/arch/arm/src/sama5/sam_ohci.c
+++ b/arch/arm/src/sama5/sam_ohci.c
@@ -4109,7 +4109,7 @@ struct usbhost_connection_s *sam_ohci_initialize(int controller)
* then it will manage the shared interrupt.
*/
- if (irq_attach(SAM_IRQ_UHPHS, sam_ohci_tophalf) != 0)
+ if (irq_attach(SAM_IRQ_UHPHS, sam_ohci_tophalf, NULL) != 0)
{
usbhost_trace1(OHCI_TRACE1_IRQATTACH, SAM_IRQ_UHPHS);
return NULL;
@@ -4176,7 +4176,7 @@ struct usbhost_connection_s *sam_ohci_initialize(int controller)
*
****************************************************************************/
-int sam_ohci_tophalf(int irq, void *context)
+int sam_ohci_tophalf(int irq, void *context, FAR void *arg)
{
uint32_t intst;
uint32_t inten;
diff --git a/arch/arm/src/sama5/sam_pioirq.c b/arch/arm/src/sama5/sam_pioirq.c
index 2d9950168ed167b52abd7cb4f2f12a11fe47be46..97aef6a0bce21afb7a27580b30a689808890d3d1 100644
--- a/arch/arm/src/sama5/sam_pioirq.c
+++ b/arch/arm/src/sama5/sam_pioirq.c
@@ -202,42 +202,42 @@ static int sam_piointerrupt(uint32_t base, int irq0, void *context)
}
#ifdef CONFIG_SAMA5_PIOA_IRQ
-static int sam_pioainterrupt(int irq, void *context)
+static int sam_pioainterrupt(int irq, void *context, FAR void *arg)
{
return sam_piointerrupt(SAM_PIOA_VBASE, SAM_IRQ_PA0, context);
}
#endif
#ifdef CONFIG_SAMA5_PIOB_IRQ
-static int sam_piobinterrupt(int irq, void *context)
+static int sam_piobinterrupt(int irq, void *context, FAR void *arg)
{
return sam_piointerrupt(SAM_PIOB_VBASE, SAM_IRQ_PB0, context);
}
#endif
#ifdef CONFIG_SAMA5_PIOC_IRQ
-static int sam_piocinterrupt(int irq, void *context)
+static int sam_piocinterrupt(int irq, void *context, FAR void *arg)
{
return sam_piointerrupt(SAM_PIOC_VBASE, SAM_IRQ_PC0, context);
}
#endif
#ifdef CONFIG_SAMA5_PIOD_IRQ
-static int sam_piodinterrupt(int irq, void *context)
+static int sam_piodinterrupt(int irq, void *context, FAR void *arg)
{
return sam_piointerrupt(SAM_PIOD_VBASE, SAM_IRQ_PD0, context);
}
#endif
#ifdef CONFIG_SAMA5_PIOE_IRQ
-static int sam_pioeinterrupt(int irq, void *context)
+static int sam_pioeinterrupt(int irq, void *context, FAR void *arg)
{
return sam_piointerrupt(SAM_PIOE_VBASE, SAM_IRQ_PE0, context);
}
#endif
#ifdef CONFIG_SAMA5_PIOF_IRQ
-static int sam_piofinterrupt(int irq, void *context)
+static int sam_piofinterrupt(int irq, void *context, FAR void *arg)
{
return sam_piointerrupt(SAM_PIOF_VBASE, SAM_IRQ_PF0, context);
}
@@ -272,7 +272,7 @@ void sam_pioirqinitialize(void)
/* Attach and enable the PIOA IRQ */
- (void)irq_attach(SAM_IRQ_PIOA, sam_pioainterrupt);
+ (void)irq_attach(SAM_IRQ_PIOA, sam_pioainterrupt, NULL);
up_enable_irq(SAM_IRQ_PIOA);
#endif
@@ -290,7 +290,7 @@ void sam_pioirqinitialize(void)
/* Attach and enable the PIOB IRQ */
- (void)irq_attach(SAM_IRQ_PIOB, sam_piobinterrupt);
+ (void)irq_attach(SAM_IRQ_PIOB, sam_piobinterrupt, NULL);
up_enable_irq(SAM_IRQ_PIOB);
#endif
@@ -308,7 +308,7 @@ void sam_pioirqinitialize(void)
/* Attach and enable the PIOC IRQ */
- (void)irq_attach(SAM_IRQ_PIOC, sam_piocinterrupt);
+ (void)irq_attach(SAM_IRQ_PIOC, sam_piocinterrupt, NULL);
up_enable_irq(SAM_IRQ_PIOC);
#endif
@@ -326,7 +326,7 @@ void sam_pioirqinitialize(void)
/* Attach and enable the PIOC IRQ */
- (void)irq_attach(SAM_IRQ_PIOD, sam_piodinterrupt);
+ (void)irq_attach(SAM_IRQ_PIOD, sam_piodinterrupt, NULL);
up_enable_irq(SAM_IRQ_PIOD);
#endif
@@ -344,7 +344,7 @@ void sam_pioirqinitialize(void)
/* Attach and enable the PIOE IRQ */
- (void)irq_attach(SAM_IRQ_PIOE, sam_pioeinterrupt);
+ (void)irq_attach(SAM_IRQ_PIOE, sam_pioeinterrupt, NULL);
up_enable_irq(SAM_IRQ_PIOE);
#endif
@@ -362,7 +362,7 @@ void sam_pioirqinitialize(void)
/* Attach and enable the PIOF IRQ */
- (void)irq_attach(SAM_IRQ_PIOF, sam_piofinterrupt);
+ (void)irq_attach(SAM_IRQ_PIOF, sam_piofinterrupt, NULL);
up_enable_irq(SAM_IRQ_PIOF);
#endif
}
diff --git a/arch/arm/src/sama5/sam_pwm.c b/arch/arm/src/sama5/sam_pwm.c
index 622d4569b0f09385ea953d3d1723ab7b5f970c0d..90b204eac30c03d958419e8b082d309dfb90de64 100644
--- a/arch/arm/src/sama5/sam_pwm.c
+++ b/arch/arm/src/sama5/sam_pwm.c
@@ -330,7 +330,7 @@ static void pwm_dumpregs(FAR struct sam_pwm_chan_s *chan, FAR const char *msg);
/* PWM Interrupts */
#ifdef PWM_INTERRUPTS
-static int pwm_interrupt(int irq, void *context);
+static int pwm_interrupt(int irq, void *context, FAR void *arg);
#endif
/* PWM driver methods */
@@ -836,7 +836,7 @@ static void pwm_dumpregs(struct sam_pwm_chan_s *chan, FAR const char *msg)
****************************************************************************/
#ifdef PWM_INTERRUPTS
-static int pwm_interrupt(int irq, void *context)
+static int pwm_interrupt(int irq, void *context, FAR void *arg)
{
/* No PWM interrupts are used in the current design */
@@ -1393,7 +1393,7 @@ FAR struct pwm_lowerhalf_s *sam_pwminitialize(int channel)
/* Attach the PWM interrupt handler */
#ifdef PWM_INTERRUPTS
- ret = irq_attach(SAM_IRQ_PWM, pwm_interrupt);
+ ret = irq_attach(SAM_IRQ_PWM, pwm_interrupt, NULL);
if (ret < 0)
{
pwmerr("ERROR: Failed to attach IRQ%d\n", channel);
diff --git a/arch/arm/src/sama5/sam_rtc.c b/arch/arm/src/sama5/sam_rtc.c
index e73e473b706a7f8e25676f08da7e994d883c4b37..b5a893b361658cdb11306b3abbd6a712875cfda0 100644
--- a/arch/arm/src/sama5/sam_rtc.c
+++ b/arch/arm/src/sama5/sam_rtc.c
@@ -255,7 +255,7 @@ static void rtc_worker(FAR void *arg)
************************************************************************************/
#ifdef CONFIG_RTC_ALARM
-static int rtc_interrupt(int irq, void *context)
+static int rtc_interrupt(int irq, void *context, FAR void *arg)
{
int ret;
@@ -321,7 +321,7 @@ int up_rtc_initialize(void)
#ifdef CONFIG_RTC_ALARM
/* Then attach the ALARM interrupt handler */
- irq_attach(SAM_PID_SYS, rtc_interrupt);
+ irq_attach(SAM_PID_SYS, rtc_interrupt, NULL);
/* Should RTC alarm interrupt be enabled at the peripheral? Let's assume so
* for now. Let's say yes if the time is valid and a valid alarm has been
diff --git a/arch/arm/src/sama5/sam_serial.c b/arch/arm/src/sama5/sam_serial.c
index a73ac33cd24f3b190db4fe9e4032544ca5e1f3c6..b9da00d8555bbc86d9e46b630be1364d454e2dc0 100644
--- a/arch/arm/src/sama5/sam_serial.c
+++ b/arch/arm/src/sama5/sam_serial.c
@@ -418,7 +418,6 @@
struct up_dev_s
{
- xcpt_t handler; /* Interrupt handler */
uint32_t usartbase; /* Base address of USART registers */
uint32_t baud; /* Configured baud */
uint32_t sr; /* Saved status bits */
@@ -435,38 +434,7 @@ struct up_dev_s
* Private Function Prototypes
****************************************************************************/
-static int up_interrupt(struct uart_dev_s *dev);
-#ifdef CONFIG_SAMA5_UART0
-static int up_uart0_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_SAMA5_UART1
-static int up_uart1_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_SAMA5_UART2
-static int up_uart2_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_SAMA5_UART3
-static int up_uart3_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_SAMA5_UART4
-static int up_uart4_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_USART0_SERIALDRIVER
-static int up_usart0_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_USART1_SERIALDRIVER
-static int up_usart1_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_USART2_SERIALDRIVER
-static int up_usart2_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_USART3_SERIALDRIVER
-static int up_usart3_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_USART4_SERIALDRIVER
-static int up_usart4_interrupt(int irq, void *context);
-#endif
-
+static int up_interrupt(int irq, void *context, FAR void *arg);
static int up_setup(struct uart_dev_s *dev);
static void up_shutdown(struct uart_dev_s *dev);
static int up_attach(struct uart_dev_s *dev);
@@ -561,7 +529,6 @@ static char g_usart4txbuffer[CONFIG_USART4_TXBUFSIZE];
static struct up_dev_s g_uart0priv =
{
- .handler = up_uart0_interrupt,
.usartbase = SAM_UART0_VBASE,
.baud = CONFIG_UART0_BAUD,
.irq = SAM_IRQ_UART0,
@@ -602,7 +569,6 @@ static uart_dev_t g_uart0port =
static struct up_dev_s g_uart1priv =
{
- .handler = up_uart1_interrupt,
.usartbase = SAM_UART1_VBASE,
.baud = CONFIG_UART1_BAUD,
.irq = SAM_IRQ_UART1,
@@ -643,7 +609,6 @@ static uart_dev_t g_uart1port =
static struct up_dev_s g_uart2priv =
{
- .handler = up_uart2_interrupt,
.usartbase = SAM_UART2_VBASE,
.baud = CONFIG_UART2_BAUD,
.irq = SAM_IRQ_UART2,
@@ -684,7 +649,6 @@ static uart_dev_t g_uart2port =
static struct up_dev_s g_uart3priv =
{
- .handler = up_uart3_interrupt,
.usartbase = SAM_UART3_VBASE,
.baud = CONFIG_UART3_BAUD,
.irq = SAM_IRQ_UART3,
@@ -725,7 +689,6 @@ static uart_dev_t g_uart3port =
static struct up_dev_s g_uart4priv =
{
- .handler = up_uart4_interrupt,
.usartbase = SAM_UART4_VBASE,
.baud = CONFIG_UART4_BAUD,
.irq = SAM_IRQ_UART4,
@@ -756,7 +719,6 @@ static uart_dev_t g_uart4port =
#ifdef CONFIG_USART0_SERIALDRIVER
static struct up_dev_s g_usart0priv =
{
- .handler = up_usart0_interrupt,
.usartbase = SAM_USART0_VBASE,
.baud = CONFIG_USART0_BAUD,
.irq = SAM_IRQ_USART0,
@@ -790,7 +752,6 @@ static uart_dev_t g_usart0port =
#ifdef CONFIG_USART1_SERIALDRIVER
static struct up_dev_s g_usart1priv =
{
- .handler = up_usart1_interrupt,
.usartbase = SAM_USART1_VBASE,
.baud = CONFIG_USART1_BAUD,
.irq = SAM_IRQ_USART1,
@@ -824,7 +785,6 @@ static uart_dev_t g_usart1port =
#ifdef CONFIG_USART2_SERIALDRIVER
static struct up_dev_s g_usart2priv =
{
- .handler = up_usart2_interrupt,
.usartbase = SAM_USART2_VBASE,
.baud = CONFIG_USART2_BAUD,
.irq = SAM_IRQ_USART2,
@@ -858,7 +818,6 @@ static uart_dev_t g_usart2port =
#ifdef CONFIG_USART3_SERIALDRIVER
static struct up_dev_s g_usart3priv =
{
- .handler = up_usart3_interrupt,
.usartbase = SAM_USART3_VBASE,
.baud = CONFIG_USART3_BAUD,
.irq = SAM_IRQ_USART3,
@@ -892,7 +851,6 @@ static uart_dev_t g_usart3port =
#ifdef CONFIG_USART4_SERIALDRIVER
static struct up_dev_s g_usart4priv =
{
- .handler = up_usart4_interrupt,
.usartbase = SAM_USART4_VBASE,
.baud = CONFIG_USART4_BAUD,
.irq = SAM_IRQ_USART4,
@@ -989,8 +947,9 @@ static void up_disableallints(struct up_dev_s *priv, uint32_t *imr)
*
****************************************************************************/
-static int up_interrupt(struct uart_dev_s *dev)
+static int up_interrupt(int irq, void *context, FAR void *arg)
{
+ struct uart_dev_s *dev = (struct uart_dev_s *)arg;
struct up_dev_s *priv;
uint32_t pending;
uint32_t imr;
@@ -1043,67 +1002,6 @@ static int up_interrupt(struct uart_dev_s *dev)
return OK;
}
-#ifdef CONFIG_SAMA5_UART0
-static int up_uart0_interrupt(int irq, void *context)
-{
- return up_interrupt(&g_uart0port);
-}
-#endif
-#ifdef CONFIG_SAMA5_UART1
-static int up_uart1_interrupt(int irq, void *context)
-{
- return up_interrupt(&g_uart1port);
-}
-#endif
-#ifdef CONFIG_SAMA5_UART2
-static int up_uart2_interrupt(int irq, void *context)
-{
- return up_interrupt(&g_uart2port);
-}
-#endif
-#ifdef CONFIG_SAMA5_UART3
-static int up_uart3_interrupt(int irq, void *context)
-{
- return up_interrupt(&g_uart3port);
-}
-#endif
-#ifdef CONFIG_SAMA5_UART4
-static int up_uart4_interrupt(int irq, void *context)
-{
- return up_interrupt(&g_uart4port);
-}
-#endif
-#ifdef CONFIG_USART0_SERIALDRIVER
-static int up_usart0_interrupt(int irq, void *context)
-{
- return up_interrupt(&g_usart0port);
-}
-#endif
-#ifdef CONFIG_USART1_SERIALDRIVER
-static int up_usart1_interrupt(int irq, void *context)
-{
- return up_interrupt(&g_usart1port);
-}
-#endif
-#ifdef CONFIG_USART2_SERIALDRIVER
-static int up_usart2_interrupt(int irq, void *context)
-{
- return up_interrupt(&g_usart2port);
-}
-#endif
-#ifdef CONFIG_USART3_SERIALDRIVER
-static int up_usart3_interrupt(int irq, void *context)
-{
- return up_interrupt(&g_usart3port);
-}
-#endif
-#ifdef CONFIG_USART4_SERIALDRIVER
-static int up_usart4_interrupt(int irq, void *context)
-{
- return up_interrupt(&g_usart4port);
-}
-#endif
-
/****************************************************************************
* Name: up_setup
*
@@ -1294,7 +1192,7 @@ static int up_attach(struct uart_dev_s *dev)
/* Attach and enable the IRQ */
- ret = irq_attach(priv->irq, priv->handler);
+ ret = irq_attach(priv->irq, up_interrupt, dev);
if (ret == OK)
{
/* Enable the interrupt (RX and TX interrupts are still disabled
diff --git a/arch/arm/src/sama5/sam_tc.c b/arch/arm/src/sama5/sam_tc.c
index 7d8e19370cc64d87d4d653ade7d888d60055ffcd..015d6bc96a5958a97d4a79b96de254631bf1fa5b 100644
--- a/arch/arm/src/sama5/sam_tc.c
+++ b/arch/arm/src/sama5/sam_tc.c
@@ -175,13 +175,13 @@ static inline void sam_chan_putreg(struct sam_chan_s *chan,
static int sam_tc_interrupt(struct sam_tc_s *tc);
#ifdef CONFIG_SAMA5_TC0
-static int sam_tc012_interrupt(int irq, void *context);
+static int sam_tc012_interrupt(int irq, void *context, FAR void *arg);
#endif
#ifdef CONFIG_SAMA5_TC1
-static int sam_tc345_interrupt(int irq, void *context);
+static int sam_tc345_interrupt(int irq, void *context, FAR void *arg);
#endif
#ifdef CONFIG_SAMA5_TC2
-static int sam_tc678_interrupt(int irq, void *context);
+static int sam_tc678_interrupt(int irq, void *context, FAR void *arg);
#endif
/* Initialization ***********************************************************/
@@ -763,21 +763,21 @@ static int sam_tc_interrupt(struct sam_tc_s *tc)
****************************************************************************/
#ifdef CONFIG_SAMA5_TC0
-static int sam_tc012_interrupt(int irq, void *context)
+static int sam_tc012_interrupt(int irq, void *context, void *arg)
{
return sam_tc_interrupt(&g_tc012);
}
#endif
#ifdef CONFIG_SAMA5_TC1
-static int sam_tc345_interrupt(int irq, void *context)
+static int sam_tc345_interrupt(int irq, void *context, FAR void *arg)
{
return sam_tc_interrupt(&g_tc345);
}
#endif
#ifdef CONFIG_SAMA5_TC2
-static int sam_tc678_interrupt(int irq, void *context)
+static int sam_tc678_interrupt(int irq, void *context, FAR void *arg)
{
return sam_tc_interrupt(&g_tc678);
}
@@ -1038,7 +1038,7 @@ static inline struct sam_chan_s *sam_tc_initialize(int channel)
/* Attach the timer interrupt handler and enable the timer interrupts */
- (void)irq_attach(tc->pid, handler);
+ (void)irq_attach(tc->pid, handler, NULL);
up_enable_irq(tc->pid);
/* Now the channel is initialized */
diff --git a/arch/arm/src/sama5/sam_timerisr.c b/arch/arm/src/sama5/sam_timerisr.c
index 3495bc642717b2f20fdd438a3da6b8216323bb07..957c4efad2463147e77e4a399f1be8e4d4bc1f90 100644
--- a/arch/arm/src/sama5/sam_timerisr.c
+++ b/arch/arm/src/sama5/sam_timerisr.c
@@ -88,7 +88,7 @@
*
****************************************************************************/
-static int sam_timerisr(int irq, uint32_t *regs)
+static int sam_timerisr(int irq, uint32_t *regs, void *arg)
{
/* "When CPIV and PICNT values are obtained by reading the Periodic
* Interval Value Register (PIT_PIVR), the overflow counter (PICNT) is
@@ -136,7 +136,7 @@ void arm_timer_initialize(void)
/* Attach the timer interrupt vector */
- (void)irq_attach(SAM_IRQ_PIT, (xcpt_t)sam_timerisr);
+ (void)irq_attach(SAM_IRQ_PIT, (xcpt_t)sam_timerisr, NULL);
/* Set the PIT overflow value (PIV), enable the PIT, and enable
* interrupts from the PIT.
diff --git a/arch/arm/src/sama5/sam_trng.c b/arch/arm/src/sama5/sam_trng.c
index c724612456a515f0df1fa341e3acba216d032f8d..fed9a347acfa3f90d9ece8a09b0e04ce9f372003 100644
--- a/arch/arm/src/sama5/sam_trng.c
+++ b/arch/arm/src/sama5/sam_trng.c
@@ -71,7 +71,7 @@
/* Interrupts */
-static int sam_interrupt(int irq, void *context);
+static int sam_interrupt(int irq, void *context, FAR void *arg);
/* Character driver methods */
@@ -127,7 +127,7 @@ static const struct file_operations g_trngops =
*
****************************************************************************/
-static int sam_interrupt(int irq, void *context)
+static int sam_interrupt(int irq, void *context, FAR void *arg)
{
uint32_t odata;
@@ -371,7 +371,7 @@ static int sam_rng_initialize(void)
/* Initialize the TRNG interrupt */
- ret = irq_attach(SAM_IRQ_TRNG, sam_interrupt);
+ ret = irq_attach(SAM_IRQ_TRNG, sam_interrupt, NULL);
if (ret < 0)
{
ferr("ERROR: Failed to attach to IRQ%d\n", SAM_IRQ_TRNG);
diff --git a/arch/arm/src/sama5/sam_twi.c b/arch/arm/src/sama5/sam_twi.c
index 52f3e0950d10f9dce350ca60d918bc516b1ca62e..117f29b44516263c2761db8c14f5ba5844582dd4 100644
--- a/arch/arm/src/sama5/sam_twi.c
+++ b/arch/arm/src/sama5/sam_twi.c
@@ -199,21 +199,9 @@ static inline void twi_putrel(struct twi_dev_s *priv, unsigned int offset,
/* I2C transfer helper functions */
-static int twi_wait(struct twi_dev_s *priv, unsigned int size);
+static int twi_wait(struct twi_dev_s *priv, unsigned int size);
static void twi_wakeup(struct twi_dev_s *priv, int result);
-static int twi_interrupt(struct twi_dev_s *priv);
-#ifdef CONFIG_SAMA5_TWI0
-static int twi0_interrupt(int irq, FAR void *context);
-#endif
-#ifdef CONFIG_SAMA5_TWI1
-static int twi1_interrupt(int irq, FAR void *context);
-#endif
-#ifdef CONFIG_SAMA5_TWI2
-static int twi2_interrupt(int irq, FAR void *context);
-#endif
-#ifdef CONFIG_SAMA5_TWI3
-static int twi3_interrupt(int irq, FAR void *context);
-#endif
+static int twi_interrupt(int irq, FAR void *context, FAR void *arg);
static void twi_timeout(int argc, uint32_t arg, ...);
static void twi_startread(struct twi_dev_s *priv, struct i2c_msg_s *msg);
@@ -246,7 +234,6 @@ static const struct twi_attr_s g_twi0attr =
.sclcfg = PIO_TWI0_CK,
.sdacfg = PIO_TWI0_D,
.base = SAM_TWI0_VBASE,
- .handler = twi0_interrupt,
};
static struct twi_dev_s g_twi0;
@@ -261,7 +248,6 @@ static const struct twi_attr_s g_twi1attr =
.sclcfg = PIO_TWI1_CK,
.sdacfg = PIO_TWI1_D,
.base = SAM_TWI1_VBASE,
- .handler = twi1_interrupt,
};
static struct twi_dev_s g_twi1;
@@ -276,7 +262,6 @@ static const struct twi_attr_s g_twi2attr =
.sclcfg = PIO_TWI2_CK,
.sdacfg = PIO_TWI2_D,
.base = SAM_TWI2_VBASE,
- .handler = twi2_interrupt,
};
static struct twi_dev_s g_twi2;
@@ -291,7 +276,6 @@ static const struct twi_attr_s g_twi3attr =
.sclcfg = PIO_TWI3_CK,
.sdacfg = PIO_TWI3_D,
.base = SAM_TWI3_VBASE,
- .handler = twi3_interrupt,
};
static struct twi_dev_s g_twi3;
@@ -550,14 +534,17 @@ static void twi_wakeup(struct twi_dev_s *priv, int result)
*
****************************************************************************/
-static int twi_interrupt(struct twi_dev_s *priv)
+static int twi_interrupt(int irq, FAR void *context, FAR void *arg)
{
+ struct twi_dev_s *priv = (struct twi_dev_s *)arg;
struct i2c_msg_s *msg;
uint32_t sr;
uint32_t imr;
uint32_t pending;
uint32_t regval;
+ DEBUGASSERT(priv != NULL);
+
/* Retrieve masked interrupt status */
sr = twi_getrel(priv, SAM_TWI_SR_OFFSET);
@@ -667,34 +654,6 @@ static int twi_interrupt(struct twi_dev_s *priv)
return OK;
}
-#ifdef CONFIG_SAMA5_TWI0
-static int twi0_interrupt(int irq, FAR void *context)
-{
- return twi_interrupt(&g_twi0);
-}
-#endif
-
-#ifdef CONFIG_SAMA5_TWI1
-static int twi1_interrupt(int irq, FAR void *context)
-{
- return twi_interrupt(&g_twi1);
-}
-#endif
-
-#ifdef CONFIG_SAMA5_TWI2
-static int twi2_interrupt(int irq, FAR void *context)
-{
- return twi_interrupt(&g_twi2);
-}
-#endif
-
-#ifdef CONFIG_SAMA5_TWI3
-static int twi3_interrupt(int irq, FAR void *context)
-{
- return twi_interrupt(&g_twi3);
-}
-#endif
-
/****************************************************************************
* Name: twi_timeout
*
@@ -1296,7 +1255,7 @@ struct i2c_master_s *sam_i2cbus_initialize(int bus)
/* Attach Interrupt Handler */
- ret = irq_attach(priv->attr->irq, priv->attr->handler);
+ ret = irq_attach(priv->attr->irq, twi_interrupt, priv);
if (ret < 0)
{
ierr("ERROR: Failed to attach irq %d\n", priv->attr->irq);
diff --git a/arch/arm/src/sama5/sam_udphs.c b/arch/arm/src/sama5/sam_udphs.c
index 76f704d1f690b19d19a416430f02a59ddf9ac6c1..3f27bd311224c04f2f47e31e2c84549779486c9f 100644
--- a/arch/arm/src/sama5/sam_udphs.c
+++ b/arch/arm/src/sama5/sam_udphs.c
@@ -448,7 +448,7 @@ static void sam_setdevaddr(struct sam_usbdev_s *priv, uint8_t value);
static void sam_ep0_setup(struct sam_usbdev_s *priv);
static void sam_dma_interrupt(struct sam_usbdev_s *priv, int chan);
static void sam_ep_interrupt(struct sam_usbdev_s *priv, int epno);
-static int sam_udphs_interrupt(int irq, void *context);
+static int sam_udphs_interrupt(int irq, void *context, FAR void *arg);
/* Endpoint helpers *********************************************************/
@@ -2770,7 +2770,7 @@ static void sam_ep_interrupt(struct sam_usbdev_s *priv, int epno)
*
****************************************************************************/
-static int sam_udphs_interrupt(int irq, void *context)
+static int sam_udphs_interrupt(int irq, void *context, FAR void *arg)
{
/* For now there is only one USB controller, but we will always refer to
* it using a pointer to make any future ports to multiple UDPHS controllers
@@ -4437,7 +4437,7 @@ void up_usbinitialize(void)
* them when we need them later.
*/
- if (irq_attach(SAM_IRQ_UDPHS, sam_udphs_interrupt) != 0)
+ if (irq_attach(SAM_IRQ_UDPHS, sam_udphs_interrupt, NULL) != 0)
{
usbtrace(TRACE_DEVERROR(SAM_TRACEERR_IRQREGISTRATION),
(uint16_t)SAM_IRQ_UDPHS);
diff --git a/arch/arm/src/sama5/sam_usbhost.h b/arch/arm/src/sama5/sam_usbhost.h
index a67a0a42ddc71c6292ec9cefd279a6df6f9aeb74..90e2b81a5909504dc11047968c0adb3cf34f98d6 100644
--- a/arch/arm/src/sama5/sam_usbhost.h
+++ b/arch/arm/src/sama5/sam_usbhost.h
@@ -271,7 +271,7 @@ FAR struct usbhost_connection_s *sam_ohci_initialize(int controller);
************************************************************************************/
#ifdef CONFIG_SAMA5_OHCI
-int sam_ohci_tophalf(int irq, FAR void *context);
+int sam_ohci_tophalf(int irq, FAR void *context, FAR void *arg);
#endif
/************************************************************************************
diff --git a/arch/arm/src/sama5/sam_wdt.c b/arch/arm/src/sama5/sam_wdt.c
index 342aa5c8f3dba58f99905f38f2ac2c068d3475f2..9d3f7dd61eaed194699b3e485a7712664a01b036 100644
--- a/arch/arm/src/sama5/sam_wdt.c
+++ b/arch/arm/src/sama5/sam_wdt.c
@@ -120,7 +120,7 @@ static void sam_putreg(uint32_t regval, uintptr_t regaddr);
/* Interrupt hanlding *******************************************************/
#ifdef CONFIG_SAMA5_WDT_INTERRUPT
-static int sam_interrupt(int irq, FAR void *context);
+static int sam_interrupt(int irq, FAR void *context, FAR void *arg);
#endif
/* "Lower half" driver methods **********************************************/
@@ -260,7 +260,7 @@ static void sam_putreg(uint32_t regval, uintptr_t regaddr)
****************************************************************************/
#ifdef CONFIG_SAMA5_WDT_INTERRUPT
-static int sam_interrupt(int irq, FAR void *context)
+static int sam_interrupt(int irq, FAR void *context, FAR void *arg)
{
FAR struct sam_lowerhalf_s *priv = &g_wdtdev;
@@ -684,7 +684,7 @@ int sam_wdt_initialize(void)
#ifdef CONFIG_SAMA5_WDT_INTERRUPT
/* Attach our WDT interrupt handler (But don't enable it yet) */
- (void)irq_attach(SAM_IRQ_WDT, sam_interrupt);
+ (void)irq_attach(SAM_IRQ_WDT, sam_interrupt, NULL);
#endif
/* Register the watchdog driver at the configured location (default
diff --git a/arch/arm/src/sama5/sam_xdmac.c b/arch/arm/src/sama5/sam_xdmac.c
index 9b819555569e3079c1fcc3fed55cd10542da9d36..54386d92e197975f0605e885d6fc5c105cf6b6ff 100644
--- a/arch/arm/src/sama5/sam_xdmac.c
+++ b/arch/arm/src/sama5/sam_xdmac.c
@@ -1825,14 +1825,17 @@ static void sam_dmaterminate(struct sam_xdmach_s *xdmach, int result)
*
****************************************************************************/
-static int sam_xdmac_interrupt(struct sam_xdmac_s *xdmac)
+static int sam_xdmac_interrupt(int irq, void *context, FAR void *arg)
{
+ struct sam_xdmac_s *xdmac = (struct sam_xdmac_s *)arg;
struct sam_xdmach_s *xdmach;
unsigned int chndx;
uint32_t gpending;
uint32_t chpending;
uint32_t bit;
+ DEBUGASSERT(xdmac != NULL);
+
/* Get the set of pending, unmasked global XDMAC interrupts */
gpending = sam_getdmac(xdmac, SAM_XDMAC_GIS_OFFSET) &
@@ -1890,28 +1893,6 @@ static int sam_xdmac_interrupt(struct sam_xdmac_s *xdmac)
return OK;
}
-/****************************************************************************
- * Name: sam_xdmac0_interrupt and sam_xdmac1_interrupt
- *
- * Description:
- * DMA interrupt handler
- *
- ****************************************************************************/
-
-#ifdef CONFIG_SAMA5_XDMAC0
-static int sam_xdmac0_interrupt(int irq, void *context)
-{
- return sam_xdmac_interrupt(&g_xdmac0);
-}
-#endif
-
-#ifdef CONFIG_SAMA5_XDMAC1
-static int sam_xdmac1_interrupt(int irq, void *context)
-{
- return sam_xdmac_interrupt(&g_xdmac1);
-}
-#endif
-
/****************************************************************************
* Name: sam_dmainitialize
*
@@ -1965,7 +1946,7 @@ void weak_function up_dmainitialize(void)
/* Attach DMA interrupt vector */
- (void)irq_attach(SAM_IRQ_XDMAC0, sam_xdmac0_interrupt);
+ (void)irq_attach(SAM_IRQ_XDMAC0, sam_xdmac_interrupt, &g_xdmac0);
/* Initialize the controller */
@@ -1985,7 +1966,7 @@ void weak_function up_dmainitialize(void)
/* Attach DMA interrupt vector */
- (void)irq_attach(SAM_IRQ_XDMAC1, sam_xdmac1_interrupt);
+ (void)irq_attach(SAM_IRQ_XDMAC1, sam_xdmac_interrupt, &g_xdmac1);
/* Initialize the controller */
diff --git a/arch/arm/src/samdl/sam_dmac.c b/arch/arm/src/samdl/sam_dmac.c
index d465d4d5f87c89e14e1607d8befee060f5d68572..20501ecc0eda381377ae7d2e0013a39967ef3e58 100644
--- a/arch/arm/src/samdl/sam_dmac.c
+++ b/arch/arm/src/samdl/sam_dmac.c
@@ -117,7 +117,7 @@ static void sam_takedsem(void);
static inline void sam_givedsem(void);
#endif
static void sam_dmaterminate(struct sam_dmach_s *dmach, int result);
-static int sam_dmainterrupt(int irq, void *context);
+static int sam_dmainterrupt(int irq, void *context, FAR void *arg);
static struct dma_desc_s *sam_alloc_desc(struct sam_dmach_s *dmach);
static struct dma_desc_s *sam_append_desc(struct sam_dmach_s *dmach,
uint16_t btctrl, uint16_t btcnt,
@@ -275,7 +275,7 @@ static void sam_dmaterminate(struct sam_dmach_s *dmach, int result)
*
****************************************************************************/
-static int sam_dmainterrupt(int irq, void *context)
+static int sam_dmainterrupt(int irq, void *context, FAR void *arg)
{
struct sam_dmach_s *dmach;
unsigned int chndx;
@@ -807,7 +807,7 @@ void weak_function up_dmainitialize(void)
/* Attach DMA interrupt vector */
- (void)irq_attach(SAM_IRQ_DMAC, sam_dmainterrupt);
+ (void)irq_attach(SAM_IRQ_DMAC, sam_dmainterrupt, NULL);
/* Set the LPRAM DMA descriptor table addresses. These can only be
* written when the DMAC is disabled.
diff --git a/arch/arm/src/samdl/sam_irq.c b/arch/arm/src/samdl/sam_irq.c
index 025c20081825d7b0736386a1c346ac9ed1cbf419..6d3deeb2e8379f613a62989e575af35c3bad8f4e 100644
--- a/arch/arm/src/samdl/sam_irq.c
+++ b/arch/arm/src/samdl/sam_irq.c
@@ -94,7 +94,7 @@ volatile uint32_t *g_current_regs[1];
****************************************************************************/
#ifdef CONFIG_DEBUG_FEATURES
-static int sam_nmi(int irq, FAR void *context)
+static int sam_nmi(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! NMI received\n");
@@ -102,7 +102,7 @@ static int sam_nmi(int irq, FAR void *context)
return 0;
}
-static int sam_pendsv(int irq, FAR void *context)
+static int sam_pendsv(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! PendSV received\n");
@@ -110,7 +110,7 @@ static int sam_pendsv(int irq, FAR void *context)
return 0;
}
-static int sam_reserved(int irq, FAR void *context)
+static int sam_reserved(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Reserved interrupt\n");
@@ -187,15 +187,15 @@ void up_irqinitialize(void)
* under certain conditions.
*/
- irq_attach(SAM_IRQ_SVCALL, up_svcall);
- irq_attach(SAM_IRQ_HARDFAULT, up_hardfault);
+ irq_attach(SAM_IRQ_SVCALL, up_svcall, NULL);
+ irq_attach(SAM_IRQ_HARDFAULT, up_hardfault, NULL);
/* Attach all other processor exceptions (except reset and sys tick) */
#ifdef CONFIG_DEBUG_FEATURES
- irq_attach(SAM_IRQ_NMI, sam_nmi);
- irq_attach(SAM_IRQ_PENDSV, sam_pendsv);
- irq_attach(SAM_IRQ_RESERVED, sam_reserved);
+ irq_attach(SAM_IRQ_NMI, sam_nmi, NULL);
+ irq_attach(SAM_IRQ_PENDSV, sam_pendsv, NULL);
+ irq_attach(SAM_IRQ_RESERVED, sam_reserved, NULL);
#endif
sam_dumpnvic("initial", NR_IRQS);
diff --git a/arch/arm/src/samdl/sam_serial.c b/arch/arm/src/samdl/sam_serial.c
index ac94f694acf05153a44f7be1e754f071983f453c..8c88850acc6f80c20025f8271d58aeada12c4ccf 100644
--- a/arch/arm/src/samdl/sam_serial.c
+++ b/arch/arm/src/samdl/sam_serial.c
@@ -228,8 +228,6 @@ struct sam_dev_s
const struct sam_usart_config_s * const config;
/* Information unique to the serial driver */
-
- xcpt_t handler; /* Interrupt handler */
};
/****************************************************************************
@@ -249,26 +247,7 @@ static inline void
sam_serialout16(struct sam_dev_s *priv, int offset,
uint16_t regval);
static void sam_disableallints(struct sam_dev_s *priv);
-static int sam_interrupt(struct uart_dev_s *dev);
-
-#ifdef SAMDL_HAVE_USART0
-static int sam_usart0_interrupt(int irq, void *context);
-#endif
-#ifdef SAMDL_HAVE_USART1
-static int sam_usart1_interrupt(int irq, void *context);
-#endif
-#ifdef SAMDL_HAVE_USART2
-static int sam_usart2_interrupt(int irq, void *context);
-#endif
-#ifdef SAMDL_HAVE_USART3
-static int sam_usart3_interrupt(int irq, void *context);
-#endif
-#ifdef SAMDL_HAVE_USART4
-static int sam_usart4_interrupt(int irq, void *context);
-#endif
-#ifdef SAMDL_HAVE_USART5
-static int sam_usart5_interrupt(int irq, void *context);
-#endif
+static int sam_interrupt(int irq, void *context, FAR void *arg);
/* UART methods */
@@ -340,7 +319,6 @@ static char g_usart5txbuffer[CONFIG_USART5_TXBUFSIZE];
static struct sam_dev_s g_usart0priv =
{
.config = &g_usart0config,
- .handler = sam_usart0_interrupt,
};
static uart_dev_t g_usart0port =
@@ -366,7 +344,6 @@ static uart_dev_t g_usart0port =
static struct sam_dev_s g_usart1priv =
{
.config = &g_usart1config,
- .handler = sam_usart1_interrupt,
};
static uart_dev_t g_usart1port =
@@ -392,7 +369,6 @@ static uart_dev_t g_usart1port =
static struct sam_dev_s g_usart2priv =
{
.config = &g_usart2config,
- .handler = sam_usart2_interrupt,
};
static uart_dev_t g_usart2port =
@@ -418,7 +394,6 @@ static uart_dev_t g_usart2port =
static struct sam_dev_s g_usart3priv =
{
.config = &g_usart3config,
- .handler = sam_usart3_interrupt,
};
static uart_dev_t g_usart3port =
@@ -444,7 +419,6 @@ static uart_dev_t g_usart3port =
static struct sam_dev_s g_usart4priv =
{
.config = &g_usart4config,
- .handler = sam_usart4_interrupt,
};
static uart_dev_t g_usart4port =
@@ -470,7 +444,6 @@ static uart_dev_t g_usart4port =
static struct sam_dev_s g_usart5priv =
{
.config = &g_usart5config,
- .handler = sam_usart5_interrupt,
};
static uart_dev_t g_usart5port =
@@ -555,13 +528,17 @@ static void sam_disableallints(struct sam_dev_s *priv)
*
****************************************************************************/
-static int sam_interrupt(struct uart_dev_s *dev)
+static int sam_interrupt(int irq, void *context, FAR void *arg)
{
- struct sam_dev_s *priv = (struct sam_dev_s *)dev->priv;
+ struct uart_dev_s *dev = (struct uart_dev_s *)arg;
+ struct sam_dev_s *priv;
uint8_t pending;
uint8_t intflag;
uint8_t inten;
+ DEBUGASSERT(dev != NULL && dev->priv != NULL);
+ priv = (struct sam_dev_s *)dev->priv;
+
/* Get the set of pending USART interrupts (we are only interested in the
* unmasked interrupts).
*/
@@ -599,57 +576,6 @@ static int sam_interrupt(struct uart_dev_s *dev)
return OK;
}
-/****************************************************************************
- * Name: sam_usartN_interrupt
- *
- * Description:
- * Handle each SERCOM USART interrupt by calling the common interrupt
- * handling logic with the USART-specific state.
- *
- ****************************************************************************/
-
-#ifdef SAMDL_HAVE_USART0
-static int sam_usart0_interrupt(int irq, void *context)
-{
- return sam_interrupt(&g_usart0port);
-}
-#endif
-
-#ifdef SAMDL_HAVE_USART1
-static int sam_usart1_interrupt(int irq, void *context)
-{
- return sam_interrupt(&g_usart1port);
-}
-#endif
-
-#ifdef SAMDL_HAVE_USART2
-static int sam_usart2_interrupt(int irq, void *context)
-{
- return sam_interrupt(&g_usart2port);
-}
-#endif
-
-#ifdef SAMDL_HAVE_USART3
-static int sam_usart3_interrupt(int irq, void *context)
-{
- return sam_interrupt(&g_usart3port);
-}
-#endif
-
-#ifdef SAMDL_HAVE_USART4
-static int sam_usart4_interrupt(int irq, void *context)
-{
- return sam_interrupt(&g_usart4port);
-}
-#endif
-
-#ifdef SAMDL_HAVE_USART5
-static int sam_usart5_interrupt(int irq, void *context)
-{
- return sam_interrupt(&g_usart5port);
-}
-#endif
-
/****************************************************************************
* Name: sam_setup
*
@@ -726,7 +652,7 @@ static int sam_attach(struct uart_dev_s *dev)
/* Attach and enable the IRQ */
- ret = irq_attach(config->irq, priv->handler);
+ ret = irq_attach(config->irq, sam_interrupt, dev);
if (ret == OK)
{
/* Enable the interrupt (RX and TX interrupts are still disabled
diff --git a/arch/arm/src/samdl/sam_spi.c b/arch/arm/src/samdl/sam_spi.c
index ac7ea3d2cc2cf1e30d219a5490e4ed2eaea3e774..cc17758d86af129ae6bea2304fb6c300419bdbfc 100644
--- a/arch/arm/src/samdl/sam_spi.c
+++ b/arch/arm/src/samdl/sam_spi.c
@@ -163,26 +163,7 @@ static void spi_dumpregs(struct sam_spidev_s *priv, const char *msg);
/* Interrupt handling */
#if 0 /* Not used */
-static int spi_interrupt(struct sam_spidev_s *dev);
-
-#ifdef SAMDL_HAVE_SPI0
-static int spi0_interrupt(int irq, void *context);
-#endif
-#ifdef SAMDL_HAVE_SPI1
-static int spi1_interrupt(int irq, void *context);
-#endif
-#ifdef SAMDL_HAVE_SPI2
-static int spi2_interrupt(int irq, void *context);
-#endif
-#ifdef SAMDL_HAVE_SPI3
-static int spi3_interrupt(int irq, void *context);
-#endif
-#ifdef SAMDL_HAVE_SPI4
-static int spi4_interrupt(int irq, void *context);
-#endif
-#ifdef SAMDL_HAVE_SPI5
-static int spi5_interrupt(int irq, void *context);
-#endif
+static int spi_interrupt(int irq, void *context, FAR void *arg);
#endif
/* SPI methods */
@@ -255,9 +236,6 @@ static struct sam_spidev_s g_spi0dev =
.muxconfig = BOARD_SERCOM0_MUXCONFIG,
.srcfreq = BOARD_SERCOM0_FREQUENCY,
.base = SAM_SERCOM0_BASE,
-#if 0 /* Not used */
- .handler = spi0_interrupt,
-#endif
.spilock = SEM_INITIALIZER(1),
};
#endif
@@ -304,9 +282,6 @@ static struct sam_spidev_s g_spi1dev =
.muxconfig = BOARD_SERCOM1_MUXCONFIG,
.srcfreq = BOARD_SERCOM1_FREQUENCY,
.base = SAM_SERCOM1_BASE,
-#if 0 /* Not used */
- .handler = spi1_interrupt,
-#endif
.spilock = SEM_INITIALIZER(1),
};
#endif
@@ -353,9 +328,6 @@ static struct sam_spidev_s g_spi2dev =
.muxconfig = BOARD_SERCOM2_MUXCONFIG,
.srcfreq = BOARD_SERCOM2_FREQUENCY,
.base = SAM_SERCOM2_BASE,
-#if 0 /* Not used */
- .handler = spi2_interrupt,
-#endif
.spilock = SEM_INITIALIZER(1),
};
#endif
@@ -402,9 +374,6 @@ static struct sam_spidev_s g_spi3dev =
.muxconfig = BOARD_SERCOM3_MUXCONFIG,
.srcfreq = BOARD_SERCOM3_FREQUENCY,
.base = SAM_SERCOM3_BASE,
-#if 0 /* Not used */
- .handler = spi3_interrupt,
-#endif
.spilock = SEM_INITIALIZER(1),
};
#endif
@@ -451,9 +420,6 @@ static struct sam_spidev_s g_spi4dev =
.muxconfig = BOARD_SERCOM4_MUXCONFIG,
.srcfreq = BOARD_SERCOM4_FREQUENCY,
.base = SAM_SERCOM4_BASE,
-#if 0 /* Not used */
- .handler = spi4_interrupt,
-#endif
.spilock = SEM_INITIALIZER(1),
};
#endif
@@ -500,9 +466,6 @@ static struct sam_spidev_s g_spi5dev =
.muxconfig = BOARD_SERCOM5_MUXCONFIG,
.srcfreq = BOARD_SERCOM5_FREQUENCY,
.base = SAM_SERCOM5_BASE,
-#if 0 /* Not used */
- .handler = spi5_interrupt,
-#endif
.spilock = SEM_INITIALIZER(1),
};
#endif
@@ -748,13 +711,15 @@ static void spi_dumpregs(struct sam_spidev_s *priv, const char *msg)
****************************************************************************/
#if 0 /* Not used */
-static int spi_interrupt(struct sam_spidev_s *dev)
+static int spi_interrupt(int irq, void *context, FAR void *arg)
{
- struct sam_dev_s *priv = (struct sam_dev_s *)dev->priv;
+ struct sam_dev_s *priv = (struct sam_dev_s *)arg
uint8_t pending;
uint8_t intflag;
uint8_t inten;
+ DEBUGASSERT(priv != NULL);
+
/* Get the set of pending SPI interrupts (we are only interested in the
* unmasked interrupts).
*/
@@ -791,59 +756,6 @@ static int spi_interrupt(struct sam_spidev_s *dev)
}
#endif
-/****************************************************************************
- * Name: spiN_interrupt
- *
- * Description:
- * Handle each SERCOM SPI interrupt by calling the common interrupt
- * handling logic with the SPI-specific state.
- *
- ****************************************************************************/
-
-#if 0 /* Not used */
-#ifdef SAMDL_HAVE_SPI0
-static int spi0_interrupt(int irq, void *context)
-{
- return spi_interrupt(&g_spi0dev);
-}
-#endif
-
-#ifdef SAMDL_HAVE_SPI1
-static int spi1_interrupt(int irq, void *context)
-{
- return spi_interrupt(&g_spi1dev);
-}
-#endif
-
-#ifdef SAMDL_HAVE_SPI2
-static int spi2_interrupt(int irq, void *context)
-{
- return spi_interrupt(&g_spi2dev);
-}
-#endif
-
-#ifdef SAMDL_HAVE_SPI3
-static int spi3_interrupt(int irq, void *context)
-{
- return spi_interrupt(&g_spi3dev);
-}
-#endif
-
-#ifdef SAMDL_HAVE_SPI4
-static int spi4_interrupt(int irq, void *context)
-{
- return spi_interrupt(&g_spi4dev);
-}
-#endif
-
-#ifdef SAMDL_HAVE_SPI5
-static int spi5_interrupt(int irq, void *context)
-{
- return spi_interrupt(&g_spi5dev);
-}
-#endif
-#endif
-
/****************************************************************************
* Name: spi_lock
*
@@ -1546,7 +1458,7 @@ struct spi_dev_s *sam_spibus_initialize(int port)
#if 0 /* Not used */
/* Attach and enable the SERCOM interrupt handler */
- ret = irq_attach(priv->irq, priv->handler);
+ ret = irq_attach(priv->irq, spi_interrupt, priv);
if (ret < 0)
{
spierr("ERROR: Failed to attach interrupt: %d\n", irq);
diff --git a/arch/arm/src/samdl/sam_timerisr.c b/arch/arm/src/samdl/sam_timerisr.c
index 5236ee45b5b6a70ceaddb9890b49595190d5f6ce..abc61f355f00562dbc8cf8f764bc5e1946c06619 100644
--- a/arch/arm/src/samdl/sam_timerisr.c
+++ b/arch/arm/src/samdl/sam_timerisr.c
@@ -95,7 +95,7 @@
*
****************************************************************************/
-static int sam_timerisr(int irq, uint32_t *regs)
+static int sam_timerisr(int irq, uint32_t *regs, void *arg)
{
/* Process timer interrupt */
@@ -133,7 +133,7 @@ void arm_timer_initialize(void)
/* Attach the timer interrupt vector */
- (void)irq_attach(SAM_IRQ_SYSTICK, (xcpt_t)sam_timerisr);
+ (void)irq_attach(SAM_IRQ_SYSTICK, (xcpt_t)sam_timerisr, NULL);
/* Enable SysTick interrupts */
diff --git a/arch/arm/src/samv7/sam_dac.c b/arch/arm/src/samv7/sam_dac.c
index 598201ce3908ac06b5b9c103cc060cd3e7e76905..78a19929b5412af48185d1039f4944b4b0878f85 100644
--- a/arch/arm/src/samv7/sam_dac.c
+++ b/arch/arm/src/samv7/sam_dac.c
@@ -109,7 +109,7 @@ struct sam_chan_s
/* Interrupt handler */
-static int dac_interrupt(int irq, FAR void *context);
+static int dac_interrupt(int irq, FAR void *context, FAR void *arg);
/* DAC methods */
@@ -199,7 +199,7 @@ static struct sam_dac_s g_dacmodule;
*
****************************************************************************/
-static int dac_interrupt(int irq, FAR void *context)
+static int dac_interrupt(int irq, FAR void *context, FAR void *arg)
{
#ifdef CONFIG_SAMV7_DAC1
uint32_t status;
@@ -569,7 +569,7 @@ static int dac_module_init(void)
/* Configure interrupts */
- ret = irq_attach(SAM_IRQ_DACC, dac_interrupt);
+ ret = irq_attach(SAM_IRQ_DACC, dac_interrupt, NULL);
if (ret < 0)
{
aerr("irq_attach failed: %d\n", ret);
diff --git a/arch/arm/src/samv7/sam_emac.c b/arch/arm/src/samv7/sam_emac.c
index a7ea10c109d41834521f8a660c96fdcd3112f69b..8905ee55546de9cb213cc68d9d6545028e9dd235 100644
--- a/arch/arm/src/samv7/sam_emac.c
+++ b/arch/arm/src/samv7/sam_emac.c
@@ -2,7 +2,7 @@
* arch/arm/src/samv7/sam_emac.c
* 10/100 Base-T Ethernet driver for the SAMV71.
*
- * Copyright (C) 2015 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
*
* This logic derives from the SAMA5 Ethernet driver which, in turn, derived
@@ -431,7 +431,6 @@ struct sam_emacattr_s
/* Basic hardware information */
uint32_t base; /* EMAC Register base address */
- xcpt_t handler; /* EMAC interrupt handler */
uint8_t emac; /* EMACn, n=0 or 1 */
uint8_t irq; /* EMAC interrupt number */
@@ -518,7 +517,8 @@ struct sam_emac_s
uint8_t ifup : 1; /* true:ifup false:ifdown */
WDOG_ID txpoll; /* TX poll timer */
WDOG_ID txtimeout; /* TX timeout timer */
- struct work_s work; /* For deferring work to the work queue */
+ struct work_s irqwork; /* For deferring work to the work queue */
+ struct work_s pollwork; /* For deferring work to the work queue */
/* This holds the information visible to the NuttX network */
@@ -583,13 +583,7 @@ static void sam_txdone(struct sam_emac_s *priv, int qid);
static void sam_txerr_interrupt(FAR struct sam_emac_s *priv, int qid);
static void sam_interrupt_work(FAR void *arg);
-static int sam_emac_interrupt(struct sam_emac_s *priv);
-#ifdef CONFIG_SAMV7_EMAC0
-static int sam_emac0_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_SAMV7_EMAC1
-static int sam_emac1_interrupt(int irq, void *context);
-#endif
+static int sam_emac_interrupt(int irq, void *context, FAR void *arg);
/* Watchdog timer expirations */
@@ -778,7 +772,6 @@ static const struct sam_emacattr_s g_emac0_attr =
/* Basic hardware information */
.base = SAM_EMAC0_BASE,
- .handler = sam_emac0_interrupt,
.emac = EMAC0_INTF,
.irq = SAM_IRQ_EMAC0,
@@ -859,7 +852,6 @@ static const struct sam_emacattr_s g_emac1_attr =
/* Basic hardware information */
.base = SAM_EMAC1_BASE,
- .handler = sam_emac1_interrupt,
.emac = EMAC1_INTF,
.irq = SAM_IRQ_EMAC1,
@@ -2467,10 +2459,13 @@ static void sam_interrupt_work(FAR void *arg)
*
****************************************************************************/
-static int sam_emac_interrupt(struct sam_emac_s *priv)
+static int sam_emac_interrupt(int irq, void *context, FAR void *arg)
{
+ struct sam_emac_s *priv = (struct sam_emac_s *)arg;
uint32_t tsr;
+ DEBUGASSERT(priv != NULL);
+
/* Disable further Ethernet interrupts. Because Ethernet interrupts are
* also disabled if the TX timeout event occurs, there can be no race
* condition here.
@@ -2494,58 +2489,15 @@ static int sam_emac_interrupt(struct sam_emac_s *priv)
* expiration and the deferred interrupt processing.
*/
- wd_cancel(priv->txtimeout);
-
- /* Make sure that the TX poll timer is running (if it is already
- * running, the following would restart it). This is necessary to
- * avoid certain race conditions where the polling sequence can be
- * interrupted.
- */
-
- (void)wd_start(priv->txpoll, SAM_WDDELAY, sam_poll_expiry, 1, priv);
+ wd_cancel(priv->txtimeout);
}
- /* Cancel any pending poll work */
-
- work_cancel(ETHWORK, &priv->work);
-
/* Schedule to perform the interrupt processing on the worker thread. */
- work_queue(ETHWORK, &priv->work, sam_interrupt_work, priv, 0);
+ work_queue(ETHWORK, &priv->irqwork, sam_interrupt_work, priv, 0);
return OK;
}
-/****************************************************************************
- * Function: sam_emac0/1_interrupt
- *
- * Description:
- * EMAC hardware interrupt handler
- *
- * Parameters:
- * irq - Number of the IRQ that generated the interrupt
- * context - Interrupt register state save info (architecture-specific)
- *
- * Returned Value:
- * OK on success
- *
- * Assumptions:
- *
- ****************************************************************************/
-
-#ifdef CONFIG_SAMV7_EMAC0
-static int sam_emac0_interrupt(int irq, void *context)
-{
- return sam_emac_interrupt(&g_emac0);
-}
-#endif
-
-#ifdef CONFIG_SAMV7_EMAC1
-static int sam_emac1_interrupt(int irq, void *context)
-{
- return sam_emac_interrupt(&g_emac1);
-}
-#endif
-
/****************************************************************************
* Function: sam_txtimeout_work
*
@@ -2613,15 +2565,9 @@ static void sam_txtimeout_expiry(int argc, uint32_t arg, ...)
up_disable_irq(priv->attr->irq);
- /* Cancel any pending poll or interrupt work. This will have no effect
- * on work that has already been started.
- */
-
- work_cancel(ETHWORK, &priv->work);
-
/* Schedule to perform the TX timeout processing on the worker thread. */
- work_queue(ETHWORK, &priv->work, sam_txtimeout_work, priv, 0);
+ work_queue(ETHWORK, &priv->irqwork, sam_txtimeout_work, priv, 0);
}
/****************************************************************************
@@ -2686,24 +2632,9 @@ static void sam_poll_expiry(int argc, uint32_t arg, ...)
{
FAR struct sam_emac_s *priv = (FAR struct sam_emac_s *)arg;
- /* Is our single work structure available? It may not be if there are
- * pending interrupt actions.
- */
-
- if (work_available(&priv->work))
- {
- /* Schedule to perform the interrupt processing on the worker thread. */
-
- work_queue(ETHWORK, &priv->work, sam_poll_work, priv, 0);
- }
- else
- {
- /* No.. Just re-start the watchdog poll timer, missing one polling
- * cycle.
- */
+ /* Schedule to perform the interrupt processing on the worker thread. */
- (void)wd_start(priv->txpoll, SAM_WDDELAY, sam_poll_expiry, 1, arg);
- }
+ work_queue(ETHWORK, &priv->pollwork, sam_poll_work, priv, 0);
}
/****************************************************************************
@@ -2905,11 +2836,11 @@ static int sam_txavail(struct net_driver_s *dev)
* availability action.
*/
- if (work_available(&priv->work))
+ if (work_available(&priv->pollwork))
{
/* Schedule to serialize the poll on the worker thread. */
- work_queue(ETHWORK, &priv->work, sam_txavail_work, priv, 0);
+ work_queue(ETHWORK, &priv->pollwork, sam_txavail_work, priv, 0);
}
return OK;
@@ -5037,10 +4968,11 @@ int sam_emac_initialize(int intf)
* the interface is in the 'up' state.
*/
- ret = irq_attach(priv->attr->irq, priv->attr->handler);
+ ret = irq_attach(priv->attr->irq, sam_emac_interrupt, priv);
if (ret < 0)
{
- nerr("ERROR: Failed to attach the handler to the IRQ%d\n", priv->attr->irq);
+ nerr("ERROR: Failed to attach the handler to the IRQ%d\n",
+ priv->attr->irq);
goto errout_with_buffers;
}
diff --git a/arch/arm/src/samv7/sam_gpioirq.c b/arch/arm/src/samv7/sam_gpioirq.c
index 8929d1757799f24144465196ea8f8da13aae128a..78cbc4c5ed79090e122f54e9231bd6186b94cf80 100644
--- a/arch/arm/src/samv7/sam_gpioirq.c
+++ b/arch/arm/src/samv7/sam_gpioirq.c
@@ -192,35 +192,35 @@ static int sam_gpiointerrupt(uint32_t base, int irq0, void *context)
}
#ifdef CONFIG_SAMV7_GPIOA_IRQ
-static int sam_gpioainterrupt(int irq, void *context)
+static int sam_gpioainterrupt(int irq, void *context, FAR void *arg)
{
return sam_gpiointerrupt(SAM_PIOA_BASE, SAM_IRQ_PA0, context);
}
#endif
#ifdef CONFIG_SAMV7_GPIOB_IRQ
-static int sam_gpiobinterrupt(int irq, void *context)
+static int sam_gpiobinterrupt(int irq, void *context, FAR void *arg)
{
return sam_gpiointerrupt(SAM_PIOB_BASE, SAM_IRQ_PB0, context);
}
#endif
#ifdef CONFIG_SAMV7_GPIOC_IRQ
-static int sam_gpiocinterrupt(int irq, void *context)
+static int sam_gpiocinterrupt(int irq, void *context, FAR void *arg)
{
return sam_gpiointerrupt(SAM_PIOC_BASE, SAM_IRQ_PC0, context);
}
#endif
#ifdef CONFIG_SAMV7_GPIOD_IRQ
-static int sam_gpiodinterrupt(int irq, void *context)
+static int sam_gpiodinterrupt(int irq, void *context, FAR void *arg)
{
return sam_gpiointerrupt(SAM_PIOD_BASE, SAM_IRQ_PD0, context);
}
#endif
#ifdef CONFIG_SAMV7_GPIOE_IRQ
-static int sam_gpioeinterrupt(int irq, void *context)
+static int sam_gpioeinterrupt(int irq, void *context, FAR void *arg)
{
return sam_gpiointerrupt(SAM_PIOE_BASE, SAM_IRQ_PE0, context);
}
@@ -255,7 +255,7 @@ void sam_gpioirqinitialize(void)
/* Attach and enable the GPIOA IRQ */
- (void)irq_attach(SAM_IRQ_PIOA, sam_gpioainterrupt);
+ (void)irq_attach(SAM_IRQ_PIOA, sam_gpioainterrupt, NULL);
up_enable_irq(SAM_IRQ_PIOA);
#endif
@@ -273,7 +273,7 @@ void sam_gpioirqinitialize(void)
/* Attach and enable the GPIOB IRQ */
- (void)irq_attach(SAM_IRQ_PIOB, sam_gpiobinterrupt);
+ (void)irq_attach(SAM_IRQ_PIOB, sam_gpiobinterrupt, NULL);
up_enable_irq(SAM_IRQ_PIOB);
#endif
@@ -291,7 +291,7 @@ void sam_gpioirqinitialize(void)
/* Attach and enable the GPIOC IRQ */
- (void)irq_attach(SAM_IRQ_PIOC, sam_gpiocinterrupt);
+ (void)irq_attach(SAM_IRQ_PIOC, sam_gpiocinterrupt, NULL);
up_enable_irq(SAM_IRQ_PIOC);
#endif
@@ -309,7 +309,7 @@ void sam_gpioirqinitialize(void)
/* Attach and enable the GPIOC IRQ */
- (void)irq_attach(SAM_IRQ_PIOD, sam_gpiodinterrupt);
+ (void)irq_attach(SAM_IRQ_PIOD, sam_gpiodinterrupt, NULL);
up_enable_irq(SAM_IRQ_PIOD);
#endif
@@ -327,7 +327,7 @@ void sam_gpioirqinitialize(void)
/* Attach and enable the GPIOE IRQ */
- (void)irq_attach(SAM_IRQ_PIOE, sam_gpioeinterrupt);
+ (void)irq_attach(SAM_IRQ_PIOE, sam_gpioeinterrupt, NULL);
up_enable_irq(SAM_IRQ_PIOE);
#endif
}
diff --git a/arch/arm/src/samv7/sam_hsmci.c b/arch/arm/src/samv7/sam_hsmci.c
index 3fe5a7dbff3ad8bc0af41a45626bd77220ba2a9d..a83a51ecc0b3b11e841af7ba8b1e03a73d284973 100644
--- a/arch/arm/src/samv7/sam_hsmci.c
+++ b/arch/arm/src/samv7/sam_hsmci.c
@@ -472,13 +472,7 @@ static void sam_notransfer(struct sam_dev_s *priv);
/* Interrupt Handling *******************************************************/
-static int sam_hsmci_interrupt(struct sam_dev_s *priv);
-#ifdef CONFIG_SAMV7_HSMCI0
-static int sam_hsmci0_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_SAMV7_HSMCI1
-static int sam_hsmci1_interrupt(int irq, void *context);
-#endif
+static int sam_hsmci_interrupt(int irq, void *context, void *arg);
/* SDIO interface methods ***************************************************/
@@ -1437,20 +1431,22 @@ static void sam_notransfer(struct sam_dev_s *priv)
* HSMCI interrupt handler
*
* Input Parameters:
- * irq - IRQ number of the interrupts
- * context - Saved machine context at the time of the interrupt
+ * Standard interrupt handler arguments.
*
* Returned Value:
* None
*
****************************************************************************/
-static int sam_hsmci_interrupt(struct sam_dev_s *priv)
+static int sam_hsmci_interrupt(int irq, void *context, void *arg)
{
+ struct sam_dev_s *priv = (struct sam_dev_s *)arg;
uint32_t sr;
uint32_t enabled;
uint32_t pending;
+ DEBUGASSERT(priv != NULL);
+
/* Loop while there are pending interrupts. */
for (; ; )
@@ -1643,35 +1639,6 @@ static int sam_hsmci_interrupt(struct sam_dev_s *priv)
return OK;
}
-/****************************************************************************
- * Name: sam_hsmci0_interrupt, sam_hsmci1_interrupt, and sam_hsmci2_interrupt
- *
- * Description:
- * HSMCI interrupt handler
- *
- * Input Parameters:
- * irq - IRQ number of the interrupts
- * context - Saved machine context at the time of the interrupt
- *
- * Returned Value:
- * None
- *
- ****************************************************************************/
-
-#ifdef CONFIG_SAMV7_HSMCI0
-static int sam_hsmci0_interrupt(int irq, void *context)
-{
- return sam_hsmci_interrupt(&g_hsmci0);
-}
-#endif
-
-#ifdef CONFIG_SAMV7_HSMCI1
-static int sam_hsmci1_interrupt(int irq, void *context)
-{
- return sam_hsmci_interrupt(&g_hsmci1);
-}
-#endif
-
/****************************************************************************
* SDIO Interface Methods
****************************************************************************/
@@ -1922,7 +1889,6 @@ static void sam_clock(FAR struct sdio_dev_s *dev, enum sdio_clock_e rate)
static int sam_attach(FAR struct sdio_dev_s *dev)
{
struct sam_dev_s *priv = (struct sam_dev_s *)dev;
- xcpt_t handler;
int irq;
int ret;
@@ -1931,16 +1897,14 @@ static int sam_attach(FAR struct sdio_dev_s *dev)
#ifdef CONFIG_SAMV7_HSMCI0
if (priv->hsmci == 0)
{
- handler = sam_hsmci0_interrupt;
- irq = SAM_IRQ_HSMCI0;
+ irq = SAM_IRQ_HSMCI0;
}
else
#endif
#ifdef CONFIG_SAMV7_HSMCI1
if (priv->hsmci == 1)
{
- handler = sam_hsmci1_interrupt;
- irq = SAM_IRQ_HSMCI1;
+ irq = SAM_IRQ_HSMCI1;
}
else
#endif
@@ -1951,7 +1915,7 @@ static int sam_attach(FAR struct sdio_dev_s *dev)
/* Attach the HSMCI interrupt handler */
- ret = irq_attach(irq, handler);
+ ret = irq_attach(irq, sam_hsmci_interrupt, priv);
if (ret == OK)
{
diff --git a/arch/arm/src/samv7/sam_irq.c b/arch/arm/src/samv7/sam_irq.c
index 08537f65970950d13d58aa5c1a0c299a6c22323a..f2e448932984dee2183fda3db49de3a7df6a3299 100644
--- a/arch/arm/src/samv7/sam_irq.c
+++ b/arch/arm/src/samv7/sam_irq.c
@@ -174,7 +174,7 @@ static void sam_dumpnvic(const char *msg, int irq)
****************************************************************************/
#ifdef CONFIG_DEBUG_FEATURES
-static int sam_nmi(int irq, FAR void *context)
+static int sam_nmi(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! NMI received\n");
@@ -182,7 +182,7 @@ static int sam_nmi(int irq, FAR void *context)
return 0;
}
-static int sam_busfault(int irq, FAR void *context)
+static int sam_busfault(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Bus fault received: %08x\n", getreg32(NVIC_CFAULTS));
@@ -190,7 +190,7 @@ static int sam_busfault(int irq, FAR void *context)
return 0;
}
-static int sam_usagefault(int irq, FAR void *context)
+static int sam_usagefault(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Usage fault received: %08x\n", getreg32(NVIC_CFAULTS));
@@ -198,7 +198,7 @@ static int sam_usagefault(int irq, FAR void *context)
return 0;
}
-static int sam_pendsv(int irq, FAR void *context)
+static int sam_pendsv(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! PendSV received\n");
@@ -206,7 +206,7 @@ static int sam_pendsv(int irq, FAR void *context)
return 0;
}
-static int sam_dbgmonitor(int irq, FAR void *context)
+static int sam_dbgmonitor(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Debug Monitor received\n");
@@ -214,7 +214,7 @@ static int sam_dbgmonitor(int irq, FAR void *context)
return 0;
}
-static int sam_reserved(int irq, FAR void *context)
+static int sam_reserved(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Reserved interrupt\n");
@@ -435,8 +435,8 @@ void up_irqinitialize(void)
* under certain conditions.
*/
- irq_attach(SAM_IRQ_SVCALL, up_svcall);
- irq_attach(SAM_IRQ_HARDFAULT, up_hardfault);
+ irq_attach(SAM_IRQ_SVCALL, up_svcall, NULL);
+ irq_attach(SAM_IRQ_HARDFAULT, up_hardfault, NULL);
/* Set the priority of the SVCall interrupt */
@@ -452,22 +452,22 @@ void up_irqinitialize(void)
*/
#ifdef CONFIG_ARM_MPU
- irq_attach(SAM_IRQ_MEMFAULT, up_memfault);
+ irq_attach(SAM_IRQ_MEMFAULT, up_memfault, NULL);
up_enable_irq(SAM_IRQ_MEMFAULT);
#endif
/* Attach all other processor exceptions (except reset and sys tick) */
#ifdef CONFIG_DEBUG_FEATURES
- irq_attach(SAM_IRQ_NMI, sam_nmi);
+ irq_attach(SAM_IRQ_NMI, sam_nmi, NULL);
#ifndef CONFIG_ARM_MPU
- irq_attach(SAM_IRQ_MEMFAULT, up_memfault);
+ irq_attach(SAM_IRQ_MEMFAULT, up_memfault, NULL);
#endif
- irq_attach(SAM_IRQ_BUSFAULT, sam_busfault);
- irq_attach(SAM_IRQ_USAGEFAULT, sam_usagefault);
- irq_attach(SAM_IRQ_PENDSV, sam_pendsv);
- irq_attach(SAM_IRQ_DBGMONITOR, sam_dbgmonitor);
- irq_attach(SAM_IRQ_RESERVED, sam_reserved);
+ irq_attach(SAM_IRQ_BUSFAULT, sam_busfault, NULL);
+ irq_attach(SAM_IRQ_USAGEFAULT, sam_usagefault, NULL);
+ irq_attach(SAM_IRQ_PENDSV, sam_pendsv, NULL);
+ irq_attach(SAM_IRQ_DBGMONITOR, sam_dbgmonitor, NULL);
+ irq_attach(SAM_IRQ_RESERVED, sam_reserved, NULL);
#endif
sam_dumpnvic("initial", SAM_IRQ_NIRQS);
diff --git a/arch/arm/src/samv7/sam_mcan.c b/arch/arm/src/samv7/sam_mcan.c
index 683463be9e615ea3de018ed828ed5b2a6b70f8fd..7d16f0898df0572d7d414164d99d796848424396 100644
--- a/arch/arm/src/samv7/sam_mcan.c
+++ b/arch/arm/src/samv7/sam_mcan.c
@@ -841,7 +841,6 @@ struct sam_config_s
{
gpio_pinset_t rxpinset; /* RX pin configuration */
gpio_pinset_t txpinset; /* TX pin configuration */
- xcpt_t handler; /* MCAN common interrupt handler */
uintptr_t base; /* Base address of the MCAN registers */
uint32_t baud; /* Configured baud */
uint32_t btp; /* Bit timing/prescaler register setting */
@@ -973,13 +972,7 @@ static void mcan_error(FAR struct can_dev_s *dev, uint32_t status,
#endif
static void mcan_receive(FAR struct can_dev_s *dev,
FAR uint32_t *rxbuffer, unsigned long nwords);
-static void mcan_interrupt(FAR struct can_dev_s *dev);
-#ifdef CONFIG_SAMV7_MCAN0
-static int mcan0_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_SAMV7_MCAN1
-static int mcan1_interrupt(int irq, void *context);
-#endif
+static int mcan_interrupt(int irq, void *context, FAR void *arg);
/* Hardware initialization */
@@ -1019,7 +1012,6 @@ static const struct sam_config_s g_mcan0const =
{
.rxpinset = GPIO_MCAN0_RX,
.txpinset = GPIO_MCAN0_TX,
- .handler = mcan0_interrupt,
.base = SAM_MCAN0_BASE,
.baud = CONFIG_SAMV7_MCAN0_BITRATE,
.btp = MCAN_BTP_BRP(MCAN0_BRP) | MCAN_BTP_TSEG1(MCAN0_TSEG1) |
@@ -1096,7 +1088,6 @@ static const struct sam_config_s g_mcan1const =
{
.rxpinset = GPIO_MCAN1_RX,
.txpinset = GPIO_MCAN1_TX,
- .handler = mcan1_interrupt,
.base = SAM_MCAN1_BASE,
.baud = CONFIG_SAMV7_MCAN1_BITRATE,
.btp = MCAN_BTP_BRP(MCAN1_BRP) | MCAN_BTP_TSEG1(MCAN1_TSEG1) |
@@ -2340,7 +2331,7 @@ static int mcan_setup(FAR struct can_dev_s *dev)
/* Attach the MCAN interrupt handlers */
- ret = irq_attach(config->irq0, config->handler);
+ ret = irq_attach(config->irq0, mcan_interrupt, dev);
if (ret < 0)
{
canerr("ERROR: Failed to attach MCAN%d line 0 IRQ (%d)",
@@ -2348,7 +2339,7 @@ static int mcan_setup(FAR struct can_dev_s *dev)
return ret;
}
- ret = irq_attach(config->irq1, config->handler);
+ ret = irq_attach(config->irq1, mcan_interrupt, dev);
if (ret < 0)
{
canerr("ERROR: Failed to attach MCAN%d line 1 IRQ (%d)",
@@ -3378,9 +3369,10 @@ static void mcan_receive(FAR struct can_dev_s *dev, FAR uint32_t *rxbuffer,
*
****************************************************************************/
-static void mcan_interrupt(FAR struct can_dev_s *dev)
+static int mcan_interrupt(int irq, void *context, FAR void *arg)
{
- FAR struct sam_mcan_s *priv = dev->cd_priv;
+ FAR struct can_dev_s *dev = (FAR struct can_dev_s *)arg;
+ FAR struct sam_mcan_s *priv;
FAR const struct sam_config_s *config;
uint32_t ir;
uint32_t ie;
@@ -3390,6 +3382,8 @@ static void mcan_interrupt(FAR struct can_dev_s *dev)
unsigned int ndx;
bool handled;
+ DEBUGASSERT(dev != NULL);
+ priv = dev->cd_priv;
DEBUGASSERT(priv && priv->config);
config = priv->config;
@@ -3675,52 +3669,6 @@ static void mcan_interrupt(FAR struct can_dev_s *dev)
while (handled);
}
-/****************************************************************************
- * Name: mcan0_interrupt
- *
- * Description:
- * MCAN0 interrupt handler
- *
- * Input Parameters:
- * irq - The IRQ number of the interrupt.
- * context - The register state save array at the time of the interrupt.
- *
- * Returned Value:
- * Zero on success; a negated errno on failure
- *
- ****************************************************************************/
-
-#ifdef CONFIG_SAMV7_MCAN0
-static int mcan0_interrupt(int irq, void *context)
-{
- mcan_interrupt(&g_mcan0dev);
- return OK;
-}
-#endif
-
-/****************************************************************************
- * Name: mcan1_interrupt
- *
- * Description:
- * MCAN1 interrupt handler
- *
- * Input Parameters:
- * irq - The IRQ number of the interrupt.
- * context - The register state save array at the time of the interrupt.
- *
- * Returned Value:
- * Zero on success; a negated errno on failure
- *
- ****************************************************************************/
-
-#ifdef CONFIG_SAMV7_MCAN1
-static int mcan1_interrupt(int irq, void *context)
-{
- mcan_interrupt(&g_mcan1dev);
- return OK;
-}
-#endif
-
/****************************************************************************
* Name: mcan_hw_initialize
*
diff --git a/arch/arm/src/samv7/sam_qspi.c b/arch/arm/src/samv7/sam_qspi.c
index a37245c7e6e8493e46f5c19d92052fce8de121c8..3e51bee7515a2131320ed261f6f5e5e6e7363f45 100644
--- a/arch/arm/src/samv7/sam_qspi.c
+++ b/arch/arm/src/samv7/sam_qspi.c
@@ -270,7 +270,7 @@ static void qspi_memcpy(uint8_t *dest, const uint8_t *src,
#ifdef QSPI_USE_INTERRUPTS
static int qspi_interrupt(struct sam_qspidev_s *priv);
#ifdef CONFIG_SAMV7_QSPI
-static int qspi0_interrupt(int irq, void *context);
+static int qspi0_interrupt(int irq, void *context, FAR void *arg);
#endif
#endif
@@ -1811,7 +1811,7 @@ struct qspi_dev_s *sam_qspi_initialize(int intf)
#ifdef QSPI_USE_INTERRUPTS
/* Attach the interrupt handler */
- ret = irq_attach(priv->irq, priv->handler);
+ ret = irq_attach(priv->irq, priv->handler, NULL);
if (ret < 0)
{
spierr("ERROR: Failed to attach irq %d\n", priv->irq);
diff --git a/arch/arm/src/samv7/sam_rswdt.c b/arch/arm/src/samv7/sam_rswdt.c
index 980ecd5b037369ea1f511434a08fb3ed45ce0d08..6d5add03a23ac158e16eb569deb6ed4c4e1b885b 100644
--- a/arch/arm/src/samv7/sam_rswdt.c
+++ b/arch/arm/src/samv7/sam_rswdt.c
@@ -120,7 +120,7 @@ static void sam_putreg(uint32_t regval, uintptr_t regaddr);
/* Interrupt hanlding *******************************************************/
#ifdef CONFIG_SAMV7_RSWDT_INTERRUPT
-static int sam_interrupt(int irq, FAR void *context);
+static int sam_interrupt(int irq, FAR void *context, FAR void *arg);
#endif
/* "Lower half" driver methods **********************************************/
@@ -260,7 +260,7 @@ static void sam_putreg(uint32_t regval, uintptr_t regaddr)
****************************************************************************/
#ifdef CONFIG_SAMV7_RSWDT_INTERRUPT
-static int sam_interrupt(int irq, FAR void *context)
+static int sam_interrupt(int irq, FAR void *context, FAR void *arg)
{
FAR struct sam_lowerhalf_s *priv = &g_wdtdev;
@@ -684,7 +684,7 @@ int sam_rswdt_initialize(void)
#ifdef CONFIG_SAMV7_RSWDT_INTERRUPT
/* Attach our RSWDT interrupt handler (But don't enable it yet) */
- (void)irq_attach(SAM_IRQ_RSWDT, sam_interrupt);
+ (void)irq_attach(SAM_IRQ_RSWDT, sam_interrupt, NULL);
#endif
/* Register the watchdog driver as /dev/rswdt */
diff --git a/arch/arm/src/samv7/sam_serial.c b/arch/arm/src/samv7/sam_serial.c
index 6744a72ce2e92a4884943a5305295fd3f27ecec2..ad81eb94765514466404409bcb93bce5204e53c2 100644
--- a/arch/arm/src/samv7/sam_serial.c
+++ b/arch/arm/src/samv7/sam_serial.c
@@ -333,7 +333,6 @@
struct sam_dev_s
{
const uint32_t usartbase; /* Base address of USART registers */
- xcpt_t handler; /* Interrupt handler */
uint32_t baud; /* Configured baud */
uint32_t sr; /* Saved status bits */
uint8_t irq; /* IRQ associated with this USART */
@@ -353,31 +352,7 @@ static int sam_setup(struct uart_dev_s *dev);
static void sam_shutdown(struct uart_dev_s *dev);
static int sam_attach(struct uart_dev_s *dev);
static void sam_detach(struct uart_dev_s *dev);
-static int sam_interrupt(struct uart_dev_s *dev);
-#ifdef CONFIG_SAMV7_UART0
-static int sam_uart0_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_SAMV7_UART1
-static int sam_uart1_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_SAMV7_UART2
-static int sam_uart2_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_SAMV7_UART3
-static int sam_uart3_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_SAMV7_UART4
-static int sam_uart4_interrupt(int irq, void *context);
-#endif
-#if defined(CONFIG_SAMV7_USART0) && defined(CONFIG_USART0_SERIALDRIVER)
-static int sam_usart0_interrupt(int irq, void *context);
-#endif
-#if defined(CONFIG_SAMV7_USART1) && defined(CONFIG_USART1_SERIALDRIVER)
-static int sam_usart1_interrupt(int irq, void *context);
-#endif
-#if defined(CONFIG_SAMV7_USART2) && defined(CONFIG_USART2_SERIALDRIVER)
-static int sam_usart2_interrupt(int irq, void *context);
-#endif
+static int sam_interrupt(int irq, void *context, FAR void *arg);
static int sam_ioctl(struct file *filep, int cmd, unsigned long arg);
static int sam_receive(struct uart_dev_s *dev, uint32_t *status);
static void sam_rxint(struct uart_dev_s *dev, bool enable);
@@ -451,7 +426,6 @@ static char g_usart2txbuffer[CONFIG_USART2_TXBUFSIZE];
static struct sam_dev_s g_uart0priv =
{
.usartbase = SAM_UART0_BASE,
- .handler = sam_uart0_interrupt,
.baud = CONFIG_UART0_BAUD,
.irq = SAM_IRQ_UART0,
.parity = CONFIG_UART0_PARITY,
@@ -482,7 +456,6 @@ static uart_dev_t g_uart0port =
static struct sam_dev_s g_uart1priv =
{
.usartbase = SAM_UART1_BASE,
- .handler = sam_uart1_interrupt,
.baud = CONFIG_UART1_BAUD,
.irq = SAM_IRQ_UART1,
.parity = CONFIG_UART1_PARITY,
@@ -513,7 +486,6 @@ static uart_dev_t g_uart1port =
static struct sam_dev_s g_uart2priv =
{
.usartbase = SAM_UART2_BASE,
- .handler = sam_uart2_interrupt,
.baud = CONFIG_UART2_BAUD,
.irq = SAM_IRQ_UART2,
.parity = CONFIG_UART2_PARITY,
@@ -544,7 +516,6 @@ static uart_dev_t g_uart2port =
static struct sam_dev_s g_uart3priv =
{
.usartbase = SAM_UART3_BASE,
- .handler = sam_uart3_interrupt,
.baud = CONFIG_UART3_BAUD,
.irq = SAM_IRQ_UART3,
.parity = CONFIG_UART3_PARITY,
@@ -575,7 +546,6 @@ static uart_dev_t g_uart3port =
static struct sam_dev_s g_uart4priv =
{
.usartbase = SAM_UART4_BASE,
- .handler = sam_uart4_interrupt,
.baud = CONFIG_UART4_BAUD,
.irq = SAM_IRQ_UART4,
.parity = CONFIG_UART4_PARITY,
@@ -606,7 +576,6 @@ static uart_dev_t g_uart4port =
static struct sam_dev_s g_usart0priv =
{
.usartbase = SAM_USART0_BASE,
- .handler = sam_usart0_interrupt,
.baud = CONFIG_USART0_BAUD,
.irq = SAM_IRQ_USART0,
.parity = CONFIG_USART0_PARITY,
@@ -640,7 +609,6 @@ static uart_dev_t g_usart0port =
static struct sam_dev_s g_usart1priv =
{
.usartbase = SAM_USART1_BASE,
- .handler = sam_usart1_interrupt,
.baud = CONFIG_USART1_BAUD,
.irq = SAM_IRQ_USART1,
.parity = CONFIG_USART1_PARITY,
@@ -674,7 +642,6 @@ static uart_dev_t g_usart1port =
static struct sam_dev_s g_usart2priv =
{
.usartbase = SAM_USART2_BASE,
- .handler = sam_usart2_interrupt,
.baud = CONFIG_USART2_BAUD,
.irq = SAM_IRQ_USART2,
.parity = CONFIG_USART2_PARITY,
@@ -973,7 +940,7 @@ static int sam_attach(struct uart_dev_s *dev)
/* Attach and enable the IRQ */
- ret = irq_attach(priv->irq, priv->handler);
+ ret = irq_attach(priv->irq, sam_interrupt, dev);
if (ret == OK)
{
/* Enable the interrupt (RX and TX interrupts are still disabled
@@ -1014,15 +981,16 @@ static void sam_detach(struct uart_dev_s *dev)
*
****************************************************************************/
-static int sam_interrupt(struct uart_dev_s *dev)
+static int sam_interrupt(int irq, void *context, FAR void *arg)
{
+ struct uart_dev_s *dev = (struct uart_dev_s *)arg;
struct sam_dev_s *priv;
- uint32_t pending;
- uint32_t imr;
- int passes;
- bool handled;
+ uint32_t pending;
+ uint32_t imr;
+ int passes;
+ bool handled;
- DEBUGASSERT(dev && dev->priv);
+ DEBUGASSERT(dev != NULL && dev->priv != NULL);
priv = (struct sam_dev_s *)dev->priv;
/* Loop until there are no characters to be transferred or, until we have
@@ -1068,72 +1036,6 @@ static int sam_interrupt(struct uart_dev_s *dev)
return OK;
}
-/****************************************************************************
- * Name: sam_uart[n]_interrupt
- *
- * Description:
- * UART interrupt handlers
- *
- ****************************************************************************/
-
-#ifdef CONFIG_SAMV7_UART0
-static int sam_uart0_interrupt(int irq, void *context)
-{
- return sam_interrupt(&g_uart0port);
-}
-#endif
-#ifdef CONFIG_SAMV7_UART1
-static int sam_uart1_interrupt(int irq, void *context)
-{
- return sam_interrupt(&g_uart1port);
-}
-#endif
-#ifdef CONFIG_SAMV7_UART2
-static int sam_uart2_interrupt(int irq, void *context)
-{
- return sam_interrupt(&g_uart2port);
-}
-#endif
-#ifdef CONFIG_SAMV7_UART3
-static int sam_uart3_interrupt(int irq, void *context)
-{
- return sam_interrupt(&g_uart3port);
-}
-#endif
-#ifdef CONFIG_SAMV7_UART4
-static int sam_uart4_interrupt(int irq, void *context)
-{
- return sam_interrupt(&g_uart4port);
-}
-#endif
-
-/****************************************************************************
- * Name: sam_usart[n]_interrupt
- *
- * Description:
- * USART interrupt handlers
- *
- ****************************************************************************/
-
-#if defined(CONFIG_SAMV7_USART0) && defined(CONFIG_USART0_SERIALDRIVER)
-static int sam_usart0_interrupt(int irq, void *context)
-{
- return sam_interrupt(&g_usart0port);
-}
-#endif
-#if defined(CONFIG_SAMV7_USART1) && defined(CONFIG_USART1_SERIALDRIVER)
-static int sam_usart1_interrupt(int irq, void *context)
-{
- return sam_interrupt(&g_usart1port);
-}
-#endif
-#if defined(CONFIG_SAMV7_USART2) && defined(CONFIG_USART2_SERIALDRIVER)
-static int sam_usart2_interrupt(int irq, void *context)
-{
- return sam_interrupt(&g_usart2port);
-}
-#endif
-
/****************************************************************************
* Name: sam_ioctl
*
diff --git a/arch/arm/src/samv7/sam_spi_slave.c b/arch/arm/src/samv7/sam_spi_slave.c
index d2856cd2e998e13a2ab9a6ef9465ab4224f62cf9..6b68769ab87597d28b969849f5ff333c7366498f 100644
--- a/arch/arm/src/samv7/sam_spi_slave.c
+++ b/arch/arm/src/samv7/sam_spi_slave.c
@@ -146,13 +146,7 @@ static void spi_semtake(struct sam_spidev_s *priv);
/* Interrupt Handling */
-static int spi_interrupt(struct sam_spidev_s *priv);
-#ifdef CONFIG_SAMV7_SPI0_SLAVE
-static int spi0_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_SAMV7_SPI1_SLAVE
-static int spi1_interrupt(int irq, void *context);
-#endif
+static int spi_interrupt(int irq, void *context, FAR void *arg);
/* SPI Helpers */
@@ -395,13 +389,16 @@ static void spi_semtake(struct sam_spidev_s *priv)
*
****************************************************************************/
-static int spi_interrupt(struct sam_spidev_s *priv)
+static int spi_interrupt(int irq, void *context, FAR void *arg)
{
+ struct sam_spidev_s *priv = (struct sam_spidev_s *)arg;
uint32_t sr;
uint32_t imr;
uint32_t pending;
uint32_t regval;
+ DEBUGASSERT(priv != NULL);
+
/* We loop because the TDRE interrupt will probably immediately follow the
* RDRF interrupt and we might be able to catch it in this handler
* execution.
@@ -553,48 +550,6 @@ static int spi_interrupt(struct sam_spidev_s *priv)
return OK;
}
-/****************************************************************************
- * Name: spi0_interrupt
- *
- * Description:
- * SPI0 interrupt handler
- *
- * Input Parameters:
- * Standard interrupt input parameters
- *
- * Returned Value:
- * Standard interrupt return value.
- *
- ****************************************************************************/
-
-#ifdef CONFIG_SAMV7_SPI0_SLAVE
-static int spi0_interrupt(int irq, void *context)
-{
- return spi_interrupt(&g_spi0_sctrlr);
-}
-#endif
-
-/****************************************************************************
- * Name: spi1_interrupt
- *
- * Description:
- * SPI1 interrupt handler
- *
- * Input Parameters:
- * Standard interrupt input parameters
- *
- * Returned Value:
- * Standard interrupt return value.
- *
- ****************************************************************************/
-
-#ifdef CONFIG_SAMV7_SPI1_SLAVE
-static int spi1_interrupt(int irq, void *context)
-{
- return spi_interrupt(&g_spi1_sctrlr);
-}
-#endif
-
/****************************************************************************
* Name: spi_dequeue
*
@@ -1177,9 +1132,8 @@ struct spi_sctrlr_s *sam_spi_slave_initialize(int port)
{
/* Set the SPI0 register base address and interrupt information */
- priv->base = SAM_SPI0_BASE,
- priv->irq = SAM_IRQ_SPI0;
- priv->handler = spi0_interrupt;
+ priv->base = SAM_SPI0_BASE,
+ priv->irq = SAM_IRQ_SPI0;
/* Enable peripheral clocking to SPI0 */
@@ -1200,9 +1154,8 @@ struct spi_sctrlr_s *sam_spi_slave_initialize(int port)
{
/* Set the SPI1 register base address and interrupt information */
- priv->base = SAM_SPI1_BASE,
- priv->irq = SAM_IRQ_SPI1;
- priv->handler = spi1_interrupt;
+ priv->base = SAM_SPI1_BASE,
+ priv->irq = SAM_IRQ_SPI1;
/* Enable peripheral clocking to SPI1 */
@@ -1255,7 +1208,7 @@ struct spi_sctrlr_s *sam_spi_slave_initialize(int port)
/* Attach and enable interrupts at the NVIC */
- DEBUGVERIFY(irq_attach(priv->irq, priv->handler));
+ DEBUGVERIFY(irq_attach(priv->irq, spi_interrupt, priv));
up_enable_irq(priv->irq);
spi_dumpregs(priv, "After initialization");
diff --git a/arch/arm/src/samv7/sam_tc.c b/arch/arm/src/samv7/sam_tc.c
index 691366af8f8a9224024efe6155daa3f3e02c5307..4b9303fd5348c23ef2bf0aeda1a40c858d3de51e 100644
--- a/arch/arm/src/samv7/sam_tc.c
+++ b/arch/arm/src/samv7/sam_tc.c
@@ -186,27 +186,27 @@ static inline void sam_chan_putreg(struct sam_chan_s *chan,
static int sam_tc_interrupt(struct sam_tc_s *tc, struct sam_chan_s *chan);
#ifdef CONFIG_SAMV7_TC0
-static int sam_tc0_interrupt(int irq, void *context);
-static int sam_tc1_interrupt(int irq, void *context);
-static int sam_tc2_interrupt(int irq, void *context);
+static int sam_tc0_interrupt(int irq, void *context, FAR void *arg);
+static int sam_tc1_interrupt(int irq, void *context, FAR void *arg);
+static int sam_tc2_interrupt(int irq, void *context, FAR void *arg);
#endif
#ifdef CONFIG_SAMV7_TC1
-static int sam_tc3_interrupt(int irq, void *context);
-static int sam_tc4_interrupt(int irq, void *context);
-static int sam_tc5_interrupt(int irq, void *context);
+static int sam_tc3_interrupt(int irq, void *context, FAR void *arg);
+static int sam_tc4_interrupt(int irq, void *context, FAR void *arg);
+static int sam_tc5_interrupt(int irq, void *context, FAR void *arg);
#endif
#ifdef CONFIG_SAMV7_TC2
-static int sam_tc6_interrupt(int irq, void *context);
-static int sam_tc7_interrupt(int irq, void *context);
-static int sam_tc8_interrupt(int irq, void *context);
+static int sam_tc6_interrupt(int irq, void *context, FAR void *arg);
+static int sam_tc7_interrupt(int irq, void *context, FAR void *arg);
+static int sam_tc8_interrupt(int irq, void *context, FAR void *arg);
#endif
#ifdef CONFIG_SAMV7_TC3
-static int sam_tc9_interrupt(int irq, void *context);
-static int sam_tc10_interrupt(int irq, void *context);
-static int sam_tc11_interrupt(int irq, void *context);
+static int sam_tc9_interrupt(int irq, void *context, FAR void *arg);
+static int sam_tc10_interrupt(int irq, void *context, FAR void *arg);
+static int sam_tc11_interrupt(int irq, void *context, FAR void *arg);
#endif
/* Initialization ***********************************************************/
@@ -893,68 +893,68 @@ static int sam_tc_interrupt(struct sam_tc_s *tc, struct sam_chan_s *chan)
****************************************************************************/
#ifdef CONFIG_SAMV7_TC0
-static int sam_tc0_interrupt(int irq, void *context)
+static int sam_tc0_interrupt(int irq, void *context, FAR void *arg)
{
return sam_tc_interrupt(&g_tc012, &g_tc012.channel[0]);
}
-static int sam_tc1_interrupt(int irq, void *context)
+static int sam_tc1_interrupt(int irq, void *context, FAR void *arg)
{
return sam_tc_interrupt(&g_tc012, &g_tc012.channel[1]);
}
-static int sam_tc2_interrupt(int irq, void *context)
+static int sam_tc2_interrupt(int irq, void *context, FAR void *arg)
{
return sam_tc_interrupt(&g_tc012, &g_tc012.channel[2]);
}
#endif
#ifdef CONFIG_SAMV7_TC1
-static int sam_tc3_interrupt(int irq, void *context)
+static int sam_tc3_interrupt(int irq, void *context, FAR void *arg)
{
return sam_tc_interrupt(&g_tc345, &g_tc345.channel[0]);
}
-static int sam_tc4_interrupt(int irq, void *context)
+static int sam_tc4_interrupt(int irq, void *context, FAR void *arg)
{
return sam_tc_interrupt(&g_tc345, &g_tc345.channel[1]);
}
-static int sam_tc5_interrupt(int irq, void *context)
+static int sam_tc5_interrupt(int irq, void *context, FAR void *arg)
{
return sam_tc_interrupt(&g_tc345, &g_tc345.channel[2]);
}
#endif
#ifdef CONFIG_SAMV7_TC2
-static int sam_tc6_interrupt(int irq, void *context)
+static int sam_tc6_interrupt(int irq, void *context, FAR void *arg)
{
return sam_tc_interrupt(&g_tc678, &g_tc678.channel[0]);
}
-static int sam_tc7_interrupt(int irq, void *context)
+static int sam_tc7_interrupt(int irq, void *context, FAR void *arg)
{
return sam_tc_interrupt(&g_tc678, &g_tc678.channel[1]);
}
-static int sam_tc8_interrupt(int irq, void *context)
+static int sam_tc8_interrupt(int irq, void *context, FAR void *arg)
{
return sam_tc_interrupt(&g_tc678, &g_tc678.channel[2]);
}
#endif
#ifdef CONFIG_SAMV7_TC3
-static int sam_tc9_interrupt(int irq, void *context)
+static int sam_tc9_interrupt(int irq, void *context, FAR void *arg)
{
return sam_tc_interrupt(&g_tc901, &g_tc901.channel[0]);
}
-static int sam_tc10_interrupt(int irq, void *context)
+static int sam_tc10_interrupt(int irq, void *context, FAR void *arg)
{
return sam_tc_interrupt(&g_tc901, &g_tc901.channel[1]);
}
-static int sam_tc11_interrupt(int irq, void *context)
+static int sam_tc11_interrupt(int irq, void *context, FAR void *arg)
{
return sam_tc_interrupt(&g_tc901, &g_tc901.channel[2]);
}
@@ -1279,7 +1279,7 @@ static inline struct sam_chan_s *sam_tc_initialize(int channel)
/* Attach the timer interrupt handler and enable the timer interrupts */
- (void)irq_attach(chconfig->irq, chconfig->handler);
+ (void)irq_attach(chconfig->irq, chconfig->handler, NULL);
up_enable_irq(chconfig->irq);
/* Mark the channel "inuse" */
diff --git a/arch/arm/src/samv7/sam_timerisr.c b/arch/arm/src/samv7/sam_timerisr.c
index c2c30ea0afe1d2af38fbfa4a32e877b26b059191..751878d984313a038f7174fe1eedc50910b621e6 100644
--- a/arch/arm/src/samv7/sam_timerisr.c
+++ b/arch/arm/src/samv7/sam_timerisr.c
@@ -98,7 +98,7 @@
*
****************************************************************************/
-static int sam_timerisr(int irq, uint32_t *regs)
+static int sam_timerisr(int irq, uint32_t *regs, void *arg)
{
/* Process timer interrupt */
@@ -130,7 +130,7 @@ void arm_timer_initialize(void)
/* Attach the timer interrupt vector */
- (void)irq_attach(SAM_IRQ_SYSTICK, (xcpt_t)sam_timerisr);
+ (void)irq_attach(SAM_IRQ_SYSTICK, (xcpt_t)sam_timerisr, NULL);
/* Enable SysTick interrupts (no divide-by-8) */
diff --git a/arch/arm/src/samv7/sam_trng.c b/arch/arm/src/samv7/sam_trng.c
index 6fee91e850cd42123e16cd30a5be94ea00d9efb8..e8eae34f997c9dfd06f3ac4378b9cf4afddd9a5f 100644
--- a/arch/arm/src/samv7/sam_trng.c
+++ b/arch/arm/src/samv7/sam_trng.c
@@ -72,7 +72,7 @@
/* Interrupts */
-static int sam_interrupt(int irq, void *context);
+static int sam_interrupt(int irq, void *context, FAR void *arg);
/* Character driver methods */
@@ -128,7 +128,7 @@ static const struct file_operations g_trngops =
*
****************************************************************************/
-static int sam_interrupt(int irq, void *context)
+static int sam_interrupt(int irq, void *context, FAR void *arg)
{
uint32_t odata;
@@ -372,7 +372,7 @@ static int sam_rng_initialize(void)
/* Initialize the TRNG interrupt */
- ret = irq_attach(SAM_IRQ_TRNG, sam_interrupt);
+ ret = irq_attach(SAM_IRQ_TRNG, sam_interrupt, NULL);
if (ret < 0)
{
ferr("ERROR: Failed to attach to IRQ%d\n", SAM_IRQ_TRNG);
diff --git a/arch/arm/src/samv7/sam_twihs.c b/arch/arm/src/samv7/sam_twihs.c
index bdb5523ace6c8fb8fb017b8ba8869c68559435a2..4cbd19d396532879fcfe5af81b9835f4de9d6e01 100644
--- a/arch/arm/src/samv7/sam_twihs.c
+++ b/arch/arm/src/samv7/sam_twihs.c
@@ -140,7 +140,6 @@ struct twi_attr_s
gpio_pinset_t sclcfg; /* TWIHS CK pin configuration (SCL in I2C-ese) */
gpio_pinset_t sdacfg; /* TWIHS D pin configuration (SDA in I2C-ese) */
uintptr_t base; /* Base address of TWIHS registers */
- xcpt_t handler; /* TWIHS interrupt handler */
};
/* State of a TWIHS bus */
@@ -199,18 +198,9 @@ static inline void twi_putrel(struct twi_dev_s *priv, unsigned int offset,
/* I2C transfer helper functions */
-static int twi_wait(struct twi_dev_s *priv, unsigned int size);
+static int twi_wait(struct twi_dev_s *priv, unsigned int size);
static void twi_wakeup(struct twi_dev_s *priv, int result);
-static int twi_interrupt(struct twi_dev_s *priv);
-#ifdef CONFIG_SAMV7_TWIHS0
-static int twi0_interrupt(int irq, FAR void *context);
-#endif
-#ifdef CONFIG_SAMV7_TWIHS1
-static int twi1_interrupt(int irq, FAR void *context);
-#endif
-#ifdef CONFIG_SAMV7_TWIHS2
-static int twi2_interrupt(int irq, FAR void *context);
-#endif
+static int twi_interrupt(int irq, FAR void *context, FAR void *arg);
static void twi_timeout(int argc, uint32_t arg, ...);
static void twi_startread(struct twi_dev_s *priv, struct i2c_msg_s *msg);
@@ -250,7 +240,6 @@ static const struct twi_attr_s g_twi0attr =
.sclcfg = GPIO_TWIHS0_CK,
.sdacfg = GPIO_TWIHS0_D,
.base = SAM_TWIHS0_BASE,
- .handler = twi0_interrupt,
};
static struct twi_dev_s g_twi0;
@@ -271,7 +260,6 @@ static const struct twi_attr_s g_twi1attr =
.sclcfg = GPIO_TWIHS1_CK,
.sdacfg = GPIO_TWIHS1_D,
.base = SAM_TWIHS1_BASE,
- .handler = twi1_interrupt,
};
static struct twi_dev_s g_twi1;
@@ -292,7 +280,6 @@ static const struct twi_attr_s g_twi2attr =
.sclcfg = GPIO_TWIHS2_CK,
.sdacfg = GPIO_TWIHS2_D,
.base = SAM_TWIHS2_BASE,
- .handler = twi2_interrupt,
};
static struct twi_dev_s g_twi2;
@@ -571,14 +558,17 @@ static void twi_wakeup(struct twi_dev_s *priv, int result)
*
****************************************************************************/
-static int twi_interrupt(struct twi_dev_s *priv)
+static int twi_interrupt(int irq, FAR void *context, FAR void *arg)
{
+ struct twi_dev_s *priv = (struct twi_dev_s *)arg;
struct i2c_msg_s *msg;
uint32_t sr;
uint32_t imr;
uint32_t pending;
uint32_t regval;
+ DEBUGASSERT(priv != NULL);
+
/* Retrieve masked interrupt status */
sr = twi_getrel(priv, SAM_TWIHS_SR_OFFSET);
@@ -761,27 +751,6 @@ static int twi_interrupt(struct twi_dev_s *priv)
return OK;
}
-#ifdef CONFIG_SAMV7_TWIHS0
-static int twi0_interrupt(int irq, FAR void *context)
-{
- return twi_interrupt(&g_twi0);
-}
-#endif
-
-#ifdef CONFIG_SAMV7_TWIHS1
-static int twi1_interrupt(int irq, FAR void *context)
-{
- return twi_interrupt(&g_twi1);
-}
-#endif
-
-#ifdef CONFIG_SAMV7_TWIHS2
-static int twi2_interrupt(int irq, FAR void *context)
-{
- return twi_interrupt(&g_twi2);
-}
-#endif
-
/****************************************************************************
* Name: twi_timeout
*
@@ -1444,7 +1413,7 @@ struct i2c_master_s *sam_i2cbus_initialize(int bus)
/* Attach Interrupt Handler */
- ret = irq_attach(priv->attr->irq, priv->attr->handler);
+ ret = irq_attach(priv->attr->irq, twi_interrupt, priv);
if (ret < 0)
{
ierr("ERROR: Failed to attach irq %d\n", priv->attr->irq);
diff --git a/arch/arm/src/samv7/sam_usbdevhs.c b/arch/arm/src/samv7/sam_usbdevhs.c
index 1d48ca410a1999429f98e18f12f1f889825b3440..4adfa117c11abfcbb08b0fb45ff124e8db3d5b63 100644
--- a/arch/arm/src/samv7/sam_usbdevhs.c
+++ b/arch/arm/src/samv7/sam_usbdevhs.c
@@ -517,7 +517,7 @@ static void sam_ep0_setup(struct sam_usbdev_s *priv);
static void sam_dma_interrupt(struct sam_usbdev_s *priv, int epno);
#endif
static void sam_ep_interrupt(struct sam_usbdev_s *priv, int epno);
-static int sam_usbhs_interrupt(int irq, void *context);
+static int sam_usbhs_interrupt(int irq, void *context, FAR void *arg);
/* Endpoint helpers *********************************************************/
@@ -2992,7 +2992,7 @@ static void sam_ep_interrupt(struct sam_usbdev_s *priv, int epno)
*
****************************************************************************/
-static int sam_usbhs_interrupt(int irq, void *context)
+static int sam_usbhs_interrupt(int irq, void *context, FAR void *arg)
{
/* For now there is only one USB controller, but we will always refer to
* it using a pointer to make any future ports to multiple USBHS controllers
@@ -4862,7 +4862,7 @@ void up_usbinitialize(void)
* them when we need them later.
*/
- if (irq_attach(SAM_IRQ_USBHS, sam_usbhs_interrupt) != 0)
+ if (irq_attach(SAM_IRQ_USBHS, sam_usbhs_interrupt, NULL) != 0)
{
usbtrace(TRACE_DEVERROR(SAM_TRACEERR_IRQREGISTRATION),
(uint16_t)SAM_IRQ_USBHS);
diff --git a/arch/arm/src/samv7/sam_wdt.c b/arch/arm/src/samv7/sam_wdt.c
index 850fd2288c34b35dc6be6c479cebc096e1d82449..e662146077e9ead6939446ad654ccc05a5ecc9e3 100644
--- a/arch/arm/src/samv7/sam_wdt.c
+++ b/arch/arm/src/samv7/sam_wdt.c
@@ -120,7 +120,7 @@ static void sam_putreg(uint32_t regval, uintptr_t regaddr);
/* Interrupt hanlding *******************************************************/
#ifdef CONFIG_SAMV7_WDT_INTERRUPT
-static int sam_interrupt(int irq, FAR void *context);
+static int sam_interrupt(int irq, FAR void *context, FAR void *arg);
#endif
/* "Lower half" driver methods **********************************************/
@@ -260,7 +260,7 @@ static void sam_putreg(uint32_t regval, uintptr_t regaddr)
****************************************************************************/
#ifdef CONFIG_SAMV7_WDT_INTERRUPT
-static int sam_interrupt(int irq, FAR void *context)
+static int sam_interrupt(int irq, FAR void *context, FAR void *arg)
{
FAR struct sam_lowerhalf_s *priv = &g_wdtdev;
@@ -684,7 +684,7 @@ int sam_wdt_initialize(void)
#ifdef CONFIG_SAMV7_WDT_INTERRUPT
/* Attach our WDT interrupt handler (But don't enable it yet) */
- (void)irq_attach(SAM_IRQ_WDT, sam_interrupt);
+ (void)irq_attach(SAM_IRQ_WDT, sam_interrupt, NULL);
#endif
/* Register the watchdog driver as device-node configured via .config.
diff --git a/arch/arm/src/samv7/sam_xdmac.c b/arch/arm/src/samv7/sam_xdmac.c
index 206ecb5d0f14ef53ef3be0dc96c0f7e0b0131d7a..b47617cafecdc61f0c961205bb30f9f037905996 100644
--- a/arch/arm/src/samv7/sam_xdmac.c
+++ b/arch/arm/src/samv7/sam_xdmac.c
@@ -1506,7 +1506,7 @@ static void sam_dmaterminate(struct sam_xdmach_s *xdmach, int result)
*
****************************************************************************/
-static int sam_xdmac_interrupt(int irq, void *context)
+static int sam_xdmac_interrupt(int irq, void *context, FAR void *arg)
{
struct sam_xdmac_s *xdmac = &g_xdmac;
struct sam_xdmach_s *xdmach;
@@ -1624,7 +1624,7 @@ void weak_function up_dmainitialize(void)
/* Attach DMA interrupt vector */
- (void)irq_attach(SAM_IRQ_XDMAC, sam_xdmac_interrupt);
+ (void)irq_attach(SAM_IRQ_XDMAC, sam_xdmac_interrupt, NULL);
/* Initialize the controller */
diff --git a/arch/arm/src/stm32/Kconfig b/arch/arm/src/stm32/Kconfig
index 28665b6f0f4908bfb806dc5b05ea28182934a2af..53e1513e0b3cfeef1291a27e1d799d88671a4cd9 100644
--- a/arch/arm/src/stm32/Kconfig
+++ b/arch/arm/src/stm32/Kconfig
@@ -773,6 +773,60 @@ config ARCH_CHIP_STM32F303VC
select STM32_HAVE_UART5
select STM32_HAVE_USBDEV
+config ARCH_CHIP_STM32F334K4
+ bool "STM32F334K4"
+ select ARCH_CORTEXM4
+ select STM32_STM32F33XX
+ select ARCH_HAVE_FPU
+
+config ARCH_CHIP_STM32F334K6
+ bool "STM32F334K6"
+ select ARCH_CORTEXM4
+ select STM32_STM32F33XX
+ select ARCH_HAVE_FPU
+
+config ARCH_CHIP_STM32F334K8
+ bool "STM32F334K8"
+ select ARCH_CORTEXM4
+ select STM32_STM32F33XX
+ select ARCH_HAVE_FPU
+
+config ARCH_CHIP_STM32F334C4
+ bool "STM32F334C4"
+ select ARCH_CORTEXM4
+ select STM32_STM32F33XX
+ select ARCH_HAVE_FPU
+
+config ARCH_CHIP_STM32F334C6
+ bool "STM32F334C6"
+ select ARCH_CORTEXM4
+ select STM32_STM32F33XX
+ select ARCH_HAVE_FPU
+
+config ARCH_CHIP_STM32F334C8
+ bool "STM32F334C8"
+ select ARCH_CORTEXM4
+ select STM32_STM32F33XX
+ select ARCH_HAVE_FPU
+
+config ARCH_CHIP_STM32F334R4
+ bool "STM32F334R4"
+ select ARCH_CORTEXM4
+ select STM32_STM32F33XX
+ select ARCH_HAVE_FPU
+
+config ARCH_CHIP_STM32F334R6
+ bool "STM32F334R6"
+ select ARCH_CORTEXM4
+ select STM32_STM32F33XX
+ select ARCH_HAVE_FPU
+
+config ARCH_CHIP_STM32F334R8
+ bool "STM32F334R8"
+ select ARCH_CORTEXM4
+ select STM32_STM32F33XX
+ select ARCH_HAVE_FPU
+
config ARCH_CHIP_STM32F372C8
bool "STM32F372C8"
select ARCH_CORTEXM4
@@ -1388,6 +1442,25 @@ config STM32_STM32F303
select STM32_HAVE_DAC2
select STM32_HAVE_TIM7
+config STM32_STM32F33XX
+ bool
+ default n
+ select STM32_HAVE_HRTIM1
+ select STM32_HAVE_COMP2
+ select STM32_HAVE_COMP4
+ select STM32_HAVE_COMP6
+ select STM32_HAVE_OPAMP
+ select STM32_HAVE_CCM
+ select STM32_HAVE_TIM1
+ select STM32_HAVE_TIM15
+ select STM32_HAVE_TIM16
+ select STM32_HAVE_TIM17
+ select STM32_HAVE_ADC2
+ select STM32_HAVE_CAN1
+ select STM32_HAVE_DAC1
+ select STM32_HAVE_DAC2
+ select STM32_HAVE_USART3
+
config STM32_STM32F37XX
bool
default n
@@ -1673,6 +1746,10 @@ config STM32_HAVE_FSMC
bool
default n
+config STM32_HAVE_HRTIM1
+ bool
+ default n
+
config STM32_HAVE_LTDC
bool
default n
@@ -1829,6 +1906,18 @@ config STM32_HAVE_CAN2
bool
default n
+config STM32_HAVE_COMP2
+ bool
+ default n
+
+config STM32_HAVE_COMP4
+ bool
+ default n
+
+config STM32_HAVE_COMP6
+ bool
+ default n
+
config STM32_HAVE_DAC1
bool
default n
@@ -1881,6 +1970,10 @@ config STM32_HAVE_I2SPLL
bool
default n
+config STM32_HAVE_OPAMP
+ bool
+ default n
+
# These are the peripheral selections proper
config STM32_ADC1
@@ -1938,6 +2031,21 @@ config STM32_COMP
default n
depends on STM32_STM32L15XX
+config STM32_COMP2
+ bool "COMP2"
+ default n
+ depends on STM32_HAVE_COMP2
+
+config STM32_COMP4
+ bool "COMP4"
+ default n
+ depends on STM32_HAVE_COMP4
+
+config STM32_COMP6
+ bool "COMP6"
+ default n
+ depends on STM32_HAVE_COMP6
+
config STM32_BKP
bool "BKP"
default n
@@ -2033,6 +2141,11 @@ config STM32_HASH
default n
depends on STM32_STM32F207 || STM32_STM32F40XX
+config STM32_HRTIM1
+ bool "HRTIM1"
+ default n
+ depends on STM32_HAVE_HRTIM1
+
config STM32_I2C1
bool "I2C1"
default n
@@ -2068,6 +2181,11 @@ config STM32_DMA2D
The STM32 DMA2D is an Chrom-Art Accelerator for image manipulation
available on the STM32F429 and STM32F439 devices.
+config STM32_OPAMP
+ bool "OPAMP"
+ default n
+ depends on STM32_HAVE_OPAMP
+
config STM32_OTGFS
bool "OTG FS"
default n
@@ -6768,11 +6886,12 @@ config STM32_TIM1_QE
if STM32_TIM1_QE
-config STM32_TIM1_QECLKOUT
- int "TIM1 output clock"
- default 2800000
+config STM32_TIM1_QEPSC
+ int "TIM1 pulse prescaler"
+ default 1
---help---
- The output clock of TIM1.
+ This prescaler divides the number of recorded encoder pulses,
+ limiting the count rate at the expense of resolution.
endif
@@ -6785,11 +6904,12 @@ config STM32_TIM2_QE
if STM32_TIM2_QE
-config STM32_TIM2_QECLKOUT
- int "TIM2 output clock"
- default 2800000
+config STM32_TIM2_QEPSC
+ int "TIM2 pulse prescaler"
+ default 1
---help---
- The output clock of TIM2.
+ This prescaler divides the number of recorded encoder pulses,
+ limiting the count rate at the expense of resolution.
endif
@@ -6802,11 +6922,12 @@ config STM32_TIM3_QE
if STM32_TIM3_QE
-config STM32_TIM3_QECLKOUT
- int "TIM3 output clock"
- default 2800000
+config STM32_TIM3_QEPSC
+ int "TIM3 pulse prescaler"
+ default 1
---help---
- The output clock of TIM3.
+ This prescaler divides the number of recorded encoder pulses,
+ limiting the count rate at the expense of resolution.
endif
@@ -6819,11 +6940,12 @@ config STM32_TIM4_QE
if STM32_TIM4_QE
-config STM32_TIM4_QECLKOUT
- int "TIM4 output clock"
- default 2800000
+config STM32_TIM4_QEPSC
+ int "TIM4 pulse prescaler"
+ default 1
---help---
- The output clock of TIM4.
+ This prescaler divides the number of recorded encoder pulses,
+ limiting the count rate at the expense of resolution.
endif
@@ -6836,11 +6958,12 @@ config STM32_TIM5_QE
if STM32_TIM5_QE
-config STM32_TIM5_QECLKOUT
- int "TIM5 output clock"
- default 2800000
+config STM32_TIM5_QEPSC
+ int "TIM5 pulse prescaler"
+ default 1
---help---
- The output clock of TIM5.
+ This prescaler divides the number of recorded encoder pulses,
+ limiting the count rate at the expense of resolution.
endif
@@ -6853,11 +6976,12 @@ config STM32_TIM8_QE
if STM32_TIM8_QE
-config STM32_TIM8_QECLKOUT
- int "TIM8 output clock"
- default 2800000
+config STM32_TIM8_QEPSC
+ int "TIM8 pulse prescaler"
+ default 1
---help---
- The output clock of TIM8.
+ This prescaler divides the number of recorded encoder pulses,
+ limiting the count rate at the expense of resolution.
endif
diff --git a/arch/arm/src/stm32/chip.h b/arch/arm/src/stm32/chip.h
index 4542a3885f02a6fee8f26ca3df9318b006ba30c4..64ec1db604977d383218b6a66d6c5d170bc584c6 100644
--- a/arch/arm/src/stm32/chip.h
+++ b/arch/arm/src/stm32/chip.h
@@ -127,6 +127,8 @@
#elif defined(CONFIG_STM32_STM32F30XX)
# include "chip/stm32f30xxx_pinmap.h"
+#elif defined(CONFIG_STM32_STM32F33XX)
+# include "chip/stm32f33xxx_pinmap.h"
#elif defined(CONFIG_STM32_STM32F37XX)
# include "chip/stm32f37xxx_pinmap.h"
@@ -151,6 +153,8 @@
# include "chip/stm32f20xxx_vectors.h"
# elif defined(CONFIG_STM32_STM32F30XX)
# include "chip/stm32f30xxx_vectors.h"
+# elif defined(CONFIG_STM32_STM32F33XX)
+# include "chip/stm32f33xxx_vectors.h"
# elif defined(CONFIG_STM32_STM32F37XX)
# include "chip/stm32f37xxx_vectors.h"
# elif defined(CONFIG_STM32_STM32F40XX)
diff --git a/arch/arm/src/stm32/chip/stm32_dac.h b/arch/arm/src/stm32/chip/stm32_dac.h
index 61332080eab5d7cdcc44f27d9cc963d8cb4e8ed4..48ea76280ec5cbe1d302e2f1cd755ef01305ac77 100644
--- a/arch/arm/src/stm32/chip/stm32_dac.h
+++ b/arch/arm/src/stm32/chip/stm32_dac.h
@@ -177,7 +177,7 @@
# define DAC_CR_TSEL1_TIM4 (5 << DAC_CR_TSEL1_SHIFT) /* Timer 4 TRGO event */
# define DAC_CR_TSEL1_EXT9 (6 << DAC_CR_TSEL1_SHIFT) /* External line9 */
# define DAC_CR_TSEL1_SW (7 << DAC_CR_TSEL1_SHIFT) /* Software trigger */
-#define DAC_CR_WAVE1_SHIFT (6) /* Bits 6-7: DAC channel 1 noise/triangle wave generation */enable
+#define DAC_CR_WAVE1_SHIFT (6) /* Bits 6-7: DAC channel 1 noise/triangle wave generation */
#define DAC_CR_WAVE1_MASK (3 << DAC_CR_WAVE1_SHIFT)
# define DAC_CR_WAVE1_DISABLED (0 << DAC_CR_WAVE1_SHIFT) /* Wave generation disabled */
# define DAC_CR_WAVE1_NOISE (1 << DAC_CR_WAVE1_SHIFT) /* Noise wave generation enabled */
diff --git a/arch/arm/src/stm32/chip/stm32_dbgmcu.h b/arch/arm/src/stm32/chip/stm32_dbgmcu.h
index dc22cd2e7be0630e3c62150d0f8aa7793f2abf39..af80113a737eed289b5918486fe3fe7d7b9328e8 100644
--- a/arch/arm/src/stm32/chip/stm32_dbgmcu.h
+++ b/arch/arm/src/stm32/chip/stm32_dbgmcu.h
@@ -53,7 +53,8 @@
#define STM32_DBGMCU_IDCODE 0xe0042000 /* MCU identifier */
#define STM32_DBGMCU_CR 0xe0042004 /* MCU debug */
#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F30XX) || \
- defined(CONFIG_STM32_STM32F40XX) || defined(CONFIG_STM32_STM32L15XX)
+ defined(CONFIG_STM32_STM32F33XX) || defined(CONFIG_STM32_STM32F40XX) || \
+ defined(CONFIG_STM32_STM32L15XX)
# define STM32_DBGMCU_APB1_FZ 0xe0042008 /* Debug MCU APB1 freeze register */
# define STM32_DBGMCU_APB2_FZ 0xe004200c /* Debug MCU APB2 freeze register */
#endif
@@ -118,7 +119,8 @@
# define DBGMCU_APB1_I2C3STOP (1 << 23) /* Bit 23: SMBUS timeout mode stopped when Core is halted */
# define DBGMCU_APB1_CAN1STOP (1 << 25) /* Bit 25: CAN1 stopped when core is halted */
# define DBGMCU_APB1_CAN2STOP (1 << 26) /* Bit 26: CAN2 stopped when core is halted */
-#elif defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32L15XX)
+#elif defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX) || \
+ defined(CONFIG_STM32_STM32L15XX)
# define DBGMCU_APB1_TIM2STOP (1 << 0) /* Bit 0: TIM2 stopped when core is halted */
# define DBGMCU_APB1_TIM3STOP (1 << 1) /* Bit 1: TIM3 stopped when core is halted */
# define DBGMCU_APB1_TIM4STOP (1 << 2) /* Bit 2: TIM4 stopped when core is halted */
@@ -129,7 +131,7 @@
# define DBGMCU_APB1_IWDGSTOP (1 << 12) /* Bit 12: Independent Watchdog stopped when core is halted */
# define DBGMCU_APB1_I2C1STOP (1 << 21) /* Bit 21: SMBUS timeout mode stopped when Core is halted */
# define DBGMCU_APB1_I2C2STOP (1 << 22) /* Bit 22: SMBUS timeout mode stopped when Core is halted */
-# if defined(CONFIG_STM32_STM32F30XX)
+# if defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX)
# define DBGMCU_APB1_CAN1STOP (1 << 25) /* Bit 25: CAN1 stopped when core is halted */
# endif
#endif
@@ -142,7 +144,7 @@
# define DBGMCU_APB2_TIM9STOP (1 << 16) /* Bit 16: TIM9 stopped when core is halted */
# define DBGMCU_APB2_TIM10STOP (1 << 17) /* Bit 17: TIM10 stopped when core is halted */
# define DBGMCU_APB2_TIM11STOP (1 << 18) /* Bit 18: TIM11 stopped when core is halted */
-#elif defined(CONFIG_STM32_STM32F30XX)
+#elif defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX)
# define DBGMCU_APB2_TIM1STOP (1 << 0) /* Bit 0: TIM1 stopped when core is halted */
# define DBGMCU_APB2_TIM8STOP (1 << 1) /* Bit 1: TIM8 stopped when core is halted */
# define DBGMCU_APB2_TIM15STOP (1 << 2) /* Bit 2: TIM15 stopped when core is halted */
diff --git a/arch/arm/src/stm32/chip/stm32_exti.h b/arch/arm/src/stm32/chip/stm32_exti.h
index a3092ca0e4295e0aa2d88bc6969e96875c9e896c..791bed1f174fe1c876eee7bb9b86133c80ccd996 100644
--- a/arch/arm/src/stm32/chip/stm32_exti.h
+++ b/arch/arm/src/stm32/chip/stm32_exti.h
@@ -55,7 +55,7 @@
# define STM32_NEXTI 19
# define STM32_EXTI_MASK 0x0007ffff
# endif
-#elif defined(CONFIG_STM32_STM32F30XX)
+#elif defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX)
# define STM32_NEXTI1 31
# define STM32_EXTI1_MASK 0xffffffff
# define STM32_NEXTI2 4
@@ -69,7 +69,7 @@
/* Register Offsets *****************************************************************/
-#if defined(CONFIG_STM32_STM32F30XX)
+#if defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX)
# define STM32_EXTI1_OFFSET 0x0000 /* Offset to EXTI1 registers */
# define STM32_EXTI2_OFFSET 0x0018 /* Offset to EXTI2 registers */
#endif
@@ -83,7 +83,7 @@
/* Register Addresses ***************************************************************/
-#if defined(CONFIG_STM32_STM32F30XX)
+#if defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX)
# define STM32_EXTI1_BASE (STM32_EXTI_BASE+STM32_EXTI1_OFFSET)
# define STM32_EXTI2_BASE (STM32_EXTI_BASE+STM32_EXTI2_OFFSET)
@@ -146,7 +146,8 @@
# define EXTI_RTC_TAMPER (1 << 21) /* EXTI line 21 is connected to the RTC Tamper and TimeStamp events */
# define EXTI_RTC_TIMESTAMP (1 << 21) /* EXTI line 21 is connected to the RTC Tamper and TimeStamp events */
# define EXTI_RTC_WAKEUP (1 << 22) /* EXTI line 22 is connected to the RTC Wakeup event */
-#elif defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F37XX)
+#elif defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX) || \
+ defined(CONFIG_STM32_STM32F37XX)
# define EXTI_PVD_LINE (1 << 16) /* EXTI line 16 is connected to the PVD output */
# define EXTI_RTC_ALARM (1 << 17) /* EXTI line 17 is connected to the RTC Alarm event */
# define EXTI_OTGFS_WAKEUP (1 << 18) /* EXTI line 18 is connected to the USB OTG FS Wakeup event */
@@ -193,7 +194,7 @@
/* Compatibility Definitions ********************************************************/
-#if defined(CONFIG_STM32_STM32F30XX)
+#if defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX)
# define STM32_NEXTI STM32_NEXTI1
# define STM32_EXTI_MASK STM32_EXTI1_MASK
# define STM32_EXTI_IMR STM32_EXTI1_IMR
diff --git a/arch/arm/src/stm32/chip/stm32_flash.h b/arch/arm/src/stm32/chip/stm32_flash.h
index 70e6d62d97607717a3baa12d6c1ed198feaaef4d..218ba05fcf77323cfd689ea049f46f54965a7e29 100644
--- a/arch/arm/src/stm32/chip/stm32_flash.h
+++ b/arch/arm/src/stm32/chip/stm32_flash.h
@@ -90,6 +90,10 @@
# define STM32_FLASH_NPAGES 128
# define STM32_FLASH_PAGESIZE 2048
+# elif defined(CONFIG_STM32_STM32F33XX)
+# define STM32_FLASH_NPAGES 32
+# define STM32_FLASH_PAGESIZE 2048
+
# elif defined(CONFIG_STM32_STM32F37XX)
# define STM32_FLASH_NPAGES 128
# define STM32_FLASH_PAGESIZE 2048
@@ -212,7 +216,7 @@
#define STM32_FLASH_CR_OFFSET 0x0010
#if defined(CONFIG_STM32_STM32F10XX) || defined(CONFIG_STM32_STM32F30XX) || \
- defined(CONFIG_STM32_STM32F37XX)
+ defined(CONFIG_STM32_STM32F33XX) || defined(CONFIG_STM32_STM32F37XX)
# define STM32_FLASH_AR_OFFSET 0x0014
# define STM32_FLASH_OBR_OFFSET 0x001c
# define STM32_FLASH_WRPR_OFFSET 0x0020
@@ -233,7 +237,7 @@
#define STM32_FLASH_CR (STM32_FLASHIF_BASE+STM32_FLASH_CR_OFFSET)
#if defined(CONFIG_STM32_STM32F10XX) || defined(CONFIG_STM32_STM32F30XX) || \
- defined(CONFIG_STM32_STM32F37XX)
+ defined(CONFIG_STM32_STM32F33XX) || defined(CONFIG_STM32_STM32F37XX)
# define STM32_FLASH_AR (STM32_FLASHIF_BASE+STM32_FLASH_AR_OFFSET)
# define STM32_FLASH_OBR (STM32_FLASHIF_BASE+STM32_FLASH_OBR_OFFSET)
# define STM32_FLASH_WRPR (STM32_FLASHIF_BASE+STM32_FLASH_WRPR_OFFSET)
@@ -267,10 +271,11 @@
# define FLASH_ACR_LATENCY_7 (7 << FLASH_ACR_LATENCY_SHIFT) /* 111: Seven wait states */
# if defined(CONFIG_STM32_STM32F10XX) || defined(CONFIG_STM32_STM32F30XX) || \
- defined(CONFIG_STM32_STM32F37XX)
+ defined(CONFIG_STM32_STM32F33XX) || defined(CONFIG_STM32_STM32F37XX)
# define FLASH_ACR_HLFCYA (1 << 3) /* Bit 3: FLASH half cycle access */
# define FLASH_ACR_PRTFBE (1 << 4) /* Bit 4: FLASH prefetch enable */
-# if defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F37XX)
+# if defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX) || \
+ defined(CONFIG_STM32_STM32F37XX)
# define FLASH_ACR_PRFTBS (1 << 5) /* Bit 5: FLASH prefetch buffer status */
# endif
# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX)
@@ -285,7 +290,7 @@
/* Flash Status Register (SR) */
#if defined(CONFIG_STM32_STM32F10XX) || defined(CONFIG_STM32_STM32F30XX) || \
- defined(CONFIG_STM32_STM32F37XX)
+ defined(CONFIG_STM32_STM32F33XX) || defined(CONFIG_STM32_STM32F37XX)
# define FLASH_SR_BSY (1 << 0) /* Busy */
# define FLASH_SR_PGERR (1 << 2) /* Programming Error */
# define FLASH_SR_WRPRT_ERR (1 << 4) /* Write Protection Error */
@@ -303,7 +308,7 @@
/* Flash Control Register (CR) */
#if defined(CONFIG_STM32_STM32F10XX) || defined(CONFIG_STM32_STM32F30XX) || \
- defined(CONFIG_STM32_STM32F37XX)
+ defined(CONFIG_STM32_STM32F33XX) || defined(CONFIG_STM32_STM32F37XX)
# define FLASH_CR_PG (1 << 0) /* Bit 0: Program Page */
# define FLASH_CR_PER (1 << 1) /* Bit 1: Page Erase */
# define FLASH_CR_MER (1 << 2) /* Bit 2: Mass Erase */
@@ -314,7 +319,8 @@
# define FLASH_CR_OPTWRE (1 << 9) /* Bit 8: Option Bytes Write Enable */
# define FLASH_CR_ERRIE (1 << 10) /* Bit 10: Error Interrupt Enable */
# define FLASH_CR_EOPIE (1 << 12) /* Bit 12: End of Program Interrupt Enable */
-# if defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F37XX)
+# if defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX) || \
+ defined(CONFIG_STM32_STM32F37XX)
# define FLASH_CR_OBL_LAUNCH (1 << 13) /* Bit 13: Force option byte loading */
# endif
#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX)
diff --git a/arch/arm/src/stm32/chip/stm32_memorymap.h b/arch/arm/src/stm32/chip/stm32_memorymap.h
index 28f6590033cafb5da2b109572d8be837a2602504..3e88405ca750aea9c4a85ee90e30441a9d9d7754 100644
--- a/arch/arm/src/stm32/chip/stm32_memorymap.h
+++ b/arch/arm/src/stm32/chip/stm32_memorymap.h
@@ -51,6 +51,8 @@
# include "chip/stm32f20xxx_memorymap.h"
#elif defined(CONFIG_STM32_STM32F30XX)
# include "chip/stm32f30xxx_memorymap.h"
+#elif defined(CONFIG_STM32_STM32F33XX)
+# include "chip/stm32f33xxx_memorymap.h"
#elif defined(CONFIG_STM32_STM32F37XX)
# include "chip/stm32f37xxx_memorymap.h"
#elif defined(CONFIG_STM32_STM32F40XX)
diff --git a/arch/arm/src/stm32/chip/stm32_pwr.h b/arch/arm/src/stm32/chip/stm32_pwr.h
index f2c2fdde0bf29a60df7d0aca4a00e3527f7c43f5..20209ee12c5620c82e4371c3eb7b5226d3eecc7c 100644
--- a/arch/arm/src/stm32/chip/stm32_pwr.h
+++ b/arch/arm/src/stm32/chip/stm32_pwr.h
@@ -150,7 +150,8 @@
#if defined(CONFIG_STM32_STM32F30XX)
# define PWR_CSR_EWUP1 (1 << 8) /* Bit 8: Enable WKUP1 pin */
# define PWR_CSR_EWUP2 (1 << 9) /* Bit 9: Enable WKUP2 pin */
-#elif defined(CONFIG_STM32_STM32L15XX) || defined(CONFIG_STM32_STM32F37XX)
+#elif defined(CONFIG_STM32_STM32L15XX) || defined(CONFIG_STM32_STM32F33XX) || \
+ defined(CONFIG_STM32_STM32F37XX)
# define PWR_CSR_EWUP1 (1 << 8) /* Bit 8: Enable WKUP1 pin */
# define PWR_CSR_EWUP2 (1 << 9) /* Bit 9: Enable WKUP2 pin */
# define PWR_CSR_EWUP3 (1 << 10) /* Bit 8: Enable WKUP3 pin */
diff --git a/arch/arm/src/stm32/chip/stm32f10xxx_dma.h b/arch/arm/src/stm32/chip/stm32f10xxx_dma.h
index a24c611a50a2b2099369a0adf2ad33ce728df9b0..673093189ac395eb181f846d6ca5041a8787d313 100644
--- a/arch/arm/src/stm32/chip/stm32f10xxx_dma.h
+++ b/arch/arm/src/stm32/chip/stm32f10xxx_dma.h
@@ -520,6 +520,75 @@
# define DMACHAN_UART4_TX STM32_DMA2_CHAN5
# define DMACHAN_TIM8_CH2 STM32_DMA2_CHAN5
+#elif defined(CONFIG_STM32_STM32F33XX)
+
+# define DMACHAN_ADC1 STM32_DMA1_CHAN1
+# define DMACHAN_TIM2_CH3 STM32_DMA1_CHAN1
+# define DMACHAN_TIM17_CH1_1 STM32_DMA1_CHAN1
+# define DMACHAN_TIM17_UP_1 STM32_DMA1_CHAN1
+
+# define DMACHAN_ADC2_1 STM32_DMA1_CHAN2
+# define DMACHAN_SPI1_RX_1 STM32_DMA1_CHAN2
+# define DMACHAN_USART3_TX STM32_DMA1_CHAN2
+# define DMACHAN_I2C1_TX_3 STM32_DMA1_CHAN4
+# define DMACHAN_TIM1_CH1 STM32_DMA1_CHAN2
+# define DMACHAN_TIM2_UP STM32_DMA1_CHAN2
+# define DMACHAN_TIM3_CH3 STM32_DMA1_CHAN2
+# define DMACHAN_HRTIM1_M STM32_DMA1_CHAN2
+
+# define DMACHAN_SPI1_TX_1 STM32_DMA1_CHAN3
+# define DMACHAN_USART3_RX STM32_DMA1_CHAN3
+# define DMACHAN_I2C1_RX_2 STM32_DMA1_CHAN3
+# define DMACHAN_TIM3_CH4 STM32_DMA1_CHAN3
+# define DMACHAN_TIM3_UP STM32_DMA1_CHAN3
+# define DMACHAN_TIM6_UP STM32_DMA1_CHAN3
+# define DMACHAN_DAC1_CH1 STM32_DMA1_CHAN3
+# define DMACHAN_DAC16_CH1_1 STM32_DMA1_CHAN3
+# define DMACHAN_DAC16_UP_1 STM32_DMA1_CHAN3
+# define DMACHAN_HRTIM1_A STM32_DMA1_CHAN3
+
+# define DMACHAN_ADC2_2 STM32_DMA1_CHAN4
+# define DMACHAN_SPI1_RX_2 STM32_DMA1_CHAN4
+# define DMACHAN_USART1_TX STM32_DMA1_CHAN4
+# define DMACHAN_I2C1_TX_3 STM32_DMA1_CHAN4
+# define DMACHAN_TIM1_CH4 STM32_DMA1_CHAN4
+# define DMACHAN_TIM1_TRIG STM32_DMA1_CHAN4
+# define DMACHAN_TIM1_COM STM32_DMA1_CHAN4
+# define DMACHAN_TIM7_UP STM32_DMA1_CHAN4
+# define DMACHAN_DAC2_CH2 STM32_DMA1_CHAN4
+# define DMACHAN_HRTIM1_B STM32_DMA1_CHAN4
+
+# define DMACHAN_SPI1_TX_2 STM32_DMA1_CHAN5
+# define DMACHAN_USART1_RX STM32_DMA1_CHAN5
+# define DMACHAN_I2C1_RX_3 STM32_DMA1_CHAN5
+# define DMACHAN_TIM1_UP STM32_DMA1_CHAN5
+# define DMACHAN_TIM2_CH1 STM32_DMA1_CHAN5
+# define DMACHAN_DAC2_CH1 STM32_DMA1_CHAN5
+# define DMACHAN_TIM15_CH1 STM32_DMA1_CHAN5
+# define DMACHAN_TIM15_UP STM32_DMA1_CHAN5
+# define DMACHAN_TIM15_TRIG STM32_DMA1_CHAN5
+# define DMACHAN_TIM15_COM STM32_DMA1_CHAN5
+# define DMACHAN_HRTIM1_C STM32_DMA1_CHAN5
+
+# define DMACHAN_SPI1_RX_3 STM32_DMA1_CHAN6
+# define DMACHAN_USART2_RX STM32_DMA1_CHAN6
+# define DMACHAN_I2C1_TX_1 STM32_DMA1_CHAN6
+# define DMACHAN_TIM1_CH3 STM32_DMA1_CHAN6
+# define DMACHAN_TIM3_CH1 STM32_DMA1_CHAN6
+# define DMACHAN_TIM3_TRIG STM32_DMA1_CHAN6
+# define DMACHAN_TIM16_CH1_2 STM32_DMA1_CHAN6
+# define DMACHAN_TIM16_UP_2 STM32_DMA1_CHAN6
+# define DMACHAN_HRTIM1_D STM32_DMA1_CHAN6
+
+# define DMACHAN_SPI1_TX_3 STM32_DMA1_CHAN7
+# define DMACHAN_USART2_TX STM32_DMA1_CHAN7
+# define DMACHAN_I2C1_RX_1 STM32_DMA1_CHAN7
+# define DMACHAN_TIM2_CH2 STM32_DMA1_CHAN7
+# define DMACHAN_TIM2_CH4 STM32_DMA1_CHAN7
+# define DMACHAN_TIM17_CH1_2 STM32_DMA1_CHAN7
+# define DMACHAN_TIM17_UP_2 STM32_DMA1_CHAN7
+# define DMACHAN_HRTIM1_E STM32_DMA1_CHAN7
+
#elif defined(CONFIG_STM32_STM32F37XX)
# define DMACHAN_ADC1 STM32_DMA1_CHAN1
diff --git a/arch/arm/src/stm32/chip/stm32f33xxx_adc.h b/arch/arm/src/stm32/chip/stm32f33xxx_adc.h
new file mode 100644
index 0000000000000000000000000000000000000000..ddfbd97d1f208c104233d47d3e96cd7f7309f577
--- /dev/null
+++ b/arch/arm/src/stm32/chip/stm32f33xxx_adc.h
@@ -0,0 +1,542 @@
+/****************************************************************************************************
+ * arch/arm/src/stm32/chip/stm32f33xxx_adc.h
+ *
+ * Copyright (C) 2017 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ * Modified for STM32F334 by Mateusz Szafoni
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************************************/
+
+#ifndef __ARCH_ARM_SRC_STM32_CHIP_STM32F33XXX_ADC_H
+#define __ARCH_ARM_SRC_STM32_CHIP_STM32F33XXX_ADC_H
+
+/****************************************************************************************************
+ * Included Files
+ ****************************************************************************************************/
+
+#include
+
+#include "chip.h"
+
+/****************************************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************************************/
+
+#define STM32_ADC1_BASE_OFFSET 0x0000
+#define STM32_ADC2_BASE_OFFSET 0x0100
+#define STM32_ADC12_BASE_OFFSET 0x0300
+
+#define STM32_ADC1_BASE (STM32_ADC1_BASE_OFFSET+STM32_ADC12_BASE) /* ADC1 Master ADC */
+#define STM32_ADC2_BASE (STM32_ADC1_BASE_OFFSET+STM32_ADC12_BASE) /* ADC2 Slave ADC */
+#define STM32_ADC12_BASE (STM32_ADC1_BASE_OFFSET+STM32_ADC12_BASE) /* ADC1, ADC2 common */
+
+/* Register Offsets *********************************************************************************/
+
+#define STM32_ADC_ISR_OFFSET 0x0000 /* ADC interrupt and status register */
+#define STM32_ADC_IER_OFFSET 0x0004 /* ADC interrupt enable register */
+#define STM32_ADC_CR_OFFSET 0x0008 /* ADC control register */
+#define STM32_ADC_CFGR_OFFSET 0x000c /* ADC configuration register */
+#define STM32_ADC_SMPR1_OFFSET 0x0014 /* ADC sample time register 1 */
+#define STM32_ADC_SMPR2_OFFSET 0x0018 /* ADC sample time register 2 */
+#define STM32_ADC_TR1_OFFSET 0x0020 /* ADC watchdog threshold register 1 */
+#define STM32_ADC_TR2_OFFSET 0x0024 /* ADC watchdog threshold register 2 */
+#define STM32_ADC_TR3_OFFSET 0x0028 /* ADC watchdog threshold register 3 */
+#define STM32_ADC_SQR1_OFFSET 0x0030 /* ADC regular sequence register 1 */
+#define STM32_ADC_SQR2_OFFSET 0x0034 /* ADC regular sequence register 2 */
+#define STM32_ADC_SQR3_OFFSET 0x0038 /* ADC regular sequence register 3 */
+#define STM32_ADC_SQR4_OFFSET 0x003c /* ADC regular sequence register 4 */
+#define STM32_ADC_DR_OFFSET 0x0040 /* ADC regular data register */
+#define STM32_ADC_JSQR_OFFSET 0x004c /* ADC injected sequence register */
+#define STM32_ADC_OFR1_OFFSET 0x0060 /* ADC offset register 1 */
+#define STM32_ADC_OFR2_OFFSET 0x0064 /* ADC offset register 2 */
+#define STM32_ADC_OFR3_OFFSET 0x0068 /* ADC offset register 3 */
+#define STM32_ADC_OFR4_OFFSET 0x006c /* ADC data offset register 4 */
+#define STM32_ADC_JDR1_OFFSET 0x0080 /* ADC injected data register 1 */
+#define STM32_ADC_JDR2_OFFSET 0x0084 /* ADC injected data register 2 */
+#define STM32_ADC_JDR3_OFFSET 0x0088 /* ADC injected data register 3 */
+#define STM32_ADC_JDR4_OFFSET 0x008c /* ADC injected data register 4 */
+#define STM32_ADC_AWD2CR_OFFSET 0x00a0 /* ADC analog watchdog 2 configuration register */
+#define STM32_ADC_AWD3CR_OFFSET 0x00a4 /* ADC analog watchdog 3 configuration register */
+#define STM32_ADC_DIFSEL_OFFSET 0x00b0 /* ADC differential mode selection register 2 */
+#define STM32_ADC_CALFACT_OFFSET 0x00b4 /* ADC calibration factors */
+
+/* Master and Slave ADC Common Registers */
+
+#define STM32_ADC_CSR_OFFSET 0x0000 /* Common status register */
+#define STM32_ADC_CCR_OFFSET 0x0008 /* Common control register */
+#define STM32_ADC_CDR_OFFSET 0x000c /* Common regular data register for dual mode */
+
+/* Register Addresses *******************************************************************************/
+
+#define STM32_ADC1_ISR (STM32_ADC1_BASE+STM32_ADC_ISR_OFFSET)
+#define STM32_ADC1_IER (STM32_ADC1_BASE+STM32_ADC_IER_OFFSET)
+#define STM32_ADC1_CR (STM32_ADC1_BASE+STM32_ADC_CR_OFFSET)
+#define STM32_ADC1_CFGR (STM32_ADC1_BASE+STM32_ADC_CFGR_OFFSET)
+#define STM32_ADC1_SMPR1 (STM32_ADC1_BASE+STM32_ADC_SMPR1_OFFSET)
+#define STM32_ADC1_SMPR2 (STM32_ADC1_BASE+STM32_ADC_SMPR2_OFFSET)
+#define STM32_ADC1_TR1 (STM32_ADC1_BASE+STM32_ADC_TR1_OFFSET)
+#define STM32_ADC1_TR2 (STM32_ADC1_BASE+STM32_ADC_TR2_OFFSET)
+#define STM32_ADC1_TR3 (STM32_ADC1_BASE+STM32_ADC_TR3_OFFSET)
+#define STM32_ADC1_SQR1 (STM32_ADC1_BASE+STM32_ADC_SQR1_OFFSET)
+#define STM32_ADC1_SQR2 (STM32_ADC1_BASE+STM32_ADC_SQR2_OFFSET)
+#define STM32_ADC1_SQR3 (STM32_ADC1_BASE+STM32_ADC_SQR3_OFFSET)
+#define STM32_ADC1_SQR4 (STM32_ADC1_BASE+STM32_ADC_SQR4_OFFSET)
+#define STM32_ADC1_DR (STM32_ADC1_BASE+STM32_ADC_DR_OFFSET)
+#define STM32_ADC1_JSQR (STM32_ADC1_BASE+STM32_ADC_JSQR_OFFSET)
+#define STM32_ADC1_OFR1 (STM32_ADC1_BASE+STM32_ADC_OFR1_OFFSET)
+#define STM32_ADC1_OFR2 (STM32_ADC1_BASE+STM32_ADC_OFR2_OFFSET)
+#define STM32_ADC1_OFR3 (STM32_ADC1_BASE+STM32_ADC_OFR3_OFFSET)
+#define STM32_ADC1_OFR4 (STM32_ADC1_BASE+STM32_ADC_OFR4_OFFSET)
+#define STM32_ADC1_JDR1 (STM32_ADC1_BASE+STM32_ADC_JDR1_OFFSET)
+#define STM32_ADC1_JDR2 (STM32_ADC1_BASE+STM32_ADC_JDR2_OFFSET)
+#define STM32_ADC1_JDR3 (STM32_ADC1_BASE+STM32_ADC_JDR3_OFFSET)
+#define STM32_ADC1_JDR4 (STM32_ADC1_BASE+STM32_ADC_JDR4_OFFSET)
+#define STM32_ADC1_AWD2CR (STM32_ADC1_BASE+STM32_ADC_AWD2CR_OFFSET)
+#define STM32_ADC1_AWD3CR (STM32_ADC1_BASE+STM32_ADC_AWD3CR_OFFSET)
+#define STM32_ADC1_DIFSEL (STM32_ADC1_BASE+STM32_ADC_DIFSEL_OFFSET)
+#define STM32_ADC1_CALFACT (STM32_ADC1_BASE+STM32_ADC_CALFACT_OFFSET)
+
+#define STM32_ADC2_ISR (STM32_ADC2_BASE+STM32_ADC_ISR_OFFSET)
+#define STM32_ADC2_IER (STM32_ADC2_BASE+STM32_ADC_IER_OFFSET)
+#define STM32_ADC2_CR (STM32_ADC2_BASE+STM32_ADC_CR_OFFSET)
+#define STM32_ADC2_CFGR (STM32_ADC2_BASE+STM32_ADC_CFGR_OFFSET)
+#define STM32_ADC2_SMPR1 (STM32_ADC2_BASE+STM32_ADC_SMPR1_OFFSET)
+#define STM32_ADC2_SMPR2 (STM32_ADC2_BASE+STM32_ADC_SMPR2_OFFSET)
+#define STM32_ADC2_TR1 (STM32_ADC2_BASE+STM32_ADC_TR1_OFFSET)
+#define STM32_ADC2_TR2 (STM32_ADC2_BASE+STM32_ADC_TR2_OFFSET)
+#define STM32_ADC2_TR3 (STM32_ADC2_BASE+STM32_ADC_TR3_OFFSET)
+#define STM32_ADC2_SQR1 (STM32_ADC2_BASE+STM32_ADC_SQR1_OFFSET)
+#define STM32_ADC2_SQR2 (STM32_ADC2_BASE+STM32_ADC_SQR2_OFFSET)
+#define STM32_ADC2_SQR3 (STM32_ADC2_BASE+STM32_ADC_SQR3_OFFSET)
+#define STM32_ADC2_SQR4 (STM32_ADC2_BASE+STM32_ADC_SQR4_OFFSET)
+#define STM32_ADC2_DR (STM32_ADC2_BASE+STM32_ADC_DR_OFFSET)
+#define STM32_ADC2_JSQR (STM32_ADC2_BASE+STM32_ADC_JSQR_OFFSET)
+#define STM32_ADC2_OFR1 (STM32_ADC2_BASE+STM32_ADC_OFR1_OFFSET)
+#define STM32_ADC2_OFR2 (STM32_ADC2_BASE+STM32_ADC_OFR2_OFFSET)
+#define STM32_ADC2_OFR3 (STM32_ADC2_BASE+STM32_ADC_OFR3_OFFSET)
+#define STM32_ADC2_OFR4 (STM32_ADC2_BASE+STM32_ADC_OFR4_OFFSET)
+#define STM32_ADC2_JDR1 (STM32_ADC2_BASE+STM32_ADC_JDR1_OFFSET)
+#define STM32_ADC2_JDR2 (STM32_ADC2_BASE+STM32_ADC_JDR2_OFFSET)
+#define STM32_ADC2_JDR3 (STM32_ADC2_BASE+STM32_ADC_JDR3_OFFSET)
+#define STM32_ADC2_JDR4 (STM32_ADC2_BASE+STM32_ADC_JDR4_OFFSET)
+#define STM32_ADC2_AWD2CR (STM32_ADC2_BASE+STM32_ADC_AWD2CR_OFFSET)
+#define STM32_ADC2_AWD3CR (STM32_ADC2_BASE+STM32_ADC_AWD3CR_OFFSET)
+#define STM32_ADC2_DIFSEL (STM32_ADC2_BASE+STM32_ADC_DIFSEL_OFFSET)
+#define STM32_ADC2_CALFACT (STM32_ADC2_BASE+STM32_ADC_CALFACT_OFFSET)
+
+#define STM32_ADC12_CSR (STM32_ADC12_BASE+STM32_ADC_CSR_OFFSET)
+#define STM32_ADC12_CCR (STM32_ADC12_BASE+STM32_ADC_CCR_OFFSET)
+#define STM32_ADC12_CDR (STM32_ADC12_BASE+STM32_ADC_CDR_OFFSET)
+
+/* Register Bitfield Definitions ********************************************************************/
+/* ADC interrupt and status register (ISR) and ADC interrupt enable register (IER) */
+
+#define ADC_INT_ARDY (1 << 0) /* Bit 0: ADC ready */
+#define ADC_INT_EOSMP (1 << 1) /* Bit 1: End of sampling flag */
+#define ADC_INT_EOC (1 << 2) /* Bit 2: End of conversion */
+#define ADC_INT_EOS (1 << 3) /* Bit 3: End of regular sequence flag */
+#define ADC_INT_OVR (1 << 4) /* Bit 4: Overrun */
+#define ADC_INT_JEOC (1 << 5) /* Bit 5: Injected channel end of conversion */
+#define ADC_INT_JEOS (1 << 6) /* Bit 6: Injected channel end of sequence flag */
+#define ADC_INT_AWD1 (1 << 7) /* Bit 7: Analog watchdog 1 flag */
+#define ADC_INT_AWD2 (1 << 8) /* Bit 8: Analog watchdog 2 flag */
+#define ADC_INT_AWD3 (1 << 9) /* Bit 9: Analog watchdog 3 flag */
+#define ADC_INT_JQOVF (1 << 10) /* Bit 10: Injected context queue overflow */
+
+/* ADC control register */
+
+#define ADC_CR_ADEN (1 << 0) /* Bit 0: ADC enable control */
+#define ADC_CR_ADDIS (1 << 1) /* Bit 1: ADC disable command */
+#define ADC_CR_ADSTART (1 << 2) /* Bit 2: ADC start of regular conversion */
+#define ADC_CR_JADSTART (1 << 3) /* Bit 3: ADC start of injected conversion */
+#define ADC_CR_ADSTP (1 << 4) /* Bit 4: ADC stop of regular conversion command */
+#define ADC_CR_JADSTP (1 << 5) /* Bit 5: ADC stop of injected conversion command */
+#define ADC_CR_ADVREGEN_SHIFT (28) /* Bits 28-29: ADC voltage regulator enable */
+#define ADC_CR_ADVREGEN_MASK (3 << ADC_CR_ADVREGEN_SHIFT)
+# define ADC_CR_ADVREGEN_INTER (0 << ADC_CR_ADVREGEN_SHIFT) /* Intermediate state */
+# define ADC_CR_ADVREGEN_ENABLED (1 << ADC_CR_ADVREGEN_SHIFT) /* ADC Voltage regulator enabled */
+# define ADC_CR_ADVREGEN_DISABLED (2 << ADC_CR_ADVREGEN_SHIFT) /* ADC Voltage regulator disabled */
+#define ADC_CR_ADCALDIF (1 << 30) /* Bit 30: Differential mode for calibration */
+#define ADC_CR_ADCAL (1 << 31) /* Bit 31: ADC calibration */
+
+/* ADC configuration register */
+
+#define ADC_CFGR_DMAEN (1 << 0) /* Bit 0: Direct memory access enable */
+#define ADC_CFGR_DMACFG (1 << 1) /* Bit 1: Direct memory access configuration */
+#define ADC_CFGR_RES_SHIFT (3) /* Bits 3-4: Data resolution */
+#define ADC_CFGR_RES_MASK (3 << ADC_CFGR_RES_SHIFT)
+# define ADC_CFGR_RES_12BIT (0 << ADC_CFGR_RES_SHIFT) /* 15 ADCCLK clyes */
+# define ADC_CFGR_RES_10BIT (1 << ADC_CFGR_RES_SHIFT) /* 13 ADCCLK clyes */
+# define ADC_CFGR_RES_8BIT (2 << ADC_CFGR_RES_SHIFT) /* 11 ADCCLK clyes */
+# define ADC_CFGR_RES_6BIT (3 << ADC_CFGR_RES_SHIFT) /* 9 ADCCLK clyes */
+#define ADC_CFGR_ALIGN (1 << 5) /* Bit 5: Data Alignment */
+#define ADC_CFGR_EXTSEL_SHIFT (6) /* Bits 6-9: External Event Select for regular group */
+#define ADC_CFGR_EXTSEL_MASK (15 << ADC_CFGR_EXTSEL_SHIFT)
+# define ADC12_CFGR_EXTSEL_T1CC1 (0 << ADC_CFGR_EXTSEL_SHIFT)
+# define ADC12_CFGR_EXTSEL_T1CC2 (1 << ADC_CFGR_EXTSEL_SHIFT)
+# define ADC12_CFGR_EXTSEL_T1CC3 (2 << ADC_CFGR_EXTSEL_SHIFT)
+# define ADC12_CFGR_EXTSEL_T2CC2 (3 << ADC_CFGR_EXTSEL_SHIFT)
+# define ADC12_CFGR_EXTSEL_T3TRGO (4 << ADC_CFGR_EXTSEL_SHIFT)
+ /* 0101: Reserved */
+# define ADC12_CFGR_EXTSEL_EXTI11 (6 << ADC_CFGR_EXTSEL_SHIFT) /* 0110: EXTI line 11 */
+# define ADC12_CFGR_EXTSEL_HRT1TRG1 (7 << ADC_CFGR_EXTSEL_SHIFT) /* 0111: HRTIM1 ADCTRG1 event */
+# define ADC12_CFGR_EXTSEL_HRT1TRG3 (8 << ADC_CFGR_EXTSEL_SHIFT) /* 1000: HRTIM1 ADCTRG3 event */
+# define ADC12_CFGR_EXTSEL_T1TRGO (9 << ADC_CFGR_EXTSEL_SHIFT)
+# define ADC12_CFGR_EXTSEL_T1TRGO2 (10 << ADC_CFGR_EXTSEL_SHIFT)
+# define ADC12_CFGR_EXTSEL_T2TRGO (11 << ADC_CFGR_EXTSEL_SHIFT)
+ /* 1100: Reserved */
+# define ADC12_CFGR_EXTSEL_T6TRGO (13 << ADC_CFGR_EXTSEL_SHIFT)
+# define ADC12_CFGR_EXTSEL_T15TRGO (14 << ADC_CFGR_EXTSEL_SHIFT)
+# define ADC12_CFGR_EXTSEL_T3CC4 (15 << ADC_CFGR_EXTSEL_SHIFT)
+#define ADC_CFGR_EXTEN_SHIFT (10) /* Bits 10-11: External trigger/polarity selection regular channels */
+#define ADC_CFGR_EXTEN_MASK (3 << ADC_CFGR_EXTEN_SHIFT)
+# define ADC_CFGR_EXTEN_NONE (0 << ADC_CFGR_EXTEN_SHIFT) /* Trigger detection disabled */
+# define ADC_CFGR_EXTEN_RISING (1 << ADC_CFGR_EXTEN_SHIFT) /* Trigger detection on the rising edge */
+# define ADC_CFGR_EXTEN_FALLING (2 << ADC_CFGR_EXTEN_SHIFT) /* Trigger detection on the falling edge */
+# define ADC_CFGR_EXTEN_BOTH (3 << ADC_CFGR_EXTEN_SHIFT) /* Trigger detection on both edges */
+#define ADC_CFGR_OVRMOD (1 << 12) /* Bit 12: Overrun Mode */
+#define ADC_CFGR_CONT (1 << 13) /* Bit 13: Continuous mode for regular conversions */
+#define ADC_CFGR_AUTDLY (1 << 14) /* Bit 14: Delayed conversion mode */
+#define ADC_CFGR_DISCEN (1 << 16) /* Bit 16: Discontinuous mode on regular channels */
+#define ADC_CFGR_DISCNUM_SHIFT (17) /* Bits 17-19: Discontinuous mode channel count */
+#define ADC_CFGR_DISCNUM_MASK (7 << ADC_CFGR_DISCNUM_SHIFT)
+# define ADC_CFGR_DISCNUM(n) (((n) - 1) << ADC_CFGR_DISCNUM_SHIFT) /* n = 1..8 channels */
+#define ADC_CFGR_JDISCEN (1 << 20) /* Bit 20: Discontinuous mode on injected channels */
+#define ADC_CFGR_JQM (1 << 21) /* Bit 21: JSQR queue mode */
+#define ADC_CFGR_AWD1SGL (1 << 22) /* Bit 22: Enable watchdog on single/all channels */
+#define ADC_CFGR_AWD1EN (1 << 23) /* Bit 23: Analog watchdog enable 1 regular channels */
+#define ADC_CFGR_JAWD1EN (1 << 22) /* Bit 22: Analog watchdog enable 1 injected channels */
+#define ADC_CFGR_JAUTO (1 << 25) /* Bit 25: Automatic Injected Group conversion */
+#define ADC_CFGR_AWD1CH_SHIFT (26) /* Bits 26-30: Analog watchdog 1 channel select bits */
+#define ADC_CFGR_AWD1CH_MASK (31 << ADC_CFGR_AWD1CH_SHIFT)
+# define ADC_CFGR_AWD1CH_DISABLED (0 << ADC_CFGR_AWD1CH_SHIFT)
+
+/* ADC sample time register 1 */
+
+#define ADC_SMPR_1p5 0 /* 000: 1.5 cycles */
+#define ADC_SMPR_2p5 1 /* 001: 2.5 cycles */
+#define ADC_SMPR_4p5 2 /* 010: 4.5 cycles */
+#define ADC_SMPR_7p5 3 /* 011: 7.5 cycles */
+#define ADC_SMPR_19p5 4 /* 100: 19.5 cycles */
+#define ADC_SMPR_61p5 5 /* 101: 61.5 cycles */
+#define ADC_SMPR_181p5 6 /* 110: 181.5 cycles */
+#define ADC_SMPR_601p5 7 /* 111: 601.5 cycles */
+
+#define ADC_SMPR1_SMP1_SHIFT (3) /* Bits 5-3: Channel 1 Sample time selection */
+#define ADC_SMPR1_SMP1_MASK (7 << ADC_SMPR1_SMP1_SHIFT)
+#define ADC_SMPR1_SMP2_SHIFT (6) /* Bits 8-6: Channel 2 Sample time selection */
+#define ADC_SMPR1_SMP2_MASK (7 << ADC_SMPR1_SMP2_SHIFT)
+#define ADC_SMPR1_SMP3_SHIFT (9) /* Bits 11-9: Channel 3 Sample time selection */
+#define ADC_SMPR1_SMP3_MASK (7 << ADC_SMPR1_SMP3_SHIFT)
+#define ADC_SMPR1_SMP4_SHIFT (12) /* Bits 14-12: Channel 4 Sample time selection */
+#define ADC_SMPR1_SMP4_MASK (7 << ADC_SMPR1_SMP4_SHIFT)
+#define ADC_SMPR1_SMP5_SHIFT (15) /* Bits 17-15: Channel 5 Sample time selection */
+#define ADC_SMPR1_SMP5_MASK (7 << ADC_SMPR1_SMP5_SHIFT)
+#define ADC_SMPR1_SMP6_SHIFT (18) /* Bits 20-18: Channel 6 Sample time selection */
+#define ADC_SMPR1_SMP6_MASK (7 << ADC_SMPR1_SMP6_SHIFT)
+#define ADC_SMPR1_SMP7_SHIFT (21) /* Bits 23-21: Channel 7 Sample time selection */
+#define ADC_SMPR1_SMP7_MASK (7 << ADC_SMPR1_SMP7_SHIFT)
+#define ADC_SMPR1_SMP8_SHIFT (24) /* Bits 26-24: Channel 8 Sample time selection */
+#define ADC_SMPR1_SMP8_MASK (7 << ADC_SMPR1_SMP8_SHIFT)
+#define ADC_SMPR1_SMP9_SHIFT (27) /* Bits 29-27: Channel 9 Sample time selection */
+#define ADC_SMPR1_SMP9_MASK (7 << ADC_SMPR1_SMP9_SHIFT)
+
+/* ADC sample time register 2 */
+
+#define ADC_SMPR2_SMP10_SHIFT (0) /* Bits 0-2: Channel 10 Sample time selection */
+#define ADC_SMPR2_SMP10_MASK (7 << ADC_SMPR2_SMP10_SHIFT)
+#define ADC_SMPR2_SMP11_SHIFT (3) /* Bits 3-5: Channel 11 Sample time selection */
+#define ADC_SMPR2_SMP11_MASK (7 << ADC_SMPR2_SMP11_SHIFT)
+#define ADC_SMPR2_SMP12_SHIFT (6) /* Bits 6-8: Channel 12 Sample time selection */
+#define ADC_SMPR2_SMP12_MASK (7 << ADC_SMPR2_SMP12_SHIFT)
+#define ADC_SMPR2_SMP13_SHIFT (9) /* Bits 9-11: Channel 13 Sample time selection */
+#define ADC_SMPR2_SMP13_MASK (7 << ADC_SMPR2_SMP13_SHIFT)
+#define ADC_SMPR2_SMP14_SHIFT (12) /* Bits 12-14: Channel 14 Sample time selection */
+#define ADC_SMPR2_SMP14_MASK (7 << ADC_SMPR2_SMP14_SHIFT)
+#define ADC_SMPR2_SMP15_SHIFT (15) /* Bits 15-17: Channel 15 Sample time selection */
+#define ADC_SMPR2_SMP15_MASK (7 << ADC_SMPR2_SMP15_SHIFT)
+#define ADC_SMPR2_SMP16_SHIFT (18) /* Bits 18-20: Channel 16 Sample time selection */
+#define ADC_SMPR2_SMP16_MASK (7 << ADC_SMPR2_SMP16_SHIFT)
+#define ADC_SMPR2_SMP17_SHIFT (21) /* Bits 21-23: Channel 17 Sample time selection */
+#define ADC_SMPR2_SMP17_MASK (7 << ADC_SMPR2_SMP17_SHIFT)
+#define ADC_SMPR2_SMP18_SHIFT (21) /* Bits 24-26: Channel 18 Sample time selection */
+#define ADC_SMPR2_SMP18_MASK (7 << ADC_SMPR2_SMP17_SHIFT)
+
+/* ADC watchdog threshold register 1 */
+
+#define ADC_TR1_LT_SHIFT (0) /* Bits 0-11: Analog watchdog 1 lower threshold */
+#define ADC_TR1_LT_MASK (0x0fff << ADC_TR1_LT_SHIFT)
+#define ADC_TR1_HT_SHIFT (16) /* Bits 16-27: Analog watchdog 1 higher threshold */
+#define ADC_TR1_HT_MASK (0x0fff << ADC_TR1_HT_SHIFT)
+
+/* ADC watchdog threshold register 2 */
+
+#define ADC_TR2_LT_SHIFT (0) /* Bits 0-7: Analog watchdog 2 lower threshold */
+#define ADC_TR2_LT_MASK (0xff << ADC_TR2_LT_SHIFT)
+#define ADC_TR2_HT_SHIFT (16) /* Bits 16-23: Analog watchdog 2 higher threshold */
+#define ADC_TR2_HT_MASK (0xff << ADC_TR2_HT_SHIFT)
+
+/* ADC watchdog threshold register 3 */
+
+#define ADC_TR3_LT_SHIFT (0) /* Bits 0-7: Analog watchdog 3 lower threshold */
+#define ADC_TR3_LT_MASK (0xff << ADC_TR3_LT_SHIFT)
+#define ADC_TR3_HT_SHIFT (16) /* Bits 16-23: Analog watchdog 3 higher threshold */
+#define ADC_TR3_HT_MASK (0xff << ADC_TR3_HT_SHIFT)
+
+/* Offset between SQ bits */
+
+#define ADC_SQ_OFFSET (6)
+
+/* ADC regular sequence register 1 */
+
+#define ADC_SQR1_L_SHIFT (0) /* Bits 0-3: Regular channel sequence length */
+#define ADC_SQR1_L_MASK (0x0f << ADC_SQR1_L_SHIFT)
+#define ADC_SQR1_SQ1_SHIFT (6) /* Bits 6-10: 13th conversion in regular sequence */
+#define ADC_SQR1_SQ1_MASK (0x1f << ADC_SQR1_SQ1_SHIFT)
+#define ADC_SQR1_SQ2_SHIFT (12) /* Bits 12-16: 2nd conversion in regular sequence */
+#define ADC_SQR1_SQ2_MASK (0x1f << ADC_SQR1_SQ2_SHIFT)
+#define ADC_SQR1_SQ3_SHIFT (18) /* Bits 18-22: 3rd conversion in regular sequence */
+#define ADC_SQR1_SQ3_MASK (0x1f << ADC_SQR1_SQ3_SHIFT)
+#define ADC_SQR1_SQ4_SHIFT (24) /* Bits 24-28: 4th conversion in regular sequence */
+#define ADC_SQR1_SQ4_MASK (0x1f << ADC_SQR1_SQ4_SHIFT)
+#define ADC_SQR1_RESERVED (0xe0820830)
+#define ADC_SQR1_FIRST (1)
+#define ADC_SQR1_LAST (4)
+#define ADC_SQR1_SQ_OFFSET (1*ADC_SQ_OFFSET)
+
+/* ADC regular sequence register 2 */
+
+#define ADC_SQR2_SQ5_SHIFT (0) /* Bits 4-0: 5th conversion in regular sequence */
+#define ADC_SQR2_SQ5_MASK (0x1f << ADC_SQR2_SQ5_SHIFT)
+#define ADC_SQR2_SQ6_SHIFT (6) /* Bits 6-10: 6th conversion in regular sequence */
+#define ADC_SQR2_SQ6_MASK (0x1f << ADC_SQR2_SQ6_SHIFT)
+#define ADC_SQR2_SQ7_SHIFT (12) /* Bits 12-16: 7th conversion in regular sequence */
+#define ADC_SQR2_SQ7_MASK (0x1f << ADC_SQR2_SQ7_SHIFT)
+#define ADC_SQR2_SQ8_SHIFT (18) /* Bits 18-22: 8th conversion in regular sequence */
+#define ADC_SQR2_SQ8_MASK (0x1f << ADC_SQR2_SQ8_SHIFT)
+#define ADC_SQR2_SQ9_SHIFT (24) /* Bits 24-28: 9th conversion in regular sequence */
+#define ADC_SQR2_SQ9_MASK (0x1f << ADC_SQR2_SQ9_SHIFT)
+#define ADC_SQR2_RESERVED (0xe0820820)
+#define ADC_SQR2_FIRST (5)
+#define ADC_SQR2_LAST (9)
+#define ADC_SQR2_SQ_OFFSET (0)
+
+/* ADC regular sequence register 3 */
+
+#define ADC_SQR3_SQ10_SHIFT (0) /* Bits 4-0: 10th conversion in regular sequence */
+#define ADC_SQR3_SQ10_MASK (0x1f << ADC_SQR3_SQ10_SHIFT)
+#define ADC_SQR3_SQ11_SHIFT (6) /* Bits 6-10: 11th conversion in regular sequence */
+#define ADC_SQR3_SQ11_MASK (0x1f << ADC_SQR3_SQ11_SHIFT)
+#define ADC_SQR3_SQ12_SHIFT (12) /* Bits 12-16: 12th conversion in regular sequence */
+#define ADC_SQR3_SQ12_MASK (0x1f << ADC_SQR3_SQ12_SHIFT)
+#define ADC_SQR3_SQ13_SHIFT (18) /* Bits 18-22: 13th conversion in regular sequence */
+#define ADC_SQR3_SQ13_MASK (0x1f << ADC_SQR3_SQ13_SHIFT)
+#define ADC_SQR3_SQ14_SHIFT (24) /* Bits 24-28: 14th conversion in regular sequence */
+#define ADC_SQR3_SQ14_MASK (0x1f << ADC_SQR3_SQ14_SHIFT)
+#define ADC_SQR3_RESERVED (0xe0820820)
+#define ADC_SQR3_FIRST (10)
+#define ADC_SQR3_LAST (14)
+#define ADC_SQR3_SQ_OFFSET (0)
+
+/* ADC regular sequence register 4 */
+
+#define ADC_SQR4_SQ15_SHIFT (0) /* Bits 4-0: 15th conversion in regular sequence */
+#define ADC_SQR4_SQ15_MASK (0x1f << ADC_SQR4_SQ15_SHIFT)
+#define ADC_SQR4_SQ16_SHIFT (6) /* Bits 6-10: 16th conversion in regular sequence */
+#define ADC_SQR4_SQ16_MASK (0x1f << ADC_SQR4_SQ16_SHIFT)
+#define ADC_SQR4_RESERVED (0xfffff820)
+#define ADC_SQR4_FIRST (15)
+#define ADC_SQR4_LAST (16)
+#define ADC_SQR4_SQ_OFFSET (0)
+
+/* ADC regular data register */
+
+#define ADC_DR_RDATA_SHIFT (0)
+#define ADC_DR_RDATA_MASK (0xffff << ADC_DR_RDATA_SHIFT)
+
+/* ADC injected sequence register */
+
+#define ADC_JSQR_JL_SHIFT (0) /* Bits 0-1: Injected Sequence length */
+#define ADC_JSQR_JL_MASK (3 << ADC_JSQR_JL_SHIFT)
+# define ADC_JSQR_JL(n) (((n)-1) << ADC_JSQR_JL_SHIFT) /* n=1..4 */
+#define ADC_JSQR_JEXTSEL_SHIFT (2) /* Bits 2-5: External Trigger Selection for injected group */
+#define ADC_JSQR_JEXTSEL_MASK (15 << ADC_JSQR_JEXTSEL_SHIFT)
+# define ADC12_JSQR_JEXTSEL_T1TRGO (0 << ADC_JSQR_JEXTSEL_SHIFT)
+# define ADC12_JSQR_JEXTSEL_T1CC4 (1 << ADC_JSQR_JEXTSEL_SHIFT)
+# define ADC12_JSQR_JEXTSEL_T2TRGO (2 << ADC_JSQR_JEXTSEL_SHIFT)
+# define ADC12_JSQR_JEXTSEL_T2CC1 (3 << ADC_JSQR_JEXTSEL_SHIFT)
+# define ADC12_JSQR_JEXTSEL_T3CC4 (4 << ADC_JSQR_JEXTSEL_SHIFT)
+ /* 0101: Reserved */
+# define ADC12_JSQR_JEXTSEL_EXTI15 (6 << ADC_JSQR_JEXTSEL_SHIFT) /* 0110: EXTI line 15 */
+ /* 0111: Reserved */
+# define ADC12_JSQR_JEXTSEL_T1TRGO2 (8 << ADC_JSQR_JEXTSEL_SHIFT)
+# define ADC12_JSQR_JEXTSEL_HRT1TRG2 (9 << ADC_JSQR_JEXTSEL_SHIFT) /* 1001: HRTIM1 ADCTRG2 event */
+# define ADC12_JSQR_JEXTSEL_HRT1TRG4 (10 << ADC_JSQR_JEXTSEL_SHIFT) /* 1010: HRTIM1 ADCTRG4 event */
+# define ADC12_JSQR_JEXTSEL_T3CC3 (11 << ADC_JSQR_JEXTSEL_SHIFT)
+# define ADC12_JSQR_JEXTSEL_T3TRGO (12 << ADC_JSQR_JEXTSEL_SHIFT)
+# define ADC12_JSQR_JEXTSEL_T3CC1 (13 << ADC_JSQR_JEXTSEL_SHIFT)
+# define ADC12_JSQR_JEXTSEL_T6TRGO (14 << ADC_JSQR_JEXTSEL_SHIFT)
+# define ADC12_JSQR_JEXTSEL_T15TRGO (15 << ADC_JSQR_JEXTSEL_SHIFT)
+# define ADC_JSQR_JEXTEN_SHIFT (6) /* Bits 6-7: External trigger selection for injected greoup */
+# define ADC_JSQR_JEXTEN_MASK (3 << ADC_JSQR_JEXTEN_SHIFT)
+# define ADC_JSQR_JEXTEN_NONE (0 << ADC_JSQR_JEXTEN_SHIFT) /* 00: Trigger detection disabled */
+# define ADC_JSQR_JEXTEN_RISING (1 << ADC_JSQR_JEXTEN_SHIFT) /* 01: Trigger detection on the rising edge */
+# define ADC_JSQR_JEXTEN_FALLING (2 << ADC_JSQR_JEXTEN_SHIFT) /* 10: Trigger detection on the falling edge */
+# define ADC_JSQR_JEXTEN_BOTH (3 << ADC_JSQR_JEXTEN_SHIFT) /* 11: Trigger detection on both the rising and falling edges */
+#define ADC_JSQR_JSQ1_SHIFT (8) /* Bits 8-12: 1st conversion in injected sequence */
+#define ADC_JSQR_JSQ1_MASK (0x1f << ADC_JSQR_JSQ1_SHIFT)
+# define ADC_JSQR_JSQ1(ch) ((ch) << ADC_JSQR_JSQ1_SHIFT) /* Channel number 1..18 */
+#define ADC_JSQR_JSQ2_SHIFT (14) /* Bits 14-18: 2nd conversion in injected sequence */
+#define ADC_JSQR_JSQ2_MASK (0x1f << ADC_JSQR_JSQ2_MASK)
+# define ADC_JSQR_JSQ2(ch) ((ch) << ADC_JSQR_JSQ2_MASK) /* Channel number 1..18 */
+#define ADC_JSQR_JSQ3_SHIFT (20) /* Bits 20-24: 3rd conversion in injected sequence */
+#define ADC_JSQR_JSQ3_MASK (0x1f << ADC_JSQR_JSQ3_SHIFT)
+# define ADC_JSQR_JSQ3(ch) ((ch) << ADC_JSQR_JSQ3_SHIFT) /* Channel number 1..18 */
+#define ADC_JSQR_JSQ4_SHIFT (26) /* Bits 26-30: 4th conversion in injected sequence */
+#define ADC_JSQR_JSQ4_MASK (0x1f << ADC_JSQR_JSQ4_SHIFT)
+# define ADC_JSQR_JSQ4(ch) ((ch) << ADC_JSQR_JSQ4_SHIFT) /* Channel number 1..18 */
+
+/* ADC offset register 1 and 2 */
+
+#define ADC_OFR_OFFSETY_SHIFT (0) /* Bits 0-11: Data offset y for channel OFFSETY_CH */
+#define ADC_OFR_OFFSETY_MASK (0x0fff << ADC_OFR_OFFSETY_SHIFT)
+# define ADC_OFR_OFFSETY(offset) ((offset) << ADC_OFR_OFFSETY_SHIFT)
+#define ADC_OFR_OFFSETY_CH_SHIFT (26) /* Bits 26-30: Channel selection for data offset y */
+#define ADC_OFR_OFFSETY_CH_MASK (31 << ADC_OFR_OFFSETY_CH_SHIFT)
+# define ADC_OFR_OFFSETY_CH(ch) ((ch) << ADC_OFR_OFFSETY_CH_SHIFT)
+#define ADC_OFR_OFFSETY_EN (1 << 31) /* Bit 31: Offset y enable */
+
+/* ADC injected data register 1 and 2 */
+
+#define ADC_JDR_JDATA_SHIFT (0)
+#define ADC_JDR_JDATA_MASK (0xffff << ADC_JDR_JDATA_SHIFT)
+
+/* ADC analog watchdog 2 configuration register */
+
+#define ADC_AWD2CR_CH_SHIFT (1) /* Bits 1-18: Analog watchdog 2 channel selection */
+#define ADC_AWD2CR_CH_MASK (0x3ffff << ADC_AWD2CR_CH_SHIFT)
+# define ADC_AWD2CR_CH(n) (1 << (n)) /* Channel n=1..18 */
+
+/* ADC analog watchdog 3 configuration register */
+
+#define ADC_AWD3CR_CH_SHIFT (1) /* Bits 1-18: Analog watchdog 2 channel selection */
+#define ADC_AWD3CR_CH_MASK (0x3ffff << ADC_AWD3CR_CH_SHIFT)
+# define ADC_AWD3CR_CH(n) (1 << (n)) /* Channel n=1..18 */
+
+/* ADC differential mode selection register 2 */
+#define ADC_DIFSEL_
+
+#define ADC_DIFSEL_CH_SHIFT (1) /* Bits 1-18: Analog watchdog 2 channel selection */
+#define ADC_DIFSEL_CH_MASK (0x3ffff << ADC_DIFSEL_CH_SHIFT)
+# define ADC_DIFSEL_CH(n) (1 << (n)) /* Channel n=1..18 */
+
+/* ADC calibration factors */
+
+#define ADC_CALFACT_S_SHIFT (0) /* Bits 0-6: Calibration factors in single-ended mode */
+#define ADC_CALFACT_S_MASK (0x7f << ADC_CALFACT_S_SHIFT)
+#define ADC_CALFACT_D_SHIFT (16) /* Bits 16-22: Calibration Factors indifferential mode */
+#define ADC_CALFACT_D_MASK (0x7f << ADC_CALFACT_D_SHIFT)
+
+/* Common status register */
+
+#define ADC_CSR_ADRDY_MST (1 << 0) /* Bit 0: Master ADC ready */
+#define ADC_CSR_EOSMP_MST (1 << 1) /* Bit 1: End of Sampling phase flag (master ADC) */
+#define ADC_CSR_EOC_MST (1 << 2) /* Bit 2: End of regular conversion (master ADC) */
+#define ADC_CSR_EOS_MST (1 << 3) /* Bit 3: End of regular sequence flag (master ADC) */
+#define ADC_CSR_OVR_MST (1 << 4) /* Bit 4: Overrun flag (master ADC) */
+#define ADC_CSR_JEOC_MST (1 << 5) /* Bit 5: End of injected conversion flag (master ADC) */
+#define ADC_CSR_JEOS_MST (1 << 6) /* Bit 6: End of injected sequence flag (master ADC) */
+#define ADC_CSR_AWD1_MST (1 << 7) /* Bit 7: Analog watchdog 1 flag (master ADC) */
+#define ADC_CSR_AWD2_MST (1 << 8) /* Bit 8: Analog watchdog 2 flag (master ADC) */
+#define ADC_CSR_AWD3_MST (1 << 9) /* Bit 9: Analog watchdog 3 flag (master ADC) */
+#define ADC_CSR_JQOVF_MST (1 << 10) /* Bit 10: Injected Context Queue Overflow flag (master ADC) */
+#define ADC_CSR_ADRDY_SLV (1 << 16) /* Bit 16: Slave ADC ready */
+#define ADC_CSR_EOSMP_SLV (1 << 17) /* Bit 17: End of Sampling phase flag (slave ADC) */
+#define ADC_CSR_EOC_SLV (1 << 18) /* Bit 18: End of regular conversion (slave ADC) */
+#define ADC_CSR_EOS_SLV (1 << 19) /* Bit 19: End of regular sequence flag (slave ADC) */
+#define ADC_CSR_OVR_SLV (1 << 20) /* Bit 20: Overrun flag (slave ADC) */
+#define ADC_CSR_JEOC_SLV (1 << 21) /* Bit 21: End of injected conversion flag (slave ADC) */
+#define ADC_CSR_JEOS_SLV (1 << 22) /* Bit 22: End of injected sequence flag (slave ADC) */
+#define ADC_CSR_AWD1_SLV (1 << 23) /* Bit 23: Analog watchdog 1 flag (slave ADC) */
+#define ADC_CSR_AWD2_SLV (1 << 24) /* Bit 24: Analog watchdog 2 flag (slave ADC) */
+#define ADC_CSR_AWD3_SLV (1 << 25) /* Bit 25: Analog watchdog 3 flag (slave ADC) */
+#define ADC_CSR_JQOVF_SLV (1 << 26) /* Bit 26: Injected Context Queue Overflow flag (slave ADC) */
+
+/* Common control register */
+
+#define ADC_CCR_DUAL_SHIFT (0) /* Bits 0-4: Dual ADC mode selection */
+#define ADC_CCR_DUAL_MASK (31 << ADC_CCR_DUAL_SHIFT)
+# define ADC_CCR_DUAL_IND (0 << ADC_CCR_DUAL_SHIFT) /* Independent mode */
+# define ADC_CCR_DUAL_DUAL (1 << ADC_CCR_DUAL_SHIFT) /* Dual mode, master/slave ADCs together */
+# define ADC_CCR_DUAL_SIMINJ (1 << ADC_CCR_DUAL_SHIFT) /* Combined regular sim. + injected sim. */
+# define ADC_CCR_DUAL_SIMALT (2 << ADC_CCR_DUAL_SHIFT) /* Combined regular sim. + alternate trigger */
+# define ADC_CCR_DUAL_INJECTED (5 << ADC_CCR_DUAL_SHIFT) /* Injected simultaneous mode only */
+# define ADC_CCR_DUAL_SIM (6 << ADC_CCR_DUAL_SHIFT) /* Regular simultaneous mode only */
+# define ADC_CCR_DUAL_INTERLEAVE (7 << ADC_CCR_DUAL_SHIFT) /* Interleaved mode only */
+# define ADC_CCR_DUAL_ALT (9 << ADC_CCR_DUAL_SHIFT) /* Alternate trigger mode only */
+#define ADC_CCR_DELAY_SHIFT (8) /* Bits 8-11: Delay between 2 sampling phases */
+#define ADC_CCR_DELAY_MASK (15 << ADC_CCR_DELAY_SHIFT)
+# define ADC_CCR_DELAY(n) (((n)-1) << ADC_CCR_DELAY_SHIFT) /* n * TADCCLK, 1-13 */
+#define ADC_CCR_DMACFG (1 << 13) /* Bit 13: DMA configuration (for dual ADC mode) */
+#define ADC_CCR_MDMA_SHIFT (14) /* Bits 14-15: Direct memory access mode for dual ADC mode */
+#define ADC_CCR_MDMA_MASK (3 << ADC_CCR_MDMA_SHIFT)
+# define ADC_CCR_MDMA_DISABLED (0 << ADC_CCR_MDMA_SHIFT) /* MDMA mode disabled */
+# define ADC_CCR_MDMA_10_12 (2 << ADC_CCR_MDMA_SHIFT) /* MDMA mode enabled (12 / 10-bit) */
+# define ADC_CCR_MDMA_6_8 (3 << ADC_CCR_MDMA_SHIFT) /* MDMA mode enabled (8 / 6-bit) */
+#define ADC_CCR_CKMODE_SHIFT (16) /* Bits 16-17: ADC clock mode */
+#define ADC_CCR_CKMODE_MASK (15 << ADC_CCR_CKMODE_SHIFT)
+# define ADC_CCR_CKMODE_ASYNCH (0 << ADC_CCR_CKMODE_SHIFT) /* Asynchronous clock mode */
+# define ADC_CCR_CKMODE_SYNCH_DIV1 (1 << ADC_CCR_CKMODE_SHIFT) /* Synchronous clock mode divided by 1 */
+# define ADC_CCR_CKMODE_SYNCH_DIV2 (2 << ADC_CCR_CKMODE_SHIFT) /* Synchronous clock mode divided by 2 */
+# define ADC_CCR_CKMODE_SYNCH_DIV4 (3 << ADC_CCR_CKMODE_SHIFT) /* Synchronous clock mode divided by 4 */
+#define ADC_CCR_VREFEN (1 << 22) /* Bit 22: VREFINT enable */
+#define ADC_CCR_TSEN (1 << 23) /* Bit 23: Temperature sensor enable */
+#define ADC_CCR_VBATEN (1 << 24) /* Bit 22: VBAT enable */
+
+/* Common regular data register for dual mode */
+
+#define ADC_CDR_RDATA_MST_SHIFT (0) /* Bits 0-15: Regular data of the master ADC */
+#define ADC_CDR_RDATA_MST_MASK (0xffff << ADC_CDR_RDATA_MST_SHIFT)
+#define ADC_CDR_RDATA_SLV_SHIFT (16) /* Bits 16-31: Regular data of the slave ADC */
+#define ADC_CDR_RDATA_SLV_MASK (0xffff << ADC_CDR_RDATA_SLV_SHIFT)
+
+/****************************************************************************************************
+ * Public Types
+ ****************************************************************************************************/
+
+/****************************************************************************************************
+ * Public Data
+ ****************************************************************************************************/
+
+/****************************************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************************************/
+
+#endif /* __ARCH_ARM_SRC_STM32_CHIP_STM32F33XXX_ADC_H */
diff --git a/arch/arm/src/stm32/chip/stm32f33xxx_comp.h b/arch/arm/src/stm32/chip/stm32f33xxx_comp.h
new file mode 100644
index 0000000000000000000000000000000000000000..a0803ea04bf7984ecffc3e71f7aec2a3c088a76b
--- /dev/null
+++ b/arch/arm/src/stm32/chip/stm32f33xxx_comp.h
@@ -0,0 +1,124 @@
+/****************************************************************************************************
+ * arch/arm/src/stm32/chip/stm32f33xxx_comp.h
+ *
+ * Copyright (C) 2017 Gregory Nutt. All rights reserved.
+ * Author: Mateusz Szafoni
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************************************/
+
+#ifndef __ARCH_ARM_SRC_STM32_CHIP_STM32_COMP_H
+#define __ARCH_ARM_SRC_STM32_CHIP_STM32_COMP_H
+
+/****************************************************************************************************
+ * Included Files
+ ****************************************************************************************************/
+
+#include
+
+#include "chip.h"
+
+/****************************************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************************************/
+
+/* Register Offsets *********************************************************************************/
+
+#define STM32_COMP2_CSR_OFFSET 0x0020 /* COMP2 Control register */
+#define STM32_COMP4_CSR_OFFSET 0x0028 /* COMP4 Control register */
+#define STM32_COMP6_CSR_OFFSET 0x0030 /* COMP6 Control register */
+
+/* Register Addresses *******************************************************************************/
+
+#define STM32_COMP2_CSR (STM32_COMP_BASE+STM32_COMP2_CSR_OFFSET)
+#define STM32_COMP4_CSR (STM32_COMP_BASE+STM32_COMP4_CSR_OFFSET)
+#define STM32_COMP6_CSR (STM32_COMP_BASE+STM32_COMP6_CSR_OFFSET)
+
+/* Register Bitfield Definitions ****************************************************/
+
+/* COMP control and status register */
+
+#define COMP_CSR_COMPEN (1 << 0) /* Bit 0: Comparator enable */
+ /* Bits 1-3: Reserved */
+#define COMP_CSR_INMSEL_SHIFT (4) /* Bits 4-6: Comparator inverting input selection */
+#define COMP_CSR_INMSEL_MASK (15 << COMP_CSR_INMSEL_SHIFT)
+# define COMP_CSR_INMSEL_1P4VREF (0 << COMP_CSR_INMSEL_SHIFT) /* 0000: 1/4 of Vrefint */
+# define COMP_CSR_INMSEL_1P2VREF (1 << COMP_CSR_INMSEL_SHIFT) /* 0001: 1/2 of Vrefint */
+# define COMP_CSR_INMSEL_3P4VREF (2 << COMP_CSR_INMSEL_SHIFT) /* 0010: 3/4 of Vrefint */
+# define COMP_CSR_INMSEL_VREF (3 << COMP_CSR_INMSEL_SHIFT) /* 0011: Vrefint */
+# define COMP_CSR_INMSEL_PA4 (4 << COMP_CSR_INMSEL_SHIFT) /* 0100: PA4 or DAC1_CH output if enabled */
+# define COMP_CSR_INMSEL_DAC1CH2 (5 << COMP_CSR_INMSEL_SHIFT) /* 0101: DAC1_CH2 output */
+# define COMP_CSR_INMSEL_PA2 (6 << COMP_CSR_INMSEL_SHIFT) /* 0110: PA2 (COMP2 only) */
+# define COMP_CSR_INMSEL_PB2 (7 << COMP4_CSR_INMSEL_SHIFT) /* 0111: PB2 (COMP4 only) */
+# define COMP_CSR_INMSEL_PB15 (7 << COMP6_CSR_INMSEL_SHIFT) /* 0110: PB15 (COMP6 only) */
+ /* 1000: DAC2_CH1 output, look at bit 22 */
+ /* Bits 7-9: Reserved */
+#define COMP_CSR_OUTSEL_SHIFT (4) /* Bits 10-13: Comparator output selection */
+#define COMP_CSR_OUTSEL_MASK (15 << COMP_CSR_INMSEL_SHIFT)
+# define COMP_CSR_OUTSEL_NOSEL (0 << COMP_CSR_INMSEL_SHIFT) /* 0000: No selection */
+# define COMP_CSR_OUTSEL_BRKACTH (1 << COMP_CSR_INMSEL_SHIFT) /* 0001: Timer 1 break input */
+# define COMP_CSR_OUTSEL_BRK2 (2 << COMP_CSR_INMSEL_SHIFT) /* 0010: Timer 1 break input 2 */
+ /* 0011: Reserved */
+ /* 0100: Reserved */
+# define COMP_CSR_OUTSEL_BRK2_ (5 << COMP_CSR_INMSEL_SHIFT) /* 0101: Timer 1 break input2 */
+# define COMP_CSR_OUTSEL_T1OCCC (6 << COMP_CSR_INMSEL_SHIFT) /* 0110: Timer 1 OCREF_CLR input (COMP2 only) */
+# define COMP_CSR_OUTSEL_T3CAP3 (6 << COMP_CSR_INMSEL_SHIFT) /* 0110: Timer 3 input apture 3 (COMP4 only) */
+# define COMP_CSR_OUTSEL_T2CAP2 (6 << COMP_CSR_INMSEL_SHIFT) /* 0110: Timer 2 input apture 2 (COMP6 only) */
+# define COMP_CSR_OUTSEL_T1CAP1 (7 << COMP_CSR_INMSEL_SHIFT) /* 0111: Timer 1 input capture 1 (COMP2 only) */
+# define COMP_CSR_OUTSEL_T2CAP4 (8 << COMP_CSR_INMSEL_SHIFT) /* 1000: Timer 2 input capture 4 (COMP2 only) */
+# define COMP_CSR_OUTSEL_T15CAP2 (8 << COMP_CSR_INMSEL_SHIFT) /* 1000: Timer 15 input capture 2 (COMP4 only) */
+# define COMP_CSR_OUTSEL_T2OCC (8 << COMP_CSR_INMSEL_SHIFT) /* 1000: Timer 2 OCREF CLR input (COMP6 only) */
+# define COMP_CSR_OUTSEL_T2OCC (9 << COMP_CSR_INMSEL_SHIFT) /* 1001: Timer 2 OCREF_CLR input (COMP2 only) */
+# define COMP_CSR_OUTSEL_T16OCC (9 << COMP_CSR_INMSEL_SHIFT) /* 1001: Timer 16 OCREF_CLR input (COMP6 only) */
+# define COMP_CSR_OUTSEL_T3CAP1 (10 << COMP_CSR_INMSEL_SHIFT) /* 1010: Timer 3 input capture 1 (COMP2 only) */
+# define COMP_CSR_OUTSEL_T3CAP1 (10 << COMP_CSR_INMSEL_SHIFT) /* 1010: Timer 15 OCREF_CLR input (COMP4 only) */
+# define COMP_CSR_OUTSEL_T3CAP1 (10 << COMP_CSR_INMSEL_SHIFT) /* 1010: Timer 16 input capture 1 (COMP6 only) */
+# define COMP_CSR_OUTSEL_T3OCC (11 << COMP_CSR_INMSEL_SHIFT) /* 1011: Timer 3 OCREF_CLR input (COMP2,COMP4 only) */
+ /* Bit 14: Reserved */
+#define COMP_CSR_POL (1 << 15) /* Bit 15: comparator output polarity */
+ /* Bits 16-17: Reserved */
+#define COMP_CSR_BLANCKING_SHIFT (18) /* Bit 18-20: comparator output blanking source */
+#define COMP_CSR_BLANCKING_MASK (7 << COMP_CSR_BLANCKING_SHIFT)
+# define COMP_CSR_BLANCKING_DIS (0 << COMP_CSR_BLANCKING_SHIFT) /* 000: No blanking */
+# define COMP_CSR_BLANCKING_T1OC5 (1 << COMP_CSR_BLANCKING_SHIFT) /* 001: TIM1 OC5 as blanking source (COMP2 only) */
+# define COMP_CSR_BLANCKING_T3OC4 (1 << COMP_CSR_BLANCKING_SHIFT) /* 001: TIM3 OC4 as blanking source (COMP4 only) */
+# define COMP_CSR_BLANCKING_T2OC3 (2 << COMP_CSR_BLANCKING_SHIFT) /* 010: TIM2 OC3 as blanking source (COMP2 only) */
+# define COMP_CSR_BLANCKING_T3OC3 (3 << COMP_CSR_BLANCKING_SHIFT) /* 011: TIM3 OC3 as blanking source (COMP2 only) */
+# define COMP_CSR_BLANCKING_T15OC1 (3 << COMP_CSR_BLANCKING_SHIFT) /* 011: TIM15 OC1 as blanking source (COMP4 only) */
+# define COMP_CSR_BLANCKING_T2OC4 (3 << COMP_CSR_BLANCKING_SHIFT) /* 011: TIM2 OC4 as blanking source (COMP6 only) */
+# define COMP_CSR_BLANCKING_T15OC2 (4 << COMP_CSR_BLANCKING_SHIFT) /* 011: TIM15 OC2 as blanking source (COMP6 only) */
+ /* Bit 21: Reserved */
+#define COMP_CSR_INMSEL_DAC2CH1 (1 << 22) /* Bit 22: used with bits 4-6, DAC2_CH1 output */
+ /* Bits 23-29: Reserved */
+#define COMP_CSR_OUT (1 << 30) /* Bit 30: comparator output */
+#define COMP_CSR_LOCK (1 << 31) /* Bit 31: comparator lock */
+
+
+
+#endif /* __ARCH_ARM_SRC_STM32_CHIP_STM32_COMP_H */
diff --git a/arch/arm/src/stm32/chip/stm32f33xxx_dac.h b/arch/arm/src/stm32/chip/stm32f33xxx_dac.h
new file mode 100644
index 0000000000000000000000000000000000000000..08b612102b0cae08c0b68743b4a26e36c98be886
--- /dev/null
+++ b/arch/arm/src/stm32/chip/stm32f33xxx_dac.h
@@ -0,0 +1,238 @@
+/************************************************************************************
+ * arch/arm/src/stm32/chip/stm32f33xxx_dac.h
+ *
+ * Copyright (C) 2017 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ * Modified for STM32F334 by Mateusz Szafoni
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ************************************************************************************/
+
+#ifndef __ARCH_ARM_SRC_STM32_CHIP_STM32_DAC_H
+#define __ARCH_ARM_SRC_STM32_CHIP_STM32_DAC_H
+
+/************************************************************************************
+ * Included Files
+ ************************************************************************************/
+
+#include
+#include "chip.h"
+
+/************************************************************************************
+ * Pre-processor Definitions
+ ************************************************************************************/
+
+/* Register Offsets *****************************************************************/
+
+#define STM32_DAC_CR_OFFSET 0x0000 /* DAC control register */
+#define STM32_DAC_SWTRIGR_OFFSET 0x0004 /* DAC software trigger register */
+#define STM32_DAC_DHR12R1_OFFSET 0x0008 /* DAC channel 1 12-bit right-aligned data holding register */
+#define STM32_DAC_DHR12L1_OFFSET 0x000c /* DAC channel 1 12-bit left aligned data holding register */
+#define STM32_DAC_DHR8R1_OFFSET 0x0010 /* DAC channel 1 8-bit right aligned data holding register */
+#define STM32_DAC_DHR12L2_OFFSET 0x0018 /* DAC channel 2 12-bit left aligned data holding register */
+#define STM32_DAC_DHR8R2_OFFSET 0x001c /* DAC channel 2 8-bit right-aligned data holding register */
+#define STM32_DAC_DHR12RD_OFFSET 0x0020 /* Dual DAC 12-bit right-aligned data holding register */
+#define STM32_DAC_DHR12LD_OFFSET 0x0024 /* DUAL DAC 12-bit left aligned data holding register */
+#define STM32_DAC_DHR8RD_OFFSET 0x0028 /* DUAL DAC 8-bit right aligned data holding register */
+#define STM32_DAC_DOR1_OFFSET 0x002c /* DAC channel 1 data output register */
+#define STM32_DAC_DOR2_OFFSET 0x0030 /* DAC channel 2 data output register */
+#define STM32_DAC_SR_OFFSET 0x0034 /* DAC status register */
+
+/* Register Addresses ***************************************************************/
+
+/* DAC1 */
+
+# define STM32_DAC1_CR (STM32_DAC1_BASE+STM32_DAC_CR_OFFSET)
+# define STM32_DAC1_SWTRIGR (STM32_DAC1_BASE+STM32_DAC_SWTRIGR_OFFSET)
+# define STM32_DAC1_DHR12R1 (STM32_DAC1_BASE+STM32_DAC_DHR12R1_OFFSET)
+# define STM32_DAC1_DHR12L1 (STM32_DAC1_BASE+STM32_DAC_DHR12L1_OFFSET)
+# define STM32_DAC1_DHR8R1 (STM32_DAC1_BASE+STM32_DAC_DHR8R1_OFFSET)
+# define STM32_DAC1_DHR12R2 (STM32_DAC1_BASE+STM32_DAC_DHR12R2_OFFSET)
+# define STM32_DAC1_DHR12L2 (STM32_DAC1_BASE+STM32_DAC_DHR12L2_OFFSET)
+# define STM32_DAC1_DHR8R2 (STM32_DAC1_BASE+STM32_DAC_DHR8R2_OFFSET)
+# define STM32_DAC1_DHR12RD (STM32_DAC1_BASE+STM32_DAC_DHR12RD_OFFSET)
+# define STM32_DAC1_DHR12LD (STM32_DAC1_BASE+STM32_DAC_DHR12LD_OFFSET)
+# define STM32_DAC1_DHR8RD (STM32_DAC1_BASE+STM32_DAC_DHR8RD_OFFSET)
+# define STM32_DAC1_DOR1 (STM32_DAC1_BASE+STM32_DAC_DOR1_OFFSET)
+# define STM32_DAC1_DOR2 (STM32_DAC1_BASE+STM32_DAC_DOR2_OFFSET)
+# define STM32_DAC1_SR (STM32_DAC1_BASE+STM32_DAC_SR_OFFSET)
+
+/* DAC2 */
+
+# define STM32_DAC2_CR (STM32_DAC2_BASE+STM32_DAC_CR_OFFSET)
+# define STM32_DAC2_SWTRIGR (STM32_DAC2_BASE+STM32_DAC_SWTRIGR_OFFSET)
+# define STM32_DAC2_DHR12R1 (STM32_DAC2_BASE+STM32_DAC_DHR12R1_OFFSET)
+# define STM32_DAC2_DHR12L1 (STM32_DAC2_BASE+STM32_DAC_DHR12L1_OFFSET)
+# define STM32_DAC2_DHR8R1 (STM32_DAC2_BASE+STM32_DAC_DHR8R1_OFFSET)
+# define STM32_DAC2_DHR12R2 (STM32_DAC2_BASE+STM32_DAC_DHR12R2_OFFSET)
+# define STM32_DAC2_DHR12L2 (STM32_DAC2_BASE+STM32_DAC_DHR12L2_OFFSET)
+# define STM32_DAC2_DHR8R2 (STM32_DAC2_BASE+STM32_DAC_DHR8R2_OFFSET)
+# define STM32_DAC2_DHR12RD (STM32_DAC2_BASE+STM32_DAC_DHR12RD_OFFSET)
+# define STM32_DAC2_DHR12LD (STM32_DAC2_BASE+STM32_DAC_DHR12LD_OFFSET)
+# define STM32_DAC2_DHR8RD (STM32_DAC2_BASE+STM32_DAC_DHR8RD_OFFSET)
+# define STM32_DAC2_DOR1 (STM32_DAC2_BASE+STM32_DAC_DOR1_OFFSET)
+# define STM32_DAC2_DOR2 (STM32_DAC2_BASE+STM32_DAC_DOR2_OFFSET)
+# define STM32_DAC2_SR (STM32_DAC2_BASE+STM32_DAC_SR_OFFSET)
+
+/* Register Bitfield Definitions ****************************************************/
+
+/* DAC control register */
+/* These definitions may be used with the full, 32-bit register */
+
+#define DAC_CR_EN1 (1 << 0) /* Bit 0: DAC channel 1 enable */
+#define DAC_CR_BOFF1 (1 << 1) /* Bit 1: DAC channel 1 output buffer disable */
+#define DAC_CR_TEN1 (1 << 2) /* Bit 2: DAC channel 1 trigger enable */
+#define DAC_CR_TSEL1_SHIFT (3) /* Bits 3-5: DAC channel 1 trigger selection */
+#define DAC_CR_TSEL1_MASK (7 << DAC_CR_TSEL1_SHIFT)
+# define DAC_CR_TSEL1_TIM6 (0 << DAC_CR_TSEL1_SHIFT) /* Timer 6 TRGO event */
+# define DAC_CR_TSEL1_TIM3 (1 << DAC_CR_TSEL1_SHIFT) /* Timer 3 TRGO event */
+# define DAC_CR_TSEL1_TIM7 (2 << DAC_CR_TSEL1_SHIFT) /* Timer 7 TRGO event */
+# define DAC_CR_TSEL1_TIM15 (3 << DAC_CR_TSEL1_SHIFT) /* Timer 15 TRGO event, or */
+# define DAC_CR_TSEL_HRT1TRG1 (3 << DAC_CR_TSEL_SHIFT) /* HRTIM1 DACTRG1 event (DAC1 only) */
+# define DAC_CR_TSEL1_TIM2 (4 << DAC_CR_TSEL1_SHIFT) /* Timer 2 TRGO event */
+# define DAC_CR_TSEL_HRT1TRG2 (5 << DAC_CR_TSEL_SHIFT) /* HRTIM1 DACTRG2 event (DAC1), or */
+# define DAC_CR_TSEL_HRT1TRG3 (5 << DAC_CR_TSEL_SHIFT) /* HRTIM1 DACTRG3 event (DAC2) */
+# define DAC_CR_TSEL1_EXT9 (6 << DAC_CR_TSEL1_SHIFT) /* External line9 */
+# define DAC_CR_TSEL1_SW (7 << DAC_CR_TSEL1_SHIFT) /* Software trigger */
+#define DAC_CR_WAVE1_SHIFT (6) /* Bits 6-7: DAC channel 1 noise/triangle wave generation */
+#define DAC_CR_WAVE1_MASK (3 << DAC_CR_WAVE1_SHIFT)
+# define DAC_CR_WAVE1_DISABLED (0 << DAC_CR_WAVE1_SHIFT) /* Wave generation disabled */
+# define DAC_CR_WAVE1_NOISE (1 << DAC_CR_WAVE1_SHIFT) /* Noise wave generation enabled */
+# define DAC_CR_WAVE1_TRIANGLE (2 << DAC_CR_WAVE1_SHIFT) /* Triangle wave generation enabled */
+#define DAC_CR_MAMP1_SHIFT (8) /* Bits 8-11: DAC channel 1 mask/amplitude selector */
+#define DAC_CR_MAMP1_MASK (15 << DAC_CR_MAMP1_SHIFT)
+# define DAC_CR_MAMP1_AMP1 (0 << DAC_CR_MAMP1_SHIFT) /* Unmask bit0 of LFSR/triangle amplitude=1 */
+# define DAC_CR_MAMP1_AMP3 (1 << DAC_CR_MAMP1_SHIFT) /* Unmask bits[1:0] of LFSR/triangle amplitude=3 */
+# define DAC_CR_MAMP1_AMP7 (2 << DAC_CR_MAMP1_SHIFT) /* Unmask bits[2:0] of LFSR/triangle amplitude=7 */
+# define DAC_CR_MAMP1_AMP15 (3 << DAC_CR_MAMP1_SHIFT) /* Unmask bits[3:0] of LFSR/triangle amplitude=15 */
+# define DAC_CR_MAMP1_AMP31 (4 << DAC_CR_MAMP1_SHIFT) /* Unmask bits[4:0] of LFSR/triangle amplitude=31 */
+# define DAC_CR_MAMP1_AMP63 (5 << DAC_CR_MAMP1_SHIFT) /* Unmask bits[5:0] of LFSR/triangle amplitude=63 */
+# define DAC_CR_MAMP1_AMP127 (6 << DAC_CR_MAMP1_SHIFT) /* Unmask bits[6:0] of LFSR/triangle amplitude=127 */
+# define DAC_CR_MAMP1_AMP255 (7 << DAC_CR_MAMP1_SHIFT) /* Unmask bits[7:0] of LFSR/triangle amplitude=255 */
+# define DAC_CR_MAMP1_AMP511 (8 << DAC_CR_MAMP1_SHIFT) /* Unmask bits[8:0] of LFSR/triangle amplitude=511 */
+# define DAC_CR_MAMP1_AMP1023 (9 << DAC_CR_MAMP1_SHIFT) /* Unmask bits[9:0] of LFSR/triangle amplitude=1023 */
+# define DAC_CR_MAMP1_AMP2047 (10 << DAC_CR_MAMP1_SHIFT) /* Unmask bits[10:0] of LFSR/triangle amplitude=2047 */
+# define DAC_CR_MAMP1_AMP4095 (11 << DAC_CR_MAMP1_SHIFT) /* Unmask bits[11:0] of LFSR/triangle amplitude=4095 */
+#define DAC_CR_DMAEN1 (1 << 12) /* Bit 12: DAC channel 1 DMA enable */
+#define DAC_CR_DMAUDRIE1 (1 << 13) /* Bit 13: DAC channel 1 DMA Underrun Interrupt enable */
+
+#define DAC_CR_EN2 (1 << 16) /* Bit 16: DAC channel 2 enable */
+#define DAC_CR_BOFF2 (1 << 17) /* Bit 17: DAC channel 2 output buffer disable */
+#define DAC_CR_TEN2 (1 << 18) /* Bit 18: DAC channel 2 trigger enable */
+#define DAC_CR_TSEL2_SHIFT (19) /* Bits 19-21: DAC channel 2 trigger selection */
+#define DAC_CR_TSEL2_MASK (7 << DAC_CR_TSEL2_SHIFT)
+# define DAC_CR_TSEL2_TIM6 (0 << DAC_CR_TSEL2_SHIFT) /* Timer 6 TRGO event */
+# define DAC_CR_TSEL2_TIM8 (1 << DAC_CR_TSEL2_SHIFT) /* Timer 8 TRGO event */
+# define DAC_CR_TSEL2_TIM7 (2 << DAC_CR_TSEL2_SHIFT) /* Timer 7 TRGO event */
+# define DAC_CR_TSEL2_TIM5 (3 << DAC_CR_TSEL2_SHIFT) /* Timer 5 TRGO event */
+# define DAC_CR_TSEL2_TIM2 (4 << DAC_CR_TSEL2_SHIFT) /* Timer 2 TRGO event */
+# define DAC_CR_TSEL2_TIM4 (5 << DAC_CR_TSEL2_SHIFT) /* Timer 4 TRGO event */
+# define DAC_CR_TSEL2_EXT9 (6 << DAC_CR_TSEL2_SHIFT) /* External line9 */
+# define DAC_CR_TSEL2_SW (7 << DAC_CR_TSEL2_SHIFT) /* Software trigger */
+#define DAC_CR_WAVE2_SHIFT (22) /* Bit 22-23: DAC channel 2 noise/triangle wave generation enable */
+#define DAC_CR_WAVE2_MASK (3 << DAC_CR_WAVE2_SHIFT)
+# define DAC_CR_WAVE2_DISABLED (0 << DAC_CR_WAVE2_SHIFT) /* Wave generation disabled */
+# define DAC_CR_WAVE2_NOISE (1 << DAC_CR_WAVE2_SHIFT) /* Noise wave generation enabled */
+# define DAC_CR_WAVE2_TRIANGLE (2 << DAC_CR_WAVE2_SHIFT) /* Triangle wave generation enabled */
+#define DAC_CR_MAMP2_SHIFT (24) /* Bit 24-27: DAC channel 2 mask/amplitude selector */
+#define DAC_CR_MAMP2_MASK (15 << DAC_CR_MAMP2_SHIFT)
+# define DAC_CR_MAMP2_AMP1 (0 << DAC_CR_MAMP2_SHIFT) /* Unmask bit0 of LFSR/triangle amplitude=1 */
+# define DAC_CR_MAMP2_AMP3 (1 << DAC_CR_MAMP2_SHIFT) /* Unmask bits[1:0] of LFSR/triangle amplitude=3 */
+# define DAC_CR_MAMP2_AMP7 (2 << DAC_CR_MAMP2_SHIFT) /* Unmask bits[2:0] of LFSR/triangle amplitude=7 */
+# define DAC_CR_MAMP2_AMP15 (3 << DAC_CR_MAMP2_SHIFT) /* Unmask bits[3:0] of LFSR/triangle amplitude=15 */
+# define DAC_CR_MAMP2_AMP31 (4 << DAC_CR_MAMP2_SHIFT) /* Unmask bits[4:0] of LFSR/triangle amplitude=31 */
+# define DAC_CR_MAMP2_AMP63 (5 << DAC_CR_MAMP2_SHIFT) /* Unmask bits[5:0] of LFSR/triangle amplitude=63 */
+# define DAC_CR_MAMP2_AMP127 (6 << DAC_CR_MAMP2_SHIFT) /* Unmask bits[6:0] of LFSR/triangle amplitude=127 */
+# define DAC_CR_MAMP2_AMP255 (7 << DAC_CR_MAMP2_SHIFT) /* Unmask bits[7:0] of LFSR/triangle amplitude=255 */
+# define DAC_CR_MAMP2_AMP511 (8 << DAC_CR_MAMP2_SHIFT) /* Unmask bits[8:0] of LFSR/triangle amplitude=511 */
+# define DAC_CR_MAMP2_AMP1023 (9 << DAC_CR_MAMP2_SHIFT) /* Unmask bits[9:0] of LFSR/triangle amplitude=1023 */
+# define DAC_CR_MAMP2_AMP2047 (10 << DAC_CR_MAMP2_SHIFT) /* Unmask bits[10:0] of LFSR/triangle amplitude=2047 */
+# define DAC_CR_MAMP2_AMP4095 (11 << DAC_CR_MAMP2_SHIFT) /* Unmask bits[11:0] of LFSR/triangle amplitude=4095 */
+#define DAC_CR_DMAEN2 (1 << 28) /* Bit 28: DAC channel 2 DMA enable */
+#define DAC_CR_DMAUDRIE2 (1 << 29) /* Bits 29: DAC channel 2 DMA underrun interrupt enable */
+
+/* DAC software trigger register */
+
+#define DAC_SWTRIGR_SWTRIG(n) (1 << ((n)-1))
+#define DAC_SWTRIGR_SWTRIG1 (1 << 0) /* Bit 0: DAC channel 1 software trigger */
+#define DAC_SWTRIGR_SWTRIG2 (1 << 1) /* Bit 1: DAC channel 2 software trigger */
+
+/* DAC channel 1/2 12-bit right-aligned data holding register */
+
+#define DAC_DHR12R_MASK (0x0fff)
+
+/* DAC channel 1/2 12-bit left aligned data holding register */
+
+#define DAC_DHR12L_MASK (0xfff0)
+
+/* DAC channel 1/2 8-bit right aligned data holding register */
+
+#define DAC_DHR8R_MASK (0x00ff)
+
+/* Dual DAC 12-bit right-aligned data holding register */
+
+#define DAC_DHR12RD_DACC_SHIFT(n) (1 << (((n)-1) << 4))
+#define DAC_DHR12RD_DACC_MASK(n) (0xfff << DAC_DHR12RD_DACC_SHIFT(n))
+
+#define DAC_DHR12RD_DACC1_SHIFT (0) /* Bits 0-11: DAC channel 1 12-bit right-aligned data */
+#define DAC_DHR12RD_DACC1_MASK (0xfff << DAC_DHR12RD_DACC2_SHIFT)
+#define DAC_DHR12RD_DACC2_SHIFT (16) /* Bits 16-27: DAC channel 2 12-bit right-aligned data */
+#define DAC_DHR12RD_DACC2_MASK (0xfff << DAC_DHR12RD_DACC2_SHIFT)
+
+/* Dual DAC 12-bit left-aligned data holding register */
+
+#define DAC_DHR12LD_DACC_SHIFT(n) ((1 << (((n)-1) << 4)) + 4)
+#define DAC_DHR12LD_DACC_MASK(n) (0xfff << DAC_DHR12LD_DACC_SHIFT(n))
+
+#define DAC_DHR12LD_DACC1_SHIFT (4) /* Bits 4-15: DAC channel 1 12-bit left-aligned data */
+#define DAC_DHR12LD_DACC1_MASK (0xfff << DAC_DHR12LD_DACC1_SHIFT)
+#define DAC_DHR12LD_DACC2_SHIFT (20) /* Bits 20-31: DAC channel 2 12-bit left-aligned data */
+#define DAC_DHR12LD_DACC2_MASK (0xfff << DAC_DHR12LD_DACC2_SHIFT)
+
+/* DUAL DAC 8-bit right aligned data holding register */
+
+#define DAC_DHR8RD_DACC_SHIFT(n) (1 << (((n)-1) << 3))
+#define DAC_DHR8RD_DACC_MASK(n) (0xff << DAC_DHR8RD_DACC_SHIFT(n))
+
+#define DAC_DHR8RD_DACC1_SHIFT (0) /* Bits 0-7: DAC channel 1 8-bit right-aligned data */
+#define DAC_DHR8RD_DACC1_MASK (0xff << DAC_DHR8RD_DACC1_SHIFT)
+#define DAC_DHR8RD_DACC2_SHIFT (8) /* Bits 8-15: DAC channel 2 8-bit right-aligned data */
+#define DAC_DHR8RD_DACC2_MASK (0xff << DAC_DHR8RD_DACC2_SHIFT)
+
+/* DAC channel 1/2 data output register */
+
+#define DAC_DOR_MASK (0x0fff)
+
+/* DAC status register */
+
+#define DAC_SR_DMAUDR(n) ((1 << (((n)-1) << 4)) + 13)
+#define DAC_SR_DMAUDR1 (1 << 13) /* Bit 13: DAC channel 1 DMA underrun flag */
+#define DAC_SR_DMAUDR2 (1 << 29) /* Bit 29: DAC channel 2 DMA underrun flag */
+
+#endif /* __ARCH_ARM_SRC_STM32_CHIP_STM32_DAC_H */
diff --git a/arch/arm/src/stm32/chip/stm32f33xxx_hrtim.h b/arch/arm/src/stm32/chip/stm32f33xxx_hrtim.h
new file mode 100644
index 0000000000000000000000000000000000000000..fc22deeb25a612c243118a5e6a0f6e16afbd8993
--- /dev/null
+++ b/arch/arm/src/stm32/chip/stm32f33xxx_hrtim.h
@@ -0,0 +1,2063 @@
+/****************************************************************************************************
+ * arch/arm/src/stm32/chip/stm32f33xxx_hrtim.h
+ *
+ * Copyright (C) 2017 Gregory Nutt. All rights reserved.
+ * Author: Mateusz Szafoni
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************************************/
+
+#ifndef __ARCH_ARM_SRC_STM32_CHIP_STM32_HRTIM_H
+#define __ARCH_ARM_SRC_STM32_CHIP_STM32_HRTIM_H
+
+/****************************************************************************************************
+ * Included Files
+ ****************************************************************************************************/
+
+#include
+
+#include "chip.h"
+
+/****************************************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************************************/
+
+#define STM32_HRTIM_MASTER_OFFSET 0x0000 /* HRTIM Master Timer base adress offset */
+#define STM32_HRTIM_TIMERA_OFFSET 0x0080 /* HRTIM Timer A base adress offset */
+#define STM32_HRTIM_TIMERB_OFFSET 0x0100 /* HRTIM Timer B base adress offset */
+#define STM32_HRTIM_TIMERC_OFFSET 0x0180 /* HRTIM Timer C base adress offset */
+#define STM32_HRTIM_TIMERD_OFFSET 0x0200 /* HRTIM Timer D base adress offset */
+#define STM32_HRTIM_TIMERE_OFFSET 0x0280 /* HRTIM Timer E base adress offset */
+ /* 0x300-0x37F: Reserved */
+#define STM32_HRTIM_CMN_OFFSET 0x0380 /* HRTIM Common registers base adress offset */
+
+#define STM32_HRTIM1_MASTER_BASE (STM32_HRTIM_MASTER_OFFSET+STM32_HRTIM1_BASE)
+#define STM32_HRTIM1_TIMERA_BASE (STM32_HRTIM_TIMERA_OFFSET+STM32_HRTIM1_BASE)
+#define STM32_HRTIM1_TIMERB_BASE (STM32_HRTIM_TIMERB_OFFSET+STM32_HRTIM1_BASE)
+#define STM32_HRTIM1_TIMERC_BASE (STM32_HRTIM_TIMERC_OFFSET+STM32_HRTIM1_BASE)
+#define STM32_HRTIM1_TIMERD_BASE (STM32_HRTIM_TIMERD_OFFSET+STM32_HRTIM1_BASE)
+#define STM32_HRTIM1_TIMERE_BASE (STM32_HRTIM_TIMERE_OFFSET+STM32_HRTIM1_BASE)
+#define STM32_HRTIM1_CMN_BASE (STM32_HRTIM_CMN_OFFSET+STM32_HRTIM1_BASE)
+
+/* Register Offsets *********************************************************************************/
+
+/* Register Offsets for HRTIM Master Timer */
+
+#define STM32_HRTIM_MASTER_MCR 0x0000 /* HRTIM Master Timer Control Register */
+#define STM32_HRTIM_MASTER_MISR 0x0004 /* HRTIM Master Timer Interrupt Status Register */
+#define STM32_HRTIM_MASTER_MICR 0x0008 /* HRTIM Master Timer Interrupt Clear Register */
+#define STM32_HRTIM_MASTER_MDIER 0x000C /* HRTIM Master Timer DMA/Interrupt Enable Register */
+#define STM32_HRTIM_MASTER_MCNTR 0x0010 /* HRTIM Master Timer Counter Register */
+#define STM32_HRTIM_MASTER_MPER 0x0014 /* HRTIM Master Timer Period Register */
+#define STM32_HRTIM_MASTER_MREP 0x0018 /* HRTIM Master Timer Repetition Register */
+#define STM32_HRTIM_MASTER_MCMP1R 0x001C /* HRTIM Master Timer Compare 1 Register */
+#define STM32_HRTIM_MASTER_MCMP2R 0x0024 /* HRTIM Master Timer Compare 2 Register */
+#define STM32_HRTIM_MASTER_MCMP3R 0x0028 /* HRTIM Master Timer Compare 3 Register */
+#define STM32_HRTIM_MASTER_MCMP4R 0x002C /* HRTIM Master Timer Compare 4 Register */
+
+/* Register Offsets for HRTIM Timers A-E */
+
+#define STM32_HRTIM_TIMX_CR 0x0000 /* HRTIM Timer X Control Register */
+#define STM32_HRTIM_TIMX_ISR 0x0004 /* HRTIM Timer X Interrupt Status Register */
+#define STM32_HRTIM_TIMX_ICR 0x0008 /* HRTIM Timer X Interrupt Clear Register */
+#define STM32_HRTIM_TIMX_DIER 0x000C /* HRTIM Timer X DMA/Interrupt Enable Register */
+#define STM32_HRTIM_TIMX_CNTR 0x0010 /* HRTIM Timer X Counter Register */
+#define STM32_HRTIM_TIMX_PER 0x0014 /* HRTIM Timer X Period Register */
+#define STM32_HRTIM_TIMX_REP 0x0018 /* HRTIM Timer X Repetition Register */
+#define STM32_HRTIM_TIMX_CMP1R 0x001C /* HRTIM Timer X Compare 1 Register */
+#define STM32_HRTIM_TIMX_CMP1CR 0x0020 /* HRTIM Timer X Compare 1 Compound Register */
+#define STM32_HRTIM_TIMX_CMP2R 0x0024 /* HRTIM Timer X Compare 2 Register */
+#define STM32_HRTIM_TIMX_CMP3R 0x0028 /* HRTIM Timer X Compare 3 Register */
+#define STM32_HRTIM_TIMX_CMP4R 0x002C /* HRTIM Timer X Compare 4 Register */
+#define STM32_HRTIM_TIMX_CPT1R 0x0030 /* HRTIM Timer X Capture 1 Register */
+#define STM32_HRTIM_TIMX_CPT2R 0x0034 /* HRTIM Timer X Capture 2 Register */
+#define STM32_HRTIM_TIMX_DTR 0x0038 /* HRTIM Timer X Deadtime Register */
+#define STM32_HRTIM_TIMX_SET1R 0x003C /* HRTIM Timer X Output1 Set Register */
+#define STM32_HRTIM_TIMX_RST1R 0x0040 /* HRTIM Timer X Output1 Reset Register */
+#define STM32_HRTIM_TIMX_SET2R 0x0044 /* HRTIM Timer X Output2 Set Register */
+#define STM32_HRTIM_TIMX_RST2R 0x0048 /* HRTIM Timer X Output2 Reset Register */
+#define STM32_HRTIM_TIMX_EEFR1 0x004C /* HRTIM Timer X External Event Filtering Register 1 */
+#define STM32_HRTIM_TIMX_EEFR2 0x0050 /* HRTIM Timer X External Event Filtering Register 2 */
+#define STM32_HRTIM_TIMX_RSTR 0x0054 /* HRTIM Timer X Reset Register */
+#define STM32_HRTIM_TIMX_CHPR 0x0058 /* HRTIM Timer X Chopper Register */
+#define STM32_HRTIM_TIMX_CPT1CR 0x005C /* HRTIM Timer X Capture 1 Control Register */
+#define STM32_HRTIM_TIMX_CPT2CR 0x0060 /* HRTIM Timer X Capture 2 Control Register */
+#define STM32_HRTIM_TIMX_OUTR 0x0064 /* HRTIM Timer X Output Register */
+#define STM32_HRTIM_TIMX_FLTR 0x0068 /* HRTIM Timer X Fault Register */
+
+/* Register Offset for HRTIM Common */
+
+#define STM32_HRTIM_CMN_CR1 0x0000 /* HRTIM Control Register 1 */
+#define STM32_HRTIM_CMN_CR2 0x0004 /* HRTIM Control Register 2 */
+#define STM32_HRTIM_CMN_ISR 0x0008 /* HRTIM Interrupt Status Register */
+#define STM32_HRTIM_CMN_ICR 0x000C /* HRTIM Interrupt Clear Register */
+#define STM32_HRTIM_CMN_IER 0x0010 /* HRTIM Interrupt Enable Register */
+#define STM32_HRTIM_CMN_OENR 0x0014 /* HRTIM Output Enable Register */
+#define STM32_HRTIM_CMN_DISR 0x0018 /* HRTIM Output Disable Register */
+#define STM32_HRTIM_CMN_ODSR 0x001C /* HRTIM Output Disable Status Register */
+#define STM32_HRTIM_CMN_BMCR 0x0020 /* HRTIM Burst Mode Control Register */
+#define STM32_HRTIM_CMN_BMTRGR 0x0024 /* HRTIM Burst Mode Trigger Register */
+#define STM32_HRTIM_CMN_BMCMPR 0x0028 /* HRTIM Burst Mode Compare Register */
+#define STM32_HRTIM_CMN_BMPER 0x002C /* HRTIM Burst Mode Period Register */
+#define STM32_HRTIM_CMN_EECR1 0x0030 /* HRTIM Timer External Event Control Register 1 */
+#define STM32_HRTIM_CMN_EECR2 0x0034 /* HRTIM Timer External Event Control Register 2 */
+#define STM32_HRTIM_CMN_EECR3 0x0038 /* HRTIM Timer External Event Control Register 3 */
+#define STM32_HRTIM_CMN_ADC1R 0x003C /* HRTIM ADC Trigger 1 Register */
+#define STM32_HRTIM_CMN_ADC2R 0x0040 /* HRTIM ADC Trigger 2 Register */
+#define STM32_HRTIM_CMN_ADC3R 0x0044 /* HRTIM ADC Trigger 3 Register */
+#define STM32_HRTIM_CMN_ADC4R 0x0048 /* HRTIM ADC Trigger 4 Register */
+#define STM32_HRTIM_CMN_DLLCR 0x004C /* HRTIM DLL Control Register */
+#define STM32_HRTIM_CMN_FLTINR1 0x0050 /* HRTIM Fault Input Register 1 */
+#define STM32_HRTIM_CMN_FLTINR2 0x0054 /* HRTIM Fault Input Register 2 */
+#define STM32_HRTIM_CMN_BDMUPDR 0x0058 /* HRTIM Master Timer Update Register */
+#define STM32_HRTIM_CMN_BDTAUPR 0x005C /* HRTIM Timer A Update Register */
+#define STM32_HRTIM_CMN_BDTBUPR 0x0060 /* HRTIM Timer B Update Register */
+#define STM32_HRTIM_CMN_BDTCUPR 0x0064 /* HRTIM Timer C Update Register */
+#define STM32_HRTIM_CMN_BDTDUPR 0x0068 /* HRTIM Timer D Update Register */
+#define STM32_HRTIM_CMN_BDTEUPR 0x006C /* HRTIM Timer E Update Register */
+#define STM32_HRTIM_CMN_BDMADR 0x0070 /* HRTIM DMA Data Register */
+
+/* Register Addresses *******************************************************************************/
+
+/* HRTIM1 Master Timer */
+
+#define STM32_HRTIM1_MASTER_MCR (STM32_HRTIM_MASTER_MCR+STM32_HRTIM1_MASTER_BASE)
+#define STM32_HRTIM1_MASTER_MISR (STM32_HRTIM_MASTER_MISR+STM32_HRTIM1_MASTER_BASE)
+#define STM32_HRTIM1_MASTER_MICR (STM32_HRTIM_MASTER_MICR+STM32_HRTIM1_MASTER_BASE)
+#define STM32_HRTIM1_MASTER_MDIER (STM32_HRTIM_MASTER_MDIER+STM32_HRTIM1_MASTER_BASE)
+#define STM32_HRTIM1_MASTER_MCNTR (STM32_HRTIM_MASTER_MCNTR+STM32_HRTIM1_MASTER_BASE)
+#define STM32_HRTIM1_MASTER_MPER (STM32_HRTIM_MASTER_MPER+STM32_HRTIM1_MASTER_BASE)
+#define STM32_HRTIM1_MASTER_MREP (STM32_HRTIM_MASTER_MREP+STM32_HRTIM1_MASTER_BASE)
+#define STM32_HRTIM1_MASTER_MCMP1R (STM32_HRTIM_MASTER_MCMP1R+STM32_HRTIM1_MASTER_BASE)
+#define STM32_HRTIM1_MASTER_MCMP2R (STM32_HRTIM_MASTER_MCMP2R+STM32_HRTIM1_MASTER_BASE)
+#define STM32_HRTIM1_MASTER_MCMP3R (STM32_HRTIM_MASTER_MCMP3R+STM32_HRTIM1_MASTER_BASE)
+#define STM32_HRTIM1_MASTER_MCMP4R (STM32_HRTIM_MASTER_MCMP4R+STM32_HRTIM1_MASTER_BASE)
+
+/* HRTIM1 Timer A */
+
+#define STM32_HRTIM1_TIMERA_CR (STM32_HRTIM_TIMERA_CR+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_ISR (STM32_HRTIM_TIMERA_ISR+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_ICR (STM32_HRTIM_TIMERA_ICR+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_DIER (STM32_HRTIM_TIMERA_DIER+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_CNTR (STM32_HRTIM_TIMERA_CNTR+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_PER (STM32_HRTIM_TIMERA_PER+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_REP (STM32_HRTIM_TIMERA_REP+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_CMP1R (STM32_HRTIM_TIMERA_CMP1R+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_CMP1CR (STM32_HRTIM_TIMERA_CMP1CR+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_CMP2R (STM32_HRTIM_TIMERA_CMP2R+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_CMP3R (STM32_HRTIM_TIMERA_CMP3R+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_CMP4R (STM32_HRTIM_TIMERA_CMP4R+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_CPT1R (STM32_HRTIM_TIMERA_CMPT1R+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_CPT2R (STM32_HRTIM_TIMERA_CMPT2R+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_DTR (STM32_HRTIM_TIMERA_DTR+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_SET1R (STM32_HRTIM_TIMERA_SET1R+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_RST1R (STM32_HRTIM_TIMERA_RST1R+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_SET2R (STM32_HRTIM_TIMERA_SET2R+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_RST2R (STM32_HRTIM_TIMERA_RST2R+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_EEFR1 (STM32_HRTIM_TIMERA_EEFR1+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_EEFR2 (STM32_HRTIM_TIMERA_EEFR2+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_RSTR (STM32_HRTIM_TIMERA_RSTR+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_CHPR (STM32_HRTIM_TIMERA_CHPR+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_CPT1CR (STM32_HRTIM_TIMERA_CPT1CR+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_CPT2CR (STM32_HRTIM_TIMERA_CPT2CR+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_OUTR (STM32_HRTIM_TIMERA_OUTR+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_FLTR (STM32_HRTIM_TIMERA_FLTR+STM32_HRTIM1_TIMERA_BASE)
+
+/* HRTIM1 Timer B */
+
+#define STM32_HRTIM1_TIMERB_CR (STM32_HRTIM_TIMERB_CR+STM32_HRTIM1_TIMERB_BASE)
+#define STM32_HRTIM1_TIMERB_ISR (STM32_HRTIM_TIMERB_ISR+STM32_HRTIM1_TIMERB_BASE)
+#define STM32_HRTIM1_TIMERB_ICR (STM32_HRTIM_TIMERB_ICR+STM32_HRTIM1_TIMERB_BASE)
+#define STM32_HRTIM1_TIMERB_DIER (STM32_HRTIM_TIMERB_DIER+STM32_HRTIM1_TIMERB_BASE)
+#define STM32_HRTIM1_TIMERB_CNTR (STM32_HRTIM_TIMERB_CNTR+STM32_HRTIM1_TIMERB_BASE)
+#define STM32_HRTIM1_TIMERB_PER (STM32_HRTIM_TIMERB_PER+STM32_HRTIM1_TIMERB_BASE)
+#define STM32_HRTIM1_TIMERB_REP (STM32_HRTIM_TIMERB_REP+STM32_HRTIM1_TIMERB_BASE)
+#define STM32_HRTIM1_TIMERB_CMP1R (STM32_HRTIM_TIMERB_CMP1R+STM32_HRTIM1_TIMERB_BASE)
+#define STM32_HRTIM1_TIMERB_CMP1CR (STM32_HRTIM_TIMERB_CMP1CR+STM32_HRTIM1_TIMERB_BASE)
+#define STM32_HRTIM1_TIMERB_CMP2R (STM32_HRTIM_TIMERB_CMP2R+STM32_HRTIM1_TIMERB_BASE)
+#define STM32_HRTIM1_TIMERB_CMP3R (STM32_HRTIM_TIMERB_CMP3R+STM32_HRTIM1_TIMERB_BASE)
+#define STM32_HRTIM1_TIMERB_CMP4R (STM32_HRTIM_TIMERB_CMP4R+STM32_HRTIM1_TIMERB_BASE)
+#define STM32_HRTIM1_TIMERB_CPT1R (STM32_HRTIM_TIMERB_CMPT1R+STM32_HRTIM1_TIMERB_BASE)
+#define STM32_HRTIM1_TIMERB_CPT2R (STM32_HRTIM_TIMERB_CMPT2R+STM32_HRTIM1_TIMERB_BASE)
+#define STM32_HRTIM1_TIMERB_DTR (STM32_HRTIM_TIMERB_DTR+STM32_HRTIM1_TIMERB_BASE)
+#define STM32_HRTIM1_TIMERB_SET1R (STM32_HRTIM_TIMERB_SET1R+STM32_HRTIM1_TIMERB_BASE)
+#define STM32_HRTIM1_TIMERB_RST1R (STM32_HRTIM_TIMERB_RST1R+STM32_HRTIM1_TIMERB_BASE)
+#define STM32_HRTIM1_TIMERB_SET2R (STM32_HRTIM_TIMERB_SET2R+STM32_HRTIM1_TIMERB_BASE)
+#define STM32_HRTIM1_TIMERB_RST2R (STM32_HRTIM_TIMERB_RST2R+STM32_HRTIM1_TIMERB_BASE)
+#define STM32_HRTIM1_TIMERB_EEFR1 (STM32_HRTIM_TIMERB_EEFR1+STM32_HRTIM1_TIMERB_BASE)
+#define STM32_HRTIM1_TIMERB_EEFR2 (STM32_HRTIM_TIMERB_EEFR2+STM32_HRTIM1_TIMERB_BASE)
+#define STM32_HRTIM1_TIMERB_RSTR (STM32_HRTIM_TIMERB_RSTR+STM32_HRTIM1_TIMERB_BASE)
+#define STM32_HRTIM1_TIMERB_CHPR (STM32_HRTIM_TIMERB_CHPR+STM32_HRTIM1_TIMERB_BASE)
+#define STM32_HRTIM1_TIMERB_CPT1CR (STM32_HRTIM_TIMERB_CPT1CR+STM32_HRTIM1_TIMERB_BASE)
+#define STM32_HRTIM1_TIMERB_CPT2CR (STM32_HRTIM_TIMERB_CPT2CR+STM32_HRTIM1_TIMERB_BASE)
+#define STM32_HRTIM1_TIMERB_OUTR (STM32_HRTIM_TIMERB_OUTR+STM32_HRTIM1_TIMERB_BASE)
+#define STM32_HRTIM1_TIMERB_FLTR (STM32_HRTIM_TIMERB_FLTR+STM32_HRTIM1_TIMERB_BASE)
+
+/* HRTIM1 Timer C */
+
+#define STM32_HRTIM1_TIMERC_CR (STM32_HRTIM_TIMERC_CR+STM32_HRTIM1_TIMERC_BASE)
+#define STM32_HRTIM1_TIMERC_ISR (STM32_HRTIM_TIMERC_ISR+STM32_HRTIM1_TIMERC_BASE)
+#define STM32_HRTIM1_TIMERC_ICR (STM32_HRTIM_TIMERC_ICR+STM32_HRTIM1_TIMERC_BASE)
+#define STM32_HRTIM1_TIMERC_DIER (STM32_HRTIM_TIMERC_DIER+STM32_HRTIM1_TIMERC_BASE)
+#define STM32_HRTIM1_TIMERC_CNTR (STM32_HRTIM_TIMERC_CNTR+STM32_HRTIM1_TIMERC_BASE)
+#define STM32_HRTIM1_TIMERC_PER (STM32_HRTIM_TIMERC_PER+STM32_HRTIM1_TIMERC_BASE)
+#define STM32_HRTIM1_TIMERC_REP (STM32_HRTIM_TIMERC_REP+STM32_HRTIM1_TIMERC_BASE)
+#define STM32_HRTIM1_TIMERC_CMP1R (STM32_HRTIM_TIMERC_CMP1R+STM32_HRTIM1_TIMERC_BASE)
+#define STM32_HRTIM1_TIMERC_CMP1CR (STM32_HRTIM_TIMERC_CMP1CR+STM32_HRTIM1_TIMERC_BASE)
+#define STM32_HRTIM1_TIMERC_CMP2R (STM32_HRTIM_TIMERC_CMP2R+STM32_HRTIM1_TIMERC_BASE)
+#define STM32_HRTIM1_TIMERC_CMP3R (STM32_HRTIM_TIMERC_CMP3R+STM32_HRTIM1_TIMERC_BASE)
+#define STM32_HRTIM1_TIMERC_CMP4R (STM32_HRTIM_TIMERC_CMP4R+STM32_HRTIM1_TIMERC_BASE)
+#define STM32_HRTIM1_TIMERC_CPT1R (STM32_HRTIM_TIMERC_CMPT1R+STM32_HRTIM1_TIMERC_BASE)
+#define STM32_HRTIM1_TIMERC_CPT2R (STM32_HRTIM_TIMERC_CMPT2R+STM32_HRTIM1_TIMERC_BASE)
+#define STM32_HRTIM1_TIMERC_DTR (STM32_HRTIM_TIMERC_DTR+STM32_HRTIM1_TIMERC_BASE)
+#define STM32_HRTIM1_TIMERC_SET1R (STM32_HRTIM_TIMERC_SET1R+STM32_HRTIM1_TIMERC_BASE)
+#define STM32_HRTIM1_TIMERC_RST1R (STM32_HRTIM_TIMERC_RST1R+STM32_HRTIM1_TIMERC_BASE)
+#define STM32_HRTIM1_TIMERC_SET2R (STM32_HRTIM_TIMERC_SET2R+STM32_HRTIM1_TIMERC_BASE)
+#define STM32_HRTIM1_TIMERC_RST2R (STM32_HRTIM_TIMERC_RST2R+STM32_HRTIM1_TIMERC_BASE)
+#define STM32_HRTIM1_TIMERC_EEFR1 (STM32_HRTIM_TIMERC_EEFR1+STM32_HRTIM1_TIMERC_BASE)
+#define STM32_HRTIM1_TIMERC_EEFR2 (STM32_HRTIM_TIMERC_EEFR2+STM32_HRTIM1_TIMERC_BASE)
+#define STM32_HRTIM1_TIMERC_RSTR (STM32_HRTIM_TIMERC_RSTR+STM32_HRTIM1_TIMERC_BASE)
+#define STM32_HRTIM1_TIMERC_CHPR (STM32_HRTIM_TIMERC_CHPR+STM32_HRTIM1_TIMERC_BASE)
+#define STM32_HRTIM1_TIMERC_CPT1CR (STM32_HRTIM_TIMERC_CPT1CR+STM32_HRTIM1_TIMERC_BASE)
+#define STM32_HRTIM1_TIMERC_CPT2CR (STM32_HRTIM_TIMERC_CPT2CR+STM32_HRTIM1_TIMERC_BASE)
+#define STM32_HRTIM1_TIMERC_OUTR (STM32_HRTIM_TIMERC_OUTR+STM32_HRTIM1_TIMERC_BASE)
+#define STM32_HRTIM1_TIMERC_FLTR (STM32_HRTIM_TIMERC_FLTR+STM32_HRTIM1_TIMERC_BASE)
+
+/* HRTIM1 Timer D */
+
+#define STM32_HRTIM1_TIMERD_CR (STM32_HRTIM_TIMERD_CR+STM32_HRTIM1_TIMERD_BASE)
+#define STM32_HRTIM1_TIMERD_ISR (STM32_HRTIM_TIMERD_ISR+STM32_HRTIM1_TIMERD_BASE)
+#define STM32_HRTIM1_TIMERD_ICR (STM32_HRTIM_TIMERD_ICR+STM32_HRTIM1_TIMERD_BASE)
+#define STM32_HRTIM1_TIMERD_DIER (STM32_HRTIM_TIMERD_DIER+STM32_HRTIM1_TIMERD_BASE)
+#define STM32_HRTIM1_TIMERD_CNTR (STM32_HRTIM_TIMERD_CNTR+STM32_HRTIM1_TIMERD_BASE)
+#define STM32_HRTIM1_TIMERD_PER (STM32_HRTIM_TIMERD_PER+STM32_HRTIM1_TIMERD_BASE)
+#define STM32_HRTIM1_TIMERD_REP (STM32_HRTIM_TIMERD_REP+STM32_HRTIM1_TIMERD_BASE)
+#define STM32_HRTIM1_TIMERD_CMP1R (STM32_HRTIM_TIMERD_CMP1R+STM32_HRTIM1_TIMERD_BASE)
+#define STM32_HRTIM1_TIMERD_CMP1CR (STM32_HRTIM_TIMERD_CMP1CR+STM32_HRTIM1_TIMERD_BASE)
+#define STM32_HRTIM1_TIMERD_CMP2R (STM32_HRTIM_TIMERD_CMP2R+STM32_HRTIM1_TIMERD_BASE)
+#define STM32_HRTIM1_TIMERD_CMP3R (STM32_HRTIM_TIMERD_CMP3R+STM32_HRTIM1_TIMERD_BASE)
+#define STM32_HRTIM1_TIMERD_CMP4R (STM32_HRTIM_TIMERD_CMP4R+STM32_HRTIM1_TIMERD_BASE)
+#define STM32_HRTIM1_TIMERD_CPT1R (STM32_HRTIM_TIMERD_CMPT1R+STM32_HRTIM1_TIMERD_BASE)
+#define STM32_HRTIM1_TIMERD_CPT2R (STM32_HRTIM_TIMERD_CMPT2R+STM32_HRTIM1_TIMERD_BASE)
+#define STM32_HRTIM1_TIMERD_DTR (STM32_HRTIM_TIMERD_DTR+STM32_HRTIM1_TIMERD_BASE)
+#define STM32_HRTIM1_TIMERD_SET1R (STM32_HRTIM_TIMERD_SET1R+STM32_HRTIM1_TIMERD_BASE)
+#define STM32_HRTIM1_TIMERD_RST1R (STM32_HRTIM_TIMERD_RST1R+STM32_HRTIM1_TIMERD_BASE)
+#define STM32_HRTIM1_TIMERD_SET2R (STM32_HRTIM_TIMERD_SET2R+STM32_HRTIM1_TIMERD_BASE)
+#define STM32_HRTIM1_TIMERD_RST2R (STM32_HRTIM_TIMERD_RST2R+STM32_HRTIM1_TIMERD_BASE)
+#define STM32_HRTIM1_TIMERD_EEFR1 (STM32_HRTIM_TIMERD_EEFR1+STM32_HRTIM1_TIMERD_BASE)
+#define STM32_HRTIM1_TIMERD_EEFR2 (STM32_HRTIM_TIMERD_EEFR2+STM32_HRTIM1_TIMERD_BASE)
+#define STM32_HRTIM1_TIMERD_RSTR (STM32_HRTIM_TIMERD_RSTR+STM32_HRTIM1_TIMERD_BASE)
+#define STM32_HRTIM1_TIMERD_CHPR (STM32_HRTIM_TIMERD_CHPR+STM32_HRTIM1_TIMERD_BASE)
+#define STM32_HRTIM1_TIMERD_CPT1CR (STM32_HRTIM_TIMERD_CPT1CR+STM32_HRTIM1_TIMERD_BASE)
+#define STM32_HRTIM1_TIMERD_CPT2CR (STM32_HRTIM_TIMERD_CPT2CR+STM32_HRTIM1_TIMERD_BASE)
+#define STM32_HRTIM1_TIMERD_OUTR (STM32_HRTIM_TIMERD_OUTR+STM32_HRTIM1_TIMERD_BASE)
+#define STM32_HRTIM1_TIMERD_FLTR (STM32_HRTIM_TIMERD_FLTR+STM32_HRTIM1_TIMERD_BASE)
+
+/* HRTIM1 Timer E */
+
+#define STM32_HRTIM1_TIMERE_CR (STM32_HRTIM_TIMERE_CR+STM32_HRTIM1_TIMERE_BASE)
+#define STM32_HRTIM1_TIMERE_ISR (STM32_HRTIM_TIMERE_ISR+STM32_HRTIM1_TIMERE_BASE)
+#define STM32_HRTIM1_TIMERE_ICR (STM32_HRTIM_TIMERE_ICR+STM32_HRTIM1_TIMERE_BASE)
+#define STM32_HRTIM1_TIMERE_DIER (STM32_HRTIM_TIMERE_DIER+STM32_HRTIM1_TIMERE_BASE)
+#define STM32_HRTIM1_TIMERE_CNTR (STM32_HRTIM_TIMERE_CNTR+STM32_HRTIM1_TIMERE_BASE)
+#define STM32_HRTIM1_TIMERE_PER (STM32_HRTIM_TIMERE_PER+STM32_HRTIM1_TIMERE_BASE)
+#define STM32_HRTIM1_TIMERE_REP (STM32_HRTIM_TIMERE_REP+STM32_HRTIM1_TIMERE_BASE)
+#define STM32_HRTIM1_TIMERE_CMP1R (STM32_HRTIM_TIMERE_CMP1R+STM32_HRTIM1_TIMERE_BASE)
+#define STM32_HRTIM1_TIMERE_CMP1CR (STM32_HRTIM_TIMERE_CMP1CR+STM32_HRTIM1_TIMERE_BASE)
+#define STM32_HRTIM1_TIMERE_CMP2R (STM32_HRTIM_TIMERE_CMP2R+STM32_HRTIM1_TIMERE_BASE)
+#define STM32_HRTIM1_TIMERE_CMP3R (STM32_HRTIM_TIMERE_CMP3R+STM32_HRTIM1_TIMERE_BASE)
+#define STM32_HRTIM1_TIMERE_CMP4R (STM32_HRTIM_TIMERE_CMP4R+STM32_HRTIM1_TIMERE_BASE)
+#define STM32_HRTIM1_TIMERE_CPT1R (STM32_HRTIM_TIMERE_CMPT1R+STM32_HRTIM1_TIMERE_BASE)
+#define STM32_HRTIM1_TIMERE_CPT2R (STM32_HRTIM_TIMERE_CMPT2R+STM32_HRTIM1_TIMERE_BASE)
+#define STM32_HRTIM1_TIMERE_DTR (STM32_HRTIM_TIMERE_DTR+STM32_HRTIM1_TIMERE_BASE)
+#define STM32_HRTIM1_TIMERE_SET1R (STM32_HRTIM_TIMERE_SET1R+STM32_HRTIM1_TIMERE_BASE)
+#define STM32_HRTIM1_TIMERE_RST1R (STM32_HRTIM_TIMERE_RST1R+STM32_HRTIM1_TIMERE_BASE)
+#define STM32_HRTIM1_TIMERE_SET2R (STM32_HRTIM_TIMERE_SET2R+STM32_HRTIM1_TIMERE_BASE)
+#define STM32_HRTIM1_TIMERE_RST2R (STM32_HRTIM_TIMERE_RST2R+STM32_HRTIM1_TIMERE_BASE)
+#define STM32_HRTIM1_TIMERE_EEFR1 (STM32_HRTIM_TIMERE_EEFR1+STM32_HRTIM1_TIMERE_BASE)
+#define STM32_HRTIM1_TIMERE_EEFR2 (STM32_HRTIM_TIMERE_EEFR2+STM32_HRTIM1_TIMERE_BASE)
+#define STM32_HRTIM1_TIMERE_RSTR (STM32_HRTIM_TIMERE_RSTR+STM32_HRTIM1_TIMERE_BASE)
+#define STM32_HRTIM1_TIMERE_CHPR (STM32_HRTIM_TIMERE_CHPR+STM32_HRTIM1_TIMERE_BASE)
+#define STM32_HRTIM1_TIMERE_CPT1CR (STM32_HRTIM_TIMERE_CPT1CR+STM32_HRTIM1_TIMERE_BASE)
+#define STM32_HRTIM1_TIMERE_CPT2CR (STM32_HRTIM_TIMERE_CPT2CR+STM32_HRTIM1_TIMERE_BASE)
+#define STM32_HRTIM1_TIMERE_OUTR (STM32_HRTIM_TIMERE_OUTR+STM32_HRTIM1_TIMERE_BASE)
+#define STM32_HRTIM1_TIMERE_FLTR (STM32_HRTIM_TIMERE_FLTR+STM32_HRTIM1_TIMERE_BASE)
+
+/* HRTIM1 Common Registers */
+
+#define STM32_HRTIM_CMN_CR1 (STM32_HRTIM_CMN_CR1+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_CR2 (STM32_HRTIM_CMN_CR2+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_ISR (STM32_HRTIM_CMN_ISR+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_ICR (STM32_HRTIM_CMN_ICR+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_IER (STM32_HRTIM_CMN_IER+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_OENR (STM32_HRTIM_CMN_OENR+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_DISR (STM32_HRTIM_CMN_DISR+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_ODSR (STM32_HRTIM_CMN_ODSR+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_BMCR (STM32_HRTIM_CMN_BMCR+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_BMTGR (STM32_HRTIM_CMN_BMTGR+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_BMCMPR (STM32_HRTIM_CMN_MBCMPR+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_BMPER (STM32_HRTIM_CMN_BMPER+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_EECR1 (STM32_HRTIM_CMN_EECR1+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_EECR2 (STM32_HRTIM_CMN_EECR2+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_EECR3 (STM32_HRTIM_CMN_EECR3+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_ADC1R (STM32_HRTIM_CMN_ADC1R+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_ADC2R (STM32_HRTIM_CMN_ADC2R+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_ADC3R (STM32_HRTIM_CMN_ADC3R+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_ADC4R (STM32_HRTIM_CMN_ADC4R+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_DLLCR (STM32_HRTIM_CMN_DLLCR+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_FLTINR1 (STM32_HRTIM_CMN_FTLINR1+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_FLTINR2 (STM32_HRTIM_CMN_FLTINR2+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_BDMUPDR (STM32_HRTIM_CMN_BDMUPDR+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_BDTAUPR (STM32_HRTIM_CMN_BDTAUPR+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_BDTBUPR (STM32_HRTIM_CMN_BDTBUR+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_BDTCUPR (STM32_HRTIM_CMN_BDTCUPR+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_BDTDUPR (STM32_HRTIM_CMN_BDTDUPR+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_BDTEUPR (STM32_HRTIM_CMN_BDTEUPR+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_BDMADR (STM32_HRTIM_CMN_BDMADR+STM32_HRTIM1_CMN_BASE)
+
+/* Register Bitfield Definitions ****************************************************/
+
+/* Master Timer Control Register */
+
+#define HRTIM_MCR_CKPSC_SHIFT 0 /* Bits 0-2: Clock prescaler */
+#define HRTIM_MCR_CKPSC_MASK (7 << HRTIM_MCR_CKPSC_SHIFT)
+# define HRTIM_MCR_CKPSC_NODIV (0 << HRTIM_MCR_CKPSC_SHIFT)
+# define HRTIM_MCR_CKPSC_d2 (1 << HRTIM_MCR_CKPSC_SHIFT)
+# define HRTIM_MCR_CKPSC_d4 (2 << HRTIM_MCR_CKPSC_SHIFT)
+# define HRTIM_MCR_CKPSC_d8 (3 << HRTIM_MCR_CKPSC_SHIFT)
+# define HRTIM_MCR_CKPSC_d16 (4 << HRTIM_MCR_CKPSC_SHIFT)
+# define HRTIM_MCR_CKPSC_d32 (5 << HRTIM_MCR_CKPSC_SHIFT)
+# define HRTIM_MCR_CKPSC_d64 (6 << HRTIM_MCR_CKPSC_SHIFT)
+# define HRTIM_MCR_CKPSC_d128 (7 << HRTIM_MCR_CKPSC_SHIFT)
+#define HRTIM_MCR_CONT (1 << 3) /* Bit 3: Continuous mode */
+#define HRTIM_MCR_RETRIG (1 << 4) /* Bit 4: Re-triggerable mode */
+#define HRTIM_MCR_HALF (1 << 5) /* Bit 5: Half mode */
+#define HRTIM_MCR_SYNCIN_SHIFT 8 /* Bits 8-9: Synchronization input */
+#define HRTIM_MCR_SYNCIN_MASK (3 << HRTIM_MCR_SYNCIN_SHIFT)
+# define HRTIM_MCR_SYNCIN_DIS (0 << HRTIM_MCR_SYNCIN_SHIFT) /* 00 disabled */
+# define HRTIM_MCR_SYNCIN_INTE (2 << HRTIM_MCR_SYNCIN_SHIFT) /* 10: Internal Event */
+# define HRTIM_MCR_SYNCIN_EXTE (3 << HRTIM_MCR_SYNCIN_SHIFT) /* 11: External Event */
+#define HRTIM_MCR_SYNCRST (1 << 10) /* Bit 10: Synchronization Resets Master */
+#define HRTIM_MCR_SYNCSTRTM (1 << 11) /* Bit 11: Synchronization Starts Master */
+#define HRTIM_MCR_SYNCOUT_SHIFT 12 /* Bits 12-13: Synchronization output */
+#define HRTIM_MCR_SYNCOUT_MASK (3 << HRTIM_MCR_SYNCOUT_SHIFT)
+# define HRTIM_MCR_SYNCOUT_DIS (0 << HRTIM_MCR_SYNCOUT_SHIFT) /* 00: Disabled */
+# define HRTIM_MCR_SYNCOUT_POS (2 << HRTIM_MCR_SYNCOUT_SHIFT) /* 10: Positive pulse on SCOUT */
+# define HRTIM_MCR_SYNCOUT_NEG (3 << HRTIM_MCR_SYNCOUT_SHIFT) /* 11: Negative pulse on SCOUT */
+#define HRTIM_MCR_SYNCSRC_SHIFT 14 /* Bits 14-15: Synchronization source*/
+#define HRTIM_MCR_SYNCSRC_MASK (3 << HRTIM_MCR_SYNCSRC_SHIFT)
+# define HRTIM_MCR_SYNCSRC_MSTRT (0 << HRTIM_MCR_SYNCSRC_SHIFT) /* 00: Master timer Start */
+# define HRTIM_MCR_SYNCSRC_MCMP1 (1 << HRTIM_MCR_SYNCSRC_SHIFT) /* 01: Master timer Compare 1 Event */
+# define HRTIM_MCR_SYNCSRC_TASTRT (2 << HRTIM_MCR_SYNCSRC_SHIFT) /* 10: Timer A start/reset */
+# define HRTIM_MCR_SYNCSRC_TACMP1 (3 << HRTIM_MCR_SYNCSRC_SHIFT) /* 11: Timer A Compare 1 Event */
+#define HRTIM_MCR_MCEN (1 << 16) /* Bit 16: Master timer counter enable */
+#define HRTIM_MCR_TACEN (1 << 17) /* Bit 17: Timer A counter enable */
+#define HRTIM_MCR_TBCEN (1 << 18) /* Bit 18: Timer B counter enable */
+#define HRTIM_MCR_TCCEN (1 << 19) /* Bit 19: Timer C counter enable */
+#define HRTIM_MCR_TDCEN (1 << 20) /* Bit 20: Timer D counter enable */
+#define HRTIM_MCR_TECEN (1 << 21) /* Bit 21: Timer E counter enable */
+#define HRTIM_MCR_DACSYNC_SHIFT 25 /* Bits 25-26: DAC Synchronization*/
+#define HRTIM_MCR_DACSYNC_MASK (3 << HRTIM_MCR_DACSYNC_SHIFT)
+# define HRTIM_MCR_DACSYNC_00 (0 << HRTIM_MCR_DACSYNC_SHIFT) /* 00: */
+# define HRTIM_MCR_DACSYNC_01 (1 << HRTIM_MCR_DACSYNC_SHIFT) /* 01: */
+# define HRTIM_MCR_DACSYNC_10 (2 << HRTIM_MCR_DACSYNC_SHIFT) /* 10: */
+# define HRTIM_MCR_DACSYNC_11 (3 << HRTIM_MCR_DACSYNC_SHIFT) /* 11: */
+#define HRTIM_MCR_PREEN (1 << 27) /* Bit 27: Preload enable */
+#define HRTIM_MCR_MREPU (1 << 29) /* Bit 29: Master Timer Repetition Update */
+#define HRTIM_MCR_BRSTDMA_SHIFT 30 /* Bits 30-31: Burs DMA Update*/
+#define HRTIM_MCR_BRSTDMA_MASK (3 << HRTIM_MCR_BRSTDMA_SHIFT)
+# define HRTIM_MCR_BRSTDMA_00 (0 << HRTIM_MCR_BRSTDMA_SHIFT) /* 00 */
+# define HRTIM_MCR_BRSTDMA_01 (1 << HRTIM_MCR_BRSTDMA_SHIFT) /* 01 */
+# define HRTIM_MCR_BRSTDMA_10 (2 << HRTIM_MCR_BRSTDMA_SHIFT) /* 10 */
+
+/* Master Timer Interrupt Status Register */
+
+#define HRTIM_MISR_MCMP1 (1 << 0) /* Bit 0: Master Compare 1 Interrupt Flag */
+#define HRTIM_MISR_MCMP2 (1 << 1) /* Bit 1: Master Compare 2 Interrupt Flag */
+#define HRTIM_MISR_MCMP3 (1 << 2) /* Bit 2: Master Compare 3 Interrupt Flag */
+#define HRTIM_MISR_MCMP4 (1 << 3) /* Bit 3: Master Compare 4 Interrupt Flag */
+#define HRTIM_MISR_MREP (1 << 4) /* Bit 4: Master Repetition Interrupt Flag */
+#define HRTIM_MISR_SYNC (1 << 5) /* Bit 5: Sync Input Interrupt Flag */
+#define HRTIM_MISR_MUPD (1 << 6) /* Bit 6: Master Update Interrupt Flag */
+
+/* Master Timer Interrupt Clear Register */
+
+#define HRTIM_MICR_MCMP1C (1 << 0) /* Bit 0: Master Compare 1 Interrupt Flag Clear */
+#define HRTIM_MICR_MCMP2C (1 << 1) /* Bit 1: Master Compare 2 Interrupt Flag Clear */
+#define HRTIM_MICR_MCMP3C (1 << 2) /* Bit 2: Master Compare 3 Interrupt Flag Clear */
+#define HRTIM_MICR_MCMP4C (1 << 3) /* Bit 3: Master Compare 4 Interrupt Flag Clear */
+#define HRTIM_MICR_MREPC (1 << 4) /* Bit 4: Master Repetition Interrupt Flag Clear */
+#define HRTIM_MICR_SYNCC (1 << 5) /* Bit 5: Sync Input Interrupt Flag Clear */
+#define HRTIM_MICR_MUPDC (1 << 6) /* Bit 6: Master Update Interrupt Flag Clear */
+
+/* Master Timer DMA/Interrupt Clear Register */
+
+#define HRTIM_MDIER_MCMP1IE (1 << 0) /* Bit 0: Master Compare 1 Interrupt Enable */
+#define HRTIM_MDIER_MCMP2IE (1 << 1) /* Bit 1: Master Compare 2 Interrupt Enable */
+#define HRTIM_MDIER_MCMP3IE (1 << 2) /* Bit 2: Master Compare 3 Interrupt Enable */
+#define HRTIM_MDIER_MCMP4IE (1 << 3) /* Bit 3: Master Compare 4 Interrupt Enable */
+#define HRTIM_MDIER_MREPIE (1 << 4) /* Bit 4: Master Repetition Interrupt Enable */
+#define HRTIM_MDIER_SYNCIE (1 << 5) /* Bit 5: Sync Input Interrupt Enable */
+#define HRTIM_MDIER_MUPDIE (1 << 6) /* Bit 6: Master Update Interrupt Enable */
+#define HRTIM_MDIER_MCMP1DE (1 << 16) /* Bit 16 */
+#define HRTIM_MDIER_MCMP2DE (1 << 17) /* Bit 17 */
+#define HRTIM_MDIER_MCMP3DE (1 << 18) /* Bit 18 */
+#define HRTIM_MDIER_MCMP4DE (1 << 19) /* Bit 19 */
+#define HRTIM_MDIER_MREPDE (1 << 20) /* Bit 20 */
+#define HRTIM_MDIER_SYNCDE (1 << 21) /* Bit 21 */
+#define HRTIM_MDIER_MUPDDE (1 << 22) /* Bit 22 */
+
+/* Master Timer Counter Register */
+
+#define HRTIM_MCNTR_SHIFT 0 /* Bits 0-15: Counter Value */
+#define HRTIM_MCNTR_MASK (0xffff << HRTIM_MCNTR_SHIFT)
+
+/* Master Timer Period Register */
+
+#define HRTIM_MPER_SHIFT 0 /* Bits 0-15: Master Timer Period value */
+#define HRTIM_MPER_MASK (0xffff << HRTIM_MPER_SHIFT)
+
+/* Master Timer Repetition Register */
+
+#define HRTIM_MREP_SHIFT 0 /* Bits 0-8: Master Timer Repetition period value */
+#define HRTIM_MREP_MASK (0xff << HRTIM_MREP_SHIFT)
+
+/* Master Timer Compare 1 Register */
+
+#define HRTIM_MCMP1_SHIFT 0 /* Bits 0-15: Master Timer Compare 1 value */
+#define HRTIM_MCMP1_MASK (0xffff << HRTIM_MCMP1_SHIFT)
+
+/* Master Timer Compare 2 Register */
+
+#define HRTIM_MCMP2_SHIFT 0 /* Bits 0-15: Master Timer Compare 2 value */
+#define HRTIM_MCMP2_MASK (0xffff << HRTIM_MCMP2_SHIFT)
+
+/* Master Timer Compare 3 Register */
+
+#define HRTIM_MCMP3_SHIFT 0 /* Bits 0-15: Master Timer Compare 3 value */
+#define HRTIM_MCMP3_MASK (0xffff << HRTIM_MCMP3_SHIFT)
+
+/* Master Timer Compare 4 Register */
+
+#define HRTIM_MCMP4_SHIFT 0 /* Bits 0-15: Master Timer Compare 4 value */
+#define HRTIM_MCMP4_MASK (0xffff << HRTIM_MCMP4_SHIFT)
+
+/* Timer X Control Register */
+
+#define HRTIM_TIMCR_CKPSC_SHIFT 0 /* Bits 0-2: HRTIM Timer X Clock Prescaler */
+#define HRTIM_TIMCR_CKPSC_MASK (7 << HRTIM_TIMCR_CKPSC_SHIFT)
+# define HRTIM_TIMCR_CKPSC_000 (0 << HRTIM_TIMCR_CKPSC_SHIFT) /* 000: */
+# define HRTIM_TIMCR_CKPSC_001 (1 << HRTIM_TIMCR_CKPSC_SHIFT) /* 001: */
+# define HRTIM_TIMCR_CKPSC_010 (2 << HRTIM_TIMCR_CKPSC_SHIFT) /* 010: */
+# define HRTIM_TIMCR_CKPSC_011 (3 << HRTIM_TIMCR_CKPSC_SHIFT) /* 011: */
+# define HRTIM_TIMCR_CKPSC_100 (4 << HRTIM_TIMCR_CKPSC_SHIFT) /* 100: */
+# define HRTIM_TIMCR_CKPSC_101 (5 << HRTIM_TIMCR_CKPSC_SHIFT) /* 101: */
+# define HRTIM_TIMCR_CKPSC_110 (6 << HRTIM_TIMCR_CKPSC_SHIFT) /* 110: */
+# define HRTIM_TIMCR_CKPSC_111 (7 << HRTIM_TIMCR_CKPSC_SHIFT) /* 111: */
+#define HRTIM_TIMCR_CONT (1 << 3) /* Bit 3: Continuous mode */
+#define HRTIM_TIMCR_RETRIG (1 << 4) /* Bit 4: Re-triggerable mode */
+#define HRTIM_TIMCR_HALF (1 << 5) /* Bit 5: Half mode enable */
+#define HRTIM_TIMCR_PSHPLL (1 << 6) /* Bit 6:Push-Pull mode enable */
+#define HRTIM_TIMCR_SYNCRS (1 << 10) /* Bit 10: Synchronization Resets Timer X */
+#define HRTIM_TIMCR_SYNCSTR (1 << 11) /* Bit 11: Synchronization Starts Timer X */
+#define HRTIM_TIMCR_DELCMP2_SHIFT 12 /* Bits 12-13: CMP2 auto-delayed mode */
+#define HRTIM_TIMCR_DELCMP2_MASK (3 << HRTIM_TIMCR_DELCMP2_SHIFT)
+# define HRTIM_TIMCR_DELCMP2_00 (0 << HRTIM_TIMCR_DELCMP2_SHIFT) /* 00: */
+# define HRTIM_TIMCR_DELCMP2_01 (1 << HRTIM_TIMCR_DELCMP2_SHIFT) /* 01: */
+# define HRTIM_TIMCR_DELCMP2_10 (2 << HRTIM_TIMCR_DELCMP2_SHIFT) /* 10: */
+# define HRTIM_TIMCR_DELCMP2_11 (3 << HRTIM_TIMCR_DELCMP2_SHIFT) /* 11: */
+#define HRTIM_TIMCR_DELCMP4_SHIFT 12 /* Bits 14-15: CMP4 auto-delayed mode */
+#define HRTIM_TIMCR_DELCMP4_MASK (3 << HRTIM_TIMCR_DELCMP4_SHIFT)
+# define HRTIM_TIMCR_DELCMP4_00 (0 << HRTIM_TIMCR_DELCMP4_SHIFT) /* 00: */
+# define HRTIM_TIMCR_DELCMP4_01 (1 << HRTIM_TIMCR_DELCMP4_SHIFT) /* 01: */
+# define HRTIM_TIMCR_DELCMP4_10 (2 << HRTIM_TIMCR_DELCMP4_SHIFT) /* 10: */
+# define HRTIM_TIMCR_DELCMP4_11 (3 << HRTIM_TIMCR_DELCMP4_SHIFT) /* 11: */
+#define HRTIM_TIMCR_REPU (1 << 17) /* Bit 17: Timer X Repetition Update */
+#define HRTIM_TIMCR_RSTU (1 << 18) /* Bit 18: Timer X Reset Update */
+#define HRTIM_TIMCR_TAU (1 << 19) /* Bit 19: Timer A Update */
+#define HRTIM_TIMCR_TBU (1 << 20) /* Bit 20: Timer B Update */
+#define HRTIM_TIMCR_TCU (1 << 21) /* Bit 21: Timer C Update */
+#define HRTIM_TIMCR_TDU (1 << 22) /* Bit 22: Timer D Update */
+#define HRTIM_TIMCR_TEU (1 << 23) /* Bit 23: Timer E Update */
+#define HRTIM_TIMCR_MSTU (1 << 24) /* Bit 24: Master Timer Update */
+#define HRTIM_TIMCR_DACSYNC_SHIFT 25 /* Bits 25-26: DAC Synchronization */
+#define HRTIM_TIMCR_DACSYNC_MASK (3 << HRTIM_TIMCR_DACSYNC_SHIFT)
+# define HRTIM_TIMCR_DACSYNC_00 (0 << HRTIM_TIMCR_DACSYNC_SHIFT)
+# define HRTIM_TIMCR_DACSYNC_01 (1 << HRTIM_TIMCR_DACSYNC_SHIFT)
+# define HRTIM_TIMCR_DACSYNC_10 (2 << HRTIM_TIMCR_DACSYNC_SHIFT)
+# define HRTIM_TIMCR_DACSYNC_11 (3 << HRTIM_TIMCR_DACSYNC_SHIFT)
+#define HRTIM_TIMCR_PREEN (1 << 27) /* Bit 27: Preload Enable */
+#define HRTIM_TIMCR_UPDGAT_SHIFT 28 /* Bits 28-31: Update Gating */
+#define HRTIM_TIMCR_UPDGAT_MASK (15 << HRTIM_TIMCR_UPDGAT_SHIFT)
+# define HRTIM_TIMCR_UPDGAT_0000 (0 << HRTIM_TIMCR_UPDGAT_SHIFT) /* 0000: */
+# define HRTIM_TIMCR_UPDGAT_0001 (1 << HRTIM_TIMCR_UPDGAT_SHIFT) /* 0001: */
+# define HRTIM_TIMCR_UPDGAT_0010 (2 << HRTIM_TIMCR_UPDGAT_SHIFT) /* 0010: */
+# define HRTIM_TIMCR_UPDGAT_0011 (3 << HRTIM_TIMCR_UPDGAT_SHIFT) /* 0011: */
+# define HRTIM_TIMCR_UPDGAT_0100 (4 << HRTIM_TIMCR_UPDGAT_SHIFT) /* 0100: */
+# define HRTIM_TIMCR_UPDGAT_0101 (5 << HRTIM_TIMCR_UPDGAT_SHIFT) /* 0101: */
+# define HRTIM_TIMCR_UPDGAT_0110 (6 << HRTIM_TIMCR_UPDGAT_SHIFT) /* 0110: */
+# define HRTIM_TIMCR_UPDGAT_0111 (7 << HRTIM_TIMCR_UPDGAT_SHIFT) /* 0111: */
+# define HRTIM_TIMCR_UPDGAT_1000 (8 << HRTIM_TIMCR_UPDGAT_SHIFT) /* 1000: */
+
+/* Timer X Interrupt Status Register */
+
+#define HRTIM_TIMISR_CMP1 (1 << 0) /* Bit 0: Compare 1 Interrupt Flag */
+#define HRTIM_TIMISR_CMP2 (1 << 1) /* Bit 1: Compare 2 Interrupt Flag */
+#define HRTIM_TIMISR_CMP3 (1 << 2) /* Bit 2: Compare 3 Interrupt Flag */
+#define HRTIM_TIMISR_CMP4 (1 << 3) /* Bit 3: Compare 4 Interrupt Flag */
+#define HRTIM_TIMISR_REP (1 << 4) /* Bit 4: Repetition Interrupt Flag */
+#define HRTIM_TIMISR_UPD (1 << 6) /* Bit 6: Update Interrupt Flag */
+#define HRTIM_TIMISR_CPT1 (1 << 7) /* Bit 7: Capture 1 Interrupt Flag */
+#define HRTIM_TIMISR_CPT2 (1 << 8) /* Bit 8: Capture 2 Interrupt Flag */
+#define HRTIM_TIMISR_SET1 (1 << 9) /* Bit 9: Output 1 Set Interrupt Flag */
+#define HRTIM_TIMISR_RST1 (1 << 10) /* Bit 10: Output 1 Reset Interrupt Flag */
+#define HRTIM_TIMISR_SET2 (1 << 11) /* Bit 11: Output 2 Set Interrupt Flag */
+#define HRTIM_TIMISR_RST2 (1 << 12) /* Bit 12: Output 2 Reset Interrupt Flag */
+#define HRTIM_TIMISR_RST (1 << 13) /* Bit 13: Reset and/or roll-over Interrupt Flag */
+#define HRTIM_TIMISR_DLYPRT (1 << 14) /* Bit 14: Delayed Protection Flag */
+#define HRTIM_TIMISR_CPPSTAT (1 << 16) /* Bit 16: Current Push Pull Status */
+#define HRTIM_TIMISR_IPPSTAT (1 << 17) /* Bit 17: Idle Push Pull Status */
+#define HRTIM_TIMISR_O1STAT (1 << 18) /* Bit 18: Output 1 Status */
+#define HRTIM_TIMISR_O2STAT (1 << 19) /* Bit 19: Output 2 Status */
+#define HRTIM_TIMISR_O1CPY (1 << 20) /* Bit 20: Output 1 Copy */
+#define HRTIM_TIMISR_O2CPY (1 << 21) /* Bit 21: Output 2 Copy */
+
+/* Timer X Interrupt Clear Register */
+
+#define HRTIM_TIMICR_CMP1C (1 << 0) /* Bit 0: Compare 1 Interrupt Flag Clear */
+#define HRTIM_TIMICR_CMP2C (1 << 1) /* Bit 1: Compare 2 Interrupt Flag Clear */
+#define HRTIM_TIMICR_CMP3C (1 << 2) /* Bit 2: Compare 3 Interrupt Flag Clear */
+#define HRTIM_TIMICR_CMP4C (1 << 3) /* Bit 3: Compare 4 Interrupt Flag Clear */
+#define HRTIM_TIMICR_REPC (1 << 4) /* Bit 4: Repetition Interrupt Flag Clear */
+#define HRTIM_TIMICR_UPDC (1 << 6) /* Bit 6: Update Interrupt Flag Clear */
+#define HRTIM_TIMICR_CPT1C (1 << 7) /* Bit 7: Capture 1 Interrupt Flag Clear */
+#define HRTIM_TIMICR_CPT2C (1 << 8) /* Bit 8: Capture 2 Interrupt Flag Clear */
+#define HRTIM_TIMICR_SET1C (1 << 9) /* Bit 9: Output 1 Set Flag Clear */
+#define HRTIM_TIMICR_RST1C (1 << 10) /* Bit 10: Output 1 Reset Flag Clear */
+#define HRTIM_TIMICR_SET2C (1 << 11) /* Bit 11: Output 2 Set Flag Clear */
+#define HRTIM_TIMICR_RST2C (1 << 12) /* Bit 12: Output 2 Reset Flag Clear */
+#define HRTIM_TIMICR_RSTC (1 << 13) /* Bit 13: Reset Interrupt Flag Clear */
+#define HRTIM_TIMICR_DLYPRTC (1 << 14) /* Bit 14: Delayed Protection Flag Clear */
+
+/* Timer X DMA/Interrupt Enable Register */
+
+#define HRTIM_TIMDIER_CMP1IE (1 << 0) /* Bit 0: Compare 1 Interrupt Enable */
+#define HRTIM_TIMDIER_CMP2IE (1 << 1) /* Bit 1: Compare 2 Interrupt Enable */
+#define HRTIM_TIMDIER_CMP3IE (1 << 2) /* Bit 2: Compare 3 Interrupt Enable */
+#define HRTIM_TIMDIER_CMP4IE (1 << 3) /* Bit 3: Compare 4 Interrupt Enable */
+#define HRTIM_TIMDIER_REPIE (1 << 4) /* Bit 4: Repetition Interrupt Enable */
+#define HRTIM_TIMDIER_UPDIE (1 << 6) /* Bit 6: Update Interrupt Enable */
+#define HRTIM_TIMDIER_CPT1IE (1 << 7) /* Bit 7: Capture 1 Interrupt Enable */
+#define HRTIM_TIMDIER_CPT2IE (1 << 8) /* Bit 8: Capture 2 Interrupt Enable */
+#define HRTIM_TIMDIER_SET1IE (1 << 9) /* Bit 9: Output 1 Set Interrupt Enable */
+#define HRTIM_TIMDIER_RST1IE (1 << 10) /* Bit 10: Output 1 Reset Interrupt Enable */
+#define HRTIM_TIMDIER_SET2IE (1 << 11) /* Bit 11: Output 2 Set Interrupt Enable */
+#define HRTIM_TIMDIER_RST2IE (1 << 12) /* Bit 12: Output 2 Reset Interrupt Enable */
+#define HRTIM_TIMDIER_RSTIE (1 << 13) /* Bit 13: Reset/roll-over Interrupt Enable */
+#define HRTIM_TIMDIER_DLYPRTIE (1 << 14) /* Bit 14: Delayed Protection Interrupt Enable */
+#define HRTIM_TIMDIER_CMP1DE (1 << 16) /* Bit 16: Compare 1 DMA Request Enable */
+#define HRTIM_TIMDIER_CMP2DE (1 << 17) /* Bit 17: Compare 2 DMA Request Enable */
+#define HRTIM_TIMDIER_CMP3DE (1 << 18) /* Bit 18: Compare 3 DMA Request Enable */
+#define HRTIM_TIMDIER_CMP4DE (1 << 19) /* Bit 19: Compare 4 DMA Request Enable */
+#define HRTIM_TIMDIER_REPDE (1 << 20) /* Bit 20: Repetition DMA Request Enable */
+#define HRTIM_TIMDIER_UPDDE (1 << 22) /* Bit 22: Update DMA Request Enable */
+#define HRTIM_TIMDIER_CPT1DE (1 << 23) /* Bit 23: Capture 1 DMA Request Enable */
+#define HRTIM_TIMDIER_CPT2DE (1 << 24) /* Bit 24: Capture 2 DMA Request Enable */
+#define HRTIM_TIMDIER_SET1DE (1 << 25) /* Bit 25: Output 1 Set DMA Request Enable */
+#define HRTIM_TIMDIER_RST1DE (1 << 26) /* Bit 26: Output 1 Reset DMA Request Enable */
+#define HRTIM_TIMDIER_SET2DE (1 << 27) /* Bit 27: Output 2 Set DMA Request Enable */
+#define HRTIM_TIMDIER_RST2DE (1 << 28) /* Bit 28: Output 2 Reset DMA Request Enable */
+#define HRTIM_TIMDIER_RSTDE (1 << 29) /* Bit 29: Reset/roll-over DMA Request Enable */
+#define HRTIM_TIMDIER_DLYPRTDE (1 << 30) /* Bit 30: Delayed Protection DMA Request Enable */
+
+/* Timer X Counter Register */
+
+#define HRTIM_TIMCNTR_SHIFT 0 /* Bits 0-15: Timer X Counter Value */
+#define HRTIM_TIMCNTR_MASK (0xffff << HRTIM_TIMCNTR_SHIFT)
+
+/* Timer X Period Register */
+
+#define HRTIM_TIMPER_SHIFT 0 /* Bits 0-15: Timer X Period Value */
+#define HRTIM_TIMPER_MASK (0xffff << HRTIM_TIMPER_SHIFT)
+
+/* Timer X Repetition Register */
+
+#define HRTIM_TIMREP_SHIFT 0 /* Bits 0-8: Timer X Repetition Value */
+#define HRTIM_TIMREP_MASK (0xff << HRTIM_TIMREP_SHIFT)
+
+/* Timer X Compare 1 Register */
+
+#define HRTIM_TIMCMP1_SHIFT 0 /* Bits 0-15: Timer X Compare 1 Value */
+#define HRTIM_TIMCMP1_MASK (0xffff << HRTIM_TIMCMP1_SHIFT)
+
+/* Timer X Compare 1 Compound Register */
+
+#define HRTIM_TIMCMP1C_SHIFT 0 /* Bits 0-15: Timer X Compare 1 Value */
+#define HRTIM_TIMCMP1C_MASK (0xffff << HRTIM_TIMCMP1C_SHIFT)
+#define HRTIM_TIMREPC_SHIFT 0 /* Bits 0-8: Timer X Repetition Value */
+#define HRTIM_TIMREPC_MASK (0xff << HRTIM_TIMCMP1C_SHIFT)
+
+/* Timer X Compare 2 Register */
+
+#define HRTIM_TIMCMP2_SHIFT 0 /* Bits 0-15: Timer X Compare 2 Value */
+#define HRTIM_TIMCMP2_MASK (0xffff << HRTIM_TIMCMP2_SHIFT)
+
+/* Timer X Compare 3 Register */
+
+#define HRTIM_TIMCMP3_SHIFT 0 /* Bits 0-15: Timer X Compare 3 Value */
+#define HRTIM_TIMCMP3_MASK (0xffff << HRTIM_TIMCMP3_SHIFT)
+
+/* Timer X Compare 4 Register */
+
+#define HRTIM_TIMCMP4_SHIFT 0 /* Bits 0-15: Timer X Compare 4 Value */
+#define HRTIM_TIMCMP4_MASK (0xffff << HRTIM_TIMCMP4_SHIFT)
+
+/* Timer X Capture 1 Register */
+
+#define HRTIM_TIMCPT1_SHIFT 0 /* Bits 0-15: Timer X Capture 1 Value */
+#define HRTIM_TIMCPT1_MASK (0xffff << HRTIM_TIMCPT1_SHIFT)
+
+/* Timer X Capture 2 Register */
+
+#define HRTIM_TIMCPT2_SHIFT 0 /* Bits 0-15: Timer X Capture 2 Value */
+#define HRTIM_TIMCPT2_MASK (0xffff << HRTIM_TIMCPT2_SHIFT)
+
+/* Timer X Deadtime Register */
+
+#define HRTIM_TIMDT_DTR_SHIFT 0 /* Bits 0-8: Deadtime Rising Value */
+#define HRTIM_TIMDT_DTR_MASK (0xff << HRTIM_TIMDT_DTR_SHIFT)
+#define HRTIM_TIMDT_SDTR (1 << 9) /* Bit 9: Sign Deadtime Rising Value */
+#define HRTIM_TIMDT_DTPRSC_SHIFT 10 /* Bits 10-12: Deadtime Prescaler */
+#define HRTIM_TIMDT_DTPRSC_MASK (7 << HRTIM_TIMDT_DTPRSC_SHIFT)
+# define HRTIM_TIMDT_DTPRSC_000 (0 << HRTIM_TIMDT_DTPRSC_SHIFT)
+# define HRTIM_TIMDT_DTPRSC_001 (1 << HRTIM_TIMDT_DTPRSC_SHIFT)
+# define HRTIM_TIMDT_DTPRSC_010 (2 << HRTIM_TIMDT_DTPRSC_SHIFT)
+# define HRTIM_TIMDT_DTPRSC_011 (3 << HRTIM_TIMDT_DTPRSC_SHIFT)
+# define HRTIM_TIMDT_DTPRSC_100 (4 << HRTIM_TIMDT_DTPRSC_SHIFT)
+# define HRTIM_TIMDT_DTPRSC_101 (5 << HRTIM_TIMDT_DTPRSC_SHIFT)
+# define HRTIM_TIMDT_DTPRSC_110 (6 << HRTIM_TIMDT_DTPRSC_SHIFT)
+# define HRTIM_TIMDT_DTPRSC_111 (7 << HRTIM_TIMDT_DTPRSC_SHIFT)
+#define HRTIM_TIMDT_DTRSLK (1 << 14) /* Bit 14: Deadtime Rising Sign Lock */
+#define HRTIM_TIMDT_DTRLK (1 << 14) /* Bit 15: Deadtime Rising Lock */
+#define HRTIM_TIMDT_DTF_SHIFT 0 /* Bits 16-24: Deadtime Falling Value */
+#define HRTIM_TIMDT_DTF_MASK (0x1ff << HRTIM_TIMDT_DTF_SHIFT)
+#define HRTIM_TIMDT_SDTF (1 << 25) /* Bit 25: Sign Deadtime Falling Value */
+#define HRTIM_TIMDT_DTFSLK (1 << 30) /* Bit 30: Deadtime Falling Sign Lock */
+#define HRTIM_TIMDT_DTFLK (1 << 31) /* Bit 31: Deadtime Falling Lock */
+
+/* Timer X Output1 Set Register */
+
+#define HRTIM_TIMSET1_SST (1 << 0) /* Bit 0: Software Set trigger */
+#define HRTIM_TIMSET1_RESYNC (1 << 1) /* Bit 1: Timer A resynchronization */
+#define HRTIM_TIMSET1_PER (1 << 2) /* Bit 2: Timer X Period */
+#define HRTIM_TIMSET1_CMP1 (1 << 3) /* Bit 3: Timer X Compare 1 */
+#define HRTIM_TIMSET1_CMP2 (1 << 4) /* Bit 4: Timer X Compare 2 */
+#define HRTIM_TIMSET1_CMP3 (1 << 5) /* Bit 5: Timer X Compare 3 */
+#define HRTIM_TIMSET1_CMP4 (1 << 6) /* Bit 6: Timer X Compare 4 */
+#define HRTIM_TIMSET1_MSTPER (1 << 7) /* Bit 7: Master Period */
+#define HRTIM_TIMSET1_MSTCMP1 (1 << 8) /* Bit 8: Master Compare 1 */
+#define HRTIM_TIMSET1_MSTCMP2 (1 << 9) /* Bit 9: Master Compare 2 */
+#define HRTIM_TIMSET1_MSTCMP3 (1 << 10) /* Bit 10: Master Compare 3 */
+#define HRTIM_TIMSET1_MSTCMP4 (1 << 11) /* Bit 11: Master Compare 4 */
+#define HRTIM_TIMSET1_TIMEVNT1 (1 << 12) /* Bit 12: Timer Event 1 */
+#define HRTIM_TIMSET1_TIMEVNT2 (1 << 13) /* Bit 13: Timer Event 2 */
+#define HRTIM_TIMSET1_TIMEVNT3 (1 << 14) /* Bit 14: Timer Event 3 */
+#define HRTIM_TIMSET1_TIMEVNT4 (1 << 15) /* Bit 15: Timer Event 4 */
+#define HRTIM_TIMSET1_TIMEVNT5 (1 << 16) /* Bit 16: Timer Event 5 */
+#define HRTIM_TIMSET1_TIMEVNT6 (1 << 17) /* Bit 17: Timer Event 6 */
+#define HRTIM_TIMSET1_TIMEVNT7 (1 << 18) /* Bit 18: Timer Event 7 */
+#define HRTIM_TIMSET1_TIMEVNT8 (1 << 19) /* Bit 19: Timer Event 8 */
+#define HRTIM_TIMSET1_TIMEVNT9 (1 << 20) /* Bit 20: Timer Event 9 */
+#define HRTIM_TIMSET1_EXTEVNT1 (1 << 21) /* Bit 21: External Event 1 */
+#define HRTIM_TIMSET1_EXTEVNT2 (1 << 22) /* Bit 22: External Event 2 */
+#define HRTIM_TIMSET1_EXTEVNT3 (1 << 23) /* Bit 23: External Event 3 */
+#define HRTIM_TIMSET1_EXTEVNT4 (1 << 24) /* Bit 24: External Event 4 */
+#define HRTIM_TIMSET1_EXTEVNT5 (1 << 25) /* Bit 25: External Event 5 */
+#define HRTIM_TIMSET1_EXTEVNT6 (1 << 26) /* Bit 26: External Event 6 */
+#define HRTIM_TIMSET1_EXTEVNT7 (1 << 27) /* Bit 27: External Event 7 */
+#define HRTIM_TIMSET1_EXTEVNT8 (1 << 28) /* Bit 28: External Event 8 */
+#define HRTIM_TIMSET1_EXTEVNT9 (1 << 29) /* Bit 29: External Event 9 */
+#define HRTIM_TIMSET1_EXTEVNT10 (1 << 30) /* Bit 30: External Event 10 */
+#define HRTIM_TIMSET1_UPDATE (1 << 31) /* Bit 31: Registers Update */
+
+/* Timer X Output1 Reset Register */
+
+#define HRTIM_TIMRST1_SST (1 << 0) /* Bit 0 */
+#define HRTIM_TIMRST1_RESYNC (1 << 1) /* Bit 1 */
+#define HRTIM_TIMRST1_PER (1 << 2) /* Bit 2 */
+#define HRTIM_TIMRST1_CMP1 (1 << 3) /* Bit 3 */
+#define HRTIM_TIMRST1_CMP2 (1 << 4) /* Bit 4 */
+#define HRTIM_TIMRST1_CMP3 (1 << 5) /* Bit 5 */
+#define HRTIM_TIMRST1_CMP4 (1 << 6) /* Bit 6 */
+#define HRTIM_TIMRST1_MSTPER (1 << 7) /* Bit 7 */
+#define HRTIM_TIMRST1_MSTCMP1 (1 << 8) /* Bit 8 */
+#define HRTIM_TIMRST1_MSTCMP2 (1 << 9) /* Bit 9 */
+#define HRTIM_TIMRST1_MSTCMP3 (1 << 10) /* Bit 10 */
+#define HRTIM_TIMRST1_MSTCMP4 (1 << 11) /* Bit 11 */
+#define HRTIM_TIMRST1_TIMEVNT1 (1 << 12) /* Bit 12 */
+#define HRTIM_TIMRST1_TIMEVNT2 (1 << 13) /* Bit 13 */
+#define HRTIM_TIMRST1_TIMEVNT3 (1 << 14) /* Bit 14 */
+#define HRTIM_TIMRST1_TIMEVNT4 (1 << 15) /* Bit 15 */
+#define HRTIM_TIMRST1_TIMEVNT5 (1 << 16) /* Bit 16 */
+#define HRTIM_TIMRST1_TIMEVNT6 (1 << 17) /* Bit 17 */
+#define HRTIM_TIMRST1_TIMEVNT7 (1 << 18) /* Bit 18 */
+#define HRTIM_TIMRST1_TIMEVNT8 (1 << 19) /* Bit 19 */
+#define HRTIM_TIMRST1_TIMEVNT9 (1 << 20) /* Bit 20 */
+#define HRTIM_TIMRST1_EXTEVNT1 (1 << 21) /* Bit 21 */
+#define HRTIM_TIMRST1_EXTEVNT2 (1 << 22) /* Bit 22 */
+#define HRTIM_TIMRST1_EXTEVNT3 (1 << 23) /* Bit 23 */
+#define HRTIM_TIMRST1_EXTEVNT4 (1 << 24) /* Bit 24 */
+#define HRTIM_TIMRST1_EXTEVNT5 (1 << 25) /* Bit 25 */
+#define HRTIM_TIMRST1_EXTEVNT6 (1 << 26) /* Bit 26 */
+#define HRTIM_TIMRST1_EXTEVNT7 (1 << 27) /* Bit 27 */
+#define HRTIM_TIMRST1_EXTEVNT8 (1 << 28) /* Bit 28 */
+#define HRTIM_TIMRST1_EXTEVNT9 (1 << 29) /* Bit 29 */
+#define HRTIM_TIMRST1_EXTEVNT10 (1 << 30) /* Bit 30 */
+#define HRTIM_TIMRST1_UPDATE (1 << 31) /* Bit 31 */
+
+/* Timer X Output2 Set Register */
+
+#define HRTIM_TIMSET2_SST (1 << 0) /* Bit 0 */
+#define HRTIM_TIMSET2_RESYNC (1 << 1) /* Bit 1 */
+#define HRTIM_TIMSET2_PER (1 << 2) /* Bit 2 */
+#define HRTIM_TIMSET2_CMP1 (1 << 3) /* Bit 3 */
+#define HRTIM_TIMSET2_CMP2 (1 << 4) /* Bit 4 */
+#define HRTIM_TIMSET2_CMP3 (1 << 5) /* Bit 5 */
+#define HRTIM_TIMSET2_CMP4 (1 << 6) /* Bit 6 */
+#define HRTIM_TIMSET2_MSTPER (1 << 7) /* Bit 7 */
+#define HRTIM_TIMSET2_MSTCMP1 (1 << 8) /* Bit 8 */
+#define HRTIM_TIMSET2_MSTCMP2 (1 << 9) /* Bit 9 */
+#define HRTIM_TIMSET2_MSTCMP3 (1 << 10) /* Bit 10 */
+#define HRTIM_TIMSET2_MSTCMP4 (1 << 11) /* Bit 11 */
+#define HRTIM_TIMSET2_TIMEVNT1 (1 << 12) /* Bit 12 */
+#define HRTIM_TIMSET2_TIMEVNT2 (1 << 13) /* Bit 13 */
+#define HRTIM_TIMSET2_TIMEVNT3 (1 << 14) /* Bit 14 */
+#define HRTIM_TIMSET2_TIMEVNT4 (1 << 15) /* Bit 15 */
+#define HRTIM_TIMSET2_TIMEVNT5 (1 << 16) /* Bit 16 */
+#define HRTIM_TIMSET2_TIMEVNT6 (1 << 17) /* Bit 17 */
+#define HRTIM_TIMSET2_TIMEVNT7 (1 << 18) /* Bit 18 */
+#define HRTIM_TIMSET2_TIMEVNT8 (1 << 19) /* Bit 19 */
+#define HRTIM_TIMSET2_TIMEVNT9 (1 << 20) /* Bit 20 */
+#define HRTIM_TIMSET2_EXTEVNT1 (1 << 21) /* Bit 21 */
+#define HRTIM_TIMSET2_EXTEVNT2 (1 << 22) /* Bit 22 */
+#define HRTIM_TIMSET2_EXTEVNT3 (1 << 23) /* Bit 23 */
+#define HRTIM_TIMSET2_EXTEVNT4 (1 << 24) /* Bit 24 */
+#define HRTIM_TIMSET2_EXTEVNT5 (1 << 25) /* Bit 25 */
+#define HRTIM_TIMSET2_EXTEVNT6 (1 << 26) /* Bit 26 */
+#define HRTIM_TIMSET2_EXTEVNT7 (1 << 27) /* Bit 27 */
+#define HRTIM_TIMSET2_EXTEVNT8 (1 << 28) /* Bit 28 */
+#define HRTIM_TIMSET2_EXTEVNT9 (1 << 29) /* Bit 29 */
+#define HRTIM_TIMSET2_EXTEVNT10 (1 << 30) /* Bit 30 */
+#define HRTIM_TIMSET2_UPDATE (1 << 31) /* Bit 31 */
+
+/* Timer X Output2 Reset Register */
+
+#define HRTIM_TIMRST2_SST (1 << 0) /* Bit 0 */
+#define HRTIM_TIMRST2_RESYNC (1 << 1) /* Bit 1 */
+#define HRTIM_TIMRST2_PER (1 << 2) /* Bit 2 */
+#define HRTIM_TIMRST2_CMP1 (1 << 3) /* Bit 3 */
+#define HRTIM_TIMRST2_CMP2 (1 << 4) /* Bit 4 */
+#define HRTIM_TIMRST2_CMP3 (1 << 5) /* Bit 5 */
+#define HRTIM_TIMRST2_CMP4 (1 << 6) /* Bit 6 */
+#define HRTIM_TIMRST2_MSTPER (1 << 7) /* Bit 7 */
+#define HRTIM_TIMRST2_MSTCMP1 (1 << 8) /* Bit 8 */
+#define HRTIM_TIMRST2_MSTCMP2 (1 << 9) /* Bit 9 */
+#define HRTIM_TIMRST2_MSTCMP3 (1 << 10) /* Bit 10 */
+#define HRTIM_TIMRST2_MSTCMP4 (1 << 11) /* Bit 11 */
+#define HRTIM_TIMRST2_TIMEVNT1 (1 << 12) /* Bit 12 */
+#define HRTIM_TIMRST2_TIMEVNT2 (1 << 13) /* Bit 13 */
+#define HRTIM_TIMRST2_TIMEVNT3 (1 << 14) /* Bit 14 */
+#define HRTIM_TIMRST2_TIMEVNT4 (1 << 15) /* Bit 15 */
+#define HRTIM_TIMRST2_TIMEVNT5 (1 << 16) /* Bit 16 */
+#define HRTIM_TIMRST2_TIMEVNT6 (1 << 17) /* Bit 17 */
+#define HRTIM_TIMRST2_TIMEVNT7 (1 << 18) /* Bit 18 */
+#define HRTIM_TIMRST2_TIMEVNT8 (1 << 19) /* Bit 19 */
+#define HRTIM_TIMRST2_TIMEVNT9 (1 << 20) /* Bit 20 */
+#define HRTIM_TIMRST2_EXTEVNT1 (1 << 21) /* Bit 21 */
+#define HRTIM_TIMRST2_EXTEVNT2 (1 << 22) /* Bit 22 */
+#define HRTIM_TIMRST2_EXTEVNT3 (1 << 23) /* Bit 23 */
+#define HRTIM_TIMRST2_EXTEVNT4 (1 << 24) /* Bit 24 */
+#define HRTIM_TIMRST2_EXTEVNT5 (1 << 25) /* Bit 25 */
+#define HRTIM_TIMRST2_EXTEVNT6 (1 << 26) /* Bit 26 */
+#define HRTIM_TIMRST2_EXTEVNT7 (1 << 27) /* Bit 27 */
+#define HRTIM_TIMRST2_EXTEVNT8 (1 << 28) /* Bit 28 */
+#define HRTIM_TIMRST2_EXTEVNT9 (1 << 29) /* Bit 29 */
+#define HRTIM_TIMRST2_EXTEVNT10 (1 << 30) /* Bit 30 */
+#define HRTIM_TIMRST2_UPDATE (1 << 31) /* Bit 31 */
+
+/* Timer X External Event Filtering Register 1 */
+
+#define HRTIM_TIMEEF1_EE1LTCH (1 << 0) /* Bit 0: External Event 1 Latch */
+#define HRTIM_TIMEEF1_EE1FLT_SHIFT 1 /* Bits 1-4: External Event 1 Filter */
+#define HRTIM_TIMEEF1_EE1FLT_MASK (15 << HRTIM_TIMEEF1_EE1FLT_SHIFT)
+# define HRTIM_TIMEEF1_EE1FLT_0 (0 << HRTIM_TIMEEF1_EE1FLT_SHIFT) /* 0000: No filtering */
+# define HRTIM_TIMEEF1_EE1FLT_1 (1 << HRTIM_TIMEEF1_EE1FLT_SHIFT) /* 0001: Blanking from counter reset/roll-over to Compare 1 */
+# define HRTIM_TIMEEF1_EE1FLT_2 (2 << HRTIM_TIMEEF1_EE1FLT_SHIFT) /* 0010: Blanking from counter reset/roll-over to Compare 2 */
+# define HRTIM_TIMEEF1_EE1FLT_3 (3 << HRTIM_TIMEEF1_EE1FLT_SHIFT) /* 0011: Blanking from counter reset/roll-over to Compare 3 */
+# define HRTIM_TIMEEF1_EE1FLT_4 (4 << HRTIM_TIMEEF1_EE1FLT_SHIFT) /* 0100: Blanking from counter reset/roll-over to Compare 4 */
+# define HRTIM_TIMEEF1_EE1FLT_5 (5 << HRTIM_TIMEEF1_EE1FLT_SHIFT) /* 0101: Blanking from TIMFLTR1 source */
+# define HRTIM_TIMEEF1_EE1FLT_6 (6 << HRTIM_TIMEEF1_EE1FLT_SHIFT) /* 0110: Blanking from TIMFLTR2 source */
+# define HRTIM_TIMEEF1_EE1FLT_7 (7 << HRTIM_TIMEEF1_EE1FLT_SHIFT) /* 0111: Blanking from TIMFLTR3 source */
+# define HRTIM_TIMEEF1_EE1FLT_8 (8 << HRTIM_TIMEEF1_EE1FLT_SHIFT) /* 1000: Blanking from TIMFLTR4 source */
+# define HRTIM_TIMEEF1_EE1FLT_9 (9 << HRTIM_TIMEEF1_EE1FLT_SHIFT) /* 1001: Blanking from TIMFLTR5 source */
+# define HRTIM_TIMEEF1_EE1FLT_10 (10 << HRTIM_TIMEEF1_EE1FLT_SHIFT) /* 1010: Blanking from TIMFLTR6 source */
+# define HRTIM_TIMEEF1_EE1FLT_11 (11 << HRTIM_TIMEEF1_EE1FLT_SHIFT) /* 1011: Blanking from TIMFLTR7 source */
+# define HRTIM_TIMEEF1_EE1FLT_12 (12 << HRTIM_TIMEEF1_EE1FLT_SHIFT) /* 1100: Blanking from TIMFLTR8 source */
+# define HRTIM_TIMEEF1_EE1FLT_13 (13 << HRTIM_TIMEEF1_EE1FLT_SHIFT) /* 1101: Windowing from counter reset/roll-over to Compare 2 */
+# define HRTIM_TIMEEF1_EE1FLT_14 (14 << HRTIM_TIMEEF1_EE1FLT_SHIFT) /* 1110: Windowing from counter reset/roll-over to Compare 3 */
+# define HRTIM_TIMEEF1_EE1FLT_15 (15 << HRTIM_TIMEEF1_EE1FLT_SHIFT) /* 1111: Windowing from TIMWIN source */
+#define HRTIM_TIMEEF1_EE2LTCH (1 << 6) /* Bit 6: External Event 2 Lack */
+#define HRTIM_TIMEEF1_EE2FLT_SHIFT 7 /* Bits 7-10: Externl Event 2 Filter */
+#define HRTIM_TIMEEF1_EE2FLT_MASK (15 << HRTIM_TIMEEF1_EE2FLT_SHIFT)
+# define HRTIM_TIMEEF1_EE2FLT_0 (0 << HRTIM_TIMEEF1_EE2FLT_SHIFT) /* 0000: No filtering */
+# define HRTIM_TIMEEF1_EE2FLT_1 (1 << HRTIM_TIMEEF1_EE2FLT_SHIFT) /* 0001: Blanking from counter reset/roll-over to Compare 1 */
+# define HRTIM_TIMEEF1_EE2FLT_2 (2 << HRTIM_TIMEEF1_EE2FLT_SHIFT) /* 0010: Blanking from counter reset/roll-over to Compare 2 */
+# define HRTIM_TIMEEF1_EE2FLT_2 (3 << HRTIM_TIMEEF1_EE2FLT_SHIFT) /* 0011: Blanking from counter reset/roll-over to Compare 3 */
+# define HRTIM_TIMEEF1_EE2FLT_4 (4 << HRTIM_TIMEEF1_EE2FLT_SHIFT) /* 0100: Blanking from counter reset/roll-over to Compare 4 */
+# define HRTIM_TIMEEF1_EE2FLT_5 (5 << HRTIM_TIMEEF1_EE2FLT_SHIFT) /* 0101: Blanking from TIMFLTR1 source */
+# define HRTIM_TIMEEF1_EE2FLT_6 (6 << HRTIM_TIMEEF1_EE2FLT_SHIFT) /* 0110: Blanking from TIMFLTR2 source */
+# define HRTIM_TIMEEF1_EE2FLT_7 (7 << HRTIM_TIMEEF1_EE2FLT_SHIFT) /* 0111: Blanking from TIMFLTR3 source */
+# define HRTIM_TIMEEF1_EE2FLT_8 (8 << HRTIM_TIMEEF1_EE2FLT_SHIFT) /* 1000: Blanking from TIMFLTR4 source */
+# define HRTIM_TIMEEF1_EE2FLT_9 (9 << HRTIM_TIMEEF1_EE2FLT_SHIFT) /* 1001: Blanking from TIMFLTR5 source */
+# define HRTIM_TIMEEF1_EE2FLT_10 (10 << HRTIM_TIMEEF1_EE2FLT_SHIFT) /* 1010: Blanking from TIMFLTR6 source */
+# define HRTIM_TIMEEF1_EE2FLT_11 (11 << HRTIM_TIMEEF1_EE2FLT_SHIFT) /* 1011: Blanking from TIMFLTR7 source */
+# define HRTIM_TIMEEF1_EE2FLT_12 (12 << HRTIM_TIMEEF1_EE2FLT_SHIFT) /* 1100: Blanking from TIMFLTR8 source */
+# define HRTIM_TIMEEF1_EE2FLT_13 (13 << HRTIM_TIMEEF1_EE2FLT_SHIFT) /* 1101: Windowing from counter reset/roll-over to Compare 2 */
+# define HRTIM_TIMEEF1_EE2FLT_14 (14 << HRTIM_TIMEEF1_EE2FLT_SHIFT) /* 1110: Windowing from counter reset/roll-over to Compare 3 */
+# define HRTIM_TIMEEF1_EE2FLT_15 (15 << HRTIM_TIMEEF1_EE2FLT_SHIFT) /* 1111: Windowing from TIMWIN source */
+#define HRTIM_TIMEEF1_EE3LTCH (1 << 12) /* Bit 12: External Event 3 Lack */
+#define HRTIM_TIMEEF1_EE3FLT_SHIFT 13 /* Bits 13-16: Externl Event 3 Filter */
+#define HRTIM_TIMEEF1_EE3FLT_MASK (15 << HRTIM_TIMEEF1_EE3FLT_SHIFT)
+# define HRTIM_TIMEEF1_EE3FLT_0 (0 << HRTIM_TIMEEF1_EE3FLT_SHIFT) /* 0000: No filtering */
+# define HRTIM_TIMEEF1_EE3FLT_1 (1 << HRTIM_TIMEEF1_EE3FLT_SHIFT) /* 0001: Blanking from counter reset/roll-over to Compare 1 */
+# define HRTIM_TIMEEF1_EE3FLT_2 (2 << HRTIM_TIMEEF1_EE3FLT_SHIFT) /* 0010: Blanking from counter reset/roll-over to Compare 2 */
+# define HRTIM_TIMEEF1_EE3FLT_3 (3 << HRTIM_TIMEEF1_EE3FLT_SHIFT) /* 0011: Blanking from counter reset/roll-over to Compare 3 */
+# define HRTIM_TIMEEF1_EE3FLT_4 (4 << HRTIM_TIMEEF1_EE3FLT_SHIFT) /* 0100: Blanking from counter reset/roll-over to Compare 4 */
+# define HRTIM_TIMEEF1_EE3FLT_5 (5 << HRTIM_TIMEEF1_EE3FLT_SHIFT) /* 0101: Blanking from TIMFLTR1 source */
+# define HRTIM_TIMEEF1_EE3FLT_6 (6 << HRTIM_TIMEEF1_EE3FLT_SHIFT) /* 0110: Blanking from TIMFLTR2 source */
+# define HRTIM_TIMEEF1_EE3FLT_7 (7 << HRTIM_TIMEEF1_EE3FLT_SHIFT) /* 0111: Blanking from TIMFLTR3 source */
+# define HRTIM_TIMEEF1_EE3FLT_8 (8 << HRTIM_TIMEEF1_EE3FLT_SHIFT) /* 1000: Blanking from TIMFLTR4 source */
+# define HRTIM_TIMEEF1_EE3FLT_9 (9 << HRTIM_TIMEEF1_EE3FLT_SHIFT) /* 1001: Blanking from TIMFLTR5 source */
+# define HRTIM_TIMEEF1_EE3FLT_10 (10 << HRTIM_TIMEEF1_EE3FLT_SHIFT) /* 1010: Blanking from TIMFLTR6 source */
+# define HRTIM_TIMEEF1_EE3FLT_11 (11 << HRTIM_TIMEEF1_EE3FLT_SHIFT) /* 1011: Blanking from TIMFLTR7 source */
+# define HRTIM_TIMEEF1_EE3FLT_12 (12 << HRTIM_TIMEEF1_EE3FLT_SHIFT) /* 1100: Blanking from TIMFLTR8 source */
+# define HRTIM_TIMEEF1_EE3FLT_13 (13 << HRTIM_TIMEEF1_EE3FLT_SHIFT) /* 1101: Windowing from counter reset/roll-over to Compare 2 */
+# define HRTIM_TIMEEF1_EE3FLT_14 (14 << HRTIM_TIMEEF1_EE3FLT_SHIFT) /* 1110: Windowing from counter reset/roll-over to Compare 3 */
+# define HRTIM_TIMEEF1_EE3FLT_15 (15 << HRTIM_TIMEEF1_EE3FLT_SHIFT) /* 1111: Windowing from TIMWIN source */
+#define HRTIM_TIMEEF1_EE4LTCH (1 << 18) /* Bit 18: External Event 4 Lack */
+#define HRTIM_TIMEEF1_EE4FLT_SHIFT 19 /* Bits 19-22: Externl Event 4 Filter */
+#define HRTIM_TIMEEF1_EE4FLT_MASK (15 << HRTIM_TIMEEF1_EE4FLT_SHIFT)
+# define HRTIM_TIMEEF1_EE4FLT_0 (0 << HRTIM_TIMEEF1_EE4FLT_SHIFT) /* 0000: No filtering */
+# define HRTIM_TIMEEF1_EE4FLT_1 (1 << HRTIM_TIMEEF1_EE4FLT_SHIFT) /* 0001: Blanking from counter reset/roll-over to Compare 1 */
+# define HRTIM_TIMEEF1_EE4FLT_2 (2 << HRTIM_TIMEEF1_EE4FLT_SHIFT) /* 0010: Blanking from counter reset/roll-over to Compare 2 */
+# define HRTIM_TIMEEF1_EE4FLT_3 (3 << HRTIM_TIMEEF1_EE4FLT_SHIFT) /* 0011: Blanking from counter reset/roll-over to Compare 3 */
+# define HRTIM_TIMEEF1_EE4FLT_4 (4 << HRTIM_TIMEEF1_EE4FLT_SHIFT) /* 0100: Blanking from counter reset/roll-over to Compare 4 */
+# define HRTIM_TIMEEF1_EE4FLT_5 (5 << HRTIM_TIMEEF1_EE4FLT_SHIFT) /* 0101: Blanking from TIMFLTR1 source */
+# define HRTIM_TIMEEF1_EE4FLT_6 (6 << HRTIM_TIMEEF1_EE4FLT_SHIFT) /* 0110: Blanking from TIMFLTR2 source */
+# define HRTIM_TIMEEF1_EE4FLT_7 (7 << HRTIM_TIMEEF1_EE4FLT_SHIFT) /* 0111: Blanking from TIMFLTR3 source */
+# define HRTIM_TIMEEF1_EE4FLT_8 (8 << HRTIM_TIMEEF1_EE4FLT_SHIFT) /* 1000: Blanking from TIMFLTR4 source */
+# define HRTIM_TIMEEF1_EE4FLT_9 (9 << HRTIM_TIMEEF1_EE4FLT_SHIFT) /* 1001: Blanking from TIMFLTR5 source */
+# define HRTIM_TIMEEF1_EE4FLT_10 (10 << HRTIM_TIMEEF1_EE4FLT_SHIFT) /* 1010: Blanking from TIMFLTR6 source */
+# define HRTIM_TIMEEF1_EE4FLT_11 (11 << HRTIM_TIMEEF1_EE4FLT_SHIFT) /* 1011: Blanking from TIMFLTR7 source */
+# define HRTIM_TIMEEF1_EE4FLT_12 (12 << HRTIM_TIMEEF1_EE4FLT_SHIFT) /* 1100: Blanking from TIMFLTR8 source */
+# define HRTIM_TIMEEF1_EE4FLT_13 (13 << HRTIM_TIMEEF1_EE4FLT_SHIFT) /* 1101: Windowing from counter reset/roll-over to Compare 2 */
+# define HRTIM_TIMEEF1_EE4FLT_14 (14 << HRTIM_TIMEEF1_EE4FLT_SHIFT) /* 1110: Windowing from counter reset/roll-over to Compare 3 */
+# define HRTIM_TIMEEF1_EE4FLT_15 (15 << HRTIM_TIMEEF1_EE4FLT_SHIFT) /* 1111: Windowing from TIMWIN source */
+#define HRTIM_TIMEEF1_EE5LTCH (1 << 24) /* Bit 24: External Event 5 Lack */
+#define HRTIM_TIMEEF1_EE5FLT_SHIFT 25 /* Bits 25-28: Externl Event 5 Filter */
+#define HRTIM_TIMEEF1_EE5FLT_MASK (15 << HRTIM_TIMEEF1_EE5FLT_SHIFT)
+# define HRTIM_TIMEEF1_EE5FLT_0 (0 << HRTIM_TIMEEF1_EE5FLT_SHIFT) /* 0000: No filtering */
+# define HRTIM_TIMEEF1_EE5FLT_1 (1 << HRTIM_TIMEEF1_EE5FLT_SHIFT) /* 0001: Blanking from counter reset/roll-over to Compare 1 */
+# define HRTIM_TIMEEF1_EE5FLT_2 (2 << HRTIM_TIMEEF1_EE5FLT_SHIFT) /* 0010: Blanking from counter reset/roll-over to Compare 2 */
+# define HRTIM_TIMEEF1_EE5FLT_3 (3 << HRTIM_TIMEEF1_EE5FLT_SHIFT) /* 0011: Blanking from counter reset/roll-over to Compare 3 */
+# define HRTIM_TIMEEF1_EE5FLT_4 (4 << HRTIM_TIMEEF1_EE5FLT_SHIFT) /* 0100: Blanking from counter reset/roll-over to Compare 4 */
+# define HRTIM_TIMEEF1_EE5FLT_5 (5 << HRTIM_TIMEEF1_EE5FLT_SHIFT) /* 0101: Blanking from TIMFLTR1 source */
+# define HRTIM_TIMEEF1_EE5FLT_6 (6 << HRTIM_TIMEEF1_EE5FLT_SHIFT) /* 0110: Blanking from TIMFLTR2 source */
+# define HRTIM_TIMEEF1_EE5FLT_7 (7 << HRTIM_TIMEEF1_EE5FLT_SHIFT) /* 0111: Blanking from TIMFLTR3 source */
+# define HRTIM_TIMEEF1_EE5FLT_8 (8 << HRTIM_TIMEEF1_EE5FLT_SHIFT) /* 1000: Blanking from TIMFLTR4 source */
+# define HRTIM_TIMEEF1_EE5FLT_9 (9 << HRTIM_TIMEEF1_EE5FLT_SHIFT) /* 1001: Blanking from TIMFLTR5 source */
+# define HRTIM_TIMEEF1_EE5FLT_10 (10 << HRTIM_TIMEEF1_EE5FLT_SHIFT) /* 1010: Blanking from TIMFLTR6 source */
+# define HRTIM_TIMEEF1_EE5FLT_11 (11 << HRTIM_TIMEEF1_EE5FLT_SHIFT) /* 1011: Blanking from TIMFLTR7 source */
+# define HRTIM_TIMEEF1_EE5FLT_12 (12 << HRTIM_TIMEEF1_EE5FLT_SHIFT) /* 1100: Blanking from TIMFLTR8 source */
+# define HRTIM_TIMEEF1_EE5FLT_13 (13 << HRTIM_TIMEEF1_EE5FLT_SHIFT) /* 1101: Windowing from counter reset/roll-over to Compare 2 */
+# define HRTIM_TIMEEF1_EE5FLT_14 (14 << HRTIM_TIMEEF1_EE5FLT_SHIFT) /* 1110: Windowing from counter reset/roll-over to Compare 3 */
+# define HRTIM_TIMEEF1_EE5FLT_15 (15 << HRTIM_TIMEEF1_EE5FLT_SHIFT) /* 1111: Windowing from TIMWIN source */
+
+/* Timer X External Event Filtering Register 2 */
+
+#define HRTIM_TIMEEF2_EE6LTCH (1 << 0) /* Bit 0 */
+#define HRTIM_TIMEEF2_EE6FLT_SHIFT 1 /* Bits 1-4 */
+#define HRTIM_TIMEEF2_EE6FLT_MASK (15 << HRTIM_TIMEEF2_EE6FLT_SHIFT)
+# define HRTIM_TIMEEF2_EE6FLT_0 (0 << HRTIM_TIMEEF2_EE6FLT_SHIFT) /* 0000: No filtering */
+# define HRTIM_TIMEEF2_EE6FLT_1 (1 << HRTIM_TIMEEF2_EE6FLT_SHIFT) /* 0001: Blanking from counter reset/roll-over to Compare 1 */
+# define HRTIM_TIMEEF2_EE6FLT_2 (2 << HRTIM_TIMEEF2_EE6FLT_SHIFT) /* 0010: Blanking from counter reset/roll-over to Compare 2 */
+# define HRTIM_TIMEEF2_EE6FLT_3 (3 << HRTIM_TIMEEF2_EE6FLT_SHIFT) /* 0011: Blanking from counter reset/roll-over to Compare 3 */
+# define HRTIM_TIMEEF2_EE6FLT_4 (4 << HRTIM_TIMEEF2_EE6FLT_SHIFT) /* 0100: Blanking from counter reset/roll-over to Compare 4 */
+# define HRTIM_TIMEEF2_EE6FLT_5 (5 << HRTIM_TIMEEF2_EE6FLT_SHIFT) /* 0101: Blanking from TIMFLTR1 source */
+# define HRTIM_TIMEEF2_EE6FLT_6 (6 << HRTIM_TIMEEF2_EE6FLT_SHIFT) /* 0110: Blanking from TIMFLTR2 source */
+# define HRTIM_TIMEEF2_EE6FLT_7 (7 << HRTIM_TIMEEF2_EE6FLT_SHIFT) /* 0111: Blanking from TIMFLTR3 source */
+# define HRTIM_TIMEEF2_EE6FLT_8 (8 << HRTIM_TIMEEF2_EE6FLT_SHIFT) /* 1000: Blanking from TIMFLTR4 source */
+# define HRTIM_TIMEEF2_EE6FLT_9 (9 << HRTIM_TIMEEF2_EE6FLT_SHIFT) /* 1001: Blanking from TIMFLTR5 source */
+# define HRTIM_TIMEEF2_EE6FLT_10 (10 << HRTIM_TIMEEF2_EE6FLT_SHIFT) /* 1010: Blanking from TIMFLTR6 source */
+# define HRTIM_TIMEEF2_EE6FLT_11 (11 << HRTIM_TIMEEF2_EE6FLT_SHIFT) /* 1011: Blanking from TIMFLTR7 source */
+# define HRTIM_TIMEEF2_EE6FLT_12 (12 << HRTIM_TIMEEF2_EE6FLT_SHIFT) /* 1100: Blanking from TIMFLTR8 source */
+# define HRTIM_TIMEEF2_EE6FLT_13 (13 << HRTIM_TIMEEF2_EE6FLT_SHIFT) /* 1101: Windowing from counter reset/roll-over to Compare 2 */
+# define HRTIM_TIMEEF2_EE6FLT_14 (14 << HRTIM_TIMEEF2_EE6FLT_SHIFT) /* 1110: Windowing from counter reset/roll-over to Compare 3 */
+# define HRTIM_TIMEEF2_EE6FLT_15 (15 << HRTIM_TIMEEF2_EE6FLT_SHIFT) /* 1111: Windowing from TIMWIN source */
+#define HRTIM_TIMEEF2_EE7LTCH (1 << 6) /* Bit 6 */
+#define HRTIM_TIMEEF2_EE7FLT_SHIFT 7 /* Bits 7-10 */
+#define HRTIM_TIMEEF2_EE7FLT_MASK (15 << HRTIM_TIMEEF2_EE7FLT_SHIFT)
+# define HRTIM_TIMEEF2_EE7FLT_0 (0 << HRTIM_TIMEEF2_EE7FLT_SHIFT) /* 0000: No filtering */
+# define HRTIM_TIMEEF2_EE7FLT_1 (1 << HRTIM_TIMEEF2_EE7FLT_SHIFT) /* 0001: Blanking from counter reset/roll-over to Compare 1 */
+# define HRTIM_TIMEEF2_EE7FLT_2 (2 << HRTIM_TIMEEF2_EE7FLT_SHIFT) /* 0010: Blanking from counter reset/roll-over to Compare 2 */
+# define HRTIM_TIMEEF2_EE7FLT_3 (3 << HRTIM_TIMEEF2_EE7FLT_SHIFT) /* 0011: Blanking from counter reset/roll-over to Compare 3 */
+# define HRTIM_TIMEEF2_EE7FLT_4 (4 << HRTIM_TIMEEF2_EE7FLT_SHIFT) /* 0100: Blanking from counter reset/roll-over to Compare 4 */
+# define HRTIM_TIMEEF2_EE7FLT_5 (5 << HRTIM_TIMEEF2_EE7FLT_SHIFT) /* 0101: Blanking from TIMFLTR1 source */
+# define HRTIM_TIMEEF2_EE7FLT_6 (6 << HRTIM_TIMEEF2_EE7FLT_SHIFT) /* 0110: Blanking from TIMFLTR2 source */
+# define HRTIM_TIMEEF2_EE7FLT_7 (7 << HRTIM_TIMEEF2_EE7FLT_SHIFT) /* 0111: Blanking from TIMFLTR3 source */
+# define HRTIM_TIMEEF2_EE7FLT_8 (8 << HRTIM_TIMEEF2_EE7FLT_SHIFT) /* 1000: Blanking from TIMFLTR4 source */
+# define HRTIM_TIMEEF2_EE7FLT_9 (9 << HRTIM_TIMEEF2_EE7FLT_SHIFT) /* 1001: Blanking from TIMFLTR5 source */
+# define HRTIM_TIMEEF2_EE7FLT_10 (10 << HRTIM_TIMEEF2_EE7FLT_SHIFT) /* 1010: Blanking from TIMFLTR6 source */
+# define HRTIM_TIMEEF2_EE7FLT_11 (11 << HRTIM_TIMEEF2_EE7FLT_SHIFT) /* 1011: Blanking from TIMFLTR7 source */
+# define HRTIM_TIMEEF2_EE7FLT_12 (12 << HRTIM_TIMEEF2_EE7FLT_SHIFT) /* 1100: Blanking from TIMFLTR8 source */
+# define HRTIM_TIMEEF2_EE7FLT_13 (13 << HRTIM_TIMEEF2_EE7FLT_SHIFT) /* 1101: Windowing from counter reset/roll-over to Compare 2 */
+# define HRTIM_TIMEEF2_EE7FLT_14 (14 << HRTIM_TIMEEF2_EE7FLT_SHIFT) /* 1110: Windowing from counter reset/roll-over to Compare 3 */
+# define HRTIM_TIMEEF2_EE7FLT_15 (15 << HRTIM_TIMEEF2_EE7FLT_SHIFT) /* 1111: Windowing from TIMWIN source */
+#define HRTIM_TIMEEF2_EE8LTCH (1 << 12) /* Bit 12 */
+#define HRTIM_TIMEEF2_EE8FLT_SHIFT 13 /* Bits 13-16 */
+#define HRTIM_TIMEEF2_EE8FLT_MASK (15 << HRTIM_TIMEEF2_EE8FLT_SHIFT)
+# define HRTIM_TIMEEF2_EE8FLT_0 (0 << HRTIM_TIMEEF2_EE8FLT_SHIFT) /* 0000: No filtering */
+# define HRTIM_TIMEEF2_EE8FLT_1 (1 << HRTIM_TIMEEF2_EE8FLT_SHIFT) /* 0001: Blanking from counter reset/roll-over to Compare 1 */
+# define HRTIM_TIMEEF2_EE8FLT_2 (2 << HRTIM_TIMEEF2_EE8FLT_SHIFT) /* 0010: Blanking from counter reset/roll-over to Compare 2 */
+# define HRTIM_TIMEEF2_EE8FLT_3 (3 << HRTIM_TIMEEF2_EE8FLT_SHIFT) /* 0011: Blanking from counter reset/roll-over to Compare 3 */
+# define HRTIM_TIMEEF2_EE8FLT_4 (4 << HRTIM_TIMEEF2_EE8FLT_SHIFT) /* 0100: Blanking from counter reset/roll-over to Compare 4 */
+# define HRTIM_TIMEEF2_EE8FLT_5 (5 << HRTIM_TIMEEF2_EE8FLT_SHIFT) /* 0101: Blanking from TIMFLTR1 source */
+# define HRTIM_TIMEEF2_EE8FLT_6 (6 << HRTIM_TIMEEF2_EE8FLT_SHIFT) /* 0110: Blanking from TIMFLTR2 source */
+# define HRTIM_TIMEEF2_EE8FLT_7 (7 << HRTIM_TIMEEF2_EE8FLT_SHIFT) /* 0111: Blanking from TIMFLTR3 source */
+# define HRTIM_TIMEEF2_EE8FLT_8 (8 << HRTIM_TIMEEF2_EE8FLT_SHIFT) /* 1000: Blanking from TIMFLTR4 source */
+# define HRTIM_TIMEEF2_EE8FLT_9 (9 << HRTIM_TIMEEF2_EE8FLT_SHIFT) /* 1001: Blanking from TIMFLTR5 source */
+# define HRTIM_TIMEEF2_EE8FLT_10 (10 << HRTIM_TIMEEF2_EE8FLT_SHIFT) /* 1010: Blanking from TIMFLTR6 source */
+# define HRTIM_TIMEEF2_EE8FLT_11 (11 << HRTIM_TIMEEF2_EE8FLT_SHIFT) /* 1011: Blanking from TIMFLTR7 source */
+# define HRTIM_TIMEEF2_EE8FLT_12 (12 << HRTIM_TIMEEF2_EE8FLT_SHIFT) /* 1100: Blanking from TIMFLTR8 source */
+# define HRTIM_TIMEEF2_EE8FLT_13 (13 << HRTIM_TIMEEF2_EE8FLT_SHIFT) /* 1101: Windowing from counter reset/roll-over to Compare 2 */
+# define HRTIM_TIMEEF2_EE8FLT_14 (14 << HRTIM_TIMEEF2_EE8FLT_SHIFT) /* 1110: Windowing from counter reset/roll-over to Compare 3 */
+# define HRTIM_TIMEEF2_EE8FLT_15 (15 << HRTIM_TIMEEF2_EE8FLT_SHIFT) /* 1111: Windowing from TIMWIN source */
+#define HRTIM_TIMEEF2_EE9LTCH (1 << 18) /* Bit 18 */
+#define HRTIM_TIMEEF2_EE9FLT_SHIFT 19 /* Bits 19-22 */
+#define HRTIM_TIMEEF2_EE9FLT_MASK (15 << HRTIM_TIMEEF2_EE9FLT_SHIFT)
+# define HRTIM_TIMEEF2_EE9FLT_0 (0 << HRTIM_TIMEEF2_EE9FLT_SHIFT) /* 0000: No filtering */
+# define HRTIM_TIMEEF2_EE9FLT_1 (1 << HRTIM_TIMEEF2_EE9FLT_SHIFT) /* 0001: Blanking from counter reset/roll-over to Compare 1 */
+# define HRTIM_TIMEEF2_EE9FLT_2 (2 << HRTIM_TIMEEF2_EE9FLT_SHIFT) /* 0010: Blanking from counter reset/roll-over to Compare 2 */
+# define HRTIM_TIMEEF2_EE9FLT_3 (3 << HRTIM_TIMEEF2_EE9FLT_SHIFT) /* 0011: Blanking from counter reset/roll-over to Compare 3 */
+# define HRTIM_TIMEEF2_EE9FLT_4 (4 << HRTIM_TIMEEF2_EE9FLT_SHIFT) /* 0100: Blanking from counter reset/roll-over to Compare 4 */
+# define HRTIM_TIMEEF2_EE9FLT_5 (5 << HRTIM_TIMEEF2_EE9FLT_SHIFT) /* 0101: Blanking from TIMFLTR1 source */
+# define HRTIM_TIMEEF2_EE9FLT_6 (6 << HRTIM_TIMEEF2_EE9FLT_SHIFT) /* 0110: Blanking from TIMFLTR2 source */
+# define HRTIM_TIMEEF2_EE9FLT_7 (7 << HRTIM_TIMEEF2_EE9FLT_SHIFT) /* 0111: Blanking from TIMFLTR3 source */
+# define HRTIM_TIMEEF2_EE9FLT_8 (8 << HRTIM_TIMEEF2_EE9FLT_SHIFT) /* 1000: Blanking from TIMFLTR4 source */
+# define HRTIM_TIMEEF2_EE9FLT_9 (9 << HRTIM_TIMEEF2_EE9FLT_SHIFT) /* 1001: Blanking from TIMFLTR5 source */
+# define HRTIM_TIMEEF2_EE9FLT_10 (10 << HRTIM_TIMEEF2_EE9FLT_SHIFT) /* 1010: Blanking from TIMFLTR6 source */
+# define HRTIM_TIMEEF2_EE9FLT_11 (11 << HRTIM_TIMEEF2_EE9FLT_SHIFT) /* 1011: Blanking from TIMFLTR7 source */
+# define HRTIM_TIMEEF2_EE9FLT_12 (12 << HRTIM_TIMEEF2_EE9FLT_SHIFT) /* 1100: Blanking from TIMFLTR8 source */
+# define HRTIM_TIMEEF2_EE9FLT_13 (13 << HRTIM_TIMEEF2_EE9FLT_SHIFT) /* 1101: Windowing from counter reset/roll-over to Compare 2 */
+# define HRTIM_TIMEEF2_EE9FLT_14 (14 << HRTIM_TIMEEF2_EE9FLT_SHIFT) /* 1110: Windowing from counter reset/roll-over to Compare 3 */
+# define HRTIM_TIMEEF2_EE9FLT_15 (15 << HRTIM_TIMEEF2_EE9FLT_SHIFT) /* 1111: Windowing from TIMWIN source */
+#define HRTIM_TIMEEF2_EE10LTCH (1 << 24) /* Bit 24 */
+#define HRTIM_TIMEEF2_EE10FLT_SHIFT 25 /* Bits 25-28 */
+#define HRTIM_TIMEEF2_EE10FLT_MASK (15 << HRTIM_TIMEEF2_EE10FLT_SHIFT)
+# define HRTIM_TIMEEF2_EE10FLT_0 (0 << HRTIM_TIMEEF2_EE10FLT_SHIFT) /* 0000: No filtering */
+# define HRTIM_TIMEEF2_EE10FLT_1 (1 << HRTIM_TIMEEF2_EE10FLT_SHIFT) /* 0001: Blanking from counter reset/roll-over to Compare 1 */
+# define HRTIM_TIMEEF2_EE10FLT_2 (2 << HRTIM_TIMEEF2_EE10FLT_SHIFT) /* 0010: Blanking from counter reset/roll-over to Compare 2 */
+# define HRTIM_TIMEEF2_EE10FLT_3 (3 << HRTIM_TIMEEF2_EE10FLT_SHIFT) /* 0011: Blanking from counter reset/roll-over to Compare 3 */
+# define HRTIM_TIMEEF2_EE10FLT_4 (4 << HRTIM_TIMEEF2_EE10FLT_SHIFT) /* 0100: Blanking from counter reset/roll-over to Compare 4 */
+# define HRTIM_TIMEEF2_EE10FLT_5 (5 << HRTIM_TIMEEF2_EE10FLT_SHIFT) /* 0101: Blanking from TIMFLTR1 source */
+# define HRTIM_TIMEEF2_EE10FLT_6 (6 << HRTIM_TIMEEF2_EE10FLT_SHIFT) /* 0110: Blanking from TIMFLTR2 source */
+# define HRTIM_TIMEEF2_EE10FLT_7 (7 << HRTIM_TIMEEF2_EE10FLT_SHIFT) /* 0111: Blanking from TIMFLTR3 source */
+# define HRTIM_TIMEEF2_EE10FLT_8 (8 << HRTIM_TIMEEF2_EE10FLT_SHIFT) /* 1000: Blanking from TIMFLTR4 source */
+# define HRTIM_TIMEEF2_EE10FLT_9 (9 << HRTIM_TIMEEF2_EE10FLT_SHIFT) /* 1001: Blanking from TIMFLTR5 source */
+# define HRTIM_TIMEEF2_EE10FLT_10 (10 << HRTIM_TIMEEF2_EE10FLT_SHIFT) /* 1010: Blanking from TIMFLTR6 source */
+# define HRTIM_TIMEEF2_EE10FLT_11 (11 << HRTIM_TIMEEF2_EE10FLT_SHIFT) /* 1011: Blanking from TIMFLTR7 source */
+# define HRTIM_TIMEEF2_EE10FLT_12 (12 << HRTIM_TIMEEF2_EE10FLT_SHIFT) /* 1100: Blanking from TIMFLTR8 source */
+# define HRTIM_TIMEEF2_EE10FLT_13 (13 << HRTIM_TIMEEF2_EE10FLT_SHIFT) /* 1101: Windowing from counter reset/roll-over to Compare 2 */
+# define HRTIM_TIMEEF2_EE10FLT_14 (14 << HRTIM_TIMEEF2_EE10FLT_SHIFT) /* 1110: Windowing from counter reset/roll-over to Compare 3 */
+# define HRTIM_TIMEEF2_EE10FLT_15 (15 << HRTIM_TIMEEF2_EE10FLT_SHIFT) /* 1111: Windowing from TIMWIN source */
+
+/* Timer X Reset Register */
+
+#define HRTIM_TIMARST_UPDT (1 << 1) /* Bit 1 */
+#define HRTIM_TIMARST_CMP2 (1 << 2) /* Bit 2 */
+#define HRTIM_TIMARST_CMP4 (1 << 3) /* Bit 3 */
+#define HRTIM_TIMARST_MSTPER (1 << 4) /* Bit 4 */
+#define HRTIM_TIMARST_MSTCMP1 (1 << 5) /* Bit 5 */
+#define HRTIM_TIMARST_MSTCMP2 (1 << 6) /* Bit 6 */
+#define HRTIM_TIMARST_MSTCMP3 (1 << 7) /* Bit 7 */
+#define HRTIM_TIMARST_MSTCMP4 (1 << 8) /* Bit 8 */
+#define HRTIM_TIMARST_EXTEVNT1 (1 << 9) /* Bit 9 */
+#define HRTIM_TIMARST_EXTEVNT2 (1 << 10) /* Bit 10 */
+#define HRTIM_TIMARST_EXTEVNT3 (1 << 11) /* Bit 11 */
+#define HRTIM_TIMARST_EXTEVNT4 (1 << 12) /* Bit 12 */
+#define HRTIM_TIMARST_EXTEVNT5 (1 << 13) /* Bit 13 */
+#define HRTIM_TIMARST_EXTEVNT6 (1 << 14) /* Bit 14 */
+#define HRTIM_TIMARST_EXTEVNT7 (1 << 15) /* Bit 15 */
+#define HRTIM_TIMARST_EXTEVNT8 (1 << 16) /* Bit 16 */
+#define HRTIM_TIMARST_EXTEVNT9 (1 << 17) /* Bit 17 */
+#define HRTIM_TIMARST_EXTEVNT10 (1 << 18) /* Bit 18 */
+#define HRTIM_TIMARST_TIMBCMP1 (1 << 19) /* Bit 19 */
+#define HRTIM_TIMARST_TIMBCMP2 (1 << 20) /* Bit 20 */
+#define HRTIM_TIMARST_TIMBCMP4 (1 << 21) /* Bit 21 */
+#define HRTIM_TIMARST_TIMCCMP1 (1 << 22) /* Bit 22 */
+#define HRTIM_TIMARST_TIMCCMP2 (1 << 23) /* Bit 23 */
+#define HRTIM_TIMARST_TIMCCMP4 (1 << 24) /* Bit 24 */
+#define HRTIM_TIMARST_TIMDCMP1 (1 << 25) /* Bit 25 */
+#define HRTIM_TIMARST_TIMDCMP2 (1 << 26) /* Bit 26 */
+#define HRTIM_TIMARST_TIMDCMP3 (1 << 27) /* Bit 27 */
+#define HRTIM_TIMARST_TIMECMP1 (1 << 28) /* Bit 28 */
+#define HRTIM_TIMARST_TIMECMP2 (1 << 29) /* Bit 29 */
+#define HRTIM_TIMARST_TIMECMP4 (1 << 30) /* Bit 30 */
+
+#define HRTIM_TIMBRST_UPDT (1 << 1) /* Bit 1 */
+#define HRTIM_TIMBRST_CMP2 (1 << 2) /* Bit 2 */
+#define HRTIM_TIMBRST_CMP4 (1 << 3) /* Bit 3 */
+#define HRTIM_TIMBRST_MSTPER (1 << 4) /* Bit 4 */
+#define HRTIM_TIMBRST_MSTCMP1 (1 << 5) /* Bit 5 */
+#define HRTIM_TIMBRST_MSTCMP2 (1 << 6) /* Bit 6 */
+#define HRTIM_TIMBRST_MSTCMP3 (1 << 7) /* Bit 7 */
+#define HRTIM_TIMBRST_MSTCMP4 (1 << 8) /* Bit 8 */
+#define HRTIM_TIMBRST_EXTEVNT1 (1 << 9) /* Bit 9 */
+#define HRTIM_TIMBRST_EXTEVNT2 (1 << 10) /* Bit 10 */
+#define HRTIM_TIMBRST_EXTEVNT3 (1 << 11) /* Bit 11 */
+#define HRTIM_TIMBRST_EXTEVNT4 (1 << 12) /* Bit 12 */
+#define HRTIM_TIMBRST_EXTEVNT5 (1 << 13) /* Bit 13 */
+#define HRTIM_TIMBRST_EXTEVNT6 (1 << 14) /* Bit 14 */
+#define HRTIM_TIMBRST_EXTEVNT7 (1 << 15) /* Bit 15 */
+#define HRTIM_TIMBRST_EXTEVNT8 (1 << 16) /* Bit 16 */
+#define HRTIM_TIMBRST_EXTEVNT9 (1 << 17) /* Bit 17 */
+#define HRTIM_TIMBRST_EXTEVNT10 (1 << 18) /* Bit 18 */
+#define HRTIM_TIMBRST_TIMACMP1 (1 << 19) /* Bit 19 */
+#define HRTIM_TIMBRST_TIMACMP2 (1 << 20) /* Bit 20 */
+#define HRTIM_TIMBRST_TIMACMP4 (1 << 21) /* Bit 21 */
+#define HRTIM_TIMBRST_TIMCCMP1 (1 << 22) /* Bit 22 */
+#define HRTIM_TIMBRST_TIMCCMP2 (1 << 23) /* Bit 23 */
+#define HRTIM_TIMBRST_TIMCCMP4 (1 << 24) /* Bit 24 */
+#define HRTIM_TIMBRST_TIMDCMP1 (1 << 25) /* Bit 25 */
+#define HRTIM_TIMBRST_TIMDCMP2 (1 << 26) /* Bit 26 */
+#define HRTIM_TIMBRST_TIMDCMP3 (1 << 27) /* Bit 27 */
+#define HRTIM_TIMBRST_TIMECMP1 (1 << 28) /* Bit 28 */
+#define HRTIM_TIMBRST_TIMECMP2 (1 << 29) /* Bit 29 */
+#define HRTIM_TIMBRST_TIMECMP4 (1 << 30) /* Bit 30 */
+
+#define HRTIM_TIMCRST_UPDT (1 << 1) /* Bit 1 */
+#define HRTIM_TIMCRST_CMP2 (1 << 2) /* Bit 2 */
+#define HRTIM_TIMCRST_CMP4 (1 << 3) /* Bit 3 */
+#define HRTIM_TIMCRST_MSTPER (1 << 4) /* Bit 4 */
+#define HRTIM_TIMCRST_MSTCMP1 (1 << 5) /* Bit 5 */
+#define HRTIM_TIMCRST_MSTCMP2 (1 << 6) /* Bit 6 */
+#define HRTIM_TIMCRST_MSTCMP3 (1 << 7) /* Bit 7 */
+#define HRTIM_TIMCRST_MSTCMP4 (1 << 8) /* Bit 8 */
+#define HRTIM_TIMCRST_EXTEVNT1 (1 << 9) /* Bit 9 */
+#define HRTIM_TIMCRST_EXTEVNT2 (1 << 10) /* Bit 10 */
+#define HRTIM_TIMCRST_EXTEVNT3 (1 << 11) /* Bit 11 */
+#define HRTIM_TIMCRST_EXTEVNT4 (1 << 12) /* Bit 12 */
+#define HRTIM_TIMCRST_EXTEVNT5 (1 << 13) /* Bit 13 */
+#define HRTIM_TIMCRST_EXTEVNT6 (1 << 14) /* Bit 14 */
+#define HRTIM_TIMCRST_EXTEVNT7 (1 << 15) /* Bit 15 */
+#define HRTIM_TIMCRST_EXTEVNT8 (1 << 16) /* Bit 16 */
+#define HRTIM_TIMCRST_EXTEVNT9 (1 << 17) /* Bit 17 */
+#define HRTIM_TIMCRST_EXTEVNT10 (1 << 18) /* Bit 18 */
+#define HRTIM_TIMCRST_TIMACMP1 (1 << 19) /* Bit 19 */
+#define HRTIM_TIMCRST_TIMACMP2 (1 << 20) /* Bit 20 */
+#define HRTIM_TIMCRST_TIMACMP4 (1 << 21) /* Bit 21 */
+#define HRTIM_TIMCRST_TIMBCMP1 (1 << 22) /* Bit 22 */
+#define HRTIM_TIMCRST_TIMBCMP2 (1 << 23) /* Bit 23 */
+#define HRTIM_TIMCRST_TIMBCMP4 (1 << 24) /* Bit 24 */
+#define HRTIM_TIMCRST_TIMDCMP1 (1 << 25) /* Bit 25 */
+#define HRTIM_TIMCRST_TIMDCMP2 (1 << 26) /* Bit 26 */
+#define HRTIM_TIMCRST_TIMDCMP3 (1 << 27) /* Bit 27 */
+#define HRTIM_TIMCRST_TIMECMP1 (1 << 28) /* Bit 28 */
+#define HRTIM_TIMCRST_TIMECMP2 (1 << 29) /* Bit 29 */
+#define HRTIM_TIMCRST_TIMECMP4 (1 << 30) /* Bit 30 */
+
+#define HRTIM_TIMDRST_UPDT (1 << 1) /* Bit 1 */
+#define HRTIM_TIMDRST_CMP2 (1 << 2) /* Bit 2 */
+#define HRTIM_TIMDRST_CMP4 (1 << 3) /* Bit 3 */
+#define HRTIM_TIMDRST_MSTPER (1 << 4) /* Bit 4 */
+#define HRTIM_TIMDRST_MSTCMP1 (1 << 5) /* Bit 5 */
+#define HRTIM_TIMDRST_MSTCMP2 (1 << 6) /* Bit 6 */
+#define HRTIM_TIMDRST_MSTCMP3 (1 << 7) /* Bit 7 */
+#define HRTIM_TIMDRST_MSTCMP4 (1 << 8) /* Bit 8 */
+#define HRTIM_TIMDRST_EXTEVNT1 (1 << 9) /* Bit 9 */
+#define HRTIM_TIMDRST_EXTEVNT2 (1 << 10) /* Bit 10 */
+#define HRTIM_TIMDRST_EXTEVNT3 (1 << 11) /* Bit 11 */
+#define HRTIM_TIMDRST_EXTEVNT4 (1 << 12) /* Bit 12 */
+#define HRTIM_TIMDRST_EXTEVNT5 (1 << 13) /* Bit 13 */
+#define HRTIM_TIMDRST_EXTEVNT6 (1 << 14) /* Bit 14 */
+#define HRTIM_TIMDRST_EXTEVNT7 (1 << 15) /* Bit 15 */
+#define HRTIM_TIMDRST_EXTEVNT8 (1 << 16) /* Bit 16 */
+#define HRTIM_TIMDRST_EXTEVNT9 (1 << 17) /* Bit 17 */
+#define HRTIM_TIMDRST_EXTEVNT10 (1 << 18) /* Bit 18 */
+#define HRTIM_TIMDRST_TIMACMP1 (1 << 19) /* Bit 19 */
+#define HRTIM_TIMDRST_TIMACMP2 (1 << 20) /* Bit 20 */
+#define HRTIM_TIMDRST_TIMACMP4 (1 << 21) /* Bit 21 */
+#define HRTIM_TIMDRST_TIMBCMP1 (1 << 22) /* Bit 22 */
+#define HRTIM_TIMDRST_TIMBCMP2 (1 << 23) /* Bit 23 */
+#define HRTIM_TIMDRST_TIMBCMP4 (1 << 24) /* Bit 24 */
+#define HRTIM_TIMDRST_TIMCCMP1 (1 << 25) /* Bit 25 */
+#define HRTIM_TIMDRST_TIMCCMP2 (1 << 26) /* Bit 26 */
+#define HRTIM_TIMDRST_TIMCCMP3 (1 << 27) /* Bit 27 */
+#define HRTIM_TIMDRST_TIMECMP1 (1 << 28) /* Bit 28 */
+#define HRTIM_TIMDRST_TIMECMP2 (1 << 29) /* Bit 29 */
+#define HRTIM_TIMDRST_TIMECMP4 (1 << 30) /* Bit 30 */
+
+#define HRTIM_TIMERST_UPDT (1 << 1) /* Bit 1 */
+#define HRTIM_TIMERST_CMP2 (1 << 2) /* Bit 2 */
+#define HRTIM_TIMERST_CMP4 (1 << 3) /* Bit 3 */
+#define HRTIM_TIMERST_MSTPER (1 << 4) /* Bit 4 */
+#define HRTIM_TIMERST_MSTCMP1 (1 << 5) /* Bit 5 */
+#define HRTIM_TIMERST_MSTCMP2 (1 << 6) /* Bit 6 */
+#define HRTIM_TIMERST_MSTCMP3 (1 << 7) /* Bit 7 */
+#define HRTIM_TIMERST_MSTCMP4 (1 << 8) /* Bit 8 */
+#define HRTIM_TIMERST_EXTEVNT1 (1 << 9) /* Bit 9 */
+#define HRTIM_TIMERST_EXTEVNT2 (1 << 10) /* Bit 10 */
+#define HRTIM_TIMERST_EXTEVNT3 (1 << 11) /* Bit 11 */
+#define HRTIM_TIMERST_EXTEVNT4 (1 << 12) /* Bit 12 */
+#define HRTIM_TIMERST_EXTEVNT5 (1 << 13) /* Bit 13 */
+#define HRTIM_TIMERST_EXTEVNT6 (1 << 14) /* Bit 14 */
+#define HRTIM_TIMERST_EXTEVNT7 (1 << 15) /* Bit 15 */
+#define HRTIM_TIMERST_EXTEVNT8 (1 << 16) /* Bit 16 */
+#define HRTIM_TIMERST_EXTEVNT9 (1 << 17) /* Bit 17 */
+#define HRTIM_TIMERST_EXTEVNT10 (1 << 18) /* Bit 18 */
+#define HRTIM_TIMERST_TIMACMP1 (1 << 19) /* Bit 19 */
+#define HRTIM_TIMERST_TIMACMP2 (1 << 20) /* Bit 20 */
+#define HRTIM_TIMERST_TIMACMP4 (1 << 21) /* Bit 21 */
+#define HRTIM_TIMERST_TIMBCMP1 (1 << 22) /* Bit 22 */
+#define HRTIM_TIMERST_TIMBCMP2 (1 << 23) /* Bit 23 */
+#define HRTIM_TIMERST_TIMBCMP4 (1 << 24) /* Bit 24 */
+#define HRTIM_TIMERST_TIMCCMP1 (1 << 25) /* Bit 25 */
+#define HRTIM_TIMERST_TIMCCMP2 (1 << 26) /* Bit 26 */
+#define HRTIM_TIMERST_TIMCCMP3 (1 << 27) /* Bit 27 */
+#define HRTIM_TIMERST_TIMDCMP1 (1 << 28) /* Bit 28 */
+#define HRTIM_TIMERST_TIMDCMP2 (1 << 29) /* Bit 29 */
+#define HRTIM_TIMERST_TIMDCMP4 (1 << 30) /* Bit 30 */
+
+/* Timer X Chopper Register */
+
+#define HRTIM_TIMCHP_CARFRQ_SHIFT 0 /* Bits 0-3 */
+#define HRTIM_TIMCHP_CARFRQ_MASK (15 << HRTIM_TIMCHP_CARFRQ_SHIFT)
+
+#define HRTIM_TIMCHP_CARDTY_SHIFT 4 /* Bits 4-6 */
+#define HRTIM_TIMCHP_CARDTY_MASK (7 << HRTIM_TIMCHP_CARDTY_SHIFT)
+
+#define HRTIM_TIMCHP_STRTPW_SHIFT 7 /* Bits 7-10 */
+#define HRTIM_TIMCHP_STRTPW_MASK (15 << HRTIM_TIMCHP_STRTPW_SHIFT)
+
+/* Timer X Capture 1 Control Register */
+
+#define HRTIM_TIMCPT1CR_SWCPT (1 << 0)
+#define HRTIM_TIMCPT1CR_UPDCPT (1 << 1)
+#define HRTIM_TIMCPT1CR_EXEV1CPT (1 << 2)
+#define HRTIM_TIMCPT1CR_EXEV2CPT (1 << 3)
+#define HRTIM_TIMCPT1CR_EXEV3CPT (1 << 4)
+#define HRTIM_TIMCPT1CR_EXEV4CPT (1 << 5)
+#define HRTIM_TIMCPT1CR_EXEV5CPT (1 << 6)
+#define HRTIM_TIMCPT1CR_EXEV6CPT (1 << 7)
+#define HRTIM_TIMCPT1CR_EXEV7CPT (1 << 8)
+#define HRTIM_TIMCPT1CR_EXEV8CPT (1 << 9)
+#define HRTIM_TIMCPT1CR_EXEV9CPT (1 << 10)
+#define HRTIM_TIMCPT1CR_EXEV10CPT (1 << 11)
+#define HRTIM_TIMCPT1CR_TA1SET (1 << 12)
+#define HRTIM_TIMCPT1CR_TA1RST (1 << 13)
+#define HRTIM_TIMCPT1CR_TACMP1 (1 << 14)
+#define HRTIM_TIMCPT1CR_TACMP2 (1 << 15)
+#define HRTIM_TIMCPT1CR_TB1SET (1 << 16)
+#define HRTIM_TIMCPT1CR_TB1RST (1 << 17)
+#define HRTIM_TIMCPT1CR_TBCMP1 (1 << 18)
+#define HRTIM_TIMCPT1CR_TBCMP2 (1 << 19)
+#define HRTIM_TIMCPT1CR_TC1SET (1 << 20)
+#define HRTIM_TIMCPT1CR_TC1RST (1 << 21)
+#define HRTIM_TIMCPT1CR_TCCMP1 (1 << 22)
+#define HRTIM_TIMCPT1CR_TCCMP2 (1 << 23)
+#define HRTIM_TIMCPT1CR_TD1SET (1 << 24)
+#define HRTIM_TIMCPT1CR_TD1RST (1 << 25)
+#define HRTIM_TIMCPT1CR_TDCMP1 (1 << 26)
+#define HRTIM_TIMCPT1CR_TDCMP2 (1 << 27)
+#define HRTIM_TIMCPT1CR_TE1SET (1 << 28)
+#define HRTIM_TIMCPT1CR_TE1RST (1 << 29)
+#define HRTIM_TIMCPT1CR_TECMP1 (1 << 30)
+#define HRTIM_TIMCPT1CR_TECMP2 (1 << 31)
+
+/* Timer X Capture 2 Control Register */
+
+#define HRTIM_TIMCPT2CR_SWCPT (1 << 0)
+#define HRTIM_TIMCPT2CR_UPDCPT (1 << 1)
+#define HRTIM_TIMCPT2CR_EXEV1CPT (1 << 2)
+#define HRTIM_TIMCPT2CR_EXEV2CPT (1 << 3)
+#define HRTIM_TIMCPT2CR_EXEV3CPT (1 << 4)
+#define HRTIM_TIMCPT2CR_EXEV4CPT (1 << 5)
+#define HRTIM_TIMCPT2CR_EXEV5CPT (1 << 6)
+#define HRTIM_TIMCPT2CR_EXEV6CPT (1 << 7)
+#define HRTIM_TIMCPT2CR_EXEV7CPT (1 << 8)
+#define HRTIM_TIMCPT2CR_EXEV8CPT (1 << 9)
+#define HRTIM_TIMCPT2CR_EXEV9CPT (1 << 10)
+#define HRTIM_TIMCPT2CR_EXEV10CPT (1 << 11)
+#define HRTIM_TIMCPT2CR_TA1SET (1 << 12)
+#define HRTIM_TIMCPT2CR_TA1RST (1 << 13)
+#define HRTIM_TIMCPT2CR_TACMP1 (1 << 14)
+#define HRTIM_TIMCPT2CR_TACMP2 (1 << 15)
+#define HRTIM_TIMCPT2CR_TB1SET (1 << 16)
+#define HRTIM_TIMCPT2CR_TB1RST (1 << 17)
+#define HRTIM_TIMCPT2CR_TBCMP1 (1 << 18)
+#define HRTIM_TIMCPT2CR_TBCMP2 (1 << 19)
+#define HRTIM_TIMCPT2CR_TC1SET (1 << 20)
+#define HRTIM_TIMCPT2CR_TC1RST (1 << 21)
+#define HRTIM_TIMCPT2CR_TCCMP1 (1 << 22)
+#define HRTIM_TIMCPT2CR_TCCMP2 (1 << 23)
+#define HRTIM_TIMCPT2CR_TD1SET (1 << 24)
+#define HRTIM_TIMCPT2CR_TD1RST (1 << 25)
+#define HRTIM_TIMCPT2CR_TDCMP1 (1 << 26)
+#define HRTIM_TIMCPT2CR_TDCMP2 (1 << 27)
+#define HRTIM_TIMCPT2CR_TE1SET (1 << 28)
+#define HRTIM_TIMCPT2CR_TE1RST (1 << 29)
+#define HRTIM_TIMCPT2CR_TECMP1 (1 << 30)
+#define HRTIM_TIMCPT2CR_TECMP2 (1 << 31)
+
+/* Timer X Output Register */
+
+#define HRTIM_TIMOUT_POL1 (1 << 1) /* Bit 1 */
+#define HRTIM_TIMOUT_IDLEM1 (1 << 2) /* Bit 2 */
+#define HRTIM_TIMOUT_IDLES1 (1 << 3) /* Bit 3 */
+#define HRTIM_TIMOUT_FAULT1_SHIFT 4 /* Bit 4-5 */
+#define HRTIM_TIMOUT_FAULT1_MASK (3 << HRTIM_TIMOUT_FAULT1_SHIFT)
+# define HRTIM_TIMOUT_FAULT1_0 (0 << HRTIM_TIMOUT_FAULT1_SHIFT)
+# define HRTIM_TIMOUT_FAULT1_1 (1 << HRTIM_TIMOUT_FAULT1_SHIFT)
+# define HRTIM_TIMOUT_FAULT1_2 (2 << HRTIM_TIMOUT_FAULT1_SHIFT)
+# define HRTIM_TIMOUT_FAULT1_3 (3 << HRTIM_TIMOUT_FAULT1_SHIFT)
+#define HRTIM_TIMOUT_CHP1 (1 << 3) /* Bit 1 */
+#define HRTIM_TIMOUT_DIDL1 (1 << 3) /* Bit 1 */
+#define HRTIM_TIMOUT_DTEN (1 << 3) /* Bit 1 */
+#define HRTIM_TIMOUT_DLYPRTEN (1 << 3) /* Bit 1 */
+#define HRTIM_TIMOUT_DLYPRT_SHIFT 10 /* Bits 10-12*/
+#define HRTIM_TIMOUT_DLYPRT_MASK (3 << HRTIM_TIMOUT_DLYPRT_SHIFT)
+# define HRTIM_TIMOUT_DLYPRT_0 (0 << HRTIM_TIMOUT_DLYPRT_SHIFT)
+# define HRTIM_TIMOUT_DLYPRT_1 (1 << HRTIM_TIMOUT_DLYPRT_SHIFT)
+# define HRTIM_TIMOUT_DLYPRT_2 (2 << HRTIM_TIMOUT_DLYPRT_SHIFT)
+# define HRTIM_TIMOUT_DLYPRT_3 (3 << HRTIM_TIMOUT_DLYPRT_SHIFT)
+#define HRTIM_TIMOUT_POL2 (1 << 17) /* Bit 17 */
+#define HRTIM_TIMOUT_IDLEM2 (1 << 18) /* Bit 18 */
+#define HRTIM_TIMOUT_IDLES2 (1 << 19) /* Bit 19 */
+#define HRTIM_TIMOUT_FAULT2_SHIFT 20 /* Bit 20-21 */
+#define HRTIM_TIMOUT_FAULT2_MASK (3 << HRTIM_TIMOUT_FAULT2_SHIFT)
+# define HRTIM_TIMOUT_FAULT2_0 (0 << HRTIM_TIMOUT_FAULT2_SHIFT)
+# define HRTIM_TIMOUT_FAULT2_1 (1 << HRTIM_TIMOUT_FAULT2_SHIFT)
+# define HRTIM_TIMOUT_FAULT2_2 (2 << HRTIM_TIMOUT_FAULT2_SHIFT)
+# define HRTIM_TIMOUT_FAULT2_3 (3 << HRTIM_TIMOUT_FAULT2_SHIFT)
+#define HRTIM_TIMOUT_CHP2 (1 << 22) /* Bit 22 */
+#define HRTIM_TIMOUT_DIDL2 (1 << 23) /* Bit 23 */
+
+/* Timer X Fault Register */
+
+#define HRTIM_TIMFLT_FLT1EN (1 << 0) /* Bit 0 */
+#define HRTIM_TIMFLT_FLT2EN (1 << 1) /* Bit 1 */
+#define HRTIM_TIMFLT_FLT3EN (1 << 2) /* Bit 2 */
+#define HRTIM_TIMFLT_FLT4EN (1 << 3) /* Bit 3 */
+#define HRTIM_TIMFLT_FLT5EN (1 << 4) /* Bit 4 */
+
+/* Common Control Register 1 */
+
+#define HRTIM_CR1_MUDIS (1 << 0) /* Bit 0 */
+#define HRTIM_CR1_TAUDIS (1 << 1) /* Bit 1 */
+#define HRTIM_CR1_TBUDIS (1 << 2) /* Bit 2 */
+#define HRTIM_CR1_TCUDIS (1 << 3) /* Bit 3 */
+#define HRTIM_CR1_TDUDIS (1 << 4) /* Bit 4 */
+#define HRTIM_CR1_TEUDIS (1 << 5) /* Bit 5 */
+#define HRTIM_CR1_AD1USRC_SHIFT 16 /* Bits 16-18 */
+#define HRTIM_CR1_AD1USRC_MASK (7 << HRTIM_CR1_AD1USRC_SHIFT)
+# define HRTIM_CR1_AD1USRC_MT (0 << HRTIM_CR1_AD1USRC_SHIFT) /* 000: Mater Timer */
+# define HRTIM_CR1_AD1USRC_TA (1 << HRTIM_CR1_AD1USRC_SHIFT) /* 001: Timer A */
+# define HRTIM_CR1_AD1USRC_TB (2 << HRTIM_CR1_AD1USRC_SHIFT) /* 010: Timer B */
+# define HRTIM_CR1_AD1USRC_TC (3 << HRTIM_CR1_AD1USRC_SHIFT) /* 011: Timer C */
+# define HRTIM_CR1_AD1USRC_TD (4 << HRTIM_CR1_AD1USRC_SHIFT) /* 100: Timer D */
+# define HRTIM_CR1_AD1USRC_TE (5 << HRTIM_CR1_AD1USRC_SHIFT) /* 101: Timer A */
+#define HRTIM_CR1_AD2USRC_SHIFT 19 /* Bits 19-21 */
+#define HRTIM_CR1_AD2USRC_MASK (7 << HRTIM_CR1_AD2USRC_SHIFT)
+# define HRTIM_CR1_AD2USRC_MT (0 << HRTIM_CR1_AD2USRC_SHIFT) /* 000: Mater Timer */
+# define HRTIM_CR1_AD2USRC_TA (1 << HRTIM_CR1_AD2USRC_SHIFT) /* 001: Timer A */
+# define HRTIM_CR1_AD2USRC_TB (2 << HRTIM_CR1_AD2USRC_SHIFT) /* 010: Timer B */
+# define HRTIM_CR1_AD2USRC_TC (3 << HRTIM_CR1_AD2USRC_SHIFT) /* 011: Timer C */
+# define HRTIM_CR1_AD2USRC_TD (4 << HRTIM_CR1_AD2USRC_SHIFT) /* 100: Timer D */
+# define HRTIM_CR1_AD2USRC_TE (5 << HRTIM_CR1_AD2USRC_SHIFT) /* 101: Timer A */
+#define HRTIM_CR1_AD3USRC_SHIFT 22 /* Bits 22-24 */
+#define HRTIM_CR1_AD3USRC_MASK (7 << HRTIM_CR1_AD3USRC_SHIFT)
+# define HRTIM_CR1_AD3USRC_MT (0 << HRTIM_CR1_AD3USRC_SHIFT) /* 000: Mater Timer */
+# define HRTIM_CR1_AD3USRC_TA (1 << HRTIM_CR1_AD3USRC_SHIFT) /* 001: Timer A */
+# define HRTIM_CR1_AD3USRC_TB (2 << HRTIM_CR1_AD3USRC_SHIFT) /* 010: Timer B */
+# define HRTIM_CR1_AD3USRC_TC (3 << HRTIM_CR1_AD3USRC_SHIFT) /* 011: Timer C */
+# define HRTIM_CR1_AD3USRC_TD (4 << HRTIM_CR1_AD3USRC_SHIFT) /* 100: Timer D */
+# define HRTIM_CR1_AD3USRC_TE (5 << HRTIM_CR1_AD3USRC_SHIFT) /* 101: Timer A */
+#define HRTIM_CR1_AD4USRC_SHIFT 25 /* Bits 25-27 */
+#define HRTIM_CR1_AD4USRC_MASK (7 << HRTIM_CR1_AD4USRC_SHIFT)
+# define HRTIM_CR1_AD4USRC_MT (0 << HRTIM_CR1_AD4USRC_SHIFT) /* 000: Mater Timer */
+# define HRTIM_CR1_AD4USRC_TA (1 << HRTIM_CR1_AD4USRC_SHIFT) /* 001: Timer A */
+# define HRTIM_CR1_AD4USRC_TB (2 << HRTIM_CR1_AD4USRC_SHIFT) /* 010: Timer B */
+# define HRTIM_CR1_AD4USRC_TC (3 << HRTIM_CR1_AD4USRC_SHIFT) /* 011: Timer C */
+# define HRTIM_CR1_AD4USRC_TD (4 << HRTIM_CR1_AD4USRC_SHIFT) /* 100: Timer D */
+# define HRTIM_CR1_AD4USRC_TE (5 << HRTIM_CR1_AD4USRC_SHIFT) /* 101: Timer A */
+
+/* Common Control Register 2 */
+
+#define HRTIM_CR2_MSWU (1 << 0) /* Bit 0: Master Timer Software Update */
+#define HRTIM_CR2_TASWU (1 << 1) /* Bit 1: Timer A Software Update */
+#define HRTIM_CR2_TBSWU (1 << 2) /* Bit 2: Timer B Software Update */
+#define HRTIM_CR2_TCSWU (1 << 3) /* Bit 3: Timer C Software Update */
+#define HRTIM_CR2_TDSWU (1 << 4) /* Bit 4: Timer D Software Update */
+#define HRTIM_CR2_TESWU (1 << 5) /* Bit 5: Timer E Software Update */
+#define HRTIM_CR2_MRST (1 << 8) /* Bit 8: Master Counter Software Reset*/
+#define HRTIM_CR2_TARST (1 << 9) /* Bit 9: Timer A Counter Software Reset*/
+#define HRTIM_CR2_TBRST (1 << 10) /* Bit 10: Timer B Counter Software Reset*/
+#define HRTIM_CR2_TCRST (1 << 11) /* Bit 11: Timer C Counter Software Reset*/
+#define HRTIM_CR2_TDRST (1 << 12) /* Bit 12: Timer D Counter Software Reset*/
+#define HRTIM_CR2_TERST (1 << 13) /* Bit 13: Timer E Counter Software Reset*/
+
+/* Common Interupt Status Register */
+
+#define HRTIM_ISR_FLT1 (1 << 0) /* Bit 0: Fault 1 Interrupt Flag */
+#define HRTIM_ISR_FLT2 (1 << 1) /* Bit 1: Fault 2 Interrupt Flag */
+#define HRTIM_ISR_FLT3 (1 << 2) /* Bit 2: Fault 3 Interrupt Flag */
+#define HRTIM_ISR_FLT4 (1 << 3) /* Bit 3: Fault 4 Interrupt Flag */
+#define HRTIM_ISR_FLT5 (1 << 4) /* Bit 4: Fault 5 Interrupt Flag */
+#define HRTIM_ISR_SYSFLT (1 << 5) /* Bit 5: System Fault Interrupt Flag */
+#define HRTIM_ISR_DLLRDY (1 << 16) /* Bit 16: DLL Ready Interrupt Flag */
+#define HRTIM_ISR_BMPER (1 << 17) /* Bit 17: Burst mode Period Interrupt Flag */
+
+/* Common Interupt Clear Register */
+
+#define HRTIM_ICR_FLT1C (1 << 0) /* Bit 0: Fault 1 Interrupt Flag Clear */
+#define HRTIM_ICR_FLT2C (1 << 1) /* Bit 1: Fault 2 Interrupt Flag Clear */
+#define HRTIM_ICR_FLT3C (1 << 2) /* Bit 2: Fault 3 Interrupt Flag Clear */
+#define HRTIM_ICR_FLT4C (1 << 3) /* Bit 3: Fault 4 Interrupt Flag Clear */
+#define HRTIM_ICR_FLT5C (1 << 4) /* Bit 4: Fault 5 Interrupt Flag Clear */
+#define HRTIM_ICR_SYSFLTC (1 << 5) /* Bit 5: System Fault Interrupt Flag Clear */
+#define HRTIM_ICR_DLLRDYC (1 << 16) /* Bit 16: DLL Ready Interrupt Flag Clear */
+#define HRTIM_ICR_BMPERC (1 << 17) /* Bit 17: Burst mode Period Interrupt Flag Clear */
+
+/* Common Interupt Enable Register */
+
+#define HRTIM_IER_FLT1IE (1 << 0) /* Bit 0: Fault 1 Interrupt Enable */
+#define HRTIM_IER_FLT2IE (1 << 1) /* Bit 1: Fault 2 Interrupt Enable */
+#define HRTIM_IER_FLT3IE (1 << 2) /* Bit 2: Fault 3 Interrupt Enable */
+#define HRTIM_IER_FLT4IE (1 << 3) /* Bit 3: Fault 4 Interrupt Enable */
+#define HRTIM_IER_FLT5IE (1 << 4) /* Bit 4: Fault 5 Interrupt Enable */
+#define HRTIM_IER_SYSFLTIE (1 << 5) /* Bit 5: System Fault Interrupt Enable */
+#define HRTIM_IER_DLLRDYIE (1 << 16) /* Bit 16: DLL Ready Interrupt Enable */
+#define HRTIM_IER_BMPERIE (1 << 17) /* Bit 17: Burst mode Period Interrupt Enable */
+
+/* Common Output Enable Register */
+
+#define HRTIM_OENR_TA1OE (1 << 0) /* Bit 0: Timer A Output 1 Enable */
+#define HRTIM_OENR_TA2OE (1 << 1) /* Bit 1: Timer A Output 2 Enable */
+#define HRTIM_OENR_TB1OE (1 << 2) /* Bit 2: Timer B Output 1 Enable */
+#define HRTIM_OENR_TB2OE (1 << 3) /* Bit 3: Timer B Output 2 Enable */
+#define HRTIM_OENR_TC1OE (1 << 4) /* Bit 4: Timer C Output 1 Enable */
+#define HRTIM_OENR_TC2OE (1 << 5) /* Bit 5: Timer C Output 2 Enable */
+#define HRTIM_OENR_TD1OE (1 << 6) /* Bit 6: Timer D Output 1 Enable */
+#define HRTIM_OENR_TD2OE (1 << 7) /* Bit 7: Timer D Output 2 Enable */
+#define HRTIM_OENR_TE1OE (1 << 8) /* Bit 8: Timer E Output 1 Enable */
+#define HRTIM_OENR_TE2OE (1 << 9) /* Bit 9: Timer E Output 2 Enable */
+
+/* Common Output Disable Register */
+
+#define HRTIM_ODISR_TA1ODIS (1 << 0) /* Bit 0: Timer A Output 1 Disable */
+#define HRTIM_ODISR_TA2ODIS (1 << 1) /* Bit 1: Timer A Output 2 Disable */
+#define HRTIM_ODISR_TB1ODIS (1 << 2) /* Bit 2: Timer B Output 1 Disable */
+#define HRTIM_ODISR_TB2ODIS (1 << 3) /* Bit 3: Timer B Output 2 Disable */
+#define HRTIM_ODISR_TC1ODIS (1 << 4) /* Bit 4: Timer C Output 1 Disable */
+#define HRTIM_ODISR_TC2ODIS (1 << 5) /* Bit 5: Timer C Output 2 Disable */
+#define HRTIM_ODISR_TD1ODIS (1 << 6) /* Bit 6: Timer D Output 1 Disable */
+#define HRTIM_ODISR_TD2ODIS (1 << 7) /* Bit 7: Timer D Output 2 Disable */
+#define HRTIM_ODISR_TE1ODIS (1 << 8) /* Bit 8: Timer E Output 1 Disable */
+#define HRTIM_ODISR_TE2ODIS (1 << 9) /* Bit 9: Timer E Output 2 Disable */
+
+/* Common Output Disable Status Register */
+
+#define HRTIM_ODSR_TA1ODS (1 << 0) /* Bit 0: Timer A Output 1 Disable Status */
+#define HRTIM_ODSR_TA2ODS (1 << 1) /* Bit 1: Timer A Output 2 Disable Status */
+#define HRTIM_ODSR_TB1ODS (1 << 2) /* Bit 2: Timer B Output 1 Disable Status */
+#define HRTIM_ODSR_TB2ODS (1 << 3) /* Bit 3: Timer B Output 2 Disable Status */
+#define HRTIM_ODSR_TC1ODS (1 << 4) /* Bit 4: Timer C Output 1 Disable Status */
+#define HRTIM_ODSR_TC2ODS (1 << 5) /* Bit 5: Timer C Output 2 Disable Status */
+#define HRTIM_ODSR_TD1ODS (1 << 6) /* Bit 6: Timer D Output 1 Disable Status */
+#define HRTIM_ODSR_TD2ODS (1 << 7) /* Bit 7: Timer D Output 2 Disable Status */
+#define HRTIM_ODSR_TE1ODS (1 << 8) /* Bit 8: Timer E Output 1 Disable Status */
+#define HRTIM_ODSR_TE2ODS (1 << 9) /* Bit 9: Timer E Output 2 Disable Status */
+
+/* Common Burst Mode Control Register */
+
+#define HRTIM_BMCR_BME (1 << 0) /* Bit 0: Burst Mode Enable */
+#define HRTIM_BMCR_BMOM (1 << 0) /* Bit 1: Burst Mode Operating Mode */
+#define HRTIM_BMCR_BMCLK_SHIFT 2 /* Bits 2-5: Burst Mode Clock Source */
+#define HRTIM_BMCR_BMCLK_MASK (15 << HRTIM_BMCR_BMCLK_SHIFT)
+# define HRTIM_BMCR_BMCLK_0 (0 << HRTIM_BMCR_BMCLK_SHIFT) /* 0000: Master Timer Counter Reset/roll-over */
+# define HRTIM_BMCR_BMCLK_1 (1 << HRTIM_BMCR_BMCLK_SHIFT) /* 0001: Timer A counter reset/roll-over */
+# define HRTIM_BMCR_BMCLK_2 (2 << HRTIM_BMCR_BMCLK_SHIFT) /* 0010: Timer B counter reset/roll-over */
+# define HRTIM_BMCR_BMCLK_3 (3 << HRTIM_BMCR_BMCLK_SHIFT) /* 0011: Timer C counter reset/roll-over */
+# define HRTIM_BMCR_BMCLK_4 (4 << HRTIM_BMCR_BMCLK_SHIFT) /* 0100: Timer D counter reset/roll-over */
+# define HRTIM_BMCR_BMCLK_5 (5 << HRTIM_BMCR_BMCLK_SHIFT) /* 0101: Timer E counter reset/roll-over */
+# define HRTIM_BMCR_BMCLK_6 (6 << HRTIM_BMCR_BMCLK_SHIFT) /* 0110: On-chip Event 1 acting as a burst mode counter clock */
+# define HRTIM_BMCR_BMCLK_7 (7 << HRTIM_BMCR_BMCLK_SHIFT) /* 0111: On-chip Event 2 acting as a burst mode counter clock */
+# define HRTIM_BMCR_BMCLK_8 (8 << HRTIM_BMCR_BMCLK_SHIFT) /* 1000: On-chip Event 3 acting as a burst mode counter clock */
+# define HRTIM_BMCR_BMCLK_9 (9 << HRTIM_BMCR_BMCLK_SHIFT) /* 1001: On-chip Event 4 acting as a burst mode counter clock */
+# define HRTIM_BMCR_BMCLK_10 (10 << HRTIM_BMCR_BMCLK_SHIFT) /* 1010: Prescaled fHRTIM clock */
+#define HRTIM_BMCR_BMPRSC_SHIFT 6 /* Bits 6-9: Burst Mode Prescaler */
+#define HRTIM_BMCR_BMPRSC_MASK (15 << HRTIM_BMCR_BMPRSC_SHIFT)
+# define HRTIM_BMCR_BMPRSC_PSCOFF (0 << HRTIM_BMCR_BMPRSC_SHIFT) /* 0000: Clock not divided */
+# define HRTIM_BMCR_BMPRSC_d2 (1 << HRTIM_BMCR_BMPRSC_SHIFT) /* 0001: Division by 2 */
+# define HRTIM_BMCR_BMPRSC_d4 (2 << HRTIM_BMCR_BMPRSC_SHIFT) /* 0010: Division by 4 */
+# define HRTIM_BMCR_BMPRSC_d8 (3 << HRTIM_BMCR_BMPRSC_SHIFT) /* 0011: Division by 8 */
+# define HRTIM_BMCR_BMPRSC_d16 (4 << HRTIM_BMCR_BMPRSC_SHIFT) /* 0100: Division by 16 */
+# define HRTIM_BMCR_BMPRSC_d32 (5 << HRTIM_BMCR_BMPRSC_SHIFT) /* 0101: Division by 32 */
+# define HRTIM_BMCR_BMPRSC_d64 (6 << HRTIM_BMCR_BMPRSC_SHIFT) /* 0110: Division by 64 */
+# define HRTIM_BMCR_BMPRSC_d128 (7 << HRTIM_BMCR_BMPRSC_SHIFT) /* 0111: Division by 128 */
+# define HRTIM_BMCR_BMPRSC_d256 (8 << HRTIM_BMCR_BMPRSC_SHIFT) /* 1000: Division by 256 */
+# define HRTIM_BMCR_BMPRSC_d512 (9 << HRTIM_BMCR_BMPRSC_SHIFT) /* 1001: Division by 512 */
+# define HRTIM_BMCR_BMPRSC_d1024 (10 << HRTIM_BMCR_BMPRSC_SHIFT) /* 1010: Division by 1024 */
+# define HRTIM_BMCR_BMPRSC_d2048 (11 << HRTIM_BMCR_BMPRSC_SHIFT) /* 1011: Division by 2048 */
+# define HRTIM_BMCR_BMPRSC_d4096 (12 << HRTIM_BMCR_BMPRSC_SHIFT) /* 1100: Division by 4096 */
+# define HRTIM_BMCR_BMPRSC_d8192 (13 << HRTIM_BMCR_BMPRSC_SHIFT) /* 1101: Division by 8192 */
+# define HRTIM_BMCR_BMPRSC_d16384 (14 << HRTIM_BMCR_BMPRSC_SHIFT) /* 1110: Division by 16384 */
+# define HRTIM_BMCR_BMPRSC_d32769 (15 << HRTIM_BMCR_BMPRSC_SHIFT) /* 1111: Division by 32768 */
+#define HRTIM_BMCR_BMPREN (1 << 10) /* Bit 10: Burst Mode Preload Enable */
+#define HRTIM_BMCR_MTBM (1 << 16) /* Bit 16: Master Timer Burst Mode */
+#define HRTIM_BMCR_TABM (1 << 17) /* Bit 17: Timer A Burst Mode */
+#define HRTIM_BMCR_TBBM (1 << 18) /* Bit 18: Timer B Burst Mode */
+#define HRTIM_BMCR_TCBM (1 << 19) /* Bit 19: Timer C Burst Mode */
+#define HRTIM_BMCR_TDBM (1 << 20) /* Bit 20: Timer D Burst Mode */
+#define HRTIM_BMCR_TEBM (1 << 21) /* Bit 21: Timer E Burst Mode */
+#define HRTIM_BMCR_BMSTAT (1 << 31) /* Bit 31: Burst Mode Status */
+
+
+/* Common Burst Mode Trigger Register */
+
+#define HRTIM_BMTRGR_SW (1 << 0) /* Bit 0: Software start */
+#define HRTIM_BMTRGR_MSTRST (1 << 1) /* Bit 1: Master reset or roll-over */
+#define HRTIM_BMTRGR_MSTREP (1 << 2) /* Bit 2: Master repetition */
+#define HRTIM_BMTRGR_MSTCMP1 (1 << 3) /* Bit 3: Master Compare 1 */
+#define HRTIM_BMTRGR_MSTCMP2 (1 << 4) /* Bit 4: Master Compare 2 */
+#define HRTIM_BMTRGR_MSTCMP3 (1 << 5) /* Bit 5: Master Compare 3 */
+#define HRTIM_BMTRGR_MSTCMP4 (1 << 6) /* Bit 6: Master Compare 4 */
+#define HRTIM_BMTRGR_TARST (1 << 7) /* Bit 7: Timer A reset or roll-over */
+#define HRTIM_BMTRGR_TAREP (1 << 8) /* Bit 8: Timer A repetition */
+#define HRTIM_BMTRGR_TACMP1 (1 << 9) /* Bit 9: Timer A Compare 1 */
+#define HRTIM_BMTRGR_TACMP2 (1 << 10) /* Bit 10: Timer A Compare 2 */
+#define HRTIM_BMTRGR_TBRST (1 << 11) /* Bit 11: Timer B reset or roll-over */
+#define HRTIM_BMTRGR_TBREP (1 << 12) /* Bit 12: Timer B repetition */
+#define HRTIM_BMTRGR_TBCMP1 (1 << 13) /* Bit 13: Timer B Compare 1 */
+#define HRTIM_BMTRGR_TBCMP2 (1 << 14) /* Bit 14: Timer B Compare 2 */
+#define HRTIM_BMTRGR_TCRST (1 << 15) /* Bit 15: Timer C reset or roll-over */
+#define HRTIM_BMTRGR_TCREP (1 << 16) /* Bit 16: Timer C repetition */
+#define HRTIM_BMTRGR_TCCMP1 (1 << 17) /* Bit 17: Timer C Compare 1 */
+#define HRTIM_BMTRGR_TCCMP2 (1 << 18) /* Bit 18: Timer C Compare 2 */
+#define HRTIM_BMTRGR_TDRST (1 << 19) /* Bit 19: Timer D reset or roll-over */
+#define HRTIM_BMTRGR_TDREP (1 << 20) /* Bit 20: Timer D repetition */
+#define HRTIM_BMTRGR_TDCMP1 (1 << 21) /* Bit 21: Timer D Compare 1 */
+#define HRTIM_BMTRGR_TDCMP2 (1 << 22) /* Bit 22: Timer D Compare 2 */
+#define HRTIM_BMTRGR_TERST (1 << 23) /* Bit 23: Timer E reset or roll-over */
+#define HRTIM_BMTRGR_TEREP (1 << 24) /* Bit 24: Timer E repetition */
+#define HRTIM_BMTRGR_TECMP1 (1 << 25) /* Bit 25: Timer E Compare 1 */
+#define HRTIM_BMTRGR_TECMP2 (1 << 26) /* Bit 26: Timer E Compare 2 */
+#define HRTIM_BMTRGR_TAEEV7 (1 << 27) /* Bit 27: Timer A period following External Event 7 */
+#define HRTIM_BMTRGR_TDEEV8 (1 << 28) /* Bit 28: Timer D period following External Event 8 */
+#define HRTIM_BMTRGR_EEV7 (1 << 29) /* Bit 29: External Event 7 */
+#define HRTIM_BMTRGR_EEV8 (1 << 30) /* Bit 30: External Event 8 */
+#define HRTIM_BMTRGR_OCHPEV (1 << 31) /* Bit 31: On-chip Event */
+
+/* Common Burst Mode Compare Register */
+
+#define HRTIM_BMCMPR_SHIFT 0 /* Bits 0-15: Burst mode compare value */
+#define HRTIM_BMCMPR_MASK (0xffff << HRTIM_BMCMPR_SHIFT)
+
+/* Common Burst Mode Period Register */
+
+#define HRTIM_BMPER_SHIFT 0 /* Bits 0-15: Burst mode Period */
+#define HRTIM_BMPER_MASK (0xffff << HRTIM_BMPER_SHIFT)
+
+/* Common External Event Control Register 1 */
+
+#define HRTIM_EECR1_EE1SRC_SHIFT 0 /* Bits 0-1: External Event 1 Source */
+#define HRTIM_EECR1_EE1SRC_MASK (3 << HRTIM_EECR1_EE1SRC_SHIFT)
+# define HRTIM_EECR1_EE1SRC_SRC1 (0 << HRTIM_EECR1_EE1SRC_SHIFT) /* 00: EE1 Src1 */
+# define HRTIM_EECR1_EE1SRC_SRC2 (1 << HRTIM_EECR1_EE1SRC_SHIFT) /* 00: EE1 Src2 */
+# define HRTIM_EECR1_EE1SRC_SRC3 (2 << HRTIM_EECR1_EE1SRC_SHIFT) /* 00: EE1 Src3 */
+# define HRTIM_EECR1_EE1SRC_SRC4 (3 << HRTIM_EECR1_EE1SRC_SHIFT) /* 00: EE1 Src4 */
+#define HRTIM_EECR1_EE1POL (1 << 2) /* Bit 2: External Event 1 Polarity */
+#define HRTIM_EECR1_EE1SNS_SHIFT 3 /* Bits 3-4: External Event 1 Sensitivity */
+#define HRTIM_EECR1_EE1SNS_MASK (3 << HRTIM_EECR1_EE1SNS_SHIFT)
+# define HRTIM_EECR1_EE1SNS_ACTIV (0 << HRTIM_EECR1_EE1SNS_SHIFT) /* 00: On active level defined by EE1POL bit */
+# define HRTIM_EECR1_EE1SNS_REDGE (1 << HRTIM_EECR1_EE1SNS_SHIFT) /* 01: Rising edge, whatever EE1POL bit value */
+# define HRTIM_EECR1_EE1SNS_FEDGE (2 << HRTIM_EECR1_EE1SNS_SHIFT) /* 10: Falling edge, whatever EE1POL bit value */
+# define HRTIM_EECR1_EE1SNS_BEDGE (3 << HRTIM_EECR1_EE1SNS_SHIFT) /* 11: Both edges, whatever EE1POL bit value */
+#define HRTIM_EECR1_EE1FAST (1 << 5) /* Bit 5: External Event 1 Fast mode */
+#define HRTIM_EECR1_EE2SRC_SHIFT 6 /* Bits 6-7: External Event 2 Source */
+#define HRTIM_EECR1_EE2SRC_MASK (3 << HRTIM_EECR1_EE2SRC_SHIFT)
+# define HRTIM_EECR1_EE2SRC_SRC1 (0 << HRTIM_EECR1_EE2SRC_SHIFT) /* 00: EE2 Src1 */
+# define HRTIM_EECR1_EE2SRC_SRC2 1 << HRTIM_EECR1_EE2SRC_SHIFT) /* 00: EE2 Src2 */
+# define HRTIM_EECR1_EE2SRC_SRC3 (2 << HRTIM_EECR1_EE2SRC_SHIFT) /* 00: EE2 Src3 */
+# define HRTIM_EECR1_EE2SRC_SRC4 (3 << HRTIM_EECR1_EE2SRC_SHIFT) /* 00: EE2 Src4 */
+#define HRTIM_EECR1_EE2POL (1 << 8) /* Bit 8: External Event 2 Polarity */
+#define HRTIM_EECR1_EE2SNS_SHIFT 9 /* Bits 9-10: External Event 2 Sensitivity */
+#define HRTIM_EECR1_EE2SNS_MASK (3 << HRTIM_EECR1_EE2SNS_SHIFT)
+# define HRTIM_EECR1_EE2SNS_ACTIV (0 << HRTIM_EECR1_EE2SNS_SHIFT) /* 00: On active level defined by EE2POL bit */
+# define HRTIM_EECR1_EE2SNS_REDGE (1 << HRTIM_EECR1_EE2SNS_SHIFT) /* 01: Rising edge, whatever EE2POL bit value */
+# define HRTIM_EECR1_EE2SNS_FEDGE (2 << HRTIM_EECR1_EE2SNS_SHIFT) /* 10: Falling edge, whatever EE2POL bit value */
+# define HRTIM_EECR1_EE2SNS_BEDGE (3 << HRTIM_EECR1_EE2SNS_SHIFT) /* 11: Both edges, whatever EE2POL bit value */
+#define HRTIM_EECR1_EE2FAST (1 << 11) /* Bit 11: External Event 2 Fast mode */
+#define HRTIM_EECR1_EE3SRC_SHIFT 12 /* Bits 6-7: External Event 3 Source */
+#define HRTIM_EECR1_EE3SRC_MASK (3 << HRTIM_EECR1_EE3SRC_SHIFT)
+# define HRTIM_EECR1_EE3SRC_SRC1 (0 << HRTIM_EECR1_EE3SRC_SHIFT) /* 00: EE3 Src1 */
+# define HRTIM_EECR1_EE3SRC_SRC2 (1 << HRTIM_EECR1_EE3SRC_SHIFT) /* 00: EE3 Src2 */
+# define HRTIM_EECR1_EE3SRC_SRC3 (2 << HRTIM_EECR1_EE3SRC_SHIFT) /* 00: EE3 Src3 */
+# define HRTIM_EECR1_EE3SRC_SRC4 (3 << HRTIM_EECR1_EE3SRC_SHIFT) /* 00: EE3 Src4 */
+#define HRTIM_EECR1_EE3POL (1 << 14) /* Bit 14: External Event 3 Polarity */
+#define HRTIM_EECR1_EE3SNS_SHIFT 15 /* Bits 15-16: External Event 3 Sensitivity */
+#define HRTIM_EECR1_EE3SNS_MASK (3 << HRTIM_EECR1_EE3SNS_SHIFT)
+# define HRTIM_EECR1_EE3SNS_ACTIV (0 << HRTIM_EECR1_EE3SNS_SHIFT) /* 00: On active level defined by EE3POL bit */
+# define HRTIM_EECR1_EE3SNS_REDGE (1 << HRTIM_EECR1_EE3SNS_SHIFT) /* 01: Rising edge, whatever EE3POL bit value */
+# define HRTIM_EECR1_EE3SNS_FEDGE (2 << HRTIM_EECR1_EE3SNS_SHIFT) /* 10: Falling edge, whatever EE3POL bit value */
+# define HRTIM_EECR1_EE3SNS_BEDGE (3 << HRTIM_EECR1_EE3SNS_SHIFT) /* 11: Both edges, whatever EE3POL bit value */
+#define HRTIM_EECR1_EE3FAST (1 << 17) /* Bit 17: External Event 3 Fast mode */
+#define HRTIM_EECR1_EE4SRC_SHIFT 18 /* Bits 18-19: External Event 4 Source */
+#define HRTIM_EECR1_EE4SRC_MASK (3 << HRTIM_EECR1_EE4SRC_SHIFT)
+# define HRTIM_EECR1_EE4SRC_SRC1 (0 << HRTIM_EECR1_EE4SRC_SHIFT) /* 00: EE4 Src1 */
+# define HRTIM_EECR1_EE4SRC_SRC2 (1 << HRTIM_EECR1_EE4SRC_SHIFT) /* 00: EE4 Src2 */
+# define HRTIM_EECR1_EE4SRC_SRC3 (2 << HRTIM_EECR1_EE4SRC_SHIFT) /* 00: EE4 Src3 */
+# define HRTIM_EECR1_EE4SRC_SRC4 (3 << HRTIM_EECR1_EE4SRC_SHIFT) /* 00: EE4 Src4 */
+#define HRTIM_EECR1_EE4POL (1 << 20) /* Bit 20: External Event 4 Polarity */
+#define HRTIM_EECR1_EE4SNS_SHIFT 21 /* Bits 21-22: External Event 4 Sensitivity */
+#define HRTIM_EECR1_EE4SNS_MASK (3 << HRTIM_EECR1_EE4SNS_SHIFT)
+# define HRTIM_EECR1_EE4SNS_ACTIV (0 << HRTIM_EECR1_EE4SNS_SHIFT) /* 00: On active level defined by EE4POL bit */
+# define HRTIM_EECR1_EE4SNS_REDGE (1 << HRTIM_EECR1_EE4SNS_SHIFT) /* 01: Rising edge, whatever EE4POL bit value */
+# define HRTIM_EECR1_EE4SNS_FEDGE (2 << HRTIM_EECR1_EE4SNS_SHIFT) /* 10: Falling edge, whatever EE4POL bit value */
+# define HRTIM_EECR1_EE4SNS_BEDGE (3 << HRTIM_EECR1_EE4SNS_SHIFT) /* 11: Both edges, whatever EE4POL bit value */
+#define HRTIM_EECR1_EE4FAST (1 << 23) /* Bit 23: External Event 4 Fast mode */
+#define HRTIM_EECR1_EE5SRC_SHIFT 24 /* Bits 24-25: External Event 5 Source */
+#define HRTIM_EECR1_EE5SRC_MASK (3 << HRTIM_EECR1_EE5SRC_SHIFT)
+# define HRTIM_EECR1_EE5SRC_SRC1 (0 << HRTIM_EECR1_EE5SRC_SHIFT) /* 00: EE5 Src1 */
+# define HRTIM_EECR1_EE5SRC_SRC2 (1 << HRTIM_EECR1_EE5SRC_SHIFT) /* 00: EE5 Src2 */
+# define HRTIM_EECR1_EE5SRC_SRC3 (2 << HRTIM_EECR1_EE5SRC_SHIFT) /* 00: EE5 Src3 */
+# define HRTIM_EECR1_EE5SRC_SRC4 (3 << HRTIM_EECR1_EE5SRC_SHIFT) /* 00: EE5 Src4 */
+#define HRTIM_EECR1_EE5POL (1 << 26) /* Bit 26: External Event 5 Polarity */
+#define HRTIM_EECR1_EE5SNS_SHIFT 27 /* Bits 27-28: External Event 5 Sensitivity */
+#define HRTIM_EECR1_EE5SNS_MASK (3 << HRTIM_EECR1_EE5SNS_SHIFT)
+# define HRTIM_EECR1_EE5SNS_ACTIV (0 << HRTIM_EECR1_EE5SNS_SHIFT) /* 00: On active level defined by EE5POL bit */
+# define HRTIM_EECR1_EE5SNS_REDGE (1 << HRTIM_EECR1_EE5SNS_SHIFT) /* 01: Rising edge, whatever EE5POL bit value */
+# define HRTIM_EECR1_EE5SNS_FEDGE (2 << HRTIM_EECR1_EE5SNS_SHIFT) /* 10: Falling edge, whatever EE5POL bit value */
+# define HRTIM_EECR1_EE5SNS_BEDGE (3 << HRTIM_EECR1_EE5SNS_SHIFT) /* 11: Both edges, whatever EE5POL bit value */
+#define HRTIM_EECR1_EE5FAST (1 << 29) /* Bit 29: External Event 5 Fast mode */
+
+/* Common External Event Control Register 2 */
+
+#define HRTIM_EECR2_EE6SRC_SHIFT 0 /* Bits 0-1: External Event 6 Source */
+#define HRTIM_EECR2_EE6SRC_MASK (3 << HRTIM_EECR2_EE6SRC_SHIFT)
+# define HRTIM_EECR2_EE6SRC_SRC1 (0 << HRTIM_EECR2_EE6SRC_SHIFT) /* 00: EE6 Src1 */
+# define HRTIM_EECR2_EE6SRC_SRC2 (1 << HRTIM_EECR2_EE6SRC_SHIFT) /* 00: EE6 Src2 */
+# define HRTIM_EECR2_EE6SRC_SRC3 (2 << HRTIM_EECR2_EE6SRC_SHIFT) /* 00: EE6 Src3 */
+# define HRTIM_EECR2_EE6SRC_SRC4 (3 << HRTIM_EECR2_EE6SRC_SHIFT) /* 00: EE6 Src4 */
+#define HRTIM_EECR2_EE6POL (1 << 3) /* Bit 3: External Event 6 Polarity */
+#define HRTIM_EECR2_EE6SNS_SHIFT 3 /* Bits 3-4: External Event 6 Sensitivity */
+#define HRTIM_EECR2_EE6SNS_MASK (3 << HRTIM_EECR2_EE6SNS_SHIFT)
+# define HRTIM_EECR2_EE6SNS_ACTIV (0 << HRTIM_EECR2_EE6SNS_SHIFT) /* 00: On active level defined by EE6POL bit */
+# define HRTIM_EECR2_EE6SNS_REDGE (1 << HRTIM_EECR2_EE6SNS_SHIFT) /* 01: Rising edge, whatever EE6POL bit value */
+# define HRTIM_EECR2_EE6SNS_FEDGE (2 << HRTIM_EECR2_EE6SNS_SHIFT) /* 10: Falling edge, whatever EE6POL bit value */
+# define HRTIM_EECR2_EE6SNS_BEDGE (3 << HRTIM_EECR2_EE6SNS_SHIFT) /* 11: Both edges, whatever EE6POL bit value */
+#define HRTIM_EECR2_EE7SRC_SHIFT 6 /* Bits 6-7: External Event 7 Source */
+#define HRTIM_EECR2_EE7SRC_MASK (3 << HRTIM_EECR2_EE7SRC_SHIFT)
+# define HRTIM_EECR2_EE7SRC_SRC1 (0 << HRTIM_EECR2_EE7SRC_SHIFT) /* 00: EE7 Src1 */
+# define HRTIM_EECR2_EE7SRC_SRC2 (1 << HRTIM_EECR2_EE7SRC_SHIFT) /* 00: EE7 Src2 */
+# define HRTIM_EECR2_EE7SRC_SRC3 (2 << HRTIM_EECR2_EE7SRC_SHIFT) /* 00: EE7 Src3 */
+# define HRTIM_EECR2_EE7SRC_SRC4 (3 << HRTIM_EECR2_EE7SRC_SHIFT) /* 00: EE7 Src4 */
+#define HRTIM_EECR2_EE7POL (1 << 8) /* Bit 8: External Event 7 Polarity */
+#define HRTIM_EECR2_EE7SNS_SHIFT 9 /* Bits 9-10: External Event 7 Sensitivity */
+#define HRTIM_EECR2_EE7SNS_MASK (3 << HRTIM_EECR2_EE7SNS_SHIFT)
+# define HRTIM_EECR2_EE7SNS_ACTIV (0 << HRTIM_EECR2_EE7SNS_SHIFT) /* 00: On active level defined by EE7POL bit */
+# define HRTIM_EECR2_EE7SNS_REDGE (1 << HRTIM_EECR2_EE7SNS_SHIFT) /* 01: Rising edge, whatever EE7POL bit value */
+# define HRTIM_EECR2_EE7SNS_FEDGE (2 << HRTIM_EECR2_EE7SNS_SHIFT) /* 10: Falling edge, whatever EE7POL bit value */
+# define HRTIM_EECR2_EE7SNS_BEDGE (3 << HRTIM_EECR2_EE7SNS_SHIFT) /* 11: Both edges, whatever EE7POL bit value */
+#define HRTIM_EECR2_EE8SRC_SHIFT 12 /* Bits 12-13: External Event 8 Source */
+#define HRTIM_EECR2_EE8SRC_MASK (3 << HRTIM_EECR2_EE8SRC_SHIFT)
+# define HRTIM_EECR2_EE8SRC_SRC1 (0 << HRTIM_EECR2_EE8SRC_SHIFT) /* 00: EE8 Src1 */
+# define HRTIM_EECR2_EE8SRC_SRC2 (1 << HRTIM_EECR2_EE8SRC_SHIFT) /* 00: EE8 Src2 */
+# define HRTIM_EECR2_EE8SRC_SRC3 (2 << HRTIM_EECR2_EE8SRC_SHIFT) /* 00: EE8 Src3 */
+# define HRTIM_EECR2_EE8SRC_SRC4 (3 << HRTIM_EECR2_EE8SRC_SHIFT) /* 00: EE8 Src4 */
+#define HRTIM_EECR2_EE8POL (1 << 14) /* Bit 14: External Event 8 Polarity */
+#define HRTIM_EECR2_EE8SNS_SHIFT 15 /* Bits 15-16: External Event 8 Sensitivity */
+#define HRTIM_EECR2_EE8SNS_MASK (3 << HRTIM_EECR2_EE8SNS_SHIFT)
+# define HRTIM_EECR2_EE8SNS_ACTIV (0 << HRTIM_EECR2_EE8SNS_SHIFT) /* 00: On active level defined by EE8POL bit */
+# define HRTIM_EECR2_EE8SNS_REDGE (1 << HRTIM_EECR2_EE8SNS_SHIFT) /* 01: Rising edge, whatever EE8POL bit value */
+# define HRTIM_EECR2_EE8SNS_FEDGE (2 << HRTIM_EECR2_EE8SNS_SHIFT) /* 10: Falling edge, whatever EE8POL bit value */
+# define HRTIM_EECR2_EE8SNS_BEDGE (3 << HRTIM_EECR2_EE8SNS_SHIFT) /* 11: Both edges, whatever EE8POL bit value */
+#define HRTIM_EECR2_EE9SRC_SHIFT 18 /* Bits 18-19: External Event 9 Source */
+#define HRTIM_EECR2_EE9SRC_MASK (3 << HRTIM_EECR2_EE9SRC_SHIFT)
+# define HRTIM_EECR2_EE9SRC_SRC1 (0 << HRTIM_EECR2_EE9SRC_SHIFT) /* 00: EE9 Src1 */
+# define HRTIM_EECR2_EE9SRC_SRC2 (1 << HRTIM_EECR2_EE9SRC_SHIFT) /* 00: EE9 Src2 */
+# define HRTIM_EECR2_EE9SRC_SRC3 (2 << HRTIM_EECR2_EE9SRC_SHIFT) /* 00: EE9 Src3 */
+# define HRTIM_EECR2_EE9SRC_SRC4 (3 << HRTIM_EECR2_EE9SRC_SHIFT) /* 00: EE9 Src4 */
+#define HRTIM_EECR2_EE9POL (1 << 20) /* Bit 20: External Event 9 Polarity */
+#define HRTIM_EECR2_EE9SNS_SHIFT 21 /* Bits 21-22: External Event 9 Sensitivity */
+#define HRTIM_EECR2_EE9SNS_MASK (3 << HRTIM_EECR2_EE9SNS_SHIFT)
+# define HRTIM_EECR2_EE9SNS_ACTIV (0 << HRTIM_EECR2_EE9SNS_SHIFT) /* 00: On active level defined by EE9POL bit */
+# define HRTIM_EECR2_EE9SNS_REDGE (1 << HRTIM_EECR2_EE9SNS_SHIFT) /* 01: Rising edge, whatever EE9POL bit value */
+# define HRTIM_EECR2_EE9SNS_FEDGE (2 << HRTIM_EECR2_EE9SNS_SHIFT) /* 10: Falling edge, whatever EE9POL bit value */
+# define HRTIM_EECR2_EE9SNS_BEDGE (3 << HRTIM_EECR2_EE9SNS_SHIFT) /* 11: Both edges, whatever EE9POL bit value */
+#define HRTIM_EECR2_EE10SRC_SHIFT 24 /* Bits 24-25: External Event 10 Source */
+#define HRTIM_EECR2_EE10SRC_MASK (3 << HRTIM_EECR2_EE10SRC_SHIFT)
+# define HRTIM_EECR2_EE10SRC_SRC1 (0 << HRTIM_EECR2_EE10SRC_SHIFT) /* 00: EE10 Src1 */
+# define HRTIM_EECR2_EE10SRC_SRC2 (1 << HRTIM_EECR2_EE10SRC_SHIFT) /* 00: EE10 Src2 */
+# define HRTIM_EECR2_EE10SRC_SRC3 (2 << HRTIM_EECR2_EE10SRC_SHIFT) /* 00: EE10 Src3 */
+# define HRTIM_EECR2_EE10SRC_SRC4 (3 << HRTIM_EECR2_EE10SRC_SHIFT) /* 00: EE10 Src4 */
+#define HRTIM_EECR2_EE10POL (1 << 26) /* Bit 26: External Event 10 Polarity */
+#define HRTIM_EECR2_EE10SNS_SHIFT 28 /* Bits 27-28: External Event 10 Sensitivity */
+#define HRTIM_EECR2_EE10SNS_MASK (3 << HRTIM_EECR2_EE10SNS_SHIFT)
+# define HRTIM_EECR2_EE10SNS_ACTIV (0 << HRTIM_EECR2_EE10SNS_SHIFT) /* 00: On active level defined by EE10POL bit */
+# define HRTIM_EECR2_EE10SNS_REDGE (1 << HRTIM_EECR2_EE10SNS_SHIFT) /* 01: Rising edge, whatever EE10POL bit value */
+# define HRTIM_EECR2_EE10SNS_FEDGE (2 << HRTIM_EECR2_EE10SNS_SHIFT) /* 10: Falling edge, whatever EE10POL bit value */
+# define HRTIM_EECR2_EE10SNS_BEDGE (3 << HRTIM_EECR2_EE10SNS_SHIFT) /* 11: Both edges, whatever EE10POL bit value */
+
+/* Common External Event Control Register 3 */
+
+#define HRTIM_EECR3_EE6F_SHIFT 0 /* Bits 0-3: External Event 6 Filter */
+#define HRTIM_EECR3_EE6F_MASK (15 << HRTIM_EECR3_EE6F_SHIFT)
+# define HRTIM_EECR3_EE6F_NOFLT (0 << HRTIM_EECR3_EE6F_SHIFT) /* 0000: No filter, FLT5 acts asynchronously */
+# define HRTIM_EECR3_EE6F_HRTN2 (1 << HRTIM_EECR3_EE6F_SHIFT) /* 0001: fSAMPLING = fHRTIM, N=2 */
+# define HRTIM_EECR3_EE6F_HRTN4 (2 << HRTIM_EECR3_EE6F_SHIFT) /* 0010: fSAMPLING = fHRTIM, N=4 */
+# define HRTIM_EECR3_EE6F_HRTN8 (3 << HRTIM_EECR3_EE6F_SHIFT) /* 0011: fSAMPLING = fHRTIM, N=8 */
+# define HRTIM_EECR3_EE6F_EEVS2N6 (4 << HRTIM_EECR3_EE6F_SHIFT) /* 0100: fSAMPLING = fEEVS/2, N=6 */
+# define HRTIM_EECR3_EE6F_EEVS2N8 (5 << HRTIM_EECR3_EE6F_SHIFT) /* 0101: fSAMPLING = fEEVS/2, N=8 */
+# define HRTIM_EECR3_EE6F_EEVS4N6 (6 << HRTIM_EECR3_EE6F_SHIFT) /* 0110: fSAMPLING = fEEVS/4, N=6 */
+# define HRTIM_EECR3_EE6F_EEVS4N8 (7 << HRTIM_EECR3_EE6F_SHIFT) /* 0111: fSAMPLING = fEEVS/4, N=8 */
+# define HRTIM_EECR3_EE6F_EEVS8N6 (8 << HRTIM_EECR3_EE6F_SHIFT) /* 1000: fSAMPLING = fEEVS/8, N=6 */
+# define HRTIM_EECR3_EE6F_EEVS8N8 (9 << HRTIM_EECR3_EE6F_SHIFT) /* 1001: fSAMPLING = fEEVS/8, N=8 */
+# define HRTIM_EECR3_EE6F_EEVS16N5 (10 << HRTIM_EECR3_EE6F_SHIFT) /* 1010: fSAMPLING = fEEVS/16, N=5 */
+# define HRTIM_EECR3_EE6F_EEVS16N6 (11 << HRTIM_EECR3_EE6F_SHIFT) /* 1011: fSAMPLING = fEEVS/16, N=6 */
+# define HRTIM_EECR3_EE6F_EEVS16N8 (12 << HRTIM_EECR3_EE6F_SHIFT) /* 1100: fSAMPLING = fEEVS/16, N=8 */
+# define HRTIM_EECR3_EE6F_EEVS32N5 (13 << HRTIM_EECR3_EE6F_SHIFT) /* 1101: fSAMPLING = fEEVS/32, N=5 */
+# define HRTIM_EECR3_EE6F_EEVS32N6 (14 << HRTIM_EECR3_EE6F_SHIFT) /* 1110: fSAMPLING = fEEVS/32, N=6 */
+# define HRTIM_EECR3_EE6F_EEVS32N8 (15 << HRTIM_EECR3_EE6F_SHIFT) /* 1111: fSAMPLING = fEEVS/32, N=8 */
+#define HRTIM_EECR3_EE7F_SHIFT 6 /* Bits 6-9: External Event 7 Filter */
+#define HRTIM_EECR3_EE7F_MASK (15 << HRTIM_EECR3_EE7F_SHIFT)
+# define HRTIM_EECR3_EE7F_NOFLT (0 << HRTIM_EECR3_EE7F_SHIFT) /* 0000: No filter, FLT5 acts asynchronously */
+# define HRTIM_EECR3_EE7F_HRTN2 (1 << HRTIM_EECR3_EE7F_SHIFT) /* 0001: fSAMPLING = fHRTIM, N=2 */
+# define HRTIM_EECR3_EE7F_HRTN4 (2 << HRTIM_EECR3_EE7F_SHIFT) /* 0010: fSAMPLING = fHRTIM, N=4 */
+# define HRTIM_EECR3_EE7F_HRTN8 (3 << HRTIM_EECR3_EE7F_SHIFT) /* 0011: fSAMPLING = fHRTIM, N=8 */
+# define HRTIM_EECR3_EE7F_EEVS2N6 (4 << HRTIM_EECR3_EE7F_SHIFT) /* 0100: fSAMPLING = fEEVS/2, N=6 */
+# define HRTIM_EECR3_EE7F_EEVS2N8 (5 << HRTIM_EECR3_EE7F_SHIFT) /* 0101: fSAMPLING = fEEVS/2, N=8 */
+# define HRTIM_EECR3_EE7F_EEVS4N6 (6 << HRTIM_EECR3_EE7F_SHIFT) /* 0110: fSAMPLING = fEEVS/4, N=6 */
+# define HRTIM_EECR3_EE7F_EEVS4N8 (7 << HRTIM_EECR3_EE7F_SHIFT) /* 0111: fSAMPLING = fEEVS/4, N=8 */
+# define HRTIM_EECR3_EE7F_EEVS8N6 (8 << HRTIM_EECR3_EE7F_SHIFT) /* 1000: fSAMPLING = fEEVS/8, N=6 */
+# define HRTIM_EECR3_EE7F_EEVS8N8 (9 << HRTIM_EECR3_EE7F_SHIFT) /* 1001: fSAMPLING = fEEVS/8, N=8 */
+# define HRTIM_EECR3_EE7F_EEVS16N5 (10 << HRTIM_EECR3_EE7F_SHIFT) /* 1010: fSAMPLING = fEEVS/16, N=5 */
+# define HRTIM_EECR3_EE7F_EEVS16N6 (11 << HRTIM_EECR3_EE7F_SHIFT) /* 1011: fSAMPLING = fEEVS/16, N=6 */
+# define HRTIM_EECR3_EE7F_EEVS16N8 (12 << HRTIM_EECR3_EE7F_SHIFT) /* 1100: fSAMPLING = fEEVS/16, N=8 */
+# define HRTIM_EECR3_EE7F_EEVS32N5 (13 << HRTIM_EECR3_EE7F_SHIFT) /* 1101: fSAMPLING = fEEVS/32, N=5 */
+# define HRTIM_EECR3_EE7F_EEVS32N6 (14 << HRTIM_EECR3_EE7F_SHIFT) /* 1110: fSAMPLING = fEEVS/32, N=6 */
+# define HRTIM_EECR3_EE7F_EEVS32N8 (15 << HRTIM_EECR3_EE7F_SHIFT) /* 1111: fSAMPLING = fEEVS/32, N=8 */
+#define HRTIM_EECR3_EE8F_SHIFT 12 /* Bits 12-15: External Event 8 Filter */
+#define HRTIM_EECR3_EE8F_MASK (15 << HRTIM_EECR3_EE8F_SHIFT)
+# define HRTIM_EECR3_EE8F_NOFLT (0 << HRTIM_EECR3_EE8F_SHIFT) /* 0000: No filter, FLT5 acts asynchronously */
+# define HRTIM_EECR3_EE8F_HRTN2 (1 << HRTIM_EECR3_EE8F_SHIFT) /* 0001: fSAMPLING = fHRTIM, N=2 */
+# define HRTIM_EECR3_EE8F_HRTN4 (2 << HRTIM_EECR3_EE8F_SHIFT) /* 0010: fSAMPLING = fHRTIM, N=4 */
+# define HRTIM_EECR3_EE8F_HRTN8 (3 << HRTIM_EECR3_EE8F_SHIFT) /* 0011: fSAMPLING = fHRTIM, N=8 */
+# define HRTIM_EECR3_EE8F_EEVS2N6 (4 << HRTIM_EECR3_EE8F_SHIFT) /* 0100: fSAMPLING = fEEVS/2, N=6 */
+# define HRTIM_EECR3_EE8F_EEVS2N8 (5 << HRTIM_EECR3_EE8F_SHIFT) /* 0101: fSAMPLING = fEEVS/2, N=8 */
+# define HRTIM_EECR3_EE8F_EEVS4N6 (6 << HRTIM_EECR3_EE8F_SHIFT) /* 0110: fSAMPLING = fEEVS/4, N=6 */
+# define HRTIM_EECR3_EE8F_EEVS4N8 (7 << HRTIM_EECR3_EE8F_SHIFT) /* 0111: fSAMPLING = fEEVS/4, N=8 */
+# define HRTIM_EECR3_EE8F_EEVS8N6 (8 << HRTIM_EECR3_EE8F_SHIFT) /* 1000: fSAMPLING = fEEVS/8, N=6 */
+# define HRTIM_EECR3_EE8F_EEVS8N8 (9 << HRTIM_EECR3_EE8F_SHIFT) /* 1001: fSAMPLING = fEEVS/8, N=8 */
+# define HRTIM_EECR3_EE8F_EEVS16N5 (10 << HRTIM_EECR3_EE8F_SHIFT) /* 1010: fSAMPLING = fEEVS/16, N=5 */
+# define HRTIM_EECR3_EE8F_EEVS16N6 (11 << HRTIM_EECR3_EE8F_SHIFT) /* 1011: fSAMPLING = fEEVS/16, N=6 */
+# define HRTIM_EECR3_EE8F_EEVS16N8 (12 << HRTIM_EECR3_EE8F_SHIFT) /* 1100: fSAMPLING = fEEVS/16, N=8 */
+# define HRTIM_EECR3_EE8F_EEVS32N5 (13 << HRTIM_EECR3_EE8F_SHIFT) /* 1101: fSAMPLING = fEEVS/32, N=5 */
+# define HRTIM_EECR3_EE8F_EEVS32N6 (14 << HRTIM_EECR3_EE8F_SHIFT) /* 1110: fSAMPLING = fEEVS/32, N=6 */
+# define HRTIM_EECR3_EE8F_EEVS32N8 (15 << HRTIM_EECR3_EE8F_SHIFT) /* 1111: fSAMPLING = fEEVS/32, N=8 */
+#define HRTIM_EECR3_EE9F_SHIFT 18 /* Bits 18-21: External Event 9 Filter */
+#define HRTIM_EECR3_EE9F_MASK (15 << HRTIM_EECR3_EE9F_SHIFT)
+# define HRTIM_EECR3_EE9F_NOFLT (0 << HRTIM_EECR3_EE9F_SHIFT) /* 0000: No filter, FLT5 acts asynchronously */
+# define HRTIM_EECR3_EE9F_HRTN2 (1 << HRTIM_EECR3_EE9F_SHIFT) /* 0001: fSAMPLING = fHRTIM, N=2 */
+# define HRTIM_EECR3_EE9F_HRTN4 (2 << HRTIM_EECR3_EE9F_SHIFT) /* 0010: fSAMPLING = fHRTIM, N=4 */
+# define HRTIM_EECR3_EE9F_HRTN8 (3 << HRTIM_EECR3_EE9F_SHIFT) /* 0011: fSAMPLING = fHRTIM, N=8 */
+# define HRTIM_EECR3_EE9F_EEVS2N6 (4 << HRTIM_EECR3_EE9F_SHIFT) /* 0100: fSAMPLING = fEEVS/2, N=6 */
+# define HRTIM_EECR3_EE9F_EEVS2N8 (5 << HRTIM_EECR3_EE9F_SHIFT) /* 0101: fSAMPLING = fEEVS/2, N=8 */
+# define HRTIM_EECR3_EE9F_EEVS4N6 (6 << HRTIM_EECR3_EE9F_SHIFT) /* 0110: fSAMPLING = fEEVS/4, N=6 */
+# define HRTIM_EECR3_EE9F_EEVS4N8 (7 << HRTIM_EECR3_EE9F_SHIFT) /* 0111: fSAMPLING = fEEVS/4, N=8 */
+# define HRTIM_EECR3_EE9F_EEVS8N6 (8 << HRTIM_EECR3_EE9F_SHIFT) /* 1000: fSAMPLING = fEEVS/8, N=6 */
+# define HRTIM_EECR3_EE9F_EEVS8N8 (9 << HRTIM_EECR3_EE9F_SHIFT) /* 1001: fSAMPLING = fEEVS/8, N=8 */
+# define HRTIM_EECR3_EE9F_EEVS16N5 (10 << HRTIM_EECR3_EE9F_SHIFT) /* 1010: fSAMPLING = fEEVS/16, N=5 */
+# define HRTIM_EECR3_EE9F_EEVS16N6 (11 << HRTIM_EECR3_EE9F_SHIFT) /* 1011: fSAMPLING = fEEVS/16, N=6 */
+# define HRTIM_EECR3_EE9F_EEVS16N8 (12 << HRTIM_EECR3_EE9F_SHIFT) /* 1100: fSAMPLING = fEEVS/16, N=8 */
+# define HRTIM_EECR3_EE9F_EEVS32N5 (13 << HRTIM_EECR3_EE9F_SHIFT) /* 1101: fSAMPLING = fEEVS/32, N=5 */
+# define HRTIM_EECR3_EE9F_EEVS32N6 (14 << HRTIM_EECR3_EE9F_SHIFT) /* 1110: fSAMPLING = fEEVS/32, N=6 */
+# define HRTIM_EECR3_EE9F_EEVS32N8 (15 << HRTIM_EECR3_EE9F_SHIFT) /* 1111: fSAMPLING = fEEVS/32, N=8 */
+#define HRTIM_EECR3_EE10F_SHIFT 24 /* Bits 24-27: External Event 10 Filter */
+#define HRTIM_EECR3_EE10F_MASK (15 << HRTIM_EECR3_EE10F_SHIFT)
+# define HRTIM_EECR3_EE10F_NOFLT (0 << HRTIM_EECR3_EE10F_SHIFT) /* 0000: No filter, FLT5 acts asynchronously */
+# define HRTIM_EECR3_EE10F_HRTN2 (1 << HRTIM_EECR3_EE10F_SHIFT) /* 0001: fSAMPLING = fHRTIM, N=2 */
+# define HRTIM_EECR3_EE10F_HRTN4 (2 << HRTIM_EECR3_EE10F_SHIFT) /* 0010: fSAMPLING = fHRTIM, N=4 */
+# define HRTIM_EECR3_EE10F_HRTN8 (3 << HRTIM_EECR3_EE10F_SHIFT) /* 0011: fSAMPLING = fHRTIM, N=8 */
+# define HRTIM_EECR3_EE10F_EEVS2N6 (4 << HRTIM_EECR3_EE10F_SHIFT) /* 0100: fSAMPLING = fEEVS/2, N=6 */
+# define HRTIM_EECR3_EE10F_EEVS2N8 (5 << HRTIM_EECR3_EE10F_SHIFT) /* 0101: fSAMPLING = fEEVS/2, N=8 */
+# define HRTIM_EECR3_EE10F_EEVS4N6 (6 << HRTIM_EECR3_EE10F_SHIFT) /* 0110: fSAMPLING = fEEVS/4, N=6 */
+# define HRTIM_EECR3_EE10F_EEVS4N8 (7 << HRTIM_EECR3_EE10F_SHIFT) /* 0111: fSAMPLING = fEEVS/4, N=8 */
+# define HRTIM_EECR3_EE10F_EEVS8N6 (8 << HRTIM_EECR3_EE10F_SHIFT) /* 1000: fSAMPLING = fEEVS/8, N=6 */
+# define HRTIM_EECR3_EE10F_EEVS8N8 (9 << HRTIM_EECR3_EE10F_SHIFT) /* 1001: fSAMPLING = fEEVS/8, N=8 */
+# define HRTIM_EECR3_EE10F_EEVS16N5 (10 << HRTIM_EECR3_EE10F_SHIFT) /* 1010: fSAMPLING = fEEVS/16, N=5 */
+# define HRTIM_EECR3_EE10F_EEVS16N6 (11 << HRTIM_EECR3_EE10F_SHIFT) /* 1011: fSAMPLING = fEEVS/16, N=6 */
+# define HRTIM_EECR3_EE10F_EEVS16N8 (12 << HRTIM_EECR3_EE10F_SHIFT) /* 1100: fSAMPLING = fEEVS/16, N=8 */
+# define HRTIM_EECR3_EE10F_EEVS32N5 (13 << HRTIM_EECR3_EE10F_SHIFT) /* 1101: fSAMPLING = fEEVS/32, N=5 */
+# define HRTIM_EECR3_EE10F_EEVS32N6 (14 << HRTIM_EECR3_EE10F_SHIFT) /* 1110: fSAMPLING = fEEVS/32, N=6 */
+# define HRTIM_EECR3_EE10F_EEVS32N8 (15 << HRTIM_EECR3_EE10F_SHIFT) /* 1111: fSAMPLING = fEEVS/32, N=8 */
+#define HRTIM_EECR3_EEVSD_SHIFT 30 /* Bits 30-31: External Event Sampling clock division */
+#define HRTIM_EECR3_EEVSD_MASK (3 << HRTIM_EECR3_EEVSD_SHIFT)
+#define HRTIM_EECR3_EEVSD_NODIV (0 << HRTIM_EECR3_EEVSD_SHIFT) /* 00: fEEVS=fHRTIM */
+#define HRTIM_EECR3_EEVSD_d2 (1 << HRTIM_EECR3_EEVSD_SHIFT) /* 01: fEEVS=fHRTIM/2 */
+#define HRTIM_EECR3_EEVSD_d4 (2 << HRTIM_EECR3_EEVSD_SHIFT) /* 10: fEEVS=fHRTIM/4 */
+#define HRTIM_EECR3_EEVSD_d8 (3 << HRTIM_EECR3_EEVSD_SHIFT) /* 11: fEEVS=fHRTIM/8 */
+
+/* Common ADC Trigger 1 Register */
+
+#define HRTIM_ADC1R_AD1MC1 (1 << 0) /* Bit 0: ADC trigger 1 on Master Compare 1 */
+#define HRTIM_ADC1R_AD1MC2 (1 << 1) /* Bit 1: ADC trigger 1 on Master Compare 2 */
+#define HRTIM_ADC1R_AD1MC3 (1 << 2) /* Bit 2: ADC trigger 1 on Master Compare 3 */
+#define HRTIM_ADC1R_AD1MC4 (1 << 3) /* Bit 3: ADC trigger 1 on Master Compare 4 */
+#define HRTIM_ADC1R_AD1MPER (1 << 4) /* Bit 4: ADC trigger 1 on Master Period*/
+#define HRTIM_ADC1R_AD1EEV1 (1 << 5) /* Bit 5: ADC trigger 1 on External Event 1 */
+#define HRTIM_ADC1R_AD1EEV2 (1 << 6) /* Bit 6: ADC trigger 1 on External Event 2 */
+#define HRTIM_ADC1R_AD1EEV3 (1 << 7) /* Bit 7: ADC trigger 1 on External Event 3 */
+#define HRTIM_ADC1R_AD1EEV4 (1 << 8) /* Bit 8: ADC trigger 1 on External Event 4 */
+#define HRTIM_ADC1R_AD1EEV5 (1 << 9) /* Bit 9: ADC trigger 1 on External Event 5 */
+#define HRTIM_ADC1R_AD1TAC2 (1 << 10) /* Bit 10: ADC trigger 1 on Timer A Compare 2 */
+#define HRTIM_ADC1R_AD1TAC3 (1 << 11) /* Bit 11: ADC trigger 1 on Timer A Compare 3 */
+#define HRTIM_ADC1R_AD1TAC4 (1 << 12) /* Bit 12: ADC trigger 1 on Timer A Compare 4 */
+#define HRTIM_ADC1R_AD1TAPER (1 << 13) /* Bit 13: ADC trigger 1 on Timer A Period */
+#define HRTIM_ADC1R_AD1TARST (1 << 14) /* Bit 14: ADC trigger 1 on Timer A Reset and counter roll-over*/
+#define HRTIM_ADC1R_AD1TBC2 (1 << 15) /* Bit 15: ADC trigger 1 on Timer B Compare 2 */
+#define HRTIM_ADC1R_AD1TBC3 (1 << 16) /* Bit 16: ADC trigger 1 on Timer B Compare 3 */
+#define HRTIM_ADC1R_AD1TBC4 (1 << 17) /* Bit 17: ADC trigger 1 on Timer B Compare 4 */
+#define HRTIM_ADC1R_AD1TBPER (1 << 18) /* Bit 18: ADC trigger 1 on Timer B Period */
+#define HRTIM_ADC1R_AD1TBRST (1 << 19) /* Bit 19: ADC trigger 1 on Timer B Reset and counter roll-over */
+#define HRTIM_ADC1R_AD1TCC2 (1 << 20) /* Bit 20: ADC trigger 1 on Timer C Compare 2 */
+#define HRTIM_ADC1R_AD1TCC3 (1 << 21) /* Bit 21: ADC trigger 1 on Timer C Compare 3 */
+#define HRTIM_ADC1R_AD1TCC4 (1 << 22) /* Bit 22: ADC trigger 1 on Timer C Compare 4 */
+#define HRTIM_ADC1R_AD1TCPER (1 << 23) /* Bit 23: ADC trigger 1 on Timer C Period*/
+#define HRTIM_ADC1R_AD1TDC2 (1 << 24) /* Bit 24: ADC trigger 1 on Timer D Compare 2 */
+#define HRTIM_ADC1R_AD1TDC3 (1 << 25) /* Bit 25: ADC trigger 1 on Timer D Compare 3 */
+#define HRTIM_ADC1R_AD1TDC4 (1 << 26) /* Bit 26: ADC trigger 1 on Timer D Compare 4 */
+#define HRTIM_ADC1R_AD1TDPER (1 << 27) /* Bit 27: ADC trigger 1 on Timer D Period*/
+#define HRTIM_ADC1R_AD1TEC2 (1 << 28) /* Bit 28: ADC trigger 1 on Timer E Compare 2 */
+#define HRTIM_ADC1R_AD1TEC3 (1 << 29) /* Bit 29: ADC trigger 1 on Timer E Compare 3 */
+#define HRTIM_ADC1R_AD1TEC4 (1 << 30) /* Bit 30: ADC trigger 1 on Timer E Compare 4 */
+#define HRTIM_ADC1R_AD1TEPER (1 << 31) /* Bit 31: ADC trigger 1 on Timer E Period */
+
+/* Common ADC Trigger 2 Register */
+
+#define HRTIM_ADC2R_AD2MC1 (1 << 0) /* Bit 0: ADC trigger 2 on Master Compare 1 */
+#define HRTIM_ADC2R_AD2MC2 (1 << 1) /* Bit 1: ADC trigger 2 on Master Compare 2 */
+#define HRTIM_ADC2R_AD2MC3 (1 << 2) /* Bit 2: ADC trigger 2 on Master Compare 3 */
+#define HRTIM_ADC2R_AD2MC4 (1 << 3) /* Bit 3: ADC trigger 2 on Master Compare 4 */
+#define HRTIM_ADC2R_AD2MPER (1 << 4) /* Bit 4: ADC trigger 2 on Master Period*/
+#define HRTIM_ADC2R_AD2EEV6 (1 << 5) /* Bit 5: ADC trigger 2 on External Event 6 */
+#define HRTIM_ADC2R_AD2EEV7 (1 << 6) /* Bit 6: ADC trigger 2 on External Event 7 */
+#define HRTIM_ADC2R_AD2EEV8 (1 << 7) /* Bit 7: ADC trigger 2 on External Event 8 */
+#define HRTIM_ADC2R_AD2EEV9 (1 << 8) /* Bit 8: ADC trigger 2 on External Event 9 */
+#define HRTIM_ADC2R_AD2EEV10 (1 << 9) /* Bit 9: ADC trigger 2 on External Event 10 */
+#define HRTIM_ADC2R_AD2TAC2 (1 << 10) /* Bit 10: ADC trigger 2 on Timer A Compare 2 */
+#define HRTIM_ADC2R_AD2TAC3 (1 << 11) /* Bit 11: ADC trigger 2 on Timer A Compare 3 */
+#define HRTIM_ADC2R_AD2TAC4 (1 << 12) /* Bit 12: ADC trigger 2 on Timer A Compare 4 */
+#define HRTIM_ADC2R_AD2TAPER (1 << 13) /* Bit 13: ADC trigger 2 on Timer A Period */
+#define HRTIM_ADC2R_AD2TBC2 (1 << 14) /* Bit 14: ADC trigger 2 on Timer B Compare 2 */
+#define HRTIM_ADC2R_AD2TBC3 (1 << 15) /* Bit 15: ADC trigger 2 on Timer B Compare 3 */
+#define HRTIM_ADC2R_AD2TBC4 (1 << 16) /* Bit 16: ADC trigger 2 on Timer B Compare 4 */
+#define HRTIM_ADC2R_AD2TBPER (1 << 17) /* Bit 18: ADC trigger 2 on Timer B Period */
+#define HRTIM_ADC2R_AD2TCC2 (1 << 18) /* Bit 19: ADC trigger 2 on Timer C Compare 2 */
+#define HRTIM_ADC2R_AD2TCC3 (1 << 19) /* Bit 20: ADC trigger 2 on Timer C Compare 3 */
+#define HRTIM_ADC2R_AD2TCC4 (1 << 20) /* Bit 21: ADC trigger 2 on Timer C Compare 4 */
+#define HRTIM_ADC2R_AD2TCPER (1 << 21) /* Bit 22: ADC trigger 2 on Timer C Period*/
+#define HRTIM_ADC2R_AD2TCRST (1 << 22) /* Bit 22: ADC trigger 2 on Timer C Reset and counter roll-over*/
+#define HRTIM_ADC2R_AD2TDC2 (1 << 23) /* Bit 23: ADC trigger 2 on Timer D Compare 2 */
+#define HRTIM_ADC2R_AD2TDC3 (1 << 24) /* Bit 24: ADC trigger 2 on Timer D Compare 3 */
+#define HRTIM_ADC2R_AD2TDC4 (1 << 25) /* Bit 25: ADC trigger 2 on Timer D Compare 4 */
+#define HRTIM_ADC2R_AD2TDPER (1 << 26) /* Bit 26: ADC trigger 2 on Timer D Period*/
+#define HRTIM_ADC2R_AD2TDRST (1 << 27) /* Bit 27: ADC trigger 2 on Timer D Reset and counter roll-over*/
+#define HRTIM_ADC2R_AD2TEC2 (1 << 28) /* Bit 28: ADC trigger 2 on Timer E Compare 2 */
+#define HRTIM_ADC2R_AD2TEC3 (1 << 29) /* Bit 29: ADC trigger 2 on Timer E Compare 3 */
+#define HRTIM_ADC2R_AD2TEC4 (1 << 30) /* Bit 30: ADC trigger 2 on Timer E Compare 4 */
+#define HRTIM_ADC2R_AD2TERST (1 << 31) /* Bit 31: ADC trigger 2 on Timer E Reset and counter roll-over */
+
+/* Common ADC Trigger 3 Register */
+
+#define HRTIM_ADC3R_AD3MC1 (1 << 0) /* Bit 0: ADC trigger 3 on Master Compare 1 */
+#define HRTIM_ADC3R_AD3MC2 (1 << 1) /* Bit 1: ADC trigger 3 on Master Compare 2 */
+#define HRTIM_ADC3R_AD3MC3 (1 << 2) /* Bit 2: ADC trigger 3 on Master Compare 3 */
+#define HRTIM_ADC3R_AD3MC4 (1 << 3) /* Bit 3: ADC trigger 3 on Master Compare 4 */
+#define HRTIM_ADC3R_AD3MPER (1 << 4) /* Bit 4: ADC trigger 3 on Master Period*/
+#define HRTIM_ADC3R_AD3EEV1 (1 << 5) /* Bit 5: ADC trigger 3 on External Event 1 */
+#define HRTIM_ADC3R_AD3EEV2 (1 << 6) /* Bit 6: ADC trigger 3 on External Event 2 */
+#define HRTIM_ADC3R_AD3EEV3 (1 << 7) /* Bit 7: ADC trigger 3 on External Event 3 */
+#define HRTIM_ADC3R_AD3EEV4 (1 << 8) /* Bit 8: ADC trigger 3 on External Event 4 */
+#define HRTIM_ADC3R_AD3EEV5 (1 << 9) /* Bit 9: ADC trigger 3 on External Event 5 */
+#define HRTIM_ADC3R_AD3TAC2 (1 << 10) /* Bit 10: ADC trigger 3 on Timer A Compare 2 */
+#define HRTIM_ADC3R_AD3TAC3 (1 << 11) /* Bit 11: ADC trigger 3 on Timer A Compare 3 */
+#define HRTIM_ADC3R_AD3TAC4 (1 << 12) /* Bit 12: ADC trigger 3 on Timer A Compare 4 */
+#define HRTIM_ADC3R_AD3TAPER (1 << 13) /* Bit 13: ADC trigger 3 on Timer A Period */
+#define HRTIM_ADC3R_AD3TARST (1 << 14) /* Bit 14: ADC trigger 3 on Timer A Reset and counter roll-over*/
+#define HRTIM_ADC3R_AD3TBC2 (1 << 15) /* Bit 15: ADC trigger 3 on Timer B Compare 2 */
+#define HRTIM_ADC3R_AD3TBC3 (1 << 16) /* Bit 16: ADC trigger 3 on Timer B Compare 3 */
+#define HRTIM_ADC3R_AD3TBC4 (1 << 17) /* Bit 17: ADC trigger 3 on Timer B Compare 4 */
+#define HRTIM_ADC3R_AD3TBPER (1 << 18) /* Bit 18: ADC trigger 3 on Timer B Period */
+#define HRTIM_ADC3R_AD3TBRST (1 << 19) /* Bit 19: ADC trigger 3 on Timer B Reset and counter roll-over */
+#define HRTIM_ADC3R_AD3TCC2 (1 << 20) /* Bit 20: ADC trigger 3 on Timer C Compare 2 */
+#define HRTIM_ADC3R_AD3TCC3 (1 << 21) /* Bit 21: ADC trigger 3 on Timer C Compare 3 */
+#define HRTIM_ADC3R_AD3TCC4 (1 << 22) /* Bit 22: ADC trigger 3 on Timer C Compare 4 */
+#define HRTIM_ADC3R_AD3TCPER (1 << 23) /* Bit 23: ADC trigger 3 on Timer C Period*/
+#define HRTIM_ADC3R_AD3TDC2 (1 << 24) /* Bit 24: ADC trigger 3 on Timer D Compare 2 */
+#define HRTIM_ADC3R_AD3TDC3 (1 << 25) /* Bit 25: ADC trigger 3 on Timer D Compare 3 */
+#define HRTIM_ADC3R_AD3TDC4 (1 << 26) /* Bit 26: ADC trigger 3 on Timer D Compare 4 */
+#define HRTIM_ADC3R_AD3TDPER (1 << 27) /* Bit 27: ADC trigger 3 on Timer D Period*/
+#define HRTIM_ADC3R_AD3TEC2 (1 << 28) /* Bit 28: ADC trigger 3 on Timer E Compare 2 */
+#define HRTIM_ADC3R_AD3TEC3 (1 << 29) /* Bit 29: ADC trigger 3 on Timer E Compare 3 */
+#define HRTIM_ADC3R_AD3TEC4 (1 << 30) /* Bit 30: ADC trigger 3 on Timer E Compare 4 */
+#define HRTIM_ADC3R_AD3TEPER (1 << 31) /* Bit 31: ADC trigger 3 on Timer E Period */
+
+/* Common ADC Trigger 4 Register */
+
+#define HRTIM_ADC4R_AD4MC1 (1 << 0) /* Bit 0: ADC trigger 4 on Master Compare 1 */
+#define HRTIM_ADC4R_AD4MC2 (1 << 1) /* Bit 1: ADC trigger 4 on Master Compare 2 */
+#define HRTIM_ADC4R_AD4MC3 (1 << 2) /* Bit 2: ADC trigger 4 on Master Compare 3 */
+#define HRTIM_ADC4R_AD4MC4 (1 << 3) /* Bit 3: ADC trigger 4 on Master Compare 4 */
+#define HRTIM_ADC4R_AD4MPER (1 << 4) /* Bit 4: ADC trigger 4 on Master Period*/
+#define HRTIM_ADC4R_AD4EEV6 (1 << 5) /* Bit 5: ADC trigger 4 on External Event 6 */
+#define HRTIM_ADC4R_AD4EEV7 (1 << 6) /* Bit 6: ADC trigger 4 on External Event 7 */
+#define HRTIM_ADC4R_AD4EEV8 (1 << 7) /* Bit 7: ADC trigger 4 on External Event 8 */
+#define HRTIM_ADC4R_AD4EEV9 (1 << 8) /* Bit 8: ADC trigger 4 on External Event 9 */
+#define HRTIM_ADC4R_AD4EEV10 (1 << 9) /* Bit 9: ADC trigger 4 on External Event 10 */
+#define HRTIM_ADC4R_AD4TAC2 (1 << 10) /* Bit 10: ADC trigger 4 on Timer A Compare 2 */
+#define HRTIM_ADC4R_AD4TAC3 (1 << 11) /* Bit 11: ADC trigger 4 on Timer A Compare 3 */
+#define HRTIM_ADC4R_AD4TAC4 (1 << 12) /* Bit 12: ADC trigger 4 on Timer A Compare 4 */
+#define HRTIM_ADC4R_AD4TAPER (1 << 13) /* Bit 13: ADC trigger 4 on Timer A Period */
+#define HRTIM_ADC4R_AD4TBC2 (1 << 14) /* Bit 14: ADC trigger 4 on Timer B Compare 2 */
+#define HRTIM_ADC4R_AD4TBC3 (1 << 15) /* Bit 15: ADC trigger 4 on Timer B Compare 3 */
+#define HRTIM_ADC4R_AD4TBC4 (1 << 16) /* Bit 16: ADC trigger 4 on Timer B Compare 4 */
+#define HRTIM_ADC4R_AD4TBPER (1 << 17) /* Bit 18: ADC trigger 4 on Timer B Period */
+#define HRTIM_ADC4R_AD4TCC2 (1 << 18) /* Bit 19: ADC trigger 4 on Timer C Compare 2 */
+#define HRTIM_ADC4R_AD4TCC3 (1 << 19) /* Bit 20: ADC trigger 4 on Timer C Compare 3 */
+#define HRTIM_ADC4R_AD4TCC4 (1 << 20) /* Bit 21: ADC trigger 4 on Timer C Compare 4 */
+#define HRTIM_ADC4R_AD4TCPER (1 << 21) /* Bit 22: ADC trigger 4 on Timer C Period*/
+#define HRTIM_ADC4R_AD4TCRST (1 << 22) /* Bit 22: ADC trigger 4 on Timer C Reset and counter roll-over*/
+#define HRTIM_ADC4R_AD4TDC2 (1 << 23) /* Bit 23: ADC trigger 4 on Timer D Compare 2 */
+#define HRTIM_ADC4R_AD4TDC3 (1 << 24) /* Bit 24: ADC trigger 4 on Timer D Compare 3 */
+#define HRTIM_ADC4R_AD4TDC4 (1 << 25) /* Bit 25: ADC trigger 4 on Timer D Compare 4 */
+#define HRTIM_ADC4R_AD4TDPER (1 << 26) /* Bit 26: ADC trigger 4 on Timer D Period*/
+#define HRTIM_ADC4R_AD4TDRST (1 << 27) /* Bit 27: ADC trigger 4 on Timer D Reset and counter roll-over*/
+#define HRTIM_ADC4R_AD4TEC2 (1 << 28) /* Bit 28: ADC trigger 4 on Timer E Compare 2 */
+#define HRTIM_ADC4R_AD4TEC3 (1 << 29) /* Bit 29: ADC trigger 4 on Timer E Compare 3 */
+#define HRTIM_ADC4R_AD4TEC4 (1 << 30) /* Bit 30: ADC trigger 4 on Timer E Compare 4 */
+#define HRTIM_ADC4R_AD4TERST (1 << 31) /* Bit 31: ADC trigger 4 on Timer E Reset and counter roll-over */
+
+
+/* Common DLL Control Register */
+
+#define HRTIM_DLLCR_CAL (1 << 0) /* Bit 0: DLL Calibration Start */
+#define HRTIM_DLLCR_CALEN (1 << 1) /* Bit 1: DLL Calibration Enable */
+#define HRTIM_DLLCR_CALRTE_SHIFT 2 /* Bits 2-3: DLL Calibration rate */
+#define HRTIM_DLLCR_CALRTE_MASK (3 << HRTIM_DLLCR_CALRTE_SHIFT)
+# define HRTIM_DLLCR_CALRTE_1048576 (0 << HRTIM_DLLCR_CALRTE_SHIFT) /* 00: 1048576 * tHRTIM */
+# define HRTIM_DLLCR_CALRTE_131072 (1 << HRTIM_DLLCR_CALRTE_SHIFT) /* 01: 131072 * tHRTIM */
+# define HRTIM_DLLCR_CALRTE_16384 (2 << HRTIM_DLLCR_CALRTE_SHIFT) /* 10: 16384 * tHRTIM */
+# define HRTIM_DLLCR_CALRTE_2048 (3 << HRTIM_DLLCR_CALRTE_SHIFT) /* 11: 2048 * tHRTIM */
+
+/* Common Fault Input Register 1 */
+
+#define HRTIM_FLTINR1_FLT1E (1 << 0) /* Bit 0: Fault 1 enable */
+#define HRTIM_FLTINR1_FLT1P (1 << 1) /* Bit 1: Fault 1 polarity */
+#define HRTIM_FLTINR1_FLT1SRC (1 << 2) /* Bit 2: Fault 1 source */
+#define HRTIM_FLTINR1_FLT1F_SHIFT 3 /* Bits 3-6: Fault 1 source */
+#define HRTIM_FLTINR1_FLT1F_MASK (15 << HRTIM_FLTINR1_FLT1F_SHIFT)
+# define HRTIM_FLTINR1_FLT1F_NOFLT (0 << HRTIM_FLTINR1_FLT1F_SHIFT) /* 0000: No filter, FLT5 acts asynchronously */
+# define HRTIM_FLTINR1_FLT1F_HRTN2 (1 << HRTIM_FLTINR1_FLT1F_SHIFT) /* 0001: fSAMPLING = fHRTIM, N=2 */
+# define HRTIM_FLTINR1_FLT1F_HRTN4 (2 << HRTIM_FLTINR1_FLT1F_SHIFT) /* 0010: fSAMPLING = fHRTIM, N=4 */
+# define HRTIM_FLTINR1_FLT1F_HRTN8 (3 << HRTIM_FLTINR1_FLT1F_SHIFT) /* 0011: fSAMPLING = fHRTIM, N=8 */
+# define HRTIM_FLTINR1_FLT1F_FLTS2N6 (4 << HRTIM_FLTINR1_FLT1F_SHIFT) /* 0100: fSAMPLING = fFLTS/2, N=6 */
+# define HRTIM_FLTINR1_FLT1F_FLTS2N8 (5 << HRTIM_FLTINR1_FLT1F_SHIFT) /* 0101: fSAMPLING = fFLTS/2, N=8 */
+# define HRTIM_FLTINR1_FLT1F_FLTS4N6 (6 << HRTIM_FLTINR1_FLT1F_SHIFT) /* 0110: fSAMPLING = fFLTS/4, N=6 */
+# define HRTIM_FLTINR1_FLT1F_FLTS4N8 (7 << HRTIM_FLTINR1_FLT1F_SHIFT) /* 0111: fSAMPLING = fFLTS/4, N=8 */
+# define HRTIM_FLTINR1_FLT1F_FLTS8N6 (8 << HRTIM_FLTINR1_FLT1F_SHIFT) /* 1000: fSAMPLING = fFLTS/8, N=6 */
+# define HRTIM_FLTINR1_FLT1F_FLTS8N8 (9 << HRTIM_FLTINR1_FLT1F_SHIFT) /* 1001: fSAMPLING = fFLTS/8, N=8 */
+# define HRTIM_FLTINR1_FLT1F_FLTS16N5 (10 << HRTIM_FLTINR1_FLT1F_SHIFT) /* 1010: fSAMPLING = fFLTS/16, N=5 */
+# define HRTIM_FLTINR1_FLT1F_FLTS16N6 (11 << HRTIM_FLTINR1_FLT1F_SHIFT) /* 1011: fSAMPLING = fFLTS/16, N=6 */
+# define HRTIM_FLTINR1_FLT1F_FLTS16N8 (12 << HRTIM_FLTINR1_FLT1F_SHIFT) /* 1100: fSAMPLING = fFLTS/16, N=8 */
+# define HRTIM_FLTINR1_FLT1F_FLTS32N5 (13 << HRTIM_FLTINR1_FLT1F_SHIFT) /* 1101: fSAMPLING = fFLTS/32, N=5 */
+# define HRTIM_FLTINR1_FLT1F_FLTS32N6 (14 << HRTIM_FLTINR1_FLT1F_SHIFT) /* 1110: fSAMPLING = fFLTS/32, N=6 */
+# define HRTIM_FLTINR1_FLT1F_FLTS32N8 (15 << HRTIM_FLTINR1_FLT1F_SHIFT) /* 1111: fSAMPLING = fFLTS/32, N=8 */
+#define HRTIM_FLTINR1_FLT1LCK (1 << 7) /* Bit 7: Fault 1 lock */
+#define HRTIM_FLTINR1_FLT2E (1 << 8) /* Bit 8: Fault 2 enable */
+#define HRTIM_FLTINR1_FLT2P (1 << 9) /* Bit 9: Fault 2 polarity */
+#define HRTIM_FLTINR1_FLT2SRC (1 << 10) /* Bit 10: Fault 2 source */
+#define HRTIM_FLTINR1_FLT2F_SHIFT 11 /* Bits 11-14: Fault 2 source */
+#define HRTIM_FLTINR1_FLT2F_MASK (15 << HRTIM_FLTINR1_FLT2F_SHIFT)
+# define HRTIM_FLTINR1_FLT2F_NOFLT (0 << HRTIM_FLTINR1_FLT2F_SHIFT) /* 0000: No filter, FLT5 acts asynchronously */
+# define HRTIM_FLTINR1_FLT2F_HRTN2 (1 << HRTIM_FLTINR1_FLT2F_SHIFT) /* 0001: fSAMPLING = fHRTIM, N=2 */
+# define HRTIM_FLTINR1_FLT2F_HRTN4 (2 << HRTIM_FLTINR1_FLT2F_SHIFT) /* 0010: fSAMPLING = fHRTIM, N=4 */
+# define HRTIM_FLTINR1_FLT2F_HRTN8 (3 << HRTIM_FLTINR1_FLT2F_SHIFT) /* 0011: fSAMPLING = fHRTIM, N=8 */
+# define HRTIM_FLTINR1_FLT2F_FLTS2N6 (4 << HRTIM_FLTINR1_FLT2F_SHIFT) /* 0100: fSAMPLING = fFLTS/2, N=6 */
+# define HRTIM_FLTINR1_FLT2F_FLTS2N8 (5 << HRTIM_FLTINR1_FLT2F_SHIFT) /* 0101: fSAMPLING = fFLTS/2, N=8 */
+# define HRTIM_FLTINR1_FLT2F_FLTS4N6 (6 << HRTIM_FLTINR1_FLT2F_SHIFT) /* 0110: fSAMPLING = fFLTS/4, N=6 */
+# define HRTIM_FLTINR1_FLT2F_FLTS4N8 (7 << HRTIM_FLTINR1_FLT2F_SHIFT) /* 0111: fSAMPLING = fFLTS/4, N=8 */
+# define HRTIM_FLTINR1_FLT2F_FLTS8N6 (8 << HRTIM_FLTINR1_FLT2F_SHIFT) /* 1000: fSAMPLING = fFLTS/8, N=6 */
+# define HRTIM_FLTINR1_FLT2F_FLTS8N8 (9 << HRTIM_FLTINR1_FLT2F_SHIFT) /* 1001: fSAMPLING = fFLTS/8, N=8 */
+# define HRTIM_FLTINR1_FLT2F_FLTS16N5 (10 << HRTIM_FLTINR1_FLT2F_SHIFT) /* 1010: fSAMPLING = fFLTS/16, N=5 */
+# define HRTIM_FLTINR1_FLT2F_FLTS16N6 (11 << HRTIM_FLTINR1_FLT2F_SHIFT) /* 1011: fSAMPLING = fFLTS/16, N=6 */
+# define HRTIM_FLTINR1_FLT2F_FLTS16N8 (12 << HRTIM_FLTINR1_FLT2F_SHIFT) /* 1100: fSAMPLING = fFLTS/16, N=8 */
+# define HRTIM_FLTINR1_FLT2F_FLTS32N5 (13 << HRTIM_FLTINR1_FLT2F_SHIFT) /* 1101: fSAMPLING = fFLTS/32, N=5 */
+# define HRTIM_FLTINR1_FLT2F_FLTS32N6 (14 << HRTIM_FLTINR1_FLT2F_SHIFT) /* 1110: fSAMPLING = fFLTS/32, N=6 */
+# define HRTIM_FLTINR1_FLT2F_FLTS32N8 (15 << HRTIM_FLTINR1_FLT2F_SHIFT) /* 1111: fSAMPLING = fFLTS/32, N=8 */
+#define HRTIM_FLTINR1_FLT2LCK (1 << 15) /* Bit 15: Fault 2 lock */
+#define HRTIM_FLTINR1_FLT3E (1 << 16) /* Bit 16: Fault 3 enable */
+#define HRTIM_FLTINR1_FLT3P (1 << 17) /* Bit 17: Fault 3 polarity */
+#define HRTIM_FLTINR1_FLT3SRC (1 << 18) /* Bit 18: Fault 3 source */
+#define HRTIM_FLTINR1_FLT3F_SHIFT 19 /* Bits 19-22: Fault 3 source */
+#define HRTIM_FLTINR1_FLT3F_MASK (15 << HRTIM_FLTINR1_FLT3F_SHIFT)
+# define HRTIM_FLTINR1_FLT3F_NOFLT (0 << HRTIM_FLTINR1_FLT3F_SHIFT) /* 0000: No filter, FLT5 acts asynchronously */
+# define HRTIM_FLTINR1_FLT3F_HRTN2 (1 << HRTIM_FLTINR1_FLT3F_SHIFT) /* 0001: fSAMPLING = fHRTIM, N=2 */
+# define HRTIM_FLTINR1_FLT3F_HRTN4 (2 << HRTIM_FLTINR1_FLT3F_SHIFT) /* 0010: fSAMPLING = fHRTIM, N=4 */
+# define HRTIM_FLTINR1_FLT3F_HRTN8 (3 << HRTIM_FLTINR1_FLT3F_SHIFT) /* 0011: fSAMPLING = fHRTIM, N=8 */
+# define HRTIM_FLTINR1_FLT3F_FLTS2N6 (4 << HRTIM_FLTINR1_FLT3F_SHIFT) /* 0100: fSAMPLING = fFLTS/2, N=6 */
+# define HRTIM_FLTINR1_FLT3F_FLTS2N8 (5 << HRTIM_FLTINR1_FLT3F_SHIFT) /* 0101: fSAMPLING = fFLTS/2, N=8 */
+# define HRTIM_FLTINR1_FLT3F_FLTS4N6 (6 << HRTIM_FLTINR1_FLT3F_SHIFT) /* 0110: fSAMPLING = fFLTS/4, N=6 */
+# define HRTIM_FLTINR1_FLT3F_FLTS4N8 (7 << HRTIM_FLTINR1_FLT3F_SHIFT) /* 0111: fSAMPLING = fFLTS/4, N=8 */
+# define HRTIM_FLTINR1_FLT3F_FLTS8N6 (8 << HRTIM_FLTINR1_FLT3F_SHIFT) /* 1000: fSAMPLING = fFLTS/8, N=6 */
+# define HRTIM_FLTINR1_FLT3F_FLTS8N8 (9 << HRTIM_FLTINR1_FLT3F_SHIFT) /* 1001: fSAMPLING = fFLTS/8, N=8 */
+# define HRTIM_FLTINR1_FLT3F_FLTS16N5 (10 << HRTIM_FLTINR1_FLT3F_SHIFT) /* 1010: fSAMPLING = fFLTS/16, N=5 */
+# define HRTIM_FLTINR1_FLT3F_FLTS16N6 (11 << HRTIM_FLTINR1_FLT3F_SHIFT) /* 1011: fSAMPLING = fFLTS/16, N=6 */
+# define HRTIM_FLTINR1_FLT3F_FLTS16N8 (12 << HRTIM_FLTINR1_FLT3F_SHIFT) /* 1100: fSAMPLING = fFLTS/16, N=8 */
+# define HRTIM_FLTINR1_FLT3F_FLTS32N5 (13 << HRTIM_FLTINR1_FLT3F_SHIFT) /* 1101: fSAMPLING = fFLTS/32, N=5 */
+# define HRTIM_FLTINR1_FLT3F_FLTS32N6 (14 << HRTIM_FLTINR1_FLT3F_SHIFT) /* 1110: fSAMPLING = fFLTS/32, N=6 */
+# define HRTIM_FLTINR1_FLT3F_FLTS32N8 (15 << HRTIM_FLTINR1_FLT3F_SHIFT) /* 1111: fSAMPLING = fFLTS/32, N=8 */
+#define HRTIM_FLTINR1_FLT3LCK (1 << 23) /* Bit 23: Fault 3 lock */
+#define HRTIM_FLTINR1_FLT4E (1 << 24) /* Bit 24: Fault 4 enable */
+#define HRTIM_FLTINR1_FLT4P (1 << 25) /* Bit 25: Fault 4 polarity */
+#define HRTIM_FLTINR1_FLT4SRC (1 << 26) /* Bit 26: Fault 4 source */
+#define HRTIM_FLTINR1_FLT4F_SHIFT 27 /* Bits 27-30: Fault 4 source */
+#define HRTIM_FLTINR1_FLT4F_MASK (15 << HRTIM_FLTINR1_FLT4F_SHIFT)
+# define HRTIM_FLTINR1_FLT4F_NOFLT (0 << HRTIM_FLTINR1_FLT4F_SHIFT) /* 0000: No filter, FLT5 acts asynchronously */
+# define HRTIM_FLTINR1_FLT4F_HRTN2 (1 << HRTIM_FLTINR1_FLT4F_SHIFT) /* 0001: fSAMPLING = fHRTIM, N=2 */
+# define HRTIM_FLTINR1_FLT4F_HRTN4 (2 << HRTIM_FLTINR1_FLT4F_SHIFT) /* 0010: fSAMPLING = fHRTIM, N=4 */
+# define HRTIM_FLTINR1_FLT4F_HRTN8 (3 << HRTIM_FLTINR1_FLT4F_SHIFT) /* 0011: fSAMPLING = fHRTIM, N=8 */
+# define HRTIM_FLTINR1_FLT4F_FLTS2N6 (4 << HRTIM_FLTINR1_FLT4F_SHIFT) /* 0100: fSAMPLING = fFLTS/2, N=6 */
+# define HRTIM_FLTINR1_FLT4F_FLTS2N8 (5 << HRTIM_FLTINR1_FLT4F_SHIFT) /* 0101: fSAMPLING = fFLTS/2, N=8 */
+# define HRTIM_FLTINR1_FLT4F_FLTS4N6 (6 << HRTIM_FLTINR1_FLT4F_SHIFT) /* 0110: fSAMPLING = fFLTS/4, N=6 */
+# define HRTIM_FLTINR1_FLT4F_FLTS4N8 (7 << HRTIM_FLTINR1_FLT4F_SHIFT) /* 0111: fSAMPLING = fFLTS/4, N=8 */
+# define HRTIM_FLTINR1_FLT4F_FLTS8N6 (8 << HRTIM_FLTINR1_FLT4F_SHIFT) /* 1000: fSAMPLING = fFLTS/8, N=6 */
+# define HRTIM_FLTINR1_FLT4F_FLTS8N8 (9 << HRTIM_FLTINR1_FLT4F_SHIFT) /* 1001: fSAMPLING = fFLTS/8, N=8 */
+# define HRTIM_FLTINR1_FLT4F_FLTS16N5 (10 << HRTIM_FLTINR1_FLT4F_SHIFT) /* 1010: fSAMPLING = fFLTS/16, N=5 */
+# define HRTIM_FLTINR1_FLT4F_FLTS16N6 (11 << HRTIM_FLTINR1_FLT4F_SHIFT) /* 1011: fSAMPLING = fFLTS/16, N=6 */
+# define HRTIM_FLTINR1_FLT4F_FLTS16N8 (12 << HRTIM_FLTINR1_FLT4F_SHIFT) /* 1100: fSAMPLING = fFLTS/16, N=8 */
+# define HRTIM_FLTINR1_FLT4F_FLTS32N5 (13 << HRTIM_FLTINR1_FLT4F_SHIFT) /* 1101: fSAMPLING = fFLTS/32, N=5 */
+# define HRTIM_FLTINR1_FLT4F_FLTS32N6 (14 << HRTIM_FLTINR1_FLT4F_SHIFT) /* 1110: fSAMPLING = fFLTS/32, N=6 */
+# define HRTIM_FLTINR1_FLT4F_FLTS32N8 (15 << HRTIM_FLTINR1_FLT4F_SHIFT) /* 1111: fSAMPLING = fFLTS/32, N=8 */
+#define HRTIM_FLTINR1_FLT4LCK (1 << 31) /* Bit 31: Fault 4 lock */
+
+/* Common Fault Input Register 2 */
+
+#define HRTIM_FLTINR2_FLT5E (1 << 0) /* Bit 0: Fault 5 enable */
+#define HRTIM_FLTINR2_FLT5P (1 << 1) /* Bit 1: Fault 5 polarity */
+#define HRTIM_FLTINR2_FLT5SRC (1 << 2) /* Bit 2: Fault 5 source */
+#define HRTIM_FLTINR2_FLT5F_SHIFT 3 /* Bits 3-6: Fault 5 source */
+#define HRTIM_FLTINR2_FLT5F_MASK (15 << HRTIM_FLTINR2_FLT5F_SHIFT)
+# define HRTIM_FLTINR2_FLT5F_NOFLT (0 << HRTIM_FLTINR2_FLT5F_SHIFT) /* 0000: No filter, FLT5 acts asynchronously */
+# define HRTIM_FLTINR2_FLT5F_HRTN2 (1 << HRTIM_FLTINR2_FLT5F_SHIFT) /* 0001: fSAMPLING = fHRTIM, N=2 */
+# define HRTIM_FLTINR2_FLT5F_HRTN4 (2 << HRTIM_FLTINR2_FLT5F_SHIFT) /* 0010: fSAMPLING = fHRTIM, N=4 */
+# define HRTIM_FLTINR2_FLT5F_HRTN8 (3 << HRTIM_FLTINR2_FLT5F_SHIFT) /* 0011: fSAMPLING = fHRTIM, N=8 */
+# define HRTIM_FLTINR2_FLT5F_FLTS2N6 (4 << HRTIM_FLTINR2_FLT5F_SHIFT) /* 0100: fSAMPLING = fFLTS/2, N=6 */
+# define HRTIM_FLTINR2_FLT5F_FLTS2N8 (5 << HRTIM_FLTINR2_FLT5F_SHIFT) /* 0101: fSAMPLING = fFLTS/2, N=8 */
+# define HRTIM_FLTINR2_FLT5F_FLTS4N6 (6 << HRTIM_FLTINR2_FLT5F_SHIFT) /* 0110: fSAMPLING = fFLTS/4, N=6 */
+# define HRTIM_FLTINR2_FLT5F_FLTS4N8 (7 << HRTIM_FLTINR2_FLT5F_SHIFT) /* 0111: fSAMPLING = fFLTS/4, N=8 */
+# define HRTIM_FLTINR2_FLT5F_FLTS8N6 (8 << HRTIM_FLTINR2_FLT5F_SHIFT) /* 1000: fSAMPLING = fFLTS/8, N=6 */
+# define HRTIM_FLTINR2_FLT5F_FLTS8N8 (9 << HRTIM_FLTINR2_FLT5F_SHIFT) /* 1001: fSAMPLING = fFLTS/8, N=8 */
+# define HRTIM_FLTINR2_FLT5F_FLTS16N5 (10 << HRTIM_FLTINR2_FLT5F_SHIFT) /* 1010: fSAMPLING = fFLTS/16, N=5 */
+# define HRTIM_FLTINR2_FLT5F_FLTS16N6 (11 << HRTIM_FLTINR2_FLT5F_SHIFT) /* 1011: fSAMPLING = fFLTS/16, N=6 */
+# define HRTIM_FLTINR2_FLT5F_FLTS16N8 (12 << HRTIM_FLTINR2_FLT5F_SHIFT) /* 1100: fSAMPLING = fFLTS/16, N=8 */
+# define HRTIM_FLTINR2_FLT5F_FLTS32N5 (13 << HRTIM_FLTINR2_FLT5F_SHIFT) /* 1101: fSAMPLING = fFLTS/32, N=5 */
+# define HRTIM_FLTINR2_FLT5F_FLTS32N6 (14 << HRTIM_FLTINR2_FLT5F_SHIFT) /* 1110: fSAMPLING = fFLTS/32, N=6 */
+# define HRTIM_FLTINR2_FLT5F_FLTS32N8 (15 << HRTIM_FLTINR2_FLT5F_SHIFT) /* 1111: fSAMPLING = fFLTS/32, N=8 */
+#define HRTIM_FLTINR2_FLT5LCK (1 << 7) /* Bit 7: Fault 5 lock */
+#define HRTIM_FLTINR2_FLTSD_SWITCH 24 /* Bits 24-25: Fault Sampling clock division */
+#define HRTIM_FLTINR2_FLTSD_MASK (3 << HRTIM_FLTINR2_FLTSD_SWITCH)
+# define HRTIM_FLTINR2_FLTSD_NODIV (0 << HRTIM_FLTINR2_FLTSD_SWITCH) /* 00: fFLTS=fHRTIM */
+# define HRTIM_FLTINR2_FLTSD_d2 (1 << HRTIM_FLTINR2_FLTSD_SWITCH) /* 01: fFLTS=fHRTIM/2 */
+# define HRTIM_FLTINR2_FLTSD_d4 (2 << HRTIM_FLTINR2_FLTSD_SWITCH) /* 10: fFLTS=fHRTIM/4 */
+# define HRTIM_FLTINR2_FLTSD_d8 (3 << HRTIM_FLTINR2_FLTSD_SWITCH) /* 11: fFLTS=fHRTIM/8 */
+
+/* Common Burst DMA Master Timer Update Register */
+
+#define HRTIM_BDMUPR_MCR (1 << 0) /* Bit 0: MCR register update enable */
+#define HRTIM_BDMUPR_MICR (1 << 1) /* Bit 1: MICR register update enable */
+#define HRTIM_BDMUPR_MDIER (1 << 2) /* Bit 2: MDIER register update enable */
+#define HRTIM_BDMUPR_MCNT (1 << 3) /* Bit 3: MCNTR register update enable */
+#define HRTIM_BDMUPR_MPER (1 << 4) /* Bit 4: MPER register update enable */
+#define HRTIM_BDMUPR_MREP (1 << 5) /* Bit 5: MREP register update enable */
+#define HRTIM_BDMUPR_MCMP1 (1 << 6) /* Bit 6: MCMP1R register update enable */
+#define HRTIM_BDMUPR_MCMP2 (1 << 7) /* Bit 7: MCMP2R register update enable */
+#define HRTIM_BDMUPR_MCMP3 (1 << 8) /* Bit 8: MCMP3R register update enable */
+#define HRTIM_BDMUPR_MCMP4 (1 << 9) /* Bit 9: MCMP4R register update enable */
+
+/* Common Burst DMA Timer X Update Register (Timer A-E)*/
+
+#define HRTIM_BDTxUPR_CR (1 << 0) /* Bit 0: HRTIM_TIMxCR register update enablce */
+#define HRTIM_BDTxUPR_ICR (1 << 1) /* Bit 1: HRTIM_TIMxICR register update enablce */
+#define HRTIM_BDTxUPR_DIER (1 << 2) /* Bit 2: HRTIM_TIMxDIER register update enablce */
+#define HRTIM_BDTxUPR_CNT (1 << 3) /* Bit 3: HRTIM_CNTxR register update enablce */
+#define HRTIM_BDTxUPR_PER (1 << 4) /* Bit 4: HRTIM_PERxR register update enablce */
+#define HRTIM_BDTxUPR_REP (1 << 5) /* Bit 5: HRTIM_REPxR register update enablce */
+#define HRTIM_BDTxUPR_CMP1 (1 << 6) /* Bit 6: HRTIM_CMP1xR register update enablce */
+#define HRTIM_BDTxUPR_CMP2 (1 << 7) /* Bit 7: HRTIM_CMP2xR register update enablce */
+#define HRTIM_BDTxUPR_CMP3 (1 << 8) /* Bit 8: HRTIM_CMP3xR register update enablce */
+#define HRTIM_BDTxUPR_CMP4 (1 << 9) /* Bit 9: HRTIM_CMP4xR register update enablce */
+#define HRTIM_BDTxUPR_DTR (1 << 10) /* Bit 10: HRTIM_DTxR register update enablce */
+#define HRTIM_BDTxUPR_SET1R (1 << 11) /* Bit 11: HRTIM_SET1xR register update enablce */
+#define HRTIM_BDTxUPR_RST1R (1 << 12) /* Bit 12: HRTIM_RST1xR register update enablce */
+#define HRTIM_BDTxUPR_SET2R (1 << 13) /* Bit 13: HRTIM_SET2xR register update enablce */
+#define HRTIM_BDTxUPR_RST2R (1 << 14) /* Bit 14: HRTIM_RST2xR register update enablce */
+#define HRTIM_BDTxUPR_EEFR1 (1 << 15) /* Bit 15: HRTIM_EEFxR1 register update enablce */
+#define HRTIM_BDTxUPR_EEFR2 (1 << 16) /* Bit 16: HRTIM_EEFxR2 register update enablce */
+#define HRTIM_BDTxUPR_RSTR (1 << 17) /* Bit 17: HRTIM_RSTxR register update enablce */
+#define HRTIM_BDTxUPR_CHPR (1 << 18) /* Bit 18: HRTIM_CHRxR register update enablce */
+#define HRTIM_BDTxUPR_OUTR (1 << 19) /* Bit 19: HRTIM_OUTxR register update enablce */
+#define HRTIM_BDTxUPR_FLTR (1 << 20) /* Bit 20: HRTIM_FLTxR register update enablce */
+
+/* Common Burst DMA Data Register */
+
+#define HRTIM_BDMADR_SHIFT 0 /* Bits 0-31: Burst DMA Data register */
+#define HRTIM_BDMADR_MASK (0xffffffff << HRTIM_BDMADR_SHIFT)
+
+#endif /* __ARCH_ARM_SRC_STM32_CHIP_STM32_HRTIM_H */
diff --git a/arch/arm/src/stm32/chip/stm32f33xxx_memorymap.h b/arch/arm/src/stm32/chip/stm32f33xxx_memorymap.h
new file mode 100644
index 0000000000000000000000000000000000000000..85e5ce175d615d44e0c5eabc06269bf225e962ae
--- /dev/null
+++ b/arch/arm/src/stm32/chip/stm32f33xxx_memorymap.h
@@ -0,0 +1,151 @@
+/************************************************************************************
+ * arch/arm/src/stm32/chip/stm32f33xxx_memorymap.h
+ *
+ * Copyright (C) 2017 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ * Modified for STM32F334 by Mateusz Szafoni
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ************************************************************************************/
+
+#ifndef __ARCH_ARM_SRC_STM32_CHIP_STM32F33XXX_MEMORYMAP_H
+#define __ARCH_ARM_SRC_STM32_CHIP_STM32F33XXX_MEMORYMAP_H
+
+/************************************************************************************
+ * Pre-processor Definitions
+ ************************************************************************************/
+
+/* STM32F33XXX Address Blocks *******************************************************/
+
+#define STM32_CODE_BASE 0x00000000 /* 0x00000000-0x1fffffff: 512Mb code block */
+#define STM32_SRAM_BASE 0x20000000 /* 0x20000000-0x3fffffff: 512Mb sram block */
+#define STM32_PERIPH_BASE 0x40000000 /* 0x40000000-0x5fffffff: 512Mb peripheral block */
+ /* 0x60000000-0xdfffffff: Reserved */
+#define STM32_CORTEX_BASE 0xe0000000 /* 0xe0000000-0xffffffff: 512Mb Cortex-M4 block */
+
+#define STM32_REGION_MASK 0xf0000000
+#define STM32_IS_SRAM(a) ((((uint32_t)(a)) & STM32_REGION_MASK) == STM32_SRAM_BASE)
+
+/* Code Base Addresses **************************************************************/
+
+#define STM32_BOOT_BASE 0x00000000 /* 0x00000000-0x0000ffff: Aliased boot memory */
+ /* 0x00010000-0x07ffffff: Reserved */
+#define STM32_FLASH_BASE 0x08000000 /* 0x08000000-0x0800ffff: FLASH memory */
+ /* 0x08100000-0x1ffeffff: Reserved */
+#define STM32_CCMRAM_BASE 0x10000000 /* 0x10000000-0x10000fff: 4Kb CCM data RAM */
+ /* 0x10001000-0x1ffeffff: Reserved */
+#define STM32_SYSMEM_BASE 0x1fffd800 /* 0x1fff0000-0x1fff7a0f: System memory */
+ /* 0x1fff7a10-0x1fff7fff: Reserved */
+#define STM32_OPTION_BASE 0x1ffff800 /* 0x1fffc000-0x1fffc007: Option bytes */
+ /* 0x1fffc008-0x1fffffff: Reserved */
+
+
+/* System Memory Addresses **********************************************************/
+
+#define STM32_SYSMEM_UID 0x1ffff7ac /* The 96-bit unique device identifier */
+#define STM32_SYSMEM_FSIZE 0x1ffff7cc /* This bitfield indicates the size of
+ * the device Flash memory expressed in
+ * Kbytes. Example: 0x040 corresponds
+ * to 64 Kbytes
+ */
+
+/* Peripheral Base Addresses ********************************************************/
+
+#define STM32_APB1_BASE 0x40000000 /* 0x40000000-0x40009fff: APB1 */
+ /* 0x4000a000-0x4000ffff: Reserved */
+#define STM32_APB2_BASE 0x40010000 /* 0x40010000-0x40006bff: APB2 */
+ /* 0x40016c00-0x4001ffff: Reserved */
+#define STM32_AHB1_BASE 0x40020000 /* 0x40020000-0x400243ff: APB1 */
+ /* 0x40024400-0x4007ffff: Reserved */
+#define STM32_AHB2_BASE 0x48000000 /* 0x48000000-0x480017ff: AHB2 */
+ /* 0x48001800-0x4fffffff: Reserved */
+#define STM32_AHB3_BASE 0x50000000 /* 0x50000000-0x500003ff: AHB3 */
+
+/* APB1 Base Addresses **************************************************************/
+
+#define STM32_TIM2_BASE 0x40000000 /* 0x40000000-0x400003ff TIM2 */
+#define STM32_TIM3_BASE 0x40000400 /* 0x40000400-0x400007ff TIM3 */
+#define STM32_TIM6_BASE 0x40001000 /* 0x40001000-0x400013ff TIM6 */
+#define STM32_TIM7_BASE 0x40001400 /* 0x40001400-0x400017ff TIM7 */
+#define STM32_RTC_BASE 0x40002800 /* 0x40002800-0x40002bff RTC */
+#define STM32_BKP_BASE 0x40002850 /* 0x40002850-0x400028cc BKP */
+#define STM32_WWDG_BASE 0x40002c00 /* 0x40002c00-0x40002fff WWDG */
+#define STM32_IWDG_BASE 0x40003000 /* 0x40003000-0x400033ff IWDG */
+#define STM32_USART2_BASE 0x40004400 /* 0x40004400-0x400047ff USART2 */
+#define STM32_USART3_BASE 0x40004800 /* 0x40004800-0x40004bff USART3 */
+#define STM32_I2C1_BASE 0x40005400 /* 0x40005400-0x400057ff I2C1 */
+#define STM32_CAN1_BASE 0x40006400 /* 0x40006400-0x400067ff bxCAN */
+#define STM32_PWR_BASE 0x40007000 /* 0x40007000-0x400073ff PWR */
+#define STM32_DAC1_BASE 0x40007400 /* 0x40007400-0x400077ff DAC1 */
+#define STM32_DAC2_BASE 0x40009800 /* 0x40009800-0x40009bff DAC2 */
+
+/* APB2 Base Addresses **************************************************************/
+
+#define STM32_SYSCFG_BASE 0x40010000 /* 0x40010000-0x400103FF SYSCFG, and */
+#define STM32_COMP_BASE 0x40010000 /* COMP, and */
+#define STM32_OPAMP_BASE 0x40010000 /* OPAMP */
+#define STM32_EXTI_BASE 0x40010400 /* 0x40010400-0x400107FF EXTI */
+#define STM32_TIM1_BASE 0x40012c00 /* 0x40012c00-0x40012fff TIM1 */
+#define STM32_SPI1_BASE 0x40013000 /* 0x40013000-0x400133ff SPI1 */
+#define STM32_USART1_BASE 0x40013800 /* 0x40013800-0x40013bff USART1 */
+#define STM32_TIM15_BASE 0x40014000 /* 0x40014000-0x400143ff TIM15 */
+#define STM32_TIM16_BASE 0x40014400 /* 0x40014400-0x400147ff TIM16 */
+#define STM32_TIM17_BASE 0x40014800 /* 0x40014800-0x40014bff TIM17 */
+#define STM32_HRTIM1_BASE 0x40017400 /* 0x40017400-0x400177ff HRTIM1 */
+
+/* AHB1 Base Addresses **************************************************************/
+
+#define STM32_DMA1_BASE 0x40020000 /* 0x40020000-0x400203ff: DMA1 */
+#define STM32_RCC_BASE 0x40021000 /* 0x40021000-0x400213ff: Reset and Clock control RCC */
+#define STM32_FLASHIF_BASE 0x40022000 /* 0x40022000-0x400223ff: Flash memory interface */
+#define STM32_CRC_BASE 0x40023000 /* 0x40023000-0x400233ff: CRC */
+#define STM32_TSC_BASE 0x40024000 /* 0x40024000-0x400243ff: TSC */
+
+/* AHB2 Base Addresses **************************************************************/
+
+#define STM32_GPIOA_BASE 0x48000000 /* 0x48000000-0x480003ff: GPIO Port A */
+#define STM32_GPIOB_BASE 0x48000400 /* 0x48000400-0x480007ff: GPIO Port B */
+#define STM32_GPIOC_BASE 0x48000800 /* 0x48000800-0x48000bff: GPIO Port C */
+#define STM32_GPIOD_BASE 0X48000C00 /* 0x48000c00-0x48000fff: GPIO Port D */
+#define STM32_GPIOE_BASE 0X48001000 /* 0x48001000-0x480013ff: GPIO Port E */
+#define STM32_GPIOF_BASE 0x48001400 /* 0x48001400-0x480017ff: GPIO Port F */
+
+/* AHB3 Base Addresses **************************************************************/
+
+#define STM32_ADC12_BASE 0x50000000 /* 0x50000000-0x500003ff: ADC12 */
+
+/* Cortex-M4 Base Addresses *********************************************************/
+/* Other registers -- see armv7-m/nvic.h for standard Cortex-M4 registers in this
+ * address range
+ */
+
+#define STM32_SCS_BASE 0xe000e000
+#define STM32_DEBUGMCU_BASE 0xe0042000
+
+#endif /* __ARCH_ARM_SRC_STM32_CHIP_STM32F33XXX_MEMORYMAP_H */
diff --git a/arch/arm/src/stm32/chip/stm32f33xxx_opamp.h b/arch/arm/src/stm32/chip/stm32f33xxx_opamp.h
new file mode 100644
index 0000000000000000000000000000000000000000..a6940bb0550feaa2f295490e6cc450561afef149
--- /dev/null
+++ b/arch/arm/src/stm32/chip/stm32f33xxx_opamp.h
@@ -0,0 +1,117 @@
+/****************************************************************************************************
+ * arch/arm/src/stm32/chip/stm32f33xxx_opamp.h
+ *
+ * Copyright (C) 2017 Gregory Nutt. All rights reserved.
+ * Author: Mateusz Szafoni
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************************************/
+
+#ifndef __ARCH_ARM_SRC_STM32_CHIP_STM32_OPAMP_H
+#define __ARCH_ARM_SRC_STM32_CHIP_STM32_OPAMP_H
+
+/****************************************************************************************************
+ * Included Files
+ ****************************************************************************************************/
+
+#include
+
+#include "chip.h"
+
+/****************************************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************************************/
+
+/* Register Offsets *********************************************************************************/
+
+#define STM32_OPAMP2_CSR_OFFSET 0x003C /* OPAMP2 Control register */
+
+/* Register Addresses *******************************************************************************/
+
+#define STM32_OPAMP2_CSR (STM32_OPAMP2_BASE+STM32_OPAMP2_CSR_OFFSET)
+
+/* Register Bitfield Definitions ****************************************************/
+
+/* OPAMP control and status register */
+
+#define OPAMP_CSR_OPAMPEN (1 << 0) /* Bit 0: OPAMP enable */
+#define OPAMP_CSR_FORCE_VP (1 << 1) /* Bit 1: Force a calibration reference voltage on non-nverting */
+ /* input and disables external connections */
+#define OPAMP_CSR_VPSEL_SHIFT (3) /* Bits 2-3: OPAMP non inverting input selection */
+#define OPAMP_CSR_VPSEL_MASK (3 << OPAMP_CSR_VPSEL_SHIFT)
+ /* 00: Reserved */
+# define OPAMP_CSR_VPSEL_PB13 (1 << OPAMP_CSR_VPSEL_SHIFT) /* 01: PB14 */
+# define OPAMP_CSR_VPSEL_PB0 (2 << OPAMP_CSR_VPSEL_SHIFT) /* 10: PB0 */
+# define OPAMP_CSR_VPSEL_PA7 (3 << OPAMP_CSR_VPSEL_SHIFT) /* 11: PA7 */
+ /* Bit 4: Reserved */
+#define OPAMP_CSR_VMSEL_SHIFT (5) /* Bits 5-6: OPAMP inverting input selection */
+#define OPAMP_CSR_VMSEL_MASK (3 << OPAMP_CSR_VMSEL_SHIFT)
+# define OPAMP_CSR_VMSEL_PC5 (0 << OPAMP_CSR_VMSEL_SHIFT) /* 00: PC5 */
+# define OPAMP_CSR_VMSEL_PA5 (1 << OPAMP_CSR_VMSEL_SHIFT) /* 01: PA5 */
+# define OPAMP_CSR_VMSEL_RESISTOR (2 << OPAMP_CSR_VMSEL_SHIFT) /* 10: Resistor feedback output */
+# define OPAMP_CSR_VMSEL_FOLLOWER (3 << OPAMP_CSR_VMSEL_SHIFT) /* 11: Follower mode */
+#define OPAMP_CSR_TCMEN (1 << 7) /* Bit 7: Timer controlled Mux mode enable */
+#define OPAMP_CSR_VMSSEL (1 << 8) /* Bit 8: OPAMP inverting input secondary selection */
+#define OPAMP_CSR_VPSSEL_SHIFT (1 << 9) /* Bits 9-10: OPAMP Non inverting input secondary selection */
+#define OPAMP_CSR_VPSSEL_MASK (3 << OPAMP_CSR_VPSSEL_SHIFT)
+ /* 00: Reserved */
+# define OPAMP_CSR_VPSSEL_PB14 (1 << OPAMP_CSR_VPSSEL_SHIFT) /* 01: PB14 */
+# define OPAMP_CSR_VPSSEL_PB0 (2 << OPAMP_CSR_VPSSEL_SHIFT) /* 10: PB0 */
+# define OPAMP_CSR_VPSSEL_PA7 (3 << OPAMP_CSR_VPSSEL_SHIFT) /* 11: PA7 */
+#define OPAMP_CSR_CALON (1 << 11) /* Bit 11: Calibration mode enable */
+#define OPAMP_CSR_CALSEL_SHIFT (12) /* Bits 12-13: Calibration selection */
+#define OPAMP_CSR_CALSEL_MASK (3 << OPAMP_CSR_CALSEL_SHIFT)
+# define OPAMP_CSR_CALSEL_3P3 (0 << OPAMP_CSR_CALSEL_SHIFT) /* 00 V_REFOPAMP = 3.3% V_DDA */
+# define OPAMP_CSR_CALSEL_10 (1 << OPAMP_CSR_CALSEL_SHIFT) /* 01 V_REFOPAMP = 10% V_DDA */
+# define OPAMP_CSR_CALSEL_50 (2 << OPAMP_CSR_CALSEL_SHIFT) /* 10 V_REFOPAMP = 50% V_DDA */
+# define OPAMP_CSR_CALSEL_90 (3 << OPAMP_CSR_CALSEL_SHIFT) /* 11 V_REFOPAMP = 90% V_DDA */
+#define OPAMP_CSR_PGAGAIN_SHIFT (14) /* Bits 14-17: Gain in PGA mode */
+#define OPAMP_CSR_PGAGAIN_MASK (15 << OPAMP_CSR_PGAGAIN_SHIFT)
+# define OPAMP_CSR_PGAGAIN_2 (0 << OPAMP_CSR_PGAGAIN_SHIFT) /* 0X00: Non-inverting gain = 2 */
+# define OPAMP_CSR_PGAGAIN_4 (1 << OPAMP_CSR_PGAGAIN_SHIFT) /* 0X01: Non-inverting gain = 4 */
+# define OPAMP_CSR_PGAGAIN_8 (2 << OPAMP_CSR_PGAGAIN_SHIFT) /* 0X1-: Non-inverting gain = 8 */
+# define OPAMP_CSR_PGAGAIN_16 (3 << OPAMP_CSR_PGAGAIN_SHIFT) /* 0X11: Non-inverting gain = 16 */
+# define OPAMP_CSR_PGAGAIN_2VM0 (8 << OPAMP_CSR_PGAGAIN_SHIFT) /* 1000: Non-inverting gain = 2 - VM0*/
+# define OPAMP_CSR_PGAGAIN_4VM0 (9 << OPAMP_CSR_PGAGAIN_SHIFT) /* 1001: Non-inverting gain = 4 - VM0*/
+# define OPAMP_CSR_PGAGAIN_8VM0 (10 << OPAMP_CSR_PGAGAIN_SHIFT) /* 1010: Non-inverting gain = 8 - VM0*/
+# define OPAMP_CSR_PGAGAIN_16VM0 (11 << OPAMP_CSR_PGAGAIN_SHIFT) /* 1011: Non-inverting gain = 16 - VM0*/
+# define OPAMP_CSR_PGAGAIN_2VM1 (12 << OPAMP_CSR_PGAGAIN_SHIFT) /* 1100: Non-inverting gain = 2 - VM1*/
+# define OPAMP_CSR_PGAGAIN_4VM1 (13 << OPAMP_CSR_PGAGAIN_SHIFT) /* 1101: Non-inverting gain = 4 - VM1*/
+# define OPAMP_CSR_PGAGAIN_8VM1 (14 << OPAMP_CSR_PGAGAIN_SHIFT) /* 1110: Non-inverting gain = 8 - VM1*/
+# define OPAMP_CSR_PGAGAIN_16VM1 (15 << OPAMP_CSR_PGAGAIN_SHIFT) /* 1111: Non-inverting gain = 16 - VM1*/
+#define OPAMP_CSR_USERTRIM (1 << 18) /* Bit 18: User trimming enable */
+#define OPAMP_CSR_TRIMOFFSETP_SHIFT (19) /* Bits 19-23: Offset trimming value (PMOS)*/
+#define OPAMP_CSR_TRIMOFFSETP_MASK (31 << OPAMP_CSR_TRIMOFFSETP_SHIFT)
+#define OPAMP_CSR_TRIMOFFSETN_SHIFT (24) /* Bits 24-28: Offset trimming value (NMOS) */
+#define OPAMP_CSR_TRIMOFFSETN_MASK (31 << OPAMP_CSR_TRIMOFFSETN_SHIFT)
+#define OPAMP_CSR_TSTREF (1 << 29) /* Bit 29: Output the internal reference voltage */
+#define OPAMP_CSR_OUTCAL (1 << 30) /* Bit 30: OPAMP output status flag */
+#define OPAMP_CSR_LOCK (1 << 31) /* Bit 31: OPAMP 2 lock */
+
+#endif /* __ARCH_ARM_SRC_STM32_CHIP_STM32_OPAMP_H */
diff --git a/arch/arm/src/stm32/chip/stm32f33xxx_pinmap.h b/arch/arm/src/stm32/chip/stm32f33xxx_pinmap.h
new file mode 100644
index 0000000000000000000000000000000000000000..b5b97c88da098d8912e583e416cebe3ba2a17338
--- /dev/null
+++ b/arch/arm/src/stm32/chip/stm32f33xxx_pinmap.h
@@ -0,0 +1,464 @@
+/************************************************************************************
+ * arch/arm/src/stm32/chip/stm32f33xxx_pinmap.h
+ *
+ * Copyright (C) 2017 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ * Modified for STM32F334 by Mateusz Szafoni
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ************************************************************************************/
+
+#ifndef __ARCH_ARM_SRC_STM32_CHIP_STM32F33XXX_PINMAP_H
+#define __ARCH_ARM_SRC_STM32_CHIP_STM32F33XXX_PINMAP_H
+
+/************************************************************************************
+ * Included Files
+ ************************************************************************************/
+
+#include
+
+#include "stm32_gpio.h"
+
+/************************************************************************************
+ * Pre-processor Definitions
+ ************************************************************************************/
+
+/* Alternate Pin Functions. All members of the STM32F33xxx family share the same
+ * pin multiplexing (although they may differ in the pins physically available).
+ *
+ * Alternative pin selections are provided with a numeric suffix like _1, _2, etc.
+ * Drivers, however, will use the pin selection without the numeric suffix.
+ * Additional definitions are required in the board.h file. For example, if
+ * CAN1_RX connects vis PA11 on some board, then the following definitions should
+ * appear inthe board.h header file for that board:
+ *
+ * #define GPIO_CAN1_RX GPIO_CAN1_RX_1
+ *
+ * The driver will then automatically configre PA11 as the CAN1 RX pin.
+ */
+
+/* WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!!
+ * Additional effort is required to select specific GPIO options such as frequency,
+ * open-drain/push-pull, and pull-up/down! Just the basics are defined for most
+ * pins in this file.
+ */
+
+/* ADC */
+
+#define GPIO_ADC1_IN1 (GPIO_ANALOG|GPIO_PORTA|GPIO_PIN0)
+#define GPIO_ADC1_IN2 (GPIO_ANALOG|GPIO_PORTA|GPIO_PIN1)
+#define GPIO_ADC1_IN3 (GPIO_ANALOG|GPIO_PORTA|GPIO_PIN2)
+#define GPIO_ADC1_IN4 (GPIO_ANALOG|GPIO_PORTA|GPIO_PIN3)
+#undef GPIO_ADC1_IN5
+#define GPIO_ADC1_IN6 (GPIO_ANALOG|GPIO_PORTC|GPIO_PIN0)
+#define GPIO_ADC1_IN7 (GPIO_ANALOG|GPIO_PORTC|GPIO_PIN1)
+#define GPIO_ADC1_IN8 (GPIO_ANALOG|GPIO_PORTC|GPIO_PIN2)
+#define GPIO_ADC1_IN9 (GPIO_ANALOG|GPIO_PORTC|GPIO_PIN3)
+#undef GPIO_ADC1_IN10
+#define GPIO_ADC1_IN11 (GPIO_ANALOG|GPIO_PORTB|GPIO_PIN0)
+#define GPIO_ADC1_IN12 (GPIO_ANALOG|GPIO_PORTB|GPIO_PIN1)
+#define GPIO_ADC1_IN13 (GPIO_ANALOG|GPIO_PORTB|GPIO_PIN13)
+
+#define GPIO_ADC2_IN1 (GPIO_ANALOG|GPIO_PORTA|GPIO_PIN4)
+#define GPIO_ADC2_IN2 (GPIO_ANALOG|GPIO_PORTA|GPIO_PIN5)
+#define GPIO_ADC2_IN3 (GPIO_ANALOG|GPIO_PORTA|GPIO_PIN6)
+#define GPIO_ADC2_IN4 (GPIO_ANALOG|GPIO_PORTA|GPIO_PIN7)
+#define GPIO_ADC2_IN5 (GPIO_ANALOG|GPIO_PORTC|GPIO_PIN4)
+#define GPIO_ADC2_IN6 (GPIO_ANALOG|GPIO_PORTC|GPIO_PIN0)
+#define GPIO_ADC2_IN7 (GPIO_ANALOG|GPIO_PORTC|GPIO_PIN1)
+#define GPIO_ADC2_IN8 (GPIO_ANALOG|GPIO_PORTC|GPIO_PIN2)
+#define GPIO_ADC2_IN9 (GPIO_ANALOG|GPIO_PORTC|GPIO_PIN3)
+#undef GPIO_ADC2_IN10
+#define GPIO_ADC2_IN11 (GPIO_ANALOG|GPIO_PORTC|GPIO_PIN5)
+#define GPIO_ADC2_IN12 (GPIO_ANALOG|GPIO_PORTB|GPIO_PIN2)
+#define GPIO_ADC2_IN13 (GPIO_ANALOG|GPIO_PORTB|GPIO_PIN12)
+#define GPIO_ADC2_IN14 (GPIO_ANALOG|GPIO_PORTB|GPIO_PIN14)
+#define GPIO_ADC2_IN15 (GPIO_ANALOG|GPIO_PORTB|GPIO_PIN15)
+
+/* CAN */
+
+#define GPIO_CAN_RX_1 (GPIO_ALT|GPIO_AF9|GPIO_SPEED_50MHz|GPIO_PUSHPULL|GPIO_PORTA|GPIO_PIN11)
+#define GPIO_CAN_RX_2 (GPIO_ALT|GPIO_AF9|GPIO_SPEED_50MHz|GPIO_PUSHPULL|GPIO_PORTB|GPIO_PIN8)
+#undef GPIO_CAN_RX_3
+#define GPIO_CAN_TX_1 (GPIO_ALT|GPIO_AF9|GPIO_SPEED_50MHz|GPIO_PUSHPULL|GPIO_PORTA|GPIO_PIN12)
+#define GPIO_CAN_TX_2 (GPIO_ALT|GPIO_AF9|GPIO_SPEED_50MHz|GPIO_PUSHPULL|GPIO_PORTB|GPIO_PIN9)
+#undef GPIO_CAN_TX_3
+
+
+/* Comparator Outputs */
+
+#define GPIO_COMP2_OUT_1 (GPIO_ALT|GPIO_AF8|GPIO_PORTA|GPIO_PIN2)
+#define GPIO_COMP2_OUT_2 (GPIO_ALT|GPIO_AF8|GPIO_PORTA|GPIO_PIN12)
+#define GPIO_COMP2_OUT_3 (GPIO_ALT|GPIO_AF8|GPIO_PORTB|GPIO_PIN9)
+#define GPIO_COMP4_OUT (GPIO_ALT|GPIO_AF8|GPIO_PORTB|GPIO_PIN1)
+#define GPIO_COMP6_OUT_1 (GPIO_ALT|GPIO_AF8|GPIO_PORTA|GPIO_PIN10)
+#define GPIO_COMP6_OUT_2 (GPIO_ALT|GPIO_AF7|GPIO_PORTC|GPIO_PIN6)
+
+/* Comparator Inputs non inverting*/
+
+#define GPIO_COMP2_INP (GPIO_ALT|GPIO_AF8|GPIO_PORTA|GPIO_PIN7)
+#define GPIO_COMP4_INP (GPIO_ALT|GPIO_AF8|GPIO_PORTB|GPIO_PIN0)
+#define GPIO_COMP6_INP (GPIO_ALT|GPIO_AF8|GPIO_PORTB|GPIO_PIN11)
+
+/* Comparator Inputs inverting*/
+
+#define GPIO_COMP2_INM (GPIO_ALT|GPIO_AF8|GPIO_PORTA|GPIO_PIN4)
+#define GPIO_COMP4_INM_1 (GPIO_ALT|GPIO_AF8|GPIO_PORTB|GPIO_PIN2)
+#define GPIO_COMP4_INM_2 (GPIO_ALT|GPIO_AF8|GPIO_PORTA|GPIO_PIN4)
+#define GPIO_COMP6_INM_1 (GPIO_ALT|GPIO_AF8|GPIO_PORTA|GPIO_PIN4)
+#define GPIO_COMP6_INM_2 (GPIO_ALT|GPIO_AF8|GPIO_PORTB|GPIO_PIN15)
+
+
+/* DAC -" Once the DAC channelx is enabled, the corresponding GPIO pin
+ * (PA4 or PA5) is automatically connected to the analog converter output
+ * (DACy_OUTx). In order to avoid parasitic consumption, the PA4 or PA5 pin
+ * should first be configured to analog (AIN)".
+ */
+
+#define GPIO_DAC1_OUT1 (GPIO_ANALOG|GPIO_PORTA|GPIO_PIN4)
+#define GPIO_DAC1_OUT2 (GPIO_ANALOG|GPIO_PORTA|GPIO_PIN5)
+#define GPIO_DAC2_OUT1 (GPIO_ANALOG|GPIO_PORTA|GPIO_PIN6)
+
+/* I2C */
+
+#define GPIO_I2C1_SCL_1 (GPIO_ALT|GPIO_AF4|GPIO_SPEED_50MHz|GPIO_OPENDRAIN|GPIO_PORTA|GPIO_PIN15)
+#define GPIO_I2C1_SCL_2 (GPIO_ALT|GPIO_AF4|GPIO_SPEED_50MHz|GPIO_OPENDRAIN|GPIO_PORTB|GPIO_PIN6)
+#define GPIO_I2C1_SCL_3 (GPIO_ALT|GPIO_AF4|GPIO_SPEED_50MHz|GPIO_OPENDRAIN|GPIO_PORTB|GPIO_PIN8)
+#define GPIO_I2C1_SDA_1 (GPIO_ALT|GPIO_AF4|GPIO_SPEED_50MHz|GPIO_OPENDRAIN|GPIO_PORTA|GPIO_PIN14)
+#define GPIO_I2C1_SDA_2 (GPIO_ALT|GPIO_AF4|GPIO_SPEED_50MHz|GPIO_OPENDRAIN|GPIO_PORTB|GPIO_PIN7)
+#define GPIO_I2C1_SDA_3 (GPIO_ALT|GPIO_AF4|GPIO_SPEED_50MHz|GPIO_OPENDRAIN|GPIO_PORTB|GPIO_PIN9)
+#define GPIO_I2C1_SMBA (GPIO_ALT|GPIO_AF4|GPIO_SPEED_50MHz|GPIO_PUSHPULL|GPIO_PORTB|GPIO_PIN5)
+
+/* IR */
+
+#define GPIO_IR_OUT_1 (GPIO_ALT|GPIO_AF5|GPIO_PORTA|GPIO_PIN13)
+#define GPIO_IR_OUT_2 (GPIO_ALT|GPIO_AF6|GPIO_PORTB|GPIO_PIN9)
+
+/* JTAG/SWD */
+
+#define GPIO_JTDI (GPIO_ALT|GPIO_AF0|GPIO_PORTA|GPIO_PIN15)
+#define GPIO_JTDO_TRACES_WO (GPIO_ALT|GPIO_AF0|GPIO_PORTB|GPIO_PIN3)
+#define GPIO_NJTRST (GPIO_ALT|GPIO_AF0|GPIO_PORTB|GPIO_PIN4)
+#define GPIO_SWCLK_JTCK (GPIO_ALT|GPIO_AF0|GPIO_PORTA|GPIO_PIN14)
+#define GPIO_SWDIO_JTMS (GPIO_ALT|GPIO_AF0|GPIO_PORTA|GPIO_PIN13)
+
+/* MCO */
+
+#define GPIO_MCO (GPIO_ALT|GPIO_AF0|GPIO_SPEED_50MHz|GPIO_PUSHPULL|GPIO_PORTA|GPIO_PIN8)
+
+/* SPI */
+
+#define GPIO_SPI1_MISO_1 (GPIO_ALT|GPIO_AF5|GPIO_SPEED_50MHz|GPIO_PUSHPULL|GPIO_PORTA|GPIO_PIN6)
+#define GPIO_SPI1_MISO_2 (GPIO_ALT|GPIO_AF5|GPIO_SPEED_50MHz|GPIO_PUSHPULL|GPIO_PORTB|GPIO_PIN4)
+#define GPIO_SPI1_MOSI_1 (GPIO_ALT|GPIO_AF5|GPIO_SPEED_50MHz|GPIO_PUSHPULL|GPIO_PORTA|GPIO_PIN7)
+#define GPIO_SPI1_MOSI_2 (GPIO_ALT|GPIO_AF5|GPIO_SPEED_50MHz|GPIO_PUSHPULL|GPIO_PORTB|GPIO_PIN5)
+#define GPIO_SPI1_NSS_1 (GPIO_ALT|GPIO_AF5|GPIO_SPEED_50MHz|GPIO_PUSHPULL|GPIO_PORTA|GPIO_PIN4)
+#define GPIO_SPI1_NSS_2 (GPIO_ALT|GPIO_AF5|GPIO_SPEED_50MHz|GPIO_PUSHPULL|GPIO_PORTA|GPIO_PIN15)
+#define GPIO_SPI1_SCK_1 (GPIO_ALT|GPIO_AF5|GPIO_SPEED_50MHz|GPIO_PUSHPULL|GPIO_PORTA|GPIO_PIN5)
+#define GPIO_SPI1_SCK_2 (GPIO_ALT|GPIO_AF5|GPIO_SPEED_50MHz|GPIO_PUSHPULL|GPIO_PORTB|GPIO_PIN3)
+
+/* Timers */
+
+#define GPIO_TIM1_BKIN_1 (GPIO_ALT|GPIO_AF12|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN8)
+#define GPIO_TIM1_BKIN_2 (GPIO_ALT|GPIO_AF6|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN14)
+#define GPIO_TIM1_BKIN_3 (GPIO_ALT|GPIO_AF6|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN6)
+#define GPIO_TIM1_BKIN_4 (GPIO_ALT|GPIO_AF6|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN12)
+#define GPIO_TIM1_BKIN2_1 (GPIO_ALT|GPIO_AF12|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN11)
+#define GPIO_TIM1_BKIN2_2 (GPIO_ALT|GPIO_AF6|GPIO_SPEED_50MHz|GPIO_PORTC|GPIO_PIN3)
+#define GPIO_TIM1_CH1IN_1 (GPIO_ALT|GPIO_FLOAT|GPIO_AF6|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN8)
+#define GPIO_TIM1_CH1OUT_1 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF6|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN8)
+#define GPIO_TIM1_CH1IN_2 (GPIO_ALT|GPIO_FLOAT|GPIO_AF2|GPIO_SPEED_50MHz|GPIO_PORTC|GPIO_PIN0)
+#define GPIO_TIM1_CH1OUT_2 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF2|GPIO_SPEED_50MHz|GPIO_PORTC|GPIO_PIN0)
+#define GPIO_TIM1_CH1N_1 (GPIO_ALT|GPIO_AF4|GPIO_SPEED_50MHz|GPIO_PORTC|GPIO_PIN13)
+#define GPIO_TIM1_CH1N_2 (GPIO_ALT|GPIO_AF6|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN11)
+#define GPIO_TIM1_CH1N_3 (GPIO_ALT|GPIO_AF6|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN7)
+#define GPIO_TIM1_CH1N_4 (GPIO_ALT|GPIO_AF6|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN13)
+#define GPIO_TIM1_CH2IN (GPIO_ALT|GPIO_FLOAT|GPIO_AF6|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN9)
+#define GPIO_TIM1_CH2OUT (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF6|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN9)
+#define GPIO_TIM1_CH2N_1 (GPIO_ALT|GPIO_AF6|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN12)
+#define GPIO_TIM1_CH2N_2 (GPIO_ALT|GPIO_AF6|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN0)
+#define GPIO_TIM1_CH2N_3 (GPIO_ALT|GPIO_AF6|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN14)
+#define GPIO_TIM1_CH3IN_1 (GPIO_ALT|GPIO_FLOAT|GPIO_AF6|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN10)
+#define GPIO_TIM1_CH3OUT_1 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF6|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN10)
+#define GPIO_TIM1_CH3IN_2 (GPIO_ALT|GPIO_FLOAT|GPIO_AF2|GPIO_SPEED_50MHz|GPIO_PORTC|GPIO_PIN2)
+#define GPIO_TIM1_CH3OUT_2 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF2|GPIO_SPEED_50MHz|GPIO_PORTC|GPIO_PIN2)
+#define GPIO_TIM1_CH3N_1 (GPIO_ALT|GPIO_AF4|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN15)
+#define GPIO_TIM1_CH3N_2 (GPIO_ALT|GPIO_AF6|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN1)
+#define GPIO_TIM1_CH3N_3 (GPIO_ALT|GPIO_AF6|GPIO_SPEED_50MHz|GPIO_PORTF|GPIO_PIN0)
+#define GPIO_TIM1_CH4IN_1 (GPIO_ALT|GPIO_FLOAT|GPIO_AF11|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN11)
+#define GPIO_TIM1_CH4OUT_1 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF11|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN11)
+#define GPIO_TIM1_CH4IN_2 (GPIO_ALT|GPIO_FLOAT|GPIO_AF2|GPIO_SPEED_50MHz|GPIO_PORTC|GPIO_PIN3)
+#define GPIO_TIM1_CH4OUT_2 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF2|GPIO_SPEED_50MHz|GPIO_PORTC|GPIO_PIN3)
+#define GPIO_TIM1_ETR_1 (GPIO_ALT|GPIO_FLOAT|GPIO_AF11|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN12)
+#define GPIO_TIM1_ETR_2 (GPIO_ALT|GPIO_FLOAT|GPIO_AF2|GPIO_SPEED_50MHz|GPIO_PORTC|GPIO_PIN4)
+
+#define GPIO_TIM2_CH1_ETR_1 (GPIO_ALT|GPIO_FLOAT|GPIO_AF1|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN0)
+#define GPIO_TIM2_CH1_ETR_2 (GPIO_ALT|GPIO_FLOAT|GPIO_AF1|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN15)
+#define GPIO_TIM2_CH1_ETR_3 (GPIO_ALT|GPIO_FLOAT|GPIO_AF1|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN5)
+#define GPIO_TIM2_CH2IN_1 (GPIO_ALT|GPIO_FLOAT|GPIO_AF1|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN1)
+#define GPIO_TIM2_CH2OUT_1 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF1|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN1)
+#define GPIO_TIM2_CH2IN_2 (GPIO_ALT|GPIO_FLOAT|GPIO_AF1|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN3)
+#define GPIO_TIM2_CH2OUT_2 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF1|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN3)
+#define GPIO_TIM2_CH3IN_1 (GPIO_ALT|GPIO_FLOAT|GPIO_AF10|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN9)
+#define GPIO_TIM2_CH3OUT_1 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF10|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN9)
+#define GPIO_TIM2_CH3IN_2 (GPIO_ALT|GPIO_FLOAT|GPIO_AF1|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN2)
+#define GPIO_TIM2_CH3OUT_2 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF1|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN2)
+#define GPIO_TIM2_CH3IN_3 (GPIO_ALT|GPIO_FLOAT|GPIO_AF1|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN10)
+#define GPIO_TIM2_CH3OUT_3 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF1|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN10)
+#define GPIO_TIM2_CH4IN_1 (GPIO_ALT|GPIO_FLOAT|GPIO_AF10|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN10)
+#define GPIO_TIM2_CH4OUT_1 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF10|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN10)
+#define GPIO_TIM2_CH4IN_2 (GPIO_ALT|GPIO_FLOAT|GPIO_AF1|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN3)
+#define GPIO_TIM2_CH4OUT_2 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF1|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN3)
+#define GPIO_TIM2_CH4IN_3 (GPIO_ALT|GPIO_FLOAT|GPIO_AF1|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN11)
+#define GPIO_TIM2_CH4OUT_3 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF1|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN11)
+
+#define GPIO_TIM3_CH1IN_1 (GPIO_ALT|GPIO_FLOAT|GPIO_AF2|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN6)
+#define GPIO_TIM3_CH1OUT_1 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF2|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN6)
+#define GPIO_TIM3_CH1IN_2 (GPIO_ALT|GPIO_FLOAT|GPIO_AF2|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN4)
+#define GPIO_TIM3_CH1OUT_2 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF2|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN4)
+#define GPIO_TIM3_CH1IN_3 (GPIO_ALT|GPIO_FLOAT|GPIO_AF2|GPIO_SPEED_50MHz|GPIO_PORTC|GPIO_PIN6)
+#define GPIO_TIM3_CH1OUT_3 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF2|GPIO_SPEED_50MHz|GPIO_PORTC|GPIO_PIN6)
+#define GPIO_TIM3_CH2IN_1 (GPIO_ALT|GPIO_FLOAT|GPIO_AF2|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN4)
+#define GPIO_TIM3_CH2OUT_1 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF2|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN4)
+#define GPIO_TIM3_CH2IN_2 (GPIO_ALT|GPIO_FLOAT|GPIO_AF2|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN7)
+#define GPIO_TIM3_CH2OUT_2 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF2|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN7)
+#define GPIO_TIM3_CH2IN_3 (GPIO_ALT|GPIO_FLOAT|GPIO_AF2|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN5)
+#define GPIO_TIM3_CH2OUT_3 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF2|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN5)
+#define GPIO_TIM3_CH2IN_4 (GPIO_ALT|GPIO_FLOAT|GPIO_AF2|GPIO_SPEED_50MHz|GPIO_PORTC|GPIO_PIN7)
+#define GPIO_TIM3_CH2OUT_4 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF2|GPIO_SPEED_50MHz|GPIO_PORTC|GPIO_PIN7)
+#define GPIO_TIM3_CH3IN_1 (GPIO_ALT|GPIO_FLOAT|GPIO_AF2|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN0)
+#define GPIO_TIM3_CH3OUT_1 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF2|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN0)
+#define GPIO_TIM3_CH3IN_2 (GPIO_ALT|GPIO_FLOAT|GPIO_AF2|GPIO_SPEED_50MHz|GPIO_PORTC|GPIO_PIN8)
+#define GPIO_TIM3_CH3OUT_2 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF2|GPIO_SPEED_50MHz|GPIO_PORTC|GPIO_PIN8)
+#define GPIO_TIM3_CH4IN_1 (GPIO_ALT|GPIO_FLOAT|GPIO_AF10|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN7)
+#define GPIO_TIM3_CH4OUT_1 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF10|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN7)
+#define GPIO_TIM3_CH4IN_2 (GPIO_ALT|GPIO_FLOAT|GPIO_AF2|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN1)
+#define GPIO_TIM3_CH4OUT_2 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF2|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN1)
+#define GPIO_TIM3_CH4IN_3 (GPIO_ALT|GPIO_FLOAT|GPIO_AF2|GPIO_SPEED_50MHz|GPIO_PORTC|GPIO_PIN9)
+#define GPIO_TIM3_CH4OUT_3 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF2|GPIO_SPEED_50MHz|GPIO_PORTC|GPIO_PIN9)
+#define GPIO_TIM3_ETR_1 (GPIO_ALT|GPIO_FLOAT|GPIO_AF10|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN3)
+#define GPIO_TIM3_ETR_2 (GPIO_ALT|GPIO_FLOAT|GPIO_AF2|GPIO_SPEED_50MHz|GPIO_PORTD|GPIO_PIN2)
+
+#define GPIO_TIM15_BKIN (GPIO_ALT|GPIO_AF9|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN9)
+#define GPIO_TIM15_CH1IN_1 (GPIO_ALT|GPIO_FLOAT|GPIO_AF1|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN14)
+#define GPIO_TIM15_CH1OUT_1 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF1|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN14)
+#define GPIO_TIM15_CH1IN_2 (GPIO_ALT|GPIO_FLOAT|GPIO_AF9|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN2)
+#define GPIO_TIM15_CH1OUT_2 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF9|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN2)
+#define GPIO_TIM15_CH1N_1 (GPIO_ALT|GPIO_AF2|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN15)
+#define GPIO_TIM15_CH1N_2 (GPIO_ALT|GPIO_AF9|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN1)
+#define GPIO_TIM15_CH2IN_1 (GPIO_ALT|GPIO_FLOAT|GPIO_AF1|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN15)
+#define GPIO_TIM15_CH2OUT_1 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF1|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN15)
+#define GPIO_TIM15_CH2IN_2 (GPIO_ALT|GPIO_FLOAT|GPIO_AF9|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN3)
+#define GPIO_TIM15_CH2OUT_2 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF9|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN3)
+
+#define GPIO_TIM16_BKIN (GPIO_ALT|GPIO_AF1|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN5)
+#define GPIO_TIM16_CH1IN_1 (GPIO_ALT|GPIO_FLOAT|GPIO_AF1|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN12)
+#define GPIO_TIM16_CH1OUT_1 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF1|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN12)
+#define GPIO_TIM16_CH1IN_2 (GPIO_ALT|GPIO_FLOAT|GPIO_AF1|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN6)
+#define GPIO_TIM16_CH1OUT_2 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF1|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN6)
+#define GPIO_TIM16_CH1IN_3 (GPIO_ALT|GPIO_FLOAT|GPIO_AF1|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN4)
+#define GPIO_TIM16_CH1OUT_3 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF1|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN4)
+#define GPIO_TIM16_CH1IN_4 (GPIO_ALT|GPIO_FLOAT|GPIO_AF1|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN8)
+#define GPIO_TIM16_CH1OUT_4 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF1|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN8)
+#define GPIO_TIM16_CH1N_1 (GPIO_ALT|GPIO_AF1|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN13)
+#define GPIO_TIM16_CH1N_2 (GPIO_ALT|GPIO_AF1|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN6)
+
+#define GPIO_TIM17_BKIN_1 (GPIO_ALT|GPIO_AF10|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN4)
+#define GPIO_TIM17_BKIN_2 (GPIO_ALT|GPIO_AF1|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN10)
+#define GPIO_TIM17_CH1IN_1 (GPIO_ALT|GPIO_FLOAT|GPIO_AF1|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN7)
+#define GPIO_TIM17_CH1OUT_1 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF1|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN7)
+#define GPIO_TIM17_CH1IN_2 (GPIO_ALT|GPIO_FLOAT|GPIO_AF10|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN5)
+#define GPIO_TIM17_CH1OUT_2 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF10|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN5)
+#define GPIO_TIM17_CH1IN_3 (GPIO_ALT|GPIO_FLOAT|GPIO_AF1|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN9)
+#define GPIO_TIM17_CH1OUT_3 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF1|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN9)
+#define GPIO_TIM17_CH1N (GPIO_ALT|GPIO_AF1|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN7)
+
+/* HRTIM */
+
+#define GPIO_HRTIM1_SCOUT_1 (GPIO_ALT|GPIO_AF11|GPIO_PORTB|GPIO_PIN3)
+#define GPIO_HRTIM1_SCOUT_2 (GPIO_ALT|GPIO_AF13|GPIO_PORTB|GPIO_PIN1)
+#define GPIO_HRTIM1_SCIN_1 (GPIO_ALT|GPIO_AF11|GPIO_PORTB|GPIO_PIN6)
+#define GPIO_HRTIM1_SCIN_2 (GPIO_ALT|GPIO_AF13|GPIO_PORTB|GPIO_PIN2)
+#define GPIO_HRTIM1_CHA1 (GPIO_ALT|GPIO_AF13|GPIO_PORTA|GPIO_PIN8)
+#define GPIO_HRTIM1_CHA2 (GPIO_ALT|GPIO_AF13|GPIO_PORTA|GPIO_PIN9)
+#define GPIO_HRTIM1_CHB1 (GPIO_ALT|GPIO_AF13|GPIO_PORTA|GPIO_PIN10)
+#define GPIO_HRTIM1_CHB2 (GPIO_ALT|GPIO_AF13|GPIO_PORTA|GPIO_PIN11)
+#define GPIO_HRTIM1_CHC1 (GPIO_ALT|GPIO_AF13|GPIO_PORTB|GPIO_PIN12)
+#define GPIO_HRTIM1_CHC2 (GPIO_ALT|GPIO_AF13|GPIO_PORTB|GPIO_PIN13)
+#define GPIO_HRTIM1_CHD1 (GPIO_ALT|GPIO_AF13|GPIO_PORTB|GPIO_PIN14)
+#define GPIO_HRTIM1_CHD2 (GPIO_ALT|GPIO_AF13|GPIO_PORTB|GPIO_PIN15)
+#define GPIO_HRTIM1_CHE1 (GPIO_ALT|GPIO_AF3|GPIO_PORTC|GPIO_PIN8)
+#define GPIO_HRTIM1_CHE2 (GPIO_ALT|GPIO_AF3|GPIO_PORTC|GPIO_PIN9)
+#define GPIO_HRTIM1_FLT1 (GPIO_ALT|GPIO_AF13|GPIO_PORTA|GPIO_PIN12)
+#define GPIO_HRTIM1_FLT2 (GPIO_ALT|GPIO_AF13|GPIO_PORTA|GPIO_PIN15)
+#define GPIO_HRTIM1_FLT3 (GPIO_ALT|GPIO_AF13|GPIO_PORTB|GPIO_PIN10)
+#define GPIO_HRTIM1_FLT4 (GPIO_ALT|GPIO_AF13|GPIO_PORTB|GPIO_PIN11)
+#define GPIO_HRTIM1_FLT5 (GPIO_ALT|GPIO_AF3|GPIO_PORTC|GPIO_PIN7)
+#define GPIO_HRTIM1_EEV1 (GPIO_ALT|GPIO_AF3|GPIO_PORTC|GPIO_PIN12)
+#define GPIO_HRTIM1_EEV2 (GPIO_ALT|GPIO_AF3|GPIO_PORTC|GPIO_PIN11)
+#define GPIO_HRTIM1_EEV3 (GPIO_ALT|GPIO_AF13|GPIO_PORTB|GPIO_PIN7)
+#define GPIO_HRTIM1_EEV4 (GPIO_ALT|GPIO_AF13|GPIO_PORTB|GPIO_PIN6)
+#define GPIO_HRTIM1_EEV5 (GPIO_ALT|GPIO_AF13|GPIO_PORTB|GPIO_PIN9)
+#define GPIO_HRTIM1_EEV6 (GPIO_ALT|GPIO_AF13|GPIO_PORTB|GPIO_PIN5)
+#define GPIO_HRTIM1_EEV7 (GPIO_ALT|GPIO_AF13|GPIO_PORTB|GPIO_PIN4)
+#define GPIO_HRTIM1_EEV8 (GPIO_ALT|GPIO_AF13|GPIO_PORTB|GPIO_PIN8)
+#define GPIO_HRTIM1_EEV9 (GPIO_ALT|GPIO_AF13|GPIO_PORTB|GPIO_PIN3)
+#define GPIO_HRTIM1_EEV10 (GPIO_ALT|GPIO_AF3|GPIO_PORTC|GPIO_PIN6)
+
+/* OPAMP */
+
+#define GPIO_OPAMP2_DIG (GPIO_ALT|GPIO_AF3|GPIO_PORTA|GPIO_PIN6)
+#define GPIO_OPAMP2_VINM_1 (GPIO_ANALOG|GPIO_PORTA|GPIO_PIN5)
+#define GPIO_OPAMP2_VINM_2 (GPIO_ANALOG|GPIO_PORTC|GPIO_PIN5)
+#define GPIO_OPAMP2_VOUT (GPIO_ANALOG|GPIO_PORTA|GPIO_PIN6)
+#define GPIO_OPAMP2_VINP_1 (GPIO_ANALOG|GPIO_PORTA|GPIO_PIN7)
+#define GPIO_OPAMP2_VINP_2 (GPIO_ANALOG|GPIO_PORTB|GPIO_PIN0)
+#define GPIO_OPAMP2_VINP_3 (GPIO_ANALOG|GPIO_PORTB|GPIO_PIN14)
+
+/* TSC */
+
+#define GPIO_TSC_G1_IO1 (GPIO_ALT|GPIO_AF3|GPIO_PORTA|GPIO_PIN0)
+#define GPIO_TSC_G1_IO2 (GPIO_ALT|GPIO_AF3|GPIO_PORTA|GPIO_PIN1)
+#define GPIO_TSC_G1_IO3 (GPIO_ALT|GPIO_AF3|GPIO_PORTA|GPIO_PIN2)
+#define GPIO_TSC_G1_IO4 (GPIO_ALT|GPIO_AF3|GPIO_PORTA|GPIO_PIN3)
+#define GPIO_TSC_G2_IO1 (GPIO_ALT|GPIO_AF3|GPIO_PORTA|GPIO_PIN4)
+#define GPIO_TSC_G2_IO2 (GPIO_ALT|GPIO_AF3|GPIO_PORTA|GPIO_PIN5)
+#define GPIO_TSC_G2_IO3 (GPIO_ALT|GPIO_AF3|GPIO_PORTA|GPIO_PIN6)
+#define GPIO_TSC_G2_IO4 (GPIO_ALT|GPIO_AF3|GPIO_PORTA|GPIO_PIN7)
+#define GPIO_TSC_G3_IO1 (GPIO_ALT|GPIO_AF3|GPIO_PORTC|GPIO_PIN5)
+#define GPIO_TSC_G3_IO2 (GPIO_ALT|GPIO_AF3|GPIO_PORTB|GPIO_PIN0)
+#define GPIO_TSC_G3_IO3 (GPIO_ALT|GPIO_AF3|GPIO_PORTB|GPIO_PIN1)
+#define GPIO_TSC_G3_IO4 (GPIO_ALT|GPIO_AF3|GPIO_PORTB|GPIO_PIN2)
+#define GPIO_TSC_G4_IO1 (GPIO_ALT|GPIO_AF3|GPIO_PORTA|GPIO_PIN9)
+#define GPIO_TSC_G4_IO2 (GPIO_ALT|GPIO_AF3|GPIO_PORTA|GPIO_PIN10)
+#define GPIO_TSC_G4_IO3 (GPIO_ALT|GPIO_AF3|GPIO_PORTA|GPIO_PIN13)
+#define GPIO_TSC_G4_IO4 (GPIO_ALT|GPIO_AF3|GPIO_PORTA|GPIO_PIN14)
+#define GPIO_TSC_G5_IO1 (GPIO_ALT|GPIO_AF3|GPIO_PORTB|GPIO_PIN3)
+#define GPIO_TSC_G5_IO2 (GPIO_ALT|GPIO_AF3|GPIO_PORTB|GPIO_PIN4)
+#define GPIO_TSC_G5_IO3 (GPIO_ALT|GPIO_AF3|GPIO_PORTB|GPIO_PIN6)
+#define GPIO_TSC_G5_IO4 (GPIO_ALT|GPIO_AF3|GPIO_PORTB|GPIO_PIN7)
+#define GPIO_TSC_G6_IO1 (GPIO_ALT|GPIO_AF3|GPIO_PORTB|GPIO_PIN11)
+#define GPIO_TSC_G6_IO2 (GPIO_ALT|GPIO_AF3|GPIO_PORTB|GPIO_PIN12)
+#define GPIO_TSC_G6_IO3 (GPIO_ALT|GPIO_AF3|GPIO_PORTB|GPIO_PIN13)
+#define GPIO_TSC_G6_IO4 (GPIO_ALT|GPIO_AF3|GPIO_PORTB|GPIO_PIN14)
+#define GPIO_TSC_SYNC_1 (GPIO_ALT|GPIO_AF3|GPIO_PORTB|GPIO_PIN10)
+#define GPIO_TSC_SYNC_2 (GPIO_ALT|GPIO_AF3|GPIO_PORTA|GPIO_PIN15)
+#define GPIO_TSC_SYNC_3 (GPIO_ALT|GPIO_AF3|GPIO_PORTB|GPIO_PIN8)
+
+/* USARTs/UARTs */
+
+#define GPIO_USART1_CK (GPIO_ALT|GPIO_AF7|GPIO_PORTA|GPIO_PIN8)
+#define GPIO_USART1_CTS (GPIO_ALT|GPIO_AF7|GPIO_PORTA|GPIO_PIN11)
+#define GPIO_USART1_RTS (GPIO_ALT|GPIO_AF7|GPIO_PORTA|GPIO_PIN12)
+#define GPIO_USART1_RX_1 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF7|GPIO_PULLUP|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN10)
+#define GPIO_USART1_RX_2 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF7|GPIO_PULLUP|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN7)
+#define GPIO_USART1_RX_3 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF7|GPIO_PULLUP|GPIO_SPEED_50MHz|GPIO_PORTC|GPIO_PIN5)
+#define GPIO_USART1_TX_1 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF7|GPIO_PULLUP|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN9)
+#define GPIO_USART1_TX_2 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF7|GPIO_PULLUP|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN6)
+#define GPIO_USART1_TX_3 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF7|GPIO_PULLUP|GPIO_SPEED_50MHz|GPIO_PORTC|GPIO_PIN4)
+
+#define GPIO_USART2_CK_1 (GPIO_ALT|GPIO_AF7|GPIO_PORTA|GPIO_PIN4)
+#define GPIO_USART2_CK_2 (GPIO_ALT|GPIO_AF7|GPIO_PORTB|GPIO_PIN5)
+#define GPIO_USART2_CTS (GPIO_ALT|GPIO_AF7|GPIO_PORTA|GPIO_PIN0)
+#define GPIO_USART2_RTS (GPIO_ALT|GPIO_AF7|GPIO_PORTA|GPIO_PIN1)
+#define GPIO_USART2_RX_1 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF7|GPIO_PULLUP|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN3)
+#define GPIO_USART2_RX_2 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF7|GPIO_PULLUP|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN15)
+#define GPIO_USART2_RX_3 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF7|GPIO_PULLUP|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN4)
+#define GPIO_USART2_TX_1 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF7|GPIO_PULLUP|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN2)
+#define GPIO_USART2_TX_2 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF7|GPIO_PULLUP|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN14)
+#define GPIO_USART2_TX_3 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF7|GPIO_PULLUP|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN3)
+
+#define GPIO_USART3_CK_1 (GPIO_ALT|GPIO_AF7|GPIO_PORTB|GPIO_PIN12)
+#define GPIO_USART3_CK_2 (GPIO_ALT|GPIO_AF7|GPIO_PORTC|GPIO_PIN12)
+#define GPIO_USART3_CTS_1 (GPIO_ALT|GPIO_AF7|GPIO_PORTB|GPIO_PIN13)
+#define GPIO_USART3_CTS_2 (GPIO_ALT|GPIO_AF7|GPIO_PORTA|GPIO_PIN13)
+#define GPIO_USART3_RTS (GPIO_ALT|GPIO_AF7|GPIO_PORTB|GPIO_PIN14)
+#define GPIO_USART3_RX_1 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF7|GPIO_PULLUP|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN11)
+#define GPIO_USART3_RX_2 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF7|GPIO_PULLUP|GPIO_SPEED_50MHz|GPIO_PORTC|GPIO_PIN11)
+#define GPIO_USART3_RX_3 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF7|GPIO_PULLUP|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN8)
+#define GPIO_USART3_TX_1 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF7|GPIO_PULLUP|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN10)
+#define GPIO_USART3_TX_2 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF7|GPIO_PULLUP|GPIO_SPEED_50MHz|GPIO_PORTC|GPIO_PIN10)
+#define GPIO_USART3_TX_3 (GPIO_ALT|GPIO_PUSHPULL|GPIO_AF7|GPIO_PULLUP|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN9)
+
+/* Event Outputs */
+
+#define GPIO_PA0_EVENT_OUT (GPIO_ALT|GPIO_AF15|GPIO_PORTA|GPIO_PIN0)
+#define GPIO_PA0_EVENT_OUT (GPIO_ALT|GPIO_AF15|GPIO_PORTA|GPIO_PIN0)
+#define GPIO_PA0_EVENT_OUT (GPIO_ALT|GPIO_AF15|GPIO_PORTA|GPIO_PIN0)
+#define GPIO_PA0_EVENT_OUT (GPIO_ALT|GPIO_AF15|GPIO_PORTA|GPIO_PIN0)
+#define GPIO_PA1_EVENT_OUT (GPIO_ALT|GPIO_AF15|GPIO_PORTA|GPIO_PIN1)
+#define GPIO_PA2_EVENT_OUT (GPIO_ALT|GPIO_AF15|GPIO_PORTA|GPIO_PIN2)
+#define GPIO_PA3_EVENT_OUT (GPIO_ALT|GPIO_AF15|GPIO_PORTA|GPIO_PIN3)
+#define GPIO_PA4_EVENT_OUT (GPIO_ALT|GPIO_AF15|GPIO_PORTA|GPIO_PIN4)
+#define GPIO_PA5_EVENT_OUT (GPIO_ALT|GPIO_AF15|GPIO_PORTA|GPIO_PIN5)
+#define GPIO_PA6_EVENT_OUT (GPIO_ALT|GPIO_AF15|GPIO_PORTA|GPIO_PIN6)
+#define GPIO_PA7_EVENT_OUT (GPIO_ALT|GPIO_AF15|GPIO_PORTA|GPIO_PIN7)
+#define GPIO_PA8_EVENT_OUT (GPIO_ALT|GPIO_AF15|GPIO_PORTA|GPIO_PIN8)
+#define GPIO_PA9_EVENT_OUT (GPIO_ALT|GPIO_AF15|GPIO_PORTA|GPIO_PIN9)
+#define GPIO_PA10_EVENT_OUT (GPIO_ALT|GPIO_AF15|GPIO_PORTA|GPIO_PIN10)
+#define GPIO_PA11_EVENT_OUT (GPIO_ALT|GPIO_AF15|GPIO_PORTA|GPIO_PIN11)
+#define GPIO_PA12_EVENT_OUT (GPIO_ALT|GPIO_AF15|GPIO_PORTA|GPIO_PIN12)
+#define GPIO_PA13_EVENT_OUT (GPIO_ALT|GPIO_AF15|GPIO_PORTA|GPIO_PIN13)
+#define GPIO_PA14_EVENT_OUT (GPIO_ALT|GPIO_AF15|GPIO_PORTA|GPIO_PIN14)
+#define GPIO_PA15_EVENT_OUT (GPIO_ALT|GPIO_AF15|GPIO_PORTA|GPIO_PIN15)
+
+#define GPIO_PB0_EVENT_OUT (GPIO_ALT|GPIO_AF15|GPIO_PORTB|GPIO_PIN0)
+#define GPIO_PB1_EVENT_OUT (GPIO_ALT|GPIO_AF15|GPIO_PORTB|GPIO_PIN1)
+#define GPIO_PB2_EVENT_OUT (GPIO_ALT|GPIO_AF15|GPIO_PORTB|GPIO_PIN2)
+#define GPIO_PB3_EVENT_OUT (GPIO_ALT|GPIO_AF15|GPIO_PORTB|GPIO_PIN3)
+#define GPIO_PB4_EVENT_OUT (GPIO_ALT|GPIO_AF15|GPIO_PORTB|GPIO_PIN4)
+#define GPIO_PB5_EVENT_OUT (GPIO_ALT|GPIO_AF15|GPIO_PORTB|GPIO_PIN5)
+#define GPIO_PB6_EVENT_OUT (GPIO_ALT|GPIO_AF15|GPIO_PORTB|GPIO_PIN6)
+#define GPIO_PB7_EVENT_OUT (GPIO_ALT|GPIO_AF15|GPIO_PORTB|GPIO_PIN7)
+#define GPIO_PB8_EVENT_OUT (GPIO_ALT|GPIO_AF15|GPIO_PORTB|GPIO_PIN8)
+#define GPIO_PB9_EVENT_OUT (GPIO_ALT|GPIO_AF15|GPIO_PORTB|GPIO_PIN9)
+#define GPIO_PB10_EVENT_OUT (GPIO_ALT|GPIO_AF15|GPIO_PORTB|GPIO_PIN10)
+#define GPIO_PB11_EVENT_OUT (GPIO_ALT|GPIO_AF15|GPIO_PORTB|GPIO_PIN11)
+#define GPIO_PB12_EVENT_OUT (GPIO_ALT|GPIO_AF15|GPIO_PORTB|GPIO_PIN12)
+#define GPIO_PB13_EVENT_OUT (GPIO_ALT|GPIO_AF15|GPIO_PORTB|GPIO_PIN13)
+#define GPIO_PB14_EVENT_OUT (GPIO_ALT|GPIO_AF15|GPIO_PORTB|GPIO_PIN14)
+#define GPIO_PB15_EVENT_OUT (GPIO_ALT|GPIO_AF15|GPIO_PORTB|GPIO_PIN15)
+
+#define GPIO_PC0_EVENT_OUT (GPIO_ALT|GPIO_AF1|GPIO_PORTC|GPIO_PIN0)
+#define GPIO_PC1_EVENT_OUT (GPIO_ALT|GPIO_AF1|GPIO_PORTC|GPIO_PIN1)
+#define GPIO_PC2_EVENT_OUT (GPIO_ALT|GPIO_AF1|GPIO_PORTC|GPIO_PIN2)
+#define GPIO_PC3_EVENT_OUT (GPIO_ALT|GPIO_AF1|GPIO_PORTC|GPIO_PIN3)
+#define GPIO_PC4_EVENT_OUT (GPIO_ALT|GPIO_AF1|GPIO_PORTC|GPIO_PIN4)
+#define GPIO_PC5_EVENT_OUT (GPIO_ALT|GPIO_AF1|GPIO_PORTC|GPIO_PIN5)
+#define GPIO_PC6_EVENT_OUT (GPIO_ALT|GPIO_AF1|GPIO_PORTC|GPIO_PIN6)
+#define GPIO_PC7_EVENT_OUT (GPIO_ALT|GPIO_AF1|GPIO_PORTC|GPIO_PIN7)
+#define GPIO_PC8_EVENT_OUT (GPIO_ALT|GPIO_AF1|GPIO_PORTC|GPIO_PIN8)
+#define GPIO_PC9_EVENT_OUT (GPIO_ALT|GPIO_AF1|GPIO_PORTC|GPIO_PIN9)
+#define GPIO_PC10_EVENT_OUT (GPIO_ALT|GPIO_AF1|GPIO_PORTC|GPIO_PIN10)
+#define GPIO_PC11_EVENT_OUT (GPIO_ALT|GPIO_AF1|GPIO_PORTC|GPIO_PIN11)
+#define GPIO_PC12_EVENT_OUT (GPIO_ALT|GPIO_AF1|GPIO_PORTC|GPIO_PIN12)
+
+#define GPIO_PD2_EVENT_OUT (GPIO_ALT|GPIO_AF1|GPIO_PORTD|GPIO_PIN2)
+
+#endif /* __ARCH_ARM_SRC_STM32_CHIP_STM32F33XXX_PINMAP_H */
diff --git a/arch/arm/src/stm32/chip/stm32f33xxx_rcc.h b/arch/arm/src/stm32/chip/stm32f33xxx_rcc.h
new file mode 100644
index 0000000000000000000000000000000000000000..806b22e0502d9583899f6cc6a7778a77c9d88f08
--- /dev/null
+++ b/arch/arm/src/stm32/chip/stm32f33xxx_rcc.h
@@ -0,0 +1,361 @@
+/************************************************************************************
+ * arch/arm/src/stm32/chip/stm32f33xx_rcc.h
+ * For STM32F33xx advanced ARM-based 32-bit MCUs
+ *
+ * Copyright (C) 2013 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ * Modified for STM32F334 by Mateusz Szafoni
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ************************************************************************************/
+
+#ifndef __ARCH_ARM_SRC_STM32_CHIP_STM32F33XXX_RCC_H
+#define __ARCH_ARM_SRC_STM32_CHIP_STM32F33XXX_RCC_H
+
+/************************************************************************************
+ * Pre-processor Definitions
+ ************************************************************************************/
+
+/* Register Offsets *****************************************************************/
+
+#define STM32_RCC_CR_OFFSET 0x0000 /* Clock control register */
+#define STM32_RCC_CFGR_OFFSET 0x0004 /* Clock configuration register */
+#define STM32_RCC_CIR_OFFSET 0x0008 /* Clock interrupt register */
+#define STM32_RCC_APB2RSTR_OFFSET 0x000c /* APB2 Peripheral reset register */
+#define STM32_RCC_APB1RSTR_OFFSET 0x0010 /* APB1 Peripheral reset register */
+#define STM32_RCC_AHBENR_OFFSET 0x0014 /* AHB Peripheral Clock enable register */
+#define STM32_RCC_APB2ENR_OFFSET 0x0018 /* APB2 Peripheral Clock enable register */
+#define STM32_RCC_APB1ENR_OFFSET 0x001c /* APB1 Peripheral Clock enable register */
+#define STM32_RCC_BDCR_OFFSET 0x0020 /* Backup domain control register */
+#define STM32_RCC_CSR_OFFSET 0x0024 /* Control/status register */
+#define STM32_RCC_AHBRSTR_OFFSET 0x0028 /* AHB Reset register */
+#define STM32_RCC_CFGR2_OFFSET 0x002c /* Clock configuration register 2 */
+#define STM32_RCC_CFGR3_OFFSET 0x0030 /* Clock configuration register 3 */
+
+/* Register Addresses ***************************************************************/
+
+#define STM32_RCC_CR (STM32_RCC_BASE+STM32_RCC_CR_OFFSET)
+#define STM32_RCC_CFGR (STM32_RCC_BASE+STM32_RCC_CFGR_OFFSET)
+#define STM32_RCC_CIR (STM32_RCC_BASE+STM32_RCC_CIR_OFFSET)
+#define STM32_RCC_APB2RSTR (STM32_RCC_BASE+STM32_RCC_APB2RSTR_OFFSET)
+#define STM32_RCC_APB1RSTR (STM32_RCC_BASE+STM32_RCC_APB1RSTR_OFFSET)
+#define STM32_RCC_AHBENR (STM32_RCC_BASE+STM32_RCC_AHBENR_OFFSET)
+#define STM32_RCC_APB2ENR (STM32_RCC_BASE+STM32_RCC_APB2ENR_OFFSET)
+#define STM32_RCC_APB1ENR (STM32_RCC_BASE+STM32_RCC_APB1ENR_OFFSET)
+#define STM32_RCC_BDCR (STM32_RCC_BASE+STM32_RCC_BDCR_OFFSET)
+#define STM32_RCC_CSR (STM32_RCC_BASE+STM32_RCC_CSR_OFFSET)
+#define STM32_RCC_AHBRSTR (STM32_RCC_BASE+STM32_RCC_AHBRSTR_OFFSET)
+#define STM32_RCC_CFGR2 (STM32_RCC_BASE+STM32_RCC_CFGR2_OFFSET)
+#define STM32_RCC_CFGR3 (STM32_RCC_BASE+STM32_RCC_CFGR3_OFFSET)
+
+/* Register Bitfield Definitions ****************************************************/
+
+/* Clock control register */
+
+#define RCC_CR_HSION (1 << 0) /* Bit 0: Internal High Speed clock enable */
+#define RCC_CR_HSIRDY (1 << 1) /* Bit 1: Internal High Speed clock ready flag */
+#define RCC_CR_HSITRIM_SHIFT (3) /* Bits 7-3: Internal High Speed clock trimming */
+#define RCC_CR_HSITRIM_MASK (0x1f << RCC_CR_HSITRIM_SHIFT)
+#define RCC_CR_HSICAL_SHIFT (8) /* Bits 15-8: Internal High Speed clock Calibration */
+#define RCC_CR_HSICAL_MASK (0xff << RCC_CR_HSICAL_SHIFT)
+#define RCC_CR_HSEON (1 << 16) /* Bit 16: External High Speed clock enable */
+#define RCC_CR_HSERDY (1 << 17) /* Bit 17: External High Speed clock ready flag */
+#define RCC_CR_HSEBYP (1 << 18) /* Bit 18: External High Speed clock Bypass */
+#define RCC_CR_CSSON (1 << 19) /* Bit 19: Clock Security System enable */
+#define RCC_CR_PLLON (1 << 24) /* Bit 24: PLL enable */
+#define RCC_CR_PLLRDY (1 << 25) /* Bit 25: PLL clock ready flag */
+
+/* Clock configuration register */
+
+#define RCC_CFGR_SW_SHIFT (0) /* Bits 1-0: System clock Switch */
+#define RCC_CFGR_SW_MASK (3 << RCC_CFGR_SW_SHIFT)
+# define RCC_CFGR_SW_HSI (0 << RCC_CFGR_SW_SHIFT) /* 00: HSI selected as system clock */
+# define RCC_CFGR_SW_HSE (1 << RCC_CFGR_SW_SHIFT) /* 01: HSE selected as system clock */
+# define RCC_CFGR_SW_PLL (2 << RCC_CFGR_SW_SHIFT) /* 10: PLL selected as system clock */
+#define RCC_CFGR_SWS_SHIFT (2) /* Bits 3-2: System Clock Switch Status */
+#define RCC_CFGR_SWS_MASK (3 << RCC_CFGR_SWS_SHIFT)
+# define RCC_CFGR_SWS_HSI (0 << RCC_CFGR_SWS_SHIFT) /* 00: HSI oscillator used as system clock */
+# define RCC_CFGR_SWS_HSE (1 << RCC_CFGR_SWS_SHIFT) /* 01: HSE oscillator used as system clock */
+# define RCC_CFGR_SWS_PLL (2 << RCC_CFGR_SWS_SHIFT) /* 10: PLL used as system clock */
+#define RCC_CFGR_HPRE_SHIFT (4) /* Bits 7-4: AHB prescaler */
+#define RCC_CFGR_HPRE_MASK (0x0f << RCC_CFGR_HPRE_SHIFT)
+# define RCC_CFGR_HPRE_SYSCLK (0 << RCC_CFGR_HPRE_SHIFT) /* 0xxx: SYSCLK not divided */
+# define RCC_CFGR_HPRE_SYSCLKd2 (8 << RCC_CFGR_HPRE_SHIFT) /* 1000: SYSCLK divided by 2 */
+# define RCC_CFGR_HPRE_SYSCLKd4 (9 << RCC_CFGR_HPRE_SHIFT) /* 1001: SYSCLK divided by 4 */
+# define RCC_CFGR_HPRE_SYSCLKd8 (10 << RCC_CFGR_HPRE_SHIFT) /* 1010: SYSCLK divided by 8 */
+# define RCC_CFGR_HPRE_SYSCLKd16 (11 << RCC_CFGR_HPRE_SHIFT) /* 1011: SYSCLK divided by 16 */
+# define RCC_CFGR_HPRE_SYSCLKd64 (12 << RCC_CFGR_HPRE_SHIFT) /* 1100: SYSCLK divided by 64 */
+# define RCC_CFGR_HPRE_SYSCLKd128 (13 << RCC_CFGR_HPRE_SHIFT) /* 1101: SYSCLK divided by 128 */
+# define RCC_CFGR_HPRE_SYSCLKd256 (14 << RCC_CFGR_HPRE_SHIFT) /* 1110: SYSCLK divided by 256 */
+# define RCC_CFGR_HPRE_SYSCLKd512 (15 << RCC_CFGR_HPRE_SHIFT) /* 1111: SYSCLK divided by 512 */
+#define RCC_CFGR_PPRE1_SHIFT (8) /* Bits 10-8: APB Low speed prescaler (APB1) */
+#define RCC_CFGR_PPRE1_MASK (7 << RCC_CFGR_PPRE1_SHIFT)
+# define RCC_CFGR_PPRE1_HCLK (0 << RCC_CFGR_PPRE1_SHIFT) /* 0xx: HCLK not divided */
+# define RCC_CFGR_PPRE1_HCLKd2 (4 << RCC_CFGR_PPRE1_SHIFT) /* 100: HCLK divided by 2 */
+# define RCC_CFGR_PPRE1_HCLKd4 (5 << RCC_CFGR_PPRE1_SHIFT) /* 101: HCLK divided by 4 */
+# define RCC_CFGR_PPRE1_HCLKd8 (6 << RCC_CFGR_PPRE1_SHIFT) /* 110: HCLK divided by 8 */
+# define RCC_CFGR_PPRE1_HCLKd16 (7 << RCC_CFGR_PPRE1_SHIFT) /* 111: HCLK divided by 16 */
+#define RCC_CFGR_PPRE2_SHIFT (11) /* Bits 13-11: APB High speed prescaler (APB2) */
+#define RCC_CFGR_PPRE2_MASK (7 << RCC_CFGR_PPRE2_SHIFT)
+# define RCC_CFGR_PPRE2_HCLK (0 << RCC_CFGR_PPRE2_SHIFT) /* 0xx: HCLK not divided */
+# define RCC_CFGR_PPRE2_HCLKd2 (4 << RCC_CFGR_PPRE2_SHIFT) /* 100: HCLK divided by 2 */
+# define RCC_CFGR_PPRE2_HCLKd4 (5 << RCC_CFGR_PPRE2_SHIFT) /* 101: HCLK divided by 4 */
+# define RCC_CFGR_PPRE2_HCLKd8 (6 << RCC_CFGR_PPRE2_SHIFT) /* 110: HCLK divided by 8 */
+# define RCC_CFGR_PPRE2_HCLKd16 (7 << RCC_CFGR_PPRE2_SHIFT) /* 111: HCLK divided by 16 */
+#define RCC_CFGR_PLLSRC (1 << 16) /* Bit 16: PLL entry clock source */
+#define RCC_CFGR_PLLXTPRE (1 << 17) /* Bit 17: HSE divider for PLL entry */
+#define RCC_CFGR_PLLMUL_SHIFT (18) /* Bits 21-18: PLL Multiplication Factor */
+#define RCC_CFGR_PLLMUL_MASK (0x0f << RCC_CFGR_PLLMUL_SHIFT)
+# define RCC_CFGR_PLLMUL_CLKx2 (0 << RCC_CFGR_PLLMUL_SHIFT) /* 0000: PLL input clock x 2 */
+# define RCC_CFGR_PLLMUL_CLKx3 (1 << RCC_CFGR_PLLMUL_SHIFT) /* 0001: PLL input clock x 3 */
+# define RCC_CFGR_PLLMUL_CLKx4 (2 << RCC_CFGR_PLLMUL_SHIFT) /* 0010: PLL input clock x 4 */
+# define RCC_CFGR_PLLMUL_CLKx5 (3 << RCC_CFGR_PLLMUL_SHIFT) /* 0011: PLL input clock x 5 */
+# define RCC_CFGR_PLLMUL_CLKx6 (4 << RCC_CFGR_PLLMUL_SHIFT) /* 0100: PLL input clock x 6 */
+# define RCC_CFGR_PLLMUL_CLKx7 (5 << RCC_CFGR_PLLMUL_SHIFT) /* 0101: PLL input clock x 7 */
+# define RCC_CFGR_PLLMUL_CLKx8 (6 << RCC_CFGR_PLLMUL_SHIFT) /* 0110: PLL input clock x 8 */
+# define RCC_CFGR_PLLMUL_CLKx9 (7 << RCC_CFGR_PLLMUL_SHIFT) /* 0111: PLL input clock x 9 */
+# define RCC_CFGR_PLLMUL_CLKx10 (8 << RCC_CFGR_PLLMUL_SHIFT) /* 1000: PLL input clock x 10 */
+# define RCC_CFGR_PLLMUL_CLKx11 (9 << RCC_CFGR_PLLMUL_SHIFT) /* 1001: PLL input clock x 11 */
+# define RCC_CFGR_PLLMUL_CLKx12 (10 << RCC_CFGR_PLLMUL_SHIFT) /* 1010: PLL input clock x 12 */
+# define RCC_CFGR_PLLMUL_CLKx13 (11 << RCC_CFGR_PLLMUL_SHIFT) /* 1011: PLL input clock x 13 */
+# define RCC_CFGR_PLLMUL_CLKx14 (12 << RCC_CFGR_PLLMUL_SHIFT) /* 1100: PLL input clock x 14 */
+# define RCC_CFGR_PLLMUL_CLKx15 (13 << RCC_CFGR_PLLMUL_SHIFT) /* 1101: PLL input clock x 15 */
+# define RCC_CFGR_PLLMUL_CLKx16 (14 << RCC_CFGR_PLLMUL_SHIFT) /* 111x: PLL input clock x 16 */
+#define RCC_CFGR_MCO_SHIFT (24) /* Bits 26-24: Microcontroller Clock Output */
+#define RCC_CFGR_MCO_MASK (3 << RCC_CFGR_MCO_SHIFT)
+# define RCC_CFGR_MCO_DISABLED (0 << RCC_CFGR_MCO_SHIFT) /* 000: MCO output disabled, no clock on MCO */
+# define RCC_CFGR_MCO_LSICLK (2 << RCC_CFGR_MCO_SHIFT) /* 010: LSI clock selected */
+# define RCC_CFGR_MCO_LSECLK (3 << RCC_CFGR_MCO_SHIFT) /* 011: LSE clock selected */
+# define RCC_CFGR_MCO_SYSCLK (4 << RCC_CFGR_MCO_SHIFT) /* 100: System clock (SYSCLK) selected */
+# define RCC_CFGR_MCO_HSICLK (5 << RCC_CFGR_MCO_SHIFT) /* 101: HSI clock selected */
+# define RCC_CFGR_MCO_HSECLK (6 << RCC_CFGR_MCO_SHIFT) /* 101: HSE clock selected */
+# define RCC_CFGR_PLLCLKd2 (7 << RCC_CFGR_MCO_SHIFT) /* 111: PLL clock divided by 2 selected */
+#define RCC_CFGR_MCOPRE_SHIFT (28) /* Bits 30-28: Microcontroller Clock Output */
+#define RCC_CFGR_MCOPRE_MASK (7 << RCC_CFGR_MCOPRE_SHIFT)
+# define RCC_CFGR_MCOPRE_MCOd1 (0 << RCC_CFGR_MCOPRE_SHIFT) /* 000: MCO is divided by 1 */
+# define RCC_CFGR_MCOPRE_MCOd2 (1 << RCC_CFGR_MCOPRE_SHIFT) /* 001: MCO is divided by 2 */
+# define RCC_CFGR_MCOPRE_MCOd4 (2 << RCC_CFGR_MCOPRE_SHIFT) /* 010: MCO is divided by 4 */
+# define RCC_CFGR_MCOPRE_MCOd8 (3 << RCC_CFGR_MCOPRE_SHIFT) /* 011: MCO is divided by 8 */
+# define RCC_CFGR_MCOPRE_MCOd16 (4 << RCC_CFGR_MCOPRE_SHIFT) /* 100: MCO is divided by 16 */
+# define RCC_CFGR_MCOPRE_MCOd32 (5 << RCC_CFGR_MCOPRE_SHIFT) /* 101: MCO is divided by 32 */
+# define RCC_CFGR_MCOPRE_MCOd64 (6 << RCC_CFGR_MCOPRE_SHIFT) /* 110: MCO is divided by 64 */
+# define RCC_CFGR_MCOPRE_MCOd128 (7 << RCC_CFGR_MCOPRE_SHIFT) /* 111: MCO is divided by 128 */
+#define RCC_CFGR_PLLNODIV (1 << 31) /* Bit 31: Do not divide PLL to MCO */
+
+/* Clock interrupt register */
+
+#define RCC_CIR_LSIRDYF (1 << 0) /* Bit 0: LSI Ready Interrupt flag */
+#define RCC_CIR_LSERDYF (1 << 1) /* Bit 1: LSE Ready Interrupt flag */
+#define RCC_CIR_HSIRDYF (1 << 2) /* Bit 2: HSI Ready Interrupt flag */
+#define RCC_CIR_HSERDYF (1 << 3) /* Bit 3: HSE Ready Interrupt flag */
+#define RCC_CIR_PLLRDYF (1 << 4) /* Bit 4: PLL Ready Interrupt flag */
+#define RCC_CIR_CSSF (1 << 7) /* Bit 7: Clock Security System Interrupt flag */
+#define RCC_CIR_LSIRDYIE (1 << 8) /* Bit 8: LSI Ready Interrupt Enable */
+#define RCC_CIR_LSERDYIE (1 << 9) /* Bit 9: LSE Ready Interrupt Enable */
+#define RCC_CIR_HSIRDYIE (1 << 10) /* Bit 10: HSI Ready Interrupt Enable */
+#define RCC_CIR_HSERDYIE (1 << 11) /* Bit 11: HSE Ready Interrupt Enable */
+#define RCC_CIR_PLLRDYIE (1 << 12) /* Bit 12: PLL Ready Interrupt Enable */
+#define RCC_CIR_LSIRDYC (1 << 16) /* Bit 16: LSI Ready Interrupt Clear */
+#define RCC_CIR_LSERDYC (1 << 17) /* Bit 17: LSE Ready Interrupt Clear */
+#define RCC_CIR_HSIRDYC (1 << 18) /* Bit 18: HSI Ready Interrupt Clear */
+#define RCC_CIR_HSERDYC (1 << 19) /* Bit 19: HSE Ready Interrupt Clear */
+#define RCC_CIR_PLLRDYC (1 << 20) /* Bit 20: PLL Ready Interrupt Clear */
+#define RCC_CIR_CSSC (1 << 23) /* Bit 23: Clock Security System Interrupt Clear */
+
+/* APB2 Peripheral reset register */
+
+#define RCC_APB2RSTR_SYSCFGRST (1 << 0) /* Bit 0: SYSCFG, Comparators and operational amplifiers reset */
+#define RCC_APB2RSTR_TIM1RST (1 << 9) /* Bit 9: TIM1 reset */
+#define RCC_APB2RSTR_SPI1RST (1 << 12) /* Bit 12: SPI 1 reset */
+#define RCC_APB2RSTR_USART1RST (1 << 14) /* Bit 14: USART1 reset */
+#define RCC_APB2RSTR_TIM15RST (1 << 16) /* Bit 16: TIM15 reset */
+#define RCC_APB2RSTR_TIM16RST (1 << 17) /* Bit 17: TIM16 reset */
+#define RCC_APB2RSTR_TIM17RST (1 << 18) /* Bit 18: TIM17 reset */
+#define RCC_APB2RSTR_HRTIM1RST (1 << 26) /* Bit 29: HRTIM1 reset */
+
+/* APB1 Peripheral reset register */
+
+#define RCC_APB1RSTR_TIM2RST (1 << 0) /* Bit 0: Timer 2 reset */
+#define RCC_APB1RSTR_TIM3RST (1 << 1) /* Bit 1: Timer 3 reset */
+#define RCC_APB1RSTR_TIM6RST (1 << 4) /* Bit 4: Timer 6 reset */
+#define RCC_APB1RSTR_TIM7RST (1 << 5) /* Bit 5: Timer 7 reset */
+#define RCC_APB1RSTR_WWDGRST (1 << 11) /* Bit 11: Window Watchdog reset */
+#define RCC_APB1RSTR_USART2RST (1 << 17) /* Bit 17: USART 2 reset */
+#define RCC_APB1RSTR_USART3RST (1 << 18) /* Bit 18: USART 3 reset */
+#define RCC_APB1RSTR_I2C1RST (1 << 21) /* Bit 21: I2C 1 reset */
+#define RCC_APB1RSTR_CANRST (1 << 25) /* Bit 25: CAN reset */
+#define RCC_APB1RSTR_CAN1RST (1 << 25) /* Bit 25: CAN reset */
+#define RCC_APB1RSTR_DAC2RST (1 << 26) /* Bit 26: DAC2 interface reset */
+#define RCC_APB1RSTR_PWRRST (1 << 28) /* Bit 28: Power interface reset */
+#define RCC_APB1RSTR_DAC1RST (1 << 29) /* Bit 29: DAC1 interface reset */
+
+/* AHB Peripheral Clock enable register */
+
+#define RCC_AHBENR_DMA1EN (1 << 0) /* Bit 0: DMA1 clock enable */
+#define RCC_AHBENR_SRAMEN (1 << 2) /* Bit 2: SRAM interface clock enable */
+#define RCC_AHBENR_FLITFEN (1 << 4) /* Bit 4: FLITF clock enable */
+#define RCC_AHBENR_CRCEN (1 << 6) /* Bit 6: CRC clock enable */
+#define RCC_AHBENR_IOPAEN (1 << 17) /* Bit 17: I/O port A clock enable */
+#define RCC_AHBENR_IOPBEN (1 << 18) /* Bit 17: I/O port B clock enable */
+#define RCC_AHBENR_IOPCEN (1 << 19) /* Bit 17: I/O port C clock enable */
+#define RCC_AHBENR_IOPDEN (1 << 20) /* Bit 17: I/O port D clock enable */
+#define RCC_AHBENR_IOPFEN (1 << 22) /* Bit 17: I/O port F clock enable */
+#define RCC_AHBENR_TSCEN (1 << 24) /* Bit 24: TSCEN: Touch sensing controller clock enable */
+#define RCC_AHBENR_ADC12EN (1 << 28) /* Bit 28: ADC1/ADC2 clock enable */
+
+/* APB2 Peripheral Clock enable register */
+
+#define RCC_APB2ENR_SYSCFGEN (1 << 0) /* Bit 0: SYSCFG, Comparators and operational amplifiers clock enable */
+#define RCC_APB2ENR_TIM1EN (1 << 11) /* Bit 11: TIM1 clock enable */
+#define RCC_APB2ENR_SPI1EN (1 << 12) /* Bit 12: SPI 1 clock enable */
+#define RCC_APB2ENR_USART1EN (1 << 14) /* Bit 14: USART1 clock enable */
+#define RCC_APB2ENR_TIM15EN (1 << 16) /* Bit 16: TIM15 clock enable */
+#define RCC_APB2ENR_TIM16EN (1 << 17) /* Bit 17: TIM16 clock enable */
+#define RCC_APB2ENR_TIM17EN (1 << 18) /* Bit 18: TIM17 clock enable */
+#define RCC_APB2ENR_HRTIM1EN (1 << 29) /* Bit 29: HRTIM1 clock enable */
+
+/* APB1 Peripheral Clock enable register */
+
+#define RCC_APB1ENR_TIM2EN (1 << 0) /* Bit 0: Timer 2 clock enable */
+#define RCC_APB1ENR_TIM3EN (1 << 1) /* Bit 1: Timer 3 clock enable */
+#define RCC_APB1ENR_TIM6EN (1 << 4) /* Bit 4: Timer 6 clock enable */
+#define RCC_APB1ENR_TIM7EN (1 << 5) /* Bit 5: Timer 7 clock enable */
+#define RCC_APB1ENR_WWDGEN (1 << 11) /* Bit 11: Window Watchdog clock enable */
+#define RCC_APB1ENR_USART2EN (1 << 17) /* Bit 17: USART 2 clock enable */
+#define RCC_APB1ENR_USART3EN (1 << 18) /* Bit 18: USART 3 clock enable */
+#define RCC_APB1ENR_I2C1EN (1 << 21) /* Bit 21: I2C 1 clock enable */
+#define RCC_APB1ENR_CANEN (1 << 25) /* Bit 25: CAN clock enable */
+#define RCC_APB1ENR_DAC2EN (1 << 26) /* Bit 26: DAC1 interface clock enable */
+#define RCC_APB1ENR_PWREN (1 << 28) /* Bit 28: Power interface clock enable */
+#define RCC_APB1ENR_DAC1EN (1 << 29) /* Bit 29: DAC1 interface clock enable */
+
+/* Backup domain control register */
+
+#define RCC_BDCR_LSEON (1 << 0) /* Bit 0: External Low Speed oscillator enable */
+#define RCC_BDCR_LSERDY (1 << 1) /* Bit 1: External Low Speed oscillator Ready */
+#define RCC_BDCR_LSEBYP (1 << 2) /* Bit 2: External Low Speed oscillator Bypass */
+#define RCC_BDCR_LSEDRV_SHIFT (3) /* Bits 4:3: LSE oscillator drive capability */
+#define RCC_BDCR_LSEDRV_MASK (3 << RCC_BDCR_LSEDRV_SHIFT)
+# define RCC_BDCR_LSEDRV_LOW (0 << RCC_BDCR_LSEDRV_SHIFT) /* 'Xtal mode' lower driving capability */
+# define RCC_BDCR_LSEDRV_MEDLOW (1 << RCC_BDCR_LSEDRV_SHIFT) /* 'Xtal mode' medium low driving capability */
+# define RCC_BDCR_LSEDRV_MEDHIGH (2 << RCC_BDCR_LSEDRV_SHIFT) /* 'Xtal mode' medium high driving capability */
+# define RCC_BDCR_LSEDRV_HIGH (3 << RCC_BDCR_LSEDRV_SHIFT) /* 'Xtal mode' higher driving capability */
+#define RCC_BDCR_RTCSEL_SHIFT (8) /* Bits 9:8: RTC clock source selection */
+#define RCC_BDCR_RTCSEL_MASK (3 << RCC_BDCR_RTCSEL_SHIFT)
+# define RCC_BDCR_RTCSEL_NOCLK (0 << RCC_BDCR_RTCSEL_SHIFT) /* 00: No clock */
+# define RCC_BDCR_RTCSEL_LSE (1 << RCC_BDCR_RTCSEL_SHIFT) /* 01: LSE oscillator clock used as RTC clock */
+# define RCC_BDCR_RTCSEL_LSI (2 << RCC_BDCR_RTCSEL_SHIFT) /* 10: LSI oscillator clock used as RTC clock */
+# define RCC_BDCR_RTCSEL_HSE (3 << RCC_BDCR_RTCSEL_SHIFT) /* 11: HSE oscillator clock divided by 128 used as RTC clock */
+#define RCC_BDCR_RTCEN (1 << 15) /* Bit 15: RTC clock enable */
+#define RCC_BDCR_BDRST (1 << 16) /* Bit 16: Backup domain software reset */
+
+/* Control/status register */
+
+#define RCC_CSR_LSION (1 << 0) /* Bit 0: Internal Low Speed oscillator enable */
+#define RCC_CSR_LSIRDY (1 << 1) /* Bit 1: Internal Low Speed oscillator Ready */
+#define RCC_CSR_RMVF (1 << 24) /* Bit 24: Remove reset flag */
+#define RCC_CSR_OBLRSTF (1 << 25) /* Bit 25: Option byte loader reset flag */
+#define RCC_CSR_PINRSTF (1 << 26) /* Bit 26: PIN reset flag */
+#define RCC_CSR_PORRSTF (1 << 27) /* Bit 27: POR/PDR reset flag */
+#define RCC_CSR_SFTRSTF (1 << 28) /* Bit 28: Software Reset flag */
+#define RCC_CSR_IWDGRSTF (1 << 29) /* Bit 29: Independent Watchdog reset flag */
+#define RCC_CSR_WWDGRSTF (1 << 30) /* Bit 30: Window watchdog reset flag */
+#define RCC_CSR_LPWRRSTF (1 << 31) /* Bit 31: Low-Power reset flag */
+
+/* AHB peripheral clock reset register (RCC_AHBRSTR) */
+
+#define RCC_AHBRSTR_IOPARST (1 << 17) /* Bit 17: I/O port A reset */
+#define RCC_AHBRSTR_IOPBRST (1 << 18) /* Bit 18: I/O port B reset */
+#define RCC_AHBRSTR_IOPCRST (1 << 29) /* Bit 19: I/O port C reset */
+#define RCC_AHBRSTR_IOPDRST (1 << 20) /* Bit 20: I/O port D reset */
+#define RCC_AHBRSTR_IOPFRST (1 << 22) /* Bit 22: I/O port F reset */
+#define RCC_AHBRSTR_TSCRST (1 << 24) /* Bit 24: Touch sensing controller reset */
+#define RCC_AHBRSTR_ADC12RST (1 << 28) /* Bit 24: ADC1/ADC2 reset */
+
+/* Clock configuration register 2 */
+
+#define RCC_CFGR2_PREDIV_SHIFT (0) /* Bits 0-3: PREDIV division factor */
+#define RCC_CFGR2_PREDIV_MASK (15 << RCC_CFGR2_PREDIV_SHIFT)
+# define RCC_CFGR2_PREDIVd1 (0 << RCC_CFGR2_PREDIV_SHIFT) /* 0000: HSE input to PLL not divided */
+# define RCC_CFGR2_PREDIVd2 (1 << RCC_CFGR2_PREDIV_SHIFT) /* 0001: HSE input to PLL divided by 2 */
+# define RCC_CFGR2_PREDIVd3 (2 << RCC_CFGR2_PREDIV_SHIFT) /* 0010: HSE input to PLL divided by 3 */
+# define RCC_CFGR2_PREDIVd4 (3 << RCC_CFGR2_PREDIV_SHIFT) /* 0011: HSE input to PLL divided by 4 */
+# define RCC_CFGR2_PREDIVd5 (4 << RCC_CFGR2_PREDIV_SHIFT) /* 0100: HSE input to PLL divided by 5 */
+# define RCC_CFGR2_PREDIVd6 (5 << RCC_CFGR2_PREDIV_SHIFT) /* 0101: HSE input to PLL divided by 6 */
+# define RCC_CFGR2_PREDIVd7 (6 << RCC_CFGR2_PREDIV_SHIFT) /* 0110: HSE input to PLL divided by 7 */
+# define RCC_CFGR2_PREDIVd8 (7 << RCC_CFGR2_PREDIV_SHIFT) /* 0111: HSE input to PLL divided by 8 */
+# define RCC_CFGR2_PREDIVd9 (8 << RCC_CFGR2_PREDIV_SHIFT) /* 1000: HSE input to PLL divided by 9 */
+# define RCC_CFGR2_PREDIVd10 (9 << RCC_CFGR2_PREDIV_SHIFT) /* 1001: HSE input to PLL divided by 10 */
+# define RCC_CFGR2_PREDIVd11 (10 << RCC_CFGR2_PREDIV_SHIFT) /* 1010: HSE input to PLL divided by 11 */
+# define RCC_CFGR2_PREDIVd12 (11 << RCC_CFGR2_PREDIV_SHIFT) /* 1011: HSE input to PLL divided by 12 */
+# define RCC_CFGR2_PREDIVd13 (12 << RCC_CFGR2_PREDIV_SHIFT) /* 1100: HSE input to PLL divided by 13 */
+# define RCC_CFGR2_PREDIVd14 (13 << RCC_CFGR2_PREDIV_SHIFT) /* 1101: HSE input to PLL divided by 14 */
+# define RCC_CFGR2_PREDIVd15 (14 << RCC_CFGR2_PREDIV_SHIFT) /* 1110: HSE input to PLL divided by 15 */
+# define RCC_CFGR2_PREDIVd16 (15 << RCC_CFGR2_PREDIV_SHIFT) /* 1111: HSE input to PLL divided by 16 */
+#define RCC_CFGR2_ADC12PRES_SHIFT (4) /* Bits 4-8: ADC12PRES division factor */
+#define RCC_CFGR2_ADC12PRES_MASK (32 << RCC_CFGR2_ADC12PRES_SHIFT)
+# define RCC_CFGR2_ADC12DISABLED (0 << RCC_CFGR2_ADC12PRES_SHIFT) /* 00000: ADC12 clock disabled */
+# define RCC_CFGR2_ADC12PRESd1 (16 << RCC_CFGR2_ADC12PRES_SHIFT) /* 10000: PLL clock divided by 1 */
+# define RCC_CFGR2_ADC12PRESd2 (17 << RCC_CFGR2_ADC12PRES_SHIFT) /* 10001: PLL clock divided by 2 */
+# define RCC_CFGR2_ADC12PRESd4 (18 << RCC_CFGR2_ADC12PRES_SHIFT) /* 10010: PLL clock divided by 4 */
+# define RCC_CFGR2_ADC12PRESd6 (19 << RCC_CFGR2_ADC12PRES_SHIFT) /* 10011: PLL clock divided by 6 */
+# define RCC_CFGR2_ADC12PRESd8 (20 << RCC_CFGR2_ADC12PRES_SHIFT) /* 10100: PLL clock divided by 8 */
+# define RCC_CFGR2_ADC12PRESd10 (21 << RCC_CFGR2_ADC12PRES_SHIFT) /* 10101: PLL clock divided by 10 */
+# define RCC_CFGR2_ADC12PRESd12 (22 << RCC_CFGR2_ADC12PRES_SHIFT) /* 10110: PLL clock divided by 12 */
+# define RCC_CFGR2_ADC12PRESd16 (23 << RCC_CFGR2_ADC12PRES_SHIFT) /* 10111: PLL clock divided by 16 */
+# define RCC_CFGR2_ADC12PRESd32 (24 << RCC_CFGR2_ADC12PRES_SHIFT) /* 11000: PLL clock divided by 32 */
+# define RCC_CFGR2_ADC12PRESd64 (25 << RCC_CFGR2_ADC12PRES_SHIFT) /* 11001: PLL clock divided by 64 */
+# define RCC_CFGR2_ADC12PRESd128 (26 << RCC_CFGR2_ADC12PRES_SHIFT) /* 11010: PLL clock divided by 128 */
+# define RCC_CFGR2_ADC12PRESd256 (27 << RCC_CFGR2_ADC12PRES_SHIFT) /* 11011: PLL clock divided by 256 */
+
+/* Clock configuration register 3 */
+
+#define RCC_CFGR3_USART1SW_SHIFT (0) /* Bits 0-1: USART1 clock source selection */
+#define RCC_CFGR3_USART1SW_MASK (3 << RCC_CFGR3_USART1SW_SHIFT)
+# define RCC_CFGR3_USART1SW_PCLK (0 << RCC_CFGR3_USART1SW_SHIFT) /* PCLK */
+# define RCC_CFGR3_USART1SW_SYSCLK (1 << RCC_CFGR3_USART1SW_SHIFT) /* System clock (SYSCLK) */
+# define RCC_CFGR3_USART1SW_LSE (2 << RCC_CFGR3_USART1SW_SHIFT) /* LSE clock */
+# define RCC_CFGR3_USART1SW_HSI (0 << RCC_CFGR3_USART1SW_SHIFT) /* HSI clock */
+#define RCC_CFGR3_I2C1SW (1 << 4) /* Bit 4: I2C1 clock source selection */
+#define RCC_CFGR3_TIM1SW (1 << 8) /* Bit 8: TIM1 clock source selection */
+#define RCC_CFGR3_HRTIM1SW (1 << 9) /* Bit 9: HRTIM clock source selection */
+#define RCC_CFGR3_USART2SW_SHIFT (16) /* Bits 16-17: USART2 clock source selection */
+#define RCC_CFGR3_USART2SW_MASK (3 << RCC_CFGR3_USART2SW_SHIFT)
+# define RCC_CFGR3_USART2SW_PCLK (0 << RCC_CFGR3_USART2SW_SHIFT) /* PCLK */
+# define RCC_CFGR3_USART2SW_SYSCLK (1 << RCC_CFGR3_USART2SW_SHIFT) /* System clock (SYSCLK) */
+# define RCC_CFGR3_USART2SW_LSE (2 << RCC_CFGR3_USART2SW_SHIFT) /* LSE clock */
+# define RCC_CFGR3_USART2SW_HSI (0 << RCC_CFGR3_USART2SW_SHIFT) /* HSI clock */
+#define RCC_CFGR3_USART3SW_SHIFT (18) /* Bits 18-19: USART3 clock source selection */
+#define RCC_CFGR3_USART3SW_MASK (3 << RCC_CFGR3_USART3SW_SHIFT)
+# define RCC_CFGR3_USART3SW_PCLK (0 << RCC_CFGR3_USART3SW_SHIFT) /* PCLK */
+# define RCC_CFGR3_USART3SW_SYSCLK (1 << RCC_CFGR3_USART3SW_SHIFT) /* System clock (SYSCLK) */
+# define RCC_CFGR3_USART3SW_LSE (2 << RCC_CFGR3_USART3SW_SHIFT) /* LSE clock */
+# define RCC_CFGR3_USART3SW_HSI (0 << RCC_CFGR3_USART3SW_SHIFT) /* HSI clock */
+
+#endif /* __ARCH_ARM_SRC_STM32_CHIP_STM32F33XXX_RCC_H */
diff --git a/arch/arm/src/stm32/chip/stm32f33xxx_syscfg.h b/arch/arm/src/stm32/chip/stm32f33xxx_syscfg.h
new file mode 100644
index 0000000000000000000000000000000000000000..6e83d0b611123e4cc30f2de1fbe204d9bd112fa8
--- /dev/null
+++ b/arch/arm/src/stm32/chip/stm32f33xxx_syscfg.h
@@ -0,0 +1,182 @@
+/****************************************************************************************************
+ * arch/arm/src/stm32/chip/stm32f33xxx_syscfg.h
+ *
+ * Copyright (C) 2013 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ * Modified for STM32F334 by Mateusz Szafoni
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************************************/
+
+#ifndef __ARCH_ARM_SRC_STM32_CHIP_STM32F33XXX_SYSCFG_H
+#define __ARCH_ARM_SRC_STM32_CHIP_STM32F33XXX_SYSCFG_H
+
+/****************************************************************************************************
+ * Included Files
+ ****************************************************************************************************/
+
+#include
+#include "chip.h"
+
+#ifdef CONFIG_STM32_STM32F33XX
+
+/****************************************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************************************/
+
+/* Register Offsets *********************************************************************************/
+
+#define STM32_SYSCFG_CFGR1_OFFSET 0x0000 /* SYSCFG configuration register 1 */
+#define STM32_SYSCFG_RCR_OFFSET 0x0004 /* SYSCFG CCM SRAM protection register */
+
+#define STM32_SYSCFG_EXTICR_OFFSET(p) (0x0008 + ((p) & 0x000c)) /* Registers are displaced by 4! */
+#define STM32_SYSCFG_EXTICR1_OFFSET 0x0008 /* SYSCFG external interrupt configuration register 1 */
+#define STM32_SYSCFG_EXTICR2_OFFSET 0x000c /* SYSCFG external interrupt configuration register 2 */
+#define STM32_SYSCFG_EXTICR3_OFFSET 0x0010 /* SYSCFG external interrupt configuration register 3 */
+#define STM32_SYSCFG_EXTICR4_OFFSET 0x0014 /* SYSCFG external interrupt configuration register 4 */
+
+#define STM32_SYSCFG_CFGR2_OFFSET 0x0018 /* SYSCFG configuration register 2 */
+#define STM32_SYSCFG_CFGR3_OFFSET 0x0050 /* SYSCFG configuration register 3 */
+
+/* Register Addresses *******************************************************************************/
+
+#define STM32_SYSCFG_CFGR1 (STM32_SYSCFG_BASE+STM32_SYSCFG_CFGR1_OFFSET)
+#define STM32_SYSCFG_RCR (STM32_SYSCFG_BASE+STM32_SYSCFG_RCR_OFFSET)
+
+#define STM32_SYSCFG_EXTICR(p) (STM32_SYSCFG_BASE+STM32_SYSCFG_EXTICR_OFFSET(p))
+#define STM32_SYSCFG_EXTICR1 (STM32_SYSCFG_BASE+STM32_SYSCFG_EXTICR1_OFFSET)
+#define STM32_SYSCFG_EXTICR2 (STM32_SYSCFG_BASE+STM32_SYSCFG_EXTICR2_OFFSET)
+#define STM32_SYSCFG_EXTICR3 (STM32_SYSCFG_BASE+STM32_SYSCFG_EXTICR3_OFFSET)
+#define STM32_SYSCFG_EXTICR4 (STM32_SYSCFG_BASE+STM32_SYSCFG_EXTICR4_OFFSET)
+
+#define STM32_SYSCFG_CFGR2 (STM32_SYSCFG_BASE+STM32_SYSCFG_CFGR2_OFFSET)
+#define STM32_SYSCFG_CFGR3 (STM32_SYSCFG_BASE+STM32_SYSCFG_CFGR3_OFFSET)
+
+/* Register Bitfield Definitions ********************************************************************/
+
+/* SYSCFG memory remap register */
+
+#define SYSCFG_CFGR1_MEMMODE_SHIFT (0) /* Bits 1:0 MEM_MODE: Memory mapping selection */
+#define SYSCFG_CFGR1_MEMMODE_MASK (3 << SYSCFG_CFGR1_MEMMODE_SHIFT)
+# define SYSCFG_CFGR1_MEMMODE_FLASH (0 << SYSCFG_CFGR1_MEMMODE_SHIFT) /* 00: Main Flash at 0x00000000 */
+# define SYSCFG_CFGR1_MEMMODE_SYSTEM (1 << SYSCFG_CFGR1_MEMMODE_SHIFT) /* 01: System Flash at 0x00000000 */
+# define SYSCFG_CFGR1_MEMMODE_SRAM (3 << SYSCFG_CFGR1_MEMMODE_SHIFT) /* 11: Embedded SRAM at 0x00000000 */
+#define SYSCFG_CFGR1_TIM1_ITR3RMP (1 << 6) /* Bit 6: Timer 1 ITR3 selection */
+#define SYSCFG_CFGR1_DAC_TRIGRMP (1 << 7) /* Bit 7: DAC trigger remap (when TSEL = 001) */
+#define SYSCFG_CFGR1_TIM16_DMARMP (1 << 11) /* Bit 11: TIM16 DMA request remapping bit */
+#define SYSCFG_CFGR1_TIM17_DMARMP (1 << 12) /* Bit 12: TIM17 DMA request remapping bit */
+#define SYSCFG_CFGR1_TIM6_DMARMP (1 << 13) /* Bit 13: TIM6 DMA remap, or */
+#define SYSCFG_CFGR1_DAC1_DMARMP (1 << 13) /* Bit 13: DAC channel DMA remap */
+#define SYSCFG_CFGR1_TIM7_DMARMP (1 << 14) /* Bit 14: TIM7 DMA remap */
+#define SYSCFG_CFGR1_DAC2CH2_DMARMP (1 << 14) /* Bit 14: DAC channel2 DMA remap */
+#define SYSCFG_CFGR1_DAC2CH1_DMARMP (1 << 15) /* Bit 14: DAC channel1 DMA remap */
+#define SYSCFG_CFGR1_I2C_PBXFMP_SHIFT (0) /* Bits 16-19: Fast Mode Plus (FM+) driving capability */
+#define SYSCFG_CFGR1_I2C_PBXFMP_MASK (15 << SYSCFG_CFGR1_I2C_PBXFMP_SHIFT)
+#define SYSCFG_CFGR1_I2C1_FMP (1 << 20) /* Bit 20: I2C1 fast mode Plus driving capability */
+#define SYSCFG_CFGR1_I2C2_FMP (1 << 21) /* Bit 21: I2C2 fast mode Plus driving capability */
+#define SYSCFG_CFGR1_ENCMODE_SHIFT (22) /* Bits 22-23: Encoder mode */
+#define SYSCFG_CFGR1_ENCMODE_MASK (3 << SYSCFG_CFGR1_ENCMODE_SHIFT)
+# define SYSCFG_CFGR1_ENCMODE_NONE (0 << SYSCFG_CFGR1_ENCMODE_SHIFT) /* No redirection */
+# define SYSCFG_CFGR1_ENCMODE_TIM2 (1 << SYSCFG_CFGR1_ENCMODE_SHIFT) /* TIM2 I2C1-2 -> TIM15 IC1/2 */
+# define SYSCFG_CFGR1_ENCMODE_TIM3 (2 << SYSCFG_CFGR1_ENCMODE_SHIFT) /* TIM3 I2C1-2 -> TIM15 IC1/2 */
+# define SYSCFG_CFGR1_ENCMODE_TIM4 (3 << SYSCFG_CFGR1_ENCMODE_SHIFT) /* TIM4 I2C1-2 -> TIM15 IC1/2 */
+#define SYSCFG_CFGR1_FPUIE_SHIFT (26) /* Bits 26-31: Floating Point Unit interrupts enable bits */
+#define SYSCFG_CFGR1_FPUIE_MASK (63 << SYSCFG_CFGR1_FPUIE_SHIFT)
+# define SYSCFG_CFGR1_FPUIE_INVALIDOP (1 << SYSCFG_CFGR1_FPUIE_SHIFT) /* Invalid operation interrupt enable */
+# define SYSCFG_CFGR1_FPUIE_DIVZERO (2 << SYSCFG_CFGR1_FPUIE_SHIFT) /* Divide-by-zero interrupt enable */
+# define SYSCFG_CFGR1_FPUIE_UNDERFLOW (4 << SYSCFG_CFGR1_FPUIE_SHIFT) /* Underflow interrupt enable */
+# define SYSCFG_CFGR1_FPUIE_OVERFLOW (8 << SYSCFG_CFGR1_FPUIE_SHIFT) /* Overflow interrupt enable */
+# define SYSCFG_CFGR1_FPUIE_DENORMAL (16 << SYSCFG_CFGR1_FPUIE_SHIFT) /* Input denormal interrupt enable */
+# define SYSCFG_CFGR1_FPUIE_INEXACT (32 << SYSCFG_CFGR1_FPUIE_SHIFT) /* Inexact interrupt enable */
+
+/* SYSCFG CCM SRAM protection register */
+
+#define SYSCFG_RCR(page) (1 << (page)) /* Bit n: Write protection page n */
+
+/* SYSCFG external interrupt configuration register 1-4 */
+
+#define SYSCFG_EXTICR_PORTA (0) /* 0000: PA[x] pin */
+#define SYSCFG_EXTICR_PORTB (1) /* 0001: PB[x] pin */
+#define SYSCFG_EXTICR_PORTC (2) /* 0010: PC[x] pin */
+#define SYSCFG_EXTICR_PORTD (3) /* 0011: PD[x] pin */
+#define SYSCFG_EXTICR_PORTE (4) /* 0100: PE[x] pin */
+
+#define SYSCFG_EXTICR_PORT_MASK (15)
+#define SYSCFG_EXTICR_EXTI_SHIFT(g) (((g) & 3) << 2)
+#define SYSCFG_EXTICR_EXTI_MASK(g) (SYSCFG_EXTICR_PORT_MASK << (SYSCFG_EXTICR_EXTI_SHIFT(g)))
+
+#define SYSCFG_EXTICR1_EXTI0_SHIFT (0) /* Bits 0-3: EXTI 0 coinfiguration */
+#define SYSCFG_EXTICR1_EXTI0_MASK (SYSCFG_EXTICR_PORT_MASK << SYSCFG_EXTICR1_EXTI0_SHIFT)
+#define SYSCFG_EXTICR1_EXTI1_SHIFT (4) /* Bits 4-7: EXTI 1 coinfiguration */
+#define SYSCFG_EXTICR1_EXTI1_MASK (SYSCFG_EXTICR_PORT_MASK << SYSCFG_EXTICR1_EXTI1_SHIFT)
+#define SYSCFG_EXTICR1_EXTI2_SHIFT (8) /* Bits 8-11: EXTI 2 coinfiguration */
+#define SYSCFG_EXTICR1_EXTI2_MASK (SYSCFG_EXTICR_PORT_MASK << SYSCFG_EXTICR1_EXTI2_SHIFT)
+#define SYSCFG_EXTICR1_EXTI3_SHIFT (12) /* Bits 12-15: EXTI 3 coinfiguration */
+#define SYSCFG_EXTICR1_EXTI3_MASK (SYSCFG_EXTICR_PORT_MASK << SYSCFG_EXTICR1_EXTI3_SHIFT)
+
+#define SYSCFG_EXTICR2_EXTI4_SHIFT (0) /* Bits 0-3: EXTI 4 coinfiguration */
+#define SYSCFG_EXTICR2_EXTI4_MASK (SYSCFG_EXTICR_PORT_MASK << SYSCFG_EXTICR2_EXTI4_SHIFT)
+#define SYSCFG_EXTICR2_EXTI5_SHIFT (4) /* Bits 4-7: EXTI 5 coinfiguration */
+#define SYSCFG_EXTICR2_EXTI5_MASK (SYSCFG_EXTICR_PORT_MASK << SYSCFG_EXTICR2_EXTI5_SHIFT)
+#define SYSCFG_EXTICR2_EXTI6_SHIFT (8) /* Bits 8-11: EXTI 6 coinfiguration */
+#define SYSCFG_EXTICR2_EXTI6_MASK (SYSCFG_EXTICR_PORT_MASK << SYSCFG_EXTICR2_EXTI6_SHIFT)
+#define SYSCFG_EXTICR2_EXTI7_SHIFT (12) /* Bits 12-15: EXTI 7 coinfiguration */
+#define SYSCFG_EXTICR2_EXTI7_MASK (SYSCFG_EXTICR_PORT_MASK << SYSCFG_EXTICR2_EXTI7_SHIFT)
+
+#define SYSCFG_EXTICR3_EXTI8_SHIFT (0) /* Bits 0-3: EXTI 8 coinfiguration */
+#define SYSCFG_EXTICR3_EXTI8_MASK (SYSCFG_EXTICR_PORT_MASK << SYSCFG_EXTICR3_EXTI8_SHIFT)
+#define SYSCFG_EXTICR3_EXTI9_SHIFT (4) /* Bits 4-7: EXTI 9 coinfiguration */
+#define SYSCFG_EXTICR3_EXTI9_MASK (SYSCFG_EXTICR_PORT_MASK << SYSCFG_EXTICR3_EXTI9_SHIFT)
+#define SYSCFG_EXTICR3_EXTI10_SHIFT (8) /* Bits 8-11: EXTI 10 coinfiguration */
+#define SYSCFG_EXTICR3_EXTI10_MASK (SYSCFG_EXTICR_PORT_MASK << SYSCFG_EXTICR3_EXTI10_SHIFT)
+#define SYSCFG_EXTICR3_EXTI11_SHIFT (12) /* Bits 12-15: EXTI 11 coinfiguration */
+#define SYSCFG_EXTICR3_EXTI11_MASK (SYSCFG_EXTICR_PORT_MASK << SYSCFG_EXTICR3_EXTI11_SHIFT)
+
+#define SYSCFG_EXTICR4_EXTI12_SHIFT (0) /* Bits 0-3: EXTI 12 coinfiguration */
+#define SYSCFG_EXTICR4_EXTI12_MASK (SYSCFG_EXTICR_PORT_MASK << SYSCFG_EXTICR4_EXTI12_SHIFT)
+#define SYSCFG_EXTICR4_EXTI13_SHIFT (4) /* Bits 4-7: EXTI 13 coinfiguration */
+#define SYSCFG_EXTICR4_EXTI13_MASK (SYSCFG_EXTICR_PORT_MASK << SYSCFG_EXTICR4_EXTI13_SHIFT)
+#define SYSCFG_EXTICR4_EXTI14_SHIFT (8) /* Bits 8-11: EXTI 14 coinfiguration */
+#define SYSCFG_EXTICR4_EXTI14_MASK (SYSCFG_EXTICR_PORT_MASK << SYSCFG_EXTICR4_EXTI14_SHIFT)
+#define SYSCFG_EXTICR4_EXTI15_SHIFT (12) /* Bits 12-15: EXTI 15 coinfiguration */
+#define SYSCFG_EXTICR4_EXTI15_MASK (SYSCFG_EXTICR_PORT_MASK << SYSCFG_EXTICR4_EXTI15_SHIFT)
+
+/* SYSCFG configuration register 2 */
+
+#define SYSCFG_CFGR2_LOCKUPLOCK (1 << 0) /* Bit 0: Cortex-M4 Hardfault output bit enable */
+#define SYSCFG_CFGR2_SRAM_PARITYLOCK (1 << 1) /* Bit 1: RAM parity lock */
+#define SYSCFG_CFGR2_PVDLOCK (1 << 2) /* Bit 2: PVD lock enable */
+#define SYSCFG_CFGR2_BYPADDPAR (1 << 4) /* Bit 4: Bypass address bit 29 in parity calculation */
+#define SYSCFG_CFGR2_SRAM_PEF (1 << 8) /* Bit 8: SRAM parity error */
+
+/* SYSCFG configuration register 3 */
+/* TODO */
+
+#endif /* CONFIG_STM32_STM32F33XX */
+#endif /* __ARCH_ARM_SRC_STM32_CHIP_STM32F33XXX_SYSCFG_H */
diff --git a/arch/arm/src/stm32/chip/stm32f33xxx_vectors.h b/arch/arm/src/stm32/chip/stm32f33xxx_vectors.h
new file mode 100644
index 0000000000000000000000000000000000000000..cd1077a5e21aa2dc84c07c61686f9e0db036acaa
--- /dev/null
+++ b/arch/arm/src/stm32/chip/stm32f33xxx_vectors.h
@@ -0,0 +1,151 @@
+/************************************************************************************
+ * arch/arm/src/stm32/chip/stm32f33xxx_vectors.h
+ *
+ * Copyright (C) 2017 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ * Modified for STM32F334 by Mateusz Szafoni
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ************************************************************************************/
+
+/************************************************************************************
+ * Pre-processor definitions
+ ************************************************************************************/
+/* This file is included by stm32_vectors.S. It provides the macro VECTOR that
+ * supplies each STM32F33xxx vector in terms of a (lower-case) ISR label and an
+ * (upper-case) IRQ number as defined in arch/arm/include/stm32/stm32f33xxx_irq.h.
+ * stm32_vectors.S will defined the VECTOR in different ways in order to generate
+ * the interrupt vectors and handlers in their final form.
+ */
+
+/* If the common ARMv7-M vector handling is used, then all it needs is the following
+ * definition that provides the number of supported vectors.
+ */
+
+#ifdef CONFIG_ARMV7M_CMNVECTOR
+
+/* Reserve 82 interrupt table entries for I/O interrupts. */
+
+# define ARMV7M_PERIPHERAL_INTERRUPTS 82
+
+#else
+
+VECTOR(stm32_wwdg, STM32_IRQ_WWDG) /* 0: Window Watchdog interrupt */
+VECTOR(stm32_pvd, STM32_IRQ_PVD) /* 1: PVD through EXTI Line detection interrupt */
+VECTOR(stm32_tamper, STM32_IRQ_TAMPER) /* 2: Tamper or Time stamp interrupt */
+VECTOR(stm32_rtc_wkup, STM32_IRQ_RTC_WKUP) /* 3: RTC global interrupt */
+VECTOR(stm32_flash, STM32_IRQ_FLASH) /* 4: Flash global interrupt */
+VECTOR(stm32_rcc, STM32_IRQ_RCC) /* 5: RCC global interrupt */
+VECTOR(stm32_exti0, STM32_IRQ_EXTI0) /* 6: EXTI Line 0 interrupt */
+VECTOR(stm32_exti1, STM32_IRQ_EXTI1) /* 7: EXTI Line 1 interrupt */
+VECTOR(stm32_exti2, STM32_IRQ_EXTI2) /* 8: EXTI Line 2 or TSC interrupt */
+VECTOR(stm32_exti3, STM32_IRQ_EXTI3) /* 9: EXTI Line 3 interrupt */
+
+VECTOR(stm32_exti4, STM32_IRQ_EXTI4) /* 10: EXTI Line 4 interrupt */
+VECTOR(stm32_dma1ch1, STM32_IRQ_DMA1CH1) /* 11: DMA1 channel 1 global interrupt */
+VECTOR(stm32_dma1ch2, STM32_IRQ_DMA1CH2) /* 12: DMA1 channel 2 global interrupt */
+VECTOR(stm32_dma1ch3, STM32_IRQ_DMA1CH3) /* 13: DMA1 channel 3 global interrupt */
+VECTOR(stm32_dma1ch4, STM32_IRQ_DMA1CH4) /* 14: DMA1 channel 4 global interrupt */
+VECTOR(stm32_dma1ch5, STM32_IRQ_DMA1CH5) /* 15: DMA1 channel 5 global interrupt */
+VECTOR(stm32_dma1ch6, STM32_IRQ_DMA1CH6) /* 16: DMA1 channel 6 global interrupt */
+VECTOR(stm32_dma1ch7, STM32_IRQ_DMA1CH7) /* 17: DMA1 channel 7 global interrupt */
+VECTOR(stm32_adc12, STM32_IRQ_ADC12) /* 18: ADC1/ADC2 global interrupt */
+VECTOR(stm32_can1tx, STM32_IRQ_CAN1TX) /* 19: USB High Priority or CAN1 TX interrupts */
+
+VECTOR(stm32_can1rx0, STM32_IRQ_CAN1RX0) /* 20: USB Low Priority or CAN1 RX0 interrupts*/
+VECTOR(stm32_can1rx1, STM32_IRQ_CAN1RX1) /* 21: CAN1 RX1 interrupt */
+VECTOR(stm32_can1sce, STM32_IRQ_CAN1SCE) /* 22: CAN1 SCE interrupt */
+VECTOR(stm32_exti95, STM32_IRQ_EXTI95) /* 23: EXTI Line[9:5] interrupts */
+VECTOR(stm32_tim1brk, STM32_IRQ_TIM1BRK) /* 24: TIM1 Break or TIM15 global interrupt */
+VECTOR(stm32_tim1up, STM32_IRQ_TIM1UP) /* 25: TIM1 Update or TIM16 global interrupt */
+VECTOR(stm32_tim1trgcom, STM32_IRQ_TIM1TRGCOM) /* 26: TIM1 Trigger or TIM17 global interrupt */
+VECTOR(stm32_tim1cc, STM32_IRQ_TIM1CC) /* 27: TIM1 Capture Compare interrupt */
+VECTOR(stm32_tim2, STM32_IRQ_TIM2) /* 28: TIM2 global interrupt */
+VECTOR(stm32_tim3, STM32_IRQ_TIM3) /* 29: TIM3 global interrupt */
+
+UNUSED(STM32_IRQ_RESERVED30) /* 30: Reserved */
+VECTOR(stm32_i2c1ev, STM32_IRQ_I2C1EV) /* 31: I2C1 event or EXTI Line23 interrupt */
+VECTOR(stm32_i2c1er, STM32_IRQ_I2C1ER) /* 32: I2C1 error interrupt */
+UNUSED(STM32_IRQ_RESERVED33) /* 33: Reserved */
+UNUSED(STM32_IRQ_RESERVED34) /* 34: Reserved */
+VECTOR(stm32_spi1, STM32_IRQ_SPI1) /* 35: SPI1 global interrupt */
+UNUSED(STM32_IRQ_RESERVED36) /* 36: Reserved */
+VECTOR(stm32_usart1, STM32_IRQ_USART1) /* 37: USART1 global or EXTI Line 25 interrupt */
+VECTOR(stm32_usart2, STM32_IRQ_USART2) /* 38: USART2 global or EXTI Line 26 interrupt */
+VECTOR(stm32_usart3, STM32_IRQ_USART3) /* 39: USART3 global or EXTI Line 28 interrupt */
+
+VECTOR(stm32_exti1510, STM32_IRQ_EXTI1510) /* 40: EXTI Line[15:10] interrupts */
+VECTOR(stm32_rtcalrm, STM32_IRQ_RTCALRM) /* 41: RTC alarm through EXTI line interrupt */
+UNUSED(STM32_IRQ_RESERVED42) /* 42: Reserved */
+UNUSED(STM32_IRQ_RESERVED43) /* 43: Reserved */
+UNUSED(STM32_IRQ_RESERVED44) /* 44: Reserved */
+UNUSED(STM32_IRQ_RESERVED45) /* 45: Reserved */
+UNUSED(STM32_IRQ_RESERVED46) /* 46: Reserved */
+UNUSED(STM32_IRQ_RESERVED47) /* 47: Reserved*/
+UNUSED(STM32_IRQ_RESERVED48) /* 48: Reserved */
+UNUSED(STM32_IRQ_RESERVED49) /* 49: Reserved */
+
+UNUSED(STM32_IRQ_RESERVED50) /* 50: Reserved */
+UNUSED(STM32_IRQ_RESERVED51) /* 51: Reserved */
+UNUSED(STM32_IRQ_RESERVED51) /* 52: Reserved */
+UNUSED(STM32_IRQ_RESERVED52) /* 53: Reserved */
+VECTOR(stm32_dac1, STM32_IRQ_DAC1) /* 54: TIM6 global or DAC1 underrun interrupts */
+VECTOR(stm32_dac2, STM32_IRQ_DAC2) /* 55: TIM7 global or DAC2 underrun interrupt */
+UNUSED(STM32_IRQ_RESERVED56) /* 56: Reserved */
+UNUSED(STM32_IRQ_RESERVED57) /* 57: Reserved */
+UNUSED(STM32_IRQ_RESERVED58) /* 58: Reserved */
+UNUSED(STM32_IRQ_RESERVED59) /* 59: Reserved */
+
+UNUSED(STM32_IRQ_RESERVED60) /* 60: Reserved */
+UNUSED(STM32_IRQ_RESERVED61) /* 61: Reserved */
+UNUSED(STM32_IRQ_RESERVED62) /* 62: Reserved */
+UNUSED(STM32_IRQ_RESERVED63) /* 63: Reserved */
+VECTOR(stm32_comp2, STM32_IRQ_COMP2) /* 64: COMP2 or EXTI Lines 21-2 and 29 interrupts */
+VECTOR(stm32_comp46, STM32_IRQ_COMP46) /* 65: COMP4/COMP6 or EXTI Lines 30-2 interrupts */
+UNUSED(STM32_IRQ_RESERVED66) /* 66: Reserved */
+VECTOR(stm32_hrtim_tm, STM32_IRQ_HRTIMTM) /* 67: HRTIM master timer interrutp */
+VECTOR(stm32_hrtim_ta, STM32_IRQ_HRTIMTA) /* 68: HRTIM timer A interrutp */
+VECTOR(stm32_hrtim_tb, STM32_IRQ_HRTIMTB) /* 69: HRTIM timer B interrutp */
+
+VECTOR(stm32_hrtim_tc, STM32_IRQ_HRTIMTC) /* 70: HRTIM timer C interrutp */
+VECTOR(stm32_hrtim_td, STM32_IRQ_HRTIMTD) /* 71: HRTIM timer D interrutp */
+VECTOR(stm32_hrtim_te, STM32_IRQ_HRTIMTE) /* 72: HRTIM timer E interrutp */
+VECTOR(stm32_hrtim_flt, STM32_IRQ_HRTIMFLT) /* 73: HRTIM fault interrutp */
+UNUSED(STM32_IRQ_RESERVED73) /* 74: Reserved */
+UNUSED(STM32_IRQ_RESERVED74) /* 75: Reserved */
+UNUSED(STM32_IRQ_RESERVED75) /* 76: Reserved */
+UNUSED(STM32_IRQ_RESERVED76) /* 77: Reserved */
+UNUSED(STM32_IRQ_RESERVED77) /* 78: Reserved */
+UNUSED(STM32_IRQ_RESERVED78) /* 79: Reserved */
+
+UNUSED(STM32_IRQ_RESERVED79) /* 80: Reserved */
+UNUSED(STM32_IRQ_RESERVED80) /* 81: Reserved */
+VECTOR(stm32_fpu, STM32_IRQ_FPU) /* 82: FPU global interrupt */
+
+#endif /* CONFIG_ARMV7M_CMNVECTOR */
diff --git a/arch/arm/src/stm32/gnu/stm32_vectors.S b/arch/arm/src/stm32/gnu/stm32_vectors.S
index a1a39dff2f9479b633dbb09875fb173cfc12864b..31f62c8d112d2b46c96004609fdabff644755f81 100644
--- a/arch/arm/src/stm32/gnu/stm32_vectors.S
+++ b/arch/arm/src/stm32/gnu/stm32_vectors.S
@@ -177,6 +177,8 @@ _vectors:
# include "chip/stm32f20xxx_vectors.h"
#elif defined(CONFIG_STM32_STM32F30XX)
# include "chip/stm32f30xxx_vectors.h"
+#elif defined(CONFIG_STM32_STM32F33XX)
+# include "chip/stm32f33xxx_vectors.h"
#elif defined(CONFIG_STM32_STM32F37XX)
# include "chip/stm32f37xxx_vectors.h"
#elif defined(CONFIG_STM32_STM32F40XX)
@@ -222,6 +224,8 @@ handlers:
# include "chip/stm32f20xxx_vectors.h"
#elif defined(CONFIG_STM32_STM32F30XX)
# include "chip/stm32f30xxx_vectors.h"
+#elif defined(CONFIG_STM32_STM32F33XX)
+# include "chip/stm32f33xxx_vectors.h"
#elif defined(CONFIG_STM32_STM32F37XX)
# include "chip/stm32f37xxx_vectors.h"
#elif defined(CONFIG_STM32_STM32F40XX)
diff --git a/arch/arm/src/stm32/iar/stm32_vectors.S b/arch/arm/src/stm32/iar/stm32_vectors.S
index cb9069dbc194998d908f6341f0cf10ef047cd562..cf83e7b8bff68dc69ad11110b7ad28ac23725652 100644
--- a/arch/arm/src/stm32/iar/stm32_vectors.S
+++ b/arch/arm/src/stm32/iar/stm32_vectors.S
@@ -461,6 +461,8 @@ __vector_table:
DCD stm32_hash /* Vector 16+80: Hash and Rng global interrupt */
#elif defined(CONFIG_STM32_STM32F30XX)
# include "chip/stm32f30xxx_vectors.h"
+#elif defined(CONFIG_STM32_STM32F33XX)
+# include "chip/stm32f33xxx_vectors.h"
#elif defined(CONFIG_STM32_STM32F37XX)
# include "chip/stm32f37xxx_vectors.h"
#elif defined(CONFIG_STM32_STM32F427) || defined(CONFIG_STM32_STM32F429)
@@ -778,6 +780,8 @@ handlers:
#elif defined(CONFIG_STM32_STM32F30XX)
# include "chip/stm32f30xxx_vectors.h"
+#elif defined(CONFIG_STM32_STM32F33XX)
+# include "chip/stm32f33xxx_vectors.h"
#elif defined(CONFIG_STM32_STM32F37XX)
# include "chip/stm32f37xxx_vectors.h"
#elif defined(CONFIG_STM32_STM32F427) || defined(CONFIG_STM32_STM32F429)
diff --git a/arch/arm/src/stm32/stm32_1wire.c b/arch/arm/src/stm32/stm32_1wire.c
index 952f2777ec7aacc6bae377a6a8cba3d4e66b5801..b43769577a8e12f30358ae25946343e6d2f8b2bd 100644
--- a/arch/arm/src/stm32/stm32_1wire.c
+++ b/arch/arm/src/stm32/stm32_1wire.c
@@ -117,7 +117,6 @@ struct stm32_1wire_config_s
const uint32_t apbclock; /* PCLK 1 or 2 frequency */
const uint32_t data_pin; /* GPIO configuration for DATA */
const uint8_t irq; /* IRQ associated with this USART */
- int (*const vector)(int irq, void *context); /* Interrupt handler */
};
/* 1-Wire device Private Data */
@@ -161,33 +160,7 @@ static inline void stm32_1wire_sem_wait(FAR struct stm32_1wire_priv_s *priv);
static inline void stm32_1wire_sem_post(FAR struct stm32_1wire_priv_s *priv);
static int stm32_1wire_process(struct stm32_1wire_priv_s *priv,
FAR const struct stm32_1wire_msg_s *msgs, int count);
-static int stm32_1wire_isr(struct stm32_1wire_priv_s *priv);
-
-#ifdef CONFIG_STM32_USART1_1WIREDRIVER
-static int stm32_interrupt_1wire1(int irq, void *context);
-#endif
-#ifdef CONFIG_STM32_USART2_1WIREDRIVER
-static int stm32_interrupt_1wire2(int irq, void *context);
-#endif
-#ifdef CONFIG_STM32_USART3_1WIREDRIVER
-static int stm32_interrupt_1wire3(int irq, void *context);
-#endif
-#ifdef CONFIG_STM32_UART4_1WIREDRIVER
-static int stm32_interrupt_1wire4(int irq, void *context);
-#endif
-#ifdef CONFIG_STM32_UART5_1WIREDRIVER
-static int stm32_interrupt_1wire5(int irq, void *context);
-#endif
-#ifdef CONFIG_STM32_USART6_1WIREDRIVER
-static int stm32_interrupt_1wire6(int irq, void *context);
-#endif
-#ifdef CONFIG_STM32_UART7_1WIREDRIVER
-static int stm32_interrupt_1wire7(int irq, void *context);
-#endif
-#ifdef CONFIG_STM32_UART8_1WIREDRIVER
-static int stm32_interrupt_1wire8(int irq, void *context);
-#endif
-
+static int stm32_1wire_isr(int irq, void *context, void *arg);
static int stm32_1wire_reset(FAR struct onewire_dev_s *dev);
static int stm32_1wire_write(FAR struct onewire_dev_s *dev,
const uint8_t *buffer, int buflen);
@@ -211,7 +184,6 @@ static const struct stm32_1wire_config_s stm32_1wire1_config =
.apbclock = STM32_PCLK2_FREQUENCY,
.data_pin = PIN_OPENDRAIN(GPIO_USART1_TX),
.irq = STM32_IRQ_USART1,
- .vector = stm32_interrupt_1wire1,
};
static struct stm32_1wire_priv_s stm32_1wire1_priv =
@@ -231,7 +203,6 @@ static const struct stm32_1wire_config_s stm32_1wire2_config =
.apbclock = STM32_PCLK1_FREQUENCY,
.data_pin = PIN_OPENDRAIN(GPIO_USART2_TX),
.irq = STM32_IRQ_USART2,
- .vector = stm32_interrupt_1wire2,
};
static struct stm32_1wire_priv_s stm32_1wire2_priv =
@@ -251,7 +222,6 @@ static const struct stm32_1wire_config_s stm32_1wire3_config =
.apbclock = STM32_PCLK1_FREQUENCY,
.data_pin = PIN_OPENDRAIN(GPIO_USART3_TX),
.irq = STM32_IRQ_USART3,
- .vector = stm32_interrupt_1wire3,
};
static struct stm32_1wire_priv_s stm32_1wire3_priv =
@@ -271,7 +241,6 @@ static const struct stm32_1wire_config_s stm32_1wire4_config =
.apbclock = STM32_PCLK1_FREQUENCY,
.data_pin = PIN_OPENDRAIN(GPIO_UART4_TX),
.irq = STM32_IRQ_UART4,
- .vector = stm32_interrupt_1wire4,
};
static struct stm32_1wire_priv_s stm32_1wire4_priv =
@@ -291,7 +260,6 @@ static const struct stm32_1wire_config_s stm32_1wire5_config =
.apbclock = STM32_PCLK1_FREQUENCY,
.data_pin = PIN_OPENDRAIN(GPIO_UART5_TX),
.irq = STM32_IRQ_UART5,
- .vector = stm32_interrupt_1wire5,
};
static struct stm32_1wire_priv_s stm32_1wire5_priv =
@@ -311,7 +279,6 @@ static const struct stm32_1wire_config_s stm32_1wire6_config =
.apbclock = STM32_PCLK2_FREQUENCY,
.data_pin = PIN_OPENDRAIN(GPIO_USART6_TX),
.irq = STM32_IRQ_USART6,
- .vector = stm32_interrupt_1wire6,
};
static struct stm32_1wire_priv_s stm32_1wire6_priv =
@@ -331,7 +298,6 @@ static const struct stm32_1wire_config_s stm32_1wire7_config =
.apbclock = STM32_PCLK1_FREQUENCY,
.data_pin = PIN_OPENDRAIN(GPIO_UART7_TX),
.irq = STM32_IRQ_UART7,
- .vector = stm32_interrupt_1wire7,
};
static struct stm32_1wire_priv_s stm32_1wire7_priv =
@@ -351,7 +317,6 @@ static const struct stm32_1wire_config_s stm32_1wire8_config =
.apbclock = STM32_PCLK1_FREQUENCY,
.data_pin = PIN_OPENDRAIN(GPIO_UART8_TX),
.irq = STM32_IRQ_UART8,
- .vector = stm32_interrupt_1wire8,
};
static struct stm32_1wire_priv_s stm32_1wire8_priv =
@@ -679,7 +644,7 @@ static int stm32_1wire_init(FAR struct stm32_1wire_priv_s *priv)
stm32_configgpio(config->data_pin);
- ret = irq_attach(config->irq, config->vector);
+ ret = irq_attach(config->irq, stm32_1wire_isr, priv);
if (ret == OK)
{
up_enable_irq(config->irq);
@@ -917,9 +882,13 @@ static int stm32_1wire_process(struct stm32_1wire_priv_s *priv,
* Common Interrupt Service Routine
****************************************************************************/
-static int stm32_1wire_isr(struct stm32_1wire_priv_s *priv)
+static int stm32_1wire_isr(int irq, void *context, void *arg)
{
- uint32_t sr, dr;
+ struct stm32_1wire_priv_s *priv = (struct stm32_1wire_priv_s *)arg;
+ uint32_t sr;
+ uint32_t dr;
+
+ DEBUGASSERT(priv != NULL);
/* Get the masked USART status word. */
@@ -1041,55 +1010,6 @@ static int stm32_1wire_isr(struct stm32_1wire_priv_s *priv)
return OK;
}
-#ifdef CONFIG_STM32_USART1_1WIREDRIVER
-static int stm32_interrupt_1wire1(int irq, void *context)
-{
- return stm32_1wire_isr(&stm32_1wire1_priv);
-}
-#endif
-#ifdef CONFIG_STM32_USART2_1WIREDRIVER
-static int stm32_interrupt_1wire2(int irq, void *context)
-{
- return stm32_1wire_isr(&stm32_1wire2_priv);
-}
-#endif
-#ifdef CONFIG_STM32_USART3_1WIREDRIVER
-static int stm32_interrupt_1wire3(int irq, void *context)
-{
- return stm32_1wire_isr(&stm32_1wire3_priv);
-}
-#endif
-#ifdef CONFIG_STM32_UART4_1WIREDRIVER
-static int stm32_interrupt_1wire4(int irq, void *context)
-{
- return stm32_1wire_isr(&stm32_1wire4_priv);
-}
-#endif
-#ifdef CONFIG_STM32_UART5_1WIREDRIVER
-static int stm32_interrupt_1wire5(int irq, void *context)
-{
- return stm32_1wire_isr(&stm32_1wire5_priv);
-}
-#endif
-#ifdef CONFIG_STM32_USART6_1WIREDRIVER
-static int stm32_interrupt_1wire6(int irq, void *context)
-{
- return stm32_1wire_isr(&stm32_1wire6_priv);
-}
-#endif
-#ifdef CONFIG_STM32_UART7_1WIREDRIVER
-static int stm32_interrupt_1wire7(int irq, void *context)
-{
- return stm32_1wire_isr(&stm32_1wire7_priv);
-}
-#endif
-#ifdef CONFIG_STM32_UART8_1WIREDRIVER
-static int stm32_interrupt_1wire8(int irq, void *context)
-{
- return stm32_1wire_isr(&stm32_1wire8_priv);
-}
-#endif
-
/****************************************************************************
* Name: stm32_1wire_reset
*
diff --git a/arch/arm/src/stm32/stm32_adc.c b/arch/arm/src/stm32/stm32_adc.c
index 5ede920b24ba07f4b88bab9d63d670dd046af196..ef91b77b40f3af0047ad417cc950769f260cd574 100644
--- a/arch/arm/src/stm32/stm32_adc.c
+++ b/arch/arm/src/stm32/stm32_adc.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/stm32/stm32_adc.c
*
- * Copyright (C) 2011, 2013, 2015-2016 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2011, 2013, 2015-2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2015 Omni Hoverboards Inc. All rights reserved.
* Authors: Gregory Nutt
* Diego Sanchez
@@ -58,6 +58,7 @@
#include
#include
#include
+#include
#include "up_internal.h"
#include "up_arch.h"
@@ -363,20 +364,20 @@ static void adc_rccreset(FAR struct stm32_dev_s *priv, bool reset);
static int adc_interrupt(FAR struct adc_dev_s *dev);
#if defined(STM32_IRQ_ADC1) && defined(CONFIG_STM32_ADC1)
-static int adc1_interrupt(int irq, FAR void *context);
+static int adc1_interrupt(int irq, FAR void *context, FAR void *arg);
#endif
#if defined(STM32_IRQ_ADC12) && (defined(CONFIG_STM32_ADC1) || \
defined(CONFIG_STM32_ADC2))
-static int adc12_interrupt(int irq, FAR void *context);
+static int adc12_interrupt(int irq, FAR void *context, FAR void *arg);
#endif
#if (defined(STM32_IRQ_ADC3) && defined(CONFIG_STM32_ADC3))
-static int adc3_interrupt(int irq, FAR void *context);
+static int adc3_interrupt(int irq, FAR void *context, FAR void *arg);
#endif
#if defined(STM32_IRQ_ADC4) && defined(CONFIG_STM32_ADC4)
-static int adc4_interrupt(int irq, FAR void *context);
+static int adc4_interrupt(int irq, FAR void *context, FAR void *arg);
#endif
#if defined(STM32_IRQ_ADC)
-static int adc123_interrupt(int irq, FAR void *context);
+static int adc123_interrupt(int irq, FAR void *context, FAR void *arg);
#endif
/* ADC Driver Methods */
@@ -2136,7 +2137,7 @@ static int adc_setup(FAR struct adc_dev_s *dev)
/* Attach the ADC interrupt */
- ret = irq_attach(priv->irq, priv->isr);
+ ret = irq_attach(priv->irq, priv->isr, NULL);
if (ret < 0)
{
ainfo("irq_attach failed: %d\n", ret);
@@ -2831,7 +2832,7 @@ static int adc_interrupt(FAR struct adc_dev_s *dev)
****************************************************************************/
#if defined(STM32_IRQ_ADC1)
-static int adc1_interrupt(int irq, FAR void *context)
+static int adc1_interrupt(int irq, FAR void *context, FAR void *arg)
{
adc_interrupt(&g_adcdev1);
@@ -2853,7 +2854,7 @@ static int adc1_interrupt(int irq, FAR void *context)
#if defined(STM32_IRQ_ADC12) && \
(defined(CONFIG_STM32_ADC1) || defined(CONFIG_STM32_ADC2))
-static int adc12_interrupt(int irq, FAR void *context)
+static int adc12_interrupt(int irq, FAR void *context, FAR void *arg)
{
#ifdef CONFIG_STM32_ADC1
adc_interrupt(&g_adcdev1);
@@ -2880,7 +2881,7 @@ static int adc12_interrupt(int irq, FAR void *context)
****************************************************************************/
#if defined(STM32_IRQ_ADC3) && defined(CONFIG_STM32_ADC3)
-static int adc3_interrupt(int irq, FAR void *context)
+static int adc3_interrupt(int irq, FAR void *context, FAR void *arg)
{
adc_interrupt(&g_adcdev3);
@@ -2901,7 +2902,7 @@ static int adc3_interrupt(int irq, FAR void *context)
****************************************************************************/
#if defined(STM32_IRQ_ADC4) && defined(CONFIG_STM32_ADC4)
-static int adc4_interrupt(int irq, FAR void *context)
+static int adc4_interrupt(int irq, FAR void *context, FAR void *arg)
{
adc_interrupt(&g_adcdev4);
return OK;
@@ -2921,7 +2922,7 @@ static int adc4_interrupt(int irq, FAR void *context)
****************************************************************************/
#if defined(STM32_IRQ_ADC)
-static int adc123_interrupt(int irq, FAR void *context)
+static int adc123_interrupt(int irq, FAR void *context, FAR void *arg)
{
#ifdef CONFIG_STM32_ADC1
adc_interrupt(&g_adcdev1);
diff --git a/arch/arm/src/stm32/stm32_adc.h b/arch/arm/src/stm32/stm32_adc.h
index b2f4ee39189c4be8949f35dbec9c6df4b647bb82..03ffaecbc01f2745ab22bc1f522cc9f189b0daac 100644
--- a/arch/arm/src/stm32/stm32_adc.h
+++ b/arch/arm/src/stm32/stm32_adc.h
@@ -48,6 +48,8 @@
#if defined(CONFIG_STM32_STM32F30XX)
# include "chip/stm32f30xxx_adc.h"
+#elif defined(CONFIG_STM32_STM32F33XX)
+# include "chip/stm32f33xxx_adc.h"
#elif defined(CONFIG_STM32_STM32F37XX)
# include "chip/stm32f37xxx_adc.h"
#else
diff --git a/arch/arm/src/stm32/stm32_allocateheap.c b/arch/arm/src/stm32/stm32_allocateheap.c
index 92a3fcdd81005542be945bab459b4053f57a4990..3e6a73f2cd7ff4b9633da762021fd351fe172555 100644
--- a/arch/arm/src/stm32/stm32_allocateheap.c
+++ b/arch/arm/src/stm32/stm32_allocateheap.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * arch/arm/src/stm32/up_allocateheap.c
+ * arch/arm/src/stm32/stm32_allocateheap.c
*
* Copyright (C) 2011-2013, 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
@@ -222,6 +222,76 @@
# endif
# endif
+/* All members of the STM32F33xxx families have 16 Kbi ram and 4 KB CCM SRAM.
+ * No external RAM is supported (the F3 family has no FSMC).
+ *
+ * As a complication, CCM SRAM cannot be used for DMA. So, if STM32 DMA is
+ * enabled, CCM SRAM should probably be excluded from the heap.
+ */
+#elif defined(CONFIG_STM32_STM32F33XX)
+
+ /* Set the end of system SRAM */
+
+# define SRAM1_END CONFIG_RAM_END
+
+/* Set the range of CCM SRAM as well (although we may not use it) */
+
+# define SRAM2_START 0x10000000
+# define SRAM2_END 0x10001000
+
+ /* There is no FSMC */
+
+# undef CONFIG_STM32_FSMC_SRAM
+
+ /* There are 2 possible SRAM configurations:
+ *
+ * Configuration 1. System SRAM (only)
+ * CONFIG_MM_REGIONS == 1
+ * CONFIG_STM32_CCMEXCLUDE defined
+ * Configuration 2. System SRAM and CCM SRAM
+ * CONFIG_MM_REGIONS == 2
+ * CONFIG_STM32_CCMEXCLUDE NOT defined
+ */
+
+# if CONFIG_MM_REGIONS < 2
+
+ /* Only one memory region. Force Configuration 1 */
+
+# ifndef CONFIG_STM32_CCMEXCLUDE
+# if CONFIG_STM32_HAVE_CCM
+# warning "CCM SRAM excluded from the heap"
+# endif
+# define CONFIG_STM32_CCMEXCLUDE 1
+# endif
+
+ /* CONFIG_MM_REGIONS may be 2 if CCM SRAM is included in the head */
+
+# elif CONFIG_MM_REGIONS >= 2
+# if CONFIG_MM_REGIONS > 2
+# error "No more than two memory regions can be supported (CONFIG_MM_REGIONS)"
+# undef CONFIG_MM_REGIONS
+# define CONFIG_MM_REGIONS 2
+# endif
+
+ /* Two memory regions is okay if CCM SRAM is not disabled. */
+
+# ifdef CONFIG_STM32_CCMEXCLUDE
+
+ /* Configuration 1: CONFIG_MM_REGIONS should have been 2 */
+
+# error "CONFIG_MM_REGIONS >= 2 but but CCM SRAM is excluded (CONFIG_STM32_CCMEXCLUDE)"
+# undef CONFIG_MM_REGIONS
+# define CONFIG_MM_REGIONS 1
+# else
+
+ /* Configuration 2: DMA should be disabled */
+
+# ifdef CONFIG_ARCH_DMA
+# warning "CCM SRAM is included in the heap AND DMA is enabled"
+# endif
+# endif
+# endif
+
/* All members of the STM32F37xxx families have 16-32 Kib ram in a single
* bank. No external RAM is supported (the F3 family has no FSMC).
*/
@@ -246,7 +316,6 @@
# error "CONFIG_MM_REGIONS > 1. The STM32L15X has only one memory region."
# endif
-
/* Most members of both the STM32F20xxx and STM32F40xxx families have 128Kib
* in two banks:
*
diff --git a/arch/arm/src/stm32/stm32_can.c b/arch/arm/src/stm32/stm32_can.c
index ed973d57bd0d3155f5382400503c95143ac14ee4..d90e5cd06da76fda8f9035824de0505b0d11101e 100644
--- a/arch/arm/src/stm32/stm32_can.c
+++ b/arch/arm/src/stm32/stm32_can.c
@@ -159,10 +159,10 @@ static bool stm32can_txempty(FAR struct can_dev_s *dev);
/* CAN interrupt handling */
-static int stm32can_rxinterrupt(int irq, FAR void *context, int rxmb);
-static int stm32can_rx0interrupt(int irq, FAR void *context);
-static int stm32can_rx1interrupt(int irq, FAR void *context);
-static int stm32can_txinterrupt(int irq, FAR void *context);
+static int stm32can_rxinterrupt(FAR struct can_dev_s *dev, int rxmb);
+static int stm32can_rx0interrupt(int irq, FAR void *context, FAR void *arg);
+static int stm32can_rx1interrupt(int irq, FAR void *context, FAR void *arg);
+static int stm32can_txinterrupt(int irq, FAR void *context, FAR void *arg);
/* Initialization */
@@ -654,7 +654,7 @@ static int stm32can_setup(FAR struct can_dev_s *dev)
* The others are not used.
*/
- ret = irq_attach(priv->canrx[0], stm32can_rx0interrupt);
+ ret = irq_attach(priv->canrx[0], stm32can_rx0interrupt, dev);
if (ret < 0)
{
canerr("ERROR: Failed to attach CAN%d RX0 IRQ (%d)",
@@ -662,7 +662,7 @@ static int stm32can_setup(FAR struct can_dev_s *dev)
return ret;
}
- ret = irq_attach(priv->canrx[1], stm32can_rx1interrupt);
+ ret = irq_attach(priv->canrx[1], stm32can_rx1interrupt, dev);
if (ret < 0)
{
canerr("ERROR: Failed to attach CAN%d RX1 IRQ (%d)",
@@ -670,7 +670,7 @@ static int stm32can_setup(FAR struct can_dev_s *dev)
return ret;
}
- ret = irq_attach(priv->cantx, stm32can_txinterrupt);
+ ret = irq_attach(priv->cantx, stm32can_txinterrupt, dev);
if (ret < 0)
{
canerr("ERROR: Failed to attach CAN%d TX IRQ (%d)",
@@ -1371,9 +1371,8 @@ static bool stm32can_txempty(FAR struct can_dev_s *dev)
*
****************************************************************************/
-static int stm32can_rxinterrupt(int irq, FAR void *context, int rxmb)
+static int stm32can_rxinterrupt(FAR struct can_dev_s *dev, int rxmb)
{
- FAR struct can_dev_s *dev = NULL;
FAR struct stm32_can_s *priv;
struct can_hdr_s hdr;
uint8_t data[CAN_MAXDATALEN];
@@ -1381,24 +1380,7 @@ static int stm32can_rxinterrupt(int irq, FAR void *context, int rxmb)
int npending;
int ret;
-#if defined(CONFIG_STM32_CAN1) && defined(CONFIG_STM32_CAN2)
- if (g_can1priv.canrx[rxmb] == irq)
- {
- dev = &g_can1dev;
- }
- else if (g_can2priv.canrx[rxmb] == irq)
- {
- dev = &g_can2dev;
- }
- else
- {
- PANIC();
- }
-#elif defined(CONFIG_STM32_CAN1)
- dev = &g_can1dev;
-#else /* defined(CONFIG_STM32_CAN2) */
- dev = &g_can2dev;
-#endif
+ DEBUGASSERT(dev != NULL && dev->cd_priv != NULL);
priv = dev->cd_priv;
/* Verify that a message is pending in the FIFO */
@@ -1506,9 +1488,10 @@ errout:
*
****************************************************************************/
-static int stm32can_rx0interrupt(int irq, FAR void *context)
+static int stm32can_rx0interrupt(int irq, FAR void *context, FAR void *arg)
{
- return stm32can_rxinterrupt(irq, context, 0);
+ FAR struct can_dev_s *dev = (FAR struct can_dev_s *)arg;
+ return stm32can_rxinterrupt(dev, 0);
}
/****************************************************************************
@@ -1526,9 +1509,10 @@ static int stm32can_rx0interrupt(int irq, FAR void *context)
*
****************************************************************************/
-static int stm32can_rx1interrupt(int irq, FAR void *context)
+static int stm32can_rx1interrupt(int irq, FAR void *context, FAR void *arg)
{
- return stm32can_rxinterrupt(irq, context, 1);
+ FAR struct can_dev_s *dev = (FAR struct can_dev_s *)arg;
+ return stm32can_rxinterrupt(dev, 1);
}
/****************************************************************************
@@ -1546,30 +1530,13 @@ static int stm32can_rx1interrupt(int irq, FAR void *context)
*
****************************************************************************/
-static int stm32can_txinterrupt(int irq, FAR void *context)
+static int stm32can_txinterrupt(int irq, FAR void *context, FAR void *arg)
{
- FAR struct can_dev_s *dev = NULL;
+ FAR struct can_dev_s *dev = (FAR struct can_dev_s *)arg;
FAR struct stm32_can_s *priv;
uint32_t regval;
-#if defined(CONFIG_STM32_CAN1) && defined(CONFIG_STM32_CAN2)
- if (g_can1priv.cantx == irq)
- {
- dev = &g_can1dev;
- }
- else if (g_can2priv.cantx == irq)
- {
- dev = &g_can2dev;
- }
- else
- {
- PANIC();
- }
-#elif defined(CONFIG_STM32_CAN1)
- dev = &g_can1dev;
-#else /* defined(CONFIG_STM32_CAN2) */
- dev = &g_can2dev;
-#endif
+ DEBUGASSERT(dev != NULL && dev->cd_priv != NULL);
priv = dev->cd_priv;
/* Get the transmit status */
diff --git a/arch/arm/src/stm32/stm32_capture.c b/arch/arm/src/stm32/stm32_capture.c
index e5fefa74cfc27a2fbb93a735df4d4c6ab6379731..6b22ae8261ef1071fb79525c79615f1cb992ea4b 100644
--- a/arch/arm/src/stm32/stm32_capture.c
+++ b/arch/arm/src/stm32/stm32_capture.c
@@ -1,5 +1,5 @@
/************************************************************************************
- * arm/arm/src/stm32/stm32_capture.c
+ * arch/arm/src/stm32/stm32_capture.c
*
* Copyright (C) 2015 Bouteville Pierre-Noel. All rights reserved.
* Author: Bouteville Pierre-Noel
@@ -702,7 +702,7 @@ static int stm32_cap_setclock(FAR struct stm32_cap_dev_s *dev, stm32_cap_clk_t c
return prescaler;
}
-static int stm32_cap_setisr(FAR struct stm32_cap_dev_s *dev, xcpt_t handler)
+static int stm32_cap_setisr(FAR struct stm32_cap_dev_s *dev, xcpt_t handler, void *arg)
{
const struct stm32_cap_priv_s *priv = (const struct stm32_cap_priv_s *)dev;
int irq;
@@ -736,13 +736,13 @@ static int stm32_cap_setisr(FAR struct stm32_cap_dev_s *dev, xcpt_t handler)
/* Otherwise set callback and enable interrupt */
- irq_attach(irq, handler);
+ irq_attach(irq, handler, arg);
up_enable_irq(irq);
#ifdef USE_ADVENCED_TIM
if (priv->irq_of)
{
- irq_attach(priv->irq_of, handler);
+ irq_attach(priv->irq_of, handler, arg);
up_enable_irq(priv->irq_of);
}
#endif
diff --git a/arch/arm/src/stm32/stm32_capture.h b/arch/arm/src/stm32/stm32_capture.h
index d015c80e5622edef89c02788888c9d5bf8523464..5c81e77d9c29773685ceaf0e058892ba546287da 100644
--- a/arch/arm/src/stm32/stm32_capture.h
+++ b/arch/arm/src/stm32/stm32_capture.h
@@ -54,7 +54,7 @@
#define STM32_CAP_SETCLOCK(d,clk_src,psc,max) ((d)->ops->setclock(d,clk_src,psc,max))
#define STM32_CAP_SETCHANNEL(d,ch,cfg) ((d)->ops->setchannel(d,ch,cfg))
#define STM32_CAP_GETCAPTURE(d,ch) ((d)->ops->getcapture(d,ch))
-#define STM32_CAP_SETISR(d,hnd) ((d)->ops->setisr(d,hnd))
+#define STM32_CAP_SETISR(d,hnd,arg) ((d)->ops->setisr(d,hnd,arg))
#define STM32_CAP_ENABLEINT(d,s,on) ((d)->ops->enableint(d,s,on))
#define STM32_CAP_ACKFLAGS(d,f) ((d)->ops->ackflags(d,f))
#define STM32_CAP_GETFLAGS(d) ((d)->ops->getflags(d))
@@ -178,7 +178,7 @@ struct stm32_cap_ops_s
int (*setclock)( FAR struct stm32_cap_dev_s *dev, stm32_cap_clk_t clk, uint32_t prescaler, uint32_t max);
int (*setchannel)(FAR struct stm32_cap_dev_s *dev, uint8_t channel, stm32_cap_ch_cfg_t cfg);
uint32_t (*getcapture)(FAR struct stm32_cap_dev_s *dev, uint8_t channel);
- int (*setisr)( FAR struct stm32_cap_dev_s *dev, xcpt_t handler);
+ int (*setisr)(FAR struct stm32_cap_dev_s *dev, xcpt_t handler, void *arg);
void (*enableint)( FAR struct stm32_cap_dev_s *dev, stm32_cap_flags_t src, bool on );
void (*ackflags)( FAR struct stm32_cap_dev_s *dev, int flags);
stm32_cap_flags_t (*getflags)(FAR struct stm32_cap_dev_s *dev);
@@ -194,7 +194,7 @@ FAR struct stm32_cap_dev_s *stm32_cap_init(int timer);
/* Power-down timer, mark it as unused */
-int stm32_cap_deinit(FAR struct stm32_cap_dev_s * dev);
+int stm32_cap_deinit(FAR struct stm32_cap_dev_s *dev);
#undef EXTERN
#if defined(__cplusplus)
diff --git a/arch/arm/src/stm32/stm32_ccm.c b/arch/arm/src/stm32/stm32_ccm.c
index c3f72a398eff6c4ed22eb34908222149df0d35cd..cdf7fb8805ba403f47ece456ac8b74bb35f6854d 100644
--- a/arch/arm/src/stm32/stm32_ccm.c
+++ b/arch/arm/src/stm32/stm32_ccm.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * arch/arm/src/common/stm32_ccm.c
+ * arch/arm/src/stm32/stm32_ccm.c
*
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
@@ -62,4 +62,4 @@ struct mm_heap_s g_ccm_heap;
* Public Function Prototypes
****************************************************************************/
-#endif /* HAVE_CCM_HEAP */
\ No newline at end of file
+#endif /* HAVE_CCM_HEAP */
diff --git a/arch/arm/src/stm32/stm32_ccm.h b/arch/arm/src/stm32/stm32_ccm.h
index ce441ff7601880e525d076f49731e05329ee8d85..20cc650eee802544468ea31ec8de9d414a268b7f 100644
--- a/arch/arm/src/stm32/stm32_ccm.h
+++ b/arch/arm/src/stm32/stm32_ccm.h
@@ -1,5 +1,5 @@
/****************************************************************************
- * arch/arm/src/common/stm32_ccm.h
+ * arch/arm/src/stm32/stm32_ccm.h
*
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
@@ -58,7 +58,8 @@
#if defined(CONFIG_STM32_STM32F30XX)
# define CCM_START 0x10000000
# define CCM_END 0x10002000
-#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX)
+#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) || \
+ defined(CONFIG_STM32_STM32F33XX)
# define CCM_START 0x10000000
# define CCM_END 0x10010000
#else
diff --git a/arch/arm/src/stm32/stm32_dac.c b/arch/arm/src/stm32/stm32_dac.c
index 796bb81d2136537da93ae6ed38eb361c9fef51f6..e12c9f65c5f6eecf487e84c81714735b95ff7a17 100644
--- a/arch/arm/src/stm32/stm32_dac.c
+++ b/arch/arm/src/stm32/stm32_dac.c
@@ -94,6 +94,12 @@
# undef CONFIG_STM32_DAC1_DMA
# undef CONFIG_STM32_DAC2_DMA
# endif
+# elif defined(CONFIG_STM32_STM32F33XX)
+# ifndef CONFIG_STM32_DMA1
+# warning "STM32 F334 DAC DMA support requires CONFIG_STM32_DMA1"
+# undef CONFIG_STM32_DAC1_DMA
+# undef CONFIG_STM32_DAC2_DMA
+# endif
# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX)
# ifndef CONFIG_STM32_DMA1
# warning "STM32 F4 DAC DMA support requires CONFIG_STM32_DMA1"
@@ -147,7 +153,8 @@
# define DAC_DMA 2
# define DAC1_DMA_CHAN DMACHAN_DAC_CHAN1
# define DAC2_DMA_CHAN DMACHAN_DAC_CHAN2
-# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX)
+# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) || \
+ defined(CONFIG_STM32_STM32F33XX)
# define HAVE_DMA 1
# define DAC_DMA 1
# define DAC1_DMA_CHAN DMAMAP_DAC1
@@ -375,7 +382,7 @@ static void tim_putreg(FAR struct stm32_chan_s *chan, int offset,
/* Interrupt handler */
#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX)
-static int dac_interrupt(int irq, FAR void *context);
+static int dac_interrupt(int irq, FAR void *context, FAR void *arg);
#endif
/* DAC methods */
@@ -614,7 +621,7 @@ static void tim_modifyreg(FAR struct stm32_chan_s *chan, int offset,
****************************************************************************/
#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX)
-static int dac_interrupt(int irq, FAR void *context)
+static int dac_interrupt(int irq, FAR void *context, FAR void *arg)
{
#warning "Missing logic"
return OK;
@@ -847,7 +854,6 @@ static int dac_timinit(FAR struct stm32_chan_s *chan)
* default) will be enabled
*/
- pclk = STM32_TIM27_FREQUENCY;
regaddr = STM32_RCC_APB1ENR;
switch (chan->timer)
@@ -855,31 +861,37 @@ static int dac_timinit(FAR struct stm32_chan_s *chan)
#ifdef NEED_TIM2
case 2:
setbits = RCC_APB1ENR_TIM2EN;
+ pclk = BOARD_TIM2_FREQUENCY;
break;
#endif
#ifdef NEED_TIM3
case 3:
setbits = RCC_APB1ENR_TIM3EN;
+ pclk = BOARD_TIM3_FREQUENCY;
break;
#endif
#ifdef NEED_TIM4
case 4:
setbits = RCC_APB1ENR_TIM4EN;
+ pclk = BOARD_TIM4_FREQUENCY;
break;
#endif
#ifdef NEED_TIM5
case 5:
setbits = RCC_APB1ENR_TIM5EN;
+ pclk = BOARD_TIM5_FREQUENCY;
break;
#endif
#ifdef NEED_TIM6
case 6:
setbits = RCC_APB1ENR_TIM6EN;
+ pclk = BOARD_TIM6_FREQUENCY;
break;
#endif
#ifdef NEED_TIM7
case 7:
setbits = RCC_APB1ENR_TIM7EN;
+ pclk = BOARD_TIM7_FREQUENCY;
break;
#endif
#ifdef NEED_TIM8
@@ -891,7 +903,7 @@ static int dac_timinit(FAR struct stm32_chan_s *chan)
#endif
default:
aerr("ERROR: Could not enable timer\n");
- break;
+ return -EINVAL;
}
/* Enable the timer. */
diff --git a/arch/arm/src/stm32/stm32_dac.h b/arch/arm/src/stm32/stm32_dac.h
index 3718a245a4dce5e7dba38d9f743086e304d1f389..37ba66f0939d4f2d1c3fa09ead80903b8cb8ac85 100644
--- a/arch/arm/src/stm32/stm32_dac.h
+++ b/arch/arm/src/stm32/stm32_dac.h
@@ -43,7 +43,11 @@
#include
#include "chip.h"
+#ifdef CONFIG_STM32_STM32F33XX
+#include "chip/stm32f33xxx_dac.h"
+#else
#include "chip/stm32_dac.h"
+#endif
#include
diff --git a/arch/arm/src/stm32/stm32_dma.c b/arch/arm/src/stm32/stm32_dma.c
index 4b694e7ccb9de6ddbf582e2e848c631e7da1ef58..0de9cdcc3b8df55c4bb1985f5ea0ea42a1145367 100644
--- a/arch/arm/src/stm32/stm32_dma.c
+++ b/arch/arm/src/stm32/stm32_dma.c
@@ -56,7 +56,8 @@
*/
#if defined(CONFIG_STM32_STM32L15XX) || defined(CONFIG_STM32_STM32F10XX) || \
- defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F37XX)
+ defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX) || \
+ defined(CONFIG_STM32_STM32F37XX)
# include "stm32f10xxx_dma.c"
#elif defined(CONFIG_STM32_STM32F20XX)
# include "stm32f20xxx_dma.c"
diff --git a/arch/arm/src/stm32/stm32_dma.h b/arch/arm/src/stm32/stm32_dma.h
index d26428c35bbc758d714345ed998aff76f7614a51..36c21f3ca60dac26256368a80d4b97a7faaa6ad5 100644
--- a/arch/arm/src/stm32/stm32_dma.h
+++ b/arch/arm/src/stm32/stm32_dma.h
@@ -48,7 +48,8 @@
/* Include the correct DMA register definitions for this STM32 family */
#if defined(CONFIG_STM32_STM32L15XX) || defined(CONFIG_STM32_STM32F10XX) || \
- defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F37XX)
+ defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX) || \
+ defined(CONFIG_STM32_STM32F37XX)
# include "chip/stm32f10xxx_dma.h"
#elif defined(CONFIG_STM32_STM32F20XX)
# include "chip/stm32f20xxx_dma.h"
@@ -63,7 +64,8 @@
*/
#if defined(CONFIG_STM32_STM32L15XX) || defined(CONFIG_STM32_STM32F10XX) || \
- defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F37XX)
+ defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX) || \
+ defined(CONFIG_STM32_STM32F37XX)
# define DMA_STATUS_FEIF 0 /* (Not available in F1) */
# define DMA_STATUS_DMEIF 0 /* (Not available in F1) */
# define DMA_STATUS_TEIF DMA_CHAN_TEIF_BIT /* Channel Transfer Error */
@@ -106,7 +108,8 @@ typedef void (*dma_callback_t)(DMA_HANDLE handle, uint8_t status, void *arg);
#ifdef CONFIG_DEBUG_DMA_INFO
#if defined(CONFIG_STM32_STM32L15XX) || defined(CONFIG_STM32_STM32F10XX) || \
- defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F37XX)
+ defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX) || \
+ defined(CONFIG_STM32_STM32F37XX)
struct stm32_dmaregs_s
{
uint32_t isr;
diff --git a/arch/arm/src/stm32/stm32_dma2d.c b/arch/arm/src/stm32/stm32_dma2d.c
index c4ef73fc2be9e4a9c638920f0e2ab1d5106fb3f0..8611ab2c1a3e96eefcc9f9636cf2f84aaec5b094 100644
--- a/arch/arm/src/stm32/stm32_dma2d.c
+++ b/arch/arm/src/stm32/stm32_dma2d.c
@@ -285,7 +285,7 @@ static const uintptr_t stm32_cmar_layer_t[DMA2D_NLAYERS - 1] =
static int stm32_dma2d_pixelformat(uint8_t fmt, uint8_t *fmtmap);
static int stm32_dma2d_bpp(uint8_t fmt, uint8_t *bpp);
static void stm32_dma2d_control(uint32_t setbits, uint32_t clrbits);
-static int stm32_dma2dirq(int irq, void *context);
+static int stm32_dma2dirq(int irq, void *context, FAR void *arg);
static int stm32_dma2d_waitforirq(void);
static int stm32_dma2d_start(void);
#ifdef CONFIG_STM32_DMA2D_L8
@@ -425,7 +425,7 @@ static void stm32_dma2d_control(uint32_t setbits, uint32_t clrbits)
*
****************************************************************************/
-static int stm32_dma2dirq(int irq, void *context)
+static int stm32_dma2dirq(int irq, void *context, FAR void *arg)
{
uint32_t regval = getreg32(STM32_DMA2D_ISR);
FAR struct stm32_interrupt_s *priv = &g_interrupt;
@@ -2190,7 +2190,7 @@ int up_dma2dinitialize(void)
/* Attach DMA2D interrupt vector */
- (void)irq_attach(g_interrupt.irq, stm32_dma2dirq);
+ (void)irq_attach(g_interrupt.irq, stm32_dma2dirq, NULL);
/* Enable the IRQ at the NVIC */
diff --git a/arch/arm/src/stm32/stm32_dma2d.h b/arch/arm/src/stm32/stm32_dma2d.h
index 7755ffe39d3653cc94616e0481771f8ac2b7e741..ddaeada7b20e28684c11b7b0868dcbc0bd84945d 100644
--- a/arch/arm/src/stm32/stm32_dma2d.h
+++ b/arch/arm/src/stm32/stm32_dma2d.h
@@ -83,7 +83,7 @@
*
****************************************************************************/
-FAR struct dma2d_layer_s * stm32_dma2dinitltdc(FAR struct stm32_ltdc_s *layer);
+FAR struct dma2d_layer_s *stm32_dma2dinitltdc(FAR struct stm32_ltdc_s *layer);
# endif /* CONFIG_STM32_LTDC_INTERFACE */
#endif /* CONFIG_STM32_DMA2D */
diff --git a/arch/arm/src/stm32/stm32_dumpgpio.c b/arch/arm/src/stm32/stm32_dumpgpio.c
index a8da3160d1950403a3bd50ba19b2539e6fad5a47..2540ffdcbcc6ebcf3409505f93a47ec82366bd9c 100644
--- a/arch/arm/src/stm32/stm32_dumpgpio.c
+++ b/arch/arm/src/stm32/stm32_dumpgpio.c
@@ -172,7 +172,8 @@ int stm32_dumpgpio(uint32_t pinset, const char *msg)
g_portchar[port], getreg32(STM32_RCC_AHBENR));
}
-#elif defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F37XX)
+#elif defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F37XX) || \
+ defined(CONFIG_STM32_STM32F33XX)
DEBUGASSERT(port < STM32_NGPIO_PORTS);
_info("GPIO%c pinset: %08x base: %08x -- %s\n",
diff --git a/arch/arm/src/stm32/stm32_eth.c b/arch/arm/src/stm32/stm32_eth.c
index 52dcaacd7289a120096b241a18ae71330b394e6e..7703a9a745e803e3e95aafa6cdbd169c2c5195f1 100644
--- a/arch/arm/src/stm32/stm32_eth.c
+++ b/arch/arm/src/stm32/stm32_eth.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/stm32/stm32_eth.c
*
- * Copyright (C) 2011-2012, 2014, 2016 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2011-2012, 2014, 2016-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
*
* Redistribution and use in source and binary forms, with or without
@@ -583,7 +583,8 @@ struct stm32_ethmac_s
uint8_t fduplex : 1; /* Full (vs. half) duplex */
WDOG_ID txpoll; /* TX poll timer */
WDOG_ID txtimeout; /* TX timeout timer */
- struct work_s work; /* For deferring work to the work queue */
+ struct work_s irqwork; /* For deferring interrupt work to the work queue */
+ struct work_s pollwork; /* For deferring poll work to the work queue */
/* This holds the information visible to the NuttX network */
@@ -658,7 +659,7 @@ static void stm32_freeframe(FAR struct stm32_ethmac_s *priv);
static void stm32_txdone(FAR struct stm32_ethmac_s *priv);
static void stm32_interrupt_work(FAR void *arg);
-static int stm32_interrupt(int irq, FAR void *context);
+static int stm32_interrupt(int irq, FAR void *context, FAR void *arg);
/* Watchdog timer expirations */
@@ -1931,14 +1932,6 @@ static void stm32_txdone(FAR struct stm32_ethmac_s *priv)
wd_cancel(priv->txtimeout);
- /* Then make sure that the TX poll timer is running (if it is already
- * running, the following would restart it). This is necessary to
- * avoid certain race conditions where the polling sequence can be
- * interrupted.
- */
-
- (void)wd_start(priv->txpoll, STM32_WDDELAY, stm32_poll_expiry, 1, priv);
-
/* And disable further TX interrupts. */
stm32_disableint(priv, ETH_DMAINT_TI);
@@ -2073,7 +2066,7 @@ static void stm32_interrupt_work(FAR void *arg)
*
****************************************************************************/
-static int stm32_interrupt(int irq, FAR void *context)
+static int stm32_interrupt(int irq, FAR void *context, FAR void *arg)
{
FAR struct stm32_ethmac_s *priv = &g_stm32ethmac[0];
uint32_t dmasr;
@@ -2102,13 +2095,9 @@ static int stm32_interrupt(int irq, FAR void *context)
wd_cancel(priv->txtimeout);
}
- /* Cancel any pending poll work */
-
- work_cancel(ETHWORK, &priv->work);
-
/* Schedule to perform the interrupt processing on the worker thread. */
- work_queue(ETHWORK, &priv->work, stm32_interrupt_work, priv, 0);
+ work_queue(ETHWORK, &priv->irqwork, stm32_interrupt_work, priv, 0);
}
return OK;
@@ -2181,15 +2170,11 @@ static void stm32_txtimeout_expiry(int argc, uint32_t arg, ...)
up_disable_irq(STM32_IRQ_ETH);
- /* Cancel any pending poll or interrupt work. This will have no effect
- * on work that has already been started.
+ /* Schedule to perform the TX timeout processing on the worker thread,
+ * perhaps canceling any pending IRQ processing.
*/
- work_cancel(ETHWORK, &priv->work);
-
- /* Schedule to perform the TX timeout processing on the worker thread. */
-
- work_queue(ETHWORK, &priv->work, stm32_txtimeout_work, priv, 0);
+ work_queue(ETHWORK, &priv->irqwork, stm32_txtimeout_work, priv, 0);
}
/****************************************************************************
@@ -2286,24 +2271,9 @@ static void stm32_poll_expiry(int argc, uint32_t arg, ...)
{
FAR struct stm32_ethmac_s *priv = (FAR struct stm32_ethmac_s *)arg;
- /* Is our single work structure available? It may not be if there are
- * pending interrupt actions.
- */
-
- if (work_available(&priv->work))
- {
- /* Schedule to perform the interrupt processing on the worker thread. */
+ /* Schedule to perform the interrupt processing on the worker thread. */
- work_queue(ETHWORK, &priv->work, stm32_poll_work, priv, 0);
- }
- else
- {
- /* No.. Just re-start the watchdog poll timer, missing one polling
- * cycle.
- */
-
- (void)wd_start(priv->txpoll, STM32_WDDELAY, stm32_poll_expiry, 1, (uint32_t)priv);
- }
+ work_queue(ETHWORK, &priv->pollwork, stm32_poll_work, priv, 0);
}
/****************************************************************************
@@ -2472,11 +2442,11 @@ static int stm32_txavail(struct net_driver_s *dev)
* availability action.
*/
- if (work_available(&priv->work))
+ if (work_available(&priv->pollwork))
{
/* Schedule to serialize the poll on the worker thread. */
- work_queue(ETHWORK, &priv->work, stm32_txavail_work, priv, 0);
+ work_queue(ETHWORK, &priv->pollwork, stm32_txavail_work, priv, 0);
}
return OK;
@@ -4008,7 +3978,7 @@ int stm32_ethinitialize(int intf)
/* Attach the IRQ to the driver */
- if (irq_attach(STM32_IRQ_ETH, stm32_interrupt))
+ if (irq_attach(STM32_IRQ_ETH, stm32_interrupt, NULL))
{
/* We could not attach the ISR to the interrupt */
diff --git a/arch/arm/src/stm32/stm32_exti.h b/arch/arm/src/stm32/stm32_exti.h
index 6a34582c6763f82bfa08cfa08a63218462c1214f..9ac20798df26ab279580b21faf91433194704d65 100644
--- a/arch/arm/src/stm32/stm32_exti.h
+++ b/arch/arm/src/stm32/stm32_exti.h
@@ -1,7 +1,7 @@
/************************************************************************************
* arch/arm/src/stm32/stm32_exti.h
*
- * Copyright (C) 2009, 2012, 2015 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2009, 2012, 2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
*
* Redistribution and use in source and binary forms, with or without
@@ -72,21 +72,21 @@ extern "C"
* Description:
* Sets/clears GPIO based event and interrupt triggers.
*
- * Parameters:
+ * Input Parameters:
* - pinset: gpio pin configuration
* - rising/falling edge: enables
* - event: generate event when set
* - func: when non-NULL, generate interrupt
+ * - arg: Argument passed to the interrupt callback
*
- * Returns:
- * The previous value of the interrupt handler function pointer. This value may,
- * for example, be used to restore the previous handler when multiple handlers are
- * used.
+ * Returned Value:
+ * Zero (OK) on success; a negated errno value on failure indicating the
+ * nature of the failure.
*
************************************************************************************/
-xcpt_t stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
- bool event, xcpt_t func);
+int stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
+ bool event, xcpt_t func, void *arg);
/************************************************************************************
* Name: stm32_exti_alarm
@@ -94,20 +94,21 @@ xcpt_t stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
* Description:
* Sets/clears EXTI alarm interrupt.
*
- * Parameters:
+ * Input Parameters:
* - rising/falling edge: enables interrupt on rising/falling edges
* - event: generate event when set
* - func: when non-NULL, generate interrupt
+ * - arg: Argument passed to the interrupt callback
*
- * Returns:
- * The previous value of the interrupt handler function pointer. This value may,
- * for example, be used to restore the previous handler when multiple handlers are
- * used.
+ * Returned Value:
+ * Zero (OK) on success; a negated errno value on failure indicating the
+ * nature of the failure.
*
************************************************************************************/
#ifdef CONFIG_RTC_ALARM
-xcpt_t stm32_exti_alarm(bool risingedge, bool fallingedge, bool event, xcpt_t func);
+int stm32_exti_alarm(bool risingedge, bool fallingedge, bool event, xcpt_t func,
+ void *arg);
#endif
#undef EXTERN
diff --git a/arch/arm/src/stm32/stm32_exti_alarm.c b/arch/arm/src/stm32/stm32_exti_alarm.c
index 2e6d582a4aa27341f77f08f2517127a8b4aaf69b..12000d26af53db5f4a602f249516137376d52046 100644
--- a/arch/arm/src/stm32/stm32_exti_alarm.c
+++ b/arch/arm/src/stm32/stm32_exti_alarm.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/stm32/stm32_exti_alarm.c
*
- * Copyright (C) 2009, 2012 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2009, 2012, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
* Diego Sanchez
*
@@ -59,7 +59,8 @@
/* Interrupt handlers attached to the ALARM EXTI */
-static xcpt_t stm32_exti_callback;
+static xcpt_t g_alarm_callback;
+static void *g_callback_arg;
/****************************************************************************
* Private Functions
@@ -73,7 +74,7 @@ static xcpt_t stm32_exti_callback;
*
****************************************************************************/
-static int stm32_exti_alarm_isr(int irq, void *context)
+static int stm32_exti_alarm_isr(int irq, void *context, FAR void *arg)
{
int ret = OK;
@@ -83,9 +84,9 @@ static int stm32_exti_alarm_isr(int irq, void *context)
/* And dispatch the interrupt to the handler */
- if (stm32_exti_callback)
+ if (g_alarm_callback)
{
- ret = stm32_exti_callback(irq, context);
+ ret = g_alarm_callback(irq, context, g_callback_arg);
}
return ret;
@@ -105,29 +106,27 @@ static int stm32_exti_alarm_isr(int irq, void *context)
* - rising/falling edge: enables interrupt on rising/falling edget
* - event: generate event when set
* - func: when non-NULL, generate interrupt
+ * - arg: Argument passed to the interrupt callback
*
* Returns:
- * The previous value of the interrupt handler function pointer. This
- * value may, for example, be used to restore the previous handler when
- * multiple handlers are used.
+ * Zero (OK) on success; a negated errno value on failure indicating the
+ * nature of the failure.
*
****************************************************************************/
-xcpt_t stm32_exti_alarm(bool risingedge, bool fallingedge, bool event,
- xcpt_t func)
+int stm32_exti_alarm(bool risingedge, bool fallingedge, bool event,
+ xcpt_t func, void *arg)
{
- xcpt_t oldhandler;
-
/* Get the previous GPIO IRQ handler; Save the new IRQ handler. */
- oldhandler = stm32_exti_callback;
- stm32_exti_callback = func;
+ g_alarm_callback = func;
+ g_callback_arg = arg;
/* Install external interrupt handlers (if not already attached) */
if (func)
{
- irq_attach(STM32_IRQ_RTCALRM, stm32_exti_alarm_isr);
+ irq_attach(STM32_IRQ_RTCALRM, stm32_exti_alarm_isr, NULL);
up_enable_irq(STM32_IRQ_RTCALRM);
}
else
@@ -155,5 +154,5 @@ xcpt_t stm32_exti_alarm(bool risingedge, bool fallingedge, bool event,
/* Return the old IRQ handler */
- return oldhandler;
+ return OK;
}
diff --git a/arch/arm/src/stm32/stm32_exti_gpio.c b/arch/arm/src/stm32/stm32_exti_gpio.c
index 6aa2cf4be2b0900fed3f422e7f4f2ffd7f3e4dda..663c0416b85f8608e8fbb2630f53b247469f73f1 100644
--- a/arch/arm/src/stm32/stm32_exti_gpio.c
+++ b/arch/arm/src/stm32/stm32_exti_gpio.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/stm32/stm32_exti_gpio.c
*
- * Copyright (C) 2009, 2011-2012, 2015 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2009, 2011-2012, 2015, 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2011 Uros Platise. All rights reserved.
* Author: Gregory Nutt
* Uros Platise
@@ -55,13 +55,23 @@
#include "stm32_gpio.h"
#include "stm32_exti.h"
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct gpio_callback_s
+{
+ xcpt_t callback;
+ void *arg;
+};
+
/****************************************************************************
* Private Data
****************************************************************************/
/* Interrupt handlers attached to each EXTI */
-static xcpt_t stm32_exti_callbacks[16];
+static struct gpio_callback_s g_gpio_callbacks[16];
/****************************************************************************
* Private Functions
@@ -71,7 +81,7 @@ static xcpt_t stm32_exti_callbacks[16];
* Interrupt Service Routines - Dispatchers
****************************************************************************/
-static int stm32_exti0_isr(int irq, void *context)
+static int stm32_exti0_isr(int irq, void *context, void *arg)
{
int ret = OK;
@@ -81,15 +91,18 @@ static int stm32_exti0_isr(int irq, void *context)
/* And dispatch the interrupt to the handler */
- if (stm32_exti_callbacks[0])
+ if (g_gpio_callbacks[0].callback != NULL)
{
- ret = stm32_exti_callbacks[0](irq, context);
+ xcpt_t callback = g_gpio_callbacks[0].callback;
+ void *cbarg = g_gpio_callbacks[0].arg;
+
+ ret = callback(irq, context, cbarg);
}
return ret;
}
-static int stm32_exti1_isr(int irq, void *context)
+static int stm32_exti1_isr(int irq, void *context, void *arg)
{
int ret = OK;
@@ -99,15 +112,18 @@ static int stm32_exti1_isr(int irq, void *context)
/* And dispatch the interrupt to the handler */
- if (stm32_exti_callbacks[1])
+ if (g_gpio_callbacks[1].callback != NULL)
{
- ret = stm32_exti_callbacks[1](irq, context);
+ xcpt_t callback = g_gpio_callbacks[1].callback;
+ void *cbarg = g_gpio_callbacks[1].arg;
+
+ ret = callback(irq, context, cbarg);
}
return ret;
}
-static int stm32_exti2_isr(int irq, void *context)
+static int stm32_exti2_isr(int irq, void *context, void *arg)
{
int ret = OK;
@@ -117,15 +133,18 @@ static int stm32_exti2_isr(int irq, void *context)
/* And dispatch the interrupt to the handler */
- if (stm32_exti_callbacks[2])
+ if (g_gpio_callbacks[2].callback != NULL)
{
- ret = stm32_exti_callbacks[2](irq, context);
+ xcpt_t callback = g_gpio_callbacks[2].callback;
+ void *cbarg = g_gpio_callbacks[2].arg;
+
+ ret = callback(irq, context, cbarg);
}
return ret;
}
-static int stm32_exti3_isr(int irq, void *context)
+static int stm32_exti3_isr(int irq, void *context, void * arg)
{
int ret = OK;
@@ -135,15 +154,18 @@ static int stm32_exti3_isr(int irq, void *context)
/* And dispatch the interrupt to the handler */
- if (stm32_exti_callbacks[3])
+ if (g_gpio_callbacks[3].callback != NULL)
{
- ret = stm32_exti_callbacks[3](irq, context);
+ xcpt_t callback = g_gpio_callbacks[3].callback;
+ void *cbarg = g_gpio_callbacks[3].arg;
+
+ ret = callback(irq, context, cbarg);
}
return ret;
}
-static int stm32_exti4_isr(int irq, void *context)
+static int stm32_exti4_isr(int irq, void *context, void *arg)
{
int ret = OK;
@@ -153,15 +175,19 @@ static int stm32_exti4_isr(int irq, void *context)
/* And dispatch the interrupt to the handler */
- if (stm32_exti_callbacks[4])
+ if (g_gpio_callbacks[4].callback != NULL)
{
- ret = stm32_exti_callbacks[4](irq, context);
+ xcpt_t callback = g_gpio_callbacks[4].callback;
+ void *cbarg = g_gpio_callbacks[4].arg;
+
+ ret = callback(irq, context, cbarg);
}
return ret;
}
-static int stm32_exti_multiisr(int irq, void *context, int first, int last)
+static int stm32_exti_multiisr(int irq, void *context, void *arg,
+ int first, int last)
{
uint32_t pr;
int pin;
@@ -186,10 +212,14 @@ static int stm32_exti_multiisr(int irq, void *context, int first, int last)
/* And dispatch the interrupt to the handler */
- if (stm32_exti_callbacks[pin])
+ if (g_gpio_callbacks[pin].callback != NULL)
{
- int tmp = stm32_exti_callbacks[pin](irq, context);
- if (tmp != OK)
+ xcpt_t callback = g_gpio_callbacks[pin].callback;
+ void *cbarg = g_gpio_callbacks[pin].arg;
+ int tmp;
+
+ tmp = callback(irq, context, cbarg);
+ if (tmp < 0)
{
ret = tmp;
}
@@ -200,14 +230,14 @@ static int stm32_exti_multiisr(int irq, void *context, int first, int last)
return ret;
}
-static int stm32_exti95_isr(int irq, void *context)
+static int stm32_exti95_isr(int irq, void *context, void *arg)
{
- return stm32_exti_multiisr(irq, context, 5, 9);
+ return stm32_exti_multiisr(irq, context, arg, 5, 9);
}
-static int stm32_exti1510_isr(int irq, void *context)
+static int stm32_exti1510_isr(int irq, void *context, void *arg)
{
- return stm32_exti_multiisr(irq, context, 10, 15);
+ return stm32_exti_multiisr(irq, context, arg, 10, 15);
}
/****************************************************************************
@@ -220,30 +250,29 @@ static int stm32_exti1510_isr(int irq, void *context)
* Description:
* Sets/clears GPIO based event and interrupt triggers.
*
- * Parameters:
+ * Input Parameters:
* - pinset: GPIO pin configuration
* - risingedge: Enables interrupt on rising edges
* - fallingedge: Enables interrupt on falling edges
* - event: Generate event when set
* - func: When non-NULL, generate interrupt
+ * - arg: Argument passed to the interrupt callback
*
- * Returns:
- * The previous value of the interrupt handler function pointer. This
- * value may, for example, be used to restore the previous handler when
- * multiple handlers are used.
+ * Returned Value:
+ * Zero (OK) on success; a negated errno value on failure indicating the
+ * nature of the failure.
*
****************************************************************************/
-xcpt_t stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
- bool event, xcpt_t func)
+int stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
+ bool event, xcpt_t func, void *arg)
{
+ FAR struct gpio_callback_s *shared_cbs;
uint32_t pin = pinset & GPIO_PIN_MASK;
uint32_t exti = STM32_EXTI_BIT(pin);
int irq;
xcpt_t handler;
- xcpt_t oldhandler = NULL;
int nshared;
- xcpt_t *shared_cbs;
int i;
/* Select the interrupt handler for this EXTI pin */
@@ -252,7 +281,7 @@ xcpt_t stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
{
irq = pin + STM32_IRQ_EXTI0;
nshared = 1;
- shared_cbs = &stm32_exti_callbacks[pin];
+ shared_cbs = &g_gpio_callbacks[pin];
switch (pin)
{
case 0:
@@ -280,27 +309,27 @@ xcpt_t stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
{
irq = STM32_IRQ_EXTI95;
handler = stm32_exti95_isr;
- shared_cbs = &stm32_exti_callbacks[5];
+ shared_cbs = &g_gpio_callbacks[5];
nshared = 5;
}
else
{
irq = STM32_IRQ_EXTI1510;
handler = stm32_exti1510_isr;
- shared_cbs = &stm32_exti_callbacks[10];
+ shared_cbs = &g_gpio_callbacks[10];
nshared = 6;
}
/* Get the previous GPIO IRQ handler; Save the new IRQ handler. */
- oldhandler = stm32_exti_callbacks[pin];
- stm32_exti_callbacks[pin] = func;
+ g_gpio_callbacks[pin].callback = func;
+ g_gpio_callbacks[pin].arg = arg;
/* Install external interrupt handlers */
if (func)
{
- irq_attach(irq, handler);
+ irq_attach(irq, handler, NULL);
up_enable_irq(irq);
}
else
@@ -311,7 +340,7 @@ xcpt_t stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
for (i = 0; i < nshared; i++)
{
- if (shared_cbs[i] != NULL)
+ if (shared_cbs[i].callback != NULL)
{
break;
}
@@ -352,7 +381,5 @@ xcpt_t stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
func ? 0 : exti,
func ? exti : 0);
- /* Return the old IRQ handler */
-
- return oldhandler;
+ return OK;
}
diff --git a/arch/arm/src/stm32/stm32_exti_pwr.c b/arch/arm/src/stm32/stm32_exti_pwr.c
index f57e85e6ca9422c7250ece3dfb0a5f2eeddff032..5ab6138ac4bb345729b20edcb879a27804266816 100644
--- a/arch/arm/src/stm32/stm32_exti_pwr.c
+++ b/arch/arm/src/stm32/stm32_exti_pwr.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/stm32/stm32_exti_pwr.c
*
- * Copyright (C) 2009, 2011-2012, 2015 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2009, 2011-2012, 2015, 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2015 Haltian Ltd. All rights reserved.
* Authors: Gregory Nutt
* Dmitry Nikolaev
@@ -65,11 +65,8 @@
/* Interrupt handlers attached to the PVD EXTI */
-static xcpt_t stm32_exti_pvd_callback;
-
-/****************************************************************************
- * Public Data
- ****************************************************************************/
+static xcpt_t g_pvd_callback;
+static void *g_callback_arg;
/****************************************************************************
* Private Functions
@@ -83,7 +80,7 @@ static xcpt_t stm32_exti_pvd_callback;
*
****************************************************************************/
-static int stm32_exti_pvd_isr(int irq, void *context)
+static int stm32_exti_pvd_isr(int irq, void *context, FAR void *arg)
{
int ret = OK;
@@ -93,9 +90,9 @@ static int stm32_exti_pvd_isr(int irq, void *context)
/* And dispatch the interrupt to the handler */
- if (stm32_exti_pvd_callback)
+ if (g_pvd_callback != NULL)
{
- ret = stm32_exti_pvd_callback(irq, context);
+ ret = g_pvd_callback(irq, context, g_callback_arg);
}
return ret;
@@ -115,29 +112,27 @@ static int stm32_exti_pvd_isr(int irq, void *context)
* - rising/falling edge: enables interrupt on rising/falling edge
* - event: generate event when set
* - func: when non-NULL, generate interrupt
+ * - arg: Argument passed to the interrupt callback
*
* Returns:
- * The previous value of the interrupt handler function pointer. This
- * value may, for example, be used to restore the previous handler when
- * multiple handlers are used.
+ * Zero (OK) returned on success; a negated errno value is returned on
+ * failure.
*
****************************************************************************/
-xcpt_t stm32_exti_pvd(bool risingedge, bool fallingedge, bool event,
- xcpt_t func)
+int stm32_exti_pvd(bool risingedge, bool fallingedge, bool event,
+ xcpt_t func, void *arg)
{
- xcpt_t oldhandler;
-
/* Get the previous GPIO IRQ handler; Save the new IRQ handler. */
- oldhandler = stm32_exti_pvd_callback;
- stm32_exti_pvd_callback = func;
+ g_pvd_callback = func;
+ g_callback_arg = arg;
/* Install external interrupt handlers (if not already attached) */
if (func)
{
- irq_attach(STM32_IRQ_PVD, stm32_exti_pvd_isr);
+ irq_attach(STM32_IRQ_PVD, stm32_exti_pvd_isr, NULL);
up_enable_irq(STM32_IRQ_PVD);
}
else
@@ -163,7 +158,5 @@ xcpt_t stm32_exti_pvd(bool risingedge, bool fallingedge, bool event,
func ? 0 : EXTI_PVD_LINE,
func ? EXTI_PVD_LINE : 0);
- /* Return the old IRQ handler */
-
- return oldhandler;
+ return OK;
}
diff --git a/arch/arm/src/stm32/stm32_exti_pwr.h b/arch/arm/src/stm32/stm32_exti_pwr.h
index 4955045a2f19e1695a7619147f0f30017111512f..c4841dffebe9d14c3445458e03774644a3baef27 100644
--- a/arch/arm/src/stm32/stm32_exti_pwr.h
+++ b/arch/arm/src/stm32/stm32_exti_pwr.h
@@ -57,15 +57,15 @@
* - rising/falling edge: enables interrupt on rising/falling edge
* - event: generate event when set
* - func: when non-NULL, generate interrupt
+ * - arg: Argument passed to the interrupt callback
*
* Returns:
- * The previous value of the interrupt handler function pointer. This
- * value may, for example, be used to restore the previous handler when
- * multiple handlers are used.
+ * Zero (OK) returned on success; a negated errno value is returned on
+ * failure.
*
****************************************************************************/
-xcpt_t stm32_exti_pvd(bool risingedge, bool fallingedge, bool event,
- xcpt_t func);
+int stm32_exti_pvd(bool risingedge, bool fallingedge, bool event,
+ xcpt_t func, void *arg);
#endif /* STM32_EXTI_PWR_H_ */
diff --git a/arch/arm/src/stm32/stm32_freerun.c b/arch/arm/src/stm32/stm32_freerun.c
index 38133c7c36540a79284d029ee569e138ca335ad1..673b0412d7813f64d6ce6c5caa4d9f6296bbe7eb 100644
--- a/arch/arm/src/stm32/stm32_freerun.c
+++ b/arch/arm/src/stm32/stm32_freerun.c
@@ -52,12 +52,6 @@
#ifdef CONFIG_STM32_FREERUN
-/****************************************************************************
- * Private Data
- ****************************************************************************/
-
-static struct stm32_freerun_s *g_freerun;
-
/****************************************************************************
* Private Functions
****************************************************************************/
@@ -81,9 +75,9 @@ static struct stm32_freerun_s *g_freerun;
****************************************************************************/
#ifndef CONFIG_CLOCK_TIMEKEEPING
-static int stm32_freerun_handler(int irq, void *context)
+static int stm32_freerun_handler(int irq, void *context, void *arg)
{
- struct stm32_freerun_s *freerun = g_freerun;
+ struct stm32_freerun_s *freerun = (struct stm32_freerun_s *) arg;
DEBUGASSERT(freerun != NULL && freerun->overflow < UINT32_MAX);
freerun->overflow++;
@@ -151,11 +145,10 @@ int stm32_freerun_initialize(struct stm32_freerun_s *freerun, int chan,
#ifndef CONFIG_CLOCK_TIMEKEEPING
freerun->overflow = 0;
- g_freerun = freerun;
/* Set up to receive the callback when the counter overflow occurs */
- STM32_TIM_SETISR(freerun->tch, stm32_freerun_handler, 0);
+ STM32_TIM_SETISR(freerun->tch, stm32_freerun_handler, freerun, 0);
#endif
/* Set timer period */
@@ -305,14 +298,13 @@ int stm32_freerun_uninitialize(struct stm32_freerun_s *freerun)
STM32_TIM_DISABLEINT(freerun->tch, 0);
STM32_TIM_SETMODE(freerun->tch, STM32_TIM_MODE_DISABLED);
- STM32_TIM_SETISR(freerun->tch, NULL, 0);
+ STM32_TIM_SETISR(freerun->tch, NULL, NULL, 0);
/* Free the timer */
stm32_tim_deinit(freerun->tch);
freerun->tch = NULL;
- g_freerun = NULL;
return OK;
}
diff --git a/arch/arm/src/stm32/stm32_gpio.c b/arch/arm/src/stm32/stm32_gpio.c
index 63d09e982e48ddafb33674c357827e3238fa39fb..9eb5fb9597b79c365f2b78dfe210cf809064ef4f 100644
--- a/arch/arm/src/stm32/stm32_gpio.c
+++ b/arch/arm/src/stm32/stm32_gpio.c
@@ -55,8 +55,8 @@
#include "stm32_gpio.h"
#if defined(CONFIG_STM32_STM32L15XX) || defined(CONFIG_STM32_STM32F20XX) || \
- defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F37XX) || \
- defined(CONFIG_STM32_STM32F40XX)
+ defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX) || \
+ defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F40XX)
# include "chip/stm32_syscfg.h"
#endif
@@ -427,8 +427,8 @@ int stm32_configgpio(uint32_t cfgset)
****************************************************************************/
#if defined(CONFIG_STM32_STM32L15XX) || defined(CONFIG_STM32_STM32F20XX) || \
- defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F37XX) || \
- defined(CONFIG_STM32_STM32F40XX)
+ defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX) || \
+ defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F40XX)
int stm32_configgpio(uint32_t cfgset)
{
uintptr_t base;
@@ -585,7 +585,8 @@ int stm32_configgpio(uint32_t cfgset)
setting = GPIO_OSPEED_50MHz;
break;
-#if !defined(CONFIG_STM32_STM32F30XX) && !defined(CONFIG_STM32_STM32F37XX)
+#if !defined(CONFIG_STM32_STM32F30XX) && !defined(CONFIG_STM32_STM32F33XX) && \
+ !defined(CONFIG_STM32_STM32F37XX)
case GPIO_SPEED_100MHz: /* 100 MHz High speed output */
setting = GPIO_OSPEED_100MHz;
break;
@@ -681,8 +682,8 @@ int stm32_unconfiggpio(uint32_t cfgset)
#if defined(CONFIG_STM32_STM32F10XX)
cfgset |= GPIO_INPUT | GPIO_CNF_INFLOAT | GPIO_MODE_INPUT;
#elif defined(CONFIG_STM32_STM32L15XX) || defined(CONFIG_STM32_STM32F20XX) || \
- defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F37XX) || \
- defined(CONFIG_STM32_STM32F40XX)
+ defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX) || \
+ defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F40XX)
cfgset |= GPIO_INPUT | GPIO_FLOAT;
#else
# error "Unsupported STM32 chip"
@@ -707,8 +708,8 @@ void stm32_gpiowrite(uint32_t pinset, bool value)
#if defined(CONFIG_STM32_STM32F10XX)
uint32_t offset;
#elif defined(CONFIG_STM32_STM32L15XX) || defined(CONFIG_STM32_STM32F20XX) || \
- defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F37XX) || \
- defined(CONFIG_STM32_STM32F40XX)
+ defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX) || \
+ defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F40XX)
uint32_t bit;
#endif
unsigned int port;
@@ -741,8 +742,8 @@ void stm32_gpiowrite(uint32_t pinset, bool value)
putreg32((1 << pin), base + offset);
#elif defined(CONFIG_STM32_STM32L15XX) || defined(CONFIG_STM32_STM32F20XX) || \
- defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F37XX) || \
- defined(CONFIG_STM32_STM32F40XX)
+ defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX) || \
+ defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F40XX)
if (value)
{
@@ -787,5 +788,6 @@ bool stm32_gpioread(uint32_t pinset)
pin = (pinset & GPIO_PIN_MASK) >> GPIO_PIN_SHIFT;
return ((getreg32(base + STM32_GPIO_IDR_OFFSET) & (1 << pin)) != 0);
}
+
return 0;
}
diff --git a/arch/arm/src/stm32/stm32_gpio.h b/arch/arm/src/stm32/stm32_gpio.h
index 34b49bf0d6da1d2dc9e2f5b31f167de6ca18114d..0385d1e9519344cb1e0472b2049b0d2e05267121 100644
--- a/arch/arm/src/stm32/stm32_gpio.h
+++ b/arch/arm/src/stm32/stm32_gpio.h
@@ -59,7 +59,8 @@
# include "chip/stm32f10xxx_gpio.h"
#elif defined(CONFIG_STM32_STM32F20XX)
# include "chip/stm32f20xxx_gpio.h"
-#elif defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F37XX)
+#elif defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX) || \
+ defined(CONFIG_STM32_STM32F37XX)
# include "chip/stm32f30xxx_gpio.h"
#elif defined(CONFIG_STM32_STM32F40XX)
# include "chip/stm32f40xxx_gpio.h"
@@ -201,8 +202,8 @@
#define GPIO_PIN15 (15 << GPIO_PIN_SHIFT)
#elif defined(CONFIG_STM32_STM32L15XX) || defined(CONFIG_STM32_STM32F20XX) || \
- defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F37XX) || \
- defined(CONFIG_STM32_STM32F40XX)
+ defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX) || \
+ defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F40XX)
/* Each port bit of the general-purpose I/O (GPIO) ports can be individually configured
* by software in several modes:
@@ -431,7 +432,7 @@ EXTERN const uint32_t g_gpiobase[STM32_NGPIO_PORTS];
* function, it must be unconfigured with stm32_unconfiggpio() with
* the same cfgset first before it can be set to non-alternative function.
*
- * Returns:
+ * Returned Value:
* OK on success
* ERROR on invalid port, or when pin is locked as ALT function.
*
@@ -452,7 +453,7 @@ int stm32_configgpio(uint32_t cfgset);
* operate in PWM mode could produce excessive on-board currents and trigger
* over-current/alarm function.
*
- * Returns:
+ * Returned Value:
* OK on success
* ERROR on invalid port
*
@@ -486,21 +487,21 @@ bool stm32_gpioread(uint32_t pinset);
* Description:
* Sets/clears GPIO based event and interrupt triggers.
*
- * Parameters:
+ * Input Parameters:
* - pinset: gpio pin configuration
* - rising/falling edge: enables
* - event: generate event when set
* - func: when non-NULL, generate interrupt
+ * - arg: Argument passed to the interrupt callback
*
- * Returns:
- * The previous value of the interrupt handler function pointer. This value may,
- * for example, be used to restore the previous handler when multiple handlers are
- * used.
+ * Returned Value:
+ * Zero (OK) on success; a negated errno value on failure indicating the
+ * nature of the failure.
*
************************************************************************************/
-xcpt_t stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
- bool event, xcpt_t func);
+int stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
+ bool event, xcpt_t func, void *arg);
/************************************************************************************
* Function: stm32_dumpgpio
diff --git a/arch/arm/src/stm32/stm32_i2c.c b/arch/arm/src/stm32/stm32_i2c.c
index 631ba665016b47887899c1c64574c0bf0ceeefc2..f4c97eca50643ed345a91c7b379864aaa5c4ceb9 100644
--- a/arch/arm/src/stm32/stm32_i2c.c
+++ b/arch/arm/src/stm32/stm32_i2c.c
@@ -230,7 +230,7 @@ struct stm32_i2c_config_s
uint32_t scl_pin; /* GPIO configuration for SCL as SCL */
uint32_t sda_pin; /* GPIO configuration for SDA as SDA */
#ifndef CONFIG_I2C_POLLED
- int (*isr)(int, void *); /* Interrupt handler */
+ int (*isr)(int, void *, void *); /* Interrupt handler */
uint32_t ev_irq; /* Event IRQ */
uint32_t er_irq; /* Error IRQ */
#endif
@@ -317,13 +317,13 @@ static int stm32_i2c_isr(struct stm32_i2c_priv_s * priv);
#ifndef CONFIG_I2C_POLLED
#ifdef CONFIG_STM32_I2C1
-static int stm32_i2c1_isr(int irq, void *context);
+static int stm32_i2c1_isr(int irq, void *context, FAR void *arg);
#endif
#ifdef CONFIG_STM32_I2C2
-static int stm32_i2c2_isr(int irq, void *context);
+static int stm32_i2c2_isr(int irq, void *context, FAR void *arg);
#endif
#ifdef CONFIG_STM32_I2C3
-static int stm32_i2c3_isr(int irq, void *context);
+static int stm32_i2c3_isr(int irq, void *context, FAR void *arg);
#endif
#endif /* !CONFIG_I2C_POLLED */
@@ -1468,7 +1468,7 @@ static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv)
#ifndef CONFIG_I2C_POLLED
#ifdef CONFIG_STM32_I2C1
-static int stm32_i2c1_isr(int irq, void *context)
+static int stm32_i2c1_isr(int irq, void *context, FAR void *arg)
{
return stm32_i2c_isr(&stm32_i2c1_priv);
}
@@ -1483,7 +1483,7 @@ static int stm32_i2c1_isr(int irq, void *context)
************************************************************************************/
#ifdef CONFIG_STM32_I2C2
-static int stm32_i2c2_isr(int irq, void *context)
+static int stm32_i2c2_isr(int irq, void *context, FAR void *arg)
{
return stm32_i2c_isr(&stm32_i2c2_priv);
}
@@ -1498,7 +1498,7 @@ static int stm32_i2c2_isr(int irq, void *context)
************************************************************************************/
#ifdef CONFIG_STM32_I2C3
-static int stm32_i2c3_isr(int irq, void *context)
+static int stm32_i2c3_isr(int irq, void *context, FAR void *arg)
{
return stm32_i2c_isr(&stm32_i2c3_priv);
}
@@ -1543,8 +1543,8 @@ static int stm32_i2c_init(FAR struct stm32_i2c_priv_s *priv)
/* Attach ISRs */
#ifndef CONFIG_I2C_POLLED
- irq_attach(priv->config->ev_irq, priv->config->isr);
- irq_attach(priv->config->er_irq, priv->config->isr);
+ irq_attach(priv->config->ev_irq, priv->config->isr, NULL);
+ irq_attach(priv->config->er_irq, priv->config->isr, NULL);
up_enable_irq(priv->config->ev_irq);
up_enable_irq(priv->config->er_irq);
#endif
diff --git a/arch/arm/src/stm32/stm32_i2c.h b/arch/arm/src/stm32/stm32_i2c.h
index 7274325f548abe305a77e800da04724a75853afd..f36ee952f55178cff12bc2a13fb95a6fb85a5182 100644
--- a/arch/arm/src/stm32/stm32_i2c.h
+++ b/arch/arm/src/stm32/stm32_i2c.h
@@ -44,7 +44,8 @@
#include
#include "chip.h"
-#if defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F37XX)
+#if defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F37XX) || \
+ defined(CONFIG_STM32_STM32F33XX)
# include "chip/stm32f30xxx_i2c.h"
#else
# include "chip/stm32_i2c.h"
diff --git a/arch/arm/src/stm32/stm32_i2c_alt.c b/arch/arm/src/stm32/stm32_i2c_alt.c
index 545a64733470691552df963e42f0af2f72d94560..f9a2905f0e1a3f743736d484c5b4e62a47e00f6a 100644
--- a/arch/arm/src/stm32/stm32_i2c_alt.c
+++ b/arch/arm/src/stm32/stm32_i2c_alt.c
@@ -257,7 +257,7 @@ struct stm32_i2c_config_s
uint32_t scl_pin; /* GPIO configuration for SCL as SCL */
uint32_t sda_pin; /* GPIO configuration for SDA as SDA */
#ifndef CONFIG_I2C_POLLED
- int (*isr)(int, void *); /* Interrupt handler */
+ int (*isr)(int, void *, void *); /* Interrupt handler */
uint32_t ev_irq; /* Event IRQ */
uint32_t er_irq; /* Error IRQ */
#endif
@@ -346,13 +346,13 @@ static int stm32_i2c_isr(struct stm32_i2c_priv_s * priv);
#ifndef CONFIG_I2C_POLLED
#ifdef CONFIG_STM32_I2C1
-static int stm32_i2c1_isr(int irq, void *context);
+static int stm32_i2c1_isr(int irq, void *context, FAR void *arg);
#endif
#ifdef CONFIG_STM32_I2C2
-static int stm32_i2c2_isr(int irq, void *context);
+static int stm32_i2c2_isr(int irq, void *context, FAR void *arg);
#endif
#ifdef CONFIG_STM32_I2C3
-static int stm32_i2c3_isr(int irq, void *context);
+static int stm32_i2c3_isr(int irq, void *context, FAR void *arg);
#endif
#endif /* !CONFIG_I2C_POLLED */
@@ -1899,7 +1899,7 @@ static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv)
#ifndef CONFIG_I2C_POLLED
#ifdef CONFIG_STM32_I2C1
-static int stm32_i2c1_isr(int irq, void *context)
+static int stm32_i2c1_isr(int irq, void *context, FAR void *arg)
{
return stm32_i2c_isr(&stm32_i2c1_priv);
}
@@ -1914,7 +1914,7 @@ static int stm32_i2c1_isr(int irq, void *context)
************************************************************************************/
#ifdef CONFIG_STM32_I2C2
-static int stm32_i2c2_isr(int irq, void *context)
+static int stm32_i2c2_isr(int irq, void *context, FAR void *arg)
{
return stm32_i2c_isr(&stm32_i2c2_priv);
}
@@ -1929,7 +1929,7 @@ static int stm32_i2c2_isr(int irq, void *context)
************************************************************************************/
#ifdef CONFIG_STM32_I2C3
-static int stm32_i2c3_isr(int irq, void *context)
+static int stm32_i2c3_isr(int irq, void *context, FAR void *arg)
{
return stm32_i2c_isr(&stm32_i2c3_priv);
}
@@ -1974,8 +1974,8 @@ static int stm32_i2c_init(FAR struct stm32_i2c_priv_s *priv)
/* Attach ISRs */
#ifndef CONFIG_I2C_POLLED
- irq_attach(priv->config->ev_irq, priv->config->isr);
- irq_attach(priv->config->er_irq, priv->config->isr);
+ irq_attach(priv->config->ev_irq, priv->config->isr, NULL);
+ irq_attach(priv->config->er_irq, priv->config->isr, NULL);
up_enable_irq(priv->config->ev_irq);
up_enable_irq(priv->config->er_irq);
#endif
diff --git a/arch/arm/src/stm32/stm32_irq.c b/arch/arm/src/stm32/stm32_irq.c
index ff40bf8d0331e80e79eb0bd17a1517697d36c27f..051c9829794730b96495714c5f918c994dfdd80e 100644
--- a/arch/arm/src/stm32/stm32_irq.c
+++ b/arch/arm/src/stm32/stm32_irq.c
@@ -161,7 +161,7 @@ static void stm32_dumpnvic(const char *msg, int irq)
****************************************************************************/
#ifdef CONFIG_DEBUG_FEATURES
-static int stm32_nmi(int irq, FAR void *context)
+static int stm32_nmi(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! NMI received\n");
@@ -169,7 +169,7 @@ static int stm32_nmi(int irq, FAR void *context)
return 0;
}
-static int stm32_busfault(int irq, FAR void *context)
+static int stm32_busfault(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Bus fault received: %08x\n", getreg32(NVIC_CFAULTS));
@@ -177,7 +177,7 @@ static int stm32_busfault(int irq, FAR void *context)
return 0;
}
-static int stm32_usagefault(int irq, FAR void *context)
+static int stm32_usagefault(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Usage fault received: %08x\n", getreg32(NVIC_CFAULTS));
@@ -185,7 +185,7 @@ static int stm32_usagefault(int irq, FAR void *context)
return 0;
}
-static int stm32_pendsv(int irq, FAR void *context)
+static int stm32_pendsv(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! PendSV received\n");
@@ -193,7 +193,7 @@ static int stm32_pendsv(int irq, FAR void *context)
return 0;
}
-static int stm32_dbgmonitor(int irq, FAR void *context)
+static int stm32_dbgmonitor(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Debug Monitor received\n");
@@ -201,7 +201,7 @@ static int stm32_dbgmonitor(int irq, FAR void *context)
return 0;
}
-static int stm32_reserved(int irq, FAR void *context)
+static int stm32_reserved(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Reserved interrupt\n");
@@ -376,8 +376,8 @@ void up_irqinitialize(void)
* under certain conditions.
*/
- irq_attach(STM32_IRQ_SVCALL, up_svcall);
- irq_attach(STM32_IRQ_HARDFAULT, up_hardfault);
+ irq_attach(STM32_IRQ_SVCALL, up_svcall, NULL);
+ irq_attach(STM32_IRQ_HARDFAULT, up_hardfault, NULL);
/* Set the priority of the SVCall interrupt */
@@ -393,22 +393,22 @@ void up_irqinitialize(void)
*/
#ifdef CONFIG_ARM_MPU
- irq_attach(STM32_IRQ_MEMFAULT, up_memfault);
+ irq_attach(STM32_IRQ_MEMFAULT, up_memfault, NULL);
up_enable_irq(STM32_IRQ_MEMFAULT);
#endif
/* Attach all other processor exceptions (except reset and sys tick) */
#ifdef CONFIG_DEBUG_FEATURES
- irq_attach(STM32_IRQ_NMI, stm32_nmi);
+ irq_attach(STM32_IRQ_NMI, stm32_nmi, NULL);
#ifndef CONFIG_ARM_MPU
- irq_attach(STM32_IRQ_MEMFAULT, up_memfault);
+ irq_attach(STM32_IRQ_MEMFAULT, up_memfault, NULL);
#endif
- irq_attach(STM32_IRQ_BUSFAULT, stm32_busfault);
- irq_attach(STM32_IRQ_USAGEFAULT, stm32_usagefault);
- irq_attach(STM32_IRQ_PENDSV, stm32_pendsv);
- irq_attach(STM32_IRQ_DBGMONITOR, stm32_dbgmonitor);
- irq_attach(STM32_IRQ_RESERVED, stm32_reserved);
+ irq_attach(STM32_IRQ_BUSFAULT, stm32_busfault, NULL);
+ irq_attach(STM32_IRQ_USAGEFAULT, stm32_usagefault, NULL);
+ irq_attach(STM32_IRQ_PENDSV, stm32_pendsv, NULL);
+ irq_attach(STM32_IRQ_DBGMONITOR, stm32_dbgmonitor, NULL);
+ irq_attach(STM32_IRQ_RESERVED, stm32_reserved, NULL);
#endif
stm32_dumpnvic("initial", NR_IRQS);
diff --git a/arch/arm/src/stm32/stm32_lowputc.c b/arch/arm/src/stm32/stm32_lowputc.c
index 0bffb74808abc06619be620f1c5fcf7583b2a5be..856879454a01aa9c78b81355f553d11ff5d6024a 100644
--- a/arch/arm/src/stm32/stm32_lowputc.c
+++ b/arch/arm/src/stm32/stm32_lowputc.c
@@ -62,7 +62,11 @@
#ifdef HAVE_CONSOLE
# if defined(CONFIG_USART1_SERIAL_CONSOLE)
# define STM32_CONSOLE_BASE STM32_USART1_BASE
-# define STM32_APBCLOCK STM32_PCLK2_FREQUENCY
+# if defined(CONFIG_STM32_STM32F33XX)
+# define STM32_APBCLOCK STM32_PCLK1_FREQUENCY /* Errata 2.5.1 */
+# else
+# define STM32_APBCLOCK STM32_PCLK2_FREQUENCY
+# endif
# define STM32_CONSOLE_APBREG STM32_RCC_APB2ENR
# define STM32_CONSOLE_APBEN RCC_APB2ENR_USART1EN
# define STM32_CONSOLE_BAUD CONFIG_USART1_BAUD
@@ -230,7 +234,8 @@
# define USART_CR1_PARITY_VALUE 0
# endif
-# if defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F37XX)
+# if defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX) || \
+ defined(CONFIG_STM32_STM32F37XX)
# define USART_CR1_CLRBITS\
(USART_CR1_UESM | USART_CR1_RE | USART_CR1_TE | USART_CR1_PS | \
USART_CR1_PCE | USART_CR1_WAKE | USART_CR1_M | USART_CR1_MME | \
@@ -252,7 +257,8 @@
# define USART_CR2_STOP2_VALUE 0
# endif
-# if defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F37XX)
+# if defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX) || \
+ defined(CONFIG_STM32_STM32F37XX)
# define USART_CR2_CLRBITS \
(USART_CR2_ADDM7 | USART_CR2_LBDL | USART_CR2_LBDIE | USART_CR2_LBCL | \
USART_CR2_CPHA | USART_CR2_CPOL | USART_CR2_CLKEN | USART_CR2_STOP_MASK | \
@@ -268,7 +274,8 @@
/* CR3 settings */
-# if defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F37XX)
+# if defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX) || \
+ defined(CONFIG_STM32_STM32F37XX)
# define USART_CR3_CLRBITS \
(USART_CR3_EIE | USART_CR3_IREN | USART_CR3_IRLP | USART_CR3_HDSEL | \
@@ -288,7 +295,8 @@
/* Calculate USART BAUD rate divider */
-# if defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F37XX)
+# if defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX) || \
+ defined(CONFIG_STM32_STM32F37XX)
/* Baud rate for standard USART (SPI mode included):
*
@@ -563,8 +571,8 @@ void stm32_lowsetup(void)
}
#elif defined(CONFIG_STM32_STM32L15XX) || defined(CONFIG_STM32_STM32F20XX) || \
- defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F37XX) || \
- defined(CONFIG_STM32_STM32F40XX)
+ defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX) || \
+ defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F40XX)
void stm32_lowsetup(void)
{
diff --git a/arch/arm/src/stm32/stm32_ltdc.c b/arch/arm/src/stm32/stm32_ltdc.c
index ebaeff8d4704afbf9222aa2112d69e71905f7297..2573730172c3902b17a23815eaea7512f119d8bb 100644
--- a/arch/arm/src/stm32/stm32_ltdc.c
+++ b/arch/arm/src/stm32/stm32_ltdc.c
@@ -550,7 +550,7 @@ static void stm32_ltdc_periphconfig(void);
static void stm32_ltdc_bgcolor(uint32_t rgb);
static void stm32_ltdc_dither(bool enable, uint8_t red,
uint8_t green, uint8_t blue);
-static int stm32_ltdcirq(int irq, void *context);
+static int stm32_ltdcirq(int irq, void *context, FAR void *arg);
static int stm32_ltdc_waitforirq(void);
static int stm32_ltdc_reload(uint8_t value, bool waitvblank);
@@ -1128,7 +1128,7 @@ static void stm32_ltdc_irqctrl(uint32_t setirqs, uint32_t clrirqs)
*
****************************************************************************/
-static int stm32_ltdcirq(int irq, void *context)
+static int stm32_ltdcirq(int irq, void *context, FAR void *arg)
{
FAR struct stm32_interrupt_s *priv = &g_interrupt;
@@ -1298,7 +1298,7 @@ static void stm32_global_configure(void)
/* Attach LTDC interrupt vector */
- (void)irq_attach(g_interrupt.irq, stm32_ltdcirq);
+ (void)irq_attach(g_interrupt.irq, stm32_ltdcirq, NULL);
/* Enable the IRQ at the NVIC */
diff --git a/arch/arm/src/stm32/stm32_oneshot.c b/arch/arm/src/stm32/stm32_oneshot.c
index 92f57e928ccd1b80c88e86036230daa74d24a02d..ab8d2a4034802e7437896fa1f8cf7017dd344193 100644
--- a/arch/arm/src/stm32/stm32_oneshot.c
+++ b/arch/arm/src/stm32/stm32_oneshot.c
@@ -58,29 +58,7 @@
* Private Function Prototypes
****************************************************************************/
-static int stm32_oneshot_handler(struct stm32_oneshot_s *oneshot);
-static int stm32_oneshot1_handler(int irq, void *context);
-#if CONFIG_STM32_ONESHOT_MAXTIMERS > 1
-static int stm32_oneshot2_handler(int irq, void *context);
-#endif
-#if CONFIG_STM32_ONESHOT_MAXTIMERS > 2
-static int stm32_oneshot3_handler(int irq, void *context);
-#endif
-#if CONFIG_STM32_ONESHOT_MAXTIMERS > 3
-static int stm32_oneshot4_handler(int irq, void *context);
-#endif
-#if CONFIG_STM32_ONESHOT_MAXTIMERS > 4
-static int stm32_oneshot5_handler(int irq, void *context);
-#endif
-#if CONFIG_STM32_ONESHOT_MAXTIMERS > 5
-static int stm32_oneshot6_handler(int irq, void *context);
-#endif
-#if CONFIG_STM32_ONESHOT_MAXTIMERS > 6
-static int stm32_oneshot7_handler(int irq, void *context);
-#endif
-#if CONFIG_STM32_ONESHOT_MAXTIMERS > 7
-static int stm32_oneshot8_handler(int irq, void *context);
-#endif
+static int stm32_oneshot_handler(int irg_num, void * context, void *arg);
/****************************************************************************
* Private Data
@@ -88,34 +66,6 @@ static int stm32_oneshot8_handler(int irq, void *context);
static struct stm32_oneshot_s *g_oneshot[CONFIG_STM32_ONESHOT_MAXTIMERS];
-#if CONFIG_STM32_ONESHOT_MAXTIMERS > 1
-static const xcpt_t g_callbacks[CONFIG_STM32_ONESHOT_MAXTIMERS] =
-{
- stm32_oneshot1_handler,
-#if CONFIG_STM32_ONESHOT_MAXTIMERS > 1
- stm32_oneshot2_handler,
-#endif
-#if CONFIG_STM32_ONESHOT_MAXTIMERS > 2
- stm32_oneshot3_handler,
-#endif
-#if CONFIG_STM32_ONESHOT_MAXTIMERS > 3
- stm32_oneshot4_handler,
-#endif
-#if CONFIG_STM32_ONESHOT_MAXTIMERS > 4
- stm32_oneshot5_handler,
-#endif
-#if CONFIG_STM32_ONESHOT_MAXTIMERS > 5
- stm32_oneshot6_handler,
-#endif
-#if CONFIG_STM32_ONESHOT_MAXTIMERS > 6
- stm32_oneshot7_handler,
-#endif
-#if CONFIG_STM32_ONESHOT_MAXTIMERS > 7
- stm32_oneshot8_handler,
-#endif
-};
-#endif
-
/****************************************************************************
* Private Functions
****************************************************************************/
@@ -136,8 +86,9 @@ static const xcpt_t g_callbacks[CONFIG_STM32_ONESHOT_MAXTIMERS] =
*
****************************************************************************/
-static int stm32_oneshot_handler(struct stm32_oneshot_s *oneshot)
+static int stm32_oneshot_handler(int irg_num, void * context, void *arg)
{
+ struct stm32_oneshot_s * oneshot = (struct stm32_oneshot_s *) arg;
oneshot_handler_t oneshot_handler;
void *oneshot_arg;
@@ -148,7 +99,7 @@ static int stm32_oneshot_handler(struct stm32_oneshot_s *oneshot)
* Disable the TC now and disable any further interrupts.
*/
- STM32_TIM_SETISR(oneshot->tch, NULL, 0);
+ STM32_TIM_SETISR(oneshot->tch, NULL, NULL, 0);
STM32_TIM_DISABLEINT(oneshot->tch, 0);
STM32_TIM_SETMODE(oneshot->tch, STM32_TIM_MODE_DISABLED);
STM32_TIM_ACKINT(oneshot->tch, 0);
@@ -168,84 +119,6 @@ static int stm32_oneshot_handler(struct stm32_oneshot_s *oneshot)
return OK;
}
-/****************************************************************************
- * Name: stm32_oneshot[N]_handler
- *
- * Description:
- * Timer interrupt callbacks. When a oneshot timer interrupt expires,
- * one of these functions will be called. These functions will forward
- * the call to the nextlevel up.
- *
- * Input Parameters:
- * Standard interrupt handler arguments.
- *
- * Returned Value:
- * Always returns OK
- *
- ****************************************************************************/
-
-static int stm32_oneshot1_handler(int irq, void *context)
-{
- DEBUGASSERT(g_oneshot[0] != NULL);
- return stm32_oneshot_handler(g_oneshot[0]);
-}
-
-#if CONFIG_STM32_ONESHOT_MAXTIMERS > 1
-static int stm32_oneshot2_handler(int irq, void *context)
-{
- DEBUGASSERT(g_oneshot[1] != NULL);
- return stm32_oneshot_handler(g_oneshot[1]);
-}
-#endif
-
-#if CONFIG_STM32_ONESHOT_MAXTIMERS > 2
-static int stm32_oneshot3_handler(int irq, void *context)
-{
- DEBUGASSERT(g_oneshot[2] != NULL);
- return stm32_oneshot_handler(g_oneshot[2]);
-}
-#endif
-
-#if CONFIG_STM32_ONESHOT_MAXTIMERS > 3
-static int stm32_oneshot4_handler(int irq, void *context)
-{
- DEBUGASSERT(g_oneshot[3] != NULL);
- return stm32_oneshot_handler(g_oneshot[3]);
-}
-#endif
-
-#if CONFIG_STM32_ONESHOT_MAXTIMERS > 4
-static int stm32_oneshot5_handler(int irq, void *context)
-{
- DEBUGASSERT(g_oneshot[4] != NULL);
- return stm32_oneshot_handler(g_oneshot[4]);
-}
-#endif
-
-#if CONFIG_STM32_ONESHOT_MAXTIMERS > 5
-static int stm32_oneshot6_handler(int irq, void *context)
-{
- DEBUGASSERT(g_oneshot[6] != NULL);
- return stm32_oneshot_handler(g_oneshot[5]);
-}
-#endif
-
-#if CONFIG_STM32_ONESHOT_MAXTIMERS > 6
-static int stm32_oneshot7_handler(int irq, void *context)
-{
- DEBUGASSERT(g_oneshot[7] != NULL);
- return stm32_oneshot_handler(g_oneshot[6]);
-}
-#endif
-
-#if CONFIG_STM32_ONESHOT_MAXTIMERS > 7
-static int stm32_oneshot8_handler(int irq, void *context)
-{
- DEBUGASSERT(g_oneshot[0] != NULL);
- return stm32_oneshot_handler(g_oneshot[7]);
-}
-#endif
-
/****************************************************************************
* Name: stm32_allocate_handler
*
@@ -442,11 +315,7 @@ int stm32_oneshot_start(struct stm32_oneshot_s *oneshot,
/* Set up to receive the callback when the interrupt occurs */
-#if CONFIG_STM32_ONESHOT_MAXTIMERS > 1
- STM32_TIM_SETISR(oneshot->tch, g_callbacks[oneshot->cbndx], 0);
-#else
- STM32_TIM_SETISR(oneshot->tch, stm32_oneshot1_handler, 0);
-#endif
+ STM32_TIM_SETISR(oneshot->tch, stm32_oneshot_handler, oneshot, 0);
/* Set timer period */
@@ -539,7 +408,7 @@ int stm32_oneshot_cancel(struct stm32_oneshot_s *oneshot,
/* Now we can disable the interrupt and stop the timer. */
STM32_TIM_DISABLEINT(oneshot->tch, 0);
- STM32_TIM_SETISR(oneshot->tch, NULL, 0);
+ STM32_TIM_SETISR(oneshot->tch, NULL, NULL, 0);
STM32_TIM_SETMODE(oneshot->tch, STM32_TIM_MODE_DISABLED);
oneshot->running = false;
diff --git a/arch/arm/src/stm32/stm32_otgfsdev.c b/arch/arm/src/stm32/stm32_otgfsdev.c
index 2fcbf599f0667f939d9bb7d9df48660598d7c130..47b212c3c289c6eb87cd136c060f756662da50ba 100644
--- a/arch/arm/src/stm32/stm32_otgfsdev.c
+++ b/arch/arm/src/stm32/stm32_otgfsdev.c
@@ -619,7 +619,7 @@ static inline void stm32_otginterrupt(FAR struct stm32_usbdev_s *priv);
/* First level interrupt processing */
-static int stm32_usbinterrupt(int irq, FAR void *context);
+static int stm32_usbinterrupt(int irq, FAR void *context, FAR void *arg);
/* Endpoint operations *********************************************************/
/* Global OUT NAK controls */
@@ -3554,7 +3554,7 @@ static inline void stm32_otginterrupt(FAR struct stm32_usbdev_s *priv)
*
****************************************************************************/
-static int stm32_usbinterrupt(int irq, FAR void *context)
+static int stm32_usbinterrupt(int irq, FAR void *context, FAR void *arg)
{
/* At present, there is only a single OTG FS device support. Hence it is
* pre-allocated as g_otgfsdev. However, in most code, the private data
@@ -5502,7 +5502,7 @@ void up_usbinitialize(void)
/* Attach the OTG FS interrupt handler */
- ret = irq_attach(STM32_IRQ_OTGFS, stm32_usbinterrupt);
+ ret = irq_attach(STM32_IRQ_OTGFS, stm32_usbinterrupt, NULL);
if (ret < 0)
{
uerr("ERROR: irq_attach failed\n", ret);
diff --git a/arch/arm/src/stm32/stm32_otgfshost.c b/arch/arm/src/stm32/stm32_otgfshost.c
index 3feb0924c0d7af9c94e0937117f905c7839293b9..0adea86e7476de9107fb9b0e7db31c56fb9caa8a 100644
--- a/arch/arm/src/stm32/stm32_otgfshost.c
+++ b/arch/arm/src/stm32/stm32_otgfshost.c
@@ -404,7 +404,7 @@ static inline void stm32_gint_ipxfrisr(FAR struct stm32_usbhost_s *priv);
/* First level, global interrupt handler */
-static int stm32_gint_isr(int irq, FAR void *context);
+static int stm32_gint_isr(int irq, FAR void *context, FAR void *arg);
/* Interrupt controls */
@@ -3431,7 +3431,7 @@ static inline void stm32_gint_ipxfrisr(FAR struct stm32_usbhost_s *priv)
*
****************************************************************************/
-static int stm32_gint_isr(int irq, FAR void *context)
+static int stm32_gint_isr(int irq, FAR void *context, FAR void *arg)
{
/* At present, there is only support for a single OTG FS host. Hence it is
* pre-allocated as g_usbhost. However, in most code, the private data
@@ -5302,7 +5302,7 @@ FAR struct usbhost_connection_s *stm32_otgfshost_initialize(int controller)
/* Attach USB host controller interrupt handler */
- if (irq_attach(STM32_IRQ_OTGFS, stm32_gint_isr) != 0)
+ if (irq_attach(STM32_IRQ_OTGFS, stm32_gint_isr, NULL) != 0)
{
usbhost_trace1(OTGFS_TRACE1_IRQATTACH, 0);
return NULL;
diff --git a/arch/arm/src/stm32/stm32_otghsdev.c b/arch/arm/src/stm32/stm32_otghsdev.c
index 97d71aa0aa900daa6243fc78d40ea1c87e079a13..97474f2f435b6f908bb86a38a73232da9e1a2a5f 100644
--- a/arch/arm/src/stm32/stm32_otghsdev.c
+++ b/arch/arm/src/stm32/stm32_otghsdev.c
@@ -572,7 +572,7 @@ static inline void stm32_otginterrupt(FAR struct stm32_usbdev_s *priv);
/* First level interrupt processing */
-static int stm32_usbinterrupt(int irq, FAR void *context);
+static int stm32_usbinterrupt(int irq, FAR void *context, FAR void *arg);
/* Endpoint operations *********************************************************/
/* Global OUT NAK controls */
@@ -3498,7 +3498,7 @@ static inline void stm32_otginterrupt(FAR struct stm32_usbdev_s *priv)
*
****************************************************************************/
-static int stm32_usbinterrupt(int irq, FAR void *context)
+static int stm32_usbinterrupt(int irq, FAR void *context, FAR void *arg)
{
/* At present, there is only a single OTG HS device support. Hence it is
* pre-allocated as g_otghsdev. However, in most code, the private data
@@ -5438,7 +5438,7 @@ void up_usbinitialize(void)
/* Attach the OTG HS interrupt handler */
- ret = irq_attach(STM32_IRQ_OTGHS, stm32_usbinterrupt);
+ ret = irq_attach(STM32_IRQ_OTGHS, stm32_usbinterrupt, NULL);
if (ret < 0)
{
uerr("ERROR: irq_attach failed\n", ret);
diff --git a/arch/arm/src/stm32/stm32_otghshost.c b/arch/arm/src/stm32/stm32_otghshost.c
index 9dee00ae45cc8ccadbfad7c8fa9e2f26b67f4078..c3c8be579add26328d55e4b48c66168e2344c9db 100644
--- a/arch/arm/src/stm32/stm32_otghshost.c
+++ b/arch/arm/src/stm32/stm32_otghshost.c
@@ -409,7 +409,7 @@ static inline void stm32_gint_ipxfrisr(FAR struct stm32_usbhost_s *priv);
/* First level, global interrupt handler */
-static int stm32_gint_isr(int irq, FAR void *context);
+static int stm32_gint_isr(int irq, FAR void *context, FAR void *arg);
/* Interrupt controls */
@@ -3436,7 +3436,7 @@ static inline void stm32_gint_ipxfrisr(FAR struct stm32_usbhost_s *priv)
*
****************************************************************************/
-static int stm32_gint_isr(int irq, FAR void *context)
+static int stm32_gint_isr(int irq, FAR void *context, FAR void *arg)
{
/* At present, there is only support for a single OTG HS host. Hence it is
* pre-allocated as g_usbhost. However, in most code, the private data
@@ -5307,7 +5307,7 @@ FAR struct usbhost_connection_s *stm32_otghshost_initialize(int controller)
/* Attach USB host controller interrupt handler */
- if (irq_attach(STM32_IRQ_OTGHS, stm32_gint_isr) != 0)
+ if (irq_attach(STM32_IRQ_OTGHS, stm32_gint_isr, NULL) != 0)
{
usbhost_trace1(OTGHS_TRACE1_IRQATTACH, 0);
return NULL;
diff --git a/arch/arm/src/stm32/stm32_pwm.c b/arch/arm/src/stm32/stm32_pwm.c
index 83a1a4cd7dfa206918fde1da91c89b306fce320e..85ed3554fc956e29017bc57454536ab1512c5500 100644
--- a/arch/arm/src/stm32/stm32_pwm.c
+++ b/arch/arm/src/stm32/stm32_pwm.c
@@ -352,10 +352,10 @@ static int pwm_timer(FAR struct stm32_pwmtimer_s *priv,
#if defined(CONFIG_PWM_PULSECOUNT) && (defined(CONFIG_STM32_TIM1_PWM) || defined(CONFIG_STM32_TIM8_PWM))
static int pwm_interrupt(struct stm32_pwmtimer_s *priv);
#if defined(CONFIG_STM32_TIM1_PWM)
-static int pwm_tim1interrupt(int irq, void *context);
+static int pwm_tim1interrupt(int irq, void *context, FAR void *arg);
#endif
#if defined(CONFIG_STM32_TIM8_PWM)
-static int pwm_tim8interrupt(int irq, void *context);
+static int pwm_tim8interrupt(int irq, void *context, FAR void *arg);
#endif
static uint8_t pwm_pulsecount(uint32_t count);
#endif
@@ -1139,6 +1139,8 @@ static void pwm_dumpregs(struct stm32_pwmtimer_s *priv, FAR const char *msg)
pwm_getreg(priv, STM32_GTIM_CCMR2_OFFSET));
}
+ /* REVISIT: CNT and ARR may be 32-bits wide */
+
pwminfo(" CCER: %04x CNT: %04x PSC: %04x ARR: %04x\n",
pwm_getreg(priv, STM32_GTIM_CCER_OFFSET),
pwm_getreg(priv, STM32_GTIM_CNT_OFFSET),
@@ -1152,6 +1154,8 @@ static void pwm_dumpregs(struct stm32_pwmtimer_s *priv, FAR const char *msg)
pwm_getreg(priv, STM32_ATIM_BDTR_OFFSET));
}
+ /* REVISIT: CCR1-CCR4 may be 32-bits wide */
+
if (priv->timid == 16 || priv->timid == 17)
{
pwminfo(" CCR1: %04x\n",
@@ -1981,14 +1985,14 @@ static int pwm_interrupt(struct stm32_pwmtimer_s *priv)
****************************************************************************/
#if defined(CONFIG_PWM_PULSECOUNT) && defined(CONFIG_STM32_TIM1_PWM)
-static int pwm_tim1interrupt(int irq, void *context)
+static int pwm_tim1interrupt(int irq, void *context, FAR void *arg)
{
return pwm_interrupt(&g_pwm1dev);
}
#endif
#if defined(CONFIG_PWM_PULSECOUNT) && defined(CONFIG_STM32_TIM8_PWM)
-static int pwm_tim8interrupt(int irq, void *context)
+static int pwm_tim8interrupt(int irq, void *context, FAR void *arg)
{
return pwm_interrupt(&g_pwm8dev);
}
@@ -2599,7 +2603,7 @@ FAR struct pwm_lowerhalf_s *stm32_pwminitialize(int timer)
/* Attach but disable the TIM1 update interrupt */
#ifdef CONFIG_PWM_PULSECOUNT
- irq_attach(lower->irq, pwm_tim1interrupt);
+ irq_attach(lower->irq, pwm_tim1interrupt, NULL);
up_disable_irq(lower->irq);
#endif
break;
@@ -2636,7 +2640,7 @@ FAR struct pwm_lowerhalf_s *stm32_pwminitialize(int timer)
/* Attach but disable the TIM8 update interrupt */
#ifdef CONFIG_PWM_PULSECOUNT
- irq_attach(lower->irq, pwm_tim8interrupt);
+ irq_attach(lower->irq, pwm_tim8interrupt, NULL);
up_disable_irq(lower->irq);
#endif
break;
diff --git a/arch/arm/src/stm32/stm32_qencoder.c b/arch/arm/src/stm32/stm32_qencoder.c
index 69b0f9b2e0731d55374f29088ee62081434446a0..e2245075b9142e0ca7f1815e02f4e64f73cb7f38 100644
--- a/arch/arm/src/stm32/stm32_qencoder.c
+++ b/arch/arm/src/stm32/stm32_qencoder.c
@@ -1,7 +1,7 @@
/************************************************************************************
* arch/arm/src/stm32/stm32_qencoder.c
*
- * Copyright (C) 2012 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2012, 2017 Gregory Nutt. All rights reserved.
* Authors: Gregory Nutt
* Diego Sanchez
*
@@ -65,32 +65,6 @@
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
-/* Clocking *************************************************************************/
-/* The CLKOUT value should not exceed the CLKIN value */
-
-#if defined(CONFIG_STM32_TIM1_QE) && CONFIG_STM32_TIM1_QECLKOUT > STM32_APB2_TIM1_CLKIN
-# warning "CONFIG_STM32_TIM1_QECLKOUT exceeds STM32_APB2_TIM1_CLKIN"
-#endif
-
-#if defined(CONFIG_STM32_TIM2_QE) && CONFIG_STM32_TIM2_QECLKOUT > STM32_APB1_TIM2_CLKIN
-# warning "CONFIG_STM32_TIM2_QECLKOUT exceeds STM32_APB2_TIM2_CLKIN"
-#endif
-
-#if defined(CONFIG_STM32_TIM3_QE) && CONFIG_STM32_TIM3_QECLKOUT > STM32_APB1_TIM3_CLKIN
-# warning "CONFIG_STM32_TIM3_QECLKOUT exceeds STM32_APB2_TIM3_CLKIN"
-#endif
-
-#if defined(CONFIG_STM32_TIM4_QE) && CONFIG_STM32_TIM4_QECLKOUT > STM32_APB1_TIM4_CLKIN
-# warning "CONFIG_STM32_TIM4_QECLKOUT exceeds STM32_APB2_TIM4_CLKIN"
-#endif
-
-#if defined(CONFIG_STM32_TIM5_QE) && CONFIG_STM32_TIM5_QECLKOUT > STM32_APB1_TIM5_CLKIN
-# warning "CONFIG_STM32_TIM5_QECLKOUT exceeds STM32_APB2_TIM5_CLKIN"
-#endif
-
-#if defined(CONFIG_STM32_TIM8_QE) && CONFIG_STM32_TIM8_QECLKOUT > STM32_APB2_TIM8_CLKIN
-# warning "CONFIG_STM32_TIM8_QECLKOUT exceeds STM32_APB2_TIM8_CLKIN"
-#endif
/* Timers ***************************************************************************/
@@ -269,21 +243,22 @@
struct stm32_qeconfig_s
{
- uint8_t timid; /* Timer ID {1,2,3,4,5,8} */
- uint8_t irq; /* Timer update IRQ */
+ uint8_t timid; /* Timer ID {1,2,3,4,5,8} */
+ uint8_t irq; /* Timer update IRQ */
#ifdef HAVE_MIXEDWIDTH_TIMERS
- uint8_t width; /* Timer width (16- or 32-bits) */
+ uint8_t width; /* Timer width (16- or 32-bits) */
#endif
#ifdef CONFIG_STM32_STM32F10XX
- uint16_t ti1cfg; /* TI1 input pin configuration (16-bit encoding) */
- uint16_t ti2cfg; /* TI2 input pin configuration (16-bit encoding) */
+ uint16_t ti1cfg; /* TI1 input pin configuration (16-bit encoding) */
+ uint16_t ti2cfg; /* TI2 input pin configuration (16-bit encoding) */
#else
- uint32_t ti1cfg; /* TI1 input pin configuration (20-bit encoding) */
- uint32_t ti2cfg; /* TI2 input pin configuration (20-bit encoding) */
+ uint32_t ti1cfg; /* TI1 input pin configuration (20-bit encoding) */
+ uint32_t ti2cfg; /* TI2 input pin configuration (20-bit encoding) */
#endif
- uint32_t base; /* Register base address */
- uint32_t psc; /* Timer input clock prescaler */
- xcpt_t handler; /* Interrupt handler for this IRQ */
+ uintptr_t regaddr; /* RCC clock enable register address */
+ uint32_t enable; /* RCC clock enable bit */
+ uint32_t base; /* Register base address */
+ uint32_t psc; /* Timer input clock prescaler */
};
/* Overall, RAM-based state structure */
@@ -328,25 +303,7 @@ static FAR struct stm32_lowerhalf_s *stm32_tim2lower(int tim);
/* Interrupt handling */
#ifdef HAVE_16BIT_TIMERS
-static int stm32_interrupt(FAR struct stm32_lowerhalf_s *priv);
-#if defined(CONFIG_STM32_TIM1_QE) && TIM1_BITWIDTH == 16
-static int stm32_tim1interrupt(int irq, FAR void *context);
-#endif
-#if defined(CONFIG_STM32_TIM2_QE) && TIM2_BITWIDTH == 16
-static int stm32_tim2interrupt(int irq, FAR void *context);
-#endif
-#if defined(CONFIG_STM32_TIM3_QE) && TIM3_BITWIDTH == 16
-static int stm32_tim3interrupt(int irq, FAR void *context);
-#endif
-#if defined(CONFIG_STM32_TIM4_QE) && TIM4_BITWIDTH == 16
-static int stm32_tim4interrupt(int irq, FAR void *context);
-#endif
-#if defined(CONFIG_STM32_TIM5_QE) && TIM5_BITWIDTH == 16
-static int stm32_tim5interrupt(int irq, FAR void *context);
-#endif
-#if defined(CONFIG_STM32_TIM8_QE) && TIM8_BITWIDTH == 16
-static int stm32_tim8interrupt(int irq, FAR void *context);
-#endif
+static int stm32_interrupt(int irq, FAR void *context, FAR void *arg);
#endif
/* Lower-half Quadrature Encoder Driver Methods */
@@ -381,13 +338,12 @@ static const struct stm32_qeconfig_s g_tim1config =
#ifdef HAVE_MIXEDWIDTH_TIMERS
.width = TIM1_BITWIDTH,
#endif
+ .regaddr = STM32_RCC_APB2ENR,
+ .enable = RCC_APB2ENR_TIM1EN,
.base = STM32_TIM1_BASE,
- .psc = (STM32_APB2_TIM1_CLKIN / CONFIG_STM32_TIM1_QECLKOUT) - 1,
+ .psc = CONFIG_STM32_TIM1_QEPSC,
.ti1cfg = GPIO_TIM1_CH1IN,
.ti2cfg = GPIO_TIM1_CH2IN,
-#if TIM1_BITWIDTH == 16
- .handler = stm32_tim1interrupt,
-#endif
};
static struct stm32_lowerhalf_s g_tim1lower =
@@ -407,13 +363,12 @@ static const struct stm32_qeconfig_s g_tim2config =
#ifdef HAVE_MIXEDWIDTH_TIMERS
.width = TIM2_BITWIDTH,
#endif
+ .regaddr = STM32_RCC_APB1ENR,
+ .enable = RCC_APB1ENR_TIM2EN,
.base = STM32_TIM2_BASE,
- .psc = (STM32_APB1_TIM2_CLKIN / CONFIG_STM32_TIM2_QECLKOUT) - 1,
+ .psc = CONFIG_STM32_TIM2_QEPSC,
.ti1cfg = GPIO_TIM2_CH1IN,
.ti2cfg = GPIO_TIM2_CH2IN,
-#if TIM2_BITWIDTH == 16
- .handler = stm32_tim2interrupt,
-#endif
};
static struct stm32_lowerhalf_s g_tim2lower =
@@ -433,13 +388,12 @@ static const struct stm32_qeconfig_s g_tim3config =
#ifdef HAVE_MIXEDWIDTH_TIMERS
.width = TIM3_BITWIDTH,
#endif
+ .regaddr = STM32_RCC_APB1ENR,
+ .enable = RCC_APB1ENR_TIM3EN,
.base = STM32_TIM3_BASE,
- .psc = (STM32_APB1_TIM3_CLKIN / CONFIG_STM32_TIM3_QECLKOUT) - 1,
+ .psc = CONFIG_STM32_TIM3_QEPSC,
.ti1cfg = GPIO_TIM3_CH1IN,
.ti2cfg = GPIO_TIM3_CH2IN,
-#if TIM3_BITWIDTH == 16
- .handler = stm32_tim3interrupt,
-#endif
};
static struct stm32_lowerhalf_s g_tim3lower =
@@ -459,13 +413,12 @@ static const struct stm32_qeconfig_s g_tim4config =
#ifdef HAVE_MIXEDWIDTH_TIMERS
.width = TIM4_BITWIDTH,
#endif
+ .regaddr = STM32_RCC_APB1ENR,
+ .enable = RCC_APB1ENR_TIM4EN,
.base = STM32_TIM4_BASE,
- .psc = (STM32_APB1_TIM4_CLKIN / CONFIG_STM32_TIM4_QECLKOUT) - 1,
+ .psc = CONFIG_STM32_TIM4_QEPSC,
.ti1cfg = GPIO_TIM4_CH1IN,
.ti2cfg = GPIO_TIM4_CH2IN,
-#if TIM4_BITWIDTH == 16
- .handler = stm32_tim4interrupt,
-#endif
};
static struct stm32_lowerhalf_s g_tim4lower =
@@ -485,13 +438,12 @@ static const struct stm32_qeconfig_s g_tim5config =
#ifdef HAVE_MIXEDWIDTH_TIMERS
.width = TIM5_BITWIDTH,
#endif
+ .regaddr = STM32_RCC_APB1ENR,
+ .enable = RCC_APB1ENR_TIM5EN,
.base = STM32_TIM5_BASE,
- .psc = (STM32_APB1_TIM5_CLKIN / CONFIG_STM32_TIM5_QECLKOUT) - 1,
+ .psc = CONFIG_STM32_TIM5_QEPSC,
.ti1cfg = GPIO_TIM5_CH1IN,
.ti2cfg = GPIO_TIM5_CH2IN,
-#if TIM5_BITWIDTH == 16
- .handler = stm32_tim5interrupt,
-#endif
};
static struct stm32_lowerhalf_s g_tim5lower =
@@ -511,13 +463,12 @@ static const struct stm32_qeconfig_s g_tim8config =
#ifdef HAVE_MIXEDWIDTH_TIMERS
.width = TIM8_BITWIDTH,
#endif
+ .regaddr = STM32_RCC_APB2ENR,
+ .enable = RCC_APB2ENR_TIM8EN,
.base = STM32_TIM8_BASE,
- .psc = (STM32_APB2_TIM8_CLKIN / CONFIG_STM32_TIM8_QECLKOUT) - 1,
+ .psc = CONFIG_STM32_TIM8_QEPSC,
.ti1cfg = GPIO_TIM8_CH1IN,
.ti2cfg = GPIO_TIM8_CH2IN,
-#if TIM8_BITWIDTH == 16
- .handler = stm32_tim8interrupt,
-#endif
};
static struct stm32_lowerhalf_s g_tim8lower =
@@ -725,10 +676,13 @@ static FAR struct stm32_lowerhalf_s *stm32_tim2lower(int tim)
************************************************************************************/
#ifdef HAVE_16BIT_TIMERS
-static int stm32_interrupt(FAR struct stm32_lowerhalf_s *priv)
+static int stm32_interrupt(int irq, FAR void *context, FAR void *arg)
{
+ FAR struct stm32_lowerhalf_s *priv = (FAR struct stm32_lowerhalf_s *)arg;
uint16_t regval;
+ DEBUGASSERT(priv != NULL);
+
/* Verify that this is an update interrupt. Nothing else is expected. */
regval = stm32_getreg16(priv, STM32_GTIM_SR_OFFSET);
@@ -756,56 +710,6 @@ static int stm32_interrupt(FAR struct stm32_lowerhalf_s *priv)
}
#endif
-/************************************************************************************
- * Name: stm32_intNinterrupt
- *
- * Description:
- * TIMN interrupt handler
- *
- ************************************************************************************/
-
-#if defined(CONFIG_STM32_TIM1_QE) && TIM1_BITWIDTH == 16
-static int stm32_tim1interrupt(int irq, FAR void *context)
-{
- return stm32_interrupt(&g_tim1lower);
-}
-#endif
-
-#if defined(CONFIG_STM32_TIM2_QE) && TIM2_BITWIDTH == 16
-static int stm32_tim2interrupt(int irq, FAR void *context)
-{
- return stm32_interrupt(&g_tim2lower);
-}
-#endif
-
-#if defined(CONFIG_STM32_TIM3_QE) && TIM3_BITWIDTH == 16
-static int stm32_tim3interrupt(int irq, FAR void *context)
-{
- return stm32_interrupt(&g_tim3lower);
-}
-#endif
-
-#if defined(CONFIG_STM32_TIM4_QE) && TIM4_BITWIDTH == 16
-static int stm32_tim4interrupt(int irq, FAR void *context)
-{
- return stm32_interrupt(&g_tim4lower);
-}
-#endif
-
-#if defined(CONFIG_STM32_TIM5_QE) && TIM5_BITWIDTH == 16
-static int stm32_tim5interrupt(int irq, FAR void *context)
-{
- return stm32_interrupt(&g_tim5lower);
-}
-#endif
-
-#if defined(CONFIG_STM32_TIM8_QE) && TIM8_BITWIDTH == 16
-static int stm32_tim8interrupt(int irq, FAR void *context)
-{
- return stm32_interrupt(&g_tim8lower);
-}
-#endif
-
/************************************************************************************
* Name: stm32_setup
*
@@ -820,8 +724,8 @@ static int stm32_setup(FAR struct qe_lowerhalf_s *lower)
{
FAR struct stm32_lowerhalf_s *priv = (FAR struct stm32_lowerhalf_s *)lower;
uint16_t dier;
- uint16_t smcr;
- uint16_t ccmr1;
+ uint32_t smcr;
+ uint32_t ccmr1;
uint16_t ccer;
uint16_t cr1;
#ifdef HAVE_16BIT_TIMERS
@@ -829,7 +733,9 @@ static int stm32_setup(FAR struct qe_lowerhalf_s *lower)
int ret;
#endif
- /* NOTE: Clocking should have been enabled in the low-level RCC logic at boot-up */
+ /* Enable clocking to the timer */
+
+ modifyreg32(priv->config->regaddr, 0, priv->config->enable);
/* Timer base configuration */
@@ -859,10 +765,14 @@ static int stm32_setup(FAR struct qe_lowerhalf_s *lower)
stm32_putreg16(priv, STM32_GTIM_ARR_OFFSET, 0xffff);
#endif
- /* Set the timer prescaler value. The clock input value (CLKIN) is based on the
- * peripheral clock (PCLK) and a multiplier. These CLKIN values are provided in
- * the board.h file. The prescaler value is then that CLKIN value divided by the
- * configured CLKOUT value (minus one)
+ /* Set the timer prescaler value.
+ *
+ * If we are doing precise shaft positioning, each qe pulse is important.
+ * So the STM32 has direct config control on the pulse count prescaler.
+ * This input clock just limits the incoming pulse rate, which should be
+ * lower than the peripheral clock due to resynchronization, but it is the
+ * responsibility of the system designer to decide the correct prescaler
+ * value, because it has a direct influence on the encoder resolution.
*/
stm32_putreg16(priv, STM32_GTIM_PSC_OFFSET, (uint16_t)priv->config->psc);
@@ -889,10 +799,10 @@ static int stm32_setup(FAR struct qe_lowerhalf_s *lower)
/* Set the encoder Mode 3 */
- smcr = stm32_getreg16(priv, STM32_GTIM_SMCR_OFFSET);
+ smcr = stm32_getreg32(priv, STM32_GTIM_SMCR_OFFSET);
smcr &= ~GTIM_SMCR_SMS_MASK;
smcr |= GTIM_SMCR_ENCMD3;
- stm32_putreg16(priv, STM32_GTIM_SMCR_OFFSET, smcr);
+ stm32_putreg32(priv, STM32_GTIM_SMCR_OFFSET, smcr);
/* TI1 Channel Configuration */
/* Disable the Channel 1: Reset the CC1E Bit */
@@ -901,8 +811,8 @@ static int stm32_setup(FAR struct qe_lowerhalf_s *lower)
ccer &= ~GTIM_CCER_CC1E;
stm32_putreg16(priv, STM32_GTIM_CCER_OFFSET, ccer);
- ccmr1 = stm32_getreg16(priv, STM32_GTIM_CCMR1_OFFSET);
- ccer = stm32_getreg16(priv, STM32_GTIM_CCER_OFFSET);
+ ccmr1 = stm32_getreg32(priv, STM32_GTIM_CCMR1_OFFSET);
+ ccer = stm32_getreg16(priv, STM32_GTIM_CCER_OFFSET);
/* Select the Input IC1=TI1 and set the filter fSAMPLING=fDTS/4, N=6 */
@@ -917,17 +827,17 @@ static int stm32_setup(FAR struct qe_lowerhalf_s *lower)
/* Write to TIM CCMR1 and CCER registers */
- stm32_putreg16(priv, STM32_GTIM_CCMR1_OFFSET, ccmr1);
+ stm32_putreg32(priv, STM32_GTIM_CCMR1_OFFSET, ccmr1);
stm32_putreg16(priv, STM32_GTIM_CCER_OFFSET, ccer);
/* Set the Input Capture Prescaler value: Capture performed each time an
* edge is detected on the capture input.
*/
- ccmr1 = stm32_getreg16(priv, STM32_GTIM_CCMR1_OFFSET);
+ ccmr1 = stm32_getreg32(priv, STM32_GTIM_CCMR1_OFFSET);
ccmr1 &= ~GTIM_CCMR1_IC1PSC_MASK;
ccmr1 |= (GTIM_CCMR_ICPSC_NOPSC << GTIM_CCMR1_IC1PSC_SHIFT);
- stm32_putreg16(priv, STM32_GTIM_CCMR1_OFFSET, ccmr1);
+ stm32_putreg32(priv, STM32_GTIM_CCMR1_OFFSET, ccmr1);
/* TI2 Channel Configuration */
/* Disable the Channel 2: Reset the CC2E Bit */
@@ -936,7 +846,7 @@ static int stm32_setup(FAR struct qe_lowerhalf_s *lower)
ccer &= ~GTIM_CCER_CC2E;
stm32_putreg16(priv, STM32_GTIM_CCER_OFFSET, ccer);
- ccmr1 = stm32_getreg16(priv, STM32_GTIM_CCMR1_OFFSET);
+ ccmr1 = stm32_getreg32(priv, STM32_GTIM_CCMR1_OFFSET);
ccer = stm32_getreg16(priv, STM32_GTIM_CCER_OFFSET);
/* Select the Input IC2=TI2 and set the filter fSAMPLING=fDTS/4, N=6 */
@@ -952,21 +862,21 @@ static int stm32_setup(FAR struct qe_lowerhalf_s *lower)
/* Write to TIM CCMR1 and CCER registers */
- stm32_putreg16(priv, STM32_GTIM_CCMR1_OFFSET, ccmr1);
+ stm32_putreg32(priv, STM32_GTIM_CCMR1_OFFSET, ccmr1);
stm32_putreg16(priv, STM32_GTIM_CCER_OFFSET, ccer);
/* Set the Input Capture Prescaler value: Capture performed each time an
* edge is detected on the capture input.
*/
- ccmr1 = stm32_getreg16(priv, STM32_GTIM_CCMR1_OFFSET);
+ ccmr1 = stm32_getreg32(priv, STM32_GTIM_CCMR1_OFFSET);
ccmr1 &= ~GTIM_CCMR1_IC2PSC_MASK;
ccmr1 |= (GTIM_CCMR_ICPSC_NOPSC << GTIM_CCMR1_IC2PSC_SHIFT);
- stm32_putreg16(priv, STM32_GTIM_CCMR1_OFFSET, ccmr1);
+ stm32_putreg32(priv, STM32_GTIM_CCMR1_OFFSET, ccmr1);
/* Disable the update interrupt */
- dier = stm32_getreg16(priv, STM32_GTIM_DIER_OFFSET);
+ dier = stm32_getreg16(priv, STM32_GTIM_DIER_OFFSET);
dier &= ~GTIM_DIER_UIE;
stm32_putreg16(priv, STM32_GTIM_DIER_OFFSET, dier);
@@ -979,7 +889,7 @@ static int stm32_setup(FAR struct qe_lowerhalf_s *lower)
{
/* Attach the interrupt handler */
- ret = irq_attach(priv->config->irq, priv->config->handler);
+ ret = irq_attach(priv->config->irq, stm32_interrupt, priv);
if (ret < 0)
{
stm32_shutdown(lower);
@@ -1130,6 +1040,10 @@ static int stm32_shutdown(FAR struct qe_lowerhalf_s *lower)
sninfo("regaddr: %08x resetbit: %08x\n", regaddr, resetbit);
stm32_dumpregs(priv, "After stop");
+ /* Disable clocking to the timer */
+
+ modifyreg32(priv->config->regaddr, priv->config->enable, 0);
+
/* Put the TI1 GPIO pin back to its default state */
pincfg = priv->config->ti1cfg & (GPIO_PORT_MASK | GPIO_PIN_MASK);
@@ -1239,6 +1153,8 @@ static int stm32_ioctl(FAR struct qe_lowerhalf_s *lower, int cmd, unsigned long
{
/* No ioctl commands supported */
+ /* TODO add an IOCTL to control the encoder pulse count prescaler */
+
return -ENOTTY;
}
@@ -1284,7 +1200,7 @@ int stm32_qeinitialize(FAR const char *devpath, int tim)
return -EBUSY;
}
- /* Register the priv-half driver */
+ /* Register the upper-half driver */
ret = qe_register(devpath, (FAR struct qe_lowerhalf_s *)priv);
if (ret < 0)
diff --git a/arch/arm/src/stm32/stm32_rcc.c b/arch/arm/src/stm32/stm32_rcc.c
index 7cae4be7449b72dd28c6143872a820c1941b1bed..3cb57ae6a0e26c91c8c368a4f23c52c9c7c47cf0 100644
--- a/arch/arm/src/stm32/stm32_rcc.c
+++ b/arch/arm/src/stm32/stm32_rcc.c
@@ -82,6 +82,8 @@
# include "stm32f20xxx_rcc.c"
#elif defined(CONFIG_STM32_STM32F30XX)
# include "stm32f30xxx_rcc.c"
+#elif defined(CONFIG_STM32_STM32F33XX)
+# include "stm32f33xxx_rcc.c"
#elif defined(CONFIG_STM32_STM32F37XX)
# include "stm32f37xxx_rcc.c"
#elif defined(CONFIG_STM32_STM32F40XX)
diff --git a/arch/arm/src/stm32/stm32_rcc.h b/arch/arm/src/stm32/stm32_rcc.h
index a4939221e8f2e1c2a138e1be4792c40f1df1f38a..d331ab90b6429525f38a03ca46990bc2a621588b 100644
--- a/arch/arm/src/stm32/stm32_rcc.h
+++ b/arch/arm/src/stm32/stm32_rcc.h
@@ -53,6 +53,8 @@
# include "chip/stm32f20xxx_rcc.h"
#elif defined(CONFIG_STM32_STM32F30XX)
# include "chip/stm32f30xxx_rcc.h"
+#elif defined(CONFIG_STM32_STM32F33XX)
+# include "chip/stm32f33xxx_rcc.h"
#elif defined(CONFIG_STM32_STM32F37XX)
# include "chip/stm32f37xxx_rcc.h"
#elif defined(CONFIG_STM32_STM32F40XX)
diff --git a/arch/arm/src/stm32/stm32_rng.c b/arch/arm/src/stm32/stm32_rng.c
index 8dde6a6c35c564dbeaf53b36cd8f98e17772f516..ccbbd96dd72ce689895e499919cf0a8f9b1aca5a 100644
--- a/arch/arm/src/stm32/stm32_rng.c
+++ b/arch/arm/src/stm32/stm32_rng.c
@@ -61,7 +61,7 @@
****************************************************************************/
static int stm32_rng_initialize(void);
-static int stm32_interrupt(int irq, void *context);
+static int stm32_interrupt(int irq, void *context, FAR void *arg);
static void stm32_enable(void);
static void stm32_disable(void);
static ssize_t stm32_read(struct file *filep, char *buffer, size_t);
@@ -113,7 +113,7 @@ static int stm32_rng_initialize()
sem_init(&g_rngdev.rd_devsem, 0, 1);
- if (irq_attach(STM32_IRQ_RNG, stm32_interrupt))
+ if (irq_attach(STM32_IRQ_RNG, stm32_interrupt, NULL))
{
/* We could not attach the ISR to the interrupt */
@@ -152,7 +152,7 @@ static void stm32_disable()
putreg32(regval, STM32_RNG_CR);
}
-static int stm32_interrupt(int irq, void *context)
+static int stm32_interrupt(int irq, void *context, FAR void *arg)
{
uint32_t rngsr;
uint32_t data;
diff --git a/arch/arm/src/stm32/stm32_rtcc.c b/arch/arm/src/stm32/stm32_rtcc.c
index d27a8ddd387270e3bdf85b23ac3f3c921948dce0..b7155854965cb572de63fc65e3209937c3253782 100644
--- a/arch/arm/src/stm32/stm32_rtcc.c
+++ b/arch/arm/src/stm32/stm32_rtcc.c
@@ -768,7 +768,7 @@ int up_rtc_initialize(void)
/* Then attach the ALARM interrupt handler */
- irq_attach(STM32_IRQ_RTC_WKUP, rtc_interrupt);
+ irq_attach(STM32_IRQ_RTC_WKUP, rtc_interrupt, NULL);
up_enable_irq(STM32_IRQ_RTC_WKUP);
#endif
diff --git a/arch/arm/src/stm32/stm32_rtcounter.c b/arch/arm/src/stm32/stm32_rtcounter.c
index 1c90be9c14db1b904138d62d34dae3b17b44a422..9a046f8318c7cbb0d01b73724bd4ceee64bdd950 100644
--- a/arch/arm/src/stm32/stm32_rtcounter.c
+++ b/arch/arm/src/stm32/stm32_rtcounter.c
@@ -324,7 +324,7 @@ static inline void stm32_rtc_breakout(FAR const struct timespec *tp,
************************************************************************************/
#if defined(CONFIG_RTC_HIRES) || defined(CONFIG_RTC_ALARM)
-static int stm32_rtc_interrupt(int irq, void *context)
+static int stm32_rtc_interrupt(int irq, void *context, FAR void *arg)
{
uint16_t source = getreg16(STM32_RTC_CRL);
@@ -406,7 +406,7 @@ int up_rtc_initialize(void)
/* Configure RTC interrupt to catch overflow and alarm interrupts. */
#if defined(CONFIG_RTC_HIRES) || defined(CONFIG_RTC_ALARM)
- irq_attach(STM32_IRQ_RTC, stm32_rtc_interrupt);
+ irq_attach(STM32_IRQ_RTC, stm32_rtc_interrupt, NULL);
up_enable_irq(STM32_IRQ_RTC);
#endif
diff --git a/arch/arm/src/stm32/stm32_sdadc.c b/arch/arm/src/stm32/stm32_sdadc.c
index a16cade9cd211a7c086121a7618267c0e62dfa81..67a769801bbeb2557fae1b29488822bae8d5166f 100644
--- a/arch/arm/src/stm32/stm32_sdadc.c
+++ b/arch/arm/src/stm32/stm32_sdadc.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/stm32/stm32_sdadc.c
*
- * Copyright (C) 2011, 2013, 2015-2016 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2011, 2013, 2015-2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2016 Studelec. All rights reserved.
* Authors: Gregory Nutt
* Marc Rechté
@@ -59,6 +59,7 @@
#include
#include
#include
+#include
#include "up_internal.h"
#include "up_arch.h"
@@ -92,6 +93,7 @@
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
+
/* RCC reset ****************************************************************/
#define STM32_RCC_RSTR STM32_RCC_APB2RSTR
@@ -133,7 +135,6 @@ struct stm32_dev_s
#ifdef SDADC_HAVE_TIMER
uint8_t trigger; /* Timer trigger selection: see SDADCx_JEXTSEL_TIMxx */
#endif
- xcpt_t isr; /* Interrupt handler for this SDADC block */
uint32_t base; /* Base address of registers unique to this SDADC
* block */
#ifdef SDADC_HAVE_TIMER
@@ -180,16 +181,7 @@ static void sdadc_rccreset(FAR struct stm32_dev_s *priv, bool reset);
/* ADC Interrupt Handler */
-static int sdadc_interrupt(FAR struct adc_dev_s *dev);
-#if defined(CONFIG_STM32_SDADC1)
-static int sdadc1_interrupt(int irq, FAR void *context);
-#endif
-#if defined(CONFIG_STM32_SDADC2)
-static int sdadc2_interrupt(int irq, FAR void *context);
-#endif
-#if defined(CONFIG_STM32_SDADC3)
-static int sdadc3_interrupt(int irq, FAR void *context);
-#endif
+static int sdadc_interrupt(int irq, FAR void *context, FAR void *arg);
/* ADC Driver Methods */
@@ -239,7 +231,6 @@ static const struct adc_ops_s g_sdadcops =
static struct stm32_dev_s g_sdadcpriv1 =
{
.irq = STM32_IRQ_SDADC1,
- .isr = sdadc1_interrupt,
.intf = 1,
.base = STM32_SDADC1_BASE,
.refv = SDADC1_REFV,
@@ -269,8 +260,6 @@ static struct adc_dev_s g_sdadcdev1 =
static struct stm32_dev_s g_sdadcpriv2 =
{
.irq = STM32_IRQ_SDADC2,
- .isr = sdadc2_interrupt,
- .intf = 2,
.base = STM32_SDADC2_BASE,
.refv = SDADC2_REFV,
#ifdef SDADC2_HAVE_TIMER
@@ -299,8 +288,6 @@ static struct adc_dev_s g_sdadcdev2 =
static struct stm32_dev_s g_sdadcpriv3 =
{
.irq = STM32_IRQ_SDADC3,
- .isr = sdadc3_interrupt,
- .intf = 3,
.base = STM32_SDADC3_BASE,
.refv = SDADC3_REFV,
#ifdef SDADC3_HAVE_TIMER
@@ -996,7 +983,7 @@ static int sdadc_setup(FAR struct adc_dev_s *dev)
{
/* Attach the SDADC interrupt */
- ret = irq_attach(priv->irq, priv->isr);
+ ret = irq_attach(priv->irq, sdadc_interrupt, dev);
if (ret < 0)
{
ainfo("irq_attach failed: %d\n", ret);
@@ -1006,7 +993,7 @@ static int sdadc_setup(FAR struct adc_dev_s *dev)
#else
/* Attach the SDADC interrupt */
- ret = irq_attach(priv->irq, priv->isr);
+ ret = irq_attach(priv->irq, sdadc_interrupt, dev);
if (ret < 0)
{
ainfo("irq_attach failed: %d\n", ret);
@@ -1218,14 +1205,18 @@ static int sdadc_ioctl(FAR struct adc_dev_s *dev, int cmd, unsigned long arg)
*
****************************************************************************/
-static int sdadc_interrupt(FAR struct adc_dev_s *dev)
+static int sdadc_interrupt(int irq, FAR void *context, FAR void *arg)
{
- FAR struct stm32_dev_s *priv = (FAR struct stm32_dev_s *)dev->ad_priv;
+ FAR struct adc_dev_s *dev = (FAR struct adc_dev_s *)arg;
+ FAR struct stm32_dev_s *priv;
uint32_t regval;
uint32_t pending;
int32_t data;
uint8_t chan;
+ DEBUGASSERT(dev != NULL && dev->ad_priv != NULL);
+ priv = (FAR struct stm32_dev_s *)dev->ad_priv;
+
regval = sdadc_getreg(priv, STM32_SDADC_ISR_OFFSET);
pending = regval & SDADC_ISR_ALLINTS;
if (pending == 0)
@@ -1296,75 +1287,6 @@ static int sdadc_interrupt(FAR struct adc_dev_s *dev)
return OK;
}
-/****************************************************************************
- * Name: adc1_interrupt
- *
- * Description:
- * ADC interrupt handler SDADC1
- *
- * Input Parameters:
- * irq - The IRQ number that generated the interrupt.
- * context - Architecture specific register save information.
- *
- * Returned Value:
- *
- ****************************************************************************/
-
-#if defined(CONFIG_STM32_SDADC1)
-static int sdadc1_interrupt(int irq, FAR void *context)
-{
- sdadc_interrupt(&g_sdadcdev1);
-
- return OK;
-}
-#endif
-
-/****************************************************************************
- * Name: adc2_interrupt
- *
- * Description:
- * ADC interrupt handler SDADC2
- *
- * Input Parameters:
- * irq - The IRQ number that generated the interrupt.
- * context - Architecture specific register save information.
- *
- * Returned Value:
- *
- ****************************************************************************/
-
-#if defined(CONFIG_STM32_SDADC2)
-static int sdadc2_interrupt(int irq, FAR void *context)
-{
- sdadc_interrupt(&g_sdadcdev2);
-
- return OK;
-}
-#endif
-
-/****************************************************************************
- * Name: adc3_interrupt
- *
- * Description:
- * ADC interrupt handler SDADC3
- *
- * Input Parameters:
- * irq - The IRQ number that generated the interrupt.
- * context - Architecture specific register save information.
- *
- * Returned Value:
- *
- ****************************************************************************/
-
-#if defined(CONFIG_STM32_SDADC3)
-static int sdadc3_interrupt(int irq, FAR void *context)
-{
- sdadc_interrupt(&g_sdadcdev3);
-
- return OK;
-}
-#endif
-
/****************************************************************************
* Public Functions
****************************************************************************/
diff --git a/arch/arm/src/stm32/stm32_sdio.c b/arch/arm/src/stm32/stm32_sdio.c
index 68ca6122c813cc334f667312a0f43315b1362306..01d533ba704c169177ddbd75b43558e18d438109 100644
--- a/arch/arm/src/stm32/stm32_sdio.c
+++ b/arch/arm/src/stm32/stm32_sdio.c
@@ -416,9 +416,9 @@ static void stm32_endtransfer(struct stm32_dev_s *priv, sdio_eventset_t wkupeven
/* Interrupt Handling *******************************************************/
-static int stm32_interrupt(int irq, void *context);
+static int stm32_interrupt(int irq, void *context, void *arg);
#ifdef CONFIG_MMCSD_SDIOWAIT_WRCOMPLETE
-static int stm32_rdyinterrupt(int irq, void *context);
+static int stm32_rdyinterrupt(int irq, void *context, void *arg);
#endif
/* SDIO interface methods ***************************************************/
@@ -668,14 +668,16 @@ static void stm32_configwaitints(struct stm32_dev_s *priv, uint32_t waitmask,
/* Arm the SDIO_D Ready and install Isr */
- stm32_gpiosetevent(pinset, true, false, false, stm32_rdyinterrupt);
+ (void)stm32_gpiosetevent(pinset, true, false, false,
+ stm32_rdyinterrupt, priv);
}
/* Disarm SDIO_D ready */
if ((wkupevent & SDIOWAIT_WRCOMPLETE) != 0)
{
- stm32_gpiosetevent(GPIO_SDIO_D0, false, false, false , NULL);
+ (void)stm32_gpiosetevent(GPIO_SDIO_D0, false, false, false,
+ NULL, NULL);
stm32_configgpio(GPIO_SDIO_D0);
}
#endif
@@ -1315,9 +1317,9 @@ static void stm32_endtransfer(struct stm32_dev_s *priv, sdio_eventset_t wkupeven
****************************************************************************/
#ifdef CONFIG_MMCSD_SDIOWAIT_WRCOMPLETE
-static int stm32_rdyinterrupt(int irq, void *context)
+static int stm32_rdyinterrupt(int irq, void *context, FAR void *arg)
{
- struct stm32_dev_s *priv = &g_sdiodev;
+ struct stm32_dev_s *priv = (struct stm32_dev_s *)arg;
stm32_endwait(priv, SDIOWAIT_WRCOMPLETE);
return OK;
}
@@ -1337,7 +1339,7 @@ static int stm32_rdyinterrupt(int irq, void *context)
*
****************************************************************************/
-static int stm32_interrupt(int irq, void *context)
+static int stm32_interrupt(int irq, void *context, FAR void *arg)
{
struct stm32_dev_s *priv = &g_sdiodev;
uint32_t enabled;
@@ -1768,7 +1770,7 @@ static int stm32_attach(FAR struct sdio_dev_s *dev)
/* Attach the SDIO interrupt handler */
- ret = irq_attach(STM32_IRQ_SDIO, stm32_interrupt);
+ ret = irq_attach(STM32_IRQ_SDIO, stm32_interrupt, NULL);
if (ret == OK)
{
diff --git a/arch/arm/src/stm32/stm32_serial.c b/arch/arm/src/stm32/stm32_serial.c
index 8f774838da6316c40ca6766ca23041e49e9fa5d3..a6a2d07b51bb51b584b4b731f40c24a6e54e76d6 100644
--- a/arch/arm/src/stm32/stm32_serial.c
+++ b/arch/arm/src/stm32/stm32_serial.c
@@ -151,7 +151,8 @@
# endif
# elif defined(CONFIG_STM32_STM32L15XX) || defined(CONFIG_STM32_STM32F10XX) || \
- defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F30XX)
+ defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX) || \
+ defined(CONFIG_STM32_STM32F37XX)
# if defined(CONFIG_USART1_RXDMA) || defined(CONFIG_USART2_RXDMA) || \
defined(CONFIG_USART3_RXDMA)
@@ -188,7 +189,8 @@
# ifndef CONFIG_USART_DMAPRIO
# if defined(CONFIG_STM32_STM32L15XX) || defined(CONFIG_STM32_STM32F10XX) || \
- defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F37XX)
+ defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX) || \
+ defined(CONFIG_STM32_STM32F37XX)
# define CONFIG_USART_DMAPRIO DMA_CCR_PRIMED
# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX)
# define CONFIG_USART_DMAPRIO DMA_SCR_PRIMED
@@ -197,7 +199,8 @@
# endif
# endif
# if defined(CONFIG_STM32_STM32L15XX) || defined(CONFIG_STM32_STM32F10XX) || \
- defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F37XX)
+ defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX) || \
+ defined(CONFIG_STM32_STM32F37XX)
# if (CONFIG_USART_DMAPRIO & ~DMA_CCR_PL_MASK) != 0
# error "Illegal value for CONFIG_USART_DMAPRIO"
# endif
@@ -312,8 +315,6 @@ struct up_dev_s
const unsigned int rxdma_channel; /* DMA channel assigned */
#endif
- int (*const vector)(int irq, void *context); /* Interrupt handler */
-
/* RX DMA state */
#ifdef SERIAL_HAVE_DMA
@@ -338,7 +339,7 @@ static int up_setup(struct uart_dev_s *dev);
static void up_shutdown(struct uart_dev_s *dev);
static int up_attach(struct uart_dev_s *dev);
static void up_detach(struct uart_dev_s *dev);
-static int up_interrupt_common(struct up_dev_s *dev);
+static int up_interrupt(int irq, void *context, void *arg);
static int up_ioctl(struct file *filep, int cmd, unsigned long arg);
#ifndef SERIAL_HAVE_ONLY_DMA
static int up_receive(struct uart_dev_s *dev, unsigned int *status);
@@ -370,31 +371,6 @@ static int up_pm_prepare(struct pm_callback_s *cb, int domain,
enum pm_state_e pmstate);
#endif
-#ifdef CONFIG_STM32_USART1_SERIALDRIVER
-static int up_interrupt_usart1(int irq, void *context);
-#endif
-#ifdef CONFIG_STM32_USART2_SERIALDRIVER
-static int up_interrupt_usart2(int irq, void *context);
-#endif
-#ifdef CONFIG_STM32_USART3_SERIALDRIVER
-static int up_interrupt_usart3(int irq, void *context);
-#endif
-#ifdef CONFIG_STM32_UART4_SERIALDRIVER
-static int up_interrupt_uart4(int irq, void *context);
-#endif
-#ifdef CONFIG_STM32_UART5_SERIALDRIVER
-static int up_interrupt_uart5(int irq, void *context);
-#endif
-#ifdef CONFIG_STM32_USART6_SERIALDRIVER
-static int up_interrupt_usart6(int irq, void *context);
-#endif
-#ifdef CONFIG_STM32_UART7_SERIALDRIVER
-static int up_interrupt_uart7(int irq, void *context);
-#endif
-#ifdef CONFIG_STM32_UART8_SERIALDRIVER
-static int up_interrupt_uart8(int irq, void *context);
-#endif
-
/****************************************************************************
* Private Data
****************************************************************************/
@@ -540,7 +516,11 @@ static struct up_dev_s g_usart1priv =
.bits = CONFIG_USART1_BITS,
.stopbits2 = CONFIG_USART1_2STOP,
.baud = CONFIG_USART1_BAUD,
+#if defined(CONFIG_STM32_STM32F33XX)
+ .apbclock = STM32_PCLK1_FREQUENCY, /* Errata 2.5.1 */
+#else
.apbclock = STM32_PCLK2_FREQUENCY,
+#endif
.usartbase = STM32_USART1_BASE,
.tx_gpio = GPIO_USART1_TX,
.rx_gpio = GPIO_USART1_RX,
@@ -556,7 +536,6 @@ static struct up_dev_s g_usart1priv =
.rxdma_channel = DMAMAP_USART1_RX,
.rxfifo = g_usart1rxfifo,
#endif
- .vector = up_interrupt_usart1,
#ifdef CONFIG_USART1_RS485
.rs485_dir_gpio = GPIO_USART1_RS485_DIR,
@@ -618,7 +597,6 @@ static struct up_dev_s g_usart2priv =
.rxdma_channel = DMAMAP_USART2_RX,
.rxfifo = g_usart2rxfifo,
#endif
- .vector = up_interrupt_usart2,
#ifdef CONFIG_USART2_RS485
.rs485_dir_gpio = GPIO_USART2_RS485_DIR,
@@ -680,7 +658,6 @@ static struct up_dev_s g_usart3priv =
.rxdma_channel = DMAMAP_USART3_RX,
.rxfifo = g_usart3rxfifo,
#endif
- .vector = up_interrupt_usart3,
#ifdef CONFIG_USART3_RS485
.rs485_dir_gpio = GPIO_USART3_RS485_DIR,
@@ -746,7 +723,6 @@ static struct up_dev_s g_uart4priv =
.rxdma_channel = DMAMAP_UART4_RX,
.rxfifo = g_uart4rxfifo,
#endif
- .vector = up_interrupt_uart4,
#ifdef CONFIG_UART4_RS485
.rs485_dir_gpio = GPIO_UART4_RS485_DIR,
@@ -812,7 +788,6 @@ static struct up_dev_s g_uart5priv =
.rxdma_channel = DMAMAP_UART5_RX,
.rxfifo = g_uart5rxfifo,
#endif
- .vector = up_interrupt_uart5,
#ifdef CONFIG_UART5_RS485
.rs485_dir_gpio = GPIO_UART5_RS485_DIR,
@@ -874,7 +849,6 @@ static struct up_dev_s g_usart6priv =
.rxdma_channel = DMAMAP_USART6_RX,
.rxfifo = g_usart6rxfifo,
#endif
- .vector = up_interrupt_usart6,
#ifdef CONFIG_USART6_RS485
.rs485_dir_gpio = GPIO_USART6_RS485_DIR,
@@ -936,7 +910,6 @@ static struct up_dev_s g_uart7priv =
.rxdma_channel = DMAMAP_UART7_RX,
.rxfifo = g_uart7rxfifo,
#endif
- .vector = up_interrupt_uart7,
#ifdef CONFIG_UART7_RS485
.rs485_dir_gpio = GPIO_UART7_RS485_DIR,
@@ -998,7 +971,6 @@ static struct up_dev_s g_uart8priv =
.rxdma_channel = DMAMAP_UART8_RX,
.rxfifo = g_uart8rxfifo,
#endif
- .vector = up_interrupt_uart8,
#ifdef CONFIG_UART8_RS485
.rs485_dir_gpio = GPIO_UART8_RS485_DIR,
@@ -1173,7 +1145,8 @@ static int up_dma_nextrx(struct up_dev_s *priv)
static void up_set_format(struct uart_dev_s *dev)
{
struct up_dev_s *priv = (struct up_dev_s *)dev->priv;
-#if defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F37XX)
+#if defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX) || \
+ defined(CONFIG_STM32_STM32F37XX)
uint32_t usartdiv8;
#else
uint32_t usartdiv32;
@@ -1187,7 +1160,8 @@ static void up_set_format(struct uart_dev_s *dev)
regval = up_serialin(priv, STM32_USART_CR1_OFFSET);
-#if defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F37XX)
+#if defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX)|| \
+ defined(CONFIG_STM32_STM32F37XX)
/* This first implementation is for U[S]ARTs that support oversampling
* by 8 in additional to the standard oversampling by 16.
* With baud rate of fCK / Divider for oversampling by 16.
@@ -1735,7 +1709,7 @@ static int up_attach(struct uart_dev_s *dev)
/* Attach and enable the IRQ */
- ret = irq_attach(priv->irq, priv->vector);
+ ret = irq_attach(priv->irq, up_interrupt, priv);
if (ret == OK)
{
/* Enable the interrupt (RX and TX interrupts are still disabled
@@ -1744,6 +1718,7 @@ static int up_attach(struct uart_dev_s *dev)
up_enable_irq(priv->irq);
}
+
return ret;
}
@@ -1765,7 +1740,7 @@ static void up_detach(struct uart_dev_s *dev)
}
/****************************************************************************
- * Name: up_interrupt_common
+ * Name: up_interrupt
*
* Description:
* This is the USART interrupt handler. It will be invoked when an
@@ -1776,11 +1751,14 @@ static void up_detach(struct uart_dev_s *dev)
*
****************************************************************************/
-static int up_interrupt_common(struct up_dev_s *priv)
+static int up_interrupt(int irq, void *context, void *arg)
{
+ struct up_dev_s *priv = (struct up_dev_s *)arg;
int passes;
bool handled;
+ DEBUGASSERT(priv != NULL);
+
/* Report serial activity to the power management logic */
#if defined(CONFIG_PM) && CONFIG_PM_SERIAL_ACTIVITY > 0
@@ -1855,7 +1833,8 @@ static int up_interrupt_common(struct up_dev_s *priv)
else if ((priv->sr & (USART_SR_ORE | USART_SR_NE | USART_SR_FE)) != 0)
{
-#if defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F37XX)
+#if defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX) || \
+ defined(CONFIG_STM32_STM32F37XX)
/* These errors are cleared by writing the corresponding bit to the
* interrupt clear register (ICR).
*/
@@ -2501,70 +2480,6 @@ static bool up_txready(struct uart_dev_s *dev)
return ((up_serialin(priv, STM32_USART_SR_OFFSET) & USART_SR_TXE) != 0);
}
-/****************************************************************************
- * Name: up_interrupt_u[s]art[n]
- *
- * Description:
- * Interrupt handlers for U[S]ART[n] where n=1,..,6.
- *
- ****************************************************************************/
-
-#ifdef CONFIG_STM32_USART1_SERIALDRIVER
-static int up_interrupt_usart1(int irq, void *context)
-{
- return up_interrupt_common(&g_usart1priv);
-}
-#endif
-
-#ifdef CONFIG_STM32_USART2_SERIALDRIVER
-static int up_interrupt_usart2(int irq, void *context)
-{
- return up_interrupt_common(&g_usart2priv);
-}
-#endif
-
-#ifdef CONFIG_STM32_USART3_SERIALDRIVER
-static int up_interrupt_usart3(int irq, void *context)
-{
- return up_interrupt_common(&g_usart3priv);
-}
-#endif
-
-#ifdef CONFIG_STM32_UART4_SERIALDRIVER
-static int up_interrupt_uart4(int irq, void *context)
-{
- return up_interrupt_common(&g_uart4priv);
-}
-#endif
-
-#ifdef CONFIG_STM32_UART5_SERIALDRIVER
-static int up_interrupt_uart5(int irq, void *context)
-{
- return up_interrupt_common(&g_uart5priv);
-}
-#endif
-
-#ifdef CONFIG_STM32_USART6_SERIALDRIVER
-static int up_interrupt_usart6(int irq, void *context)
-{
- return up_interrupt_common(&g_usart6priv);
-}
-#endif
-
-#ifdef CONFIG_STM32_UART7_SERIALDRIVER
-static int up_interrupt_uart7(int irq, void *context)
-{
- return up_interrupt_common(&g_uart7priv);
-}
-#endif
-
-#ifdef CONFIG_STM32_UART8_SERIALDRIVER
-static int up_interrupt_uart8(int irq, void *context)
-{
- return up_interrupt_common(&g_uart8priv);
-}
-#endif
-
/****************************************************************************
* Name: up_dma_rxcallback
*
diff --git a/arch/arm/src/stm32/stm32_spi.c b/arch/arm/src/stm32/stm32_spi.c
index ad6d2fc47cd39c32a32227ef2b899c46f2d2fcd6..3a4a7c8bf98781affbe7870e31c540bfaf4ca8b6 100644
--- a/arch/arm/src/stm32/stm32_spi.c
+++ b/arch/arm/src/stm32/stm32_spi.c
@@ -1,5 +1,5 @@
/************************************************************************************
- * arm/arm/src/stm32/stm32_spi.c
+ * arch/arm/src/stm32/stm32_spi.c
*
* Copyright (C) 2009-2013, 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
diff --git a/arch/arm/src/stm32/stm32_syscfg.h b/arch/arm/src/stm32/stm32_syscfg.h
index 8098779f2a6dcc8b61141584f25d789f50a04548..9d832b0f2ea0e931fd10edae7ae395fbbf470668 100644
--- a/arch/arm/src/stm32/stm32_syscfg.h
+++ b/arch/arm/src/stm32/stm32_syscfg.h
@@ -49,6 +49,8 @@
# include "chip/stm32f20xxx_syscfg.h"
#elif defined(CONFIG_STM32_STM32F30XX)
# include "chip/stm32f30xxx_syscfg.h"
+#elif defined(CONFIG_STM32_STM32F33XX)
+# include "chip/stm32f33xxx_syscfg.h"
#elif defined(CONFIG_STM32_STM32F37XX)
# include "chip/stm32f37xxx_syscfg.h"
#elif defined(CONFIG_STM32_STM32F40XX)
diff --git a/arch/arm/src/stm32/stm32_tim.c b/arch/arm/src/stm32/stm32_tim.c
index ff470b3065cf118062a182e5293962a7f6020ce8..5590992827056fbcd0da75eafa59f7cbeed2c5ec 100644
--- a/arch/arm/src/stm32/stm32_tim.c
+++ b/arch/arm/src/stm32/stm32_tim.c
@@ -1,5 +1,5 @@
/************************************************************************************
- * arm/arm/src/stm32/stm32_tim.c
+ * arch/arm/src/stm32/stm32_tim.c
*
* Copyright (C) 2011 Uros Platise. All rights reserved.
* Author: Uros Platise
@@ -344,9 +344,8 @@ static int stm32_tim_setchannel(FAR struct stm32_tim_dev_s *dev, uint8_t channel
static int stm32_tim_setcompare(FAR struct stm32_tim_dev_s *dev, uint8_t channel,
uint32_t compare);
static int stm32_tim_getcapture(FAR struct stm32_tim_dev_s *dev, uint8_t channel);
-static int stm32_tim_setisr(FAR struct stm32_tim_dev_s *dev,
- int (*handler)(int irq, void *context),
- int source);
+static int stm32_tim_setisr(FAR struct stm32_tim_dev_s *dev, xcpt_t handler,
+ void *arg, int source);
static void stm32_tim_enableint(FAR struct stm32_tim_dev_s *dev, int source);
static void stm32_tim_disableint(FAR struct stm32_tim_dev_s *dev, int source);
static void stm32_tim_ackint(FAR struct stm32_tim_dev_s *dev, int source);
@@ -1484,9 +1483,8 @@ static int stm32_tim_getcapture(FAR struct stm32_tim_dev_s *dev, uint8_t channel
* Name: stm32_tim_setisr
************************************************************************************/
-static int stm32_tim_setisr(FAR struct stm32_tim_dev_s *dev,
- int (*handler)(int irq, void *context),
- int source)
+static int stm32_tim_setisr(FAR struct stm32_tim_dev_s *dev, xcpt_t handler,
+ void * arg, int source)
{
int vectorno;
@@ -1596,7 +1594,7 @@ static int stm32_tim_setisr(FAR struct stm32_tim_dev_s *dev,
/* Otherwise set callback and enable interrupt */
- irq_attach(vectorno, handler);
+ irq_attach(vectorno, handler ,arg);
up_enable_irq(vectorno);
#ifdef CONFIG_ARCH_IRQPRIO
diff --git a/arch/arm/src/stm32/stm32_tim.h b/arch/arm/src/stm32/stm32_tim.h
index e31250537b4727201681adfad2b368b40fa2aa45..921baebc6c34415252cac0ab516ecfb301de1d3b 100644
--- a/arch/arm/src/stm32/stm32_tim.h
+++ b/arch/arm/src/stm32/stm32_tim.h
@@ -50,6 +50,8 @@
#include "chip.h"
#include "chip/stm32_tim.h"
+#include
+
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
@@ -62,7 +64,7 @@
#define STM32_TIM_SETCHANNEL(d,ch,mode) ((d)->ops->setchannel(d,ch,mode))
#define STM32_TIM_SETCOMPARE(d,ch,comp) ((d)->ops->setcompare(d,ch,comp))
#define STM32_TIM_GETCAPTURE(d,ch) ((d)->ops->getcapture(d,ch))
-#define STM32_TIM_SETISR(d,hnd,s) ((d)->ops->setisr(d,hnd,s))
+#define STM32_TIM_SETISR(d,hnd,arg,s) ((d)->ops->setisr(d,hnd,arg,s))
#define STM32_TIM_ENABLEINT(d,s) ((d)->ops->enableint(d,s))
#define STM32_TIM_DISABLEINT(d,s) ((d)->ops->disableint(d,s))
#define STM32_TIM_ACKINT(d,s) ((d)->ops->ackint(d,s))
@@ -172,8 +174,7 @@ struct stm32_tim_ops_s
/* Timer interrupts */
- int (*setisr)(FAR struct stm32_tim_dev_s *dev,
- int (*handler)(int irq, void *context), int source);
+ int (*setisr)(FAR struct stm32_tim_dev_s *dev, xcpt_t handler, void * arg, int source);
void (*enableint)(FAR struct stm32_tim_dev_s *dev, int source);
void (*disableint)(FAR struct stm32_tim_dev_s *dev, int source);
void (*ackint)(FAR struct stm32_tim_dev_s *dev, int source);
@@ -190,7 +191,7 @@ FAR struct stm32_tim_dev_s *stm32_tim_init(int timer);
/* Power-down timer, mark it as unused */
-int stm32_tim_deinit(FAR struct stm32_tim_dev_s * dev);
+int stm32_tim_deinit(FAR struct stm32_tim_dev_s *dev);
/****************************************************************************
* Name: stm32_timer_initialize
diff --git a/arch/arm/src/stm32/stm32_tim_lowerhalf.c b/arch/arm/src/stm32/stm32_tim_lowerhalf.c
index 684381cc68ca9ea36dbbddca444ddc899ee39edc..cea5e2c2726454b46286dd688f46d99def02a1bb 100644
--- a/arch/arm/src/stm32/stm32_tim_lowerhalf.c
+++ b/arch/arm/src/stm32/stm32_tim_lowerhalf.c
@@ -109,7 +109,6 @@ struct stm32_lowerhalf_s
FAR struct stm32_tim_dev_s *tim; /* stm32 timer driver */
tccb_t callback; /* Current user interrupt callback */
FAR void *arg; /* Argument passed to upper half callback */
- const xcpt_t timhandler; /* Current timer interrupt handler */
bool started; /* True: Timer has been started */
const uint8_t resolution; /* Number of bits in the timer (16 or 32 bits) */
};
@@ -117,53 +116,7 @@ struct stm32_lowerhalf_s
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
-
-/* Interrupt handling *******************************************************/
-
-#ifdef CONFIG_STM32_TIM1
-static int stm32_tim1_interrupt(int irq, FAR void *context);
-#endif
-#ifdef CONFIG_STM32_TIM2
-static int stm32_tim2_interrupt(int irq, FAR void *context);
-#endif
-#ifdef CONFIG_STM32_TIM3
-static int stm32_tim3_interrupt(int irq, FAR void *context);
-#endif
-#ifdef CONFIG_STM32_TIM4
-static int stm32_tim4_interrupt(int irq, FAR void *context);
-#endif
-#ifdef CONFIG_STM32_TIM5
-static int stm32_tim5_interrupt(int irq, FAR void *context);
-#endif
-#ifdef CONFIG_STM32_TIM6
-static int stm32_tim6_interrupt(int irq, FAR void *context);
-#endif
-#ifdef CONFIG_STM32_TIM7
-static int stm32_tim7_interrupt(int irq, FAR void *context);
-#endif
-#ifdef CONFIG_STM32_TIM8
-static int stm32_tim8_interrupt(int irq, FAR void *context);
-#endif
-#ifdef CONFIG_STM32_TIM9
-static int stm32_tim9_interrupt(int irq, FAR void *context);
-#endif
-#ifdef CONFIG_STM32_TIM10
-static int stm32_tim10_interrupt(int irq, FAR void *context);
-#endif
-#ifdef CONFIG_STM32_TIM11
-static int stm32_tim11_interrupt(int irq, FAR void *context);
-#endif
-#ifdef CONFIG_STM32_TIM12
-static int stm32_tim12_interrupt(int irq, FAR void *context);
-#endif
-#ifdef CONFIG_STM32_TIM13
-static int stm32_tim13_interrupt(int irq, FAR void *context);
-#endif
-#ifdef CONFIG_STM32_TIM14
-static int stm32_tim14_interrupt(int irq, FAR void *context);
-#endif
-
-static int stm32_timer_handler(FAR struct stm32_lowerhalf_s *lower);
+static int stm32_timer_handler(int irq, void * context, void * arg);
/* "Lower half" driver methods **********************************************/
@@ -193,7 +146,6 @@ static const struct timer_ops_s g_timer_ops =
static struct stm32_lowerhalf_s g_tim1_lowerhalf =
{
.ops = &g_timer_ops,
- .timhandler = stm32_tim1_interrupt,
.resolution = STM32_TIM1_RES,
};
#endif
@@ -202,7 +154,6 @@ static struct stm32_lowerhalf_s g_tim1_lowerhalf =
static struct stm32_lowerhalf_s g_tim2_lowerhalf =
{
.ops = &g_timer_ops,
- .timhandler = stm32_tim2_interrupt,
.resolution = STM32_TIM2_RES,
};
#endif
@@ -211,7 +162,6 @@ static struct stm32_lowerhalf_s g_tim2_lowerhalf =
static struct stm32_lowerhalf_s g_tim3_lowerhalf =
{
.ops = &g_timer_ops,
- .timhandler = stm32_tim3_interrupt,
.resolution = STM32_TIM3_RES,
};
#endif
@@ -220,7 +170,6 @@ static struct stm32_lowerhalf_s g_tim3_lowerhalf =
static struct stm32_lowerhalf_s g_tim4_lowerhalf =
{
.ops = &g_timer_ops,
- .timhandler = stm32_tim4_interrupt,
.resolution = STM32_TIM4_RES,
};
#endif
@@ -229,7 +178,6 @@ static struct stm32_lowerhalf_s g_tim4_lowerhalf =
static struct stm32_lowerhalf_s g_tim5_lowerhalf =
{
.ops = &g_timer_ops,
- .timhandler = stm32_tim5_interrupt,
.resolution = STM32_TIM5_RES,
};
#endif
@@ -238,7 +186,6 @@ static struct stm32_lowerhalf_s g_tim5_lowerhalf =
static struct stm32_lowerhalf_s g_tim6_lowerhalf =
{
.ops = &g_timer_ops,
- .timhandler = stm32_tim6_interrupt,
.resolution = STM32_TIM6_RES,
};
#endif
@@ -247,7 +194,6 @@ static struct stm32_lowerhalf_s g_tim6_lowerhalf =
static struct stm32_lowerhalf_s g_tim7_lowerhalf =
{
.ops = &g_timer_ops,
- .timhandler = stm32_tim7_interrupt,
.resolution = STM32_TIM7_RES,
};
#endif
@@ -256,7 +202,6 @@ static struct stm32_lowerhalf_s g_tim7_lowerhalf =
static struct stm32_lowerhalf_s g_tim8_lowerhalf =
{
.ops = &g_timer_ops,
- .timhandler = stm32_tim8_interrupt,
.resolution = STM32_TIM8_RES,
};
#endif
@@ -265,7 +210,6 @@ static struct stm32_lowerhalf_s g_tim8_lowerhalf =
static struct stm32_lowerhalf_s g_tim9_lowerhalf =
{
.ops = &g_timer_ops,
- .timhandler = stm32_tim9_interrupt,
.resolution = STM32_TIM9_RES,
};
#endif
@@ -274,7 +218,6 @@ static struct stm32_lowerhalf_s g_tim9_lowerhalf =
static struct stm32_lowerhalf_s g_tim10_lowerhalf =
{
.ops = &g_timer_ops,
- .timhandler = stm32_tim10_interrupt,
.resolution = STM32_TIM10_RES,
};
#endif
@@ -283,7 +226,6 @@ static struct stm32_lowerhalf_s g_tim10_lowerhalf =
static struct stm32_lowerhalf_s g_tim11_lowerhalf =
{
.ops = &g_timer_ops,
- .timhandler = stm32_tim11_interrupt,
.resolution = STM32_TIM11_RES,
};
#endif
@@ -292,7 +234,6 @@ static struct stm32_lowerhalf_s g_tim11_lowerhalf =
static struct stm32_lowerhalf_s g_tim12_lowerhalf =
{
.ops = &g_timer_ops,
- .timhandler = stm32_tim12_interrupt,
.resolution = STM32_TIM12_RES,
};
#endif
@@ -301,7 +242,6 @@ static struct stm32_lowerhalf_s g_tim12_lowerhalf =
static struct stm32_lowerhalf_s g_tim13_lowerhalf =
{
.ops = &g_timer_ops,
- .timhandler = stm32_tim13_interrupt,
.resolution = STM32_TIM13_RES,
};
#endif
@@ -310,7 +250,6 @@ static struct stm32_lowerhalf_s g_tim13_lowerhalf =
static struct stm32_lowerhalf_s g_tim14_lowerhalf =
{
.ops = &g_timer_ops,
- .timhandler = stm32_tim14_interrupt,
.resolution = STM32_TIM14_RES,
};
#endif
@@ -319,112 +258,6 @@ static struct stm32_lowerhalf_s g_tim14_lowerhalf =
* Private Functions
****************************************************************************/
-/****************************************************************************
- * Name: stm32_timN_interrupt, N=1..14
- *
- * Description:
- * Individual interrupt handlers for each timer
- *
- ****************************************************************************/
-
-#ifdef CONFIG_STM32_TIM1
-static int stm32_tim1_interrupt(int irq, FAR void *context)
-{
- return stm32_timer_handler(&g_tim1_lowerhalf);
-}
-#endif
-
-#ifdef CONFIG_STM32_TIM2
-static int stm32_tim2_interrupt(int irq, FAR void *context)
-{
- return stm32_timer_handler(&g_tim2_lowerhalf);
-}
-#endif
-
-#ifdef CONFIG_STM32_TIM3
-static int stm32_tim3_interrupt(int irq, FAR void *context)
-{
- return stm32_timer_handler(&g_tim3_lowerhalf);
-}
-#endif
-
-#ifdef CONFIG_STM32_TIM4
-static int stm32_tim4_interrupt(int irq, FAR void *context)
-{
- return stm32_timer_handler(&g_tim4_lowerhalf);
-}
-#endif
-
-#ifdef CONFIG_STM32_TIM5
-static int stm32_tim5_interrupt(int irq, FAR void *context)
-{
- return stm32_timer_handler(&g_tim5_lowerhalf);
-}
-#endif
-
-#ifdef CONFIG_STM32_TIM6
-static int stm32_tim6_interrupt(int irq, FAR void *context)
-{
- return stm32_timer_handler(&g_tim6_lowerhalf);
-}
-#endif
-
-#ifdef CONFIG_STM32_TIM7
-static int stm32_tim7_interrupt(int irq, FAR void *context)
-{
- return stm32_timer_handler(&g_tim7_lowerhalf);
-}
-#endif
-
-#ifdef CONFIG_STM32_TIM8
-static int stm32_tim8_interrupt(int irq, FAR void *context)
-{
- return stm32_timer_handler(&g_tim8_lowerhalf);
-}
-#endif
-
-#ifdef CONFIG_STM32_TIM9
-static int stm32_tim9_interrupt(int irq, FAR void *context)
-{
- return stm32_timer_handler(&g_tim9_lowerhalf);
-}
-#endif
-
-#ifdef CONFIG_STM32_TIM10
-static int stm32_tim10_interrupt(int irq, FAR void *context)
-{
- return stm32_timer_handler(&g_tim10_lowerhalf);
-}
-#endif
-
-#ifdef CONFIG_STM32_TIM11
-static int stm32_tim11_interrupt(int irq, FAR void *context)
-{
- return stm32_timer_handler(&g_tim11_lowerhalf);
-}
-#endif
-
-#ifdef CONFIG_STM32_TIM12
-static int stm32_tim12_interrupt(int irq, FAR void *context)
-{
- return stm32_timer_handler(&g_tim12_lowerhalf);
-}
-#endif
-
-#ifdef CONFIG_STM32_TIM13
-static int stm32_tim13_interrupt(int irq, FAR void *context)
-{
- return stm32_timer_handler(&g_tim13_lowerhalf);
-}
-#endif
-
-#ifdef CONFIG_STM32_TIM14
-static int stm32_tim14_interrupt(int irq, FAR void *context)
-{
- return stm32_timer_handler(&g_tim14_lowerhalf);
-}
-#endif
-
/****************************************************************************
* Name: stm32_timer_handler
*
@@ -437,8 +270,9 @@ static int stm32_tim14_interrupt(int irq, FAR void *context)
*
****************************************************************************/
-static int stm32_timer_handler(FAR struct stm32_lowerhalf_s *lower)
+static int stm32_timer_handler(int irq, void * context, void * arg)
{
+ FAR struct stm32_lowerhalf_s *lower = (struct stm32_lowerhalf_s *) arg;
uint32_t next_interval_us = 0;
STM32_TIM_ACKINT(lower->tim, 0);
@@ -483,7 +317,7 @@ static int stm32_start(FAR struct timer_lowerhalf_s *lower)
if (priv->callback != NULL)
{
- STM32_TIM_SETISR(priv->tim, priv->timhandler, 0);
+ STM32_TIM_SETISR(priv->tim, stm32_timer_handler, priv, 0);
STM32_TIM_ENABLEINT(priv->tim, 0);
}
@@ -519,7 +353,7 @@ static int stm32_stop(struct timer_lowerhalf_s *lower)
{
STM32_TIM_SETMODE(priv->tim, STM32_TIM_MODE_DISABLED);
STM32_TIM_DISABLEINT(priv->tim, 0);
- STM32_TIM_SETISR(priv->tim, 0, 0);
+ STM32_TIM_SETISR(priv->tim, NULL, NULL, 0);
priv->started = false;
return OK;
}
@@ -605,13 +439,13 @@ static void stm32_setcallback(FAR struct timer_lowerhalf_s *lower,
if (callback != NULL && priv->started)
{
- STM32_TIM_SETISR(priv->tim, priv->timhandler, 0);
+ STM32_TIM_SETISR(priv->tim, stm32_timer_handler, priv, 0);
STM32_TIM_ENABLEINT(priv->tim, 0);
}
else
{
STM32_TIM_DISABLEINT(priv->tim, 0);
- STM32_TIM_SETISR(priv->tim, 0, 0);
+ STM32_TIM_SETISR(priv->tim, NULL, NULL, 0);
}
leave_critical_section(flags);
diff --git a/arch/arm/src/stm32/stm32_timerisr.c b/arch/arm/src/stm32/stm32_timerisr.c
index cb0bd885a7db39f27244dbfaff520863896cb34d..ac2aaae09453929b75e77f3173d98bed4ec546b8 100644
--- a/arch/arm/src/stm32/stm32_timerisr.c
+++ b/arch/arm/src/stm32/stm32_timerisr.c
@@ -98,7 +98,7 @@
*
****************************************************************************/
-static int stm32_timerisr(int irq, uint32_t *regs)
+static int stm32_timerisr(int irq, uint32_t *regs, void *arg)
{
/* Process timer interrupt */
@@ -148,7 +148,7 @@ void arm_timer_initialize(void)
/* Attach the timer interrupt vector */
- (void)irq_attach(STM32_IRQ_SYSTICK, (xcpt_t)stm32_timerisr);
+ (void)irq_attach(STM32_IRQ_SYSTICK, (xcpt_t)stm32_timerisr, NULL);
/* Enable SysTick interrupts */
diff --git a/arch/arm/src/stm32/stm32_uart.h b/arch/arm/src/stm32/stm32_uart.h
index 76fc41e0ba07e5b71e78781c46590e349cd94ab0..fe2542cfa6948592e8eef935484ee7e071feb5ad 100644
--- a/arch/arm/src/stm32/stm32_uart.h
+++ b/arch/arm/src/stm32/stm32_uart.h
@@ -50,7 +50,8 @@
# include "chip/stm32f10xxx_uart.h"
#elif defined(CONFIG_STM32_STM32F20XX)
# include "chip/stm32f20xxx_uart.h"
-#elif defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F37XX)
+#elif defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX) || \
+ defined(CONFIG_STM32_STM32F37XX)
# include "chip/stm32f30xxx_uart.h"
#elif defined(CONFIG_STM32_STM32F40XX)
# include "chip/stm32f40xxx_uart.h"
diff --git a/arch/arm/src/stm32/stm32_usbdev.c b/arch/arm/src/stm32/stm32_usbdev.c
index 9c69a86b8fecb5cd75be5c7764ef4d4fceb00cf1..e042f50a76e005e4854385eb5fc2b70e5a7a900b 100644
--- a/arch/arm/src/stm32/stm32_usbdev.c
+++ b/arch/arm/src/stm32/stm32_usbdev.c
@@ -484,8 +484,8 @@ static void stm32_ep0in(struct stm32_usbdev_s *priv);
static inline void
stm32_ep0done(struct stm32_usbdev_s *priv, uint16_t istr);
static void stm32_lptransfer(struct stm32_usbdev_s *priv);
-static int stm32_hpinterrupt(int irq, void *context);
-static int stm32_lpinterrupt(int irq, void *context);
+static int stm32_hpinterrupt(int irq, void *context, FAR void *arg);
+static int stm32_lpinterrupt(int irq, void *context, FAR void *arg);
/* Endpoint helpers *********************************************************/
@@ -2413,7 +2413,7 @@ static void stm32_lptransfer(struct stm32_usbdev_s *priv)
* Name: stm32_hpinterrupt
****************************************************************************/
-static int stm32_hpinterrupt(int irq, void *context)
+static int stm32_hpinterrupt(int irq, void *context, FAR void *arg)
{
/* For now there is only one USB controller, but we will always refer to
* it using a pointer to make any future ports to multiple USB controllers
@@ -2455,7 +2455,7 @@ static int stm32_hpinterrupt(int irq, void *context)
* Name: stm32_lpinterrupt
****************************************************************************/
-static int stm32_lpinterrupt(int irq, void *context)
+static int stm32_lpinterrupt(int irq, void *context, FAR void *arg)
{
/* For now there is only one USB controller, but we will always refer to
* it using a pointer to make any future ports to multiple USB controllers
@@ -3752,14 +3752,14 @@ void up_usbinitialize(void)
* them when we need them later.
*/
- if (irq_attach(STM32_IRQ_USBHP, stm32_hpinterrupt) != 0)
+ if (irq_attach(STM32_IRQ_USBHP, stm32_hpinterrupt, NULL) != 0)
{
usbtrace(TRACE_DEVERROR(STM32_TRACEERR_IRQREGISTRATION),
(uint16_t)STM32_IRQ_USBHP);
goto errout;
}
- if (irq_attach(STM32_IRQ_USBLP, stm32_lpinterrupt) != 0)
+ if (irq_attach(STM32_IRQ_USBLP, stm32_lpinterrupt, NULL) != 0)
{
usbtrace(TRACE_DEVERROR(STM32_TRACEERR_IRQREGISTRATION),
(uint16_t)STM32_IRQ_USBLP);
diff --git a/arch/arm/src/stm32/stm32_wwdg.c b/arch/arm/src/stm32/stm32_wwdg.c
index 6c9829974377e2ad222a5cee5804af63d3deb48f..a299de8c991461b0c44d75f7e92d389a8d7f37f5 100644
--- a/arch/arm/src/stm32/stm32_wwdg.c
+++ b/arch/arm/src/stm32/stm32_wwdg.c
@@ -121,7 +121,7 @@ static void stm32_setwindow(FAR struct stm32_lowerhalf_s *priv,
/* Interrupt hanlding *******************************************************/
-static int stm32_interrupt(int irq, FAR void *context);
+static int stm32_interrupt(int irq, FAR void *context, FAR void *arg);
/* "Lower half" driver methods **********************************************/
@@ -286,7 +286,7 @@ static void stm32_setwindow(FAR struct stm32_lowerhalf_s *priv, uint8_t window)
*
****************************************************************************/
-static int stm32_interrupt(int irq, FAR void *context)
+static int stm32_interrupt(int irq, FAR void *context, FAR void *arg)
{
FAR struct stm32_lowerhalf_s *priv = &g_wdgdev;
uint16_t regval;
@@ -305,7 +305,7 @@ static int stm32_interrupt(int irq, FAR void *context)
* upon return.
*/
- priv->handler(irq, context);
+ priv->handler(irq, context, arg);
}
/* The EWI interrupt is cleared by writing '0' to the EWIF bit in the
@@ -766,7 +766,7 @@ void stm32_wwdginitialize(FAR const char *devpath)
/* Attach our EWI interrupt handler (But don't enable it yet) */
- (void)irq_attach(STM32_IRQ_WWDG, stm32_interrupt);
+ (void)irq_attach(STM32_IRQ_WWDG, stm32_interrupt, NULL);
/* Select an arbitrary initial timeout value. But don't start the watchdog
* yet. NOTE: If the "Hardware watchdog" feature is enabled through the
@@ -780,7 +780,7 @@ void stm32_wwdginitialize(FAR const char *devpath)
(void)watchdog_register(devpath, (FAR struct watchdog_lowerhalf_s *)priv);
- /* When the microcontroller enters debug mode (Cortex-M4F core halted),
+ /* When the microcontroller enters debug mode (Cortex�-M4F core halted),
* the WWDG counter either continues to work normally or stops, depending
* on DBG_WWDG_STOP configuration bit in DBG module.
*/
diff --git a/arch/arm/src/stm32/stm32f10xxx_dma.c b/arch/arm/src/stm32/stm32f10xxx_dma.c
index 8a7782773e268a1b025fffcd5c2d7b68cad76a24..1e6751ee56358ed0a069e308d120a7cc66ea61b8 100644
--- a/arch/arm/src/stm32/stm32f10xxx_dma.c
+++ b/arch/arm/src/stm32/stm32f10xxx_dma.c
@@ -275,7 +275,7 @@ static void stm32_dmachandisable(struct stm32_dma_s *dmach)
*
************************************************************************************/
-static int stm32_dmainterrupt(int irq, void *context)
+static int stm32_dmainterrupt(int irq, void *context, FAR void *arg)
{
struct stm32_dma_s *dmach;
uint32_t isr;
@@ -351,7 +351,7 @@ void weak_function up_dmainitialize(void)
/* Attach DMA interrupt vectors */
- (void)irq_attach(dmach->irq, stm32_dmainterrupt);
+ (void)irq_attach(dmach->irq, stm32_dmainterrupt, NULL);
/* Disable the DMA channel */
diff --git a/arch/arm/src/stm32/stm32f20xxx_dma.c b/arch/arm/src/stm32/stm32f20xxx_dma.c
index 8edd31db2cb98aced83bc7b24e0caee1d8252674..6fb9d33cee1bd84c7c253ff4851306e5ad34a194 100644
--- a/arch/arm/src/stm32/stm32f20xxx_dma.c
+++ b/arch/arm/src/stm32/stm32f20xxx_dma.c
@@ -370,7 +370,7 @@ static void stm32_dmastreamdisable(struct stm32_dma_s *dmast)
*
************************************************************************************/
-static int stm32_dmainterrupt(int irq, void *context)
+static int stm32_dmainterrupt(int irq, void *context, FAR void *arg)
{
struct stm32_dma_s *dmast;
uint32_t status;
@@ -482,7 +482,7 @@ void weak_function up_dmainitialize(void)
/* Attach DMA interrupt vectors */
- (void)irq_attach(dmast->irq, stm32_dmainterrupt);
+ (void)irq_attach(dmast->irq, stm32_dmainterrupt, dmast);
/* Disable the DMA stream */
diff --git a/arch/arm/src/stm32/stm32f30xxx_i2c.c b/arch/arm/src/stm32/stm32f30xxx_i2c.c
index 312e0b4bb880f687d74c14263828d887be61d319..4a1ae02a512432a6093cbfffe37d676d42be6f8f 100644
--- a/arch/arm/src/stm32/stm32f30xxx_i2c.c
+++ b/arch/arm/src/stm32/stm32f30xxx_i2c.c
@@ -222,7 +222,7 @@ struct stm32_i2c_config_s
uint32_t scl_pin; /* GPIO configuration for SCL as SCL */
uint32_t sda_pin; /* GPIO configuration for SDA as SDA */
#ifndef CONFIG_I2C_POLLED
- int (*isr)(int, void *); /* Interrupt handler */
+ int (*isr)(int, void *, void *); /* Interrupt handler */
uint32_t ev_irq; /* Event IRQ */
uint32_t er_irq; /* Error IRQ */
#endif
@@ -304,13 +304,13 @@ static inline uint32_t stm32_i2c_getstatus(FAR struct stm32_i2c_priv_s *priv);
static int stm32_i2c_isr(struct stm32_i2c_priv_s * priv);
#ifndef CONFIG_I2C_POLLED
#ifdef CONFIG_STM32_I2C1
-static int stm32_i2c1_isr(int irq, void *context);
+static int stm32_i2c1_isr(int irq, void *context, FAR void *arg);
#endif
#ifdef CONFIG_STM32_I2C2
-static int stm32_i2c2_isr(int irq, void *context);
+static int stm32_i2c2_isr(int irq, void *context, FAR void *arg);
#endif
#ifdef CONFIG_STM32_I2C3
-static int stm32_i2c3_isr(int irq, void *context);
+static int stm32_i2c3_isr(int irq, void *context, FAR void *arg);
#endif
#endif
static int stm32_i2c_init(FAR struct stm32_i2c_priv_s *priv);
@@ -1493,7 +1493,7 @@ static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv)
#ifndef CONFIG_I2C_POLLED
#ifdef CONFIG_STM32_I2C1
-static int stm32_i2c1_isr(int irq, void *context)
+static int stm32_i2c1_isr(int irq, void *context, FAR void *arg)
{
return stm32_i2c_isr(&stm32_i2c1_priv);
}
@@ -1508,7 +1508,7 @@ static int stm32_i2c1_isr(int irq, void *context)
************************************************************************************/
#ifdef CONFIG_STM32_I2C2
-static int stm32_i2c2_isr(int irq, void *context)
+static int stm32_i2c2_isr(int irq, void *context, FAR void *arg)
{
return stm32_i2c_isr(&stm32_i2c2_priv);
}
@@ -1523,7 +1523,7 @@ static int stm32_i2c2_isr(int irq, void *context)
************************************************************************************/
#ifdef CONFIG_STM32_I2C3
-static int stm32_i2c3_isr(int irq, void *context)
+static int stm32_i2c3_isr(int irq, void *context, FAR void *arg)
{
return stm32_i2c_isr(&stm32_i2c3_priv);
}
@@ -1568,8 +1568,8 @@ static int stm32_i2c_init(FAR struct stm32_i2c_priv_s *priv)
/* Attach ISRs */
#ifndef CONFIG_I2C_POLLED
- irq_attach(priv->config->ev_irq, priv->config->isr);
- irq_attach(priv->config->er_irq, priv->config->isr);
+ irq_attach(priv->config->ev_irq, priv->config->isr, NULL);
+ irq_attach(priv->config->er_irq, priv->config->isr, NULL);
up_enable_irq(priv->config->ev_irq);
up_enable_irq(priv->config->er_irq);
#endif
diff --git a/arch/arm/src/stm32/stm32f33xxx_rcc.c b/arch/arm/src/stm32/stm32f33xxx_rcc.c
new file mode 100644
index 0000000000000000000000000000000000000000..82923a7ef869c6ac5e8a0aad660ba7078ca56e77
--- /dev/null
+++ b/arch/arm/src/stm32/stm32f33xxx_rcc.c
@@ -0,0 +1,628 @@
+/****************************************************************************
+ * arch/arm/src/stm32/stm32f33xxx_rcc.c
+ *
+ * Copyright (C) 2012, 2015, 2017 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ * Modified for STM32F334 by Mateusz Szafoni
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* Allow up to 100 milliseconds for the high speed clock to become ready.
+ * that is a very long delay, but if the clock does not become ready we are
+ * hosed anyway. Normally this is very fast, but I have seen at least one
+ * board that required this long, long timeout for the HSE to be ready.
+ */
+
+#define HSERDY_TIMEOUT (100 * CONFIG_BOARD_LOOPSPERMSEC)
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: rcc_reset
+ *
+ * Description:
+ * Put all RCC registers in reset state
+ *
+ ****************************************************************************/
+
+static inline void rcc_reset(void)
+{
+ uint32_t regval;
+
+ putreg32(0, STM32_RCC_APB2RSTR); /* Disable APB2 Peripheral Reset */
+ putreg32(0, STM32_RCC_APB1RSTR); /* Disable APB1 Peripheral Reset */
+ putreg32(RCC_AHBENR_FLITFEN | RCC_AHBENR_SRAMEN, STM32_RCC_AHBENR); /* FLITF and SRAM Clock ON */
+ putreg32(0, STM32_RCC_APB2ENR); /* Disable APB2 Peripheral Clock */
+ putreg32(0, STM32_RCC_APB1ENR); /* Disable APB1 Peripheral Clock */
+
+ regval = getreg32(STM32_RCC_CR); /* Set the HSION bit */
+ regval |= RCC_CR_HSION;
+ putreg32(regval, STM32_RCC_CR);
+
+ regval = getreg32(STM32_RCC_CFGR); /* Reset SW, HPRE, PPRE1, PPRE2, and MCO bits */
+ regval &= ~(RCC_CFGR_SW_MASK | RCC_CFGR_HPRE_MASK | RCC_CFGR_PPRE1_MASK |
+ RCC_CFGR_PPRE2_MASK | RCC_CFGR_MCO_MASK);
+
+ putreg32(regval, STM32_RCC_CFGR);
+
+ regval = getreg32(STM32_RCC_CFGR2); /* Reset PREDIV, and ADC12PRE bits */
+ regval &= ~(RCC_CFGR2_PREDIV_MASK | RCC_CFGR2_ADC12PRES_MASK);
+ putreg32(regval, STM32_RCC_CFGR2);
+
+ regval = getreg32(STM32_RCC_CFGR3); /* Reset all U[S]ARTs, I2C1, TIM1 and HRTIM1 bits */
+ regval &= ~(RCC_CFGR3_USART1SW_MASK | RCC_CFGR3_USART2SW_MASK | RCC_CFGR3_USART3SW_MASK | \
+ RCC_CFGR3_I2C1SW | RCC_CFGR3_TIM1SW | RCC_CFGR3_HRTIM1SW);
+ putreg32(regval, STM32_RCC_CFGR3);
+
+ regval = getreg32(STM32_RCC_CR); /* Reset HSEON, CSSON and PLLON bits */
+ regval &= ~(RCC_CR_HSEON | RCC_CR_CSSON | RCC_CR_PLLON);
+ putreg32(regval, STM32_RCC_CR);
+
+ regval = getreg32(STM32_RCC_CR); /* Reset HSEBYP bit */
+ regval &= ~RCC_CR_HSEBYP;
+ putreg32(regval, STM32_RCC_CR);
+
+ regval = getreg32(STM32_RCC_CFGR); /* Reset PLLSRC, PLLXTPRE, PLLMUL and USBPRE bits */
+ regval &= ~(RCC_CFGR_PLLSRC | RCC_CFGR_PLLXTPRE | RCC_CFGR_PLLMUL_MASK);
+ putreg32(regval, STM32_RCC_CFGR);
+
+ putreg32(0, STM32_RCC_CIR); /* Disable all interrupts */
+}
+
+/****************************************************************************
+ * Name: rcc_enableahb
+ *
+ * Description:
+ * Enable selected AHB peripherals
+ *
+ ****************************************************************************/
+
+static inline void rcc_enableahb(void)
+{
+ uint32_t regval;
+
+ /* Always enable FLITF clock and SRAM clock */
+
+ regval = RCC_AHBENR_FLITFEN | RCC_AHBENR_SRAMEN;
+
+ /* Enable GPIO PORTA, PORTB, ... PORTF */
+
+ regval |= (RCC_AHBENR_IOPAEN | RCC_AHBENR_IOPBEN | RCC_AHBENR_IOPCEN |
+ RCC_AHBENR_IOPDEN | RCC_AHBENR_IOPFEN);
+
+#ifdef CONFIG_STM32_DMA1
+ /* DMA 1 clock enable */
+
+ regval |= RCC_AHBENR_DMA1EN;
+#endif
+
+#ifdef CONFIG_STM32_CRC
+ /* CRC clock enable */
+
+ regval |= RCC_AHBENR_CRCEN;
+#endif
+
+#ifdef CONFIG_STM32_TSC
+ /* CRC clock enable */
+
+ regval |= RCC_AHBENR_TSCEN;
+#endif
+
+#if defined(CONFIG_STM32_ADC1) || defined(CONFIG_STM32_ADC2)
+ /* ADC1/ADC2 interface clock enable */
+
+ regval |= RCC_AHBENR_ADC12EN;
+#endif
+
+ putreg32(regval, STM32_RCC_AHBENR); /* Enable peripherals */
+}
+
+/****************************************************************************
+ * Name: rcc_enableapb1
+ *
+ * Description:
+ * Enable selected APB1 peripherals
+ *
+ ****************************************************************************/
+
+static inline void rcc_enableapb1(void)
+{
+ uint32_t regval;
+
+ /* Set the appropriate bits in the APB1ENR register to enabled the
+ * selected APB1 peripherals.
+ */
+
+ regval = getreg32(STM32_RCC_APB1ENR);
+
+#ifdef CONFIG_STM32_TIM2
+ /* Timer 2 clock enable */
+
+#ifdef CONFIG_STM32_FORCEPOWER
+ regval |= RCC_APB1ENR_TIM2EN;
+#endif
+#endif
+
+#ifdef CONFIG_STM32_TIM3
+ /* Timer 3 clock enable */
+
+#ifdef CONFIG_STM32_FORCEPOWER
+ regval |= RCC_APB1ENR_TIM3EN;
+#endif
+#endif
+
+#ifdef CONFIG_STM32_TIM6
+ /* Timer 6 clock enable */
+
+#ifdef CONFIG_STM32_FORCEPOWER
+ regval |= RCC_APB1ENR_TIM6EN;
+#endif
+#endif
+
+#ifdef CONFIG_STM32_TIM7
+ /* Timer 7 clock enable */
+
+#ifdef CONFIG_STM32_FORCEPOWER
+ regval |= RCC_APB1ENR_TIM7EN;
+#endif
+#endif
+
+#ifdef CONFIG_STM32_WWDG
+ /* Window Watchdog clock enable */
+
+ regval |= RCC_APB1ENR_WWDGEN;
+#endif
+
+#ifdef CONFIG_STM32_USART2
+ /* USART 2 clock enable */
+
+ regval |= RCC_APB1ENR_USART2EN;
+#endif
+
+#ifdef CONFIG_STM32_USART3
+ /* USART 3 clock enable */
+
+ regval |= RCC_APB1ENR_USART3EN;
+#endif
+
+#ifdef CONFIG_STM32_I2C1
+ /* I2C 1 clock enable */
+
+#ifdef CONFIG_STM32_FORCEPOWER
+ regval |= RCC_APB1ENR_I2C1EN;
+#endif
+#endif
+
+#ifdef CONFIG_STM32_CAN1
+ /* CAN1 clock enable */
+
+ regval |= RCC_APB1ENR_CAN1EN;
+#endif
+
+#ifdef CONFIG_STM32_DAC2
+ /* DAC2 interface clock enable */
+
+ regval |= RCC_APB1ENR_DAC2EN;
+#endif
+
+#ifdef CONFIG_STM32_PWR
+ /* Power interface clock enable */
+
+ regval |= RCC_APB1ENR_PWREN;
+#endif
+
+#ifdef CONFIG_STM32_DAC1
+ /* DAC1 interface clock enable */
+
+ regval |= RCC_APB1ENR_DAC1EN;
+#endif
+
+ putreg32(regval, STM32_RCC_APB1ENR);
+}
+
+/****************************************************************************
+ * Name: rcc_enableapb2
+ *
+ * Description:
+ * Enable selected APB2 peripherals
+ *
+ ****************************************************************************/
+
+static inline void rcc_enableapb2(void)
+{
+ uint32_t regval;
+
+ /* Set the appropriate bits in the APB2ENR register to enabled the
+ * selected APB2 peripherals.
+ */
+
+ regval = getreg32(STM32_RCC_APB2ENR);
+
+#ifdef CONFIG_STM32_SYSCFG
+ /* SYSCFG clock */
+
+ regval |= RCC_APB2ENR_SYSCFGEN;
+#endif
+
+#ifdef CONFIG_STM32_TIM1
+ /* TIM1 Timer clock enable */
+
+#ifdef CONFIG_STM32_FORCEPOWER
+ regval |= RCC_APB2ENR_TIM1EN;
+#endif
+#endif
+
+#ifdef CONFIG_STM32_SPI1
+ /* SPI 1 clock enable */
+
+ regval |= RCC_APB2ENR_SPI1EN;
+#endif
+
+#ifdef CONFIG_STM32_USART1
+ /* USART1 clock enable */
+
+ regval |= RCC_APB2ENR_USART1EN;
+#endif
+
+#ifdef CONFIG_STM32_TIM15
+ /* TIM15 Timer clock enable */
+
+#ifdef CONFIG_STM32_FORCEPOWER
+ regval |= RCC_APB2ENR_TIM15EN;
+#endif
+#endif
+
+#ifdef CONFIG_STM32_TIM16
+ /* TIM16 Timer clock enable */
+
+#ifdef CONFIG_STM32_FORCEPOWER
+ regval |= RCC_APB2ENR_TIM16EN;
+#endif
+#endif
+
+#ifdef CONFIG_STM32_TIM17
+ /* TIM17 Timer clock enable */
+
+#ifdef CONFIG_STM32_FORCEPOWER
+ regval |= RCC_APB2ENR_TIM17EN;
+#endif
+#endif
+
+#ifdef CONFIG_STM32_HRTIM1
+ /* HRTIM1 Timer clock enable */
+
+#ifdef CONFIG_STM32_FORCEPOWER
+ regval |= RCC_APB2ENR_HRTIM1EN;
+#endif
+#endif
+
+ putreg32(regval, STM32_RCC_APB2ENR);
+}
+
+/****************************************************************************
+ * Name: stm32_stdclockconfig
+ *
+ * Description:
+ * Called to change to new clock based on settings in board.h. This
+ * version is for the Connectivity Line parts.
+ *
+ * NOTE: This logic would need to be extended if you need to select low-
+ * power clocking modes!
+ ****************************************************************************/
+
+#if !defined(CONFIG_ARCH_BOARD_STM32_CUSTOM_CLOCKCONFIG) && defined(CONFIG_STM32_CONNECTIVITYLINE)
+static void stm32_stdclockconfig(void)
+{
+ uint32_t regval;
+
+ /* Enable HSE */
+
+ regval = getreg32(STM32_RCC_CR);
+ regval &= ~RCC_CR_HSEBYP; /* Disable HSE clock bypass */
+ regval |= RCC_CR_HSEON; /* Enable HSE */
+ putreg32(regval, STM32_RCC_CR);
+
+ /* Set flash wait states
+ * Sysclk runs with 72MHz -> 2 waitstates.
+ * 0WS from 0-24MHz
+ * 1WS from 24-48MHz
+ * 2WS from 48-72MHz
+ */
+
+ regval = getreg32(STM32_FLASH_ACR);
+ regval &= ~FLASH_ACR_LATENCY_MASK;
+ regval |= (FLASH_ACR_LATENCY_2 | FLASH_ACR_PRTFBE);
+ putreg32(regval, STM32_FLASH_ACR);
+
+ /* Set up PLL input scaling (with source = PLL2) */
+
+ regval = getreg32(STM32_RCC_CFGR2);
+ regval &= ~(RCC_CFGR2_PREDIV2_MASK | RCC_CFGR2_PLL2MUL_MASK |
+ RCC_CFGR2_PREDIV1SRC_MASK | RCC_CFGR2_PREDIV1_MASK);
+ regval |= (STM32_PLL_PREDIV2 | STM32_PLL_PLL2MUL |
+ RCC_CFGR2_PREDIV1SRC_PLL2 | STM32_PLL_PREDIV1);
+ putreg32(regval, STM32_RCC_CFGR2);
+
+ /* Set the PCLK2 divider */
+
+ regval = getreg32(STM32_RCC_CFGR);
+ regval &= ~(RCC_CFGR_PPRE2_MASK | RCC_CFGR_HPRE_MASK);
+ regval |= STM32_RCC_CFGR_PPRE2;
+ regval |= RCC_CFGR_HPRE_SYSCLK;
+ putreg32(regval, STM32_RCC_CFGR);
+
+ /* Set the PCLK1 divider */
+
+ regval = getreg32(STM32_RCC_CFGR);
+ regval &= ~RCC_CFGR_PPRE1_MASK;
+ regval |= STM32_RCC_CFGR_PPRE1;
+ putreg32(regval, STM32_RCC_CFGR);
+
+ /* Enable PLL2 */
+
+ regval = getreg32(STM32_RCC_CR);
+ regval |= RCC_CR_PLL2ON;
+ putreg32(regval, STM32_RCC_CR);
+
+ /* Wait for PLL2 ready */
+
+ while ((getreg32(STM32_RCC_CR) & RCC_CR_PLL2RDY) == 0);
+
+ /* Setup PLL3 for MII/RMII clock on MCO */
+
+#if defined(CONFIG_STM32_MII_MCO) || defined(CONFIG_STM32_RMII_MCO)
+ regval = getreg32(STM32_RCC_CFGR2);
+ regval &= ~(RCC_CFGR2_PLL3MUL_MASK);
+ regval |= STM32_PLL_PLL3MUL;
+ putreg32(regval, STM32_RCC_CFGR2);
+
+ /* Switch PLL3 on */
+
+ regval = getreg32(STM32_RCC_CR);
+ regval |= RCC_CR_PLL3ON;
+ putreg32(regval, STM32_RCC_CR);
+
+ while ((getreg32(STM32_RCC_CR) & RCC_CR_PLL3RDY) == 0);
+#endif
+
+ /* Set main PLL source and multiplier */
+
+ regval = getreg32(STM32_RCC_CFGR);
+ regval &= ~(RCC_CFGR_PLLSRC | RCC_CFGR_PLLMUL_MASK);
+ regval |= (RCC_CFGR_PLLSRC | STM32_PLL_PLLMUL);
+ putreg32(regval, STM32_RCC_CFGR);
+
+ /* Switch main PLL on */
+
+ regval = getreg32(STM32_RCC_CR);
+ regval |= RCC_CR_PLLON;
+ putreg32(regval, STM32_RCC_CR);
+
+ while ((getreg32(STM32_RCC_CR) & RCC_CR_PLLRDY) == 0);
+
+ /* Select PLL as system clock source */
+
+ regval = getreg32(STM32_RCC_CFGR);
+ regval &= ~RCC_CFGR_SW_MASK;
+ regval |= RCC_CFGR_SW_PLL;
+ putreg32(regval, STM32_RCC_CFGR);
+
+ /* Wait until PLL is used as the system clock source */
+
+ while ((getreg32(STM32_RCC_CFGR) & RCC_CFGR_SWS_PLL) == 0);
+}
+#endif
+
+/****************************************************************************
+ * Name: stm32_stdclockconfig
+ *
+ * Description:
+ * Called to change to new clock based on settings in board.h. This
+ * version is for the non-Connectivity Line parts.
+ *
+ * NOTE: This logic would need to be extended if you need to select low-
+ * power clocking modes!
+ ****************************************************************************/
+
+#if !defined(CONFIG_ARCH_BOARD_STM32_CUSTOM_CLOCKCONFIG) && \
+ !defined(CONFIG_STM32_CONNECTIVITYLINE)
+static void stm32_stdclockconfig(void)
+{
+ uint32_t regval;
+
+ /* If the PLL is using the HSE, or the HSE is the system clock */
+
+#if (STM32_CFGR_PLLSRC == RCC_CFGR_PLLSRC) || (STM32_SYSCLK_SW == RCC_CFGR_SW_HSE)
+ {
+ volatile int32_t timeout;
+
+ /* Enable External High-Speed Clock (HSE) */
+
+ regval = getreg32(STM32_RCC_CR);
+ regval &= ~RCC_CR_HSEBYP; /* Disable HSE clock bypass */
+ regval |= RCC_CR_HSEON; /* Enable HSE */
+ putreg32(regval, STM32_RCC_CR);
+
+ /* Wait until the HSE is ready (or until a timeout elapsed) */
+
+ for (timeout = HSERDY_TIMEOUT; timeout > 0; timeout--)
+ {
+ /* Check if the HSERDY flag is the set in the CR */
+
+ if ((getreg32(STM32_RCC_CR) & RCC_CR_HSERDY) != 0)
+ {
+ /* If so, then break-out with timeout > 0 */
+
+ break;
+ }
+ }
+
+ if (timeout == 0)
+ {
+ /* In the case of a timeout starting the HSE, we really don't have a
+ * strategy. This is almost always a hardware failure or
+ * misconfiguration.
+ */
+
+ return;
+ }
+ }
+
+# if defined(CONFIG_STM32_VALUELINE) && (STM32_CFGR_PLLSRC == RCC_CFGR_PLLSRC)
+ /* If this is a value-line part and we are using the HSE as the PLL */
+
+# if (STM32_CFGR_PLLXTPRE >> 17) != (STM32_CFGR2_PREDIV1 & 1)
+# error STM32_CFGR_PLLXTPRE must match the LSB of STM32_CFGR2_PREDIV1
+# endif
+
+ /* Set the HSE prescaler */
+
+ regval = STM32_CFGR2_PREDIV1;
+ putreg32(regval, STM32_RCC_CFGR2);
+
+# endif
+#endif
+
+#ifndef CONFIG_STM32_VALUELINE
+ /* Value-line devices don't implement flash prefetch/waitstates */
+ /* Enable FLASH prefetch buffer and 2 wait states */
+
+ regval = getreg32(STM32_FLASH_ACR);
+ regval &= ~FLASH_ACR_LATENCY_MASK;
+ regval |= (FLASH_ACR_LATENCY_2 | FLASH_ACR_PRTFBE);
+ putreg32(regval, STM32_FLASH_ACR);
+#endif
+
+ /* Set the HCLK source/divider */
+
+ regval = getreg32(STM32_RCC_CFGR);
+ regval &= ~RCC_CFGR_HPRE_MASK;
+ regval |= STM32_RCC_CFGR_HPRE;
+ putreg32(regval, STM32_RCC_CFGR);
+
+ /* Set the PCLK2 divider */
+
+ regval = getreg32(STM32_RCC_CFGR);
+ regval &= ~RCC_CFGR_PPRE2_MASK;
+ regval |= STM32_RCC_CFGR_PPRE2;
+ putreg32(regval, STM32_RCC_CFGR);
+
+ /* Set the PCLK1 divider */
+
+ regval = getreg32(STM32_RCC_CFGR);
+ regval &= ~RCC_CFGR_PPRE1_MASK;
+ regval |= STM32_RCC_CFGR_PPRE1;
+ putreg32(regval, STM32_RCC_CFGR);
+
+#if STM32_SYSCLK_SW == RCC_CFGR_SW_PLL
+ /* If we are using the PLL, configure and start it */
+ /* Set the PLL divider and multiplier */
+
+ regval = getreg32(STM32_RCC_CFGR);
+ regval &= ~(RCC_CFGR_PLLSRC | RCC_CFGR_PLLXTPRE | RCC_CFGR_PLLMUL_MASK);
+ regval |= (STM32_CFGR_PLLSRC | STM32_CFGR_PLLXTPRE | STM32_CFGR_PLLMUL);
+ putreg32(regval, STM32_RCC_CFGR);
+
+ /* Enable the PLL */
+
+ regval = getreg32(STM32_RCC_CR);
+ regval |= RCC_CR_PLLON;
+ putreg32(regval, STM32_RCC_CR);
+
+ /* Wait until the PLL is ready */
+
+ while ((getreg32(STM32_RCC_CR) & RCC_CR_PLLRDY) == 0);
+
+#endif
+
+ /* Select the system clock source (probably the PLL) */
+
+ regval = getreg32(STM32_RCC_CFGR);
+ regval &= ~RCC_CFGR_SW_MASK;
+ regval |= STM32_SYSCLK_SW;
+ putreg32(regval, STM32_RCC_CFGR);
+
+ /* Wait until the selected source is used as the system clock source */
+
+ while ((getreg32(STM32_RCC_CFGR) & RCC_CFGR_SWS_MASK) != STM32_SYSCLK_SWS);
+
+#if defined(CONFIG_STM32_IWDG) || defined(CONFIG_RTC_LSICLOCK)
+ /* Low speed internal clock source LSI
+ *
+ * TODO: There is another case where the LSI needs to
+ * be enabled: if the MCO pin selects LSI as source.
+ */
+
+ stm32_rcc_enablelsi();
+#endif
+
+#if defined(CONFIG_RTC_LSECLOCK)
+ /* Low speed external clock source LSE
+ *
+ * TODO: There is another case where the LSE needs to
+ * be enabled: if the MCO pin selects LSE as source.
+ *
+ * TODO: There is another case where the LSE needs to
+ * be enabled: if USARTx selects LSE as source.
+ */
+
+ stm32_rcc_enablelse();
+#endif
+}
+#endif
+
+/****************************************************************************
+ * Name: rcc_enableperiphals
+ ****************************************************************************/
+
+static inline void rcc_enableperipherals(void)
+{
+ rcc_enableahb();
+ rcc_enableapb2();
+ rcc_enableapb1();
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
diff --git a/arch/arm/src/stm32/stm32f40xxx_alarm.h b/arch/arm/src/stm32/stm32f40xxx_alarm.h
index 5d8d94a197561f10c74625b95326624400463554..2c09bee31b8ba5e0e97be67d895a05bdedad5127 100644
--- a/arch/arm/src/stm32/stm32f40xxx_alarm.h
+++ b/arch/arm/src/stm32/stm32f40xxx_alarm.h
@@ -1,5 +1,5 @@
/****************************************************************************
- * arch/arm/src/include/stm32/stm32f0xxx_alarm.h
+ * arch/arm/src/stm32/stm32f0xxx_alarm.h
*
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: Neil hancock - delegated to Gregory Nutt Mar 30, 2016
diff --git a/arch/arm/src/stm32/stm32f40xxx_dma.c b/arch/arm/src/stm32/stm32f40xxx_dma.c
index f631c6ea4a6aa5ff19a2422cc7eb596dc7f0c0bf..1824c76bf461efcf443a933d265772df84604be4 100644
--- a/arch/arm/src/stm32/stm32f40xxx_dma.c
+++ b/arch/arm/src/stm32/stm32f40xxx_dma.c
@@ -369,7 +369,7 @@ static void stm32_dmastreamdisable(struct stm32_dma_s *dmast)
*
************************************************************************************/
-static int stm32_dmainterrupt(int irq, void *context)
+static int stm32_dmainterrupt(int irq, void *context, void *arg)
{
struct stm32_dma_s *dmast;
uint32_t status;
@@ -481,7 +481,7 @@ void weak_function up_dmainitialize(void)
/* Attach DMA interrupt vectors */
- (void)irq_attach(dmast->irq, stm32_dmainterrupt);
+ (void)irq_attach(dmast->irq, stm32_dmainterrupt, dmast);
/* Disable the DMA stream */
diff --git a/arch/arm/src/stm32/stm32f40xxx_i2c.c b/arch/arm/src/stm32/stm32f40xxx_i2c.c
index 2bb715c4a8786531abff18e535a946535874ee02..be15a27be0015f1ed4c1074b5c9f524f1f8ca2af 100644
--- a/arch/arm/src/stm32/stm32f40xxx_i2c.c
+++ b/arch/arm/src/stm32/stm32f40xxx_i2c.c
@@ -230,7 +230,7 @@ struct stm32_i2c_config_s
uint32_t scl_pin; /* GPIO configuration for SCL as SCL */
uint32_t sda_pin; /* GPIO configuration for SDA as SDA */
#ifndef CONFIG_I2C_POLLED
- int (*isr)(int, void *); /* Interrupt handler */
+ int (*isr)(int, void *, void *); /* Interrupt handler */
uint32_t ev_irq; /* Event IRQ */
uint32_t er_irq; /* Error IRQ */
#endif
@@ -319,13 +319,13 @@ static int stm32_i2c_isr(struct stm32_i2c_priv_s * priv);
#ifndef CONFIG_I2C_POLLED
#ifdef CONFIG_STM32_I2C1
-static int stm32_i2c1_isr(int irq, void *context);
+static int stm32_i2c1_isr(int irq, void *context, FAR void *arg);
#endif
#ifdef CONFIG_STM32_I2C2
-static int stm32_i2c2_isr(int irq, void *context);
+static int stm32_i2c2_isr(int irq, void *context, FAR void *arg);
#endif
#ifdef CONFIG_STM32_I2C3
-static int stm32_i2c3_isr(int irq, void *context);
+static int stm32_i2c3_isr(int irq, void *context, FAR void *arg);
#endif
#endif /* !CONFIG_I2C_POLLED */
@@ -1878,7 +1878,7 @@ static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv)
#ifndef CONFIG_I2C_POLLED
#ifdef CONFIG_STM32_I2C1
-static int stm32_i2c1_isr(int irq, void *context)
+static int stm32_i2c1_isr(int irq, void *context, FAR void *arg)
{
return stm32_i2c_isr(&stm32_i2c1_priv);
}
@@ -1893,7 +1893,7 @@ static int stm32_i2c1_isr(int irq, void *context)
************************************************************************************/
#ifdef CONFIG_STM32_I2C2
-static int stm32_i2c2_isr(int irq, void *context)
+static int stm32_i2c2_isr(int irq, void *context, FAR void *arg)
{
return stm32_i2c_isr(&stm32_i2c2_priv);
}
@@ -1908,7 +1908,7 @@ static int stm32_i2c2_isr(int irq, void *context)
************************************************************************************/
#ifdef CONFIG_STM32_I2C3
-static int stm32_i2c3_isr(int irq, void *context)
+static int stm32_i2c3_isr(int irq, void *context, FAR void *arg)
{
return stm32_i2c_isr(&stm32_i2c3_priv);
}
@@ -1953,8 +1953,8 @@ static int stm32_i2c_init(FAR struct stm32_i2c_priv_s *priv)
/* Attach ISRs */
#ifndef CONFIG_I2C_POLLED
- irq_attach(priv->config->ev_irq, priv->config->isr);
- irq_attach(priv->config->er_irq, priv->config->isr);
+ irq_attach(priv->config->ev_irq, priv->config->isr, NULL);
+ irq_attach(priv->config->er_irq, priv->config->isr, NULL);
up_enable_irq(priv->config->ev_irq);
up_enable_irq(priv->config->er_irq);
#endif
diff --git a/arch/arm/src/stm32/stm32f40xxx_rtcc.c b/arch/arm/src/stm32/stm32f40xxx_rtcc.c
index cbd136d6d5343ce2730f8cb57c4107c40ccb74e2..4e8cfc773be597c0450b439fb7d83ab061d13c0a 100644
--- a/arch/arm/src/stm32/stm32f40xxx_rtcc.c
+++ b/arch/arm/src/stm32/stm32f40xxx_rtcc.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/stm32/stm32f40xxx_rtcc.c
*
- * Copyright (C) 2012-2016 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2012-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
* Modified: Neil Hancock
*
@@ -591,11 +591,11 @@ static void rtc_resume(void)
****************************************************************************/
#ifdef CONFIG_RTC_ALARM
-static int stm32_rtc_alarm_handler(int irq, void *context)
+static int stm32_rtc_alarm_handler(int irq, void *context, void *arg)
{
FAR struct alm_cbinfo_s *cbinfo;
alm_callback_t cb;
- FAR void *arg;
+ FAR void *cb_arg;
uint32_t isr;
uint32_t cr;
int ret = OK;
@@ -615,12 +615,12 @@ static int stm32_rtc_alarm_handler(int irq, void *context)
/* Alarm A callback */
cb = cbinfo->ac_cb;
- arg = (FAR void *)cbinfo->ac_arg;
+ cb_arg = (FAR void *)cbinfo->ac_arg;
cbinfo->ac_cb = NULL;
cbinfo->ac_arg = NULL;
- cb(arg, RTC_ALARMA);
+ cb(cb_arg, RTC_ALARMA);
}
isr = getreg32(STM32_RTC_ISR) & ~RTC_ISR_ALRAF;
@@ -640,12 +640,12 @@ static int stm32_rtc_alarm_handler(int irq, void *context)
/* Alarm B callback */
cb = cbinfo->ac_cb;
- arg = (FAR void *)cbinfo->ac_arg;
+ cb_arg = (FAR void *)cbinfo->ac_arg;
cbinfo->ac_cb = NULL;
cbinfo->ac_arg = NULL;
- cb(arg, RTC_ALARMB);
+ cb(cb_arg, RTC_ALARMB);
}
isr = getreg32(STM32_RTC_ISR) & ~RTC_ISR_ALRBF;
@@ -847,7 +847,7 @@ static inline void rtc_enable_alarm(void)
* 3. Configure the RTC to generate RTC alarms (Alarm A or Alarm B).
*/
- stm32_exti_alarm(true, false, true, stm32_rtc_alarm_handler);
+ (void)stm32_exti_alarm(true, false, true, stm32_rtc_alarm_handler, NULL);
g_alarm_enabled = true;
}
}
diff --git a/arch/arm/src/stm32f7/stm32_adc.c b/arch/arm/src/stm32f7/stm32_adc.c
index df9232048e8946f5875d7219b3b8fc6a7c49b0d6..df3ab7028e23098d1f3fcc78eb80a58457b4e6b8 100644
--- a/arch/arm/src/stm32f7/stm32_adc.c
+++ b/arch/arm/src/stm32f7/stm32_adc.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/stm32f7/stm32_adc.c
*
- * Copyright (C) 2011, 2013, 2015-2016 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2011, 2013, 2015-2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2015 Omni Hoverboards Inc. All rights reserved.
* Authors: Gregory Nutt
* Diego Sanchez
@@ -60,8 +60,9 @@
#include
#include
#include
-#include
#include
+#include
+#include
#include "up_internal.h"
#include "up_arch.h"
@@ -257,7 +258,7 @@ static void adc_rccreset(FAR struct stm32_dev_s *priv, bool reset);
/* ADC Interrupt Handler */
static int adc_interrupt(FAR struct adc_dev_s *dev);
-static int adc123_interrupt(int irq, FAR void *context);
+static int adc123_interrupt(int irq, FAR void *context, FAR void *arg);
/* ADC Driver Methods */
@@ -1372,7 +1373,7 @@ static int adc_setup(FAR struct adc_dev_s *dev)
/* Attach the ADC interrupt */
- ret = irq_attach(priv->irq, priv->isr);
+ ret = irq_attach(priv->irq, priv->isr, NULL);
if (ret < 0)
{
ainfo("irq_attach failed: %d\n", ret);
@@ -1677,7 +1678,7 @@ static int adc_interrupt(FAR struct adc_dev_s *dev)
*
****************************************************************************/
-static int adc123_interrupt(int irq, FAR void *context)
+static int adc123_interrupt(int irq, FAR void *context, FAR void *arg)
{
#ifdef CONFIG_STM32F7_ADC1
adc_interrupt(&g_adcdev1);
diff --git a/arch/arm/src/stm32f7/stm32_allocateheap.c b/arch/arm/src/stm32f7/stm32_allocateheap.c
index 8b21ad68b762db71e7969c8f92e8429bdb3d6525..ffa6d27455b39b45ed67b7e487c87711de986608 100644
--- a/arch/arm/src/stm32f7/stm32_allocateheap.c
+++ b/arch/arm/src/stm32f7/stm32_allocateheap.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/stm32f7/up_allocateheap.c
*
- * Copyright (C) 2015 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
*
* Redistribution and use in source and binary forms, with or without
@@ -57,10 +57,12 @@
#include "up_arch.h"
#include "up_internal.h"
#include "stm32_mpuinit.h"
+#include "stm32_dtcm.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
+
/* Internal SRAM is available in all members of the STM32 family. The
* following definitions must be provided to specify the size and
* location of internal(system) SRAM:
@@ -92,6 +94,20 @@
#define SRAM2_START STM32_SRAM2_BASE
#define SRAM2_END (SRAM2_START + STM32F7_SRAM2_SIZE)
+/* The STM32 F7 has DTCM memory */
+
+#undef HAVE_DTCM
+#define HAVE_DTCM 1
+#if !defined(DTCM_START) || !defined(DTCM_END)
+# undef HAVE_DTCM
+#endif
+
+/* DTCM to be excluded from the main heap. */
+
+#ifdef CONFIG_STM32F7_DTCMEXCLUDE
+# undef HAVE_DTCM
+#endif
+
/* We can't possibly have FSMC SRAM if the FSMC is not enabled */
#ifndef CONFIG_STM32F7_FSMC
@@ -110,7 +126,7 @@
# endif
#endif
-/* There are 3 possible heap configurations:
+/* There are 4 possible heap configurations:
*
* Configuration 1. System SRAM1 (only)
* CONFIG_MM_REGIONS == 1
@@ -118,9 +134,18 @@
* Configuration 2. System SRAM1 and SRAM2
* CONFIG_MM_REGIONS == 2
* CONFIG_STM32F7_FSMC_SRAM NOT defined
- * Configuration 3. System SRAM1 and SRAM2 and FSMC SRAM
+ * Configuration 3. System SRAM1 and SRAM2 and DTCM
+ * CONFIG_MM_REGIONS == 3
+ * CONFIG_STM32F7_FSMC_SRAM undefined
+ * HAVE_DTCM defined
+ * Configuration 4. System SRAM1 and SRAM2 and FSMC SRAM
* CONFIG_MM_REGIONS == 3
* CONFIG_STM32F7_FSMC_SRAM defined
+ * HAVE_DTCM undefined
+ * Configuration 5. System SRAM1 and SRAM2 and DTCM and FSMC SRAM
+ * CONFIG_MM_REGIONS == 4
+ * CONFIG_STM32F7_FSMC_SRAM defined
+ * HAVE_DTCM defined
*
* Let's make sure that all definitions are consistent before doing
* anything else
@@ -128,24 +153,48 @@
#if CONFIG_MM_REGIONS < 2
# ifdef CONFIG_STM32F7_FSMC_SRAM
-# warning FSMC SRAM and SRAM2 excluded from the heap
-# else
-# warning "SRAM2 excluded from the heap"
+# warning "FSMC SRAM excluded from the heap"
+# undef CONFIG_STM32F7_FSMC_SRAM
+# endif
+# ifdef HAVE_DTCM
+# warning "DTCM excluded from the heap"
+# undef HAVE_DTCM
# endif
+# warning "SRAM2 excluded from the heap"
#elif CONFIG_MM_REGIONS < 3
# ifdef CONFIG_STM32F7_FSMC_SRAM
-# warning FSMC SRAM excluded from the heap
+# warning "FSMC SRAM excluded from the heap"
+# undef CONFIG_STM32F7_FSMC_SRAM
+# endif
+# ifdef HAVE_DTCM
+# warning "DTCM excluded from the heap"
+# undef HAVE_DTCM
# endif
#elif CONFIG_MM_REGIONS < 4
-# ifndef CONFIG_STM32F7_FSMC_SRAM
-# error CONFIG_MM_REGIONS > 2 but I do not know what some of the region(s) are
+# if defined(CONFIG_STM32F7_FSMC_SRAM) && defined(HAVE_DTCM)
+# warning "CONFIG_MM_REGIONS == 3 but have both FSMC SRAM and DTCM. DTCM excluded from the heap."
+# undef HAVE_DTCM
+# elif !defined(CONFIG_STM32F7_FSMC_SRAM) && !defined(HAVE_DTCM)
+# error "CONFIG_MM_REGIONS == 3 but I do not know what some of the region(s) are"
+# undef CONFIG_MM_REGIONS
+# define CONFIG_MM_REGIONS 2
+# endif
+#elif CONFIG_MM_REGIONS < 5
+# if !defined(CONFIG_STM32F7_FSMC_SRAM) && !defined(HAVE_DTCM)
+# error "CONFIG_MM_REGIONS == 4 but I do not know what some of the region(s) are"
# undef CONFIG_MM_REGIONS
# define CONFIG_MM_REGIONS 2
+# elif !defined(CONFIG_STM32F7_FSMC_SRAM) || !defined(HAVE_DTCM)
+# error "CONFIG_MM_REGIONS == 4 but I do not know what some of the region(s) are"
+# undef CONFIG_MM_REGIONS
+# define CONFIG_MM_REGIONS 3
# endif
#else
-# error CONFIG_MM_REGIONS > 3 but I do not know what some of the region(s) are
+# error "CONFIG_MM_REGIONS > 4 but I do not know what some of the region(s) are"
# undef CONFIG_MM_REGIONS
-# ifdef CONFIG_STM32F7_FSMC_SRAM
+# if defined(CONFIG_STM32F7_FSMC_SRAM) && defined(HAVE_DTCM)
+# define CONFIG_MM_REGIONS 4
+# elif defined(CONFIG_STM32F7_FSMC_SRAM) || defined(HAVE_DTCM)
# define CONFIG_MM_REGIONS 3
# else
# define CONFIG_MM_REGIONS 2
@@ -338,6 +387,24 @@ void up_addregion(void)
kumm_addregion((FAR void *)SRAM2_START, SRAM2_END-SRAM2_START);
+#ifdef HAVE_DTCM
+#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_MM_KERNEL_HEAP)
+
+ /* Allow user-mode access to the DTCM heap */
+
+ stm32_mpu_uheap((uintptr_t)DTCM_START, DTCM_END-DTCM_START);
+
+#endif
+
+ /* Colorize the heap for debug */
+
+ up_heap_color((FAR void *)DTCM_START, DTCM_END-DTCM_START);
+
+ /* Add the DTCM user heap region. */
+
+ kumm_addregion((FAR void *)DTCM_START, DTCM_END-DTCM_START);
+#endif
+
#ifdef CONFIG_STM32F7_FSMC_SRAM
#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_MM_KERNEL_HEAP)
diff --git a/arch/arm/src/stm32f7/stm32_dma.c b/arch/arm/src/stm32f7/stm32_dma.c
index a695a07adf5b5447a14f237186e25dcf1268aa5a..e1d8256f0919e142d41f8747e98ecef16b7bef25 100644
--- a/arch/arm/src/stm32f7/stm32_dma.c
+++ b/arch/arm/src/stm32f7/stm32_dma.c
@@ -369,7 +369,7 @@ static void stm32_dmastreamdisable(struct stm32_dma_s *dmast)
*
************************************************************************************/
-static int stm32_dmainterrupt(int irq, void *context)
+static int stm32_dmainterrupt(int irq, void *context, FAR void *arg)
{
struct stm32_dma_s *dmast;
uint32_t status;
@@ -482,7 +482,7 @@ void weak_function up_dmainitialize(void)
/* Attach DMA interrupt vectors */
- (void)irq_attach(dmast->irq, stm32_dmainterrupt);
+ (void)irq_attach(dmast->irq, stm32_dmainterrupt, dmast);
/* Disable the DMA stream */
diff --git a/arch/arm/src/stm32f7/stm32_ethernet.c b/arch/arm/src/stm32f7/stm32_ethernet.c
index b84e8511ac80f23a1d4ab262ab3418f360a0f4db..480c395c79e938b429a933d2253e3c56b7bf05b1 100644
--- a/arch/arm/src/stm32f7/stm32_ethernet.c
+++ b/arch/arm/src/stm32f7/stm32_ethernet.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/stm32f7/stm32_ethernet.c
*
- * Copyright (C) 2015-2016 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2015-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
*
* Redistribution and use in source and binary forms, with or without
@@ -607,7 +607,8 @@ struct stm32_ethmac_s
uint8_t intf; /* Ethernet interface number */
WDOG_ID txpoll; /* TX poll timer */
WDOG_ID txtimeout; /* TX timeout timer */
- struct work_s work; /* For deferring work to the work queue */
+ struct work_s irqwork; /* For deferring interrupt work to the work queue */
+ struct work_s pollwork; /* For deferring poll work to the work queue */
/* This holds the information visible to the NuttX network */
@@ -701,7 +702,7 @@ static void stm32_freeframe(struct stm32_ethmac_s *priv);
static void stm32_txdone(struct stm32_ethmac_s *priv);
static void stm32_interrupt_work(void *arg);
-static int stm32_interrupt(int irq, void *context);
+static int stm32_interrupt(int irq, void *context, FAR void *arg);
/* Watchdog timer expirations */
@@ -2044,14 +2045,6 @@ static void stm32_txdone(struct stm32_ethmac_s *priv)
wd_cancel(priv->txtimeout);
- /* Then make sure that the TX poll timer is running (if it is already
- * running, the following would restart it). This is necessary to
- * avoid certain race conditions where the polling sequence can be
- * interrupted.
- */
-
- (void)wd_start(priv->txpoll, STM32_WDDELAY, stm32_poll_expiry, 1, priv);
-
/* And disable further TX interrupts. */
stm32_disableint(priv, ETH_DMAINT_TI);
@@ -2185,7 +2178,7 @@ static void stm32_interrupt_work(void *arg)
*
****************************************************************************/
-static int stm32_interrupt(int irq, void *context)
+static int stm32_interrupt(int irq, void *context, FAR void *arg)
{
struct stm32_ethmac_s *priv = &g_stm32ethmac[0];
uint32_t dmasr;
@@ -2214,13 +2207,9 @@ static int stm32_interrupt(int irq, void *context)
wd_cancel(priv->txtimeout);
}
- /* Cancel any pending poll work */
-
- work_cancel(ETHWORK, &priv->work);
-
/* Schedule to perform the interrupt processing on the worker thread. */
- work_queue(ETHWORK, &priv->work, stm32_interrupt_work, priv, 0);
+ work_queue(ETHWORK, &priv->irqwork, stm32_interrupt_work, priv, 0);
}
return OK;
@@ -2293,15 +2282,9 @@ static void stm32_txtimeout_expiry(int argc, uint32_t arg, ...)
up_disable_irq(STM32_IRQ_ETH);
- /* Cancel any pending poll or interrupt work. This will have no effect
- * on work that has already been started.
- */
-
- work_cancel(ETHWORK, &priv->work);
-
/* Schedule to perform the TX timeout processing on the worker thread. */
- work_queue(ETHWORK, &priv->work, stm32_txtimeout_work, priv, 0);
+ work_queue(ETHWORK, &priv->irqwork, stm32_txtimeout_work, priv, 0);
}
/****************************************************************************
@@ -2398,24 +2381,9 @@ static void stm32_poll_expiry(int argc, uint32_t arg, ...)
{
struct stm32_ethmac_s *priv = (struct stm32_ethmac_s *)arg;
- /* Is our single work structure available? It may not be if there are
- * pending interrupt actions.
- */
+ /* Schedule to perform the interrupt processing on the worker thread. */
- if (work_available(&priv->work))
- {
- /* Schedule to perform the interrupt processing on the worker thread. */
-
- work_queue(ETHWORK, &priv->work, stm32_poll_work, priv, 0);
- }
- else
- {
- /* No.. Just re-start the watchdog poll timer, missing one polling
- * cycle.
- */
-
- (void)wd_start(priv->txpoll, STM32_WDDELAY, stm32_poll_expiry, 1, (uint32_t)priv);
- }
+ work_queue(ETHWORK, &priv->pollwork, stm32_poll_work, priv, 0);
}
/****************************************************************************
@@ -2584,11 +2552,11 @@ static int stm32_txavail(struct net_driver_s *dev)
* availability action.
*/
- if (work_available(&priv->work))
+ if (work_available(&priv->pollwork))
{
/* Schedule to serialize the poll on the worker thread. */
- work_queue(ETHWORK, &priv->work, stm32_txavail_work, priv, 0);
+ work_queue(ETHWORK, &priv->pollwork, stm32_txavail_work, priv, 0);
}
return OK;
@@ -4121,7 +4089,7 @@ int stm32_ethinitialize(int intf)
/* Attach the IRQ to the driver */
- if (irq_attach(STM32_IRQ_ETH, stm32_interrupt))
+ if (irq_attach(STM32_IRQ_ETH, stm32_interrupt, NULL))
{
/* We could not attach the ISR to the interrupt */
diff --git a/arch/arm/src/stm32f7/stm32_exti.h b/arch/arm/src/stm32f7/stm32_exti.h
index 38ed8a1d6ed78bdcfdd45c6ab17eefe73da0756a..f9b1f2eaa0c3c1460f7a7b0293dcc008aeb943d7 100644
--- a/arch/arm/src/stm32f7/stm32_exti.h
+++ b/arch/arm/src/stm32f7/stm32_exti.h
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/stm32f7/stm32_exti.h
*
- * Copyright (C) 2015 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
*
* Redistribution and use in source and binary forms, with or without
@@ -72,22 +72,22 @@ extern "C"
* Description:
* Sets/clears GPIO based event and interrupt triggers.
*
- * Parameters:
+ * Input Parameters:
* - pinset: GPIO pin configuration
* - risingedge: Enables interrupt on rising edges
* - fallingedge: Enables interrupt on falling edges
* - event: Generate event when set
* - func: When non-NULL, generate interrupt
+ * - arg: Argument passed to the interrupt callback
*
- * Returns:
- * The previous value of the interrupt handler function pointer. This
- * value may, for example, be used to restore the previous handler when
- * multiple handlers are used.
+ * Returned Value:
+ * Zero (OK) on success; a negated errno value on failure indicating the
+ * nature of the failure.
*
- ****************************************************************************/
+ ************************************************************************************/
-xcpt_t stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
- bool event, xcpt_t func);
+int stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
+ bool event, xcpt_t func, void *arg);
/****************************************************************************
* Name: stm32_exti_alarm
@@ -95,21 +95,22 @@ xcpt_t stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
* Description:
* Sets/clears EXTI alarm interrupt.
*
- * Parameters:
+ * Input Parameters:
* - risingedge: Enables interrupt on rising edges
* - fallingedge: Enables interrupt on falling edges
* - event: Generate event when set
* - func: When non-NULL, generate interrupt
+ * - arg: Argument passed to the interrupt callback
*
- * Returns:
- * The previous value of the interrupt handler function pointer. This
- * value may, for example, be used to restore the previous handler when
- * multiple handlers are used.
+ * Returned Value:
+ * Zero (OK) on success; a negated errno value on failure indicating the
+ * nature of the failure.
*
****************************************************************************/
#ifdef CONFIG_RTC_ALARM
-xcpt_t stm32_exti_alarm(bool risingedge, bool fallingedge, bool event, xcpt_t func);
+int stm32_exti_alarm(bool risingedge, bool fallingedge, bool event,
+ xcpt_t func, void *arg);
#endif
#undef EXTERN
diff --git a/arch/arm/src/stm32f7/stm32_exti_alarm.c b/arch/arm/src/stm32f7/stm32_exti_alarm.c
index ff53915178a1a4d9ebf41a96484bd1f76f44df1a..9fd90d761852829390e02ced27826ff187a19c2c 100644
--- a/arch/arm/src/stm32f7/stm32_exti_alarm.c
+++ b/arch/arm/src/stm32f7/stm32_exti_alarm.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/stm32f7/stm32_exti_alarm.c
*
- * Copyright (C) 2015 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
*
* This file derives from similar logic for the STM32 F1:
@@ -57,17 +57,14 @@
#include "stm32_gpio.h"
#include "stm32_exti.h"
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
/****************************************************************************
* Private Data
****************************************************************************/
/* Interrupt handlers attached to the ALARM EXTI */
-static xcpt_t stm32_exti_callback;
+static xcpt_t g_alarm_callback;
+static void *g_callback_arg;
/****************************************************************************
* Public Data
@@ -85,7 +82,7 @@ static xcpt_t stm32_exti_callback;
*
****************************************************************************/
-static int stm32_exti_alarm_isr(int irq, void *context)
+static int stm32_exti_alarm_isr(int irq, void *context, FAR void *arg)
{
int ret = OK;
@@ -95,9 +92,9 @@ static int stm32_exti_alarm_isr(int irq, void *context)
/* And dispatch the interrupt to the handler */
- if (stm32_exti_callback)
+ if (g_alarm_callback != NULL)
{
- ret = stm32_exti_callback(irq, context);
+ ret = g_alarm_callback(irq, context, g_callback_arg);
}
return ret;
@@ -117,29 +114,27 @@ static int stm32_exti_alarm_isr(int irq, void *context)
* - rising/falling edge: enables interrupt on rising/falling edget
* - event: generate event when set
* - func: when non-NULL, generate interrupt
+ * - arg: Argument passed to the interrupt callback
*
* Returns:
- * The previous value of the interrupt handler function pointer. This
- * value may, for example, be used to restore the previous handler when
- * multiple handlers are used.
+ * Zero (OK) on success; a negated errno value on failure indicating the
+ * nature of the failure.
*
****************************************************************************/
-xcpt_t stm32_exti_alarm(bool risingedge, bool fallingedge, bool event,
- xcpt_t func)
+int stm32_exti_alarm(bool risingedge, bool fallingedge, bool event,
+ xcpt_t func, void *arg)
{
- xcpt_t oldhandler;
-
/* Get the previous GPIO IRQ handler; Save the new IRQ handler. */
- oldhandler = stm32_exti_callback;
- stm32_exti_callback = func;
+ g_alarm_callback = func;
+ g_callback_arg = arg;
/* Install external interrupt handlers (if not already attached) */
if (func)
{
- irq_attach(STM32_IRQ_RTCALRM, stm32_exti_alarm_isr);
+ irq_attach(STM32_IRQ_RTCALRM, stm32_exti_alarm_isr, NULL);
up_enable_irq(STM32_IRQ_RTCALRM);
}
else
@@ -167,5 +162,5 @@ xcpt_t stm32_exti_alarm(bool risingedge, bool fallingedge, bool event,
/* Return the old IRQ handler */
- return oldhandler;
+ return OK;
}
diff --git a/arch/arm/src/stm32f7/stm32_exti_gpio.c b/arch/arm/src/stm32f7/stm32_exti_gpio.c
index ec4cd1a7d7156a19f686a4a7e1952fba2d260c2e..e388054515967d448d229e5a7126c01a1c53ab0c 100644
--- a/arch/arm/src/stm32f7/stm32_exti_gpio.c
+++ b/arch/arm/src/stm32f7/stm32_exti_gpio.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/stm32f7/stm32_exti_gpio.c
*
- * Copyright (C) 2015 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
*
* Based on EXTI GPIO logic from the Cortex-M3/4 which includes contributions
@@ -68,13 +68,23 @@
#if defined(CONFIG_STM32F7_STM32F74XX) || defined(CONFIG_STM32F7_STM32F75XX) \
|| defined(CONFIG_STM32F7_STM32F76XX) || defined(CONFIG_STM32F7_STM32F77XX)
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct gpio_callback_s
+{
+ xcpt_t callback;
+ void *arg;
+};
+
/****************************************************************************
* Private Data
****************************************************************************/
/* Interrupt handlers attached to each EXTI */
-static xcpt_t stm32_exti_callbacks[16];
+static struct gpio_callback_s g_gpio_callbacks[16];
/****************************************************************************
* Private Functions
@@ -84,7 +94,7 @@ static xcpt_t stm32_exti_callbacks[16];
* Interrupt Service Routines - Dispatchers
****************************************************************************/
-static int stm32_exti0_isr(int irq, void *context)
+static int stm32_exti0_isr(int irq, void *context, void *arg)
{
int ret = OK;
@@ -94,15 +104,18 @@ static int stm32_exti0_isr(int irq, void *context)
/* And dispatch the interrupt to the handler */
- if (stm32_exti_callbacks[0])
+ if (g_gpio_callbacks[0].callback != NULL)
{
- ret = stm32_exti_callbacks[0](irq, context);
+ xcpt_t callback = g_gpio_callbacks[0].callback;
+ void *cbarg = g_gpio_callbacks[0].arg;
+
+ ret = callback(irq, context, cbarg);
}
return ret;
}
-static int stm32_exti1_isr(int irq, void *context)
+static int stm32_exti1_isr(int irq, void *context, void *arg)
{
int ret = OK;
@@ -112,15 +125,18 @@ static int stm32_exti1_isr(int irq, void *context)
/* And dispatch the interrupt to the handler */
- if (stm32_exti_callbacks[1])
+ if (g_gpio_callbacks[1].callback != NULL)
{
- ret = stm32_exti_callbacks[1](irq, context);
+ xcpt_t callback = g_gpio_callbacks[1].callback;
+ void *cbarg = g_gpio_callbacks[1].arg;
+
+ ret = callback(irq, context, cbarg);
}
return ret;
}
-static int stm32_exti2_isr(int irq, void *context)
+static int stm32_exti2_isr(int irq, void *context, void *arg)
{
int ret = OK;
@@ -130,15 +146,18 @@ static int stm32_exti2_isr(int irq, void *context)
/* And dispatch the interrupt to the handler */
- if (stm32_exti_callbacks[2])
+ if (g_gpio_callbacks[2].callback != NULL)
{
- ret = stm32_exti_callbacks[2](irq, context);
+ xcpt_t callback = g_gpio_callbacks[2].callback;
+ void *cbarg = g_gpio_callbacks[2].arg;
+
+ ret = callback(irq, context, cbarg);
}
return ret;
}
-static int stm32_exti3_isr(int irq, void *context)
+static int stm32_exti3_isr(int irq, void *context, void *arg)
{
int ret = OK;
@@ -148,15 +167,18 @@ static int stm32_exti3_isr(int irq, void *context)
/* And dispatch the interrupt to the handler */
- if (stm32_exti_callbacks[3])
+ if (g_gpio_callbacks[3].callback != NULL)
{
- ret = stm32_exti_callbacks[3](irq, context);
+ xcpt_t callback = g_gpio_callbacks[3].callback;
+ void *cbarg = g_gpio_callbacks[3].arg;
+
+ ret = callback(irq, context, cbarg);
}
return ret;
}
-static int stm32_exti4_isr(int irq, void *context)
+static int stm32_exti4_isr(int irq, void *context, void *arg)
{
int ret = OK;
@@ -166,9 +188,12 @@ static int stm32_exti4_isr(int irq, void *context)
/* And dispatch the interrupt to the handler */
- if (stm32_exti_callbacks[4])
+ if (g_gpio_callbacks[4].callback != NULL)
{
- ret = stm32_exti_callbacks[4](irq, context);
+ xcpt_t callback = g_gpio_callbacks[4].callback;
+ void *cbarg = g_gpio_callbacks[4].arg;
+
+ ret = callback(irq, context, cbarg);
}
return ret;
@@ -199,10 +224,14 @@ static int stm32_exti_multiisr(int irq, void *context, int first, int last)
/* And dispatch the interrupt to the handler */
- if (stm32_exti_callbacks[pin])
+ if (g_gpio_callbacks[pin].callback != NULL)
{
- int tmp = stm32_exti_callbacks[pin](irq, context);
- if (tmp != OK)
+ xcpt_t callback = g_gpio_callbacks[pin].callback;
+ void *cbarg = g_gpio_callbacks[pin].arg;
+ int tmp;
+
+ tmp = callback(irq, context, cbarg);
+ if (tmp < 0)
{
ret = tmp;
}
@@ -213,12 +242,12 @@ static int stm32_exti_multiisr(int irq, void *context, int first, int last)
return ret;
}
-static int stm32_exti95_isr(int irq, void *context)
+static int stm32_exti95_isr(int irq, void *context, void *arg)
{
return stm32_exti_multiisr(irq, context, 5, 9);
}
-static int stm32_exti1510_isr(int irq, void *context)
+static int stm32_exti1510_isr(int irq, void *context, void *arg)
{
return stm32_exti_multiisr(irq, context, 10, 15);
}
@@ -233,30 +262,29 @@ static int stm32_exti1510_isr(int irq, void *context)
* Description:
* Sets/clears GPIO based event and interrupt triggers.
*
- * Parameters:
+ * Input Parameters:
* - pinset: GPIO pin configuration
* - risingedge: Enables interrupt on rising edges
* - fallingedge: Enables interrupt on falling edges
* - event: Generate event when set
* - func: When non-NULL, generate interrupt
+ * - arg: Argument passed to the interrupt callback
*
- * Returns:
- * The previous value of the interrupt handler function pointer. This
- * value may, for example, be used to restore the previous handler when
- * multiple handlers are used.
+ * Returned Value:
+ * Zero (OK) on success; a negated errno value on failure indicating the
+ * nature of the failure.
*
****************************************************************************/
-xcpt_t stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
- bool event, xcpt_t func)
+int stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
+ bool event, xcpt_t func, void *arg)
{
+ struct gpio_callback_s *shared_cbs;
uint32_t pin = pinset & GPIO_PIN_MASK;
uint32_t exti = STM32_EXTI_BIT(pin);
int irq;
xcpt_t handler;
- xcpt_t oldhandler = NULL;
int nshared;
- xcpt_t *shared_cbs;
int i;
/* Select the interrupt handler for this EXTI pin */
@@ -265,7 +293,7 @@ xcpt_t stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
{
irq = pin + STM32_IRQ_EXTI0;
nshared = 1;
- shared_cbs = &stm32_exti_callbacks[pin];
+ shared_cbs = &g_gpio_callbacks[pin];
switch (pin)
{
case 0:
@@ -293,27 +321,27 @@ xcpt_t stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
{
irq = STM32_IRQ_EXTI95;
handler = stm32_exti95_isr;
- shared_cbs = &stm32_exti_callbacks[5];
+ shared_cbs = &g_gpio_callbacks[5];
nshared = 5;
}
else
{
irq = STM32_IRQ_EXTI1510;
handler = stm32_exti1510_isr;
- shared_cbs = &stm32_exti_callbacks[10];
+ shared_cbs = &g_gpio_callbacks[10];
nshared = 6;
}
/* Get the previous GPIO IRQ handler; Save the new IRQ handler. */
- oldhandler = stm32_exti_callbacks[pin];
- stm32_exti_callbacks[pin] = func;
+ g_gpio_callbacks[pin].callback = func;
+ g_gpio_callbacks[pin].arg = arg;
/* Install external interrupt handlers */
if (func)
{
- irq_attach(irq, handler);
+ irq_attach(irq, handler, NULL);
up_enable_irq(irq);
}
else
@@ -324,7 +352,7 @@ xcpt_t stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
for (i = 0; i < nshared; i++)
{
- if (shared_cbs[i] != NULL)
+ if (shared_cbs[i].callback != NULL)
{
break;
}
@@ -365,9 +393,7 @@ xcpt_t stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
func ? 0 : exti,
func ? exti : 0);
- /* Return the old IRQ handler */
-
- return oldhandler;
+ return OK;
}
#endif /* CONFIG_STM32F7_STM32F74XX || CONFIG_STM32F7_STM32F75XX */
diff --git a/arch/arm/src/stm32f7/stm32_exti_pwr.c b/arch/arm/src/stm32f7/stm32_exti_pwr.c
index 104dbff01055da91010d43b23fb5002cd30b64be..09d064e930ebf3e8efa3a05ec186250ab99ff4e5 100644
--- a/arch/arm/src/stm32f7/stm32_exti_pwr.c
+++ b/arch/arm/src/stm32f7/stm32_exti_pwr.c
@@ -70,7 +70,8 @@
/* Interrupt handlers attached to the PVD EXTI */
-static xcpt_t stm32_exti_pvd_callback;
+static xcpt_t g_pvd_callback;
+static void *g_callback_arg;
/****************************************************************************
* Public Data
@@ -88,7 +89,7 @@ static xcpt_t stm32_exti_pvd_callback;
*
****************************************************************************/
-static int stm32_exti_pvd_isr(int irq, void *context)
+static int stm32_exti_pvd_isr(int irq, void *context, void *arg)
{
int ret = OK;
@@ -98,9 +99,9 @@ static int stm32_exti_pvd_isr(int irq, void *context)
/* And dispatch the interrupt to the handler */
- if (stm32_exti_pvd_callback)
+ if (g_pvd_callback)
{
- ret = stm32_exti_pvd_callback(irq, context);
+ ret = g_pvd_callback(irq, context, g_callback_arg);
}
return ret;
@@ -122,27 +123,24 @@ static int stm32_exti_pvd_isr(int irq, void *context)
* - func: when non-NULL, generate interrupt
*
* Returns:
- * The previous value of the interrupt handler function pointer. This
- * value may, for example, be used to restore the previous handler when
- * multiple handlers are used.
+ * Zero (OK) returned on success; a negated errno value is returned on
+ * failure.
*
****************************************************************************/
-xcpt_t stm32_exti_pvd(bool risingedge, bool fallingedge, bool event,
- xcpt_t func)
+int stm32_exti_pvd(bool risingedge, bool fallingedge, bool event,
+ xcpt_t func, void *arg);
{
- xcpt_t oldhandler;
-
/* Get the previous GPIO IRQ handler; Save the new IRQ handler. */
- oldhandler = stm32_exti_pvd_callback;
- stm32_exti_pvd_callback = func;
+ g_pvd_callback = func;
+ g_callback_arg = arg;
/* Install external interrupt handlers (if not already attached) */
if (func)
{
- irq_attach(STM32_IRQ_PVD, stm32_exti_pvd_isr);
+ irq_attach(STM32_IRQ_PVD, stm32_exti_pvd_isr, NULL);
up_enable_irq(STM32_IRQ_PVD);
}
else
@@ -168,7 +166,5 @@ xcpt_t stm32_exti_pvd(bool risingedge, bool fallingedge, bool event,
func ? 0 : EXTI_PVD_LINE,
func ? EXTI_PVD_LINE : 0);
- /* Return the old IRQ handler */
-
- return oldhandler;
+ return OK;
}
diff --git a/arch/arm/src/stm32f7/stm32_exti_pwr.h b/arch/arm/src/stm32f7/stm32_exti_pwr.h
index b72acd5cc9fcaeeec51b942753151befd7ebeedc..67e22d05ff8400fb6b14f351c19f09f9a724e7f8 100644
--- a/arch/arm/src/stm32f7/stm32_exti_pwr.h
+++ b/arch/arm/src/stm32f7/stm32_exti_pwr.h
@@ -58,15 +58,15 @@
* - rising/falling edge: enables interrupt on rising/falling edge
* - event: generate event when set
* - func: when non-NULL, generate interrupt
+ * - arg: Argument passed to the interrupt callback
*
* Returns:
- * The previous value of the interrupt handler function pointer. This
- * value may, for example, be used to restore the previous handler when
- * multiple handlers are used.
+ * Zero (OK) returned on success; a negated errno value is returned on
+ * failure.
*
****************************************************************************/
-xcpt_t stm32_exti_pvd(bool risingedge, bool fallingedge, bool event,
- xcpt_t func);
+int stm32_exti_pvd(bool risingedge, bool fallingedge, bool event,
+ xcpt_t func, void *arg);
#endif /* __ARCH_ARM_SRC_STM32F7_STM32_EXTI_PWR_H */
diff --git a/arch/arm/src/stm32f7/stm32_gpio.h b/arch/arm/src/stm32f7/stm32_gpio.h
index f79b398b7a1b9eae53e022628a33b7490046cf29..35b7fc39d25d18139346a38b3886323a5a49bd1e 100644
--- a/arch/arm/src/stm32f7/stm32_gpio.h
+++ b/arch/arm/src/stm32f7/stm32_gpio.h
@@ -266,7 +266,7 @@ EXTERN const uint32_t g_gpiobase[STM32F7_NGPIO];
* function, it must be unconfigured with stm32_unconfiggpio() with
* the same cfgset first before it can be set to non-alternative function.
*
- * Returns:
+ * Returned Value:
* OK on success
* ERROR on invalid port, or when pin is locked as ALT function.
*
@@ -287,7 +287,7 @@ int stm32_configgpio(uint32_t cfgset);
* operate in PWM mode could produce excessive on-board currents and trigger
* over-current/alarm function.
*
- * Returns:
+ * Returned Value:
* OK on success
* ERROR on invalid port
*
@@ -315,27 +315,28 @@ void stm32_gpiowrite(uint32_t pinset, bool value);
bool stm32_gpioread(uint32_t pinset);
-/************************************************************************************
+/****************************************************************************
* Name: stm32_gpiosetevent
*
* Description:
* Sets/clears GPIO based event and interrupt triggers.
*
- * Parameters:
- * - pinset: gpio pin configuration
- * - rising/falling edge: enables
- * - event: generate event when set
- * - func: when non-NULL, generate interrupt
+ * Input Parameters:
+ * - pinset: GPIO pin configuration
+ * - risingedge: Enables interrupt on rising edges
+ * - fallingedge: Enables interrupt on falling edges
+ * - event: Generate event when set
+ * - func: When non-NULL, generate interrupt
+ * - arg: Argument passed to the interrupt callback
*
- * Returns:
- * The previous value of the interrupt handler function pointer. This value may,
- * for example, be used to restore the previous handler when multiple handlers are
- * used.
+ * Returned Value:
+ * Zero (OK) on success; a negated errno value on failure indicating the
+ * nature of the failure.
*
************************************************************************************/
-xcpt_t stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
- bool event, xcpt_t func);
+int stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
+ bool event, xcpt_t func, void *arg);
/************************************************************************************
* Function: stm32_dumpgpio
diff --git a/arch/arm/src/stm32f7/stm32_i2c.c b/arch/arm/src/stm32f7/stm32_i2c.c
index d089db9623bbc107a25123391a8d00bc1b5c2724..c98a1bd2251ced43bb6fc73d1534402deb2c546f 100644
--- a/arch/arm/src/stm32f7/stm32_i2c.c
+++ b/arch/arm/src/stm32f7/stm32_i2c.c
@@ -402,7 +402,7 @@ struct stm32_i2c_config_s
uint32_t scl_pin; /* GPIO configuration for SCL as SCL */
uint32_t sda_pin; /* GPIO configuration for SDA as SDA */
#ifndef CONFIG_I2C_POLLED
- int (*isr)(int, void *); /* Interrupt handler */
+ int (*isr)(int, void *, void *); /* Interrupt handler */
uint32_t ev_irq; /* Event IRQ */
uint32_t er_irq; /* Error IRQ */
#endif
@@ -487,16 +487,16 @@ static inline uint32_t stm32_i2c_getstatus(FAR struct stm32_i2c_priv_s *priv);
static int stm32_i2c_isr(struct stm32_i2c_priv_s * priv);
#ifndef CONFIG_I2C_POLLED
# ifdef CONFIG_STM32F7_I2C1
-static int stm32_i2c1_isr(int irq, void *context);
+static int stm32_i2c1_isr(int irq, void *context, FAR void *arg);
# endif
# ifdef CONFIG_STM32F7_I2C2
-static int stm32_i2c2_isr(int irq, void *context);
+static int stm32_i2c2_isr(int irq, void *context, FAR void *arg);
# endif
# ifdef CONFIG_STM32F7_I2C3
-static int stm32_i2c3_isr(int irq, void *context);
+static int stm32_i2c3_isr(int irq, void *context, FAR void *arg);
# endif
# ifdef CONFIG_STM32F7_I2C4
-static int stm32_i2c4_isr(int irq, void *context);
+static int stm32_i2c4_isr(int irq, void *context, FAR void *arg);
# endif
#endif
static int stm32_i2c_init(FAR struct stm32_i2c_priv_s *priv);
@@ -2152,7 +2152,7 @@ static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv)
#ifndef CONFIG_I2C_POLLED
# ifdef CONFIG_STM32F7_I2C1
-static int stm32_i2c1_isr(int irq, void *context)
+static int stm32_i2c1_isr(int irq, void *context, FAR void *arg)
{
return stm32_i2c_isr(&stm32_i2c1_priv);
}
@@ -2167,7 +2167,7 @@ static int stm32_i2c1_isr(int irq, void *context)
************************************************************************************/
# ifdef CONFIG_STM32F7_I2C2
-static int stm32_i2c2_isr(int irq, void *context)
+static int stm32_i2c2_isr(int irq, void *context, FAR void *arg)
{
return stm32_i2c_isr(&stm32_i2c2_priv);
}
@@ -2182,7 +2182,7 @@ static int stm32_i2c2_isr(int irq, void *context)
************************************************************************************/
# ifdef CONFIG_STM32F7_I2C3
-static int stm32_i2c3_isr(int irq, void *context)
+static int stm32_i2c3_isr(int irq, void *context, FAR void *arg)
{
return stm32_i2c_isr(&stm32_i2c3_priv);
}
@@ -2197,7 +2197,7 @@ static int stm32_i2c3_isr(int irq, void *context)
************************************************************************************/
# ifdef CONFIG_STM32F7_I2C4
-static int stm32_i2c4_isr(int irq, void *context)
+static int stm32_i2c4_isr(int irq, void *context, FAR void *arg)
{
return stm32_i2c_isr(&stm32_i2c4_priv);
}
@@ -2242,8 +2242,8 @@ static int stm32_i2c_init(FAR struct stm32_i2c_priv_s *priv)
#ifndef CONFIG_I2C_POLLED
/* Attach error and event interrupts to the ISRs */
- irq_attach(priv->config->ev_irq, priv->config->isr);
- irq_attach(priv->config->er_irq, priv->config->isr);
+ irq_attach(priv->config->ev_irq, priv->config->isr, NULL);
+ irq_attach(priv->config->er_irq, priv->config->isr, NULL);
up_enable_irq(priv->config->ev_irq);
up_enable_irq(priv->config->er_irq);
#endif
diff --git a/arch/arm/src/stm32f7/stm32_irq.c b/arch/arm/src/stm32f7/stm32_irq.c
index 758f32b14778b41a3317ea5c7b6c11815db4e1ad..b24075010362497cf64e60151ff2a64cd28f40b7 100644
--- a/arch/arm/src/stm32f7/stm32_irq.c
+++ b/arch/arm/src/stm32f7/stm32_irq.c
@@ -186,7 +186,7 @@ static void stm32_dumpnvic(const char *msg, int irq)
****************************************************************************/
#ifdef CONFIG_DEBUG_FEATURES
-static int stm32_nmi(int irq, FAR void *context)
+static int stm32_nmi(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! NMI received\n");
@@ -194,7 +194,7 @@ static int stm32_nmi(int irq, FAR void *context)
return 0;
}
-static int stm32_busfault(int irq, FAR void *context)
+static int stm32_busfault(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Bus fault received: %08x\n", getreg32(NVIC_CFAULTS));
@@ -202,7 +202,7 @@ static int stm32_busfault(int irq, FAR void *context)
return 0;
}
-static int stm32_usagefault(int irq, FAR void *context)
+static int stm32_usagefault(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Usage fault received: %08x\n", getreg32(NVIC_CFAULTS));
@@ -210,7 +210,7 @@ static int stm32_usagefault(int irq, FAR void *context)
return 0;
}
-static int stm32_pendsv(int irq, FAR void *context)
+static int stm32_pendsv(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! PendSV received\n");
@@ -218,7 +218,7 @@ static int stm32_pendsv(int irq, FAR void *context)
return 0;
}
-static int stm32_dbgmonitor(int irq, FAR void *context)
+static int stm32_dbgmonitor(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Debug Monitor received\n");
@@ -226,7 +226,7 @@ static int stm32_dbgmonitor(int irq, FAR void *context)
return 0;
}
-static int stm32_reserved(int irq, FAR void *context)
+static int stm32_reserved(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Reserved interrupt\n");
@@ -469,8 +469,8 @@ void up_irqinitialize(void)
* under certain conditions.
*/
- irq_attach(STM32_IRQ_SVCALL, up_svcall);
- irq_attach(STM32_IRQ_HARDFAULT, up_hardfault);
+ irq_attach(STM32_IRQ_SVCALL, up_svcall, NULL);
+ irq_attach(STM32_IRQ_HARDFAULT, up_hardfault, NULL);
/* Set the priority of the SVCall interrupt */
@@ -486,22 +486,22 @@ void up_irqinitialize(void)
*/
#ifdef CONFIG_ARM_MPU
- irq_attach(STM32_IRQ_MEMFAULT, up_memfault);
+ irq_attach(STM32_IRQ_MEMFAULT, up_memfault, NULL);
up_enable_irq(STM32_IRQ_MEMFAULT);
#endif
/* Attach all other processor exceptions (except reset and sys tick) */
#ifdef CONFIG_DEBUG_FEATURES
- irq_attach(STM32_IRQ_NMI, stm32_nmi);
+ irq_attach(STM32_IRQ_NMI, stm32_nmi, NULL);
#ifndef CONFIG_ARM_MPU
- irq_attach(STM32_IRQ_MEMFAULT, up_memfault);
+ irq_attach(STM32_IRQ_MEMFAULT, up_memfault, NULL);
#endif
- irq_attach(STM32_IRQ_BUSFAULT, stm32_busfault);
- irq_attach(STM32_IRQ_USAGEFAULT, stm32_usagefault);
- irq_attach(STM32_IRQ_PENDSV, stm32_pendsv);
- irq_attach(STM32_IRQ_DBGMONITOR, stm32_dbgmonitor);
- irq_attach(STM32_IRQ_RESERVED, stm32_reserved);
+ irq_attach(STM32_IRQ_BUSFAULT, stm32_busfault, NULL);
+ irq_attach(STM32_IRQ_USAGEFAULT, stm32_usagefault, NULL);
+ irq_attach(STM32_IRQ_PENDSV, stm32_pendsv, NULL);
+ irq_attach(STM32_IRQ_DBGMONITOR, stm32_dbgmonitor, NULL);
+ irq_attach(STM32_IRQ_RESERVED, stm32_reserved, NULL);
#endif
stm32_dumpnvic("initial", STM32_IRQ_NIRQS);
diff --git a/arch/arm/src/stm32f7/stm32_otgdev.c b/arch/arm/src/stm32f7/stm32_otgdev.c
index 9bf818182b4a20c65e8202c1e129572ba3e02026..ff2a6e026ee470b927fc23d4ed937adbbf238120 100644
--- a/arch/arm/src/stm32f7/stm32_otgdev.c
+++ b/arch/arm/src/stm32f7/stm32_otgdev.c
@@ -650,7 +650,7 @@ static inline void stm32_otginterrupt(FAR struct stm32_usbdev_s *priv);
/* First level interrupt processing */
-static int stm32_usbinterrupt(int irq, FAR void *context);
+static int stm32_usbinterrupt(int irq, FAR void *context, FAR void *arg);
/* Endpoint operations *********************************************************/
/* Global OUT NAK controls */
@@ -3572,7 +3572,7 @@ static inline void stm32_otginterrupt(FAR struct stm32_usbdev_s *priv)
*
****************************************************************************/
-static int stm32_usbinterrupt(int irq, FAR void *context)
+static int stm32_usbinterrupt(int irq, FAR void *context, FAR void *arg)
{
/* At present, there is only a single OTG device support. Hence it is
* pre-allocated as g_otghsdev. However, in most code, the private data
@@ -5557,7 +5557,7 @@ void up_usbinitialize(void)
/* Attach the OTG interrupt handler */
- ret = irq_attach(STM32_IRQ_OTG, stm32_usbinterrupt);
+ ret = irq_attach(STM32_IRQ_OTG, stm32_usbinterrupt, NULL);
if (ret < 0)
{
uerr("irq_attach failed\n", ret);
diff --git a/arch/arm/src/stm32f7/stm32_otghost.c b/arch/arm/src/stm32f7/stm32_otghost.c
index 12488c262f07069229804ff918f4534b24fcffe8..9eb12159e7d51c322dabf2714e75b455545aec0e 100644
--- a/arch/arm/src/stm32f7/stm32_otghost.c
+++ b/arch/arm/src/stm32f7/stm32_otghost.c
@@ -406,7 +406,7 @@ static inline void stm32_gint_ipxfrisr(FAR struct stm32_usbhost_s *priv);
/* First level, global interrupt handler */
-static int stm32_gint_isr(int irq, FAR void *context);
+static int stm32_gint_isr(int irq, FAR void *context, FAR void *arg);
/* Interrupt controls */
@@ -3430,7 +3430,7 @@ static inline void stm32_gint_ipxfrisr(FAR struct stm32_usbhost_s *priv)
*
****************************************************************************/
-static int stm32_gint_isr(int irq, FAR void *context)
+static int stm32_gint_isr(int irq, FAR void *context, FAR void *arg)
{
/* At present, there is only support for a single OTG FS host. Hence it is
* pre-allocated as g_usbhost. However, in most code, the private data
@@ -5300,7 +5300,7 @@ FAR struct usbhost_connection_s *stm32_otgfshost_initialize(int controller)
/* Attach USB host controller interrupt handler */
- if (irq_attach(STM32_IRQ_OTGFS, stm32_gint_isr) != 0)
+ if (irq_attach(STM32_IRQ_OTGFS, stm32_gint_isr, NULL) != 0)
{
usbhost_trace1(OTG_TRACE1_IRQATTACH, 0);
return NULL;
diff --git a/arch/arm/src/stm32f7/stm32_rtc.c b/arch/arm/src/stm32f7/stm32_rtc.c
index 5445c01de97dea53a5055d0c43d7dd00b0a1db25..8a21ec41fea98b9a397d75e7ea473ca6bb1c4a6c 100644
--- a/arch/arm/src/stm32f7/stm32_rtc.c
+++ b/arch/arm/src/stm32f7/stm32_rtc.c
@@ -1037,7 +1037,7 @@ int up_rtc_initialize(void)
* 3. Configure the RTC to generate RTC alarms (Alarm A or Alarm B).
*/
- stm32_exti_alarm(true, false, true, stm32_rtc_alarm_handler);
+ (void)stm32_exti_alarm(true, false, true, stm32_rtc_alarm_handler, NULL);
rtc_dumpregs("After InitExtiAlarm");
#else
rtc_dumpregs("After Initialization");
diff --git a/arch/arm/src/stm32f7/stm32_sdmmc.c b/arch/arm/src/stm32f7/stm32_sdmmc.c
index 376f67ce2d3e17d7e8af4bbe7416802429bc2095..2249dc87c3bc9e8e4213ab96ea4d8e9a93edd756 100644
--- a/arch/arm/src/stm32f7/stm32_sdmmc.c
+++ b/arch/arm/src/stm32f7/stm32_sdmmc.c
@@ -347,13 +347,11 @@ struct stm32_dev_s
/* STM32-specific extensions */
uint32_t base;
int nirq;
- xcpt_t handler;
#ifdef CONFIG_ARCH_IRQPRIO
int irqprio;
#endif
#ifdef CONFIG_MMCSD_SDIOWAIT_WRCOMPLETE
uint32_t d0_gpio;
- xcpt_t wrchandler;
#endif
#ifdef CONFIG_STM32F7_SDMMC_DMA
uint32_t dmapri;
@@ -470,22 +468,9 @@ static void stm32_endtransfer(struct stm32_dev_s *priv, sdio_eventset_t wkupeven
/* Interrupt Handling *******************************************************/
-static int stm32_sdmmc_interrupt(struct stm32_dev_s *sdmmc_dev);
-
-#ifdef CONFIG_STM32F7_SDMMC1
-static int stm32_sdmmc1_interrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_STM32F7_SDMMC2
-static int stm32_sdmmc2_interrupt(int irq, void *context);
-#endif
-
+static int stm32_sdmmc_interrupt(int irq, void *context, void *arg);
#ifdef CONFIG_MMCSD_SDIOWAIT_WRCOMPLETE
-#ifdef CONFIG_STM32F7_SDMMC1
-static int stm32_sdmmc1_rdyinterrupt(int irq, void *context);
-#endif
-#ifdef CONFIG_STM32F7_SDMMC2
-static int stm32_sdmmc2_rdyinterrupt(int irq, void *context);
-#endif
+static int stm32_sdmmc_rdyinterrupt(int irq, void *context, void *arg);
#endif
/* SDIO interface methods ***************************************************/
@@ -609,13 +594,11 @@ struct stm32_dev_s g_sdmmcdev1 =
},
.base = STM32_SDMMC1_BASE,
.nirq = STM32_IRQ_SDMMC1,
- .handler = stm32_sdmmc1_interrupt,
#ifdef CONFIG_SDMMC1_PRI
.irqprio = CONFIG_SDMMC1_PRI,
#endif
#ifdef CONFIG_MMCSD_SDIOWAIT_WRCOMPLETE
.d0_gpio = GPIO_SDMMC1_D0,
- .wrchandler = stm32_sdmmc1_rdyinterrupt,
#endif
#ifdef CONFIG_STM32F7_SDMMC1_DMAPRIO
.dmapri = CONFIG_STM32F7_SDMMC1_DMAPRIO,
@@ -665,13 +648,11 @@ struct stm32_dev_s g_sdmmcdev2 =
},
.base = STM32_SDMMC2_BASE,
.nirq = STM32_IRQ_SDMMC2,
- .handler = stm32_sdmmc2_interrupt,
#ifdef CONFIG_SDMMC2_PRI
.irqprio = CONFIG_SDMMC2_PRI,
#endif
#ifdef CONFIG_MMCSD_SDIOWAIT_WRCOMPLETE
.d0_gpio = GPIO_SDMMC2_D0,
- .wrchandler = stm32_sdmmc2_rdyinterrupt,
#endif
#ifdef CONFIG_STM32F7_SDMMC2_DMAPRIO
.dmapri = CONFIG_STM32F7_SDMMC2_DMAPRIO,
@@ -846,14 +827,16 @@ static void stm32_configwaitints(struct stm32_dev_s *priv, uint32_t waitmask,
/* Arm the SDMMC_D Ready and install Isr */
- stm32_gpiosetevent(pinset, true, false, false, priv->wrchandler);
+ (void)stm32_gpiosetevent(pinset, true, false, false,
+ stm32_sdmmc_rdyinterrupt, priv);
}
/* Disarm SDMMC_D ready */
if ((wkupevent & SDIOWAIT_WRCOMPLETE) != 0)
{
- stm32_gpiosetevent(priv->d0_gpio, false, false, false , NULL);
+ (void)stm32_gpiosetevent(priv->d0_gpio, false, false, false,
+ NULL, NULL);
stm32_configgpio(priv->d0_gpio);
}
#endif
@@ -1505,30 +1488,19 @@ static void stm32_endtransfer(struct stm32_dev_s *priv,
****************************************************************************/
#ifdef CONFIG_MMCSD_SDIOWAIT_WRCOMPLETE
-# if defined(CONFIG_STM32F7_SDMMC1)
-static int stm32_sdmmc1_rdyinterrupt(int irq, void *context)
+static int stm32_sdmmc_rdyinterrupt(int irq, void *context, void *arg)
{
- struct stm32_dev_s *priv = &g_sdmmcdev1;
- stm32_endwait(priv, SDIOWAIT_WRCOMPLETE);
- return OK;
-}
-# endif
-
-# if defined(CONFIG_STM32F7_SDMMC2)
-static int stm32_sdmmc2_rdyinterrupt(int irq, void *context)
-{
- struct stm32_dev_s *priv = &g_sdmmcdev2;
+ struct stm32_dev_s *priv = (struct stm32_dev_s *)arg;
stm32_endwait(priv, SDIOWAIT_WRCOMPLETE);
return OK;
}
-# endif
#endif
/****************************************************************************
* Name: stm32_sdmmc_interrupt
*
* Description:
- * SDMMC common interrupt handler
+ * SDMMC interrupt handler
*
* Input Parameters:
* priv - Instance of the SDMMC private state structure.
@@ -1538,11 +1510,14 @@ static int stm32_sdmmc2_rdyinterrupt(int irq, void *context)
*
****************************************************************************/
-static int stm32_sdmmc_interrupt(struct stm32_dev_s *priv)
+static int stm32_sdmmc_interrupt(int irq, void *context, void *arg);
{
+ struct stm32_dev_s *priv =(struct stm32_dev_s *)arg;
uint32_t enabled;
uint32_t pending;
+ DEBUGASSERT(priv != NULL);
+
/* Loop while there are pending interrupts. Check the SDIO status
* register. Mask out all bits that don't correspond to enabled
* interrupts. (This depends on the fact that bits are ordered
@@ -1726,49 +1701,6 @@ static int stm32_sdmmc_interrupt(struct stm32_dev_s *priv)
return OK;
}
-/****************************************************************************
- * Name: stm32_sdmmc1_interrupt
- *
- * Description:
- * SDMMC 1 interrupt handler wrapper
- *
- * Input Parameters:
- * irq - not used
- * context - not used
- *
- * Returned Value:
- * None
- *
- ****************************************************************************/
-
-#ifdef CONFIG_STM32F7_SDMMC1
-static int stm32_sdmmc1_interrupt(int irq, void *context)
-{
- return stm32_sdmmc_interrupt(&g_sdmmcdev1);
-}
-#endif
-
-/****************************************************************************
- * Name: stm32_sdmmc2_interrupt
- *
- * Description:
- * SDMMC 2 interrupt handler wrapper
- *
- * Input Parameters:
- * irq - not used
- * context - not used
- *
- *
- * Returned Value:
- * None
- *
- ****************************************************************************/
-#ifdef CONFIG_STM32F7_SDMMC2
-static int stm32_sdmmc2_interrupt(int irq, void *context)
-{
- return stm32_sdmmc_interrupt(&g_sdmmcdev2);
-}
-#endif
/****************************************************************************
* SDIO Interface Methods
****************************************************************************/
@@ -2021,8 +1953,7 @@ static int stm32_attach(FAR struct sdio_dev_s *dev)
/* Attach the SDIO interrupt handler */
- ret = irq_attach(priv->nirq, priv->handler);
-
+ ret = irq_attach(priv->nirq, stm32_sdmmc_interrupt, priv);
if (ret == OK)
{
@@ -3064,6 +2995,7 @@ static int stm32_dmasendsetup(FAR struct sdio_dev_s *dev,
/****************************************************************************
* Initialization/uninitialization/reset
****************************************************************************/
+
/****************************************************************************
* Name: stm32_callback
*
diff --git a/arch/arm/src/stm32f7/stm32_serial.c b/arch/arm/src/stm32f7/stm32_serial.c
index 1f5445ac7105df871b3358a70283ed2551a5fd2a..77138526dd64dea41ca15495071926854fd5faaa 100644
--- a/arch/arm/src/stm32f7/stm32_serial.c
+++ b/arch/arm/src/stm32f7/stm32_serial.c
@@ -281,8 +281,6 @@ struct up_dev_s
const unsigned int rxdma_channel; /* DMA channel assigned */
#endif
- int (*const vector)(int irq, void *context); /* Interrupt handler */
-
/* RX DMA state */
#ifdef SERIAL_HAVE_DMA
@@ -308,7 +306,7 @@ static int up_setup(struct uart_dev_s *dev);
static void up_shutdown(struct uart_dev_s *dev);
static int up_attach(struct uart_dev_s *dev);
static void up_detach(struct uart_dev_s *dev);
-static int up_interrupt_common(struct up_dev_s *dev);
+static int up_interrupt(int irq, void *context, FAR void *arg);
static int up_ioctl(struct file *filep, int cmd, unsigned long arg);
#ifndef SERIAL_HAVE_ONLY_DMA
static int up_receive(struct uart_dev_s *dev, unsigned int *status);
@@ -340,31 +338,6 @@ static int up_pm_prepare(struct pm_callback_s *cb, int domain,
enum pm_state_e pmstate);
#endif
-#ifdef CONFIG_STM32F7_USART1
-static int up_interrupt_usart1(int irq, void *context);
-#endif
-#ifdef CONFIG_STM32F7_USART2
-static int up_interrupt_usart2(int irq, void *context);
-#endif
-#ifdef CONFIG_STM32F7_USART3
-static int up_interrupt_usart3(int irq, void *context);
-#endif
-#ifdef CONFIG_STM32F7_UART4
-static int up_interrupt_uart4(int irq, void *context);
-#endif
-#ifdef CONFIG_STM32F7_UART5
-static int up_interrupt_uart5(int irq, void *context);
-#endif
-#ifdef CONFIG_STM32F7_USART6
-static int up_interrupt_usart6(int irq, void *context);
-#endif
-#ifdef CONFIG_STM32F7_UART7
-static int up_interrupt_uart7(int irq, void *context);
-#endif
-#ifdef CONFIG_STM32F7_UART8
-static int up_interrupt_uart8(int irq, void *context);
-#endif
-
/****************************************************************************
* Private Data
****************************************************************************/
@@ -554,7 +527,6 @@ static struct up_dev_s g_usart1priv =
.rxdma_channel = DMAMAP_USART1_RX,
.rxfifo = g_usart1rxfifo,
#endif
- .vector = up_interrupt_usart1,
#ifdef CONFIG_USART1_RS485
.rs485_dir_gpio = GPIO_USART1_RS485_DIR,
@@ -616,7 +588,6 @@ static struct up_dev_s g_usart2priv =
.rxdma_channel = DMAMAP_USART2_RX,
.rxfifo = g_usart2rxfifo,
#endif
- .vector = up_interrupt_usart2,
#ifdef CONFIG_USART2_RS485
.rs485_dir_gpio = GPIO_USART2_RS485_DIR,
@@ -678,7 +649,6 @@ static struct up_dev_s g_usart3priv =
.rxdma_channel = DMAMAP_USART3_RX,
.rxfifo = g_usart3rxfifo,
#endif
- .vector = up_interrupt_usart3,
#ifdef CONFIG_USART3_RS485
.rs485_dir_gpio = GPIO_USART3_RS485_DIR,
@@ -744,7 +714,6 @@ static struct up_dev_s g_uart4priv =
.rxdma_channel = DMAMAP_UART4_RX,
.rxfifo = g_uart4rxfifo,
#endif
- .vector = up_interrupt_uart4,
#ifdef CONFIG_UART4_RS485
.rs485_dir_gpio = GPIO_UART4_RS485_DIR,
@@ -810,7 +779,6 @@ static struct up_dev_s g_uart5priv =
.rxdma_channel = DMAMAP_UART5_RX,
.rxfifo = g_uart5rxfifo,
#endif
- .vector = up_interrupt_uart5,
#ifdef CONFIG_UART5_RS485
.rs485_dir_gpio = GPIO_UART5_RS485_DIR,
@@ -872,7 +840,6 @@ static struct up_dev_s g_usart6priv =
.rxdma_channel = DMAMAP_USART6_RX,
.rxfifo = g_usart6rxfifo,
#endif
- .vector = up_interrupt_usart6,
#ifdef CONFIG_USART6_RS485
.rs485_dir_gpio = GPIO_USART6_RS485_DIR,
@@ -934,7 +901,6 @@ static struct up_dev_s g_uart7priv =
.rxdma_channel = DMAMAP_UART7_RX,
.rxfifo = g_uart7rxfifo,
#endif
- .vector = up_interrupt_uart7,
#ifdef CONFIG_UART7_RS485
.rs485_dir_gpio = GPIO_UART7_RS485_DIR,
@@ -996,7 +962,6 @@ static struct up_dev_s g_uart8priv =
.rxdma_channel = DMAMAP_UART8_RX,
.rxfifo = g_uart8rxfifo,
#endif
- .vector = up_interrupt_uart8,
#ifdef CONFIG_UART8_RS485
.rs485_dir_gpio = GPIO_UART8_RS485_DIR,
@@ -1681,7 +1646,7 @@ static int up_attach(struct uart_dev_s *dev)
/* Attach and enable the IRQ */
- ret = irq_attach(priv->irq, priv->vector);
+ ret = irq_attach(priv->irq, up_interrupt, priv);
if (ret == OK)
{
/* Enable the interrupt (RX and TX interrupts are still disabled
@@ -1711,7 +1676,7 @@ static void up_detach(struct uart_dev_s *dev)
}
/****************************************************************************
- * Name: up_interrupt_common
+ * Name: up_interrupt
*
* Description:
* This is the USART interrupt handler. It will be invoked when an
@@ -1722,11 +1687,14 @@ static void up_detach(struct uart_dev_s *dev)
*
****************************************************************************/
-static int up_interrupt_common(struct up_dev_s *priv)
+static int up_interrupt(int irq, void *context, FAR void *arg)
{
+ struct up_dev_s *priv = (struct up_dev_s *)arg;
int passes;
bool handled;
+ DEBUGASSERT(priv != NULL);
+
/* Report serial activity to the power management logic */
#if defined(CONFIG_PM) && CONFIG_PM_SERIAL_ACTIVITY > 0
@@ -2501,70 +2469,6 @@ static bool up_txready(struct uart_dev_s *dev)
return ((up_serialin(priv, STM32_USART_ISR_OFFSET) & USART_ISR_TXE) != 0);
}
-/****************************************************************************
- * Name: up_interrupt_u[s]art[n]
- *
- * Description:
- * Interrupt handlers for U[S]ART[n] where n=1,..,6.
- *
- ****************************************************************************/
-
-#ifdef CONFIG_STM32F7_USART1
-static int up_interrupt_usart1(int irq, void *context)
-{
- return up_interrupt_common(&g_usart1priv);
-}
-#endif
-
-#ifdef CONFIG_STM32F7_USART2
-static int up_interrupt_usart2(int irq, void *context)
-{
- return up_interrupt_common(&g_usart2priv);
-}
-#endif
-
-#ifdef CONFIG_STM32F7_USART3
-static int up_interrupt_usart3(int irq, void *context)
-{
- return up_interrupt_common(&g_usart3priv);
-}
-#endif
-
-#ifdef CONFIG_STM32F7_UART4
-static int up_interrupt_uart4(int irq, void *context)
-{
- return up_interrupt_common(&g_uart4priv);
-}
-#endif
-
-#ifdef CONFIG_STM32F7_UART5
-static int up_interrupt_uart5(int irq, void *context)
-{
- return up_interrupt_common(&g_uart5priv);
-}
-#endif
-
-#ifdef CONFIG_STM32F7_USART6
-static int up_interrupt_usart6(int irq, void *context)
-{
- return up_interrupt_common(&g_usart6priv);
-}
-#endif
-
-#ifdef CONFIG_STM32F7_UART7
-static int up_interrupt_uart7(int irq, void *context)
-{
- return up_interrupt_common(&g_uart7priv);
-}
-#endif
-
-#ifdef CONFIG_STM32F7_UART8
-static int up_interrupt_uart8(int irq, void *context)
-{
- return up_interrupt_common(&g_uart8priv);
-}
-#endif
-
/****************************************************************************
* Name: up_dma_rxcallback
*
diff --git a/arch/arm/src/stm32f7/stm32_tim.c b/arch/arm/src/stm32f7/stm32_tim.c
index 84934db13dca9d8d9f572446cff735b116dac14f..09a7c1f1d8a76727f51ca4d08fae924f618fb374 100644
--- a/arch/arm/src/stm32f7/stm32_tim.c
+++ b/arch/arm/src/stm32f7/stm32_tim.c
@@ -488,8 +488,7 @@ static void stm32_tim_setperiod(FAR struct stm32_tim_dev_s *dev,
}
static int stm32_tim_setisr(FAR struct stm32_tim_dev_s *dev,
- int (*handler)(int irq, void *context),
- int source)
+ xcpt_t handler, void *arg, int source)
{
int vectorno;
@@ -584,7 +583,7 @@ static int stm32_tim_setisr(FAR struct stm32_tim_dev_s *dev,
/* Otherwise set callback and enable interrupt */
- irq_attach(vectorno, handler);
+ irq_attach(vectorno, handler, arg);
up_enable_irq(vectorno);
#ifdef CONFIG_ARCH_IRQPRIO
diff --git a/arch/arm/src/stm32f7/stm32_tim.h b/arch/arm/src/stm32f7/stm32_tim.h
index c4561288a91985ae7608af1441020ebc3c97a628..5f3bf82c1002d61ccb4f46768ba84259f0a0262b 100644
--- a/arch/arm/src/stm32f7/stm32_tim.h
+++ b/arch/arm/src/stm32f7/stm32_tim.h
@@ -61,7 +61,7 @@
#define STM32_TIM_SETCHANNEL(d,ch,mode) ((d)->ops->setchannel(d,ch,mode))
#define STM32_TIM_SETCOMPARE(d,ch,comp) ((d)->ops->setcompare(d,ch,comp))
#define STM32_TIM_GETCAPTURE(d,ch) ((d)->ops->getcapture(d,ch))
-#define STM32_TIM_SETISR(d,hnd,s) ((d)->ops->setisr(d,hnd,s))
+#define STM32_TIM_SETISR(d,hnd,arg,s) ((d)->ops->setisr(d,hnd,arg,s))
#define STM32_TIM_ENABLEINT(d,s) ((d)->ops->enableint(d,s))
#define STM32_TIM_DISABLEINT(d,s) ((d)->ops->disableint(d,s))
#define STM32_TIM_ACKINT(d,s) ((d)->ops->ackint(d,s))
@@ -167,7 +167,7 @@ struct stm32_tim_ops_s
/* Timer interrupts */
- int (*setisr)(FAR struct stm32_tim_dev_s *dev, int (*handler)(int irq, void *context), int source);
+ int (*setisr)(FAR struct stm32_tim_dev_s *dev, xcpt_t handler, void *arg, int source);
void (*enableint)(FAR struct stm32_tim_dev_s *dev, int source);
void (*disableint)(FAR struct stm32_tim_dev_s *dev, int source);
void (*ackint)(FAR struct stm32_tim_dev_s *dev, int source);
@@ -183,7 +183,7 @@ FAR struct stm32_tim_dev_s *stm32_tim_init(int timer);
/* Power-down timer, mark it as unused */
-int stm32_tim_deinit(FAR struct stm32_tim_dev_s * dev);
+int stm32_tim_deinit(FAR struct stm32_tim_dev_s *dev);
/****************************************************************************
* Name: stm32_timer_initialize
diff --git a/arch/arm/src/stm32f7/stm32_timerisr.c b/arch/arm/src/stm32f7/stm32_timerisr.c
index 07cfd01d0f5d08cb00731c32f1b0133c11dd7116..5261088235676892cc531bfe0a1acd0e4c984f21 100644
--- a/arch/arm/src/stm32f7/stm32_timerisr.c
+++ b/arch/arm/src/stm32f7/stm32_timerisr.c
@@ -104,7 +104,7 @@
*
****************************************************************************/
-static int stm32_timerisr(int irq, uint32_t *regs)
+static int stm32_timerisr(int irq, uint32_t *regs, void *arg)
{
/* Process timer interrupt */
@@ -136,7 +136,7 @@ void arm_timer_initialize(void)
/* Attach the timer interrupt vector */
- (void)irq_attach(STM32_IRQ_SYSTICK, (xcpt_t)stm32_timerisr);
+ (void)irq_attach(STM32_IRQ_SYSTICK, (xcpt_t)stm32_timerisr, NULL);
/* Enable SysTick interrupts:
*
diff --git a/arch/arm/src/stm32f7/stm32f74xx75xx_rcc.c b/arch/arm/src/stm32f7/stm32f74xx75xx_rcc.c
index 10e4fe2bb5203d699ddbef666194342cb9f98e3d..a10c399f887d21d3592bd8311613573722ac3896 100644
--- a/arch/arm/src/stm32f7/stm32f74xx75xx_rcc.c
+++ b/arch/arm/src/stm32f7/stm32f74xx75xx_rcc.c
@@ -687,6 +687,11 @@ static void stm32_stdclockconfig(void)
/* Enable External High-Speed Clock (HSE) */
regval = getreg32(STM32_RCC_CR);
+#ifdef STM32_HSEBYP_ENABLE /* May be defined in board.h header file */
+ regval |= RCC_CR_HSEBYP; /* Enable HSE clock bypass */
+#else
+ regval &= ~RCC_CR_HSEBYP; /* Disable HSE clock bypass */
+#endif
regval |= RCC_CR_HSEON; /* Enable HSE */
putreg32(regval, STM32_RCC_CR);
diff --git a/arch/arm/src/stm32l4/Kconfig b/arch/arm/src/stm32l4/Kconfig
index a518c5cede9f8119722e3c2934bf969809e9b0d3..68d6ee6806b947f6f35b9dd7d929e4b3b0255b54 100644
--- a/arch/arm/src/stm32l4/Kconfig
+++ b/arch/arm/src/stm32l4/Kconfig
@@ -37,31 +37,49 @@ endchoice # STM32 L4 Chip Selection
# Chip families
-config STM32L4_STM32L476XX
+config STM32L4_STM32L4X3
+ bool
+ default n
+ select STM32L4_HAVE_USART1
+ select STM32L4_HAVE_USART2
+ select STM32L4_HAVE_USART3
+ select STM32L4_HAVE_LPTIM1
+ select STM32L4_HAVE_LPTIM2
+ select STM32L4_HAVE_COMP
+ select STM32L4_HAVE_SAI1
+ select STM32L4_HAVE_SAI2
+
+config STM32L4_STM32L4X6
bool
default n
- select ARCH_HAVE_FPU
- select ARCH_HAVE_DPFPU # REVISIT
- select ARMV7M_HAVE_ITCM
- select ARMV7M_HAVE_DTCM
select STM32L4_HAVE_USART1
select STM32L4_HAVE_USART2
select STM32L4_HAVE_USART3
select STM32L4_HAVE_UART4
select STM32L4_HAVE_UART5
+ select STM32L4_HAVE_LPTIM1
+ select STM32L4_HAVE_LPTIM2
+ select STM32L4_HAVE_COMP
+ select STM32L4_HAVE_SAI1
+ select STM32L4_HAVE_SAI2
+
+config STM32L4_STM32L476XX
+ bool
+ default n
+ select STM32L4_STM32L4X6
+ select ARCH_HAVE_FPU
+ select ARCH_HAVE_DPFPU # REVISIT
+ select ARMV7M_HAVE_ITCM
+ select ARMV7M_HAVE_DTCM
config STM32L4_STM32L486XX
bool
default n
+ select STM32L4_STM32L4X6
select ARCH_HAVE_FPU
select ARCH_HAVE_DPFPU # REVISIT
select ARMV7M_HAVE_ITCM
select ARMV7M_HAVE_DTCM
- select STM32L4_HAVE_USART1
- select STM32L4_HAVE_USART2
- select STM32L4_HAVE_USART3
- select STM32L4_HAVE_UART4
- select STM32L4_HAVE_UART5
select STM32L4_FLASH_1024KB
choice
@@ -118,6 +136,26 @@ config STM32L4_HAVE_LTDC
bool
default n
+config STM32L4_HAVE_LPTIM1
+ bool
+ default n
+
+config STM32L4_HAVE_LPTIM2
+ bool
+ default n
+
+config STM32L4_HAVE_COMP
+ bool
+ default n
+
+config STM32L4_HAVE_SAI1
+ bool
+ default n
+
+config STM32L4_HAVE_SAI2
+ bool
+ default n
+
# These "hidden" settings are the OR of individual peripheral selections
# indicating that the general capability is required.
@@ -154,8 +192,8 @@ config STM32L4_USART
default n
config STM32L4_LPTIM
- bool
- default n
+ bool
+ default n
# These are the peripheral selections proper
@@ -212,6 +250,38 @@ config STM32L4_RNG
default n
select ARCH_HAVE_RNG
+config STM32L4_SAI1_A
+ bool "SAI1 Block A"
+ default n
+ select AUDIO
+ select I2S
+ select SCHED_WORKQUEUE
+ select STM32L4_SAI
+
+config STM32L4_SAI1_B
+ bool "SAI1 Block B"
+ default n
+ select AUDIO
+ select I2S
+ select SCHED_WORKQUEUE
+ select STM32L4_SAI
+
+config STM32L4_SAI2_A
+ bool "SAI2 Block A"
+ default n
+ select AUDIO
+ select I2S
+ select SCHED_WORKQUEUE
+ select STM32L4_SAI
+
+config STM32L4_SAI2_B
+ bool "SAI2 Block B"
+ default n
+ select AUDIO
+ select I2S
+ select SCHED_WORKQUEUE
+ select STM32L4_SAI
+
comment "AHB3 Peripherals"
config STM32L4_FMC
@@ -394,8 +464,8 @@ config STM32L4_TIM7
default n
config STM32L4_LCD
- bool "LCD"
- default n
+ bool "LCD"
+ default n
config STM32L4_SPI2
bool "SPI2"
@@ -481,13 +551,14 @@ config STM32L4_DAC2
select STM32L4_DAC
config STM32L4_OPAMP
- bool "OPAMP"
- default n
+ bool "OPAMP"
+ default n
config STM32L4_LPTIM1
bool "LPTIM1"
default n
- select STM32L4_LPTIM
+ select STM32L4_LPTIM
+ depends on STM32L4_HAVE_LPTIM1
config STM32L4_LPUART1
bool "LPUART1"
@@ -496,13 +567,14 @@ config STM32L4_LPUART1
select ARCH_HAVE_LPUART1
config STM32L4_SWPMI
- bool "SWPMI"
- default n
+ bool "SWPMI"
+ default n
config STM32L4_LPTIM2
bool "LPTIM2"
default n
- select STM32L4_LPTIM
+ select STM32L4_LPTIM
+ depends on STM32L4_HAVE_LPTIM2
comment "APB2 Peripherals"
@@ -553,19 +625,24 @@ config STM32L4_TIM17
bool "TIM17"
default n
+config STM32L4_COMP
+ bool "COMP"
+ default n
+ depends on STM32L4_HAVE_COMP
+
config STM32L4_SAI1
bool "SAI1"
default n
- select STM32L4_SAI
+ depends on STM32L4_HAVE_SAI1
config STM32L4_SAI2
bool "SAI2"
default n
- select STM32L4_SAI
+ depends on STM32L4_HAVE_SAI2
config STM32L4_DFSDM
- bool "DFSDM"
- default n
+ bool "DFSDM"
+ default n
comment "Other Peripherals"
@@ -2996,4 +3073,68 @@ endchoice
endmenu
+menu "SAI Configuration"
+ depends on STM32L4_SAI
+
+choice
+ prompt "Operation mode"
+ default STM32L4_SAI_DMA
+ ---help---
+ Select the operation mode the SAI driver should use.
+
+config STM32L4_SAI_POLLING
+ bool "Polling"
+ ---help---
+ The SAI registers are polled for events.
+
+config STM32L4_SAI_INTERRUPTS
+ bool "Interrupt"
+ ---help---
+ Select to enable interrupt driven SAI support.
+
+config STM32L4_SAI_DMA
+ bool "DMA"
+ ---help---
+ Use DMA to improve SAI transfer performance.
+
+endchoice # Operation mode
+
+choice
+ prompt "SAI1 synchronization enable"
+ default STM32L4_SAI1_BOTH_ASYNC
+ depends on STM32L4_SAI1_A && STM32L4_SAI1_B
+ ---help---
+ Select the synchronization mode of the SAI sub-blocks
+
+config STM32L4_SAI1_BOTH_ASYNC
+ bool "Both asynchronous"
+
+config STM32L4_SAI1_A_SYNC_WITH_B
+ bool "Block A is synchronous with Block B"
+
+config STM32L4_SAI1_B_SYNC_WITH_A
+ bool "Block B is synchronous with Block A"
+
+endchoice # SAI1 synchronization enable
+
+choice
+ prompt "SAI2 synchronization enable"
+ default STM32L4_SAI2_BOTH_ASYNC
+ depends on STM32L4_SAI2_A && STM32L4_SAI2_B
+ ---help---
+ Select the synchronization mode of the SAI sub-blocks
+
+config STM32L4_SAI2_BOTH_ASYNC
+ bool "Both asynchronous"
+
+config STM32L4_SAI2_A_SYNC_WITH_B
+ bool "Block A is synchronous with Block B"
+
+config STM32L4_SAI2_B_SYNC_WITH_A
+ bool "Block B is synchronous with Block A"
+
+endchoice # SAI2 synchronization enable
+
+endmenu
+
endif # ARCH_CHIP_STM32L4
diff --git a/arch/arm/src/stm32l4/Make.defs b/arch/arm/src/stm32l4/Make.defs
index 15b50d86929fe8b8053d6720d23db7cce40813f3..359875b63c70464cd7722942721b4b6ed8152625 100644
--- a/arch/arm/src/stm32l4/Make.defs
+++ b/arch/arm/src/stm32l4/Make.defs
@@ -1,6 +1,7 @@
############################################################################
# arch/arm/src/stm32l4/Make.defs
#
+# Copyright (C) 2017 Gregory Nutt. All rights reserved.
# Copyright (C) 2015-2016 Sebastien Lorquet. All rights reserved.
# Author: Sebastien Lorquet
#
@@ -159,6 +160,15 @@ endif
endif
endif
+ifeq ($(CONFIG_PM),y)
+CHIP_CSRCS += stm32l4_pmlpr.c stm32l4_pmsleep.c stm32l4_pmstandby.c
+CHIP_CSRCS += stm32l4_pmstop.c
+
+ifneq ($(CONFIG_ARCH_CUSTOM_PMINIT),y)
+CHIP_CSRCS += stm32l4_pminitialize.c
+endif
+endif
+
ifeq ($(CONFIG_STM32L4_PWR),y)
CHIP_CSRCS += stm32l4_exti_pwr.c
endif
@@ -177,10 +187,22 @@ ifeq ($(CONFIG_DEBUG_FEATURES),y)
CHIP_CSRCS += stm32l4_dumpgpio.c
endif
+ifeq ($(CONFIG_STM32L4_COMP),y)
+CHIP_CSRCS += stm32l4_comp.c stm32l4_exti_comp.c
+endif
+
ifeq ($(CONFIG_STM32L4_RNG),y)
CHIP_CSRCS += stm32l4_rng.c
endif
+ifeq ($(CONFIG_STM32L4_SAI),y)
+CHIP_CSRCS += stm32l4_sai.c
+endif
+
+ifeq ($(CONFIG_STM32L4_LPTIM),y)
+CHIP_CSRCS += stm32l4_lptim.c
+endif
+
ifeq ($(CONFIG_PWM),y)
CHIP_CSRCS += stm32l4_pwm.c
endif
diff --git a/arch/arm/src/stm32l4/chip/stm32l4_comp.h b/arch/arm/src/stm32l4/chip/stm32l4_comp.h
new file mode 100644
index 0000000000000000000000000000000000000000..a09c6826527bad66004c132a2c025eee099267f9
--- /dev/null
+++ b/arch/arm/src/stm32l4/chip/stm32l4_comp.h
@@ -0,0 +1,107 @@
+/****************************************************************************************************
+ * arch/arm/src/stm32l4/stm32l4_comp.h
+ *
+ * Copyright (C) 2017 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************************************/
+
+#ifndef __ARCH_ARM_SRC_STM32L4_CHIP_STM32L4_COMP_H
+#define __ARCH_ARM_SRC_STM32L4_CHIP_STM32L4_COMP_H
+
+/****************************************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************************************/
+
+/* Register Offsets *********************************************************************************/
+
+#define STM32L4_COMP_CSR_OFFSET(n) (((n)-1) << 2)
+#define STM32L4_COMP1_CSR_OFFSET 0x0000 /* Comparator 1 control and status register */
+#define STM32L4_COMP2_CSR_OFFSET 0x0004 /* Comparator 2 control and status register */
+
+/* Register Addresses *******************************************************************************/
+
+#define STM32L4_COMP_CSR(n) (STM32L4_COMP_BASE+STM32L4_COMP_CSR_OFFSET(n))
+#define STM32L4_COMP1_CSR (STM32L4_COMP_BASE+STM32L4_COMP1_CSR_OFFSET)
+#define STM32L4_COMP2_CSR (STM32L4_COMP_BASE+STM32L4_COMP2_CSR_OFFSET)
+
+/* Register Bitfield Definitions ********************************************************************/
+
+#define COMP_CSR_EN (1 << 0) /* Bit 0: Comparator enable bit */
+ /* Bit 1: Reserved */
+#define COMP_CSR_PWRMODE_SHIFT (2) /* Bits 2-3: Power Mode */
+#define COMP_CSR_PWRMODE_MASK (3 << COMP_CSR_PWRMODE_SHIFT)
+# define COMP_CSR_PWRMODE_HIGH (0 << COMP_CSR_PWRMODE_SHIFT) /* High speed */
+# define COMP_CSR_PWRMODE_MEDIUM (1 << COMP_CSR_PWRMODE_SHIFT) /* Medium speed */
+# define COMP_CSR_PWRMODE_LOW (3 << COMP_CSR_PWRMODE_SHIFT) /* Ultra low power */
+#define COMP_CSR_INMSEL_SHIFT (4) /* Bits 4-6: Input minus selection bits */
+#define COMP_CSR_INMSEL_MASK (7 << COMP_CSR_INMSEL_SHIFT)
+# define COMP_CSR_INMSEL_25PCT (0 << COMP_CSR_INMSEL_SHIFT) /* 1/4 VREFINT */
+# define COMP_CSR_INMSEL_50PCT (1 << COMP_CSR_INMSEL_SHIFT) /* 1/2 VREFINT */
+# define COMP_CSR_INMSEL_75PCT (2 << COMP_CSR_INMSEL_SHIFT) /* 3/4 VREFINT */
+# define COMP_CSR_INMSEL_VREF (3 << COMP_CSR_INMSEL_SHIFT) /* VREFINT */
+# define COMP_CSR_INMSEL_DAC1 (4 << COMP_CSR_INMSEL_SHIFT) /* DAC Channel1 */
+# define COMP_CSR_INMSEL_DAC2 (5 << COMP_CSR_INMSEL_SHIFT) /* DAC Channel2 */
+# define COMP_CSR_INMSEL_PIN1 (6 << COMP_CSR_INMSEL_SHIFT) /* Input minus pin 1: COMP1=PB1; COMP2=PB3 */
+# define COMP_CSR_INMSEL_PIN2 (7 << COMP_CSR_INMSEL_SHIFT) /* Input minus pin 2: COMP1=PC4; COMP2=PB7 */
+#define COMP_CSR_INPSEL_MASK (1 << 7) /* Bit 7: Input plus selection bit */
+# define COMP_CSR_INPSEL_PIN1 (0) /* Input plus pin 1: COMP1=PC5; COMP2=PB4 */
+# define COMP_CSR_INPSEL_PIN2 COMP_CSR_INPSEL_MASK /* Input plus pin 1: COMP1=PB2; COMP2=PB6 */
+#define COMP2_CSR_WINMODE (1 << 9) /* Bit 9: Windows mode selection bit (COMP2 only) */
+# define COMP2_CSR_WINMODE_NOCONN (0) /* Comparator 2 input not connected to Comparator 1 */
+# define COMP2_CSR_WINMODE_CONN COMP2_CSR_WINMODE /* Comparator 2 input connected to Comparator 1 */
+#define COMP_CSR_POLARITY_MASK (1 << 15) /* Bit 15: Polarity selection bit */
+# define COMP_CSR_POLARITY_NORMAL (0)
+# define COMP_CSR_POLARITY_INVERT COMP_CSR_POLARITY_MASK
+#define COMP_CSR_HYST_SHIFT (16) /* Bits 16-17: Hysteresis selection bits */
+#define COMP_CSR_HYST_MASK (3 << COMP_CSR_HYST_SHIFT)
+# define COMP_CSR_HYST_NONE (0 << COMP_CSR_HYST_SHIFT) /* No hysteresis */
+# define COMP_CSR_HYST_LOW (1 << COMP_CSR_HYST_SHIFT) /* Low hysteresis */
+# define COMP_CSR_HYST_MEDIUM (2 << COMP_CSR_HYST_SHIFT) /* Medium hysteresis */
+# define COMP_CSR_HYST_HIGH (3 << COMP_CSR_HYST_SHIFT) /* High hysteresis */
+#define COMP_CSR_BLANK_SHIFT (18) /* Bits 18-20: Blanking source selection bits */
+#define COMP_CSR_BLANK_MASK (7 << COMP_CSR_BLANK_SHIFT)
+# define COMP_CSR_BLANK_NONE (0 << COMP_CSR_BLANK_SHIFT) /* No blanking */
+# define COMP1_CSR_BLANK_TIM1OC5 (1 << COMP_CSR_BLANK_SHIFT) /* TIM1 OC5 is blanking source */
+# define COMP1_CSR_BLANK_TIM2OC3 (2 << COMP_CSR_BLANK_SHIFT) /* TIM2 OC3 is blanking source */
+# define COMP1_CSR_BLANK_TIM3OC3 (4 << COMP_CSR_BLANK_SHIFT) /* TIM3 OC3 is blanking source */
+# define COMP2_CSR_BLANK_TIM3OC4 (1 << COMP_CSR_BLANK_SHIFT) /* TIM3 OC4 is blanking source */
+# define COMP2_CSR_BLANK_TIM8OC5 (2 << COMP_CSR_BLANK_SHIFT) /* TIM8 OC5 is blanking source */
+# define COMP2_CSR_BLANK_TIM15OC1 (4 << COMP_CSR_BLANK_SHIFT) /* TIM15 OC1 is blanking source */
+ /* Bit 21: Reserved */
+#define COMP_CSR_BRGEN (1 << 22) /* Bit 22: Scaler bridge enable */
+#define COMP_CSR_SCALEN (1 << 23) /* Bit 23: Voltage scaler enable bit */
+ /* Bits 24-29: Reserved */
+#define COMP_CSR_VALUE (1 << 30) /* Bit 30: Comparator output status bit */
+#define COMP_CSR_LOCK_MASK (1 << 31) /* Bit 31: CSR register lock bit */
+# define COMP_CSR_LOCK_RW (0)
+# define COMP_CSR_LOCK_RO COMP_CSR_LOCK_MASK
+
+#endif /* __ARCH_ARM_SRC_STM32L4_CHIP_STM32L4_COMP_H */
diff --git a/arch/arm/src/stm32l4/chip/stm32l4_lptim.h b/arch/arm/src/stm32l4/chip/stm32l4_lptim.h
new file mode 100644
index 0000000000000000000000000000000000000000..1822effec45039747ae7e639b274b7be10513cf1
--- /dev/null
+++ b/arch/arm/src/stm32l4/chip/stm32l4_lptim.h
@@ -0,0 +1,117 @@
+/****************************************************************************************************
+ * arch/arm/src/stm32l4/stm32l4_lptim.h
+ *
+ * Copyright (C) 2016 Motorola Mobility, LLC. All rights reserved.
+ * Copyright (C) 2009, 2011-2012, 2017 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************************************/
+
+#ifndef __ARCH_ARM_SRC_STM32L4_CHIP_STM32L4_LPTIM_H
+#define __ARCH_ARM_SRC_STM32L4_CHIP_STM32L4_LPTIM_H
+
+/****************************************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************************************/
+
+/* Register Offsets *********************************************************************************/
+
+/* Basic Timers - TIM6 and TIM7 */
+
+#define STM32L4_LPTIM_ISR_OFFSET 0x0000 /* Interrupt and Status Register */
+#define STM32L4_LPTIM_ICR_OFFSET 0x0004 /* Interrupt Clear Register */
+#define STM32L4_LPTIM_IER_OFFSET 0x0008 /* Interrupt Enable Register */
+#define STM32L4_LPTIM_CFGR_OFFSET 0x000c /* Configuration Register */
+#define STM32L4_LPTIM_CR_OFFSET 0x0010 /* Control Register */
+#define STM32L4_LPTIM_CMP_OFFSET 0x0014 /* Compare Register */
+#define STM32L4_LPTIM_ARR_OFFSET 0x0018 /* Autoreload Register */
+#define STM32L4_LPTIM_CNT_OFFSET 0x001c /* Counter Register */
+
+/* Register Addresses *******************************************************************************/
+
+/* Low-Power Timers - LPTIM1 and LPTIM2 */
+
+#define STM32L4_LPTIM1_ISR (STM32L4_LPTIM1_BASE+STM32L4_LPTIM_ISR_OFFSET)
+#define STM32L4_LPTIM1_ICR (STM32L4_LPTIM1_BASE+STM32L4_LPTIM_ICR_OFFSET)
+#define STM32L4_LPTIM1_IER (STM32L4_LPTIM1_BASE+STM32L4_LPTIM_IER_OFFSET)
+#define STM32L4_LPTIM1_CFGR (STM32L4_LPTIM1_BASE+STM32L4_LPTIM_CFGR_OFFSET)
+#define STM32L4_LPTIM1_CR (STM32L4_LPTIM1_BASE+STM32L4_LPTIM_CR_OFFSET)
+#define STM32L4_LPTIM1_CMP (STM32L4_LPTIM1_BASE+STM32L4_LPTIM_CMP_OFFSET)
+#define STM32L4_LPTIM1_ARR (STM32L4_LPTIM1_BASE+STM32L4_LPTIM_ARR_OFFSET)
+#define STM32L4_LPTIM1_CNT (STM32L4_LPTIM1_BASE+STM32L4_LPTIM_CNT_OFFSET)
+
+#define STM32L4_LPTIM2_ISR (STM32L4_LPTIM2_BASE+STM32L4_LPTIM_ISR_OFFSET)
+#define STM32L4_LPTIM2_ICR (STM32L4_LPTIM2_BASE+STM32L4_LPTIM_ICR_OFFSET)
+#define STM32L4_LPTIM2_IER (STM32L4_LPTIM2_BASE+STM32L4_LPTIM_IER_OFFSET)
+#define STM32L4_LPTIM2_CFGR (STM32L4_LPTIM2_BASE+STM32L4_LPTIM_CFGR_OFFSET)
+#define STM32L4_LPTIM2_CR (STM32L4_LPTIM2_BASE+STM32L4_LPTIM_CR_OFFSET)
+#define STM32L4_LPTIM2_CMP (STM32L4_LPTIM2_BASE+STM32L4_LPTIM_CMP_OFFSET)
+#define STM32L4_LPTIM2_ARR (STM32L4_LPTIM2_BASE+STM32L4_LPTIM_ARR_OFFSET)
+#define STM32L4_LPTIM2_CNT (STM32L4_LPTIM2_BASE+STM32L4_LPTIM_CNT_OFFSET)
+
+/* Register Bitfield Definitions ********************************************************************/
+
+#define LPTIM_CFGR_CKSEL (1 << 0) /* Bit 0: Clock selector */
+#define LPTIM_CFGR_CKPOL_SHIFT (1) /* Bits 2-1: Clock Polarity */
+#define LPTIM_CFGR_CKPOL_MASK (3 << LPTIM_CFGR_CKPOL_SHIFT)
+#define LPTIM_CFGR_CKFLT_SHIFT (3) /* Bits 4-3: Digital filter for external clock */
+#define LPTIM_CFGR_CKFLTN_MASK (3 << LPTIM_CFGR_CKFLT_SHIFT)
+ /* Bit 5: reserved */
+#define LPTIM_CFGR_TRGFLT_SHIFT (6) /* Bits 7-6: Digital filter for trigger */
+#define LPTIM_CFGR_TRGFLT_MASK (3 << LPTIM_CFGR_TRGFLT_SHIFT)
+ /* Bit 8: reserved */
+#define LPTIM_CFGR_PRESC_SHIFT (9) /* Bits 11-9: clock pre-scaler */
+#define LPTIM_CFGR_PRESC_MASK (7 << LPTIM_CFGR_PRESC_SHIFT)
+# define LPTIM_CFGR_PRESCd1 (0 << LPTIM_CFGR_PRESC_SHIFT) /* 000: divide by 1 */
+# define LPTIM_CFGR_PRESCd2 (1 << LPTIM_CFGR_PRESC_SHIFT) /* 001: divide by 2 */
+# define LPTIM_CFGR_PRESCd4 (2 << LPTIM_CFGR_PRESC_SHIFT) /* 010: divide by 4 */
+# define LPTIM_CFGR_PRESCd8 (3 << LPTIM_CFGR_PRESC_SHIFT) /* 011: divide by 8 */
+# define LPTIM_CFGR_PRESCd16 (4 << LPTIM_CFGR_PRESC_SHIFT) /* 100: divide by 16 */
+# define LPTIM_CFGR_PRESCd32 (5 << LPTIM_CFGR_PRESC_SHIFT) /* 101: divide by 32 */
+# define LPTIM_CFGR_PRESCd64 (6 << LPTIM_CFGR_PRESC_SHIFT) /* 110: divide by 64 */
+# define LPTIM_CFGR_PRESCd128 (7 << LPTIM_CFGR_PRESC_SHIFT) /* 111: divide by 128 */
+ /* Bit 12: reserved */
+#define LPTIM_CFGR_TRIGSEL_SHIFT (13) /* Bits 15-13: Trigger selector */
+#define LPTIM_CFGR_TRIGSEL_MASK (7 << LPTIM_CFGR_TRIGSEL_SHIFT)
+ /* Bit 16: reserved */
+#define LPTIM_CFGR_TRIGEN_SHIFT (17) /* Bits 18-17: Trigger enable and polarity */
+#define LPTIM_CFGR_TRIGEN_MASK (3 << LPTIM_CFGR_TRIGEN_SHIFT)
+#define LPTIM_CFGR_TIMOUT (1 << 19) /* Bit 19: Timeout enable */
+#define LPTIM_CFGR_WAVE (1 << 20) /* Bit 20: Waveform shape */
+#define LPTIM_CFGR_WAVPOL (1 << 21) /* Bit 21: Waveform polarity */
+#define LPTIM_CFGR_PRELOAD (1 << 22) /* Bit 22: Update mode enable */
+#define LPTIM_CFGR_COUNTMODE (1 << 23) /* Bit 23: Count mode enable */
+#define LPTIM_CFGR_ENC (1 << 24) /* Bit 24: Encoder mode enable (LPTIM1 only) */
+
+#define LPTIM_CR_ENABLE (1 << 0) /* Bit 0: Enable */
+#define LPTIM_CR_SNGSTRT (1 << 1) /* Bit 1: Single Mode */
+#define LPTIM_CR_CNTSTRT (1 << 2) /* Bit 2: Continuous Mode */
+
+#endif /* __ARCH_ARM_SRC_STM32L4_CHIP_STM32L4_LPTIM_H */
diff --git a/arch/arm/src/stm32l4/chip/stm32l4_pinmap.h b/arch/arm/src/stm32l4/chip/stm32l4_pinmap.h
index 906e53dccb558890eb25c72a727199cc6ebda424..0b2b537f1e4c57314cf67df23cbbccb3193a774b 100644
--- a/arch/arm/src/stm32l4/chip/stm32l4_pinmap.h
+++ b/arch/arm/src/stm32l4/chip/stm32l4_pinmap.h
@@ -33,8 +33,8 @@
*
************************************************************************************/
-#ifndef __ARCH_ARM_SRC_STM32L4_CHIP_STM32_PINMAP_H
-#define __ARCH_ARM_SRC_STM32L4_CHIP_STM32_PINMAP_H
+#ifndef __ARCH_ARM_SRC_STM32L4_CHIP_STM32L4_PINMAP_H
+#define __ARCH_ARM_SRC_STM32L4_CHIP_STM32L4_PINMAP_H
/************************************************************************************
* Included Files
@@ -49,5 +49,5 @@
# error "Unsupported STM32 L4 pin map"
#endif
-#endif /* __ARCH_ARM_SRC_STM32L4_CHIP_STM32_PINMAP_H */
+#endif /* __ARCH_ARM_SRC_STM32L4_CHIP_STM32L4_PINMAP_H */
diff --git a/arch/arm/src/stm32l4/chip/stm32l4_pwr.h b/arch/arm/src/stm32l4/chip/stm32l4_pwr.h
index 2e771551f8ea23e2faad53ae83f3446ef3b65645..2b81413a793c69a9f83fc5c5be74636ace27b6dd 100644
--- a/arch/arm/src/stm32l4/chip/stm32l4_pwr.h
+++ b/arch/arm/src/stm32l4/chip/stm32l4_pwr.h
@@ -105,8 +105,8 @@
#define PWR_CR1_LPMS_SHIFT 0
#define PWR_CR1_LPMS_MASK (7 << PWR_CR1_LPMS_SHIFT) /* Bits 0-2: Low-power mode selection */
-# define PWR_CR1_LPMS_STOP0 (0 << PWR_CR1_LPMS_SHIFT) /* 000: Stop 0 mode */
-# define PWR_CR1_LPMS_STOP1 (1 << PWR_CR1_LPMS_SHIFT) /* 001: Stpp 1 mode */
+# define PWR_CR1_LPMS_STOP1MR (0 << PWR_CR1_LPMS_SHIFT) /* Stop 1 mode with main regulator (MR) */
+# define PWR_CR1_LPMS_STOP1LPR (1 << PWR_CR1_LPMS_SHIFT) /* Stop 1 mode with low-power regulator (LPR) */
# define PWR_CR1_LPMS_STOP2 (2 << PWR_CR1_LPMS_SHIFT) /* 010: Stop 2 mode*/
# define PWR_CR1_LPMS_STANDBY (3 << PWR_CR1_LPMS_SHIFT) /* 011: Standby mode */
# define PWR_CR1_LPMS_SHUTDOWN (4 << PWR_CR1_LPMS_SHIFT) /* 1xx: Shutdown node */
@@ -120,7 +120,7 @@
/* Power control register 2 */
#define PWR_CR2_PVDE (1 << 0) /* Bit 0: Power voltage detector enable */
-#define PWR_CR2_PLS_SHIFT 1
+#define PWR_CR2_PLS_SHIFT 1
#define PWR_CR2_PLS_MASK (7 << PWR_CR2_PLS_SHIFT) /* Bits 1-3: Power voltage detector level selection */
# define PWR_CR2_PLS_2000mv (0 << PWR_CR2_PLS_SHIFT) /* 000: VPVD0 around 2.0V */
# define PWR_CR2_PLS_2200mv (1 << PWR_CR2_PLS_SHIFT) /* 001: VPVD1 around 2.2V */
diff --git a/arch/arm/src/stm32l4/chip/stm32l4_rng.h b/arch/arm/src/stm32l4/chip/stm32l4_rng.h
index 434b77c1c265c93b2706f0c85c0a351804a8aea6..7812110b620ffe4625fd7ac18144546f2354d992 100644
--- a/arch/arm/src/stm32l4/chip/stm32l4_rng.h
+++ b/arch/arm/src/stm32l4/chip/stm32l4_rng.h
@@ -33,8 +33,8 @@
*
************************************************************************************/
-#ifndef __ARCH_ARM_STC_STM32_CHIP_STM32L4_RNG_H
-#define __ARCH_ARM_STC_STM32_CHIP_STM32L4_RNG_H
+#ifndef __ARCH_ARM_STC_STM32L4_CHIP_STM32L4_RNG_H
+#define __ARCH_ARM_STC_STM32L4_CHIP_STM32L4_RNG_H
/************************************************************************************
* Included Files
@@ -74,4 +74,4 @@
#define RNG_SR_CEIS (1 << 5) /* Bit 5: Clock error interrupt status */
#define RNG_SR_SEIS (1 << 6) /* Bit 6: Seed error interrupt status */
-#endif /* __ARCH_ARM_STC_STM32_CHIP_STM32L4_RNG_H */
+#endif /* __ARCH_ARM_STC_STM32L4_CHIP_STM32L4_RNG_H */
diff --git a/arch/arm/src/stm32l4/chip/stm32l4_sai.h b/arch/arm/src/stm32l4/chip/stm32l4_sai.h
new file mode 100644
index 0000000000000000000000000000000000000000..f411fb72baf0408964adc9ed0314c32cc7cc3507
--- /dev/null
+++ b/arch/arm/src/stm32l4/chip/stm32l4_sai.h
@@ -0,0 +1,259 @@
+/************************************************************************************
+ * arch/arm/src/stm32/chip/stm32l4_sai.h
+ *
+ * Copyright (C) 2017 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ************************************************************************************/
+
+#ifndef __ARCH_ARM_STC_STM32L4_CHIP_STM32L4_SAI_H
+#define __ARCH_ARM_STC_STM32L4_CHIP_STM32L4_SAI_H
+
+/************************************************************************************
+ * Included Files
+ ************************************************************************************/
+
+#include
+#include "chip.h"
+
+/************************************************************************************
+ * Pre-processor Definitions
+ ************************************************************************************/
+
+/* Register Offsets *****************************************************************/
+
+#define STM32L4_SAI_GCR_OFFSET 0x0000 /* SAI Global Configuration Register */
+
+#define STM32L4_SAI_A_OFFSET 0x0004
+#define STM32L4_SAI_B_OFFSET 0x0024
+
+#define STM32L4_SAI_CR1_OFFSET 0x0000 /* SAI Configuration Register 1 A */
+#define STM32L4_SAI_CR2_OFFSET 0x0004 /* SAI Configuration Register 2 A */
+#define STM32L4_SAI_FRCR_OFFSET 0x0008 /* SAI Frame Configuration Register A */
+#define STM32L4_SAI_SLOTR_OFFSET 0x000c /* SAI Slot Register A */
+#define STM32L4_SAI_IM_OFFSET 0x0010 /* SAI Interrupt Mask Register 2 A */
+#define STM32L4_SAI_SR_OFFSET 0x0014 /* SAI Status Register A */
+#define STM32L4_SAI_CLRFR_OFFSET 0x0018 /* SAI Clear Flag Register A */
+#define STM32L4_SAI_DR_OFFSET 0x001c /* SAI Data Register A */
+
+/* Register Addresses ***************************************************************/
+
+#define STM32L4_SAI1_GCR (STM32L4_SAI_GCR_OFFSET)
+
+#define STM32L4_SAI1_A_BASE (STM32L4_SAI1_BASE+STM32L4_SAI_A_OFFSET)
+#define STM32L4_SAI1_B_BASE (STM32L4_SAI1_BASE+STM32L4_SAI_B_OFFSET)
+
+#define STM32L4_SAI1_ACR1 (STM32L4_SAI1_A_BASE+STM32L4_SAI_ACR1_OFFSET)
+#define STM32L4_SAI1_ACR2 (STM32L4_SAI1_A_BASE+STM32L4_SAI_ACR2_OFFSET)
+#define STM32L4_SAI1_AFRCR (STM32L4_SAI1_A_BASE+STM32L4_SAI_AFRCR_OFFSET)
+#define STM32L4_SAI1_ASLOTR (STM32L4_SAI1_A_BASE+STM32L4_SAI_ASLOTR_OFFSET)
+#define STM32L4_SAI1_AIM (STM32L4_SAI1_A_BASE+STM32L4_SAI_AIM_OFFSET)
+#define STM32L4_SAI1_ASR (STM32L4_SAI1_A_BASE+STM32L4_SAI_ASR_OFFSET)
+#define STM32L4_SAI1_ACLRFR (STM32L4_SAI1_A_BASE+STM32L4_SAI_ACLRFR_OFFSET)
+#define STM32L4_SAI1_ADR (STM32L4_SAI1_A_BASE+STM32L4_SAI_ADR_OFFSET)
+
+#define STM32L4_SAI1_BCR1 (STM32L4_SAI1_B_BASE+STM32L4_SAI_BCR1_OFFSET)
+#define STM32L4_SAI1_BCR2 (STM32L4_SAI1_B_BASE+STM32L4_SAI_BCR2_OFFSET)
+#define STM32L4_SAI1_BFRCR (STM32L4_SAI1_B_BASE+STM32L4_SAI_BFRCR_OFFSET)
+#define STM32L4_SAI1_BSLOTR (STM32L4_SAI1_B_BASE+STM32L4_SAI_BSLOTR_OFFSET)
+#define STM32L4_SAI1_BIM (STM32L4_SAI1_B_BASE+STM32L4_SAI_BIM_OFFSET)
+#define STM32L4_SAI1_BSR (STM32L4_SAI1_B_BASE+STM32L4_SAI_BSR_OFFSET)
+#define STM32L4_SAI1_BCLRFR (STM32L4_SAI1_B_BASE+STM32L4_SAI_BCLRFR_OFFSET)
+#define STM32L4_SAI1_BDR (STM32L4_SAI1_B_BASE+STM32L4_SAI_BDR_OFFSET)
+
+#define STM32L4_SAI2_GCR (STM32L4_SAI2_BASE+STM32L4_SAI_GCR_OFFSET)
+
+#define STM32L4_SAI2_A_BASE (STM32L4_SAI2_BASE+STM32L4_SAI_A_OFFSET)
+#define STM32L4_SAI2_B_BASE (STM32L4_SAI2_BASE+STM32L4_SAI_B_OFFSET)
+
+#define STM32L4_SAI2_ACR1 (STM32L4_SAI2_A_BASE+STM32L4_SAI_ACR1_OFFSET)
+#define STM32L4_SAI2_ACR2 (STM32L4_SAI2_A_BASE+STM32L4_SAI_ACR2_OFFSET)
+#define STM32L4_SAI2_AFRCR (STM32L4_SAI2_A_BASE+STM32L4_SAI_AFRCR_OFFSET)
+#define STM32L4_SAI2_ASLOTR (STM32L4_SAI2_A_BASE+STM32L4_SAI_ASLOTR_OFFSET)
+#define STM32L4_SAI2_AIM (STM32L4_SAI2_A_BASE+STM32L4_SAI_AIM_OFFSET)
+#define STM32L4_SAI2_ASR (STM32L4_SAI2_A_BASE+STM32L4_SAI_ASR_OFFSET)
+#define STM32L4_SAI2_ACLRFR (STM32L4_SAI2_A_BASE+STM32L4_SAI_ACLRFR_OFFSET)
+#define STM32L4_SAI2_ADR (STM32L4_SAI2_A_BASE+STM32L4_SAI_ADR_OFFSET)
+
+#define STM32L4_SAI2_BCR1 (STM32L4_SAI2_B_BASE+STM32L4_SAI_BCR1_OFFSET)
+#define STM32L4_SAI2_BCR2 (STM32L4_SAI2_B_BASE+STM32L4_SAI_BCR2_OFFSET)
+#define STM32L4_SAI2_BFRCR (STM32L4_SAI2_B_BASE+STM32L4_SAI_BFRCR_OFFSET)
+#define STM32L4_SAI2_BSLOTR (STM32L4_SAI2_B_BASE+STM32L4_SAI_BSLOTR_OFFSET)
+#define STM32L4_SAI2_BIM (STM32L4_SAI2_B_BASE+STM32L4_SAI_BIM_OFFSET)
+#define STM32L4_SAI2_BSR (STM32L4_SAI2_B_BASE+STM32L4_SAI_BSR_OFFSET)
+#define STM32L4_SAI2_BCLRFR (STM32L4_SAI2_B_BASE+STM32L4_SAI_BCLRFR_OFFSET)
+#define STM32L4_SAI2_BDR (STM32L4_SAI2_B_BASE+STM32L4_SAI_BDR_OFFSET)
+
+/* Register Bitfield Definitions ****************************************************/
+
+/* SAI Global Configuration Register */
+
+#define SAI_GCR_SYNCIN_SHIFT (0) /* Bits 0-1: Synchronization inputs */
+#define SAI_GCR_SYNCIN_MASK (3 << SAI_GCR_SYNCIN_SHIFT)
+# define SAI_GCR_SYNCIN(n) ((uint32_t)(n) << SAI_GCR_SYNCIN_SHIFT)
+ /* Bits 2-3: Reserved */
+#define SAI_GCR_SYNCOUT_SHIFT (4) /* Bits 4-5: Synchronization outputs */
+#define SAI_GCR_SYNCOUT_MASK (3 << SAI_GCR_SYNCOUT_SHIFT)
+# define SAI_GCR_SYNCOUT ((uint32_t)(n) << SAI_GCR_SYNCOUT_SHIFT)
+ /* Bits 6-31: Reserved */
+
+/* SAI Configuration Register 1 */
+
+#define SAI_CR1_MODE_SHIFT (0) /* Bits 0-1: SAI audio block mode */
+#define SAI_CR1_MODE_MASK (3 << SAI_CR1_MODE_SHIFT)
+# define SAI_CR1_MODE_MASTER_TX (0 << SAI_CR1_MODE_SHIFT) /* Master transmitter */
+# define SAI_CR1_MODE_MASTER_RX (1 << SAI_CR1_MODE_SHIFT) /* Master receiver */
+# define SAI_CR1_MODE_SLAVE_TX (2 << SAI_CR1_MODE_SHIFT) /* Slave transmitter */
+# define SAI_CR1_MODE_SLAVE_RX (3 << SAI_CR1_MODE_SHIFT) /* Slave receiver */
+#define SAI_CR1_PRTCFG_SHIFT (2) /* Bits 2-3: Protocol configuration */
+#define SAI_CR1_PRTCFG_MASK (3 << SAI_CR1_PRTCFG_SHIFT)
+# define SAI_CR1_PRTCFG_FREE (0 << SAI_CR1_PRTCFG_SHIFT) /* Free protocol */
+# define SAI_CR1_PRTCFG_SPDIF (1 << SAI_CR1_PRTCFG_SHIFT) /* SPDIF protocol */
+# define SAI_CR1_PRTCFG_AC97 (2 << SAI_CR1_PRTCFG_SHIFT) /* AC97 protocol */
+ /* Bit 4: Reserved */
+#define SAI_CR1_DS_SHIFT (5) /* Bits 5-7: Data size */
+#define SAI_CR1_DS_MASK (7 << SAI_CR1_DS_SHIFT)
+# define SAI_CR1_DS_8BITS (2 << SAI_CR1_DS_SHIFT) /* 8 bits */
+# define SAI_CR1_DS_10BITS (3 << SAI_CR1_DS_SHIFT) /* 10 bits */
+# define SAI_CR1_DS_16BITS (4 << SAI_CR1_DS_SHIFT) /* 16 bits */
+# define SAI_CR1_DS_20BITS (5 << SAI_CR1_DS_SHIFT) /* 20 bits */
+# define SAI_CR1_DS_24BITS (6 << SAI_CR1_DS_SHIFT) /* 24 bits */
+# define SAI_CR1_DS_32BITS (7 << SAI_CR1_DS_SHIFT) /* 32 bits */
+#define SAI_CR1_LSBFIRST (1 << 8) /* Bit 8: Least significant bit first */
+#define SAI_CR1_CKSTR (1 << 9) /* Bit 9: Clock strobing edge */
+#define SAI_CR1_SYNCEN_SHIFT (10) /* Bits 10-11: Synchronization enable */
+#define SAI_CR1_SYNCEN_MASK (3 << SAI_CR1_SYNCEN_SHIFT)
+# define SAI_CR1_SYNCEN_ASYNCH (0 << SAI_CR1_SYNCEN_SHIFT) /* Asynchronous mode */
+# define SAI_CR1_SYNCEN_INTERNAL (1 << SAI_CR1_SYNCEN_SHIFT) /* Synchronous with other internal sub-block */
+# define SAI_CR1_SYNCEN_EXTERNAL (2 << SAI_CR1_SYNCEN_SHIFT) /* Aynchronous with external SAI peripheral */
+#define SAI_CR1_MONO (1 << 12) /* Bit 12: Mono mode */
+#define SAI_CR1_OUTDRIV (1 << 13) /* Bit 13: Output drive */
+ /* Bits 14-15: Reserved */
+#define SAI_CR1_SAIEN (1 << 16) /* Bit 16: Audio block enable */
+#define SAI_CR1_DMAEN (1 << 17) /* Bit 17: DMA enable */
+ /* Bit 18: Reserved */
+#define SAI_CR1_NODIV (1 << 19) /* Bit 19: No divider */
+#define SAI_CR1_MCKDIV_SHIFT (20) /* Bits 20-23: Master clock divider */
+#define SAI_CR1_MCKDIV_MASK (15 << SAI_CR1_MCKDIV_SHIFT)
+# define SAI_CR1_MCKDIV(n) ((uint32_t)(n) << SAI_CR1_MCKDIV_SHIFT)
+ /* Bits 24-31: Reserved */
+
+/* SAI Configuration Register 2 */
+
+#define SAI_CR2_FTH_SHIFT (0) /* Bits 0-2: FIFO threshold */
+#define SAI_CR2_FTH_MASK (7 << SAI_CR2_FTH_SHIFT)
+# define SAI_CR2_FTH_EMPTY (0 << SAI_CR2_FTH_SHIFT) /* FIFO empty */
+# define SAI_CR2_FTH_1QF (1 << SAI_CR2_FTH_SHIFT) /* 1/4 FIFO */
+# define SAI_CR2_FTH_HF (2 << SAI_CR2_FTH_SHIFT) /* 1/2 FIFO */
+# define SAI_CR2_FTH_3QF (3 << SAI_CR2_FTH_SHIFT) /* 3/4 FIFO */
+# define SAI_CR2_FTH_FULL (4 << SAI_CR2_FTH_SHIFT) /* FIFO full */
+#define SAI_CR2_FFLUSH (1 << 3) /* Bit 3: FIFO flush */
+#define SAI_CR2_TRIS (1 << 4) /* Bit 4: Tristate management on data line */
+#define SAI_CR2_MUTE (1 << 5) /* Bit 5: Mute */
+#define SAI_CR2_MUTEVAL (1 << 6) /* Bit 6: Mute value */
+#define SAI_CR2_MUTECNT_SHIFT (7) /* Bits 7-12: Mute counter */
+#define SAI_CR2_MUTECNT_MASK (0x3f << SAI_CR2_MUTECNT_SHIFT)
+# define SAI_CR2_MUTECNT(n) ((uint32_t)(n) << SAI_CR2_MUTECNT_SHIFT)
+#define SAI_CR2_CPL (1 << 13) /* Bit 13: Complement */
+#define SAI_CR2_COMP_SHIFT (14) /* Bits 14-15: Companding mode */
+#define SAI_CR2_COMP_MASK (3 << SAI_CR2_COMP_SHIFT)
+# define SAI_CR2_COMP_NONE (0 << SAI_CR2_COMP_SHIFT) /* No companding algorithm */
+# define SAI_CR2_COMP_ULAW (2 << SAI_CR2_COMP_SHIFT) /* μ-Law algorithm */
+# define SAI_CR2_COMP_ALAW (3 << SAI_CR2_COMP_SHIFT) /* A-Law algorithm */
+ /* Bits 16-31: Reserved */
+
+/* SAI Frame Configuration Register */
+
+#define SAI_FRCR_FRL_SHIFT (0) /* Bits 0-7: Frame length */
+#define SAI_FRCR_FRL_MASK (0xff << SAI_FRCR_FRL_SHIFT)
+# define SAI_FRCR_FRL(n) ((uint32_t)((n) - 1) << SAI_FRCR_FRL_SHIFT)
+#define SAI_FRCR_FSALL_SHIFT (8) /* Bits 8-14: Frame synchronization active level length */
+#define SAI_FRCR_FSALL_MASK (0x7f << SAI_FRCR_FSALL_SHIFT)
+# define SAI_FRCR_FSALL(n) ((uint32_t)((n) - 1) << SAI_FRCR_FSALL_SHIFT)
+#define SAI_FRCR_FSDEF (1 << 16) /* Bit 16: Frame synchronization definition */
+# define SAI_FRCR_FSDEF_SF (0) /* FS signal is a start frame signal */
+# define SAI_FRCR_FSDEF_CHID SAI_FRCR_FSDEF /* FS signal is a start of frame + channel side ID */
+#define SAI_FRCR_FSPOL (1 << 17) /* Bit 17: Frame synchronization polarity */
+# define SAI_FRCR_FSPOL_LOW (0) /* FS is active low */
+# define SAI_FRCR_FSPOL_HIGH SAI_FRCR_FSPOL /* FS is active high */
+#define SAI_FRCR_FSOFF (1 << 18) /* Bit 18: Frame synchronization offset */
+# define SAI_FRCR_FSOFF_FB (0) /* FS on first bit of slot 0 */
+# define SAI_FRCR_FSOFF_BFB SAI_FRCR_FSOFF /* FS one bit before first bit of slot 0 */
+ /* Bits 19-31: Reserved */
+
+/* SAI Slot Register */
+
+#define SAI_SLOTR_FBOFF_SHIFT (0) /* Bits 0-4: First bit offset */
+#define SAI_SLOTR_FBOFF_MASK (32 << SAI_SLOTR_FBOFF_SHIFT)
+# define SAI_SLOTR_FBOFF(n) ((uint32_t)(n) << SAI_SLOTR_FBOFF_SHIFT)
+ /* Bit 5: Reserved */
+#define SAI_SLOTR_SLOTSZ_SHIFT (6) /* Bits 6-7: Slot size */
+#define SAI_SLOTR_SLOTSZ_MASK (3 << SAI_SLOTR_SLOTSZ_SHIFT)
+# define SAI_SLOTR_SLOTSZ_DATA (0 << SAI_SLOTR_SLOTSZ_SHIFT) /* Same as data size */
+# define SAI_SLOTR_SLOTSZ_16BIT (1 << SAI_SLOTR_SLOTSZ_SHIFT) /* 16-bit */
+# define SAI_SLOTR_SLOTSZ_32BIT (2 << SAI_SLOTR_SLOTSZ_SHIFT) /* 32-bit */
+#define SAI_SLOTR_NBSLOT_SHIFT (0) /* Bits 0-3: Number of slots in an audio frame */
+#define SAI_SLOTR_NBSLOT_MASK (15 << SAI_SLOTR_NBSLOT_SHIFT)
+# define SAI_SLOTR_NBSLOT(n) ((uint32_t)((n) - 1) << SAI_SLOTR_NBSLOT_SHIFT)
+ /* Bits 12-15: Reserved */
+#define SAI_SLOTR_SLOTEN_SHIFT (16) /* Bits 16-31: Slot enable */
+#define SAI_SLOTR_SLOTEN_MASK (0xffff << SAI_SLOTR_SLOTEN_SHIFT)
+# define SAI_SLOTR_SLOTEN(n) ((uint32_t)(n) << SAI_SLOTR_SLOTEN_SHIFT)
+# define SAI_SLOTR_SLOTEN_0 (1 << 16) /* Bit 16: Slot 0 Enabled */
+# define SAI_SLOTR_SLOTEN_1 (1 << 17) /* Bit 17: Slot 1 Enabled */
+# define SAI_SLOTR_SLOTEN_2 (1 << 18) /* Bit 18: Slot 2 Enabled */
+# define SAI_SLOTR_SLOTEN_3 (1 << 19) /* Bit 19: Slot 3 Enabled */
+# define SAI_SLOTR_SLOTEN_4 (1 << 20) /* Bit 20: Slot 4 Enabled */
+# define SAI_SLOTR_SLOTEN_5 (1 << 21) /* Bit 21: Slot 5 Enabled */
+# define SAI_SLOTR_SLOTEN_6 (1 << 22) /* Bit 22: Slot 6 Enabled */
+# define SAI_SLOTR_SLOTEN_7 (1 << 23) /* Bit 23: Slot 7 Enabled */
+# define SAI_SLOTR_SLOTEN_8 (1 << 24) /* Bit 24: Slot 8 Enabled */
+# define SAI_SLOTR_SLOTEN_9 (1 << 25) /* Bit 25: Slot 9 Enabled */
+# define SAI_SLOTR_SLOTEN_10 (1 << 26) /* Bit 26: Slot 10 Enabled */
+# define SAI_SLOTR_SLOTEN_11 (1 << 27) /* Bit 27: Slot 11 Enabled */
+# define SAI_SLOTR_SLOTEN_12 (1 << 28) /* Bit 28: Slot 12 Enabled */
+# define SAI_SLOTR_SLOTEN_13 (1 << 29) /* Bit 29: Slot 13 Enabled */
+# define SAI_SLOTR_SLOTEN_14 (1 << 30) /* Bit 30: Slot 14 Enabled */
+# define SAI_SLOTR_SLOTEN_15 (1 << 31) /* Bit 31: Slot 15 Enabled */
+
+/* SAI Interrupt Mask Register 2, SAI Status Register, and SAI Clear Flag Register */
+
+#define SAI_INT_OVRUDR (1 << 0) /* Bit 0: Overrun/underrun interrupt */
+#define SAI_INT_MUTEDET (1 << 1) /* Bit 1: Mute detection interrupt */
+#define SAI_INT_WCKCFG (1 << 2) /* Bit 2: Wrong clock configuration interrupt */
+#define SAI_INT_FREQ (1 << 3) /* Bit 3: FIFO request interrupt (not CLRFFR) */
+#define SAI_INT_CNRDY (1 << 4) /* Bit 4: Codec not ready interrupt (AC97). */
+#define SAI_INT_AFSDET (1 << 5) /* Bit 5: Anticipated frame synchronization detection interrupt */
+#define SAI_INT_LFSDET (1 << 6) /* Bit 6: Late frame synchronization detection interrupt */
+ /* Bits 7-31: Reserved */
+
+/* SAI Data Register (32-bit data) */
+
+#endif /* __ARCH_ARM_STC_STM32L4_CHIP_STM32L4_SAI_H */
diff --git a/arch/arm/src/stm32l4/chip/stm32l4x6xx_firewall.h b/arch/arm/src/stm32l4/chip/stm32l4x6xx_firewall.h
index e0471567fec6ac6c73edd4ddb75aa1d3f03f7a96..e1531de5d0349d8e73e6a1ccb0f6158e77338f43 100644
--- a/arch/arm/src/stm32l4/chip/stm32l4x6xx_firewall.h
+++ b/arch/arm/src/stm32l4/chip/stm32l4x6xx_firewall.h
@@ -101,4 +101,3 @@
#define FIREWALL_CR_VDE (1 << 2) /* Bit 2: Volatile data execution */
#endif /* __ARCH_ARM_SRC_STM32L4_CHIP_STM32L4X6XX_FIREWALL_H */
-
diff --git a/arch/arm/src/stm32l4/chip/stm32l4x6xx_pinmap.h b/arch/arm/src/stm32l4/chip/stm32l4x6xx_pinmap.h
index 2915c0c4397b72bbddfeb0302aa550c688b5efc2..8be6eca5a54eef2c65d41f4067dec036c7d2fe6d 100644
--- a/arch/arm/src/stm32l4/chip/stm32l4x6xx_pinmap.h
+++ b/arch/arm/src/stm32l4/chip/stm32l4x6xx_pinmap.h
@@ -845,4 +845,3 @@
#define GPIO_LPUART1_RTS_DE_2 (GPIO_ALT|GPIO_AF8 |GPIO_PORTG|GPIO_PIN6)
#endif /* __ARCH_ARM_SRC_STM32L4_CHIP_STM32L4X6XX_PINMAP_H */
-
diff --git a/arch/arm/src/stm32l4/chip/stm32l4x6xx_rcc.h b/arch/arm/src/stm32l4/chip/stm32l4x6xx_rcc.h
index c56e59c81168e63f6b219600d87b69d4cc0aa81d..c45c199e9b8b7f41ef8028fe0994fec0c8e48a42 100644
--- a/arch/arm/src/stm32l4/chip/stm32l4x6xx_rcc.h
+++ b/arch/arm/src/stm32l4/chip/stm32l4x6xx_rcc.h
@@ -760,5 +760,5 @@
#define RCC_CSR_WWDGRSTF (1 << 30) /* Bit 30: Window watchdog reset flag */
#define RCC_CSR_LPWRRSTF (1 << 31) /* Bit 31: Low-Power reset flag */
-#endif /* CONFIG_STM32L4_STM32F427 || CONFIG_STM32L4_STM32F429 */
+#endif /* CONFIG_STM32L4_STM32L476XX || CONFIG_STM32L4_STM32L486XX */
#endif /* __ARCH_ARM_SRC_STM32L4_CHIP_STM32F42XXX_RCC_H */
diff --git a/arch/arm/src/stm32l4/stm32l4_can.c b/arch/arm/src/stm32l4/stm32l4_can.c
index 18b49a86e7437f2a7d304c63b1ceb1fcb4ea65f0..ed14ca436093a5319d61130ca3c56dd8066be3c9 100644
--- a/arch/arm/src/stm32l4/stm32l4_can.c
+++ b/arch/arm/src/stm32l4/stm32l4_can.c
@@ -163,9 +163,9 @@ static bool stm32l4can_txempty(FAR struct can_dev_s *dev);
/* CAN interrupt handling */
static int stm32l4can_rxinterrupt(int irq, FAR void *context, int rxmb);
-static int stm32l4can_rx0interrupt(int irq, FAR void *context);
-static int stm32l4can_rx1interrupt(int irq, FAR void *context);
-static int stm32l4can_txinterrupt(int irq, FAR void *context);
+static int stm32l4can_rx0interrupt(int irq, FAR void *context, FAR void *arg);
+static int stm32l4can_rx1interrupt(int irq, FAR void *context, FAR void *arg);
+static int stm32l4can_txinterrupt(int irq, FAR void *context, FAR void *arg);
/* Initialization */
@@ -627,7 +627,7 @@ static int stm32l4can_setup(FAR struct can_dev_s *dev)
* The others are not used.
*/
- ret = irq_attach(priv->canrx[0], stm32l4can_rx0interrupt);
+ ret = irq_attach(priv->canrx[0], stm32l4can_rx0interrupt, NULL);
if (ret < 0)
{
canerr("ERROR: Failed to attach CAN%d RX0 IRQ (%d)",
@@ -635,7 +635,7 @@ static int stm32l4can_setup(FAR struct can_dev_s *dev)
return ret;
}
- ret = irq_attach(priv->canrx[1], stm32l4can_rx1interrupt);
+ ret = irq_attach(priv->canrx[1], stm32l4can_rx1interrupt, NULL);
if (ret < 0)
{
canerr("ERROR: Failed to attach CAN%d RX1 IRQ (%d)",
@@ -643,7 +643,7 @@ static int stm32l4can_setup(FAR struct can_dev_s *dev)
return ret;
}
- ret = irq_attach(priv->cantx, stm32l4can_txinterrupt);
+ ret = irq_attach(priv->cantx, stm32l4can_txinterrupt, NULL);
if (ret < 0)
{
canerr("ERROR: Failed to attach CAN%d TX IRQ (%d)",
@@ -1462,7 +1462,7 @@ errout:
*
****************************************************************************/
-static int stm32l4can_rx0interrupt(int irq, FAR void *context)
+static int stm32l4can_rx0interrupt(int irq, FAR void *context, FAR void *arg)
{
return stm32l4can_rxinterrupt(irq, context, 0);
}
@@ -1482,7 +1482,7 @@ static int stm32l4can_rx0interrupt(int irq, FAR void *context)
*
****************************************************************************/
-static int stm32l4can_rx1interrupt(int irq, FAR void *context)
+static int stm32l4can_rx1interrupt(int irq, FAR void *context, FAR void *arg)
{
return stm32l4can_rxinterrupt(irq, context, 1);
}
@@ -1502,7 +1502,7 @@ static int stm32l4can_rx1interrupt(int irq, FAR void *context)
*
****************************************************************************/
-static int stm32l4can_txinterrupt(int irq, FAR void *context)
+static int stm32l4can_txinterrupt(int irq, FAR void *context, FAR void *arg)
{
FAR struct can_dev_s *dev = NULL;
FAR struct stm32l4_can_s *priv;
diff --git a/arch/arm/src/stm32l4/stm32l4_comp.c b/arch/arm/src/stm32l4/stm32l4_comp.c
new file mode 100644
index 0000000000000000000000000000000000000000..518e648639ce8b6e3c26cc24fe20eb02d2e15ac0
--- /dev/null
+++ b/arch/arm/src/stm32l4/stm32l4_comp.c
@@ -0,0 +1,316 @@
+/************************************************************************************
+ * arch/arm/src/stm32l4/stm32l4_comp.c
+ *
+ * Copyright (c) 2017 Gregory Nutt. All rights reserved.
+ *
+ * Based on COMP driver from the Motorola MDK:
+ *
+ * Copyright (c) 2016 Motorola Mobility, LLC. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ************************************************************************************/
+
+/************************************************************************************
+ * Included Files
+ ************************************************************************************/
+
+#include "chip.h"
+#include "stm32l4_comp.h"
+#include "stm32l4_gpio.h"
+#include "up_arch.h"
+
+#include
+
+#if !(defined(CONFIG_STM32L4_STM32L4X3) || defined(CONFIG_STM32L4_STM32L4X6))
+# error "Unrecognized STM32 chip"
+#endif
+
+/************************************************************************************
+ * Private Functions
+ ************************************************************************************/
+
+/************************************************************************************
+ * Name: modify_csr
+ ************************************************************************************/
+
+static inline void modify_csr(int cmp, uint32_t clearbits, uint32_t setbits)
+{
+ modifyreg32(cmp == STM32L4_COMP1 ? STM32L4_COMP1_CSR : STM32L4_COMP2_CSR,
+ clearbits, setbits);
+}
+
+/************************************************************************************
+ * Name: get_csr
+ ************************************************************************************/
+
+static inline uint32_t get_csr(int cmp)
+{
+ return getreg32(cmp == STM32L4_COMP1 ? STM32L4_COMP1_CSR : STM32L4_COMP2_CSR);
+}
+
+/*************************************************************************************
+ * Public Functions
+ ************************************************************************************/
+
+/************************************************************************************
+ * Name: stm32l4_compconfig
+ *
+ * Description:
+ * Configure comparator and I/Os used as comparators inputs
+ *
+ * Parameters:
+ * cmp - comparator
+ * cfg - configuration
+ *
+ * Returns:
+ * 0 on success, a negated errno value on failure
+ *
+ ************************************************************************************/
+
+int stm32l4_compconfig(int cmp, const struct stm32l4_comp_config_s *cfg)
+{
+ uint32_t regval = 0;
+ uint32_t mask = 0;
+ uint32_t clearbits;
+ uint32_t setbits;
+
+ /* Input plus */
+
+ mask |= COMP_CSR_INPSEL_MASK;
+ switch (cfg->inp)
+ {
+ case STM32L4_COMP_INP_PIN_1:
+ stm32l4_configgpio(cmp == STM32L4_COMP1 ? GPIO_COMP1_INP_1 : GPIO_COMP2_INP_1);
+ regval |= COMP_CSR_INPSEL_PIN1;
+ break;
+
+ case STM32L4_COMP_INP_PIN_2:
+ stm32l4_configgpio(cmp == STM32L4_COMP1 ? GPIO_COMP1_INP_2 : GPIO_COMP2_INP_2);
+ regval |= COMP_CSR_INPSEL_PIN2;
+ break;
+
+#if defined(CONFIG_STM32L4_STM32L4X3)
+ case STM32L4_COMP_INP_PIN_3:
+ stm32l4_configgpio(cmp == STM32L4_COMP1 ? GPIO_COMP1_INP_3 : GPIO_COMP2_INP_3);
+ regval |= COMP_CSR_INPSEL_PIN3;
+ break;
+#endif
+
+ default:
+ return -EINVAL;
+ }
+
+ /* Input minus */
+
+ mask |= COMP_CSR_INMSEL_MASK;
+ switch (cfg->inm)
+ {
+ case STM32L4_COMP_INM_1_4_VREF:
+ regval |= COMP_CSR_INMSEL_25PCT;
+ mask |= (COMP_CSR_SCALEN | COMP_CSR_BRGEN);
+ regval |= (COMP_CSR_SCALEN | COMP_CSR_BRGEN);
+ break;
+
+ case STM32L4_COMP_INM_1_2_VREF:
+ regval |= COMP_CSR_INMSEL_50PCT;
+ mask |= (COMP_CSR_SCALEN | COMP_CSR_BRGEN);
+ regval |= (COMP_CSR_SCALEN | COMP_CSR_BRGEN);
+ break;
+
+ case STM32L4_COMP_INM_3_4_VREF:
+ regval |= COMP_CSR_INMSEL_75PCT;
+ mask |= (COMP_CSR_SCALEN | COMP_CSR_BRGEN);
+ regval |= (COMP_CSR_SCALEN | COMP_CSR_BRGEN);
+ break;
+
+ case STM32L4_COMP_INM_VREF:
+ regval |= COMP_CSR_INMSEL_VREF;
+ mask |= (COMP_CSR_SCALEN | COMP_CSR_BRGEN);
+ regval |= COMP_CSR_SCALEN;
+ break;
+
+ case STM32L4_COMP_INM_DAC_1:
+ regval |= COMP_CSR_INMSEL_DAC1;
+ break;
+
+ case STM32L4_COMP_INM_DAC_2:
+ regval |= COMP_CSR_INMSEL_DAC2;
+ break;
+
+ case STM32L4_COMP_INM_PIN_1:
+ stm32l4_configgpio(cmp == STM32L4_COMP1 ? GPIO_COMP1_INM_1 : GPIO_COMP2_INM_1);
+ regval |= COMP_CSR_INMSEL_PIN1;
+ break;
+
+ case STM32L4_COMP_INM_PIN_2:
+ stm32l4_configgpio(cmp == STM32L4_COMP1 ? GPIO_COMP1_INM_2 : GPIO_COMP2_INM_2);
+#if defined(CONFIG_STM32L4_STM32L4X6)
+ regval |= COMP_CSR_INMSEL_PIN2;
+#else
+ regval |= COMP_CSR_INMSEL_INMESEL;
+ mask |= COMP_CSR_INMESEL_MASK;
+ regval |= COMP_CSR_INMSEL_PIN2;
+#endif
+ break;
+
+#if defined(CONFIG_STM32L4_STM32L4X3)
+ case STM32L4_COMP_INM_PIN_3:
+ stm32l4_configgpio(cmp == STM32L4_COMP1 ? GPIO_COMP1_INM_3 : GPIO_COMP2_INM_3);
+ regval |= COMP_CSR_INMSEL_INMESEL;
+ mask |= COMP_CSR_INMESEL_MASK;
+ regval |= COMP_CSR_INMSEL_PIN3;
+ break;
+
+ case STM32L4_COMP_INM_PIN_4:
+ stm32l4_configgpio(cmp == STM32L4_COMP1 ? GPIO_COMP1_INM_4 : GPIO_COMP2_INM_4);
+ regval |= COMP_CSR_INMSEL_INMESEL;
+ mask |= COMP_CSR_INMESEL_MASK;
+ regval |= COMP_CSR_INMSEL_PIN4;
+ break;
+
+ case STM32L4_COMP_INM_PIN_5:
+ stm32l4_configgpio(cmp == STM32L4_COMP1 ? GPIO_COMP1_INM_5 : GPIO_COMP2_INM_5);
+ regval |= COMP_CSR_INMSEL_INMESEL;
+ mask |= COMP_CSR_INMESEL_MASK;
+ regval |= COMP_CSR_INMSEL_PIN5;
+ break;
+
+#endif
+ default:
+ return -EINVAL;
+ }
+
+ /* Hysteresis */
+
+ mask |= COMP_CSR_HYST_MASK;
+ switch (cfg->hyst)
+ {
+ case STM32L4_COMP_HYST_NONE:
+ regval |= COMP_CSR_HYST_NONE;
+ break;
+
+ case STM32L4_COMP_HYST_LOW:
+ regval |= COMP_CSR_HYST_LOW;
+ break;
+
+ case STM32L4_COMP_HYST_MEDIUM:
+ regval |= COMP_CSR_HYST_MEDIUM;
+ break;
+
+ case STM32L4_COMP_HYST_HIGH:
+ regval |= COMP_CSR_HYST_HIGH;
+ break;
+
+ default:
+ return -EINVAL;
+ }
+
+ /* Power/speed Mode */
+
+ mask |= COMP_CSR_PWRMODE_MASK;
+ switch(cfg->speed)
+ {
+ case STM32L4_COMP_SPEED_HIGH:
+ regval |= COMP_CSR_PWRMODE_HIGH;
+ break;
+
+ case STM32L4_COMP_SPEED_MEDIUM:
+ regval |= COMP_CSR_PWRMODE_MEDIUM;
+ break;
+
+ case STM32L4_COMP_SPEED_LOW:
+ regval |= COMP_CSR_PWRMODE_LOW;
+ break;
+
+ default:
+ return -EINVAL;
+ }
+
+ /* Polarity */
+
+ mask |= COMP_CSR_POLARITY_MASK;
+ if (cfg->inverted)
+ {
+ regval |= COMP_CSR_POLARITY_INVERT;
+ }
+
+ /* Disable blanking */
+
+ mask |= COMP_CSR_BLANK_MASK;
+ regval |= COMP_CSR_BLANK_NONE;
+
+ clearbits = regval ^ mask;
+ setbits = regval;
+
+ modify_csr(cmp, clearbits, setbits);
+ return 0;
+}
+
+/************************************************************************************
+ * Name: stm32l4_compenable
+ *
+ * Description:
+ * Enable/disable comparator
+ *
+ * Parameters:
+ * cmp - comparator
+ * cfg - enable/disable flag
+ *
+ * Returns:
+ * 0 on success, a negated errno value on failure
+ *
+ ************************************************************************************/
+
+int stm32l4_compenable(int cmp, bool en)
+{
+ uint32_t clearbits = en ? 0 : COMP_CSR_EN;
+ uint32_t setbits = en ? COMP_CSR_EN : 0;
+
+ modify_csr(cmp, clearbits, setbits);
+ return 0;
+}
+
+/************************************************************************************
+ * Name: stm32l4_compread
+ *
+ * Description:
+ * Read comparator output
+ *
+ * Parameters:
+ * - cmp: comparator
+ *
+ * Returns:
+ * true for high, false for low
+ *
+ ************************************************************************************/
+
+bool stm32l4_compread(int cmp)
+{
+ return !!(get_csr(cmp) & COMP_CSR_VALUE);
+}
diff --git a/arch/arm/src/stm32l4/stm32l4_comp.h b/arch/arm/src/stm32l4/stm32l4_comp.h
new file mode 100644
index 0000000000000000000000000000000000000000..eecede715b2a4c63d0a411a05ac59bfc790e8a93
--- /dev/null
+++ b/arch/arm/src/stm32l4/stm32l4_comp.h
@@ -0,0 +1,221 @@
+/************************************************************************************
+ * arch/arm/src/stm32/stm32l4_comp.h
+ *
+ * Copyright (c) 2016 Motorola Mobility, LLC.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ************************************************************************************/
+
+#ifndef __ARCH_ARM_SRC_STM32L4_STM32L4_COMP_H
+#define __ARCH_ARM_SRC_STM32L4_STM32L4_COMP_H
+
+/************************************************************************************
+ * Included Files
+ ************************************************************************************/
+
+#include
+
+#include
+
+#include "chip/stm32l4_comp.h"
+
+/************************************************************************************
+ * Public Types
+ ************************************************************************************/
+
+#if defined(CONFIG_STM32L4_STM32L4X3)
+/* Comparators */
+
+enum stm32l4_comp_e
+{
+ STM32L4_COMP1,
+ STM32L4_COMP2,
+ STM32L4_COMP_NUM /* Number of comparators */
+};
+
+/* Plus input */
+
+enum stm32l4_comp_inp_e
+{
+ STM32L4_COMP_INP_PIN_1, /* COMP1: PC5, COMP2: PB4 */
+ STM32L4_COMP_INP_PIN_2, /* COMP1: PB2, COMP2: PB6 */
+ STM32L4_COMP_INP_PIN_3 /* COMP1: PA1, COMP2: PA3 */
+};
+
+/* Minus input */
+
+enum stm32l4_comp_inm_e
+{
+ STM32L4_COMP_INM_1_4_VREF,
+ STM32L4_COMP_INM_1_2_VREF,
+ STM32L4_COMP_INM_3_4_VREF,
+ STM32L4_COMP_INM_VREF,
+ STM32L4_COMP_INM_DAC_1,
+ STM32L4_COMP_INM_DAC_2,
+ STM32L4_COMP_INM_PIN_1, /* COMP1: PB1, COMP2: PB3 */
+ STM32L4_COMP_INM_PIN_2, /* COMP1: PC4, COMP2: PB7 */
+ STM32L4_COMP_INM_PIN_3, /* COMP1: PA0, COMP2: PA2 */
+ STM32L4_COMP_INM_PIN_4, /* COMP1: PA4, COMP2: PA4 */
+ STM32L4_COMP_INM_PIN_5 /* COMP1: PA5, COMP2: PA5 */
+};
+
+#elif defined(CONFIG_STM32L4_STM32L4X6)
+/* Comparators */
+
+enum stm32l4_comp_e
+{
+ STM32L4_COMP1,
+ STM32L4_COMP2,
+ STM32L4_COMP_NUM /* Number of comparators */
+};
+
+/* Plus input */
+
+enum stm32l4_comp_inp_e
+{
+ STM32L4_COMP_INP_PIN_1, /* COMP1: PC5, COMP2: PB4 */
+ STM32L4_COMP_INP_PIN_2 /* COMP1: PB2, COMP2: PB6 */
+};
+
+/* Minus input */
+
+enum stm32l4_comp_inm_e
+{
+ STM32L4_COMP_INM_1_4_VREF,
+ STM32L4_COMP_INM_1_2_VREF,
+ STM32L4_COMP_INM_3_4_VREF,
+ STM32L4_COMP_INM_VREF,
+ STM32L4_COMP_INM_DAC_1,
+ STM32L4_COMP_INM_DAC_2,
+ STM32L4_COMP_INM_PIN_1, /* COMP1: PB1, COMP2: PB3 */
+ STM32L4_COMP_INM_PIN_2 /* COMP1: PC4, COMP2: PB7 */
+};
+#endif
+
+/* Hysteresis */
+
+enum stm32l4_comp_hyst_e
+{
+ STM32L4_COMP_HYST_NONE,
+ STM32L4_COMP_HYST_LOW,
+ STM32L4_COMP_HYST_MEDIUM,
+ STM32L4_COMP_HYST_HIGH
+};
+
+/* Power/Speed Modes */
+
+enum stm32l4_comp_speed_e
+{
+ STM32L4_COMP_SPEED_HIGH,
+ STM32L4_COMP_SPEED_MEDIUM,
+ STM32L4_COMP_SPEED_LOW
+};
+
+/* Comparator configuration ***********************************************************/
+
+struct stm32l4_comp_config_s
+{
+ uint8_t inp; /* Plus input pin (see enum stm32l4_comp_inp_e) */
+ uint8_t inm; /* Minus input pin (see enum stm32l4_comp_inm_e) */
+ uint8_t hyst; /* Hysteresis (see enum stm32l4_comp_hyst_e) */
+ uint8_t speed; /* Speed (see stm32l4_comp_speed_e) */
+ bool inverted; /* Invert output? */
+};
+
+/************************************************************************************
+ * Public Function Prototypes
+ ************************************************************************************/
+
+#ifndef __ASSEMBLY__
+#ifdef __cplusplus
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+/************************************************************************************
+ * Name: stm32l4_compconfig
+ *
+ * Description:
+ * Configure comparator and I/Os used as comparators inputs
+ *
+ * Parameters:
+ * cmp - comparator
+ * cfg - configuration
+ *
+ * Returns:
+ * 0 on success, a negated errno value on failure
+ *
+ ************************************************************************************/
+
+int stm32l4_compconfig(int cmp, const struct stm32l4_comp_config_s *cfg);
+
+/************************************************************************************
+ * Name: stm32l4_compenable
+ *
+ * Description:
+ * Enable/disable comparator
+ *
+ * Parameters:
+ * cmp - comparator
+ * cfg - enable/disable flag
+ *
+ * Returns:
+ * 0 on success, a negated errno value on failure
+ *
+ ************************************************************************************/
+
+int stm32l4_compenable(int cmp, bool en);
+
+/************************************************************************************
+ * Name: stm32l4_compread
+ *
+ * Description:
+ * Read comparator output
+ *
+ * Parameters:
+ * - cmp: comparator
+ *
+ * Returns:
+ * true for high, false for low
+ *
+ ************************************************************************************/
+
+bool stm32l4_compread(int cmp);
+
+#undef EXTERN
+#ifdef __cplusplus
+}
+#endif
+#endif /* __ASSEMBLY__ */
+
+#endif /* __ARCH_ARM_SRC_STM32L4_STM32L4_COMP_H */
diff --git a/arch/arm/src/stm32l4/stm32l4_exti.h b/arch/arm/src/stm32l4/stm32l4_exti.h
index 87dbd78c25506963cf1e2830bb347ed2cd513c01..2f57229ea213222a067cb1ff83a2a47b98fa4b36 100644
--- a/arch/arm/src/stm32l4/stm32l4_exti.h
+++ b/arch/arm/src/stm32l4/stm32l4_exti.h
@@ -1,7 +1,7 @@
/************************************************************************************
* arch/arm/src/stm32l4/stm32l4_exti.h
*
- * Copyright (C) 2009, 2012, 2015 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2009, 2012, 2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
*
* Redistribution and use in source and binary forms, with or without
@@ -72,23 +72,24 @@ extern "C"
* Description:
* Sets/clears GPIO based event and interrupt triggers.
*
- * Parameters:
- * - pinset: gpio pin configuration
- * - rising/falling edge: enables
- * - event: generate event when set
- * - func: when non-NULL, generate interrupt
+ * Input Parameters:
+ * pinset - GPIO pin configuration
+ * risingedge - Enables interrupt on rising edges
+ * fallingedge - Enables interrupt on falling edges
+ * event - Generate event when set
+ * func - When non-NULL, generate interrupt
+ * arg - Argument passed to the interrupt callback
*
- * Returns:
- * The previous value of the interrupt handler function pointer. This value may,
- * for example, be used to restore the previous handler when multiple handlers are
- * used.
+ * Returned Value:
+ * Zero (OK) is returned on success, otherwise a negated errno value is returned
+ * to indicate the nature of the failure.
*
************************************************************************************/
-xcpt_t stm32l4_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
- bool event, xcpt_t func);
+int stm32l4_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
+ bool event, xcpt_t func, void *arg);
-/************************************************************************************
+/****************************************************************************
* Name: stm32l4_exti_alarm
*
* Description:
@@ -98,16 +99,41 @@ xcpt_t stm32l4_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
* - rising/falling edge: enables interrupt on rising/falling edges
* - event: generate event when set
* - func: when non-NULL, generate interrupt
+ * - arg: Argument passed to the interrupt callback
*
* Returns:
- * The previous value of the interrupt handler function pointer. This value may,
- * for example, be used to restore the previous handler when multiple handlers are
- * used.
+ * Zero (OK) on success; a negated errno value on failure indicating the
+ * nature of the failure.
*
- ************************************************************************************/
+ ****************************************************************************/
#ifdef CONFIG_RTC_ALARM
-xcpt_t stm32l4_exti_alarm(bool risingedge, bool fallingedge, bool event, xcpt_t func);
+int stm32l4_exti_alarm(bool risingedge, bool fallingedge, bool event,
+ xcpt_t func, void *arg);
+#endif
+
+/****************************************************************************
+ * Name: stm32l4_exti_comp
+ *
+ * Description:
+ * Sets/clears comparator based events and interrupt triggers.
+ *
+ * Parameters:
+ * - cmp: comparator
+ * - rising/falling edge: enables interrupt on rising/falling edget
+ * - event: generate event when set
+ * - func: when non-NULL, generate interrupt
+ * - arg: Argument passed to the interrupt callback
+ *
+ * Returns:
+ * Zero (OK) returned on success; a negated errno value is returned on
+ * failure.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_STM32L4_COMP
+int stm32l4_exti_comp(int cmp, bool risingedge, bool fallingedge,
+ bool event, xcpt_t func, void *arg);
#endif
#undef EXTERN
diff --git a/arch/arm/src/stm32l4/stm32l4_exti_alarm.c b/arch/arm/src/stm32l4/stm32l4_exti_alarm.c
index c71d9752837a4079bd51774e3ce56827174876ef..d4fbfd6c039c2d5fd207c17296d3f53221ea56cc 100644
--- a/arch/arm/src/stm32l4/stm32l4_exti_alarm.c
+++ b/arch/arm/src/stm32l4/stm32l4_exti_alarm.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/stm32l4/stm32l4_exti_alarm.c
*
- * Copyright (C) 2009, 2012 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2009, 2012, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
* Diego Sanchez
* dev@ziggurat29.com (adaptation to stm32l4)
@@ -60,7 +60,8 @@
/* Interrupt handlers attached to the ALARM EXTI */
-static xcpt_t stm32l4_exti_callback;
+static xcpt_t g_alarm_callback;
+static void *g_callback_arg;
/****************************************************************************
* Private Functions
@@ -74,15 +75,15 @@ static xcpt_t stm32l4_exti_callback;
*
****************************************************************************/
-static int stm32l4_exti_alarm_isr(int irq, void *context)
+static int stm32l4_exti_alarm_isr(int irq, void *context, FAR void *arg)
{
int ret = OK;
/* Dispatch the interrupt to the handler */
- if (stm32l4_exti_callback)
+ if (g_alarm_callback != NULL)
{
- ret = stm32l4_exti_callback(irq, context);
+ ret = g_alarm_callback(irq, context, g_callback_arg);
}
/* Clear the pending EXTI interrupt */
@@ -108,27 +109,24 @@ static int stm32l4_exti_alarm_isr(int irq, void *context)
* - func: when non-NULL, generate interrupt
*
* Returns:
- * The previous value of the interrupt handler function pointer. This
- * value may, for example, be used to restore the previous handler when
- * multiple handlers are used.
+ * Zero (OK) on success; a negated errno value on failure indicating the
+ * nature of the failure.
*
****************************************************************************/
-xcpt_t stm32l4_exti_alarm(bool risingedge, bool fallingedge, bool event,
- xcpt_t func)
+int stm32l4_exti_alarm(bool risingedge, bool fallingedge, bool event,
+ xcpt_t func, void *arg)
{
- xcpt_t oldhandler;
-
/* Get the previous GPIO IRQ handler; Save the new IRQ handler. */
- oldhandler = stm32l4_exti_callback;
- stm32l4_exti_callback = func;
+ g_alarm_callback = func;
+ g_callback_arg = arg;
/* Install external interrupt handlers (if not already attached) */
if (func)
{
- irq_attach(STM32L4_IRQ_RTCALRM, stm32l4_exti_alarm_isr);
+ irq_attach(STM32L4_IRQ_RTCALRM, stm32l4_exti_alarm_isr, NULL);
up_enable_irq(STM32L4_IRQ_RTCALRM);
}
else
@@ -156,5 +154,5 @@ xcpt_t stm32l4_exti_alarm(bool risingedge, bool fallingedge, bool event,
/* Return the old IRQ handler */
- return oldhandler;
+ return OK;
}
diff --git a/arch/arm/src/stm32l4/stm32l4_exti_comp.c b/arch/arm/src/stm32l4/stm32l4_exti_comp.c
new file mode 100644
index 0000000000000000000000000000000000000000..a1295b6970b714ec22d93a24fc32c791b00dedb9
--- /dev/null
+++ b/arch/arm/src/stm32l4/stm32l4_exti_comp.c
@@ -0,0 +1,180 @@
+/****************************************************************************
+ * arch/arm/src/stm32/stm32l4_exti_comp.c
+ *
+ * Copyright (c) 2017 Gregory Nutt. All rights reserved
+ * Copyright (c) 2016 Motorola Mobility, LLC. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include
+
+#include
+#include
+
+#include "up_arch.h"
+#include "stm32l4_comp.h"
+#include "stm32l4_exti.h"
+#include "chip/stm32l4_exti.h"
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct comp_callback_s
+{
+ xcpt_t callback;
+ void *arg;
+};
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/* Interrupt handlers attached to the COMP EXTI lines */
+
+static struct comp_callback_s g_comp_handlers[STM32L4_COMP_NUM];
+
+/* Comparator EXTI lines */
+
+static const uint32_t g_comp_lines[STM32L4_COMP_NUM] =
+{
+#if defined(CONFIG_STM32L4_STM32L4X3) || defined (CONFIG_STM32L4_STM32L4X6)
+ EXTI1_COMP1,
+ EXTI1_COMP2
+#else
+# error "Unrecognized STM32L4 chip"
+#endif
+};
+
+ /****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+static int stm32l4_exti_comp_isr(int irq, void *context)
+{
+ uint32_t pr;
+ uint32_t ln;
+ int ret = 0;
+ int i;
+
+ /* Examine the state of each comparator line and dispatch interrupts */
+
+ pr = getreg32(STM32L4_EXTI1_PR);
+ for (i = 0; i < STM32L4_COMP_NUM; i++)
+ {
+ ln = g_comp_lines[i];
+ if ((pr & ln) != 0)
+ {
+ /* Clear the pending interrupt */
+
+ putreg32(ln, STM32L4_EXTI1_PR);
+ if (g_comp_handlers[i].callback != NULL)
+ {
+ xcpt_t callback = g_comp_handlers[i].callback;
+ vid *arg = g_comp_handlers[i].arg;
+ ret = callback(irq, context, arg);
+ }
+ }
+ }
+
+ return ret;
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: stm32l4_exti_comp
+ *
+ * Description:
+ * Sets/clears comparator based events and interrupt triggers.
+ *
+ * Parameters:
+ * - cmp: comparator
+ * - rising/falling edge: enables interrupt on rising/falling edget
+ * - event: generate event when set
+ * - func: when non-NULL, generate interrupt
+ * - arg: Argument passed to the interrupt callback
+ *
+ * Returns:
+ * Zero (OK) returned on success; a negated errno value is returned on
+ * failure.
+ *
+ ****************************************************************************/
+
+int stm32l4_exti_comp(int cmp, bool risingedge, bool fallingedge,
+ bool event, xcpt_t func, void *arg)
+{
+ irqstate_t flags;
+ uint32_t ln = g_comp_lines[cmp];
+
+ /* Perform the following within a critical section so that the handler gets
+ * installed correctly before the next interrupt is received.
+ */
+
+ flags = enter_critical_section();
+
+ /* Install external interrupt handlers */
+
+ if (func != NULL)
+ {
+ irq_attach(STM32L4_IRQ_COMP, stm32l4_exti_comp_isr, NULL);
+ up_enable_irq(STM32L4_IRQ_COMP);
+ }
+ else
+ {
+ up_disable_irq(STM32L4_IRQ_COMP);
+ }
+
+ /* Configure rising/falling edges */
+
+ modifyreg32(STM32L4_EXTI1_RTSR, risingedge ? 0 : ln, risingedge ? ln : 0);
+ modifyreg32(STM32L4_EXTI1_FTSR, fallingedge ? 0 : ln, fallingedge ? ln : 0);
+
+ /* Enable Events and Interrupts */
+
+ modifyreg32(STM32L4_EXTI1_EMR, event ? 0 : ln, event ? ln : 0);
+ modifyreg32(STM32L4_EXTI1_IMR, func ? 0 : ln, func ? ln : 0);
+
+ /* Get the previous IRQ handler and save the new IRQ handler. */
+
+ g_comp_handlers[cmp].callback = func;
+ g_comp_handlers[cmp].arg = arg;
+
+ /* Leave the critical section */
+
+ leave_critical_section(flags);
+ return OK;
+}
diff --git a/arch/arm/src/stm32l4/stm32l4_exti_gpio.c b/arch/arm/src/stm32l4/stm32l4_exti_gpio.c
index ede05e83221963110e1e4bb108b51e2a3e54c2ff..da7eb4e19aaaa81a7782ae4f9c7b4035fbff7779 100644
--- a/arch/arm/src/stm32l4/stm32l4_exti_gpio.c
+++ b/arch/arm/src/stm32l4/stm32l4_exti_gpio.c
@@ -55,13 +55,23 @@
#include "stm32l4_gpio.h"
#include "stm32l4_exti.h"
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct gpio_callback_s
+{
+ xcpt_t callback; /* Callback entry point */
+ void *arg; /* The argument that accompanies the callback */
+};
+
/****************************************************************************
* Private Data
****************************************************************************/
/* Interrupt handlers attached to each EXTI */
-static xcpt_t stm32l4_exti_callbacks[16];
+static struct gpio_callback_s g_gpio_handlers[16];
/****************************************************************************
* Private Functions
@@ -71,7 +81,7 @@ static xcpt_t stm32l4_exti_callbacks[16];
* Interrupt Service Routines - Dispatchers
****************************************************************************/
-static int stm32l4_exti0_isr(int irq, void *context)
+static int stm32l4_exti0_isr(int irq, void *context, FAR void *arg)
{
int ret = OK;
@@ -81,15 +91,18 @@ static int stm32l4_exti0_isr(int irq, void *context)
/* And dispatch the interrupt to the handler */
- if (stm32l4_exti_callbacks[0])
+ if (g_gpio_handlers[0].callback != NULL)
{
- ret = stm32l4_exti_callbacks[0](irq, context);
+ xcpt_t callback = g_gpio_handlers[0].callback;
+ void *cbarg = g_gpio_handlers[0].arg;
+
+ ret = callback(irq, context, cbarg);
}
return ret;
}
-static int stm32l4_exti1_isr(int irq, void *context)
+static int stm32l4_exti1_isr(int irq, void *context, FAR void *arg)
{
int ret = OK;
@@ -99,15 +112,18 @@ static int stm32l4_exti1_isr(int irq, void *context)
/* And dispatch the interrupt to the handler */
- if (stm32l4_exti_callbacks[1])
+ if (g_gpio_handlers[1].callback != NULL)
{
- ret = stm32l4_exti_callbacks[1](irq, context);
+ xcpt_t callback = g_gpio_handlers[1].callback;
+ void *cbarg = g_gpio_handlers[1].arg;
+
+ ret = callback(irq, context, cbarg);
}
return ret;
}
-static int stm32l4_exti2_isr(int irq, void *context)
+static int stm32l4_exti2_isr(int irq, void *context, FAR void *arg)
{
int ret = OK;
@@ -117,15 +133,18 @@ static int stm32l4_exti2_isr(int irq, void *context)
/* And dispatch the interrupt to the handler */
- if (stm32l4_exti_callbacks[2])
+ if (g_gpio_handlers[2].callback != NULL)
{
- ret = stm32l4_exti_callbacks[2](irq, context);
+ xcpt_t callback = g_gpio_handlers[2].callback;
+ void *cbarg = g_gpio_handlers[2].arg;
+
+ ret = callback(irq, context, cbarg);
}
return ret;
}
-static int stm32l4_exti3_isr(int irq, void *context)
+static int stm32l4_exti3_isr(int irq, void *context, FAR void *arg)
{
int ret = OK;
@@ -135,15 +154,18 @@ static int stm32l4_exti3_isr(int irq, void *context)
/* And dispatch the interrupt to the handler */
- if (stm32l4_exti_callbacks[3])
+ if (g_gpio_handlers[3].callback != NULL)
{
- ret = stm32l4_exti_callbacks[3](irq, context);
+ xcpt_t callback = g_gpio_handlers[3].callback;
+ void *cbarg = g_gpio_handlers[3].arg;
+
+ ret = callback(irq, context, cbarg);
}
return ret;
}
-static int stm32l4_exti4_isr(int irq, void *context)
+static int stm32l4_exti4_isr(int irq, void *context, FAR void *arg)
{
int ret = OK;
@@ -153,15 +175,18 @@ static int stm32l4_exti4_isr(int irq, void *context)
/* And dispatch the interrupt to the handler */
- if (stm32l4_exti_callbacks[4])
+ if (g_gpio_handlers[4].callback != NULL)
{
- ret = stm32l4_exti_callbacks[4](irq, context);
+ xcpt_t callback = g_gpio_handlers[4].callback;
+ void *cbarg = g_gpio_handlers[4].arg;
+
+ ret = callback(irq, context, cbarg);
}
return ret;
}
-static int stm32l4_exti_multiisr(int irq, void *context, int first, int last)
+static int stm32l4_exti_multiisr(int irq, void *context, void *arg, int first, int last)
{
uint32_t pr;
int pin;
@@ -186,10 +211,14 @@ static int stm32l4_exti_multiisr(int irq, void *context, int first, int last)
/* And dispatch the interrupt to the handler */
- if (stm32l4_exti_callbacks[pin])
+ if (g_gpio_handlers[pin].callback != NULL)
{
- int tmp = stm32l4_exti_callbacks[pin](irq, context);
- if (tmp != OK)
+ xcpt_t callback = g_gpio_handlers[pin].callback;
+ void *cbarg = g_gpio_handlers[pin].arg;
+ int tmp;
+
+ tmp = callback(irq, context, cbarg);
+ if (tmp < 0)
{
ret = tmp;
}
@@ -200,14 +229,14 @@ static int stm32l4_exti_multiisr(int irq, void *context, int first, int last)
return ret;
}
-static int stm32l4_exti95_isr(int irq, void *context)
+static int stm32l4_exti95_isr(int irq, void *context, void *arg)
{
- return stm32l4_exti_multiisr(irq, context, 5, 9);
+ return stm32l4_exti_multiisr(irq, context, arg, 5, 9);
}
-static int stm32l4_exti1510_isr(int irq, void *context)
+static int stm32l4_exti1510_isr(int irq, void *context, FAR void *arg)
{
- return stm32l4_exti_multiisr(irq, context, 10, 15);
+ return stm32l4_exti_multiisr(irq, context, arg, 10, 15);
}
/****************************************************************************
@@ -220,30 +249,32 @@ static int stm32l4_exti1510_isr(int irq, void *context)
* Description:
* Sets/clears GPIO based event and interrupt triggers.
*
- * Parameters:
- * - pinset: GPIO pin configuration
- * - risingedge: Enables interrupt on rising edges
- * - fallingedge: Enables interrupt on falling edges
- * - event: Generate event when set
- * - func: When non-NULL, generate interrupt
+ * Description:
+ * Sets/clears GPIO based event and interrupt triggers.
*
- * Returns:
- * The previous value of the interrupt handler function pointer. This
- * value may, for example, be used to restore the previous handler when
- * multiple handlers are used.
+ * Input Parameters:
+ * pinset - GPIO pin configuration
+ * risingedge - Enables interrupt on rising edges
+ * fallingedge - Enables interrupt on falling edges
+ * event - Generate event when set
+ * func - When non-NULL, generate interrupt
+ * arg - Argument passed to the interrupt callback
*
- ****************************************************************************/
+ * Returned Value:
+ * Zero (OK) is returned on success, otherwise a negated errno value is returned
+ * to indicate the nature of the failure.
+ *
+ ************************************************************************************/
-xcpt_t stm32l4_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
- bool event, xcpt_t func)
+int stm32l4_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
+ bool event, xcpt_t func, void *arg)
{
+ struct gpio_callback_s *shared_cbs;
uint32_t pin = pinset & GPIO_PIN_MASK;
uint32_t exti = STM32L4_EXTI1_BIT(pin);
int irq;
xcpt_t handler;
- xcpt_t oldhandler = NULL;
int nshared;
- xcpt_t *shared_cbs;
int i;
/* Select the interrupt handler for this EXTI pin */
@@ -252,7 +283,7 @@ xcpt_t stm32l4_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
{
irq = pin + STM32L4_IRQ_EXTI0;
nshared = 1;
- shared_cbs = &stm32l4_exti_callbacks[pin];
+ shared_cbs = &g_gpio_handlers[pin];
switch (pin)
{
case 0:
@@ -280,27 +311,27 @@ xcpt_t stm32l4_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
{
irq = STM32L4_IRQ_EXTI95;
handler = stm32l4_exti95_isr;
- shared_cbs = &stm32l4_exti_callbacks[5];
+ shared_cbs = &g_gpio_handlers[5];
nshared = 5;
}
else
{
irq = STM32L4_IRQ_EXTI1510;
handler = stm32l4_exti1510_isr;
- shared_cbs = &stm32l4_exti_callbacks[10];
+ shared_cbs = &g_gpio_handlers[10];
nshared = 6;
}
/* Get the previous GPIO IRQ handler; Save the new IRQ handler. */
- oldhandler = stm32l4_exti_callbacks[pin];
- stm32l4_exti_callbacks[pin] = func;
+ g_gpio_handlers[pin].callback = func;
+ g_gpio_handlers[pin].arg = arg;
/* Install external interrupt handlers */
if (func)
{
- irq_attach(irq, handler);
+ irq_attach(irq, handler, NULL);
up_enable_irq(irq);
}
else
@@ -311,7 +342,7 @@ xcpt_t stm32l4_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
for (i = 0; i < nshared; i++)
{
- if (shared_cbs[i] != NULL)
+ if (shared_cbs[i].callback != NULL)
{
break;
}
@@ -354,5 +385,5 @@ xcpt_t stm32l4_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
/* Return the old IRQ handler */
- return oldhandler;
+ return OK;
}
diff --git a/arch/arm/src/stm32l4/stm32l4_exti_pwr.c b/arch/arm/src/stm32l4/stm32l4_exti_pwr.c
index f037936c649934f1002fa4d01cedd2707e61185b..ab19f6f3cb95384a0c35b84400d606c01fda2f8c 100644
--- a/arch/arm/src/stm32l4/stm32l4_exti_pwr.c
+++ b/arch/arm/src/stm32l4/stm32l4_exti_pwr.c
@@ -65,11 +65,8 @@
/* Interrupt handlers attached to the PVD EXTI */
-static xcpt_t stm32l4_exti_pvd_callback;
-
-/****************************************************************************
- * Public Data
- ****************************************************************************/
+static xcpt_t g_pvd_callback;
+static void *g_callback_arg;
/****************************************************************************
* Private Functions
@@ -83,7 +80,7 @@ static xcpt_t stm32l4_exti_pvd_callback;
*
****************************************************************************/
-static int stm32l4_exti_pvd_isr(int irq, void *context)
+static int stm32l4_exti_pvd_isr(int irq, void *context, FAR void *arg)
{
int ret = OK;
@@ -93,9 +90,9 @@ static int stm32l4_exti_pvd_isr(int irq, void *context)
/* And dispatch the interrupt to the handler */
- if (stm32l4_exti_pvd_callback)
+ if (g_pvd_callback != NULL)
{
- ret = stm32l4_exti_pvd_callback(irq, context);
+ ret = g_pvd_callback(irq, context, g_callback_arg);
}
return ret;
@@ -117,27 +114,24 @@ static int stm32l4_exti_pvd_isr(int irq, void *context)
* - func: when non-NULL, generate interrupt
*
* Returns:
- * The previous value of the interrupt handler function pointer. This
- * value may, for example, be used to restore the previous handler when
- * multiple handlers are used.
+ * Zero (OK) returned on success; a negated errno value is returned on
+ * failure.
*
****************************************************************************/
-xcpt_t stm32l4_exti_pvd(bool risingedge, bool fallingedge, bool event,
- xcpt_t func)
+int stm32l4_exti_pvd(bool risingedge, bool fallingedge, bool event,
+ xcpt_t func, void *arg)
{
- xcpt_t oldhandler;
-
/* Get the previous GPIO IRQ handler; Save the new IRQ handler. */
- oldhandler = stm32l4_exti_pvd_callback;
- stm32l4_exti_pvd_callback = func;
+ g_pvd_callback = func;
+ g_callback_arg = arg;
/* Install external interrupt handlers (if not already attached) */
if (func)
{
- irq_attach(STM32L4_IRQ_PVD, stm32l4_exti_pvd_isr);
+ irq_attach(STM32L4_IRQ_PVD, stm32l4_exti_pvd_isr, NULL);
up_enable_irq(STM32L4_IRQ_PVD);
}
else
@@ -163,7 +157,5 @@ xcpt_t stm32l4_exti_pvd(bool risingedge, bool fallingedge, bool event,
func ? 0 : EXTI1_PVD_LINE,
func ? EXTI1_PVD_LINE : 0);
- /* Return the old IRQ handler */
-
- return oldhandler;
+ return OK;
}
diff --git a/arch/arm/src/stm32l4/stm32l4_exti_pwr.h b/arch/arm/src/stm32l4/stm32l4_exti_pwr.h
index 5789e37076489ba45d4ea522e8e7316bf057eba7..27e584779b9fe981ce6fc93a9f2c7b86a764b3de 100644
--- a/arch/arm/src/stm32l4/stm32l4_exti_pwr.h
+++ b/arch/arm/src/stm32l4/stm32l4_exti_pwr.h
@@ -57,15 +57,15 @@
* - rising/falling edge: enables interrupt on rising/falling edge
* - event: generate event when set
* - func: when non-NULL, generate interrupt
+ * - arg: Argument passed to the interrupt callback
*
* Returns:
- * The previous value of the interrupt handler function pointer. This
- * value may, for example, be used to restore the previous handler when
- * multiple handlers are used.
+ * Zero (OK) returned on success; a negated errno value is returned on
+ * failure.
*
****************************************************************************/
-xcpt_t stm32l4_exti_pvd(bool risingedge, bool fallingedge, bool event,
- xcpt_t func);
+int stm32l4_exti_pvd(bool risingedge, bool fallingedge, bool event,
+ xcpt_t func, void *arg);
#endif /* STM32L4_EXTI_PWR_H_ */
diff --git a/arch/arm/src/stm32l4/stm32l4_freerun.c b/arch/arm/src/stm32l4/stm32l4_freerun.c
index 1a653b49657681129ef0b98463e3f255f2b45bad..a8a42588e0eb63c5d02177111524e4366d23d16a 100644
--- a/arch/arm/src/stm32l4/stm32l4_freerun.c
+++ b/arch/arm/src/stm32l4/stm32l4_freerun.c
@@ -53,12 +53,6 @@
#ifdef CONFIG_STM32L4_FREERUN
-/****************************************************************************
- * Private Functions
- ****************************************************************************/
-
-FAR static struct stm32l4_freerun_s *g_freerun;
-
/****************************************************************************
* Private Functions
****************************************************************************/
@@ -81,9 +75,9 @@ FAR static struct stm32l4_freerun_s *g_freerun;
*
****************************************************************************/
-static int stm32l4_freerun_handler(int irq, FAR void *context)
+static int stm32l4_freerun_handler(int irq, FAR void *context, void *arg)
{
- FAR struct stm32l4_freerun_s *freerun = g_freerun;
+ FAR struct stm32l4_freerun_s *freerun = (FAR struct stm32l4_freerun_s *) arg;
DEBUGASSERT(freerun != NULL && freerun->overflow < UINT32_MAX);
freerun->overflow++;
@@ -145,11 +139,9 @@ int stm32l4_freerun_initialize(FAR struct stm32l4_freerun_s *freerun, int chan,
freerun->running = false;
freerun->overflow = 0;
- g_freerun = freerun;
-
/* Set up to receive the callback when the counter overflow occurs */
- STM32L4_TIM_SETISR(freerun->tch, stm32l4_freerun_handler, 0);
+ STM32L4_TIM_SETISR(freerun->tch, stm32l4_freerun_handler, freerun, 0);
/* Set timer period */
@@ -283,14 +275,13 @@ int stm32l4_freerun_uninitialize(FAR struct stm32l4_freerun_s *freerun)
STM32L4_TIM_DISABLEINT(freerun->tch, 0);
STM32L4_TIM_SETMODE(freerun->tch, STM32L4_TIM_MODE_DISABLED);
- STM32L4_TIM_SETISR(freerun->tch, NULL, 0);
+ STM32L4_TIM_SETISR(freerun->tch, NULL, NULL, 0);
/* Free the timer */
stm32l4_tim_deinit(freerun->tch);
freerun->tch = NULL;
- g_freerun = NULL;
return OK;
}
diff --git a/arch/arm/src/stm32l4/stm32l4_gpio.h b/arch/arm/src/stm32l4/stm32l4_gpio.h
index 04dbc5679b1754560fc56b8005bc2a8e6a6fb137..5d4f74d58dc5870dbdcd161fa106ea1311b28641 100644
--- a/arch/arm/src/stm32l4/stm32l4_gpio.h
+++ b/arch/arm/src/stm32l4/stm32l4_gpio.h
@@ -326,21 +326,22 @@ bool stm32l4_gpioread(uint32_t pinset);
* Description:
* Sets/clears GPIO based event and interrupt triggers.
*
- * Parameters:
- * - pinset: gpio pin configuration
- * - rising/falling edge: enables
- * - event: generate event when set
- * - func: when non-NULL, generate interrupt
- *
- * Returns:
- * The previous value of the interrupt handler function pointer. This value may,
- * for example, be used to restore the previous handler when multiple handlers are
- * used.
+ * Input Parameters:
+ * pinset - GPIO pin configuration
+ * risingedge - Enables interrupt on rising edges
+ * fallingedge - Enables interrupt on falling edges
+ * event - Generate event when set
+ * func - When non-NULL, generate interrupt
+ * arg - Argument passed to the interrupt callback
+ *
+ * Returned Value:
+ * Zero (OK) is returned on success, otherwise a negated errno value is returned
+ * to indicate the nature of the failure.
*
************************************************************************************/
-xcpt_t stm32l4_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
- bool event, xcpt_t func);
+int stm32l4_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
+ bool event, xcpt_t func, void *arg);
/************************************************************************************
* Function: stm32l4_dumpgpio
diff --git a/arch/arm/src/stm32l4/stm32l4_i2c.c b/arch/arm/src/stm32l4/stm32l4_i2c.c
index eed199f86dd0dae91327d97eb60e9a191a3ee50b..48aa7a9b0e29dacd007568746811a16ea4f963c2 100644
--- a/arch/arm/src/stm32l4/stm32l4_i2c.c
+++ b/arch/arm/src/stm32l4/stm32l4_i2c.c
@@ -214,7 +214,7 @@ struct stm32l4_i2c_config_s
uint32_t scl_pin; /* GPIO configuration for SCL as SCL */
uint32_t sda_pin; /* GPIO configuration for SDA as SDA */
#ifndef CONFIG_I2C_POLLED
- int (*isr)(int, void *); /* Interrupt handler */
+ int (*isr)(int, void *, void *); /* Interrupt handler */
uint32_t ev_irq; /* Event IRQ */
uint32_t er_irq; /* Error IRQ */
#endif
@@ -292,13 +292,13 @@ static inline uint32_t stm32l4_i2c_getstatus(FAR struct stm32l4_i2c_priv_s *priv
static int stm32l4_i2c_isr(struct stm32l4_i2c_priv_s * priv);
#ifndef CONFIG_I2C_POLLED
#ifdef CONFIG_STM32L4_I2C1
-static int stm32l4_i2c1_isr(int irq, void *context);
+static int stm32l4_i2c1_isr(int irq, void *context, FAR void *arg);
#endif
#ifdef CONFIG_STM32L4_I2C2
-static int stm32l4_i2c2_isr(int irq, void *context);
+static int stm32l4_i2c2_isr(int irq, void *context, FAR void *arg);
#endif
#ifdef CONFIG_STM32L4_I2C3
-static int stm32l4_i2c3_isr(int irq, void *context);
+static int stm32l4_i2c3_isr(int irq, void *context, FAR void *arg);
#endif
#endif
static int stm32l4_i2c_init(FAR struct stm32l4_i2c_priv_s *priv);
@@ -1515,7 +1515,7 @@ static int stm32l4_i2c_isr(struct stm32l4_i2c_priv_s *priv)
#ifndef CONFIG_I2C_POLLED
#ifdef CONFIG_STM32L4_I2C1
-static int stm32l4_i2c1_isr(int irq, void *context)
+static int stm32l4_i2c1_isr(int irq, void *context, FAR void *arg)
{
return stm32l4_i2c_isr(&stm32l4_i2c1_priv);
}
@@ -1530,7 +1530,7 @@ static int stm32l4_i2c1_isr(int irq, void *context)
************************************************************************************/
#ifdef CONFIG_STM32L4_I2C2
-static int stm32l4_i2c2_isr(int irq, void *context)
+static int stm32l4_i2c2_isr(int irq, void *context, FAR void *arg)
{
return stm32l4_i2c_isr(&stm32l4_i2c2_priv);
}
@@ -1545,7 +1545,7 @@ static int stm32l4_i2c2_isr(int irq, void *context)
************************************************************************************/
#ifdef CONFIG_STM32L4_I2C3
-static int stm32l4_i2c3_isr(int irq, void *context)
+static int stm32l4_i2c3_isr(int irq, void *context, FAR void *arg)
{
return stm32l4_i2c_isr(&stm32l4_i2c3_priv);
}
@@ -1590,8 +1590,8 @@ static int stm32l4_i2c_init(FAR struct stm32l4_i2c_priv_s *priv)
/* Attach ISRs */
#ifndef CONFIG_I2C_POLLED
- irq_attach(priv->config->ev_irq, priv->config->isr);
- irq_attach(priv->config->er_irq, priv->config->isr);
+ irq_attach(priv->config->ev_irq, priv->config->isr, NULL);
+ irq_attach(priv->config->er_irq, priv->config->isr, NULL);
up_enable_irq(priv->config->ev_irq);
up_enable_irq(priv->config->er_irq);
#endif
diff --git a/arch/arm/src/stm32l4/stm32l4_idle.c b/arch/arm/src/stm32l4/stm32l4_idle.c
index 60dacd2928d9f6f9920015748ffbcd6b816e713a..015be72d0398b8790b39b12ec90caeca3c967fff 100644
--- a/arch/arm/src/stm32l4/stm32l4_idle.c
+++ b/arch/arm/src/stm32l4/stm32l4_idle.c
@@ -42,11 +42,10 @@
#include
#include
+#include
#include
#include
-#include
-
#include "chip.h"
#include "stm32l4_pm.h"
#include "up_internal.h"
@@ -97,7 +96,7 @@ static void up_idlepm(void)
if (newstate != oldstate)
{
- flags = irqsave();
+ flags = enter_critical_section();
/* Perform board-specific, state-dependent logic here */
@@ -141,7 +140,7 @@ static void up_idlepm(void)
break;
}
- irqrestore(flags);
+ leave_critical_section(flags);
}
}
#else
diff --git a/arch/arm/src/stm32l4/stm32l4_irq.c b/arch/arm/src/stm32l4/stm32l4_irq.c
index 720c05ecc698a4b78a5d03c35ae6eb2f1129ec56..7a0ed88bd371679bb9c8aefd63f082919b0d9d39 100644
--- a/arch/arm/src/stm32l4/stm32l4_irq.c
+++ b/arch/arm/src/stm32l4/stm32l4_irq.c
@@ -155,7 +155,7 @@ static void stm32l4_dumpnvic(const char *msg, int irq)
****************************************************************************/
#ifdef CONFIG_DEBUG_FEATURES
-static int stm32l4_nmi(int irq, FAR void *context)
+static int stm32l4_nmi(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! NMI received\n");
@@ -163,7 +163,7 @@ static int stm32l4_nmi(int irq, FAR void *context)
return 0;
}
-static int stm32l4_busfault(int irq, FAR void *context)
+static int stm32l4_busfault(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Bus fault received: %08x\n", getreg32(NVIC_CFAULTS));
@@ -171,7 +171,7 @@ static int stm32l4_busfault(int irq, FAR void *context)
return 0;
}
-static int stm32l4_usagefault(int irq, FAR void *context)
+static int stm32l4_usagefault(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Usage fault received: %08x\n", getreg32(NVIC_CFAULTS));
@@ -179,7 +179,7 @@ static int stm32l4_usagefault(int irq, FAR void *context)
return 0;
}
-static int stm32l4_pendsv(int irq, FAR void *context)
+static int stm32l4_pendsv(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! PendSV received\n");
@@ -187,7 +187,7 @@ static int stm32l4_pendsv(int irq, FAR void *context)
return 0;
}
-static int stm32l4_dbgmonitor(int irq, FAR void *context)
+static int stm32l4_dbgmonitor(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Debug Monitor received\n");
@@ -195,7 +195,7 @@ static int stm32l4_dbgmonitor(int irq, FAR void *context)
return 0;
}
-static int stm32l4_reserved(int irq, FAR void *context)
+static int stm32l4_reserved(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Reserved interrupt\n");
@@ -366,8 +366,8 @@ void up_irqinitialize(void)
* under certain conditions.
*/
- irq_attach(STM32L4_IRQ_SVCALL, up_svcall);
- irq_attach(STM32L4_IRQ_HARDFAULT, up_hardfault);
+ irq_attach(STM32L4_IRQ_SVCALL, up_svcall, NULL);
+ irq_attach(STM32L4_IRQ_HARDFAULT, up_hardfault, NULL);
/* Set the priority of the SVCall interrupt */
@@ -383,22 +383,22 @@ void up_irqinitialize(void)
*/
#ifdef CONFIG_ARM_MPU
- irq_attach(STM32L4_IRQ_MEMFAULT, up_memfault);
+ irq_attach(STM32L4_IRQ_MEMFAULT, up_memfault, NULL);
up_enable_irq(STM32L4_IRQ_MEMFAULT);
#endif
/* Attach all other processor exceptions (except reset and sys tick) */
#ifdef CONFIG_DEBUG_FEATURES
- irq_attach(STM32L4_IRQ_NMI, stm32l4_nmi);
+ irq_attach(STM32L4_IRQ_NMI, stm32l4_nmi, NULL);
#ifndef CONFIG_ARM_MPU
- irq_attach(STM32L4_IRQ_MEMFAULT, up_memfault);
+ irq_attach(STM32L4_IRQ_MEMFAULT, up_memfault, NULL);
#endif
- irq_attach(STM32L4_IRQ_BUSFAULT, stm32l4_busfault);
- irq_attach(STM32L4_IRQ_USAGEFAULT, stm32l4_usagefault);
- irq_attach(STM32L4_IRQ_PENDSV, stm32l4_pendsv);
- irq_attach(STM32L4_IRQ_DBGMONITOR, stm32l4_dbgmonitor);
- irq_attach(STM32L4_IRQ_RESERVED, stm32l4_reserved);
+ irq_attach(STM32L4_IRQ_BUSFAULT, stm32l4_busfault, NULL);
+ irq_attach(STM32L4_IRQ_USAGEFAULT, stm32l4_usagefault, NULL);
+ irq_attach(STM32L4_IRQ_PENDSV, stm32l4_pendsv, NULL);
+ irq_attach(STM32L4_IRQ_DBGMONITOR, stm32l4_dbgmonitor, NULL);
+ irq_attach(STM32L4_IRQ_RESERVED, stm32l4_reserved, NULL);
#endif
stm32l4_dumpnvic("initial", NR_IRQS);
diff --git a/arch/arm/src/stm32l4/stm32l4_lptim.c b/arch/arm/src/stm32l4/stm32l4_lptim.c
new file mode 100644
index 0000000000000000000000000000000000000000..4833472120c2d46d0a122eb4a321ab7300985216
--- /dev/null
+++ b/arch/arm/src/stm32l4/stm32l4_lptim.c
@@ -0,0 +1,548 @@
+/************************************************************************************
+ * arm/arm/src/stm3l42/stm32l4_lptim.c
+ *
+ * Copyright (C) 2011 Uros Platise. All rights reserved.
+ * Author: Uros Platise
+ *
+ * With modifications and updates by:
+ *
+ * Copyright (C) 2016 Motorola Mobility, LLC. All rights reserved.
+ * Copyright (C) 2011-2012, 2017 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ************************************************************************************/
+/************************************************************************************
+ * Copyright (c) 2015 Google, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its
+ * may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ ************************************************************************************/
+
+/************************************************************************************
+ * Included Files
+ ************************************************************************************/
+
+#include
+
+#include
+
+#include
+
+#include "stm32l4.h"
+#include "stm32l4_gpio.h"
+#include "stm32l4_lptim.h"
+
+#if defined(CONFIG_STM32L4_LPTIM1) || defined(CONFIG_STM32L4_LPTIM2)
+
+/************************************************************************************
+ * Private Types
+ ************************************************************************************/
+
+/* TIM Device Structure */
+
+struct stm32l4_lptim_priv_s
+{
+ const struct stm32l4_lptim_ops_s *ops;
+ stm32l4_lptim_mode_t mode;
+ uint32_t base; /* LPTIMn base address */
+ uint32_t freq; /* Clocking for the LPTIM module */
+};
+
+/************************************************************************************
+ * Private Function Prototypes
+ ************************************************************************************/
+
+static struct stm32l4_lptim_dev_s *stm32l4_lptim_getstruct(int timer);
+static inline void stm32l4_modifyreg32(FAR struct stm32l4_lptim_dev_s *dev,
+ uint8_t offset, uint32_t clearbits,
+ uint32_t setbits);
+static int stm32l4_lptim_enable(FAR struct stm32l4_lptim_dev_s *dev);
+static int stm32l4_lptim_disable(FAR struct stm32l4_lptim_dev_s *dev);
+static int stm32l4_lptim_reset(FAR struct stm32l4_lptim_dev_s *dev);
+static int stm32l4_lptim_get_gpioconfig(FAR struct stm32l4_lptim_dev_s *dev,
+ stm32l4_lptim_channel_t channel,
+ uint32_t *cfg);
+static int stm32l4_lptim_setmode(FAR struct stm32l4_lptim_dev_s *dev,
+ stm32l4_lptim_mode_t mode);
+static int stm32l4_lptim_setclock(FAR struct stm32l4_lptim_dev_s *dev,
+ uint32_t freq);
+static int stm32l4_lptim_setchannel(FAR struct stm32l4_lptim_dev_s *dev,
+ stm32l4_lptim_channel_t channel, int enable);
+
+/************************************************************************************
+ * Private Data
+ ************************************************************************************/
+
+static const struct stm32l4_lptim_ops_s stm32l4_lptim_ops =
+{
+ .setmode = &stm32l4_lptim_setmode,
+ .setclock = &stm32l4_lptim_setclock,
+ .setchannel = &stm32l4_lptim_setchannel,
+};
+
+#if CONFIG_STM32L4_LPTIM1
+static struct stm32l4_lptim_priv_s stm32l4_lptim1_priv =
+{
+ .ops = &stm32l4_lptim_ops,
+ .mode = STM32L4_LPTIM_MODE_UNUSED,
+ .base = STM32L4_LPTIM1_BASE,
+ .freq = STM32L4_LPTIM1_FREQUENCY, /* Must be efined in board.h */
+};
+#endif
+
+#if CONFIG_STM32L4_LPTIM2
+static struct stm32l4_lptim_priv_s stm32l4_lptim2_priv =
+{
+ .ops = &stm32l4_lptim_ops,
+ .mode = STM32L4_LPTIM_MODE_UNUSED,
+ .base = STM32L4_LPTIM2_BASE,
+ .freq = STM32L4_LPTIM2_FREQUENCY, /* Must be efined in board.h */
+};
+#endif
+
+/************************************************************************************
+ * Private Functions
+ ************************************************************************************/
+
+/************************************************************************************
+ * Name: stm32l4_lptim_getstruct
+ ************************************************************************************/
+
+static struct stm32l4_lptim_dev_s *stm32l4_lptim_getstruct(int timer)
+{
+ switch (timer)
+ {
+#if CONFIG_STM32L4_LPTIM1
+ case 1:
+ return (struct stm32l4_lptim_dev_s *)&stm32l4_lptim1_priv;
+#endif
+#if CONFIG_STM32L4_LPTIM2
+ case 2:
+ return (struct stm32l4_lptim_dev_s *)&stm32l4_lptim2_priv;
+#endif
+ default:
+ return NULL;
+ }
+}
+
+/************************************************************************************
+ * Name: stm32l4_modifyreg32
+ ************************************************************************************/
+
+static inline void stm32l4_modifyreg32(FAR struct stm32l4_lptim_dev_s *dev,
+ uint8_t offset, uint32_t clearbits,
+ uint32_t setbits)
+{
+ modifyreg32(((struct stm32l4_lptim_priv_s *)dev)->base + offset, clearbits, setbits);
+}
+
+/************************************************************************************
+ * Name: stm32l4_lptim_enable
+ ************************************************************************************/
+
+static int stm32l4_lptim_enable(FAR struct stm32l4_lptim_dev_s *dev)
+{
+ DEBUGASSERT(dev != NULL);
+
+ switch (((struct stm32l4_lptim_priv_s *)dev)->base)
+ {
+#if CONFIG_STM32L4_LPTIM1
+ case STM32L4_LPTIM1_BASE:
+ modifyreg32(STM32L4_RCC_APB1ENR1, 0, RCC_APB1ENR1_LPTIM1EN);
+ break;
+#endif
+#if CONFIG_STM32L4_LPTIM2
+ case STM32L4_LPTIM2_BASE:
+ modifyreg32(STM32L4_RCC_APB1ENR2, 0, RCC_APB1ENR2_LPTIM2EN);
+ break;
+#endif
+
+ default:
+ return ERROR;
+ }
+
+ return OK;
+}
+
+/************************************************************************************
+ * Name: stm32l4_lptim_disable
+ ************************************************************************************/
+
+static int stm32l4_lptim_disable(FAR struct stm32l4_lptim_dev_s *dev)
+{
+ DEBUGASSERT(dev != NULL);
+
+ switch (((struct stm32l4_lptim_priv_s *)dev)->base)
+ {
+#if CONFIG_STM32L4_LPTIM1
+ case STM32L4_LPTIM1_BASE:
+ modifyreg32(STM32L4_RCC_APB1ENR1, RCC_APB1ENR1_LPTIM1EN, 0);
+ break;
+#endif
+#if CONFIG_STM32L4_LPTIM2
+ case STM32L4_LPTIM2_BASE:
+ modifyreg32(STM32L4_RCC_APB1ENR2, RCC_APB1ENR2_LPTIM2EN, 0);
+ break;
+#endif
+
+ default:
+ return ERROR;
+ }
+
+ return OK;
+}
+
+/************************************************************************************
+ * Name: stm32l4_lptim_reset
+ ************************************************************************************/
+
+static int stm32l4_lptim_reset(FAR struct stm32l4_lptim_dev_s *dev)
+{
+ DEBUGASSERT(dev != NULL);
+
+ switch (((struct stm32l4_lptim_priv_s *)dev)->base)
+ {
+#if CONFIG_STM32L4_LPTIM1
+ case STM32L4_LPTIM1_BASE:
+ modifyreg32(STM32L4_RCC_APB1RSTR1, 0, RCC_APB1RSTR1_LPTIM1RST);
+ modifyreg32(STM32L4_RCC_APB1RSTR1, RCC_APB1RSTR1_LPTIM1RST, 0);
+ break;
+#endif
+#if CONFIG_STM32L4_LPTIM2
+ case STM32L4_LPTIM2_BASE:
+ modifyreg32(STM32L4_RCC_APB1RSTR2, 0, RCC_APB1RSTR2_LPTIM2RST);
+ modifyreg32(STM32L4_RCC_APB1RSTR2, RCC_APB1RSTR2_LPTIM2RST, 0);
+ break;
+#endif
+ }
+
+ return OK;
+}
+
+/************************************************************************************
+ * Name: stm32l4_lptim_get_gpioconfig
+ ************************************************************************************/
+
+static int stm32l4_lptim_get_gpioconfig(FAR struct stm32l4_lptim_dev_s *dev,
+ stm32l4_lptim_channel_t channel,
+ uint32_t *cfg)
+{
+ DEBUGASSERT(dev != NULL && cfg != NULL);
+
+ channel &= STM32L4_LPTIM_CH_MASK;
+
+ switch (((struct stm32l4_lptim_priv_s *)dev)->base)
+ {
+#if CONFIG_STM32L4_LPTIM1
+ case STM32L4_LPTIM1_BASE:
+ switch (channel)
+ {
+# if defined(GPIO_LPTIM1_OUT_1)
+ case 1:
+ *cfg = GPIO_LPTIM1_OUT_1;
+ break;
+# endif
+# if defined(GPIO_LPTIM1_OUT_2)
+ case 2:
+ *cfg = GPIO_LPTIM1_OUT_2;
+ break;
+# endif
+# if defined(GPIO_LPTIM1_OUT_3)
+ case 3:
+ *cfg = GPIO_LPTIM1_OUT_3;
+ break;
+# endif
+ default:
+ return ERROR;
+ }
+ break;
+#endif /* CONFIG_STM32L4_LPTIM1 */
+
+#if CONFIG_STM32L4_LPTIM2
+ case STM32L4_LPTIM2_BASE:
+ switch (channel)
+ {
+# if defined(GPIO_LPTIM2_OUT_1)
+ case 1:
+ *cfg = GPIO_LPTIM2_OUT_1;
+ break;
+# endif
+# if defined(GPIO_LPTIM2_OUT_2)
+ case 2:
+ *cfg = GPIO_LPTIM2_OUT_2;
+ break;
+# endif
+# if defined(GPIO_LPTIM2_OUT_3)
+ case 3:
+ *cfg = GPIO_LPTIM2_OUT_3;
+ break;
+# endif
+ default:
+ return ERROR;
+ }
+ break;
+#endif /* CONFIG_STM32L4_LPTIM2 */
+
+ default:
+ return ERROR;
+ }
+
+ return OK;
+}
+
+/************************************************************************************
+ * Name: stm32l4_lptim_setmode
+ ************************************************************************************/
+
+static int stm32l4_lptim_setmode(FAR struct stm32l4_lptim_dev_s *dev,
+ stm32l4_lptim_mode_t mode)
+{
+ const uint32_t addr = ((struct stm32l4_lptim_priv_s *)dev)->base +
+ STM32L4_LPTIM_CR_OFFSET;
+
+ DEBUGASSERT(dev != NULL);
+
+ /* Mode */
+
+ switch (mode & STM32L4_LPTIM_MODE_MASK)
+ {
+ case STM32L4_LPTIM_MODE_DISABLED:
+ modifyreg32(addr, LPTIM_CR_ENABLE, 0);
+ break;
+
+ case STM32L4_LPTIM_MODE_SINGLE:
+ modifyreg32(addr, 0, LPTIM_CR_ENABLE);
+ modifyreg32(addr, 0, LPTIM_CR_SNGSTRT);
+ break;
+
+ case STM32L4_LPTIM_MODE_CONTINUOUS:
+ modifyreg32(addr, 0, LPTIM_CR_ENABLE);
+ modifyreg32(addr, 0, LPTIM_CR_CNTSTRT);
+ break;
+
+ default:
+ return ERROR;
+ }
+
+ /* Save mode */
+
+ ((struct stm32l4_lptim_priv_s *)dev)->mode = mode;
+
+ return OK;
+}
+
+/************************************************************************************
+ * Name: stm32l4_lptim_setclock
+ ************************************************************************************/
+
+static int stm32l4_lptim_setclock(FAR struct stm32l4_lptim_dev_s *dev,
+ uint32_t freq)
+{
+ FAR struct stm32l4_lptim_priv_s *priv = (FAR struct stm32l4_lptim_priv_s *)dev;
+ uint32_t setbits;
+ uint32_t actual;
+
+ DEBUGASSERT(dev != NULL);
+
+ /* Disable Timer? */
+
+ if (freq == 0)
+ {
+ stm32l4_lptim_disable(dev);
+ return 0;
+ }
+
+ if (freq >= priv->freq >> 0)
+ {
+ /* More than clock source. This is as fast as we can go */
+
+ setbits = LPTIM_CFGR_PRESCd1;
+ actual = priv->freq >> 0;
+ }
+ else if (freq >= priv->freq >> 1)
+ {
+ setbits = LPTIM_CFGR_PRESCd2;
+ actual = priv->freq >> 1;
+ }
+ else if (freq >= priv->freq >> 2)
+ {
+ setbits = LPTIM_CFGR_PRESCd4;
+ actual = priv->freq >> 2;
+ }
+ else if (freq >= priv->freq >> 3)
+ {
+ setbits = LPTIM_CFGR_PRESCd8;
+ actual = priv->freq >> 3;
+ }
+ else if (freq >= priv->freq >> 4)
+ {
+ setbits = LPTIM_CFGR_PRESCd16;
+ actual = priv->freq >> 4;
+ }
+ else if (freq >= priv->freq >> 5)
+ {
+ setbits = LPTIM_CFGR_PRESCd32;
+ actual = priv->freq >> 5;
+ }
+ else if (freq >= priv->freq >> 6)
+ {
+ setbits = LPTIM_CFGR_PRESCd64;
+ actual = priv->freq >> 6;
+ }
+ else
+ {
+ /* This is as slow as we can go */
+
+ setbits = LPTIM_CFGR_PRESCd128;
+ actual = priv->freq >> 7;
+ }
+
+ stm32l4_modifyreg32(dev, STM32L4_LPTIM_CFGR_OFFSET, LPTIM_CFGR_PRESC_MASK,
+ setbits);
+ stm32l4_lptim_enable(dev);
+
+ return actual;
+}
+
+/************************************************************************************
+ * Name: stm32l4_lptim_setchannel
+ ************************************************************************************/
+
+static int stm32l4_lptim_setchannel(FAR struct stm32l4_lptim_dev_s *dev,
+ stm32l4_lptim_channel_t channel, int enable)
+{
+ int ret = OK;
+ uint32_t cfg = 0;
+
+ ASSERT(dev);
+
+ /* Configure GPIOs */
+
+ ret = stm32l4_lptim_get_gpioconfig(dev, channel, &cfg);
+ if (!ret)
+ {
+ if (enable)
+ {
+ stm32l4_configgpio(cfg);
+ }
+ else
+ {
+ stm32l4_unconfiggpio(cfg);
+ }
+ }
+
+ return ret;
+}
+
+/************************************************************************************
+ * Public Functions
+ ************************************************************************************/
+
+/************************************************************************************
+ * Name: stm32l4_lptim_init
+ ************************************************************************************/
+
+FAR struct stm32l4_lptim_dev_s *stm32l4_lptim_init(int timer)
+{
+ struct stm32l4_lptim_dev_s *dev = NULL;
+
+ /* Get structure and enable power */
+
+ dev = stm32l4_lptim_getstruct(timer);
+ if (!dev)
+ {
+ return NULL;
+ }
+
+ /* Is device already allocated */
+
+ if (((struct stm32l4_lptim_priv_s *)dev)->mode != STM32L4_LPTIM_MODE_UNUSED)
+ {
+ return NULL;
+ }
+
+ /* Enable power */
+
+ stm32l4_lptim_enable(dev);
+
+ /* Reset timer */
+
+ stm32l4_lptim_reset(dev);
+
+ /* Mark it as used */
+
+ ((struct stm32l4_lptim_priv_s *)dev)->mode = STM32L4_LPTIM_MODE_DISABLED;
+
+ return dev;
+}
+
+/************************************************************************************
+ * Name: stm32l4_lptim_deinit
+ ************************************************************************************/
+
+int stm32l4_lptim_deinit(FAR struct stm32l4_lptim_dev_s * dev)
+{
+ ASSERT(dev);
+
+ /* Disable power */
+
+ stm32l4_lptim_disable(dev);
+
+ /* Mark it as free */
+
+ ((struct stm32l4_lptim_priv_s *)dev)->mode = STM32L4_LPTIM_MODE_UNUSED;
+
+ return OK;
+}
+
+#endif /* CONFIG_STM32L4_LPTIM1 || CONFIG_STM32L4_LPTIM2 */
diff --git a/arch/arm/src/stm32l4/stm32l4_lptim.h b/arch/arm/src/stm32l4/stm32l4_lptim.h
new file mode 100644
index 0000000000000000000000000000000000000000..90e0cb0d3bb72662f2c6f43f951d60ad4d0e6ae3
--- /dev/null
+++ b/arch/arm/src/stm32l4/stm32l4_lptim.h
@@ -0,0 +1,171 @@
+/************************************************************************************
+ * arch/arm/src/stm32l4/stm32l4_lptim.h
+ *
+ * Copyright (C) 2011 Uros Platise. All rights reserved.
+ * Author: Uros Platise
+ *
+ * With modifications and updates by:
+ *
+ * Copyright (C) 2016 Motorola Mobility, LLC. All rights reserved.
+ * Copyright (C) 2011-2012, 2017 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ************************************************************************************/
+/************************************************************************************
+ * Copyright (c) 2015 Google, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its
+ * may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ ************************************************************************************/
+
+#ifndef __ARCH_ARM_SRC_STM32L4_STM32L4_LPTIM_H
+#define __ARCH_ARM_SRC_STM32L4_STM32L4_LPTIM_H
+
+/************************************************************************************
+ * Included Files
+ ************************************************************************************/
+
+#include
+
+#include "chip.h"
+#include "chip/stm32l4_lptim.h"
+
+/************************************************************************************
+ * Pre-processor Definitions
+ ************************************************************************************/
+/* Helpers **************************************************************************/
+
+#define STM32L4_LPTIM_SETMODE(d,mode) ((d)->ops->setmode(d,mode))
+#define STM32L4_LPTIM_SETCLOCK(d,freq) ((d)->ops->setclock(d,freq))
+#define STM32L4_LPTIM_SETCHANNEL(d,ch,en) ((d)->ops->setchannel(d,ch,en))
+
+/************************************************************************************
+ * Public Types
+ ************************************************************************************/
+
+#ifndef __ASSEMBLY__
+
+#undef EXTERN
+#if defined(__cplusplus)
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+/* LPTIM Device Structure */
+
+struct stm32l4_lptim_dev_s
+{
+ struct stm32l4_lptim_ops_s *ops;
+};
+
+/* LPTIM Modes of Operation */
+
+typedef enum
+{
+ STM32L4_LPTIM_MODE_UNUSED = -1,
+
+ /* MODES */
+
+ STM32L4_LPTIM_MODE_DISABLED = 0x0000,
+ STM32L4_LPTIM_MODE_SINGLE = 0x0001,
+ STM32L4_LPTIM_MODE_CONTINUOUS = 0x0002,
+ STM32L4_LPTIM_MODE_MASK = 0x003f,
+} stm32l4_lptim_mode_t;
+
+/* LPTIM Channel Modes */
+
+typedef enum
+{
+ STM32L4_LPTIM_CH_DISABLED = 0x0000,
+
+ /* CHANNELS */
+
+ STM32L4_LPTIM_CH_CHINVALID = 0x0000,
+ STM32L4_LPTIM_CH_CH1 = 0x0001,
+ STM32L4_LPTIM_CH_CH2 = 0x0002,
+ STM32L4_LPTIM_CH_CH3 = 0x0003,
+ STM32L4_LPTIM_CH_MASK = 0x000f,
+} stm32l4_lptim_channel_t;
+
+/* LPTIM Operations */
+
+struct stm32l4_lptim_ops_s
+{
+ int (*setmode)(FAR struct stm32l4_lptim_dev_s *dev, stm32l4_lptim_mode_t mode);
+ int (*setclock)(FAR struct stm32l4_lptim_dev_s *dev, uint32_t freq);
+ int (*setchannel)(FAR struct stm32l4_lptim_dev_s *dev,
+ stm32l4_lptim_channel_t channel, int enable);
+};
+
+/************************************************************************************
+ * Public Functions
+ ************************************************************************************/
+
+/* Get timer structure, power-up, reset, and mark it as used */
+
+FAR struct stm32l4_lptim_dev_s *stm32l4_lptim_init(int timer);
+
+/* Power-down timer, mark it as unused */
+
+int stm32l4_lptim_deinit(FAR struct stm32l4_lptim_dev_s *dev);
+
+#undef EXTERN
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* __ASSEMBLY__ */
+#endif /* __ARCH_ARM_SRC_STM32L4_STM32L4_LPTIM_H */
diff --git a/arch/arm/src/stm32l4/stm32l4_oneshot.c b/arch/arm/src/stm32l4/stm32l4_oneshot.c
index 7dbfcf126ca17ee8e8e9690823638081e8637296..5ae8e069adb4c84e0170f8bf50e7a00ac3df8716 100644
--- a/arch/arm/src/stm32l4/stm32l4_oneshot.c
+++ b/arch/arm/src/stm32l4/stm32l4_oneshot.c
@@ -59,29 +59,7 @@
* Private Function Prototypes
****************************************************************************/
-static int stm32l4_oneshot_handler(struct stm32l4_oneshot_s *oneshot);
-static int stm32l4_oneshot1_handler(int irq, void *context);
-#if CONFIG_STM32L4_ONESHOT_MAXTIMERS > 1
-static int stm32l4_oneshot2_handler(int irq, void *context);
-#endif
-#if CONFIG_STM32L4_ONESHOT_MAXTIMERS > 2
-static int stm32l4_oneshot3_handler(int irq, void *context);
-#endif
-#if CONFIG_STM32L4_ONESHOT_MAXTIMERS > 3
-static int stm32l4_oneshot4_handler(int irq, void *context);
-#endif
-#if CONFIG_STM32L4_ONESHOT_MAXTIMERS > 4
-static int stm32l4_oneshot5_handler(int irq, void *context);
-#endif
-#if CONFIG_STM32L4_ONESHOT_MAXTIMERS > 5
-static int stm32l4_oneshot6_handler(int irq, void *context);
-#endif
-#if CONFIG_STM32L4_ONESHOT_MAXTIMERS > 6
-static int stm32l4_oneshot7_handler(int irq, void *context);
-#endif
-#if CONFIG_STM32L4_ONESHOT_MAXTIMERS > 7
-static int stm32l4_oneshot8_handler(int irq, void *context);
-#endif
+static int stm32l4_oneshot_handler(int irq, void *context, void *arg);
/****************************************************************************
* Private Data
@@ -89,34 +67,6 @@ static int stm32l4_oneshot8_handler(int irq, void *context);
static struct stm32l4_oneshot_s *g_oneshot[CONFIG_STM32L4_ONESHOT_MAXTIMERS];
-#if CONFIG_STM32L4_ONESHOT_MAXTIMERS > 1
-static const xcpt_t g_callbacks[CONFIG_STM32L4_ONESHOT_MAXTIMERS] =
-{
- stm32l4_oneshot1_handler,
-#if CONFIG_STM32L4_ONESHOT_MAXTIMERS > 1
- stm32l4_oneshot2_handler,
-#endif
-#if CONFIG_STM32L4_ONESHOT_MAXTIMERS > 2
- stm32l4_oneshot3_handler,
-#endif
-#if CONFIG_STM32L4_ONESHOT_MAXTIMERS > 3
- stm32l4_oneshot4_handler,
-#endif
-#if CONFIG_STM32L4_ONESHOT_MAXTIMERS > 4
- stm32l4_oneshot5_handler,
-#endif
-#if CONFIG_STM32L4_ONESHOT_MAXTIMERS > 5
- stm32l4_oneshot6_handler,
-#endif
-#if CONFIG_STM32L4_ONESHOT_MAXTIMERS > 6
- stm32l4_oneshot7_handler,
-#endif
-#if CONFIG_STM32L4_ONESHOT_MAXTIMERS > 7
- stm32l4_oneshot8_handler,
-#endif
-};
-#endif
-
/****************************************************************************
* Private Functions
****************************************************************************/
@@ -137,8 +87,9 @@ static const xcpt_t g_callbacks[CONFIG_STM32L4_ONESHOT_MAXTIMERS] =
*
****************************************************************************/
-static int stm32l4_oneshot_handler(struct stm32l4_oneshot_s *oneshot)
+static int stm32l4_oneshot_handler(int irq, void *context, void *arg)
{
+ struct stm32l4_oneshot_s *oneshot = (struct stm32l4_oneshot_s *) arg;
oneshot_handler_t oneshot_handler;
FAR void *oneshot_arg;
@@ -149,7 +100,7 @@ static int stm32l4_oneshot_handler(struct stm32l4_oneshot_s *oneshot)
* Disable the TC now and disable any further interrupts.
*/
- STM32L4_TIM_SETISR(oneshot->tch, NULL, 0);
+ STM32L4_TIM_SETISR(oneshot->tch, NULL, NULL, 0);
STM32L4_TIM_DISABLEINT(oneshot->tch, 0);
STM32L4_TIM_SETMODE(oneshot->tch, STM32L4_TIM_MODE_DISABLED);
STM32L4_TIM_ACKINT(oneshot->tch, 0);
@@ -169,84 +120,6 @@ static int stm32l4_oneshot_handler(struct stm32l4_oneshot_s *oneshot)
return OK;
}
-/****************************************************************************
- * Name: stm32l4_oneshot[N]_handler
- *
- * Description:
- * Timer interrupt callbacks. When a oneshot timer interrupt expires,
- * one of these functions will be called. These functions will forward
- * the call to the nextlevel up.
- *
- * Input Parameters:
- * Standard interrupt handler arguments.
- *
- * Returned Value:
- * Always returns OK
- *
- ****************************************************************************/
-
-static int stm32l4_oneshot1_handler(int irq, void *context)
-{
- DEBUGASSERT(g_oneshot[0] != NULL);
- return stm32l4_oneshot_handler(g_oneshot[0]);
-}
-
-#if CONFIG_STM32L4_ONESHOT_MAXTIMERS > 1
-static int stm32l4_oneshot2_handler(int irq, void *context)
-{
- DEBUGASSERT(g_oneshot[1] != NULL);
- return stm32l4_oneshot_handler(g_oneshot[1]);
-}
-#endif
-
-#if CONFIG_STM32L4_ONESHOT_MAXTIMERS > 2
-static int stm32l4_oneshot3_handler(int irq, void *context)
-{
- DEBUGASSERT(g_oneshot[2] != NULL);
- return stm32l4_oneshot_handler(g_oneshot[2]);
-}
-#endif
-
-#if CONFIG_STM32L4_ONESHOT_MAXTIMERS > 3
-static int stm32l4_oneshot4_handler(int irq, void *context)
-{
- DEBUGASSERT(g_oneshot[3] != NULL);
- return stm32l4_oneshot_handler(g_oneshot[3]);
-}
-#endif
-
-#if CONFIG_STM32L4_ONESHOT_MAXTIMERS > 4
-static int stm32l4_oneshot5_handler(int irq, void *context)
-{
- DEBUGASSERT(g_oneshot[4] != NULL);
- return stm32l4_oneshot_handler(g_oneshot[4]);
-}
-#endif
-
-#if CONFIG_STM32L4_ONESHOT_MAXTIMERS > 5
-static int stm32l4_oneshot6_handler(int irq, void *context)
-{
- DEBUGASSERT(g_oneshot[6] != NULL);
- return stm32l4_oneshot_handler(g_oneshot[5]);
-}
-#endif
-
-#if CONFIG_STM32L4_ONESHOT_MAXTIMERS > 6
-static int stm32l4_oneshot7_handler(int irq, void *context)
-{
- DEBUGASSERT(g_oneshot[7] != NULL);
- return stm32l4_oneshot_handler(g_oneshot[6]);
-}
-#endif
-
-#if CONFIG_STM32L4_ONESHOT_MAXTIMERS > 7
-static int stm32l4_oneshot8_handler(int irq, void *context)
-{
- DEBUGASSERT(g_oneshot[0] != NULL);
- return stm32l4_oneshot_handler(g_oneshot[7]);
-}
-#endif
-
/****************************************************************************
* Name: stm32l4_allocate_handler
*
@@ -444,11 +317,7 @@ int stm32l4_oneshot_start(FAR struct stm32l4_oneshot_s *oneshot,
/* Set up to receive the callback when the interrupt occurs */
-#if CONFIG_STM32L4_ONESHOT_MAXTIMERS > 1
- STM32L4_TIM_SETISR(oneshot->tch, g_callbacks[oneshot->cbndx], 0);
-#else
- STM32L4_TIM_SETISR(oneshot->tch, stm32l4_oneshot1_handler, 0);
-#endif
+ STM32L4_TIM_SETISR(oneshot->tch, stm32l4_oneshot_handler, oneshot, 0);
/* Set timer period */
@@ -541,7 +410,7 @@ int stm32l4_oneshot_cancel(FAR struct stm32l4_oneshot_s *oneshot,
/* Now we can disable the interrupt and stop the timer. */
STM32L4_TIM_DISABLEINT(oneshot->tch, 0);
- STM32L4_TIM_SETISR(oneshot->tch, NULL, 0);
+ STM32L4_TIM_SETISR(oneshot->tch, NULL, NULL, 0);
STM32L4_TIM_SETMODE(oneshot->tch, STM32L4_TIM_MODE_DISABLED);
oneshot->running = false;
diff --git a/arch/arm/src/stm32l4/stm32l4_otgfs.h b/arch/arm/src/stm32l4/stm32l4_otgfs.h
index cdeb0ee590e015cfa43e25c5d1697b4fd58f16fa..0d64e0a72ca2ae858ce36e4a1413720d498641db 100644
--- a/arch/arm/src/stm32l4/stm32l4_otgfs.h
+++ b/arch/arm/src/stm32l4/stm32l4_otgfs.h
@@ -124,6 +124,5 @@ void stm32l4_usbsuspend(FAR struct usbdev_s *dev, bool resume);
#endif
#endif /* __ASSEMBLY__ */
-#endif /* CONFIG_STM32_OTGFS */
-#endif /* __ARCH_ARM_SRC_STM32_STM32_OTGFS_H */
-
+#endif /* CONFIG_STM32L4_OTGFS */
+#endif /* __ARCH_ARM_SRC_STM32L4_STM32L4_OTGFS_H */
diff --git a/arch/arm/src/stm32l4/stm32l4_otgfsdev.c b/arch/arm/src/stm32l4/stm32l4_otgfsdev.c
index 407534f4fbc1b1f90fbcc487f7183a0e4479419b..d57701ad6ae468bde64d83ded439bcf14b04324e 100644
--- a/arch/arm/src/stm32l4/stm32l4_otgfsdev.c
+++ b/arch/arm/src/stm32l4/stm32l4_otgfsdev.c
@@ -678,7 +678,7 @@ static inline void stm32l4_otginterrupt(FAR struct stm32l4_usbdev_s *priv);
/* First level interrupt processing */
-static int stm32l4_usbinterrupt(int irq, FAR void *context);
+static int stm32l4_usbinterrupt(int irq, FAR void *context, FAR void *arg);
/* Endpoint operations *********************************************************/
/* Global OUT NAK controls */
@@ -3621,7 +3621,7 @@ static inline void stm32l4_otginterrupt(FAR struct stm32l4_usbdev_s *priv)
*
****************************************************************************/
-static int stm32l4_usbinterrupt(int irq, FAR void *context)
+static int stm32l4_usbinterrupt(int irq, FAR void *context, FAR void *arg)
{
/* At present, there is only a single OTG FS device support. Hence it is
* pre-allocated as g_otgfsdev. However, in most code, the private data
@@ -5584,7 +5584,7 @@ void up_usbinitialize(void)
/* Attach the OTG FS interrupt handler */
- ret = irq_attach(STM32L4_IRQ_OTGFS, stm32l4_usbinterrupt);
+ ret = irq_attach(STM32L4_IRQ_OTGFS, stm32l4_usbinterrupt, NULL);
if (ret < 0)
{
uerr("irq_attach failed\n", ret);
diff --git a/arch/arm/src/stm32l4/stm32l4_otgfshost.c b/arch/arm/src/stm32l4/stm32l4_otgfshost.c
index d47295f429ba767ab6077bf6c4beb86995c9c2b4..f6a34f1f7a4196ef0eb4c001d6ea1378b6b122b5 100644
--- a/arch/arm/src/stm32l4/stm32l4_otgfshost.c
+++ b/arch/arm/src/stm32l4/stm32l4_otgfshost.c
@@ -405,7 +405,7 @@ static inline void stm32l4_gint_ipxfrisr(FAR struct stm32l4_usbhost_s *priv);
/* First level, global interrupt handler */
-static int stm32l4_gint_isr(int irq, FAR void *context);
+static int stm32l4_gint_isr(int irq, FAR void *context, FAR void *arg);
/* Interrupt controls */
@@ -3436,7 +3436,7 @@ static inline void stm32l4_gint_ipxfrisr(FAR struct stm32l4_usbhost_s *priv)
*
****************************************************************************/
-static int stm32l4_gint_isr(int irq, FAR void *context)
+static int stm32l4_gint_isr(int irq, FAR void *context, FAR void *arg)
{
/* At present, there is only support for a single OTG FS host. Hence it is
* pre-allocated as g_usbhost. However, in most code, the private data
@@ -5307,7 +5307,7 @@ FAR struct usbhost_connection_s *stm32l4_otgfshost_initialize(int controller)
/* Attach USB host controller interrupt handler */
- if (irq_attach(STM32L4_IRQ_OTGFS, stm32l4_gint_isr) != 0)
+ if (irq_attach(STM32L4_IRQ_OTGFS, stm32l4_gint_isr, NULL) != 0)
{
usbhost_trace1(OTGFS_TRACE1_IRQATTACH, 0);
return NULL;
diff --git a/arch/arm/src/stm32l4/stm32l4_pm.h b/arch/arm/src/stm32l4/stm32l4_pm.h
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0bf7a827f39468218b2f26c9a049b93374be6ac0 100644
--- a/arch/arm/src/stm32l4/stm32l4_pm.h
+++ b/arch/arm/src/stm32l4/stm32l4_pm.h
@@ -0,0 +1,171 @@
+/************************************************************************************
+ * arch/arm/src/stm32l4/stm32l4_pm.h
+ *
+ * Copyright (C) 2017 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ************************************************************************************/
+
+#ifndef __ARCH_ARM_SRC_STM32L4_STM32L4_PM_H
+#define __ARCH_ARM_SRC_STM32L4_STM32L4_PM_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include
+
+#include
+
+#include "chip.h"
+#include "up_internal.h"
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+#ifndef __ASSEMBLY__
+#ifdef __cplusplus
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+/****************************************************************************
+ * Name: stm32l4_pmstop
+ *
+ * Description:
+ * Enter STOP mode.
+ *
+ * Input Parameters:
+ * lpds - true: To further reduce power consumption in Stop mode, put the
+ * internal voltage regulator in low-power mode using the LPDS bit
+ * of the Power control register (PWR_CR).
+ *
+ * Returned Value:
+ * Zero means that the STOP was successfully entered and the system has
+ * been re-awakened. The internal voltage regulator is back to its
+ * original state. Otherwise, STOP mode did not occur and a negated
+ * errno value is returned to indicate the cause of the failure.
+ *
+ ****************************************************************************/
+
+int stm32l4_pmstop(bool lpds);
+
+/****************************************************************************
+ * Name: stm32l4_pmstop2
+ *
+ * Description:
+ * Enter STOP2 mode.
+ *
+ * Input Parameters:
+ * None
+ *
+ * Returned Value:
+ * Zero means that the STOP2 was successfully entered and the system has
+ * been re-awakened. Otherwise, STOP2 mode did not occur and a negated
+ * errno value is returned to indicate the cause of the failure.
+ *
+ ****************************************************************************/
+
+#if defined(CONFIG_STM32L4_STM32L4X6) || defined(CONFIG_STM32L4_STM32L4X3)
+int stm32l4_pmstop2(void);
+#endif
+
+/****************************************************************************
+ * Name: stm32l4_pmstandby
+ *
+ * Description:
+ * Enter STANDBY mode.
+ *
+ * Input Parameters:
+ * None
+ *
+ * Returned Value.
+ * On success, this function will not return (STANDBY mode can only be
+ * terminated with a reset event). Otherwise, STANDBY mode did not occur
+ * and a negated errno value is returned to indicate the cause of the
+ * failure.
+ *
+ ****************************************************************************/
+
+int stm32l4_pmstandby(void);
+
+/****************************************************************************
+ * Name: stm32l4_pmsleep
+ *
+ * Description:
+ * Enter SLEEP mode.
+ *
+ * Input Parameters:
+ * sleeponexit - true: SLEEPONEXIT bit is set when the WFI instruction is
+ * executed, the MCU enters Sleep mode as soon as it
+ * exits the lowest priority ISR.
+ * - false: SLEEPONEXIT bit is cleared, the MCU enters Sleep mode
+ * as soon as WFI or WFE instruction is executed.
+ * Returned Value:
+ * Zero means that the STOP was successfully entered and the system has
+ * been re-awakened. The internal volatage regulator is back to its
+ * original state. Otherwise, STOP mode did not occur and a negated
+ * errno value is returned to indicate the cause of the failure.
+ *
+ ****************************************************************************/
+
+void stm32l4_pmsleep(bool sleeponexit);
+
+/****************************************************************************
+ * Name: stm32l4_pmlpr
+ *
+ * Description:
+ * Enter Low-Power Run (LPR) mode.
+ *
+ * Input Parameters:
+ * None
+ *
+ * Returned Value:
+ * Zero means that LPR was successfully entered. Otherwise, LPR mode was not
+ * entered and a negated errno value is returned to indicate the cause of the
+ * failure.
+ *
+ ****************************************************************************/
+
+#if defined(CONFIG_STM32L4_STM32L4X6) || defined(CONFIG_STM32L4_STM32L4X3)
+int stm32l4_pmlpr(void);
+#endif
+
+#undef EXTERN
+#ifdef __cplusplus
+}
+#endif
+#endif /* __ASSEMBLY__ */
+
+#endif /* __ARCH_ARM_SRC_STM32L4_STM32L4_PM_H */
diff --git a/arch/arm/src/stm32l4/stm32l4_pminitialize.c b/arch/arm/src/stm32l4/stm32l4_pminitialize.c
new file mode 100644
index 0000000000000000000000000000000000000000..05988f21bf5723da1df9944580531b9fbf187c56
--- /dev/null
+++ b/arch/arm/src/stm32l4/stm32l4_pminitialize.c
@@ -0,0 +1,78 @@
+/****************************************************************************
+ * arch/arm/src/stm32l4/stm32l4_pminitialize.c
+ *
+ * Copyright (C) 2012, 2017 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include
+
+#include
+
+#include "up_internal.h"
+#include "stm32l4_pm.h"
+
+#ifdef CONFIG_PM
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: up_pminitialize
+ *
+ * Description:
+ * This function is called by MCU-specific logic at power-on reset in
+ * order to provide one-time initialization the power management subystem.
+ * This function must be called *very* early in the initialization sequence
+ * *before* any other device drivers are initialized (since they may
+ * attempt to register with the power management subsystem).
+ *
+ * Input parameters:
+ * None.
+ *
+ * Returned value:
+ * None.
+ *
+ ****************************************************************************/
+
+void up_pminitialize(void)
+{
+ /* Then initialize the NuttX power management subsystem proper */
+
+ pm_initialize();
+}
+
+#endif /* CONFIG_PM */
diff --git a/arch/arm/src/stm32l4/stm32l4_pmlpr.c b/arch/arm/src/stm32l4/stm32l4_pmlpr.c
new file mode 100644
index 0000000000000000000000000000000000000000..83a6782cf726d0dd00997eb60785035a4f3b0160
--- /dev/null
+++ b/arch/arm/src/stm32l4/stm32l4_pmlpr.c
@@ -0,0 +1,111 @@
+/****************************************************************************
+ * arch/arm/src/stm32l4/stm32l4_pmlpr.c
+ *
+ * Copyright (C) 2012, 2017 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2015 Motorola Mobility, LLC. All rights reserved.
+ * Author: Gregory Nutt
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include
+
+#include
+
+#include "up_arch.h"
+#include "nvic.h"
+#include "stm32l4_pwr.h"
+#include "stm32l4_pm.h"
+#include "stm32l4_rcc.h"
+
+#if defined(CONFIG_STM32L4_STM32L4X6) || defined(CONFIG_STM32L4_STM32L4X3)
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: stm32l4_pmlpr
+ *
+ * Description:
+ * Enter Low-Power Run (LPR) mode.
+ *
+ * Input Parameters:
+ * None
+ *
+ * Returned Value:
+ * Zero means that LPR was successfully entered. Otherwise, LPR mode was not
+ * entered and a negated errno value is returned to indicate the cause of the
+ * failure.
+ *
+ ****************************************************************************/
+
+int stm32l4_pmlpr(void)
+{
+ uint32_t regval;
+
+ /* Enable MSI clock */
+
+ regval = getreg32(STM32L4_RCC_CR);
+ regval |= RCC_CR_MSION;
+
+ /* Set MSI clock to 2 MHz */
+
+ regval &= ~RCC_CR_MSIRANGE_MASK;
+ regval |= RCC_CR_MSIRANGE_2M; /* 2 MHz */
+ regval |= RCC_CR_MSIRGSEL; /* Select new MSIRANGE */
+ putreg32(regval, STM32L4_RCC_CR);
+
+ /* Select MSI clock as system clock source */
+
+ regval = getreg32(STM32L4_RCC_CFGR);
+ regval &= ~RCC_CFGR_SW_MASK;
+ regval |= RCC_CFGR_SW_MSI;
+ putreg32(regval, STM32L4_RCC_CFGR);
+
+ /* Wait until the MSI source is used as the system clock source */
+
+ while ((getreg32(STM32L4_RCC_CFGR) & RCC_CFGR_SWS_MASK) != RCC_CFGR_SWS_MSI)
+ {
+ }
+
+ /* Enable Low-Power Run */
+
+ regval = getreg32(STM32L4_PWR_CR1);
+ regval |= PWR_CR1_LPR;
+ putreg32(regval, STM32L4_PWR_CR1);
+
+ return OK;
+}
+
+#endif /* CONFIG_STM32L4_STM32L4X6 || CONFIG_STM32L4_STM32L4X3 */
diff --git a/arch/arm/src/stm32l4/stm32l4_pmsleep.c b/arch/arm/src/stm32l4/stm32l4_pmsleep.c
new file mode 100644
index 0000000000000000000000000000000000000000..2a5ebcd58ae9d9920f82c5bc96e55c43f4a2d644
--- /dev/null
+++ b/arch/arm/src/stm32l4/stm32l4_pmsleep.c
@@ -0,0 +1,104 @@
+/****************************************************************************
+ * arch/arm/src/stm32l4/stm32l4_pmsleep.c
+ *
+ * Copyright (C) 2012, 2017 Gregory Nutt. All rights reserved.
+ * Authors: Gregory Nutt
+ * Diego Sanchez
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include
+
+#include
+
+#include "up_arch.h"
+#include "nvic.h"
+#include "stm32l4_pwr.h"
+#include "stm32l4_pm.h"
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: stm32l4_pmsleep
+ *
+ * Description:
+ * Enter SLEEP mode.
+ *
+ * Input Parameters:
+ * sleeponexit - true: SLEEPONEXIT bit is set when the WFI instruction is
+ * executed, the MCU enters Sleep mode as soon as it
+ * exits the lowest priority ISR.
+ * - false: SLEEPONEXIT bit is cleared, the MCU enters Sleep mode
+ * as soon as WFI or WFE instruction is executed.
+ * Returned Value:
+ * Zero means that the STOP was successfully entered and the system has
+ * been re-awakened. The internal volatage regulator is back to its
+ * original state. Otherwise, STOP mode did not occur and a negated
+ * errno value is returned to indicate the cause of the failure.
+ *
+ ****************************************************************************/
+
+void stm32l4_pmsleep(bool sleeponexit)
+{
+ uint32_t regval;
+
+ /* Clear SLEEPDEEP bit of Cortex System Control Register */
+
+ regval = getreg32(NVIC_SYSCON);
+ regval &= ~NVIC_SYSCON_SLEEPDEEP;
+ if (sleeponexit)
+ {
+ regval |= NVIC_SYSCON_SLEEPONEXIT;
+ }
+ else
+ {
+ regval &= ~NVIC_SYSCON_SLEEPONEXIT;
+ }
+
+ putreg32(regval, NVIC_SYSCON);
+
+ /* Sleep until the wakeup interrupt or event occurs */
+
+#ifdef CONFIG_PM_WFE
+ /* Mode: SLEEP + Entry with WFE */
+
+ asm("wfe");
+#else
+ /* Mode: SLEEP + Entry with WFI */
+
+ asm("wfi");
+#endif
+}
diff --git a/arch/arm/src/stm32l4/stm32l4_pmstandby.c b/arch/arm/src/stm32l4/stm32l4_pmstandby.c
new file mode 100644
index 0000000000000000000000000000000000000000..99101ee5280aba901e6c7f7b7a8ba23d0c6ea28c
--- /dev/null
+++ b/arch/arm/src/stm32l4/stm32l4_pmstandby.c
@@ -0,0 +1,114 @@
+/****************************************************************************
+ * arch/arm/src/stm32l4/stm32l4_pmstandby.c
+ *
+ * Copyright (C) 2012, 2017 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2015 Motorola Mobility, LLC. All rights reserved.
+ * Author: Gregory Nutt
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include
+
+#include
+
+#include "up_arch.h"
+#include "nvic.h"
+#include "stm32l4_pwr.h"
+#include "stm32l4_pm.h"
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: stm32l4_pmstandby
+ *
+ * Description:
+ * Enter STANDBY mode.
+ *
+ * Input Parameters:
+ * None
+ *
+ * Returned Value.
+ * On success, this function will not return (STANDBY mode can only be
+ * terminated with a reset event). Otherwise, STANDBY mode did not occur
+ * and a negated errno value is returned to indicate the cause of the
+ * failure.
+ *
+ ****************************************************************************/
+
+int stm32l4_pmstandby(void)
+{
+ uint32_t regval;
+
+#if defined(CONFIG_STM32L4_STM32L4X6) || defined(CONFIG_STM32L4_STM32L4X3)
+ /* Clear the Wake-Up Flags by setting the CWUFx bits in the power status
+ * clear register
+ */
+ regval = PWR_SCR_CWUF1 | PWR_SCR_CWUF2 | PWR_SCR_CWUF3 |
+ PWR_SCR_CWUF4 | PWR_SCR_CWUF5;
+ putreg32(regval, STM32L4_PWR_SCR);
+
+ /* Select Standby mode */
+ regval = getreg32(STM32L4_PWR_CR1);
+ regval &= ~PWR_CR1_LPMS_MASK;
+ regval |= PWR_CR1_LPMS_STANDBY;
+
+ putreg32(regval, STM32L4_PWR_CR1);
+#else
+ /* Clear the Wake-Up Flag by setting the CWUF bit in the power control
+ * register.
+ */
+
+ regval = getreg32(STM32L4_PWR_CR);
+ regval |= PWR_CR_CWUF;
+ putreg32(regval, STM32L4_PWR_CR);
+
+ /* Set the Power Down Deep Sleep (PDDS) bit in the power control register. */
+
+ regval |= PWR_CR_PDDS;
+ putreg32(regval, STM32L4_PWR_CR);
+#endif
+
+ /* Set SLEEPDEEP bit of Cortex System Control Register */
+
+ regval = getreg32(NVIC_SYSCON);
+ regval |= NVIC_SYSCON_SLEEPDEEP;
+ putreg32(regval, NVIC_SYSCON);
+
+ /* Sleep until the wakeup reset occurs */
+
+ asm("wfi");
+ return OK; /* Won't get here */
+}
diff --git a/arch/arm/src/stm32l4/stm32l4_pmstop.c b/arch/arm/src/stm32l4/stm32l4_pmstop.c
new file mode 100644
index 0000000000000000000000000000000000000000..9be563cf9ecfbd7b6dc0b49b014160698913b38f
--- /dev/null
+++ b/arch/arm/src/stm32l4/stm32l4_pmstop.c
@@ -0,0 +1,177 @@
+/****************************************************************************
+ * arch/arm/src/stm32l4/stm32l4_pmstop.c
+ *
+ * Copyright (C) 2012, 2017 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2015 Motorola Mobility, LLC. All rights reserved.
+ * Author: Gregory Nutt
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include
+
+#include
+
+#include "up_arch.h"
+#include "nvic.h"
+#include "stm32l4_pwr.h"
+#include "stm32l4_pm.h"
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+static int do_stop(void)
+{
+ uint32_t regval;
+
+ /* Set SLEEPDEEP bit of Cortex System Control Register */
+
+ regval = getreg32(NVIC_SYSCON);
+ regval |= NVIC_SYSCON_SLEEPDEEP;
+ putreg32(regval, NVIC_SYSCON);
+
+ /* Sleep until the wakeup interrupt or event occurs */
+
+#ifdef CONFIG_PM_WFE
+ /* Mode: SLEEP + Entry with WFE */
+
+ asm("wfe");
+#else
+ /* Mode: SLEEP + Entry with WFI */
+
+ asm("wfi");
+#endif
+
+ /* Clear SLEEPDEEP bit of Cortex System Control Register */
+
+ regval = getreg32(NVIC_SYSCON);
+ regval &= ~NVIC_SYSCON_SLEEPDEEP;
+ putreg32(regval, NVIC_SYSCON);
+
+ return OK;
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: stm32l4_pmstop
+ *
+ * Description:
+ * Enter STOP mode.
+ *
+ * Input Parameters:
+ * lpds - true: To further reduce power consumption in Stop mode, put the
+ * internal voltage regulator in low-power mode using the LPDS bit
+ * of the Power control register (PWR_CR).
+ *
+ * Returned Value:
+ * Zero means that the STOP was successfully entered and the system has
+ * been re-awakened. The internal volatage regulator is back to its
+ * original state. Otherwise, STOP mode did not occur and a negated
+ * errno value is returned to indicate the cause of the failure.
+ *
+ ****************************************************************************/
+
+int stm32l4_pmstop(bool lpds)
+{
+ uint32_t regval;
+
+#if defined(CONFIG_STM32L4_STM32L4X6) || defined(CONFIG_STM32L4_STM32L4X3)
+ /* Clear Low-Power Mode Selection (LPMS) bits in power control register 1. */
+ regval = getreg32(STM32L4_PWR_CR1);
+ regval &= ~PWR_CR1_LPMS_MASK;
+
+ /* Select Stop 1 mode with low-power regulator if so requested */
+ if (lpds)
+ {
+ regval |= PWR_CR1_LPMS_STOP1LPR;
+ }
+
+ putreg32(regval, STM32L4_PWR_CR1);
+#else
+ /* Clear the Power Down Deep Sleep (PDDS), Low Power Deep Sleep (LPDS), and
+ * Low Power regulator Low Voltage in Deep Sleep (LPLVDS) bits in the power
+ * control register.
+ */
+
+ regval = getreg32(STM32L4_PWR_CR);
+ regval &= ~(PWR_CR_LPDS | PWR_CR_PDDS | PWR_CR_LPLVDS);
+
+ /* Set the Low Power Deep Sleep (LPDS) and Low Power regulator Low Voltage
+ * in Deep Sleep (LPLVDS) bits if so requested */
+
+ if (lpds)
+ {
+ regval |= PWR_CR_LPDS | PWR_CR_LPLVDS;
+ }
+
+ putreg32(regval, STM32L4_PWR_CR);
+#endif
+
+ return do_stop();
+}
+
+/****************************************************************************
+ * Name: stm32l4_pmstop2
+ *
+ * Description:
+ * Enter STOP2 mode.
+ *
+ * Input Parameters:
+ * None
+ *
+ * Returned Value:
+ * Zero means that the STOP2 was successfully entered and the system has
+ * been re-awakened. Otherwise, STOP2 mode did not occur and a negated
+ * errno value is returned to indicate the cause of the failure.
+ *
+ ****************************************************************************/
+
+#if defined(CONFIG_STM32L4_STM32L4X6) || defined(CONFIG_STM32L4_STM32L4X3)
+int stm32l4_pmstop2(void)
+{
+ uint32_t regval;
+
+ /* Select Stop 2 mode in power control register 1. */
+
+ regval = getreg32(STM32L4_PWR_CR1);
+ regval &= ~PWR_CR1_LPMS_MASK;
+ regval |= PWR_CR1_LPMS_STOP2;
+ putreg32(regval, STM32L4_PWR_CR1);
+
+ return do_stop();
+}
+#endif
diff --git a/arch/arm/src/stm32l4/stm32l4_pwm.c b/arch/arm/src/stm32l4/stm32l4_pwm.c
index 80214fb9e5bbbc8b453d227c22382b0522cbdc12..fe46e8cc4ef5ef15817e4813ae815904dfdeae1d 100644
--- a/arch/arm/src/stm32l4/stm32l4_pwm.c
+++ b/arch/arm/src/stm32l4/stm32l4_pwm.c
@@ -178,10 +178,10 @@ static int stm32l4pwm_timer(FAR struct stm32l4_pwmtimer_s *priv,
#if defined(CONFIG_PWM_PULSECOUNT) && (defined(CONFIG_STM32L4_TIM1_PWM) || defined(CONFIG_STM32L4_TIM8_PWM))
static int stm32l4pwm_interrupt(struct stm32l4_pwmtimer_s *priv);
#if defined(CONFIG_STM32L4_TIM1_PWM)
-static int stm32l4pwm_tim1interrupt(int irq, void *context);
+static int stm32l4pwm_tim1interrupt(int irq, void *context, FAR void *arg);
#endif
#if defined(CONFIG_STM32L4_TIM8_PWM)
-static int stm32l4pwm_tim8interrupt(int irq, void *context);
+static int stm32l4pwm_tim8interrupt(int irq, void *context, FAR void *arg);
#endif
static uint8_t stm32l4pwm_pulsecount(uint32_t count);
#endif
@@ -1527,14 +1527,14 @@ static int stm32l4pwm_interrupt(struct stm32l4_pwmtimer_s *priv)
****************************************************************************/
#if defined(CONFIG_PWM_PULSECOUNT) && defined(CONFIG_STM32L4_TIM1_PWM)
-static int stm32l4pwm_tim1interrupt(int irq, void *context)
+static int stm32l4pwm_tim1interrupt(int irq, void *context, FAR void *arg)
{
return stm32l4pwm_interrupt(&g_pwm1dev);
}
#endif
#if defined(CONFIG_PWM_PULSECOUNT) && defined(CONFIG_STM32L4_TIM8_PWM)
-static int stm32l4pwm_tim8interrupt(int irq, void *context)
+static int stm32l4pwm_tim8interrupt(int irq, void *context, FAR void *arg)
{
return stm32l4pwm_interrupt(&g_pwm8dev);
}
@@ -2072,7 +2072,7 @@ FAR struct pwm_lowerhalf_s *stm32l4_pwminitialize(int timer)
/* Attach but disable the TIM1 update interrupt */
#ifdef CONFIG_PWM_PULSECOUNT
- irq_attach(lower->irq, stm32l4pwm_tim1interrupt);
+ irq_attach(lower->irq, stm32l4pwm_tim1interrupt, NULL);
up_disable_irq(lower->irq);
#endif
break;
@@ -2109,7 +2109,7 @@ FAR struct pwm_lowerhalf_s *stm32l4_pwminitialize(int timer)
/* Attach but disable the TIM8 update interrupt */
#ifdef CONFIG_PWM_PULSECOUNT
- irq_attach(lower->irq, stm32l4pwm_tim8interrupt);
+ irq_attach(lower->irq, stm32l4pwm_tim8interrupt, NULL);
up_disable_irq(lower->irq);
#endif
break;
diff --git a/arch/arm/src/stm32l4/stm32l4_qencoder.c b/arch/arm/src/stm32l4/stm32l4_qencoder.c
index 4e0ebb0283cfbb56e23431f83c16c2f26865504c..7c65b95d5a9d58fd07c30119c124de9b57828010 100644
--- a/arch/arm/src/stm32l4/stm32l4_qencoder.c
+++ b/arch/arm/src/stm32l4/stm32l4_qencoder.c
@@ -199,7 +199,6 @@ struct stm32l4_qeconfig_s
uint32_t ti2cfg; /* TI2 input pin configuration (20-bit encoding) */
uint32_t base; /* Register base address */
uint32_t psc; /* Encoder pulses prescaler */
- xcpt_t handler; /* Interrupt handler for this IRQ */
};
/* Overall, RAM-based state structure */
@@ -244,25 +243,7 @@ static FAR struct stm32l4_lowerhalf_s *stm32l4_tim2lower(int tim);
/* Interrupt handling */
#ifdef HAVE_16BIT_TIMERS
-static int stm32l4_interrupt(FAR struct stm32l4_lowerhalf_s *priv);
-#if defined(CONFIG_STM32L4_TIM1_QE) && TIM1_BITWIDTH == 16
-static int stm32l4_tim1interrupt(int irq, FAR void *context);
-#endif
-#if defined(CONFIG_STM32L4_TIM2_QE) && TIM2_BITWIDTH == 16
-static int stm32l4_tim2interrupt(int irq, FAR void *context);
-#endif
-#if defined(CONFIG_STM32L4_TIM3_QE) && TIM3_BITWIDTH == 16
-static int stm32l4_tim3interrupt(int irq, FAR void *context);
-#endif
-#if defined(CONFIG_STM32L4_TIM4_QE) && TIM4_BITWIDTH == 16
-static int stm32l4_tim4interrupt(int irq, FAR void *context);
-#endif
-#if defined(CONFIG_STM32L4_TIM5_QE) && TIM5_BITWIDTH == 16
-static int stm32l4_tim5interrupt(int irq, FAR void *context);
-#endif
-#if defined(CONFIG_STM32L4_TIM8_QE) && TIM8_BITWIDTH == 16
-static int stm32l4_tim8interrupt(int irq, FAR void *context);
-#endif
+static int stm32l4_interrupt(int irq, FAR void *context, FAR void *arg);
#endif
/* Lower-half Quadrature Encoder Driver Methods */
@@ -301,9 +282,6 @@ static const struct stm32l4_qeconfig_s g_tim1config =
.psc = CONFIG_STM32L4_TIM1_QEPSC,
.ti1cfg = GPIO_TIM1_CH1IN,
.ti2cfg = GPIO_TIM1_CH2IN,
-#if TIM1_BITWIDTH == 16
- .handler = stm32l4_tim1interrupt,
-#endif
};
static struct stm32l4_lowerhalf_s g_tim1lower =
@@ -327,9 +305,6 @@ static const struct stm32l4_qeconfig_s g_tim2config =
.psc = CONFIG_STM32L4_TIM2_QEPSC,
.ti1cfg = GPIO_TIM2_CH1IN,
.ti2cfg = GPIO_TIM2_CH2IN,
-#if TIM2_BITWIDTH == 16
- .handler = stm32l4_tim2interrupt,
-#endif
};
static struct stm32l4_lowerhalf_s g_tim2lower =
@@ -353,9 +328,6 @@ static const struct stm32l4_qeconfig_s g_tim3config =
.psc = CONFIG_STM32L4_TIM3_QEPSC,
.ti1cfg = GPIO_TIM3_CH1IN,
.ti2cfg = GPIO_TIM3_CH2IN,
-#if TIM3_BITWIDTH == 16
- .handler = stm32l4_tim3interrupt,
-#endif
};
static struct stm32l4_lowerhalf_s g_tim3lower =
@@ -379,9 +351,6 @@ static const struct stm32l4_qeconfig_s g_tim4config =
.psc = CONFIG_STM32L4_TIM4_QEPSC,
.ti1cfg = GPIO_TIM4_CH1IN,
.ti2cfg = GPIO_TIM4_CH2IN,
-#if TIM4_BITWIDTH == 16
- .handler = stm32l4_tim4interrupt,
-#endif
};
static struct stm32l4_lowerhalf_s g_tim4lower =
@@ -405,9 +374,6 @@ static const struct stm32l4_qeconfig_s g_tim5config =
.psc = CONFIG_STM32L4_TIM5_QEPSC,
.ti1cfg = GPIO_TIM5_CH1IN,
.ti2cfg = GPIO_TIM5_CH2IN,
-#if TIM5_BITWIDTH == 16
- .handler = stm32l4_tim5interrupt,
-#endif
};
static struct stm32l4_lowerhalf_s g_tim5lower =
@@ -431,9 +397,6 @@ static const struct stm32l4_qeconfig_s g_tim8config =
.psc = CONFIG_STM32L4_TIM8_QEPSC,
.ti1cfg = GPIO_TIM8_CH1IN,
.ti2cfg = GPIO_TIM8_CH2IN,
-#if TIM8_BITWIDTH == 16
- .handler = stm32l4_tim8interrupt,
-#endif
};
static struct stm32l4_lowerhalf_s g_tim8lower =
@@ -645,10 +608,13 @@ static FAR struct stm32l4_lowerhalf_s *stm32l4_tim2lower(int tim)
************************************************************************************/
#ifdef HAVE_16BIT_TIMERS
-static int stm32l4_interrupt(FAR struct stm32l4_lowerhalf_s *priv)
+static int stm32l4_interrupt(int irq, FAR void *context, FAR void *arg)
{
+ FAR struct stm32l4_lowerhalf_s *priv = (FAR struct stm32l4_lowerhalf_s *)arg;
uint16_t regval;
+ DEBUGASSERT(priv != NULL);
+
/* Verify that this is an update interrupt. Nothing else is expected. */
regval = stm32l4_getreg16(priv, STM32L4_GTIM_SR_OFFSET);
@@ -676,56 +642,6 @@ static int stm32l4_interrupt(FAR struct stm32l4_lowerhalf_s *priv)
}
#endif
-/************************************************************************************
- * Name: stm32l4_timNinterrupt
- *
- * Description:
- * TIMN interrupt handler
- *
- ************************************************************************************/
-
-#if defined(CONFIG_STM32L4_TIM1_QE) && TIM1_BITWIDTH == 16
-static int stm32l4_tim1interrupt(int irq, FAR void *context)
-{
- return stm32l4_interrupt(&g_tim1lower);
-}
-#endif
-
-#if defined(CONFIG_STM32L4_TIM2_QE) && TIM2_BITWIDTH == 16
-static int stm32l4_tim2interrupt(int irq, FAR void *context)
-{
- return stm32l4_interrupt(&g_tim2lower);
-}
-#endif
-
-#if defined(CONFIG_STM32L4_TIM3_QE) && TIM3_BITWIDTH == 16
-static int stm32l4_tim3interrupt(int irq, FAR void *context)
-{
- return stm32l4_interrupt(&g_tim3lower);
-}
-#endif
-
-#if defined(CONFIG_STM32L4_TIM4_QE) && TIM4_BITWIDTH == 16
-static int stm32l4_tim4interrupt(int irq, FAR void *context)
-{
- return stm32l4_interrupt(&g_tim4lower);
-}
-#endif
-
-#if defined(CONFIG_STM32L4_TIM5_QE) && TIM5_BITWIDTH == 16
-static int stm32l4_tim5interrupt(int irq, FAR void *context)
-{
- return stm32l4_interrupt(&g_tim5lower);
-}
-#endif
-
-#if defined(CONFIG_STM32L4_TIM8_QE) && TIM8_BITWIDTH == 16
-static int stm32l4_tim8interrupt(int irq, FAR void *context)
-{
- return stm32l4_interrupt(&g_tim8lower);
-}
-#endif
-
/************************************************************************************
* Name: stm32l4_setup
*
@@ -912,7 +828,7 @@ static int stm32l4_setup(FAR struct qe_lowerhalf_s *lower)
{
/* Attach the interrupt handler */
- ret = irq_attach(priv->config->irq, priv->config->handler);
+ ret = irq_attach(priv->config->irq, stm32l4_interrupt, priv);
if (ret < 0)
{
stm32l4_shutdown(lower);
diff --git a/arch/arm/src/stm32l4/stm32l4_qspi.c b/arch/arm/src/stm32l4/stm32l4_qspi.c
index 95d2da540b47dda10c1538c4df8684fe81574a9c..0f55e764a0d2b289725a77461ace7e8bc24aa785 100644
--- a/arch/arm/src/stm32l4/stm32l4_qspi.c
+++ b/arch/arm/src/stm32l4/stm32l4_qspi.c
@@ -281,7 +281,7 @@ static void qspi_dumpgpioconfig(const char *msg);
/* Interrupts */
#ifdef STM32L4_QSPI_INTERRUPTS
-static int qspi0_interrupt(int irq, void *context);
+static int qspi0_interrupt(int irq, void *context, FAR void *arg);
#endif
@@ -1067,7 +1067,7 @@ static void qspi_ccrconfig(struct stm32l4_qspidev_s *priv,
*
****************************************************************************/
-static int qspi0_interrupt(int irq, void *context)
+static int qspi0_interrupt(int irq, void *context, FAR void *arg)
{
uint32_t status;
uint32_t cr;
@@ -2522,7 +2522,7 @@ struct qspi_dev_s *stm32l4_qspi_initialize(int intf)
#ifdef STM32L4_QSPI_INTERRUPTS
/* Attach the interrupt handler */
- ret = irq_attach(priv->irq, priv->handler);
+ ret = irq_attach(priv->irq, priv->handler, NULL);
if (ret < 0)
{
spierr("ERROR: Failed to attach irq %d\n", priv->irq);
diff --git a/arch/arm/src/stm32l4/stm32l4_rcc.c b/arch/arm/src/stm32l4/stm32l4_rcc.c
index 599ed7c4cc8b67bbe98718aa53c85ab17ed77b4f..73abae16c5b2dbee1712f979c3fc7b6496391827 100644
--- a/arch/arm/src/stm32l4/stm32l4_rcc.c
+++ b/arch/arm/src/stm32l4/stm32l4_rcc.c
@@ -105,7 +105,7 @@
*
****************************************************************************/
-#if defined(CONFIG_STM32_PWR) && defined(CONFIG_RTC)
+#if defined(CONFIG_STM32L4_PWR) && defined(CONFIG_RTC)
static inline void rcc_resetbkp(void)
{
bool init_stat;
diff --git a/arch/arm/src/stm32l4/stm32l4_rng.c b/arch/arm/src/stm32l4/stm32l4_rng.c
index abd2851037437b1b3b6770c03216df77c8eff0c9..dd0f782f2d053263f02daa6d787987577d6d5529 100644
--- a/arch/arm/src/stm32l4/stm32l4_rng.c
+++ b/arch/arm/src/stm32l4/stm32l4_rng.c
@@ -63,7 +63,7 @@
****************************************************************************/
static int stm32l4_rng_initialize(void);
-static int stm32l4_rnginterrupt(int irq, void *context);
+static int stm32l4_rnginterrupt(int irq, void *context, FAR void *arg);
static void stm32l4_rngenable(void);
static void stm32l4_rngdisable(void);
static ssize_t stm32l4_rngread(struct file *filep, char *buffer, size_t);
@@ -117,7 +117,7 @@ static int stm32l4_rng_initialize(void)
sem_init(&g_rngdev.rd_devsem, 0, 1);
- if (irq_attach(STM32L4_IRQ_RNG, stm32l4_rnginterrupt))
+ if (irq_attach(STM32L4_IRQ_RNG, stm32l4_rnginterrupt, NULL))
{
/* We could not attach the ISR to the interrupt */
@@ -157,7 +157,7 @@ static void stm32l4_rngdisable()
putreg32(regval, STM32L4_RNG_CR);
}
-static int stm32l4_rnginterrupt(int irq, void *context)
+static int stm32l4_rnginterrupt(int irq, void *context, FAR void *arg)
{
uint32_t rngsr;
uint32_t data;
diff --git a/arch/arm/src/stm32l4/stm32l4_rtc.h b/arch/arm/src/stm32l4/stm32l4_rtc.h
index 222f5bc7c0cf9f79469fda8f0634eab7bf4246fc..404f8325ad5b5b99ac5d79bfe3866b09b956f70e 100644
--- a/arch/arm/src/stm32l4/stm32l4_rtc.h
+++ b/arch/arm/src/stm32l4/stm32l4_rtc.h
@@ -54,8 +54,8 @@
* Pre-processor Definitions
****************************************************************************/
-#define STM32_RTC_PRESCALER_SECOND 32767 /* Default prescaler to get a second base */
-#define STM32_RTC_PRESCALER_MIN 1 /* Maximum speed of 16384 Hz */
+#define STM32L4_RTC_PRESCALER_SECOND 32767 /* Default prescaler to get a second base */
+#define STM32L4_RTC_PRESCALER_MIN 1 /* Maximum speed of 16384 Hz */
/****************************************************************************
* Public Types
@@ -146,7 +146,7 @@ bool rtc_is_inits(void);
*
****************************************************************************/
-#ifdef CONFIG_STM32_HAVE_RTC_SUBSECONDS
+#ifdef CONFIG_STM32L4_HAVE_RTC_SUBSECONDS
int stm32l4_rtc_getdatetime_with_subseconds(FAR struct tm *tp, FAR long *nsec);
#endif
diff --git a/arch/arm/src/stm32l4/stm32l4_rtcc.c b/arch/arm/src/stm32l4/stm32l4_rtcc.c
index 1ee4306080fe2c8ac8a5bea9f83e975f19c09de3..a0221240f7868cb419d6b8edcd9bb15869581b54 100644
--- a/arch/arm/src/stm32l4/stm32l4_rtcc.c
+++ b/arch/arm/src/stm32l4/stm32l4_rtcc.c
@@ -512,7 +512,7 @@ static void rtc_resume(void)
************************************************************************************/
#ifdef CONFIG_RTC_ALARM
-static int stm32l4_rtc_alarm_handler(int irq, FAR void *context)
+static int stm32l4_rtc_alarm_handler(int irq, FAR void *context, FAR void *rtc_handler_arg)
{
FAR struct alm_cbinfo_s *cbinfo;
alm_callback_t cb;
@@ -801,7 +801,7 @@ static inline void rtc_enable_alarm(void)
* 3. Configure the RTC to generate RTC alarms (Alarm A or Alarm B).
*/
- stm32l4_exti_alarm(true, false, true, stm32l4_rtc_alarm_handler);
+ (void)stm32l4_exti_alarm(true, false, true, stm32l4_rtc_alarm_handler, NULL);
g_alarm_enabled = true;
}
}
diff --git a/arch/arm/src/stm32l4/stm32l4_sai.c b/arch/arm/src/stm32l4/stm32l4_sai.c
new file mode 100644
index 0000000000000000000000000000000000000000..f57f2ee593c8078ef1a51caca73462cdc3c88a70
--- /dev/null
+++ b/arch/arm/src/stm32l4/stm32l4_sai.c
@@ -0,0 +1,1450 @@
+/****************************************************************************
+ * arch/arm/src/stm32l4/stm32l4_sai.c
+ *
+ * Copyright (C) 2013-2014, 2017 Gregory Nutt. All rights reserved.
+ * Authors: Gregory Nutt
+ * Copyright (c) 2016 Motorola Mobility, LLC. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+#include "stm32l4_dma.h"
+#include "stm32l4_gpio.h"
+#include "stm32l4_sai.h"
+
+#ifdef CONFIG_STM32L4_SAI
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#ifndef CONFIG_SCHED_WORKQUEUE
+# error Work queue support is required (CONFIG_SCHED_WORKQUEUE)
+#endif
+
+#ifndef CONFIG_AUDIO
+# error CONFIG_AUDIO required by this driver
+#endif
+
+#ifndef CONFIG_I2S
+# error CONFIG_I2S required by this driver
+#endif
+
+#ifdef CONFIG_STM32L4_SAI_POLLING
+# error "Polling SAI not yet supported"
+#endif
+
+#ifdef CONFIG_STM32L4_SAI_INTERRUPTS
+# error "Interrupt driven SAI not yet supported"
+#endif
+
+#ifndef CONFIG_STM32L4_SAI_DEFAULT_SAMPLERATE
+# define CONFIG_STM32L4_SAI_DEFAULT_SAMPLERATE (48000)
+#endif
+
+#ifndef CONFIG_STM32L4_SAI_DEFAULT_DATALEN
+# define CONFIG_STM32L4_SAI_DEFAULT_DATALEN (16)
+#endif
+
+#ifndef CONFIG_STM32L4_SAI_MAXINFLIGHT
+# define CONFIG_STM32L4_SAI_MAXINFLIGHT (16)
+#endif
+
+#ifdef CONFIG_STM32L4_SAI_DMA
+/* SAI DMA priority */
+
+# if defined(CONFIG_STM32L4_SAI_DMAPRIO)
+# define SAI_DMA_PRIO CONFIG_STM32L4_SAI_DMAPRIO
+# else
+# define SAI_DMA_PRIO DMA_CCR_PRIMED
+# endif
+
+# if (SAI_DMA_PRIO & ~DMA_CCR_PL_MASK) != 0
+# error "Illegal value for CONFIG_STM32L4_SAI_DMAPRIO"
+# endif
+
+/* DMA channel configuration */
+
+# define SAI_RXDMA8_CONFIG (SAI_DMA_PRIO|DMA_CCR_MSIZE_8BITS |DMA_CCR_PSIZE_8BITS |DMA_CCR_MINC )
+# define SAI_RXDMA16_CONFIG (SAI_DMA_PRIO|DMA_CCR_MSIZE_16BITS|DMA_CCR_PSIZE_16BITS|DMA_CCR_MINC )
+# define SAI_RXDMA32_CONFIG (SAI_DMA_PRIO|DMA_CCR_MSIZE_32BITS|DMA_CCR_PSIZE_32BITS|DMA_CCR_MINC )
+# define SAI_TXDMA8_CONFIG (SAI_DMA_PRIO|DMA_CCR_MSIZE_8BITS |DMA_CCR_PSIZE_8BITS |DMA_CCR_MINC|DMA_CCR_DIR)
+# define SAI_TXDMA16_CONFIG (SAI_DMA_PRIO|DMA_CCR_MSIZE_16BITS|DMA_CCR_PSIZE_16BITS|DMA_CCR_MINC|DMA_CCR_DIR)
+# define SAI_TXDMA32_CONFIG (SAI_DMA_PRIO|DMA_CCR_MSIZE_32BITS|DMA_CCR_PSIZE_32BITS|DMA_CCR_MINC|DMA_CCR_DIR)
+#endif
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+/* I2S buffer container */
+
+struct sai_buffer_s
+{
+ struct sai_buffer_s *flink; /* Supports a singly linked list */
+ i2s_callback_t callback; /* Function to call when the transfer completes */
+ uint32_t timeout; /* The timeout value to use with transfers */
+ void *arg; /* The argument to be returned with the callback */
+ struct ap_buffer_s *apb; /* The audio buffer */
+ int result; /* The result of the transfer */
+};
+
+/* The state of the one SAI peripheral */
+
+struct stm32l4_sai_s
+{
+ struct i2s_dev_s dev; /* Externally visible I2S interface */
+ uintptr_t base; /* SAI block register base address */
+ sem_t exclsem; /* Assures mutually exclusive acess to SAI */
+ uint32_t frequency; /* SAI clock frequency */
+ uint32_t syncen; /* Synchronization setting */
+#ifdef CONFIG_STM32L4_SAI_DMA
+ uint16_t dma_ch; /* DMA channel number */
+ DMA_HANDLE dma; /* DMA channel handle */
+ uint32_t dma_ccr; /* DMA control register */
+#endif
+ uint8_t datalen; /* Data width */
+ uint32_t samplerate; /* Data sample rate */
+ uint8_t rxenab:1; /* True: RX transfers enabled */
+ uint8_t txenab:1; /* True: TX transfers enabled */
+ WDOG_ID dog; /* Watchdog that handles timeouts */
+ sq_queue_t pend; /* A queue of pending transfers */
+ sq_queue_t act; /* A queue of active transfers */
+ sq_queue_t done; /* A queue of completed transfers */
+ struct work_s work; /* Supports worker thread operations */
+
+ /* Pre-allocated pool of buffer containers */
+
+ sem_t bufsem; /* Buffer wait semaphore */
+ struct sai_buffer_s *freelist; /* A list a free buffer containers */
+ struct sai_buffer_s containers[CONFIG_STM32L4_SAI_MAXINFLIGHT];
+};
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+#ifdef CONFIG_DEBUG_I2S_INFO
+static void sai_dump_regs(struct stm32l4_sai_s *priv, const char *msg);
+#else
+# define sai_dump_regs(s,m)
+#endif
+
+/* Semaphore helpers */
+
+static void sai_exclsem_take(struct stm32l4_sai_s *priv);
+#define sai_exclsem_give(priv) sem_post(&priv->exclsem)
+
+static void sai_bufsem_take(struct stm32l4_sai_s *priv);
+#define sai_bufsem_give(priv) sem_post(&priv->bufsem)
+
+/* Buffer container helpers */
+
+static struct sai_buffer_s *
+ sai_buf_allocate(struct stm32l4_sai_s *priv);
+static void sai_buf_free(struct stm32l4_sai_s *priv,
+ struct sai_buffer_s *bfcontainer);
+static void sai_buf_initialize(struct stm32l4_sai_s *priv);
+
+/* DMA support */
+
+#ifdef CONFIG_STM32L4_SAI_DMA
+static void sai_schedule(struct stm32l4_sai_s *priv, int result);
+static void sai_dma_callback(DMA_HANDLE handle, uint8_t isr, void *arg);
+#endif
+
+/* I2S methods */
+
+static uint32_t sai_samplerate(struct i2s_dev_s *dev, uint32_t rate);
+static uint32_t sai_datawidth(struct i2s_dev_s *dev, int bits);
+static int sai_receive(struct i2s_dev_s *dev, struct ap_buffer_s *apb,
+ i2s_callback_t callback, void *arg, uint32_t timeout);
+static int sai_send(struct i2s_dev_s *dev, struct ap_buffer_s *apb,
+ i2s_callback_t callback, void *arg,
+ uint32_t timeout);
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/* I2S device operations */
+
+static const struct i2s_ops_s g_i2sops =
+{
+ /* Receiver methods */
+
+ .i2s_rxsamplerate = sai_samplerate,
+ .i2s_rxdatawidth = sai_datawidth,
+ .i2s_receive = sai_receive,
+
+ /* Transmitter methods */
+
+ .i2s_txsamplerate = sai_samplerate,
+ .i2s_txdatawidth = sai_datawidth,
+ .i2s_send = sai_send,
+};
+
+/* SAI1 state */
+
+#ifdef CONFIG_STM32L4_SAI1_A
+static struct stm32l4_sai_s g_sai1a_priv =
+{
+ .dev.ops = &g_i2sops,
+ .base = STM32L4_SAI1_A_BASE,
+ .frequency = STM32L4_SAI1_FREQUENCY,
+#ifdef CONFIG_STM32L4_SAI1_A_SYNC_WITH_B
+ .syncen = SAI_CR1_SYNCEN_SYNC_INT,
+#else
+ .syncen = SAI_CR1_SYNCEN_ASYNC,
+#endif
+#ifdef CONFIG_STM32L4_SAI_DMA
+ .dma_ch = DMACHAN_SAI1_A,
+#endif
+ .datalen = CONFIG_STM32L4_SAI_DEFAULT_DATALEN,
+ .samplerate = CONFIG_STM32L4_SAI_DEFAULT_SAMPLERATE,
+};
+#endif
+
+#ifdef CONFIG_STM32L4_SAI1_B
+static struct stm32l4_sai_s g_sai1b_priv =
+{
+ .dev.ops = &g_i2sops,
+ .base = STM32L4_SAI1_B_BASE,
+ .frequency = STM32L4_SAI1_FREQUENCY,
+#ifdef CONFIG_STM32L4_SAI1_B_SYNC_WITH_A
+ .syncen = SAI_CR1_SYNCEN_SYNC_INT,
+#else
+ .syncen = SAI_CR1_SYNCEN_ASYNC,
+#endif
+#ifdef CONFIG_STM32L4_SAI_DMA
+ .dma_ch = DMACHAN_SAI1_B,
+#endif
+ .datalen = CONFIG_STM32L4_SAI_DEFAULT_DATALEN,
+ .samplerate = CONFIG_STM32L4_SAI_DEFAULT_SAMPLERATE,
+};
+#endif
+
+/* SAI2 state */
+
+#ifdef CONFIG_STM32L4_SAI2_A
+static struct stm32l4_sai_s g_sai2a_priv =
+{
+ .dev.ops = &g_i2sops,
+ .base = STM32L4_SAI2_A_BASE,
+ .frequency = STM32L4_SAI2_FREQUENCY,
+#ifdef CONFIG_STM32L4_SAI2_A_SYNC_WITH_B
+ .syncen = SAI_CR1_SYNCEN_SYNC_INT,
+#else
+ .syncen = SAI_CR1_SYNCEN_ASYNC,
+#endif
+#ifdef CONFIG_STM32L4_SAI_DMA
+ .dma_ch = DMACHAN_SAI2_A,
+#endif
+ .datalen = CONFIG_STM32L4_SAI_DEFAULT_DATALEN,
+ .samplerate = CONFIG_STM32L4_SAI_DEFAULT_SAMPLERATE,
+};
+#endif
+
+#ifdef CONFIG_STM32L4_SAI2_B
+static struct stm32l4_sai_s g_sai2b_priv =
+{
+ .dev.ops = &g_i2sops,
+ .base = STM32L4_SAI2_B_BASE,
+ .frequency = STM32L4_SAI2_FREQUENCY,
+#ifdef CONFIG_STM32L4_SAI2_B_SYNC_WITH_A
+ .syncen = SAI_CR1_SYNCEN_SYNC_INT,
+#else
+ .syncen = SAI_CR1_SYNCEN_ASYNC,
+#endif
+#ifdef CONFIG_STM32L4_SAI_DMA
+ .dma_ch = DMACHAN_SAI2_B,
+#endif
+ .datalen = CONFIG_STM32L4_SAI_DEFAULT_DATALEN,
+ .samplerate = CONFIG_STM32L4_SAI_DEFAULT_SAMPLERATE,
+};
+#endif
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: sai_getbitrate
+ *
+ * Description:
+ * Get the currently configured bitrate
+ *
+ * Input Parameters:
+ * priv - private SAI device structure
+ *
+ * Returned Value:
+ * The current bitrate
+ *
+ ****************************************************************************/
+
+static inline uint32_t sai_getbitrate(struct stm32l4_sai_s *priv)
+{
+ /* Calculate the bitrate in Hz */
+
+ return priv->samplerate * priv->datalen;
+}
+
+/****************************************************************************
+ * Name: sai_getreg
+ *
+ * Description:
+ * Get the contents of the SAI register at offset
+ *
+ * Input Parameters:
+ * priv - private SAI device structure
+ * offset - offset to the register of interest
+ *
+ * Returned Value:
+ * The contents of the 32-bit register
+ *
+ ****************************************************************************/
+
+static inline uint32_t sai_getreg(struct stm32l4_sai_s *priv, uint8_t offset)
+{
+ return getreg32(priv->base + offset);
+}
+
+/****************************************************************************
+ * Name: sai_putreg
+ *
+ * Description:
+ * Write a 16-bit value to the SAI register at offset
+ *
+ * Input Parameters:
+ * priv - private SAI device structure
+ * offset - offset to the register of interest
+ * value - the 32-bit value to be written
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+static inline void sai_putreg(struct stm32l4_sai_s *priv, uint8_t offset,
+ uint32_t value)
+{
+ putreg32(value, priv->base + offset);
+}
+
+/************************************************************************************
+ * Name: sai_modifyreg
+ *
+ * Description:
+ * Clear and set bits in the SAI register at offset
+ *
+ * Input Parameters:
+ * priv - private SAI device structure
+ * offset - offset to the register of interest
+ * clrbits - The bits to clear
+ * setbits - The bits to set
+ *
+ * Returned Value:
+ * None
+ *
+ ************************************************************************************/
+
+static void sai_modifyreg(struct stm32l4_sai_s *priv, uint8_t offset,
+ uint32_t clrbits, uint32_t setbits)
+{
+ uint32_t regval;
+
+ regval = sai_getreg(priv, offset);
+ regval &= ~clrbits;
+ regval |= setbits;
+ sai_putreg(priv, offset, regval);
+}
+
+/****************************************************************************
+ * Name: sai_dump_regs
+ *
+ * Description:
+ * Dump the contents of all SAI block registers
+ *
+ * Input Parameters:
+ * priv - The SAI block controller to dump
+ * msg - Message to print before the register data
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_DEBUG_I2S_INFO
+static void sai_dump_regs(struct stm32l4_sai_s *priv, const char *msg)
+{
+ if (msg)
+ i2sinfo("%s\n", msg);
+
+ i2sinfo("CR1:%08x CR2:%08x FRCR:%08x SLOTR:%08x\n",
+ sai_getreg(priv, STM32L4_SAI_CR1_OFFSET),
+ sai_getreg(priv, STM32L4_SAI_CR2_OFFSET),
+ sai_getreg(priv, STM32L4_SAI_FRCR_OFFSET),
+ sai_getreg(priv, STM32L4_SAI_SLOTR_OFFSET));
+ i2sinfo(" IM:%08x SR:%08x CLRFR:%08x\n",
+ sai_getreg(priv, STM32L4_SAI_IM_OFFSET),
+ sai_getreg(priv, STM32L4_SAI_SR_OFFSET),
+ sai_getreg(priv, STM32L4_SAI_CLRFR_OFFSET));
+}
+#endif
+
+/****************************************************************************
+ * Name: sai_exclsem_take
+ *
+ * Description:
+ * Take the exclusive access semaphore handling any exceptional conditions
+ *
+ * Input Parameters:
+ * priv - A reference to the SAI peripheral state
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+static void sai_exclsem_take(struct stm32l4_sai_s *priv)
+{
+ int ret;
+
+ /* Wait until we successfully get the semaphore. EINTR is the only
+ * expected 'failure' (meaning that the wait for the semaphore was
+ * interrupted by a signal).
+ */
+
+ do
+ {
+ ret = sem_wait(&priv->exclsem);
+ DEBUGASSERT(ret == 0 || errno == EINTR);
+ }
+ while (ret < 0);
+}
+
+/****************************************************************************
+ * Name: sai_mckdivider
+ *
+ * Description:
+ * Setup the master clock divider based on the currently selected data width
+ * and the sample rate
+ *
+ * Input Parameter:
+ * priv - SAI device structure (only the sample rate and frequency are
+ * needed at this point).
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+static void sai_mckdivider(struct stm32l4_sai_s *priv)
+{
+ uint8_t mckdiv;
+
+ DEBUGASSERT(priv && priv->samplerate > 0 && priv->frequency > 0);
+
+ /* Configure Master Clock using the following formula:
+ * MCLK_x = SAI_CK_x / (MCKDIV[3:0] * 2) with MCLK_x = 256 * FS
+ * FS = SAI_CK_x / (MCKDIV[3:0] * 2) * 256
+ * MCKDIV[3:0] = SAI_CK_x / FS * 512
+ */
+
+ mckdiv = priv->frequency / (priv->samplerate * 2 * 256);
+
+ sai_modifyreg(priv, STM32L4_SAI_CR1_OFFSET, SAI_CR1_MCKDIV_MASK,
+ mckdiv << SAI_CR1_MCKDIV_SHIFT);
+}
+
+/****************************************************************************
+ * Name: sai_timeout
+ *
+ * Description:
+ * The watchdog timeout without completion of the transfer.
+ *
+ * Input Parameters:
+ * argc - The number of arguments (should be 1)
+ * arg - The argument (state structure reference cast to uint32_t)
+ *
+ * Returned Value:
+ * None
+ *
+ * Assumptions:
+ * Always called from the interrupt level with interrupts disabled.
+ *
+ ****************************************************************************/
+
+static void sai_timeout(int argc, uint32_t arg)
+{
+ struct stm32l4_sai_s *priv = (struct stm32l4_sai_s *)arg;
+ DEBUGASSERT(priv != NULL);
+
+#ifdef CONFIG_STM32L4_SAI_DMA
+ /* Cancel the DMA */
+
+ stm32l4_dmastop(priv->dma);
+#endif
+
+ /* Then schedule completion of the transfer to occur on the worker thread. */
+
+ sai_schedule(priv, -ETIMEDOUT);
+}
+
+/****************************************************************************
+ * Name: sai_dma_setup
+ *
+ * Description:
+ * Setup and initiate the next DMA transfer
+ *
+ * Input Parameters:
+ * priv - SAI state instance
+ *
+ * Returned Value:
+ * OK on success; a negated errno value on failure
+ *
+ * Assumptions:
+ * Interrupts are disabled
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_STM32L4_SAI_DMA
+static int sai_dma_setup(struct stm32l4_sai_s *priv)
+{
+ struct sai_buffer_s *bfcontainer;
+ struct ap_buffer_s *apb;
+ uintptr_t samp;
+ apb_samp_t nbytes;
+ size_t ntransfers = 0;
+ int ret;
+
+ /* If there is already an active transmission in progress, then bail
+ * returning success.
+ */
+
+ if (!sq_empty(&priv->act))
+ {
+ return OK;
+ }
+
+ /* If there are no pending transfer, then bail returning success */
+
+ if (sq_empty(&priv->pend))
+ {
+ priv->txenab = priv->rxenab = false;
+ return OK;
+ }
+
+ /* Remove the pending transfer at the head of the pending queue. */
+
+ bfcontainer = (struct sai_buffer_s *)sq_remfirst(&priv->pend);
+ DEBUGASSERT(bfcontainer && bfcontainer->apb);
+
+ apb = bfcontainer->apb;
+
+ /* Get the transfer information, accounting for any data offset */
+
+ samp = (uintptr_t)&apb->samp[apb->curbyte];
+
+ /* Configure the DMA */
+
+ if (priv->txenab)
+ {
+ nbytes = apb->nbytes - apb->curbyte;
+
+ switch (priv->datalen)
+ {
+ case 8:
+ priv->dma_ccr = SAI_TXDMA8_CONFIG;
+ ntransfers = nbytes;
+ break;
+
+ case 16:
+ priv->dma_ccr = SAI_TXDMA16_CONFIG;
+ DEBUGASSERT((nbytes & 0x1) == 0);
+ ntransfers = nbytes >> 1;
+ break;
+
+ case 32:
+ priv->dma_ccr = SAI_TXDMA32_CONFIG;
+ DEBUGASSERT((nbytes & 0x3) == 0);
+ ntransfers = nbytes >> 2;
+ break;
+ }
+ }
+ else if (priv->rxenab)
+ {
+ nbytes = apb->nmaxbytes - apb->curbyte;
+
+ switch (priv->datalen)
+ {
+ case 8:
+ priv->dma_ccr = SAI_RXDMA8_CONFIG;
+ ntransfers = nbytes;
+ break;
+
+ case 16:
+ priv->dma_ccr = SAI_RXDMA16_CONFIG;
+ DEBUGASSERT((nbytes & 0x1) == 0);
+ ntransfers = nbytes >> 1;
+ break;
+
+ case 32:
+ priv->dma_ccr = SAI_RXDMA32_CONFIG;
+ DEBUGASSERT((nbytes & 0x3) == 0);
+ ntransfers = nbytes >> 2;
+ break;
+ }
+ }
+
+ DEBUGASSERT(ntransfers > 0);
+
+ stm32l4_dmasetup(priv->dma, priv->base + STM32L4_SAI_DR_OFFSET,
+ samp, ntransfers, priv->dma_ccr);
+
+ /* Add the container to the list of active DMAs */
+
+ sq_addlast((sq_entry_t *)bfcontainer, &priv->act);
+
+ /* Start the DMA, saving the container as the current active transfer */
+
+ stm32l4_dmastart(priv->dma, sai_dma_callback, priv, false);
+
+ /* Enable the transmitter */
+
+ sai_modifyreg(priv, STM32L4_SAI_CR1_OFFSET, 0, SAI_CR1_SAIEN);
+
+ /* Start a watchdog to catch DMA timeouts */
+
+ if (bfcontainer->timeout > 0)
+ {
+ ret = wd_start(priv->dog, bfcontainer->timeout, (wdentry_t)sai_timeout,
+ 1, (uint32_t)priv);
+
+ /* Check if we have successfully started the watchdog timer. Note
+ * that we do nothing in the case of failure to start the timer. We
+ * are already committed to the DMA anyway. Let's just hope that the
+ * DMA does not hang.
+ */
+
+ if (ret < 0)
+ {
+ i2serr("ERROR: wd_start failed: %d\n", ret);
+ }
+ }
+
+ return OK;
+}
+#endif
+
+/****************************************************************************
+ * Name: sai_worker
+ *
+ * Description:
+ * Transfer done worker
+ *
+ * Input Parameters:
+ * arg - the SAI device instance cast to void*
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+static void sai_worker(void *arg)
+{
+ struct stm32l4_sai_s *priv = (struct stm32l4_sai_s *)arg;
+ struct sai_buffer_s *bfcontainer;
+ irqstate_t flags;
+
+ DEBUGASSERT(priv);
+
+ /* When the transfer was started, the active buffer containers were removed
+ * from the pend queue and saved in the act queue. We get here when the
+ * transfer is finished... either successfully, with an error, or with a
+ * timeout.
+ *
+ * In any case, the buffer containers in act will be moved to the end
+ * of the done queue and act will be emptied before this worker is
+ * started.
+ */
+
+ i2sinfo("act.head=%p done.head=%p\n", priv->act.head, priv->done.head);
+
+ /* Check if IDLE */
+
+ if (sq_empty(&priv->act))
+ {
+ /* Then start the next transfer. This must be done with interrupts
+ * disabled.
+ */
+
+ flags = enter_critical_section();
+#ifdef CONFIG_STM32L4_SAI_DMA
+ (void)sai_dma_setup(priv);
+#endif
+ leave_critical_section(flags);
+ }
+
+ /* Process each buffer in the done queue */
+
+ while (sq_peek(&priv->done) != NULL)
+ {
+ /* Remove the buffer container from the done queue. NOTE that
+ * interupts must be enabled to do this because the done queue is
+ * also modified from the interrupt level.
+ */
+
+ flags = enter_critical_section();
+ bfcontainer = (struct sai_buffer_s *)sq_remfirst(&priv->done);
+ leave_critical_section(flags);
+
+ /* Perform the transfer done callback */
+
+ DEBUGASSERT(bfcontainer && bfcontainer->callback);
+ bfcontainer->callback(&priv->dev, bfcontainer->apb,
+ bfcontainer->arg, bfcontainer->result);
+
+ /* Release our reference on the audio buffer. This may very likely
+ * cause the audio buffer to be freed.
+ */
+
+ apb_free(bfcontainer->apb);
+
+ /* And release the buffer container */
+
+ sai_buf_free(priv, bfcontainer);
+ }
+}
+
+/****************************************************************************
+ * Name: sai_schedule
+ *
+ * Description:
+ * An transfer completion or timeout has occurred. Schedule processing on
+ * the working thread.
+ *
+ * Input Parameters:
+ * priv - SAI state instance
+ * result - The result of the transfer
+ *
+ * Returned Value:
+ * None
+ *
+ * Assumptions:
+ * - Interrupts are disabled
+ * - The timeout has been canceled.
+ *
+ ****************************************************************************/
+
+static void sai_schedule(struct stm32l4_sai_s *priv, int result)
+{
+ struct sai_buffer_s *bfcontainer;
+ int ret;
+
+ /* Move all entries from the act queue to the done queue */
+
+ while (!sq_empty(&priv->act))
+ {
+ /* Remove the next buffer container from the act list */
+
+ bfcontainer = (struct sai_buffer_s *)sq_remfirst(&priv->act);
+
+ /* Report the result of the transfer */
+
+ bfcontainer->result = result;
+
+ /* Add the completed buffer container to the tail of the done queue */
+
+ sq_addlast((sq_entry_t *)bfcontainer, &priv->done);
+ }
+
+ /* If the worker has completed running, then reschedule the working thread.
+ * REVISIT: There may be a race condition here. So we do nothing is the
+ * worker is not available.
+ */
+
+ if (work_available(&priv->work))
+ {
+ /* Schedule the done processing to occur on the worker thread. */
+
+ ret = work_queue(HPWORK, &priv->work, sai_worker, priv, 0);
+ if (ret != 0)
+ {
+ i2serr("ERROR: Failed to queue work: %d\n", ret);
+ }
+ }
+}
+
+/****************************************************************************
+ * Name: sai_dma_callback
+ *
+ * Description:
+ * This callback function is invoked at the completion of the SAI DMA.
+ *
+ * Input Parameters:
+ * handle - The DMA handler
+ * isr - The interrupt status of the DMA transfer
+ * arg - A pointer to the SAI state instance
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_STM32L4_SAI_DMA
+static void sai_dma_callback(DMA_HANDLE handle, uint8_t isr, void *arg)
+{
+ struct stm32l4_sai_s *priv = (struct stm32l4_sai_s *)arg;
+ DEBUGASSERT(priv);
+
+ /* Cancel the watchdog timeout */
+
+ (void)wd_cancel(priv->dog);
+
+ /* Then schedule completion of the transfer to occur on the worker thread */
+
+ sai_schedule(priv, (isr & DMA_CHAN_TEIF_BIT) ? -EIO : OK);
+}
+#endif
+
+/****************************************************************************
+ * Name: sai_samplerate
+ *
+ * Description:
+ * Set the I2S RX/TX sample rate.
+ *
+ * Input Parameters:
+ * dev - Device-specific state data
+ * rate - The I2S sample rate in samples (not bits) per second
+ *
+ * Returned Value:
+ * Returns the resulting bitrate
+ *
+ ****************************************************************************/
+
+static uint32_t sai_samplerate(struct i2s_dev_s *dev, uint32_t rate)
+{
+ struct stm32l4_sai_s *priv = (struct stm32l4_sai_s *)dev;
+
+ DEBUGASSERT(priv && rate > 0);
+
+ /* Save the new sample rate and update the divider */
+
+ priv->samplerate = rate;
+ sai_mckdivider(priv);
+
+ return sai_getbitrate(priv);
+}
+
+/****************************************************************************
+ * Name: sai_datawidth
+ *
+ * Description:
+ * Set the I2S data width. The bitrate is determined by
+ * sample_rate * data_width.
+ *
+ * Input Parameters:
+ * dev - Device-specific state data
+ * width - The I2S data with in bits.
+ *
+ * Returned Value:
+ * Returns the resulting bitrate
+ *
+ ****************************************************************************/
+
+static uint32_t sai_datawidth(struct i2s_dev_s *dev, int bits)
+{
+ struct stm32l4_sai_s *priv = (struct stm32l4_sai_s *)dev;
+ uint32_t setbits;
+
+ DEBUGASSERT(priv && bits >= 8);
+
+ switch (bits)
+ {
+ case 8:
+ setbits = SAI_CR1_DS_8BITS;
+ break;
+
+ case 16:
+ setbits = SAI_CR1_DS_16BITS;
+ break;
+
+ case 32:
+ setbits = SAI_CR1_DS_32BITS;
+ break;
+
+ default:
+ i2serr("ERROR: Unsupported or invalid data width: %d\n", bits);
+ return 0;
+ }
+
+ sai_modifyreg(priv, STM32L4_SAI_CR1_OFFSET, SAI_CR1_DS_MASK, setbits);
+
+ sai_modifyreg(priv, STM32L4_SAI_FRCR_OFFSET,
+ SAI_FRCR_FSALL_MASK | SAI_FRCR_FRL_MASK,
+ SAI_FRCR_FSALL(bits) | SAI_FRCR_FRL(bits * 2));
+
+ /* Save the new data width */
+
+ priv->datalen = bits;
+
+ return sai_getbitrate(priv);
+}
+
+/****************************************************************************
+ * Name: sai_receive
+ *
+ * Description:
+ * Receive a block of data from I2S.
+ *
+ * Input Parameters:
+ * dev - Device-specific state data
+ * apb - A pointer to the audio buffer in which to recieve data
+ * callback - A user provided callback function that will be called at
+ * the completion of the transfer. The callback will be
+ * performed in the context of the worker thread.
+ * arg - An opaque argument that will be provided to the callback
+ * when the transfer complete
+ * timeout - The timeout value to use. The transfer will be canceled
+ * and an ETIMEDOUT error will be reported if this timeout
+ * elapsed without completion of the DMA transfer. Units
+ * are system clock ticks. Zero means no timeout.
+ *
+ * Returned Value:
+ * OK on success; a negated errno value on failure. NOTE: This function
+ * only enqueues the transfer and returns immediately. Success here only
+ * means that the transfer was enqueued correctly.
+ *
+ * When the transfer is complete, a 'result' value will be provided as
+ * an argument to the callback function that will indicate if the transfer
+ * failed.
+ *
+ ****************************************************************************/
+
+static int sai_receive(struct i2s_dev_s *dev, struct ap_buffer_s *apb,
+ i2s_callback_t callback, void *arg, uint32_t timeout)
+{
+ struct stm32l4_sai_s *priv = (struct stm32l4_sai_s *)dev;
+ struct sai_buffer_s *bfcontainer;
+ uint32_t mode;
+ irqstate_t flags;
+ int ret;
+
+ DEBUGASSERT(priv && apb);
+ i2sinfo("apb=%p nbytes=%d arg=%p timeout=%d\n",
+ apb, apb->nbytes - apb->curbyte, arg, timeout);
+
+ /* Allocate a buffer container in advance */
+
+ bfcontainer = sai_buf_allocate(priv);
+ DEBUGASSERT(bfcontainer);
+
+ /* Get exclusive access to the SAI driver data */
+
+ sai_exclsem_take(priv);
+
+ /* Verify not already TX'ing */
+
+ if (priv->txenab)
+ {
+ i2serr("ERROR: SAI has no receiver\n");
+ ret = -EAGAIN;
+ goto errout_with_exclsem;
+ }
+
+ mode = priv->syncen ? SAI_CR1_MODE_SLAVE_RX : SAI_CR1_MODE_MASTER_RX;
+ sai_modifyreg(priv, STM32L4_SAI_CR1_OFFSET, SAI_CR1_MODE_MASK, mode);
+ priv->rxenab = true;
+
+ /* Add a reference to the audio buffer */
+
+ apb_reference(apb);
+
+ /* Initialize the buffer container structure */
+
+ bfcontainer->callback = (void *)callback;
+ bfcontainer->timeout = timeout;
+ bfcontainer->arg = arg;
+ bfcontainer->apb = apb;
+ bfcontainer->result = -EBUSY;
+
+ /* Add the buffer container to the end of the pending queue */
+
+ flags = enter_critical_section();
+ sq_addlast((sq_entry_t *)bfcontainer, &priv->pend);
+
+ /* Then start the next transfer. If there is already a transfer in progess,
+ * then this will do nothing.
+ */
+
+#ifdef CONFIG_STM32L4_SAI_DMA
+ ret = sai_dma_setup(priv);
+#endif
+ DEBUGASSERT(ret == OK);
+ leave_critical_section(flags);
+ sai_exclsem_give(priv);
+ return OK;
+
+errout_with_exclsem:
+ sai_exclsem_give(priv);
+ sai_buf_free(priv, bfcontainer);
+ return ret;
+}
+
+/****************************************************************************
+ * Name: sai_send
+ *
+ * Description:
+ * Send a block of data on I2S.
+ *
+ * Input Parameters:
+ * dev - Device-specific state data
+ * apb - A pointer to the audio buffer from which to send data
+ * callback - A user provided callback function that will be called at
+ * the completion of the transfer. The callback will be
+ * performed in the context of the worker thread.
+ * arg - An opaque argument that will be provided to the callback
+ * when the transfer complete
+ * timeout - The timeout value to use. The transfer will be canceled
+ * and an ETIMEDOUT error will be reported if this timeout
+ * elapsed without completion of the DMA transfer. Units
+ * are system clock ticks. Zero means no timeout.
+ *
+ * Returned Value:
+ * OK on success; a negated errno value on failure. NOTE: This function
+ * only enqueues the transfer and returns immediately. Success here only
+ * means that the transfer was enqueued correctly.
+ *
+ * When the transfer is complete, a 'result' value will be provided as
+ * an argument to the callback function that will indicate if the transfer
+ * failed.
+ *
+ ****************************************************************************/
+
+static int sai_send(struct i2s_dev_s *dev, struct ap_buffer_s *apb,
+ i2s_callback_t callback, void *arg, uint32_t timeout)
+{
+ struct stm32l4_sai_s *priv = (struct stm32l4_sai_s *)dev;
+ struct sai_buffer_s *bfcontainer;
+ uint32_t mode;
+ irqstate_t flags;
+ int ret;
+
+ DEBUGASSERT(priv && apb);
+ i2sinfo("apb=%p nbytes=%d arg=%p timeout=%d\n",
+ apb, apb->nbytes - apb->curbyte, arg, timeout);
+
+ /* Allocate a buffer container in advance */
+
+ bfcontainer = sai_buf_allocate(priv);
+ DEBUGASSERT(bfcontainer);
+
+ /* Get exclusive access to the SAI driver data */
+
+ sai_exclsem_take(priv);
+
+ /* Verify not already RX'ing */
+
+ if (priv->rxenab)
+ {
+ i2serr("ERROR: SAI has no transmitter\n");
+ ret = -EAGAIN;
+ goto errout_with_exclsem;
+ }
+
+ mode = priv->syncen ? SAI_CR1_MODE_SLAVE_TX : SAI_CR1_MODE_MASTER_TX;
+ sai_modifyreg(priv, STM32L4_SAI_CR1_OFFSET, SAI_CR1_MODE_MASK, mode);
+ priv->txenab = true;
+
+ /* Add a reference to the audio buffer */
+
+ apb_reference(apb);
+
+ /* Initialize the buffer container structure */
+
+ bfcontainer->callback = (void *)callback;
+ bfcontainer->timeout = timeout;
+ bfcontainer->arg = arg;
+ bfcontainer->apb = apb;
+ bfcontainer->result = -EBUSY;
+
+ /* Add the buffer container to the end of the pending queue */
+
+ flags = enter_critical_section();
+ sq_addlast((sq_entry_t *)bfcontainer, &priv->pend);
+
+ /* Then start the next transfer. If there is already a transfer in progess,
+ * then this will do nothing.
+ */
+
+#ifdef CONFIG_STM32L4_SAI_DMA
+ ret = sai_dma_setup(priv);
+#endif
+ DEBUGASSERT(ret == OK);
+ leave_critical_section(flags);
+ sai_exclsem_give(priv);
+ return OK;
+
+errout_with_exclsem:
+ sai_exclsem_give(priv);
+ sai_buf_free(priv, bfcontainer);
+ return ret;
+}
+
+/****************************************************************************
+ * Name: sai_bufsem_take
+ *
+ * Description:
+ * Take the buffer semaphore handling any exceptional conditions
+ *
+ * Input Parameters:
+ * priv - A reference to the SAI peripheral state
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+static void sai_bufsem_take(struct stm32l4_sai_s *priv)
+{
+ int ret;
+
+ /* Wait until we successfully get the semaphore. EINTR is the only
+ * expected 'failure' (meaning that the wait for the semaphore was
+ * interrupted by a signal).
+ */
+
+ do
+ {
+ ret = sem_wait(&priv->bufsem);
+ DEBUGASSERT(ret == 0 || errno == EINTR);
+ }
+ while (ret < 0);
+}
+
+/****************************************************************************
+ * Name: sai_buf_allocate
+ *
+ * Description:
+ * Allocate a buffer container by removing the one at the head of the
+ * free list
+ *
+ * Input Parameters:
+ * priv - SAI state instance
+ *
+ * Returned Value:
+ * A non-NULL pointer to the allocate buffer container on success; NULL if
+ * there are no available buffer containers.
+ *
+ * Assumptions:
+ * The caller does NOT have exclusive access to the SAI state structure.
+ * That would result in a deadlock!
+ *
+ ****************************************************************************/
+
+static struct sai_buffer_s *sai_buf_allocate(struct stm32l4_sai_s *priv)
+{
+ struct sai_buffer_s *bfcontainer;
+ irqstate_t flags;
+
+ /* Set aside a buffer container. By doing this, we guarantee that we will
+ * have at least one free buffer container.
+ */
+
+ sai_bufsem_take(priv);
+
+ /* Get the buffer from the head of the free list */
+
+ flags = enter_critical_section();
+ bfcontainer = priv->freelist;
+ ASSERT(bfcontainer);
+
+ /* Unlink the buffer from the freelist */
+
+ priv->freelist = bfcontainer->flink;
+ leave_critical_section(flags);
+ return bfcontainer;
+}
+
+/****************************************************************************
+ * Name: sai_buf_free
+ *
+ * Description:
+ * Free buffer container by adding it to the head of the free list
+ *
+ * Input Parameters:
+ * priv - SAI state instance
+ * bfcontainer - The buffer container to be freed
+ *
+ * Returned Value:
+ * None
+ *
+ * Assumptions:
+ * The caller has exclusive access to the SAI state structure
+ *
+ ****************************************************************************/
+
+static void sai_buf_free(struct stm32l4_sai_s *priv, struct sai_buffer_s *bfcontainer)
+{
+ irqstate_t flags;
+
+ /* Put the buffer container back on the free list */
+
+ flags = enter_critical_section();
+ bfcontainer->flink = priv->freelist;
+ priv->freelist = bfcontainer;
+ leave_critical_section(flags);
+
+ /* Wake up any threads waiting for a buffer container */
+
+ sai_bufsem_give(priv);
+}
+
+/****************************************************************************
+ * Name: sai_buf_initialize
+ *
+ * Description:
+ * Initialize the buffer container allocator by adding all of the
+ * pre-allocated buffer containers to the free list
+ *
+ * Input Parameters:
+ * priv - SAI state instance
+ *
+ * Returned Value:
+ * None
+ *
+ * Assumptions:
+ * Called early in SAI initialization so that there are no issues with
+ * concurrency.
+ *
+ ****************************************************************************/
+
+static void sai_buf_initialize(struct stm32l4_sai_s *priv)
+{
+ int i;
+
+ priv->freelist = NULL;
+ sem_init(&priv->bufsem, 0, CONFIG_STM32L4_SAI_MAXINFLIGHT);
+
+ for (i = 0; i < CONFIG_STM32L4_SAI_MAXINFLIGHT; i++)
+ {
+ sai_buf_free(priv, &priv->containers[i]);
+ }
+}
+
+/****************************************************************************
+ * Name: sai_portinitialize
+ *
+ * Description:
+ * Initialize the selected SAI port in its default state
+ *
+ * Input Parameter:
+ * priv - private SAI device structure
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+static void sai_portinitialize(struct stm32l4_sai_s *priv)
+{
+ sai_dump_regs(priv, "Before initialization");
+
+ sem_init(&priv->exclsem, 0, 1);
+
+ /* Create a watchdog timer to catch transfer timeouts */
+
+ priv->dog = wd_create();
+ ASSERT(priv->dog);
+
+ /* Initialize buffering */
+
+ sai_buf_initialize(priv);
+
+ /* Configure the master clock divider */
+
+ sai_mckdivider(priv);
+
+ /* Configure the data width */
+
+ sai_datawidth((struct i2s_dev_s *)priv, CONFIG_STM32L4_SAI_DEFAULT_DATALEN);
+
+#ifdef CONFIG_STM32L4_SAI_DMA
+ /* Get DMA channel */
+
+ priv->dma = stm32l4_dmachannel(priv->dma_ch);
+ DEBUGASSERT(priv->dma);
+
+ sai_modifyreg(priv, STM32L4_SAI_CR1_OFFSET, 0, SAI_CR1_DMAEN);
+#endif
+
+ sai_modifyreg(priv, STM32L4_SAI_CR1_OFFSET, SAI_CR1_SYNCEN_MASK, priv->syncen);
+
+ sai_modifyreg(priv, STM32L4_SAI_CR2_OFFSET, SAI_CR2_FTH_MASK, SAI_CR2_FTH_1QF);
+
+ sai_modifyreg(priv, STM32L4_SAI_FRCR_OFFSET,
+ SAI_FRCR_FSDEF | SAI_FRCR_FSPOL | SAI_FRCR_FSOFF,
+ SAI_FRCR_FSDEF_CHID | SAI_FRCR_FSPOL_LOW | SAI_FRCR_FSOFF_BFB);
+
+ sai_modifyreg(priv, STM32L4_SAI_SLOTR_OFFSET,
+ SAI_SLOTR_NBSLOT_MASK | SAI_SLOTR_SLOTEN_MASK,
+ SAI_SLOTR_NBSLOT(2) | SAI_SLOTR_SLOTEN_0 | SAI_SLOTR_SLOTEN_1);
+
+ sai_dump_regs(priv, "After initialization");
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: stm32l4_sai_initialize
+ *
+ * Description:
+ * Initialize the selected SAI block
+ *
+ * Input Parameter:
+ * intf - I2S interface number (identifying the "logical" SAI interface)
+ *
+ * Returned Value:
+ * Valid I2S device structure reference on success; a NULL on failure
+ *
+ ****************************************************************************/
+
+struct i2s_dev_s *stm32l4_sai_initialize(int intf)
+{
+ struct stm32l4_sai_s *priv;
+ irqstate_t flags;
+
+ flags = enter_critical_section();
+
+ switch (intf)
+ {
+#ifdef CONFIG_STM32L4_SAI1_A
+ case SAI1_BLOCK_A:
+ {
+ i2sinfo("SAI1 Block A Selected\n");
+ priv = &g_sai1a_priv;
+
+ stm32l4_configgpio(GPIO_SAI1_SD_A);
+# ifndef CONFIG_STM32L4_SAI1_A_SYNC_WITH_B
+ stm32l4_configgpio(GPIO_SAI1_FS_A);
+ stm32l4_configgpio(GPIO_SAI1_SCK_A);
+ stm32l4_configgpio(GPIO_SAI1_MCLK_A);
+# endif
+ break;
+ }
+#endif
+#ifdef CONFIG_STM32L4_SAI1_B
+ case SAI1_BLOCK_B:
+ {
+ i2sinfo("SAI1 Block B Selected\n");
+ priv = &g_sai1b_priv;
+
+ stm32l4_configgpio(GPIO_SAI1_SD_B);
+# ifndef CONFIG_STM32L4_SAI1_B_SYNC_WITH_A
+ stm32l4_configgpio(GPIO_SAI1_FS_B);
+ stm32l4_configgpio(GPIO_SAI1_SCK_B);
+ stm32l4_configgpio(GPIO_SAI1_MCLK_B);
+# endif
+ break;
+ }
+#endif
+#ifdef CONFIG_STM32L4_SAI2_A
+ case SAI2_BLOCK_A:
+ {
+ i2sinfo("SAI2 Block A Selected\n");
+ priv = &g_sai2a_priv;
+
+ stm32l4_configgpio(GPIO_SAI2_SD_A);
+# ifndef CONFIG_STM32L4_SAI2_A_SYNC_WITH_B
+ stm32l4_configgpio(GPIO_SAI2_FS_A);
+ stm32l4_configgpio(GPIO_SAI2_SCK_A);
+ stm32l4_configgpio(GPIO_SAI2_MCLK_A);
+# endif
+ break;
+ }
+#endif
+#ifdef CONFIG_STM32L4_SAI2_B
+ case SAI2_BLOCK_B:
+ {
+ i2sinfo("SAI2 Block B Selected\n");
+ priv = &g_sai2b_priv;
+
+ stm32l4_configgpio(GPIO_SAI2_SD_B);
+# ifndef CONFIG_STM32L4_SAI2_B_SYNC_WITH_A
+ stm32l4_configgpio(GPIO_SAI2_FS_B);
+ stm32l4_configgpio(GPIO_SAI2_SCK_B);
+ stm32l4_configgpio(GPIO_SAI2_MCLK_B);
+# endif
+ break;
+ }
+#endif
+ default:
+ {
+ i2sinfo("No SAI interface defined\n");
+ goto err;
+ }
+ }
+
+ sai_portinitialize(priv);
+ leave_critical_section(flags);
+
+ return &priv->dev;
+
+err:
+ leave_critical_section(flags);
+ return NULL;
+}
+
+#endif
diff --git a/arch/arm/src/stm32l4/stm32l4_sai.h b/arch/arm/src/stm32l4/stm32l4_sai.h
new file mode 100644
index 0000000000000000000000000000000000000000..b1b4955185e8921c08303341117361c35a80c820
--- /dev/null
+++ b/arch/arm/src/stm32l4/stm32l4_sai.h
@@ -0,0 +1,94 @@
+/******************************************************************************
+ * arch/arm/src/stm32l4/stm32l4_sai.h
+ *
+ * Copyright (C) 2017 Gregory Nutt. All rights reserved.
+ * Copyright (c) 2016 Motorola Mobility, LLC. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ******************************************************************************/
+
+#ifndef __ARCH_ARM_SRC_STM32L4_STM32L4_SAI_H
+#define __ARCH_ARM_SRC_STM32L4_STM32L4_SAI_H
+
+/******************************************************************************
+ * Included Files
+ ******************************************************************************/
+
+#include
+
+#include "chip.h"
+#include "chip/stm32l4_sai.h"
+
+#include
+
+/******************************************************************************
+ * Pre-processor definitions
+ ******************************************************************************/
+
+#define SAI1_BLOCK_A 0
+#define SAI1_BLOCK_B 1
+#define SAI2_BLOCK_A 2
+#define SAI2_BLOCK_B 3
+
+/******************************************************************************
+ * Public Function Prototypes
+ ******************************************************************************/
+
+#ifndef __ASSEMBLY__
+#ifdef __cplusplus
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+/****************************************************************************
+ * Name: stm32l4_sai_initialize
+ *
+ * Description:
+ * Initialize the selected SAI block
+ *
+ * Input Parameters:
+ * intf - I2S interface number (identifying the "logical" SAI interface)
+ *
+ * Returned Value:
+ * Valid I2S device structure reference on success; a NULL on failure
+ *
+ ****************************************************************************/
+
+struct i2s_dev_s *stm32l4_sai_initialize(int intf);
+
+#undef EXTERN
+#ifdef __cplusplus
+}
+#endif
+#endif /* __ASSEMBLY__ */
+
+#endif /* __ARCH_ARM_SRC_STM32L4_STM32L4_SAI_H */
diff --git a/arch/arm/src/stm32l4/stm32l4_serial.c b/arch/arm/src/stm32l4/stm32l4_serial.c
index dfef76a9b104216298ab2aab03e407c53f34b43b..187a8f8f9bb67860332f251ee3b825bf6335c563 100644
--- a/arch/arm/src/stm32l4/stm32l4_serial.c
+++ b/arch/arm/src/stm32l4/stm32l4_serial.c
@@ -243,8 +243,6 @@ struct stm32l4_serial_s
const unsigned int rxdma_channel; /* DMA channel assigned */
#endif
- int (*const vector)(int irq, void *context); /* Interrupt handler */
-
/* RX DMA state */
#ifdef SERIAL_HAVE_DMA
@@ -271,7 +269,7 @@ static int stm32l4serial_setup(FAR struct uart_dev_s *dev);
static void stm32l4serial_shutdown(FAR struct uart_dev_s *dev);
static int stm32l4serial_attach(FAR struct uart_dev_s *dev);
static void stm32l4serial_detach(FAR struct uart_dev_s *dev);
-static int up_interrupt_common(FAR struct stm32l4_serial_s *dev);
+static int up_interrupt(int irq, FAR void *context, FAR void *arg);
static int stm32l4serial_ioctl(FAR struct file *filep, int cmd,
unsigned long arg);
#ifndef SERIAL_HAVE_ONLY_DMA
@@ -307,22 +305,6 @@ static int stm32l4serial_pmprepare(FAR struct pm_callback_s *cb, int domain,
enum pm_state_e pmstate);
#endif
-#ifdef CONFIG_STM32L4_USART1
-static int up_interrupt_usart1(int irq, FAR void *context);
-#endif
-#ifdef CONFIG_STM32L4_USART2
-static int up_interrupt_usart2(int irq, FAR void *context);
-#endif
-#ifdef CONFIG_STM32L4_USART3
-static int up_interrupt_usart3(int irq, FAR void *context);
-#endif
-#ifdef CONFIG_STM32L4_UART4
-static int up_interrupt_uart4(int irq, FAR void *context);
-#endif
-#ifdef CONFIG_STM32L4_UART5
-static int up_interrupt_uart5(int irq, FAR void *context);
-#endif
-
/****************************************************************************
* Private Variables
****************************************************************************/
@@ -460,7 +442,6 @@ static struct stm32l4_serial_s g_usart1priv =
.rxdma_channel = DMAMAP_USART1_RX,
.rxfifo = g_usart1rxfifo,
#endif
- .vector = up_interrupt_usart1,
#ifdef CONFIG_USART1_RS485
.rs485_dir_gpio = GPIO_USART1_RS485_DIR,
@@ -522,7 +503,6 @@ static struct stm32l4_serial_s g_usart2priv =
.rxdma_channel = DMAMAP_USART2_RX,
.rxfifo = g_usart2rxfifo,
#endif
- .vector = up_interrupt_usart2,
#ifdef CONFIG_USART2_RS485
.rs485_dir_gpio = GPIO_USART2_RS485_DIR,
@@ -584,7 +564,6 @@ static struct stm32l4_serial_s g_usart3priv =
.rxdma_channel = DMAMAP_USART3_RX,
.rxfifo = g_usart3rxfifo,
#endif
- .vector = up_interrupt_usart3,
#ifdef CONFIG_USART3_RS485
.rs485_dir_gpio = GPIO_USART3_RS485_DIR,
@@ -650,7 +629,6 @@ static struct stm32l4_serial_s g_uart4priv =
.rxdma_channel = DMAMAP_UART4_RX,
.rxfifo = g_uart4rxfifo,
#endif
- .vector = up_interrupt_uart4,
#ifdef CONFIG_UART4_RS485
.rs485_dir_gpio = GPIO_UART4_RS485_DIR,
@@ -716,7 +694,6 @@ static struct stm32l4_serial_s g_uart5priv =
.rxdma_channel = DMAMAP_UART5_RX,
.rxfifo = g_uart5rxfifo,
#endif
- .vector = up_interrupt_uart5,
#ifdef CONFIG_UART5_RS485
.rs485_dir_gpio = GPIO_UART5_RS485_DIR,
@@ -1399,7 +1376,7 @@ static int stm32l4serial_attach(FAR struct uart_dev_s *dev)
/* Attach and enable the IRQ */
- ret = irq_attach(priv->irq, priv->vector);
+ ret = irq_attach(priv->irq, up_interrupt, priv);
if (ret == OK)
{
/* Enable the interrupt (RX and TX interrupts are still disabled
@@ -1429,7 +1406,7 @@ static void stm32l4serial_detach(FAR struct uart_dev_s *dev)
}
/****************************************************************************
- * Name: up_interrupt_common
+ * Name: up_interrupt
*
* Description:
* This is the USART interrupt handler. It will be invoked when an
@@ -1440,11 +1417,14 @@ static void stm32l4serial_detach(FAR struct uart_dev_s *dev)
*
****************************************************************************/
-static int up_interrupt_common(FAR struct stm32l4_serial_s *priv)
+static int up_interrupt(int irq, FAR void *context, FAR void *arg)
{
+ FAR struct stm32l4_serial_s *priv = (FAR struct stm32l4_serial_s *)arg;
int passes;
bool handled;
+ DEBUGASSERT(priv != NULL);
+
/* Report serial activity to the power management logic */
#if defined(CONFIG_PM) && CONFIG_PM_SERIAL_ACTIVITY > 0
@@ -1750,8 +1730,8 @@ static int stm32l4serial_ioctl(FAR struct file *filep, int cmd,
irqstate_t flags;
flags = enter_critical_section();
- cr1 = stm32l4serial_getreg(priv, STM32_USART_CR1_OFFSET);
- stm32l4serial_putreg(priv, STM32_USART_CR1_OFFSET, cr1 | USART_CR1_SBK);
+ cr1 = stm32l4serial_getreg(priv, STM32L4_USART_CR1_OFFSET);
+ stm32l4serial_putreg(priv, STM32L4_USART_CR1_OFFSET, cr1 | USART_CR1_SBK);
leave_critical_section(flags);
}
break;
@@ -1762,8 +1742,8 @@ static int stm32l4serial_ioctl(FAR struct file *filep, int cmd,
irqstate_t flags;
flags = enter_critical_section();
- cr1 = stm32l4serial_getreg(priv, STM32_USART_CR1_OFFSET);
- stm32l4serial_putreg(priv, STM32_USART_CR1_OFFSET, cr1 & ~USART_CR1_SBK);
+ cr1 = stm32l4serial_getreg(priv, STM32L4_USART_CR1_OFFSET);
+ stm32l4serial_putreg(priv, STM32L4_USART_CR1_OFFSET, cr1 & ~USART_CR1_SBK);
leave_critical_section(flags);
}
break;
@@ -2200,49 +2180,6 @@ static bool stm32l4serial_txready(FAR struct uart_dev_s *dev)
return ((stm32l4serial_getreg(priv, STM32L4_USART_ISR_OFFSET) & USART_ISR_TXE) != 0);
}
-/****************************************************************************
- * Name: up_interrupt_u[s]art[n]
- *
- * Description:
- * Interrupt handlers for U[S]ART[n] where n=1,..,6.
- *
- ****************************************************************************/
-
-#ifdef CONFIG_STM32L4_USART1
-static int up_interrupt_usart1(int irq, FAR void *context)
-{
- return up_interrupt_common(&g_usart1priv);
-}
-#endif
-
-#ifdef CONFIG_STM32L4_USART2
-static int up_interrupt_usart2(int irq, FAR void *context)
-{
- return up_interrupt_common(&g_usart2priv);
-}
-#endif
-
-#ifdef CONFIG_STM32L4_USART3
-static int up_interrupt_usart3(int irq, FAR void *context)
-{
- return up_interrupt_common(&g_usart3priv);
-}
-#endif
-
-#ifdef CONFIG_STM32L4_UART4
-static int up_interrupt_uart4(int irq, FAR void *context)
-{
- return up_interrupt_common(&g_uart4priv);
-}
-#endif
-
-#ifdef CONFIG_STM32L4_UART5
-static int up_interrupt_uart5(int irq, FAR void *context)
-{
- return up_interrupt_common(&g_uart5priv);
-}
-#endif
-
/****************************************************************************
* Name: stm32l4serial_dmarxcallback
*
diff --git a/arch/arm/src/stm32l4/stm32l4_tim.c b/arch/arm/src/stm32l4/stm32l4_tim.c
index 57440d902aaf8c0b92f0a2f913df00d4dc9cc71e..938be218ae0813ab5ee703043b30a710de610d22 100644
--- a/arch/arm/src/stm32l4/stm32l4_tim.c
+++ b/arch/arm/src/stm32l4/stm32l4_tim.c
@@ -268,8 +268,7 @@ static int stm32l4_tim_setcompare(FAR struct stm32l4_tim_dev_s *dev,
static int stm32l4_tim_getcapture(FAR struct stm32l4_tim_dev_s *dev,
uint8_t channel);
static int stm32l4_tim_setisr(FAR struct stm32l4_tim_dev_s *dev,
- int (*handler)(int irq, FAR void *context),
- int source);
+ xcpt_t handler, void *arg, int source);
static void stm32l4_tim_enableint(FAR struct stm32l4_tim_dev_s *dev,
int source);
static void stm32l4_tim_disableint(FAR struct stm32l4_tim_dev_s *dev,
@@ -1158,8 +1157,7 @@ static int stm32l4_tim_getcapture(FAR struct stm32l4_tim_dev_s *dev,
************************************************************************************/
static int stm32l4_tim_setisr(FAR struct stm32l4_tim_dev_s *dev,
- int (*handler)(int irq, FAR void *context),
- int source)
+ xcpt_t handler, void *arg, int source)
{
int vectorno;
@@ -1239,7 +1237,7 @@ static int stm32l4_tim_setisr(FAR struct stm32l4_tim_dev_s *dev,
/* Otherwise set callback and enable interrupt */
- irq_attach(vectorno, handler);
+ irq_attach(vectorno, handler, arg);
up_enable_irq(vectorno);
#ifdef CONFIG_ARCH_IRQPRIO
diff --git a/arch/arm/src/stm32l4/stm32l4_tim.h b/arch/arm/src/stm32l4/stm32l4_tim.h
index 1601f1277e6ccfb71345529400fbd1c96f61bfef..8362ef13875d1abe30384886dd8777065dcc7111 100644
--- a/arch/arm/src/stm32l4/stm32l4_tim.h
+++ b/arch/arm/src/stm32l4/stm32l4_tim.h
@@ -63,7 +63,7 @@
#define STM32L4_TIM_SETCHANNEL(d,ch,mode) ((d)->ops->setchannel(d,ch,mode))
#define STM32L4_TIM_SETCOMPARE(d,ch,comp) ((d)->ops->setcompare(d,ch,comp))
#define STM32L4_TIM_GETCAPTURE(d,ch) ((d)->ops->getcapture(d,ch))
-#define STM32L4_TIM_SETISR(d,hnd,s) ((d)->ops->setisr(d,hnd,s))
+#define STM32L4_TIM_SETISR(d,hnd,arg,s) ((d)->ops->setisr(d,hnd,arg,s))
#define STM32L4_TIM_ENABLEINT(d,s) ((d)->ops->enableint(d,s))
#define STM32L4_TIM_DISABLEINT(d,s) ((d)->ops->disableint(d,s))
#define STM32L4_TIM_ACKINT(d,s) ((d)->ops->ackint(d,s))
@@ -174,7 +174,7 @@ struct stm32l4_tim_ops_s
/* Timer interrupts */
int (*setisr)(FAR struct stm32l4_tim_dev_s *dev,
- int (*handler)(int irq, void *context), int source);
+ xcpt_t handler, void *arg, int source);
void (*enableint)(FAR struct stm32l4_tim_dev_s *dev, int source);
void (*disableint)(FAR struct stm32l4_tim_dev_s *dev, int source);
void (*ackint)(FAR struct stm32l4_tim_dev_s *dev, int source);
@@ -191,7 +191,7 @@ FAR struct stm32l4_tim_dev_s *stm32l4_tim_init(int timer);
/* Power-down timer, mark it as unused */
-int stm32l4_tim_deinit(FAR struct stm32l4_tim_dev_s * dev);
+int stm32l4_tim_deinit(FAR struct stm32l4_tim_dev_s *dev);
/****************************************************************************
* Name: stm32l4_timer_initialize
diff --git a/arch/arm/src/stm32l4/stm32l4_tim_lowerhalf.c b/arch/arm/src/stm32l4/stm32l4_tim_lowerhalf.c
index 7f872736a4932ea00e29c9a7f5123a9f1bd9a0cb..59918c81ba9292ad26e2fa9e6ea98d336dc26af4 100644
--- a/arch/arm/src/stm32l4/stm32l4_tim_lowerhalf.c
+++ b/arch/arm/src/stm32l4/stm32l4_tim_lowerhalf.c
@@ -95,7 +95,6 @@ struct stm32l4_lowerhalf_s
FAR struct stm32l4_tim_dev_s *tim; /* stm32 timer driver */
tccb_t callback; /* Current upper half interrupt callback */
FAR void *arg; /* Argument passed to upper half callback */
- const xcpt_t timhandler; /* Current timer interrupt handler */
bool started; /* True: Timer has been started */
const uint8_t resolution; /* Number of bits in the timer (16 or 32 bits) */
};
@@ -106,41 +105,7 @@ struct stm32l4_lowerhalf_s
/* Interrupt handling *******************************************************/
-#ifdef CONFIG_STM32L4_TIM1
-static int stm32l4_tim1_interrupt(int irq, FAR void *context);
-#endif
-#ifdef CONFIG_STM32L4_TIM2
-static int stm32l4_tim2_interrupt(int irq, FAR void *context);
-#endif
-#ifdef CONFIG_STM32L4_TIM3
-static int stm32l4_tim3_interrupt(int irq, FAR void *context);
-#endif
-#ifdef CONFIG_STM32L4_TIM4
-static int stm32l4_tim4_interrupt(int irq, FAR void *context);
-#endif
-#ifdef CONFIG_STM32L4_TIM5
-static int stm32l4_tim5_interrupt(int irq, FAR void *context);
-#endif
-#ifdef CONFIG_STM32L4_TIM6
-static int stm32l4_tim6_interrupt(int irq, FAR void *context);
-#endif
-#ifdef CONFIG_STM32L4_TIM7
-static int stm32l4_tim7_interrupt(int irq, FAR void *context);
-#endif
-#ifdef CONFIG_STM32L4_TIM8
-static int stm32l4_tim8_interrupt(int irq, FAR void *context);
-#endif
-#ifdef CONFIG_STM32L4_TIM15
-static int stm32l4_tim15_interrupt(int irq, FAR void *context);
-#endif
-#ifdef CONFIG_STM32L4_TIM16
-static int stm32l4_tim16_interrupt(int irq, FAR void *context);
-#endif
-#ifdef CONFIG_STM32L4_TIM17
-static int stm32l4_tim17_interrupt(int irq, FAR void *context);
-#endif
-
-static int stm32l4_timer_handler(FAR struct stm32l4_lowerhalf_s *lower);
+static int stm32l4_timer_handler(int irq, void *context, void *arg);
/* "Lower half" driver methods **********************************************/
@@ -170,7 +135,6 @@ static const struct timer_ops_s g_timer_ops =
static struct stm32l4_lowerhalf_s g_tim1_lowerhalf =
{
.ops = &g_timer_ops,
- .timhandler = stm32l4_tim1_interrupt,
.resolution = STM32L4_TIM1_RES,
};
#endif
@@ -179,7 +143,6 @@ static struct stm32l4_lowerhalf_s g_tim1_lowerhalf =
static struct stm32l4_lowerhalf_s g_tim2_lowerhalf =
{
.ops = &g_timer_ops,
- .timhandler = stm32l4_tim2_interrupt,
.resolution = STM32L4_TIM2_RES,
};
#endif
@@ -188,7 +151,6 @@ static struct stm32l4_lowerhalf_s g_tim2_lowerhalf =
static struct stm32l4_lowerhalf_s g_tim3_lowerhalf =
{
.ops = &g_timer_ops,
- .timhandler = stm32l4_tim3_interrupt,
.resolution = STM32L4_TIM3_RES,
};
#endif
@@ -197,7 +159,6 @@ static struct stm32l4_lowerhalf_s g_tim3_lowerhalf =
static struct stm32l4_lowerhalf_s g_tim4_lowerhalf =
{
.ops = &g_timer_ops,
- .timhandler = stm32l4_tim4_interrupt,
.resolution = STM32L4_TIM4_RES,
};
#endif
@@ -206,7 +167,6 @@ static struct stm32l4_lowerhalf_s g_tim4_lowerhalf =
static struct stm32l4_lowerhalf_s g_tim5_lowerhalf =
{
.ops = &g_timer_ops,
- .timhandler = stm32l4_tim5_interrupt,
.resolution = STM32L4_TIM5_RES,
};
#endif
@@ -215,7 +175,6 @@ static struct stm32l4_lowerhalf_s g_tim5_lowerhalf =
static struct stm32l4_lowerhalf_s g_tim6_lowerhalf =
{
.ops = &g_timer_ops,
- .timhandler = stm32l4_tim6_interrupt,
.resolution = STM32L4_TIM6_RES,
};
#endif
@@ -224,7 +183,6 @@ static struct stm32l4_lowerhalf_s g_tim6_lowerhalf =
static struct stm32l4_lowerhalf_s g_tim7_lowerhalf =
{
.ops = &g_timer_ops,
- .timhandler = stm32l4_tim7_interrupt,
.resolution = STM32L4_TIM7_RES,
};
#endif
@@ -233,7 +191,6 @@ static struct stm32l4_lowerhalf_s g_tim7_lowerhalf =
static struct stm32l4_lowerhalf_s g_tim8_lowerhalf =
{
.ops = &g_timer_ops,
- .timhandler = stm32l4_tim8_interrupt,
.resolution = STM32L4_TIM8_RES,
};
#endif
@@ -242,7 +199,6 @@ static struct stm32l4_lowerhalf_s g_tim8_lowerhalf =
static struct stm32l4_lowerhalf_s g_tim15_lowerhalf =
{
.ops = &g_timer_ops,
- .timhandler = stm32l4_tim15_interrupt,
.resolution = STM32L4_TIM15_RES,
};
#endif
@@ -251,7 +207,6 @@ static struct stm32l4_lowerhalf_s g_tim15_lowerhalf =
static struct stm32l4_lowerhalf_s g_tim16_lowerhalf =
{
.ops = &g_timer_ops,
- .timhandler = stm32l4_tim16_interrupt,
.resolution = STM32L4_TIM16_RES,
};
#endif
@@ -260,7 +215,6 @@ static struct stm32l4_lowerhalf_s g_tim16_lowerhalf =
static struct stm32l4_lowerhalf_s g_tim17_lowerhalf =
{
.ops = &g_timer_ops,
- .timhandler = stm32l4_tim17_interrupt,
.resolution = STM32L4_TIM17_RES,
};
#endif
@@ -269,91 +223,6 @@ static struct stm32l4_lowerhalf_s g_tim17_lowerhalf =
* Private Functions
****************************************************************************/
-/****************************************************************************
- * Name: stm32l4_timN_interrupt, N=1..14
- *
- * Description:
- * Individual interrupt handlers for each timer
- *
- ****************************************************************************/
-
-#ifdef CONFIG_STM32L4_TIM1
-static int stm32l4_tim1_interrupt(int irq, FAR void *context)
-{
- return stm32l4_timer_handler(&g_tim1_lowerhalf);
-}
-#endif
-
-#ifdef CONFIG_STM32L4_TIM2
-static int stm32l4_tim2_interrupt(int irq, FAR void *context)
-{
- return stm32l4_timer_handler(&g_tim2_lowerhalf);
-}
-#endif
-
-#ifdef CONFIG_STM32L4_TIM3
-static int stm32l4_tim3_interrupt(int irq, FAR void *context)
-{
- return stm32l4_timer_handler(&g_tim3_lowerhalf);
-}
-#endif
-
-#ifdef CONFIG_STM32L4_TIM4
-static int stm32l4_tim4_interrupt(int irq, FAR void *context)
-{
- return stm32l4_timer_handler(&g_tim4_lowerhalf);
-}
-#endif
-
-#ifdef CONFIG_STM32L4_TIM5
-static int stm32l4_tim5_interrupt(int irq, FAR void *context)
-{
- return stm32l4_timer_handler(&g_tim5_lowerhalf);
-}
-#endif
-
-#ifdef CONFIG_STM32L4_TIM6
-static int stm32l4_tim6_interrupt(int irq, FAR void *context)
-{
- return stm32l4_timer_handler(&g_tim6_lowerhalf);
-}
-#endif
-
-#ifdef CONFIG_STM32L4_TIM7
-static int stm32l4_tim7_interrupt(int irq, FAR void *context)
-{
- return stm32l4_timer_handler(&g_tim7_lowerhalf);
-}
-#endif
-
-#ifdef CONFIG_STM32L4_TIM8
-static int stm32l4_tim8_interrupt(int irq, FAR void *context)
-{
- return stm32l4_timer_handler(&g_tim8_lowerhalf);
-}
-#endif
-
-#ifdef CONFIG_STM32L4_TIM15
-static int stm32l4_tim15_interrupt(int irq, FAR void *context)
-{
- return stm32l4_timer_handler(&g_tim15_lowerhalf);
-}
-#endif
-
-#ifdef CONFIG_STM32L4_TIM16
-static int stm32l4_tim16_interrupt(int irq, FAR void *context)
-{
- return stm32l4_timer_handler(&g_tim16_lowerhalf);
-}
-#endif
-
-#ifdef CONFIG_STM32L4_TIM17
-static int stm32l4_tim17_interrupt(int irq, FAR void *context)
-{
- return stm32l4_timer_handler(&g_tim17_lowerhalf);
-}
-#endif
-
/****************************************************************************
* Name: stm32l4_timer_handler
*
@@ -366,8 +235,9 @@ static int stm32l4_tim17_interrupt(int irq, FAR void *context)
*
****************************************************************************/
-static int stm32l4_timer_handler(FAR struct stm32l4_lowerhalf_s *lower)
+static int stm32l4_timer_handler(int irq, void *context, void *arg)
{
+ FAR struct stm32l4_lowerhalf_s *lower = (FAR struct stm32l4_lowerhalf_s *) arg;
uint32_t next_interval_us = 0;
STM32L4_TIM_ACKINT(lower->tim, 0);
@@ -412,7 +282,7 @@ static int stm32l4_start(FAR struct timer_lowerhalf_s *lower)
if (priv->callback != NULL)
{
- STM32L4_TIM_SETISR(priv->tim, priv->timhandler, 0);
+ STM32L4_TIM_SETISR(priv->tim, stm32l4_timer_handler, priv, 0);
STM32L4_TIM_ENABLEINT(priv->tim, 0);
}
@@ -448,7 +318,7 @@ static int stm32l4_stop(FAR struct timer_lowerhalf_s *lower)
{
STM32L4_TIM_SETMODE(priv->tim, STM32L4_TIM_MODE_DISABLED);
STM32L4_TIM_DISABLEINT(priv->tim, 0);
- STM32L4_TIM_SETISR(priv->tim, 0, 0);
+ STM32L4_TIM_SETISR(priv->tim, NULL, NULL, 0);
priv->started = false;
return OK;
}
@@ -534,13 +404,13 @@ static void stm32l4_setcallback(FAR struct timer_lowerhalf_s *lower,
if (callback != NULL && priv->started)
{
- STM32L4_TIM_SETISR(priv->tim, priv->timhandler, 0);
+ STM32L4_TIM_SETISR(priv->tim, stm32l4_timer_handler, priv, 0);
STM32L4_TIM_ENABLEINT(priv->tim, 0);
}
else
{
STM32L4_TIM_DISABLEINT(priv->tim, 0);
- STM32L4_TIM_SETISR(priv->tim, 0, 0);
+ STM32L4_TIM_SETISR(priv->tim, NULL, NULL, 0);
}
leave_critical_section(flags);
diff --git a/arch/arm/src/stm32l4/stm32l4_timerisr.c b/arch/arm/src/stm32l4/stm32l4_timerisr.c
index fff106e8525544e87c82b08fd8373161dde550fc..4fdec1a6209730a4e9a455d08bf9893a7b7d7e56 100644
--- a/arch/arm/src/stm32l4/stm32l4_timerisr.c
+++ b/arch/arm/src/stm32l4/stm32l4_timerisr.c
@@ -98,7 +98,7 @@
*
****************************************************************************/
-static int stm32l4_timerisr(int irq, uint32_t *regs)
+static int stm32l4_timerisr(int irq, uint32_t *regs, void *arg)
{
/* Process timer interrupt */
@@ -148,7 +148,7 @@ void arm_timer_initialize(void)
/* Attach the timer interrupt vector */
- (void)irq_attach(STM32L4_IRQ_SYSTICK, (xcpt_t)stm32l4_timerisr);
+ (void)irq_attach(STM32L4_IRQ_SYSTICK, (xcpt_t)stm32l4_timerisr, NULL);
/* Enable SysTick interrupts */
diff --git a/arch/arm/src/stm32l4/stm32l4x6xx_dma.c b/arch/arm/src/stm32l4/stm32l4x6xx_dma.c
index e05173d82c4d193f3d296ea7262db86b7b80008c..335e008b182d2863e02417b6cac0083ce8d594c4 100644
--- a/arch/arm/src/stm32l4/stm32l4x6xx_dma.c
+++ b/arch/arm/src/stm32l4/stm32l4x6xx_dma.c
@@ -275,7 +275,7 @@ static void stm32l4_dmachandisable(struct stm32l4_dma_s *dmach)
*
************************************************************************************/
-static int stm32l4_dmainterrupt(int irq, void *context)
+static int stm32l4_dmainterrupt(int irq, void *context, FAR void *arg)
{
struct stm32l4_dma_s *dmach;
uint32_t isr;
@@ -351,7 +351,7 @@ void weak_function up_dmainitialize(void)
/* Attach DMA interrupt vectors */
- (void)irq_attach(dmach->irq, stm32l4_dmainterrupt);
+ (void)irq_attach(dmach->irq, stm32l4_dmainterrupt, NULL);
/* Disable the DMA channel */
diff --git a/arch/arm/src/str71x/str71x_serial.c b/arch/arm/src/str71x/str71x_serial.c
index fe98f543aa7f0ea559bbc7c851f6b703ddfabe24..f1688ae3838527615f0c55f5088d25dbbba76266 100644
--- a/arch/arm/src/str71x/str71x_serial.c
+++ b/arch/arm/src/str71x/str71x_serial.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/str71x/str71x_serial.c
*
- * Copyright (C) 2008-2009, 2012-2013 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2008-2009, 2012-2013, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
*
* Redistribution and use in source and binary forms, with or without
@@ -254,7 +254,7 @@ static int up_setup(struct uart_dev_s *dev);
static void up_shutdown(struct uart_dev_s *dev);
static int up_attach(struct uart_dev_s *dev);
static void up_detach(struct uart_dev_s *dev);
-static int up_interrupt(int irq, void *context);
+static int up_interrupt(int irq, void *context, void *arg);
static int up_ioctl(struct file *filep, int cmd, unsigned long arg);
static int up_receive(struct uart_dev_s *dev, uint32_t *status);
static void up_rxint(struct uart_dev_s *dev, bool enable);
@@ -618,7 +618,7 @@ static int up_attach(struct uart_dev_s *dev)
/* Attach and enable the IRQ */
- ret = irq_attach(priv->irq, up_interrupt);
+ ret = irq_attach(priv->irq, up_interrupt, dev);
if (ret == OK)
{
/* Enable the interrupt (RX and TX interrupts are still disabled
@@ -667,47 +667,15 @@ static void up_detach(struct uart_dev_s *dev)
*
****************************************************************************/
-static int up_interrupt(int irq, void *context)
+static int up_interrupt(int irq, void *context, void *arg)
{
- struct uart_dev_s *dev = NULL;
+ struct uart_dev_s *dev = (struct uart_dev_s *)arg;
struct up_dev_s *priv;
int passes;
bool handled;
-#ifdef CONFIG_STR71X_UART0
- if (g_uart0priv.irq == irq)
- {
- dev = &g_uart0port;
- }
- else
-#endif
-#ifdef CONFIG_STR71X_UART1
- if (g_uart1priv.irq == irq)
- {
- dev = &g_uart1port;
- }
- else
-#endif
-#ifdef CONFIG_STR71X_UART2
- if (g_uart2priv.irq == irq)
- {
- dev = &g_uart2port;
- }
- else
-#endif
-#ifdef CONFIG_STR71X_UART3
- if (g_uart3priv.irq == irq)
- {
- dev = &g_uart3port;
- }
- else
-#endif
- {
- PANIC();
- }
-
+ DEBUGASSERT(dev != NULL && dev->priv != NULL);
priv = (struct up_dev_s *)dev->priv;
- DEBUGASSERT(priv && dev);
/* Loop until there are no characters to be transferred or,
* until we have been looping for a long time.
diff --git a/arch/arm/src/str71x/str71x_timerisr.c b/arch/arm/src/str71x/str71x_timerisr.c
index 553705d24ccdb6ff46257a7b9350ae1f0ed648a5..8fe2bda5aa57f6c95397ce56deef57239f0b9d10 100644
--- a/arch/arm/src/str71x/str71x_timerisr.c
+++ b/arch/arm/src/str71x/str71x_timerisr.c
@@ -126,7 +126,7 @@
*
****************************************************************************/
-static int str71x_timerisr(int irq, uint32_t *regs)
+static int str71x_timerisr(int irq, uint32_t *regs, void *arg)
{
uint16_t ocar;
@@ -204,7 +204,7 @@ void arm_timer_initialize(void)
/* Attach the timer interrupt vector */
- (void)irq_attach(STR71X_IRQ_SYSTIMER, (xcpt_t)str71x_timerisr);
+ (void)irq_attach(STR71X_IRQ_SYSTIMER, (xcpt_t)str71x_timerisr, NULL);
/* And enable the timer interrupt */
diff --git a/arch/arm/src/str71x/str71x_xti.c b/arch/arm/src/str71x/str71x_xti.c
index 1bb42e656b9d22e11b571e5a143fe244d040dc58..386b01784bbe1c1a8b0cf4ae891b5bf749a7f300 100644
--- a/arch/arm/src/str71x/str71x_xti.c
+++ b/arch/arm/src/str71x/str71x_xti.c
@@ -95,7 +95,7 @@ static const struct xtiregs_s g_xtiregs[2] =
*
********************************************************************************/
-static int str71x_xtiinterrupt(int irq, FAR void *context)
+static int str71x_xtiinterrupt(int irq, FAR void *context, FAR void *arg)
{
uint16_t enabled = (uint16_t)getreg8(STR71X_XTI_MRH) << 8 |
(uint16_t)getreg8(STR71X_XTI_MRL);
@@ -168,7 +168,7 @@ int str71x_xtiinitialize(void)
/* Attach the XTI interrupt */
- ret = irq_attach(STR71X_IRQ_XTI, str71x_xtiinterrupt);
+ ret = irq_attach(STR71X_IRQ_XTI, str71x_xtiinterrupt, NULL);
if (ret == OK)
{
/* Enable the XTI interrupt at the XTI */
diff --git a/arch/arm/src/tiva/lm3s_ethernet.c b/arch/arm/src/tiva/lm3s_ethernet.c
index bfe8f2669d9c2ee63687dfe55c078d723c4967f5..acfa6c7c2e40120ae831e71699f0a68ad93f346f 100644
--- a/arch/arm/src/tiva/lm3s_ethernet.c
+++ b/arch/arm/src/tiva/lm3s_ethernet.c
@@ -202,7 +202,8 @@ struct tiva_driver_s
bool ld_bifup; /* true:ifup false:ifdown */
WDOG_ID ld_txpoll; /* TX poll timer */
WDOG_ID ld_txtimeout; /* TX timeout timer */
- struct work_s ld_work; /* For deferring work to the work queue */
+ struct work_s ld_irqwork; /* For deferring interrupt work to the work queue */
+ struct work_s ld_pollwork; /* For deferring poll work to the work queue */
/* This holds the information visible to the NuttX network */
@@ -251,7 +252,7 @@ static void tiva_receive(struct tiva_driver_s *priv);
static void tiva_txdone(struct tiva_driver_s *priv);
static void tiva_interrupt_work(void *arg);
-static int tiva_interrupt(int irq, void *context);
+static int tiva_interrupt(int irq, void *context, FAR void *arg);
/* Watchdog timer expirations */
@@ -1029,9 +1030,9 @@ static void tiva_interrupt_work(void *arg)
/* Re-enable Ethernet interrupts */
#if TIVA_NETHCONTROLLERS > 1
- up_disable_irq(priv->irq);
+ up_enable_irq(priv->irq);
#else
- up_disable_irq(TIVA_IRQ_ETHCON);
+ up_enable_irq(TIVA_IRQ_ETHCON);
#endif
}
@@ -1052,7 +1053,7 @@ static void tiva_interrupt_work(void *arg)
*
****************************************************************************/
-static int tiva_interrupt(int irq, void *context)
+static int tiva_interrupt(int irq, void *context, FAR void *arg)
{
struct tiva_driver_s *priv;
uint32_t ris;
@@ -1093,13 +1094,9 @@ static int tiva_interrupt(int irq, void *context)
wd_cancel(priv->ld_txtimeout);
}
- /* Cancel any pending poll work */
-
- work_cancel(ETHWORK, &priv->ld_work);
-
/* Schedule to perform the interrupt processing on the worker thread. */
- work_queue(ETHWORK, &priv->ld_work, tiva_interrupt_work, priv, 0);
+ work_queue(ETHWORK, &priv->ld_irqwork, tiva_interrupt_work, priv, 0);
return OK;
}
@@ -1176,15 +1173,9 @@ static void tiva_txtimeout_expiry(int argc, wdparm_t arg, ...)
up_disable_irq(TIVA_IRQ_ETHCON);
#endif
- /* Cancel any pending poll or interrupt work. This will have no effect
- * on work that has already been started.
- */
-
- work_cancel(ETHWORK, &priv->ld_work);
-
/* Schedule to perform the TX timeout processing on the worker thread. */
- work_queue(ETHWORK, &priv->ld_work, tiva_txtimeout_work, priv, 0);
+ work_queue(ETHWORK, &priv->ld_irqwork, tiva_txtimeout_work, priv, 0);
}
/****************************************************************************
@@ -1256,24 +1247,9 @@ static void tiva_poll_expiry(int argc, wdparm_t arg, ...)
{
struct tiva_driver_s *priv = (struct tiva_driver_s *)arg;
- /* Is our single work structure available? It may not be if there are
- * pending interrupt actions.
- */
-
- if (work_available(&priv->ld_work))
- {
- /* Schedule to perform the interrupt processing on the worker thread. */
-
- work_queue(ETHWORK, &priv->ld_work, tiva_poll_work, priv, 0);
- }
- else
- {
- /* No.. Just re-start the watchdog poll timer, missing one polling
- * cycle.
- */
+ /* Schedule to perform the interrupt processing on the worker thread. */
- (void)wd_start(priv->ld_txpoll, TIVA_WDDELAY, tiva_poll_expiry, 1, arg);
- }
+ work_queue(ETHWORK, &priv->ld_pollwork, tiva_poll_work, priv, 0);
}
/****************************************************************************
@@ -1425,7 +1401,8 @@ static int tiva_ifup(struct net_driver_s *dev)
/* Set and activate a timer process */
- (void)wd_start(priv->ld_txpoll, TIVA_WDDELAY, tiva_poll_expiry, 1, (uint32_t)priv);
+ (void)wd_start(priv->ld_txpoll, TIVA_WDDELAY, tiva_poll_expiry,
+ 1, (uint32_t)priv);
priv->ld_bifup = true;
leave_critical_section(flags);
@@ -1585,11 +1562,11 @@ static int tiva_txavail(struct net_driver_s *dev)
* availability action.
*/
- if (work_available(&priv->ld_work))
+ if (work_available(&priv->ld_pollwork))
{
/* Schedule to serialize the poll on the worker thread. */
- work_queue(ETHWORK, &priv->ld_work, tiva_txavail_work, priv, 0);
+ work_queue(ETHWORK, &priv->ld_pollwork, tiva_txavail_work, priv, 0);
}
return OK;
@@ -1739,9 +1716,9 @@ static inline int tiva_ethinitialize(int intf)
/* Attach the IRQ to the driver */
#if TIVA_NETHCONTROLLERS > 1
- ret = irq_attach(priv->irq, tiva_interrupt);
+ ret = irq_attach(priv->irq, tiva_interrupt, NULL);
#else
- ret = irq_attach(TIVA_IRQ_ETHCON, tiva_interrupt);
+ ret = irq_attach(TIVA_IRQ_ETHCON, tiva_interrupt, NULL);
#endif
if (ret != 0)
{
diff --git a/arch/arm/src/tiva/tiva_adclib.c b/arch/arm/src/tiva/tiva_adclib.c
index 8376e51cc8b1c22843ba0cba17135db257aa2fd8..dc2768fc16300c4b831e15e2bff9a01cef62afc1 100644
--- a/arch/arm/src/tiva/tiva_adclib.c
+++ b/arch/arm/src/tiva/tiva_adclib.c
@@ -414,7 +414,7 @@ void tiva_adc_irq_attach(uint8_t adc, uint8_t sse, xcpt_t isr)
isr, adc, sse, irq);
#endif
- ret = irq_attach(irq, isr);
+ ret = irq_attach(irq, isr, NULL);
if (ret < 0)
{
aerr("ERROR: Failed to attach IRQ %d: %d\n", irq, ret);
diff --git a/arch/arm/src/tiva/tiva_adclow.c b/arch/arm/src/tiva/tiva_adclow.c
index 6a89e62b5777fe194ebca1da757bb48c58d261fe..46943a07baf91a9916c5a91b65c69aa8be153b58 100644
--- a/arch/arm/src/tiva/tiva_adclow.c
+++ b/arch/arm/src/tiva/tiva_adclow.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/tiva/tiva_adclow.c
*
- * Copyright (C) 2016 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2016-2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2015 TRD2 Inc. All rights reserved.
* Author: Calvin Maguranis
* Gregory Nutt
@@ -58,12 +58,9 @@
* Included Files
****************************************************************************/
-#include
-#include
-#include
+#include
#include
-
#include
#include
#include
@@ -72,6 +69,11 @@
#include
#include
+#include
+#include
+#include
+#include
+
#include
#include "up_arch.h"
diff --git a/arch/arm/src/tiva/tiva_gpio.h b/arch/arm/src/tiva/tiva_gpio.h
index a20dccc15f08b4ba72ba143623191618dd4d4286..54b12cf37ba944dfc1dd905de61b385b0a256cf0 100644
--- a/arch/arm/src/tiva/tiva_gpio.h
+++ b/arch/arm/src/tiva/tiva_gpio.h
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/tiva/tiva_gpio.h
*
- * Copyright (C) 2009-2010, 2013-2015 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2009-2010, 2013-2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt