diff --git a/.gitignore b/.gitignore
index 42240bd35d4a9a631d16da728aa59d45f6f15453..fd06298905b1d6e06c28dc7a69b698e0f2763ff6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,8 +14,6 @@ core
/.config.old
/.version
/Make.defs
-/setenv.sh
-/setenv.bat
/nuttx
/nuttx.*
/nuttx-*
diff --git a/ChangeLog b/ChangeLog
index e15bf20e50b65ef62265ccc47d5561cba2288cda..bd1e20ba37ac8cc88a0990104748fd3da2ce0e0e 100755
--- a/ChangeLog
+++ b/ChangeLog
@@ -584,7 +584,7 @@
* Added fixed precision math support
* Added some color converson routines into what may become a real graphics library someday.
* Added a framebuffer driver for the DM320 (untested on initial check-in)
- * Network: add support for outgoing multicast addresses
+ * Network: Add support for outgoing multicast addresses
* Added some rasterizers to the graphics library
0.4.0 2008-12-06 Gregory Nutt
@@ -924,7 +924,7 @@
context switches and background/user context switches. This change should
improve the performance of those background/user context switches by a factor
of about two.
- * arch/arm/src/stm32/: fix several typos in the serial logic. It turns out
+ * arch/arm/src/stm32/: Fix several typos in the serial logic. It turns out
that these typose don't make any difference as long as you use only one
serial port and all uarts are configured the same. But the typos are bugs
waiting to happen in any other configuration.
@@ -1591,7 +1591,7 @@
where the GPL driver(s) can be re-installed into the NuttX source
tree. By re-installing the driver, you agree to the GPL licsensing
and all of its implications.
- * Makefile, apps/Makefile, tools/configure.sh: add logic to copy
+ * Makefile, apps/Makefile, tools/configure.sh: Add logic to copy
configs///appdir to apps/.config and to simply the
application configuration logic.
* examples/nsh and apps/nshlib: Move the core NuttShell (NSH) logic
@@ -1617,7 +1617,7 @@
without the SDcard (but one issue still exists in STM32)
* arch/arm/src/stm32/stm32_tim.*: Added basic timer support TIM1..TIM8
with output PWMs and interrupt logic
- * config/vsn/src: added basic support for Sensor Interface (GPIO and
+ * config/vsn/src: Added basic support for Sensor Interface (GPIO and
PWM Power Output, and the sif utility program)
* fs/: Reorgnize header so that file systems can be built outside
of the nuttx source tree
@@ -6362,7 +6362,7 @@
from Max Holtzberg (2014-1-4).
* configs/olimex-stm32-p107/nsh/Make.defs: Add native Windows build
support for the Olimex STM32 P107. From Max Holtzberg (2014-1-4).
- * Makefile.win: Changes for native Windows build: fix creation of
+ * Makefile.win: Changes for native Windows build: Fix creation of
a .version file if one does not exist. Make sure that the APPDIR
environment variable is set before configuring. From Max Holtzberg
(2014-1-4).
@@ -7917,7 +7917,7 @@
command line NxPlayer (2014-7-31).
* audio/audio.c: More debug output (2014-7-31).
* configs/sama5d3x-ek/README.txt: REAME update (2014-7-31).
- * drivers/audio/wm8904.c: Was not saving i2s interface instance
+ * drivers/audio/wm8904.c: Was not saving I2S interface instance
(2014-7-31).
* sched/sem_wait.c: Use set_errno() and get_errno(). Direct access
inside the OS may not be supported in the future (2014-7-31).
@@ -9341,11 +9341,11 @@
That is because not handles not only the case of semaphore wait
being awakened by a signal, but also the case with sem_timedwait.c
when the semaphore wait is awakened by a timeout (2014-12-28).
- * arch/arm/src/stm32/stm32_ltdc.c: stm32: fix faulty access to non-
+ * arch/arm/src/stm32/stm32_ltdc.c: stm32: Fix faulty access to non-
existing layer. This disables operation that requires double layer
support, when configured for single layer only. From Marco Krahl
(2014-12-29).
- * arch/arm/src/stm32/stm32_ltdc.c: stm32: fix wait upon vertical blank.
+ * arch/arm/src/stm32/stm32_ltdc.c: stm32: Fix wait upon vertical blank.
This should never have occurred before. From Marco Krahl (2014-12-29).
* configs/stm32f429i-disco/ltdc/defconfig and src/stm32_boot.c:
stm32f429i-disco: change ltdc initializing during boot up. This moves
@@ -9465,7 +9465,7 @@
* arch/arm/src/tiva/tm4c_ethernet.c: When calling into the stack
from the worker thread, it is necessary to have the stack locked
(2015-01-18).
- * nuttx/arch/arm/src/stm32/stm32_serial.c: fix declaration and
+ * nuttx/arch/arm/src/stm32/stm32_serial.c: Fix declaration and
definition of up_receive() and up_dma_receive() to match fields of
uart_ops_s from nuttx/include/nuttx/serial/serial.h. From Freddie
Chopin (2015-01-19).
@@ -10323,7 +10323,7 @@
LED, PWM, and UART0 have been tested. The SPI pins are mapped
correctly but have not yet been tested. From Michael Hope as
SourceForge patch 51 (2015-05-07).
- * arch/arm/src/kl/kl_pwm.c: fix PWM debugging. TPM1 and TPM2 have two
+ * arch/arm/src/kl/kl_pwm.c: Fix PWM debugging. TPM1 and TPM2 have two
channels instead of six and will hard fault if you try to read the
missing channels. From Michael Hope (2015-05-07).
* arch/arm/src/kl/kl_lowputc.c: enable the clocks to UART1 and UART2.
@@ -10770,8 +10770,8 @@
serial device servers. From Anton D. Kachalov (2015-07-29).
* drivers/net/ and include/nuttx/net: Add support for a Faraday
* FTMAC100 Ethernet MAC Driver. From Anton D. Kachalov (2015-07-29).
- * 16550 UART Driver: Add a configuration option to indicate the the
- THR empty bit is inverted. This is the the case for the moxART SoC.
+ * 16550 UART Driver: Add a configuration option to indicate the
+ THR empty bit is inverted. This is the case for the moxART SoC.
Based comments from Anton D. Kachalov (2015-07-29).
* STM32 F4: Add DMA support to the ADC driver for STM32 F4. From
Max Kriegler (2015-07-30).
@@ -11954,7 +11954,7 @@
stm32_pwm.c. From Konstantin Berezenko (2016-06-09).
* arch/arm/src/kinetis: Support up to 8 channels per timer. From kfazz
(2016-06-09).
- * lib/: crc16: fix error. From Paul Alexander Patience (2016-06-10).
+ * lib/: crc16: Fix error. From Paul Alexander Patience (2016-06-10).
* lib/: Add crc64 support. From Paul Alexander Patience (2016-06-10).
* arch/arm/src/kinetis: Added kl_dumpgpio functionality as
kinetis_pindump. From kfazz (2016-06-10).
@@ -12243,7 +12243,7 @@
* drivers/syslog: Add a SYSLOG character device that can be used to re-
direct output to the SYSLOG (2016-07-05).
* net/netdev: Break out internal interface psock_ioctl() (2016-07-06).
- * configs/stm32f4disovery: add can driver for stm32f4discovery. From
+ * configs/stm32f4disovery: Add can driver for stm32f4discovery. From
Matthias Renner (2016-07-06).
* configs/freedom-k64f: Increase MCU clock to 120MHz (2016-07-06).
* arch/arm/src/stm32: Add support for Tickless mode (two timer
@@ -12598,7 +12598,7 @@
feature is EXPERIMENTAL because (1) it is untested and (2) has some
know design issues that must be addressed before it can be of use
(2016-08-28).
- * CXXFLAGS: add -fcheck-new whenever -fno-exceptions is used. From Beat
+ * CXXFLAGS: Add -fcheck-new whenever -fno-exceptions is used. From Beat
Küng (2016-08-23).
* tools/mkfsdata.pl was still generating the old-style apps/include
inclusion paths (2016-08-23).
@@ -12769,7 +12769,7 @@
Mateusz Szafoni (2016-10-06).
* STM32 SPI: stm32_modifycr2 should be available on all platforms if DMA
is enabled. (2016-10-06).
- * STM32 DMA2D: fix an error in up_dma2dcreatelayer where an invalid
+ * STM32 DMA2D: Fix an error in up_dma2dcreatelayer where an invalid
pointer was returned when a certain underlying function failed. From
Jens Gräf (2016-10-07).
@@ -12808,10 +12808,10 @@
* libc/locale: Add clocale header file (2016-10-18).
* libc/wchar: Add functions btowc, mbrtowc, mbtowc, wcscmp, wcscoll,
wmemmove. From Alan Carvalho de Assis (2016-10-18).
- * usbhost/enumerate: fix possible buffer overwrite. From Janne Rosberg
+ * usbhost/enumerate: Fix possible buffer overwrite. From Janne Rosberg
(2016-10-18).
* configs/Board.mk: Add extra clean operations (2016-10-18).
- * usbhost/composite: fix compile; missing semicolons. From Jann
+ * usbhost/composite: Fix compile; missing semicolons. From Jann
Rosberg (2016-10-18).
* libc/stdio: Include wchar.h in lib_libvsprintf.c to fix compilation
error. From Alan Carvalho de Assis (2016-10-18).
@@ -12843,7 +12843,7 @@
From Alan Carvalho de Assis (2016-10-19).
* syslog: Fixes required for file syslog output. From Max Kriegleder
(2016-10-19).
- * arch/arm/src/stm32: add TIM8 to STM32F103V pinmap. From Maciej Wójcik
+ * arch/arm/src/stm32: Add TIM8 to STM32F103V pinmap. From Maciej Wójcik
(2016-10-19).
* libc/locale: Allows c++ code to compile with or without
CONFIG_LIBC_LOCALE and will generate a link error if CONFIG_LIBC_LOCALE
@@ -12989,24 +12989,24 @@
* arch/arm/src/armv7-r: Fix compilation error. This commit fixes
compilation errors on MPU support for ARMv7-R. From Heesub Shin
(2016-11-06).
- * arch/arm/src/armv7-r: fix invalid drbar handling. In ARMv7-R,
+ * arch/arm/src/armv7-r: Fix invalid drbar handling. In ARMv7-R,
[31:5] bits of DRBAR is physical base address and other bits are
reserved and SBZ. Thus, there is no point in passing other than the
base address. From Heesub Shin (2016-11-06).
* arch/arm/src/armv7-r: Remove the redundant update on SCTLR.
mpu_control() is invoking cp15_wrsctlr() around SCTLR update
redundantly. From Heesub Shin (2016-11-06).
- * arch/arm/src/armv7-r: add new Kconfig entries for d/i-cache.
+ * arch/arm/src/armv7-r: Add new Kconfig entries for d/i-cache.
Unlike in ARMv7-A/M, Kconfig entries for data and instruction caches
are currently missing in ARMv7-R. This commit adds those missing
Kconfig entries. Actual implmenetation for those functions will be
added in the subsequent patches. From Heesub Shin (2016-11-06).
- * arch/arm/src/armv7-r: add cache handling functions. This commit
+ * arch/arm/src/armv7-r: Add cache handling functions. This commit
adds functions for enabling and disabling d/i-caches which were
missing for ARMv7-R. From Heesub Shin (2016-11-06).
- * arch/arm/src/armv7-r: fix typo in mpu support. s/ARMV7M/ARMV7R/g.
+ * arch/arm/src/armv7-r: Fix typo in mpu support. s/ARMV7M/ARMV7R/g.
From Heesub Shin (2016-11-06).
- * arch/arm/src/armv7-r: fix CPSR corruption after exception handling.
+ * arch/arm/src/armv7-r: Fix CPSR corruption after exception handling.
A sporadic hang with consequent crash was observed when booting. It
seemed to be caused by the corrupted or wrong CPSR restored on return
from exception. NuttX restores the context using code like this:
@@ -13027,7 +13027,7 @@
result in the corruption of cpsr and thus unexpected behavior.
From Heesub Shin (2016-11-06).
- * arch/arm/src/armv7-r: fix to restore the Thumb flag in CPSR. Thumb
+ * arch/arm/src/armv7-r: Fix to restore the Thumb flag in CPSR. Thumb
flag in CPSR is not restored back when the context switch occurs while
executing thumb instruction. From Heesub Shin (2016-11-06).
* sched/wqueue: When queuing new LP work, don't signal any threads
@@ -13129,7 +13129,7 @@
protect code.
So this change adds locking (via enter_critical section) to wdog
- expiration logic for the the case if the SMP configuration
+ expiration logic for the case if the SMP configuration
(2016-11-18).
* SAM3/4: Add delay between setting and clearing the endpoint RESET bit
in sam_ep_resume(). We need to add a delay between setting and
@@ -13248,7 +13248,7 @@
select to log only notes from certain CPUs (2016-11-28).
* Misoc LM3: Add Misoc Ethernet driver. Integrate network support into
configs/misoc/hello. Remove configs/misoc/include/generated directory.
- I suppose the the intent now is that this is a symbolic link? DANGER!
+ I suppose the intent now is that this is a symbolic link? DANGER!
This means that you cannot compile this code with first generating
these files a providing a symbolic link to this location! From Ramtin
Amin (2016-11-28).
@@ -13271,9 +13271,9 @@
CONFIG_NET_MULTIBUFFER (2016-11-29).
* stm32_otghshost: if STM32F446 increase number of channels to 16. From
Janne Rosberg (2016-11-30).
- * usbhost_composite: fix end offset in usbhost_copyinterface(). From
+ * usbhost_composite: Fix end offset in usbhost_copyinterface(). From
Janne Rosberg (2016-11-30).
- * usbhost_cdcacm: add CDC_SUBCLASS_ACM and CDC_PROTO_ATM to supported
+ * usbhost_cdcacm: Add CDC_SUBCLASS_ACM and CDC_PROTO_ATM to supported
class and proto. From Janne Rosberg (2016-11-30).
* LPC43 SD/MMC: Correct some git definitions on SMMC control register
in lpc43_sdmmc.h. From Alan Carvalho de Assis (2016-11-30).
@@ -13850,7 +13850,7 @@
* STM32L4: Bring LPTIM driver in from the Motorola MDK (2017-02-18).
* drivers/sensors: Add driver for the ST L3GD20 3 axis gyro. From
raiden00 (2017-02-19).
- * config/stm32f429i-disco: add support for the L3GD20 driver. From
+ * config/stm32f429i-disco: Add support for the L3GD20 driver. From
raiden00 (2017-02-19).
* STM32L4 COMP: Port from Motorola MDK (2017-02-19).
* Add twr-k64f120m config and fix some ENET related problems. From Marc
@@ -14004,7 +14004,7 @@
standardized approach. From Mark Schulte (2017-03-01).
* Fix open() a block device with CONFIG_DISABLE_PSEUDOFS_OPERATIONS=y.
From Masayuki Ishikawa (2017-03-01).
- * net/: fixed a nullptr-dereference on iob_clone. From Pascal Speck
+ * net/: Fixed a nullptr-dereference on iob_clone. From Pascal Speck
(2017-03-01).
* configs/: All functions that used to return an xcpt_t old handler value,
not return NULL. The oldhandler value is no longer useful with the
@@ -14089,7 +14089,1305 @@
Janne Rosberg. Adapt Janne Rosberg's patch to STM32 OTGHS host to
OTGFS host, and to similar USB host implementations for STM32 L4 and
F7 (2017-03-07).
- * usbhost_cdcacm: fix tx outbuffer overflow and remove now invalid
+ * usbhost_cdcacm: Fix tx outbuffer overflow and remove now invalid
assert. From Janne Rosberg (2017-03-07).
-7.21 2017-xx-xx Gregory Nutt
+7.21 2017-06-05 Gregory Nutt
+
+ * tools/kconfig2html: Need to increase the maximum number of default
+ values (2017-03-08).
+ * C library: Add strerror_r() (2017-03-08).
+ * C Library: Add wcstoull(), swprintf(), wcstod(), wcstof(), wcstol(),
+ wcstold(), wcstoul(), wcstoll() functions. Add mbsnrtowcs() and
+ wcsnrtombs() (just returning success). Add mbtowc() and wctomb() to
+ C++ std namespace. From Alan Carvalho de Assis (2017-03-08).
+ * Kinetis: Fixed GPIO _PIN_OUTPUT_LOWDRIVE swapped with
+ _PIN_OUTPUT_OPENDRAIN. From David Sidrane (2017-03-08).
+ * Ensure interrupts are back on BEFORE running code dependant on
+ clock_systimer. From David Sidrane (2017-03-08).
+ * Enable compilation of libc++ same way as uClibc++. From Alan
+ Carvalho de Assis (2017-03-08).
+ * Add LPC4337FET256. From Andreas Bihlmaier (2017-03-09).
+ * Change Kconfig type of ADC0_MASK from hex to int; add ADC driver
+ options to lpc43xx. From Andreas Bihlmaier (2017-03-09).
+ * Add missing PINCONF_INBUFFER in several places of
+ lpc4310203050_pinconfig.h. From Andreas Bihlmaier (2017-03-09).
+ * Rename LPC43_GPDMA_GLOBAL_CONFIG (already slipped previous commit C
+ file); fix GPDMA_CONTROL_SBSIZE_*, improve usability of
+ GPDMA_CONTROL_{S,D} macros. From Andreas Bihlmaier (2017-03-09).
+ * Fix errors in LPC43 SCT and SGPIO headers. From Andreas Bihlmaier
+ (2017-03-09).
+ * Fix logic error in lpc43_adc. From Andreas Bihlmaier (2017-03-09).
+ * Fix logic in preprocessor checks and correct arguments to
+ lpc43_pin_config initialization. From Andreas Bihlmaier (2017-03-09).
+ * Use correct macro for irqid (fortunately both point to
+ LPC43_IRQ_EXTINT+18). From Andreas Bihlmaier (2017-03-09).
+ * Actually write modified value to register. From Andreas Bihlmaier
+ (2017-03-09).
+ * Increase number of supported PWM channels from 4 to 6. From Andreas
+ Bihlmaier (2017-03-09).
+ * Fix as5048b by adding missing frequency parameter. From Andreas
+ Bihlmaier (2017-03-09).
+ * Kinetis: Allow Board to add Pullups on SDHC lines. From David
+ Sidrane (2017-03-09).
+ * EZ80F910200KITG: Missing support logic in configs/Kconfig (2017-03-09).
+ * Olimex-STM32-P407: Update USB host support (2017-03-09).
+ * Olimex STM32 P407: USB host support for USB FLASH sticks is now
+ supported in the base nsh configuration (2017-03-09).
+ * STM32, STM32 F7, and STM32 L4: Back out part of
+ 3331e9c49aaaa6dcc3aefa6a9e2c80422ffedcd3. Returning immediately in
+ the case of a NAK makes the Mass Storage Class driver unreliable.
+ The retry/timeout logic is necessary. This implementation tries to
+ implement a compromise: If a NAK is received after some data is
+ received, then the partial data received is returned as with
+ 3331e9c49aaaa6dcc3aefa6a9e2c80422ffedcd3. If if a NAK is received
+ with no data, then no longer returns the NAK error immediately but
+ retries until data is received or a timeout occurs. Initial testing
+ indicates that this fixes the issues the MSC. However, I have
+ concerns that if multiple sectors are read in one transfer, there
+ could be NAKs between sectors as well and, in that case, then change
+ will still cause failures (2017-03-09).
+ * STM32F2: Add USB OTG HS support for stm32f20xxx cores. From Simon
+ Piriou (2017-03-09).
+ * Remove all references to arch_usbhost_initialize(). That was
+ incorrectly called from apps/examples/hidkbd. That is violation of
+ the OS interfacing rules and will no longer be supported. USB host
+ should be initialized as part of the board bring-up logic was with
+ any other devices and should not involve illegal calls from
+ applications into the OS (2017-03-09).
+ * STM32, STM32 F7, STM32 L4: OTG host drivers: Do not do data toggle
+ if interrupt transfer is NAKed. Sugested by webbbn@gmail.com
+ (2017-03-09).
+ * apps/examples/usbterm is gone because it can be configured to perform
+ an illegal call into the OS. Remove all traces of
+ CONFIG_EXAMPLES_USBTERM* and all of the illegal device support
+ (2017-03-09).
+ * Save elapsed time before handling I2C in stm32_i2c_sem_waitstop().
+ This patch follows the same logic as in previous fix to
+ stm32_i2c_sem_waitdone(). It is possible that a context switch
+ occurs after I2C registers are read but before elapsed time is saved
+ in stm32_i2c_sem_waitstop(). It is then possible that the registers
+ were read only once with "elapsed time" equal 0. When scheduler
+ resumes this thread it is quite possible that now "elapsed time" will
+ be well above timeout threshold. In that case the function returns
+ and reports a timeout, even though the registers were not read
+ "recently". Fix this by inverting the order of operations in the loop
+ - save elapsed time before reading registers. This way a context
+ switch anywhere in the loop will not cause an erroneous "timeout"
+ error. From Freddie Chopin (2017-03-10).
+ * pthreads: Fix pthread_mutexattr_init(). It was not initializing the
+ protocol field when priority inheritance is enabled (2017-03-10).
+ * Priority inheritance: When CONFIG_SEM_PREALLOCHOLDERS==0, there is
+ only a single, hard-allocated holder structure. This is problem
+ because in sem_wait() the holder is released, but needs to remain in
+ the holder container until sem_restorebaseprio() is called. The call
+ to sem_restorebaseprio() must be one of the last things the
+ sem_wait() does because it can cause the task to be suspended. If in
+ sem_wait(), a new task gets the semaphore count then it will fail to
+ allocate the holder and will not participate in priority
+ inheritance. This fix is to add two hard-allocated holders in the
+ sem_t structure: One of the old holder and one for the new holder
+ (2017-03-10).
+ * STM32, STM32 F7, and STM32 L4: Clone Freddie Chopin's I2C change to
+ similar STM32 I2C drivers. From David Sidrane (2017-03-10).
+ * Priority Inversion fixes: Initalization. From David Sidrane
+ (2017-03-10).
+ * configs: Add Particle Photon board support. From Simon Piriou
+ (2017-03-10).
+ * tools/testbuild.sh: Add debug option (-d) (2017-03-10).
+ * multiple fixes in nrf24l01 driver: (1) signal POLLIN if there is
+ already data in the FIFO, (2) send ETIMEDOUT to userspace after 2
+ seconds if TX IRQ was not received, (3) handle FIFO overflow, (4)
+ handle invalid pipes/empty FIFO, and (5) multiple cosmetics (missing
+ static, duplicate define, missing \n). From Leif Jakob (2017-03-10).
+ * STM32 F33 ADC: Correct bad definitions of base addresses; Fix
+ naming collision by changing colliding STM32_ADC12_BASE to
+ STM32_ADC12_CMN_BASE (2017-03-10).
+ * photon: Add iwdg timer support. From Simon Piriou (2017-03-11).
+ * photon: Add usb otg hs support and usbnsh app. From Simon Piriou
+ (2017-03-11).
+ * photon: Add LEDs and BUTTONS support. From Simon Piriou (2017-03-11).
+ * As discovered by dcabecinhas. This fix assume the 8 byte alignment
+ options for size stack size or this will overwrite the first word
+ after TOS. See
+ https://github.com/PX4/Firmware/issues/6613#issuecomment-285869778.
+ From David Sidrane (2017-03-11).
+ * STM32F20xxx: Add BOARD_DISABLE_USBOTG_HSULPI flag. From Simon
+ Piriou (2017-03-11).
+ * STM32: Propagate STM32 F2 changes of last PR to STM32 F4 and F7
+ OTGHS (2017-03-11).
+ * STM32 OTG HS: A little research reveals that only the F2 RCC
+ initialization set the OTGHSULPIEN bit and Photon is the only F2
+ board configuration that uses OTG. Therefore, we can simplify the
+ conditional logic of the last PR. Negative logic was used (#ifndef
+ BOARD_DISABLE_USBOTG_HSULPI) to prevent bad settings in other
+ configurations. But giveh these facts, the preferred positive logic
+ now makes more sense (#ifdef BOARD_ENABLE_USBOTG_HSULPI) (2017-03-11).
+ * STM32: OTG host implementations of stm32_in_transfer() must obey the
+ polling interval for the case of isochronous and interrupt endpoints
+ (2017-03-12).
+ * Photon: Add basic support for wlan chip. From Simon Piriou
+ (2017-03-12).
+ * Networking: Add registration support for integrated ieee80211
+ wireless drivers. Rename CONFIG_IEEE802154 to
+ CONFIG_WIRELESS_IEEE8021514 following the convention of including the
+ location of the configuration variable as a part of its name
+ (2017-03-12).
+ * If whence is SEEK_END, the file offset shall be set to the size of
+ the file plus offset. Noted by eunb.song@samsung.com (2017-03-13).
+ * Move IEEE 802.11 wireless IOCTLs from include/nuttx/net/ioctl to
+ include/nuttx/wireless/wireless.h. Add some Linux compatible
+ structures to use with the IOCTL commands. (2017-03-13).
+ * semaphore: sem_holder sem_findholder missing inintalization of
+ pholder. sem_findholder would fail and code optimization covered
+ this up. From David Sidrane (2017-03-13).
+ * Partial Fix priority inheritance CONFIG_SEM_PREALLOCHOLDERS=0. From
+ David Sidrane (2017-03-13).
+ * semaphore: sem_boostholderprio prevent overrun of pend_reprios. The
+ second case rtcb->sched_priority <= htcb->sched_priority did not
+ check if there is sufficient space in the pend_reprios array. From
+ David Sidrane (2017-03-13).
+ * Include C++ library to 'make export'. From Alan Carvalho de Assis
+ (2017-03-13).
+ * arch/arm/src/xmc4: Initial, partial support for Infineon XMC4xxx
+ (2017-03-14).
+ * photon: Porting wlan device. From Simon Piriou (2017-03-14).
+ * lp_worker: Guard from pend_reprios overlow. From David Sidrane
+ (2017-03-15).
+ * wireless/ieee802154: Renamed file ieee802154_device to
+ radio802154_device. From Anthony Merlino (2017-03-15).
+ * Add option to enable wireless debug output (2017-03-15).
+ * wireless/ieee802.15.4: Refactors ieee802154_dev character driver to
+ be radio802154_device. From Anthony Merlino (2017-03-15).
+ * Integrate use of new wireless debug macros. Replace ad hoc debug
+ macros. Convert obsolete dbg() macros to current info(), warn(),
+ err() macros (2017-03-15).
+ * sem_holder: Fixes improper restoration of base_priority in the case
+ of CONFIG_SEM_PREALLOCHOLDERS=0. The call to
+ sem_restorebaseprio_task context switches in the
+ sem_foreachholder(sem, sem_restoreholderprioB, stcb); call prior to
+ releasing the holder. So the running task is left as a holder as is
+ the started task. Leaving both slots filled thus failing to perform
+ the boost/or restoration on the correct tcb. This PR fixes this by
+ releasing the running task slot prior to reprioritization that can
+ lead to the context switch. To faclitate this, the interface to
+ sem_restorebaseprio needed to take the tcb from the holder prior to
+ the holder being freed. In the failure case where sched_verifytcb
+ fails it added the overhead of looking up the holder. There is also
+ the additional thunking on the foreach to get from holer to
+ holder->tcb. An alternate approach could be to leve the interface
+ the same and allocate a holder on the stack of sem_restoreholderprioB
+ copy the sem's holder to it, free it as is done in this pr and and
+ then pass that address sem_restoreholderprio as the holder. It could
+ then get the holder's tcb but we would keep the same sem_findholder
+ in sched_verifytcb. From David Sidrane (2017-03-15).
+ * ARM: Remove redundant interrupt stack coloring. From David
+ Cabecinhas (2017-03-16).
+ * ARM: Set EABI stack alignment for all ARM architectures (remove OABI
+ code). From David Cabecinhas (2017-03-16).
+ * Remove redundant interrupt stack coloring and OABI code. From David
+ Cabecinhas (2017-03-16).
+ * Fixed descritpions of NUC100/120. From no1wudi (2017-03-16).
+ * XMC4500 Relax: Add basic board support infrastructure of Infineon
+ XMC4500 Relax Lite v1 (2017-03-16).
+ * Fix mksyscall host binary name. From Alan Carvalho de Assis
+ (2017-03-16).
+ * sem_holder: The logic for the list version is unchanged. From David
+ Sidrane (2017-03-16).
+ * sem_holder: Fixes improper restoration of base_priority. From David
+ Sidrane (2017-03-17).
+ * C Library: printf: Fix precision for string formatting. Fixes use
+ of format precision to truncate input string. From Jussi Kivilinna
+ (2017-03-17).
+ * vsnprintf(): If size is zero, then vsnprintf() should return the
+ size of the required buffer without writing anything. This is same
+ fix that was done for snprintf in 2014 by commit
+ 59846a8fe928abb389e3776ebdbb52022da45be3. From Jussi Kivilinna
+ (2017-03-17).
+ * Adds driver support for the XBox One controller. Currently only the
+ latest version (XBox One X) controller works. The older XBox One
+ controllers do not enumerate correctly. From Brian Webb (2017-03-17).
+ * USB Host driver for the XBox One game controller. From Brian Webb
+ (2017-03-18).
+ * ARM: Fix off-by-one interrupt stack allocation in 8-byte aligned
+ architectures. From David Cabecinhas (2017-03-18).
+ * configs/nucleo_f334r8: Add ADC example. From Mateusz Szafoni
+ (2017-03-18).
+ * mtd/progmem: Fix incorrect target address calculation.
+ progmem_read/write() is incorrectly calculating the target address,
+ expecting the offset argument is given in a block number. This is
+ completely wrong and as a result invalid flash region is accessed.
+ Byte-oriented read/write interfaces of mtd device accept the target
+ address in a byte offset, not a block number. From Heesub Shin
+ (2017-03-18).
+ * STM32F33: Move DMA logic to a separate files + add ADC support. From
+ Mateusz Szafoni (2017-03-18).
+ * Nucleo-F334R8: Add COMP support. From Mateusz Szafoni (2017-03-19).
+ * STM32F3: Add COMP support. From Mateusz Szafoni (2017-03-19).
+ * XMC4xxx/XMC4500 Relax: First, clean build of basic NSH configurtion
+ (2017-03-20).
+ * XMC4500-Relax: Add LED support (2017-03-20).
+ * input/mxt: Prevent overriding i2c transfer return value.
+ put_reg/get_reg function was overriding i2c transfer error code with
+ i2creset return value, that lead to OK status although actual
+ transfer failed. From Juha Niskanen (2017-03-21).
+ * drivers/audio/wm8904: WM8904 has same problem as that fixed by Juha
+ Niskanen in the MaxTouch driver (2017-03-21).
+ * drivers/lcd/st7565.c: Extend to include support for the AQM_1248A.
+ From Masayuki Ishikawa (2017-03-21).
+ * Fixed wrong assert on udp dgram send. From Pascal Speck (2017-03-21).
+ * sem_holder: Indexing error. From David Sidrane (2017-03-21).
+
+ if (sem->holder[0].htcb != NULL || sem->holder[**1**].htcb != NULL)
+ * sched/semaphore: Convert strange use of DEBUGASSERT to DEBUGPANIC
+ (2017-03-21).
+ * sched/semaphore: Fix a warning aout an unused variable when priority
+ inheritance is enabled (2017-03-21).
+ * Clicker2-STM32: Add support for Mikroelektronika Clicker 2 for
+ STM32. From Anthony Merlino (2017-03-21).
+ * Implement DMA support for the stm32f4 I2C. Max and I have verified
+ that it works on our systems. From rg (2017-03-21).
+ * drivers/lcd/st7565.c: Use ST7565_POWERCTRL_INT instead of
+ ST7565_POWERCTRL_BRF. From Masayuki Ishikawa (2017-03-21).
+ * SMP Kconfig: Change the minimum SMP_NCPUS to 1. From Masayuki
+ Ishikawa (2017-03-xx).
+ * SMP: Setting CONFIG_SMP_NCPUS=1 should only be permitted in a debug
+ configuration (2017-03-22).
+ * Clicker2-STM32: Create src/, kernel/, and scripts/ directories
+ (2017-03-22).
+ * Clicker2-STM32: Add an NSH configuration (2017-03-22).
+ * Clicker2 STM32: Add SPI support (2017-03-22).
+ * XMC4xxx: Add FPU support. From David S. Alessio (2017-03-22).
+ * Clicker2-STM32: Add definitions for remaining mikroBUS pins
+ (2017-03-22).
+ * STM32: Fix erase sector number for microcontrolers with more than 11
+ sectors. Erase a sector from the second bank cause the bit 4 of SNB
+ being set but never unsed, so trying to erase a sector from the first
+ bank was acually eraseing a sector from the second bank. From José
+ Roberto de Souza (2017-03-22).
+ * STM32: Make up_progmem thread safe. Writing to a flash sector while
+ starting the erase of other sector have a undefined behavior so lets
+ add a semaphore and syncronize access to Flash registers. But for
+ the semaphore to work it needs to be initialized so each board needs
+ call stm32_flash_initialize() on initialization, so to avoid runtime
+ problems it is only using semaphore and making it thread safe if
+ initialized, after all boards starts to call stm32_flash_initialize()
+ we can remove the boolean and the check. From José Roberto de Souza
+ (2017-03-22).
+ * STM32: Add workaround for flash data cache corruption on
+ read-while-write. This is a known hardware issue on some STM32 see
+ the errata of your model and if you make use of both memory banks you
+ should enable it. From José Roberto de Souza (2017-03-22).
+ * Clicker2-STM32: Add framework for MRF24J40 support. Untested and
+ still some missing logic (2017-03-22).
+ * STM32 Flash fixes. From José Roberto de Souza (2017-03-22).
+ * STM32F7: In stm32_allocateheap.c There are 5 not 4 configurations.
+ From David Sidrane (2017-03-23).
+ * Clicker2-STM32: Add logic to register the MRF24J40 radio character
+ device (2017-03-23).
+ * Clicker2-STM32: Add some mostly bogus MAC initializatinon logic
+ (2017-03-23).
+ * STM32 I2C: Do not allow CONFIG_I2C_POLLED and CONFIG_I2C_DMA. From
+ rg (2017-03-23).
+ * stm32_flash: Need conditinal on non F4 targets. From David Sidrane
+ (2017-03-23).
+ * stm32_i2c_alt: Duplicate non CS dev of regval. From David Sidrane
+ (2017-03-23).
+ * stm32f40xxx_i2c: Duplicate non CS dev of regval. From David Sidrane
+ (2017-03-23).
+ * stm32_i2c_alt: Move def of regval to top func def per CS. From
+ David Sidrane (2017-03-31).
+ * stm322_flash: Missing unlock on F1 HSI off path. From David Sidrane
+ (2017-03-24).
+ * Fix compile error when disabled the flash data cache corruption for
+ stm32 f1xx. From no1wudi (2017-03-24).
+ * The interrupt occurs over the counter overflow. From Aleksandr
+ Vyhovanec (2017-03-24).
+ * I needed to use DS3231, I remember that in past it worked ok, but now
+ for stm32f4xx is used another driver (chip
+ specific, stm32f40xxx_i2c.c) and DS3231 driver doesn't work. After
+ investigating a problem I found that I2C driver (isr routine) has a
+ few places there it sends stop bit even if not all messages are
+ managed. So, e.g., removing stm32_i2c_sendstop (#1744) and adding
+ stm32_i2c_sendstart after data reading helps to make DS3231 working.
+ From Alexander Oryshchenko; verified by David Sidrane (2017-03-24).
+ * wireless/ieee802154: Adds IOCTL definitions for accessing PHY
+ layer. From Anthony Merlino (2017-03-24).
+ * Add ffsl(), ffsll(), fls(), flsl(), flsll() and use GCC's
+ __builtin_ctz/__builtin_clz for faster implementation of these. From
+ Jussi Kivilinna (2017-03-24).
+ * MRF24J40/Clicker2: Add an MRF24J40 radio configuration to the
+ Clicker2 STM32 board. Fix a few errors discovered during build
+ (2017-03-24).
+ * configs/: Rename all stm32_wireless.c files to stm32_cc3000.c
+ (2017-03-24).
+ * configs/: Rename all xyz_wifi.c files to stm32_cc3000.c (2017-03-24).
+ * Clicker2-STM32: Add usbnsh configuration (2017-03-25).
+ * drivers/analog: Add basic COMP driver. From Mateusz Szafoni
+ (2017-03-25).
+ * STM32F33: Support for COMP character driver. From Mateusz Szafoni
+ (2017-03-25).
+ * Nucleo-F334R8: Use new COMP driver. From Mateusz Szafoni
+ (2017-03-25).
+ * stm32/Kconfig: Update COMP and OPAMP definitions. From Mateusz
+ Szafoni (2017-03-26).
+ * pthreads: Add more robustness characteristics: pthread_mutex_lock()
+ and trylock() will now return EOWNERDEAD if the mutex is locked by a
+ thread that no longer exists. Add pthread_mutex_consistent() to
+ recover from this situation (2017-03-26).
+ * pthread: Fix return value of pthread_give/takesemaphore(). Add
+ option to pthread_takesemaphore to ignore EINTR or not (2017-03-26).
+ * pthreads: Partial implementation of final part of robust mutexes:
+ Keep list of all mutexes held by a thread in a list in the TCB
+ (2017-03-26).
+ * when pthread exits or is cancelled, mutexes held by thread are marked
+ inconsistent and the highest priority thread waiting for the mutex is
+ awakened (2017-03-26).
+ * pthreads: Add a configuration option to disable robust mutexes and
+ revert to the traditional unsafe mutexes (2017-03-26).
+ * pthread mutexes: Add option to support both unsafe and robust
+ mutexes via pthread_mutexattr_get/setrobust() (2017-03-26).
+ * pthread mutexes: Finish logic to support configuration mutex
+ robustness (2017-03-27).
+ * Rename CONFIG_MUTEX_TYPES to CONFIG_PTHREAD_MUTEX_TYPES (2017-03-27).
+ * Make sure that CONFIG_PTHREAD_MUTEX_ROBUST=y is selected every
+ configuration that enabled pthreads (2017-03-27).
+ * Add syscall support for pthread_mutex_consistent() (2017-03-27).
+ * Include wcstold in C++ cwchar header file. From Alan Carvalho de
+ Assis (2017-03-27).
+ * AT86RF23x: Clean-up, standardize lower half interface. Take
+ advantage of new OS features for interrupt parameter passing
+ (2017-03-xx).
+ * MRF24J40: Take advantage of new OS features for interrupt parameter
+ passing (2017-03-27).
+ * lcd/: PCF8574 backpack logic needs to include poll.h
+ CONFIG_DISABLE_POLL is not set (2017-03-27).
+ * drivers/analog: Add driver for the LTC1767L ADC. From Martin
+ Lederhilger (2017-03-28).
+ * realloc(): When realloc() has to fall back to calling malloc(), size
+ including overhead was being provided to malloc(), causing a slightly
+ larger allocation than needed. Noted by initialkjc@yahoo.com
+ (2017-03-28).
+ * Fix PTHREAD_MUTEX_INITIALIZER which was not updated with last mutex
+ changes. From Jussi Kivilinna (2017-03-28).
+ * STM32 F7: Add stm32 RNG support. This is copied from stm32l4.
+ Tested on STM32F746ZG board. From Juha Niskanen (2017-03-29).
+ * STM32 RNG: Fix semaphore initial value and disable priority
+ inheritance. From Juha Niskanen (2017-03-29).
+ * Fix an assertion noted by Jussi Kivilinna. This was a consequence of
+ the recent robust mutex changes. If robust mutexes are selected,
+ then each mutex that a thread takes is retained in a list in threads
+ TCB. If the thread exits and that list is not empty, then we know
+ that the thread exitted while holding mutexes. And, in that case,
+ each will be marked as inconsistent and the any waiter for the thread
+ is awakened. For the case of pthread_mutex_trywait(), the mutex was
+ not being added to the list! while not usually a fatal error, this
+ was caught by an assertion when pthread_mutex_unlock() was called:
+ It tried to remove the mutex from the TCB list and it was not there
+ when, of course, it shoule be. The fix was to add
+ pthread_mutex_trytake() which does sem_trywait() and if successful,
+ does correctly add the mutext to the TCB list. This should
+ eliminated the assertion (2017-03-29).
+ * 6loWPAN: IEEE802.15.4 MAC driver will need a special form of the
+ network device structure to manage fragmentation of the large packet
+ into frames (2017-03-29).
+ * wireless/ieee802154: Adds MAC character driver structure.
+ Nonfunctional. From Anthony Merlino (2017-03-29).
+ * configs/clicker2-STM32: Adds logic to create an 802.15.4 MAC and
+ register a character driver. From Anthony Merlino (2017-03-29).
+ * net/local: connect: Fix warning with gcc-arm-none-eabi-5-2016q1.
+ Using compiler from gcc-arm-none-eabi-5-2016q1 toolchain:
+
+ gcc version 5.3.1 20160307 (release) [ARM/embedded-5-branch revision 234589] (GNU Tools for ARM Embedded Processors)
+
+ gives error:
+
+ local/local_connect.c:188:7: error: '_local_semtake' is static but used in inline function 'local_stream_connect' which is not static [-Werror]
+
+ this is due to compiler enforcing ISO/IEC 9899:1999 6.7.4.3: "An
+ inline definition of a function with external linkage shall not
+ contain a definition of a modifiable object with static storage
+ duration, and shall not contain a reference to an identifier with
+ internal linkage." Fix by making inlined caller to have internal
+ linkage as well. From Juha Niskanen (2017-03-30).
+ * Add entropy pool and strong random number generator. Entropy pool
+ gathers environmental noise from device drivers, user-space, etc.,
+ and returns good random numbers, suitable for cryptographic use.
+ Based on entropy pool design from *BSDs and uses BLAKE2Xs algorithm
+ for CSPRNG output. Patch also adds /dev/urandom support for using
+ entropy pool RNG and new 'getrandom' system call for getting
+ randomness without file-descriptor usage (thus avoiding
+ file-descriptor exhaustion attacks). The 'getrandom' interface is
+ similar as 'getentropy' and 'getrandom' available on OpenBSD and
+ Linux respectively. From Jussi Kivilinna (2017-03-30).
+ * Change STM32 tickless to use only one timer. From Konstantin
+ Berezenko (2017-03-30).
+ * drivers/sensors: Add driver for ST HTS221 humidity sensor. From Juha
+ Niskanen (2017-03-30).
+ * HTS221 driver: Modify to use new interrupt parameter passing hooks
+ (2017-03-31).
+ * drivers/sensors: Add driver for ST LPS25H pressure sensor. From
+ Juha Niskanen (2017-03-31).
+ * drivers/usbmisc: Add driver for Fairchild FUSB301 USB type-C
+ controller. From Harri Luhtala . Tested
+ with earlier version of NuttX; with current version checked that it
+ compiles. Via Juha Niskane (2017-03-31).
+ * Add user-space networking stack API (usrsock). User-space networking
+ stack API allows user-space daemon to provide TCP/IP stack
+ implementation for NuttX network. Main use for this is to allow use
+ and seamless integration of HW-provided TCP/IP stacks to NuttX. For
+ example, user-space daemon can translate /dev/usrsock API requests to
+ HW TCP/IP API requests while rest of the user-space can access
+ standard socket API, with socket descriptors that can be used with
+ NuttX system calls. From Jussi Kivilinna (2017-03-31).
+ * STM32F7: Add support for LSE RTC and enable RTC subseconds. From
+ Jussi Kivilinna (2017-03-31).
+ * TCP/IPv6: Fix a compile issue when IPv6, but not IPv4 is enabled
+ (2017-03-31).
+ * net/: Fix MULTINIC/MULTILINK selection when 6loWPAN selected
+ (2017-03-31).
+ * net/: Permit net/neighbor to build when IPv6 is defined, but not
+ Ethernet. Needs more work to support 6loWPAN (2017-03-31).
+ * stm32f7: Serial fix for dropped data: (1) Revert the inherited dma
+ bug from the stm32. see
+ https://bitbucket.org/nuttx/nuttx/commits/df9ae3c13fc2fff2c21ebdb098c520b11f43280d
+
+ for details. And (2) Most all CR1-CR3 settings can not be configured
+ while UE is true. Threfore we make all operation atomic and disable
+ UE and restore it's originalstate on exit. From David Sidrane
+ (2017-03-31).
+ * stm32f7: stm32_sdmmc removed stray semicolon. From David Sidrane
+ (2017-03-31).
+ * 6loWPAN: Contiki 6loWPAN port is now complete (but completely
+ untested) (2017-04-02).
+ * iee802154 loopback: Eliminate dependency on CONFIG_NET_LOOPBACK
+ (2017-04-02).
+ * drivers/sensors: Add driver for ST LIS2DH accelerometer. From Timo
+ Voutilainen et al. via Juha Niskanen
+ (2017-04-03).
+ * net/socket/accept: Fix building with CONFIG_NET_LOCAL_STREAM. From
+ Jussi Kivilinna (2017-04-03).
+ * STM32: Fix IWDG and WWDG debug mode stop for STM32L15XX. From Juha
+ Niskanen (2017-04-03).
+ * STM32: Add STM32L162VE to chip.h. From Juha Niskanen (2017-04-03).
+ * iee802154 loopback: Eliminate dependency on CONFIG_NET_LOOPBACK
+ (2017-04-02).
+ * sim: Add a configuration for testing 6loWPAN (2017-04-03).
+ * wireless/ieee802154: Add initialization logic for loopback driver;
+ configs/sim: Add configuration for testing 6loWPAN; net/sixlowpan:
+ Fix for compilation with debug output enabled (2017-04-03).
+ * 6loWPAN: Updates/fixes from initial testing with the IEEE802.15.4
+ loopback driver (2017-04-03).
+ * STM32: Add I2C3 SDA pin mapping for STM32F411. From no1wudi
+ (2017-04-04).
+ * sensors: lis2dh: Fix hardfault when reading from unconfigured
+ sensor. From Juha Niskanen (2017-04-04).
+ * STM32: stm32_flash: Add EEPROM writing for STM32L15XX. From Juha
+ Niskanen (2017-04-04).
+ * 6loWPAN: Add option to dump buffers (2017-04-04).
+ * STM32: stm32l15xx_rcc: Add support for using MSI as system clock.
+ From Juha Niskanen (2017-04-05).
+ * STM32: stm32l15xxx_rcc: configure medium performance voltage range
+ and zero wait-state when allowed by SYSCLK setting. Zero wait-state
+ for flash can be configured when: (1) Range 1 and SYSCLK <= 16 Mhz,
+ (2) Range 2 and SYSCLK <= 8 Mhz, or (3) Range 3 and SYSCLK <= 4.2
+ Mhz. Medium performance voltage range (1.5V) can be configured when
+ SYSCLK is up to 16 Mhz and PLLVCO up to 48 Mhz. From Juha Niskanen
+ (2017-04-05).
+ * wireless/ieee802154: Initial MAC char driver write functionality.
+ From Anthony Merlino (2017-04-05).
+ * photon: wlan support. From Simon Piriou (2017-04-03).
+ * Document set [{+|-}{e|x|xe|ex}] [ ]. From David Sidrane
+ (2017-04-05).
+ * STM32: Fix SYSCFG_CFGR1_I2C_PBXFMP_SHIFT value. From Alan Carvalho
+ de Assis (2017-04-06).
+ * STM32F7: Serial: Add interface to get uart_dev_t by USART number,
+ stm32_serial_get_uart. From Jussi Kivilinna (2017-04-06).
+ * STM32F7: Default CONFIG_STM32F7_DMACAPABLE to 'n'. STM32F7 does not
+ have CCM RAM but DTCM, so this option does not need to enabled. DTCM
+ RAM is DMA-able through CPU AHBS bus. From Jussi Kivilinna
+ (2017-04-06).
+ * STM32F7: Fix UART7 and UART8 IFLOWCONTROL options. From Jussi
+ Kivilinna (2017-04-06).
+ * STM32F7: Add warning for RXDMA + IFLOWCONTROL combination.
+ Combination of RXDMA + IFLOWCONTROL does not work as one might
+ expect. Since RXDMA uses circular DMA-buffer, DMA will always keep
+ reading new data from USART peripheral even if DMA buffer underruns.
+ Thus this combination only does following: RTS is asserted on USART
+ setup and deasserted on shutdown and does not perform actual RTS
+ flow-control. Data loss can be demonstrated by doing long up_mdelay
+ inside irq critical section and feeding data to RXDMA+IFLOWCONTROL
+ UART. From Jussi Kivilinna (2017-04-06).
+ * sim/sixlowpan: Now supports apps/examples/udpblaster too (2017-04-06).
+ * SAMV7: Watchdog: Fix Forbidden Window Value. According the Datasheet
+ the WDD Value is the lower bound of a so called Forbidden Window and
+ to disable this we have to set the WDD Value greater than or equal to
+ the WDV Value. This seems to be a bug in the datasheet. It looks
+ like we have to set it to a greater value than the WDV to really
+ disable this Thing. When triggering the Watchdog faster than the
+ (very slow) clock source of the Watchdog fires, this Forbidden Window
+ Feature resets the System if WDD equals to WDV. This Changeset
+ disables the Forbidden Window by setting the WDD Value to the Maximum
+ (0xfff) Value possible. From Frank Benkert (2017-04-06).
+ * RTC: Add interface for check if RTC time has been set. New interface
+ allows checking if RTC time has been set. This allows to application
+ to detect if RTC has valid time (after reset) or should application
+ attempt to get real time by other means (for example, by launching
+ ntpclient or GPS). From Jussi Kivilinna (2017-04-06).
+ * 6loWPAN: Add network IOCTL support to set the node address
+ (2017-04-06).
+ * EFM32 I2C: Fix timeout calculation. From Masayuki Ishikawa
+ (2017-04-06).
+ * Disable serial console on stm32f103-minimum usbnsh example project
+ config. Devices enumerate after this change. From Bob Ryan
+ (2017-04-07).
+ * pthreads: Adding rwlock implementation. Adding an implementation for
+ read/write locks into the pthread library. These locks are writer
+ priority, such that if any writers come in they are given priority
+ for writing. From Mark Schulte (2017-04-07).
+ * pthread rwlock bugfixes. From Mark Schulte (2017-04-07).
+ * 6loWPAN: Add calculation of TCP header size. It is not a constant
+ (2017-04-07).
+ * Restore TCP_HDRLEN to MSS calculation. Also add to UDP MSS
+ calculation where it never appearred. Add some missing MSS and
+ RDVWNDO definitions for 6loWOPAN (2017-04-08).
+ * pthread.h: Remove duplicate, possible erroneous definition of
+ PTHREAD_MUTEX_INITIALIZER that crept in with some recent changes
+ (2017-04-08).
+ * pthread.h: Fix rwlock initializer. From Mark Schulte (2017-04-08).
+ * Add configuration/build support for an IEEE802.15.4 network device
+ (2017-04-08).
+ * Fix some old-style interrupt handling logic in drivers/net/skeleton.c
+ (2017-04-08).
+ * wireless/ieee802154: Add a implementation of the IEEE802.15.4
+ network driver. This is very incomplete on the initial commit
+ (2017-04-08).
+ * Buttons: Change return value of board_buttons() and the type of
+ btn_buttonset_t to uint32_t so that more than 8 buttons can be
+ supported (2017-04-09).
+ * Add support for NuttX controlled LEDS and for board_initialize.
+ Separate initialization logic to stm32_bringup.c so that in
+ initialization can occur either through board_initialize() or through
+ board_app_initialize(). Same as with most other newer board
+ configurations (2017-04-09).
+ * net procfs: Some long lines were being generated that cause
+ buffer-related problems and corrupted output (2017-04-09).
+ * stm32 COMP: Logic in stm32_comp.h must be configured on
+ CONFIG_STM32_COMP or otherwise it causes an error via #error on every
+ platform without COMP support (2017-04-09).
+ * Photon: Add logic to automatically mount the procfs file system on
+ startup. Fix some LED-related configuration conflicts (2017-04-09).
+ * Buttons: Correct some comments left after last button-related
+ change: 32- vs 8-bit bit set (2017-04-09).
+ * pthread: Use cancel cleanup handlers in rwlock. From Juha Niskanen
+ (2017-04-10).
+ * STM32F7: serial: disallow broken configuration combination of
+ CONFIG_STM32F7_FLOWCONTROL_BROKEN=y and
+ CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS not set. From Jussi Kivilinna
+ (2017-04-11).
+ * STM32F7: serial: do not stop processing input in SW flow-control
+ mode. From Jussi Kivilinna (2017-04-11).
+ * STM32XX: Fix Pending Register definition. From Alan Carvalho de
+ Assis (2017-04-11).
+ * Add logic to disable cancellation points within the OS. This is
+ useful when an internal OS function that is NOT a cancellation point
+ calls an OS function which is a cancellation point. In that case,
+ irrecoverable states may occur if the cancellation is within the OS.
+ From Juha Niskanen (2017-04-11).
+ * Fix LLVM libc++ undefined reference to __cxa_guard_*. From Alan
+ Carvalho de Assis (2017-04-11).
+ * libc/netdb: in dns_query_callback, ret != -EADDRNOTAVAIL condition
+ consumes error returns including EAGAIN in this case, dns query
+ retransmission doesn't work. From Ritajina (2017-04-12).
+ * STM32L4 DMA: Correct bad channel definition. From Sebastien Lorquet
+ (2017-04-12).
+ * TUN driver: Implement TAP (OSI layer 2) mode. Enable by setting the
+ IFF_TAP flag instead of the IFF_TUN flag in ifr_flags. From Thomas
+ Keh (2017-04-13).
+ * Adds USB host support to stm32f411-disco board. From Brian Webb
+ (2017-04-13).
+ * ieee802.15.4 radio: Add data structure definitions for Radio IOCTLs
+ (2017-04-13).
+ * ieee802.15.4 MAC: Add data structure definitions for MAC IOCTLs
+ (2017-04-13).
+ * ieee802154 radio: Implement IOCTL decode and dispatch in all radio
+ drivers (2017-04-13).
+ * drivers/net/skeleton.c: Add support for IOCTL handling (2017-04-13).
+ * ieee802.15.4 netdev: Add IOCTL support (2017-04-13).
+ * ieee802.15.4 radio: Remove interface methods that duplicate IOCTL
+ commands (2017-04-13).
+ * ieee802.15.4: de-couple MAC driver interface. Now works more like
+ other drivers (2017-04-13).
+ * sched: Fix tg_flags check with GROUP_FLAG_NOCLDWAIT. From Masayuki
+ Ishikawa (2017-04-14).
+ * Add basic support for STM32F0. From Alan Carvalho de Assis
+ (2017-04-14).
+ * Add stm32f0discovery board support. From Alan Carvalho de Assis
+ (2017-04-14).
+ * arch/arm/Kconfig: Add option for STM32F0 (2017-04-14).
+ * IEEE802.15.4: There is only one instance of the IEEE802.15.4 MAC
+ lower level. There is no need for the interface to be indirect via a
+ vtable. In this case, standard global functions should be used
+ (2017-04-14).
+ * ieee802.15.4: New global functions exported by the lower MAC layer
+ should be private to the MAC module. Function prototypes moved from
+ include/nuttx/wireless/ieee802154/ieee802154_mac.h to
+ wireless/ieee802154/mac802154.h (2017-04-14).
+ * radio802154_device.c now accesses the PHY layer via the IOCTL helper
+ functions (2017-04-14).
+ * photon: Add sdpcm + thread support for wlan. From Simon Piriou
+ (2017-04-13).
+ * Not a clean fix, but at least makes DHCP working with
+ CONFIG_NETDEV_MULTINIC. From Andreas Bihlmaier (2017-04-15).
+ * networking: IPv4 change of last PR should also be applied to
+ corresponding IPv6 logic (2017-04-15).
+ * 6loWPAN: Add some checks for the case where there are multiple
+ network devices and multiple link layer protocols (2017-04-15).
+ * net/: Add IOCTL support for forwarding IEEE802.15.4 MAC and PHY
+ IOCTLs (2017-04-15).
+ * Argument of network device IOCTL should be unsigned long, just as
+ will all other IOCTL methods (2017-04-15).
+ * wireless/ieee802154: Adds ability to receive notifications from MAC
+ char driver. From Anthony Merlino (2017-04-05).
+ * wireless/ieee802154/mrf24j40: Added bind method. From Anthony
+ Merlino (2017-04-15).
+ * wireless/ieee802154: Starts adding MAC request data functionality.
+ From Anthony Merlino (2017-04-15).
+ * wireless/ieee802154: Starts defining interface between PHY layer and
+ next highest layer. From Anthony Merlino (2017-04-15).
+ * wireless/ieee802154: Skeleton code for request associate. From
+ Anthony Merlino (2017-04-15).
+ * wireless/ieee802154: Bind MAC phyif to radio. From Anthony Merlino
+ (2017-04-15).
+ * STM32: Provide TIM5 definition for STM32F429. From Matias v01d
+ (2017-04-15).
+ * photon: Add sdpcm tx basic support. From Simon Piriou (2017-04-16).
+ * photon: Request firmware version and MAC address. From Simon Piriou
+ (2017-04-16).
+ * 6loWPAN network driver: Still only a skeleton but has some added
+ thought experimentation (2017-04-16).
+ * 6loWPAN: Correct ordering of headers. fragmentation header was
+ coming out before FCF (2017-04-16).
+ * wireless/ieee802154: Continues development on transmit structure.
+ From Anthony Merlino (2017-04-17).
+ * STM32F0: Enable the clock for all GPIO ports. From Alan Carvalho de
+ Assis (2017-04-17).
+ * STM32F0: Fix HSI clock definition. From Alan Carvalho de Assis
+ (2017-04-17).
+ * STM32F0: Fix System Clock value to 48MHz and remove MCLK
+ definition. From Alan Carvalho de Assis (2017-04-17).
+ * Update coding standard document to discuss un-named structure fields
+ (2017-04-17).
+ * STM32F0: Add basic support for STM32F07x family (2017-04-17).
+ * STM32F0: Move enabling of GPIO peripherals form UART setup to
+ clockconfig. This is not a UART function. It is needed by all
+ peripherals (2017-04-xx).
+ * STM32F0: Add logic to enable other USARTs. No UART4/5. Rather
+ USART4/5 (2017-04-17).
+ * STM32F7: Warn if no DMA2 configured when using ADC with DMA. Also
+ correct ADC channel numbers that DMA callback passes to upper half
+ driver. From Juha Niskanen (2017-04-18).
+ * STM32F7: stm32_adc: Do not override ADCPRE_DIV when measuring
+ internal voltage. From Juha Niskanen (2017-04-18).
+ * Move CONFIG_ADC_NO_START_CONV from drivers/adc/Kconfig to
+ arch/arm/src/stm32[f7]/Kconfig as STM32[F7]_ADC_NO_START_CONV.
+ Refresh all configurations with any reference to
+ CONFIG_ADC_NO_START_CONV (2017-04-18).
+ * STM32F0: The STM32F2 does not have use alternate function groupings
+ as does the F1. Rather, it is like other members of the STM32 family
+ with An alternate setting AF0-AF7 for each pin (2017-04-18).
+ * Nucleo-F072RB: Add board configuration (2017-04-18).
+ * wireless/ieee802154: Lots of small fixes to eliminate build issues.
+ Generally cleans things up and fixes lots of small issues preventing a
+ successful build. Does not completely build, but there are
+ significantly less errors. From Anthony Merlino (2017-04-18).
+ * Coding standard: Defining structures within the scope of another
+ structure is discouraged (2017-04-18).
+ * Nucleo-F072RB: Enable board_app_inititalize, procfs, and built-in
+ functions (2017-04-19).
+ * wireless/ieee802154: Simplifies MAC callback interface. Adds
+ missing data type definitions. From Anthony Merlino (2017-04-19).
+ * wireless/ieee802154: Renames mac802154_devwrapper_s to
+ mac802154_chardevice_s. From Anthony Merlino (2017-04-19).
+ * wireless/ieee802154: Changes radio interface to match MAC callback
+ design. From Anthony Merlino (2017-04-19).
+ * 6loWPAN: Fix a missing source address in header. Correct
+ calculation of payload size (2017-04-19).
+ * SAMV7 EMAC: Add conditional logic to account the fact that the
+ SAMV71 has 6 rather than 3 queues after version 1. From Ian McAfee
+ (2017-04-19).
+ * wireless/ieee802154: Starts structuring transmission completion
+ handling. From Anthony Merlino (2017-04-19).
+ * 6loWPAN: Add an IOCTL to set the IEEE802.15.4 PAN ID (2017-04-19).
+ * STM32 L1: stm32l15xx_rcc: Allow board to configure HSE clock in
+ bypass-mode. Allows using MCO output from ST-link chip (on Nucleo
+ and Discovery boards) as HSE input. From Juha Niskanen (2017-04-20).
+ * Add support for STM32L152CC, STM32L152RC and STM32L152VC. Update
+ some bits and comments for other STM32L1 parts in chip.h. From Juha
+ Niskanen (2017-04-20).
+ * UART 16550: Missing left parenthesis in function prototype. This is
+ Bitbucket Issue #41 (2017-04-20).
+ * procfs: Fix wrong member IDs are displayed when 'cat
+ /proc//group/status'. From Nobutaka Toyoshima (2017-04-28).
+ * STM32F0: Add support for HSI48 (2017-04-20).
+ * STM32F0: Add an untested port of the F1 USB device to the STM32F0
+ (2017-04-20).
+ * Move include/nuttx/net/iob.h to include/drivers/iob.h; rename
+ CONFIG_NET_IOB to CONFIG_DRIVERS_IOB (2017-04-20).
+ * Move net/iob to drivers/iob so that the I/O buffering feature can be
+ available to other drivers when networking is disabled (2017-04-20).
+ * VFS poll(): Add some error handling logic (2017-04-20).
+ * Add support for the STM32F09X family. From Juha Niskanen (2017-04-21).
+ * clock: Add clock_resynchronize and use subseconds RTC. Add
+ clock_resynchronize for better synchronization of CLOCK_REALTIME and
+ CLOCK_MONOTONIC to match RTC after resume from low-power state. Add
+ up_rtc_getdatetime_with_subseconds under
+ CONFIG_ARCH_HAVE_RTC_SUBSECONDS to allow initializing (and
+ resynchronizing) system clock with subseconds accuracy RTC. From
+ Jussi Kivilinna (2017-04-21).
+ * clock: Add new type ssystime_t for relative 64-bit ticks, change
+ ticks<->time conversion functions to use ssystime_t. From Jussi
+ Kivilinna (2017-04-21).
+ * clock: add testing for 32-bit overflow of 64-bit system timer. From
+ Jussi Kivilinna (2017-04-21).
+ * wireless/ieee802154: Simplifies TX completion interface. Documents
+ and cleans up some functions. From Anthony Merlino (2017-04-21).
+ * Remove the 6loWPAN PANID IOCTLs they are redundant (2017-04-21).
+ * 6loWPAN: Remove the PAN ID from the 6loWPAN data structure. This is
+ owned by the radio driver. Rather, use an IOCTL to obtain the PAN ID
+ from the downstream radio driver (2017-04-21).
+ * photon: Add basic wlan scan function. From Simon Piriou (2017-04-22).
+ * 6loWPAN: Separate MAC-related definitions from sixlowpan.h. Put in
+ ieee802154.h (2017-04-22).
+ * net/: network drver now retains Ethernet MAC address in a union so
+ that other link layer addresses may be used in a MULTILINK
+ environment (2017-04-22).
+ * 6loWPAN: Add IEEE802.15.4 Rime address to union of link layer
+ addresses in the network driver (2017-04-22).
+ * SAM3/4: Fixed configurations for TWI master. Obviously an
+ incomplete port from SAMA5 (2017-04-23).
+ * SAM3/4: Remove inappropriate semicolon. From kc_dtm (2017-04-23).
+ * configs/photon: Add DOWNLOAD function to upload firmware through
+ DFU. From Simon Piriou (2017-04-23).
+ * drivers/ieee80211/: Change all occurrences of _info, _warn, and _err
+ to wlinfo, wlwarn, and wlerr (2017-04-23).
+ * USBMSC: Fix a wrong lun number issue. From Masayuki Ishikawa
+ (2017-04-24).
+ * sched: Fix CHILD_FLAG_EXITED in include/nuttx/sched.h. From
+ Masayuki Ishikawa (2017-04-24).
+ * wireless/ieee80211: Add skeleton for a broadcom network driver
+ (2017-04-24).
+ * wiress/ieee80211: Broadcom network driver needs to register as an
+ ieee802.11 driver, not an Ethernet driver (2017-04-24).
+ * wireless/ieee80211: Add broadcom network device registration logic
+ (2017-04-24).
+ * drivers/wireless/bcmf: Register network driver + update defconfig
+ file. From Simon Piriou (2017-04-24).
+ * procfs: Fix incorrect uptime with CONFIG_SYSTEM_TIME64. From
+ Masayuki Ishikawa (2017-04-25).
+ * configs/photon/wlan: Minor config changes to get a clean build
+ (2017-04-25).
+ * STM32L4: Add support for the STM32L496XX family. From Juha Niskanen
+ (2017-04-25).
+ * configs/photon: Rename ld.script to photon_jtag.ld for symmetry
+ (2017-04-25).
+ * configs/photon/src/stm32_wlan.c: Remove unused, inappropriate
+ network driver registration (2017-04-25).
+ * netdev_register: If there is only one ieee80211 and both
+ CONFIG_ETHERNET and CONFIG_DRIVERS_IEEE8011, then use the wlan0
+ naming, not the eth0 naming (2017-04-25).
+ * configs/nucle-f072rb/nsh: Correct amount of available SRAM in
+ defconfig (2017-04-26).
+ * CONFIG_DEBUG_HARDFAULT should be available for Cortex-M0 too
+ (2017-04-26).
+ * drivers/wireless/bcmf: Enable DMA for SDIO transfers. From Simon
+ Piriou (2017-04-26).
+ * configs: Remove all setenv.bat files. Remove all references to
+ setenv.sh and setenv.bat from all config README files (2017-04-26).
+ * drivers/syslog: Use monotonic clock for timestamp when available.
+ From Jussi Kivilinna (2017-04-26).
+ * Enable wireless IOCTL commands in photon/wlan configuration
+ (2017-04-26).
+ * Network IOCTLs: Correct a compilation error when wireless IOCTLs are
+ enabled (2017-04-26).
+ * binfmt/elf: Fix offset value when calling elf_read() in
+ elf_symname(). From Masayuki Ishikawa (2017-04-26).
+ * STM32, STM32F7, STM32L4: Remove incorrect comment about STM32L1
+ LSE/RTC/LCD. From Juha Niskanen (2017-04-27).
+ * STM32L4: Add some defines for the new peripherals in STM32L496
+ parts. From Juha Niskanen (2017-04-27).
+ * STM32F0: Fix some missing settings in the clock configuration logic
+ (2017-04-27).
+ * IOCTLS. Separate wireless character driver IOCTL commands from
+ wireless network driver IOCTL commands. Move from wireless.h to
+ ioctl.h (2017-04-27).
+ * IEEE 802.15.4: Move MAC character driver IOCTL commands from
+ ieee802154_mac.h to ieee802154_ioctl.h (2017-04-27).
+ * Wireless IOCTLs: Correct use of _WLIOC where _WLCIOC is required
+ (2017-04-27).
+ * net/socket: Fix cloning of local and raw sockets. From Jussi
+ Kivilinna (2017-04-28).
+ * STM32L4: stm32l4_i2c: Add I2C4 code. From Juha Niskanen (2017-04-28).
+ * STM32L4: I2C was not using current interrupt handling parameter
+ passing logic (2017-04-28).
+ * vfs/poll: round timeout up to next full tick. Calling poll() with
+ timeout less than half tick (thus MSEC2TICK(timeout) => 0) caused
+ returning error with EAGAIN. Instead of rounding timeout down, value
+ should be rounded up. Open Group spec for poll says:
+ "Implementations may place limitations on the granularity of timeout
+ intervals. If the requested timeout interval requires a finer
+ granularity than the implementation supports, the actual timeout
+ interval will be rounded up to the next supported value." From Jussi
+ Kivilinna (2017-04-28).
+ * In last change to poll(), converted timeout to unsigned to eliminate
+ the possibility of overflow of signed overflow (2017-04-28).
+ * drivers/wireless/bcmf: Add escan ioctls support + cleanup. From
+ Simon Piriou (2017-04-28).
+ * Add all network IOCTLs to include/sys/ioctl.h (2017-04-28).
+ * Add all ieee802.15.4 IOCTLs to include/sys/ioctl.h (2017-04-28).
+ * 6loWPAN: Can't reuse same header on each fragment. DSN needs to
+ increment (2017-04-29).
+ * SPI: Add an instance argument to the SPIDEV definitions (2017-04-29).
+ * STM32F0: Add some protection. There is only one interrupt for
+ USART3-8. Current interrupt handling logic will support only one
+ interrupt in that range (2017-04-29).
+ * STM32F0 I2C: Initial cut at driver. Still a work in progress. From
+ Alan Carvalho de Assis (2017-04-29).
+ * STM32F33: Add OPAMP support. From Mateusz Szafoni (2017-04-30).
+ * drivers/analog: Add basic OPAMP driver. From Mateusz Szafoni
+ (2017-04-30).
+ * Nucleo-F334R8: Add OPAMP support. From Mateusz Szafoni (2017-04-30).
+ * Nucleo-F072RB: Add support for the I2C driver used by I2C tools
+ (2017-04-20).
+ * drivers/i2c: Fix compile issus if CONFIG_DISABLE_PSEUDOFS_OPERATIONS
+ is enabled (2017-04-xx).
+ * STM32F0 I2C: Update driver to use the standard interrupt parameter
+ passing logic (2017-04-30).
+ * STM32F0 I2C: Pin definitions should specify open drain (and probably
+ 50Mhz) (2017-04-30).
+ * EFM32, STM32, and STM32 F7 I2C: Update to use the standard parameter
+ passing to interrupt handlers (2017-04-30).
+ * drivers/wireless/bcmf: Add netdev support for Broadcom FullMAC
+ driver. From Simon Piriou (2017-04-30).
+ * Tiva I2C: Update to use the standard parameter passing to interrupt
+ handlers (2017-04-30).
+ * ieee802.11: Bring some BSD licensed header files in from FreeBSD
+ (2017-04-30).
+ * Clicker2-STM32: Add protected build knsh configuration (2017-05-01).
+ * STM32F0: Fix I2C frequency table. From Alan Carvalho de Assis
+ (2017-05-01).
+ * STM32F0: I2C frequency quantization. Add logic to get closer if an
+ oddball frequency is used (2017-05-01).
+ * pthread: Fix compilation error on pthread_cond_wait when
+ CONFIG_CANCELLATION_POINTS and CONFIG_PTHREAD_MUTEX_UNSAFE are
+ enabled. From EunBong Song (2017-05-02).
+ * binfmt/elf: Fix offset value when calling elf_read() in
+ elf_sectname(). From Masayuki Ishikawa (2017-05-02).
+ * configs: Add nucleo-l496zg board files. From Juha Niskanen
+ (2017-05-02).
+ * configs: Add nucleo-f091rc board files. From Juha Niskanen
+ (2017-05-02).
+ * STM32L4: Don't think these chips have DPFPU, DTCM or ITCM. From
+ Juha Niskanen (2017-05-02).
+ * STM32L4: Add GPIO_PORTI definition. From Juha Niskanen (2017-05-02).
+ * STM32L4: Delete more references to DFPU, ITCM, and DTCM (2017-05-02).
+ * wireless/ieee802154: Changes transmit data path to use IOBs and
+ exposes function for getting size of MAC header. From Anthony
+ Merlino (2017-05-02).
+ * Extend wireless.h with definitions needed by wext. From Simon Piriou
+ (2017-05-02).
+ * drivers/wireless/bcmf: implement basic wext interface for
+ authentication. From Simon Piriou (2017-05-02).
+ * First attempt at a nucleo-l432kc board. From Sebastien Lorquet
+ (2017-05-02).
+ * STM32F7: Flash: macro naming errors, there is no FLASH_CONFIG_F for
+ F7. From Juha Niskanen (2017-05-02).
+ * STM32L4: stm32l4x6xx_pinmap: Update I2C4 and DCMI pins. From Juha
+ Niskanen (2017-05-02).
+ * 6loWPAN: Add basic call path to interface with the MAC layer through
+ the MAC network driver. Logic has not yet been implemented. This is
+ just a structural change in preparation for additional changes
+ (2017-05-02).
+ * wireless/ieee802154: Sets up default PIB attributes. From Anthony
+ Merlino (2017-05-02).
+ * wireless/ieee802154: Finishes some IOCTL logic for MAC layer. From
+ Anthony Merlino (2017-05-02).
+ * 6loWPAN: Changes to use new MAC interfaces. Incomplete and needs
+ some clean-up of dangling, unused definitions (2017-05-03).
+ * wireless/ieee802154: Starts work on setting PIB attributes. From
+ Anthony Merlino (2017-05-03).
+ * 6loWPAN: Fixes hang in loopback test (2017-05-03).
+ * drivers/wireless/bcmf: Fix frame not freed when dropped + cleanup.
+ From Simon Piriou (2017-05-03).
+ * STM32L4: stm32l4_i2c: Change wrong macro to CONFIG_I2C_POLLED. From
+ Juha Niskanen (2017-05-04).
+ * STM32L4: modularize Kconfig to support different product
+ lines/families. This is modeled after STM32F7. Idea is to declare
+ each chip in Kconfig but allow for flash size override. Commit adds
+ many STM32L4_HAVE_XXX feature test macros. From Juha Niskanen
+ (2017-05-02).
+ * STM32L4: Changes needed for STM32L452 and Nucleo-L452RE board. GPIO
+ and UART seem similar across STMicro product matrix, so renamed files
+ accordingly. RCC is cloned just in case, while conflicting
+ differences there seem to be very minor. From Juha Niskanen
+ (2017-05-02).
+ * STM32L4: Flash: update override config macros and add
+ FLASH_CONFIG_B. From Juha Niskanen (2017-05-02).
+ * configs: Add nucleo-l452re board files. From Juha Niskanen
+ (2017-05-04).
+ * fixedmath: Add square root and b32_t conversion operators. From
+ Jussi Kivilinna (2017-05-04).
+ * Fix STM32F7 I2C interrupt handler. From Jussi Kivilinna (2017-05-04).
+ * STM32F7 serial: Allow configuring Rx DMA buffer size. From Jussi
+ Kivilinna (2017-05-04).
+ * 6loWPAN: Replace Rime address naming with more consistent
+ short/exended address terminology (2017-05-04).
+ * 6loWPAN: Remove all ieee802.15.4 MAC knowledge from 6loWPAN. Now
+ relies on wires/ieee802154 for all MAC-related operations (2017-05-04).
+ * 6loWPAN: Local address length is fixed by the configuration. The
+ remote address be with short or extended (2017-05-04).
+ * STM32L4: Separate SYSCFG into product line specific files for
+ clarity. From Juha Niskanen (2017-05-05).
+ * STM32L4: firewall for stm32l4x3xx. Not tested for any product
+ family, but now it at least compiles. L496 devices can have one bit
+ wider Volatile Data Segment. From Juha Niskanen (2017-05-05).
+ * STM32L4: Add more chips to Kconfig. This also removes
+ DPFPU/DTCM/ITCM features again, fixing a recent git history hickup.
+ From Juha Niskanen (2017-05-05).
+ * configs/nucleo-l496zg: Kconfig was copied from nucleo-144. Removed
+ as most options have not been tested. From Juha Niskanen (2017-05-05).
+ * nucleo-144: Default for choice in Kconfig was not one of the
+ possible choices (2017-05-05).
+ * Kinetis: Add TPM to K66 chip. From David Sidrane (2017-05-05).
+ * Kinetis: Fixed CLKSRC Bit Names. From David Sidrane (2017-05-05).
+ * Kinetis: Add OSC_DIV to the kinetis_osc header. From David Sidrane
+ (2017-05-05).
+ * Kinetis: Use optional BOARD_OSC_CR and BOARD_OSC_DIV in clock
+ configuration. From David Sidrane (2017-05-05).
+ * Kinetis: Added HW flow control and termios. From David Sidrane
+ (2017-05-05).
+ * wireless/ieee802154: Changes rxenable at radio layer. From Anthony
+ Merlino (2017-05-03).
+ * wireless/ieee802154: Finishes promiscuous mode IOCTL. From Anthony
+ Merlino (2017-05-03).
+ * wireless/ieee802154: Removes radio IOCTL. Starts bringing radio and
+ MAC closer with well-defined interface. From Anthony Merlino
+ (2017-05-05).
+ * STM32L4: Add support for many new MCUs from STM32L4X3XX product line
+ and Nucleo-L452 board. From Juha Niskanen (2017-05-05).
+ * 6loWPAN: Use information in struct ieee802154_data_ind_s when
+ reassembling a packet (2017-05-05).
+ * ieee 802.15.4: Add a pool-based memory allocator for RX frame
+ meta-data (2017-05-05).
+ * kinetis k66, k64, k60, k40, k20: Pin mux configure all I2C signals as
+ Open Drain. The output structure of the GPIO for I2C needs to be
+ open drain. When left at the default, one can observe on a scope the
+ slave contending with the push-pull during the ACK. From David
+ Sidrane (2017-05-05).
+ * wireless/ieee802154: Removes msdu_length from meta-data since it is
+ intrinsically in the IOB. From Anthony Merlino (2017-05-06).
+ * wireless/ieee802154: Reworks data_ind allocation to include IOB
+ allocation/deallocation. Hides private data. From Anthony Merlino
+ (2017-05-05).
+ * wireless/ieee802154: Completes Rx data flow through MAC layer to
+ callback. From Anthony Merlino (2017-05-06).
+ * Kinetis: Add ARCH_HAVE_I2CRESET. From David Sidrane (2017-05-06).
+ * Reworks data_ind allocation to include IOB allocation/deallocation.
+ Hides private data. From Anthony Merlino (2017-05-06).
+ * STM32: Serial Allow configuring Rx DMA buffer size. From David
+ Sidrane (2017-05-06).
+ * 6loWPAN: Minor cleanup and re-verification of all compression modes
+ after so many recent changes (2017-05-06).
+ * Update the C coding standard document (2017-05-06).
+ * IEEE 802.15.4 network driver. Remove support for multicast address
+ filtering; doesn't work that way on an IEEE 802.15.4 network
+ (2017-05-08).
+ * STM32: Serial DMA buffer round off not up. From David Sidrane
+ (2017-05-08).
+ * STM32 TIM: Add method to get timer width. Freerun timer: Use timer
+ width to get the correct clock rollover point (2017-05-08).
+ * wireless/ieee802154: Finishes MAC processing of received data frame.
+ From Anthony Merlino (2017-05-08).
+ * wireless/ieee802154: Finishes MAC char driver read functionality.
+ From Anthony Merlino (2017-05-08).
+ * wireless/ieee802154: MRF24J40: Finishes receive functionality,
+ supports promicuous mode, and rxonidle attributes. From Anthony
+ Merlino (2017-05-08).
+ * wireless/ieee802154: Completes basic receive functionality. From
+ Anthony Merlino (2017-05-08).
+ * Final fixes to get the nucleo-l432kc config build. Execution not
+ tested yet. From Sebastien Lorquet (2017-05-09).
+ * Adapt stm32l43x pin definitions. From Sebastien Lorquet (2017-05-09).
+ * More unbuilt stm32 -> stm32l4 changes. From Sebastien Lorquet
+ (2017-05-09).
+ * Restore settings for UARTs 4 and 5. From Sebastien Lorquet
+ (2017-05-09).
+ * IOBs: Move from driver/iob to a better location in mm/iob
+ (2017-05-09).
+ * STM32L4: Add dbgmcu header files. From Juha Niskanen (2017-05-09).
+ * wireless/ieee802154: Fixes missing handle of read/write being able to
+ be interrupted. From Anthony Merlino (2017-05-09).
+ * wireless/ieee802154: Starts implementing START.request primitive.
+ From Anthony Merlino (2017-05-09).
+ * drivers/serial: I discovered a problem in the file
+ drivers/serial/serial.c concerning the function uart_close(…). In the
+ case that a serial device is opened with the flag O_NONBLOCK the
+ function uart_close(…) blocks until all data in the buffer is
+ transmitted. The function close(…) called on an handle opened with
+ O_NONBLOCK should not block. The problem occurred with a CDC/ACM
+ device. From Stefan Kolb (2017-05-10).
+ * mtd/config: erase block between block read and write. From Juha
+ Niskanen (2017-05-10).
+ * Moved LIS3DSH from the I2C-dependent block to the SPI-block to make
+ Make.defs consistent with the driver (SPI only) and
+ drivers/sensors/Kconfig. From Floxx (2017-05-10).
+ * syslog: Add option to buffer SYSLOG output to avoid interleaving
+ (2017-05-10).
+ * syslog buffering: Use IOBs to buffer data, not an on-stack buffer
+ (2017-05-10).
+ * STM32L4: Add internal flash write support. From Juha Niskanen
+ (2017-05-11).
+ * When syslog message has addition characters after last new-line. With
+ buffering those now get lost as vsyslog does not flush output after
+ lib_sprintf. Additional trailing characters could be ANSI escape
+ sequence to reset state that message setups. For example, macro here
+ uses colors and resets state after actual message (including '\n'):
+ With flushing added to vsyslog, then there is problem that next
+ syslog line might come from other task before reset sequence, causing
+ wrong line getting color. This could be avoided by not flushing on
+ '\n' but only if IOB is full and/or at end of vsyslog. Would this
+ make sense?. From Jussi Kivilinna (2017-05-11).
+ * Syslog: Need inclusion of errno.h for fix building with
+ CONFIG_SYSLOG_TIMESTMAP=y (2017-05-11).
+ * mtd: Build RAMTRON and AT45DB drivers only if selected. From Juha
+ Niskanen (2017-05-11).
+ * mtd/config: Fix byte read interface test. From Juha Niskanen
+ (2017-05-11).
+ * mtd: Fix some unallocated and NULL pointer issues. rwb->wrflush and
+ rwb->wrmaxblocks in rwbuffer could get unallocated values from
+ ftl_initialize() in some configurations. Also fixes related assert:
+
+ up_assert: Assertion failed at file:rwbuffer.c line: 643
+
+ that can happen with the following configuration:
+
+ CONFIG_FTL_WRITEBUFFER=y
+ CONFIG_DRVR_WRITEBUFFER=y
+ # CONFIG_FS_WRITABLE is not set
+
+ These problems are caused by CONFIG variable differences between the
+ buffer layers. TODO: This is not a perfect solution. readahead
+ support has similar issues. From Juha Niskanen (2017-05-11).
+ * STM32L4: port stm32l4_serial_get_uart function from STM32F7. From
+ Juha Niskanen (2017-05-12).
+ * syslog: Avoid flushing syslog_stream buffer, if possible, until
+ lib_vsprintf() completely parses the format. This assures that the
+ flush will flush the entire output, even data that may potentially
+ follow the linefeed. And, in that case, it cannot be interleaved
+ with other devug output. Suggested by Jussi Kivilinna (2017-05-12).
+ * syslog: There is yet another place where the output can get split.
+ That is in syslog_dev_write(): It will break up the stream to insert
+ a CR before the LF. This can that can be avoid be generating the
+ CR-LF sequence in the buffer and then detecting and ignoring valid
+ CR-LF sequences, rather than expecting syslog_dev_write() to insert
+ the CR in this case. I don't like the idea that syslog_dev_write()
+ still scans the entire output buffer to expand CR-LF sequence. This
+ seems really wasteful, especially in this case where we can be sure
+ that the is no CR or LF without a matching LF or CR. Bu, I think,
+ the existing behavior in syslog_dev_write() must be retained because
+ it is needed in other contexts (2017-05-12).
+ * Bitbucket Issue 47: Some of last syslog changes needed to be
+ condition on #ifdef CONFIG_SYSLOG_BUFFER in order to be built without
+ syslog buffering enabled (2017-05-12).
+ * Move CAN subsystem to its own directory and put device drivers
+ there. From Alan Carvalho de Assis (2017-05-12).
+ * locale.h: Add a bogus definition of locale_t. From (2017-05-12).
+ * kinetis K66: Fixed TMP2_CH1 definition. From David Sidrane
+ (2017-05-12).
+ * kinetis K66: Define ALT1 to match ref manual. From David Sidrane
+ (2017-05-12).
+ * kinetis K66: GPIO and pin mux cleanup. From David Sidrane
+ (2017-05-13).
+ * STM32F410: Add support for STM32F410. STM32F410 is a version of
+ STM32F4 with 32 KB of RAM and 62 or 128 KB of flash. From Gwenhael
+ Goavec-Merou (2017-05-13).
+ * Kconfig/deconfigs: Add CONFIG_ARCH_TOOLCHAIN_GNU to indicate that
+ the toolchain is based on GNU gcc/as/ld. This is in addition to the
+ CPU-specific versions of the same definition (2017-05-13).
+ * Remove CONFIG_ARM_TOOLCHAIN_GNU; replace with
+ CONFIG_ARCH_TOOLCHAIN_GNU (2017-05-13).
+ * Tiva I2C: Correct an error in conditional compilation (2017-05-13).
+ * Kconfig: Rename CONFIG_ARM_TOOLCHAIN_IAR to
+ CONFIG_ARCH_TOOLCHAIN_IAR (2017-05-13).
+ * Move prototype for up_cxxinitialize() from nuttx/include/nuttx/arch.h
+ to apps/include/platform/cxxinitialize.h (2017-05-13).
+ * libc/wchar: Versions mbrlen and mbsrtowcs taken and adapted from
+ FreeBSD code (at https://github.com/freebsd/freebsd/). From Matias
+ v01d (2017-05-13).
+ * tcp: wait for 3-Way Handshare before accept() returns. From Simon
+ Piriou (2017-05-14).
+ * configs/photon/wlan: disable network logs and add nsh over telnet.
+ From Simon Piriou (2017-05-14).
+ * TCP: Send RST if applicaiton 'unlistens()' before we complete the
+ connection sequence (2017-05-14).
+ * drivers: fix some bad NULL checks. From Juha Niskanen (2017-05-15).
+ * drivers: rename newly introduced up_i2creset to I2C_RESET. From
+ Juha Niskanen (2017-05-15).
+ * TCP: An RST received during the 3-way handshake requires a little
+ more clean-up (2017-05-15).
+ * STM32 CAN: I had the problem that the transmit FIFO size (= actual
+ elements in FIFO) was slowly increasing over time, and was full after
+ a few hours. The reason was that the code hit the line
+ "canerr("ERROR: No available mailbox\n");" in stm32_cansend, so
+ can_xmit thinks it has sent the packet to the hardware, but actually
+ has not. Therefore the transmit interrupt never happens which would
+ call can_txdone, and so the size of the FIFO size does not decrease.
+ The reason why the code actually hit the mentioned line above, is
+ because stm32can_txready uses a different (incomplete) condition than
+ stm32can_send to determine if the mailbox can be used for sending,
+ and thus can_xmit forwards the packet to stm32can_send.
+ stm32can_txready considered mailboxes OK for sending if the mailbox
+ was empty, but did not consider that mailboxes may not yet be used if
+ the request completed bit is set - stm32can_txinterrupt has to
+ process these mailboxes first. Note that I have also modified
+ stm32can_txinterrupt - I removed the if condition, because the CAN
+ controller retries to send the packet until it succeeds. Also if the
+ condition would not evaluate to true, can_txdone would not be called
+ and the FIFO size would not decrease also. From Lederhilger Martin
+ (2017-05-16).
+ * drivers/bch: BCH character driver bch_ioctl() always returns -ENOTTY
+ for DIOC_GETPRIV command. It should returns OK if DIOC_GETPRIV
+ command succeeds. From EunBong Song (2017-05-16).
+ * There can be a failure in IOB allocation to some asynchronous
+ behavior caused by the use of sem_post(). Consider this scenario:
+ (1) Task A holds an IOB. There are no further IOBs. The value of
+ semcount is zero. Task B calls iob_alloc(). Since there are not
+ IOBs, it calls sem_wait(). The value of semcount is now -1. (2)
+ Task A frees the IOB. iob_free() adds the IOB to the free list and
+ calls sem_post() this makes Task B ready to run and sets semcount to
+ zero NOT 1. There is one IOB in the free list and semcount is zero.
+ When Task B wakes up it would increment the sem_count back to the
+ correct value. (3) But an interrupt or another task runs occurs
+ before Task B executes. The interrupt or other tak takes the IOB off
+ of the free list and decrements the semcount. But since semcount is
+ then < 0, this causes the assertion because that is an invalid state
+ in the interrupt handler. So I think that the root cause is that
+ there the asynchrony between incrementing the semcount. This change
+ separates the list of IOBs: Currently there is only a free list of
+ IOBs. The problem, I believe, is because of asynchronies due
+ sem_post() post cause the semcount and the list content to become out
+ of sync. This change adds a new 'committed' list: When there is a
+ task waiting for an IOB, it will go into the committed list rather
+ than the free list before the semaphore is posted. On the waiting
+ side, when awakened from the semaphore wait, it will expect to find
+ its IOB in the committed list, rather than free list. In this way,
+ the content of the free list and the value of the semaphore count
+ always remain in sync (2017-05-16).
+ * stm32_serial: Fix freezing serial port. Serial interrupt
+ enable/disable functions do not disable interrupts and can freeze
+ device when serial interrupt is received while execution is at those
+ functions. Trivially triggered with two or more threads write to
+ regular syslog stream and to emergency stream. In this case, freeze
+ happens because of mismatch of priv->ie (TXEIE == 0) and actually
+ enabled interrupts in USART registers (TXEIE == 1), which leads to
+ unhandled TXE interrupt and causes interrupt storm for USART. From
+ Jussi Kivilinna (2017-05-17).
+ * STM32 Ethernet: Add support for KSZ8081 PHY interrupts. From
+ Sebastien Lorquet (2017-05-17).
+ * IPv6: Fix net_ipv6_pref2mask(). From Masayuki Ishikawa (2017-05-18).
+ * net procfs: Fix buffer corruption and refactor netdev_statistics.c.
+ From Masayuki Ishikawa (2017-05-19).
+ * binfmt: Fix .dtor memory allocation. From Masayuki Ishikawa
+ (2017-05-19).
+ * stm32_i2c: make private symbols static. From Juha Niskanen
+ (2017-05-19).
+ * network IOCTL commands: The only place in net/netdev/netdev_ioctl.c
+ where the interface state should change is for SIOCSIFFLAGS. The
+ other ones .. SIOCSIFADDR, SIOSLIFADDR, SIODIFADDR .. should not
+ change the link state. From Sebastien Lorquet (2017-05-19).
+ * drivers/wireless/ieee80211: Add support for AP scanning. From Simon
+ Piriou (2017-05-21).
+ * drivers/audio: Add cs43l22 audio driver STM32F4: Add I2S driver.
+ From Taras Drozdovsky (2017-05-21).
+ * This is based on a patch by Taras Drozdovsky. Basically, the delay
+ that was added during the integration of the CDC/ACM host driver was
+ interfering with streaming audio. That delay was put there to
+ prevent build endpoints from hogging the system bandwidth. So what
+ do we do? Do we hog the bandwidth or do we insert arbitrarity
+ delays. I think both ideas such (2017-05-21).
+ * Replace sprintf() with snprintf() in pipe.c. From Nobutaka Toyoshima
+ (2017-05-22).
+ * drivers/bch: Fix 'Missing Unlock' in bchdev_driver.c. From Masayuki
+ Ishikawa (2017-05-22).
+ * FAT: Fix 'Missing unlock' in fs_fat32.c. From Masayuki Ishikawa
+ (2017-05-22).
+ * netdb: Fix time info in lib_dnscache.c. From Masayuki Ishikawa
+ (2017-05-23).
+ * STM32L4: Add IWDG peripheral. This is the same as for STM32 except
+ that prescale and reload can be changed after watchdog has been
+ started, as this seems to work on L4. From Juha Niskanen (2017-05-23).
+ * drivers/can: Add Microchip MCP2515 CAN Bus controller driver. From
+ Alan Carvalho de Assis (2017-05-23).
+ * button_upper: Fix interrupt enabling for poll-events. From Jussi
+ Kivilinna (2017-05-24).
+ * netdb: Fix bugs in lib_gethostbynamer.c. This fix sets h_name in
+ struct hostent returned by gethostbyname(). From Masayuki Ishikawa
+ (2017-05-25).
+ * TCP: Fix tcp_findlistner() in dual stack mode. From Masayuki
+ Ishikawa (2017-05-25).
+ * TCP: tcp_input() now receives IP domain as an input parameter vs.
+ deriving from the IP header length (2017-05-25).
+ * Kinetis ADC: Various corrections and updates. From David Sidrane
+ (2017-05-25).
+ * drivers/lcd: Add driver for Nokia 5110 (Philips PCD8544). From Alan
+ Carvalho de Assis (2017-05-26).
+ * configs/stm32f103-miniumum: Add board support to use the Nokia 5110
+ LCD display driver. From Alan Carvalho de Assis (2017-05-26).
+ * configs/pic32mx7mmb: Add support for the Pinquino toolchain
+ (2017-05-27).
+ * configs/pic32mx7mmb: Repartition files to match newer
+ configurations. Add support for PROCFS file system. Default is now
+ Pinguino toolchain. Verify networking (2017-05-27).
+ * pthread_trylock: Fixes a problem in pthread_trylock() noted by
+ initialkjc@yahoo.com. When CONFIG_PTHREAD_MUTEX_UNSAFE=y, the
+ special return value EAGAIN was not being detected due to differences
+ in reporting of returned values (2017-05-29).
+ * vfs: fdopen: Add missing file stream flags clearing. Clear file
+ stream structure regardless of config options. Structure clearing is
+ needed as previous use of stream list entry might leave fs_flags
+ set. From Harri Luhtala (2017-05-31).
+ * drivers/input: Add Cypress MBR3108 CapSense touch button driver.
+ From Juha Niskanen (2017-05-31).
+ * STM32L4: gpio: put back EXTI line source selection. From Juha
+ Niskanen (2017-05-31).
+ * mtd/smart: Fix use of uninitialized variable. From Jussi Kivilinna
+ (2017-05-31).
+ * drivers/mtd/w25.c: Erase sector only if it is not in erased state.
+ From Jussi Kivilinna (2017-05-31).
+ * stm32f7: Add SPI DMA support. From Jussi Kivilinna (2017-05-31).
+ * drivers/mtd/w25.c: Enable short delay after sector/chip erase. From
+ Jussi Kivilinna (2017-05-31).
+ * pthread robust mutexes: Fix memmory trashing problem: the main task
+ may also use mutexes; need to check thread type before accessing
+ pthread-specific mutex data structures. Problem noted by Jussi
+ Kivilinna (2017-05-31).
+ * STM32L4 RTC: store RTC MAGIC to backup reg, not to address zero.
+ From Juha Niskanen (2017-06-01).
+ * drivers/{sensors,usbmisc}: Fix uninitialized I2C frequency. From
+ Juha Niskanen (2017-06-01).
+ * mtd/config: Add some error checks for I/O errors. From Juha
+ Niskanen (2017-06-01).
+ * pthread mutex: Remove bogus DEBUGASSERT. Problem noted by Jussi
+ Kivilinna (2017-06-01).
+ * Tiva SSI: Resolves issue 52 'Copy-Paste error in
+ tiva_ssibus_initialize()' submitted by Aleksandr Kazantsev
+ (2017-06-01).
+ * nucleo-f4x1re User LEDS: Issue #51 reports compilation problems with
+ stm32_userled.c. Reported by Gappi92 (2017-06-01).
+ * tools/: Add initialconfig.c so that perhaps in the future we will be
+ able to use this to generate a new configuration from scratch (rather
+ than having to derive new configurations from existing
+ configurations). NOTE: Not yet intregated into the build system
+ (2017-06-02).
+
+7.22 2017-xx-xx Gregory Nutt
diff --git a/Documentation/NfsHowto.html b/Documentation/NfsHowto.html
index a6e7d3fb2edbc424e133e165d0f89c23aa6d9192..95da2bb73c7787e35312817813226071b15c3a5e 100644
--- a/Documentation/NfsHowto.html
+++ b/Documentation/NfsHowto.html
@@ -287,7 +287,7 @@ This is a test
Setting up the server will be done in two steps:
First, setting up the configuration file for NFS, and then starting the NFS services.
- But first, you need to install the nfs server on Ubuntu with the these two commands:
+ But first, you need to install the nfs server on Ubuntu with these two commands:
# sudo apt-get install nfs-common
diff --git a/Documentation/NuttShell.html b/Documentation/NuttShell.html
index 987f8a7177964283f154f29d0e468339015912b7..dae6f3019fbc27215d195e2b80e6fe3700585fc9 100644
--- a/Documentation/NuttShell.html
+++ b/Documentation/NuttShell.html
@@ -8,7 +8,7 @@
NuttShell (NSH)
- Last Updated: February 5, 2017
+ Last Updated: June 13, 2017
|
@@ -305,7 +305,7 @@
|
- 2.37 Create a FAT Filesystem (mkfatfs)
+ 2.37 Create a FAT File System (mkfatfs)
|
@@ -335,7 +335,7 @@
|
- 2.42 Mount an NFS file system (nfsmount)
+ 2.42 Mount an NFS File System (nfsmount)
|
@@ -619,9 +619,35 @@
NuttShell (NSH)
nsh>
- The greating may also include NuttX versioning information if you are using a versioned copy of NuttX.
+ The greeting may also include NuttX versioning information if you are using a versioned copy of NuttX.
nsh>
is the NSH prompt and indicates that you may enter a command from the console.
+
+ USB console startup.
+ When using a USB console, the start-up sequence differs a little: In this case, you are required to press ENTER three times. Then NSH prompt will appear as described above.
+ This is required for the following reasons:
+
+
+ -
+ This assures that the USB connection is stable.
+ The USB connection may be made, broken, and re-established a few times if the USB cable is not yet fully seated.
+ Waiting for ENTER to be pressed three times assures that the connection is stable.
+
+ -
+ The establishment of the connection is two step process: First, the USB serial connection is made with the host PC. Then the application that uses the serial interface is started on the host.
+ When the serial connection is established on the host, the host operating system may send several AT modem commands to the host depending upon how the host serial port is configured.
+ By waiting for ENTER to be pressed three consecutive times, all of these modem commands will go to the bit-bucket and will not be interpreted as NSH command input.
+
+ -
+ Similarly, in the second step when the applications is started, there may be additional AT modem commands sent out the serial port.
+ Most serial terminal programs will do this unless they are specifically configured to suppress the modem command output.
+ Waiting for the ENTER input eliminates the invalid command errors from both (2) and (3).
+
+ -
+ Finally, if NSH did not wait for some positive indication that the serial terminal program is up and running, then the output of the NSH greeting and initial NSH prompt would be lost.
+
+
+
Extended Command Line Editing.
By default, NuttX uses a simple command line editor that allows command entry after the nsh>
and supports only the backspace key for editing.
@@ -752,7 +778,7 @@ nsh>
<file> |
is the full or relative path to any writable object
- in the filesystem name space (file or character driver).
+ in the file system name space (file or character driver).
Such objects will be referred to simply as files throughout
this document.
|
@@ -779,7 +805,7 @@ nsh>
Optional Syntax Extensions
- Because these features commit significant resources, it is disabled by default.
+ Because these features commit significant resources, they are disabled by default.
-
@@ -804,7 +830,7 @@ set BAR 123
set FOOBAR ABC_${FOO}_${BAR}
would set the environment variable FOO
to XYZ
, BAR
to 123
and FOOBAR
to ABC_XYZ_123
.
- If CONFIG_NSH_ARGCAT
is not selected, then a slightly small FLASH footprint results but then also only simple environment variables like $FOO
can be used on the command line.
+ If CONFIG_NSH_ARGCAT
is not selected, then a slightly smaller FLASH footprint results but then also only simple environment variables like $FOO
can be used on the command line.
@@ -820,7 +846,7 @@ set FOOBAR ABC_${FOO}_${BAR}
An if-then[-else]-fi
construct is also supported in order to
support conditional execution of commands. This works from the
command line but is primarily intended for use within NSH scripts
- (see the sh
commnd). The syntax is as follows:
+ (see the sh
command). The syntax is as follows:
if <cmd>
@@ -968,7 +994,7 @@ done
-
NSH will create a read-only RAM disk (a ROM disk), containing a tiny
- ROMFS filesystem containing the following:
+ ROMFS file system containing the following:
`--init.d/
`-- rcS
@@ -976,7 +1002,7 @@ done
Where rcS is the NSH start-up script.
-
- NSH will then mount the ROMFS filesystem at
/etc
, resulting in:
+ NSH will then mount the ROMFS file system at /etc
, resulting in:
|--dev/
| `-- ram0
@@ -1058,7 +1084,7 @@ mount -t vfat /dev/ram1 /tmp
All of the startup-behavior is contained in rcS.template
. The
role of mkromfsimg.sh
is to (1) apply the specific configuration
settings to rcS.template
to create the final rcS
, and (2) to
- generate the header file nsh_romfsimg.h
containg the ROMFS
+ generate the header file nsh_romfsimg.h
containing the ROMFS
file system image.
@@ -1139,7 +1165,7 @@ addroute <target> <netmask> <router>
Synopsis.
This command adds an entry in the routing table.
- The new entry will map the IP address of a router on a local network(<router>) to an external network characterized by the <target> IP address and a network mask <netmask>
+ The new entry will map the IP address of a router on a local network (<router>) to an external network characterized by the <target> IP address and a network mask <netmask>
Example:
@@ -1274,7 +1300,7 @@ cat <path>
[<path>
[<path>
Synopsis.
- This command copies and concatentates all of the files at <path>
+ This command copies and concatenates all of the files at <path>
to the console (or to another file if the output is redirected).
@@ -1352,7 +1378,7 @@ cp <source-path> <dest-path>
Synopsis.
Copy of the contents of the file at <source-path>
to the location
- in the filesystem indicated by <dest-path>
.
+ in the file system indicated by <dest-path>
.
@@ -1425,7 +1451,7 @@ nsh> dd if=/dev/zero of=/dev/ram0
- Read from a block devic, write to a character device. This
+ Read from a block device, write to a character device. This
will read the entire block device and dump the contents in
the bit bucket.
@@ -1564,7 +1590,7 @@ exit
Synopsis.
Exit NSH. Only useful for the serial front end if you have started some other tasks (perhaps
using the exec
command) and you would like to have NSH out of the
- way. For the telnet front-end, exit
terminates the telenet session.
+ way. For the telnet front-end, exit
terminates the telnet session.
@@ -1638,7 +1664,7 @@ get [-b|-n] [-f <local-path>] -h <ip-address> <remote-path>
-b|-n |
- Selects either binary ("octet") or test ("netascii") transfer
+ Selects either binary ("octet") or text ("netascii") transfer
mode. Default: text.
|
@@ -1686,12 +1712,25 @@ help [-v] [<cmd>]
Command Syntax:
-hexdump <file or device>
+hexdump <file or device> [skip=<bytes>] [count=<bytes>]
Synopsis.
Dump data in hexadecimal format from a file or character device.
+
+
+ skip=<bytes> |
+ Will skip <bytes> number of bytes from the beginning.
+ |
+
+ count=<bytes> |
+ Will stop after dumping <bytes> number of bytes.
+ |
+
+
+The skip
and count
options are only available if CONFIG_NSH_CMDOPT_HEXDUMP
is defined in the NuttX configuration.
+
@@ -1707,13 +1746,13 @@ ifconfig [nic_name [<ip-address>|dhcp]] [dr|gw|gateway <dr-address>]
Synopsis.
- Multiple forms of the ifconfig
command are supported:
+ Multiple forms of the ifconfig
command are supported:
-
With one or no arguments, ifconfig
will shows the
- current configuration of the network and, perhaps, the status of ethernet
+ current configuration of the network and, perhaps, the status of Ethernet
device:
@@ -1736,7 +1775,7 @@ eth0 HWaddr 00:18:11:80:10:06
-
If both the network interface name and an IP address are supplied as arguments,
- then ifconfig
will set the address of the ethernet device:
+ then ifconfig
will set the address of the Ethernet device:
ifconfig nic_name ip_address
@@ -1880,7 +1919,7 @@ nsh>
NOTE:
NuttX does not support a FULL POSIX signalling system.
- Standard signals like SIGCHLD, SIGINTR, SIGKILL, etc. do not exist in NuttX and sending those signal may not have the result that you expect.
+ Standard signals like SIGCHLD, SIGINTR, SIGKILL, etc. do not exist in NuttX and sending those signals may not have the result that you expect.
Rather, NuttX supports only what are referred to as POSIX real-time signals.
These signals may be used to communicate with running tasks, may be use to waiting waiting tasks, etc.
But, as an example, kill -9
(SIGKILL) will not terminate a task.
@@ -1942,22 +1981,22 @@ losetup d <dev-path>
Command Syntax:
-link [-s] <target> <link>
+ln [-s] <target> <link>
Synopsis.
- The link
command will create a new symbolic link at <link> for the existing file or directory, <target>.
- This implementation is simplied for use with NuttX in these ways:
+ The ln
command will create a new symbolic link at <link> for the existing file or directory, <target>.
+ This implementation is simplified for use with NuttX in these ways:
- - Links may be created only within the NuttX top-level, pseudo file system.
+
- Links may be created only within the NuttX top-level, pseudo file system.
No file system currently supported by NuttX provides symbolic links.
- For the same reason, only soft links are implemented.
- File privileges are ignored.
@@ -1979,7 +2018,7 @@ ls [-lRs] <dir-path>
Synopsis.
Show the contents of the directory at <dir-path>
. NOTE:
- <dir-path>
must refer to a directory and no other filesystem
+ <dir-path>
must refer to a directory and no other file system
object.
Options:
@@ -2073,20 +2112,19 @@ mw <hex-address>[=<hex-value>][ <hex-byte-count>]
- <hex-address> . |
+ <hex-address> |
Specifies the address to be accessed. The current
value at that address will always be read and displayed.
|
- <hex-address>=<hex-value> . |
+ <hex-address>=<hex-value> |
Read the value, then write <hex-value>
to the location.
|
- <hex-byte-count> . |
+ <hex-byte-count> |
Perform the mb, mh, or mw operation on a total
- of <hex-byte-count> bytes, increment the <hex-address> appropriately
- after each access
+ of <hex-byte-count> bytes, increment the <hex-address> appropriately after each access.
|
Example:
@@ -2160,10 +2198,10 @@ mkdir <path>
Limited to Mounted File Systems.
- Recall that NuttX uses a pseudo filesystem for its root file
+ Recall that NuttX uses a pseudo file system for its root file
system.
The mkdir
command can only be used to create directories in volumes set up with the
- mount
command; it cannot be used to create directories in the pseudo filesystem.
+ mount
command; it cannot be used to create directories in the pseudo file system.
Example:
@@ -2178,7 +2216,7 @@ nsh>
@@ -2196,7 +2234,7 @@ mkfatfs [-F <fatsize>] <block-driver>
NSH provides this command to access the mkfatfs()
NuttX API.
- This block device must reside in the NuttX pseudo filesystem and
+ This block device must reside in the NuttX pseudo file system and
must have been created by some call to register_blockdriver()
(see include/nuttx/fs/fs.h
).
@@ -2307,26 +2345,26 @@ mount -t <fstype> [-o <options>] <block-device> <dir-
If no parameters are provided on the command line after the mount
command, then the mount
command will enumerate all of the current mountpoints on the console.
- If the mount parameters are provied on the command after the mount
command, then the mount
command will mount a file system in the NuttX pseudo-file system.
- mount
' performs a three way association, binding:
+ If the mount parameters are provided on the command after the mount
command, then the mount
command will mount a file system in the NuttX pseudo-file system.
+ mount
performs a three way association, binding:
- - File system.
+
- File System.
The '-t
<fstype>
' option identifies the type of
file system that has been formatted on the <block-device>
.
As of this writing, vfat
is the only supported value for <fstype>
- Block Device.
The
<block-device>
argument is the full or relative
- path to a block driver inode in the pseudo filesystem.
+ path to a block driver inode in the pseudo file system.
By convention, this is a name under the /dev
sub-directory.
This <block-device>
must have been previously formatted with the same file system
type as specified by <fstype>
- Mount Point.
The mount point,
<dir-path>
, is the location in the
- pseudo filesystem where the mounted volume will appear.
- This mount point can only reside in the NuttX pseudo filesystem.
+ pseudo file system where the mounted volume will appear.
+ This mount point can only reside in the NuttX pseudo file system.
By convention, this mount point is a subdirectory under /mnt
.
The mount command will create whatever pseudo directories that may be needed to complete the
full path but the full path must not already exist.
@@ -2334,8 +2372,8 @@ mount -t <fstype> [-o <options>] <block-device> <dir-
After the volume has been mounted in the NuttX
- pseudo filesystem,
- it may be access in the same way as other objects in thefile system.
+ pseudo file system,
+ it may be access in the same way as other objects in the file system.
Examples:
Using mount
to mount a file system:
@@ -2383,7 +2421,7 @@ mv <old-path> <new-path>
Synopsis.
Rename the file object at <old-path>
to <new-path>
.
- Both paths must reside in the same mounted filesystem.
+ Both paths must reside in the same mounted file system.
@@ -2527,7 +2565,7 @@ put [-b|-n] [-f <remote-path>] -h <ip-address> <local-path>
-b|-n |
- Selects either binary ("octet") or test ("netascii") transfer
+ Selects either binary ("octet") or text ("netascii") transfer
mode. Default: text.
|
@@ -2616,11 +2654,11 @@ rm <file-path>
Synopsis.
Remove the specified <file-path>
name from the mounted file system.
- Recall that NuttX uses a pseudo filesystem for its root file
+ Recall that NuttX uses a pseudo file system for its root file
system.
The rm
command can only be used to remove (unlink) files in volumes set up with the
mount
command;
- it cannot be used to remove names in the pseudo filesystem.
+ it cannot be used to remove names in the pseudo file system.
Example:
@@ -2650,11 +2688,11 @@ rmdir <dir-path>
Synopsis.
Remove the specified <dir-path>
directory from the mounted file system.
- Recall that NuttX uses a pseudo filesystem for its root file
+ Recall that NuttX uses a pseudo file system for its root file
system.
The rmdir
command can only be used to remove directories from volumes set up with the
mount
command;
- it cannot be used to remove directories from the pseudo filesystem.
+ it cannot be used to remove directories from the pseudo file system.
Example:
@@ -2708,12 +2746,11 @@ nsh>
Command Syntax:
-set <name> <value>
+set [{+|-}{e|x|xe|ex}] [<name> <value>]
Synopsis.
- Set the environment variable <name>
to the string <value>
.
- For example,
+ Set the environment variable <name>
to the string <value>
and or set NSH parser control options. For example,
nsh> echo $foobar
@@ -2724,6 +2761,50 @@ foovalue
nsh>
+
+ Set the 'exit on error control' and/or 'print a trace' of commands when parsing
+ scripts in NSH. The settings are in effect from the point of execution, until
+ they are changed again, or in the case of the init script, the settings are
+ returned to the default settings when it exits. Included child scripts will run
+ with the parents settings and changes made in the child script will effect the
+ parent on return.
+
+
+ Use 'set -e' to enable and 'set +e' to disable (ignore) the exit condition on commands.
+ The default is -e. Errors cause script to exit.
+
+
+ Use 'set -x' to enable and 'set +x' to disable (silence) printing a trace of the script
+ commands as they are executed.
+ The default is +x: no printing of a trace of script commands as they are executed.
+
+
+ Example 1 - no exit on command not found
+
+ set +e
+ notacommand
+
+
+ Example 2 - will exit on command not found
+
+ set -e
+ notacommand
+
+
+ Example 3 - will exit on command not found, and print a trace of the script commands
+
+ set -ex
+
+
+ Example 4 - will exit on command not found, and print a trace of the script commands
+ and set foobar to foovalue.
+
+ set -ex foobar foovalue
+ nsh> echo $foobar
+ foovalue
+
+
+
@@ -2808,8 +2889,7 @@ nsh> time "sleep 2"
nsh>
- The additional 10 millseconds in this example is due to the way that the sleep command works: It always waits one system clock tick longer than requested and this test setup used a 10 millisecond periodic system
- timer.
+ The additional 10 milliseconds in this example is due to the way that the sleep command works: It always waits one system clock tick longer than requested and this test setup used a 10 millisecond periodic system timer.
Sources of error could include various quantization errors, competing CPU usage, and the additional overhead of the time command execution itself which is included in the total.
@@ -2902,7 +2982,7 @@ uname [-a | -imnoprsv]
|
-n |
- Print the network node hostname (only availabel if CONFIG_NET=y )
+ Print the network node hostname (only available if CONFIG_NET=y )
|
@@ -3120,7 +3200,7 @@ nsh>
- Note that in addition to general NuttX configuation settings, each NSH command can be
+ Note that in addition to general NuttX configuration settings, each NSH command can be
individually disabled via the settings in the rightmost column.
All of these settings make the configuration of NSH potentially complex but also allow it to
squeeze into very small memory footprints.
@@ -3289,13 +3369,13 @@ nsh>
ln |
- CONFIG_NFILE_DESCRIPTORS > 0 |
- CONFIG_NSH_DISABLE_LL |
+ CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_PSEUDOFS_SOFTLINKS |
+ CONFIG_NSH_DISABLE_LN |
ls |
CONFIG_NFILE_DESCRIPTORS > 0 |
- CONFIG_NSH_DISABLE_LS && CONFIG_PSEUDOFS_SOFTLINKS |
+ CONFIG_NSH_DISABLE_LS |
lsmod |
@@ -3394,6 +3474,11 @@ nsh>
!CONFIG_DISABLE_ENVIRON && CONFIG_NFILE_DESCRIPTORS > 0 |
CONFIG_NSH_DISABLE_PWD |
+
+ readlink |
+ CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_PSEUDOFS_SOFTLINKS |
+ CONFIG_NSH_DISABLE_READLINK |
+
reboot |
CONFIG_BOARD_RESET |
@@ -3441,7 +3526,7 @@ nsh>
time |
-   |
+ |
CONFIG_NSH_DISABLE_TIME |
@@ -3451,7 +3536,7 @@ nsh>
uname |
- br |
+ |
CONFIG_NSH_DISABLE_UNAME |
@@ -3500,15 +3585,15 @@ nsh>
1
Because of hardware padding, the actual required packet size may be larger
2
- Special TFTP server start-up optionss will probably be required to permit
+ Special TFTP server start-up options will probably be required to permit
creation of files for the correct operation of the put
command.
3
CONFIG_FS_READABLE
is not a user configuration but is set automatically
- if any readable filesystem is selected. At present, this is either CONFIG_FS_FAT
+ if any readable file system is selected. At present, this is either CONFIG_FS_FAT
or CONFIG_FS_ROMFS
.
4
CONFIG_FS_WRITABLE
is not a user configuration but is set automatically
- if any writable filesystem is selected. At present, this is only CONFIG_FS_FAT
.
+ if any writable file system is selected. At present, this is only CONFIG_FS_FAT
.
5
Verbose help output can be suppressed by defining CONFIG_NSH_HELP_TERSE
.
In that case, the help command is still available but will be slightly smaller.
@@ -3566,7 +3651,7 @@ nsh>
CONFIG_NSH_FILEIOSIZE |
Size of a static I/O buffer used for file access (ignored if
- there is no filesystem). Default is 1024.
+ there is no file system). Default is 1024.
|
@@ -3639,7 +3724,7 @@ set FOOBAR ABC_${FOO}_${BAR}
CONFIG_NSH_NESTDEPTH |
The maximum number of nested if-then[-else]-fi sequences that
- are permissable. Default: 3
+ are permissible. Default: 3
|
@@ -3687,7 +3772,7 @@ set FOOBAR ABC_${FOO}_${BAR}
CONFIG_NSH_ROMFSETC |
- Mount a ROMFS filesystem at /etc and provide a startup script
+ Mount a ROMFS file system at /etc and provide a startup script
at /etc/init.d/rcS . The default startup script will mount
a FAT FS RAMDISK at /tmp but the logic is
easily extensible.
@@ -3790,7 +3875,7 @@ set FOOBAR ABC_${FOO}_${BAR}
|
CONFIG_NSH_TELNET |
- If CONFIG_NSH_TELNET is set to y, then a TELENET
+ If CONFIG_NSH_TELNET is set to y, then a TELNET
server front-end is selected. When this option is provided,
you may log into NuttX remotely using telnet in order to
access NSH.
@@ -3885,7 +3970,7 @@ set FOOBAR ABC_${FOO}_${BAR}
| CONFIG_NSH_IOBUFFER_SIZE |
Determines the size of the I/O buffer to use for sending/
- receiving TELNET commands/reponses
+ receiving TELNET commands/responses
|
@@ -3916,7 +4001,7 @@ set FOOBAR ABC_${FOO}_${BAR}
CONFIG_NSH_NOMAC |
- Set if your ethernet hardware has no built-in MAC address.
+ Set if your Ethernet hardware has no built-in MAC address.
If set, a bogus MAC will be assigned.
|
@@ -4189,7 +4274,7 @@ mount -t vfat /dev/ram1 /tmp
-
- Mount the FAT filesystem at a configured mountpoint, /tmp
.
+ Mount the FAT file system at a configured mountpoint, /tmp
.
@@ -4317,7 +4402,7 @@ struct cmdmap_s
That last string is what is printed when enter "nsh> help
".
- So, for you sample commnd, you would add the following the to the g_cmdmap[]
table:
+ So, for you sample command, you would add the following the to the g_cmdmap[]
table:
{ "mycmd", cmd_mycmd, 1, 1, NULL },
@@ -4478,7 +4563,7 @@ int hello_main(int argc, char *argv[])
-
- And finally, the apps/examples/Makefile
will execute the context target in all configured example
sub-directores, getting us finally to apps/examples/Makefile
which is covered below.
+ And finally, the apps/examples/Makefile
will execute the context target in all configured example
sub-directories, getting us finally to apps/examples/Makefile
which is covered below.
@@ -4607,7 +4692,7 @@ CONFIG_SCHED_WAITPID=y
You replace the sample code at apps/examples/nsh/nsh_main.c
with whatever start-up logic that you want.
NSH is a library at apps/nshlib
.
- apps.examplex/nsh
is just a tiny, example start-up function (CONFIG_USER_ENTRYPOINT
()) that that runs immediately and illustrates how to start NSH
+ apps.examples/nsh
is just a tiny, example start-up function (CONFIG_USER_ENTRYPOINT
()) that that runs immediately and illustrates how to start NSH
If you want something else to run immediately then you can write your write your own custom CONFIG_USER_ENTRYPOINT
() function and then start other tasks from your custom CONFIG_USER_ENTRYPOINT
().
-
@@ -4664,7 +4749,7 @@ CONFIG_SCHED_WAITPID=y
-
- NSH will create a read-only RAM disk (a ROM disk), containing a tiny ROMFS filesystem containing the following:
+ NSH will create a read-only RAM disk (a ROM disk), containing a tiny ROMFS file system containing the following:
`--init.d/
@@ -4675,7 +4760,7 @@ CONFIG_SCHED_WAITPID=y
-
- NSH will then mount the ROMFS filesystem at /etc
, resulting in:
+ NSH will then mount the ROMFS file system at /etc
, resulting in:
|--dev/
@@ -4782,7 +4867,7 @@ mount -t vfat /dev/ram1 /tmp
To generate a custom rcS
file a copy of rcS.template
needs to be placed at tools/
and changed according to the desired start-up behaviour.
- Running tools/mkromfsimg.h
creates nsh_romfsimg.h
which needs to be copied to apps/nhslib
OR if CONFIG_NSH_ARCHROMFS
is defined to configs/<board>/include
.
+ Running tools/mkromfsimg.h
creates nsh_romfsimg.h
which needs to be copied to apps/nshlib
OR if CONFIG_NSH_ARCHROMFS
is defined to configs/<board>/include
.
@@ -4798,7 +4883,7 @@ mount -t vfat /dev/ram1 /tmp
All of the startup-behavior is contained in rcS.template
.
- The role of mkromfsimg.sh
script is to (1) apply the specific configuration settings to rcS.template
to create the final rcS
, and (2) to generate the header file nsh_romfsimg.h
containg the ROMFS file system image.
+ The role of mkromfsimg.sh
script is to (1) apply the specific configuration settings to rcS.template
to create the final rcS
, and (2) to generate the header file nsh_romfsimg.h
containing the ROMFS file system image.
To do this, mkromfsimg.sh
uses two tools that must be installed in your system:
@@ -5269,13 +5354,13 @@ xxd -i romfs_img >nsh_romfsimg.h
insmod
kill
losetup
- - ln
- - ls
+ ln
+ ls
mb
- Login
- Login, Credentials
lsmod
- - md5
+ md5
mh
mw
mkdir
@@ -5284,10 +5369,10 @@ xxd -i romfs_img >nsh_romfsimg.h
mkrd
mkromfsimg.sh
mount
+ mv
|
@@ -317,7 +317,7 @@
|
- - POSIX/ANSI-like task controls, named message queues, counting semaphores, clocks/timers, signals, pthreads, cancellation points, environment variables, filesystem.
+ - POSIX/ANSI-like task controls, named message queues, counting semaphores, clocks/timers, signals, pthreads, robust mutexes, cancellation points, environment variables, filesystem.
@@ -772,6 +772,14 @@
|
+
+
|
+
+
+ - User space stacks.
+
+ |
+
|
@@ -792,7 +800,23 @@
|
|
- - DNS name resolution.
+ - DNS name resolution / NetDB
+
+ |
+
+
+
|
+
+
+ - IEEE 802.11 FullMac
+
+ |
+
+
+
|
+
+
+ - IEEE 802.15.4 MAC + 6loWPAN
|
@@ -1339,11 +1363,11 @@
Released Versions
In addition to the ever-changing GIT repository, there are frozen released versions of NuttX available.
- The current release is NuttX 7.20.
- NuttX 7.20 is the 120th release of NuttX.
- It was released on March 8, 2016, and is available for download from the
+ The current release is NuttX 7.21.
+ NuttX 7.21 is the 121st release of NuttX.
+ It was released on June 5, 2016, and is available for download from the
Bitbucket.org website.
- Note that the release consists of two tarballs: nuttx-7.20.tar.gz
and apps-7.20.tar.gz
.
+ Note that the release consists of two tarballs: nuttx-7.21.tar.gz
and apps-7.21.tar.gz
.
Both may be needed (see the top-level nuttx/README.txt
file for build information).
@@ -1352,7 +1376,7 @@
- nuttx.
- Release notes for NuttX 7.20 are available here.
+ Release notes for NuttX 7.21 are available here.
Release notes for all released versions on NuttX are available in the Bitbucket GIT.
The ChangeLog for all releases of NuttX is available in the ChangeLog file that can viewed in the Bitbucket GIT.
The ChangeLog for the current release is at the bottom of that file.
@@ -1360,7 +1384,7 @@
- apps.
- Atmel AVR
@@ -1525,6 +1549,11 @@
- Linux/Cygwin user mode simulation
+ - Infineon
+
+
- Intel
- Intel 80x86
@@ -1595,8 +1624,9 @@
- STMicroelectronics
- STMicro STR71x (ARM7TDMI)
- - STMicro STM32L152 (STM32 L "EnergyLite" Line, ARM Cortex-M3)
- - STMicro STM32L162 (STM32 L "EnergyLite" Medium+ Density, ARM Cortex-M3)
+ - STMicro STM32L152 (STM32 L1 "EnergyLite" Line, ARM Cortex-M3)
+ - STMicro STM32L162 (STM32 L1 "EnergyLite" Medium+ Density, ARM Cortex-M3)
+ - STMicro STM32F0xx (STM32 F0, ARM Cortex-M0)
- STMicro STM32F100x (STM32 F1 "Value Line"Family, ARM Cortex-M3)
- STMicro STM32F102x (STM32 F1 Family, ARM Cortex-M3)
- STMicro STM32F103C4/C8 (STM32 F1 "Low- and Medium-Density Line" Family, ARM Cortex-M3)
@@ -1608,19 +1638,22 @@
- STMicro STM32F302x (STM32 F3 family, ARM Cortex-M4)
- STMicro STM32F303x (STM32 F3 family, ARM Cortex-M4)
- STMicro STM32 F372/F373 (ARM Cortex-M4)
- - STMicro STM32F401x (STM32 F4 family, ARM Cortex-M4)
- STMicroelectronics (Continued)
+ - STMicro STM32F4x1 (STM32 F4 family, ARM Cortex-M4)
+ - STMicro STM32F410 (STM32 F4 family, ARM Cortex-M4)
- STMicro STM32F407x (STM32 F4 family, ARM Cortex-M4)
- STMicro STM32 F427/F437 (STM32 F4 family, ARM Cortex-M4)
- STMicro STM32 F429 (STM32 F4 family, ARM Cortex-M4)
- STMicro STM32 F446 (STM32 F4 family, ARM Cortex-M4)
- STMicro STM32 F46xx (STM32 F4 family, ARM Cortex-M4)
- - STMicro STM32 L476 (STM32 F4 family, ARM Cortex-M4)
+ - STMicro STM32 L4x2 (STM32 L4 family, ARM Cortex-M4)
+ - STMicro STM32 L476 (STM32 L4 family, ARM Cortex-M4)
+ - STMicro STM32 L496 (STM32 L4 family, ARM Cortex-M4)
- STMicro STM32 F745/F746 (STM32 F7 family, ARM Cortex-M7)
- STMicro STM32 F756 (STM32 F7 family, ARM Cortex-M7)
- STMicro STM32 F76xx/F77xx (STM32 F7 family, ARM Cortex-M7)
@@ -2792,7 +2825,7 @@ nsh>
- The STM32L-Discovery and 32L152CDISCOVERY kits are functionally equivalent.
+ The STM32L-Discovery and STM32L152C DISCOVERY kits are functionally equivalent.
The difference is the internal Flash memory size (STM32L152RBT6 with 128 Kbytes or STM32L152RCT6 with 256 Kbytes).
Both boards feature:
@@ -2807,6 +2840,7 @@ nsh>
STATUS.
Initial support for the STM32L-Discovery was released in NuttX-6.28.
+ Addition (architecture-only) support for the STM32L152xC family was added in NuttX-7.21.
This initial support includes a configuration using the NuttShell (NSH) that might be the basis for an application development.
A driver for the on-board segment LCD is included as well as an option to drive the segment LCD from an NSH "built-in" command.
As of this writing, a few more things are needed to make this a more complete port: 1) Verfication of more device drivers (timers, quadrature encoders, PWM, etc.), and 2) logic that actually uses the low-power consumption modes of the EnergyLite part.
@@ -2837,7 +2871,7 @@ Mem: 14096 3928 10168 10168
nsh>
- You can see that 9.9KB (62%) of SRAM heap is staill available for further application development while NSH is running.
+ You can see that 9.9KB (62%) of SRAM heap is still available for further application development while NSH is running.
|
@@ -2849,12 +2883,50 @@ nsh>
|
- STMicro STM32F152x/162x(STM32 F1 "EnergyLite" Medium+ Density Family).
- Support for the STM32152 and STM32162 Medium+ density parts from Jussi Kivilinna and Sami Pelkonen was included in NuttX-7.3, extending the basic STM32F152x support.
- This is architecture-only support, meaning that support for the boards with these chips is available, but not support for any publicly available boards is included.
+ STMicro STM32L152x/162x (STM32 L1 "EnergyLite" Medium+ Density Family).
+ Support for the STM32L152 and STM32L162 Medium+ density parts from Jussi Kivilinna and Sami Pelkonen was included in NuttX-7.3, extending the basic STM32L152x support.
+ This is architecture-only support, meaning that support for the boards with these chips is available, but no support for any publicly available boards is included.
|
+
+
+
|
+
|
+
+
+
|
+
+
+ STMicro STM32F0xx (STM32 F0, ARM Cortex-M0).
+ Support for the STM32 F0 family was contributed by Alan Carvalho de Assis in NuttX-7.21.
+ There are ports to three different boards in this respository:
+
+
+ -
+ STM32F0-Discovery
+ This board features the STM32 2F051R8 and was used by Alan to produce the initial STM32 F0 port.
+ However, its very limited 8KB SRAM makes this port unsuitable for for usages.
+ Contributed by Alan Carvalho de Assis in NuttX-7.21.
+
+ -
+ Nucleo-F072RB
+ With 16KB of SRAM the STM32 F072RB makes a much more usable platform.
+
+ -
+ Nucleo-F091RC
+ With 32KB of SRAM the STM32 F091RC this board is a great match for NuttX.
+ Contributed by Juha Niskanen in NuttX-7.21.
+
+
+ STATUS:
+ In this initial release, the level of support for the STM32 F0 family is minimal.
+ Certainly enough is in place to support a robust NSH configuration.
+ There are also unverified I2C and USB device drivers available in NuttX-7.21.
+
+ |
+
+
|
|
@@ -2923,7 +2995,7 @@ nsh>
-
- The other port is for a generic minimual STM32F103CBT6 "blue" board contributed by Alan Carvalho de Assis.
+ The other port is for a generic minimal STM32F103CBT6 "blue" board contributed by Alan Carvalho de Assis.
Alan added support for numerous sensors, tone generators, user LEDs, and LCD support in NuttX 7.18.
@@ -3098,7 +3170,7 @@ nsh>
STMicro STM32F107x (STM32 F1 "Connectivity Line" family).
- Chip support for the STM32 F1 "Connectivity Line" family has been present in NuttX for some time and users have reported that they have successful brought up NuttX on theor proprietary boards using this logic.
+ Chip support for the STM32 F1 "Connectivity Line" family has been present in NuttX for some time and users have reported that they have successful brought up NuttX on their proprietary boards using this logic.
-
@@ -3176,11 +3248,18 @@ nsh>
STMicro STM32F205 (STM32 F2 family).
- Architecture only support for the STM32F205RG was contributed as an anonymous contribution in NuttX-7.10
+ Architecture only support for the STM32F205RG was contributed as an anonymous contribution in NuttX-7.10.
+
+
+ Particle.io Phone.
+ Support for the Particle.io Photon board was contributed by Simon Pirious in NuttX-7.21.
+ The Photon board features the STM32F205RG MCU.
+ The STM32F205RG is a 120 MHz Cortex-M3 operation with 1Mbit Flash memory and 128kbytes.
+ The board port includes support for the on-board Broadcom BCM43362 WiFi and fully usable FullMac network support.
STATUS:
- There are currently on board configurations for any board using the STM32F205.
+ In addition to the above-mention WiFI support, the Photon board support includes buttons, LEDS, IWDG, USB OTG HS, and procfs support. Configurations available for nsh, usbnsh, and wlan configurations. See the Photon README file for additional information.
|
|
@@ -3481,6 +3560,26 @@ nsh>
ARM Cortex-M4.
+
+
+
|
+
+
+ Infineon XMC45xx.
+ An initial but still incomplete port to the XMC4500 Relax board was released with NuttX-7.21 (although it is not really ready for prime time).
+ Much is functional but there are still some issues with the output to the NSH serial console.
+
+
+ This initial porting effort uses the Infineon XMC4500 Relax v1 board as described on the manufacturer's website.
+ The current status of the board is available in the board README file
+
+ |
+
+
+
+
|
+
|
+
|
@@ -3499,6 +3598,7 @@ nsh>
|
+
|
|
@@ -3683,7 +3783,7 @@ nsh>
- STMicro ST Nucleo F303RE board..
+ STMicro ST Nucleo F303RE board.
Contributed by Paul Alexander Patience.
@@ -3711,6 +3811,7 @@ nsh>
+
|
|
@@ -3719,26 +3820,53 @@ nsh>
|
- STMicro STM32401x (STM32 F4 family).
+ STMicro STM324x1 (STM32 F4 family).
Nucleo F401RE.
- This port uses the STMicro Nucleo F401RE board featuring the STM32F104RE MCU.
- Refer to the STMicro web site for further information about this board.
+ This port uses the STMicro Nucleo F401RE board featuring the STM32F401RE MCU.
+ Refer to the STMicro web site for further information about this board.
+
+
+ Nucleo F411RE.
+ This port uses the STMicro Nucleo F411RE board featuring the STM32F411RE MCU.
+ Refer to the STMicro web site for further information about this board.
STATUS:
- NuttX-7.2
The basic port for STMicro Nucleo F401RE board was contributed by Frank Bennett.
+
+ - NuttX-7.6
+ The basic port for STMicro Nucleo F401RE board was added by Serg Podtynnyi.
+
-
- Refer to the NuttX board README file for further information.
+ Refer to the NuttX board README file for further information.
|
+
+
+
|
+
|
+
+
+
|
+
+
+ STMicro STM32410 (STM32 F4 family).
+
+ |
+
+
|
|
@@ -3867,6 +3995,20 @@ nsh>
Support for the Olimex STM32 P407 development board appeared in NuttX-7.19.
See the NuttX board README file for further information about the NuttX port.
+
+ MikroElektronika Clicker2 for STM32.
+ This is yet another board supported by NuttX that uses the same STM32F407VGT6 MCU as does the STM32F4-Discovery board.
+ This board has been used primarily with the MRF24J40 Click board for the development of IEEE 802.15.4 MAC and 6loWPAN support.
+
+ See the Mikroelektronika website for more information about this board and the NuttX board README file for further information about the NuttX port.
+
+
+
+ STATUS:
+ The basic port for the Clicker2 STM32 was contributed by Anthony Merlino and was first released in NuttX-7.21.
+ All compatible drivers for the STM32 F4 family may be used with this board as well.
+
+
@@ -3905,7 +4047,7 @@ nsh>
+
+
+
|
+
|
+
+
+
|
+
+
+ STMicro STM32 L4x2.
+ Architecture support for STM32 L4x2 family was contributed by Juha Niskanen in NuttX-7.21.
+ Two boards are currently supported.
+
+
+ -
+
+ Nucleo-L432KC.
+ Board support for the STMicro Nucleo-L432KC board from ST Micro was contributed by JSebastien Lorquet in NuttX-7.21. See the STMicro website and the board README file for further information.
+
+
+ -
+
+ Nucleo-L452RE.
+ Board support for the STMicro Nucleo-L452RE board from ST Micro was contributed by Juha Niskanen in NuttX-7.21. See the STMicro website and the board README file for further information.
+
+
+
+
+ See also the status above for the STM32 L476 most of which also applies to these parts.
+
+ |
+
+
+
+
|
+
|
+
+
+
|
+
+
+ STMicro STM32 L496.
+ Architecture support for STM32 L496 was contributed by Juha Niskanen along with board support for the Nucleo-L496ZG in NuttX-7.21:
+
+
|
@@ -4284,7 +4488,7 @@ nsh>
-
This board supports included two configurations for the NuttShell (NSH).
Both are networked enabled: One configured to support IPv4 and one configured to supported IPv6.
- Instructions are included in the board README file for configuring both IPv4 and IPv6 simultaneously..
+ Instructions are included in the board README file for configuring both IPv4 and IPv6 simultaneously.
-
Tiva PWM and Quadrature Encoder drivers were contributed to NuttX in 7.18 by Young.
diff --git a/Documentation/NuttXBinfmt.html b/Documentation/NuttXBinfmt.html
index 49a999846c78a88cf77166165aaa90d9016b463e..600693ba49a40dfedd01c303b49cb4b5d24a331d 100644
--- a/Documentation/NuttXBinfmt.html
+++ b/Documentation/NuttXBinfmt.html
@@ -381,7 +381,7 @@ EXEPATH_HANDLE exepath_init(void);
On success, exepath_init()
return a non-NULL
, opaque handle that may subsequently be used in calls to exepath_next()
and exepath_release()
.
On error, a NULL
handle value will be returned.
- The most likely cause of an error would be that the there is no value associated with the PATH
variable.
+ The most likely cause of an error would be that there is no value associated with the PATH
variable.
diff --git a/Documentation/NuttXCCodingStandard.html b/Documentation/NuttXCCodingStandard.html
index 977af36225b1b38fafc229a793742c5d7bdca5ae..a80b4d396091feedca5434236d8c72f6f1b8fc65 100644
--- a/Documentation/NuttXCCodingStandard.html
+++ b/Documentation/NuttXCCodingStandard.html
@@ -12,7 +12,7 @@
NuttX C Coding Standard
- Last Updated: February 9, 2017
+ Last Updated: June 11, 2017
@@ -405,8 +405,11 @@
Line Spacing
A single blank line should precede and follow each comment.
- The only exception is for the file header block comment that begins on line one;
+ The only exceptions are (1) for the file header block comment that begins on line one;
there is no preceding blank line in that case.
+ And (2) for conditional compilation.
+ Conditional compilation should include the conditional logic and all comments associated with the conditional logic.
+ In this case, the blank line appears before the conditional, not after it.
@@ -416,6 +419,12 @@
a = b;
/* set b equal to c */
b = c;
+
+ /* Do the impossible */
+
+#ifdef CONFIG_THE_IMPOSSIBLE
+ the_impossible();
+#endif
|
@@ -430,6 +439,11 @@
b = c;
+#ifdef CONFIG_THE_IMPOSSIBLE
+ /* Do the impossible */
+
+ the_impossible();
+#endif
|
@@ -722,12 +736,25 @@ void some_function(void)
-
Always on Separate Lines.
- Braces always appear on a separate line containing nothing else other that white space.
+ Braces always appear on a separate line containing nothing else other than white space.
-
Never Comments on Braces.
Do not put comments on the same line as braces.
+ -
+ Compound Statements.
+ Within this document, an opening left brace followed by a sequence of statments, and ending with a closing right brace is refered to as a compound statement.
+
+ -
+ Nested Compound Statements.
+ In the case where there are nested compound statements that end with several consecutive right braces, each closing right brace must lie on a separate line and must be indented to match the corresponding opening brace.
+
+ -
+ Final brace followed by a single blank line.
+ The final right brace must be followed by a blank line as per standard rules.
+ In the case where there are nested several consecutive right braces, no blank lines should be inserted except for after the final right brace.
+
-
Special Indentation Rules.
Special indentation rules apply to braces.
@@ -749,6 +776,19 @@ while (true)
...
} /* not valid */
} /* end forever */
+if (a < b) {
+ if (a < 0) {
+ c = -a;
+ } else {
+ c = a;
+ }
+} else {
+ if (b < 0) {
+ c = -b;
+ } else {
+ c = b;
+ }
+}
@@ -765,12 +805,36 @@ while (true)
...
}
}
+
+if (a < b)
+ {
+ if (a < 0)
+ {
+ c = -a;
+ }
+ else
+ {
+ c = a;
+ }
+ }
+else
+ {
+ if (b < 0)
+ {
+ c = -b;
+ }
+ else
+ {
+ c = b;
+ }
+ }
+
|
- Exceptions.
+ Exception to Indentation Rule for Braces.
The exception is braces that following structure, enumeration, union, and function declarations.
There is no additional indentation for those braces;
those braces align with the beginning of the definition
@@ -840,6 +904,7 @@ int animals(int animal)
{
...
}
+
@@ -1291,14 +1356,28 @@ typedef int myinteger_t;
No un-named structures.
All structures must be named, even if they are part of a type definition.
- The exception to this rule is for structures that are defined within another union or structure. In those cases, the structure name should always be omitted.
+ That is, a structure name must follow the reserved word struct
in all structure definitions.
+ The exception to this rule is for structures that are defined within another union or structure (discouraged). In those cases, the structure name should always be omitted.
+
+
+ Structured defined with structures discouraged.
+ Fields within a structure may be another structure that is defined only with the scope of the containing structure.
+ This practice is acceptable, but discouraged.
+
+ No un-named structure fields.
+ Structure may contain other structures as fields.
+ This this case, the structure field must be named.
+ C11 permits such un-named structure fields within a structure.
+ NuttX generally follows C89 and all code outside of architecture specific directories must be compatible with C89.
No structure definitions within Type Definition.
The practice of defining a structure within a type definition is discouraged.
It is preferred that the structure definition and the type definition be separate definitions.
In general, the NuttX coding style discourages any typdef
-ing of structures;
normally the full structure name is used as types throughout the code.
+ The reason for this is that is structure pointers may be forward referenced in header files without having to include the file the provides the type definition.
+ This greatly reduces header file coupling.
Short structure names.
@@ -1373,7 +1452,7 @@ typedef int myinteger_t;
Incorrect
-typedef struct
+typedef struct /* Un-named structure */
{
...
int val1, val2, val3; /* Values 1-3 */
@@ -1388,33 +1467,97 @@ struct xyz_information
bitc : 1; /* Bit C */
...
};
+
+struct abc_s
+{
+ ...
+ struct
+ {
+ int a; /* Value A */
+ int b; /* Value B */
+ int c; /* Value C */
+ }; /* Un-named structure field */
+ ...
+};
+
|
- Correct
-
+
+
+
+ Correct
+
+
struct xyz_info_s
{
...
- int val1; /* Value 1. */
- int val2; /* Value 2. */
- int val3; /* Value 3. */
+ int val1; /* Value 1 */
+ int val2; /* Value 2 */
+ int val3; /* Value 3 */
...
};
-
-typdef struct xyz_info_s xzy_info_t;
+
+
+ Discouraged
+
+
+typedef struct xyz_info_s xzy_info_t;
-(The use of typedef'ed structures is acceptable but discouraged)
+
+ The use of typedef'ed structures is acceptable but discouraged.
+
+
+
+ Correct
+
struct xyz_info_s
{
...
- uint8_t bita : 1, /* Bit A. */
- uint8_t bitb : 1, /* Bit B. */
- uint8_t bitc : 1, /* Bit C. */
+ uint8_t bita : 1, /* Bit A */
+ uint8_t bitb : 1, /* Bit B */
+ uint8_t bitc : 1, /* Bit C */
+ ...
+};
+
+
+
+ Discouraged
+
+
+struct abc_s
+{
+ ...
+ struct
+ {
+ int a; /* Value A */
+ int b; /* Value B */
+ int c; /* Value C */
+ } abc;
...
};
+
+
+ The use of structures defined within other structures is acceptable provided that they define named fields.
+ The general practice of defining a structure within the scope of another structure, however, is still but discouraged in any case.
+ The following is preferred:
+
+
+
+ Preferred
+
+
+struct abc_s
+{
+ ...
+ int a; /* Value A */
+ int b; /* Value B */
+ int c; /* Value C */
+ ...
+};
+
|
@@ -1433,13 +1576,18 @@ struct xyz_info_s
Example
-union xyz_union_u
+union xyz_union_u /* All unions must be named */
{
- uint8_t b[4]; /* Byte values. */
- uint16_t h[2]; /* Half word values. */
- uint32_t w; /* Word Value. */
+ uint8_t b[4]; /* Byte values. */
+ uint16_t h[2]; /* Half word values. */
+ uint32_t w; /* Word Value. */
};
-
+
+
+typedef union xyz_union_u xzy_union_t;
+
+The use of typedef'ed unions is acceptable but discouraged.
+
struct xyz_info_s
{
...
@@ -1448,17 +1596,18 @@ struct xyz_info_s
uint8_t b[4]; /* Byte values. */
uint16_t h[2]; /* Half word values. */
uint32_t w; /* Word Value. */
- } u;
+ } u; /* All union fields must be named */
...
};
+
|
NOTE:
- Note that the union name u
is used often.
+ Note that the union fields within structures are often named u
.
This is another exception to the prohibition against using single character variable and field names.
- The short field name u
clearly identifies a union field and prevents the full name to the union value from being excessively long.
+ The short field name u
clearly identifies a union field and prevents the full name of the union value from being excessively long.
@@ -1527,7 +1676,7 @@ enum xyz_state_e
Lowercase Exceptions.
- There are3 a few lower case values in NuttX macro names. Such as a lower-case p
for a period or decimal point (such as VOLTAGE_3p3V
).
+ There are a few lower case values in NuttX macro names. Such as a lower-case p
for a period or decimal point (such as VOLTAGE_3p3V
).
I have also used lower-case v
for a version number (such as CONFIG_NET_IPv6
).
However, these are exceptions to the rule rather than illustrating a rule.
@@ -2001,12 +2150,24 @@ x++;
+
+ Forbidden Multicharacter Forms.
+ Many operators are expressed as a character in combination with =
such as +=
, >=
, >>=
, etc.
+ Some compilers will accept the =
at the beginning or the end of the sequence.
+ This standard, however, requires that the =
always appear last in order to avoid amiguities that may arise if the =
were to appear first. For example, a =++ b;
could also be interpreted as a =+ +b;
or a = ++b
all of which are very different.
+
+
4.4 if then else
Statement
Coding Standard:
-
+
if
separated from <condition>
.
+ The if
keyword and the <condition>
must appear on the same line.
+ The if
keyword and the <condition>
must be separated by a single space.
+
+
Keywords on separate lines.
if <condition>
and else
must lie on separate lines with nothing else present on the line.
@@ -2020,16 +2181,24 @@ x++;
-
Statement(s) always enclosed in braces.
- Statement(s) following the
if <condition>
and else
lines must always be enclosed in braces.
- Braces must follow the if <condition>
and else
lines even in the case where these is no contained statement!
+ Statement(s) following the if <condition>
and else
keywords must always be enclosed in braces.
+ Braces must follow the if <condition>
and else
lines even in the cases where (a) there is no contained statement or (b) there is only a single statement!
-
Braces and indentation.
- The placement of braces and statements must follow the standard rules for braces and indentation.
+ The placement of braces and statements must follow the standard rules for braces and indentation.
-
- Followed by a single blank line.
- The final right brace must be followed by a blank line.
+ Final brace followed by a single blank line.
+ The final right brace of the
if
-else
must be followed by a blank line in most cases (the exception given below).
+ This may be the final brace of the if
compound statement if the else
keyword is not present.
+ Or it may be the the final brace of the else
compound statement if present.
+ A blank line never follows the right brace closing the if
compound statement if the else
keyword is present.
+ Use of braces must follow all other standard rules for braces and spacing.
+
+ -
+ Exception.
+ That blank line must also be omitted for certain cases where the
if <condition>
-else
statement is nested within another compound statement; there should be no blank lines between consecutive right braces as discussed in the standard rules for use of braces.
@@ -2123,6 +2292,11 @@ x++;
Coding Standard:
+ -
+
switch
separated from <value>
.
+ The switch
keyword and the switch <value>
must appear on the same line.
+ The if
keyword and the <value>
must be separated by a single space.
+
-
Falling through.
Falling through a case statement into the next case statement is be permitted as long as a comment is included.
@@ -2141,6 +2315,14 @@ x++;
break
statements are normally indented by two spaces.
When used conditionally with case logic, the placement of the break statement follows normal indentation rules.
+ -
+ Followed by a single blank line.
+ The final right brace that closes the
switch <value>
statement must be followed by a single blank line.
+
+ -
+ Exception.
+ That blank line must be omitted for certain cases where the
switch <value>
statement is nested within another compound statement; there should be no blank lines between consecutive right braces as discussed in the standard rules for use of braces.
+
Other Applicable Coding Standards.
@@ -2176,6 +2358,11 @@ x++;
Coding Standard:
+ -
+
while
separated from <condition>
.
+ The while
keyword and the <condition>
must appear on the same line.
+ The while
keyword and the <condition>
must be separated by a single space.
+
-
Keywords on separate lines.
while <condition>
must lie on a separate line with nothing else present on the line.
@@ -2199,7 +2386,11 @@ x++;
-
Followed by a single blank line.
- The final right brace must be followed by a blank line.
+ The final right brace that closes the
while <condition>
statment must be followed by a single blank line.
+
+ -
+ Exception.
+ That blank line must be omitted for certain cases where the
while <condition>
statement is nested within another compound statement; there should be no blank lines between consecutive right braces as discussed in the standard rules for use of braces.
@@ -2247,15 +2438,20 @@ x++;
Statements enclosed in braces
- Statement(s) following the do
must always be enclosed in braces, even if only a single statement follows.
+ Statement(s) following the do
must always be enclosed in braces, even if only a single statement (or no statement) follows.
Braces and indentation.
The placement of braces and statements must follow the standard rules for braces and indentation.
+
+ while
separated from <condition>
.
+ The while
keyword and the <condition>
must appear on the same line.
+ The while
keyword and the <condition>
must be separated by a single space.
+
Followed by a single blank line.
- The final right brace must be followed by a blank line.
+ The concluding while <condition>
must be followed by a single blank line.
@@ -2290,6 +2486,7 @@ x++;
ptr++;
}
while (*ptr != '\0');
+
diff --git a/Documentation/NuttxPortingGuide.html b/Documentation/NuttxPortingGuide.html
index 2e20d72ac9da106e47e41da3c0c26b9daeaa4704..01abeba222bef3956bf434a9bbbf7ed36c67cd23 100644
--- a/Documentation/NuttxPortingGuide.html
+++ b/Documentation/NuttxPortingGuide.html
@@ -12,7 +12,7 @@
NuttX RTOS Porting Guide
- Last Updated: February 7, 2017
+ Last Updated: May 20, 2017
@@ -149,7 +149,7 @@
4.5.16 up_addrenv_kstackfree()
4.6 boardctl()
Application Interface
- 4.7 Symmetric Multiprocssing (SMP) Application Interface
+ 4.7 Symmetric Multiprocessing (SMP) Application Interface
+ 4.12 I/O Buffer Management
+
5.0 NuttX File System
6.0 NuttX Device Drivers
@@ -253,7 +260,7 @@
Directory Structure.
- The general directly layout for NuttX is very similar to the directory structure
+ The general directory layout for NuttX is very similar to the directory structure
of the Linux kernel -- at least at the most superficial layers.
At the top level is the main makefile and a series of sub-directories identified
below and discussed in the following paragraphs:
@@ -416,7 +423,7 @@
Chip/SoC specific files.
Each processor processor architecture is embedded in chip or System-on-a-Chip (SoC) architecture.
The full chip architecture includes the processor architecture plus chip-specific interrupt logic,
- clocking logic, general purpose I/O (GIO) logic, and specialized, internal peripherals (such as UARTs, USB, etc.).
+ clocking logic, general purpose I/O (GPIO) logic, and specialized, internal peripherals (such as UARTs, USB, etc.).
These chip-specific files are contained within chip-specific sub-directories in the
arch/
<arch-name>/
directory and are selected via
@@ -742,12 +749,10 @@
| `-- (board-specific source files)
|-- <config1-dir>
| |-- Make.defs
-| |-- defconfig
-| `-- setenv.sh
+| `-- defconfig
|-- <config2-dir>
| |-- Make.defs
-| |-- defconfig
-| `-- setenv.sh
+| `-- defconfig
| ...
`-- (other board-specific configuration sub-directories)/
@@ -780,7 +785,7 @@
The configs/
<board-name>/
sub-directory holds all of the
files that are necessary to configure NuttX for the particular board.
A board may have various different configurations using the common source files.
- Each board configuration is described by three files: Make.defs
, defconfig
, and setenv.sh
.
+ Each board configuration is described by two files: Make.defs
and defconfig
.
Typically, each set of configuration files is retained in a separate configuration sub-directory
(<config1-dir>, <config2-dir>, .. in the above diagram).
@@ -836,15 +841,6 @@
most C files in the system.
-
-
- setenv.sh
: This is a script that can be included that will be installed at
- the top level of the directory structure and can be sourced to set any
- necessary environment variables.
- You will most likely have to customize the default setenv.sh
script in order
- for it to work correctly in your environment.
-
-
@@ -912,7 +908,7 @@ config ARCH_BOARD
In our case, these files reside in configs/myboard
and we add the following to the long list of defaults (again in alphabetical order):
- default "myboar" if ARCH_BOARD_MYBOARD
+ default "myboard" if ARCH_BOARD_MYBOARD
Now the build system knows where to find your board configuration!
@@ -1015,7 +1011,7 @@ drivers/
|-- spi/
| |-- Kconfig
| |-- Make.defs
-| `-- (Common SPI-related drivers and helper fuctions)
+| `-- (Common SPI-related drivers and helper functions)
|-- syslog/
| |-- Kconfig
| |-- Make.defs
@@ -1145,7 +1141,7 @@ include/
| |-input/
| | `-- (Input device driver header files)
| |-ioexpander/
-| | `-- (I/O exander and GPIO drvier header files)
+| | `-- (I/O expander and GPIO driver header files)
| |-lcd/
| | `-- (LCD driver header files)
| |-leds/
@@ -1188,7 +1184,7 @@ include/
This is a (almost) empty directory that has a holding place for generated static libraries.
- The NuttX build system generates a collection of such static libraries in this directory during the compile phaase.
+ The NuttX build system generates a collection of such static libraries in this directory during the compile phase.
These libraries are then in a known place for the final link phase where they are accessed to generated the final binaries.
@@ -1313,7 +1309,7 @@ tools/
|-- cnvwindeps.c
|-- copydir.sh / copydir.bat
|-- define.sh / define.bat
-|-- incdir.sh / indir.bat
+|-- incdir.sh / incdir.bat
|-- indent.sh
|-- link.sh / link.bat
|-- mkconfig.c
@@ -1364,7 +1360,6 @@ tools/
- Copy
configs/
<board-name>/[
<config-dir>/]Make.defs
to ${TOPDIR}/Make.defs
, -
-
- Copy
configs/
<board-name>/[
<config-dir>/]setenv.sh
to ${TOPDIR}/setenv.sh
, and
- Copy
configs/
<board-name>/[
<config-dir>/]defconfig
to ${TOPDIR}/.config
@@ -1464,7 +1459,6 @@ tools/version.h -v 6.1 .version
cd ${TOPDIR}
-source ./setenv.sh
make
@@ -1477,15 +1471,12 @@ make
That directory also holds:
- - The makefile fragment
.config
that describes the current configuration.
- - The makefile fragment
Make.defs
that provides customized build targets, and
- - The shell script
setenv.sh
that sets up the configuration environment for the build.
+ - The makefile fragment
.config
that describes the current configuration, and
+ - The makefile fragment
Make.defs
that provides customized build targets.
-The setenv.sh
contains Linux/Cygwin environmental settings that are needed for the build.
+Environment Variables.
The specific environmental definitions are unique for each board but should include, as a minimum, updates to the PATH
variable to include the full path to the architecture-specific toolchain identified in Make.defs
.
-The setenv.sh
only needs to be source'ed at the beginning of a session.
-The system can be re-made subsequently by just typing make
.
First Time Make.
@@ -2146,7 +2137,7 @@ else
Most MCUs include RTC hardware built into the chip.
Other RTCs, external MCUs, may be provided as separate chips typically
interfacing with the MCU via a serial interface such as SPI or I2C.
- These external RTCs differ from the builtin RTCs in that they cannot be initialized
+ These external RTCs differ from the built-in RTCs in that they cannot be initialized
until the operating system is fully booted and can support the required serial
communications. CONFIG_RTC_EXTERNAL
will configure the operating
system so that it defers initialization of its time facilities.
@@ -2174,7 +2165,7 @@ else
up_rtc_initialize()
.
- Initialize the builtin, MCU hardware RTC per the selected configuration.
+ Initialize the built-in, MCU hardware RTC per the selected configuration.
This function is called once very early in the OS initialization sequence.
NOTE that initialization of external RTC hardware that depends on the
availability of OS resources (such as SPI or I2C) must be deferred
@@ -2307,7 +2298,7 @@ config ARCH_SIM
In the default configuration where system time is provided by a periodic timer interrupt, the default system timer is configure the timer for 100Hz or CONFIG_USEC_PER_TICK=10000
. If CONFIG_SCHED_TICKLESS
is selected, then there are no system timer interrupt. In this case, CONFIG_USEC_PER_TICK
does not control any timer rates. Rather, it only determines the resolution of time reported by clock_systimer()
and the resolution of times that can be set for certain delays including watchdog timers and delayed work.
- In this case there is still a trade-off: It is better to have the CONFIG_USEC_PER_TICK
as low as possible for higher timing resolution. However, the the time is currently held in unsigned int
. On some systems, this may be 16-bits in width but on most contemporary systems it will be 32-bits. In either case, smaller values of CONFIG_USEC_PER_TICK
will reduce the range of values that delays that can be represented. So the trade-off is between range and resolution (you could also modify the code to use a 64-bit value if you really want both).
+ In this case there is still a trade-off: It is better to have the CONFIG_USEC_PER_TICK
as low as possible for higher timing resolution. However, the time is currently held in unsigned int
. On some systems, this may be 16-bits in width but on most contemporary systems it will be 32-bits. In either case, smaller values of CONFIG_USEC_PER_TICK
will reduce the range of values that delays that can be represented. So the trade-off is between range and resolution (you could also modify the code to use a 64-bit value if you really want both).
The default, 100 microseconds, will provide for a range of delays up to 120 hours.
@@ -2318,14 +2309,14 @@ config ARCH_SIM
-
+
The interfaces that must be provided by the platform specified code are defined in include/nuttx/arch.h
, listed below, and summarized in the following paragraphs:
-
<arch>
_timer_initialize()
:
- Initializes the timer facilities. Called early in the intialization sequence (by up_intialize()
).
+ Initializes the timer facilities. Called early in the initialization sequence (by up_initialize()
).
-
up_timer_gettime()
:
@@ -2345,7 +2336,7 @@ config ARCH_SIM
-
up_alarm_start()
:
- Enables (or re-enables) the alaram.
+ Enables (or re-enables) the alarm.
@@ -2388,7 +2379,7 @@ void <arch>_timer_initialize()(void);
Description:
- Initializes all platform-specific timer facilities. This function is called early in the initialization sequence by up_intialize()
. On return, the current up-time should be available from up_timer_gettime()
and the interval timer is ready for use (but not actively timing).
+ Initializes all platform-specific timer facilities. This function is called early in the initialization sequence by up_initialize()
. On return, the current up-time should be available from up_timer_gettime()
and the interval timer is ready for use (but not actively timing).
Input Parameters:
@@ -2424,7 +2415,7 @@ int up_timer_gettime(FAR struct timespec *ts);
Assumptions:
- Called from the the normal tasking context. The implementation must provide whatever mutual exclusion is necessary for correct operation. This can include disabling interrupts in order to assure atomic register operations.
+ Called from the normal tasking context. The implementation must provide whatever mutual exclusion is necessary for correct operation. This can include disabling interrupts in order to assure atomic register operations.
@@ -2447,7 +2438,7 @@ int up_alarm_cancel(FAR struct timespec *ts);
Assumptions:
- May be called from interrupt level handling or from the normal tasking level. iterrupts may need to be disabled internally to assure non-reentrancy.
+ May be called from interrupt level handling or from the normal tasking level. interrupts may need to be disabled internally to assure non-reentrancy.
@@ -2457,7 +2448,7 @@ int up_alarm_cancel(FAR struct timespec *ts);
int up_alarm_start(FAR const struct timespec *ts);
Description:
- Start the alarm. sched_timer_expiration()
will be called when the alarm occurs (unless up_alaram_cancel
is called to stop it).
+ Start the alarm. sched_timer_expiration()
will be called when the alarm occurs (unless up_alarm_cancel
is called to stop it).
Input Parameters:
@@ -2493,7 +2484,7 @@ int up_timer_cancel(FAR struct timespec *ts);
Assumptions:
- May be called from interrupt level handling or from the normal tasking level. iterrupts may need to be disabled internally to assure non-reentrancy.
+ May be called from interrupt level handling or from the normal tasking level. interrupts may need to be disabled internally to assure non-reentrancy.
@@ -2721,7 +2712,7 @@ VxWorks provides the following comparable interface:
#include <nuttx/wdog.h>
- Sint wd_gettime(WDOG_ID wdog);
+ int wd_gettime(WDOG_ID wdog);
Description:
@@ -2777,7 +2768,7 @@ typedef uint32_t wdparm_t;
Classes of Work Queues.
- There are three different classes of work queues, each with different properties and intended usage. These class of work queues along with the the common work queue interface are described in the following paragraphs.
+ There are three different classes of work queues, each with different properties and intended usage. These class of work queues along with the common work queue interface are described in the following paragraphs.
@@ -2796,13 +2787,13 @@ typedef uint32_t wdparm_t;
CONFIG_SCHED_HPWORK
.
- Enables the hight prioirity work queue.
+ Enables the hight priority work queue.
CONFIG_SCHED_HPWORKPRIORITY
.
The execution priority of the high-priority worker thread. Default: 224
CONFIG_SCHED_HPWORKPERIOD
.
- How often the worker thread re-checks for work in units of microseconds. This work period is really only necessary if the the high priority thread is performing periodic garbage collection. The worker thread will be awakened immediately with it is queued work to be done. If the high priority worker thread is performing garbage collection, then the default is 50*1000 (50 MS). Otherwise, if the lower priority worker thread is performing garbage collection, the default is 100*1000.
+ How often the worker thread re-checks for work in units of microseconds. This work period is really only necessary if the high priority thread is performing periodic garbage collection. The worker thread will be awakened immediately with it is queued work to be done. If the high priority worker thread is performing garbage collection, then the default is 50*1000 (50 MS). Otherwise, if the lower priority worker thread is performing garbage collection, the default is 100*1000.
CONFIG_SCHED_HPWORKSTACKSIZE
.
The stack size allocated for the worker thread in bytes. Default: 2048.
@@ -2824,7 +2815,7 @@ typedef uint32_t wdparm_t;
Compared to the High Priority Work Queue.
- The lower priority work queue runs at a lower priority than the high priority work queue, of course, and so is inapproperiate to serve as a driver bottom half. The lower priority work queue has the other advantages, however, that make it better suited for some tasks:
+ The lower priority work queue runs at a lower priority than the high priority work queue, of course, and so is inappropriate to serve as a driver bottom half. The lower priority work queue has the other advantages, however, that make it better suited for some tasks:
-
@@ -2934,7 +2925,7 @@ typedef uint32_t wdparm_t;
-
struct work_s
.
- Defines one entry in the work queue. This is a client-allocated structure. Work queue clients should not reference any field in this structure since they are subjec to change. The user only needs this structure in order to declare instances of the work structure. Handling of all fields is performed by the work queue interfaces described below.
+ Defines one entry in the work queue. This is a client-allocated structure. Work queue clients should not reference any field in this structure since they are subject to change. The user only needs this structure in order to declare instances of the work structure. Handling of all fields is performed by the work queue interfaces described below.
@@ -3194,7 +3185,7 @@ void lpwork_restorepriority(uint8_t reqprio);
CPUs that support memory management units (MMUs) may provide address environments within which tasks and their child threads execute.
The configuration indicates the CPUs ability to support address environments by setting the configuration variable CONFIG_ARCH_HAVE_ADDRENV=y
.
- That will enable the selection of the actual address evironment support which is indicated by the selection of the configuration variable CONFIG_ARCH_ADDRENV=y
.
+ That will enable the selection of the actual address environment support which is indicated by the selection of the configuration variable CONFIG_ARCH_ADDRENV=y
.
These address environments are created only when tasks are created via exec()
or exec_module()
(see include/nuttx/binfmt/binfmt.h
).
@@ -3706,7 +3697,7 @@ void lpwork_restorepriority(uint8_t reqprio);
-1 (ERROR
) is returned on failure with the errno
variable to to indicate the nature of the failure.
-
+
According to Wikipedia: "Symmetric multiprocessing (SMP) involves a symmetric multiprocessor system hardware and software architecture where two or more identical processors connect to a single, shared main memory, have full access to all I/O devices, and are controlled by a single operating system instance that treats all processors equally, reserving none for special purposes. Most multiprocessor systems today use an SMP architecture. In the case of multi-core processors, the SMP architecture applies to the cores, treating them as separate processors.
@@ -3789,7 +3780,7 @@ int up_cpu_start(int cpu);
Description:
- In an SMP configution, only one CPU is initially active (CPU 0).
+ In an SMP configuration, only one CPU is initially active (CPU 0).
System initialization occurs on that single thread.
At the completion of the initialization of the OS, just before beginning normal multitasking, the additional CPUs would be started by calling this function.
@@ -3935,7 +3926,7 @@ void sched_timer_expiration(void);
Base code implementation assumes that this function is called from interrupt handling logic with interrupts disabled.
-
+
Function Prototype:
#include <nuttx/arch.h>
@@ -4165,11 +4156,11 @@ void board_autoled_off(int led);
NOTE: In most architectures, board_autoled_initialize()
is called from board-specific initialization logic.
But there are a few architectures where this initialization function is still called from common chip architecture logic.
- This interface is nott, however, a common board interface in any event.
+ This interface is not, however, a common board interface in any event.
WARNING: This interface name will eventually be removed; do not use it in new board ports.
- New implementations should not use the naming convention for common board interfaces, but should instted use the naming conventions for microprocessor-specific interfaces or the board-specific interfaces (such as stm32_led_initialize()
).
+ New implementations should not use the naming convention for common board interfaces, but should instead use the naming conventions for microprocessor-specific interfaces or the board-specific interfaces (such as stm32_led_initialize()
).
@@ -4188,6 +4179,429 @@ void board_autoled_off(int led);
+
+
+NuttX supports generic I/O buffer management (IOB) logic.
+This logic was originally added to support network I/O buffering, but has been generalized to meet buffering requirements by all device drivers.
+At the time of this writing, IOBs are currently used not only be networking but also by logic in drivers/syslog
and drivers/wireless
.
+NOTE that some of the wording in this section still reflects those legacy roots as a part of the networking subsystem.
+This objectives of this feature are:
+
+
+ -
+ Provide common I/O buffer management logic for all drivers,
+
+ -
+ Support I/O buffer allocation from both the tasking and interrupt level contexts.
+
+ -
+ Use a fixed amount of pre-allocated memory.
+
+ -
+ No costly, non-deterministic dynamic memory allocation.
+
+ -
+ When the fixed number of pre-allocated I/O buffers is exhausted, further attempts to allocate memory from tasking logic will cause the task to block and wait until a an I/O buffer to be freed.
+
+ -
+ Each I/O buffer should be small, but can be chained together to support buffering of larger thinks such as full size network packets.
+
+ -
+ Support throttling logic to prevent lower priority tasks from hogging all available I/O buffering.
+
+
+
+
+
+
+ CONFIG_MM_IOB
+ - Enables generic I/O buffer support. This setting will build the common I/O buffer (IOB) support library.
+
+
CONFIG_IOB_NBUFFERS
+ - Number of pre-allocated I/O buffers. Each packet is represented by a series of small I/O buffers in a chain. This setting determines the number of preallocated I/O buffers available for packet data.
+
+ The default value is setup for network support. The default is 8 buffers if neither TCP read-ahead or TCP write buffering is enabled (neither
CONFIG_NET_TCP_WRITE_BUFFERS
nor CONFIG_NET_TCP_READAHEAD
), 24 if only write buffering is enabled, and 36 if both read-ahead and write buffering are enabled.
+
+ CONFIG_IOB_BUFSIZE
+ - Payload size of one I/O buffer. Each packet is represented by a series of small I/O buffers in a chain. This setting determines the data payload each preallocated I/O buffer. The default value is 196 bytes.
+
+
CONFIG_IOB_NCHAINS
+ - Number of pre-allocated I/O buffer chain heads. These tiny nodes are used as containers to support queueing of I/O buffer chains. This will limit the number of I/O transactions that can be in-flight at any give time. The default value of zero disables this features.
+
+
- These generic I/O buffer chain containers are not currently used by any logic in NuttX. That is because their other other specialized I/O buffer chain containers that also carry a payload of usage specific information.
+
+ The default value is zero if nether TCP nor UDP read-ahead buffering is enabled (i.e., neither
CONFIG_NET_TCP_READAHEAD
&& !CONFIG_NET_UDP_READAHEAD
or eight if either is enabled.
+
+ CONFIG_IOB_THROTTLE
+ - I/O buffer throttle value. TCP write buffering and read-ahead buffer use the same pool of free I/O buffers. In order to prevent uncontrolled incoming TCP packets from hogging all of the available, pre-allocated I/O buffers, a throttling value is required. This throttle value assures that I/O buffers will be denied to the read-ahead logic before TCP writes are halted.
+
+ The default 0 if neither TCP write buffering nor TCP read-ahead buffering is enabled. Otherwise, the default is 8.
+
+
CONFIG_IOB_DEBUG
+ - Force I/O buffer debug. This option will force debug output from I/O buffer logic. This is not normally something that would want to do but is convenient if you are debugging the I/O buffer logic and do not want to get overloaded with other un-related debug output.
+
+ NOTE that this selection is not available if DEBUG features are not enabled (
CONFIG_DEBUG_FEATURES
) with IOBs are being used to syslog buffering logic (CONFIG_SYSLOG_BUFFER
).
+
+
+
+
+
+An allocation throttle was added. I/O buffer allocation logic supports a throttle value originally for read-ahead buffering to prevent the read-ahead logic from consuming all available I/O buffers and blocking the write buffering logic. This throttle logic is only needed for networking only if both write buffering and read-ahead buffering are used. Of use of I/O buffering might have other motivations for throttling.
+
+
+
+
+ This structure represents one I/O buffer. A packet is contained by one or more I/O buffers in a chain. The io_pktlen
is only valid for the I/O buffer at the head of the chain.
+
+
+
+struct iob_s
+{
+ /* Singly-link list support */
+
+ FAR struct iob_s *io_flink;
+
+ /* Payload */
+
+#if CONFIG_IOB_BUFSIZE < 256
+ uint8_t io_len; /* Length of the data in the entry */
+ uint8_t io_offset; /* Data begins at this offset */
+#else
+ uint16_t io_len; /* Length of the data in the entry */
+ uint16_t io_offset; /* Data begins at this offset */
+#endif
+ uint16_t io_pktlen; /* Total length of the packet */
+
+ uint8_t io_data[CONFIG_IOB_BUFSIZE];
+};
+
+
+
+ This container structure supports queuing of I/O buffer chains. This structure is intended only for internal use by the IOB module.
+
+
+
+#if CONFIG_IOB_NCHAINS > 0
+struct iob_qentry_s
+{
+ /* Singly-link list support */
+
+ FAR struct iob_qentry_s *qe_flink;
+
+ /* Payload -- Head of the I/O buffer chain */
+
+ FAR struct iob_s *qe_head;
+};
+#endif /* CONFIG_IOB_NCHAINS > 0 */
+
+
+
+ The I/O buffer queue head structure.
+
+
+
+#if CONFIG_IOB_NCHAINS > 0
+struct iob_queue_s
+{
+ /* Head of the I/O buffer chain list */
+
+ FAR struct iob_qentry_s *qh_head;
+ FAR struct iob_qentry_s *qh_tail;
+};
+#endif /* CONFIG_IOB_NCHAINS > 0 */
+
+
+
+
+
+
+
+Function Prototype:
+
+#include <nuttx/mm/iob.h>
+void iob_initialize(void);
+
+
+Description.
+ Set up the I/O buffers for normal operations.
+
+
+
+Function Prototype:
+
+#include <nuttx/mm/iob.h>
+FAR struct iob_s *iob_alloc(bool throttled);
+
+
+Description.
+ Allocate an I/O buffer by taking the buffer at the head of the free list.
+
+
+
+Function Prototype:
+
+#include <nuttx/mm/iob.h>
+FAR struct iob_s *iob_tryalloc(bool throttled);
+
+
+Description.
+ Try to allocate an I/O buffer by taking the buffer at the head of the free list without waiting for a buffer to become free.
+
+
+
+Function Prototype:
+
+#include <nuttx/mm/iob.h>
+FAR struct iob_s *iob_free(FAR struct iob_s *iob);
+
+
+Description.
+ Free the I/O buffer at the head of a buffer chain returning it to the free list. The link to the next I/O buffer in the chain is return.
+
+
+
+Function Prototype:
+
+#include <nuttx/mm/iob.h>
+void iob_free_chain(FAR struct iob_s *iob);
+
+
+Description.
+ Free an entire buffer chain, starting at the beginning of the I/O buffer chain
+
+
+
+Function Prototype:
+
+#include <nuttx/mm/iob.h>
+#if CONFIG_IOB_NCHAINS > 0
+int iob_add_queue(FAR struct iob_s *iob, FAR struct iob_queue_s *iobq);
+#endif /* CONFIG_IOB_NCHAINS > 0 */
+
+
+Description.
+ Add one I/O buffer chain to the end of a queue. May fail due to lack of resources.
+
+
+
+Function Prototype:
+
+#include <nuttx/mm/iob.h>
+#if CONFIG_IOB_NCHAINS > 0
+int iob_tryadd_queue(FAR struct iob_s *iob, FAR struct iob_queue_s *iobq);
+#endif /* CONFIG_IOB_NCHAINS > 0 */
+
+
+Description.
+ Add one I/O buffer chain to the end of a queue without waiting for resources to become free.
+
+
+
+Function Prototype:
+
+#include <nuttx/mm/iob.h>
+#if CONFIG_IOB_NCHAINS > 0
+FAR struct iob_s *iob_remove_queue(FAR struct iob_queue_s *iobq);
+#endif /* CONFIG_IOB_NCHAINS > 0 */
+
+
+Description.
+ Remove and return one I/O buffer chain from the head of a queue.
+
+
+Returned Value.
+ Returns a reference to the I/O buffer chain at the head of the queue.
+
+
+
+Function Prototype:
+
+#include <nuttx/mm/iob.h>
+#if CONFIG_IOB_NCHAINS > 0
+FAR struct iob_s *iob_peek_queue(FAR struct iob_queue_s *iobq);
+#endif
+
+
+Description.
+ Return a reference to the I/O buffer chain at the head of a queue. This is similar to iob_remove_queue except that the I/O buffer chain is in place at the head of the queue. The I/O buffer chain may safely be modified by the caller but must be removed from the queue before it can be freed.
+
+
+Returned Value.
+ Returns a reference to the I/O buffer chain at the head of the queue.
+
+
+
+Function Prototype:
+
+#include <nuttx/mm/iob.h>
+#if CONFIG_IOB_NCHAINS > 0
+void iob_free_queue(FAR struct iob_queue_s *qhead);
+#endif /* CONFIG_IOB_NCHAINS > 0 */
+
+
+Description.
+ Free an entire queue of I/O buffer chains.
+
+
+
+Function Prototype:
+
+#include <nuttx/mm/iob.h>
+int iob_copyin(FAR struct iob_s *iob, FAR const uint8_t *src,
+ unsigned int len, unsigned int offset, bool throttled);
+
+
+Description.
+ Copy data len
bytes from a user buffer into the I/O buffer chain, starting at offset
, extending the chain as necessary.
+
+
+
+Function Prototype:
+
+#include <nuttx/mm/iob.h>
+int iob_trycopyin(FAR struct iob_s *iob, FAR const uint8_t *src,
+ unsigned int len, unsigned int offset, bool throttled);
+
+
+Description.
+ Copy data len
bytes from a user buffer into the I/O buffer chain, starting at offset
, extending the chain as necessary BUT without waiting if buffers are not available.
+
+
+
+Function Prototype:
+
+#include <nuttx/mm/iob.h>
+int iob_copyout(FAR uint8_t *dest, FAR const struct iob_s *iob,
+ unsigned int len, unsigned int offset);
+
+
+Description.
+ Copy data len
bytes of data into the user buffer starting at offset
in the I/O buffer, returning that actual number of bytes copied out.
+
+
+
+Function Prototype:
+
+#include <nuttx/mm/iob.h>
+int iob_clone(FAR struct iob_s *iob1, FAR struct iob_s *iob2, bool throttled);
+
+
+Description.
+ Duplicate (and pack) the data in iob1
in iob2
. iob2
must be empty.
+
+
+
+Function Prototype:
+
+#include <nuttx/mm/iob.h>
+void iob_concat(FAR struct iob_s *iob1, FAR struct iob_s *iob2);
+
+
+Description.
+ Concatenate iob_s chain iob2 to iob1.
+
+
+
+Function Prototype:
+
+#include <nuttx/mm/iob.h>
+FAR struct iob_s *iob_trimhead(FAR struct iob_s *iob, unsigned int trimlen);
+
+
+Description.
+ Remove bytes from the beginning of an I/O chain. Emptied I/O buffers are freed and, hence, the beginning of the chain may change.
+
+
+
+Function Prototype:
+
+#include <nuttx/mm/iob.h>
+#if CONFIG_IOB_NCHAINS > 0
+FAR struct iob_s *iob_trimhead_queue(FAR struct iob_queue_s *qhead,
+ unsigned int trimlen);
+#endif
+
+
+Description.
+ Remove bytes from the beginning of an I/O chain at the head of the queue. Emptied I/O buffers are freed and, hence, the head of the queue may change.
+
+
+ This function is just a wrapper around iob_trimhead() that assures that the iob at the head of queue is modified with the trimming operations.
+
+
+Returned Value.
+ The new iob at the head of the queue is returned.
+
+
+
+Function Prototype:
+
+#include <nuttx/mm/iob.h>
+FAR struct iob_s *iob_trimtail(FAR struct iob_s *iob, unsigned int trimlen);
+
+
+Description.
+ Remove bytes from the end of an I/O chain. Emptied I/O buffers are freed NULL will be returned in the special case where the entry I/O buffer chain is freed.
+
+
+
+Function Prototype:
+
+#include <nuttx/mm/iob.h>
+FAR struct iob_s *iob_pack(FAR struct iob_s *iob);
+
+
+Description.
+ Pack all data in the I/O buffer chain so that the data offset is zero and all but the final buffer in the chain are filled. Any emptied buffers at the end of the chain are freed.
+
+
+
+Function Prototype:
+
+#include <nuttx/mm/iob.h>
+int iob_contig(FAR struct iob_s *iob, unsigned int len);
+
+
+Description.
+ Ensure that there is len
bytes of contiguous space at the beginning of the I/O buffer chain starting at iob
.
+
+
+
+Function Prototype:
+
+#include <nuttx/mm/iob.h>
+#ifdef CONFIG_DEBUG_FEATURES
+void iob_dump(FAR const char *msg, FAR struct iob_s *iob, unsigned int len,
+ unsigned int offset);
+#endif
+
+
+Description.
+ Dump the contents of a I/O buffer chain
+
+
@@ -4561,7 +4975,7 @@ void board_autoled_off(int led);
- Interface Definition.
- The header file for the NuttX CAN driver resides at
include/nuttx/drivers/can.h .
+ The header file for the NuttX CAN driver resides at include/nuttx/can/can.h .
This header file includes both the application level interface to the CAN driver as well as the interface between the "upper half" and "lower half" drivers.
The CAN module uses a standard character driver framework.
@@ -5030,11 +5444,11 @@ int kbd_decode(FAR struct lib_instream_s *stream, FAR struct kbd_getstate_s *sta
That structure defines a call table with the following methods:
void lock(FAR struct spi_dev_s *dev);
- void select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
+
void select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected);
uint32_t setfrequency(FAR struct spi_dev_s *dev, uint32_t frequency);
void setmode(FAR struct spi_dev_s *dev, enum spi_mode_e mode);
void setbits(FAR struct spi_dev_s *dev, int nbits);
- uint8_t status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+ uint8_t status(FAR struct spi_dev_s *dev, uint32_t devid);
uint16_t send(FAR struct spi_dev_s *dev, uint16_t wd);
void exchange(FAR struct spi_dev_s *dev, FAR const void *txbuffer, FAR void *rxbuffer, size_t nwords);
int registercallback(FAR struct spi_dev_s *dev, mediachange_t callback, void *arg);
@@ -5702,7 +6116,7 @@ int setlogmask(int mask);
-
- Kernel Build: The kernel build is compliant with the POSIX requirement: There will be one mask for for each user process, controlling the SYSLOG output only form that process. There will be a separate mask accessable only in the kernel code to control kernel SYSLOG output.
+ Kernel Build: The kernel build is compliant with the POSIX requirement: There will be one mask for for each user process, controlling the SYSLOG output only form that process. There will be a separate mask accessible only in the kernel code to control kernel SYSLOG output.
The above are all standard interfaces as defined at OpenGroup.org. Those interfaces are available for use by application software. The remaining interfaces discussed in this section are non-standard, OS-internal interfaces.
@@ -5710,7 +6124,7 @@ int setlogmask(int mask);
- In NuttX, syslog output is really synonymous to debug output and, herefore, the debugging interface macros defined in the header file
+ In NuttX, syslog output is really synonymous to debug output and, therefore, the debugging interface macros defined in the header file
include/debug.h are also syslogging interfaces. Those macros are simply wrappers around syslog() . The debugging interfaces differ from the syslog interfaces in that:
@@ -5744,7 +6158,7 @@ int setlogmask(int mask);
-
warn() . The warn() macro has medium priority (LOG_WARN ) and is controlled by CONFIG_DEBUG_subsystem_WARN . The warn() is intended to
- note exceptional or unexpected conditions that meigh be potential
+ note exceptional or unexpected conditions that might be potential
errors or, perhaps, minor errors that easily recovered.
-
@@ -5796,7 +6210,7 @@ int syslog_channel(FAR const struct syslog_channel_s *channel);
syslog_channel() is a non-standard, internal OS interface and is not available to applications. It may be called numerous times as necessary to change channel interfaces.
By default, all system log output goes to console (/dev/console ).
-Input Parmeters:
+ Input Parameters:
-
@@ -5917,7 +6331,7 @@ int syslog_initialize(enum syslog_init_e phase);
-
- The output generated by up_putc() is immediate and in real-time. The normal SYSLOG output, on the other hand, is buffered in the serial driver and may be delayed with respect to the immediate output by many lines. Therefore, the interrupt level SYSLOG ouput provided throug up_putc() is grossly out of synchronization with other debug output
+ The output generated by up_putc() is immediate and in real-time. The normal SYSLOG output, on the other hand, is buffered in the serial driver and may be delayed with respect to the immediate output by many lines. Therefore, the interrupt level SYSLOG output provided through up_putc() is grossly out of synchronization with other debug output
@@ -5969,7 +6383,7 @@ int syslog_initialize(enum syslog_init_e phase);
-
- CONFIG_SYSLOG_CONSOLE . This configuration option is manually selected from the SYSLOG menu. This is the option that acutally enables the SYSLOG console device. It depends on CONFIG_DEV_CONSOLE and it will automatically select CONFIG_SYSLOG_SERIAL_CONSOLE if CONFIG_SERIAL_CONSOLE is selected.
+ CONFIG_SYSLOG_CONSOLE . This configuration option is manually selected from the SYSLOG menu. This is the option that actually enables the SYSLOG console device. It depends on CONFIG_DEV_CONSOLE and it will automatically select CONFIG_SYSLOG_SERIAL_CONSOLE if CONFIG_SERIAL_CONSOLE is selected.
-
@@ -5998,7 +6412,7 @@ int syslog_initialize(enum syslog_init_e phase);
The system console device, /dev/console , is a character driver with some special properties. However, any character driver may be used as the SYSLOG output channel. For example, suppose you have a serial console on /dev/ttyS0 and you want SYSLOG output on /dev/ttyS1 . Or suppose you support only a Telnet console but want to capture debug output /dev/ttyS0 .
- This SYSLOG device channel is selected with CONFIG_SYSLOG_CHAR and has no other dependencies. Differences fromthe SYSLOG console channel include:
+ This SYSLOG device channel is selected with CONFIG_SYSLOG_CHAR and has no other dependencies. Differences from the SYSLOG console channel include:
-
@@ -6150,7 +6564,7 @@ int syslog_file_channel(FAR const char *devpath);
|
@@ -62,12 +62,16 @@ nuttx/
| | `- README.txt
| |- avr32dev1/
| | `- README.txt
+ | |- b-l475e-iot01a/
+ | | `- README.txt
| |- bambino-200e/
| | `- README.txt
| |- c5471evm/
| | `- README.txt
| |- cc3200-launchpad/
| | `- README.txt
+ | |- clicker2-stm32/
+ | | `- README.txt
| |- cloudctrl/
| | `- README.txt
| |- demo9s12ne64/
@@ -159,8 +163,25 @@ nuttx/
| | `- README.txt
| |- nucleo-144/
| | `- README.txt
+ | | `- README.txt
+ | |- nucleo-f072rb/
+ | | `- README.txt
+ | |- nucleo-f091rc/
+ | | `- README.txt
+ | |- nucleo-f303re/
+ | | `- README.txt
+ | |- nucleo-f334r8/
+ | | `- README.txt
| |- nucleo-f4x1re/
| | `- README.txt
+ | |- nucleo-l432kc/
+ | | `- README.txt
+ | |- nucleo-l452re/
+ | | `- README.txt
+ | |- nucleo-l476rg/
+ | | `- README.txt
+ | |- nucleo-l496zg/
+ | | `- README.txt
| |- nutiny-nuc120/
| | `- README.txt
| |- olimex-efm32g880f129-stk/
@@ -197,6 +218,8 @@ nuttx/
| | `- README.txt
| |- pic32mz-starterkit/
| | `- README.txt
+ | |- photon/
+ | | `- README.txt
| |- qemu-i486/
| | `- README.txt
| |- sabre-6quad/
@@ -297,6 +320,8 @@ nuttx/
| | `- README.txt
| |- viewtool-stm32f107/
| | `- README.txt
+ | |- xmc4500-relax/
+ | | `- README.txt
| |- xtrs/
| | `- README.txt
| |- z16f2800100zcog/
@@ -358,6 +383,8 @@ nuttx/
| | `- README.txt
| `- README.txt
|- net/
+ | |- sixlowpan/
+ | | `- README.txt
| `- README.txt
|- syscall/
| `- README.txt
diff --git a/Documentation/acronyms.txt b/Documentation/acronyms.txt
index 00321607bab048b2e12f18d08de165073a73e785..aab1760a2bb2e4ce74d8bbf2a40a5c0c463cbbc2 100644
--- a/Documentation/acronyms.txt
+++ b/Documentation/acronyms.txt
@@ -1,57 +1,112 @@
-AIC Advanced Interrupt Controller (Atmel SAM)
+6loWPAN IPv6 over Low power Wireless Personal Area Networks
+ACM Abstract Control Model (USB)
ADC Analog to Digital Conversion
+AIC Advanced Interrupt Controller (Atmel SAM)
ARP Address Resolution Protocol (networking)
BCH Block to Character
BINFMT Binary Format (Dynamic Loader)
+BPP Bits Per Pixel
CAN Controller Area Network
+CDC Communication Device Class (USB)
CP15 Coprocessor 15 (ARM)
+CPU Central Processing Unit
DEVIF Device Interface (networking)
DAC Digital to Analog Conversion
+DCD Device Controller Driver (USB)
+DCMI Digital Camera Interface
DEV Device
+DHCP Dynamic Host Configuration Protocol
+DHCPC DHCP Client
+DHCPD DHCP Daemon (server)
DMA Direct Memory Access (hardware)
DMAC DMA Controller (hardware)
+DNS Domain Name Service (or System or Server) (networking)
DRAM Dynamic RAM
+EABI Embedded-Application Binary Interface
+EEPROM Electrically Erasable Programmable Read-Only Memory
+EMAC Ethernet Media Access Controller (networking)
+EPROM Erasable Programmable Read-Only Memory
FAT File Allocation Table (file systems)
+FB Frame Buffer (video interface)
+FSMC Flexible Static Memory Controller (STM32)
FTL FLASH Translation Layer (MTD)
+GPIO General Purpose Input/Output
+GMAC Gigabit Media Access Controller (networking)
+HCD Host Controller Driver (USB)
HSMCI High Speed Memory Card Interface (Atmel)
I/O Input/Output
+IOCTL Input/Output Control
+IoT Internet of Things (marketing BS)
IP Internet Protocol (version 4?) (networking)
+IPv4 Internet Protocol Version 4 (networking)
IPv6 Internet Protocol Version 6 (networking)
-IRQ Interrupt Request
-I2C Inter-Integrated Circuit
-I2S Inter IC Sound
+IRQ Interrupt Request (hardware)
+I2C Inter-Integrated Circuit (serial interface)
+I2S Inter IC Sound (serial interface)
ICMP Internet Control Message Protocol (networking)
+ICMPv6 Internet Control Message Protocol for IPv6 (networking)
+IGMP Internet Group Multicast Protocol (networking)
IOB I/O Buffer (networking)
+LAN Local Area Network (networking)
+LCD Liquid Crystal Display
LIBC The "C" Library
+LIBM The "C" Math Library
+MAC Media Access Control (networking, OSI model)
MCI Memory Card Interface
+MCU Microcontroller Unit
MM Memory Management/Manager
MMAP Memory Map
MMC Multi-Media Card
MMCSD See MMC and SD
+MMU Memory Management Unit
+MPU Memory Protection Unit
MTD Memory Technology Device
NFS Network File System
+NETDB Network Data Base (networking)
NETDEV Network Device (networking)
NSH NuttShell
+NVM Non-Volatile Memory
+NTP Network Time Protocol (networking)
NX NuttX, the NuttX Graphics server (graphics)
NXFFS NuttX Flash File System
NXWM The NuttX Window Manager (graphics)
-PID Peripheral ID (Atmel SAM)
+PID Process ID (operating systems)
+ Peripheral ID (Atmel SAM)
+PROM Programmable Read-Only Memory
+OS Operating System
+OTG On-The-Go (USB)
+OTP One-Time Programmable
PWM Pulse Width Modulation
PKT "Raw" Packet socket (networking)
+PRNG Pseudo-Random Number Generator
RAM Random Access Memory
+RNG Random Number Generator
+ROM Read-Only Memory
RTC Real Time Clock
RTCC Real Time Clock/Calendar
+RTOS Real Time Operating System
SAIC Secure Advanced Interrupt Controller (Atmel SAM)
-SD Secure Digital
+SD Secure Digital (flash memory)
+SDHC Secure Digital High Capacity (flash memory),
+ Secure Digital Host Controller (hardware)
SDIO Secure Digital I/O
+SDRAM Synchronous Dynamic Random Access Memory
+SLCD Segment Liquid Crystal Display
SMC Static Memory Controller (hardware)
SPI Serial Periperhal Interface
+SPRNG Scalable Parallel Random Number Generator
+SRAM Static RAM
+SYSLOG System Log
TCP Transmission Control Protocol (networking)
TSC Touchscreen Controller
-TWI Two-Wire Interface
+TUN network TUNnel
+TWI Two-Wire Interface (serial interface)
UDP User Datagram Protocol (networking)
UART Universal Asynchronous Receiver/Transmitter
-USB Universal Serial Bus
+USB Universal Serial Bus (serial interface)
USART Universal Synchronous/Asynchronous Receiver/Transmitter
-WDT Watchdog Timer
+WAN Wide Area Network (networking)
+WLAN Wireless Local Area Network (networking)
+WPAN Wireless Personal Area Network (networking)
+WDT Watchdog Timer (hardware)
XDMAC Extended DMA Controller (Atmel)
diff --git a/FlatLibs.mk b/FlatLibs.mk
index 69fe6a9fa067419996c597ec493e4273d519c0a8..0a05e84c4934c8fa7fd6501b71fb241667f77f29 100644
--- a/FlatLibs.mk
+++ b/FlatLibs.mk
@@ -118,6 +118,12 @@ ifeq ($(CONFIG_WIRELESS),y)
NUTTXLIBS += lib$(DELIM)libwireless$(LIBEXT)
endif
+# Add C++ library
+
+ifeq ($(CONFIG_HAVE_CXX),y)
+NUTTXLIBS += lib$(DELIM)libcxx$(LIBEXT)
+endif
+
# Export all libraries
EXPORTLIBS = $(NUTTXLIBS)
diff --git a/Kconfig b/Kconfig
index 4d7949d4e31da4417ff62727a53eb865291c86c2..d2157939e8f2cde0aef9b807b949fdb741e4ac54 100644
--- a/Kconfig
+++ b/Kconfig
@@ -313,6 +313,25 @@ config UIMAGE_ENTRY_POINT
hex "uImage entry point"
default 0x0
+endif
+
+menuconfig DFU_BINARY
+ bool "DFU binary format"
+ select RAW_BINARY
+ ---help---
+ Create the dfu binary used with dfu-utils.
+
+if DFU_BINARY
+
+config DFU_BASE
+ hex "Address DFU image is loaded to"
+
+config DFU_VID
+ hex "VID to use for DFU image"
+
+config DFU_PID
+ hex "PID to use for DFU image"
+
endif
endmenu # Binary Output Formats
@@ -732,6 +751,38 @@ config DEBUG_NET_INFO
endif # DEBUG_NET
+config DEBUG_WIRELESS
+ bool "Wireless Debug Features"
+ default n
+ depends on WIRELESS || DRIVERS_WIRELESS
+ ---help---
+ Enable wireless debug features.
+
+if DEBUG_WIRELESS
+
+config DEBUG_WIRELESS_ERROR
+ bool "Wireless Error Output"
+ default n
+ depends on DEBUG_ERROR
+ ---help---
+ Enable wireless error output to SYSLOG.
+
+config DEBUG_WIRELESS_WARN
+ bool "Wireless Warnings Output"
+ default n
+ depends on DEBUG_WARN
+ ---help---
+ Enable wireless warning output to SYSLOG.
+
+config DEBUG_WIRELESS_INFO
+ bool "Wireless Informational Output"
+ default n
+ depends on DEBUG_INFO
+ ---help---
+ Enable wireless informational output to SYSLOG.
+
+endif # DEBUG_WIRELESS
+
config DEBUG_SCHED
bool "Scheduler Debug Features"
default n
diff --git a/KernelLibs.mk b/KernelLibs.mk
index 719430b6c9be4d435f414d62813dd4b87022f35b..b1da6dbd0b9fd17feec4e93500621ef29dff09f7 100644
--- a/KernelLibs.mk
+++ b/KernelLibs.mk
@@ -113,6 +113,12 @@ ifeq ($(CONFIG_WIRELESS),y)
NUTTXLIBS += lib$(DELIM)libwireless$(LIBEXT)
endif
+# Add C++ library
+
+ifeq ($(CONFIG_HAVE_CXX),y)
+NUTTXLIBS += lib$(DELIM)libcxx$(LIBEXT)
+endif
+
# Export only the user libraries
EXPORTLIBS = $(USERLIBS)
diff --git a/Makefile.unix b/Makefile.unix
index 220740c5bd3a08af6492d82b3113b10b080a50b3..bfdc3c5a8dece47856b2c67a30de3f3ac81eb510 100644
--- a/Makefile.unix
+++ b/Makefile.unix
@@ -280,28 +280,40 @@ tools/cnvwindeps$(HOSTEXEEXT):
# Directories links. Most of establishing the NuttX configuration involves
# setting up symbolic links with 'generic' directory names to specific,
# configured directories.
+
+# Make.defs:
+# $(Q) echo "No Make.defs file found, creating one"
+# $(Q) echo "include $(TOPDIR)$(DELIM).config" > Make.defs
+# $(Q) echo "include $(TOPDIR)$(DELIM)tools$(DELIM)Config.mk" >> Make.defs
+
+# tools/initialconfig$(HOSTEXEEXT):
+# $(Q) $(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" initialconfig$(HOSTEXEEXT)
#
+# .config: tools/initialconfig$(HOSTEXEEXT)
+# $(Q) echo "No .config file found, creating one"
+# $(Q) tools/initialconfig$(HOSTEXEEXT)
+
# Link the arch//include directory to include/arch
-include/arch: Make.defs
+include/arch: .config
@echo "LN: include/arch to $(ARCH_DIR)/include"
$(Q) $(DIRLINK) $(TOPDIR)/$(ARCH_DIR)/include include/arch
# Link the configs//include directory to include/arch/board
-include/arch/board: include/arch Make.defs include/arch
+include/arch/board: include/arch
@echo "LN: include/arch/board to $(BOARD_DIR)/include"
$(Q) $(DIRLINK) $(BOARD_DIR)/include include/arch/board
# Link the configs//src dir to arch//src/board
-$(ARCH_SRC)/board: Make.defs
+$(ARCH_SRC)/board: .config
@echo "LN: $(ARCH_SRC)/board to $(BOARD_DIR)/src"
$(Q) $(DIRLINK) $(BOARD_DIR)/src $(ARCH_SRC)/board
# Link arch//include/ to arch//include/chip
-$(ARCH_SRC)/chip: Make.defs
+$(ARCH_SRC)/chip: .config
ifneq ($(CONFIG_ARCH_CHIP),)
@echo "LN: $(ARCH_SRC)/chip to $(ARCH_SRC)/$(CONFIG_ARCH_CHIP)"
$(Q) $(DIRLINK) $(TOPDIR)/$(ARCH_SRC)/$(CONFIG_ARCH_CHIP) $(ARCH_SRC)/chip
@@ -309,7 +321,7 @@ endif
# Link arch//src/ to arch//src/chip
-include/arch/chip: include/arch Make.defs
+include/arch/chip: include/arch
ifneq ($(CONFIG_ARCH_CHIP),)
@echo "LN: include/arch/chip to $(ARCH_INC)/$(CONFIG_ARCH_CHIP)"
$(Q) $(DIRLINK) $(TOPDIR)/$(ARCH_INC)/$(CONFIG_ARCH_CHIP) include/arch/chip
@@ -498,7 +510,7 @@ do_qconfig: dirlinks apps_preconfig
qconfig: do_qconfig clean_context
-gconfig: dirlinks apps_preconfig
+do_gconfig: dirlinks apps_preconfig
$(Q) APPSDIR=${CONFIG_APPS_DIR} kconfig-gconf Kconfig
gconfig: do_gconfig clean_context
@@ -558,8 +570,6 @@ ifeq ($(CONFIG_BUILD_2PASS),y)
$(Q) $(MAKE) -C $(CONFIG_PASS1_BUILDIR) TOPDIR="$(TOPDIR)" distclean
endif
$(call DELFILE, Make.defs)
- $(call DELFILE, setenv.sh)
- $(call DELFILE, setenv.bat)
$(call DELFILE, .config)
$(call DELFILE, .config.old)
diff --git a/Makefile.win b/Makefile.win
index feb94d5eb3ff973dbd901ea9eed57d66808be185..a023c6e0136c3dfab52e5b39a8d5ac786459f937 100644
--- a/Makefile.win
+++ b/Makefile.win
@@ -275,10 +275,22 @@ tools\mkdeps$(HOSTEXEEXT):
# Directories links. Most of establishing the NuttX configuration involves
# setting up symbolic links with 'generic' directory names to specific,
# configured directories.
+
+# Make.defs:
+# $(Q) echo "No Make.defs file found, creating one"
+# $(Q) echo "include $(TOPDIR)$(DELIM).config" > Make.defs
+# $(Q) echo "include $(TOPDIR)$(DELIM)tools$(DELIM)Config.mk" >> Make.defs
+
+# tools\initialconfig$(HOSTEXEEXT):
+# $(Q) $(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" initialconfig$(HOSTEXEEXT)
#
+# .config: tools\initialconfig$(HOSTEXEEXT)
+# $(Q) echo "No .config file found, creating one"
+# $(Q) tools\initialconfig$(HOSTEXEEXT)
+
# Link the arch\\include directory to include\arch
-include\arch: Make.defs
+include\arch: .config
@echo LN: include\arch to $(ARCH_DIR)\include
ifeq ($(CONFIG_WINDOWS_MKLINK),y)
$(Q) /user:administrator mklink /d include\arch $(TOPDIR)\$(ARCH_DIR)\include
@@ -289,7 +301,7 @@ endif
# Link the configs\\include directory to include\arch\board
-include\arch\board: include\arch Make.defs include\arch
+include\arch\board: include\arch
@echo LN: include\arch\board to $(BOARD_DIR)\include
ifeq ($(CONFIG_WINDOWS_MKLINK),y)
$(Q) /user:administrator mklink /d include\arch\board $(BOARD_DIR)\include
@@ -300,7 +312,7 @@ endif
# Link the configs\\src dir to arch\\src\board
-$(ARCH_SRC)\board: Make.defs
+$(ARCH_SRC)\board: .config
@echo LN: $(ARCH_SRC)\board to $(BOARD_DIR)\src
ifeq ($(CONFIG_WINDOWS_MKLINK),y)
$(Q) /user:administrator mklink /d $(ARCH_SRC)\board $(BOARD_DIR)\src
@@ -311,7 +323,7 @@ endif
# Link arch\\include\ to arch\\include\chip
-$(ARCH_SRC)\chip: Make.defs
+$(ARCH_SRC)\chip: .config
ifneq ($(CONFIG_ARCH_CHIP),)
@echo LN: $(ARCH_SRC)\chip to $(ARCH_SRC)\$(CONFIG_ARCH_CHIP)
ifeq ($(CONFIG_WINDOWS_MKLINK),y)
@@ -324,7 +336,7 @@ endif
# Link arch\\src\ to arch\\src\chip
-include\arch\chip: include\arch Make.defs
+include\arch\chip: include\arch
ifneq ($(CONFIG_ARCH_CHIP),)
@echo LN: include\arch\chip to $(ARCH_INC)\$(CONFIG_ARCH_CHIP)
ifeq ($(CONFIG_WINDOWS_MKLINK),y)
@@ -536,8 +548,6 @@ ifeq ($(CONFIG_BUILD_2PASS),y)
$(Q) $(MAKE) -C $(CONFIG_PASS1_BUILDIR) TOPDIR="$(TOPDIR)" distclean
endif
$(call DELFILE, Make.defs)
- $(call DELFILE, setenv.sh)
- $(call DELFILE, setenv.bat)
$(call DELFILE, .config)
$(call DELFILE, .config.old)
diff --git a/ProtectedLibs.mk b/ProtectedLibs.mk
index 4f2e2c6072d35fc34030967de75fa7fe93434c5d..5dd45a6fab8ffe1d5fdf62417f71987e5fc23e51 100644
--- a/ProtectedLibs.mk
+++ b/ProtectedLibs.mk
@@ -123,6 +123,12 @@ ifeq ($(CONFIG_WIRELESS),y)
NUTTXLIBS += lib$(DELIM)libwireless$(LIBEXT)
endif
+# Add C++ library
+
+ifeq ($(CONFIG_HAVE_CXX),y)
+NUTTXLIBS += lib$(DELIM)libcxx$(LIBEXT)
+endif
+
# Export only the user libraries
EXPORTLIBS = $(USERLIBS)
diff --git a/README.txt b/README.txt
index ed3d41c30f8420f294941b1eb721d996ca277999..8e466a7dd40ee15a25f82eca969b9499ec597076 100644
--- a/README.txt
+++ b/README.txt
@@ -186,6 +186,13 @@ Ubuntu Bash under Windows 10
With these differences (perhaps a few other Windows quirks) the Ubuntu
install works just like Ubuntu running natively on your PC.
+ A good tip for file sharing is to use symbolic links within your Ubuntu
+ home directory. For example, suppose you have your "projects" directory
+ at C:\Documents\projects. Then you can set up a link to the projects/
+ directory in your Ubuntu directory like:
+
+ $ ln -s /mnt/c/Documents/projects projects
+
Accessing Ubuntu Files From Windows
-----------------------------------
In Ubuntu Userspace for Windows, the Ubuntu file system root directory is
@@ -197,7 +204,29 @@ Ubuntu Bash under Windows 10
C:\Users\Username\AppData\Local\lxss\rootfs
- Install Linux Software.
+ However, I am unable to see my files under the rootfs\home directory.
+ After some looking around, I find the home directory
+ %localappdata%\lxss\home.
+
+ With that trick access to the /home directory, you should actually be
+ able to use Windows tools outside of the Ubuntu sandbox with versions of
+ NuttX built within the sandbox using that path.
+
+ Executing Windows Tools from Ubuntu
+ -----------------------------------
+ You can also execute Windows tools from within the Ubuntu sandbox:
+
+ $ /mnt/c/Program\ Files\ \(x86\)/Microchip/xc32/v1.43/bin/xc32-gcc.exe --version
+ Unable to translate current working directory. Using C:\WINDOWS\System32
+ xc32-gcc.exe (Microchip Technology) 4.8.3 MPLAB XC32 Compiler v1.43 Build date: Mar 1 2017
+ ...
+
+ The error message indicates that there are more issues: You cannot mix
+ Windows tools that use Windows style paths in an environment that uses
+ POSIX paths. I think you would have to use Linux tools only from within
+ the Ubuntu sandbox.
+
+ Install Ubuntu Software
-----------------------
Use "sudo apt-get install ". As examples, this is how
you would get GIT:
@@ -461,9 +490,9 @@ Notes about Header Files
Certain header files, such as setjmp.h, stdarg.h, and math.h, may still
be needed from your toolchain and your compiler may not, however, be able
- to find these if you compile NuttX without using standard header file.
- If that is the case, one solution is to copy those header file from
- your toolchain into the NuttX include directory.
+ to find these if you compile NuttX without using standard header files
+ (ie., with -nostdinc). If that is the case, one solution is to copy
+ those header file from your toolchain into the NuttX include directory.
Duplicated Header Files.
@@ -547,13 +576,6 @@ Instantiating "Canned" Configurations
and link code. You may need to modify this file to match the
specific needs of your toolchain.
- Copy configs///setenv.sh to ${TOPDIR}/setenv.sh
-
- setenv.sh is an optional convenience file that I use to set
- the PATH variable to the toolchain binaries. You may chose to
- use setenv.sh or not. If you use it, then it may need to be
- modified to include the path to your toolchain binaries.
-
Copy configs///defconfig to ${TOPDIR}/.config
The defconfig file holds the actual build configuration. This
@@ -925,10 +947,8 @@ Cross-Development Toolchains
That README file contains suggestions and information about appropriate
tools and development environments for use with your board.
- In any case, the script, setenv.sh that was deposited in the top-
- level directory when NuttX was configured should be edited to set
- the path to where you installed the toolchain. The use of setenv.sh
- is optional but can save a lot of confusion in the future.
+ In any case, the PATH environment variable will need to be updated to
+ include the loction where the build can find the toolchain binaries.
NuttX Buildroot Toolchain
-------------------------
@@ -1006,12 +1026,11 @@ Building
NuttX builds in-place in the source tree. You do not need to create
any special build directories. Assuming that your Make.defs is setup
- properly for your tool chain and that setenv.sh contains the path to where
- your cross-development tools are installed, the following steps are all that
- are required to build NuttX:
+ properly for your tool chain and that PATH environment variable contains
+ the path to where your cross-development tools are installed, the
+ following steps are all that are required to build NuttX:
cd ${TOPDIR}
- . ./setenv.sh
make
At least one configuration (eagle100) requires additional command line
@@ -1183,10 +1202,6 @@ Native Windows Build
(2) it still lacks some of the creature-comforts of the more mature
environments.
- There is an alternative to the setenv.sh script available for the Windows
- native environment: tools/configure.bat. See tools/README.txt for additional
- information.
-
Installing GNUWin32
-------------------
@@ -1447,12 +1462,16 @@ nuttx/
| | `- README.txt
| |- avr32dev1/
| | `- README.txt
+ | |- b-l475e-iot01a/
+ | | `- README.txt
| |- bambino-200e/
| | `- README.txt
| |- c5471evm/
| | `- README.txt
| |- cc3200-launchpad/
| | `- README.txt
+ | |- clicker2-stm32
+ | | `- README.txt
| |- cloudctrl
| | `- README.txt
| |- demo0s12ne64/
@@ -1543,8 +1562,24 @@ nuttx/
| | `- README.txt
| |- nucleo-144/
| | `- README.txt
+ | |- nucleo-f072rb/
+ | | `- README.txt
+ | |- nucleo-f091rc/
+ | | `- README.txt
+ | |- nucleo-f303re/
+ | | `- README.txt
+ | |- nucleo-f334r8/
+ | | `- README.txt
| |- nucleo-f4x1re/
| | `- README.txt
+ | |- nucleo-l432kc/
+ | | `- README.txt
+ | |- nucleo-l452re/
+ | | `- README.txt
+ | |- nucleo-l476rg/
+ | | `- README.txt
+ | |- nucleo-l496zg/
+ | | `- README.txt
| |- nutiny-nuc120/
| | `- README.txt
| |- olimex-efm32g880f129-stk/
@@ -1581,6 +1616,8 @@ nuttx/
| | `- README.txt
| |- pic32mz-starterkit/
| | `- README.txt
+ | |- photon/
+ | | `- README.txt
| |- qemu-i486/
| | `- README.txt
| |- sabre-6quad/
@@ -1681,6 +1718,8 @@ nuttx/
| | `- README.txt
| |- viewtool-stm32f107/
| | `- README.txt
+ | |- xmc5400-relax/
+ | | `- README.txt
| |- xtrs/
| | `- README.txt
| |- z16f2800100zcog/
@@ -1743,6 +1782,8 @@ nuttx/
| | `- README.txt
| `- README.txt
|- net/
+ | |- sixlowpan
+ | | `- README.txt
| `- README.txt
|- syscall/
| `- README.txt
diff --git a/ReleaseNotes b/ReleaseNotes
index ed69375e61034f336d44cee9ce212b69711c422b..92be9fef5f0f442f5280ce9e1c499d8b3bccb272 100644
--- a/ReleaseNotes
+++ b/ReleaseNotes
@@ -2025,7 +2025,7 @@ standard I/O buffer flushing. See the ChangeLog for further details.
NuttX-6.4
---------
-The 71st release of NuttX, Version 6.4, was made on June 6, 2011
+The 71st release of NuttX, Version 6.4, was made on June 5, 2011
and is available for download from the SourceForge website. The
6.4 release includes several new features:
@@ -11146,7 +11146,7 @@ Additional new features and extended functionality:
- SYSLOG character device channel will now expand LF to CR-LF.
Controllable with a configuration option.
- Add a SYSLOG character device that can be used to re-direct output
- to the SYSLOG channel (Not be be confused the the SYSLGO output to a
+ to the SYSLOG channel (Not be be confused the SYSLGO output to a
character device).
- Debug features are now enabled separately from debug output.
(1) CONFIG_DEBUG is gone. It is replaced with CONFIG_DEBUG_FEATURES.
@@ -12417,7 +12417,7 @@ Additional new features and extended functionality:
- Misoc LM32 Qemu: Integrate network support into configs/misoc/hello.
From Ramtin Amin.
- Misoc LM32 Qemu: Remove configs/misoc/include/generated directory. I
- suppose the the intent now is that this is a symbolic link? DANGER!
+ suppose the intent now is that this is a symbolic link? DANGER!
This means that you cannot compile this code with first generating
these files a providing a symbolic link to this location! There is a
sample directory containing generated sources. This is really only
@@ -13546,3 +13546,991 @@ detailed bugfix information):
- In apps/examples/mtdpart/mtdpart_main.c where
CONFIG_EXAMPLES_MTDPART_NPARTITIONS defining is checked should be
#ifndef instead of #ifdef. Noted by Oleg Evseev.
+
+NuttX-7.21 Release Notes
+------------------------
+
+The 121st release of NuttX, Version 7.21, was made on June 6, 2017,
+and is available for download from the Bitbucket.org website. Note
+that release consists of two tarballs: nuttx-7.21.tar.gz and
+apps-7.21.tar.gz. These are available from:
+
+ https://bitbucket.org/nuttx/nuttx/downloads
+ https://bitbucket.org/nuttx/apps/downloads
+
+Both may be needed (see the top-level nuttx/README.txt file for build
+information).
+
+Additional new features and extended functionality:
+
+ * Core OS:
+
+ - pthread rwlocks: Add an implementation for read/write locks
+ (rwlocks) into the pthread library. These locks are writer
+ priority, such that if any writers come in they are given priority
+ for writing. From Mark Schulte.
+ - pthread robust mutexes: Implement robust mutex support:
+ pthread_mutex_lock() and trylock() will return EOWNERDEAD if the
+ mutex is locked by a thread that no longer exists. Add
+ pthread_mutex_consistent() to recover from this situation. Keep
+ list of all mutexes held by a thread in a list in the pthread's TCB.
+ When pthread exits or is cancelled, mutexes held by thread are
+ marked inconsistent and the highest priority thread waiting for the
+ mutex is awakened. There is a configuration option to (a) support
+ only robust mutexes, (b) support only traditional unsafe mutexes,
+ or (c) Support both unsafe and robust mutexes via
+ pthread_mutexattr_get/setrobust().
+ - pthread cancellation points: Add logic to disable cancellation
+ points within the OS. This is useful when an internal OS function
+ that is NOT a cancellation point calls an OS function which is a
+ cancellation point. In that case, irrecoverable states may occur if
+ the cancellation is within the OS. From Juha Niskanen.
+ - clock: Add clock_resynchronize and use subseconds RTC. Add
+ clock_resynchronize for better synchronization of CLOCK_REALTIME and
+ CLOCK_MONOTONIC to match RTC after resume from low-power state. Add
+ up_rtc_getdatetime_with_subseconds under
+ CONFIG_ARCH_HAVE_RTC_SUBSECONDS to allow initializing (and
+ resynchronizing) system clock with subseconds accuracy RTC. From
+ Jussi Kivilinna.
+ - clock: Add new type ssystime_t for relative 64-bit ticks, change
+ ticks<->time conversion functions to use ssystime_t. From Jussi
+ Kivilinna.
+ - clock: Add testing for 32-bit overflow of 64-bit system timer. From
+ Jussi Kivilinna.
+
+ * File Systems/Block and MTD Drivers
+
+ - drivers/mtd/w25.c: Erase sector only if it is not in erased state.
+ From Jussi Kivilinna.
+
+ * Graphics/Display Drivers:
+
+ - drivers/lcd: Extend st7565 driver to include support for the
+ AQM_1248A. From Masayuki Ishikawa.
+ - drivers/lcd: Add driver for Nokia 5110 (Philips PCD8544). From Alan
+ Carvalho de Assis.
+
+ * Networking/Network Drivers:
+
+ - Extensive modifications to support wireless network (see below).
+ - TUN driver: Implement TAP (OSI layer 2) mode. Enable by setting the
+ IFF_TAP flag instead of the IFF_TUN flag in ifr_flags. From Thomas
+ Keh.
+ - Add user-space networking stack API (usrsock). User-space
+ networking stack API allows user-space daemon to provide TCP/IP
+ stack implementation for NuttX network. Main use for this is to
+ allow use and seamless integration of HW-provided TCP/IP stacks to
+ NuttX. For example, user-space daemon can translate /dev/usrsock
+ API requests to HW TCP/IP API requests while rest of the user-space
+ can access standard socket API, with socket descriptors that can be
+ used with NuttX system calls. From Jussi Kivilinna.
+ - net/: Network driver now retains Ethernet MAC address in a union so
+ that other link layer addresses may be used in a MULTILINK
+ environment.
+
+ * Wireless Networking/Wireless Drivers:
+
+ - BCM43362: Support for Broadcom's BCM43362 WiFi chip was contributed
+ by Simon Piriou as part of the port of the Particle Photon board.
+ Only station functionality is available at present. This work
+ includes not on the WiFi driver, but the support Particle Photon
+ board, the infrasture for IEEE 802.11 FullMAC networking including
+ the network device interface, WiFi configuration, AP scanning and
+ authentication and association with an AP.
+ - IEEE 802.11 networking tools and support.
+ - IEEE 802.15.4 MAC support. This is an effort that was started some
+ time back by Sebastien Lorquet (with some help from Matte Poppe).
+ Recently, Anthony Merlino has taken on this effort and has made
+ some significant progress. Using the Microchip MRF24J40 module with
+ the Mikroe Clicker2-STM32 board along with a PC-based IEEE 802.15.4
+ sniffer, Anthonly has verified correct transmittion and receipt of
+ basic frames.
+ - Microchip MRF24J40: As mentioned above, this IEEE 802.15.4 radio
+ driver is now basically functional.
+ - IEEE 802.15.4 Network Driver: A driver that interfaces the NuttX
+ network with the IEEE 802.15.4 MAC has been developed but is still
+ incomplete and has not been verified.
+ - IEEE 802.15.4 Network Loopback Driver: A simple IEEE 802.15.4 MAC
+ loopback driver was developed. This driver allowed for parallel
+ development of the IEEE 802.15.4 MAC and 6loWPAN.
+ - 6loWPAN: The Contiki 6loWPAN stack has been ported so that works
+ within the NuttX networking framework and interfaces with the new
+ IEEE 802.15.4 MAC via the network driver. Live testing with
+ IEEE 802.15.4 radios has not yet been done; all testing has used
+ the loopback driver. There are no known problems and the stack
+ is ready for additional testing.
+ - Add option to enable wireless debug output.
+
+ * Other Common Device Drivers:
+
+ - Add entropy pool and strong random number generator. Entropy pool
+ gathers environmental noise from device drivers, user-space, etc.,
+ and returns good random numbers, suitable for cryptographic use.
+ Based on entropy pool design from *BSDs and uses BLAKE2Xs algorithm
+ for CSPRNG output. Patch also adds /dev/urandom support for using
+ entropy pool RNG and new 'getrandom' system call for getting
+ randomness without file-descriptor usage (thus avoiding file-
+ descriptor exhaustion attacks). The 'getrandom' interface is similar
+ as 'getentropy' and 'getrandom' available on OpenBSD and Linux
+ respectively. From Jussi Kivilinna.
+ - XBox One controller: Adds USB host driver support for the XBox One
+ controller. Currently only the latest version (XBox One X)
+ controller works. The older XBox One controllers do not enumerate
+ correctly. From Brian Webb.
+ - drivers/analog: Add basic COMP driver. From Mateusz Szafoni.
+ - drivers/analog: Add driver for the LTC1767L ADC. From Martin
+ Lederhilger.
+ - drivers/analog: Add basic OPAMP driver. From Mateusz Szafoni.
+ - drivers/sensors: Add driver for ST HTS221 humidity sensor. From
+ Juha Niskanen.
+ - drivers/sensors: Add driver for ST LPS25H pressure sensor. From
+ Juha Niskanen.
+ - drivers/sensors: Add driver for ST LIS2DH accelerometer. From Timo
+ Voutilainen.
+ - drivers/usbmisc: Add driver for Fairchild FUSB301 USB type-C
+ controller. From Harri Luhtala.
+ - RTC: Add interface for check if RTC time has been set. New
+ interface allows checking if RTC time has been set. This allows to
+ application to detect if RTC has valid time (after reset) or should
+ application attempt to get real time by other means (for example, by
+ launching ntpclient or GPS). From Jussi Kivilinna.
+ - Buttons: Change return value of board_buttons() and the type of
+ btn_buttonset_t to uint32_t so that more than 8 buttons can be
+ supported.
+ - drivers/syslog: Use monotonic clock for timestamp when available.
+ From Jussi Kivilinna.
+ - SPI: Add an instance argument to the SPIDEV definitions. Thus,
+ instead of specifying a FLASH device, for example, as SPI_FLASH, you
+ would now use SPI_FLASH(0) where the "instance" argument now
+ distinguishes multiple FLASH devices on the same SPI bus. From
+ Sebastien Lorquet.
+ - IOBs: Move from net/iob to a better location in mm/iob where they
+ can be shared outside of the networking logic. Current also used
+ by IEEE 802.15.4 MAC and by syslog (when buffering enabled).
+ - syslog: Add option to buffer SYSLOG output to avoid interleaving.
+ Uses new shareable IOBs. Additional logic to assure that the the
+ write from the buffer is a single atomic write in normal debug
+ output.
+ - drivers/can: Move CAN subsystem to its own directory and put device
+ drivers there. From Alan Carvalho de Assis.
+ - drivers/can: Add Microchip MCP2515 CAN Bus controller driver. From
+ Alan Carvalho de Assis.
+ - drivers/audio: Add cs43l22 audio driver. From Taras Drozdovsky.
+ - drivers/input: Add Cypress MBR3108 CapSense touch button driver.
+ From Juha Niskanen.
+
+ * Simulation
+
+ - configs/sim/sixlowpan: Configuration for testing the 6loWPAN with
+ the IEEE 802.15.4 loopback network driver.
+
+ * Infineon XMC4xxx:
+
+ - arch/arm/src/xmc4: Initial, partial support for Infineon XMC4xxx.
+
+ * Infineon XMC4xxx Boards:
+
+ - XMC4500 Relax: Add basic board support infrastructure of Infineon
+ XMC4500 Relax Lite v1. Basic serial, LED, and button button support
+ for a simple NSH configuration. There are still stome remaining
+ issues with serial communications.
+
+ * MicroChip PIC32MX Boards:
+
+ - pic32mx7mmb: Add support for the Pinquino toolchain.
+ - pic32mx7mmb: Add support for PROCFS file system.
+
+ * NXP Freescale Kinetis:
+
+ - Kinetis: Allow board to add pullups on SDHC lines. From David
+ Sidrane.
+ - Kinetis: Use optional BOARD_OSC_CR and BOARD_OSC_DIV in clock
+ configuration. From David Sidrane.
+
+ * NXP Freescale Kinetis Drivers:
+
+ - Kinetis: Add Timer PWM Module (TPM) to K66 chip. From David
+ Sidrane.
+ - Kinetis: Added HW flow control and termios. From David Sidrane.
+ - Kinetis: Add ARCH_HAVE_I2CRESET. From David Sidrane.
+
+ * NXP Freescale LPC43xx:
+
+ - Add support for LPC4337FET256. From Andreas Bihlmaier.
+
+ * STMicro STM32:
+
+ - Change STM32 tickless to use only one timer. From Konstantin
+ Berezenko.
+ - STM32 F7: Add support for LSE RTC and enable RTC subseconds. From
+ Jussi Kivilinna.
+ - STM32 L1: stm32l15xx_rcc: Add support for using MSI as system
+ clock. From Juha Niskanen.
+ - STM32 L1: stm32l15xxx_rcc: configure medium performance voltage
+ range and zero wait-state when allowed by SYSCLK setting. Zero
+ wait-state for flash can be configured when: (1) Range 1 and
+ SYSCLK <= 16 Mhz, (2) Range 2 and SYSCLK <= 8 Mhz, or (3) Range 3
+ and SYSCLK <= 4.2 Mhz. Medium performance voltage range (1.5V)
+ can be configured when SYSCLK is up to 16 Mhz and PLLVCO up to
+ 48 Mhz. From Juha Niskanen.
+ - STM32 F0: Add basic support for STM32F0. From Alan Carvalho de
+ Assis.
+ - STM32 F0: Add basic support for STM32F07x family.
+ - STM32 L1: stm32l15xx_rcc: Allow board to configure HSE clock in
+ bypass-mode. Allows using MCO output from ST-link chip (on Nucleo
+ and Discovery boards) as HSE input. From Juha Niskanen.
+ - STM32 L1: Add support for STM32L152CC, STM32L152RC and STM32L152VC.
+ From Juha Niskanen.
+ - STM32 F0: Add support for HSI48.
+ - STM32 L4: Add support for the STM32L496XX family. From Juha
+ Niskanen.
+ - STM32 L4: modularize Kconfig to support different product
+ lines/families. This is modeled after STM32F7. Idea is to declare
+ each chip in Kconfig but allow for flash size override. Commit adds
+ many STM32L4_HAVE_XXX feature test macros. From Juha Niskanen.
+ - STM32 L4: Separate SYSCFG into product line specific files for
+ clarity. From Juha Niskanen.
+ - STM32 L4: Add support for many new MCUs from the STM32L4X3XX
+ product line. From Juha Niskanen.
+ - STM32 L4: Add dbgmcu header files. From Juha Niskanen.
+ - STM32 F410: Add support for STM32F410. STM32F410 is a version of
+ STM32F4 with 32 KB of RAM and 62 or 128 KB of flash. From Gwenhael
+ Goavec-Merou.
+
+ * STMicro STM32 Drivers:
+
+ - SDIO: Extensions to support the SDIO interface to the BCM43362 from
+ Simon Piriou.
+ - STM32 F2: Add USB OTG HS support for stm32f20xxx cores. From Simon
+ Piriou.
+ - STM32 F2, F4, and F7: Add BOARD_DISABLE_USBOTG_HSULPI flag. From
+ Simon Piriou.
+ - STM32 F33: Move DMA logic to a separate files + add ADC support.
+ From Mateusz Szafoni.
+ - STM32 F3: Add COMP support. From Mateusz Szafoni.
+ - STM32 F33: Support for COMP character driver. From Mateusz Szafoni.
+ - STM32 F4: Implement DMA support for the STM32F4 I2C. From rg.
+ - STM32 F7: Add stm32 RNG support. This is copied from stm32l4.
+ Tested on STM32F746ZG board. From Juha Niskanen.
+ - STM32 L1: Add STM32L162VE to chip.h. From Juha Niskanen.
+ - STM32 F4: Add I2C3 SDA pin mapping for STM32F411. From no1wudi.
+ - STM32 L1: stm32_flash: Add EEPROM writing for STM32L15XX. From
+ Juha Niskanen.
+ - STM32 F7: Serial: Add interface to get uart_dev_t by USART number,
+ stm32_serial_get_uart. From Jussi Kivilinna.
+ - STM32 F4: Provide TIM5 definition for STM32F429. From Matias v01d.
+ - STM32 F0: Add an untested port of the F1 USB device to the STM32F0.
+ - STM32 F0: Add support for the STM32F09X family. From Juha
+ Niskanen.
+ - STM32 F0: Initial cut at I2C driver. Still a work in progress.
+ From Alan Carvalho de Assis.
+ - STM32 F33: Add OPAMP support. From Mateusz Szafoni.
+ - STM32 L4: stm32l4_i2c: Add I2C4 code. From Juha Niskanen.
+ - STM32 L4: Add GPIO_PORTI definition. From Juha Niskanen.
+ - STM32 F7 Serial: Allow configuring Rx DMA buffer size. From Jussi
+ Kivilinna.
+ - STM32 L4: Firewall for stm32l4x3xx. Not tested for any product
+ family, but now it at least compiles. L496 devices can have one bit
+ wider Volatile Data Segment. From Juha Niskanen.
+ - STM32 TIM: Add method to get timer width. Freerun timer: Use timer
+ width to get the correct clock rollover point.
+ - STM32 L4: Add internal flash write support. From Juha Niskanen.
+ - STM32 L4: Port stm32l4_serial_get_uart function from STM32F7. From
+ Juha Niskanen.
+ - STM32 Ethernet: Add support for KSZ8081 PHY interrupts. From
+ Sebastien Lorquet.
+ - STM32 F4: Add I2S driver. From Taras Drozdovsky.
+ - STM32 L4: Add IWDG peripheral. This is the same as for STM32
+ except that prescale and reload can be changed after watchdog has
+ been started, as this seems to work on L4. From Juha Niskanen.
+ - STM32 F7: Add SPI DMA support. From Jussi Kivilinna.
+
+ * STMicro STM32 Boards:
+
+ - Support for the Particle Photon board was contributed by Simon
+ Piriou. The Photon board is based on a STM32F205G MCU with and on-
+ board BCM43362 WiFi chip that interfaces via the STM32's SDIO
+ interface. Board configuration support includes, in addition,
+ buttons, LEDS, IWDG, USB OTG HS, and procfs support. Configurations
+ available for nsh, usbnsh, and wlan configurations.
+ - Clicker2-STM32: Support for the Mikroelektronika Clicker 2 for
+ STM32 was added by Anthony Merlino. This board, along with the
+ MRF24J40 Click board is the platform used to deveop the IEEE
+ 802.15.4 support. The boad configuration includes the MRF24J40
+ intialization logic and SPI support. Configurations exist for nsh,
+ knsh, usbnsh, and mrf24j40-radio.
+ - Nucleo_F334R8: Add ADC example. From Mateusz Szafoni.
+ - Nucleo-F334R8: Add COMP support. From Mateusz Szafoni.
+ - Nucleo-F334R8: Use new COMP driver. From Mateusz Szafoni.
+ - Adds USB host support to stm32f411-disco board. From Brian Webb.
+ - Add stm32f0discovery board support. From Alan Carvalho de Assis.
+ - Nucleo-F072RB: Add board configuration.
+ - Nucleo-F334R8: Add OPAMP support. From Mateusz Szafoni.
+ - Nucleo-F072RB: Add support for the I2C driver used by I2C tools.
+ - Nucleo-L496ZG: Add nucleo-l496zg board files. From Juha Niskanen.
+ - Nucleo-F091RC: Add nucleo-f091rc board files. From Juha Niskanen.
+ - Nucleo-L432KC: Add nucleo-l432kc board files. From Sebastien
+ Lorquet.
+ - Nucleo-L452RE: Add nucleo-l452re board files. From Juha Niskanen.
+ - stm32f103-miniumum: Add board support to use the Nokia 5110
+ LCD display driver. From Alan Carvalho de Assis.
+
+ * C Library/Header Files:
+
+ - C library: Add strerror_r().
+ - C Library: Add wcstoull(), swprintf(), wcstod(), wcstof(), wcstol(),
+ wcstold(), wcstoul(), wcstoll() functions. Add mbsnrtowcs() and
+ wcsnrtombs() (just returning success). Add mbtowc() and wctomb() to
+ C++ std namespace. From Alan Carvalho de Assis.
+ - C Library: Add ffsl(), ffsll(), fls(), flsl(), flsll() and use
+ GCC's __builtin_ctz/__builtin_clz for faster implementation of these.
+ From Jussi Kivilinna.
+ - fixedmath: Add square root and b32_t conversion operators. From
+ Jussi Kivilinna.
+ - locale.h: Add a bogus definition of locale_t.
+ - C library: Versions mbrlen and mbsrtowcs taken and adapted from
+ FreeBSD code (at https://github.com/freebsd/freebsd/). From Matias
+ v01d.
+
+ * Build/Configuration System:
+
+ - Include C++ library in 'make export'. From Alan Carvalho de Assis.
+ - configs: Remove all setenv.sh and setenv.bat files. Remove all
+ references to setenv.sh and setenv.bat from all config README files.
+ - Kconfig/deconfigs: Add CONFIG_ARCH_TOOLCHAIN_GNU to indicate that
+ the toolchain is based on GNU gcc/as/ld. This is in addition to the
+ CPU-specific versions of the same definition.
+ - Move prototype for up_cxxinitialize() from nuttx/include/nuttx/arch.h
+ to apps/include/platform/cxxinitialize.h.
+
+ * Tools:
+
+ - Add initialconfig.c so that perhaps in the future we will be able to
+ use this to generate a new configuration from scratch (rather than
+ having to derive new configurations from existing configurations).
+ NOTE: Not yet intregated into the build system.
+
+ * NSH: apps/nshlib:
+
+ - Added support for set [{+|-}{e|x|xe|ex}] [ ]. Set the
+ 'exit on error control' and/or 'print a trace' of commands when
+ parsing scripts in NSH. The settinngs are in effect from the point
+ of exection, until they are changed again, or in the case of the init
+ script, the settings are returned to the default settings when it
+ exits. Included child scripts will run with the parents settings and
+ changes made in the child script will effect the parent on return.
+ Use 'set -e' to enable and 'set +e' to disable (ignore) the exit
+ condition on commands. The default is -e. Errors cause script to
+ exit. Use 'set -x' to enable and 'set +x' to disable (silence)
+ printing a trace of the script commands as they are ececuted. The
+ default is +x. No printing of a trace of script commands as they are
+ executed. From David Sidrane.
+ - Print expanded variables if -x. From David Sidrane.
+ - ifconfig command: Extend ifconfig to support 6loWPAN. Adapt to
+ some changes in configuration variable usage.
+ - Network initialization: If IEEE802.11 selected use wlan0 instead of
+ eth0 for network device name.
+ - Network initialization: NSH now has configuration options to select
+ the wireless properties. It builds the configuration structure and
+ passes this to wpa_driver_wext_associate() so that it will set the
+ network as configured.
+ - Network initialization: Add a new option CONFIG_NSH_NETLOCAL that
+ will suppress some built in operations and will support manual
+ configuration of a wireless network through command line tools.
+
+ * Examples/Tests: apps/examples:
+
+ - examples/xbc_text: Adds a test program for the XBox One controller
+ driver. From Brian Webb.
+ - examples/ostest: Add a test of robust mutexes.
+ - examples/ostest: Add tests for pthread_rwlock. Adding tests to be
+ used to verify the pthread_rwlock lock works. From Mark Schulte.
+ - examples/ostest: Additional test for rwlock and one for cancel
+ cleanup handlers. From Juha Niskanen.
+ - examples/usrsocktest: Add application for USRSOCK testing. From
+ Jussi Kivilinna.
+ - examples/nettest: Adapt for use in testing 6loWPAN.
+ - examples/nettest: If doing loopback, but not using the official
+ loopback device, then use the server should use the configured client
+ IP address.
+ - examples/udpblaster: Several fixes to work with 6loWPAN.
+ - examples/udpblaster: Add logic to bind the local UDP socket to a
+ well-known address.
+ - examples/configdata: Add stacksize and priority. From Juha Niskanen.
+
+ * Network Utilies: apps/netuils:
+
+ - netutils/netlib: Add IEEE 802.11 wireless IOCTL wrappers.
+ - netutils/netlib: Add a helper function to convert a string to a
+ 6loWPAN node address.
+ - netlib and NSH: Add logic to get/set the IEEE802.15.4 PAN ID.
+ - netutils/dhcpc: Make the network device name a configuration
+ option. Was hardcoded to eth0 but may, instead, need to be wlan0.
+ - netutils/dhcpc: Remove hard-coded interface device. Now passed as
+ a parameter to dhcpc_open(). From Sebastien Lorquet.
+
+ * Wireless Utilies: apps/wireless:
+
+ - wireless/wapi: Port of Wapi wireless services. The original
+ depended on features not supported by NuttX: Removed logic that
+ depends on Linux netlink. Removed functionality that depended on
+ the Linux procfs: This includes only 1) listing of available
+ interfaces and 2) listing of all routes.
+ - wireless/wapi: Create command line Wapi application based on
+ Wapi sample code.
+ - wireless/wapi: wpa_driver_wext_associate() now accepts a
+ configuration parameter that can be used to specify the wireless
+ properties.
+ - wireless/wapi: Add basic wapi_event_stream_extract implementation.
+ From Simon Piriou.
+ - wireless/ieee802154: Add iwpan and i8sak tools. iwpan is similar
+ in concept to wapi. From Anthony Merlino (i8sak was originally
+ by Sebastien Lorquet).
+ - wireless/ieee802154/libmac: IEEE 802.15.4 MAC library.
+ - wireless/wext: Add drivers_wext from the WPA supplicant; Integrate
+ into NSH. From Simon Piriou.
+
+ * System Unitilities (apps/system)
+
+ - apps/system/dhcpc: Add a command to renew or establish a lease on an
+ IPv4 address.
+ - apps/system/ntpc: Add a command to start or stop the NTPC daemon.
+ - apps/system/ramtest: Make stacksize and priority conigurable.
+
+ * Platform-Specific Support (apps/platform)
+
+ - apps/platform: Create gnu/ subdirectory that contains the one and
+ only GNU C++ initialization function. Remove all other C++
+ initialization functions.
+
+Bugfixes. Only the most critical bugfixes are listed here (see the
+ChangeLog for the complete list of bugfixes and for additional, more
+detailed bugfix information):
+
+ * Core OS:
+
+ - Priority inheritance: When CONFIG_SEM_PREALLOCHOLDERS==0, there is
+ only a single, hard-allocated holder structure. This is problem
+ because in sem_wait() the holder is released, but needs to remain in
+ the holder container until sem_restorebaseprio() is called. The call
+ to sem_restorebaseprio() must be one of the last things the
+ sem_wait() does because it can cause the task to be suspended. If in
+ sem_wait(), a new task gets the semaphore count then it will fail to
+ allocate the holder and will not participate in priority
+ inheritance. This fix is to add two hard-allocated holders in the
+ sem_t structure: One of the old holder and one for the new holder.
+ - Priority inheritance: sem_holder sem_findholder missing
+ inintalization of pholder. sem_findholder would fail and code
+ optimization covered this up. From David Sidrane.
+ - Partial Fix priority inheritance CONFIG_SEM_PREALLOCHOLDERS=0. From
+ David Sidrane.
+ - Priority inheritance: sem_boostholderprio prevent overrun of
+ pend_reprios. The second case rtcb->sched_priority <=
+ htcb->sched_priority did not check if there is sufficient space in
+ the pend_reprios array. From David Sidrane.
+ - lp_worker: Guard from pend_reprios overlow. From David Sidrane.
+ - Priority inheritance: Fixes improper restoration of base_priority in
+ the case of CONFIG_SEM_PREALLOCHOLDERS=0. The call to
+ sem_restorebaseprio_task context switches in the
+ sem_foreachholder(sem, sem_restoreholderprioB, stcb); call prior to
+ releasing the holder. So the running task is left as a holder as is
+ the started task. Leaving both slots filled thus failing to perform
+ the boost/or restoration on the correct tcb. This PR fixes this by
+ releasing the running task slot prior to reprioritization that can
+ lead to the context switch. To faclitate this, the interface to
+ sem_restorebaseprio needed to take the tcb from the holder prior to
+ the holder being freed. In the failure case where sched_verifytcb
+ fails it added the overhead of looking up the holder. There is also
+ the additional thunking on the foreach to get from holer to
+ holder->tcb. An alternate approach could be to leve the interface
+ the same and allocate a holder on the stack of sem_restoreholderprioB
+ copy the sem's holder to it, free it as is done in this pr and and
+ then pass that address sem_restoreholderprio as the holder. It could
+ then get the holder's tcb but we would keep the same sem_findholder
+ in sched_verifytcb. From David Sidrane.
+ - Priority inheritance: Fixes improper restoration of base_priority.
+ From David Sidrane.
+ - sem_holder: Indexing error. From David Sidrane.
+
+ if (sem->holder[0].htcb != NULL || sem->holder[**1**].htcb != NULL)
+ - realloc(): When realloc() has to fall back to calling malloc(), size
+ including overhead was being provided to malloc(), causing a slightly
+ larger allocation than needed. Noted by initialkjc@yahoo.com.
+ - scheduler: Fix tg_flags check with GROUP_FLAG_NOCLDWAIT. From Masayuki
+ Ishikawa.
+ - scheduler: Fix CHILD_FLAG_EXITED in include/nuttx/sched.h. From
+ Masayuki Ishikawa.
+ - binfmt/elf: Fix offset value when calling elf_read() in
+ elf_symname(). From Masayuki Ishikawa.
+ - binfmt/elf: Fix offset value when calling elf_read() in
+ elf_sectname(). From Masayuki Ishikawa.
+ - There can be a failure in IOB allocation to some asynchronous
+ behavior caused by the use of sem_post(). Consider this scenario:
+ (1) Task A holds an IOB. There are no further IOBs. The value of
+ semcount is zero. Task B calls iob_alloc(). Since there are not
+ IOBs, it calls sem_wait(). The value of semcount is now -1. (2)
+ Task A frees the IOB. iob_free() adds the IOB to the free list and
+ calls sem_post() this makes Task B ready to run and sets semcount to
+ zero NOT 1. There is one IOB in the free list and semcount is zero.
+ When Task B wakes up it would increment the sem_count back to the
+ correct value. (3) But an interrupt or another task runs occurs
+ before Task B executes. The interrupt or other tak takes the IOB off
+ of the free list and decrements the semcount. But since semcount is
+ then < 0, this causes the assertion because that is an invalid state
+ in the interrupt handler. So I think that the root cause is that
+ there the asynchrony between incrementing the semcount. This change
+ separates the list of IOBs: Currently there is only a free list of
+ IOBs. The problem, I believe, is because of asynchronies due
+ sem_post() post cause the semcount and the list content to become out
+ of sync. This change adds a new 'committed' list: When there is a
+ task waiting for an IOB, it will go into the committed list rather
+ than the free list before the semaphore is posted. On the waiting
+ side, when awakened from the semaphore wait, it will expect to find
+ its IOB in the committed list, rather than free list. In this way,
+ the content of the free list and the value of the semaphore count
+ always remain in sync.
+ - binfmt: Fix .dtor memory allocation. From Masayuki Ishikawa.
+
+ * File System/Block and MTD Drivers:
+
+ - SmartFS: If whence is SEEK_END, the file offset shall be set to the
+ size of the file plus offset. Noted by eunb.song@samsung.com.
+ - mtd/progmem: Fix incorrect target address calculation.
+ progmem_read/write() is incorrectly calculating the target address,
+ expecting the offset argument is given in a block number. This is
+ completely wrong and as a result invalid flash region is accessed.
+ Byte-oriented read/write interfaces of mtd device accept the target
+ address in a byte offset, not a block number. From Heesub Shin.
+ - procfs: Fix wrong member IDs are displayed when 'cat
+ /proc//group/status'. From Nobutaka Toyoshima.
+ - procfs: Fix incorrect uptime with CONFIG_SYSTEM_TIME64. From
+ Masayuki Ishikawa.
+ - vfs/poll: round timeout up to next full tick. Calling poll() with
+ timeout less than half tick (thus MSEC2TICK(timeout) => 0) caused
+ returning error with EAGAIN. Instead of rounding timeout down, value
+ should be rounded up. Open Group spec for poll says:
+ "Implementations may place limitations on the granularity of timeout
+ intervals. If the requested timeout interval requires a finer
+ granularity than the implementation supports, the actual timeout
+ interval will be rounded up to the next supported value." From Jussi
+ Kivilinna.
+ - mtd/config: erase block between block read and write. From Juha
+ Niskanen.
+ - mtd: Build RAMTRON and AT45DB drivers only if selected. From Juha
+ Niskanen.
+ - mtd/config: Fix byte read interface test. From Juha Niskanen.
+ - mtd: Fix some unallocated and NULL pointer issues. rwb->wrflush and
+ rwb->wrmaxblocks in rwbuffer could get unallocated values from
+ ftl_initialize() in some configurations. Also fixes related assert:
+
+ up_assert: Assertion failed at file:rwbuffer.c line: 643
+
+ that can happen with the following configuration:
+
+ CONFIG_FTL_WRITEBUFFER=y
+ CONFIG_DRVR_WRITEBUFFER=y
+ # CONFIG_FS_WRITABLE is not set
+
+ These problems are caused by CONFIG variable differences between the
+ buffer layers. TODO: This is not a perfect solution. readahead
+ support has similar issues. From Juha Niskanen.
+ - net procfs: Fix buffer corruption and refactor netdev_statistics.c.
+ From Masayuki Ishikawa.
+ - FAT: Fix 'Missing unlock' in fs_fat32.c. From Masayuki Ishikawa.
+ - VFS fdopen: Add missing file stream flags clearing. Clear file
+ stream structure regardless of config options. Structure clearing is
+ needed as previous use of stream list entry might leave fs_flags
+ set. From Harri Luhtala.
+ - mtd/smart: Fix use of uninitialized variable. From Jussi Kivilinna.
+ - mtd/w25.c: Enable short delay after sector/chip erase. From Jussi
+ Kivilinna.
+ - mtd/config: Add some error checks for I/O errors. From Juha
+ Niskanen.
+
+ * Graphics/Graphic Drivers:
+
+ - net procfs: Some long lines were being generated that cause buffer-
+ related problems and corrupted output.
+
+ * Networking/Network Drivers:
+
+ - Fixed wrong assert on udp dgram send. From Pascal Speck.
+ - TCP/IPv6: Fix a compile issue when IPv6, but not IPv4 is enabled.
+ - net/socket/accept: Fix building with CONFIG_NET_LOCAL_STREAM. From
+ Jussi Kivilinna.
+ - Argument of network device IOCTL should be unsigned long, just as
+ will all other IOCTL methods.
+ - net/socket: Fix cloning of local and raw sockets. From Jussi
+ Kivilinna.
+ - TCP: Wait for 3-Way Handshare before accept() returns. From Simon
+ Piriou.
+ - TCP: Send RST if applicaiton 'unlistens()' before we complete the
+ connection sequence.
+ - TCP: An RST received during the 3-way handshake requires a little
+ more clean-up.
+ - IPv6: Fix net_ipv6_pref2mask(). From Masayuki Ishikawa.
+ - network IOCTL commands: The only place in net/netdev/netdev_ioctl.c
+ where the interface state should change is for SIOCSIFFLAGS. The
+ other ones .. SIOCSIFADDR, SIOSLIFADDR, SIODIFADDR .. should not
+ change the link state. From Sebastien Lorquet.
+ - TCP: Fix tcp_findlistner() in dual stack mode. From Masayuki
+ Ishikawa.
+
+ * Common Drivers:
+
+ - Fix as5048b by adding missing frequency parameter. From Andreas
+ Bihlmaier.
+ - multiple fixes in nrf24l01 driver: (1) signal POLLIN if there is
+ already data in the FIFO, (2) send ETIMEDOUT to userspace after 2
+ seconds if TX IRQ was not received, (3) handle FIFO overflow, (4)
+ handle invalid pipes/empty FIFO, and (5) multiple cosmetics (missing
+ static, duplicate define, missing \n). From Leif Jakob.
+ - input/mxt: Prevent overriding i2c transfer return value.
+ put_reg/get_reg function was overriding i2c transfer error code with
+ i2creset return value, that lead to OK status although actual
+ transfer failed. From Juha Niskanen.
+ - drivers/audio/wm8904: WM8904 has same problem as that fixed by Juha
+ Niskanen in the MaxTouch driver.
+ - UART 16550: Missing left parenthesis in function prototype. This is
+ Bitbucket Issue #41.
+ - USBMSC: Fix a wrong lun number issue. From Masayuki Ishikawa.
+ - drivers/i2c: Fix compile issues if CONFIG_DISABLE_PSEUDOFS_OPERATIONS
+ is enabled.
+ - drivers/serial: I discovered a problem in the file
+ drivers/serial/serial.c concerning the function uart_close(). In the
+ case that a serial device is opened with the flag O_NONBLOCK the
+ function uart_close() blocks until all data in the buffer is
+ transmitted. The function close() called on an handle opened with
+ O_NONBLOCK should not block. The problem occurred with a CDC/ACM
+ device. From Stefan Kolb.
+ - drivers: Fix some bad NULL checks. From Juha Niskanen.
+ - drivers: Rename newly introduced up_i2creset to I2C_RESET. From
+ Juha Niskanen.
+ - drivers/bch: BCH character driver bch_ioctl() always returns -ENOTTY
+ for DIOC_GETPRIV command. It should returns OK if DIOC_GETPRIV
+ command succeeds. From EunBong Song.
+ - Replace sprintf() with snprintf() in pipe.c. From Nobutaka Toyoshima.
+ - drivers/bch: Fix 'Missing Unlock' in bchdev_driver.c. From Masayuki
+ Ishikawa.
+ - button_upper: Fix interrupt enabling for poll-events. From Jussi
+ Kivilinna.
+ - drivers/{sensors,usbmisc}: Fix uninitialized I2C frequency. From
+ Juha Niskanen.
+
+ * ARM:
+
+ - Set EABI stack alignment for all ARM architectures (remove OABI
+ code). From David Cabecinhas.
+ - Remove redundant interrupt stack coloring and OABI code. From David
+ Cabecinhas.
+ - Fix off-by-one interrupt stack allocation in 8-byte aligned
+ architectures. From David Cabecinhas.
+
+ * ARMv6-M:
+
+ - CONFIG_DEBUG_HARDFAULT should be available for Cortex-M0 too.
+
+ * Microchip/Atmel SAM3/4 Drivers:
+
+ - SAM3/4: Fixed configurations for TWI master. Obviously an
+ incomplete port from SAMA5.
+
+ * Microchip/Atmel SAMv7 Drivers:
+
+ - SAMV7: Watchdog: Fix Forbidden Window Value. According the Datasheet
+ the WDD Value is the lower bound of a so called Forbidden Window and
+ to disable this we have to set the WDD Value greater than or equal to
+ the WDV Value. This seems to be a bug in the datasheet. It looks
+ like we have to set it to a greater value than the WDV to really
+ disable this Thing. When triggering the Watchdog faster than the
+ (very slow) clock source of the Watchdog fires, this Forbidden Window
+ Feature resets the System if WDD equals to WDV. This Changeset
+ disables the Forbidden Window by setting the WDD Value to the Maximum
+ (0xfff) Value possible. From Frank Benkert.
+ - SAMV7 EMAC: Add conditional logic to account the fact that the
+ SAMV71 has 6 rather than 3 queues after version 1. From Ian McAfee.
+
+ * NXP/Freescale Kinetis Drivers:
+
+ - Kinetis: Fixed GPIO _PIN_OUTPUT_LOWDRIVE swapped with
+ _PIN_OUTPUT_OPENDRAIN. From David Sidrane.
+ - Ensure interrupts are back on BEFORE running code dependant on
+ clock_systimer. From David Sidrane.
+ - Kinetis k66, k64, k60, k40, k20: Pin mux configure all I2C signals as
+ Open Drain. The output structure of the GPIO for I2C needs to be
+ open drain. When left at the default, one can observe on a scope the
+ slave contending with the push-pull during the ACK. From David
+ Sidrane.
+ - Kinetis K66: Fixed TMP2_CH1 definition. From David Sidrane.
+ - Kinetis K66: Define ALT1 to match ref manual. From David Sidrane.
+ - Kinetis K66: GPIO and pin mux cleanup. From David Sidrane.
+ - Kinetis ADC: Various corrections and updates. From David Sidrane.
+
+ * NXP/Freescale LPC43xx:
+
+ - Add missing PINCONF_INBUFFER in several places of
+ lpc4310203050_pinconfig.h. From Andreas Bihlmaier.
+ - Fix logic in preprocessor checks and correct arguments to
+ lpc43_pin_config initialization. From Andreas Bihlmaier.
+
+ * NXP/Freescale LPC43xx Drivers:
+
+ - Fix logic error in lpc43_adc. From Andreas Bihlmaier.
+ - Use correct macro for irqid (fortunately both point to
+ LPC43_IRQ_EXTINT+18). From Andreas Bihlmaier.
+ - Actually write modified value to register. From Andreas Bihlmaier.
+ - Increase number of supported PWM channels from 4 to 6. From Andreas
+ Bihlmaier.
+
+ * Silicon Labs EFM32 Drivers:
+
+ - EFM32 I2C: Fix timeout calculation. From Masayuki Ishikawa.
+
+ * STMicro STM32:
+
+ - As discovered by dcabecinhas. This fix assume the 8 byte alignment
+ options for size stack size or this will overwrite the first word
+ after TOS. See
+ https://github.com/PX4/Firmware/issues/6613#issuecomment-285869778.
+ From David Sidrane.
+ - STM32 F7: In stm32_allocateheap.c There are 5 not 4 configurations.
+ From David Sidrane.
+
+ * STMicro STM32 Drivers:
+
+ - STM32, STM32 F7, STM32 L4: OTG host drivers: Do not do data toggle
+ if interrupt transfer is NAKed. Sugested by webbbn@gmail.com.
+ - Save elapsed time before handling I2C in stm32_i2c_sem_waitstop().
+ This change follows the same logic as in previous fix to
+ stm32_i2c_sem_waitdone(). It is possible that a context switch
+ occurs after I2C registers are read but before elapsed time is saved
+ in stm32_i2c_sem_waitstop(). It is then possible that the registers
+ were read only once with "elapsed time" equal 0. When scheduler
+ resumes this thread it is quite possible that now "elapsed time" will
+ be well above timeout threshold. In that case the function returns
+ and reports a timeout, even though the registers were not read
+ "recently". Fix this by inverting the order of operations in the loop
+ - save elapsed time before reading registers. This way a context
+ switch anywhere in the loop will not cause an erroneous "timeout"
+ error. From Freddie Chopin.
+ - STM32, STM32 F7, and STM32 L4: Clone Freddie Chopin's I2C change to
+ similar STM32 I2C drivers. From David Sidrane.
+ - STM32: OTG host implementations of stm32_in_transfer() must obey the
+ polling interval for the case of isochronous and interrupt endpoints.
+ - STM32: Fix erase sector number for microcontrolers with more than 11
+ sectors. Erase a sector from the second bank cause the bit 4 of SNB
+ being set but never unsed, so trying to erase a sector from the first
+ bank was acually eraseing a sector from the second bank. From Jos
+ Roberto de Souza.
+ - STM32: Make up_progmem thread safe. Writing to a flash sector while
+ starting the erase of other sector have a undefined behavior so lets
+ add a semaphore and syncronize access to Flash registers. But for
+ the semaphore to work it needs to be initialized so each board needs
+ call stm32_flash_initialize() on initialization, so to avoid runtime
+ problems it is only using semaphore and making it thread safe if
+ initialized, after all boards starts to call stm32_flash_initialize()
+ we can remove the boolean and the check. From Jos Roberto de Souza.
+ - STM32: Add workaround for flash data cache corruption on
+ read-while-write. This is a known hardware issue on some STM32 see
+ the errata of your model and if you make use of both memory banks you
+ should enable it. From Jos Roberto de Souza.
+ - STM32 Flash fixes. From Jos Roberto de Souza.
+ - STM32 Flash: Missing unlock on F1 HSI off path. From David Sidrane.
+ - STM32 F4 I2C: I needed to use DS3231,I rememberthatin past it
+ worked ok, but now for stm32f4xx is used another driver (chip
+ specific,stm32f40xxx_i2c.c) and DS3231 driver doesn't work. After
+ investigating a problem I found that I2C driver (isr routine) has a
+ few places there it sends stop bit even if not all messages are
+ managed. So, e.g., removing stm32_i2c_sendstop (#1744) and adding
+ stm32_i2c_sendstart after data reading helps to make DS3231 working.
+ From Alexander Oryshchenko; verified by David Sidrane.
+ - STM32 F7 Serial: Serial fix for dropped data: (1) Revert the
+ inherited dma bug from the stm32. see
+ https://bitbucket.org/nuttx/nuttx/commits/df9ae3c13fc2fff2c21ebdb098c520b11f43280d
+ for details. And (2) Most all CR1-CR3 settings can not be configured
+ while UE is true. Threfore we make all operation atomic and disable
+ UE and restore it's originalstate on exit. From David Sidrane.
+ - STM32 L1: Fix IWDG and WWDG debug mode stop for STM32L15XX. From
+ Juha Niskanen.
+ - STM32 F7: Fix UART7 and UART8 IFLOWCONTROL options. From Jussi
+ Kivilinna.
+ - STM32 F7: Add warning for RXDMA + IFLOWCONTROL combination.
+ Combination of RXDMA + IFLOWCONTROL does not work as one might
+ expect. Since RXDMA uses circular DMA-buffer, DMA will always keep
+ reading new data from USART peripheral even if DMA buffer underruns.
+ Thus this combination only does following: RTS is asserted on USART
+ setup and deasserted on shutdown and does not perform actual RTS
+ flow-control. Data loss can be demonstrated by doing long up_mdelay
+ inside irq critical section and feeding data to RXDMA+IFLOWCONTROL
+ UART. From Jussi Kivilinna.
+ - STM32 F7 Serial: Do not stop processing input in SW flow-control
+ mode. From Jussi Kivilinna.
+ - STM32 L4 DMA: Correct bad channel definition. From Sebastien Lorquet.
+ - STM32 F7: Warn if no DMA2 configured when using ADC with DMA. Also
+ correct ADC channel numbers that DMA callback passes to upper half
+ driver. From Juha Niskanen.
+ - STM32 F7 ADC: Do not override ADCPRE_DIV when measuring
+ internal voltage. From Juha Niskanen.
+ - STM32 L4: Don't think these chips have DPFPU, DTCM or ITCM. From
+ Juha Niskanen.
+ - STM32 F7 Flash: macro naming errors, there is no FLASH_CONFIG_F for
+ F7. From Juha Niskanen.
+ - STM32 L4: stm32l4x6xx_pinmap: Update I2C4 and DCMI pins. From Juha
+ Niskanen.
+ - STM32 L4: stm32l4_i2c: change wrong macro to CONFIG_I2C_POLLED. From
+ Juha Niskanen.
+ - Fix STM32F7 I2C interrupt handler. From Jussi Kivilinna.
+ - STM32: Serial Allow configuring Rx DMA buffer size. From David
+ Sidrane.
+ - STM32 CAN: I had the problem that the transmit FIFO size (= actual
+ elements in FIFO) was slowly increasing over time, and was full after
+ a few hours. The reason was that the code hit the line
+ "canerr("ERROR: No available mailbox\n");" in stm32_cansend, so
+ can_xmit thinks it has sent the packet to the hardware, but actually
+ has not. Therefore the transmit interrupt never happens which would
+ call can_txdone, and so the size of the FIFO size does not decrease.
+ The reason why the code actually hit the mentioned line above, is
+ because stm32can_txready uses a different (incomplete) condition than
+ stm32can_send to determine if the mailbox can be used for sending,
+ and thus can_xmit forwards the packet to stm32can_send.
+ stm32can_txready considered mailboxes OK for sending if the mailbox
+ was empty, but did not consider that mailboxes may not yet be used if
+ the request completed bit is set - stm32can_txinterrupt has to
+ process these mailboxes first. Note that I have also modified
+ stm32can_txinterrupt - I removed the if condition, because the CAN
+ controller retries to send the packet until it succeeds. Also if the
+ condition would not evaluate to true, can_txdone would not be called
+ and the FIFO size would not decrease also. From Lederhilger Martin.
+ - STM32 Serial: Fix freezing serial port. Serial interrupt
+ enable/disable functions do not disable interrupts and can freeze
+ device when serial interrupt is received while execution is at those
+ functions. Trivially triggered with two or more threads write to
+ regular syslog stream and to emergency stream. In this case, freeze
+ happens because of mismatch of priv->ie (TXEIE == 0) and actually
+ enabled interrupts in USART registers (TXEIE == 1), which leads to
+ unhandled TXE interrupt and causes interrupt storm for USART. From
+ Jussi Kivilinna.
+ - STM32 I2C: Make private symbols static. From Juha Niskanen.
+ - STM32 L4 GPIO: Put back EXTI line source selection. From Juha
+ Niskanen.
+ - STM32 L4 RTC: Store RTC MAGIC to backup reg, not to address zero.
+ From Juha Niskanen.
+
+ * STMicro STM32 Boards:
+
+ - Disable serial console on stm32f103-minimum usbnsh example project
+ config. Devices enumerate after this change. From Bob Ryan.
+ - Nucleo-144: Default for choice in Kconfig was not one of the
+ possible choices.
+ - Nucleo-F4X1RE User LEDS: Issue #51 reports compilation problems with
+ stm32_userled.c. Reported by Gappi92.
+
+ * TI Tiva Drivers:
+
+ - Tiva I2C: Correct an error in conditional compilation.
+ - Tiva SSI: Resolves issue 52 'Copy-Paste error in
+ tiva_ssibus_initialize()' submitted by Aleksandr Kazantsev.
+
+ * C Library/Header Files:
+
+ - C Library vsnprintf(): Fix precision for string formatting. Fixes
+ use of format precision to truncate input string. From Jussi
+ Kivilinna.
+ - C Library vsnprintf(): If size is zero, then vsnprintf() should
+ return the size of the required buffer without writing anything.
+ From Jussi Kivilinna.
+ - C Library netdb: in dns_query_callback, ret != -EADDRNOTAVAIL
+ condition consumes error returns including EAGAIN in this case,
+ dns query retransmission doesn't work. From Ritajina.
+ - C Library netdb: Fix time info in lib_dnscache.c. From Masayuki
+ Ishikawa.
+ - C Library netdb: Fix bugs in lib_gethostbynamer.c. This fix sets
+ h_name in struct hostent returned by gethostbyname(). From Masayuki
+ Ishikawa.
+ - C Library Defect Workaround: replace '%6.6u' format with an
+ equivalent '%06u'. From Tomasz Wozniak.
+
+ * Tools
+
+ - Fix mksyscall host binary name. From Alan Carvalho de Assis.
+
+ * Applications (apps/)
+
+ - Fix some calls to task_create(): argv[0] is the first parameter, not
+ the name of the task.
+ - Bitbucket Issue 5: I found an unexpected behavior in apps/
+ configuration generation. Adding external symbolic link in apps/
+ directory and using Make.defs for Kconfig generation, Kconfig file
+ has a wrong path in the source argument. It contains original dir
+ path outside of the source tree instead path to sub-directory in
+ apps/. The problem is connected with make/system symbolic link path
+ resolution. Corrected by a patch submitted by Artur Madrzak with
+ Issue 5.
+ - apps/: Make more globals static to avoid name clashes. From Juha
+ Niskanen.
+
+ * NSH: apps/nshlib:
+
+ - NSH library: In nsh_argexand(), if CONFIG_NSH_ARGCAT is defined but
+ CONFIG_NSH_CMDPARMS defined and/or CONFIG_DISABLE_ENVIRON not
+ defined, then there is a situation that causes an infinite loop in
+ the parser. Noted by Freddie Chopin.
+ - NSH library: Fix building when CONFIG_NET_USRSOCK enabled with other
+ link-layers. From Jussi Kivilinna.
+ - NSH library: Fix some warnings about integer/pointer casts of
+ different sizes (probably only effects 64-bit simulation).
+ - NSH library: Fix open flags in nsh_codeccmd.c. From Masayuki
+ Ishikawa.
+ - I need to look at the registers that are at or around 0xe000ef90.
+ Using mw and xd, I see that nsh does not support pointers greater
+ than 0x7fffffff. A quick look at the source shows that the pointers
+ for those two commands are set with calls to strtol() rather than
+ strtoul(). Changing the two pointer-setting instances to strtoul()
+ fixes the problem, at least for my architecture/config. From Ian
+ McAfee.
+ - NSH library: Fix a resource leak in cmd_hexdump(). From Nobutaka
+ Toyoshima.
+
+ * Examples/Tests: apps/examples:
+
+ - apps/examples/hidkbd: Remove call to arch_usbhost_initialize().
+ That is violation of the OS interfacing rules and will no longer be
+ supported. USB host should be initialized as part of the normal
+ board bring-up logic as with any other devices and should not involve
+ illegal calls from applications into the OS.
+ - apps/examples/usbterm: Removed because it is not very useful and
+ because it can be configured to use an illegal call into the OS.
+ - examples/mm: Fix Makefile. Built-in was not being registered.
+ - examples/hidkbd: Add some missing configuration settings.
+ - examples/random: Avoid stack overflows. From Juha Niskanen.
+ - examples/nettest: Fix an error in pre-processor expression.
+ - examples/mtdpart: Prevent part array overflow. mtdpart examples
+ create partions and allocate from 1 index not a 0 index to part[]
+ array. This cause buffer overflow for part array. This change fixes
+ this problem. From EunBong Song.
+ - examples/can: Fix can example app to print data when
+ CONFIG_EXAMPLE_CAN_READ is defined. From Alan Carvalho de Assis.
+
+ * Network Utilies: apps/netuils:
+
+ - Not a clean fix, but at least makes DHCP working with
+ CONFIG_NETDEV_MULTINIC. From Andreas Bihlmaier.
+ - Ensure netlib will not be broken when setip will not bring the
+ network up anymore. From Sebastien Lorquet.
+
+ * CAN Utilies: apps/canutils:
+
+ - Fix libcanard github download link to get it compiling correctly.
+ From Alan Carvalho de Assis.
+ - Fix to use the new canardInit() function. From Alan Carvalho de
+ Assis.
+
+ * System Unitilities (apps/system)
+
+ - system/dhcpc: Add missing argument of fprintf.
+
+ * Tools (apps/tools):
+
+ - The dedicated windows tool at tools/mkkconfig.bat uses $APPSDIR,
+ which is not a windows shell variable, and is left uninitialized, but
+ in fact should be the current directory. From Sebastien Lorquet.
diff --git a/TODO b/TODO
index 8ab2b48b50f3d3d42c1e06db1cc40abd99411c31..46f6c597e4e9960c0308949fe1aecb130747dbb0 100644
--- a/TODO
+++ b/TODO
@@ -1,4 +1,4 @@
-NuttX TODO List (Last updated March 7, 2017)
+NuttX TODO List (Last updated June 14, 2017)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This file summarizes known NuttX bugs, limitations, inconsistencies with
@@ -9,23 +9,23 @@ issues related to each board port.
nuttx/:
- (10) Task/Scheduler (sched/)
+ (11) Task/Scheduler (sched/)
(1) SMP
(1) Memory Management (mm/)
(0) Power Management (drivers/pm)
(3) Signals (sched/signal, arch/)
- (2) pthreads (sched/pthread)
+ (3) pthreads (sched/pthread)
(0) Message Queues (sched/mqueue)
(8) Kernel/Protected Build
(3) C++ Support
(6) Binary loaders (binfmt/)
- (13) Network (net/, drivers/net)
+ (14) Network (net/, drivers/net)
(4) USB (drivers/usbdev, drivers/usbhost)
(0) Other drivers (drivers/)
(12) Libraries (libc/, libm/)
(10) File system/Generic drivers (fs/, drivers/)
(9) Graphics Subsystem (graphics/)
- (2) Build system / Toolchains
+ (3) Build system / Toolchains
(3) Linux/Cywgin simulation (arch/sim)
(4) ARM (arch/arm/)
@@ -45,10 +45,17 @@ o Task/Scheduler (sched/)
terminated?
Status: Closed. No, this behavior will not be implemented.
Priority: Medium, required for good emulation of process/pthread model.
+ The current behavior allows for the main thread of a task to
+ exit() and any child pthreads will perist. That does raise
+ some issues: The main thread is treated much like just-another-
+ pthread but must follow the semantics of a task or a process.
+ That results in some inconsistencies (for example, with robust
+ mutexes, what should happen if the main thread exits while
+ holding a mutex?)
Title: pause() NON-COMPLIANCE
- Description: In the POSIX description of this function is the pause() function
- will suspend the calling thread until delivery of a signal whose
+ Description: In the POSIX description of this function the pause() function
+ must suspend the calling thread until delivery of a signal whose
action is either to execute a signal-catching function or to
terminate the process. The current implementation only waits for
any non-blocked signal to be received. It should only wake up if
@@ -108,9 +115,10 @@ o Task/Scheduler (sched/)
2. They run in supervisor mode (if applicable), and
3. They do not obey any setup of PIC or address
environments. Do they need to?
- 4. In the case of task_delete() and pthread_cancel(), these
- callbacks will run on the thread of execution and address
- context of the caller of task. That is very bad!
+ 4. In the case of task_delete() and pthread_cancel() without
+ defferred cancellation, these callbacks will run on the
+ thread of execution and address context of the caller of
+ task_delete() or pthread_cancel(). That is very bad!
The fix for all of these issues it to have the callbacks
run on the caller's thread as is currently done with
@@ -185,6 +193,74 @@ o Task/Scheduler (sched/)
Priority: Low. Things are just the way that we want them for the way
that NuttX is used today.
+ Title: INTERNAL VERSIONS OF USER FUNCTIONS
+ Description: The internal NuttX logic uses the same interfaces as does
+ the application. That sometime produces a problem because
+ there is "overloaded" functionality in those user interfaces
+ that are not desireable.
+
+ For example, having cancellation points hidden inside of the
+ OS can cause non-cancellation point interfaces to behave
+ strangely. There was a change recently in pthread_cond_wait()
+ and pthread_cond_timedwait() recently to effectively disable
+ the cancellation point behavior of sem_wait(). This was
+ accomplished with two functions: pthread_disable_cancel()
+ and pthread_enable_cancel()
+
+ Here is another issue: Internal OS functions should not set
+ errno and should never have to look at the errno value to
+ determine the cause of the failure. The errno is provided
+ for compatibility with POSIX application interface
+ requirements and really doesn't need to be used within the
+ OS.
+
+ Both of these could be fixed if there were special internal
+ versions these functions. For example, there could be a an
+ nx_sem_wait() that does all of the same things as sem_wait()
+ was does not create a cancellation point and does not set
+ the errno value on failures.
+
+ Everything inside the OS would use nx_sem_wait().
+ Applications would call sem_wait() which would just be a
+ wrapper around nx_sem_wait() that adds the cancellation point
+ and that sets the errno value on failures.
+
+ Changes like that could clean up some of this internal
+ craziness. The condition variable change described above is
+ really a "bandaid" to handle the case that sem_wait() is a
+ cancellation point.
+ Status: Open
+ Priority: Low. Things are working OK the way they are. But the design
+ could be improved and made a little more efficient with this
+ change.
+
+ Title: INAPPROPRIATE USE OF sched_lock() BY pthreads
+ Description: In implementation of standard pthread functions, the non-
+ standard, NuttX function sched_lock() is used. This is very
+ strong sense it disables pre-emption for all threads in all
+ task groups. I believe it is only really necessary in most
+ cases to lock threads in the task group with a new non-
+ standard interface, say pthread_lock().
+
+ This is because the OS resources used by a thread such as
+ mutexes, condition variable, barriers, etc. are only
+ meaningful from within the task group. So, in order to
+ performance exclusive operations on these resources, it is
+ only necessary to block other threads executing within the
+ task group.
+
+ This is an easy change: pthread_lock() and pthread_unlock()
+ would simply operate on a semaphore retained in the task
+ group structure. I am, however, hesitant to make this change:
+ I the flat build model, there is nothing that prevents people
+ from accessing the inter-thread controls from threads in
+ differnt task groups. Making this change, while correct,
+ might introduce subtle bugs in code by people who are not
+ using NuttX correctly.
+ Status: Open
+ Priority: Low. This change would improve real-time performance of the
+ OS but is not otherwise required.
+
o SMP
^^^
@@ -346,7 +422,7 @@ o Signals (sched/signal, arch/)
Priority: Low. Even if there are only 31 usable signals, that is still a lot.
o pthreads (sched/pthreads)
- ^^^^^^^^^^^^^^^^^
+ ^^^^^^^^^^^^^^^^^^^^^^^^^
Title: PTHREAD_PRIO_PROTECT
Description: Extend pthread_mutexattr_setprotocol(). It should support
@@ -448,6 +524,16 @@ o pthreads (sched/pthreads)
Status: Not really open. This is just the way it is.
Priority: Nothing additional is planned.
+ Title: PTHREAD FILES IN WRONG LOCATION
+ Description: There are many pthread interface functions in files located in
+ sched/pthread. These should be moved from that location to
+ libc/pthread. In the flat build, this really does not matter,
+ but in the protected build that location means that system calls
+ are required to access the pthread interface functions.
+ Status: Open
+ Priority: Medium-low. Priority may be higher if system call overheade becomes
+ an issue.
+
o Message Queues (sched/mqueue)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -507,7 +593,7 @@ o Kernel/Protected Build
in the nuttx/ directory. However, the user interfaces must be
moved into a NuttX library or into apps/. Currently
applications calls to the NxTerm user interfaces are
- undefined.
+ undefined in the Kernel/Protected builds.
Status: Open
Priority: Medium
@@ -940,8 +1026,8 @@ o Network (net/, drivers/net)
however. Others support the address filtering interfaces but
have never been verifed:
- C5471, LM3X, ez80, DM0x90 NIC, PIC: Do not support address
- filteringing.
+ C5471, LM3S, ez80, DM0x90 NIC, PIC: Do not support address
+ filtering.
Kinetis, LPC17xx, LPC43xx: Untested address filter support
Status: Open
@@ -1023,19 +1109,11 @@ o Network (net/, drivers/net)
Status: Open
Priority: Low
- Title: REMOVE CONFIG_NET_MULTIBUFFER
- Description: The CONFIG_NET_MULTIBUFFER controls some details in the layout
- of the network device structure. This is really a unnecessary
- complexity and should be removed. The cost for those network
- drivers that currently do not support CONFIG_NET_MULTIBUFFER
- is the size of one pointer.
- 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
+ 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."
@@ -1065,6 +1143,34 @@ o Network (net/, drivers/net)
Status: Open
Priority: High if you happen to be using Ethernet in this configuration.
+ Title: REPARTITION DRIVER FUNCTIONALITY
+ Description: Every network driver performs the first level of packet decoding.
+ It examines the packet header and calls ipv4_input(), ipv6_input().
+ icmp_input(), etc. as appropriate. This is a maintenance problem
+ because it means that any changes to the network input interfaces
+ affects all drivers.
+
+ A better, more maintainable solution would use a single net_input()
+ function that would receive all incoming packets. This function
+ would then perform that common packet decoding logic that is
+ currently implemented in every network driver.
+ Status: Open
+ Priority: Low. Really just as aesthetic maintainability issue.
+
+ Title: BROADCAST WITH MULTIPLE NETWORK INTERFACES
+ Description: There is currently no mechanism to send a broadcast packet
+ out through several network interfaces. Currently packets
+ can be sent to only one device. Logic in netdev_findby_ipvXaddr()
+ currently just selects the first device in the list of
+ devices; only that device will receive broadcast packets.
+ Status: Open
+ Priority: High if you require broadcast on multiple networks. There is
+ no simple solution known at this time, however. Perhaps
+ netdev_findby_ipvXaddr() should return a list of devices rather
+ than a single device? All upstream logic would then have to
+ deal with a list of devices. That would be a huge effect and
+ certainly doesn't dount as a "simple solution".
+
o USB (drivers/usbdev, drivers/usbhost)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -1753,6 +1859,73 @@ o Build system
Priority: Low, since I am not aware of anyone using the Windows Native build.
But, of course, very high if you want to use it.
+ Title: CONTROL-C CAN BREAK DEPENDENCIES
+ Description: If you control C out of a make, then there are things that can go
+ wrong. For one, you can break the dependencies in this scenario:
+
+ - The build in a given directory begins with all of the compilations.
+ On terminal, this the long phase with CC: on each line. As each
+ .o file is created, it is timestamped with the current time.
+
+ - The dependencies on each .o are such that the C file will be re-
+ compile if the .o file is OLDER that the corresponding .a archive
+ file.
+
+ - The compilation phase is followed by a single, relatively short
+ AR: phase that adds each of the file to the .a archive file. As
+ each file is added to archive, the timestamp of the of archive is
+ updated to the current time. After the first .o file has been
+ added, then archive file will have a newly timestamp than any of
+ the newly compiled .o file.
+
+ - If the user aborts with control-C during this AR: phase, then we
+ are left with: (1) not all of the files have bee added to the
+ archive, and (2) the archive file has a newer timestamp than any
+ of the .o file.
+
+ So when the make is restarted after a control, the dependencies will
+ see that the .a archive file has the newer time stamp and those .o
+ file will never be added to the archive until the directory is cleaned
+ or some other dependency changes.
+ Status Open
+ Priority: Medium-High. It is a rare event that control-C happens at just the
+ point in time. However, when it does occur the resulting code may
+ have binary incompatiblies in the code taken from the out-of-sync
+ archives and cost a lot of debug time before you realize the issue.
+
+ A work-around is to do 'make clean' if you ever decide to control-C
+ out of a make. A couple of solutions have been considered:
+
+ - Currently, there is a sequence of compilations ins a directory
+ with messages like CC:, CC:, CC: etc. This is followed by one big
+ archival AR:
+
+ The window in which the control-C problem can occur could be
+ minimized (but not eliminated) by performing a archival for each
+ compiliation like CC: AR:, CC: AR:, etc.
+
+ - Introduce a spurious dependency that has the correct time stamp.
+ For example given Make like like (from nuttx/sched/Makefile):
+
+ $(BIN): $(OBJS)
+ $(call ARCHIVE, $@, $(OBJS))
+
+ Could be changed like:
+
+ .archive: $(OBJS)
+ $(call ARCHIVE, $@, $(OBJS))
+ @touch .archive
+
+ $(BIN): .archive
+
+ .archive would be a totally spurious file that is touched only AFTER
+ ALL .o files have been archived. Thus is the user control-C's out of
+ the make during the archival, the timestamp on .archive is not
+ updated.
+
+ The .archive file would have to be removed on 'make clean' and would
+ also need to appear in .gitignore files.
+
o Other drivers (drivers/)
^^^^^^^^^^^^^^^^^^^^^^^^
@@ -1993,7 +2166,7 @@ o Pascal Add-On (pcode/)
Priority: Medium
Title: PDBG
- Description: Move the the pascal p-code debugger into the NuttX apps/ tree
+ Description: Move the pascal p-code debugger into the NuttX apps/ tree
where it can be used from the NSH command line.
Status: Open
Priority: Low
@@ -2039,4 +2212,3 @@ o Other Applications & Tests (apps/examples/)
the artifact is larger.
Status: Open
Priority: Medium.
-
diff --git a/arch/Kconfig b/arch/Kconfig
index 6fac6fd310b679ec458384978ddab7e298c78faf..a621f6f163519263e39d5eb097520abcb5ef47b4 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -124,6 +124,14 @@ source arch/xtensa/Kconfig
source arch/z16/Kconfig
source arch/z80/Kconfig
+config ARCH_TOOLCHAIN_IAR
+ bool
+ default n
+
+config ARCH_TOOLCHAIN_GNU
+ bool
+ default n
+
comment "Architecture Options"
config ARCH_NOINTC
@@ -190,6 +198,10 @@ config ARCH_HAVE_RESET
bool
default n
+config ARCH_HAVE_RTC_SUBSECONDS
+ bool
+ default n
+
config ARCH_USE_MMU
bool "Enable MMU"
default n
@@ -763,7 +775,7 @@ config ARCH_HIPRI_INTERRUPT
there will most likely be a system failure.
If the interrupt stack is selected, on the other hand, then the
- interrupt handler will always set the the MSP to the interrupt
+ interrupt handler will always set the MSP to the interrupt
stack. So when the high priority interrupt occurs, it will either
use the MSP of the last privileged thread to run or, in the case of
the nested interrupt, the interrupt stack if no privileged task has
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index fd44dcff0775e5506d35eebbe4a922167106e031..54f254ff6835a4767cdbae312cab0e0a693bae2b 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -76,6 +76,7 @@ config ARCH_CHIP_KINETIS
select ARCH_HAVE_FPU
select ARCH_HAVE_RAMFUNCS
select ARCH_HAVE_CMNVECTOR
+ select ARCH_HAVE_I2CRESET
---help---
Freescale Kinetis Architectures (ARM Cortex-M4)
@@ -151,12 +152,20 @@ config ARCH_CHIP_LPC43XX
---help---
NPX LPC43XX architectures (ARM Cortex-M4).
+config ARCH_CHIP_MOXART
+ bool "MoxART"
+ select ARCH_ARM7TDMI
+ select ARCH_HAVE_RESET
+ select ARCH_HAVE_SERIAL_TERMIOS
+ ---help---
+ MoxART family
+
config ARCH_CHIP_NUC1XX
bool "Nuvoton NUC100/120"
select ARCH_CORTEXM0
select ARCH_HAVE_CMNVECTOR
---help---
- NPX LPC43XX architectures (ARM Cortex-M4).
+ Nuvoton NUC100/120 architectures (ARM Cortex-M0).
config ARCH_CHIP_SAMA5
bool "Atmel SAMA5"
@@ -224,6 +233,13 @@ config ARCH_CHIP_STM32
---help---
STMicro STM32 architectures (ARM Cortex-M3/4).
+config ARCH_CHIP_STM32F0
+ bool "STMicro STM32 F0"
+ select ARCH_CORTEXM0
+ select ARCH_HAVE_CMNVECTOR
+ ---help---
+ STMicro STM32 architectures (ARM Cortex-M0).
+
config ARCH_CHIP_STM32F7
bool "STMicro STM32 F7"
select ARCH_HAVE_CMNVECTOR
@@ -270,13 +286,18 @@ config ARCH_CHIP_TMS570
---help---
TI TMS570 family
-config ARCH_CHIP_MOXART
- bool "MoxART"
- select ARCH_ARM7TDMI
- select ARCH_HAVE_RESET
- select ARCH_HAVE_SERIAL_TERMIOS
+config ARCH_CHIP_XMC4
+ bool "Infineon XMC4xxx"
+ select ARCH_HAVE_CMNVECTOR
+ select ARCH_CORTEXM4
+ select ARCH_HAVE_MPU
+ select ARCH_HAVE_RAMFUNCS
+ select ARCH_HAVE_I2CRESET
+ select ARM_HAVE_MPU_UNIFIED
+ select ARMV7M_CMNVECTOR
+ select ARMV7M_HAVE_STACKCHECK
---help---
- MoxART family
+ Infineon XMC4xxx(ARM Cortex-M4) architectures
endchoice
@@ -421,25 +442,19 @@ config ARCH_CHIP
default "lpc2378" if ARCH_CHIP_LPC2378
default "lpc31xx" if ARCH_CHIP_LPC31XX
default "lpc43xx" if ARCH_CHIP_LPC43XX
+ default "moxart" if ARCH_CHIP_MOXART
default "nuc1xx" if ARCH_CHIP_NUC1XX
default "sama5" if ARCH_CHIP_SAMA5
default "samdl" if ARCH_CHIP_SAMD || ARCH_CHIP_SAML
default "sam34" if ARCH_CHIP_SAM34
default "samv7" if ARCH_CHIP_SAMV7
default "stm32" if ARCH_CHIP_STM32
+ default "stm32f0" if ARCH_CHIP_STM32F0
default "stm32f7" if ARCH_CHIP_STM32F7
default "stm32l4" if ARCH_CHIP_STM32L4
default "str71x" if ARCH_CHIP_STR71X
default "tms570" if ARCH_CHIP_TMS570
- default "moxart" if ARCH_CHIP_MOXART
-
-config ARM_TOOLCHAIN_IAR
- bool
- default n
-
-config ARM_TOOLCHAIN_GNU
- bool
- default n
+ default "xmc4" if ARCH_CHIP_XMC4
config ARMV7M_USEBASEPRI
bool "Use BASEPRI Register"
@@ -596,7 +611,7 @@ config ARCH_ROMPGTABLE
config DEBUG_HARDFAULT
bool "Verbose Hard-Fault Debug"
default n
- depends on DEBUG_FEATURES && (ARCH_CORTEXM3 || ARCH_CORTEXM4 || ARCH_CORTEXM7)
+ depends on DEBUG_FEATURES && (ARCH_CORTEXM0 || ARCH_CORTEXM3 || ARCH_CORTEXM4 || ARCH_CORTEXM7)
---help---
Enables verbose debug output when a hard fault is occurs. This verbose
output is sometimes helpful when debugging difficult hard fault problems,
@@ -662,6 +677,9 @@ endif
if ARCH_CHIP_LPC43XX
source arch/arm/src/lpc43xx/Kconfig
endif
+if ARCH_CHIP_MOXART
+source arch/arm/src/moxart/Kconfig
+endif
if ARCH_CHIP_NUC1XX
source arch/arm/src/nuc1xx/Kconfig
endif
@@ -680,6 +698,9 @@ endif
if ARCH_CHIP_STM32
source arch/arm/src/stm32/Kconfig
endif
+if ARCH_CHIP_STM32F0
+source arch/arm/src/stm32f0/Kconfig
+endif
if ARCH_CHIP_STM32F7
source arch/arm/src/stm32f7/Kconfig
endif
@@ -692,8 +713,8 @@ endif
if ARCH_CHIP_TMS570
source arch/arm/src/tms570/Kconfig
endif
-if ARCH_CHIP_MOXART
-source arch/arm/src/moxart/Kconfig
+if ARCH_CHIP_XMC4
+source arch/arm/src/xmc4/Kconfig
endif
endif # ARCH_ARM
diff --git a/arch/arm/include/kinetis/chip.h b/arch/arm/include/kinetis/chip.h
index 5c6cc76a0822deb212292e76d37e72dc737e7d55..cc50674e97d5644a1186b2c660dd2c98a91a8388 100644
--- a/arch/arm/include/kinetis/chip.h
+++ b/arch/arm/include/kinetis/chip.h
@@ -1438,8 +1438,9 @@
# define KINETIS_NDAC6 4 /* Four 6-bit DAC */
# define KINETIS_NDAC12 2 /* Two 12-bit DAC */
# define KINETIS_NVREF 1 /* Voltage reference */
-# define KINETIS_NTIMERS8 2 /* ? Two 8 channel timers */
-# define KINETIS_NTIMERS2 2 /* ? Two 2 channel timers */
+# define KINETIS_NTIMERS8 2 /* Two 8 channel FTM timers */
+# define KINETIS_NTIMERS2 2 /* Two 2 channel FTM timers */
+# define KINETIS_NTPMTIMERS2 2 /* Two 2 channel TPM timers */
# define KINETIS_NRTC 1 /* Real time clock */
# define KINETIS_NRNG 1 /* Random number generator */
# define KINETIS_NMMCAU 1 /* Hardware encryption */
diff --git a/arch/arm/include/lpc11xx/irq.h b/arch/arm/include/lpc11xx/irq.h
index 46ff7d27cac9225a98bca731e1a287dff5beb9ab..dad551e5d8f241a560be5d71dc94bbc329ea9727 100644
--- a/arch/arm/include/lpc11xx/irq.h
+++ b/arch/arm/include/lpc11xx/irq.h
@@ -109,8 +109,8 @@
#define LPC11_IRQ_PIO0 (47) /* Vector 47: PIO0 */
#endif
-#define NR_VECTORS (64) /* 64 vectors */
-#define NR_IRQS (48) /* 64 interrupts but 48 IRQ numbers */
+#define NR_VECTORS (48) /* 48 vectors */
+#define NR_IRQS (48) /* 32 interrupts plus 16 exceptions */
/****************************************************************************
* Public Types
diff --git a/arch/arm/include/nuc1xx/nuc120_irq.h b/arch/arm/include/nuc1xx/nuc120_irq.h
index 5310b2cd8ece82260b4c9db629d87bbfb6e7558b..fa287c05d3c0a39cb0eaaae242088a0067fc0e44 100644
--- a/arch/arm/include/nuc1xx/nuc120_irq.h
+++ b/arch/arm/include/nuc1xx/nuc120_irq.h
@@ -52,10 +52,10 @@
#define NUC_IRQ_BOD (16) /* Brown-out low voltage detected */
#define NUC_IRQ_WDT (17) /* Watchdog Timer */
-#define NUC_IRQ_EINT0 (18) /* Eternal interrupt from PB.14 */
-#define NUC_IRQ_EINT1 (19) /* Eternal interrupt from PB.15 */
-#define NUC_IRQ_GPAB (20) /* Eternal interrupt from PA[15:0]/PB[13:0] */
-#define NUC_IRQ_GPCDE (21) /* Eternal interrupt from PC[15:0]/PD[15:0]/PE[15:0] */
+#define NUC_IRQ_EINT0 (18) /* External interrupt from PB.14 */
+#define NUC_IRQ_EINT1 (19) /* External interrupt from PB.15 */
+#define NUC_IRQ_GPAB (20) /* External interrupt from PA[15:0]/PB[13:0] */
+#define NUC_IRQ_GPCDE (21) /* External interrupt from PC[15:0]/PD[15:0]/PE[15:0] */
#define NUC_IRQ_PWMA (22) /* PWM0-3 */
#define NUC_IRQ_PWMB (23) /* PWM4-7 */
#define NUC_IRQ_TMR0 (24) /* Timer 0 */
diff --git a/arch/arm/include/samdl/samd20_irq.h b/arch/arm/include/samdl/samd20_irq.h
index 709fddaeac891120c423746105fa696dcc3580e5..9524b3650ce0ce4d96c40357912ea1b583da6616 100644
--- a/arch/arm/include/samdl/samd20_irq.h
+++ b/arch/arm/include/samdl/samd20_irq.h
@@ -82,22 +82,22 @@
/* GPIO interrupts. Up to 16 pins may be configured to support interrupts */
#ifdef CONFIG_SAMDL_GPIOIRQ
-# define SAM_IRQ_EXTINT0 (SAM_IRQ_NIRQS+0) /* External interrupt 0 */
-# define SAM_IRQ_EXTINT1 (SAM_IRQ_NIRQS+1) /* External interrupt 1 */
-# define SAM_IRQ_EXTINT2 (SAM_IRQ_NIRQS+2) /* External interrupt 2 */
-# define SAM_IRQ_EXTINT3 (SAM_IRQ_NIRQS+3) /* External interrupt 3 */
-# define SAM_IRQ_EXTINT4 (SAM_IRQ_NIRQS+4) /* External interrupt 4 */
-# define SAM_IRQ_EXTINT5 (SAM_IRQ_NIRQS+5) /* External interrupt 5 */
-# define SAM_IRQ_EXTINT6 (SAM_IRQ_NIRQS+6) /* External interrupt 6 */
-# define SAM_IRQ_EXTINT7 (SAM_IRQ_NIRQS+7) /* External interrupt 7 */
-# define SAM_IRQ_EXTINT8 (SAM_IRQ_NIRQS+8) /* External interrupt 8 */
-# define SAM_IRQ_EXTINT9 (SAM_IRQ_NIRQS+9) /* External interrupt 9 */
-# define SAM_IRQ_EXTINT10 (SAM_IRQ_NIRQS+10) /* External interrupt 10 */
-# define SAM_IRQ_EXTINT11 (SAM_IRQ_NIRQS+11) /* External interrupt 11 */
-# define SAM_IRQ_EXTINT12 (SAM_IRQ_NIRQS+12) /* External interrupt 12 */
-# define SAM_IRQ_EXTINT13 (SAM_IRQ_NIRQS+13) /* External interrupt 13 */
-# define SAM_IRQ_EXTINT14 (SAM_IRQ_NIRQS+14) /* External interrupt 14 */
-# define SAM_IRQ_EXTINT15 (SAM_IRQ_NIRQS+15) /* External interrupt 15 */
+# define SAM_IRQ_EXTINT0 (SAM_IRQ_NIRQS+0) /* External interrupt 0 */
+# define SAM_IRQ_EXTINT1 (SAM_IRQ_NIRQS+1) /* External interrupt 1 */
+# define SAM_IRQ_EXTINT2 (SAM_IRQ_NIRQS+2) /* External interrupt 2 */
+# define SAM_IRQ_EXTINT3 (SAM_IRQ_NIRQS+3) /* External interrupt 3 */
+# define SAM_IRQ_EXTINT4 (SAM_IRQ_NIRQS+4) /* External interrupt 4 */
+# define SAM_IRQ_EXTINT5 (SAM_IRQ_NIRQS+5) /* External interrupt 5 */
+# define SAM_IRQ_EXTINT6 (SAM_IRQ_NIRQS+6) /* External interrupt 6 */
+# define SAM_IRQ_EXTINT7 (SAM_IRQ_NIRQS+7) /* External interrupt 7 */
+# define SAM_IRQ_EXTINT8 (SAM_IRQ_NIRQS+8) /* External interrupt 8 */
+# define SAM_IRQ_EXTINT9 (SAM_IRQ_NIRQS+9) /* External interrupt 9 */
+# define SAM_IRQ_EXTINT10 (SAM_IRQ_NIRQS+10) /* External interrupt 10 */
+# define SAM_IRQ_EXTINT11 (SAM_IRQ_NIRQS+11) /* External interrupt 11 */
+# define SAM_IRQ_EXTINT12 (SAM_IRQ_NIRQS+12) /* External interrupt 12 */
+# define SAM_IRQ_EXTINT13 (SAM_IRQ_NIRQS+13) /* External interrupt 13 */
+# define SAM_IRQ_EXTINT14 (SAM_IRQ_NIRQS+14) /* External interrupt 14 */
+# define SAM_IRQ_EXTINT15 (SAM_IRQ_NIRQS+15) /* External interrupt 15 */
# define SAM_IRQ_NEXTINTS 16
#else
# define SAM_IRQ_NEXTINTS 0
diff --git a/arch/arm/include/samdl/samd21_irq.h b/arch/arm/include/samdl/samd21_irq.h
index 7b5c633ef62bffe9675a20ced0096a3c5d75bcf3..e0b26bf962a8b0c4bc1e06a420b166e048e6139d 100644
--- a/arch/arm/include/samdl/samd21_irq.h
+++ b/arch/arm/include/samdl/samd21_irq.h
@@ -89,22 +89,22 @@
/* GPIO interrupts. Up to 16 pins may be configured to support interrupts */
#ifdef CONFIG_SAMDL_GPIOIRQ
-# define SAM_IRQ_EXTINT0 (SAM_IRQ_NIRQS+0) /* External interrupt 0 */
-# define SAM_IRQ_EXTINT1 (SAM_IRQ_NIRQS+1) /* External interrupt 1 */
-# define SAM_IRQ_EXTINT2 (SAM_IRQ_NIRQS+2) /* External interrupt 2 */
-# define SAM_IRQ_EXTINT3 (SAM_IRQ_NIRQS+3) /* External interrupt 3 */
-# define SAM_IRQ_EXTINT4 (SAM_IRQ_NIRQS+4) /* External interrupt 4 */
-# define SAM_IRQ_EXTINT5 (SAM_IRQ_NIRQS+5) /* External interrupt 5 */
-# define SAM_IRQ_EXTINT6 (SAM_IRQ_NIRQS+6) /* External interrupt 6 */
-# define SAM_IRQ_EXTINT7 (SAM_IRQ_NIRQS+7) /* External interrupt 7 */
-# define SAM_IRQ_EXTINT8 (SAM_IRQ_NIRQS+8) /* External interrupt 8 */
-# define SAM_IRQ_EXTINT9 (SAM_IRQ_NIRQS+9) /* External interrupt 9 */
-# define SAM_IRQ_EXTINT10 (SAM_IRQ_NIRQS+10) /* External interrupt 10 */
-# define SAM_IRQ_EXTINT11 (SAM_IRQ_NIRQS+11) /* External interrupt 11 */
-# define SAM_IRQ_EXTINT12 (SAM_IRQ_NIRQS+12) /* External interrupt 12 */
-# define SAM_IRQ_EXTINT13 (SAM_IRQ_NIRQS+13) /* External interrupt 13 */
-# define SAM_IRQ_EXTINT14 (SAM_IRQ_NIRQS+14) /* External interrupt 14 */
-# define SAM_IRQ_EXTINT15 (SAM_IRQ_NIRQS+15) /* External interrupt 15 */
+# define SAM_IRQ_EXTINT0 (SAM_IRQ_NIRQS+0) /* External interrupt 0 */
+# define SAM_IRQ_EXTINT1 (SAM_IRQ_NIRQS+1) /* External interrupt 1 */
+# define SAM_IRQ_EXTINT2 (SAM_IRQ_NIRQS+2) /* External interrupt 2 */
+# define SAM_IRQ_EXTINT3 (SAM_IRQ_NIRQS+3) /* External interrupt 3 */
+# define SAM_IRQ_EXTINT4 (SAM_IRQ_NIRQS+4) /* External interrupt 4 */
+# define SAM_IRQ_EXTINT5 (SAM_IRQ_NIRQS+5) /* External interrupt 5 */
+# define SAM_IRQ_EXTINT6 (SAM_IRQ_NIRQS+6) /* External interrupt 6 */
+# define SAM_IRQ_EXTINT7 (SAM_IRQ_NIRQS+7) /* External interrupt 7 */
+# define SAM_IRQ_EXTINT8 (SAM_IRQ_NIRQS+8) /* External interrupt 8 */
+# define SAM_IRQ_EXTINT9 (SAM_IRQ_NIRQS+9) /* External interrupt 9 */
+# define SAM_IRQ_EXTINT10 (SAM_IRQ_NIRQS+10) /* External interrupt 10 */
+# define SAM_IRQ_EXTINT11 (SAM_IRQ_NIRQS+11) /* External interrupt 11 */
+# define SAM_IRQ_EXTINT12 (SAM_IRQ_NIRQS+12) /* External interrupt 12 */
+# define SAM_IRQ_EXTINT13 (SAM_IRQ_NIRQS+13) /* External interrupt 13 */
+# define SAM_IRQ_EXTINT14 (SAM_IRQ_NIRQS+14) /* External interrupt 14 */
+# define SAM_IRQ_EXTINT15 (SAM_IRQ_NIRQS+15) /* External interrupt 15 */
# define SAM_IRQ_NEXTINTS 16
#else
# define SAM_IRQ_NEXTINTS 0
diff --git a/arch/arm/include/samdl/saml21_irq.h b/arch/arm/include/samdl/saml21_irq.h
index 24c774dbd0f4421e56f97c5e1eedf73d4083d51d..467708baa9de14b983eceed6f17095908d32800d 100644
--- a/arch/arm/include/samdl/saml21_irq.h
+++ b/arch/arm/include/samdl/saml21_irq.h
@@ -90,22 +90,22 @@
/* GPIO interrupts. Up to 16 pins may be configured to support interrupts */
#ifdef CONFIG_SAMDL_GPIOIRQ
-# define SAM_IRQ_EXTINT0 (SAM_IRQ_NIRQS+0) /* External interrupt 0 */
-# define SAM_IRQ_EXTINT1 (SAM_IRQ_NIRQS+1) /* External interrupt 1 */
-# define SAM_IRQ_EXTINT2 (SAM_IRQ_NIRQS+2) /* External interrupt 2 */
-# define SAM_IRQ_EXTINT3 (SAM_IRQ_NIRQS+3) /* External interrupt 3 */
-# define SAM_IRQ_EXTINT4 (SAM_IRQ_NIRQS+4) /* External interrupt 4 */
-# define SAM_IRQ_EXTINT5 (SAM_IRQ_NIRQS+5) /* External interrupt 5 */
-# define SAM_IRQ_EXTINT6 (SAM_IRQ_NIRQS+6) /* External interrupt 6 */
-# define SAM_IRQ_EXTINT7 (SAM_IRQ_NIRQS+7) /* External interrupt 7 */
-# define SAM_IRQ_EXTINT8 (SAM_IRQ_NIRQS+8) /* External interrupt 8 */
-# define SAM_IRQ_EXTINT9 (SAM_IRQ_NIRQS+9) /* External interrupt 9 */
-# define SAM_IRQ_EXTINT10 (SAM_IRQ_NIRQS+10) /* External interrupt 10 */
-# define SAM_IRQ_EXTINT11 (SAM_IRQ_NIRQS+11) /* External interrupt 11 */
-# define SAM_IRQ_EXTINT12 (SAM_IRQ_NIRQS+12) /* External interrupt 12 */
-# define SAM_IRQ_EXTINT13 (SAM_IRQ_NIRQS+13) /* External interrupt 13 */
-# define SAM_IRQ_EXTINT14 (SAM_IRQ_NIRQS+14) /* External interrupt 14 */
-# define SAM_IRQ_EXTINT15 (SAM_IRQ_NIRQS+15) /* External interrupt 15 */
+# define SAM_IRQ_EXTINT0 (SAM_IRQ_NIRQS+0) /* External interrupt 0 */
+# define SAM_IRQ_EXTINT1 (SAM_IRQ_NIRQS+1) /* External interrupt 1 */
+# define SAM_IRQ_EXTINT2 (SAM_IRQ_NIRQS+2) /* External interrupt 2 */
+# define SAM_IRQ_EXTINT3 (SAM_IRQ_NIRQS+3) /* External interrupt 3 */
+# define SAM_IRQ_EXTINT4 (SAM_IRQ_NIRQS+4) /* External interrupt 4 */
+# define SAM_IRQ_EXTINT5 (SAM_IRQ_NIRQS+5) /* External interrupt 5 */
+# define SAM_IRQ_EXTINT6 (SAM_IRQ_NIRQS+6) /* External interrupt 6 */
+# define SAM_IRQ_EXTINT7 (SAM_IRQ_NIRQS+7) /* External interrupt 7 */
+# define SAM_IRQ_EXTINT8 (SAM_IRQ_NIRQS+8) /* External interrupt 8 */
+# define SAM_IRQ_EXTINT9 (SAM_IRQ_NIRQS+9) /* External interrupt 9 */
+# define SAM_IRQ_EXTINT10 (SAM_IRQ_NIRQS+10) /* External interrupt 10 */
+# define SAM_IRQ_EXTINT11 (SAM_IRQ_NIRQS+11) /* External interrupt 11 */
+# define SAM_IRQ_EXTINT12 (SAM_IRQ_NIRQS+12) /* External interrupt 12 */
+# define SAM_IRQ_EXTINT13 (SAM_IRQ_NIRQS+13) /* External interrupt 13 */
+# define SAM_IRQ_EXTINT14 (SAM_IRQ_NIRQS+14) /* External interrupt 14 */
+# define SAM_IRQ_EXTINT15 (SAM_IRQ_NIRQS+15) /* External interrupt 15 */
# define SAM_IRQ_NEXTINTS 16
#else
# define SAM_IRQ_NEXTINTS 0
diff --git a/arch/arm/include/stm32/chip.h b/arch/arm/include/stm32/chip.h
index 0844c5a09fb5b9d888891b414b79680eafd2b15d..a9eca2813fb4a9365eb1bffc5aa6a58bbd1b23d4 100644
--- a/arch/arm/include/stm32/chip.h
+++ b/arch/arm/include/stm32/chip.h
@@ -64,12 +64,16 @@
* STM32L15XCX -- 48-pins
* STM32L15XRX -- 64-pins
* STM32L15XVX -- 100-pins
+ * STM32L15XZX -- 144-pins
*
* STM32L15XX6 -- 32KB FLASH, 10KB SRAM, 4KB EEPROM
* STM32L15XX8 -- 64KB FLASH, 10KB SRAM, 4KB EEPROM
* STM32L15XXB -- 128KB FLASH, 16KB SRAM, 4KB EEPROM
*
* STM32L15XXC -- 256KB FLASH, 32KB SRAM, 8KB EEPROM (medium+ density)
+ *
+ * STM32L16XXD -- 384KB FLASH, 48KB SRAM, 12KB EEPROM (high density)
+ * STM32L16XXE -- 512KB FLASH, 80KB SRAM, 16KB EEPROM (high density)
*/
#if defined(CONFIG_ARCH_CHIP_STM32L151C6) || defined(CONFIG_ARCH_CHIP_STM32L151C8) || \
@@ -104,7 +108,7 @@
# define STM32_NLCD 0 /* No LCD */
# define STM32_NUSBOTG 0 /* No USB OTG FS/HS (only USB 2.0 device) */
# define STM32_NGPIO 37 /* GPIOA-E,H */
-# define STM32_NADC 1 /* ADC1, 16-channels */
+# define STM32_NADC 1 /* ADC1, 14-channels */
# define STM32_NDAC 2 /* DAC 1-2, 2 channels */
/* (2) Comparators */
# define STM32_NCAPSENSE 13 /* Capacitive sensing channels */
@@ -224,10 +228,10 @@
# define STM32_NI2C 2 /* I2C1-2 */
# define STM32_NCAN 0 /* No CAN */
# define STM32_NSDIO 0 /* No SDIO */
-# define STM32_NLCD 1 /* LCD 4x16 */
+# define STM32_NLCD 1 /* LCD 4x18 */
# define STM32_NUSBOTG 0 /* No USB OTG FS/HS (only USB 2.0 device) */
# define STM32_NGPIO 37 /* GPIOA-E,H */
-# define STM32_NADC 1 /* ADC1, 16-channels */
+# define STM32_NADC 1 /* ADC1, 14-channels */
# define STM32_NDAC 2 /* DAC 1-2, 2 channels */
/* (2) Comparators */
# define STM32_NCAPSENSE 13 /* Capacitive sensing channels */
@@ -306,7 +310,7 @@
# define STM32_NI2C 2 /* I2C1-2 */
# define STM32_NCAN 0 /* No CAN */
# define STM32_NSDIO 0 /* No SDIO */
-# define STM32_NLCD 1 /* LCD 4x44, 8x40*/
+# define STM32_NLCD 1 /* LCD 4x44, 8x40 */
# define STM32_NUSBOTG 0 /* No USB OTG FS/HS (only USB 2.0 device) */
# define STM32_NGPIO 83 /* GPIOA-E,H */
# define STM32_NADC 1 /* ADC1, 24-channels */
@@ -318,9 +322,49 @@
# define STM32_NRNG 0 /* No random number generator (RNG) */
# define STM32_NDCMI 0 /* No digital camera interface (DCMI) */
+#elif defined(CONFIG_ARCH_CHIP_STM32L152CC)
+# define CONFIG_STM32_STM32L15XX 1 /* STM32L151xx and STM32L152xx family */
+# define CONFIG_STM32_ENERGYLITE 1 /* STM32L EnergyLite family */
+# undef CONFIG_STM32_STM32F10XX /* STM32F10xxx family */
+# undef CONFIG_STM32_LOWDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes
+ * and STM32L15xxx */
+# undef CONFIG_STM32_MEDIUMDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
+# define CONFIG_STM32_MEDIUMPLUSDENSITY 1 /* 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 */
+# 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 */
+# define STM32_NATIM 0 /* No advanced timers */
+# define STM32_NGTIM 3 /* 16-bit general up/down timers TIM2-4 with DMA */
+# define STM32_NGTIMNDMA 3 /* 16-bit general timers TIM9-11 without DMA */
+# define STM32_NBTIM 2 /* 2 basic timers: TIM6, TIM7 with DMA */
+# define STM32_NDMA 2 /* DMA1, 7-channels, DMA2 (5 channels) */
+# define STM32_NSPI 3 /* SPI1-3 */
+# define STM32_NI2S 2 /* I2S1-2, overlapping with SPI2-3 */
+# define STM32_NUSART 3 /* USART1-3 */
+# define STM32_NI2C 2 /* I2C1-2 */
+# define STM32_NCAN 0 /* No CAN */
+# define STM32_NSDIO 0 /* No SDIO */
+# define STM32_NLCD 1 /* LCD 4x18 */
+# define STM32_NUSBOTG 1 /* USB OTG FS/HS (only USB 2.0 device) */
+# define STM32_NGPIO 37 /* GPIOA-E,H */
+# define STM32_NADC 1 /* ADC1, 14-channels */
+# define STM32_NDAC 2 /* DAC 1-2, 2 channels */
+ /* (2) Comparators */
+# define STM32_NCAPSENSE 16 /* Capacitive sensing channels */
+# define STM32_NCRC 1 /* CRC */
+# define STM32_NETHERNET 0 /* No ethernet */
+# define STM32_NRNG 0 /* No random number generator (RNG) */
+# define STM32_NDCMI 0 /* No digital camera interface (DCMI) */
+
#elif defined(CONFIG_ARCH_CHIP_STM32L152RC)
# define CONFIG_STM32_STM32L15XX 1 /* STM32L151xx and STM32L152xx family */
-# define CONFIG_STM32_ENERGYLITE 1 /* STM32L EnergyLite vamily */
+# define CONFIG_STM32_ENERGYLITE 1 /* STM32L EnergyLite family */
# undef CONFIG_STM32_STM32F10XX /* STM32F10xxx family */
# undef CONFIG_STM32_LOWDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes
* and STM32L15xxx */
@@ -331,6 +375,8 @@
# 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 */
# define STM32_NATIM 0 /* No advanced timers */
@@ -344,13 +390,53 @@
# define STM32_NI2C 2 /* I2C1-2 */
# define STM32_NCAN 0 /* No CAN */
# define STM32_NSDIO 0 /* No SDIO */
-# define STM32_NLCD 1 /* LCD 4x44, 8x40*/
+# define STM32_NLCD 1 /* LCD 4x32, 8x28 */
+# define STM32_NUSBOTG 1 /* USB OTG FS/HS (only USB 2.0 device) */
+# define STM32_NGPIO 51 /* GPIOA-E,H */
+# define STM32_NADC 1 /* ADC1, 21-channels */
+# define STM32_NDAC 2 /* DAC 1-2, 2 channels */
+ /* (2) Comparators */
+# define STM32_NCAPSENSE 23 /* Capacitive sensing channels */
+# define STM32_NCRC 1 /* CRC */
+# define STM32_NETHERNET 0 /* No ethernet */
+# define STM32_NRNG 0 /* No random number generator (RNG) */
+# define STM32_NDCMI 0 /* No digital camera interface (DCMI) */
+
+#elif defined(CONFIG_ARCH_CHIP_STM32L152VC)
+# define CONFIG_STM32_STM32L15XX 1 /* STM32L151xx and STM32L152xx family */
+# define CONFIG_STM32_ENERGYLITE 1 /* STM32L EnergyLite family */
+# undef CONFIG_STM32_STM32F10XX /* STM32F10xxx family */
+# undef CONFIG_STM32_LOWDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes
+ * and STM32L15xxx */
+# undef CONFIG_STM32_MEDIUMDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
+# define CONFIG_STM32_MEDIUMPLUSDENSITY 1 /* 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 */
+# 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 */
+# define STM32_NATIM 0 /* No advanced timers */
+# define STM32_NGTIM 3 /* 16-bit general up/down timers TIM2-4 with DMA */
+# define STM32_NGTIMNDMA 3 /* 16-bit general timers TIM9-11 without DMA */
+# define STM32_NBTIM 2 /* 2 basic timers: TIM6, TIM7 with DMA */
+# define STM32_NDMA 2 /* DMA1, 7-channels, DMA2 (5 channels) */
+# define STM32_NSPI 3 /* SPI1-3 */
+# define STM32_NI2S 2 /* I2S1-2, overlapping with SPI2-3 */
+# define STM32_NUSART 3 /* USART1-3 */
+# define STM32_NI2C 2 /* I2C1-2 */
+# define STM32_NCAN 0 /* No CAN */
+# define STM32_NSDIO 0 /* No SDIO */
+# define STM32_NLCD 1 /* LCD 4x44, 8x40 */
# define STM32_NUSBOTG 1 /* USB OTG FS/HS (only USB 2.0 device) */
# define STM32_NGPIO 83 /* GPIOA-E,H */
-# define STM32_NADC 1 /* ADC1, 24-channels */
+# define STM32_NADC 1 /* ADC1, 25-channels */
# define STM32_NDAC 2 /* DAC 1-2, 2 channels */
/* (2) Comparators */
-# define STM32_NCAPSENSE 20 /* Capacitive sensing channels */
+# define STM32_NCAPSENSE 23 /* Capacitive sensing channels */
# define STM32_NCRC 1 /* CRC */
# define STM32_NETHERNET 0 /* No ethernet */
# define STM32_NRNG 0 /* No random number generator (RNG) */
@@ -358,17 +444,19 @@
#elif defined(CONFIG_ARCH_CHIP_STM32L162ZD)
# define CONFIG_STM32_STM32L15XX 1 /* STM32L151xx and STM32L152xx family */
-# define CONFIG_STM32_ENERGYLITE 1 /* STM32L EnergyLite vamily */
+# define CONFIG_STM32_ENERGYLITE 1 /* STM32L EnergyLite family */
# undef CONFIG_STM32_STM32F10XX /* STM32F10xxx family */
# undef CONFIG_STM32_LOWDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes
* and STM32L15xxx */
# undef CONFIG_STM32_MEDIUMDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
# undef CONFIG_STM32_MEDIUMPLUSDENSITY /* STM32L15xxC w/ 32/256 Kbytes */
-# define CONFIG_STM32_HIGHDENSITY 1 /* STM32F100x, STM32F101x, and STM32F103x w/ 256/512 Kbytes, STM32L16x w/ 48/384 Kbytes. */
+# define CONFIG_STM32_HIGHDENSITY 1 /* STM32L16xD w/ 48/384 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 */
+# 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 */
# define STM32_NATIM 0 /* No advanced timers */
@@ -383,18 +471,61 @@
# define STM32_NI2C 2 /* I2C1-2 */
# define STM32_NCAN 0 /* No CAN */
# define STM32_NSDIO 1 /* SDIO */
-# define STM32_NLCD 1 /* LCD 4x44, 8x40*/
+# define STM32_NLCD 1 /* LCD 4x44, 8x40 */
# define STM32_NUSBOTG 1 /* USB OTG FS/HS (only USB 2.0 device) */
# define STM32_NGPIO 115 /* GPIOA-G,H */
-# define STM32_NADC 1 /* ADC1, 24-channels */
+# define STM32_NADC 1 /* ADC1, 40-channels */
# define STM32_NDAC 2 /* DAC 1-2, 2 channels */
/* (2) Comparators */
-# define STM32_NCAPSENSE 20 /* Capacitive sensing channels */
+# define STM32_NCAPSENSE 34 /* Capacitive sensing channels */
+# define STM32_NCRC 1 /* CRC */
+# define STM32_NETHERNET 0 /* No ethernet */
+# define STM32_NRNG 0 /* No random number generator (RNG) */
+# define STM32_NDCMI 0 /* No digital camera interface (DCMI) */
+
+#elif defined(CONFIG_ARCH_CHIP_STM32L162VE)
+# define CONFIG_STM32_STM32L15XX 1 /* STM32L151xx and STM32L152xx family */
+# define CONFIG_STM32_ENERGYLITE 1 /* STM32L EnergyLite family */
+# undef CONFIG_STM32_STM32F10XX /* STM32F10xxx family */
+# undef CONFIG_STM32_LOWDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes
+ * and STM32L15xxx */
+# undef CONFIG_STM32_MEDIUMDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
+# undef CONFIG_STM32_MEDIUMPLUSDENSITY /* STM32L15xxC w/ 32/256 Kbytes */
+# define CONFIG_STM32_HIGHDENSITY 1 /* STM32L16xE w/ 80/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 */
+# 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 */
+# define STM32_NATIM 0 /* No advanced timers */
+# define STM32_NGTIM 4 /* 16-bit general timers TIM2-4 with DMA
+ * 32-bit general timer TIM5 with DMA */
+# define STM32_NGTIMNDMA 3 /* 16-bit general timers TIM9-11 without DMA */
+# define STM32_NBTIM 2 /* 2 basic timers: TIM6, TIM7 with DMA */
+# define STM32_NDMA 2 /* DMA1, 12-channels */
+# define STM32_NSPI 3 /* SPI1-3 */
+# define STM32_NI2S 2 /* I2S1-2, overlapping with SPI2-3 */
+# define STM32_NUSART 5 /* USART1-3, UART4-5 */
+# define STM32_NI2C 2 /* I2C1-2 */
+# define STM32_NCAN 0 /* No CAN */
+# define STM32_NSDIO 0 /* No SDIO */
+# define STM32_NLCD 1 /* LCD 4x44, 8x40*/
+# define STM32_NUSBOTG 1 /* USB OTG FS/HS (only USB 2.0 device) */
+# define STM32_NGPIO 83 /* GPIOA-G,H */
+
+# define STM32_NADC 1 /* ADC1, 25-channels */
+# define STM32_NDAC 2 /* DAC 1-2, 2 channels */
+ /* (2) Comparators */
+# define STM32_NCAPSENSE 23 /* Capacitive sensing channels */
# define STM32_NCRC 1 /* CRC */
# define STM32_NETHERNET 0 /* No ethernet */
# define STM32_NRNG 0 /* No random number generator (RNG) */
# define STM32_NDCMI 0 /* No digital camera interface (DCMI) */
+
/* STM32 F100 Value Line ************************************************************/
#elif defined(CONFIG_ARCH_CHIP_STM32F100C8) || defined(CONFIG_ARCH_CHIP_STM32F100CB) \
@@ -562,7 +693,7 @@
#elif defined(CONFIG_ARCH_CHIP_STM32F102CB)
# undef CONFIG_STM32_STM32L15XX /* STM32L151xx and STM32L152xx family */
-# undef CONFIG_STM32_ENERGYLITE /* STM32L EnergyLite vamily */
+# undef CONFIG_STM32_ENERGYLITE /* STM32L EnergyLite family */
# define CONFIG_STM32_STM32F10XX 1 /* STM32F10xx family */
# undef CONFIG_STM32_LOWDENSITY /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 16/32 Kbytes */
# define CONFIG_STM32_MEDIUMDENSITY 1 /* STM32F100x, STM32F101x, STM32F102x and STM32F103x w/ 64/128 Kbytes */
@@ -1129,7 +1260,7 @@
#elif defined(CONFIG_ARCH_CHIP_STM32F302K6) || defined(CONFIG_ARCH_CHIP_STM32F302K8)
# undef CONFIG_STM32_STM32L15XX /* STM32L151xx and STM32L152xx family */
-# undef CONFIG_STM32_ENERGYLITE /* STM32L EnergyLite vamily */
+# 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 */
@@ -1668,7 +1799,7 @@
#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 */
+# 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 */
@@ -1750,6 +1881,44 @@
# define STM32_NRNG 0 /* No Random number generator (RNG) */
# define STM32_NDCMI 0 /* No digital camera interface (DCMI) */
+#elif defined(CONFIG_ARCH_CHIP_STM32F410RB) /* LQFP64 package, 512Kb FLASH, 96KiB SRAM */
+# 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 */
+# undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */
+# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx and STM32407xx */
+# define STM32_NFSMC 0 /* No FSMC */
+# define STM32_NATIM 1 /* One advanced timers TIM1 */
+# define STM32_NGTIM 4 /* 16-bit general timers TIM3 and 4 with DMA
+ * 32-bit general timers TIM2 and 5 with DMA */
+# define STM32_NGTIMNDMA 3 /* 16-bit general timers TIM9-11 without DMA */
+# define STM32_NBTIM 0 /* No basic timers */
+# define STM32_NDMA 2 /* DMA1-2 with 8 streams each*/
+# define STM32_NSPI 3 /* SPI1-4 */
+# define STM32_NI2S 0 /* I2S1-2 (multiplexed with SPI2-3) */
+# define STM32_NUSART 3 /* Actually only 3: USART1, 2 and 6 */
+# define STM32_NI2C 3 /* I2C1-3 */
+# define STM32_NCAN 0 /* No CAN */
+# define STM32_NSDIO 0 /* One SDIO interface */
+# define STM32_NLCD 0 /* No LCD */
+# define STM32_NUSBOTG 0 /* USB OTG FS (only) */
+# define STM32_NGPIO 50 /* GPIOA-H */
+# define STM32_NADC 1 /* One 12-bit ADC1, 16 channels */
+# define STM32_NDAC 1 /* No DAC */
+# define STM32_NCAPSENSE 0 /* No capacitive sensing channels */
+# define STM32_NCRC 1 /* No CRC */
+# define STM32_NETHERNET 0 /* No Ethernet MAC */
+# define STM32_NRNG 1 /* No Random number generator (RNG) */
+# define STM32_NDCMI 0 /* No digital camera interface (DCMI) */
+
#elif defined(CONFIG_ARCH_CHIP_STM32F411RE) /* LQFP64 package, 512Kb FLASH, 128KiB SRAM */
# undef CONFIG_STM32_STM32L15XX /* STM32L151xx and STM32L152xx family */
# undef CONFIG_STM32_ENERGYLITE /* STM32L EnergyLite family */
diff --git a/arch/arm/include/stm32/ltdc.h b/arch/arm/include/stm32/ltdc.h
index 704b578a9965f4cdd9218f5caddf52bb0a8c74ff..c561c680cd6262e5c8c24ea0841c5fc3e2037072 100644
--- a/arch/arm/include/stm32/ltdc.h
+++ b/arch/arm/include/stm32/ltdc.h
@@ -410,7 +410,7 @@ struct ltdc_layer_s
* On error - -EINVAL
*
* Procedure Information:
- * If the srcxpos and srcypos unequal the the xpos and ypos of the coord
+ * If the srcxpos and srcypos unequal the xpos and ypos of the coord
* structure this acts like moving the visible area to another position on
* the screen during the next update operation.
*
diff --git a/arch/arm/include/stm32/stm32f40xxx_irq.h b/arch/arm/include/stm32/stm32f40xxx_irq.h
index 64df1a6fe5752554ceb31090e22eaed3b6f3af7d..6f4c23c018eda43060849698e41e6ea2c4b3aa6b 100644
--- a/arch/arm/include/stm32/stm32f40xxx_irq.h
+++ b/arch/arm/include/stm32/stm32f40xxx_irq.h
@@ -1,7 +1,7 @@
/****************************************************************************************************
* arch/arm/include/stm32/stm32f40xxx_irq.h
*
- * Copyright (C) 2009, 2014-2015 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2009, 2014-2015, 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2016 Omni Hoverboards Inc. All rights reserved.
* Author: Gregory Nutt
* David Sidrane
@@ -64,170 +64,280 @@
* 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 and time stamp interrupts */
-#define STM32_IRQ_TIMESTAMP (STM32_IRQ_FIRST+2) /* 2: Tamper and time stamp interrupts */
-#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 */
-#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_DMA1S0 (STM32_IRQ_FIRST+11) /* 11: DMA1 Stream 0 global interrupt */
-#define STM32_IRQ_DMA1S1 (STM32_IRQ_FIRST+12) /* 12: DMA1 Stream 1 global interrupt */
-#define STM32_IRQ_DMA1S2 (STM32_IRQ_FIRST+13) /* 13: DMA1 Stream 2 global interrupt */
-#define STM32_IRQ_DMA1S3 (STM32_IRQ_FIRST+14) /* 14: DMA1 Stream 3 global interrupt */
-#define STM32_IRQ_DMA1S4 (STM32_IRQ_FIRST+15) /* 15: DMA1 Stream 4 global interrupt */
-#define STM32_IRQ_DMA1S5 (STM32_IRQ_FIRST+16) /* 16: DMA1 Stream 5 global interrupt */
-#define STM32_IRQ_DMA1S6 (STM32_IRQ_FIRST+17) /* 17: DMA1 Stream 6 global interrupt */
-#define STM32_IRQ_ADC (STM32_IRQ_FIRST+18) /* 18: ADC1, ADC2, and ADC3 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 */
-#define STM32_IRQ_TIM9 (STM32_IRQ_FIRST+24) /* 24: TIM9 global interrupt */
-#define STM32_IRQ_TIM1UP (STM32_IRQ_FIRST+25) /* 25: TIM1 Update interrupt */
-#define STM32_IRQ_TIM10 (STM32_IRQ_FIRST+25) /* 25: TIM10 global interrupt */
-#define STM32_IRQ_TIM1TRGCOM (STM32_IRQ_FIRST+26) /* 26: TIM1 Trigger and Commutation interrupts */
-#define STM32_IRQ_TIM11 (STM32_IRQ_FIRST+26) /* 26: TIM11 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_TIM4 (STM32_IRQ_FIRST+30) /* 30: TIM4 global interrupt */
-#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_I2C2EV (STM32_IRQ_FIRST+33) /* 33: I2C2 event interrupt */
-#define STM32_IRQ_I2C2ER (STM32_IRQ_FIRST+34) /* 34: I2C2 error interrupt */
-#define STM32_IRQ_SPI1 (STM32_IRQ_FIRST+35) /* 35: SPI1 global interrupt */
-#define STM32_IRQ_SPI2 (STM32_IRQ_FIRST+36) /* 36: SPI2 global interrupt */
-#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_OTGFSWKUP (STM32_IRQ_FIRST+42) /* 42: USB On-The-Go FS Wakeup through EXTI line interrupt */
-#define STM32_IRQ_TIM8BRK (STM32_IRQ_FIRST+43) /* 43: TIM8 Break interrupt */
-#define STM32_IRQ_TIM12 (STM32_IRQ_FIRST+43) /* 43: TIM12 global interrupt */
-#define STM32_IRQ_TIM8UP (STM32_IRQ_FIRST+44) /* 44: TIM8 Update interrupt */
-#define STM32_IRQ_TIM13 (STM32_IRQ_FIRST+44) /* 44: TIM13 global interrupt */
-#define STM32_IRQ_TIM8TRGCOM (STM32_IRQ_FIRST+45) /* 45: TIM8 Trigger and Commutation interrupts */
-#define STM32_IRQ_TIM14 (STM32_IRQ_FIRST+45) /* 45: TIM14 global interrupt */
-#define STM32_IRQ_TIM8CC (STM32_IRQ_FIRST+46) /* 46: TIM8 Capture Compare interrupt */
-#define STM32_IRQ_DMA1S7 (STM32_IRQ_FIRST+47) /* 47: DMA1 Stream 7 global interrupt */
-#define STM32_IRQ_FSMC (STM32_IRQ_FIRST+48) /* 48: FSMC global interrupt */
-#define STM32_IRQ_SDIO (STM32_IRQ_FIRST+49) /* 49: SDIO global interrupt */
-#define STM32_IRQ_TIM5 (STM32_IRQ_FIRST+50) /* 50: TIM5 global interrupt */
-#define STM32_IRQ_SPI3 (STM32_IRQ_FIRST+51) /* 51: SPI3 global interrupt */
-#define STM32_IRQ_UART4 (STM32_IRQ_FIRST+52) /* 52: UART4 global interrupt */
-#define STM32_IRQ_UART5 (STM32_IRQ_FIRST+53) /* 53: UART5 global interrupt */
-#define STM32_IRQ_TIM6 (STM32_IRQ_FIRST+54) /* 54: TIM6 global interrupt */
-#define STM32_IRQ_DAC (STM32_IRQ_FIRST+54) /* 54: DAC1 and DAC2 underrun error interrupts */
-#define STM32_IRQ_TIM7 (STM32_IRQ_FIRST+55) /* 55: TIM7 global interrupt */
-#define STM32_IRQ_DMA2S0 (STM32_IRQ_FIRST+56) /* 56: DMA2 Stream 0 global interrupt */
-#define STM32_IRQ_DMA2S1 (STM32_IRQ_FIRST+57) /* 57: DMA2 Stream 1 global interrupt */
-#define STM32_IRQ_DMA2S2 (STM32_IRQ_FIRST+58) /* 58: DMA2 Stream 2 global interrupt */
-#define STM32_IRQ_DMA2S3 (STM32_IRQ_FIRST+59) /* 59: DMA2 Stream 3 global interrupt */
-#define STM32_IRQ_DMA2S4 (STM32_IRQ_FIRST+60) /* 60: DMA2 Stream 4 global interrupt */
+#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 and time stamp interrupts */
+#define STM32_IRQ_TIMESTAMP (STM32_IRQ_FIRST+2) /* 2: Tamper and time stamp interrupts */
+#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 */
+#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_DMA1S0 (STM32_IRQ_FIRST+11) /* 11: DMA1 Stream 0 global interrupt */
+#define STM32_IRQ_DMA1S1 (STM32_IRQ_FIRST+12) /* 12: DMA1 Stream 1 global interrupt */
+#define STM32_IRQ_DMA1S2 (STM32_IRQ_FIRST+13) /* 13: DMA1 Stream 2 global interrupt */
+#define STM32_IRQ_DMA1S3 (STM32_IRQ_FIRST+14) /* 14: DMA1 Stream 3 global interrupt */
+#define STM32_IRQ_DMA1S4 (STM32_IRQ_FIRST+15) /* 15: DMA1 Stream 4 global interrupt */
+#define STM32_IRQ_DMA1S5 (STM32_IRQ_FIRST+16) /* 16: DMA1 Stream 5 global interrupt */
+#define STM32_IRQ_DMA1S6 (STM32_IRQ_FIRST+17) /* 17: DMA1 Stream 6 global interrupt */
+#define STM32_IRQ_ADC (STM32_IRQ_FIRST+18) /* 18: ADC1, ADC2, and ADC3 global interrupt */
+
+#if defined(CONFIG_STM32_STM32F410)
+# define STM32_IRQ_RESERVED19 (STM32_IRQ_FIRST+19) /* 19: Reserved */
+# define STM32_IRQ_RESERVED20 (STM32_IRQ_FIRST+20) /* 20: Reserved */
+# define STM32_IRQ_RESERVED21 (STM32_IRQ_FIRST+21) /* 21: Reserved */
+# define STM32_IRQ_RESERVED22 (STM32_IRQ_FIRST+22) /* 22: Reserved */
+#else
+# 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 */
+#endif
+
+#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 */
+#define STM32_IRQ_TIM9 (STM32_IRQ_FIRST+24) /* 24: TIM9 global interrupt */
+#define STM32_IRQ_TIM1UP (STM32_IRQ_FIRST+25) /* 25: TIM1 Update interrupt */
+#define STM32_IRQ_TIM10 (STM32_IRQ_FIRST+25) /* 25: TIM10 global interrupt */
+#define STM32_IRQ_TIM1TRGCOM (STM32_IRQ_FIRST+26) /* 26: TIM1 Trigger and Commutation interrupts */
+#define STM32_IRQ_TIM11 (STM32_IRQ_FIRST+26) /* 26: TIM11 global interrupt */
+#define STM32_IRQ_TIM1CC (STM32_IRQ_FIRST+27) /* 27: TIM1 Capture Compare interrupt */
+
+#if defined(CONFIG_STM32_STM32F410)
+# define STM32_IRQ_RESERVED28 (STM32_IRQ_FIRST+28) /* 28: Reserved */
+# define STM32_IRQ_RESERVED29 (STM32_IRQ_FIRST+29) /* 29: Reserved */
+# define STM32_IRQ_RESERVED30 (STM32_IRQ_FIRST+30) /* 30: Reserved */
+#else
+# 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_TIM4 (STM32_IRQ_FIRST+30) /* 30: TIM4 global interrupt */
+#endif
+
+#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_I2C2EV (STM32_IRQ_FIRST+33) /* 33: I2C2 event interrupt */
+#define STM32_IRQ_I2C2ER (STM32_IRQ_FIRST+34) /* 34: I2C2 error interrupt */
+#define STM32_IRQ_SPI1 (STM32_IRQ_FIRST+35) /* 35: SPI1 global interrupt */
+#define STM32_IRQ_SPI2 (STM32_IRQ_FIRST+36) /* 36: SPI2 global interrupt */
+#define STM32_IRQ_USART1 (STM32_IRQ_FIRST+37) /* 37: USART1 global interrupt */
+#define STM32_IRQ_USART2 (STM32_IRQ_FIRST+38) /* 38: USART2 global interrupt */
+
+#if defined(CONFIG_STM32_STM32F410)
+# define STM32_IRQ_RESERVED39 (STM32_IRQ_FIRST+39) /* 39: Reserved */
+#else
+# define STM32_IRQ_USART3 (STM32_IRQ_FIRST+39) /* 39: USART3 global interrupt */
+#endif
+
+#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 */
+
+#if defined(CONFIG_STM32_STM32F410)
+# 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 */
+#else
+# define STM32_IRQ_OTGFSWKUP (STM32_IRQ_FIRST+42) /* 42: USB On-The-Go FS Wakeup through EXTI line interrupt */
+# define STM32_IRQ_TIM8BRK (STM32_IRQ_FIRST+43) /* 43: TIM8 Break interrupt */
+# define STM32_IRQ_TIM12 (STM32_IRQ_FIRST+43) /* 43: TIM12 global interrupt */
+# define STM32_IRQ_TIM8UP (STM32_IRQ_FIRST+44) /* 44: TIM8 Update interrupt */
+# define STM32_IRQ_TIM13 (STM32_IRQ_FIRST+44) /* 44: TIM13 global interrupt */
+# define STM32_IRQ_TIM8TRGCOM (STM32_IRQ_FIRST+45) /* 45: TIM8 Trigger and Commutation interrupts */
+# define STM32_IRQ_TIM14 (STM32_IRQ_FIRST+45) /* 45: TIM14 global interrupt */
+# define STM32_IRQ_TIM8CC (STM32_IRQ_FIRST+46) /* 46: TIM8 Capture Compare interrupt */
+#endif
+
+#define STM32_IRQ_DMA1S7 (STM32_IRQ_FIRST+47) /* 47: DMA1 Stream 7 global interrupt */
+
+#if defined(CONFIG_STM32_STM32F410)
+# define STM32_IRQ_RESERVED48 (STM32_IRQ_FIRST+48) /* 48: Reserved */
+# define STM32_IRQ_RESERVED49 (STM32_IRQ_FIRST+49) /* 48: Reserved */
+#else
+# define STM32_IRQ_FSMC (STM32_IRQ_FIRST+48) /* 48: FSMC global interrupt */
+# define STM32_IRQ_SDIO (STM32_IRQ_FIRST+49) /* 49: SDIO global interrupt */
+#endif
+
+#define STM32_IRQ_TIM5 (STM32_IRQ_FIRST+50) /* 50: TIM5 global interrupt */
+
+#if defined(CONFIG_STM32_STM32F410)
+# 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 */
+#else
+# define STM32_IRQ_SPI3 (STM32_IRQ_FIRST+51) /* 51: SPI3 global interrupt */
+# define STM32_IRQ_UART4 (STM32_IRQ_FIRST+52) /* 52: UART4 global interrupt */
+# define STM32_IRQ_UART5 (STM32_IRQ_FIRST+53) /* 53: UART5 global interrupt */
+#endif
+
+#define STM32_IRQ_TIM6 (STM32_IRQ_FIRST+54) /* 54: TIM6 global interrupt */
+#define STM32_IRQ_DAC (STM32_IRQ_FIRST+54) /* 54: DAC1 and DAC2 underrun error interrupts */
+
+#if defined(CONFIG_STM32_STM32F410)
+# define STM32_IRQ_RESERVED55 (STM32_IRQ_FIRST+55) /* 55: Reserved */
+#else
+# define STM32_IRQ_TIM7 (STM32_IRQ_FIRST+55) /* 55: TIM7 global interrupt */
+#endif
+
+#define STM32_IRQ_DMA2S0 (STM32_IRQ_FIRST+56) /* 56: DMA2 Stream 0 global interrupt */
+#define STM32_IRQ_DMA2S1 (STM32_IRQ_FIRST+57) /* 57: DMA2 Stream 1 global interrupt */
+#define STM32_IRQ_DMA2S2 (STM32_IRQ_FIRST+58) /* 58: DMA2 Stream 2 global interrupt */
+#define STM32_IRQ_DMA2S3 (STM32_IRQ_FIRST+59) /* 59: DMA2 Stream 3 global interrupt */
+#define STM32_IRQ_DMA2S4 (STM32_IRQ_FIRST+60) /* 60: DMA2 Stream 4 global interrupt */
+
#if defined(CONFIG_STM32_STM32F446)
-# define STM32_IRQ_RESERVED61 (STM32_IRQ_FIRST+61) /* 61: Reserved */
-# define STM32_IRQ_RESERVED62 (STM32_IRQ_FIRST+62) /* 62: Reserved */
+# define STM32_IRQ_RESERVED61 (STM32_IRQ_FIRST+61) /* 61: Reserved */
+# define STM32_IRQ_RESERVED62 (STM32_IRQ_FIRST+62) /* 62: Reserved */
#else
-# define STM32_IRQ_ETH (STM32_IRQ_FIRST+61) /* 61: Ethernet global interrupt */
-# define STM32_IRQ_ETHWKUP (STM32_IRQ_FIRST+62) /* 62: Ethernet Wakeup through EXTI line interrupt */
+# define STM32_IRQ_ETH (STM32_IRQ_FIRST+61) /* 61: Ethernet global interrupt */
+# define STM32_IRQ_ETHWKUP (STM32_IRQ_FIRST+62) /* 62: Ethernet Wakeup through EXTI line interrupt */
#endif
-#define STM32_IRQ_CAN2TX (STM32_IRQ_FIRST+63) /* 63: CAN2 TX interrupts */
-#define STM32_IRQ_CAN2RX0 (STM32_IRQ_FIRST+64) /* 64: CAN2 RX0 interrupts */
-#define STM32_IRQ_CAN2RX1 (STM32_IRQ_FIRST+65) /* 65: CAN2 RX1 interrupt */
-#define STM32_IRQ_CAN2SCE (STM32_IRQ_FIRST+66) /* 66: CAN2 SCE interrupt */
-#define STM32_IRQ_OTGFS (STM32_IRQ_FIRST+67) /* 67: USB On The Go FS global interrupt */
-#define STM32_IRQ_DMA2S5 (STM32_IRQ_FIRST+68) /* 68: DMA2 Stream 5 global interrupt */
-#define STM32_IRQ_DMA2S6 (STM32_IRQ_FIRST+69) /* 69: DMA2 Stream 6 global interrupt */
-#define STM32_IRQ_DMA2S7 (STM32_IRQ_FIRST+70) /* 70: DMA2 Stream 7 global interrupt */
-#define STM32_IRQ_USART6 (STM32_IRQ_FIRST+71) /* 71: USART6 global interrupt */
-#define STM32_IRQ_I2C3EV (STM32_IRQ_FIRST+72) /* 72: I2C3 event interrupt */
-#define STM32_IRQ_I2C3ER (STM32_IRQ_FIRST+73) /* 73: I2C3 error interrupt */
-#define STM32_IRQ_OTGHSEP1OUT (STM32_IRQ_FIRST+74) /* 74: USB On The Go HS End Point 1 Out global interrupt */
-#define STM32_IRQ_OTGHSEP1IN (STM32_IRQ_FIRST+75) /* 75: USB On The Go HS End Point 1 In global interrupt */
-#define STM32_IRQ_OTGHSWKUP (STM32_IRQ_FIRST+76) /* 76: USB On The Go HS Wakeup through EXTI interrupt */
-#define STM32_IRQ_OTGHS (STM32_IRQ_FIRST+77) /* 77: USB On The Go HS global interrupt */
-#define STM32_IRQ_DCMI (STM32_IRQ_FIRST+78) /* 78: DCMI global interrupt */
+
+#if defined(CONFIG_STM32_STM32F410)
+# define STM32_IRQ_RESERVED63 (STM32_IRQ_FIRST+63) /* 63: Reserved */
+# define STM32_IRQ_RESERVED64 (STM32_IRQ_FIRST+64) /* 63: Reserved */
+# define STM32_IRQ_RESERVED65 (STM32_IRQ_FIRST+65) /* 63: Reserved */
+# define STM32_IRQ_RESERVED66 (STM32_IRQ_FIRST+66) /* 63: Reserved */
+# define STM32_IRQ_RESERVED67 (STM32_IRQ_FIRST+67) /* 63: Reserved */
+#else
+# define STM32_IRQ_CAN2TX (STM32_IRQ_FIRST+63) /* 63: CAN2 TX interrupts */
+# define STM32_IRQ_CAN2RX0 (STM32_IRQ_FIRST+64) /* 64: CAN2 RX0 interrupts */
+# define STM32_IRQ_CAN2RX1 (STM32_IRQ_FIRST+65) /* 65: CAN2 RX1 interrupt */
+# define STM32_IRQ_CAN2SCE (STM32_IRQ_FIRST+66) /* 66: CAN2 SCE interrupt */
+# define STM32_IRQ_OTGFS (STM32_IRQ_FIRST+67) /* 67: USB On The Go FS global interrupt */
+#endif
+
+#define STM32_IRQ_DMA2S5 (STM32_IRQ_FIRST+68) /* 68: DMA2 Stream 5 global interrupt */
+#define STM32_IRQ_DMA2S6 (STM32_IRQ_FIRST+69) /* 69: DMA2 Stream 6 global interrupt */
+#define STM32_IRQ_DMA2S7 (STM32_IRQ_FIRST+70) /* 70: DMA2 Stream 7 global interrupt */
+#define STM32_IRQ_USART6 (STM32_IRQ_FIRST+71) /* 71: USART6 global interrupt */
+
+#if defined(CONFIG_STM32_STM32F410)
+# define STM32_IRQ_RESERVED72 (STM32_IRQ_FIRST+72) /* 72: Reserved */
+# define STM32_IRQ_RESERVED73 (STM32_IRQ_FIRST+73) /* 73: Reserved */
+# 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 */
+#else
+# define STM32_IRQ_I2C3EV (STM32_IRQ_FIRST+72) /* 72: I2C3 event interrupt */
+# define STM32_IRQ_I2C3ER (STM32_IRQ_FIRST+73) /* 73: I2C3 error interrupt */
+# define STM32_IRQ_OTGHSEP1OUT (STM32_IRQ_FIRST+74) /* 74: USB On The Go HS End Point 1 Out global interrupt */
+# define STM32_IRQ_OTGHSEP1IN (STM32_IRQ_FIRST+75) /* 75: USB On The Go HS End Point 1 In global interrupt */
+# define STM32_IRQ_OTGHSWKUP (STM32_IRQ_FIRST+76) /* 76: USB On The Go HS Wakeup through EXTI interrupt */
+# define STM32_IRQ_OTGHS (STM32_IRQ_FIRST+77) /* 77: USB On The Go HS global interrupt */
+# define STM32_IRQ_DCMI (STM32_IRQ_FIRST+78) /* 78: DCMI global interrupt */
+#endif
+
#if defined(CONFIG_STM32_STM32F446)
-# define STM32_IRQ_RESERVED79 (STM32_IRQ_FIRST+79) /* 79: Reserved */
-# define STM32_IRQ_RESERVED80 (STM32_IRQ_FIRST+80) /* 80: Reserved */
+# define STM32_IRQ_RESERVED79 (STM32_IRQ_FIRST+79) /* 79: Reserved */
+# define STM32_IRQ_RESERVED80 (STM32_IRQ_FIRST+80) /* 80: Reserved */
#else
-# define STM32_IRQ_CRYP (STM32_IRQ_FIRST+79) /* 79: CRYP crypto global interrupt */
-# define STM32_IRQ_HASH (STM32_IRQ_FIRST+80) /* 80: Hash and Rng global interrupt */
-# define STM32_IRQ_RNG (STM32_IRQ_FIRST+80) /* 80: Hash and Rng global interrupt */
+# if defined(CONFIG_STM32_STM32F410)
+# define STM32_IRQ_RESERVED79 (STM32_IRQ_FIRST+79) /* 79: Reserved */
+# else
+# define STM32_IRQ_CRYP (STM32_IRQ_FIRST+79) /* 79: CRYP crypto global interrupt */
+# endif
+# define STM32_IRQ_HASH (STM32_IRQ_FIRST+80) /* 80: Hash and Rng global interrupt */
+# define STM32_IRQ_RNG (STM32_IRQ_FIRST+80) /* 80: Hash and Rng global interrupt */
#endif
-#define STM32_IRQ_FPU (STM32_IRQ_FIRST+81) /* 81: FPU global interrupt */
+
+#define STM32_IRQ_FPU (STM32_IRQ_FIRST+81) /* 81: FPU global interrupt */
+
#if defined(CONFIG_STM32_STM32F427) || defined(CONFIG_STM32_STM32F429) || \
defined(CONFIG_STM32_STM32F469)
-# define STM32_IRQ_UART7 (STM32_IRQ_FIRST+82) /* 82: UART7 interrupt */
-# define STM32_IRQ_UART8 (STM32_IRQ_FIRST+83) /* 83: UART8 interrupt */
-#elif defined(CONFIG_STM32_STM32F446)
-# define STM32_IRQ_RESERVED82 (STM32_IRQ_FIRST+82) /* 82: Reserved */
-# define STM32_IRQ_RESERVED83 (STM32_IRQ_FIRST+83) /* 83: Reserved */
+# define STM32_IRQ_UART7 (STM32_IRQ_FIRST+82) /* 82: UART7 interrupt */
+# define STM32_IRQ_UART8 (STM32_IRQ_FIRST+83) /* 83: UART8 interrupt */
+#elif defined(CONFIG_STM32_STM32F446) || defined(CONFIG_STM32_STM32F410)
+# define STM32_IRQ_RESERVED82 (STM32_IRQ_FIRST+82) /* 82: Reserved */
+# define STM32_IRQ_RESERVED83 (STM32_IRQ_FIRST+83) /* 83: Reserved */
#endif
-#if defined(CONFIG_STM32_STM32F427) || defined(CONFIG_STM32_STM32F429) || \
+
+#if defined(CONFIG_STM32_STM32F410)
+# define STM32_IRQ_RESERVED84 (STM32_IRQ_FIRST+84) /* 84: Reserved */
+#elif defined(CONFIG_STM32_STM32F427) || defined(CONFIG_STM32_STM32F429) || \
defined(CONFIG_STM32_STM32F446) || defined(CONFIG_STM32_STM32F469)
-# define STM32_IRQ_SPI4 (STM32_IRQ_FIRST+84) /* 84: SPI4 interrupt */
+# define STM32_IRQ_SPI4 (STM32_IRQ_FIRST+84) /* 84: SPI4 interrupt */
#endif
-#if defined(CONFIG_STM32_STM32F427) || defined(CONFIG_STM32_STM32F429) || \
+
+#if defined(CONFIG_STM32_STM32F410)
+# define STM32_IRQ_SPI5 (STM32_IRQ_FIRST+85) /* 85: SPI5 interrupt */
+# define STM32_IRQ_RESERVED86 (STM32_IRQ_FIRST+86) /* 86: Reserved */
+#elif defined(CONFIG_STM32_STM32F427) || defined(CONFIG_STM32_STM32F429) || \
defined(CONFIG_STM32_STM32F469)
-# define STM32_IRQ_SPI5 (STM32_IRQ_FIRST+85) /* 85: SPI5 interrupt */
-# define STM32_IRQ_SPI6 (STM32_IRQ_FIRST+86) /* 86: SPI6 interrupt */
+# define STM32_IRQ_SPI5 (STM32_IRQ_FIRST+85) /* 85: SPI5 interrupt */
+# define STM32_IRQ_SPI6 (STM32_IRQ_FIRST+86) /* 86: SPI6 interrupt */
#elif defined(CONFIG_STM32_STM32F446)
-# define STM32_IRQ_RESERVED85 (STM32_IRQ_FIRST+85) /* 85: Reserved */
-# define STM32_IRQ_RESERVED86 (STM32_IRQ_FIRST+86) /* 86: Reserved */
+# define STM32_IRQ_RESERVED85 (STM32_IRQ_FIRST+85) /* 85: Reserved */
+# define STM32_IRQ_RESERVED86 (STM32_IRQ_FIRST+86) /* 86: Reserved */
#endif
-#if defined(CONFIG_STM32_STM32F429) || defined(CONFIG_STM32_STM32F446) || \
+
+#if defined(CONFIG_STM32_STM32F410)
+# define STM32_IRQ_RESERVED87 (STM32_IRQ_FIRST+87) /* 87: Reserved */
+#elif defined(CONFIG_STM32_STM32F429) || defined(CONFIG_STM32_STM32F446) || \
defined(CONFIG_STM32_STM32F446) || defined(CONFIG_STM32_STM32F469)
-# define STM32_IRQ_SAI1 (STM32_IRQ_FIRST+87) /* 87: SAI1 interrupt */
+# define STM32_IRQ_SAI1 (STM32_IRQ_FIRST+87) /* 87: SAI1 interrupt */
#endif
+
#if defined(CONFIG_STM32_STM32F429) || defined(CONFIG_STM32_STM32F469)
-# define STM32_IRQ_LTDCINT (STM32_IRQ_FIRST+88) /* 88: LTDCINT interrupt */
-# define STM32_IRQ_LTDCERRINT (STM32_IRQ_FIRST+89) /* 89: LTDCERRINT interrupt */
-# define STM32_IRQ_DMA2D (STM32_IRQ_FIRST+90) /* 90: DMA2D interrupt */
-#elif defined(CONFIG_STM32_STM32F446)
-# define STM32_IRQ_RESERVED88 (STM32_IRQ_FIRST+88) /* 88: Reserved */
-# define STM32_IRQ_RESERVED89 (STM32_IRQ_FIRST+89) /* 89: Reserved */
-# define STM32_IRQ_RESERVED90 (STM32_IRQ_FIRST+90) /* 90: Reserved */
+# define STM32_IRQ_LTDCINT (STM32_IRQ_FIRST+88) /* 88: LTDCINT interrupt */
+# define STM32_IRQ_LTDCERRINT (STM32_IRQ_FIRST+89) /* 89: LTDCERRINT interrupt */
+# define STM32_IRQ_DMA2D (STM32_IRQ_FIRST+90) /* 90: DMA2D interrupt */
+#elif defined(CONFIG_STM32_STM32F446) || defined(CONFIG_STM32_STM32F410)
+# define STM32_IRQ_RESERVED88 (STM32_IRQ_FIRST+88) /* 88: Reserved */
+# define STM32_IRQ_RESERVED89 (STM32_IRQ_FIRST+89) /* 89: Reserved */
+# define STM32_IRQ_RESERVED90 (STM32_IRQ_FIRST+90) /* 90: Reserved */
#endif
-#if defined(CONFIG_STM32_STM32F446)
-# define STM32_IRQ_SAI2 (STM32_IRQ_FIRST+91) /* 91: SAI2 Global interrupt */
-# define STM32_IRQ_QUADSPI (STM32_IRQ_FIRST+92) /* 92: QuadSPI Global interrupt */
+
+#if defined(CONFIG_STM32_STM32F410)
+# define STM32_IRQ_RESERVED91 (STM32_IRQ_FIRST+91) /* 91: Reserved */
+# define STM32_IRQ_RESERVED92 (STM32_IRQ_FIRST+92) /* 92: Reserved */
+#elif defined(CONFIG_STM32_STM32F446)
+# define STM32_IRQ_SAI2 (STM32_IRQ_FIRST+91) /* 91: SAI2 Global interrupt */
+# define STM32_IRQ_QUADSPI (STM32_IRQ_FIRST+92) /* 92: QuadSPI Global interrupt */
#elif defined(CONFIG_STM32_STM32F469)
-# define STM32_IRQ_QUADSPI (STM32_IRQ_FIRST+91) /* 92: QuadSPI Global interrupt */
-# define STM32_IRQ_DSI (STM32_IRQ_FIRST+92) /* 91: DSI Global interrupt */
+# define STM32_IRQ_QUADSPI (STM32_IRQ_FIRST+91) /* 92: QuadSPI Global interrupt */
+# define STM32_IRQ_DSI (STM32_IRQ_FIRST+92) /* 91: DSI Global interrupt */
#endif
+
#if defined(CONFIG_STM32_STM32F446)
-# define STM32_IRQ_HDMICEC (STM32_IRQ_FIRST+93) /* 93: HDMI-CEC Global interrupt */
-# define STM32_IRQ_SPDIFRX (STM32_IRQ_FIRST+94) /* 94: SPDIF-Rx Global interrupt */
-# define STM32_IRQ_FMPI2C1 (STM32_IRQ_FIRST+95) /* 95: FMPI2C1 event interrupt */
-# define STM32_IRQ_FMPI2C1ERR (STM32_IRQ_FIRST+96) /* 96: FMPI2C1 Error event interrupt */
+# define STM32_IRQ_HDMICEC (STM32_IRQ_FIRST+93) /* 93: HDMI-CEC Global interrupt */
+# define STM32_IRQ_SPDIFRX (STM32_IRQ_FIRST+94) /* 94: SPDIF-Rx Global interrupt */
+# define STM32_IRQ_FMPI2C1 (STM32_IRQ_FIRST+95) /* 95: FMPI2C1 event interrupt */
+# define STM32_IRQ_FMPI2C1ERR (STM32_IRQ_FIRST+96) /* 96: FMPI2C1 Error event interrupt */
+#endif
+
+#if defined(CONFIG_STM32_STM32F410)
+# define STM32_IRQ_RESERVED93 (STM32_IRQ_FIRST+93) /* 93: Reserved */
+# define STM32_IRQ_RESERVED94 (STM32_IRQ_FIRST+94) /* 94: Reserved */
+# define STM32_IRQ_RESERVED95 (STM32_IRQ_FIRST+95) /* 95: Reserved */
+# define STM32_IRQ_RESERVED96 (STM32_IRQ_FIRST+96) /* 96: Reserved */
+# define STM32_IRQ_RESERVED97 (STM32_IRQ_FIRST+97) /* 97: Reserved */
#endif
#if defined(CONFIG_STM32_STM32F401) || defined(CONFIG_STM32_STM32F411) || \
defined(CONFIG_STM32_STM32F405) || defined(CONFIG_STM32_STM32F407)
-# define NR_VECTORS (STM32_IRQ_FIRST+82)
-# define NR_IRQS (STM32_IRQ_FIRST+82)
+# define NR_VECTORS (STM32_IRQ_FIRST+82)
+# define NR_IRQS (STM32_IRQ_FIRST+82)
+#elif defined(CONFIG_STM32_STM32F410)
+# define NR_VECTORS (STM32_IRQ_FIRST+98)
+# define NR_IRQS (STM32_IRQ_FIRST+98)
#elif defined(CONFIG_STM32_STM32F427)
-# define NR_VECTORS (STM32_IRQ_FIRST+87)
-# define NR_IRQS (STM32_IRQ_FIRST+87)
+# define NR_VECTORS (STM32_IRQ_FIRST+87)
+# define NR_IRQS (STM32_IRQ_FIRST+87)
#elif defined(CONFIG_STM32_STM32F429)
-# define NR_VECTORS (STM32_IRQ_FIRST+91)
-# define NR_IRQS (STM32_IRQ_FIRST+91)
+# define NR_VECTORS (STM32_IRQ_FIRST+91)
+# define NR_IRQS (STM32_IRQ_FIRST+91)
#elif defined(CONFIG_STM32_STM32F446)
-# define NR_VECTORS (STM32_IRQ_FIRST+97)
-# define NR_IRQS (STM32_IRQ_FIRST+97)
+# define NR_VECTORS (STM32_IRQ_FIRST+97)
+# define NR_IRQS (STM32_IRQ_FIRST+97)
#elif defined(CONFIG_STM32_STM32F469)
-# define NR_VECTORS (STM32_IRQ_FIRST+93)
-# define NR_IRQS (STM32_IRQ_FIRST+93)
+# define NR_VECTORS (STM32_IRQ_FIRST+93)
+# define NR_IRQS (STM32_IRQ_FIRST+93)
#endif
/****************************************************************************************************
diff --git a/arch/arm/include/stm32f0/chip.h b/arch/arm/include/stm32f0/chip.h
new file mode 100644
index 0000000000000000000000000000000000000000..196a15e22112abf6092f4f91142cfa7f9f143579
--- /dev/null
+++ b/arch/arm/include/stm32f0/chip.h
@@ -0,0 +1,313 @@
+/************************************************************************************
+ * arch/arm/include/stm32f0/chip.h
+ *
+ * Copyright (C) 2017 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ * Alan Carvalho de Assis
+ *
+ * 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_STM32F0_CHIP_H
+#define __ARCH_ARM_INCLUDE_STM32F0_CHIP_H
+
+/************************************************************************************
+ * Included Files
+ ************************************************************************************/
+
+#include
+
+/************************************************************************************
+ * Pre-processor Definitions
+ ************************************************************************************/
+
+/* Get customizations for each supported chip */
+
+#if defined(CONFIG_ARCH_CHIP_STM32F051R8)
+# define STM32F051x 1 /* STM32F051x family */
+# undef STM32F072x /* Not STM32F072x family */
+# undef STM32F091x /* Not STM32F091x family */
+
+# define STM32F0_FLASH_SIZE (64*1024) /* 64Kb */
+# define STM32F0_SRAM_SIZE (8*1024) /* 8Kb */
+
+# define STM32F0_NSPI 2 /* Two SPI modules (SPI or I2S) */
+# define STM32F0_NI2S 2 /* Two I2S modules (SPI or I2S) */
+# define STM32F0_NI2C 2 /* Two I2C modules */
+# define STM32F0_NUSART 2 /* Two USARTs modules */
+# define STM32F0_NCAN 0 /* No CAN controllers */
+# define STM32F0_NUSBDEV 1 /* One USB device controller */
+# define STM32F0_NDAC 1 /* One DAC module */
+# define STM32F0_NDACCHAN 1 /* One DAC channels */
+# define STM32F0_NCOMP 2 /* Two Analog Comparators */
+# define STM32F0_NCAP 13 /* Capacitive sensing channels (14 on UFQFPN32)) */
+# define STM32F0_NPORTS 6 /* Six GPIO ports, GPIOA-F */
+
+#elif defined(CONFIG_ARCH_CHIP_STM32F072C8) || defined(CONFIG_ARCH_CHIP_STM32F072CB)
+# undef STM32F051x /* Not STM32F051x family */
+# define STM32F072x 1 /* STM32F072x family */
+# undef STM32F091x /* Not STM32F091x family */
+
+# ifdef CONFIG_ARCH_CHIP_STM32F072C8
+# define STM32F0_FLASH_SIZE (64*1024) /* 64Kb */
+# else
+# define STM32F0_FLASH_SIZE (128*1024) /* 128Kb */
+# endif
+# define STM32F0_SRAM_SIZE (16*1024) /* 16Kb */
+
+# define STM32F0_NATIM 1 /* One advanced timer TIM1 */
+# define STM32F0_NGTIM16 5 /* 16-bit general up/down timers TIM3, TIM14-17 */
+# define STM32F0_NGTIM32 1 /* 32-bit general up/down timers TIM2 */
+# define STM32F0_NBTIM 2 /* 2 basic timers: TIM6, TIM7 */
+# define STM32F0_NSPI 2 /* Two SPI modules (SPI or I2S) */
+# define STM32F0_NI2S 2 /* Two I2S modules (SPI or I2S) */
+# define STM32F0_NI2C 2 /* Two I2C modules */
+# define STM32F0_NUSART 4 /* Four USARTs module */
+# define STM32F0_NCAN 1 /* One CAN controller */
+# define STM32F0_NUSBDEV 1 /* One USB device controller */
+# define STM32F0_NCEC 1 /* One HDMI-CEC controller */
+# define STM32F0_NADC12 1 /* One 12-bit module */
+# define STM32F0_NADCCHAN 10 /* Ten external channels */
+# define STM32F0_NADCINT 3 /* Three internal channels */
+# define STM32F0_NDAC 1 /* One DAC module */
+# define STM32F0_NDACCHAN 2 /* Two DAC channels */
+# define STM32F0_NCOMP 2 /* Two Analog Comparators */
+# define STM32F0_NCAP 17 /* Capacitive sensing channels */
+# define STM32F0_NPORTS 6 /* Six GPIO ports, GPIOA-F */
+
+#elif defined(CONFIG_ARCH_CHIP_STM32F072R8) || defined(CONFIG_ARCH_CHIP_STM32F072RB)
+# undef STM32F051x /* Not STM32F051x family */
+# define STM32F072x 1 /* STM32F072x family */
+# undef STM32F091x /* Not STM32F091x family */
+
+# ifdef CONFIG_ARCH_CHIP_STM32F072R8
+# define STM32F0_FLASH_SIZE (64*1024) /* 64Kb */
+# else
+# define STM32F0_FLASH_SIZE (128*1024) /* 128Kb */
+# endif
+# define STM32F0_SRAM_SIZE (16*1024) /* 16Kb */
+
+# define STM32F0_NATIM 1 /* One advanced timer TIM1 */
+# define STM32F0_NGTIM16 5 /* 16-bit general up/down timers TIM3, TIM14-17 */
+# define STM32F0_NGTIM32 1 /* 32-bit general up/down timers TIM2 */
+# define STM32F0_NBTIM 2 /* 2 basic timers: TIM6, TIM7 */
+# define STM32F0_NSPI 2 /* Two SPI modules (SPI or I2S) */
+# define STM32F0_NI2S 2 /* Two I2S modules (SPI or I2S) */
+# define STM32F0_NI2C 2 /* Two I2C modules */
+# define STM32F0_NUSART 4 /* Four USARTs module */
+# define STM32F0_NCAN 1 /* One CAN controller */
+# define STM32F0_NUSBDEV 1 /* One USB device controller */
+# define STM32F0_NCEC 1 /* One HDMI-CEC controller */
+# define STM32F0_NADC12 1 /* One 12-bit module */
+# define STM32F0_NADCCHAN 16 /* 16 external channels */
+# define STM32F0_NADCINT 3 /* Three internal channels */
+# define STM32F0_NDAC 1 /* One DAC module */
+# define STM32F0_NDACCHAN 2 /* Two DAC channels */
+# define STM32F0_NCOMP 2 /* Two Analog Comparators */
+# define STM32F0_NCAP 18 /* Capacitive sensing channels */
+# define STM32F0_NPORTS 6 /* Six GPIO ports, GPIOA-F */
+
+#elif defined(CONFIG_ARCH_CHIP_STM32F072V8) || defined(CONFIG_ARCH_CHIP_STM32F072VB)
+# undef STM32F051x /* Not STM32F051x family */
+# define STM32F072x 1 /* STM32F072x family */
+# undef STM32F091x /* Not STM32F091x family */
+
+# ifdef CONFIG_ARCH_CHIP_STM32F072V8
+# define STM32F0_FLASH_SIZE (64*1024) /* 64Kb */
+# else
+# define STM32F0_FLASH_SIZE (128*1024) /* 128Kb */
+# endif
+# define STM32F0_SRAM_SIZE (16*1024) /* 16Kb */
+
+# define STM32F0_NATIM 1 /* One advanced timer TIM1 */
+# define STM32F0_NGTIM16 5 /* 16-bit general up/down timers TIM3, TIM14-17 */
+# define STM32F0_NGTIM32 1 /* 32-bit general up/down timers TIM2 */
+# define STM32F0_NBTIM 2 /* 2 basic timers: TIM6, TIM7 */
+# define STM32F0_NSPI 2 /* Two SPI modules (SPI or I2S) */
+# define STM32F0_NI2S 2 /* Two I2S modules (SPI or I2S) */
+# define STM32F0_NI2C 2 /* Two I2C modules */
+# define STM32F0_NUSART 4 /* Four USARTs module */
+# define STM32F0_NCAN 1 /* One CAN controller */
+# define STM32F0_NUSBDEV 1 /* One USB device controller */
+# define STM32F0_NCEC 1 /* One HDMI-CEC controller */
+# define STM32F0_NADC12 1 /* One 12-bit module */
+# define STM32F0_NADCCHAN 16 /* 16 external channels */
+# define STM32F0_NADCINT 3 /* Three internal channels */
+# define STM32F0_NDAC 1 /* One DAC module */
+# define STM32F0_NDACCHAN 2 /* Two DAC channels */
+# define STM32F0_NCOMP 2 /* Two Analog Comparators */
+# define STM32F0_NCAP 24 /* Capacitive sensing channels */
+# define STM32F0_NPORTS 6 /* Six GPIO ports, GPIOA-F */
+
+#elif defined(CONFIG_ARCH_CHIP_STM32F091CB) || defined(CONFIG_ARCH_CHIP_STM32F091CC)
+# undef STM32F051x /* Not STM32F051x family */
+# undef STM32F072x /* Not STM32F072x family */
+# define STM32F091x 1 /* STM32F091x family */
+
+# ifdef CONFIG_ARCH_CHIP_STM32F091CB
+# define STM32F0_FLASH_SIZE (128*1024) /* 128Kb */
+# else
+# define STM32F0_FLASH_SIZE (256*1024) /* 256Kb */
+# endif
+# define STM32F0_SRAM_SIZE (32*1024) /* 32Kb */
+
+# define STM32F0_NATIM 1 /* One advanced timer TIM1 */
+# define STM32F0_NGTIM16 5 /* 16-bit general up/down timers TIM3, TIM14-17 */
+# define STM32F0_NGTIM32 1 /* 32-bit general up/down timers TIM2 */
+# define STM32F0_NBTIM 2 /* 2 basic timers: TIM6, TIM7 */
+# define STM32F0_NSPI 2 /* Two SPI modules (SPI or I2S) */
+# define STM32F0_NI2S 2 /* Two I2S modules (SPI or I2S) */
+# define STM32F0_NI2C 2 /* Two I2C modules */
+# define STM32F0_NUSART 6 /* Six USARTs modules */
+# define STM32F0_NCAN 1 /* One CAN controller */
+# define STM32F0_NUSBDEV 0 /* No USB device controller */
+# define STM32F0_NCEC 1 /* One HDMI-CEC controller */
+# define STM32F0_NADC12 1 /* One 12-bit module */
+# define STM32F0_NADCCHAN 10 /* 10 external channels */
+# define STM32F0_NADCINT 3 /* Three internal channels */
+# define STM32F0_NDAC 1 /* One DAC module */
+# define STM32F0_NDACCHAN 2 /* Two DAC channels */
+# define STM32F0_NCOMP 2 /* Two Analog Comparators */
+# define STM32F0_NCAP 17 /* Capacitive sensing channels */
+# define STM32F0_NPORTS 6 /* Six GPIO ports, GPIOA-F */
+
+#elif defined(CONFIG_ARCH_CHIP_STM32F091RB) || defined(CONFIG_ARCH_CHIP_STM32F091RC) \
+ || defined(CONFIG_ARCH_CHIP_STM32F091VB) || defined(CONFIG_ARCH_CHIP_STM32F091VC)
+# undef STM32F051x /* Not STM32F051x family */
+# undef STM32F072x /* Not STM32F072x family */
+# define STM32F091x 1 /* STM32F091x family */
+
+# if defined(CONFIG_ARCH_CHIP_STM32F091RB) || defined(CONFIG_ARCH_CHIP_STM32F091VB)
+# define STM32F0_FLASH_SIZE (128*1024) /* 128Kb */
+# else
+# define STM32F0_FLASH_SIZE (256*1024) /* 256Kb */
+# endif
+# define STM32F0_SRAM_SIZE (32*1024) /* 32Kb */
+
+# define STM32F0_NATIM 1 /* One advanced timer TIM1 */
+# define STM32F0_NGTIM16 5 /* 16-bit general up/down timers TIM3, TIM14-17 */
+# define STM32F0_NGTIM32 1 /* 32-bit general up/down timers TIM2 */
+# define STM32F0_NBTIM 2 /* 2 basic timers: TIM6, TIM7 */
+# define STM32F0_NSPI 2 /* Two SPI modules (SPI or I2S) */
+# define STM32F0_NI2S 2 /* Two I2S modules (SPI or I2S) */
+# define STM32F0_NI2C 2 /* Two I2C modules */
+# define STM32F0_NUSART 8 /* Eight USARTs modules */
+# define STM32F0_NCAN 1 /* One CAN controller */
+# define STM32F0_NUSBDEV 0 /* No USB device controller */
+# define STM32F0_NCEC 1 /* One HDMI-CEC controller */
+# define STM32F0_NADC12 1 /* One 12-bit module */
+# define STM32F0_NADCCHAN 16 /* 16 external channels */
+# define STM32F0_NADCINT 3 /* Three internal channels */
+# define STM32F0_NDAC 1 /* One DAC module */
+# define STM32F0_NDACCHAN 2 /* Two DAC channels */
+# define STM32F0_NCOMP 2 /* Two Analog Comparators */
+# if defined(CONFIG_ARCH_CHIP_STM32F091VB) || defined(CONFIG_ARCH_CHIP_STM32F091VC)
+# define STM32F0_NCAP 24 /* Capacitive sensing channels */
+# else
+# define STM32F0_NCAP 18 /* Capacitive sensing channels */
+# endif
+# define STM32F0_NPORTS 6 /* Six GPIO ports, GPIOA-F */
+
+#else
+# error "Unsupported STM32F0xx chip"
+#endif
+
+/* NVIC priority levels *************************************************************/
+/* Each priority field holds a priority value, 0-31. The lower the value, the greater
+ * the priority of the corresponding interrupt. The processor implements only
+ * bits[7:6] of each field, bits[5:0] read as zero and ignore writes.
+ */
+
+#define NVIC_SYSH_PRIORITY_MIN 0xc0 /* All bits[7:6] set is minimum priority */
+#define NVIC_SYSH_PRIORITY_DEFAULT 0x80 /* Midpoint is the default */
+#define NVIC_SYSH_PRIORITY_MAX 0x00 /* Zero is maximum priority */
+#define NVIC_SYSH_PRIORITY_STEP 0x40 /* Two bits of interrupt priority used */
+
+/* If CONFIG_ARMV7M_USEBASEPRI is selected, then interrupts will be disabled
+ * by setting the BASEPRI register to NVIC_SYSH_DISABLE_PRIORITY so that most
+ * interrupts will not have execution priority. SVCall must have execution
+ * priority in all cases.
+ *
+ * In the normal cases, interrupts are not nest-able and all interrupts run
+ * at an execution priority between NVIC_SYSH_PRIORITY_MIN and
+ * NVIC_SYSH_PRIORITY_MAX (with NVIC_SYSH_PRIORITY_MAX reserved for SVCall).
+ *
+ * If, in addition, CONFIG_ARCH_HIPRI_INTERRUPT is defined, then special
+ * high priority interrupts are supported. These are not "nested" in the
+ * normal sense of the word. These high priority interrupts can interrupt
+ * normal processing but execute outside of OS (although they can "get back
+ * into the game" via a PendSV interrupt).
+ *
+ * In the normal course of things, interrupts must occasionally be disabled
+ * using the up_irq_save() inline function to prevent contention in use of
+ * resources that may be shared between interrupt level and non-interrupt
+ * level logic. Now the question arises, if CONFIG_ARCH_HIPRI_INTERRUPT,
+ * do we disable all interrupts (except SVCall), or do we only disable the
+ * "normal" interrupts. Since the high priority interrupts cannot interact
+ * with the OS, you may want to permit the high priority interrupts even if
+ * interrupts are disabled. The setting CONFIG_ARCH_INT_DISABLEALL can be
+ * used to select either behavior:
+ *
+ * ----------------------------+--------------+----------------------------
+ * CONFIG_ARCH_HIPRI_INTERRUPT | NO | YES
+ * ----------------------------+--------------+--------------+-------------
+ * CONFIG_ARCH_INT_DISABLEALL | N/A | YES | NO
+ * ----------------------------+--------------+--------------+-------------
+ * | | | SVCall
+ * | SVCall | SVCall | HIGH
+ * Disable here and below --------> MAXNORMAL ---> HIGH --------> MAXNORMAL
+ * | | MAXNORMAL |
+ * ----------------------------+--------------+--------------+-------------
+ */
+
+#if defined(CONFIG_ARCH_HIPRI_INTERRUPT) && defined(CONFIG_ARCH_INT_DISABLEALL)
+# define NVIC_SYSH_MAXNORMAL_PRIORITY (NVIC_SYSH_PRIORITY_MAX + 2*NVIC_SYSH_PRIORITY_STEP)
+# define NVIC_SYSH_HIGH_PRIORITY (NVIC_SYSH_PRIORITY_MAX + NVIC_SYSH_PRIORITY_STEP)
+# define NVIC_SYSH_DISABLE_PRIORITY NVIC_SYSH_HIGH_PRIORITY
+# define NVIC_SYSH_SVCALL_PRIORITY NVIC_SYSH_PRIORITY_MAX
+#else
+# define NVIC_SYSH_MAXNORMAL_PRIORITY (NVIC_SYSH_PRIORITY_MAX + NVIC_SYSH_PRIORITY_STEP)
+# define NVIC_SYSH_HIGH_PRIORITY NVIC_SYSH_PRIORITY_MAX
+# define NVIC_SYSH_DISABLE_PRIORITY NVIC_SYSH_MAXNORMAL_PRIORITY
+# define NVIC_SYSH_SVCALL_PRIORITY NVIC_SYSH_PRIORITY_MAX
+#endif
+
+/************************************************************************************
+ * Public Types
+ ************************************************************************************/
+
+/************************************************************************************
+ * Public Data
+ ************************************************************************************/
+
+/************************************************************************************
+ * Public Functions
+ ************************************************************************************/
+
+#endif /* __ARCH_ARM_INCLUDE_STM32F0_CHIP_H */
diff --git a/arch/arm/include/stm32f0/irq.h b/arch/arm/include/stm32f0/irq.h
new file mode 100644
index 0000000000000000000000000000000000000000..196a3f294b182d0937bd258813541b0f9332ea32
--- /dev/null
+++ b/arch/arm/include/stm32f0/irq.h
@@ -0,0 +1,143 @@
+/****************************************************************************
+ * arch/arm/include/stm32f0/irq.h
+ *
+ * Copyright (C) 2017 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ * Alan Carvalho de Assis
+ *
+ * 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_STM32F0_IRQ_H
+#define __ARCH_ARM_INCLUDE_STM32F0_IRQ_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#ifndef __ASSEMBLY__
+# include
+#endif
+#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.
+ */
+
+/* Common Processor Exceptions (vectors 0-15) */
+
+#define STM32F0_IRQ_RESERVED (0) /* Reserved vector (only used with CONFIG_DEBUG_FEATURES) */
+ /* Vector 0: Reset stack pointer value */
+ /* Vector 1: Reset (not handler as an IRQ) */
+#define STM32F0_IRQ_NMI (2) /* Vector 2: Non-Maskable Interrupt (NMI) */
+#define STM32F0_IRQ_HARDFAULT (3) /* Vector 3: Hard fault */
+ /* Vectors 4-10: Reserved */
+#define STM32F0_IRQ_SVCALL (11) /* Vector 11: SVC call */
+ /* Vector 12-13: Reserved */
+#define STM32F0_IRQ_PENDSV (14) /* Vector 14: Pendable system service request */
+#define STM32F0_IRQ_SYSTICK (15) /* Vector 15: System tick */
+
+/* External interrupts (vectors >= 16) */
+
+#define STM32F0_IRQ_EXTINT (16) /* Vector number of the first external interrupt */
+
+#define STM32F0_IRQ_WWDG (16) /* Vector 16: WWDG */
+#define STM32F0_IRQ_PVD_VDDIO2 (17) /* Vector 17: PVD_VDDIO2 */
+#define STM32F0_IRQ_RTC (18) /* Vector 18: RTC */
+#define STM32F0_IRQ_FLASH (19) /* Vector 19: FLASH */
+#define STM32F0_IRQ_RCC_CRS (20) /* Vector 20: RCC and CRS */
+#define STM32F0_IRQ_EXTI0_1 (21) /* Vector 21: EXTI0_1 */
+#define STM32F0_IRQ_EXTI2_3 (22) /* Vector 22: EXTI2_3 */
+#define STM32F0_IRQ_EXTI4_15 (23) /* Vector 23: EXTI4_15 */
+#define STM32F0_IRQ_TSC (24) /* Vector 24: TSC */
+#define STM32F0_IRQ_DMA_CH1 (25) /* Vector 25: DMA_CH1 */
+#define STM32F0_IRQ_DMA_CH23 (26) /* Vector 26: DMA_CH2_3 and DMA2_CH1_2 */
+#define STM32F0_IRQ_DMA_CH4567 (27) /* Vector 27: DMA_CH4_5_6_7 and DMA2_CH3_4_5 */
+#define STM32F0_IRQ_ADC_COMP (28) /* Vector 28: ADC_COMP */
+#define STM32F0_IRQ_TIM1_BRK (29) /* Vector 29: TIM1_BRK_UP_TRG_COM */
+#define STM32F0_IRQ_TIM1_CC (30) /* Vector 30: TIM1_CC */
+#define STM32F0_IRQ_TIM2 (31) /* Vector 31: TIM2 */
+#define STM32F0_IRQ_TIM3 (32) /* Vector 32: TIM3 */
+#define STM32F0_IRQ_TIM6_DAC (33) /* Vector 33: TIM6 and DAC */
+#define STM32F0_IRQ_TIM7 (34) /* Vector 34: TIM7 */
+#define STM32F0_IRQ_TIM14 (35) /* Vector 35: TIM14 */
+#define STM32F0_IRQ_TIM15 (36) /* Vector 36: TIM15 */
+#define STM32F0_IRQ_TIM16 (37) /* Vector 37: TIM16 */
+#define STM32F0_IRQ_TIM17 (38) /* Vector 38: TIM17 */
+#define STM32F0_IRQ_I2C1 (39) /* Vector 39: I2C1 */
+#define STM32F0_IRQ_I2C2 (40) /* Vector 40: I2C2 */
+#define STM32F0_IRQ_SPI1 (41) /* Vector 41: SPI1 */
+#define STM32F0_IRQ_SPI2 (42) /* Vector 42: SPI2 */
+#define STM32F0_IRQ_USART1 (43) /* Vector 43: USART1 */
+#define STM32F0_IRQ_USART2 (44) /* Vector 44: USART2 */
+#define STM32F0_IRQ_USART345678 (45) /* Vector 45: USART3_4_5_6_7_8 */
+#define STM32F0_IRQ_CEC_CAN (46) /* Vector 46: HDMI CEC and CAN */
+#define STM32F0_IRQ_USB (47) /* Vector 47: USB */
+
+#define NR_VECTORS (48) /* 48 vectors */
+#define NR_IRQS (48) /* 32 interrupts plus 16 exceptions */
+
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+#ifndef __ASSEMBLY__
+typedef void (*vic_vector_t)(uint32_t *regs);
+
+/****************************************************************************
+ * Inline functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __ASSEMBLY__ */
+
+#endif /* __ARCH_ARM_INCLUDE_STM32F0_IRQ_H */
diff --git a/arch/arm/include/stm32l4/chip.h b/arch/arm/include/stm32l4/chip.h
index 9d0712b27682037e9224e5f89104edf1259841c9..99f13d2baa0a05ba76fb9a975f1ea0dc8832704f 100644
--- a/arch/arm/include/stm32l4/chip.h
+++ b/arch/arm/include/stm32l4/chip.h
@@ -1,8 +1,10 @@
/************************************************************************************
* arch/arm/include/stm32l4/chip.h
*
+ * Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2016 Sebastien Lorquet. All rights reserved.
* Author: Sebastien Lorquet
+ * Gregory Nutt
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -45,30 +47,56 @@
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
-/* STM32F476, STM32F486. Differences between family members: 486 has AES.
+/* STM32L475, STM32L476, STM32L486, STM32L496, STM32L4A6
+ *
+ * Differences between family members:
+ * - L475 has no TSC, no LCD, no AES, no I2C4, no CAN2, No Hash/CRS, no DCMI,
+ * no DMA2D
+ * - L486 has AES
+ * - L496, L4A6 has 320 Kib SRAM, 2xCAN and CameraIF. Most (all?) of these have I2C4.
+ * - L4A6 has AES and HASH
*
* ----------- ---------------- ----- ------ ------ ---- ---- -----
* PART PACKAGE GPIOs LCD Tamper FSMC CapS AdcCh
* ----------- ---------------- ----- ------ ------ ---- ---- -----
+ * STM32L475Rx LQFP100 82 3 Yes 21 16
+ * STM32L475Vx LQFP64 51 2 No 12 16
* STM32L4x6Jx WLCSP72L 57 8x28 2 No 12 16
* STM32L476Mx WLCSP81L 65 ? ? ? ? ?
* STM32L4x6Qx UFBGA132L 109 8x40 3 Yes 24 16
* STM32L4x6Rx LQFP64 51 8x28 2 No 12 16
* STM32L4x6Vx LQFP100 82 8x40 3 Yes 21 16
* STM32L4x6Zx LQFP144 114 8x40 3 Yes 24 24
+ * STM32L4x6Ax UFBGA169 132 8x40 3 Yes 24 24
* ----------- ---------------- ----- ------ ------ ---- ---- -----
*
* Parts STM32L4x6xC have 256Kb of FLASH
* Parts STM32L4x6xE have 512Kb of FLASH
* Parts STM32L4x6xG have 1024Kb of FLASH
*
- * The correct FLASH size must be set with a CONFIG_STM32L4_FLASH_*KB
+ * The correct FLASH size must be set with a CONFIG_STM32L4_FLASH_CONFIG_*
* selection.
*/
+#if defined(CONFIG_STM32L4_STM32L496XX)
+# define STM32L4_SRAM1_SIZE (256*1024) /* 256Kb SRAM1 on AHB bus Matrix */
+# define STM32L4_SRAM2_SIZE (64*1024) /* 64Kb SRAM2 on AHB bus Matrix */
+#elif defined(CONFIG_STM32L4_STM32L475XX) || defined(CONFIG_STM32L4_STM32L476XX) || \
+ defined(CONFIG_STM32L4_STM32L486XX)
# define STM32L4_SRAM1_SIZE (96*1024) /* 96Kb SRAM1 on AHB bus Matrix */
# define STM32L4_SRAM2_SIZE (32*1024) /* 32Kb SRAM2 on AHB bus Matrix */
+#elif defined(CONFIG_STM32L4_STM32L451XX) || defined(CONFIG_STM32L4_STM32L452XX) || \
+ defined(CONFIG_STM32L4_STM32L462XX)
+# define STM32L4_SRAM1_SIZE (128*1024) /* 128Kb SRAM1 on AHB bus Matrix */
+# define STM32L4_SRAM2_SIZE (32*1024) /* 32Kb SRAM2 on AHB bus Matrix */
+#elif defined(CONFIG_STM32L4_STM32L432XX)
+# define STM32L4_SRAM1_SIZE (48*1024) /* 48Kb SRAM1 on AHB bus Matrix */
+# define STM32L4_SRAM2_SIZE (16*1024) /* 16Kb SRAM2 on AHB bus Matrix */
+#else
+# error "Unsupported STM32L4 chip"
+#endif
+#if defined(CONFIG_STM32L4_STM32L4X5)
# define STM32L4_NFSMC 1 /* Have FSMC memory controller */
# define STM32L4_NATIM 2 /* Two advanced timers TIM1 and 8 */
# define STM32L4_NGTIM32 2 /* 32-bit general timers TIM2 and 5 with DMA */
@@ -80,19 +108,134 @@
# define STM32L4_NUART 2 /* UART 4-5 */
# define STM32L4_NUSART 3 /* USART 1-3 */
# define STM32L4_NLPUART 1 /* LPUART 1 */
+# define STM32L4_QSPI 1 /* QuadSPI1 */
# define STM32L4_NSPI 3 /* SPI1-3 */
# define STM32L4_NI2C 3 /* I2C1-3 */
+# define STM32L4_NSWPMI 1 /* SWPMI1 */
# define STM32L4_NUSBOTGFS 1 /* USB OTG FS */
+# define STM32L4_NUSBFS 0 /* No USB FS */
# define STM32L4_NCAN 1 /* CAN1 */
# define STM32L4_NSAI 2 /* SAI1-2 */
# define STM32L4_NSDMMC 1 /* SDMMC interface */
# define STM32L4_NDMA 2 /* DMA1-2 */
# define STM32L4_NPORTS 8 /* 8 GPIO ports, GPIOA-H */
-# define STM32L4_NADC 3 /* 12-bit ADC1-3, 24 channels *except V series) */
+# define STM32L4_NADC 3 /* 12-bit ADC1-3, 16 channels */
# define STM32L4_NDAC 2 /* 12-bit DAC1-2 */
# define STM32L4_NCRC 1 /* CRC */
# define STM32L4_NCOMP 2 /* Comparators */
# define STM32L4_NOPAMP 2 /* Operational Amplifiers */
+#endif /* CONFIG_STM32L4_STM32L4X5 */
+
+#if defined(CONFIG_STM32L4_STM32L4X6)
+# define STM32L4_NFSMC 1 /* Have FSMC memory controller */
+# define STM32L4_NATIM 2 /* Two advanced timers TIM1 and 8 */
+# define STM32L4_NGTIM32 2 /* 32-bit general timers TIM2 and 5 with DMA */
+# define STM32L4_NGTIM16 2 /* 16-bit general timers TIM3 and 4 with DMA */
+# define STM32L4_NGTIMNDMA 3 /* 16-bit general timers TIM15-17 without DMA */
+# define STM32L4_NBTIM 2 /* Two basic timers, TIM6-7 */
+# define STM32L4_NLPTIM 2 /* Two low-power timers, LPTIM1-2 */
+# define STM32L4_NRNG 1 /* Random number generator (RNG) */
+# define STM32L4_NUART 2 /* UART 4-5 */
+# define STM32L4_NUSART 3 /* USART 1-3 */
+# define STM32L4_NLPUART 1 /* LPUART 1 */
+# define STM32L4_QSPI 1 /* QuadSPI1 */
+# define STM32L4_NSPI 3 /* SPI1-3 */
+#if defined(CONFIG_STM32L4_STM32L496XX)
+# define STM32L4_NI2C 4 /* I2C1-4 */
+#else
+# define STM32L4_NI2C 3 /* I2C1-3 */
+#endif
+# define STM32L4_NSWPMI 1 /* SWPMI1 */
+# define STM32L4_NUSBOTGFS 1 /* USB OTG FS */
+# define STM32L4_NUSBFS 0 /* No USB FS */
+#if defined(CONFIG_STM32L4_STM32L496XX)
+# define STM32L4_NCAN 2 /* CAN1-2 */
+#else
+# define STM32L4_NCAN 1 /* CAN1 */
+#endif
+# define STM32L4_NSAI 2 /* SAI1-2 */
+# define STM32L4_NSDMMC 1 /* SDMMC interface */
+# define STM32L4_NDMA 2 /* DMA1-2 */
+#if defined(CONFIG_STM32L4_STM32L496XX)
+# define STM32L4_NPORTS 9 /* 9 GPIO ports, GPIOA-I */
+#else
+# define STM32L4_NPORTS 8 /* 8 GPIO ports, GPIOA-H */
+#endif
+# define STM32L4_NADC 3 /* 12-bit ADC1-3, upto 24 channels */
+# define STM32L4_NDAC 2 /* 12-bit DAC1-2 */
+# define STM32L4_NCRC 1 /* CRC */
+# define STM32L4_NCOMP 2 /* Comparators */
+# define STM32L4_NOPAMP 2 /* Operational Amplifiers */
+#endif /* CONFIG_STM32L4_STM32L4X6 */
+
+#if defined(CONFIG_STM32L4_STM32L451XX) || defined(CONFIG_STM32L4_STM32L452XX) || \
+ defined(CONFIG_STM32L4_STM32L462XX)
+# define STM32L4_NFSMC 0 /* No FSMC memory controller */
+# define STM32L4_NATIM 1 /* One advanced timer TIM1 */
+# define STM32L4_NGTIM32 1 /* 32-bit general timer TIM2 with DMA */
+# define STM32L4_NGTIM16 3 /* 16-bit general timers TIM3, TIM15-16 with DMA */
+# define STM32L4_NGTIMNDMA 0 /* No 16-bit general timers without DMA */
+# define STM32L4_NBTIM 1 /* One basic timer, TIM6 */
+# define STM32L4_NLPTIM 2 /* Two low-power timers, LPTIM1-2 */
+# define STM32L4_NRNG 1 /* Random number generator (RNG) */
+# define STM32L4_NUART 1 /* UART 4 */
+# define STM32L4_NUSART 3 /* USART 1-3 */
+# define STM32L4_NLPUART 1 /* LPUART 1 */
+# define STM32L4_QSPI 1 /* QuadSPI1 */
+# define STM32L4_NSPI 3 /* SPI1-3 */
+# define STM32L4_NI2C 4 /* I2C1-4 */
+# define STM32L4_NSWPMI 1 /* SWPMI1 */
+# define STM32L4_NUSBOTGFS 0 /* No USB OTG FS */
+#if defined(CONFIG_STM32L4_STM32L451XX)
+# define STM32L4_NUSBFS 0 /* No USB FS */
+#else
+# define STM32L4_NUSBFS 1 /* USB FS */
+#endif
+# define STM32L4_NCAN 1 /* CAN1 */
+# define STM32L4_NSAI 1 /* SAI1 */
+#if defined(CONFIG_STM32L4_HAVE_SDMMC1)
+# define STM32L4_NSDMMC 1 /* SDMMC interface */
+#else
+# define STM32L4_NSDMMC 0 /* No SDMMC interface */
+#endif
+# define STM32L4_NDMA 2 /* DMA1-2 */
+# define STM32L4_NPORTS 8 /* 8 GPIO ports, GPIOA-H */
+# define STM32L4_NADC 1 /* 12-bit ADC1, 16 channels (10 in CE,CV) */
+# define STM32L4_NDAC 1 /* 12-bit DAC1 */
+# define STM32L4_NCRC 1 /* CRC */
+# define STM32L4_NCOMP 2 /* Comparators */
+# define STM32L4_NOPAMP 1 /* Operational Amplifiers */
+#endif /* CONFIG_STM32L4_STM32L451XX */
+
+#if defined(CONFIG_STM32L4_STM32L432XX)
+# define STM32L4_NFSMC 0 /* No FSMC memory controller */
+# define STM32L4_NATIM 1 /* One advanced timer TIM1 */
+# define STM32L4_NGTIM32 1 /* 32-bit general timer TIM2 with DMA */
+# define STM32L4_NGTIM16 2 /* 16-bit general timers TIM15-16 with DMA */
+# define STM32L4_NGTIMNDMA 0 /* No 16-bit general timers without DMA */
+# define STM32L4_NBTIM 2 /* Two basic timers, TIM6-7 */
+# define STM32L4_NLPTIM 2 /* Two low-power timers, LPTIM1-2 */
+# define STM32L4_NRNG 1 /* Random number generator (RNG) */
+# define STM32L4_NUART 0 /* No UART */
+# define STM32L4_NUSART 2 /* USART 1-2 */
+# define STM32L4_NLPUART 1 /* LPUART 1 */
+# define STM32L4_QSPI 1 /* QuadSPI1 */
+# define STM32L4_NSPI 2 /* SPI1, SPI3 */
+# define STM32L4_NI2C 2 /* I2C1, I2C3 */
+# define STM32L4_NSWPMI 1 /* SWPMI1 */
+# define STM32L4_NUSBOTGFS 0 /* No USB OTG FS */
+# define STM32L4_NUSBFS 1 /* USB FS */
+# define STM32L4_NCAN 1 /* CAN1 */
+# define STM32L4_NSAI 1 /* SAI1 */
+# define STM32L4_NSDMMC 0 /* No SDMMC interface */
+# define STM32L4_NDMA 2 /* DMA1-2 */
+# define STM32L4_NPORTS 8 /* 8 GPIO ports, GPIOA-H */
+# define STM32L4_NADC 1 /* 12-bit ADC1, 10 channels */
+# define STM32L4_NDAC 2 /* 12-bit DAC1-2 */
+# define STM32L4_NCRC 1 /* CRC */
+# define STM32L4_NCOMP 2 /* Comparators */
+# define STM32L4_NOPAMP 1 /* Operational Amplifiers */
+#endif /* CONFIG_STM32L4_STM32L432XX */
/* NVIC priority levels *************************************************************/
/* 16 Programmable interrupt levels */
diff --git a/arch/arm/include/stm32l4/irq.h b/arch/arm/include/stm32l4/irq.h
index 89e74c1760bedd01330ff9062de2016f0542782f..a6419445adb63cc976be01532fc1ca3f188ad2ee 100644
--- a/arch/arm/include/stm32l4/irq.h
+++ b/arch/arm/include/stm32l4/irq.h
@@ -76,7 +76,11 @@
#define STM32L4_IRQ_FIRST (16) /* Vector number of the first external interrupt */
-#if defined(CONFIG_STM32L4_STM32L476XX) || defined(CONFIG_STM32L4_STM32L486XX)
+#if defined(CONFIG_STM32L4_STM32L4X3)
+# include
+#elif defined(CONFIG_STM32L4_STM32L4X5)
+# include
+#elif defined(CONFIG_STM32L4_STM32L4X6)
# include
#else
# error "Unsupported STM32 L4 chip"
diff --git a/arch/arm/include/stm32l4/stm32l4x3xx_irq.h b/arch/arm/include/stm32l4/stm32l4x3xx_irq.h
new file mode 100644
index 0000000000000000000000000000000000000000..e3c3c8cf17dc5799f009c85e2bd41a6ae244ce43
--- /dev/null
+++ b/arch/arm/include/stm32l4/stm32l4x3xx_irq.h
@@ -0,0 +1,185 @@
+/****************************************************************************************************
+ * arch/arm/include/stm32l4/stm32l4x3xx_irq.h
+ *
+ * Copyright (C) 2015 Sebastien Lorquet. All rights reserved.
+ * Authors: Sebastien Lorquet
+ * Juha Niskanen
+ *
+ * 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 arch/irq.h */
+
+#ifndef __ARCH_ARM_INCLUDE_STM32L4_STM32L4X3XX_IRQ_H
+#define __ARCH_ARM_INCLUDE_STM32L4_STM32L4X3XX_IRQ_H
+
+/****************************************************************************************************
+ * Included Files
+ ****************************************************************************************************/
+
+#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 the file
+ * nuttx/arch/arm/include/stm32f7/irq.h which includes this file
+ *
+ * External interrupts (vectors >= 16)
+ */
+
+#define STM32L4_IRQ_WWDG (STM32L4_IRQ_FIRST+0) /* 0: Window Watchdog interrupt */
+#define STM32L4_IRQ_PVD (STM32L4_IRQ_FIRST+1) /* 1: PVD through EXTI Line detection interrupt */
+#define STM32L4_IRQ_TAMPER (STM32L4_IRQ_FIRST+2) /* 2: Tamper and time stamp interrupts */
+#define STM32L4_IRQ_TIMESTAMP (STM32L4_IRQ_FIRST+2) /* 2: Tamper and time stamp interrupts */
+#define STM32L4_IRQ_RTC_WKUP (STM32L4_IRQ_FIRST+3) /* 3: RTC global interrupt */
+#define STM32L4_IRQ_FLASH (STM32L4_IRQ_FIRST+4) /* 4: Flash global interrupt */
+#define STM32L4_IRQ_RCC (STM32L4_IRQ_FIRST+5) /* 5: RCC global interrupt */
+#define STM32L4_IRQ_EXTI0 (STM32L4_IRQ_FIRST+6) /* 6: EXTI Line 0 interrupt */
+#define STM32L4_IRQ_EXTI1 (STM32L4_IRQ_FIRST+7) /* 7: EXTI Line 1 interrupt */
+#define STM32L4_IRQ_EXTI2 (STM32L4_IRQ_FIRST+8) /* 8: EXTI Line 2 interrupt */
+#define STM32L4_IRQ_EXTI3 (STM32L4_IRQ_FIRST+9) /* 9: EXTI Line 3 interrupt */
+#define STM32L4_IRQ_EXTI4 (STM32L4_IRQ_FIRST+10) /* 10: EXTI Line 4 interrupt */
+#define STM32L4_IRQ_DMA1CH1 (STM32L4_IRQ_FIRST+11) /* 12: DMA1 Channel 1 global interrupt */
+#define STM32L4_IRQ_DMA1CH2 (STM32L4_IRQ_FIRST+12) /* 13: DMA1 Channel 2 global interrupt */
+#define STM32L4_IRQ_DMA1CH3 (STM32L4_IRQ_FIRST+13) /* 14: DMA1 Channel 3 global interrupt */
+#define STM32L4_IRQ_DMA1CH4 (STM32L4_IRQ_FIRST+14) /* 15: DMA1 Channel 4 global interrupt */
+#define STM32L4_IRQ_DMA1CH5 (STM32L4_IRQ_FIRST+15) /* 16: DMA1 Channel 5 global interrupt */
+#define STM32L4_IRQ_DMA1CH6 (STM32L4_IRQ_FIRST+16) /* 17: DMA1 Channel 6 global interrupt */
+#define STM32L4_IRQ_DMA1CH7 (STM32L4_IRQ_FIRST+17) /* 17: DMA1 Channel 7 global interrupt */
+#define STM32L4_IRQ_ADC1 (STM32L4_IRQ_FIRST+18) /* 18: ADC1 global interrupt */
+#define STM32L4_IRQ_CAN1TX (STM32L4_IRQ_FIRST+19) /* 19: CAN1 TX interrupts */
+#define STM32L4_IRQ_CAN1RX0 (STM32L4_IRQ_FIRST+20) /* 20: CAN1 RX0 interrupts */
+#define STM32L4_IRQ_CAN1RX1 (STM32L4_IRQ_FIRST+21) /* 21: CAN1 RX1 interrupt */
+#define STM32L4_IRQ_CAN1SCE (STM32L4_IRQ_FIRST+22) /* 22: CAN1 SCE interrupt */
+#define STM32L4_IRQ_EXTI95 (STM32L4_IRQ_FIRST+23) /* 23: EXTI Line[9:5] interrupts */
+#define STM32L4_IRQ_TIM1BRK (STM32L4_IRQ_FIRST+24) /* 24: TIM1 Break interrupt */
+#define STM32L4_IRQ_TIM15 (STM32L4_IRQ_FIRST+24) /* 24: TIM15 global interrupt */
+#define STM32L4_IRQ_TIM1UP (STM32L4_IRQ_FIRST+25) /* 25: TIM1 Update interrupt */
+#define STM32L4_IRQ_TIM16 (STM32L4_IRQ_FIRST+25) /* 25: TIM16 global interrupt */
+#define STM32L4_IRQ_TIM1TRGCOM (STM32L4_IRQ_FIRST+26) /* 26: TIM1 Trigger and Commutation interrupts */
+#define STM32L4_IRQ_TIM1CC (STM32L4_IRQ_FIRST+27) /* 27: TIM1 Capture Compare interrupt */
+#define STM32L4_IRQ_TIM2 (STM32L4_IRQ_FIRST+28) /* 28: TIM2 global interrupt */
+#define STM32L4_IRQ_TIM3 (STM32L4_IRQ_FIRST+29) /* 29: TIM3 global interrupt */
+/* Reserved */ /* 30: TIM4 global interrupt */
+#define STM32L4_IRQ_I2C1EV (STM32L4_IRQ_FIRST+31) /* 31: I2C1 event interrupt */
+#define STM32L4_IRQ_I2C1ER (STM32L4_IRQ_FIRST+32) /* 32: I2C1 error interrupt */
+#define STM32L4_IRQ_I2C2EV (STM32L4_IRQ_FIRST+33) /* 33: I2C2 event interrupt */
+#define STM32L4_IRQ_I2C2ER (STM32L4_IRQ_FIRST+34) /* 34: I2C2 error interrupt */
+#define STM32L4_IRQ_SPI1 (STM32L4_IRQ_FIRST+35) /* 35: SPI1 global interrupt */
+#define STM32L4_IRQ_SPI2 (STM32L4_IRQ_FIRST+36) /* 36: SPI2 global interrupt */
+#define STM32L4_IRQ_USART1 (STM32L4_IRQ_FIRST+37) /* 37: USART1 global interrupt */
+#define STM32L4_IRQ_USART2 (STM32L4_IRQ_FIRST+38) /* 38: USART2 global interrupt */
+#define STM32L4_IRQ_USART3 (STM32L4_IRQ_FIRST+39) /* 39: USART3 global interrupt */
+#define STM32L4_IRQ_EXTI1510 (STM32L4_IRQ_FIRST+40) /* 40: EXTI Line[15:10] interrupts */
+#define STM32L4_IRQ_RTCALRM (STM32L4_IRQ_FIRST+41) /* 41: RTC alarm through EXTI line interrupt */
+/* Reserved */ /* 42-48: reserved */
+#define STM32L4_IRQ_SDMMC1 (STM32L4_IRQ_FIRST+49) /* 49: SDMMC1 global interrupt */
+/* Reserved */ /* 50: TIM5 global interrupt */
+#define STM32L4_IRQ_SPI3 (STM32L4_IRQ_FIRST+51) /* 51: SPI3 global interrupt */
+#define STM32L4_IRQ_UART4 (STM32L4_IRQ_FIRST+52) /* 52: UART4 global interrupt */
+/* Reserved */ /* 53: UART5 global interrupt */
+#define STM32L4_IRQ_TIM6 (STM32L4_IRQ_FIRST+54) /* 54: TIM6 global interrupt */
+#define STM32L4_IRQ_DAC (STM32L4_IRQ_FIRST+54) /* 54: DAC1 underrun error interrupts */
+#define STM32L4_IRQ_TIM7 (STM32L4_IRQ_FIRST+55) /* 55: TIM7 global interrupt */
+#define STM32L4_IRQ_DMA2CH1 (STM32L4_IRQ_FIRST+56) /* 56: DMA2 Channel 1 global interrupt */
+#define STM32L4_IRQ_DMA2CH2 (STM32L4_IRQ_FIRST+57) /* 57: DMA2 Channel 2 global interrupt */
+#define STM32L4_IRQ_DMA2CH3 (STM32L4_IRQ_FIRST+58) /* 58: DMA2 Channel 3 global interrupt */
+#define STM32L4_IRQ_DMA2CH4 (STM32L4_IRQ_FIRST+59) /* 59: DMA2 Channel 4 global interrupt */
+#define STM32L4_IRQ_DMA2CH5 (STM32L4_IRQ_FIRST+60) /* 60: DMA2 Channel 5 global interrupt */
+#define STM32L4_IRQ_DFSDM0 (STM32L4_IRQ_FIRST+61) /* 61: DFSDM0 global interrupt */
+#define STM32L4_IRQ_DFSDM1 (STM32L4_IRQ_FIRST+62) /* 62: DFSDM1 global interrupt*/
+/* Reserved */ /* 63: DFSDM2 global interrupt */
+#define STM32L4_IRQ_COMP (STM32L4_IRQ_FIRST+64) /* 64: COMP1/COMP2 interrupts */
+#define STM32L4_IRQ_LPTIM1 (STM32L4_IRQ_FIRST+65) /* 65: LPTIM1 global interrupt */
+#define STM32L4_IRQ_LPTIM2 (STM32L4_IRQ_FIRST+66) /* 66: LPTIM2 global interrupt */
+#define STM32L4_IRQ_USB_FS (STM32L4_IRQ_FIRST+67) /* 67: USB event interrupt through EXTI line 17 */
+#define STM32L4_IRQ_DMA2CH6 (STM32L4_IRQ_FIRST+68) /* 68: DMA2 Channel 6 global interrupt */
+#define STM32L4_IRQ_DMA2CH7 (STM32L4_IRQ_FIRST+69) /* 69: DMA2 Channel 7 global interrupt */
+#define STM32L4_IRQ_LPUART1 (STM32L4_IRQ_FIRST+70) /* 70: Low power UART 1 global interrupt */
+#define STM32L4_IRQ_QUADSPI (STM32L4_IRQ_FIRST+71) /* 71: QUADSPI global interrupt */
+#define STM32L4_IRQ_I2C3EV (STM32L4_IRQ_FIRST+72) /* 72: I2C3 event interrupt */
+#define STM32L4_IRQ_I2C3ER (STM32L4_IRQ_FIRST+73) /* 73: I2C3 error interrupt */
+#define STM32L4_IRQ_SAI1 (STM32L4_IRQ_FIRST+74) /* 74: SAI1 global interrupt */
+/* Reserved */ /* 75: SAI2 global interrupt */
+#define STM32L4_IRQ_SWPMI1 (STM32L4_IRQ_FIRST+76) /* 76: SWPMI1 global interrupt */
+#define STM32L4_IRQ_TSC (STM32L4_IRQ_FIRST+77) /* 77: TSC global interrupt */
+#define STM32L4_IRQ_LCD (STM32L4_IRQ_FIRST+78) /* 78: LCD global interrupt */
+#define STM32L4_IRQ_AES (STM32L4_IRQ_FIRST+79) /* 79: AES crypto global interrupt */
+#define STM32L4_IRQ_RNG (STM32L4_IRQ_FIRST+80) /* 80: RNG global interrupt */
+#define STM32L4_IRQ_FPU (STM32L4_IRQ_FIRST+81) /* 81: FPU global interrupt */
+#define STM32L4_IRQ_CRS (STM32L4_IRQ_FIRST+82) /* 82: CRS global interrupt */
+#define STM32L4_IRQ_I2C4EV (STM32L4_IRQ_FIRST+83) /* 83: I2C4 event interrupt */
+#define STM32L4_IRQ_I2C4ER (STM32L4_IRQ_FIRST+84) /* 84: I2C4 error interrupt */
+
+#if defined(CONFIG_STM32L4_STM32L4X3)
+# define NR_INTERRUPTS 85
+#else
+# error "Unsupported STM32L4 chip"
+#endif
+
+#define NR_VECTORS (STM32L4_IRQ_FIRST+NR_INTERRUPTS)
+
+/* EXTI interrupts (Do not use IRQ numbers) */
+
+#define NR_IRQS NR_VECTORS
+
+/****************************************************************************************************
+ * 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_STM32L4_STM32L4X3XX_IRQ_H */
diff --git a/arch/arm/include/stm32l4/stm32l4x5xx_irq.h b/arch/arm/include/stm32l4/stm32l4x5xx_irq.h
new file mode 100644
index 0000000000000000000000000000000000000000..62a135e14071632e367c4d0781c67e4aac038763
--- /dev/null
+++ b/arch/arm/include/stm32l4/stm32l4x5xx_irq.h
@@ -0,0 +1,185 @@
+/****************************************************************************************************
+ * arch/arm/include/stm32l4/stm32l4x5xx_irq.h
+ *
+ * Copyright (C) 2017 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2015 Sebastien Lorquet. All rights reserved.
+ * Author: Sebastien Lorquet
+ * 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.
+ *
+ ****************************************************************************************************/
+
+/* This file should never be included directed but, rather, only indirectly through arch/irq.h */
+
+#ifndef __ARCH_ARM_INCLUDE_STM32L4_STM32L4X5XX_IRQ_H
+#define __ARCH_ARM_INCLUDE_STM32L4_STM32L4X5XX_IRQ_H
+
+/****************************************************************************************************
+ * Included Files
+ ****************************************************************************************************/
+
+#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 the file
+ * nuttx/arch/arm/include/stm32f7/irq.h which includes this file
+ *
+ * External interrupts (vectors >= 16)
+ */
+
+#define STM32L4_IRQ_WWDG (STM32L4_IRQ_FIRST+0) /* 0: Window Watchdog interrupt */
+#define STM32L4_IRQ_PVD (STM32L4_IRQ_FIRST+1) /* 1: PVD through EXTI Line detection interrupt */
+#define STM32L4_IRQ_TAMPER (STM32L4_IRQ_FIRST+2) /* 2: Tamper and time stamp interrupts */
+#define STM32L4_IRQ_TIMESTAMP (STM32L4_IRQ_FIRST+2) /* 2: Tamper and time stamp interrupts */
+#define STM32L4_IRQ_RTC_WKUP (STM32L4_IRQ_FIRST+3) /* 3: RTC global interrupt */
+#define STM32L4_IRQ_FLASH (STM32L4_IRQ_FIRST+4) /* 4: Flash global interrupt */
+#define STM32L4_IRQ_RCC (STM32L4_IRQ_FIRST+5) /* 5: RCC global interrupt */
+#define STM32L4_IRQ_EXTI0 (STM32L4_IRQ_FIRST+6) /* 6: EXTI Line 0 interrupt */
+#define STM32L4_IRQ_EXTI1 (STM32L4_IRQ_FIRST+7) /* 7: EXTI Line 1 interrupt */
+#define STM32L4_IRQ_EXTI2 (STM32L4_IRQ_FIRST+8) /* 8: EXTI Line 2 interrupt */
+#define STM32L4_IRQ_EXTI3 (STM32L4_IRQ_FIRST+9) /* 9: EXTI Line 3 interrupt */
+#define STM32L4_IRQ_EXTI4 (STM32L4_IRQ_FIRST+10) /* 10: EXTI Line 4 interrupt */
+#define STM32L4_IRQ_DMA1CH1 (STM32L4_IRQ_FIRST+11) /* 11: DMA1 Channel 1 global interrupt */
+#define STM32L4_IRQ_DMA1CH2 (STM32L4_IRQ_FIRST+12) /* 12: DMA1 Channel 2 global interrupt */
+#define STM32L4_IRQ_DMA1CH3 (STM32L4_IRQ_FIRST+13) /* 13: DMA1 Channel 3 global interrupt */
+#define STM32L4_IRQ_DMA1CH4 (STM32L4_IRQ_FIRST+14) /* 14: DMA1 Channel 4 global interrupt */
+#define STM32L4_IRQ_DMA1CH5 (STM32L4_IRQ_FIRST+15) /* 15: DMA1 Channel 5 global interrupt */
+#define STM32L4_IRQ_DMA1CH6 (STM32L4_IRQ_FIRST+16) /* 16: DMA1 Channel 6 global interrupt */
+#define STM32L4_IRQ_DMA1CH7 (STM32L4_IRQ_FIRST+17) /* 17: DMA1 Channel 7 global interrupt */
+#define STM32L4_IRQ_ADC12 (STM32L4_IRQ_FIRST+18) /* 18: ADC1 and ADC2 global interrupt */
+#define STM32L4_IRQ_CAN1TX (STM32L4_IRQ_FIRST+19) /* 19: CAN1 TX interrupts */
+#define STM32L4_IRQ_CAN1RX0 (STM32L4_IRQ_FIRST+20) /* 20: CAN1 RX0 interrupts */
+#define STM32L4_IRQ_CAN1RX1 (STM32L4_IRQ_FIRST+21) /* 21: CAN1 RX1 interrupt */
+#define STM32L4_IRQ_CAN1SCE (STM32L4_IRQ_FIRST+22) /* 22: CAN1 SCE interrupt */
+#define STM32L4_IRQ_EXTI95 (STM32L4_IRQ_FIRST+23) /* 23: EXTI Line[9:5] interrupts */
+#define STM32L4_IRQ_TIM1BRK (STM32L4_IRQ_FIRST+24) /* 24: TIM1 Break interrupt */
+#define STM32L4_IRQ_TIM15 (STM32L4_IRQ_FIRST+24) /* 24: TIM15 global interrupt */
+#define STM32L4_IRQ_TIM1UP (STM32L4_IRQ_FIRST+25) /* 25: TIM1 Update interrupt */
+#define STM32L4_IRQ_TIM16 (STM32L4_IRQ_FIRST+25) /* 25: TIM16 global interrupt */
+#define STM32L4_IRQ_TIM1TRGCOM (STM32L4_IRQ_FIRST+26) /* 26: TIM1 Trigger and Commutation interrupts */
+#define STM32L4_IRQ_TIM17 (STM32L4_IRQ_FIRST+26) /* 26: TIM17 global interrupt */
+#define STM32L4_IRQ_TIM1CC (STM32L4_IRQ_FIRST+27) /* 27: TIM1 Capture Compare interrupt */
+#define STM32L4_IRQ_TIM2 (STM32L4_IRQ_FIRST+28) /* 28: TIM2 global interrupt */
+#define STM32L4_IRQ_TIM3 (STM32L4_IRQ_FIRST+29) /* 29: TIM3 global interrupt */
+#define STM32L4_IRQ_TIM4 (STM32L4_IRQ_FIRST+30) /* 30: TIM4 global interrupt */
+#define STM32L4_IRQ_I2C1EV (STM32L4_IRQ_FIRST+31) /* 31: I2C1 event interrupt */
+#define STM32L4_IRQ_I2C1ER (STM32L4_IRQ_FIRST+32) /* 32: I2C1 error interrupt */
+#define STM32L4_IRQ_I2C2EV (STM32L4_IRQ_FIRST+33) /* 33: I2C2 event interrupt */
+#define STM32L4_IRQ_I2C2ER (STM32L4_IRQ_FIRST+34) /* 34: I2C2 error interrupt */
+#define STM32L4_IRQ_SPI1 (STM32L4_IRQ_FIRST+35) /* 35: SPI1 global interrupt */
+#define STM32L4_IRQ_SPI2 (STM32L4_IRQ_FIRST+36) /* 36: SPI2 global interrupt */
+#define STM32L4_IRQ_USART1 (STM32L4_IRQ_FIRST+37) /* 37: USART1 global interrupt */
+#define STM32L4_IRQ_USART2 (STM32L4_IRQ_FIRST+38) /* 38: USART2 global interrupt */
+#define STM32L4_IRQ_USART3 (STM32L4_IRQ_FIRST+39) /* 39: USART3 global interrupt */
+#define STM32L4_IRQ_EXTI1510 (STM32L4_IRQ_FIRST+40) /* 40: EXTI Line[15:10] interrupts */
+#define STM32L4_IRQ_RTCALRM (STM32L4_IRQ_FIRST+41) /* 41: RTC alarm through EXTI line interrupt */
+#define STM32L4_IRQ_DFSDM3 (STM32L4_IRQ_FIRST+42) /* 42: Digital Filter / Sigma Delta Modulator interrupt */
+#define STM32L4_IRQ_TIM8BRK (STM32L4_IRQ_FIRST+43) /* 43: TIM8 Break interrupt */
+#define STM32L4_IRQ_TIM8UP (STM32L4_IRQ_FIRST+44) /* 44: TIM8 Update interrupt */
+#define STM32L4_IRQ_TIM8TRGCOM (STM32L4_IRQ_FIRST+45) /* 45: TIM8 Trigger and Commutation interrupts */
+#define STM32L4_IRQ_TIM8CC (STM32L4_IRQ_FIRST+46) /* 46: TIM8 Capture Compare interrupt */
+#define STM32L4_IRQ_ADC3 (STM32L4_IRQ_FIRST+47) /* 47: ADC3 global interrupt */
+#define STM32L4_IRQ_FSMC (STM32L4_IRQ_FIRST+48) /* 48: FSMC global interrupt */
+#define STM32L4_IRQ_SDMMC1 (STM32L4_IRQ_FIRST+49) /* 49: SDMMC1 global interrupt */
+#define STM32L4_IRQ_TIM5 (STM32L4_IRQ_FIRST+50) /* 50: TIM5 global interrupt */
+#define STM32L4_IRQ_SPI3 (STM32L4_IRQ_FIRST+51) /* 51: SPI3 global interrupt */
+#define STM32L4_IRQ_UART4 (STM32L4_IRQ_FIRST+52) /* 52: UART4 global interrupt */
+#define STM32L4_IRQ_UART5 (STM32L4_IRQ_FIRST+53) /* 53: UART5 global interrupt */
+#define STM32L4_IRQ_TIM6 (STM32L4_IRQ_FIRST+54) /* 54: TIM6 global interrupt */
+#define STM32L4_IRQ_DAC (STM32L4_IRQ_FIRST+54) /* 54: DAC1 and DAC2 underrun error interrupts */
+#define STM32L4_IRQ_TIM7 (STM32L4_IRQ_FIRST+55) /* 55: TIM7 global interrupt */
+#define STM32L4_IRQ_DMA2CH1 (STM32L4_IRQ_FIRST+56) /* 56: DMA2 Channel 1 global interrupt */
+#define STM32L4_IRQ_DMA2CH2 (STM32L4_IRQ_FIRST+57) /* 57: DMA2 Channel 2 global interrupt */
+#define STM32L4_IRQ_DMA2CH3 (STM32L4_IRQ_FIRST+58) /* 58: DMA2 Channel 3 global interrupt */
+#define STM32L4_IRQ_DMA2CH4 (STM32L4_IRQ_FIRST+59) /* 59: DMA2 Channel 4 global interrupt */
+#define STM32L4_IRQ_DMA2CH5 (STM32L4_IRQ_FIRST+60) /* 60: DMA2 Channel 5 global interrupt */
+#define STM32L4_IRQ_DFSDM0 (STM32L4_IRQ_FIRST+61) /* 61: DFSDM0 global interrupt */
+#define STM32L4_IRQ_DFSDM1 (STM32L4_IRQ_FIRST+62) /* 62: DFSDM1 global interrupt*/
+#define STM32L4_IRQ_DFSDM2 (STM32L4_IRQ_FIRST+63) /* 63: DFSDM2 global interrupt */
+#define STM32L4_IRQ_COMP (STM32L4_IRQ_FIRST+64) /* 64: COMP1/COMP2 interrupts */
+#define STM32L4_IRQ_LPTIM1 (STM32L4_IRQ_FIRST+65) /* 65: LPTIM1 global interrupt */
+#define STM32L4_IRQ_LPTIM2 (STM32L4_IRQ_FIRST+66) /* 66: LPTIM2 global interrupt */
+#define STM32L4_IRQ_OTGFS (STM32L4_IRQ_FIRST+67) /* 67: USB On The Go FS global interrupt */
+#define STM32L4_IRQ_DMA2CH6 (STM32L4_IRQ_FIRST+68) /* 68: DMA2 Channel 6 global interrupt */
+#define STM32L4_IRQ_DMA2CH7 (STM32L4_IRQ_FIRST+69) /* 69: DMA2 Channel 7 global interrupt */
+#define STM32L4_IRQ_LPUART1 (STM32L4_IRQ_FIRST+70) /* 70: Low power UART 1 global interrupt */
+#define STM32L4_IRQ_QUADSPI (STM32L4_IRQ_FIRST+71) /* 71: QUADSPI global interrupt */
+#define STM32L4_IRQ_I2C3EV (STM32L4_IRQ_FIRST+72) /* 72: I2C3 event interrupt */
+#define STM32L4_IRQ_I2C3ER (STM32L4_IRQ_FIRST+73) /* 73: I2C3 error interrupt */
+#define STM32L4_IRQ_SAI1 (STM32L4_IRQ_FIRST+74) /* 74: SAI1 global interrupt */
+#define STM32L4_IRQ_SAI2 (STM32L4_IRQ_FIRST+75) /* 75: SAI2 global interrupt */
+#define STM32L4_IRQ_SWPMI1 (STM32L4_IRQ_FIRST+76) /* 76: SWPMI1 global interrupt */
+#define STM32L4_IRQ_TSC (STM32L4_IRQ_FIRST+77) /* 77: TSC global interrupt */
+#define STM32_IRQ_RESERVED78 (STM32L4_IRQ_FIRST+78) /* 78: Reserved */
+#define STM32_IRQ_RESERVED79 (STM32L4_IRQ_FIRST+79) /* 79: Reserved */
+#define STM32L4_IRQ_RNG (STM32L4_IRQ_FIRST+80) /* 80: RNG global interrupt */
+#define STM32L4_IRQ_FPU (STM32L4_IRQ_FIRST+81) /* 81: FPU global interrupt */
+
+#define NR_INTERRUPTS 82
+#define NR_VECTORS (STM32L4_IRQ_FIRST+NR_INTERRUPTS)
+
+/* EXTI interrupts (Do not use IRQ numbers) */
+
+#define NR_IRQS NR_VECTORS
+
+/****************************************************************************************************
+ * 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_STM32L4_STM32L4X5XX_IRQ_H */
diff --git a/arch/arm/include/stm32l4/stm32l4x6xx_irq.h b/arch/arm/include/stm32l4/stm32l4x6xx_irq.h
index c992ed942fad96b0706771550768ee2a5fc9a50d..3b0a8caa27bb54de7c9374534ecf7099aeda4d9a 100644
--- a/arch/arm/include/stm32l4/stm32l4x6xx_irq.h
+++ b/arch/arm/include/stm32l4/stm32l4x6xx_irq.h
@@ -70,12 +70,12 @@
#define STM32L4_IRQ_EXTI2 (STM32L4_IRQ_FIRST+8) /* 8: EXTI Line 2 interrupt */
#define STM32L4_IRQ_EXTI3 (STM32L4_IRQ_FIRST+9) /* 9: EXTI Line 3 interrupt */
#define STM32L4_IRQ_EXTI4 (STM32L4_IRQ_FIRST+10) /* 10: EXTI Line 4 interrupt */
-#define STM32L4_IRQ_DMA1CH1 (STM32L4_IRQ_FIRST+11) /* 12: DMA1 Channel 1 global interrupt */
-#define STM32L4_IRQ_DMA1CH2 (STM32L4_IRQ_FIRST+12) /* 13: DMA1 Channel 2 global interrupt */
-#define STM32L4_IRQ_DMA1CH3 (STM32L4_IRQ_FIRST+13) /* 14: DMA1 Channel 3 global interrupt */
-#define STM32L4_IRQ_DMA1CH4 (STM32L4_IRQ_FIRST+14) /* 15: DMA1 Channel 4 global interrupt */
-#define STM32L4_IRQ_DMA1CH5 (STM32L4_IRQ_FIRST+15) /* 16: DMA1 Channel 5 global interrupt */
-#define STM32L4_IRQ_DMA1CH6 (STM32L4_IRQ_FIRST+16) /* 17: DMA1 Channel 6 global interrupt */
+#define STM32L4_IRQ_DMA1CH1 (STM32L4_IRQ_FIRST+11) /* 11: DMA1 Channel 1 global interrupt */
+#define STM32L4_IRQ_DMA1CH2 (STM32L4_IRQ_FIRST+12) /* 12: DMA1 Channel 2 global interrupt */
+#define STM32L4_IRQ_DMA1CH3 (STM32L4_IRQ_FIRST+13) /* 13: DMA1 Channel 3 global interrupt */
+#define STM32L4_IRQ_DMA1CH4 (STM32L4_IRQ_FIRST+14) /* 14: DMA1 Channel 4 global interrupt */
+#define STM32L4_IRQ_DMA1CH5 (STM32L4_IRQ_FIRST+15) /* 15: DMA1 Channel 5 global interrupt */
+#define STM32L4_IRQ_DMA1CH6 (STM32L4_IRQ_FIRST+16) /* 16: DMA1 Channel 6 global interrupt */
#define STM32L4_IRQ_DMA1CH7 (STM32L4_IRQ_FIRST+17) /* 17: DMA1 Channel 7 global interrupt */
#define STM32L4_IRQ_ADC12 (STM32L4_IRQ_FIRST+18) /* 18: ADC1 and ADC2 global interrupt */
#define STM32L4_IRQ_CAN1TX (STM32L4_IRQ_FIRST+19) /* 19: CAN1 TX interrupts */
@@ -143,15 +143,34 @@
#define STM32L4_IRQ_TSC (STM32L4_IRQ_FIRST+77) /* 77: TSC global interrupt */
#define STM32L4_IRQ_LCD (STM32L4_IRQ_FIRST+78) /* 78: LCD global interrupt */
#define STM32L4_IRQ_AES (STM32L4_IRQ_FIRST+79) /* 79: AES crypto global interrupt */
-#define STM32L4_IRQ_RNG (STM32L4_IRQ_FIRST+80) /* 80: Rng global interrupt */
+#define STM32L4_IRQ_RNG (STM32L4_IRQ_FIRST+80) /* 80: RNG global interrupt */
#define STM32L4_IRQ_FPU (STM32L4_IRQ_FIRST+81) /* 81: FPU global interrupt */
-#define NR_INTERRUPTS 82
-#define NR_VECTORS (STM32L4_IRQ_FIRST+NR_INTERRUPTS)
+/* STM32L496xx/4A6xx only: */
+
+#define STM32L4_IRQ_HASH_CRS (STM32L4_IRQ_FIRST+82) /* 82: HASH and CRS global interrupt */
+#define STM32L4_IRQ_I2C4EV (STM32L4_IRQ_FIRST+83) /* 83: I2C4 event interrupt */
+#define STM32L4_IRQ_I2C4ER (STM32L4_IRQ_FIRST+84) /* 84: I2C4 error interrupt */
+#define STM32L4_IRQ_DCMI (STM32L4_IRQ_FIRST+85) /* 85: DCMI global interrupt */
+#define STM32L4_IRQ_CAN2TX (STM32L4_IRQ_FIRST+86) /* 86: CAN2 TX interrupts */
+#define STM32L4_IRQ_CAN2RX0 (STM32L4_IRQ_FIRST+87) /* 87: CAN2 RX0 interrupts */
+#define STM32L4_IRQ_CAN2RX1 (STM32L4_IRQ_FIRST+88) /* 88: CAN2 RX1 interrupt */
+#define STM32L4_IRQ_CAN2SCE (STM32L4_IRQ_FIRST+89) /* 89: CAN2 SCE interrupt */
+#define STM32L4_IRQ_DMA2D (STM32L4_IRQ_FIRST+90) /* 90: DMA2D global interrupt */
+
+#if defined(CONFIG_STM32L4_STM32L476XX) || defined(CONFIG_STM32L4_STM32L486XX)
+# define NR_INTERRUPTS 82
+#elif defined(CONFIG_STM32L4_STM32L496XX)
+# define NR_INTERRUPTS 91
+#else
+# error "Unsupported STM32L4 chip"
+#endif
+
+#define NR_VECTORS (STM32L4_IRQ_FIRST+NR_INTERRUPTS)
/* EXTI interrupts (Do not use IRQ numbers) */
-#define NR_IRQS NR_VECTORS
+#define NR_IRQS NR_VECTORS
/****************************************************************************************************
* Public Types
diff --git a/arch/arm/include/xmc4/chip.h b/arch/arm/include/xmc4/chip.h
new file mode 100644
index 0000000000000000000000000000000000000000..8ee065ffc369348cad3c100e3a0953ab87889db4
--- /dev/null
+++ b/arch/arm/include/xmc4/chip.h
@@ -0,0 +1,139 @@
+/************************************************************************************
+ * arch/arm/include/xmc4/chip.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_INCLUDE_XMC4_CHIP_H
+#define __ARCH_ARM_INCLUDE_XMC4_CHIP_H
+
+/************************************************************************************
+ * Included Files
+ ************************************************************************************/
+
+#include
+
+/************************************************************************************
+ * Pre-processor Definitions
+ ************************************************************************************/
+
+/* Get customizations for each supported chip */
+
+#if defined(CONFIG_ARCH_CHIP_XMC4500)
+# define XMC4_NUSIC 3 /* Three USIC modules: USCI0-2 */
+# undef XMC4_SCU_GATING /* No clock gating registers */
+# define XMC4_NECAT 0 /* No EtherCAT support */
+#elif defined(CONFIG_ARCH_CHIP_XMC4700)
+# define XMC4_NUSIC 3 /* Three USIC modules: USCI0-2 */
+# define XMC4_SCU_GATING 1 /* Has clock gating registers */
+# define XMC4_NECAT 0 /* No EtherCAT support */
+#elif defined(CONFIG_ARCH_CHIP_XMC4800)
+# define XMC4_NUSIC 3 /* Three USIC modules: USCI0-2 */
+# define XMC4_SCU_GATING 1 /* Has clock gating registers */
+# define XMC4_NECAT 1 /* One EtherCAT module */
+#else
+# error "Unsupported XMC4xxx chip"
+#endif
+
+/* NVIC priority levels *************************************************************/
+/* Each priority field holds a priority value. The lower the value, the greater the
+ * priority of the corresponding interrupt. The XMC4500 implements only bits[7:2]
+ * of this field, bits[1:0] read as zero and ignore writes.
+ */
+
+#define NVIC_SYSH_PRIORITY_MIN 0xfc /* All bits[7:2] set is minimum priority */
+#define NVIC_SYSH_PRIORITY_DEFAULT 0x80 /* Midpoint is the default */
+#define NVIC_SYSH_PRIORITY_MAX 0x00 /* Zero is maximum priority */
+#define NVIC_SYSH_PRIORITY_STEP 0x04 /* Steps between supported priority values */
+
+/* If CONFIG_ARMV7M_USEBASEPRI is selected, then interrupts will be disabled
+ * by setting the BASEPRI register to NVIC_SYSH_DISABLE_PRIORITY so that most
+ * interrupts will not have execution priority. SVCall must have execution
+ * priority in all cases.
+ *
+ * In the normal cases, interrupts are not nest-able and all interrupts run
+ * at an execution priority between NVIC_SYSH_PRIORITY_MIN and
+ * NVIC_SYSH_PRIORITY_MAX (with NVIC_SYSH_PRIORITY_MAX reserved for SVCall).
+ *
+ * If, in addition, CONFIG_ARCH_HIPRI_INTERRUPT is defined, then special
+ * high priority interrupts are supported. These are not "nested" in the
+ * normal sense of the word. These high priority interrupts can interrupt
+ * normal processing but execute outside of OS (although they can "get back
+ * into the game" via a PendSV interrupt).
+ *
+ * In the normal course of things, interrupts must occasionally be disabled
+ * using the up_irq_save() inline function to prevent contention in use of
+ * resources that may be shared between interrupt level and non-interrupt
+ * level logic. Now the question arises, if CONFIG_ARCH_HIPRI_INTERRUPT,
+ * do we disable all interrupts (except SVCall), or do we only disable the
+ * "normal" interrupts. Since the high priority interrupts cannot interact
+ * with the OS, you may want to permit the high priority interrupts even if
+ * interrupts are disabled. The setting CONFIG_ARCH_INT_DISABLEALL can be
+ * used to select either behavior:
+ *
+ * ----------------------------+--------------+----------------------------
+ * CONFIG_ARCH_HIPRI_INTERRUPT | NO | YES
+ * ----------------------------+--------------+--------------+-------------
+ * CONFIG_ARCH_INT_DISABLEALL | N/A | YES | NO
+ * ----------------------------+--------------+--------------+-------------
+ * | | | SVCall
+ * | SVCall | SVCall | HIGH
+ * Disable here and below --------> MAXNORMAL ---> HIGH --------> MAXNORMAL
+ * | | MAXNORMAL |
+ * ----------------------------+--------------+--------------+-------------
+ */
+
+#if defined(CONFIG_ARCH_HIPRI_INTERRUPT) && defined(CONFIG_ARCH_INT_DISABLEALL)
+# define NVIC_SYSH_MAXNORMAL_PRIORITY (NVIC_SYSH_PRIORITY_MAX + 2*NVIC_SYSH_PRIORITY_STEP)
+# define NVIC_SYSH_HIGH_PRIORITY (NVIC_SYSH_PRIORITY_MAX + NVIC_SYSH_PRIORITY_STEP)
+# define NVIC_SYSH_DISABLE_PRIORITY NVIC_SYSH_HIGH_PRIORITY
+# define NVIC_SYSH_SVCALL_PRIORITY NVIC_SYSH_PRIORITY_MAX
+#else
+# define NVIC_SYSH_MAXNORMAL_PRIORITY (NVIC_SYSH_PRIORITY_MAX + NVIC_SYSH_PRIORITY_STEP)
+# define NVIC_SYSH_HIGH_PRIORITY NVIC_SYSH_PRIORITY_MAX
+# define NVIC_SYSH_DISABLE_PRIORITY NVIC_SYSH_MAXNORMAL_PRIORITY
+# define NVIC_SYSH_SVCALL_PRIORITY NVIC_SYSH_PRIORITY_MAX
+#endif
+
+/************************************************************************************
+ * Public Types
+ ************************************************************************************/
+
+/************************************************************************************
+ * Public Data
+ ************************************************************************************/
+
+/************************************************************************************
+ * Public Functions
+ ************************************************************************************/
+
+#endif /* __ARCH_ARM_INCLUDE_XMC4_CHIP_H */
diff --git a/arch/arm/include/xmc4/irq.h b/arch/arm/include/xmc4/irq.h
new file mode 100644
index 0000000000000000000000000000000000000000..10fc176a43cb4a7fc27242aa09bda86cdb19623d
--- /dev/null
+++ b/arch/arm/include/xmc4/irq.h
@@ -0,0 +1,120 @@
+/****************************************************************************
+ * arch/arm/include/xmc4/irq.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.
+ *
+ ****************************************************************************/
+
+/* This file should never be included directed but, rather, only indirectly
+ * through nuttx/irq.h
+ */
+
+#ifndef __ARCH_ARM_INCLUDE_XMC4_IRQ_H
+#define __ARCH_ARM_INCLUDE_XMC4_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) */
+
+#define XMC4_IRQ_RESERVED (0) /* Reserved vector (only used with CONFIG_DEBUG_FEATURES) */
+ /* Vector 0: Reset stack pointer value */
+ /* Vector 1: Reset (not handler as an IRQ) */
+#define XMC4_IRQ_NMI (2) /* Vector 2: Non-Maskable Interrupt (NMI) */
+#define XMC4_IRQ_HARDFAULT (3) /* Vector 3: Hard fault */
+#define XMC4_IRQ_MEMFAULT (4) /* Vector 4: Memory management (MPU) */
+#define XMC4_IRQ_BUSFAULT (5) /* Vector 5: Bus fault */
+#define XMC4_IRQ_USAGEFAULT (6) /* Vector 6: Usage fault */
+ /* Vectors 7-10: Reserved */
+#define XMC4_IRQ_SVCALL (11) /* Vector 11: SVC call */
+#define XMC4_IRQ_DBGMONITOR (12) /* Vector 12: Debug Monitor */
+ /* Vector 13: Reserved */
+#define XMC4_IRQ_PENDSV (14) /* Vector 14: Pendable system service request */
+#define XMC4_IRQ_SYSTICK (15) /* Vector 15: System tick */
+
+/* External interrupts (vectors >= 16). These definitions are chip-specific */
+
+#define XMC4_IRQ_FIRST (16) /* Vector number of the first external interrupt */
+
+#if defined(CONFIG_ARCH_CHIP_XMC4500)
+# include
+#else
+ /* The interrupt vectors for other parts are defined in other documents and may or
+ * may not be the same as above (the family members are all very similar) This
+ * error just means that you have to look at the document and determine for yourself
+ * if the vectors are the same.
+ */
+
+# error "No IRQ numbers for this XMC4xxx part"
+#endif
+
+/************************************************************************************
+ * 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_XMC4_IRQ_H */
+
diff --git a/arch/arm/include/xmc4/xmc4500_irq.h b/arch/arm/include/xmc4/xmc4500_irq.h
new file mode 100644
index 0000000000000000000000000000000000000000..b35a1b3f8a2c0fa7ce9d9b95c8e6c9a1fd20af40
--- /dev/null
+++ b/arch/arm/include/xmc4/xmc4500_irq.h
@@ -0,0 +1,225 @@
+/*****************************************************************************
+ * arch/arm/include/xmc4/xmc4500_.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.
+ *
+ ****************************************************************************/
+
+/* This file should never be included directed but, rather, only indirectly
+ * through nuttx/irq.h
+ */
+
+#ifndef xmc4__ARCH_ARM_INCLUDE_XMC4_XM4500_IRQ_H
+#define xmc4__ARCH_ARM_INCLUDE_XMC4_XM4500_IRQ_H
+
+/*****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#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 the file nuttx/arch/arm/include/kinets/irq.h which includes this file
+ *
+ * External interrupts (vectors >= 16)
+ *
+ * Acronyms:
+ * ADC - Analog to Digital Converter
+ * CCU - Capture Compare Unit
+ * DAC - Digital to Analog Converter
+ * DSD - Delta Sigmoid Demodulator
+ * ERU - External Request Unit
+ * FCE - Flexible CRC Engine
+ * GPDMA - General Purpose DMA
+ * LEDTS - LED and Touch Sense Control Unit
+ * PMU - Program Management Unit
+ * POSIF - Position Interface
+ * SDMMC - Multi Media Card Interface
+ * USB - Universal Serial Bus
+ * USCI - Universal Serial Interface
+ */
+
+#define XMC4_IRQ_SCU (XMC4_IRQ_FIRST+0) /* 0: System Control */
+#define XMC4_IRQ_ERU0_SR0 (XMC4_IRQ_FIRST+1) /* 1: ERU0, SR0 */
+#define XMC4_IRQ_ERU0_SR1 (XMC4_IRQ_FIRST+2) /* 2: ERU0, SR1 */
+#define XMC4_IRQ_ERU0_SR2 (XMC4_IRQ_FIRST+3) /* 3: ERU0, SR2 */
+#define XMC4_IRQ_ERU0_SR3 (XMC4_IRQ_FIRST+4) /* 4: ERU0, SR3 */
+#define XMC4_IRQ_ERU1_SR0 (XMC4_IRQ_FIRST+5) /* 5: ERU1, SR0 */
+#define XMC4_IRQ_ERU1_SR1 (XMC4_IRQ_FIRST+6) /* 6: ERU1, SR1 */
+#define XMC4_IRQ_ERU1_SR2 (XMC4_IRQ_FIRST+7) /* 7: ERU1, SR2 */
+#define XMC4_IRQ_ERU1_SR3 (XMC4_IRQ_FIRST+8) /* 8: ERU1, SR3 */
+#define XMC4_IRQ_RESVD009 (XMC4_IRQ_FIRST+9) /* 9: Reserved */
+#define XMC4_IRQ_RESVD010 (XMC4_IRQ_FIRST+10) /* 10: Reserved */
+#define XMC4_IRQ_RESVD011 (XMC4_IRQ_FIRST+11) /* 11: Reserved */
+#define XMC4_IRQ_PMU1_SR0 (XMC4_IRQ_FIRST+12) /* 12: PMU, SR0 */
+#define XMC4_IRQ_RESVD011 (XMC4_IRQ_FIRST+13) /* 13: Reserved */
+#define XMC4_IRQ_VADC_COSR0 (XMC4_IRQ_FIRST+14) /* 14: ADC Common Block 0 */
+#define XMC4_IRQ_VADC_COSR1 (XMC4_IRQ_FIRST+15) /* 15: ADC Common Block 1 */
+#define XMC4_IRQ_VADC_COSR2 (XMC4_IRQ_FIRST+16) /* 16: ADC Common Block 2 */
+#define XMC4_IRQ_VADC_COSR3 (XMC4_IRQ_FIRST+17) /* 17: ADC Common Block 3 */
+#define XMC4_IRQ_VADC_GOSR0 (XMC4_IRQ_FIRST+18) /* 18: ADC Group 0, SR0 */
+#define XMC4_IRQ_VADC_GOSR1 (XMC4_IRQ_FIRST+19) /* 19: ADC Group 0, SR1 */
+#define XMC4_IRQ_VADC_GOSR2 (XMC4_IRQ_FIRST+20) /* 20: ADC Group 0, SR2 */
+#define XMC4_IRQ_VADC_GOSR3 (XMC4_IRQ_FIRST+21) /* 21: ADC Group 0, SR3 */
+#define XMC4_IRQ_VADC_G1SR0 (XMC4_IRQ_FIRST+22) /* 22: ADC Group 1, SR0 */
+#define XMC4_IRQ_VADC_G1SR1 (XMC4_IRQ_FIRST+23) /* 23: ADC Group 1, SR1 */
+#define XMC4_IRQ_VADC_G1SR2 (XMC4_IRQ_FIRST+24) /* 24: ADC Group 1, SR2 */
+#define XMC4_IRQ_VADC_G1SR3 (XMC4_IRQ_FIRST+25) /* 25: ADC Group 1, SR3 */
+#define XMC4_IRQ_VADC_G2SR0 (XMC4_IRQ_FIRST+26) /* 26: ADC Group 2, SR0 */
+#define XMC4_IRQ_VADC_G2SR1 (XMC4_IRQ_FIRST+27) /* 27: ADC Group 2, SR1 */
+#define XMC4_IRQ_VADC_G2SR2 (XMC4_IRQ_FIRST+28) /* 28: ADC Group 2, SR2 */
+#define XMC4_IRQ_VADC_G2SR3 (XMC4_IRQ_FIRST+29) /* 29: ADC Group 2, SR3 */
+#define XMC4_IRQ_VADC_G3SR0 (XMC4_IRQ_FIRST+30) /* 30: ADC Group 3, SR0 */
+#define XMC4_IRQ_VADC_G3SR1 (XMC4_IRQ_FIRST+31) /* 31: ADC Group 3, SR1 */
+#define XMC4_IRQ_VADC_G3SR2 (XMC4_IRQ_FIRST+32) /* 32: ADC Group 3, SR2 */
+#define XMC4_IRQ_VADC_G3SR3 (XMC4_IRQ_FIRST+33) /* 33: ADC Group 3, SR3 */
+#define XMC4_IRQ_DSD_SRM0 (XMC4_IRQ_FIRST+34) /* 34: DSD Main, SRM0 */
+#define XMC4_IRQ_DSD_SRM1 (XMC4_IRQ_FIRST+35) /* 35: DSD Main, SRM1 */
+#define XMC4_IRQ_DSD_SRM2 (XMC4_IRQ_FIRST+36) /* 36: DSD Main, SRM2 */
+#define XMC4_IRQ_DSD_SRM3 (XMC4_IRQ_FIRST+37) /* 37: DSD Main, SRM3 */
+#define XMC4_IRQ_DSD_SRA0 (XMC4_IRQ_FIRST+38) /* 38: DSD Auxiliary, SRA0 */
+#define XMC4_IRQ_DSD_SRA1 (XMC4_IRQ_FIRST+39) /* 39: DSD Auxiliary, SRA1 */
+#define XMC4_IRQ_DSD_SRA2 (XMC4_IRQ_FIRST+40) /* 40: DSD Auxiliary, SRA2 */
+#define XMC4_IRQ_DSD_SRA3 (XMC4_IRQ_FIRST+41) /* 41: DSD Auxiliary, SRA3 */
+#define XMC4_IRQ_DAC_SR0 (XMC4_IRQ_FIRST+42) /* 42: DAC, SR0 */
+#define XMC4_IRQ_DAC_SR1 (XMC4_IRQ_FIRST+43) /* 43: DAC, SR1 */
+#define XMC4_IRQ_CCU40_SR0 (XMC4_IRQ_FIRST+44) /* 44: CCU4 Module 0, SR0 */
+#define XMC4_IRQ_CCU40_SR1 (XMC4_IRQ_FIRST+45) /* 45: CCU4 Module 0, SR1 */
+#define XMC4_IRQ_CCU40_SR2 (XMC4_IRQ_FIRST+46) /* 46: CCU4 Module 0, SR2 */
+#define XMC4_IRQ_CCU40_SR3 (XMC4_IRQ_FIRST+47) /* 47: CCU4 Module 0, SR3 */
+#define XMC4_IRQ_CCU41_SR0 (XMC4_IRQ_FIRST+48) /* 48: CCU4 Module 1, SR0 */
+#define XMC4_IRQ_CCU41_SR1 (XMC4_IRQ_FIRST+49) /* 49: CCU4 Module 1, SR1 */
+#define XMC4_IRQ_CCU41_SR2 (XMC4_IRQ_FIRST+50) /* 50: CCU4 Module 1, SR2 */
+#define XMC4_IRQ_CCU41_SR3 (XMC4_IRQ_FIRST+51) /* 51: CCU4 Module 1, SR3 */
+#define XMC4_IRQ_CCU42_SR0 (XMC4_IRQ_FIRST+52) /* 52: CCU4 Module 2, SR0 */
+#define XMC4_IRQ_CCU42_SR1 (XMC4_IRQ_FIRST+53) /* 53: CCU4 Module 2, SR1 */
+#define XMC4_IRQ_CCU42_SR2 (XMC4_IRQ_FIRST+54) /* 54: CCU4 Module 2, SR2 */
+#define XMC4_IRQ_CCU42_SR3 (XMC4_IRQ_FIRST+55) /* 55: CCU4 Module 2, SR3 */
+#define XMC4_IRQ_CCU43_SR0 (XMC4_IRQ_FIRST+56) /* 56: CCU4 Module 3, SR0 */
+#define XMC4_IRQ_CCU43_SR1 (XMC4_IRQ_FIRST+57) /* 57: CCU4 Module 3, SR1 */
+#define XMC4_IRQ_CCU43_SR2 (XMC4_IRQ_FIRST+58) /* 58: CCU4 Module 3, SR2 */
+#define XMC4_IRQ_CCU43_SR3 (XMC4_IRQ_FIRST+59) /* 59: CCU4 Module 3, SR3 */
+#define XMC4_IRQ_CCU80_SR0 (XMC4_IRQ_FIRST+60) /* 60: CCU8 Module 0, SR0 */
+#define XMC4_IRQ_CCU80_SR1 (XMC4_IRQ_FIRST+61) /* 61: CCU8 Module 0, SR1 */
+#define XMC4_IRQ_CCU80_SR2 (XMC4_IRQ_FIRST+62) /* 62: CCU8 Module 0, SR2 */
+#define XMC4_IRQ_CCU80_SR3 (XMC4_IRQ_FIRST+63) /* 63: CCU8 Module 0, SR3 */
+#define XMC4_IRQ_CCU81_SR0 (XMC4_IRQ_FIRST+64) /* 64: CCU8 Module 1, SR0 */
+#define XMC4_IRQ_CCU81_SR1 (XMC4_IRQ_FIRST+65) /* 65: CCU8 Module 1, SR1 */
+#define XMC4_IRQ_CCU81_SR2 (XMC4_IRQ_FIRST+66) /* 66: CCU8 Module 1, SR2 */
+#define XMC4_IRQ_CCU81_SR3 (XMC4_IRQ_FIRST+67) /* 67: CCU8 Module 1, SR3 */
+#define XMC4_IRQ_POSIF0_SR0 (XMC4_IRQ_FIRST+68) /* 68: POSIF Module 0, SR0 */
+#define XMC4_IRQ_POSIF0_SR1 (XMC4_IRQ_FIRST+69) /* 69: POSIF Module 0, SR1 */
+#define XMC4_IRQ_POSIF1_SR0 (XMC4_IRQ_FIRST+70) /* 70: POSIF Module 1, SR0 */
+#define XMC4_IRQ_POSIF1_SR1 (XMC4_IRQ_FIRST+71) /* 71: POSIF Module 1, SR1 */
+#define XMC4_IRQ_RESVD072 (XMC4_IRQ_FIRST+72) /* 72: Reserved */
+#define XMC4_IRQ_RESVD073 (XMC4_IRQ_FIRST+73) /* 73: Reserved */
+#define XMC4_IRQ_RESVD074 (XMC4_IRQ_FIRST+74) /* 74: Reserved */
+#define XMC4_IRQ_RESVD075 (XMC4_IRQ_FIRST+75) /* 75: Reserved */
+#define XMC4_IRQ_CAN_SR0 (XMC4_IRQ_FIRST+76) /* 76: MultiCAN, SR0 */
+#define XMC4_IRQ_CAN_SR1 (XMC4_IRQ_FIRST+77) /* 77: MultiCAN, SR1 */
+#define XMC4_IRQ_CAN_SR2 (XMC4_IRQ_FIRST+78) /* 78: MultiCAN, SR2 */
+#define XMC4_IRQ_CAN_SR3 (XMC4_IRQ_FIRST+79) /* 79: MultiCAN, SR3 */
+#define XMC4_IRQ_CAN_SR4 (XMC4_IRQ_FIRST+80) /* 80: MultiCAN, SR4 */
+#define XMC4_IRQ_CAN_SR5 (XMC4_IRQ_FIRST+81) /* 81: MultiCAN, SR5 */
+#define XMC4_IRQ_CAN_SR6 (XMC4_IRQ_FIRST+82) /* 82: MultiCAN, SR6 */
+#define XMC4_IRQ_CAN_SR7 (XMC4_IRQ_FIRST+83) /* 83: MultiCAN, SR7 */
+#define XMC4_IRQ_USIC0_SR0 (XMC4_IRQ_FIRST+84) /* 84: USIC0 Channel, SR0 */
+#define XMC4_IRQ_USIC0_SR1 (XMC4_IRQ_FIRST+85) /* 85: USIC0 Channel, SR1 */
+#define XMC4_IRQ_USIC0_SR2 (XMC4_IRQ_FIRST+86) /* 86: USIC0 Channel, SR2 */
+#define XMC4_IRQ_USIC0_SR3 (XMC4_IRQ_FIRST+87) /* 87: USIC0 Channel, SR3 */
+#define XMC4_IRQ_USIC0_SR4 (XMC4_IRQ_FIRST+88) /* 88: USIC0 Channel, SR4 */
+#define XMC4_IRQ_USIC0_SR5 (XMC4_IRQ_FIRST+89) /* 89: USIC0 Channel, SR5 */
+#define XMC4_IRQ_USIC1_SR0 (XMC4_IRQ_FIRST+90) /* 90: USIC1 Channel, SR0 */
+#define XMC4_IRQ_USIC1_SR1 (XMC4_IRQ_FIRST+91) /* 91: USIC1 Channel, SR1 */
+#define XMC4_IRQ_USIC1_SR2 (XMC4_IRQ_FIRST+92) /* 92: USIC1 Channel, SR2 */
+#define XMC4_IRQ_USIC1_SR3 (XMC4_IRQ_FIRST+93) /* 93: USIC1 Channel, SR3 */
+#define XMC4_IRQ_USIC1_SR4 (XMC4_IRQ_FIRST+94) /* 94: USIC1 Channel, SR4 */
+#define XMC4_IRQ_USIC1_SR5 (XMC4_IRQ_FIRST+95) /* 95: USIC1 Channel, SR5 */
+#define XMC4_IRQ_USIC2_SR0 (XMC4_IRQ_FIRST+96) /* 96: USIC1 Channel, SR0 */
+#define XMC4_IRQ_USIC2_SR1 (XMC4_IRQ_FIRST+97) /* 97: USIC1 Channel, SR1 */
+#define XMC4_IRQ_USIC2_SR2 (XMC4_IRQ_FIRST+98) /* 98: USIC1 Channel, SR2 */
+#define XMC4_IRQ_USIC2_SR3 (XMC4_IRQ_FIRST+99) /* 99: USIC1 Channel, SR3 */
+#define XMC4_IRQ_USIC2_SR4 (XMC4_IRQ_FIRST+100) /* 100: USIC1 Channel, SR4 */
+#define XMC4_IRQ_USIC2_SR5 (XMC4_IRQ_FIRST+101) /* 101: USIC1 Channel, SR5 */
+#define XMC4_IRQ_LEDTS0_SR0 (XMC4_IRQ_FIRST+102) /* 102: LEDTS0, SR0 */
+#define XMC4_IRQ_RESVD103 (XMC4_IRQ_FIRST+103) /* 103: Reserved */
+#define XMC4_IRQ_FCR_SR0 (XMC4_IRQ_FIRST+104) /* 102: FCE, SR0 */
+#define XMC4_IRQ_GPCMA0_SR0 (XMC4_IRQ_FIRST+105) /* 105: GPDMA0, SR0 */
+#define XMC4_IRQ_SDMMC_SR0 (XMC4_IRQ_FIRST+106) /* 106: SDMMC, SR0 */
+#define XMC4_IRQ_USB0_SR0 (XMC4_IRQ_FIRST+107) /* 107: USB, SR0 */
+#define XMC4_IRQ_ETH0_SR0 (XMC4_IRQ_FIRST+108) /* 108: Ethernet, module 0, SR0 */
+#define XMC4_IRQ_ECAT0_SR0 (XMC4_IRQ_FIRST+109) /* 109: EtherCAT, module 0, SR0 */
+#define XMC4_IRQ_GPCMA1_SR0 (XMC4_IRQ_FIRST+110) /* 110: GPDMA1, SR0 */
+#define XMC4_IRQ_RESVD111 (XMC4_IRQ_FIRST+111) /* 111: Reserved */
+
+#define NR_INTERRUPTS 112 /* 112 Non core IRQs*/
+#define NR_VECTORS (XMC4_IRQ_FIRST+NR_INTERRUPTS) /* 118 vectors */
+
+/* GPIO IRQ interrupts -- To be provided */
+
+#define NR_IRQS NR_VECTORS
+
+/*****************************************************************************
+ * 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 /* xmc4__ARCH_ARM_INCLUDE_XMC4_XM4500_IRQ_H */
diff --git a/arch/arm/src/Makefile b/arch/arm/src/Makefile
index e505b956da59bb8a5ccedcdb8fedd24663697e36..9cdf5898fe0606e60282f088655cd349893a2ce5 100644
--- a/arch/arm/src/Makefile
+++ b/arch/arm/src/Makefile
@@ -172,10 +172,10 @@ VPATH += chip
VPATH += common
VPATH += $(ARCH_SUBDIR)
-ifeq ($(CONFIG_ARM_TOOLCHAIN_IAR),y)
+ifeq ($(CONFIG_ARCH_TOOLCHAIN_IAR),y)
VPATH += chip$(DELIM)iar
VPATH += $(ARCH_SUBDIR)$(DELIM)iar
-else # ifeq ($(CONFIG_ARM_TOOLCHAIN_GNU),y)
+else # ifeq ($(CONFIG_ARCH_TOOLCHAIN_GNU),y)
VPATH += chip$(DELIM)gnu
VPATH += $(ARCH_SUBDIR)$(DELIM)gnu
endif
diff --git a/arch/arm/src/a1x/a1x_irq.c b/arch/arm/src/a1x/a1x_irq.c
index ecabb5ff4d66b77df5f7bab603d6866da245a18f..21c074d83cadfeb7eec86af8301fba876bde7f26 100644
--- a/arch/arm/src/a1x/a1x_irq.c
+++ b/arch/arm/src/a1x/a1x_irq.c
@@ -159,16 +159,6 @@ void up_irqinitialize(void)
(void)getreg32(A1X_INTC_IRQ_PEND(i)); /* Reading status clears pending interrupts */
}
- /* Colorize the interrupt stack for debug purposes */
-
-#if defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 3
- {
- size_t intstack_size = (CONFIG_ARCH_INTERRUPTSTACK & ~3);
- up_stack_color((FAR void *)((uintptr_t)&g_intstackbase - intstack_size),
- intstack_size);
- }
-#endif
-
/* Set the interrupt base address to zero. We do not use the vectored
* interrupts.
*/
diff --git a/arch/arm/src/a1x/a1x_lowputc.c b/arch/arm/src/a1x/a1x_lowputc.c
index 0018c8888197ae7d2901031137662983e7ce71d8..e3f682da8806c994b0237845c617cc7a0b588e10 100644
--- a/arch/arm/src/a1x/a1x_lowputc.c
+++ b/arch/arm/src/a1x/a1x_lowputc.c
@@ -228,7 +228,7 @@ void a1x_lowsetup(void)
#warning Missing logic
/* Configure UART pins for the selected CONSOLE. If there are multiple
- * pin options for a given UART, the the applicable option must be
+ * pin options for a given UART, the applicable option must be
* disambiguated in the board.h header file.
*/
diff --git a/arch/arm/src/a1x/a1x_serial.c b/arch/arm/src/a1x/a1x_serial.c
index ec8de5e0090507c7175fe96dd1ed9f423a5c2c61..307dac2d5e0f7d9d1b18fe773488376bc968bbaa 100644
--- a/arch/arm/src/a1x/a1x_serial.c
+++ b/arch/arm/src/a1x/a1x_serial.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/a1x/a1x_serial.c
*
- * Copyright (C) 2013-2014 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2013-2014, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
*
* Redistribution and use in source and binary forms, with or without
@@ -1035,7 +1035,7 @@ static int up_attach(struct uart_dev_s *dev)
/* Attach and enable the IRQ */
- ret = irq_attach(priv->irq, uart_interrupt, priv);
+ ret = irq_attach(priv->irq, uart_interrupt, dev);
if (ret == OK)
{
/* Enable the interrupt (RX and TX interrupts are still disabled
@@ -1080,7 +1080,7 @@ static void up_detach(struct uart_dev_s *dev)
static int uart_interrupt(int irq, void *context, void *arg)
{
struct uart_dev_s *dev = (struct uart_dev_s *)arg;
- struct up_dev_s *priv = (struct up_dev_s *)arg;
+ struct up_dev_s *priv;
uint32_t status;
int passes;
diff --git a/arch/arm/src/armv6-m/Kconfig b/arch/arm/src/armv6-m/Kconfig
index ed56bc9a71e7f7b36730fc08ed420fafe6e0d45a..4a22655a0505f864b3d46842a0b1a93e94f418f2 100644
--- a/arch/arm/src/armv6-m/Kconfig
+++ b/arch/arm/src/armv6-m/Kconfig
@@ -13,33 +13,41 @@ choice
config ARMV6M_TOOLCHAIN_ATOLLIC
bool "Atollic Lite/Pro for Windows"
depends on TOOLCHAIN_WINDOWS
+ select ARCH_TOOLCHAIN_GNU
config ARMV6M_TOOLCHAIN_BUILDROOT
bool "Buildroot (Cygwin or Linux)"
depends on !WINDOWS_NATIVE
+ select ARCH_TOOLCHAIN_GNU
config ARMV6M_TOOLCHAIN_CODEREDL
bool "CodeRed for Linux"
depends on HOST_LINUX
+ select ARCH_TOOLCHAIN_GNU
config ARMV6M_TOOLCHAIN_CODEREDW
bool "CodeRed for Windows"
depends on TOOLCHAIN_WINDOWS
+ select ARCH_TOOLCHAIN_GNU
config ARMV6M_TOOLCHAIN_CODESOURCERYL
bool "CodeSourcery GNU toolchain under Linux"
depends on HOST_LINUX
+ select ARCH_TOOLCHAIN_GNU
config ARMV6M_TOOLCHAIN_CODESOURCERYW
bool "CodeSourcery GNU toolchain under Windows"
depends on TOOLCHAIN_WINDOWS
+ select ARCH_TOOLCHAIN_GNU
config ARMV6M_TOOLCHAIN_DEVKITARM
bool "devkitARM GNU toolchain"
depends on TOOLCHAIN_WINDOWS
+ select ARCH_TOOLCHAIN_GNU
config ARMV6M_TOOLCHAIN_GNU_EABIL
bool "Generic GNU EABI toolchain under Linux (or other POSIX environment)"
+ select ARCH_TOOLCHAIN_GNU
---help---
This option should work for any modern GNU toolchain (GCC 4.5 or newer)
configured for arm-none-eabi.
@@ -47,6 +55,7 @@ config ARMV6M_TOOLCHAIN_GNU_EABIL
config ARMV6M_TOOLCHAIN_GNU_EABIW
bool "Generic GNU EABI toolchain under Windows"
depends on TOOLCHAIN_WINDOWS
+ select ARCH_TOOLCHAIN_GNU
---help---
This option should work for any modern GNU toolchain (GCC 4.5 or newer)
configured for arm-none-eabi.
diff --git a/arch/arm/src/armv7-a/Kconfig b/arch/arm/src/armv7-a/Kconfig
index e4746900a3fb81a0e821bb37fedc80986deb4e7d..a8dc919e353ba2d878bfa957f2fd2024bba34b38 100644
--- a/arch/arm/src/armv7-a/Kconfig
+++ b/arch/arm/src/armv7-a/Kconfig
@@ -133,12 +133,12 @@ choice
config ARMV7A_TOOLCHAIN_BUILDROOT
bool "Buildroot (Cygwin or Linux)"
- select ARM_TOOLCHAIN_GNU
+ select ARCH_TOOLCHAIN_GNU
depends on !WINDOWS_NATIVE
config ARMV7A_TOOLCHAIN_CODESOURCERYL
bool "CodeSourcery GNU toolchain under Linux"
- select ARM_TOOLCHAIN_GNU
+ select ARCH_TOOLCHAIN_GNU
depends on HOST_LINUX
---help---
For use with the GNU toolchain built with the NuttX buildroot package.
@@ -147,24 +147,24 @@ config ARMV7A_TOOLCHAIN_CODESOURCERYL
config ARMV7A_TOOLCHAIN_CODESOURCERYW
bool "CodeSourcery GNU toolchain under Windows"
- select ARM_TOOLCHAIN_GNU
+ select ARCH_TOOLCHAIN_GNU
depends on TOOLCHAIN_WINDOWS
config ARMV7A_TOOLCHAIN_DEVKITARM
bool "devkitARM GNU toolchain"
- select ARM_TOOLCHAIN_GNU
+ select ARCH_TOOLCHAIN_GNU
depends on TOOLCHAIN_WINDOWS
config ARMV7A_TOOLCHAIN_GNU_EABIL
bool "Generic GNU EABI toolchain under Linux (or other POSIX environment)"
- select ARM_TOOLCHAIN_GNU
+ select ARCH_TOOLCHAIN_GNU
---help---
This option should work for any modern GNU toolchain (GCC 4.5 or newer)
configured for arm-none-eabi-.
config ARMV7A_TOOLCHAIN_GNU_EABIW
bool "Generic GNU EABI toolchain under Windows"
- select ARM_TOOLCHAIN_GNU
+ select ARCH_TOOLCHAIN_GNU
depends on TOOLCHAIN_WINDOWS
---help---
This option should work for any modern GNU toolchain (GCC 4.5 or newer)
@@ -172,7 +172,7 @@ config ARMV7A_TOOLCHAIN_GNU_EABIW
config ARMV7A_TOOLCHAIN_GNU_OABI
bool "Generic GNU OABI toolchain"
- select ARM_TOOLCHAIN_GNU
+ select ARCH_TOOLCHAIN_GNU
---help---
This option should work for any GNU toolchain configured for arm-elf-.
diff --git a/arch/arm/src/armv7-a/arm_addrenv.c b/arch/arm/src/armv7-a/arm_addrenv.c
index 7d2818283dca2d1148ea3ecb01c9c4b66fae85a0..def1ea66d9be34d1ee9b41e8273ccc7bb2d4e7be 100644
--- a/arch/arm/src/armv7-a/arm_addrenv.c
+++ b/arch/arm/src/armv7-a/arm_addrenv.c
@@ -149,7 +149,7 @@
* Name: up_addrenv_initdata
*
* Description:
- * Initialize the region of memory at the the beginning of the .bss/.data
+ * Initialize the region of memory at the beginning of the .bss/.data
* region that is shared between the user process and the kernel.
*
****************************************************************************/
diff --git a/arch/arm/src/armv7-a/arm_gicv2.c b/arch/arm/src/armv7-a/arm_gicv2.c
index ec32fa5271072f011e78732f7514b125f2abfe95..0232685dc828fa01fde4bddc51a3cd5b7f189655 100644
--- a/arch/arm/src/armv7-a/arm_gicv2.c
+++ b/arch/arm/src/armv7-a/arm_gicv2.c
@@ -298,7 +298,7 @@ void arm_gic_initialize(void)
#endif
#if !defined(CONFIG_ARCH_HAVE_TRUSTZONE)
- /* Enable the distributor by setting the the Enable bit in the enable
+ /* Enable the distributor by setting the Enable bit in the enable
* register (no security extensions).
*/
diff --git a/arch/arm/src/armv7-a/pgalloc.h b/arch/arm/src/armv7-a/pgalloc.h
index 32436cf362ef809e64aa21418ab4287b8c2a2931..485cc666d4fedd8044c1e2d66fb5cc28285007ec 100644
--- a/arch/arm/src/armv7-a/pgalloc.h
+++ b/arch/arm/src/armv7-a/pgalloc.h
@@ -102,7 +102,7 @@ static inline void arm_tmprestore(uint32_t l1save)
*
* Description:
* If the page memory pool is statically mapped, then we do not have to
- * go through the the temporary mapping. We simply have to perform a
+ * go through the temporary mapping. We simply have to perform a
* physical to virtual memory address mapping.
*
****************************************************************************/
diff --git a/arch/arm/src/armv7-m/Kconfig b/arch/arm/src/armv7-m/Kconfig
index 4c66b55d54d2f55a97b2b1d4a15e566f8c3ed6d6..381725e0060999782a99c6cccc29d7d2974751b7 100644
--- a/arch/arm/src/armv7-m/Kconfig
+++ b/arch/arm/src/armv7-m/Kconfig
@@ -54,52 +54,52 @@ choice
config ARMV7M_TOOLCHAIN_IARW
bool "IAR for Windows"
depends on TOOLCHAIN_WINDOWS
- select ARM_TOOLCHAIN_IAR
+ select ARCH_TOOLCHAIN_IAR
config ARMV7M_TOOLCHAIN_IARL
bool "IAR for Linux"
depends on HOST_LINUX
- select ARM_TOOLCHAIN_IAR
+ select ARCH_TOOLCHAIN_IAR
config ARMV7M_TOOLCHAIN_ATOLLIC
bool "Atollic Lite/Pro for Windows"
depends on TOOLCHAIN_WINDOWS
- select ARM_TOOLCHAIN_GNU
+ select ARCH_TOOLCHAIN_GNU
config ARMV7M_TOOLCHAIN_BUILDROOT
bool "Buildroot (Cygwin or Linux)"
depends on !WINDOWS_NATIVE
- select ARM_TOOLCHAIN_GNU
+ select ARCH_TOOLCHAIN_GNU
config ARMV7M_TOOLCHAIN_CODEREDL
bool "CodeRed for Linux"
depends on HOST_LINUX
- select ARM_TOOLCHAIN_GNU
+ select ARCH_TOOLCHAIN_GNU
config ARMV7M_TOOLCHAIN_CODEREDW
bool "CodeRed for Windows"
depends on TOOLCHAIN_WINDOWS
- select ARM_TOOLCHAIN_GNU
+ select ARCH_TOOLCHAIN_GNU
config ARMV7M_TOOLCHAIN_CODESOURCERYL
bool "CodeSourcery GNU toolchain under Linux"
depends on HOST_LINUX
- select ARM_TOOLCHAIN_GNU
+ select ARCH_TOOLCHAIN_GNU
config ARMV7M_TOOLCHAIN_CODESOURCERYW
bool "CodeSourcery GNU toolchain under Windows"
depends on TOOLCHAIN_WINDOWS
- select ARM_TOOLCHAIN_GNU
+ select ARCH_TOOLCHAIN_GNU
config ARMV7M_TOOLCHAIN_DEVKITARM
bool "devkitARM GNU toolchain"
depends on TOOLCHAIN_WINDOWS
- select ARM_TOOLCHAIN_GNU
+ select ARCH_TOOLCHAIN_GNU
config ARMV7M_TOOLCHAIN_GNU_EABIL
bool "Generic GNU EABI toolchain under Linux (or other POSIX environment)"
depends on !WINDOWS_NATIVE
- select ARM_TOOLCHAIN_GNU
+ select ARCH_TOOLCHAIN_GNU
---help---
This option should work for any modern GNU toolchain (GCC 4.5 or newer)
configured for arm-none-eabi.
@@ -107,7 +107,7 @@ config ARMV7M_TOOLCHAIN_GNU_EABIL
config ARMV7M_TOOLCHAIN_GNU_EABIW
bool "Generic GNU EABI toolchain under Windows"
depends on TOOLCHAIN_WINDOWS
- select ARM_TOOLCHAIN_GNU
+ select ARCH_TOOLCHAIN_GNU
---help---
This option should work for any modern GNU toolchain (GCC 4.5 or newer)
configured for arm-none-eabi.
@@ -115,7 +115,7 @@ config ARMV7M_TOOLCHAIN_GNU_EABIW
config ARMV7M_TOOLCHAIN_RAISONANCE
bool "STMicro Raisonance for Windows"
depends on TOOLCHAIN_WINDOWS
- select ARM_TOOLCHAIN_GNU
+ select ARCH_TOOLCHAIN_GNU
endchoice
diff --git a/arch/arm/src/armv7-m/gnu/up_exception.S b/arch/arm/src/armv7-m/gnu/up_exception.S
index 0010136b0357a0f2424c4b99148921d1fb4f35db..81096aaefed5bfde7ecc1f9cc950b2dd165d2375 100644
--- a/arch/arm/src/armv7-m/gnu/up_exception.S
+++ b/arch/arm/src/armv7-m/gnu/up_exception.S
@@ -60,7 +60,7 @@
* stale MSP, there will most likely be a system failure.
*
* If the interrupt stack is selected, on the other hand, then the interrupt
- * handler will always set the the MSP to the interrupt stack. So when the high
+ * handler will always set the MSP to the interrupt stack. So when the high
* priority interrupt occurs, it will either use the MSP of the last privileged
* thread to run or, in the case of the nested interrupt, the interrupt stack if
* no privileged task has run.
@@ -70,7 +70,7 @@
# error Interrupt stack must be used with high priority interrupts in kernel mode
# endif
- /* Use the the BASEPRI to control interrupts is required if nested, high
+ /* Use the BASEPRI to control interrupts is required if nested, high
* priority interrupts are supported.
*/
@@ -323,7 +323,7 @@ exception_common:
.global g_intstackbase
.align 8
g_intstackalloc:
- .skip (CONFIG_ARCH_INTERRUPTSTACK & ~7)
+ .skip ((CONFIG_ARCH_INTERRUPTSTACK + 4) & ~7)
g_intstackbase:
.size g_intstackalloc, .-g_intstackalloc
#endif
diff --git a/arch/arm/src/armv7-m/gnu/up_lazyexception.S b/arch/arm/src/armv7-m/gnu/up_lazyexception.S
index 08ce8be75cca0f0755b27753ecc6972c6faf165b..852883aa22c06ea1d66d350a805295f21f1126a0 100644
--- a/arch/arm/src/armv7-m/gnu/up_lazyexception.S
+++ b/arch/arm/src/armv7-m/gnu/up_lazyexception.S
@@ -58,7 +58,7 @@
* interrupt occurs and uses this stale MSP, there will most likely be a system failure.
*
* If the interrupt stack is selected, on the other hand, then the interrupt handler will
- * always set the the MSP to the interrupt stack. So when the high priority interrupt occurs,
+ * always set the MSP to the interrupt stack. So when the high priority interrupt occurs,
* it will either use the MSP of the last privileged thread to run or, in the case of the
* nested interrupt, the interrupt stack if no privileged task has run.
*/
@@ -67,7 +67,7 @@
# error Interrupt stack must be used with high priority interrupts in kernel mode
# endif
- /* Use the the BASEPRI to control interrupts is required if nested, high
+ /* Use the BASEPRI to control interrupts is required if nested, high
* priority interrupts are supported.
*/
@@ -235,7 +235,7 @@ exception_common:
*
* Here:
* r0 = Address of the register save area
-
+ *
* NOTE: It is a requirement that up_restorefpu() preserve the value of
* r0!
*/
@@ -355,7 +355,7 @@ exception_common:
.global g_intstackbase
.align 8
g_intstackalloc:
- .skip (CONFIG_ARCH_INTERRUPTSTACK & ~7)
+ .skip ((CONFIG_ARCH_INTERRUPTSTACK + 4) & ~7)
g_intstackbase:
.size g_intstackalloc, .-g_intstackalloc
#endif
diff --git a/arch/arm/src/armv7-r/Kconfig b/arch/arm/src/armv7-r/Kconfig
index b4ec974db03d58b0a67a10b2eb5bb7c66ae7b6db..f5ce353584a3e34c7fc2d17a264f7e3c0da785fd 100644
--- a/arch/arm/src/armv7-r/Kconfig
+++ b/arch/arm/src/armv7-r/Kconfig
@@ -149,12 +149,12 @@ choice
config ARMV7R_TOOLCHAIN_BUILDROOT
bool "Buildroot (Cygwin or Linux)"
- select ARM_TOOLCHAIN_GNU
+ select ARCH_TOOLCHAIN_GNU
depends on !WINDOWS_NATIVE
config ARMV7R_TOOLCHAIN_CODESOURCERYL
bool "CodeSourcery GNU toolchain under Linux"
- select ARM_TOOLCHAIN_GNU
+ select ARCH_TOOLCHAIN_GNU
depends on HOST_LINUX
---help---
For use with the GNU toolchain built with the NuttX buildroot package.
@@ -163,24 +163,24 @@ config ARMV7R_TOOLCHAIN_CODESOURCERYL
config ARMV7R_TOOLCHAIN_CODESOURCERYW
bool "CodeSourcery GNU toolchain under Windows"
- select ARM_TOOLCHAIN_GNU
+ select ARCH_TOOLCHAIN_GNU
depends on TOOLCHAIN_WINDOWS
config ARMV7R_TOOLCHAIN_DEVKITARM
bool "devkitARM GNU toolchain"
- select ARM_TOOLCHAIN_GNU
+ select ARCH_TOOLCHAIN_GNU
depends on TOOLCHAIN_WINDOWS
config ARMV7R_TOOLCHAIN_GNU_EABIL
bool "Generic GNU EABI toolchain under Linux (or other POSIX environment)"
- select ARM_TOOLCHAIN_GNU
+ select ARCH_TOOLCHAIN_GNU
---help---
This option should work for any modern GNU toolchain (GCC 4.5 or newer)
configured for arm-none-eabi-.
config ARMV7R_TOOLCHAIN_GNU_EABIW
bool "Generic GNU EABI toolchain under Windows"
- select ARM_TOOLCHAIN_GNU
+ select ARCH_TOOLCHAIN_GNU
depends on TOOLCHAIN_WINDOWS
---help---
This option should work for any modern GNU toolchain (GCC 4.5 or newer)
@@ -188,7 +188,7 @@ config ARMV7R_TOOLCHAIN_GNU_EABIW
config ARMV7R_TOOLCHAIN_GNU_OABI
bool "Generic GNU OABI toolchain"
- select ARM_TOOLCHAIN_GNU
+ select ARCH_TOOLCHAIN_GNU
---help---
This option should work for any GNU toolchain configured for arm-elf-.
diff --git a/arch/arm/src/c5471/c5471_ethernet.c b/arch/arm/src/c5471/c5471_ethernet.c
index 03ddbe33837179b224215d5e7b10c658beacfc6d..b98fd6ecac9eb28e3615c24b167d58b474ba5b43 100644
--- a/arch/arm/src/c5471/c5471_ethernet.c
+++ b/arch/arm/src/c5471/c5471_ethernet.c
@@ -2364,7 +2364,7 @@ static void c5471_reset(struct c5471_driver_s *priv)
static void c5471_macassign(struct c5471_driver_s *priv)
{
struct net_driver_s *dev = &priv->c_dev;
- uint8_t *mptr = dev->d_mac.ether_addr_octet;
+ uint8_t *mptr = dev->d_mac.ether.ether_addr_octet;
register uint32_t tmp;
ninfo("MAC: %0x:%0x:%0x:%0x:%0x:%0x\n",
diff --git a/arch/arm/src/common/up_createstack.c b/arch/arm/src/common/up_createstack.c
index 70d83a83a58ac63a42569869836ba0f42f3f07f3..4503e15532ea215e61165697656098395ba092fd 100644
--- a/arch/arm/src/common/up_createstack.c
+++ b/arch/arm/src/common/up_createstack.c
@@ -66,22 +66,11 @@
# define HAVE_KERNEL_HEAP 1
#endif
-/* ARM requires at least a 4-byte stack alignment. For use with EABI and
- * floating point, the stack must be aligned to 8-byte addresses.
+/* For use with EABI and floating point, the stack must be aligned to 8-byte
+ * addresses.
*/
-#ifndef CONFIG_STACK_ALIGNMENT
-
-/* The symbol __ARM_EABI__ is defined by GCC if EABI is being used. If you
- * are not using GCC, make sure that CONFIG_STACK_ALIGNMENT is set correctly!
- */
-
-# ifdef __ARM_EABI__
-# define CONFIG_STACK_ALIGNMENT 8
-# else
-# define CONFIG_STACK_ALIGNMENT 4
-# endif
-#endif
+#define CONFIG_STACK_ALIGNMENT 8
/* Stack alignment macros */
@@ -233,9 +222,9 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype)
top_of_stack = (uint32_t)tcb->stack_alloc_ptr + stack_size - 4;
- /* The ARM stack must be aligned; 4 byte alignment for OABI and
- * 8-byte alignment for EABI. If necessary top_of_stack must be
- * rounded down to the next boundary
+ /* The ARM stack must be aligned to 8-byte alignment for EABI.
+ * If necessary top_of_stack must be rounded down to the next
+ * boundary
*/
top_of_stack = STACK_ALIGN_DOWN(top_of_stack);
diff --git a/arch/arm/src/common/up_initialize.c b/arch/arm/src/common/up_initialize.c
index 5182598246ada2b35f3cdd4ebb1e4c1635419d43..4b6cfe00df1b6d5b801fc45534f23c2458f1354c 100644
--- a/arch/arm/src/common/up_initialize.c
+++ b/arch/arm/src/common/up_initialize.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/common/up_initialize.c
*
- * Copyright (C) 2007-2010, 2012-2016 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2010, 2012-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
*
* Redistribution and use in source and binary forms, with or without
@@ -44,6 +44,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -190,9 +191,14 @@ void up_initialize(void)
arm_timer_initialize();
#endif
- /* Register devices */
+#ifdef CONFIG_MM_IOB
+ /* Initialize IO buffering */
+
+ iob_initialize();
+#endif
#if CONFIG_NFILE_DESCRIPTORS > 0
+ /* Register devices */
#if defined(CONFIG_DEV_NULL)
devnull_register(); /* Standard /dev/null */
diff --git a/arch/arm/src/common/up_stackframe.c b/arch/arm/src/common/up_stackframe.c
index b5712b2a291494d18d3e128a31fdc1432392e131..dace2e9239fa7f4071a5e4ca3491271d9e0d4261 100644
--- a/arch/arm/src/common/up_stackframe.c
+++ b/arch/arm/src/common/up_stackframe.c
@@ -53,22 +53,11 @@
* Pre-processor Macros
****************************************************************************/
-/* ARM requires at least a 4-byte stack alignment. For use with EABI and
- * floating point, the stack must be aligned to 8-byte addresses.
+/* For use with EABI and floating point, the stack must be aligned to 8-byte
+ * addresses.
*/
-#ifndef CONFIG_STACK_ALIGNMENT
-
-/* The symbol __ARM_EABI__ is defined by GCC if EABI is being used. If you
- * are not using GCC, make sure that CONFIG_STACK_ALIGNMENT is set correctly!
- */
-
-# ifdef __ARM_EABI__
-# define CONFIG_STACK_ALIGNMENT 8
-# else
-# define CONFIG_STACK_ALIGNMENT 4
-# endif
-#endif
+#define CONFIG_STACK_ALIGNMENT 8
/* Stack alignment macros */
diff --git a/arch/arm/src/common/up_udelay.c b/arch/arm/src/common/up_udelay.c
index e1a19445f041a1cd419c725dce42c7690ff915aa..9e3115b2019e8b140f640a10f54cdf1fd6a9a6a0 100644
--- a/arch/arm/src/common/up_udelay.c
+++ b/arch/arm/src/common/up_udelay.c
@@ -59,7 +59,7 @@
* Description:
* Delay inline for the requested number of microseconds. NOTE: Because
* of all of the setup, several microseconds will be lost before the actual
- * timing looop begins. Thus, the delay will always be a few microseconds
+ * timing loop begins. Thus, the delay will always be a few microseconds
* longer than requested.
*
* *** NOT multi-tasking friendly ***
diff --git a/arch/arm/src/common/up_usestack.c b/arch/arm/src/common/up_usestack.c
index 887387976aeb27703b2e41d4ed40135c69171946..f8072a66d4e177994f82a9532cade3fafd274ad2 100644
--- a/arch/arm/src/common/up_usestack.c
+++ b/arch/arm/src/common/up_usestack.c
@@ -56,22 +56,11 @@
* Pre-processor Macros
****************************************************************************/
-/* ARM requires at least a 4-byte stack alignment. For use with EABI and
- * floating point, the stack must be aligned to 8-byte addresses.
+/* For use with EABI and floating point, the stack must be aligned to 8-byte
+ * addresses.
*/
-#ifndef CONFIG_STACK_ALIGNMENT
-
-/* The symbol __ARM_EABI__ is defined by GCC if EABI is being used. If you
- * are not using GCC, make sure that CONFIG_STACK_ALIGNMENT is set correctly!
- */
-
-# ifdef __ARM_EABI__
-# define CONFIG_STACK_ALIGNMENT 8
-# else
-# define CONFIG_STACK_ALIGNMENT 4
-# endif
-#endif
+#define CONFIG_STACK_ALIGNMENT 8
/* Stack alignment macros */
@@ -143,9 +132,9 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size)
top_of_stack = (uint32_t)tcb->stack_alloc_ptr + stack_size - 4;
- /* The ARM stack must be aligned; 4 byte alignment for OABI and 8-byte
- * alignment for EABI. If necessary top_of_stack must be rounded down
- * to the next boundary
+ /* The ARM stack must be aligned to 8-byte alignment for EABI.
+ * If necessary top_of_stack must be rounded down to the next
+ * boundary
*/
top_of_stack = STACK_ALIGN_DOWN(top_of_stack);
diff --git a/arch/arm/src/common/up_vfork.c b/arch/arm/src/common/up_vfork.c
index e655ab15b43c1648777e5f454ddcf04faec162f5..5a69e310e3815d92adb927e505fa9d283d132c7b 100644
--- a/arch/arm/src/common/up_vfork.c
+++ b/arch/arm/src/common/up_vfork.c
@@ -56,22 +56,11 @@
* Pre-processor Definitions
****************************************************************************/
-/* ARM requires at least a 4-byte stack alignment. For use with EABI and
- * floating point, the stack must be aligned to 8-byte addresses.
+/* For use with EABI and floating point, the stack must be aligned to 8-byte
+ * addresses.
*/
-#ifndef CONFIG_STACK_ALIGNMENT
-
-/* The symbol __ARM_EABI__ is defined by GCC if EABI is being used. If you
- * are not using GCC, make sure that CONFIG_STACK_ALIGNMENT is set correctly!
- */
-
-# ifdef __ARM_EABI__
-# define CONFIG_STACK_ALIGNMENT 8
-# else
-# define CONFIG_STACK_ALIGNMENT 4
-# endif
-#endif
+#define CONFIG_STACK_ALIGNMENT 8
/****************************************************************************
* Public Functions
diff --git a/arch/arm/src/efm32/efm32_dma.h b/arch/arm/src/efm32/efm32_dma.h
index 011a7d987421d0ce823c77dfeb6b9890aecb000a..813b30bf703d4cfb63b6e67a150001aefe0fea3d 100644
--- a/arch/arm/src/efm32/efm32_dma.h
+++ b/arch/arm/src/efm32/efm32_dma.h
@@ -96,7 +96,7 @@
typedef FAR void *DMA_HANDLE;
/* Description:
- * This is the type of the callback that is used to inform the user of the the
+ * This is the type of the callback that is used to inform the user of the
* completion of the DMA.
*
* Input Parameters:
diff --git a/arch/arm/src/efm32/efm32_i2c.c b/arch/arm/src/efm32/efm32_i2c.c
index 59ad3aa2f840ac2ba12c71d2eead750b54b06472..6b14038a77b0d82105c927c5392dbb412f30ab2a 100644
--- a/arch/arm/src/efm32/efm32_i2c.c
+++ b/arch/arm/src/efm32/efm32_i2c.c
@@ -220,7 +220,6 @@ 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 *, void *); /* Interrupt handler */
uint32_t irq; /* Event IRQ */
#endif
};
@@ -294,15 +293,10 @@ static void efm32_i2c_tracedump(FAR struct efm32_i2c_priv_s *priv);
static void efm32_i2c_setclock(FAR struct efm32_i2c_priv_s *priv,
uint32_t frequency);
-static int efm32_i2c_isr(struct efm32_i2c_priv_s *priv);
+static int efm32_i2c_isr_process(struct efm32_i2c_priv_s *priv);
#ifndef CONFIG_I2C_POLLED
-#ifdef CONFIG_EFM32_I2C0
-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, FAR void *arg);
-#endif
+static int efm32_i2c_isr(int irq, void *context, FAR void *arg);
#endif /* !CONFIG_I2C_POLLED */
static void efm32_i2c_hwreset(FAR struct efm32_i2c_priv_s *priv);
@@ -343,7 +337,6 @@ static const struct efm32_i2c_config_s efm32_i2c0_config =
.scl_pin = BOARD_I2C0_SCL,
.sda_pin = BOARD_I2C0_SDA,
#ifndef CONFIG_I2C_POLLED
- .isr = efm32_i2c0_isr,
.irq = EFM32_IRQ_I2C0
#endif
};
@@ -371,7 +364,6 @@ static const struct efm32_i2c_config_s efm32_i2c1_config =
.scl_pin = BOARD_I2C1_SCL,
.sda_pin = BOARD_I2C1_SDA,
#ifndef CONFIG_I2C_POLLED
- .isr = efm32_i2c1_isr,
.irq = EFM32_IRQ_I2C1
#endif
};
@@ -553,7 +545,7 @@ static inline int efm32_i2c_sem_waitdone(FAR struct efm32_i2c_priv_s *priv)
#ifdef CONFIG_EFM32_I2C_DYNTIMEO
abstime.tv_nsec += 1000 * efm32_i2c_tousecs(priv->msgc, priv->msgv);
- if (abstime.tv_nsec > 1000 * 1000 * 1000)
+ if (abstime.tv_nsec >= 1000 * 1000 * 1000)
{
abstime.tv_sec++;
abstime.tv_nsec -= 1000 * 1000 * 1000;
@@ -561,7 +553,7 @@ static inline int efm32_i2c_sem_waitdone(FAR struct efm32_i2c_priv_s *priv)
#elif CONFIG_EFM32_I2CTIMEOMS > 0
abstime.tv_nsec += CONFIG_EFM32_I2CTIMEOMS * 1000 * 1000;
- if (abstime.tv_nsec > 1000 * 1000 * 1000)
+ if (abstime.tv_nsec >= 1000 * 1000 * 1000)
{
abstime.tv_sec++;
abstime.tv_nsec -= 1000 * 1000 * 1000;
@@ -632,7 +624,7 @@ static inline int efm32_i2c_sem_waitdone(FAR struct efm32_i2c_priv_s *priv)
* that it is done.
*/
- efm32_i2c_isr(priv);
+ efm32_i2c_isr_process(priv);
/* Calculate the elapsed time */
@@ -869,14 +861,14 @@ static void efm32_i2c_setclock(FAR struct efm32_i2c_priv_s *priv,
}
/****************************************************************************
- * Name: efm32_i2c_isr
+ * Name: efm32_i2c_isr_process
*
* Description:
* Common Interrupt Service Routine
*
****************************************************************************/
-static int efm32_i2c_isr(struct efm32_i2c_priv_s *priv)
+static int efm32_i2c_isr_process(struct efm32_i2c_priv_s *priv)
{
for (; ; )
{
@@ -1279,44 +1271,24 @@ done:
return OK;
}
-#ifndef CONFIG_I2C_POLLED
-
/****************************************************************************
- * Name: efm32_i2c0_isr
+ * Name: efm32_i2c_isr
*
* Description:
- * I2C0 interrupt service routine
+ * Common I2C interrupt service routine
*
****************************************************************************/
-#ifdef CONFIG_EFM32_I2C0
-static int efm32_i2c0_isr(int irq, void *context, FAR void *arg)
+#ifndef CONFIG_I2C_POLLED
+static int efm32_i2c_isr(int irq, void *context, FAR void *arg)
{
- return efm32_i2c_isr(&efm32_i2c0_priv);
-}
-#endif
+ struct efm32_i2c_priv_s *priv = (struct efm32_i2c_priv_s *)arg;
-/****************************************************************************
- * Name: efm32_i2c1_isr
- *
- * Description:
- * I2C1 interrupt service routine
- *
- ****************************************************************************/
-
-#ifdef CONFIG_EFM32_I2C1
-static int efm32_i2c1_isr(int irq, void *context, FAR void *arg)
-{
- return efm32_i2c_isr(&efm32_i2c1_priv);
+ DEBUGASSERT(priv != NULL);
+ return efm32_i2c_isr_process(priv);
}
#endif
-#endif
-
-/****************************************************************************
- * Private Initialization and Deinitialization
- ****************************************************************************/
-
/****************************************************************************
* Name: efm32_i2c_hwreset
*
@@ -1389,7 +1361,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, NULL);
+ irq_attach(priv->config->irq, efm32_i2c_isr, priv);
up_enable_irq(priv->config->irq);
#endif
@@ -1523,7 +1495,7 @@ static int efm32_i2c_transfer(FAR struct i2c_master_s *dev,
* be enabled in efm32_i2c_sem_waitdone if CONFIG_I2C_POLLED is NOT defined
*/
- efm32_i2c_isr(priv);
+ efm32_i2c_isr_process(priv);
/* Wait for an ISR, if there was a timeout, fetch latest status to get the
* BUSY flag.
diff --git a/arch/arm/src/efm32/efm32_irq.c b/arch/arm/src/efm32/efm32_irq.c
index 859860d0725bf907f686a8acdb76956f029f6672..254d196f12548e77fb66157df39b8290e753a4b1 100644
--- a/arch/arm/src/efm32/efm32_irq.c
+++ b/arch/arm/src/efm32/efm32_irq.c
@@ -319,16 +319,6 @@ void up_irqinitialize(void)
putreg32(0xffffffff, NVIC_IRQ_CLEAR(i));
}
-#if defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 3
- /* Colorize the interrupt stack for debug purposes */
-
- {
- size_t intstack_size = (CONFIG_ARCH_INTERRUPTSTACK & ~3);
- up_stack_color((FAR void *)((uintptr_t)&g_intstackbase - intstack_size),
- intstack_size);
- }
-#endif
-
/* Make sure that we are using the correct vector table. The default
* vector address is 0x0000:0000 but if we are executing code that is
* positioned in SRAM or in external FLASH, then we may need to reset
diff --git a/arch/arm/src/efm32/efm32_spi.c b/arch/arm/src/efm32/efm32_spi.c
index d0ae6d378a2932ea0482bf56aa98fd7c0d8b0d35..01491669fd7b14696d0f3c19c288e70e6070b66f 100644
--- a/arch/arm/src/efm32/efm32_spi.c
+++ b/arch/arm/src/efm32/efm32_spi.c
@@ -109,11 +109,11 @@ struct efm32_spiconfig_s
/* SPI-specific methods */
- void (*select)(struct spi_dev_s *dev, enum spi_dev_e devid,
+ void (*select)(struct spi_dev_s *dev, uint32_t devid,
bool selected);
- uint8_t (*status)(struct spi_dev_s *dev, enum spi_dev_e devid);
+ uint8_t (*status)(struct spi_dev_s *dev, uint32_t devid);
#ifdef CONFIG_SPI_CMDDATA
- int (*cmddata)(struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+ int (*cmddata)(struct spi_dev_s *dev, uint32_t devid, bool cmd);
#endif
};
@@ -180,7 +180,7 @@ static inline void spi_dmatxstart(FAR struct efm32_spidev_s *priv);
/* SPI methods */
static int spi_lock(struct spi_dev_s *dev, bool lock);
-static void spi_select(struct spi_dev_s *dev, enum spi_dev_e devid,
+static void spi_select(struct spi_dev_s *dev, uint32_t devid,
bool selected);
static uint32_t spi_setfrequency(struct spi_dev_s *dev,
uint32_t frequency);
@@ -190,9 +190,9 @@ static void spi_setbits(struct spi_dev_s *dev, int nbits);
static int spi_hwfeatures(FAR struct spi_dev_s *dev,
spi_hwfeatures_t features);
#endif
-static uint8_t spi_status(struct spi_dev_s *dev, enum spi_dev_e devid);
+static uint8_t spi_status(struct spi_dev_s *dev, uint32_t devid);
#ifdef CONFIG_SPI_CMDDATA
-static int spi_cmddata(struct spi_dev_s *dev, enum spi_dev_e devid,
+static int spi_cmddata(struct spi_dev_s *dev, uint32_t devid,
bool cmd);
#endif
static uint16_t spi_send(struct spi_dev_s *dev, uint16_t wd);
@@ -781,7 +781,7 @@ static int spi_lock(struct spi_dev_s *dev, bool lock)
*
****************************************************************************/
-static void spi_select(struct spi_dev_s *dev, enum spi_dev_e devid,
+static void spi_select(struct spi_dev_s *dev, uint32_t devid,
bool selected)
{
struct efm32_spidev_s *priv = (struct efm32_spidev_s *)dev;
@@ -1147,7 +1147,7 @@ static int spi_hwfeatures(FAR struct spi_dev_s *dev, spi_hwfeatures_t features)
*
****************************************************************************/
-static uint8_t spi_status(struct spi_dev_s *dev, enum spi_dev_e devid)
+static uint8_t spi_status(struct spi_dev_s *dev, uint32_t devid)
{
struct efm32_spidev_s *priv = (struct efm32_spidev_s *)dev;
const struct efm32_spiconfig_s *config;
@@ -1185,7 +1185,7 @@ static uint8_t spi_status(struct spi_dev_s *dev, enum spi_dev_e devid)
****************************************************************************/
#ifdef CONFIG_SPI_CMDDATA
-static int spi_cmddata(struct spi_dev_s *dev, enum spi_dev_e devid,
+static int spi_cmddata(struct spi_dev_s *dev, uint32_t devid,
bool cmd);
{
struct efm32_spidev_s *priv = (struct efm32_spidev_s *)dev;
diff --git a/arch/arm/src/efm32/efm32_spi.h b/arch/arm/src/efm32/efm32_spi.h
index 315eb0615d7baa174c3b21a4a61174fca99fdf07..9e84fb68dc3f0686b4f36214ccefac2c898c5544 100644
--- a/arch/arm/src/efm32/efm32_spi.h
+++ b/arch/arm/src/efm32/efm32_spi.h
@@ -52,7 +52,6 @@
****************************************************************************/
struct spi_dev_s; /* Forward reference */
-enum spi_dev_e; /* Forward reference */
/****************************************************************************
* Name: efm32_spibus_initialize
@@ -101,26 +100,26 @@ struct spi_dev_s *efm32_spibus_initialize(int port);
****************************************************************************/
#ifdef CONFIG_EFM32_USART0_ISSPI
-void efm32_spi0_select(struct spi_dev_s *dev, enum spi_dev_e devid,
+void efm32_spi0_select(struct spi_dev_s *dev, uint32_t devid,
bool selected);
-uint8_t efm32_spi0_status(struct spi_dev_s *dev, enum spi_dev_e devid);
-int efm32_spi0_cmddata(struct spi_dev_s *dev, enum spi_dev_e devid,
+uint8_t efm32_spi0_status(struct spi_dev_s *dev, uint32_t devid);
+int efm32_spi0_cmddata(struct spi_dev_s *dev, uint32_t devid,
bool cmd);
#endif
#ifdef CONFIG_EFM32_USART1_ISSPI
-void efm32_spi1_select(struct spi_dev_s *dev, enum spi_dev_e devid,
+void efm32_spi1_select(struct spi_dev_s *dev, uint32_t devid,
bool selected);
-uint8_t efm32_spi1_status(struct spi_dev_s *dev, enum spi_dev_e devid);
-int efm32_spi1_cmddata(struct spi_dev_s *dev, enum spi_dev_e devid,
+uint8_t efm32_spi1_status(struct spi_dev_s *dev, uint32_t devid);
+int efm32_spi1_cmddata(struct spi_dev_s *dev, uint32_t devid,
bool cmd);
#endif
#ifdef CONFIG_EFM32_USART2_ISSPI
-void efm32_spi2_select(struct spi_dev_s *dev, enum spi_dev_e devid,
+void efm32_spi2_select(struct spi_dev_s *dev, uint32_t devid,
bool selected);
-uint8_t efm32_spi2_status(struct spi_dev_s *dev, enum spi_dev_e devid);
-int efm32_spi2_cmddata(struct spi_dev_s *dev, enum spi_dev_e devid,
+uint8_t efm32_spi2_status(struct spi_dev_s *dev, uint32_t devid);
+int efm32_spi2_cmddata(struct spi_dev_s *dev, uint32_t devid,
bool cmd);
#endif
diff --git a/arch/arm/src/efm32/efm32_usbhost.c b/arch/arm/src/efm32/efm32_usbhost.c
index 3d5a6888baa5714910b3f13233b14c349693628a..e3c8c548a7f396953e56ab230ee0ebcf1b012f33 100644
--- a/arch/arm/src/efm32/efm32_usbhost.c
+++ b/arch/arm/src/efm32/efm32_usbhost.c
@@ -1955,8 +1955,8 @@ static ssize_t efm32_in_transfer(FAR struct efm32_usbhost_s *priv, int chidx,
/* Check for a special case: If (1) the transfer was NAKed and (2)
* no Tx FIFO empty or Rx FIFO not-empty event occurred, then we
* should be able to just flush the Rx and Tx FIFOs and try again.
- * We can detect this latter case because the then the transfer
- * buffer pointer and buffer size will be unaltered.
+ * We can detect this latter case because then the transfer buffer
+ * pointer and buffer size will be unaltered.
*/
elapsed = clock_systimer() - start;
@@ -2221,8 +2221,8 @@ static ssize_t efm32_out_transfer(FAR struct efm32_usbhost_s *priv, int chidx,
/* Check for a special case: If (1) the transfer was NAKed and (2)
* no Tx FIFO empty or Rx FIFO not-empty event occurred, then we
* should be able to just flush the Rx and Tx FIFOs and try again.
- * We can detect this latter case because the then the transfer
- * buffer pointer and buffer size will be unaltered.
+ * We can detect this latter case because then the transfer buffer
+ * pointer and buffer size will be unaltered.
*/
elapsed = clock_systimer() - start;
@@ -4613,7 +4613,7 @@ static ssize_t efm32_transfer(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep
* Description:
* Process a request to handle a transfer descriptor. This method will
* enqueue the transfer request and return immediately. When the transfer
- * completes, the the callback will be invoked with the provided transfer.
+ * completes, the callback will be invoked with the provided transfer.
* This method is useful for receiving interrupt transfers which may come
* infrequently.
*
diff --git a/arch/arm/src/efm32/efm32_vectors.S b/arch/arm/src/efm32/efm32_vectors.S
index 488c8581e01806f2b6941e31d6d04adebd3bce5c..3f125e9f49e5370f6404932fa297acbe71a42837 100644
--- a/arch/arm/src/efm32/efm32_vectors.S
+++ b/arch/arm/src/efm32/efm32_vectors.S
@@ -59,7 +59,7 @@
* stale MSP, there will most likely be a system failure.
*
* If the interrupt stack is selected, on the other hand, then the interrupt
- * handler will always set the the MSP to the interrupt stack. So when the high
+ * handler will always set the MSP to the interrupt stack. So when the high
* priority interrupt occurs, it will either use the MSP of the last privileged
* thread to run or, in the case of the nested interrupt, the interrupt stack if
* no privileged task has run.
@@ -69,7 +69,7 @@
# error Interrupt stack must be used with high priority interrupts in kernel mode
# endif
- /* Use the the BASEPRI to control interrupts is required if nested, high
+ /* Use the BASEPRI to control interrupts is required if nested, high
* priority interrupts are supported.
*/
diff --git a/arch/arm/src/imx1/imx_cspi.h b/arch/arm/src/imx1/imx_cspi.h
index 842a4ca11164bb46c54ee6331715cf4e6acd1caf..f15872c49b142751513eb924aacf6120df7b0391 100644
--- a/arch/arm/src/imx1/imx_cspi.h
+++ b/arch/arm/src/imx1/imx_cspi.h
@@ -178,7 +178,6 @@ extern "C"
************************************************************************************/
struct spi_dev_s; /* Forward reference */
-enum spi_dev_e; /* Forward reference */
/****************************************************************************
* Name: imx_spibus_initialize
@@ -225,10 +224,10 @@ FAR struct spi_dev_s *imx_spibus_initialize(int port);
*
****************************************************************************/
-void imx_spiselect(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
-uint8_t imx_spistatus(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+void imx_spiselect(FAR struct spi_dev_s *dev, uint32_t devid, bool selected);
+uint8_t imx_spistatus(FAR struct spi_dev_s *dev, uint32_t devid);
#ifdef CONFIG_SPI_CMDDATA
-int imx_spicmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+int imx_spicmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
#endif
#undef EXTERN
diff --git a/arch/arm/src/imx1/imx_serial.c b/arch/arm/src/imx1/imx_serial.c
index ebe996e81b4794b9c38fcd41a64eefaacdc208c4..ef32ff5bf00b2e29f8e8ce3beb3fdc51b6374c0a 100644
--- a/arch/arm/src/imx1/imx_serial.c
+++ b/arch/arm/src/imx1/imx_serial.c
@@ -1,8 +1,7 @@
/****************************************************************************
* arch/arm/src/imx1/imx_serial.c
- * arch/arm/src/chip/imx_serial.c
*
- * Copyright (C) 2009, 2012-2013 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2009, 2012-2013, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
*
* Redistribution and use in source and binary forms, with or without
@@ -111,7 +110,6 @@ 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 inline struct uart_dev_s *up_mapirq(int irq);
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);
@@ -753,13 +751,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, NULL);
+ ret = irq_attach(priv->rxirq, up_interrupt, dev);
if (ret < 0)
{
return ret;
}
- ret = irq_attach(priv->txirq, up_interrupt, NULL);
+ ret = irq_attach(priv->txirq, up_interrupt, dev);
if (ret < 0)
{
irq_detach(priv->rxirq);
@@ -772,7 +770,7 @@ static int up_attach(struct uart_dev_s *dev)
up_enable_irq(priv->txirq);
#else
- ret = irq_attach(priv->irq, up_interrupt, NULL);
+ ret = irq_attach(priv->irq, up_interrupt, dev);
if (ret == OK)
{
/* Enable the interrupt (RX and TX interrupts are still disabled
@@ -810,60 +808,6 @@ static void up_detach(struct uart_dev_s *dev)
#endif
}
-/****************************************************************************
- * Name: up_mapirq
- *
- * Description:
- * Map an IRQ number to internal UART state structure
- *
- ****************************************************************************/
-
-static inline struct uart_dev_s *up_mapirq(int irq)
-{
- struct uart_dev_s *dev;
-
- switch (irq)
- {
-#ifdef CONFIG_IMX1_UART1
-#if defined(CONFIG_ARCH_CHIP_IMX1) || defined(CONFIG_ARCH_CHIP_IMXL)
- case IMX_IRQ_UART1RX:
- case IMX_IRQ_UART1TX:
-#else
- case IMX_IRQ_UART1:
-#endif
- dev = &g_uart1port;
- break;
-#endif
-
-#ifdef CONFIG_IMX1_UART2
-#if defined(CONFIG_ARCH_CHIP_IMX1) || defined(CONFIG_ARCH_CHIP_IMXL)
- case IMX_IRQ_UART2RX:
- case IMX_IRQ_UART2TX:
-#else
- case IMX_IRQ_UART2:
-#endif
- dev = &g_uart2port;
- break;
-#endif
-
-#ifdef CONFIG_IMX1_UART3
-#if defined(CONFIG_ARCH_CHIP_IMX1) || defined(CONFIG_ARCH_CHIP_IMXL)
- case IMX_IRQ_UART3RX:
- case IMX_IRQ_UART3TX:
-#else
- case IMX_IRQ_UART3:
-#endif
- dev = &g_uart3port;
- break;
-#endif
-
- default:
- PANIC();
- break;
- }
- return dev;
-}
-
/****************************************************************************
* Name: up_interrupt (and front-ends)
*
@@ -879,12 +823,12 @@ static inline struct uart_dev_s *up_mapirq(int irq)
static int up_interrupt(int irq, void *context, FAR void *arg)
{
- struct uart_dev_s *dev;
- struct up_dev_s *priv;
+ struct uart_dev_s *dev = (struct uart_dev_s *)arg;
+ struct up_dev_s *priv;
uint32_t usr1;
- int passes = 0;
+ int passes = 0;
- dev = up_mapirq(irq);
+ 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/imx6/imx_ecspi.c b/arch/arm/src/imx6/imx_ecspi.c
index 0199419681764cd3683b49619f9763d3794d7b52..2018c410bba43804bcd65dcab44163cc5d511b30 100644
--- a/arch/arm/src/imx6/imx_ecspi.c
+++ b/arch/arm/src/imx6/imx_ecspi.c
@@ -138,12 +138,12 @@
/* Per SPI callouts to board-specific logic */
typedef CODE void (*imx_select_t)(FAR struct spi_dev_s *dev,
- enum spi_dev_e devid, bool selected);
+ uint32_t devid, bool selected);
typedef CODE uint8_t (*imx_status_t)(FAR struct spi_dev_s *dev,
- enum spi_dev_e devid);
+ uint32_t devid);
#ifdef CONFIG_SPI_CMDDATA
typedef CODE int (*imx_cmddata_t)(FAR struct spi_dev_s *dev,
- enum spi_dev_e devid, bool cmd);
+ uint32_t devid, bool cmd);
#endif
struct imx_spidev_s
@@ -228,16 +228,16 @@ static int spi_interrupt(int irq, void *context, FAR void *arg);
/* SPI methods */
static int spi_lock(FAR struct spi_dev_s *dev, bool lock);
-static void spi_select(FAR struct spi_dev_s *dev, enum spi_dev_e devid,
+static void spi_select(FAR struct spi_dev_s *dev, uint32_t devid,
bool selected);
static uint32_t spi_setfrequency(FAR struct spi_dev_s *dev,
uint32_t frequency);
static void spi_setmode(FAR struct spi_dev_s *dev, enum spi_mode_e mode);
static void spi_setbits(FAR struct spi_dev_s *dev, int nbits);
static uint16_t spi_send(FAR struct spi_dev_s *dev, uint16_t wd);
-static uint8_t spi_status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+static uint8_t spi_status(FAR struct spi_dev_s *dev, uint32_t devid);
#ifdef CONFIG_SPI_CMDDATA
-static int spi_cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid,
+static int spi_cmddata(FAR struct spi_dev_s *dev, uint32_t devid,
bool cmd);
#endif
#ifdef CONFIG_SPI_EXCHANGE
@@ -835,7 +835,7 @@ static int spi_lock(FAR struct spi_dev_s *dev, bool lock)
*
****************************************************************************/
-static void spi_select(FAR struct spi_dev_s *dev, enum spi_dev_e devid,
+static void spi_select(FAR struct spi_dev_s *dev, uint32_t devid,
bool selected)
{
struct imx_spidev_s *priv = (struct imx_spidev_s *)dev;
@@ -1051,7 +1051,7 @@ static uint16_t spi_send(FAR struct spi_dev_s *dev, uint16_t wd)
*
****************************************************************************/
-static uint8_t spi_status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
+static uint8_t spi_status(FAR struct spi_dev_s *dev, uint32_t devid)
{
struct imx_spidev_s *priv = (struct imx_spidev_s *)dev;
uint8_t ret = 0;
@@ -1091,7 +1091,7 @@ static uint8_t spi_status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
****************************************************************************/
#ifdef CONFIG_SPI_CMDDATA
-static int spi_cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid,
+static int spi_cmddata(FAR struct spi_dev_s *dev, uint32_t devid,
bool cmd)
{
struct imx_spidev_s *priv = (struct imx_spidev_s *)dev;
diff --git a/arch/arm/src/imx6/imx_ecspi.h b/arch/arm/src/imx6/imx_ecspi.h
index 40ca57c465cfc925ee3194c942ba5efb4c68e451..ac30d2291f9428ff331c50e7a3860450ed13268b 100644
--- a/arch/arm/src/imx6/imx_ecspi.h
+++ b/arch/arm/src/imx6/imx_ecspi.h
@@ -70,7 +70,6 @@ extern "C"
************************************************************************************/
struct spi_dev_s; /* Forward reference */
-enum spi_dev_e; /* Forward reference */
/************************************************************************************
* Name: imx_spibus_initialize
@@ -118,42 +117,42 @@ FAR struct spi_dev_s *imx_spibus_initialize(int port);
************************************************************************************/
#ifdef CONFIG_IMX6_ECSPI1
-void imx_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
-uint8_t imx_spi1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+void imx_spi1select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected);
+uint8_t imx_spi1status(FAR struct spi_dev_s *dev, uint32_t devid);
#ifdef CONFIG_SPI_CMDDATA
-int imx_spi1cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+int imx_spi1cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
#endif
#endif
#ifdef CONFIG_IMX6_ECSPI2
-void imx_spi2select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
-uint8_t imx_spi2status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+void imx_spi2select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected);
+uint8_t imx_spi2status(FAR struct spi_dev_s *dev, uint32_t devid);
#ifdef CONFIG_SPI_CMDDATA
-int imx_spi2cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+int imx_spi2cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
#endif
#endif
#ifdef CONFIG_IMX6_ECSPI3
-void imx_spi3select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
-uint8_t imx_spi3status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+void imx_spi3select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected);
+uint8_t imx_spi3status(FAR struct spi_dev_s *dev, uint32_t devid);
#ifdef CONFIG_SPI_CMDDATA
-int imx_spi3cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+int imx_spi3cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
#endif
#endif
#ifdef CONFIG_IMX6_ECSPI4
-void imx_spi4select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
-uint8_t imx_spi4status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+void imx_spi4select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected);
+uint8_t imx_spi4status(FAR struct spi_dev_s *dev, uint32_t devid);
#ifdef CONFIG_SPI_CMDDATA
-int imx_spi4cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+int imx_spi4cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
#endif
#endif
#ifdef CONFIG_IMX6_ECSPI5
-void imx_spi5select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
-uint8_t imx_spi5status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+void imx_spi5select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected);
+uint8_t imx_spi5status(FAR struct spi_dev_s *dev, uint32_t devid);
#ifdef CONFIG_SPI_CMDDATA
-int imx_spi5cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+int imx_spi5cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
#endif
#endif
diff --git a/arch/arm/src/imx6/imx_irq.c b/arch/arm/src/imx6/imx_irq.c
index b15a9a4e6ddbc7a707196b4e51390c3e47398d78..d5248ef40f199ff8422d65494ba70d2ce91de059 100644
--- a/arch/arm/src/imx6/imx_irq.c
+++ b/arch/arm/src/imx6/imx_irq.c
@@ -93,16 +93,6 @@ void up_irqinitialize(void)
* access to the GIC.
*/
- /* Colorize the interrupt stack for debug purposes */
-
-#if defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 3
- {
- size_t intstack_size = (CONFIG_ARCH_INTERRUPTSTACK & ~3);
- up_stack_color((FAR void *)((uintptr_t)&g_intstackbase - intstack_size),
- intstack_size);
- }
-#endif
-
/* Initialize the Generic Interrupt Controller (GIC) for CPU0 */
arm_gic0_initialize(); /* Initialization unique to CPU0 */
diff --git a/arch/arm/src/imx6/imx_memorymap.h b/arch/arm/src/imx6/imx_memorymap.h
index 6259c1b7e0177a16bd93e240532542a9b950270c..6eb308d6585ecc237088d161e461213691b7107b 100644
--- a/arch/arm/src/imx6/imx_memorymap.h
+++ b/arch/arm/src/imx6/imx_memorymap.h
@@ -50,7 +50,7 @@
************************************************************************************/
/* The vectors are, by default, positioned at the beginning of the text
- * section. Under what conditions do we have to remap the these vectors?
+ * section. Under what conditions do we have to remap these vectors?
*
* 1) If we are using high vectors (CONFIG_ARCH_LOWVECTORS=n). In this case,
* the vectors will lie at virtual address 0xffff:000 and we will need
diff --git a/arch/arm/src/imx6/imx_serial.c b/arch/arm/src/imx6/imx_serial.c
index 8ae64136b5257aeb5ba8b94a2fb80de896dea6e9..6fdc021115a99994e060bffc17fd39e1d8d89d17 100644
--- a/arch/arm/src/imx6/imx_serial.c
+++ b/arch/arm/src/imx6/imx_serial.c
@@ -595,7 +595,7 @@ static int imx_attach(struct uart_dev_s *dev)
/* Attach and enable the IRQ */
- ret = irq_attach(priv->irq, imx_interrupt, priv);
+ ret = irq_attach(priv->irq, imx_interrupt, dev);
if (ret == OK)
{
/* Configure as a (high) level interrupt */
diff --git a/arch/arm/src/kinetis/Kconfig b/arch/arm/src/kinetis/Kconfig
index 271921a9ef6a5f720d50c5ba9c134375ec69bc3f..646e7254faa035d67e3f252adfcf3b43e20337ab 100644
--- a/arch/arm/src/kinetis/Kconfig
+++ b/arch/arm/src/kinetis/Kconfig
@@ -239,6 +239,10 @@ config KINETIS_HAVE_LPUART1
# will automatically be selected and will represent the 'OR' of the
# instances selected.
+config KINETIS_SERIALDRIVER
+ bool
+ default n
+
config KINETIS_LPUART
bool
default n
@@ -268,15 +272,23 @@ config ARCH_FAMILY_K60
config ARCH_FAMILY_K64
bool
default n
+ select KINETIS_HAVE_FTM3
select KINETIS_HAVE_UART5
config ARCH_FAMILY_K66
bool
default n
+ select KINETIS_HAVE_FTM3
select KINETIS_HAVE_LPUART0
+ select KINETIS_HAVE_TPM1
+ select KINETIS_HAVE_TPM2
menu "Kinetis Peripheral Support"
+config KINETIS_HAVE_FTM3
+ bool
+ default n
+
config KINETIS_HAVE_I2C1
bool
default n
@@ -297,6 +309,14 @@ config KINETIS_HAVE_SPI2
bool
default n
+config KINETIS_HAVE_TPM1
+ bool
+ default n
+
+config KINETIS_HAVE_TPM2
+ bool
+ default n
+
config KINETIS_TRACE
bool "Trace"
default n
@@ -314,6 +334,8 @@ config KINETIS_UART0
default n
select UART0_SERIALDRIVER
select KINETIS_UART
+ select KINETIS_SERIALDRIVER
+ select ARCH_HAVE_SERIAL_TERMIOS
---help---
Support UART0
@@ -322,6 +344,8 @@ config KINETIS_UART1
default n
select UART1_SERIALDRIVER
select KINETIS_UART
+ select KINETIS_SERIALDRIVER
+ select ARCH_HAVE_SERIAL_TERMIOS
---help---
Support UART1
@@ -330,6 +354,8 @@ config KINETIS_UART2
default n
select UART2_SERIALDRIVER
select KINETIS_UART
+ select KINETIS_SERIALDRIVER
+ select ARCH_HAVE_SERIAL_TERMIOS
---help---
Support UART2
@@ -338,6 +364,8 @@ config KINETIS_UART3
default n
select UART3_SERIALDRIVER
select KINETIS_UART
+ select KINETIS_SERIALDRIVER
+ select ARCH_HAVE_SERIAL_TERMIOS
---help---
Support UART3
@@ -346,6 +374,8 @@ config KINETIS_UART4
default n
select UART4_SERIALDRIVER
select KINETIS_UART
+ select KINETIS_SERIALDRIVER
+ select ARCH_HAVE_SERIAL_TERMIOS
---help---
Support UART4
@@ -355,6 +385,8 @@ config KINETIS_UART5
depends on KINETIS_HAVE_UART5
select UART5_SERIALDRIVER
select KINETIS_UART
+ select KINETIS_SERIALDRIVER
+ select ARCH_HAVE_SERIAL_TERMIOS
---help---
Support UART5
@@ -364,6 +396,8 @@ config KINETIS_LPUART0
depends on KINETIS_HAVE_LPUART0
select OTHER_UART_SERIALDRIVER
select KINETIS_LPUART
+ select KINETIS_SERIALDRIVER
+ select ARCH_HAVE_SERIAL_TERMIOS
---help---
Support the low power UART0
@@ -373,6 +407,8 @@ config KINETIS_LPUART1
depends on KINETIS_HAVE_LPUART1
select OTHER_UART_SERIALDRIVER
select KINETIS_LPUART
+ select KINETIS_SERIALDRIVER
+ select ARCH_HAVE_SERIAL_TERMIOS
---help---
Support the low power UART1
@@ -531,10 +567,24 @@ config KINETIS_FTM2
config KINETIS_FTM3
bool "FTM3"
default n
- depends on ARCH_FAMILY_K64 || ARCH_FAMILY_K66
+ depends on KINETIS_HAVE_FTM3
---help---
Support FlexTimer 3
+config KINETIS_TPM1
+ bool "TPM1"
+ default n
+ depends on KINETIS_HAVE_TPM1
+ ---help---
+ Support TPM module 1
+
+config KINETIS_TPM2
+ bool "TPM2"
+ default n
+ depends on KINETIS_HAVE_TPM2
+ ---help---
+ Support TPM module 2
+
config KINETIS_LPTIMER
bool "Low power timer (LPTIMER)"
default n
@@ -903,6 +953,43 @@ endmenu # Kinetis SDHC Configuration
#
menu "Kinetis UART Configuration"
+if KINETIS_SERIALDRIVER || OTHER_SERIALDRIVER
+
+comment "Serial Driver Configuration"
+
+config KINETIS_UART_BREAKS
+ bool "Add TIOxSBRK to support sending Breaks"
+ depends on KINETIS_UART || KINETIS_LPUART
+ default n
+ ---help---
+ Add TIOCxBRK routines to send a line break per the Kinetis manual, the
+ break will be a pulse based on the value M. This is not a BSD compatible
+ break.
+
+config KINETIS_UART_EXTEDED_BREAK
+ bool "Selects a longer transmitted break character length"
+ depends on KINETIS_UART_BREAKS
+ default n
+ ---help---
+ Sets BRK13 to send a longer transmitted break character.
+
+config KINETIS_SERIALBRK_BSDCOMPAT
+ bool "BSD compatible break the break asserted until released"
+ depends on (KINETIS_UART || KINETIS_LPUART) && KINETIS_UART_BREAKS
+ default n
+ ---help---
+ Enable using a BSD compatible break: TIOCSBRK will start the break
+ and TIOCCBRK will end the break.
+
+config KINETIS_UART_SINGLEWIRE
+ bool "Single Wire Support"
+ default n
+ depends on KINETIS_UART || KINETIS_LPUART
+ ---help---
+ Enable single wire UART and LPUART support. The option enables support
+ for the TIOCSSINGLEWIRE ioctl in the Kineteis serial drivers.
+
+endif # KINETIS_SERIALDRIVER || OTHER_SERIALDRIVER
config KINETIS_UARTFIFOS
bool "Enable UART0 FIFO"
diff --git a/arch/arm/src/kinetis/Make.defs b/arch/arm/src/kinetis/Make.defs
index 6ee494c6526c29590b3fa14d2686f54f8a64c8bc..4d9907907ed95856c97d4c3d67c240d9ee00a3bf 100644
--- a/arch/arm/src/kinetis/Make.defs
+++ b/arch/arm/src/kinetis/Make.defs
@@ -116,6 +116,7 @@ CHIP_CSRCS += kinetis_lowputc.c kinetis_pin.c kinetis_pingpio.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
+CHIP_CSRCS += kinetis_mpuinit.c
# Configuration-dependent Kinetis files
@@ -124,7 +125,7 @@ CHIP_CSRCS += kinetis_timerisr.c
endif
ifeq ($(CONFIG_BUILD_PROTECTED),y)
-CHIP_CSRCS += kinetis_userspace.c kinetis_mpuinit.c
+CHIP_CSRCS += kinetis_userspace.c
endif
ifeq ($(CONFIG_KINETIS_GPIOIRQ),y)
@@ -139,6 +140,10 @@ ifeq ($(CONFIG_KINETIS_SDHC),y)
CHIP_CSRCS += kinetis_sdhc.c
endif
+ifeq ($(CONFIG_SPI),y)
+CHIP_CSRCS += kinetis_spi.c
+endif
+
ifeq ($(CONFIG_USBDEV),y)
CHIP_CSRCS += kinetis_usbdev.c
endif
diff --git a/arch/arm/src/kinetis/chip.h b/arch/arm/src/kinetis/chip.h
index c16f31b14d9b8f106289ca899f20a8a94673e01d..262ad5555733c9826579cc0794a4a9384b248cc2 100644
--- a/arch/arm/src/kinetis/chip.h
+++ b/arch/arm/src/kinetis/chip.h
@@ -52,7 +52,7 @@
/* If the common ARMv7-M vector handling logic is used, then it expects the
* following definition in this file that provides the number of supported external
- * interrupts which, for this architecture, is provided in the arch/stm32f7/chip.h
+ * interrupts which, for this architecture, is provided in the arch/kinetis/chip.h
* header file.
*/
diff --git a/arch/arm/src/kinetis/chip/kinetis_adc.h b/arch/arm/src/kinetis/chip/kinetis_adc.h
index 6b3b74fa9c32c51efdddcaa71d5b4bd7bbbbe0c7..847bd9b7b739d8bb99621534331d896d4a94defa 100644
--- a/arch/arm/src/kinetis/chip/kinetis_adc.h
+++ b/arch/arm/src/kinetis/chip/kinetis_adc.h
@@ -82,7 +82,6 @@
#define KINETIS_ADC_CLM0_OFFSET 0x006c /* ADC minus-side general calibration value register */
/* Register Addresses ***********************************************************************/
-# define KINETIS_ADC1_BASE 0x400bb000 /* Analog-to-digital converter (ADC) 1 */
#define KINETIS_ADC0_SC1A (KINETIS_ADC0_BASE+KINETIS_ADC_SC1A_OFFSET)
#define KINETIS_ADC0_SC1B (KINETIS_ADC0_BASE+KINETIS_ADC_SC1B_OFFSET)
@@ -152,6 +151,7 @@
#define ADC_SC1_ADCH_SHIFT (0) /* Bits 0-4: Input channel select */
#define ADC_SC1_ADCH_MASK (31 << ADC_SC1_ADCH_SHIFT)
+# define ADC_SC1_ADCH(c) (((c) & 0x1f) << ADC_SC1_ADCH_SHIFT)
# define ADC_SC1_ADCH_DADP0 (0 << ADC_SC1_ADCH_SHIFT) /* DIFF=0 DADP0; DIFF=1, DAD0 */
# define ADC_SC1_ADCH_DADP1 (1 << ADC_SC1_ADCH_SHIFT) /* DIFF=0 DADP1; DIFF=1, DAD1 */
# define ADC_SC1_ADCH_DADP2 (2 << ADC_SC1_ADCH_SHIFT) /* DIFF=0 DADP2; DIFF=1, DAD2 */
@@ -205,7 +205,7 @@
# define ADC_CFG1_ADIV_DIV1 (0 << ADC_CFG1_ADIV_SHIFT) /* Divider=1 rate=input clock */
# define ADC_CFG1_ADIV_DIV2 (1 << ADC_CFG1_ADIV_SHIFT) /* Divider=2 rate=input clock/2 */
# define ADC_CFG1_ADIV_DIV4 (2 << ADC_CFG1_ADIV_SHIFT) /* Divider=4 rate=input clock/4 */
-# define ADC_CFG1_ADIV_DIV5 (3 << ADC_CFG1_ADIV_SHIFT) /* Divider=8 rate=input clock/8 */
+# define ADC_CFG1_ADIV_DIV8 (3 << ADC_CFG1_ADIV_SHIFT) /* Divider=8 rate=input clock/8 */
#define ADC_CFG1_ADLPC (1 << 7) /* Bit 7: Low-power configuration */
/* Bits 8-31: Reserved */
/* Configuration register 2 */
diff --git a/arch/arm/src/kinetis/chip/kinetis_dspi.h b/arch/arm/src/kinetis/chip/kinetis_dspi.h
index e41674494fb617c069645911792efbcbf1026d81..897e766cfcffc0dcc93f65171c86cc537130ff5a 100644
--- a/arch/arm/src/kinetis/chip/kinetis_dspi.h
+++ b/arch/arm/src/kinetis/chip/kinetis_dspi.h
@@ -140,7 +140,7 @@
#define SPI_MCR_PCSIS_SHIFT (16) /* Bits 16-21: Peripheral Chip Select x Inactive State */
#define SPI_MCR_PCSIS_MASK (0x3f << SPI_MCR_PCSIS_SHIFT)
# define SPI_MCR_PCSIS_CS(n) ((1 << (n)) << SPI_MCR_PCSIS_SHIFT)
- /* Bits 2223: Reserved */
+ /* Bits 22-23: Reserved */
#define SPI_MCR_ROOE (1 << 24) /* Bit 24: Receive FIFO Overflow Overwrite Enable */
#define SPI_MCR_PCSSE (1 << 25) /* Bit 25: Peripheral Chip Select Strobe Enable */
#define SPI_MCR_MTFE (1 << 26) /* Bit 26: Modified Timing Format Enable */
@@ -165,6 +165,7 @@
#define SPI_CTARM_BR_SHIFT (0) /* Bits 0-3: Baud Rate Scaler */
#define SPI_CTARM_BR_MASK (15 << SPI_CTARM_BR_SHIFT)
+# define SPI_CTARM_BR(n) ((((n) & 0xf)) << SPI_CTARM_BR_SHIFT)
# define SPI_CTARM_BR_2 (0 << SPI_CTARM_BR_SHIFT)
# define SPI_CTARM_BR_4 (1 << SPI_CTARM_BR_SHIFT)
# define SPI_CTARM_BR_6 (2 << SPI_CTARM_BR_SHIFT)
@@ -205,6 +206,7 @@
# define SPI_CTARM_CSSCK_65536 (15 << SPI_CTARM_CSSCK_SHIFT)
#define SPI_CTARM_PBR_SHIFT (16) /* Bits 16-17: Baud Rate Prescaler */
#define SPI_CTARM_PBR_MASK (3 << SPI_CTARM_PBR_SHIFT)
+# define SPI_CTARM_PBR(n) (((n) & 0x3) << SPI_CTARM_PBR_SHIFT)
# define SPI_CTARM_PBR_2 (0 << SPI_CTARM_PBR_SHIFT)
# define SPI_CTARM_PBR_3 (1 << SPI_CTARM_PBR_SHIFT)
# define SPI_CTARM_PBR_5 (2 << SPI_CTARM_PBR_SHIFT)
@@ -231,6 +233,7 @@
/* Bits 25-26: See common bits above */
#define SPI_CTARM_FMSZ_SHIFT (27) /* Bits 27-30: Frame Size */
#define SPI_CTARM_FMSZ_MASK (15 << SPI_CTARM_FMSZ_SHIFT)
+#define SPI_CTARM_FMSZ(n) ((((n) & 0xf)) << SPI_CTARM_FMSZ_SHIFT)
#define SPI_CTARM_DBR (1 << 31) /* Bit 31: Double Baud Rate */
/* DSPI Clock and Transfer Attributes Register (Slave Mode) */
@@ -281,6 +284,7 @@
#define SPI_PUSHR_TXDATA_SHIFT (0) /* Bits 0-15: Transmit Data */
#define SPI_PUSHR_TXDATA_MASK (0xffff << SPI_PUSHR_TXDATA_SHIFT)
+# define SPI_PUSHR_TXDATA(d) (((d) & 0xffff) << SPI_PUSHR_TXDATA_SHIFT)
#define SPI_PUSHR_PCS_SHIFT (16) /* Bits 16-21: Select PCS signals to assert */
#define SPI_PUSHR_PCS_MASK (0x3f << SPI_PUSHR_PCS_SHIFT)
# define SPI_PUSHR_PCS(n) ((1 << (n)) << SPI_PUSHR_PCS_SHIFT)
diff --git a/arch/arm/src/kinetis/chip/kinetis_k20pinmux.h b/arch/arm/src/kinetis/chip/kinetis_k20pinmux.h
index ca708acfdf8aa4b6c6252384a16c0c31dfd6ac05..d77ea9627049e02e73990010af34cf300c40c7fe 100644
--- a/arch/arm/src/kinetis/chip/kinetis_k20pinmux.h
+++ b/arch/arm/src/kinetis/chip/kinetis_k20pinmux.h
@@ -1,8 +1,9 @@
/********************************************************************************************
* arch/arm/src/kinetis/chip/kinetis_k20pinmux.h
*
- * Copyright (C) 2015-2016 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt
+ * Copyright (C) 2015-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
@@ -159,14 +160,14 @@
# define PIN_FTM2_QD_PHA (PIN_ALT6 | PIN_PORTB | PIN18)
# define PIN_FTM2_QD_PHB (PIN_ALT6 | PIN_PORTB | PIN19)
-# define PIN_I2C0_SCL_1 (PIN_ALT2 | PIN_PORTB | PIN0)
-# define PIN_I2C0_SCL_2 (PIN_ALT2 | PIN_PORTB | PIN2)
-# define PIN_I2C0_SDA_1 (PIN_ALT2 | PIN_PORTB | PIN1)
-# define PIN_I2C0_SDA_2 (PIN_ALT2 | PIN_PORTB | PIN3)
-# define PIN_I2C1_SCL_1 (PIN_ALT2 | PIN_PORTC | PIN10)
-# define PIN_I2C1_SCL_2 (PIN_ALT6 | PIN_PORTE | PIN1)
-# define PIN_I2C1_SDA_1 (PIN_ALT2 | PIN_PORTC | PIN11)
-# define PIN_I2C1_SDA_2 (PIN_ALT6 | PIN_PORTE | PIN0)
+# define PIN_I2C0_SCL_1 (PIN_ALT2_OPENDRAIN | PIN_PORTB | PIN0)
+# define PIN_I2C0_SCL_2 (PIN_ALT2_OPENDRAIN | PIN_PORTB | PIN2)
+# define PIN_I2C0_SDA_1 (PIN_ALT2_OPENDRAIN | PIN_PORTB | PIN1)
+# define PIN_I2C0_SDA_2 (PIN_ALT2_OPENDRAIN | PIN_PORTB | PIN3)
+# define PIN_I2C1_SCL_1 (PIN_ALT2_OPENDRAIN | PIN_PORTC | PIN10)
+# define PIN_I2C1_SCL_2 (PIN_ALT6_OPENDRAIN | PIN_PORTE | PIN1)
+# define PIN_I2C1_SDA_1 (PIN_ALT2_OPENDRAIN | PIN_PORTC | PIN11)
+# define PIN_I2C1_SDA_2 (PIN_ALT6_OPENDRAIN | PIN_PORTE | PIN0)
# define PIN_I2S0_MCLK_1 (PIN_ALT4 | PIN_PORTC | PIN8)
# define PIN_I2S0_MCLK_2 (PIN_ALT6 | PIN_PORTC | PIN6)
diff --git a/arch/arm/src/kinetis/chip/kinetis_k40pinmux.h b/arch/arm/src/kinetis/chip/kinetis_k40pinmux.h
index 7083b0caf7c5dccde1573fcc508ffd8e47ef9a17..c7570edaf9acd24f5552b08b006c0785fef2ca67 100644
--- a/arch/arm/src/kinetis/chip/kinetis_k40pinmux.h
+++ b/arch/arm/src/kinetis/chip/kinetis_k40pinmux.h
@@ -1,8 +1,9 @@
/********************************************************************************************
* arch/arm/src/kinetis/chip/kinetis_k40pinmux.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
@@ -160,7 +161,7 @@
#define PIN_ADC0_SE8 (PIN_ANALOG | PIN_PORTB | PIN0)
#define PIN_ADC1_SE8 (PIN_ANALOG | PIN_PORTB | PIN0)
#define PIN_TSI0_CH0 (PIN_ANALOG | PIN_PORTB | PIN0)
-#define PIN_I2C0_SCL_1 (PIN_ALT2 | PIN_PORTB | PIN0)
+#define PIN_I2C0_SCL_1 (PIN_ALT2_OPENDRAIN | PIN_PORTB | PIN0)
#define PIN_FTM1_CH0_3 (PIN_ALT3 | PIN_PORTB | PIN0)
#define PIN_FTM1_QD_PHA_3 (PIN_ALT6 | PIN_PORTB | PIN0)
#define PIN_LCD_P0F (PIN_ALT7 | PIN_PORTB | PIN0)
@@ -168,21 +169,21 @@
#define PIN_ADC0_SE9 (PIN_ANALOG | PIN_PORTB | PIN1)
#define PIN_ADC1_SE9 (PIN_ANALOG | PIN_PORTB | PIN1)
#define PIN_TSI0_CH6 (PIN_ANALOG | PIN_PORTB | PIN1)
-#define PIN_I2C0_SDA_1 (PIN_ALT2 | PIN_PORTB | PIN1)
+#define PIN_I2C0_SDA_1 (PIN_ALT2_OPENDRAIN | PIN_PORTB | PIN1)
#define PIN_FTM1_CH1_3 (PIN_ALT3 | PIN_PORTB | PIN1)
#define PIN_FTM1_QD_PHB (PIN_ALT6 | PIN_PORTB | PIN1)
#define PIN_LCD_P1F (PIN_ALT7 | PIN_PORTB | PIN1)
#define PIN_LCD_P2 (PIN_ANALOG | PIN_PORTB | PIN2)
#define PIN_ADC0_SE12 (PIN_ANALOG | PIN_PORTB | PIN2)
#define PIN_TSI0_CH7 (PIN_ANALOG | PIN_PORTB | PIN2)
-#define PIN_I2C0_SCL_2 (PIN_ALT2 | PIN_PORTB | PIN2)
+#define PIN_I2C0_SCL_2 (PIN_ALT2_OPENDRAIN| PIN_PORTB | PIN2)
#define PIN_UART0_RTS_3 (PIN_ALT3 | PIN_PORTB | PIN2)
#define PIN_FTM0_FLT3 (PIN_ALT6 | PIN_PORTB | PIN2)
#define PIN_LCD_P2F (PIN_ALT7 | PIN_PORTB | PIN2)
#define PIN_LCD_P3 (PIN_ANALOG | PIN_PORTB | PIN3)
#define PIN_ADC0_SE13 (PIN_ANALOG | PIN_PORTB | PIN3)
#define PIN_TSI0_CH8 (PIN_ANALOG | PIN_PORTB | PIN3)
-#define PIN_I2C0_SDA_2 (PIN_ALT2 | PIN_PORTB | PIN3)
+#define PIN_I2C0_SDA_2 (PIN_ALT2_OPENDRAIN | PIN_PORTB | PIN3)
#define PIN_UART0_CTS_3 (PIN_ALT3 | PIN_PORTB | PIN3)
#define PIN_FTM0_FLT0_1 (PIN_ALT6 | PIN_PORTB | PIN3)
#define PIN_LCD_P3F (PIN_ALT7 | PIN_PORTB | PIN3)
@@ -325,12 +326,12 @@
#define PIN_LCD_P30 (PIN_ANALOG | PIN_PORTC | PIN10)
#define PIN_ADC1_SE6B (PIN_ANALOG | PIN_PORTC | PIN10)
#define PIN_CMP0_IN4 (PIN_ANALOG | PIN_PORTC | PIN10)
-#define PIN_I2C1_SCL_1 (PIN_ALT2 | PIN_PORTC | PIN10)
+#define PIN_I2C1_SCL_1 (PIN_ALT2_OPENDRAIN | PIN_PORTC | PIN10)
#define PIN_I2S0_RX_FS_2 (PIN_ALT4 | PIN_PORTC | PIN10)
#define PIN_LCD_P30F (PIN_ALT7 | PIN_PORTC | PIN10)
#define PIN_LCD_P31 (PIN_ANALOG | PIN_PORTC | PIN11)
#define PIN_ADC1_SE7B (PIN_ANALOG | PIN_PORTC | PIN11)
-#define PIN_I2C1_SDA_1 (PIN_ALT2 | PIN_PORTC | PIN11)
+#define PIN_I2C1_SDA_1 (PIN_ALT2_OPENDRAIN | PIN_PORTC | PIN11)
#define PIN_I2S0_RXD_2 (PIN_ALT4 | PIN_PORTC | PIN11)
#define PIN_LCD_P31F (PIN_ALT7 | PIN_PORTC | PIN11)
#define PIN_LCD_P32 (PIN_ANALOG | PIN_PORTC | PIN12)
@@ -427,13 +428,13 @@
#define PIN_UART1_TX_2 (PIN_ALT3 | PIN_PORTE | PIN0)
#define PIN_SDHC0_D1 (PIN_ALT4 | PIN_PORTE | PIN0)
#define PIN_FB_AD27 (PIN_ALT5 | PIN_PORTE | PIN0)
-#define PIN_I2C1_SDA_2 (PIN_ALT6 | PIN_PORTE | PIN0)
+#define PIN_I2C1_SDA_2 (PIN_ALT6_OPENDRAIN | PIN_PORTE | PIN0)
#define PIN_ADC1_SE5A (PIN_ANALOG | PIN_PORTE | PIN1)
#define PIN_SPI1_SOUT_2 (PIN_ALT2 | PIN_PORTE | PIN1)
#define PIN_UART1_RX_2 (PIN_ALT3 | PIN_PORTE | PIN1)
#define PIN_SDHC0_D0 (PIN_ALT4 | PIN_PORTE | PIN1)
#define PIN_FB_AD26 (PIN_ALT5 | PIN_PORTE | PIN1)
-#define PIN_I2C1_SCL_2 (PIN_ALT6 | PIN_PORTE | PIN1)
+#define PIN_I2C1_SCL_2 (PIN_ALT6_OPENDRAIN | PIN_PORTE | PIN1)
#define PIN_ADC1_SE6A (PIN_ANALOG | PIN_PORTE | PIN2)
#define PIN_SPI1_SCK_2 (PIN_ALT2 | PIN_PORTE | PIN2)
#define PIN_UART1_CTS_2 (PIN_ALT3 | PIN_PORTE | PIN2)
diff --git a/arch/arm/src/kinetis/chip/kinetis_k60pinmux.h b/arch/arm/src/kinetis/chip/kinetis_k60pinmux.h
index 888a5955840f58f5b66a24f9ee718d5535481b61..b1ca87746f364ffad6fba65bd297adbf63226bb4 100644
--- a/arch/arm/src/kinetis/chip/kinetis_k60pinmux.h
+++ b/arch/arm/src/kinetis/chip/kinetis_k60pinmux.h
@@ -1,8 +1,9 @@
/********************************************************************************************
* arch/arm/src/kinetis/chip/kinetis_k60pinset.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
@@ -172,7 +173,7 @@
#define PIN_ADC0_SE8 (PIN_ANALOG | PIN_PORTB | PIN0)
#define PIN_ADC1_SE8 (PIN_ANALOG | PIN_PORTB | PIN0)
#define PIN_TSI0_CH0 (PIN_ANALOG | PIN_PORTB | PIN0)
-#define PIN_I2C0_SCL_1 (PIN_ALT2 | PIN_PORTB | PIN0)
+#define PIN_I2C0_SCL_1 (PIN_ALT2_OPENDRAIN | PIN_PORTB | PIN0)
#define PIN_FTM1_CH0_3 (PIN_ALT3 | PIN_PORTB | PIN0)
#ifdef CONFIG_KINETIS_ENET_MDIOPULLUP
# define PIN_RMII0_MDIO (PIN_ALT4_PULLUP | PIN_PORTB | PIN0)
@@ -184,20 +185,20 @@
#define PIN_ADC0_SE9 (PIN_ANALOG | PIN_PORTB | PIN1)
#define PIN_ADC1_SE9 (PIN_ANALOG | PIN_PORTB | PIN1)
#define PIN_TSI0_CH6 (PIN_ANALOG | PIN_PORTB | PIN1)
-#define PIN_I2C0_SDA_1 (PIN_ALT2 | PIN_PORTB | PIN1)
+#define PIN_I2C0_SDA_1 (PIN_ALT2_OPENDRAIN | PIN_PORTB | PIN1)
#define PIN_FTM1_CH1_3 (PIN_ALT3 | PIN_PORTB | PIN1)
#define PIN_RMII0_MDC (PIN_ALT4 | PIN_PORTB | PIN1)
#define PIN_MII0_MDC (PIN_ALT4 | PIN_PORTB | PIN1)
#define PIN_FTM1_QD_PHB_3 (PIN_ALT6 | PIN_PORTB | PIN1)
#define PIN_ADC0_SE12 (PIN_ANALOG | PIN_PORTB | PIN2)
#define PIN_TSI0_CH7 (PIN_ANALOG | PIN_PORTB | PIN2)
-#define PIN_I2C0_SCL_2 (PIN_ALT2 | PIN_PORTB | PIN2)
+#define PIN_I2C0_SCL_2 (PIN_ALT2_OPENDRAIN | PIN_PORTB | PIN2)
#define PIN_UART0_RTS_3 (PIN_ALT3 | PIN_PORTB | PIN2)
#define PIN_ENET0_1588_TMR0_1 (PIN_ALT4 | PIN_PORTB | PIN2)
#define PIN_FTM0_FLT3 (PIN_ALT6 | PIN_PORTB | PIN2)
#define PIN_ADC0_SE13 (PIN_ANALOG | PIN_PORTB | PIN3)
#define PIN_TSI0_CH8 (PIN_ANALOG | PIN_PORTB | PIN3)
-#define PIN_I2C0_SDA_2 (PIN_ALT2 | PIN_PORTB | PIN3)
+#define PIN_I2C0_SDA_2 (PIN_ALT2_OPENDRAIN | PIN_PORTB | PIN3)
#define PIN_UART0_CTS_3 (PIN_ALT3 | PIN_PORTB | PIN3)
#define PIN_ENET0_1588_TMR1_1 (PIN_ALT4 | PIN_PORTB | PIN3)
#define PIN_FTM0_FLT0_2 (PIN_ALT6 | PIN_PORTB | PIN3)
@@ -313,11 +314,11 @@
#define PIN_FTM2_FLT0_2 (PIN_ALT6 | PIN_PORTC | PIN9)
#define PIN_ADC1_SE6B (PIN_ANALOG | PIN_PORTC | PIN10)
#define PIN_CMP0_IN4 (PIN_ANALOG | PIN_PORTC | PIN10)
-#define PIN_I2C1_SCL_1 (PIN_ALT2 | PIN_PORTC | PIN10)
+#define PIN_I2C1_SCL_1 (PIN_ALT2_OPENDRAIN | PIN_PORTC | PIN10)
#define PIN_I2S0_RX_FS_2 (PIN_ALT4 | PIN_PORTC | PIN10)
#define PIN_FB_AD5 (PIN_ALT5 | PIN_PORTC | PIN10)
#define PIN_ADC1_SE7B (PIN_ANALOG | PIN_PORTC | PIN11)
-#define PIN_I2C1_SDA_1 (PIN_ALT2 | PIN_PORTC | PIN11)
+#define PIN_I2C1_SDA_1 (PIN_ALT2_OPENDRAIN | PIN_PORTC | PIN11)
#define PIN_I2S0_RXD_2 (PIN_ALT4 | PIN_PORTC | PIN11)
#define PIN_FB_RW (PIN_ALT5 | PIN_PORTC | PIN11)
#define PIN_UART4_RTS_1 (PIN_ALT3 | PIN_PORTC | PIN12)
@@ -387,10 +388,10 @@
#define PIN_UART0_TX_4 (PIN_ALT3 | PIN_PORTD | PIN7)
#define PIN_FTM0_CH7_2 (PIN_ALT4 | PIN_PORTD | PIN7)
#define PIN_FTM0_FLT1_2 (PIN_ALT6 | PIN_PORTD | PIN7)
-#define PIN_I2C0_SCL_3 (PIN_ALT2 | PIN_PORTD | PIN8)
+#define PIN_I2C0_SCL_3 (PIN_ALT2_OPENDRAIN | PIN_PORTD | PIN8)
#define PIN_UART5_RX_1 (PIN_ALT3 | PIN_PORTD | PIN8)
#define PIN_FB_A16 (PIN_ALT6 | PIN_PORTD | PIN8)
-#define PIN_I2C0_SDA_3 (PIN_ALT2 | PIN_PORTD | PIN9)
+#define PIN_I2C0_SDA_3 (PIN_ALT2_OPENDRAIN | PIN_PORTD | PIN9)
#define PIN_UART5_TX_1 (PIN_ALT3 | PIN_PORTD | PIN9)
#define PIN_FB_A17 (PIN_ALT6 | PIN_PORTD | PIN9)
#define PIN_UART5_RTS_1 (PIN_ALT3 | PIN_PORTD | PIN10)
@@ -416,12 +417,12 @@
#define PIN_SPI1_PCS1_2 (PIN_ALT2 | PIN_PORTE | PIN0)
#define PIN_UART1_TX_2 (PIN_ALT3 | PIN_PORTE | PIN0)
#define PIN_SDHC0_D1 (PIN_ALT4 | PIN_PORTE | PIN0)
-#define PIN_I2C1_SDA_2 (PIN_ALT6 | PIN_PORTE | PIN0)
+#define PIN_I2C1_SDA_2 (PIN_ALT6_OPENDRAIN | PIN_PORTE | PIN0)
#define PIN_ADC1_SE5A (PIN_ANALOG | PIN_PORTE | PIN1)
#define PIN_SPI1_SOUT_2 (PIN_ALT2 | PIN_PORTE | PIN1)
#define PIN_UART1_RX_2 (PIN_ALT3 | PIN_PORTE | PIN1)
#define PIN_SDHC0_D0 (PIN_ALT4 | PIN_PORTE | PIN1)
-#define PIN_I2C1_SCL_2 (PIN_ALT6 | PIN_PORTE | PIN1)
+#define PIN_I2C1_SCL_2 (PIN_ALT6_OPENDRAIN | PIN_PORTE | PIN1)
#define PIN_ADC1_SE6A (PIN_ANALOG | PIN_PORTE | PIN2)
#define PIN_SPI1_SCK_2 (PIN_ALT2 | PIN_PORTE | PIN2)
#define PIN_UART1_CTS_2 (PIN_ALT3 | PIN_PORTE | PIN2)
diff --git a/arch/arm/src/kinetis/chip/kinetis_k64pinmux.h b/arch/arm/src/kinetis/chip/kinetis_k64pinmux.h
index 3479099bf6c99c2275611636ded8721fe11f1526..d9894b3ff7067ff5ccfb2cd7776f541956bc2d22 100644
--- a/arch/arm/src/kinetis/chip/kinetis_k64pinmux.h
+++ b/arch/arm/src/kinetis/chip/kinetis_k64pinmux.h
@@ -1,8 +1,9 @@
/********************************************************************************************
* arch/arm/src/kinetis/chip/kinetis_k64pinmux.h
*
- * Copyright (C) 2016 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt
+ * Copyright (C) 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
@@ -305,26 +306,26 @@
/* I2C */
-#define PIN_I2C0_SCL_1 (PIN_ALT2 | PIN_PORTB | PIN0)
-#define PIN_I2C0_SCL_2 (PIN_ALT2 | PIN_PORTB | PIN2)
-#define PIN_I2C0_SCL_3 (PIN_ALT2 | PIN_PORTD | PIN8)
-#define PIN_I2C0_SCL_4 (PIN_ALT5 | PIN_PORTE | PIN24)
-#define PIN_I2C0_SCL_5 (PIN_ALT7 | PIN_PORTD | PIN2)
-#define PIN_I2C0_SDA_1 (PIN_ALT2 | PIN_PORTB | PIN1)
-#define PIN_I2C0_SDA_2 (PIN_ALT2 | PIN_PORTB | PIN3)
-#define PIN_I2C0_SDA_3 (PIN_ALT2 | PIN_PORTD | PIN9)
-#define PIN_I2C0_SDA_4 (PIN_ALT5 | PIN_PORTE | PIN25)
-#define PIN_I2C0_SDA_5 (PIN_ALT7 | PIN_PORTD | PIN3)
-
-#define PIN_I2C1_SCL_1 (PIN_ALT2 | PIN_PORTC | PIN10)
-#define PIN_I2C1_SCL_2 (PIN_ALT6 | PIN_PORTE | PIN1)
-#define PIN_I2C1_SDA_1 (PIN_ALT2 | PIN_PORTC | PIN11)
-#define PIN_I2C1_SDA_2 (PIN_ALT6 | PIN_PORTE | PIN0)
-
-#define PIN_I2C2_SCL_1 (PIN_ALT5 | PIN_PORTA | PIN12)
-#define PIN_I2C2_SCL_2 (PIN_ALT5 | PIN_PORTA | PIN14)
-#define PIN_I2C2_SDA_1 (PIN_ALT5 | PIN_PORTA | PIN11)
-#define PIN_I2C2_SDA_2 (PIN_ALT5 | PIN_PORTA | PIN13)
+#define PIN_I2C0_SCL_1 (PIN_ALT2_OPENDRAIN | PIN_PORTB | PIN0)
+#define PIN_I2C0_SCL_2 (PIN_ALT2_OPENDRAIN | PIN_PORTB | PIN2)
+#define PIN_I2C0_SCL_3 (PIN_ALT2_OPENDRAIN | PIN_PORTD | PIN8)
+#define PIN_I2C0_SCL_4 (PIN_ALT5_OPENDRAIN | PIN_PORTE | PIN24)
+#define PIN_I2C0_SCL_5 (PIN_ALT7_OPENDRAIN | PIN_PORTD | PIN2)
+#define PIN_I2C0_SDA_1 (PIN_ALT2_OPENDRAIN | PIN_PORTB | PIN1)
+#define PIN_I2C0_SDA_2 (PIN_ALT2_OPENDRAIN | PIN_PORTB | PIN3)
+#define PIN_I2C0_SDA_3 (PIN_ALT2_OPENDRAIN | PIN_PORTD | PIN9)
+#define PIN_I2C0_SDA_4 (PIN_ALT5_OPENDRAIN | PIN_PORTE | PIN25)
+#define PIN_I2C0_SDA_5 (PIN_ALT7_OPENDRAIN | PIN_PORTD | PIN3)
+
+#define PIN_I2C1_SCL_1 (PIN_ALT2_OPENDRAIN | PIN_PORTC | PIN10)
+#define PIN_I2C1_SCL_2 (PIN_ALT6_OPENDRAIN | PIN_PORTE | PIN1)
+#define PIN_I2C1_SDA_1 (PIN_ALT2_OPENDRAIN | PIN_PORTC | PIN11)
+#define PIN_I2C1_SDA_2 (PIN_ALT6_OPENDRAIN | PIN_PORTE | PIN0)
+
+#define PIN_I2C2_SCL_1 (PIN_ALT5_OPENDRAIN | PIN_PORTA | PIN12)
+#define PIN_I2C2_SCL_2 (PIN_ALT5_OPENDRAIN | PIN_PORTA | PIN14)
+#define PIN_I2C2_SDA_1 (PIN_ALT5_OPENDRAIN | PIN_PORTA | PIN11)
+#define PIN_I2C2_SDA_2 (PIN_ALT5_OPENDRAIN | PIN_PORTA | PIN13)
/* I2S */
diff --git a/arch/arm/src/kinetis/chip/kinetis_k66pinmux.h b/arch/arm/src/kinetis/chip/kinetis_k66pinmux.h
index b549f5c76d1b1db80644daf20d9407c5e8964199..93676e9903143d0cc59b53ca9528569fcd66fc6f 100644
--- a/arch/arm/src/kinetis/chip/kinetis_k66pinmux.h
+++ b/arch/arm/src/kinetis/chip/kinetis_k66pinmux.h
@@ -317,31 +317,31 @@
/* I2C */
-#define PIN_I2C0_SCL_1 (PIN_ALT2 | PIN_PORTB | PIN0)
-#define PIN_I2C0_SCL_2 (PIN_ALT2 | PIN_PORTB | PIN2)
-#define PIN_I2C0_SCL_3 (PIN_ALT2 | PIN_PORTD | PIN8)
-#define PIN_I2C0_SCL_4 (PIN_ALT5 | PIN_PORTE | PIN24)
-#define PIN_I2C0_SCL_5 (PIN_ALT7 | PIN_PORTD | PIN2)
-#define PIN_I2C0_SDA_1 (PIN_ALT2 | PIN_PORTB | PIN1)
-#define PIN_I2C0_SDA_2 (PIN_ALT2 | PIN_PORTB | PIN3)
-#define PIN_I2C0_SDA_3 (PIN_ALT2 | PIN_PORTD | PIN9)
-#define PIN_I2C0_SDA_4 (PIN_ALT5 | PIN_PORTE | PIN25)
-#define PIN_I2C0_SDA_5 (PIN_ALT7 | PIN_PORTD | PIN3)
-
-#define PIN_I2C1_SCL_1 (PIN_ALT2 | PIN_PORTC | PIN10)
-#define PIN_I2C1_SCL_2 (PIN_ALT6 | PIN_PORTE | PIN1)
-#define PIN_I2C1_SDA_1 (PIN_ALT2 | PIN_PORTC | PIN11)
-#define PIN_I2C1_SDA_2 (PIN_ALT6 | PIN_PORTE | PIN0)
-
-#define PIN_I2C2_SCL_1 (PIN_ALT5 | PIN_PORTA | PIN12)
-#define PIN_I2C2_SCL_2 (PIN_ALT5 | PIN_PORTA | PIN14)
-#define PIN_I2C2_SDA_1 (PIN_ALT5 | PIN_PORTA | PIN11)
-#define PIN_I2C2_SDA_2 (PIN_ALT5 | PIN_PORTA | PIN13)
-
-#define PIN_I2C3_SCL_1 (PIN_ALT2 | PIN_PORTE | PIN11)
-#define PIN_I2C3_SCL_2 (PIN_ALT4 | PIN_PORTA | PIN2)
-#define PIN_I2C3_SDA_1 (PIN_ALT2 | PIN_PORTE | PIN10)
-#define PIN_I2C3_SDA_2 (PIN_ALT4 | PIN_PORTA | PIN1)
+#define PIN_I2C0_SCL_1 (PIN_ALT2_OPENDRAIN | PIN_PORTB | PIN0)
+#define PIN_I2C0_SCL_2 (PIN_ALT2_OPENDRAIN | PIN_PORTB | PIN2)
+#define PIN_I2C0_SCL_3 (PIN_ALT2_OPENDRAIN | PIN_PORTD | PIN8)
+#define PIN_I2C0_SCL_4 (PIN_ALT5_OPENDRAIN | PIN_PORTE | PIN24)
+#define PIN_I2C0_SCL_5 (PIN_ALT7_OPENDRAIN | PIN_PORTD | PIN2)
+#define PIN_I2C0_SDA_1 (PIN_ALT2_OPENDRAIN | PIN_PORTB | PIN1)
+#define PIN_I2C0_SDA_2 (PIN_ALT2_OPENDRAIN | PIN_PORTB | PIN3)
+#define PIN_I2C0_SDA_3 (PIN_ALT2_OPENDRAIN | PIN_PORTD | PIN9)
+#define PIN_I2C0_SDA_4 (PIN_ALT5_OPENDRAIN | PIN_PORTE | PIN25)
+#define PIN_I2C0_SDA_5 (PIN_ALT7_OPENDRAIN | PIN_PORTD | PIN3)
+
+#define PIN_I2C1_SCL_1 (PIN_ALT2_OPENDRAIN | PIN_PORTC | PIN10)
+#define PIN_I2C1_SCL_2 (PIN_ALT6_OPENDRAIN | PIN_PORTE | PIN1)
+#define PIN_I2C1_SDA_1 (PIN_ALT2_OPENDRAIN | PIN_PORTC | PIN11)
+#define PIN_I2C1_SDA_2 (PIN_ALT6_OPENDRAIN | PIN_PORTE | PIN0)
+
+#define PIN_I2C2_SCL_1 (PIN_ALT5_OPENDRAIN | PIN_PORTA | PIN12)
+#define PIN_I2C2_SCL_2 (PIN_ALT5_OPENDRAIN | PIN_PORTA | PIN14)
+#define PIN_I2C2_SDA_1 (PIN_ALT5_OPENDRAIN | PIN_PORTA | PIN11)
+#define PIN_I2C2_SDA_2 (PIN_ALT5_OPENDRAIN | PIN_PORTA | PIN13)
+
+#define PIN_I2C3_SCL_1 (PIN_ALT2_OPENDRAIN | PIN_PORTE | PIN11)
+#define PIN_I2C3_SCL_2 (PIN_ALT4_OPENDRAIN | PIN_PORTA | PIN2)
+#define PIN_I2C3_SDA_1 (PIN_ALT2_OPENDRAIN | PIN_PORTE | PIN10)
+#define PIN_I2C3_SDA_2 (PIN_ALT4_OPENDRAIN | PIN_PORTA | PIN1)
/* I2S */
@@ -615,7 +615,7 @@
#define PIN_TPM1_CH1_3 (PIN_ALT6 | PIN_PORTB | PIN1)
#define PIN_TPM2_CH0_1 (PIN_ALT6 | PIN_PORTA | PIN10)
#define PIN_TPM2_CH0_2 (PIN_ALT6 | PIN_PORTB | PIN18)
-#define PIN_TPM2_CH1_1 (PIN_ALT1 | PIN_PORTA | PIN11)
+#define PIN_TPM2_CH1_1 (PIN_ALT6 | PIN_PORTA | PIN11)
#define PIN_TPM2_CH1_2 (PIN_ALT6 | PIN_PORTB | PIN19)
#define PIN_TPM_CLKIN0_1 (PIN_ALT7 | PIN_PORTA | PIN18)
diff --git a/arch/arm/src/kinetis/chip/kinetis_kx6tpm.h b/arch/arm/src/kinetis/chip/kinetis_kx6tpm.h
new file mode 100644
index 0000000000000000000000000000000000000000..2dd103c6566f79969d38ae4a13ecde691d3caa18
--- /dev/null
+++ b/arch/arm/src/kinetis/chip/kinetis_kx6tpm.h
@@ -0,0 +1,211 @@
+/****************************************************************************
+ * arch/arm/src/kinetis/chip/kinetis_kx6tpm.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_KX6TPM_H
+#define __ARCH_ARM_SRC_KINETIS_CHIP_KINETIS_KX6TPM_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include
+
+#include "chip.h"
+
+/****************************************************************************
+ * Pre-processor Declarations
+ ****************************************************************************/
+
+#define KINETIS_TPM_SC_OFFSET 0x0000 /* Status and Control offset*/
+#define KINETIS_TPM_CNT_OFFSET 0x0004 /* Counter offset */
+#define KINETIS_TPM_MOD_OFFSET 0x0008 /* Modulo offset */
+#define KINETIS_TPM_C0SC_OFFSET 0x000C /* Channel 0 Status and Control offset */
+#define KINETIS_TPM_C0V_OFFSET 0x0010 /* Channel 0 Value offset */
+#define KINETIS_TPM_C1SC_OFFSET 0x0014 /* Channel 1 Status and Control offset */
+#define KINETIS_TPM_C1V_OFFSET 0x0018 /* Channel 1 Value offset */
+#define KINETIS_TPM_STATUS_OFFSET 0x0050 /* Capture and Compare Status offset */
+#define KINETIS_TPM_COMBINE_OFFSET 0x0064 /* Combine Channel Register offset */
+#define KINETIS_TPM_POL_OFFSET 0x0070 /* Channel Polarity offset */
+#define KINETIS_TPM_FILTER_OFFSET 0x0078 /* Filter Control offset */
+#define KINETIS_TPM_QDCTRL_OFFSET 0x0080 /* Quadrature Decoder Control and Status offset */
+#define KINETIS_TPM_CONF_OFFSET 0x0084 /* Configuration offset */
+
+#define KINETIS_TPM1_SC (KINETIS_TPM1_BASE + KINETIS_TPM_SC_OFFSET) /* TPM1 Status and Control */
+#define KINETIS_TPM1_CNT (KINETIS_TPM1_BASE + KINETIS_TPM_CNT_OFFSET) /* TPM1 Counter */
+#define KINETIS_TPM1_MOD (KINETIS_TPM1_BASE + KINETIS_TPM_MOD_OFFSET) /* TPM1 Modulo */
+#define KINETIS_TPM1_C0SC (KINETIS_TPM1_BASE + KINETIS_TPM_C0SC_OFFSET) /* TPM1 Channel 0 Status and Control */
+#define KINETIS_TPM1_C0V (KINETIS_TPM1_BASE + KINETIS_TPM_C0V_OFFSET) /* TPM1 Channel 0 Value */
+#define KINETIS_TPM1_C1SC (KINETIS_TPM1_BASE + KINETIS_TPM_C1SC_OFFSET) /* TPM1 Channel 1 Status and Control */
+#define KINETIS_TPM1_C1V (KINETIS_TPM1_BASE + KINETIS_TPM_C1V_OFFSET) /* TPM1 Channel 1 Value */
+#define KINETIS_TPM1_C2SC (KINETIS_TPM1_BASE + KINETIS_TPM_C2SC_OFFSET) /* TPM1 Channel 2 Status and Control */
+#define KINETIS_TPM1_C2V (KINETIS_TPM1_BASE + KINETIS_TPM_C2V_OFFSET) /* TPM1 Channel 2 Value */
+#define KINETIS_TPM1_STATUS (KINETIS_TPM1_BASE + KINETIS_TPM_STATUS_OFFSET) /* TPM1 Capture and Compare Status */
+#define KINETIS_TPM1_COMBINE (KINETIS_TPM1_BASE + KINETIS_TPM_COMBINE_OFFSET) /* TPM1 Combine Channel Register offset */
+#define KINETIS_TPM1_POL (KINETIS_TPM1_BASE + KINETIS_TPM_POL_OFFSET) /* TPM1 Channel Polarity offset */
+#define KINETIS_TPM1_FILTER (KINETIS_TPM1_BASE + KINETIS_TPM_FILTER_OFFSET) /* TPM1 Filter Control offset */
+#define KINETIS_TPM1_QDCTRL (KINETIS_TPM1_BASE + KINETIS_TPM_QDCTRL_OFFSET) /* TPM1 Quadrature Decoder Control and Status offset */
+#define KINETIS_TPM1_CONF (KINETIS_TPM1_BASE + KINETIS_TPM_CONF_OFFSET) /* TPM1 Configuration */
+
+#define KINETIS_TPM2_SC (KINETIS_TPM2_BASE + KINETIS_TPM_SC_OFFSET) /* TPM2 Status and Control */
+#define KINETIS_TPM2_CNT (KINETIS_TPM2_BASE + KINETIS_TPM_CNT_OFFSET) /* TPM2 Counter */
+#define KINETIS_TPM2_MOD (KINETIS_TPM2_BASE + KINETIS_TPM_MOD_OFFSET) /* TPM2 Modulo */
+#define KINETIS_TPM2_C0SC (KINETIS_TPM2_BASE + KINETIS_TPM_C0SC_OFFSET) /* TPM2 Channel 0 Status and Control */
+#define KINETIS_TPM2_C0V (KINETIS_TPM2_BASE + KINETIS_TPM_C0V_OFFSET) /* TPM2 Channel 0 Value */
+#define KINETIS_TPM2_C1SC (KINETIS_TPM2_BASE + KINETIS_TPM_C1SC_OFFSET) /* TPM2 Channel 1 Status and Control */
+#define KINETIS_TPM2_C1V (KINETIS_TPM2_BASE + KINETIS_TPM_C1V_OFFSET) /* TPM2 Channel 1 Value */
+#define KINETIS_TPM2_C2SC (KINETIS_TPM2_BASE + KINETIS_TPM_C2SC_OFFSET) /* TPM2 Channel 2 Status and Control */
+#define KINETIS_TPM2_C2V (KINETIS_TPM2_BASE + KINETIS_TPM_C2V_OFFSET) /* TPM2 Channel 2 Value */
+#define KINETIS_TPM2_STATUS (KINETIS_TPM2_BASE + KINETIS_TPM_STATUS_OFFSET) /* TPM2 Capture and Compare Status */
+#define KINETIS_TPM2_COMBINE (KINETIS_TPM2_BASE + KINETIS_TPM_COMBINE_OFFSET) /* TPM2 Combine Channel Register offset */
+#define KINETIS_TPM2_POL (KINETIS_TPM2_BASE + KINETIS_TPM_POL_OFFSET) /* TPM2 Channel Polarity offset */
+#define KINETIS_TPM2_FILTER (KINETIS_TPM2_BASE + KINETIS_TPM_FILTER_OFFSET) /* TPM2 Filter Control offset */
+#define KINETIS_TPM2_QDCTRL (KINETIS_TPM2_BASE + KINETIS_TPM_QDCTRL_OFFSET) /* TPM2 Quadrature Decoder Control and Status offset */
+#define KINETIS_TPM2_CONF (KINETIS_TPM2_BASE + KINETIS_TPM_CONF_OFFSET) /* TPM2 Configuration */
+
+#define TPM_SC_PS_SHIFT 0 /* Bits 0-2: Prescale Factor Selection */
+#define TPM_SC_PS_MASK (7 << TPM_SC_PS_SHIFT)
+# define TPM_SC_PS_DIV1 (0 << TPM_SC_PS_SHIFT) /* Divide Clock by 1 */
+# define TPM_SC_PS_DIV2 (1 << TPM_SC_PS_SHIFT) /* Divide Clock by 2 */
+# define TPM_SC_PS_DIV4 (2 << TPM_SC_PS_SHIFT) /* Divide Clock by 4 */
+# define TPM_SC_PS_DIV8 (3 << TPM_SC_PS_SHIFT) /* Divide Clock by 8 */
+# define TPM_SC_PS_DIV16 (4 << TPM_SC_PS_SHIFT) /* Divide Clock by 16 */
+# define TPM_SC_PS_DIV32 (5 << TPM_SC_PS_SHIFT) /* Divide Clock by 32 */
+# define TPM_SC_PS_DIV64 (6 << TPM_SC_PS_SHIFT) /* Divide Clock by 64 */
+# define TPM_SC_PS_DIV128 (7 << TPM_SC_PS_SHIFT) /* Divide Clock by 128 */
+
+#define TPM_SC_CMOD_SHIFT 3 /* Bits 3-4: Clock Mode Selection */
+#define TPM_SC_CMOD_MASK (3 << TPM_SC_CMOD_SHIFT)
+# define TPM_SC_CMOD_DIS (0 << TPM_SC_CMOD_SHIFT) /* TPM counter is disabled */
+# define TPM_SC_CMOD_LPTPM_CLK (1 << TPM_SC_CMOD_SHIFT) /* TPM increments on every counter clock */
+# define TPM_SC_CMOD_LPTPM_EXTCLK (2 << TPM_SC_CMOD_SHIFT) /* TPM increments on rising edge of EXTCLK */
+
+#define TPM_SC_CPWMS (1 << 5) /* Bit 5: Center-aligned PWM Select */
+#define TPM_SC_TOIE (1 << 6) /* Bit 6: Timer Overflow Interrupt Enable */
+#define TPM_SC_TOF (1 << 7) /* Bit 7: Timer Overflow Flag*/
+#define TPM_SC_DMA (1 << 8) /* Bit 8: DMA Enable*/
+ /* Bits 9-31: Reserved */
+
+#define TPM_CNT_SHIFT 0 /* Bits 0-15: Counter value */
+#define TPM_CNT_MASK (0xffff << TPM_COUNT_SHIFT) /* Any write clears Count */
+ /* Bits 16-31: Reserved */
+
+#define TPM_MOD_SHIFT 0 /* Bits 0-15: Mod value */
+#define TPM_MOD_MASK (0xffff << TPM_MOD_SHIFT) /* This field must be written with single 16 or 32-bit access */
+ /* Bits 16-31: Reserved */
+
+#define TPM_CnSC_DMA (1 << 0) /* Bit 0: Enables DMA transfers for the channel */
+ /* Bit 1: Reserved*/
+#define TPM_CnSC_ELSA (1 << 2) /* Bit 2: Edge or Level Select */
+#define TPM_CnSC_ELSB (1 << 3) /* Bit 3: Edge or Level Select */
+#define TPM_CnSC_MSA (1 << 4) /* Bit 4: Channel Mode Select */
+#define TPM_CnSC_MSB (1 << 5) /* Bit 5: Channel Mode Select */
+#define TPM_CnSC_CHIE (1 << 6) /* Bit 6: Channel Interrupt Enable */
+#define TPM_CnSC_CHF (1 << 7) /* Bit 7: Channel Flag */
+ /* Bits 8-31: Reserved */
+
+#define TPM_VAL_SHIFT 0 /* Bits 0-15: Channel value */
+#define TPM_VAL_MASK (0xffff << TPM_VAL_SHIFT) /* Captured TPM counter value of the input modes or
+ * the match value for the output modes. This field
+ * must be written with single 16 or 32-bit access.*/
+ /* Bits 16-31: Reserved */
+
+#define TPM_STATUS_CH0F (1 << 0) /* Bit 0: Channel 0 Flag */
+#define TPM_STATUS_CH1F (1 << 1) /* Bit 1: Channel 1 Flag */
+ /* Bits 2-7: Reserved */
+#define TPM_STATUS_TOF (1 << 8) /* Bit 8: Timer Overflow Flag */
+ /* Bits 9-31: Reserved */
+
+#define TPM_COMBINE_COMBINE0 (1 << 0) /* Bit 0: Combine Channels 0 and 1 */
+#define TPM_COMBINE_COMSWAP0 (1 << 1) /* Bit 1: Combine Channel 0 and 1 Swap */
+ /* Bits 2-7: Reserved */
+ /* Bits 8-31: Reserved */
+
+#define TPM_POL_POL0 (1 << 0) /* Bit 0: Channel 0 Polarity */
+#define TPM_POL_POL1 (1 << 1) /* Bit 1: Channel 1 Polarity */
+ /* Bits 2-31: Reserved */
+
+#define TPM_FILTER_CH0FVAL_SHIFT 0 /* Bits 0-3: Channel 0 Filter Value */
+#define TPM_FILTER_CH0FVAL_MASK (0xf << TPM_FILTER_CH0FVAL_SHIFT)
+#define TPM_FILTER_CH1FVAL_SHIFT 4 /* Bits 4-7: Channel 1 Filter Value */
+#define TPM_FILTER_CH1FVAL_MASK (0xf << TPM_FILTER_CH1FVAL_SHIFT)
+
+#define TPM_QDCTRL_QDCTRL (1 << 0) /* Bit 0: Enables the quadrature decoder mode */
+#define TPM_QDCTRL_TOFDIR (1 << 1) /* Bit 1: Indicates if the TOF bit was set (Read Only) */
+#define TPM_QDCTRL_QUADIR (1 << 2) /* Bit 2: Counter Direction in Quadrature Decode Mode (Read Only) */
+#define TPM_QDCTRL_QUADMODE (1 << 3) /* Bit 3: Quadrature Decoder Mode */
+ /* Bits 4-31: Reserved */
+
+#define TPM_CONF_DOZEEN (1 << 5) /* Bit 5: Doze Enable */
+#define TPM_CONF_DBGMODE_SHIFT 6 /* Bits 6-7: Debug Mode */
+#define TPM_CONF_DBGMODE_MASK (3 << TPM_CONF_DBGMODE_SHIFT)
+# define TPM_CONF_DBGMODE_PAUSE (0 << TPM_CONF_DBGMODE_SHIFT) /* TPM counter will pause during DEBUG mode */
+# define TPM_CONF_DBGMODE_CONT (3 << TPM_CONF_DBGMODE_SHIFT) /* TPM counter continue working in DEBUG mode */
+#define TPM_CONF_GTBSYNC (1 << 8) /* Bit 8: Global Time Base Synchronization */
+#define TPM_CONF_GTBEEN (1 << 9) /* Bit 9: Global Time Base Enable */
+ /* Bits 10-15: Reserved */
+#define TPM_CONF_CSOT (1 << 16) /* Bit 16: Counter Start On Trigger */
+#define TPM_CONF_CSOO (1 << 17) /* Bit 17: Counter Stop On Overflow */
+#define TPM_CONF_CROT (1 << 18) /* Bit 18: Counter Reload On Trigger */
+#define TPM_CONF_CPOT (1 << 19) /* Bit 19: Counter Pause On Trigger */
+ /* Bits 20-21: Reserved */
+#define TPM_CONF_TRGPOL (1 << 22) /* Bit 22: Trigger Polarity */
+#define TPM_CONF_TRGSRC (1 << 23) /* Bit 23: Trigger Source */
+
+#define TPM_CONF_TRGSEL_SHIFT 24 /* Bits 24-27: Trigger Select */
+#define TPM_CONF_TRGSEL_MASK (0xf << TPM_CONF_TRGSEL_SHIFT)
+ /* Internal TPM_CONF_TRGSRC set */
+# define TPM_CONF_TRGSEL_INTC0 (0 << TPM_CONF_TRGSEL_SHIFT) /* Internal Channel 0 pin input capture */
+# define TPM_CONF_TRGSEL_INTC1 (2 << TPM_CONF_TRGSEL_SHIFT) /* Internal Channel 1 pin input capture */
+# define TPM_CONF_TRGSEL_INTC01 (3 << TPM_CONF_TRGSEL_SHIFT) /* Internal Channel 0 or 1 pin input capture */
+
+# define TPM_CONF_TRGSEL_EXTRG_IN (0 << TPM_CONF_TRGSEL_SHIFT) /* External trigger pin input */
+# define TPM_CONF_TRGSEL_CMP0 (1 << TPM_CONF_TRGSEL_SHIFT) /* CPM0 output */
+# define TPM_CONF_TRGSEL_CMP1 (2 << TPM_CONF_TRGSEL_SHIFT) /* CPM1 output */
+# define TPM_CONF_TRGSEL_CMP2 (3 << TPM_CONF_TRGSEL_SHIFT) /* CPM2 output */
+# define TPM_CONF_TRGSEL_PIT0 (4 << TPM_CONF_TRGSEL_SHIFT) /* PIT trigger 0 */
+# define TPM_CONF_TRGSEL_PIT1 (5 << TPM_CONF_TRGSEL_SHIFT) /* PIT trigger 1 */
+# define TPM_CONF_TRGSEL_PIT2 (6 << TPM_CONF_TRGSEL_SHIFT) /* PIT trigger 2 */
+# define TPM_CONF_TRGSEL_PIT3 (7 << TPM_CONF_TRGSEL_SHIFT) /* PIT trigger 3 */
+# define TPM_CONF_TRGSEL_FTM0 (8 << TPM_CONF_TRGSEL_SHIFT) /* FTM0 initialization trigger and channel triggers */
+# define TPM_CONF_TRGSEL_FTM1 (9 << TPM_CONF_TRGSEL_SHIFT) /* FTM1 initialization trigger and channel triggers */
+# define TPM_CONF_TRGSEL_FTM2 (10 << TPM_CONF_TRGSEL_SHIFT) /* FTM2 initialization trigger and channel triggers */
+# define TPM_CONF_TRGSEL_FTM3 (11 << TPM_CONF_TRGSEL_SHIFT) /* FTM3 initialization trigger and channel triggers */
+# define TPM_CONF_TRGSEL_RTC_ALRM (12 << TPM_CONF_TRGSEL_SHIFT) /* RTC Alarm */
+# define TPM_CONF_TRGSEL_RTC_SECS (13 << TPM_CONF_TRGSEL_SHIFT) /* RTC Seconds */
+# define TPM_CONF_TRGSEL_LPTMR (14 << TPM_CONF_TRGSEL_SHIFT) /* LPTMR trigger */
+# define TPM_CONF_TRGSEL_SW (15 << TPM_CONF_TRGSEL_SHIFT) /* Software Trigger */
+
+#endif /* __ARCH_ARM_SRC_KINETIS_CHIP_KINETIS_KX6TPM_H */
diff --git a/arch/arm/src/kinetis/chip/kinetis_osc.h b/arch/arm/src/kinetis/chip/kinetis_osc.h
index 69a7b8a30c8cabb5d7fd8ea17946893363f1437e..e61f0a8c1c602408c7d9bf0487508543dc02560d 100644
--- a/arch/arm/src/kinetis/chip/kinetis_osc.h
+++ b/arch/arm/src/kinetis/chip/kinetis_osc.h
@@ -1,7 +1,7 @@
/********************************************************************************************
* arch/arm/src/kinetis/chip/kinetis_osc.h
*
- * Copyright (C) 2011, 2016 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2011, 2016-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
*
* Redistribution and use in source and binary forms, with or without
@@ -51,10 +51,12 @@
/* Register Offsets *************************************************************************/
#define KINETIS_OSC_CR_OFFSET 0x0000 /* OSC Control Register */
+#define KINETIS_OSC_DIV_OFFSET 0x0002 /* OSC CLock divider register */
/* Register Addresses ***********************************************************************/
#define KINETIS_OSC_CR (KINETIS_OSC_BASE+KINETIS_OSC_CR_OFFSET)
+#define KINETIS_OSC_DIV (KINETIS_OSC_BASE+KINETIS_OSC_DIV_OFFSET)
/* Register Bit Definitions *****************************************************************/
@@ -69,6 +71,15 @@
#define OSC_CR_SC8P (1 << 1) /* Bit 1: Oscillator 8 pF Capacitor Load Configure */
#define OSC_CR_SC16P (1 << 0) /* Bit 0: Oscillator 16 pF Capacitor Load Configure */
+/* OSC Control Register (8-bit) */
+ /* Bits 0-5: Reserved */
+#define OSC_DIV_ERPS_SHIFT 6 /* Bits 6-7: ERCLK prescaler */
+#define OSC_DIV_ERPS_MASK (3 << OSC_DIV_ERPS_SHIFT)
+# define OSC_DIV_ERPS_DIV1 (0 << OSC_DIV_ERPS_SHIFT) /* The divisor ratio is 1 */
+# define OSC_DIV_ERPS_DIV2 (1 << OSC_DIV_ERPS_SHIFT) /* The divisor ratio is 2 */
+# define OSC_DIV_ERPS_DIV3 (2 << OSC_DIV_ERPS_SHIFT) /* The divisor ratio is 4 */
+# define OSC_DIV_ERPS_DIV8 (3 << OSC_DIV_ERPS_SHIFT) /* The divisor ratio is 8 */
+
/********************************************************************************************
* Public Types
********************************************************************************************/
diff --git a/arch/arm/src/kinetis/chip/kinetis_sim.h b/arch/arm/src/kinetis/chip/kinetis_sim.h
index 3e6cb6a6efb709c19036429963baf371e7cbc33a..fbeba3983d947d2dd176fbaa302a04102497fc4a 100644
--- a/arch/arm/src/kinetis/chip/kinetis_sim.h
+++ b/arch/arm/src/kinetis/chip/kinetis_sim.h
@@ -328,7 +328,7 @@
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 */
+# define SIM_SOPT2_TPMSRC_MCGIRCLK (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 */
@@ -348,7 +348,7 @@
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 */
+# define SIM_SOPT2_LPUARTSRC_MCGIRCLK (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 */
@@ -1057,7 +1057,7 @@
#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(n) ((uint32_t)(((n)-1) & 0xf) << 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 */
@@ -1078,7 +1078,7 @@
#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(n) ((uint32_t)(((n)-1) & 0xf) << 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 */
@@ -1099,7 +1099,7 @@
#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(n) ((uint32_t)(((n)-1) & 0xf) << 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 */
@@ -1119,7 +1119,7 @@
#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(n) ((uint32_t)(((n)-1) & 0xf) << 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 */
diff --git a/arch/arm/src/kinetis/kinetis.h b/arch/arm/src/kinetis/kinetis.h
index 3f171e223b5cea7f85817e464b1e7609fb96169d..a1558179fd07f1ac446e6cc583a58821cc4b18b1 100644
--- a/arch/arm/src/kinetis/kinetis.h
+++ b/arch/arm/src/kinetis/kinetis.h
@@ -82,7 +82,8 @@
/* Port Modes */
/* Unshifted versions: */
#define PIN_MODE_ANALOG (0) /* 000 Pin Disabled (Analog) */
-#define PIN_MODE_GPIO (1) /* 001 Alternative 1 (GPIO) */
+#define PIN_MODE_ALT1 (1) /* 001 Alternative 1 */
+#define PIN_MODE_GPIO PIN_MODE_ALT1 /* 001 Alternative 1 (GPIO) */
#define PIN_MODE_ALT2 (2) /* 010 Alternative 2 */
#define PIN_MODE_ALT3 (3) /* 011 Alternative 3 */
#define PIN_MODE_ALT4 (4) /* 100 Alternative 4 */
@@ -91,6 +92,7 @@
#define PIN_MODE_ALT7 (7) /* 111 Alternative 7 */
/* Shifted versions: */
#define _PIN_MODE_ANALOG (0 << _PIN_MODE_SHIFT) /* 000 Pin Disabled (Analog) */
+#define _PIN_MODE_ALT1 (1 << _PIN_MODE_SHIFT) /* 001 Alternative 1 */
#define _PIN_MODE_GPIO (1 << _PIN_MODE_SHIFT) /* 001 Alternative 1 (GPIO) */
#define _PIN_MODE_ALT2 (2 << _PIN_MODE_SHIFT) /* 010 Alternative 2 */
#define _PIN_MODE_ALT3 (3 << _PIN_MODE_SHIFT) /* 011 Alternative 3 */
@@ -137,6 +139,17 @@
#define GPIO_LOWDRIVE (_PIN_MODE_GPIO | _PIN_OUTPUT_LOWDRIVE)
#define GPIO_HIGHDRIVE (_PIN_MODE_GPIO | _PIN_OUTPUT_HIGHDRIVE)
+#define PIN_ALT1 _PIN_MODE_ALT1
+#define PIN_ALT1_INPUT (_PIN_MODE_ALT1 | _PIN_INPUT)
+#define PIN_ALT1_PULLDOWN (_PIN_MODE_ALT1 | _PIN_INPUT_PULLDOWN)
+#define PIN_ALT1_PULLUP (_PIN_MODE_ALT1 | _PIN_INPUT_PULLUP)
+#define PIN_ALT1_OUTPUT (_PIN_MODE_ALT1 | _PIN_OUTPUT)
+#define PIN_ALT1_FAST (_PIN_MODE_ALT1 | _PIN_OUTPUT_FAST)
+#define PIN_ALT1_SLOW (_PIN_MODE_ALT1 | _PIN_OUTPUT_SLOW)
+#define PIN_ALT1_OPENDRAIN (_PIN_MODE_ALT1 | _PIN_OUTPUT_OPENDRAIN)
+#define PIN_ALT1_LOWDRIVE (_PIN_MODE_ALT1 | _PIN_OUTPUT_LOWDRIVE)
+#define PIN_ALT1_HIGHDRIVE (_PIN_MODE_ALT1 | _PIN_OUTPUT_HIGHDRIVE)
+
#define PIN_ALT2 _PIN_MODE_ALT2
#define PIN_ALT2_INPUT (_PIN_MODE_ALT2 | _PIN_INPUT)
#define PIN_ALT2_PULLDOWN (_PIN_MODE_ALT2 | _PIN_INPUT_PULLDOWN)
@@ -468,7 +481,8 @@ void kinetis_lpuartreset(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 stop2);
+ unsigned int stop2,
+ bool iflow, bool oflow);
#endif
/****************************************************************************
@@ -482,7 +496,8 @@ void kinetis_uartconfigure(uintptr_t uart_base, uint32_t baud, uint32_t clock,
#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);
+ unsigned int stop2,
+ bool iflow, bool oflow);
#endif
/************************************************************************************
diff --git a/arch/arm/src/kinetis/kinetis_clockconfig.c b/arch/arm/src/kinetis/kinetis_clockconfig.c
index b954f33be2e4fd75b1074fb5b85540349c3d511e..28218fcd86c50723b605d0c18fb1992caee0fbf2 100644
--- a/arch/arm/src/kinetis/kinetis_clockconfig.c
+++ b/arch/arm/src/kinetis/kinetis_clockconfig.c
@@ -49,6 +49,7 @@
#include "chip/kinetis_pmc.h"
#include "chip/kinetis_llwu.h"
#include "chip/kinetis_pinmux.h"
+#include "chip/kinetis_osc.h"
#include
@@ -199,6 +200,18 @@ void kinetis_pllconfig(void)
#endif
uint8_t regval8;
+#if defined(BOARD_OSC_CR)
+ /* Use complete BOARD_OSC_CR settings */
+
+ putreg8(BOARD_OSC_CR, KINETIS_OSC_CR);
+#endif
+
+#if defined(BOARD_OSC_DIV)
+ /* Use complete BOARD_OSC_DIV settings */
+
+ putreg8(BOARD_OSC_DIV, KINETIS_OSC_DIV);
+#endif
+
#if defined(BOARD_MCG_C2)
/* Use complete BOARD_MCG_C2 settings */
diff --git a/arch/arm/src/kinetis/kinetis_clrpend.c b/arch/arm/src/kinetis/kinetis_clrpend.c
index faf35271d8f1d4bff1ae7147fb71fd61cfedcd2f..aad182df3694db5cd0852b223476a05c2c885b47 100644
--- a/arch/arm/src/kinetis/kinetis_clrpend.c
+++ b/arch/arm/src/kinetis/kinetis_clrpend.c
@@ -1,6 +1,5 @@
/****************************************************************************
* arch/arm/src/kinetis/kinetis_clrpend.c
- * arch/arm/src/chip/kinetis_clrpend.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
diff --git a/arch/arm/src/kinetis/kinetis_enet.c b/arch/arm/src/kinetis/kinetis_enet.c
index 694b155734c5ef900e01cdc00e4e9ea41362f586..1a13ab856a147041be4db43d35b5a9505d3a3064 100644
--- a/arch/arm/src/kinetis/kinetis_enet.c
+++ b/arch/arm/src/kinetis/kinetis_enet.c
@@ -297,28 +297,30 @@ static void kinetis_polltimer_expiry(int argc, uint32_t arg, ...);
/* NuttX callback functions */
-static int kinetis_ifup(struct net_driver_s *dev);
-static int kinetis_ifdown(struct net_driver_s *dev);
+static int kinetis_ifup(struct net_driver_s *dev);
+static int kinetis_ifdown(struct net_driver_s *dev);
static void kinetis_txavail_work(FAR void *arg);
-static int kinetis_txavail(struct net_driver_s *dev);
+static int kinetis_txavail(struct net_driver_s *dev);
#ifdef CONFIG_NET_IGMP
-static int kinetis_addmac(struct net_driver_s *dev, FAR const uint8_t *mac);
-static int kinetis_rmmac(struct net_driver_s *dev, FAR const uint8_t *mac);
+static int kinetis_addmac(struct net_driver_s *dev,
+ FAR const uint8_t *mac);
+static int kinetis_rmmac(struct net_driver_s *dev, FAR const uint8_t *mac);
#endif
#ifdef CONFIG_NETDEV_PHY_IOCTL
-static int kinetis_ioctl(struct net_driver_s *dev, int cmd, long arg);
+static int kinetis_ioctl(struct net_driver_s *dev, int cmd,
+ unsigned long arg);
#endif
/* PHY/MII support */
static inline void kinetis_initmii(struct kinetis_driver_s *priv);
static int kinetis_writemii(struct kinetis_driver_s *priv, uint8_t phyaddr,
- uint8_t regaddr, uint16_t data);
+ uint8_t regaddr, uint16_t data);
static int kinetis_readmii(struct kinetis_driver_s *priv, uint8_t phyaddr,
- uint8_t regaddr, uint16_t *data);
+ uint8_t regaddr, uint16_t *data);
static inline int kinetis_initphy(struct kinetis_driver_s *priv);
/* Initialization */
@@ -1123,7 +1125,7 @@ static int kinetis_ifup(struct net_driver_s *dev)
{
FAR struct kinetis_driver_s *priv =
(FAR struct kinetis_driver_s *)dev->d_private;
- uint8_t *mac = dev->d_mac.ether_addr_octet;
+ uint8_t *mac = dev->d_mac.ether.ether_addr_octet;
uint32_t regval;
int ret;
@@ -1447,7 +1449,7 @@ static int kinetis_rmmac(struct net_driver_s *dev, FAR const uint8_t *mac)
****************************************************************************/
#ifdef CONFIG_NETDEV_PHY_IOCTL
-static int kinetis_ioctl(struct net_driver_s *dev, int cmd, long arg)
+static int kinetis_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
{
int ret;
FAR struct kinetis_driver_s *priv =
@@ -2142,7 +2144,7 @@ int kinetis_netinitialize(int intf)
uidl = getreg32(KINETIS_SIM_UIDL);
uidml = getreg32(KINETIS_SIM_UIDML);
- mac = priv->dev.d_mac.ether_addr_octet;
+ mac = priv->dev.d_mac.ether.ether_addr_octet;
uidml |= 0x00000200;
uidml &= 0x0000FEFF;
diff --git a/arch/arm/src/kinetis/kinetis_lowputc.c b/arch/arm/src/kinetis/kinetis_lowputc.c
index 31bb32f697b936efb4bce26878539827a5ffb587..bfc56dd069f005cb640c06ed54d8f663252903ad 100644
--- a/arch/arm/src/kinetis/kinetis_lowputc.c
+++ b/arch/arm/src/kinetis/kinetis_lowputc.c
@@ -41,6 +41,7 @@
#include
#include
+#include
#include
#include
@@ -59,6 +60,58 @@
* Pre-processor Definitions
****************************************************************************/
+/* Default hardware flow control */
+
+#if !defined(CONFIG_UART0_IFLOWCONTROL)
+# define CONFIG_UART0_IFLOWCONTROL 0
+#endif
+#if !defined(CONFIG_UART0_OFLOWCONTROL)
+# define CONFIG_UART0_OFLOWCONTROL 0
+#endif
+#if !defined(CONFIG_UART1_IFLOWCONTROL)
+# define CONFIG_UART1_IFLOWCONTROL 0
+#endif
+#if !defined(CONFIG_UART1_OFLOWCONTROL)
+# define CONFIG_UART1_OFLOWCONTROL 0
+#endif
+#if !defined(CONFIG_UART2_IFLOWCONTROL)
+# define CONFIG_UART2_IFLOWCONTROL 0
+#endif
+#if !defined(CONFIG_UART2_OFLOWCONTROL)
+# define CONFIG_UART2_OFLOWCONTROL 0
+#endif
+#if !defined(CONFIG_UART3_IFLOWCONTROL)
+# define CONFIG_UART3_IFLOWCONTROL 0
+#endif
+#if !defined(CONFIG_UART3_OFLOWCONTROL)
+# define CONFIG_UART3_OFLOWCONTROL 0
+#endif
+#if !defined(CONFIG_UART4_IFLOWCONTROL)
+# define CONFIG_UART4_IFLOWCONTROL 0
+#endif
+#if !defined(CONFIG_UART4_OFLOWCONTROL)
+# define CONFIG_UART4_OFLOWCONTROL 0
+#endif
+#if !defined(CONFIG_UART5_IFLOWCONTROL)
+# define CONFIG_UART5_IFLOWCONTROL 0
+#endif
+#if !defined(CONFIG_UART5_OFLOWCONTROL)
+# define CONFIG_UART5_OFLOWCONTROL 0
+#endif
+
+#if !defined(CONFIG_LPUART0_IFLOWCONTROL)
+# define CONFIG_LPUART0_IFLOWCONTROL 0
+#endif
+#if !defined(CONFIG_LPUART0_OFLOWCONTROL)
+# define CONFIG_LPUART0_OFLOWCONTROL 0
+#endif
+#if !defined(CONFIG_LPUART1_IFLOWCONTROL)
+# define CONFIG_LPUART1_IFLOWCONTROL 0
+#endif
+#if !defined(CONFIG_LPUART1_OFLOWCONTROL)
+# define CONFIG_LPUART1_OFLOWCONTROL 0
+#endif
+
/* Select UART parameters for the selected console */
#if defined(HAVE_UART_CONSOLE)
@@ -69,6 +122,8 @@
# define CONSOLE_BITS CONFIG_UART0_BITS
# define CONSOLE_2STOP CONFIG_UART0_2STOP
# define CONSOLE_PARITY CONFIG_UART0_PARITY
+# define CONSOLE_IFLOW CONFIG_UART0_IFLOWCONTROL
+# define CONSOLE_OFLOW CONFIG_UART0_OFLOWCONTROL
# elif defined(CONFIG_UART1_SERIAL_CONSOLE)
# define CONSOLE_BASE KINETIS_UART1_BASE
# define CONSOLE_FREQ BOARD_CORECLK_FREQ
@@ -76,6 +131,8 @@
# define CONSOLE_BITS CONFIG_UART1_BITS
# define CONSOLE_2STOP CONFIG_UART1_2STOP
# define CONSOLE_PARITY CONFIG_UART1_PARITY
+# define CONSOLE_IFLOW CONFIG_UART1_IFLOWCONTROL
+# define CONSOLE_OFLOW CONFIG_UART1_OFLOWCONTROL
# elif defined(CONFIG_UART2_SERIAL_CONSOLE)
# define CONSOLE_BASE KINETIS_UART2_BASE
# define CONSOLE_FREQ BOARD_BUS_FREQ
@@ -83,6 +140,8 @@
# define CONSOLE_BITS CONFIG_UART2_BITS
# define CONSOLE_2STOP CONFIG_UART2_2STOP
# define CONSOLE_PARITY CONFIG_UART2_PARITY
+# define CONSOLE_IFLOW CONFIG_UART2_IFLOWCONTROL
+# define CONSOLE_OFLOW CONFIG_UART2_OFLOWCONTROL
# elif defined(CONFIG_UART3_SERIAL_CONSOLE)
# define CONSOLE_BASE KINETIS_UART3_BASE
# define CONSOLE_FREQ BOARD_BUS_FREQ
@@ -90,6 +149,8 @@
# define CONSOLE_BITS CONFIG_UART3_BITS
# define CONSOLE_2STOP CONFIG_UART3_2STOP
# define CONSOLE_PARITY CONFIG_UART3_PARITY
+# define CONSOLE_IFLOW CONFIG_UART3_IFLOWCONTROL
+# define CONSOLE_OFLOW CONFIG_UART3_OFLOWCONTROL
# elif defined(CONFIG_UART4_SERIAL_CONSOLE)
# define CONSOLE_BASE KINETIS_UART4_BASE
# define CONSOLE_FREQ BOARD_BUS_FREQ
@@ -97,6 +158,8 @@
# define CONSOLE_BITS CONFIG_UART4_BITS
# define CONSOLE_2STOP CONFIG_UART4_2STOP
# define CONSOLE_PARITY CONFIG_UART4_PARITY
+# define CONSOLE_IFLOW CONFIG_UART4_IFLOWCONTROL
+# define CONSOLE_OFLOW CONFIG_UART4_OFLOWCONTROL
# elif defined(CONFIG_UART5_SERIAL_CONSOLE)
# define CONSOLE_BASE KINETIS_UART5_BASE
# define CONSOLE_FREQ BOARD_BUS_FREQ
@@ -104,6 +167,8 @@
# define CONSOLE_BITS CONFIG_UART5_BITS
# define CONSOLE_2STOP CONFIG_UART5_2STOP
# define CONSOLE_PARITY CONFIG_UART5_PARITY
+# define CONSOLE_IFLOW CONFIG_UART5_IFLOWCONTROL
+# define CONSOLE_OFLOW CONFIG_UART5_OFLOWCONTROL
# elif defined(HAVE_UART_CONSOLE)
# error "No CONFIG_UARTn_SERIAL_CONSOLE Setting"
# endif
@@ -115,6 +180,8 @@
# define CONSOLE_PARITY CONFIG_LPUART0_PARITY
# define CONSOLE_BITS CONFIG_LPUART0_BITS
# define CONSOLE_2STOP CONFIG_LPUART0_2STOP
+# define CONSOLE_IFLOW CONFIG_LPUART0_IFLOWCONTROL
+# define CONSOLE_OFLOW CONFIG_LPUART0_OFLOWCONTROL
# elif defined(CONFIG_LPUART1_SERIAL_CONSOLE)
# define CONSOLE_BASE KINETIS_LPUART1_BASE
# define CONSOLE_FREQ BOARD_LPUART1_FREQ
@@ -122,6 +189,8 @@
# define CONSOLE_PARITY CONFIG_LPUART1_PARITY
# define CONSOLE_BITS CONFIG_LPUART1_BITS
# define CONSOLE_2STOP CONFIG_LPUART1_2STOP
+# define CONSOLE_IFLOW CONFIG_LPUART1_IFLOWCONTROL
+# define CONSOLE_OFLOW CONFIG_LPUART1_OFLOWCONTROL
# else
# error "No LPUART console is selected"
# endif
@@ -271,26 +340,62 @@ void kinetis_lowsetup(void)
# ifdef CONFIG_KINETIS_UART0
kinetis_pinconfig(PIN_UART0_TX);
kinetis_pinconfig(PIN_UART0_RX);
+# if CONFIG_UART0_IFLOWCONTROL == 1
+ kinetis_pinconfig(PIN_UART0_RTS);
+# endif
+# if CONFIG_UART0_OFLOWCONTROL == 1
+ kinetis_pinconfig(PIN_UART0_CTS);
+# endif
# endif
# ifdef CONFIG_KINETIS_UART1
kinetis_pinconfig(PIN_UART1_TX);
kinetis_pinconfig(PIN_UART1_RX);
+# if CONFIG_UART1_IFLOWCONTROL == 1
+ kinetis_pinconfig(PIN_UART1_RTS);
+# endif
+# if CONFIG_UART1_OFLOWCONTROL == 1
+ kinetis_pinconfig(PIN_UART1_CTS);
+# endif
# endif
# ifdef CONFIG_KINETIS_UART2
kinetis_pinconfig(PIN_UART2_TX);
kinetis_pinconfig(PIN_UART2_RX);
+# if CONFIG_UART2_IFLOWCONTROL == 1
+ kinetis_pinconfig(PIN_UART2_RTS);
+# endif
+# if CONFIG_UART2_OFLOWCONTROL == 1
+ kinetis_pinconfig(PIN_UART2_CTS);
+# endif
# endif
# ifdef CONFIG_KINETIS_UART3
kinetis_pinconfig(PIN_UART3_TX);
kinetis_pinconfig(PIN_UART3_RX);
+# if CONFIG_UART3_IFLOWCONTROL == 1
+ kinetis_pinconfig(PIN_UART3_RTS);
+# endif
+# if CONFIG_UART3_OFLOWCONTROL == 1
+ kinetis_pinconfig(PIN_UART3_CTS);
+# endif
# endif
# ifdef CONFIG_KINETIS_UART4
kinetis_pinconfig(PIN_UART4_TX);
kinetis_pinconfig(PIN_UART4_RX);
+# if CONFIG_UART4_IFLOWCONTROL == 1
+ kinetis_pinconfig(PIN_UART4_RTS);
+# endif
+# if CONFIG_UART4_OFLOWCONTROL == 1
+ kinetis_pinconfig(PIN_UART4_CTS);
+# endif
# endif
# ifdef CONFIG_KINETIS_UART5
kinetis_pinconfig(PIN_UART5_TX);
kinetis_pinconfig(PIN_UART5_RX);
+# if CONFIG_UART5_IFLOWCONTROL == 1
+ kinetis_pinconfig(PIN_UART5_RTS);
+# endif
+# if CONFIG_UART5_OFLOWCONTROL == 1
+ kinetis_pinconfig(PIN_UART5_CTS);
+# endif
# endif
/* Configure the console (only) now. Other UARTs will be configured
@@ -300,7 +405,8 @@ void kinetis_lowsetup(void)
# if defined(HAVE_UART_CONSOLE) && !defined(CONFIG_SUPPRESS_UART_CONFIG)
kinetis_uartconfigure(CONSOLE_BASE, CONSOLE_BAUD, CONSOLE_FREQ, \
- CONSOLE_PARITY, CONSOLE_BITS, CONSOLE_2STOP);
+ CONSOLE_PARITY, CONSOLE_BITS, CONSOLE_2STOP, \
+ CONSOLE_IFLOW, CONSOLE_OFLOW);
# endif
#endif /* HAVE_UART_DEVICE */
@@ -327,17 +433,30 @@ void kinetis_lowsetup(void)
# ifdef CONFIG_KINETIS_LPUART0
kinetis_pinconfig(PIN_LPUART0_TX);
kinetis_pinconfig(PIN_LPUART0_RX);
+# if CONFIG_LPUART0_IFLOWCONTROL == 1
+ kinetis_pinconfig(PIN_LPUART0_RTS);
+# endif
+# if CONFIG_LPUART0_OFLOWCONTROL == 1
+ kinetis_pinconfig(PIN_LOUART0_CTS);
+# endif
# endif
# ifdef CONFIG_KINETIS_LPUART1
kinetis_pinconfig(PIN_LPUART1_TX);
kinetis_pinconfig(PIN_LPUART1_RX);
+# if CONFIG_LPUART1_IFLOWCONTROL == 1
+ kinetis_pinconfig(PIN_LPUART1_RTS);
+# endif
+# if CONFIG_LPUART1_OFLOWCONTROL == 1
+ kinetis_pinconfig(PIN_LOUART1_CTS);
+# endif
# 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);
+ CONSOLE_PARITY, CONSOLE_BITS, CONSOLE_2STOP, \
+ CONSOLE_IFLOW, CONSOLE_OFLOW);
# endif
#endif /* HAVE_LPUART_DEVICE */
}
@@ -395,7 +514,8 @@ void kinetis_lpuartreset(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 stop2)
+ unsigned int nbits, unsigned int stop2,
+ bool iflow, bool oflow)
{
uint32_t sbr;
uint32_t brfa;
@@ -542,6 +662,27 @@ void kinetis_uartconfigure(uintptr_t uart_base, uint32_t baud,
putreg8(0, uart_base+KINETIS_UART_PFIFO_OFFSET);
#endif
+ /* Hardware flow control */
+
+ regval = getreg8(uart_base+KINETIS_UART_MODEM_OFFSET);
+ regval &= ~(UART_MODEM_TXCTSE | UART_MODEM_RXRTSE);
+
+#ifdef CONFIG_SERIAL_IFLOWCONTROL
+ if (iflow)
+ {
+ regval |= UART_MODEM_RXRTSE;
+ }
+#endif
+
+#ifdef CONFIG_SERIAL_OFLOWCONTROL
+ if (oflow)
+ {
+ regval |= UART_MODEM_TXCTSE;
+ }
+#endif
+
+ putreg8(regval, uart_base+KINETIS_UART_MODEM_OFFSET);
+
/* Now we can (re-)enable the transmitter and receiver */
regval = getreg8(uart_base+KINETIS_UART_C2_OFFSET);
@@ -561,7 +702,8 @@ void kinetis_uartconfigure(uintptr_t uart_base, uint32_t baud,
#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)
+ unsigned int nbits, unsigned int stop2,
+ bool iflow, bool oflow)
{
uint32_t sbrreg;
uint32_t osrreg;
@@ -711,6 +853,25 @@ void kinetis_lpuartconfigure(uintptr_t uart_base, uint32_t baud,
DEBUGASSERT(nbits == 8);
}
+ /* Hardware flow control */
+
+ regval = getreg32(uart_base+KINETIS_LPUART_MODIR_OFFSET);
+ regval &= ~(UART_MODEM_TXCTSE | UART_MODEM_RXRTSE);
+
+#ifdef CONFIG_SERIAL_IFLOWCONTROL
+ if (iflow)
+ {
+ regval |= LPUART_MODIR_RXRTSE;
+ }
+#endif
+ #ifdef CONFIG_SERIAL_OFLOWCONTROL
+ if (oflow)
+ {
+ regval |= LPUART_MODIR_TXCTSE;
+ }
+#endif
+ putreg32(regval, uart_base+KINETIS_LPUART_MODIR_OFFSET);
+
/* Now we can (re-)enable the transmitter and receiver */
regval |= (LPUART_CTRL_RE | LPUART_CTRL_TE);
diff --git a/arch/arm/src/kinetis/kinetis_lpserial.c b/arch/arm/src/kinetis/kinetis_lpserial.c
index 2980f18b8d445bed636c513d7fe7bcaf625e2bc5..262bda4a8a4e907e989b5cfaf16a5cf4aae74655 100644
--- a/arch/arm/src/kinetis/kinetis_lpserial.c
+++ b/arch/arm/src/kinetis/kinetis_lpserial.c
@@ -53,15 +53,19 @@
#include
#include
+#ifdef CONFIG_SERIAL_TERMIOS
+# include
+#endif
+
+#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"
+#include "chip/kinetis_lpuart.h"
+#include "chip/kinetis_pinmux.h"
/****************************************************************************
* Pre-processor Definitions
@@ -153,6 +157,18 @@ struct kinetis_dev_s
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 */
+#ifdef CONFIG_SERIAL_IFLOWCONTROL
+ bool iflow; /* input flow control (RTS) enabled */
+#endif
+#ifdef CONFIG_SERIAL_OFLOWCONTROL
+ bool oflow; /* output flow control (CTS) enabled */
+#endif
+#ifdef CONFIG_SERIAL_IFLOWCONTROL
+ uint32_t rts_gpio; /* UART RTS GPIO pin configuration */
+#endif
+#ifdef CONFIG_SERIAL_OFLOWCONTROL
+ uint32_t cts_gpio; /* UART CTS GPIO pin configuration */
+#endif
};
/****************************************************************************
@@ -168,6 +184,10 @@ 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);
+#ifdef CONFIG_SERIAL_IFLOWCONTROL
+static bool kinetis_rxflowcontrol(struct uart_dev_s *dev, unsigned int nbuffered,
+ bool upper);
+#endif
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);
@@ -187,7 +207,7 @@ static const struct uart_ops_s g_lpuart_ops =
.rxint = kinetis_rxint,
.rxavailable = kinetis_rxavailable,
#ifdef CONFIG_SERIAL_IFLOWCONTROL
- .rxflowcontrol = NULL,
+ .rxflowcontrol = kinetis_rxflowcontrol,
#endif
.send = kinetis_send,
.txint = kinetis_txint,
@@ -219,6 +239,14 @@ static struct kinetis_dev_s g_lpuart0priv =
.parity = CONFIG_LPUART0_PARITY,
.bits = CONFIG_LPUART0_BITS,
.stop2 = CONFIG_LPUART0_2STOP,
+#if defined(CONFIG_SERIAL_OFLOWCONTROL) && defined(CONFIG_LPUART0_OFLOWCONTROL)
+ .oflow = true,
+ .cts_gpio = PIN_LPUART0_CTS,
+#endif
+#if defined(CONFIG_SERIAL_IFLOWCONTROL) && defined(CONFIG_LPUART0_IFLOWCONTROL)
+ .iflow = true,
+ .rts_gpio = PIN_LPUART0_RTS,
+#endif
};
static uart_dev_t g_lpuart0port =
@@ -251,6 +279,14 @@ static struct kinetis_dev_s g_lpuart1priv =
.parity = CONFIG_LPUART1_PARITY,
.bits = CONFIG_LPUART1_BITS,
.stop2 = CONFIG_LPUART1_2STOP,
+#if defined(CONFIG_SERIAL_OFLOWCONTROL) && defined(CONFIG_LPUART1_OFLOWCONTROL)
+ .oflow = true,
+ .cts_gpio = PIN_LPUART1_CTS,
+#endif
+#if defined(CONFIG_SERIAL_IFLOWCONTROL) && defined(CONFIG_LPUART1_IFLOWCONTROL)
+ .iflow = true,
+ .rts_gpio = PIN_LPUART1_RTS,
+#endif
};
static uart_dev_t g_lpuart1port =
@@ -360,11 +396,22 @@ 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;
+#ifdef CONFIG_SERIAL_IFLOWCONTROL
+ bool iflow = priv->iflow;
+#else
+ bool iflow = false;
+#endif
+#ifdef CONFIG_SERIAL_OFLOWCONTROL
+ bool oflow = priv->oflow;
+#else
+ bool oflow = false;
+#endif
/* Configure the LPUART as an RS-232 UART */
kinetis_lpuartconfigure(priv->uartbase, priv->baud, priv->clock,
- priv->parity, priv->bits, priv->stop2);
+ priv->parity, priv->bits, priv->stop2,
+ iflow, oflow);
#endif
/* Make sure that all interrupts are disabled */
@@ -408,7 +455,7 @@ static void kinetis_shutdown(struct uart_dev_s *dev)
* 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
+ * just after 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
@@ -564,23 +611,239 @@ static int kinetis_interrupt(int irq, void *context, void *arg)
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;
+#if defined(CONFIG_SERIAL_TERMIOS) || defined(CONFIG_SERIAL_TIOCSERGSTRUCT) || \
+ defined(CONFIG_KINETIS_SERIALBRK_BSDCOMPAT)
+ struct inode *inode;
+ struct uart_dev_s *dev;
+ uint8_t regval;
+#endif
+#if defined(CONFIG_SERIAL_TERMIOS) || defined(CONFIG_KINETIS_SERIALBRK_BSDCOMPAT)
struct kinetis_dev_s *priv;
- int ret = OK;
+ bool iflow = false;
+ bool oflow = false;
+#endif
+ int ret = OK;
- DEBUGASSERT(filep, filep->f_inode);
+#if defined(CONFIG_SERIAL_TERMIOS) || defined(CONFIG_SERIAL_TIOCSERGSTRUCT) || \
+ defined(CONFIG_KINETIS_SERIALBRK_BSDCOMPAT)
+ DEBUGASSERT(filep != NULL && filep->f_inode != NULL);
inode = filep->f_inode;
dev = inode->i_private;
+ DEBUGASSERT(dev != NULL && dev->priv != NULL);
+#endif
- DEBUGASSERT(dev, dev->priv);
- priv = (struct kinetis_dev_s *)dev->priv;
+#if defined(CONFIG_SERIAL_TERMIOS) || defined(CONFIG_KINETIS_SERIALBRK_BSDCOMPAT)
+ priv = (struct kinetis_dev_s *)dev->priv;
+#endif
switch (cmd)
{
- case xxx: /* Add commands here */
+#ifdef CONFIG_SERIAL_TIOCSERGSTRUCT
+ case TIOCSERGSTRUCT:
+ {
+ struct kinetis_dev_s *user = (struct kinetis_dev_s *)arg;
+ if (!user)
+ {
+ ret = -EINVAL;
+ }
+ else
+ {
+ memcpy(user, dev, sizeof(struct kinetis_dev_s));
+ }
+ }
break;
+#endif
+
+#ifdef CONFIG_KINETIS_UART_SINGLEWIRE
+ case TIOCSSINGLEWIRE:
+ {
+ /* Change to single-wire operation. the RXD pin is disconnected from
+ * the UART and the UART implements a half-duplex serial connection.
+ * The UART uses the TXD pin for both receiving and transmitting
+ */
+
+ regval = kinetis_serialin(priv, KINETIS_LPUART_CTRL_OFFSET);
+
+ if (arg == SER_SINGLEWIRE_ENABLED)
+ {
+ regval |= (LPUART_CTRL_LOOPS | LPUART_CTRL_RSRC);
+ }
+ else
+ {
+ regval &= ~(LPUART_CTRL_LOOPS | LPUART_CTRL_RSRC);
+ }
+
+ kinetis_serialout(priv, KINETIS_LPUART_CTRL_OFFSET, regval);
+ }
+ break;
+#endif
+
+#ifdef CONFIG_SERIAL_TERMIOS
+ case TCGETS:
+ {
+ struct termios *termiosp = (struct termios *)arg;
+
+ if (!termiosp)
+ {
+ ret = -EINVAL;
+ break;
+ }
+
+ cfsetispeed(termiosp, priv->baud);
+
+ /* Note: CSIZE only supports 5-8 bits. The driver only support 8/9 bit
+ * modes and therefore is no way to report 9-bit mode, we always claim
+ * 8 bit mode.
+ */
+
+ termiosp->c_cflag =
+ ((priv->parity != 0) ? PARENB : 0) |
+ ((priv->parity == 1) ? PARODD : 0) |
+ ((priv->stop2) ? CSTOPB : 0) |
+# ifdef CONFIG_SERIAL_OFLOWCONTROL
+ ((priv->oflow) ? CCTS_OFLOW : 0) |
+# endif
+# ifdef CONFIG_SERIAL_IFLOWCONTROL
+ ((priv->iflow) ? CRTS_IFLOW : 0) |
+# endif
+ CS8;
+
+ /* TODO: CCTS_IFLOW, CCTS_OFLOW */
+ }
+ break;
+
+ case TCSETS:
+ {
+ struct termios *termiosp = (struct termios *)arg;
+
+ if (!termiosp)
+ {
+ ret = -EINVAL;
+ break;
+ }
+
+ /* Perform some sanity checks before accepting any changes */
+
+ if (((termiosp->c_cflag & CSIZE) != CS8)
+# ifdef CONFIG_SERIAL_IFLOWCONTROL
+ || ((termiosp->c_cflag & CCTS_OFLOW) && (priv->cts_gpio == 0))
+# endif
+# ifdef CONFIG_SERIAL_IFLOWCONTROL
+ || ((termiosp->c_cflag & CRTS_IFLOW) && (priv->rts_gpio == 0))
+# endif
+ )
+ {
+ ret = -EINVAL;
+ break;
+ }
+
+ if (termiosp->c_cflag & PARENB)
+ {
+ priv->parity = (termiosp->c_cflag & PARODD) ? 1 : 2;
+ }
+ else
+ {
+ priv->parity = 0;
+ }
+
+ priv->stop2 = (termiosp->c_cflag & CSTOPB) != 0;
+# ifdef CONFIG_SERIAL_OFLOWCONTROL
+ priv->oflow = (termiosp->c_cflag & CCTS_OFLOW) != 0;
+ oflow = priv->oflow;
+# endif
+# ifdef CONFIG_SERIAL_IFLOWCONTROL
+ priv->iflow = (termiosp->c_cflag & CRTS_IFLOW) != 0;
+ iflow = priv->iflow;
+# endif
+
+ /* Note that since there is no way to request 9-bit mode
+ * and no way to support 5/6/7-bit modes, we ignore them
+ * all here.
+ */
+
+ /* Note that only cfgetispeed is used because we have knowledge
+ * that only one speed is supported.
+ */
+
+ priv->baud = cfgetispeed(termiosp);
+
+ /* Effect the changes immediately - note that we do not implement
+ * TCSADRAIN / TCSAFLUSH
+ */
+
+ kinetis_uartconfigure(priv->uartbase, priv->baud, priv->clock,
+ priv->parity, priv->bits, priv->stop2,
+ iflow, oflow);
+ }
+ break;
+#endif /* CONFIG_SERIAL_TERMIOS */
+
+#ifdef CONFIG_KINETIS_UART_BREAKS
+ case TIOCSBRK:
+ {
+ irqstate_t flags;
+
+ flags = enter_critical_section();
+
+ /* Send a longer break signal */
+
+ regval = kinetis_serialin(priv, KINETIS_LPUART_STAT_OFFSET);
+ regval &= ~LPUART_STAT_BRK13;
+# ifdef CONFIG_KINETIS_UART_EXTEDED_BREAK
+ regval |= LPUART_STAT_BRK13;
+# endif
+ kinetis_serialout(priv, LPUART_STAT_BRK13, regval);
+
+ /* Send a break signal */
+
+ regval = kinetis_serialin(priv, KINETIS_LPUART_CTRL_OFFSET);
+ regval |= LPUART_CTRL_SBK;
+ kinetis_serialout(priv, KINETIS_LPUART_CTRL_OFFSET, regval);
+
+# ifdef CONFIG_KINETIS_SERIALBRK_BSDCOMPAT
+ /* BSD compatibility: Turn break on, and leave it on */
+
+ kinetis_txint(dev, false);
+# else
+ /* Send a single break character
+ * Toggling SBK sends one break character. Per the manual
+ * Toggling implies clearing the SBK field before the break
+ * character has finished transmitting.
+ */
+
+ regval &= ~LPUART_CTRL_SBK;
+ kinetis_serialout(priv, KINETIS_LPUART_CTRL_OFFSET, regval);
+#endif
+
+ leave_critical_section(flags);
+ }
+ break;
+
+ case TIOCCBRK:
+ {
+ irqstate_t flags;
+
+ flags = enter_critical_section();
+
+ /* Configure TX back to UART
+ * If non BSD compatible: This code has no effect, the SBRK
+ * was already cleared.
+ * but for BSD compatibility: Turn break off
+ */
+
+ regval = kinetis_serialin(priv, KINETIS_LPUART_CTRL_OFFSET);
+ regval &= ~LPUART_CTRL_SBK;
+ kinetis_serialout(priv, KINETIS_LPUART_CTRL_OFFSET, regval);
+
+# ifdef CONFIG_KINETIS_SERIALBRK_BSDCOMPAT
+ /* Enable further tx activity */
+
+ kinetis_txint(dev, true);
+# endif
+ leave_critical_section(flags);
+ }
+ break;
+#endif /* CONFIG_KINETIS_UART_BREAKS */
default:
ret = -ENOTTY;
@@ -588,9 +851,6 @@ static int kinetis_ioctl(struct file *filep, int cmd, unsigned long arg)
}
return ret;
-#else
- return -ENOTTY;
-#endif
}
/****************************************************************************
@@ -696,6 +956,79 @@ static bool kinetis_rxavailable(struct uart_dev_s *dev)
return (kinetis_serialin(priv, KINETIS_LPUART_STAT_OFFSET) & LPUART_STAT_RDRF) != 0;
}
+/****************************************************************************
+ * Name: kinetis_rxflowcontrol
+ *
+ * Description:
+ * Called when Rx buffer is full (or exceeds configured watermark levels
+ * if CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS is defined).
+ * Return true if UART activated RX flow control to block more incoming
+ * data
+ *
+ * Input parameters:
+ * dev - UART device instance
+ * nbuffered - the number of characters currently buffered
+ * (if CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS is
+ * not defined the value will be 0 for an empty buffer or the
+ * defined buffer size for a full buffer)
+ * upper - true indicates the upper watermark was crossed where
+ * false indicates the lower watermark has been crossed
+ *
+ * Returned Value:
+ * true if RX flow control activated.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_SERIAL_IFLOWCONTROL
+static bool kinetis_rxflowcontrol(struct uart_dev_s *dev,
+ unsigned int nbuffered, bool upper)
+{
+#if defined(CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS)
+ struct kinetis_dev_s *priv = (struct kinetis_dev_s *)dev->priv;
+ uint16_t ie;
+
+ if (priv->iflow)
+ {
+ /* Is the RX buffer full? */
+
+ if (upper)
+ {
+ /* Disable Rx interrupt to prevent more data being from
+ * peripheral. When hardware RTS is enabled, this will
+ * prevent more data from coming in.
+ *
+ * This function is only called when UART recv buffer is full,
+ * that is: "dev->recv.head + 1 == dev->recv.tail".
+ *
+ * Logic in "uart_read" will automatically toggle Rx interrupts
+ * when buffer is read empty and thus we do not have to re-
+ * enable Rx interrupts.
+ */
+
+ ie = priv->ie;
+ ie &= ~LPUART_CTRL_RX_INTS;
+ kinetis_restoreuartint(priv, ie);
+ return true;
+ }
+
+ /* No.. The RX buffer is empty */
+
+ else
+ {
+ /* We might leave Rx interrupt disabled if full recv buffer was
+ * read empty. Enable Rx interrupt to make sure that more input is
+ * received.
+ */
+
+ kinetis_rxint(dev, true);
+ }
+ }
+#endif
+
+ return false;
+}
+#endif
+
/****************************************************************************
* Name: kinetis_send
*
diff --git a/arch/arm/src/kinetis/kinetis_mpuinit.c b/arch/arm/src/kinetis/kinetis_mpuinit.c
index 6c41f85bf4feae045c89f1a348ca20c892880c8c..9618b5a071d7ed74d3298398ce5e4beec65702ba 100644
--- a/arch/arm/src/kinetis/kinetis_mpuinit.c
+++ b/arch/arm/src/kinetis/kinetis_mpuinit.c
@@ -45,6 +45,7 @@
#include "mpu.h"
#include "kinetis_mpuinit.h"
+#include "chip/kinetis_mpu.h"
#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_ARM_MPU)
@@ -120,5 +121,24 @@ void kinetis_mpu_uheap(uintptr_t start, size_t size)
mpu_user_intsram(start, size);
}
+#elif defined(KINETIS_MPU)
+
+/****************************************************************************
+ * Name: kinetis_mpudisable
+ *
+ * Description:
+ * Configure the MPU to permit All buss masters access to all resources.
+ *
+ ****************************************************************************/
+
+void kinetis_mpudisable(void)
+{
+ uint32_t regval;
+
+ regval = getreg32(KINETIS_MPU_CESR);
+ regval &= ~MPU_CESR_VLD;
+ putreg32(regval, KINETIS_MPU_CESR);
+}
+
#endif /* CONFIG_BUILD_PROTECTED && CONFIG_ARM_MPU */
diff --git a/arch/arm/src/kinetis/kinetis_mpuinit.h b/arch/arm/src/kinetis/kinetis_mpuinit.h
index 3327176841b742c3c652ceb7539e3ce3d5bf84fb..91abf8e122da5c18df616ef339cbdd383b048d3e 100644
--- a/arch/arm/src/kinetis/kinetis_mpuinit.h
+++ b/arch/arm/src/kinetis/kinetis_mpuinit.h
@@ -61,6 +61,18 @@ void kinetis_mpuinitialize(void);
# define kinetis_mpuinitialize()
#endif
+/****************************************************************************
+ * Name: kinetis_mpudisable
+ *
+ * Description:
+ * Configure the MPU to permit All buss masters access to all resources.
+ *
+ ****************************************************************************/
+
+#if !defined(CONFIG_BUILD_PROTECTED) && defined(KINETIS_MPU)
+void kinetis_mpudisable(void);
+#endif
+
/****************************************************************************
* Name: kinetis_mpu_uheap
*
diff --git a/arch/arm/src/kinetis/kinetis_rtc_lowerhalf.c b/arch/arm/src/kinetis/kinetis_rtc_lowerhalf.c
index 961a212b6a8123189986fe1c0a9a1f3b9fe0d94b..b56fc5d44acb1461621a0d00b6c9ac000268e01c 100644
--- a/arch/arm/src/kinetis/kinetis_rtc_lowerhalf.c
+++ b/arch/arm/src/kinetis/kinetis_rtc_lowerhalf.c
@@ -121,6 +121,7 @@ static const struct rtc_ops_s g_rtc_ops =
{
.rdtime = kinetis_rdtime,
.settime = kinetis_settime,
+ .havesettime = NULL,
#ifdef CONFIG_RTC_ALARM
.setalarm = kinetis_setalarm,
.setrelative = kinetis_setrelative,
diff --git a/arch/arm/src/kinetis/kinetis_sdhc.c b/arch/arm/src/kinetis/kinetis_sdhc.c
index 8500c9590811e81f4319a0c18d26c95e0ce72fc0..4c8ffea18aac231094e38bd1c02f383996495174 100644
--- a/arch/arm/src/kinetis/kinetis_sdhc.c
+++ b/arch/arm/src/kinetis/kinetis_sdhc.c
@@ -95,7 +95,7 @@
/* Enable pull-up resistors
*
* Kinetis does not have pullups on all their development boards
- * So allow the the board config to enable them.
+ * So allow the board config to enable them.
*/
#if defined(BOARD_SDHC_ENABLE_PULLUPS)
diff --git a/arch/arm/src/kinetis/kinetis_serial.c b/arch/arm/src/kinetis/kinetis_serial.c
index 63873ecab5fc9ae67c4ff593fef61c7ef5ad2c3f..0f2a4b2ee46dbdaf05771af1585bf09f8453cc74 100644
--- a/arch/arm/src/kinetis/kinetis_serial.c
+++ b/arch/arm/src/kinetis/kinetis_serial.c
@@ -53,6 +53,11 @@
#include
#include
+#ifdef CONFIG_SERIAL_TERMIOS
+# include
+#endif
+
+#include
#include
#include "up_arch.h"
@@ -61,6 +66,7 @@
#include "kinetis_config.h"
#include "chip.h"
#include "chip/kinetis_uart.h"
+#include "chip/kinetis_pinmux.h"
#include "kinetis.h"
/****************************************************************************
@@ -242,6 +248,18 @@ struct up_dev_s
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 */
+#ifdef CONFIG_SERIAL_IFLOWCONTROL
+ bool iflow; /* input flow control (RTS) enabled */
+#endif
+#ifdef CONFIG_SERIAL_OFLOWCONTROL
+ bool oflow; /* output flow control (CTS) enabled */
+#endif
+#ifdef CONFIG_SERIAL_IFLOWCONTROL
+ uint32_t rts_gpio; /* UART RTS GPIO pin configuration */
+#endif
+#ifdef CONFIG_SERIAL_OFLOWCONTROL
+ uint32_t cts_gpio; /* UART CTS GPIO pin configuration */
+#endif
};
/****************************************************************************
@@ -260,6 +278,10 @@ 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);
static bool up_rxavailable(struct uart_dev_s *dev);
+#ifdef CONFIG_SERIAL_IFLOWCONTROL
+static bool up_rxflowcontrol(struct uart_dev_s *dev, unsigned int nbuffered,
+ bool upper);
+#endif
static void up_send(struct uart_dev_s *dev, int ch);
static void up_txint(struct uart_dev_s *dev, bool enable);
static bool up_txready(struct uart_dev_s *dev);
@@ -282,7 +304,7 @@ static const struct uart_ops_s g_uart_ops =
.rxint = up_rxint,
.rxavailable = up_rxavailable,
#ifdef CONFIG_SERIAL_IFLOWCONTROL
- .rxflowcontrol = NULL,
+ .rxflowcontrol = up_rxflowcontrol,
#endif
.send = up_send,
.txint = up_txint,
@@ -337,6 +359,14 @@ static struct up_dev_s g_uart0priv =
.parity = CONFIG_UART0_PARITY,
.bits = CONFIG_UART0_BITS,
.stop2 = CONFIG_UART0_2STOP,
+#if defined(CONFIG_SERIAL_OFLOWCONTROL) && defined(CONFIG_UART0_OFLOWCONTROL)
+ .oflow = true,
+ .cts_gpio = PIN_UART0_CTS,
+#endif
+#if defined(CONFIG_SERIAL_IFLOWCONTROL) && defined(CONFIG_UART0_IFLOWCONTROL)
+ .iflow = true,
+ .rts_gpio = PIN_UART0_RTS,
+#endif
};
static uart_dev_t g_uart0port =
@@ -372,6 +402,14 @@ static struct up_dev_s g_uart1priv =
.parity = CONFIG_UART1_PARITY,
.bits = CONFIG_UART1_BITS,
.stop2 = CONFIG_UART1_2STOP,
+#if defined(CONFIG_SERIAL_OFLOWCONTROL) && defined(CONFIG_UART1_OFLOWCONTROL)
+ .oflow = true,
+ .cts_gpio = PIN_UART1_CTS,
+#endif
+#if defined(CONFIG_SERIAL_IFLOWCONTROL) && defined(CONFIG_UART1_IFLOWCONTROL)
+ .iflow = true,
+ .rts_gpio = PIN_UART1_RTS,
+#endif
};
static uart_dev_t g_uart1port =
@@ -407,6 +445,14 @@ static struct up_dev_s g_uart2priv =
.parity = CONFIG_UART2_PARITY,
.bits = CONFIG_UART2_BITS,
.stop2 = CONFIG_UART2_2STOP,
+#if defined(CONFIG_SERIAL_OFLOWCONTROL) && defined(CONFIG_UART2_OFLOWCONTROL)
+ .oflow = true,
+ .cts_gpio = PIN_UART2_CTS,
+#endif
+#if defined(CONFIG_SERIAL_IFLOWCONTROL) && defined(CONFIG_UART2_IFLOWCONTROL)
+ .iflow = true,
+ .rts_gpio = PIN_UART2_RTS,
+#endif
};
static uart_dev_t g_uart2port =
@@ -442,6 +488,14 @@ static struct up_dev_s g_uart3priv =
.parity = CONFIG_UART3_PARITY,
.bits = CONFIG_UART3_BITS,
.stop2 = CONFIG_UART3_2STOP,
+#if defined(CONFIG_SERIAL_OFLOWCONTROL) && defined(CONFIG_UART3_OFLOWCONTROL)
+ .oflow = true,
+ .cts_gpio = PIN_UART3_CTS,
+#endif
+#if defined(CONFIG_SERIAL_IFLOWCONTROL) && defined(CONFIG_UART3_IFLOWCONTROL)
+ .iflow = true,
+ .rts_gpio = PIN_UART3_RTS,
+#endif
};
static uart_dev_t g_uart3port =
@@ -477,6 +531,14 @@ static struct up_dev_s g_uart4priv =
.parity = CONFIG_UART4_PARITY,
.bits = CONFIG_UART4_BITS,
.stop2 = CONFIG_UART4_2STOP,
+#if defined(CONFIG_SERIAL_OFLOWCONTROL) && defined(CONFIG_UART4_OFLOWCONTROL)
+ .oflow = true,
+ .cts_gpio = PIN_UART4_CTS,
+#endif
+#if defined(CONFIG_SERIAL_IFLOWCONTROL) && defined(CONFIG_UART4_IFLOWCONTROL)
+ .iflow = true,
+ .rts_gpio = PIN_UART4_RTS,
+#endif
};
static uart_dev_t g_uart4port =
@@ -512,6 +574,14 @@ static struct up_dev_s g_uart5priv =
.parity = CONFIG_UART5_PARITY,
.bits = CONFIG_UART5_BITS,
.stop2 = CONFIG_UART5_2STOP,
+#if defined(CONFIG_SERIAL_OFLOWCONTROL) && defined(CONFIG_UART5_OFLOWCONTROL)
+ .oflow = true,
+ .cts_gpio = PIN_UART5_CTS,
+#endif
+#if defined(CONFIG_SERIAL_IFLOWCONTROL) && defined(CONFIG_UART5_IFLOWCONTROL)
+ .iflow = true,
+ .rts_gpio = PIN_UART5_RTS,
+#endif
};
static uart_dev_t g_uart5port =
@@ -592,6 +662,7 @@ static void up_restoreuartint(struct up_dev_s *priv, uint8_t ie)
* Name: up_disableuartint
****************************************************************************/
+#ifdef HAVE_UART_CONSOLE
static void up_disableuartint(struct up_dev_s *priv, uint8_t *ie)
{
irqstate_t flags;
@@ -605,6 +676,7 @@ static void up_disableuartint(struct up_dev_s *priv, uint8_t *ie)
up_restoreuartint(priv, 0);
leave_critical_section(flags);
}
+#endif
/****************************************************************************
* Name: up_setup
@@ -619,11 +691,23 @@ static int up_setup(struct uart_dev_s *dev)
{
#ifndef CONFIG_SUPPRESS_UART_CONFIG
struct up_dev_s *priv = (struct up_dev_s *)dev->priv;
+#ifdef CONFIG_SERIAL_IFLOWCONTROL
+ bool iflow = priv->iflow;
+#else
+ bool iflow = false;
+#endif
+#ifdef CONFIG_SERIAL_OFLOWCONTROL
+ bool oflow = priv->oflow;
+#else
+ bool oflow = false;
+#endif
+
/* Configure the UART as an RS-232 UART */
kinetis_uartconfigure(priv->uartbase, priv->baud, priv->clock,
- priv->parity, priv->bits, priv->stop2);
+ priv->parity, priv->bits, priv->stop2,
+ iflow, oflow);
#endif
/* Make sure that all interrupts are disabled */
@@ -889,23 +973,239 @@ static int up_interrupts(int irq, void *context, FAR void *arg)
static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
{
-#if 0 /* Reserved for future growth */
+#if defined(CONFIG_SERIAL_TERMIOS) || defined(CONFIG_SERIAL_TIOCSERGSTRUCT) || \
+ defined(CONFIG_KINETIS_SERIALBRK_BSDCOMPAT)
struct inode *inode;
struct uart_dev_s *dev;
+ uint8_t regval;
+#endif
+#if defined(CONFIG_SERIAL_TERMIOS) || defined(CONFIG_KINETIS_SERIALBRK_BSDCOMPAT)
struct up_dev_s *priv;
- int ret = OK;
+ bool iflow = false;
+ bool oflow = false;
+#endif
+ int ret = OK;
- DEBUGASSERT(filep, filep->f_inode);
+#if defined(CONFIG_SERIAL_TERMIOS) || defined(CONFIG_SERIAL_TIOCSERGSTRUCT) || \
+ defined(CONFIG_KINETIS_SERIALBRK_BSDCOMPAT)
+ DEBUGASSERT(filep != NULL && filep->f_inode != NULL);
inode = filep->f_inode;
dev = inode->i_private;
+ DEBUGASSERT(dev != NULL && dev->priv != NULL);
+#endif
- DEBUGASSERT(dev, dev->priv);
- priv = (struct up_dev_s *)dev->priv;
+#if defined(CONFIG_SERIAL_TERMIOS) || defined(CONFIG_KINETIS_SERIALBRK_BSDCOMPAT)
+ priv = (struct up_dev_s *)dev->priv;
+#endif
switch (cmd)
{
- case xxx: /* Add commands here */
+#ifdef CONFIG_SERIAL_TIOCSERGSTRUCT
+ case TIOCSERGSTRUCT:
+ {
+ struct up_dev_s *user = (struct up_dev_s *)arg;
+ if (!user)
+ {
+ ret = -EINVAL;
+ }
+ else
+ {
+ memcpy(user, dev, sizeof(struct up_dev_s));
+ }
+ }
break;
+#endif
+
+#ifdef CONFIG_KINETIS_UART_SINGLEWIRE
+ case TIOCSSINGLEWIRE:
+ {
+ /* Change to single-wire operation. the RXD pin is disconnected from
+ * the UART and the UART implements a half-duplex serial connection.
+ * The UART uses the TXD pin for both receiving and transmitting
+ */
+
+ regval = up_serialin(priv, KINETIS_UART_C1_OFFSET);
+
+ if (arg == SER_SINGLEWIRE_ENABLED)
+ {
+ regval |= (UART_C1_LOOPS | UART_C1_RSRC);
+ }
+ else
+ {
+ regval &= ~(UART_C1_LOOPS | UART_C1_RSRC);
+ }
+
+ up_serialout(priv, KINETIS_UART_C1_OFFSET, regval);
+ }
+ break;
+#endif
+
+#ifdef CONFIG_SERIAL_TERMIOS
+ case TCGETS:
+ {
+ struct termios *termiosp = (struct termios *)arg;
+
+ if (!termiosp)
+ {
+ ret = -EINVAL;
+ break;
+ }
+
+ cfsetispeed(termiosp, priv->baud);
+
+ /* Note: CSIZE only supports 5-8 bits. The driver only support 8/9 bit
+ * modes and therefore is no way to report 9-bit mode, we always claim
+ * 8 bit mode.
+ */
+
+ termiosp->c_cflag =
+ ((priv->parity != 0) ? PARENB : 0) |
+ ((priv->parity == 1) ? PARODD : 0) |
+ ((priv->stop2) ? CSTOPB : 0) |
+# ifdef CONFIG_SERIAL_OFLOWCONTROL
+ ((priv->oflow) ? CCTS_OFLOW : 0) |
+# endif
+# ifdef CONFIG_SERIAL_IFLOWCONTROL
+ ((priv->iflow) ? CRTS_IFLOW : 0) |
+# endif
+ CS8;
+
+ /* TODO: CCTS_IFLOW, CCTS_OFLOW */
+ }
+ break;
+
+ case TCSETS:
+ {
+ struct termios *termiosp = (struct termios *)arg;
+
+ if (!termiosp)
+ {
+ ret = -EINVAL;
+ break;
+ }
+
+ /* Perform some sanity checks before accepting any changes */
+
+ if (((termiosp->c_cflag & CSIZE) != CS8)
+# ifdef CONFIG_SERIAL_IFLOWCONTROL
+ || ((termiosp->c_cflag & CCTS_OFLOW) && (priv->cts_gpio == 0))
+# endif
+# ifdef CONFIG_SERIAL_IFLOWCONTROL
+ || ((termiosp->c_cflag & CRTS_IFLOW) && (priv->rts_gpio == 0))
+# endif
+ )
+ {
+ ret = -EINVAL;
+ break;
+ }
+
+ if (termiosp->c_cflag & PARENB)
+ {
+ priv->parity = (termiosp->c_cflag & PARODD) ? 1 : 2;
+ }
+ else
+ {
+ priv->parity = 0;
+ }
+
+ priv->stop2 = (termiosp->c_cflag & CSTOPB) != 0;
+# ifdef CONFIG_SERIAL_OFLOWCONTROL
+ priv->oflow = (termiosp->c_cflag & CCTS_OFLOW) != 0;
+ oflow = priv->oflow;
+# endif
+# ifdef CONFIG_SERIAL_IFLOWCONTROL
+ priv->iflow = (termiosp->c_cflag & CRTS_IFLOW) != 0;
+ iflow = priv->iflow;
+# endif
+
+ /* Note that since there is no way to request 9-bit mode
+ * and no way to support 5/6/7-bit modes, we ignore them
+ * all here.
+ */
+
+ /* Note that only cfgetispeed is used because we have knowledge
+ * that only one speed is supported.
+ */
+
+ priv->baud = cfgetispeed(termiosp);
+
+ /* Effect the changes immediately - note that we do not implement
+ * TCSADRAIN / TCSAFLUSH
+ */
+
+ kinetis_uartconfigure(priv->uartbase, priv->baud, priv->clock,
+ priv->parity, priv->bits, priv->stop2,
+ iflow, oflow);
+ }
+ break;
+#endif /* CONFIG_SERIAL_TERMIOS */
+
+#ifdef CONFIG_KINETIS_UART_BREAKS
+ case TIOCSBRK:
+ {
+ irqstate_t flags;
+
+ flags = enter_critical_section();
+
+ /* Send a longer break signal */
+
+ regval = up_serialin(priv, KINETIS_UART_S2_OFFSET);
+ regval &= ~UART_S2_BRK13;
+# ifdef CONFIG_KINETIS_UART_EXTEDED_BREAK
+ regval |= UART_S2_BRK13;
+# endif
+ up_serialout(priv, KINETIS_UART_S2_OFFSET, regval);
+
+ /* Send a break signal */
+
+ regval = up_serialin(priv, KINETIS_UART_C2_OFFSET);
+ regval |= UART_C2_SBK;
+ up_serialout(priv, KINETIS_UART_C2_OFFSET, regval);
+
+# ifdef CONFIG_KINETIS_SERIALBRK_BSDCOMPAT
+ /* BSD compatibility: Turn break on, and leave it on */
+
+ up_txint(dev, false);
+# else
+ /* Send a single break character
+ * Toggling SBK sends one break character. Per the manual
+ * Toggling implies clearing the SBK field before the break
+ * character has finished transmitting.
+ */
+
+ regval &= ~(UART_C2_SBK);
+ up_serialout(priv, KINETIS_UART_C2_OFFSET, regval);
+#endif
+
+ leave_critical_section(flags);
+ }
+ break;
+
+ case TIOCCBRK:
+ {
+ irqstate_t flags;
+
+ flags = enter_critical_section();
+
+ /* Configure TX back to UART
+ * If non BSD compatible: This code has no effect, the SBRK
+ * was already cleared.
+ * but for BSD compatibility: Turn break off
+ */
+
+ regval = up_serialin(priv, KINETIS_UART_C2_OFFSET);
+ regval &= ~UART_C2_SBK;
+ up_serialout(priv, KINETIS_UART_C2_OFFSET, regval);
+
+# ifdef CONFIG_KINETIS_SERIALBRK_BSDCOMPAT
+ /* Enable further tx activity */
+
+ up_txint(dev, true);
+# endif
+ leave_critical_section(flags);
+ }
+ break;
+#endif /* CONFIG_KINETIS_UART_BREAKS */
default:
ret = -ENOTTY;
@@ -913,9 +1213,6 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
}
return ret;
-#else
- return -ENOTTY;
-#endif
}
/****************************************************************************
@@ -1028,6 +1325,79 @@ static bool up_rxavailable(struct uart_dev_s *dev)
#endif
}
+/****************************************************************************
+ * Name: up_rxflowcontrol
+ *
+ * Description:
+ * Called when Rx buffer is full (or exceeds configured watermark levels
+ * if CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS is defined).
+ * Return true if UART activated RX flow control to block more incoming
+ * data
+ *
+ * Input parameters:
+ * dev - UART device instance
+ * nbuffered - the number of characters currently buffered
+ * (if CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS is
+ * not defined the value will be 0 for an empty buffer or the
+ * defined buffer size for a full buffer)
+ * upper - true indicates the upper watermark was crossed where
+ * false indicates the lower watermark has been crossed
+ *
+ * Returned Value:
+ * true if RX flow control activated.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_SERIAL_IFLOWCONTROL
+static bool up_rxflowcontrol(struct uart_dev_s *dev,
+ unsigned int nbuffered, bool upper)
+{
+#if defined(CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS)
+ struct up_dev_s *priv = (struct up_dev_s *)dev->priv;
+ uint16_t ie;
+
+ if (priv->iflow)
+ {
+ /* Is the RX buffer full? */
+
+ if (upper)
+ {
+ /* Disable Rx interrupt to prevent more data being from
+ * peripheral. When hardware RTS is enabled, this will
+ * prevent more data from coming in.
+ *
+ * This function is only called when UART recv buffer is full,
+ * that is: "dev->recv.head + 1 == dev->recv.tail".
+ *
+ * Logic in "uart_read" will automatically toggle Rx interrupts
+ * when buffer is read empty and thus we do not have to re-
+ * enable Rx interrupts.
+ */
+
+ ie = priv->ie;
+ ie &= ~UART_C2_RIE;
+ up_restoreuartint(priv, ie);
+ return true;
+ }
+
+ /* No.. The RX buffer is empty */
+
+ else
+ {
+ /* We might leave Rx interrupt disabled if full recv buffer was
+ * read empty. Enable Rx interrupt to make sure that more input is
+ * received.
+ */
+
+ up_rxint(dev, true);
+ }
+ }
+#endif
+
+ return false;
+}
+#endif
+
/****************************************************************************
* Name: up_send
*
diff --git a/arch/arm/src/kinetis/kinetis_spi.c b/arch/arm/src/kinetis/kinetis_spi.c
new file mode 100644
index 0000000000000000000000000000000000000000..1c25bc9754b7d87c85fce98c522dacb4c1b01ec0
--- /dev/null
+++ b/arch/arm/src/kinetis/kinetis_spi.c
@@ -0,0 +1,1242 @@
+/************************************************************************************
+ * arch/arm/src/kinetis/kinetis_spi.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.
+ *
+ ************************************************************************************/
+
+/************************************************************************************
+ * The external functions, kinetis_spi0/1/2select and kinetis_spi0/1/26status
+ * must be provided by board-specific logic. They are implementations of
+ * the select and status methods of the SPI interface defined by structure
+ * spi_ops_s (see include/nuttx/spi/spi.h). All other methods
+ * (including kinetis_spibus_initialize()) are provided by common Kinetis
+ * logic.
+ * To use this common SPI logic on your board:
+ *
+ * 1. Provide logic in kinetis_boardinitialize() to configure SPI chip
+ * select pins.
+ * 2. Provide kinetis_spi[n]select() and kinetis_spi[n]status() functions
+ * in your board-specific logic. These functions will perform chip
+ * selection and status operations using GPIOs in the way your board is
+ * configured.
+ * 3. Add a calls to kinetis_spibus_initialize() in your low level
+ * application initialization logic.
+ * 4. The handle returned by kinetis_spibus_initialize() may then be used to
+ * bind the SPI driver to higher level logic (e.g., calling
+ * mmcsd_spislotinitialize(), for example, will bind the SPI driver to
+ * the SPI MMC/SD driver).
+ *
+ ************************************************************************************/
+
+/************************************************************************************
+ * Included Files
+ ************************************************************************************/
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+
+#include
+
+#include "up_arch.h"
+
+#include "kinetis.h"
+#include "kinetis_spi.h"
+#include "chip/kinetis_memorymap.h"
+#include "chip/kinetis_sim.h"
+#include "chip/kinetis_dspi.h"
+#include "chip/kinetis_pinmux.h"
+
+#if defined(CONFIG_KINETIS_SPI0) || defined(CONFIG_KINETIS_SPI1) || \
+ defined(CONFIG_KINETIS_SPI2)
+
+/************************************************************************************
+ * Pre-processor Definitions
+ ************************************************************************************/
+
+#define KINETIS_SPI_CLK_MAX (BOARD_BUS_FREQ / 2)
+#define KINETIS_SPI_CLK_INIT 400000
+
+/************************************************************************************
+ * Private Types
+ ************************************************************************************/
+
+struct kinetis_spidev_s
+{
+ struct spi_dev_s spidev; /* Externally visible part of the SPI interface */
+ uint32_t spibase; /* Base address of SPI registers */
+ sem_t exclsem; /* Held while chip is selected for mutual exclusion */
+ uint32_t frequency; /* Requested clock frequency */
+ uint32_t actual; /* Actual clock frequency */
+ uint8_t nbits; /* Width of word in bits (8 to 16) */
+ uint8_t mode; /* Mode 0,1,2,3 */
+ uint8_t ctarsel; /* Which CTAR */
+};
+
+/************************************************************************************
+ * Private Function Prototypes
+ ************************************************************************************/
+
+/* Helpers */
+
+static inline uint32_t spi_getreg(FAR struct kinetis_spidev_s *priv, uint8_t offset);
+static inline void spi_putreg(FAR struct kinetis_spidev_s *priv, uint8_t offset,
+ uint32_t value);
+static inline uint16_t spi_getreg16(FAR struct kinetis_spidev_s *priv, uint8_t offset);
+static inline void spi_putreg16(FAR struct kinetis_spidev_s *priv, uint8_t offset,
+ uint16_t value);
+static inline uint8_t spi_getreg8(FAR struct kinetis_spidev_s *priv, uint8_t offset);
+static inline void spi_putreg8(FAR struct kinetis_spidev_s *priv, uint8_t offset,
+ uint8_t value);
+static inline uint16_t spi_readword(FAR struct kinetis_spidev_s *priv);
+static inline void spi_writeword(FAR struct kinetis_spidev_s *priv,
+ uint16_t word);
+
+static inline void spi_run(FAR struct kinetis_spidev_s *priv, bool enable);
+static inline void spi_write_control(FAR struct kinetis_spidev_s *priv,
+ uint32_t control);
+static inline void spi_write_status(FAR struct kinetis_spidev_s *priv,
+ uint32_t status);
+static inline void spi_wait_status(FAR struct kinetis_spidev_s *priv,
+ uint32_t status);
+static uint16_t spi_send_data(FAR struct kinetis_spidev_s *priv, uint16_t wd,
+ bool last);
+
+/* SPI methods */
+
+static int spi_lock(FAR struct spi_dev_s *dev, bool lock);
+static uint32_t spi_setfrequency(FAR struct spi_dev_s *dev, uint32_t frequency);
+static void spi_setmode(FAR struct spi_dev_s *dev, enum spi_mode_e mode);
+static void spi_setbits(FAR struct spi_dev_s *dev, int nbits);
+#ifdef CONFIG_SPI_HWFEATURES
+static int spi_hwfeatures(FAR struct spi_dev_s *dev,
+ spi_hwfeatures_t features);
+#endif
+static uint16_t spi_send(FAR struct spi_dev_s *dev, uint16_t wd);
+static void spi_exchange(FAR struct spi_dev_s *dev, FAR const void *txbuffer,
+ FAR void *rxbuffer, size_t nwords);
+#ifndef CONFIG_SPI_EXCHANGE
+static void spi_sndblock(FAR struct spi_dev_s *dev, FAR const void *txbuffer,
+ size_t nwords);
+static void spi_recvblock(FAR struct spi_dev_s *dev, FAR void *rxbuffer,
+ size_t nwords);
+#endif
+
+/************************************************************************************
+ * Private Data
+ ************************************************************************************/
+
+#ifdef CONFIG_KINETIS_SPI0
+static const struct spi_ops_s g_spi0ops =
+{
+ .lock = spi_lock,
+ .select = kinetis_spi0select,
+ .setfrequency = spi_setfrequency,
+ .setmode = spi_setmode,
+ .setbits = spi_setbits,
+# ifdef CONFIG_SPI_HWFEATURES
+ .hwfeatures = spi_hwfeatures,
+# endif
+ .status = kinetis_spi0status,
+# ifdef CONFIG_SPI_CMDDATA
+ .cmddata = kinetis_spi0cmddata,
+# endif
+ .send = spi_send,
+# ifdef CONFIG_SPI_EXCHANGE
+ .exchange = spi_exchange,
+# else
+ .sndblock = spi_sndblock,
+ .recvblock = spi_recvblock,
+# endif
+# ifdef CONFIG_SPI_CALLBACK
+ .registercallback = kinetis_spi0register, /* provided externally */
+# else
+ .registercallback = 0, /* not implemented */
+# endif
+};
+
+static struct kinetis_spidev_s g_spi0dev =
+{
+ .spidev =
+ {
+ &g_spi0ops
+ },
+ .spibase = KINETIS_SPI0_BASE,
+ .ctarsel = KINETIS_SPI_CTAR0_OFFSET,
+};
+#endif
+
+#ifdef CONFIG_KINETIS_SPI1
+static const struct spi_ops_s g_spi1ops =
+{
+ .lock = spi_lock,
+ .select = kinetis_spi1select,
+ .setfrequency = spi_setfrequency,
+ .setmode = spi_setmode,
+ .setbits = spi_setbits,
+# ifdef CONFIG_SPI_HWFEATURES
+ .hwfeatures = spi_hwfeatures,
+# endif
+ .status = kinetis_spi1status,
+# ifdef CONFIG_SPI_CMDDATA
+ .cmddata = kinetis_spi1cmddata,
+# endif
+ .send = spi_send,
+# ifdef CONFIG_SPI_EXCHANGE
+ .exchange = spi_exchange,
+# else
+ .sndblock = spi_sndblock,
+ .recvblock = spi_recvblock,
+# endif
+# ifdef CONFIG_SPI_CALLBACK
+ .registercallback = kinetis_spi1register, /* provided externally */
+# else
+ .registercallback = 0, /* not implemented */
+# endif
+};
+
+static struct kinetis_spidev_s g_spi1dev =
+{
+ .spidev =
+ {
+ &g_spi1ops
+ },
+ .spibase = KINETIS_SPI1_BASE,
+ .ctarsel = KINETIS_SPI_CTAR0_OFFSET,
+};
+#endif
+
+#ifdef CONFIG_KINETIS_SPI2
+static const struct spi_ops_s g_spi2ops =
+{
+ .lock = spi_lock,
+ .select = kinetis_spi2select,
+ .setfrequency = spi_setfrequency,
+ .setmode = spi_setmode,
+ .setbits = spi_setbits,
+# ifdef CONFIG_SPI_HWFEATURES
+ .hwfeatures = spi_hwfeatures,
+# endif
+ .status = kinetis_spi2status,
+# ifdef CONFIG_SPI_CMDDATA
+ .cmddata = kinetis_spi2cmddata,
+# endif
+ .send = spi_send,
+# ifdef CONFIG_SPI_EXCHANGE
+ .exchange = spi_exchange,
+# else
+ .sndblock = spi_sndblock,
+ .recvblock = spi_recvblock,
+# endif
+# ifdef CONFIG_SPI_CALLBACK
+ .registercallback = kinetis_spi2register, /* provided externally */
+# else
+ .registercallback = 0, /* not implemented */
+# endif
+};
+
+static struct kinetis_spidev_s g_spi2dev =
+{
+ .spidev =
+ {
+ &g_spi2ops
+ },
+ .spibase = KINETIS_SPI2_BASE,
+ .ctarsel = KINETIS_SPI_CTAR0_OFFSET,
+};
+#endif
+
+/************************************************************************************
+ * Private Functions
+ ************************************************************************************/
+
+/************************************************************************************
+ * Name: spi_getreg
+ *
+ * Description:
+ * Get the 32-bit contents of the SPI register at offset
+ *
+ * Input Parameters:
+ * priv - private SPI device structure
+ * offset - offset to the register of interest
+ *
+ * Returned Value:
+ * The contents of the 32-bit register
+ *
+ ************************************************************************************/
+
+static inline uint32_t spi_getreg(FAR struct kinetis_spidev_s *priv, uint8_t offset)
+{
+ return getreg32(priv->spibase + offset);
+}
+
+/************************************************************************************
+ * Name: spi_putreg
+ *
+ * Description:
+ * Write a 32-bit value to the SPI register at offset
+ *
+ * Input Parameters:
+ * priv - private SPI device structure
+ * offset - offset to the register of interest
+ * value - the 32-bit value to be written
+ *
+ * Returned Value:
+ * Nothing
+ *
+ ************************************************************************************/
+
+static inline void spi_putreg(FAR struct kinetis_spidev_s *priv, uint8_t offset,
+ uint32_t value)
+{
+ putreg32(value, priv->spibase + offset);
+}
+
+/************************************************************************************
+ * Name: spi_getreg16
+ *
+ * Description:
+ * Get the 16 bit contents of the SPI register at offset
+ *
+ * Input Parameters:
+ * priv - private SPI device structure
+ * offset - offset to the register of interest
+ *
+ * Returned Value:
+ * The contents of the 16-bit register
+ *
+ ************************************************************************************/
+
+static inline uint16_t spi_getreg16(FAR struct kinetis_spidev_s *priv, uint8_t offset)
+{
+ return getreg16(priv->spibase + offset);
+}
+
+/************************************************************************************
+ * Name: spi_putreg16
+ *
+ * Description:
+ * Write a 16-bit value to the SPI register at offset
+ *
+ * Input Parameters:
+ * priv - private SPI device structure
+ * offset - offset to the register of interest
+ * value - the 16-bit value to be written
+ *
+ * Returned Value:
+ * Nothing
+ *
+ ************************************************************************************/
+
+static inline void spi_putreg16(FAR struct kinetis_spidev_s *priv, uint8_t offset,
+ uint16_t value)
+{
+ putreg16(value, priv->spibase + offset);
+}
+
+/************************************************************************************
+ * Name: spi_getreg8
+ *
+ * Description:
+ * Get the 8 bit contents of the SPI register at offset
+ *
+ * Input Parameters:
+ * priv - private SPI device structure
+ * offset - offset to the register of interest
+ *
+ * Returned Value:
+ * The contents of the 8-bit register
+ *
+ ************************************************************************************/
+
+static inline uint8_t spi_getreg8(FAR struct kinetis_spidev_s *priv, uint8_t offset)
+{
+ return getreg8(priv->spibase + offset);
+}
+
+/************************************************************************************
+ * Name: spi_putreg8
+ *
+ * Description:
+ * Write a 8-bit value to the SPI register at offset
+ *
+ * Input Parameters:
+ * priv - private SPI device structure
+ * offset - offset to the register of interest
+ * value - the 8-bit value to be written
+ *
+ * Returned Value:
+ * Nothing
+ *
+ ************************************************************************************/
+
+static inline void spi_putreg8(FAR struct kinetis_spidev_s *priv, uint8_t offset,
+ uint8_t value)
+{
+ putreg8(value, priv->spibase + offset);
+}
+
+/************************************************************************************
+ * Name: spi_write_status
+ *
+ * Description:
+ * Write the 32-bit status
+ *
+ * Input Parameters:
+ * priv - Device-specific state data
+ * status- any ones will clear flags.
+ *
+ * Returned Value:
+ * None
+ *
+ ************************************************************************************/
+
+static inline void spi_write_status(FAR struct kinetis_spidev_s *priv, uint32_t status)
+{
+
+ /* Write the SR Register */
+
+ spi_putreg(priv, KINETIS_SPI_SR_OFFSET, status);
+}
+
+/************************************************************************************
+ * Name: spi_wait_status
+ *
+ * Description:
+ * Wait for bit to be set in status
+ *
+ * Input Parameters:
+ * priv - Device-specific state data
+ * status- bit to wait on.
+ *
+ * Returned Value:
+ * None
+ *
+ ************************************************************************************/
+
+static inline void spi_wait_status(FAR struct kinetis_spidev_s *priv, uint32_t status)
+{
+
+ while (status != (spi_getreg(priv, KINETIS_SPI_SR_OFFSET) & status));
+}
+
+/************************************************************************************
+ * Name: spi_write_control
+ *
+ * Description:
+ * Write the 16-bit control word to the TX FIFO
+ *
+ * Input Parameters:
+ * priv - Device-specific state data
+ * control- to write
+ *
+ * Returned Value:
+ * None
+ *
+ ************************************************************************************/
+
+static inline void spi_write_control(FAR struct kinetis_spidev_s *priv, uint32_t control)
+{
+
+ /* Write the control word to the SPI Data Register */
+
+ spi_putreg16(priv, KINETIS_SPI_PUSHR_OFFSET + 2, (uint16_t) (control >> 16));
+}
+
+/************************************************************************************
+ * Name: spi_writeword
+ *
+ * Description:
+ * Write one 16 bit word to SPI TX FIFO
+ *
+ * Input Parameters:
+ * priv - Device-specific state data
+ * word - word to send
+ *
+ * Returned Value:
+ * None
+ *
+ ************************************************************************************/
+
+static inline void spi_writeword(FAR struct kinetis_spidev_s *priv, uint16_t word)
+{
+ /* Wait until there is space in the fifo */
+
+ spi_wait_status(priv, SPI_SR_TFFF);
+
+ /* Write the data to transmitted to the SPI Data Register */
+
+ spi_putreg16(priv, KINETIS_SPI_PUSHR_OFFSET, SPI_PUSHR_TXDATA(word));
+}
+
+/************************************************************************************
+ * Name: spi_readword
+ *
+ * Description:
+ * Read one 16 bit word from SPI RX FIFO
+ *
+ * Input Parameters:
+ * priv - Device-specific state data
+ *
+ * Returned Value:
+ * The 8-bit value from the FIFO
+ *
+ ************************************************************************************/
+
+static inline uint16_t spi_readword(FAR struct kinetis_spidev_s *priv)
+{
+ /* Wait until transfer completes and the data is in the RX FIFO */
+
+ spi_wait_status(priv, SPI_SR_RFDF | SPI_SR_TCF);
+
+ /* Return the data */
+
+ return spi_getreg16(priv, KINETIS_SPI_POPR_OFFSET);
+}
+
+/************************************************************************************
+ * Name: spi_run
+ *
+ * Description:
+ * Sets or clears the HALT
+ *
+ * Input Parameters:
+ * priv - private SPI device structure
+ * enable - True clears HALT
+ *
+ * Returned Value:
+ * Last enable setting
+ *
+ ************************************************************************************/
+
+void inline spi_run(FAR struct kinetis_spidev_s *priv, bool enable)
+{
+ uint32_t regval;
+
+ regval = spi_getreg(priv, KINETIS_SPI_MCR_OFFSET);
+ regval &= ~SPI_MCR_HALT;
+ regval |= enable ? 0 : SPI_MCR_HALT;
+ spi_putreg(priv, KINETIS_SPI_MCR_OFFSET, regval);
+}
+
+/************************************************************************************
+ * Name: spi_lock
+ *
+ * Description:
+ * On SPI busses where there are multiple devices, it will be necessary to
+ * lock SPI to have exclusive access to the busses for a sequence of
+ * transfers. The bus should be locked before the chip is selected. After
+ * locking the SPI bus, the caller should then also call the setfrequency,
+ * setbits, and setmode methods to make sure that the SPI is properly
+ * configured for the device. If the SPI buss is being shared, then it
+ * may have been left in an incompatible state.
+ *
+ * Input Parameters:
+ * dev - Device-specific state data
+ * lock - true: Lock spi bus, false: unlock SPI bus
+ *
+ * Returned Value:
+ * None
+ *
+ ************************************************************************************/
+
+static int spi_lock(FAR struct spi_dev_s *dev, bool lock)
+{
+ FAR struct kinetis_spidev_s *priv = (FAR struct kinetis_spidev_s *)dev;
+
+ if (lock)
+ {
+ /* Take the semaphore (perhaps waiting) */
+
+ while (sem_wait(&priv->exclsem) != 0)
+ {
+ /* The only case that an error should occur here is if the wait was awakened
+ * by a signal.
+ */
+
+ ASSERT(errno == EINTR);
+ }
+ }
+ else
+ {
+ (void)sem_post(&priv->exclsem);
+ }
+
+ return OK;
+}
+
+/************************************************************************************
+ * Name: spi_setfrequency
+ *
+ * Description:
+ * Set the SPI frequency.
+ *
+ * Input Parameters:
+ * dev - Device-specific state data
+ * frequency - The SPI frequency requested
+ *
+ * Returned Value:
+ * Returns the actual frequency selected
+ *
+ ************************************************************************************/
+
+static uint32_t spi_setfrequency(FAR struct spi_dev_s *dev, uint32_t frequency)
+{
+ FAR struct kinetis_spidev_s *priv = (FAR struct kinetis_spidev_s *)dev;
+
+ uint32_t prescale;
+ uint32_t prescalev;
+ uint32_t doublebr;
+ uint32_t scaler;
+ uint32_t scalerv;
+ uint32_t diff;
+ uint32_t actual;
+ uint32_t regval;
+
+ uint32_t pbr = 0;
+ uint32_t dbr = 1;
+ uint32_t br = 0;
+ uint32_t min = UINT32_MAX;
+
+ /* Check if requested frequency reasonable */
+
+ if (frequency > KINETIS_SPI_CLK_MAX)
+ {
+ frequency = KINETIS_SPI_CLK_MAX;
+ }
+ else if (frequency == 0)
+ {
+ frequency = KINETIS_SPI_CLK_INIT;
+ }
+
+ /* Check if the requested frequency is the same as the frequency selection */
+
+ if (priv->frequency == frequency)
+ {
+ /* We are already at this frequency. Return the actual. */
+
+ return priv->actual;
+ }
+
+ /* The clock source for the SPI baud rate generator is the bus clock.
+ * and the SCK is given by:
+ *
+ * SCK = (fP /PBR) x [(1+DBR)/BR]
+ *
+ * Where:
+ * fP - the Bus Clock
+ * PBR - Baud Rate Prescaler {2, 3, 5, 7}
+ * DBR - Double Baud Rate {0, 1}
+ * BR - Baud Rate Scaler {2, 4, 6, 8 ... 32,768}
+ *
+ * We need find a PBR and BR resulting in the in baudrate closest to the
+ * requested value. We give preference to DBR of 0 to maintina a 50/50
+ * duty sysle
+ *
+ */
+
+ for (doublebr = 1; min && doublebr <= 2; doublebr++)
+ {
+ for (prescalev = 0, prescale = 2;
+ min && prescalev <= 3;
+ prescalev ++, prescale == 2 ? prescale++ : (prescale += 2))
+ {
+ for (scalerv = 0, scaler = 2;
+ min && scalerv <= 15;
+ scalerv++, scaler < 8 ? (scaler += 2) : (scaler <<= 1))
+ {
+ actual = ((BOARD_BUS_FREQ * doublebr) / (prescale * scaler));
+ if (frequency >= actual)
+ {
+ diff = frequency - actual;
+ if (min > diff)
+ {
+ min = diff;
+ pbr = prescalev;
+ dbr = doublebr == 2 ? SPI_CTARM_DBR : 0;
+ br = scalerv;
+ priv->actual = actual;
+ }
+ }
+ }
+ }
+ }
+
+ /* Write the new dividers to the CTAR register */
+
+ regval = spi_getreg(priv, priv->ctarsel);
+ regval &= ~(SPI_CTARM_BR_MASK | SPI_CTARM_PBR_MASK | SPI_CTARM_DBR);
+ regval |= (SPI_CTARM_BR(br) | SPI_CTARM_PBR(pbr) | dbr);
+ spi_putreg(priv, priv->ctarsel, regval);
+
+ /* Save the frequency setting so that subsequent re-configurations will be
+ * faster.
+ */
+
+ priv->frequency = frequency;
+
+ spiinfo("Frequency %d->%d\n", frequency, priv->actual);
+ return priv->actual;
+}
+
+/************************************************************************************
+ * Name: spi_setmode
+ *
+ * Description:
+ * Set the SPI mode. see enum spi_mode_e for mode definitions
+ *
+ * Input Parameters:
+ * dev - Device-specific state data
+ * mode - The SPI mode requested
+ *
+ * Returned Value:
+ * Returns the actual frequency selected
+ *
+ ************************************************************************************/
+
+static void spi_setmode(FAR struct spi_dev_s *dev, enum spi_mode_e mode)
+{
+ FAR struct kinetis_spidev_s *priv = (FAR struct kinetis_spidev_s *)dev;
+ uint32_t regval;
+
+ spiinfo("mode=%d\n", mode);
+
+ /* Has the mode changed? */
+
+ if (mode != priv->mode)
+ {
+ /* Yes... Set CTAR appropriately */
+
+ regval = spi_getreg(priv, priv->ctarsel);
+ regval &= ~(SPI_CTAR_CPOL | SPI_CTAR_CPHA);
+
+ switch (mode)
+ {
+ case SPIDEV_MODE0: /* CPOL=0; CPHA=0 */
+ break;
+
+ case SPIDEV_MODE1: /* CPOL=0; CPHA=1 */
+ regval |= SPI_CTAR_CPHA;
+ break;
+
+ case SPIDEV_MODE2: /* CPOL=1; CPHA=0 */
+ regval |= SPI_CTAR_CPOL;
+ break;
+
+ case SPIDEV_MODE3: /* CPOL=1; CPHA=1 */
+ regval |= (SPI_CTAR_CPOL | SPI_CTAR_CPHA);
+ break;
+
+ default:
+ DEBUGASSERT(FALSE);
+ return;
+ }
+
+ spi_putreg(priv, priv->ctarsel, regval);
+
+ /* Save the mode so that subsequent re-configurations will be faster */
+
+ priv->mode = mode;
+ }
+}
+
+/************************************************************************************
+ * Name: spi_setbits
+ *
+ * Description:
+ * Set the number of bits per word.
+ *
+ * Input Parameters:
+ * dev - Device-specific state data
+ * nbits - The number of bits requested
+ *
+ * Returned Value:
+ * None
+ *
+ ************************************************************************************/
+
+static void spi_setbits(FAR struct spi_dev_s *dev, int nbits)
+{
+ FAR struct kinetis_spidev_s *priv = (FAR struct kinetis_spidev_s *)dev;
+ uint32_t regval;
+
+ if (nbits != priv->nbits)
+ {
+ /* Set the number of bits (valid range 4-16) */
+
+ if (nbits < 4 || nbits > 16)
+ {
+ return;
+ }
+
+ regval = spi_getreg(priv, priv->ctarsel);
+ regval &= ~(SPI_CTARM_FMSZ_MASK);
+ regval |= SPI_CTARM_FMSZ(nbits-1);
+ spi_putreg(priv, priv->ctarsel, regval);
+
+ /* Save the selection so the subsequence re-configurations will be faster */
+
+ priv->nbits = nbits;
+ }
+}
+
+/************************************************************************************
+ * Name: spi_hwfeatures
+ *
+ * Description:
+ * Set hardware-specific feature flags.
+ *
+ * Input Parameters:
+ * dev - Device-specific state data
+ * features - H/W feature flags
+ *
+ * Returned Value:
+ * Zero (OK) if the selected H/W features are enabled; A negated errno
+ * value if any H/W feature is not supportable.
+ *
+ ************************************************************************************/
+
+#ifdef CONFIG_SPI_HWFEATURES
+static int spi_hwfeatures(FAR struct spi_dev_s *dev, spi_hwfeatures_t features)
+{
+#ifdef CONFIG_SPI_BITORDER
+ FAR struct kinetis_spidev_s *priv = (FAR struct spi_dev_s *)dev;
+ uint32_t setbits;
+ uint32_t clrbits;
+
+ spiinfo("features=%08x\n", features);
+
+ /* Transfer data LSB first? */
+
+ if ((features & HWFEAT_LSBFIRST) != 0)
+ {
+ setbits = SPI_CTARM_LSBFE;
+ clrbits = 0;
+ }
+ else
+ {
+ setbits = 0;
+ clrbits = SPI_CTARM_LSBFE;
+ }
+
+ regval = spi_getreg(priv, priv->ctarsel);
+ regval &= ~clrbits;
+ regval |= setbits;
+ spi_putreg(priv, priv->ctarsel, regval);
+
+ /* Other H/W features are not supported */
+
+ return ((features & ~HWFEAT_LSBFIRST) == 0) ? OK : -ENOSYS;
+#else
+ return -ENOSYS;
+#endif
+}
+#endif
+
+/************************************************************************************
+ * Name: spi_send_data
+ *
+ * Description:
+ * Exchange one word on SPI
+ *
+ * Input Parameters:
+ * priv - Device-specific state data
+ * wd - The word to send. the size of the data is determined by the
+ * number of bits selected for the SPI interface.
+ *
+ * Returned Value:
+ * response
+ *
+ ************************************************************************************/
+
+static uint16_t spi_send_data(FAR struct kinetis_spidev_s *priv, uint16_t wd,
+ bool last)
+{
+ uint16_t ret;
+
+ /* On first write set control word and start transfer */
+
+ if (0 == (spi_getreg(priv, KINETIS_SPI_SR_OFFSET) & SPI_SR_TXRXS))
+ {
+ spi_run(priv, true);
+ spi_write_control(priv, SPI_PUSHR_CTAS_CTAR0 | SPI_PUSHR_CTCNT);
+ }
+
+ spi_writeword(priv, wd);
+ ret = spi_readword(priv);
+
+ if (!last)
+ {
+ /* Clear the Transfer complete and the RX FIFO RDY */
+
+ spi_write_status(priv, SPI_SR_TCF | SPI_SR_RFDF);
+ }
+ else
+ {
+ /* Clear all status */
+
+ spi_write_status(priv, spi_getreg(priv, KINETIS_SPI_SR_OFFSET));
+ spi_run(priv, false);
+ }
+
+ return ret;
+}
+
+/************************************************************************************
+ * Name: spi_send
+ *
+ * Description:
+ * Exchange one word on SPI
+ *
+ * Input Parameters:
+ * dev - Device-specific state data
+ * wd - The word to send. the size of the data is determined by the
+ * number of bits selected for the SPI interface.
+ *
+ * Returned Value:
+ * response
+ *
+ ************************************************************************************/
+
+static uint16_t spi_send(FAR struct spi_dev_s *dev, uint16_t wd)
+{
+ FAR struct kinetis_spidev_s *priv = (FAR struct kinetis_spidev_s *)dev;
+
+ return spi_send_data(priv, wd, true);
+}
+
+/************************************************************************************
+ * Name: spi_exchange
+ *
+ * Description:
+ * Exchange a block of data on SPI without using DMA
+ *
+ * Input Parameters:
+ * dev - Device-specific state data
+ * txbuffer - A pointer to the buffer of data to be sent
+ * rxbuffer - A pointer to a buffer in which to receive data
+ * nwords - the length of data to be exchaned in units of words.
+ * The wordsize is determined by the number of bits-per-word
+ * selected for the SPI interface. If nbits <= 8, the data is
+ * packed into uint8_t's; if nbits >8, the data is packed into uint16_t's
+ *
+ * Returned Value:
+ * None
+ *
+ ************************************************************************************/
+
+static void spi_exchange(FAR struct spi_dev_s *dev, FAR const void *txbuffer,
+ FAR void *rxbuffer, size_t nwords)
+{
+ FAR struct kinetis_spidev_s *priv = (FAR struct kinetis_spidev_s *)dev;
+ uint8_t *brxptr = (uint8_t *)rxbuffer;
+ const uint8_t *btxptr = (uint8_t *)txbuffer;
+ uint16_t *wrxptr = (uint16_t *)rxbuffer;
+ const uint16_t *wtxptr = (const uint16_t *)txbuffer;
+ uint8_t byte;
+ uint16_t word;
+
+ spiinfo("txbuffer=%p rxbuffer=%p nwords=%d\n", txbuffer, rxbuffer, nwords);
+
+ if (priv->nbits > 8)
+ {
+ /* 16-bit mode */
+
+ while (nwords-- > 0)
+ {
+ /* Get the next word to write. Is there a source buffer? */
+
+ if (wtxptr)
+ {
+ word = *wtxptr++;
+ }
+ else
+ {
+ word = 0xffff;
+ }
+
+ /* Exchange one word */
+
+ word = spi_send_data(priv, word, nwords ? false : true);
+
+ /* Is there a buffer to receive the return value? */
+
+ if (wrxptr)
+ {
+ *wrxptr++ = word;
+ }
+ }
+ }
+ else
+ {
+
+ /* 8-bit mode */
+
+ while (nwords-- > 0)
+ {
+ /* Get the next word to write. Is there a source buffer? */
+
+ if (btxptr)
+ {
+ byte = *btxptr++;
+ }
+ else
+ {
+ byte = 0xff;
+ }
+
+ /* Exchange one word */
+
+ byte = (uint8_t) spi_send_data(priv, (uint16_t)byte, nwords ? false : true);
+
+ /* Is there a buffer to receive the return value? */
+
+ if (brxptr)
+ {
+ *brxptr++ = byte;
+ }
+ }
+ }
+}
+/************************************************************************************
+ * Name: spi_sndblock
+ *
+ * Description:
+ * Send a block of data on SPI
+ *
+ * Input Parameters:
+ * dev - Device-specific state data
+ * txbuffer - A pointer to the buffer of data to be sent
+ * nwords - the length of data to send from the buffer in number of words.
+ * The wordsize is determined by the number of bits-per-word
+ * selected for the SPI interface. If nbits <= 8, the data is
+ * packed into uint8_t's; if nbits >8, the data is packed into uint16_t's
+ *
+ * Returned Value:
+ * None
+ *
+ ************************************************************************************/
+
+#ifndef CONFIG_SPI_EXCHANGE
+static void spi_sndblock(FAR struct spi_dev_s *dev, FAR const void *txbuffer,
+ size_t nwords)
+{
+ spiinfo("txbuffer=%p nwords=%d\n", txbuffer, nwords);
+ return spi_exchange(dev, txbuffer, NULL, nwords);
+}
+#endif
+
+/************************************************************************************
+ * Name: spi_recvblock
+ *
+ * Description:
+ * Receive a block of data from SPI
+ *
+ * Input Parameters:
+ * dev - Device-specific state data
+ * rxbuffer - A pointer to the buffer in which to recieve data
+ * nwords - the length of data that can be received in the buffer in number
+ * of words. The wordsize is determined by the number of bits-per-word
+ * selected for the SPI interface. If nbits <= 8, the data is
+ * packed into uint8_t's; if nbits >8, the data is packed into uint16_t's
+ *
+ * Returned Value:
+ * None
+ *
+ ************************************************************************************/
+
+#ifndef CONFIG_SPI_EXCHANGE
+static void spi_recvblock(FAR struct spi_dev_s *dev, FAR void *rxbuffer, size_t nwords)
+{
+ spiinfo("rxbuffer=%p nwords=%d\n", rxbuffer, nwords);
+ return spi_exchange(dev, NULL, rxbuffer, nwords);
+}
+#endif
+
+/************************************************************************************
+ * Public Functions
+ ************************************************************************************/
+
+/************************************************************************************
+ * Name: kinetis_spibus_initialize
+ *
+ * Description:
+ * Initialize the selected SPI port.
+ *
+ * Input Parameter:
+ * Port number (for hardware that has mutiple SPI interfaces)
+ *
+ * Returned Value:
+ * Valid SPI device structure reference on succcess; a NULL on failure
+ *
+ ************************************************************************************/
+
+FAR struct spi_dev_s *kinetis_spibus_initialize(int port)
+{
+ FAR struct kinetis_spidev_s *priv;
+ uint32_t regval;
+
+ /* Configure multiplexed pins as connected on the board. Chip select pins
+ * must be configured by board-specific logic. Most SPI pins multiple,
+ * alternative pin selection. Definitions in the board.h file must be\
+ * provided to resolve the board-specific pin configuration like:
+ *
+ * #define PIN_SPI0_SCK PIN_SPI0_SCK_1
+ */
+
+#ifdef CONFIG_KINETIS_SPI0
+ if (port == 0)
+ {
+ priv = &g_spi0dev;
+
+ /* Configure pins for SPI0 */
+
+ kinetis_pinconfig(PIN_SPI0_SCK);
+ kinetis_pinconfig(PIN_SPI0_SIN);
+ kinetis_pinconfig(PIN_SPI0_OUT);
+
+ /* Enable clocking */
+
+ regval = getreg32(KINETIS_SIM_SCGC6);
+ regval |= SIM_SCGC6_SPI0;
+ putreg32(regval, KINETIS_SIM_SCGC6);
+ }
+ else
+#endif
+#ifdef CONFIG_KINETIS_SPI1
+ if (port == 1)
+ {
+ priv = &g_spi1dev;
+
+ /* Configure pins for SPI1 */
+
+ kinetis_pinconfig(PIN_SPI1_SCK);
+ kinetis_pinconfig(PIN_SPI1_SIN);
+ kinetis_pinconfig(PIN_SPI1_OUT);
+
+ /* Enable clocking */
+
+ regval = getreg32(KINETIS_SIM_SCGC6);
+ regval |= SIM_SCGC6_SPI1;
+ putreg32(regval, KINETIS_SIM_SCGC6);
+ }
+ else
+#endif
+#ifdef CONFIG_KINETIS_SPI2
+ if (port == 2)
+ {
+ priv = &g_spi2dev;
+
+ /* Configure pins for SPI1 */
+
+ kinetis_pinconfig(PIN_SPI2_SCK);
+ kinetis_pinconfig(PIN_SPI2_SIN);
+ kinetis_pinconfig(PIN_SPI2_OUT);
+
+ /* Enable clocking */
+
+ regval = getreg32(KINETIS_SIM_SCGC3);
+ regval |= SIM_SCGC3_SPI2;
+ putreg32(regval, KINETIS_SIM_SCGC3);
+ }
+ else
+#endif
+ {
+ spierr("ERROR: Port %d not configured\n", port);
+ return NULL;
+ }
+
+ /* Halt operations */
+
+ spi_run(priv, false);
+
+ /* Configure master mode:
+ * Master Mode - Enabled
+ * Continuous SCK - Disabled
+ * SPI Configuration - SPI
+ * Freeze - Disabled
+ * Modified Transfer Format - Disabled
+ * Peripheral Chip Select Strobe - Peripheral Chip Select[5] signal
+ * Receive FIFO Overflow Overwrite - Ignore incoming
+ * Chip Select x Inactive State - High
+ * Doze - Disabled
+ * Module Disable - Enables the module clocks.
+ * Disable Transmit FIFO - yes
+ * Disable Receive FIFO - yes
+ * Clear TX FIFO - No
+ * Clear RX FIFO - No
+ * Sample Point - 0 clocks between edge and sample
+ *
+ */
+
+ spi_putreg(priv, KINETIS_SPI_MCR_OFFSET, SPI_MCR_MSTR | SPI_MCR_DCONF_SPI |
+ SPI_MCR_SMPL_PT_0CLKS | SPI_MCR_PCSIS_MASK | SPI_MCR_HALT|
+ SPI_MCR_DIS_RXF | SPI_MCR_DIS_TXF);
+
+ /* Set the initial SPI configuration */
+
+ spi_putreg(priv, priv->ctarsel, 0);
+
+ /* MSB first, 8 bit */
+
+ priv->nbits = 0;
+ spi_setbits(&priv->spidev, 8);
+
+ /* select mode 0 */
+
+ priv->mode = SPIDEV_MODE3;
+ spi_setmode(&priv->spidev, SPIDEV_MODE0);
+
+ /* Select a default frequency of approx. 400KHz */
+
+ priv->frequency = 0;
+ spi_setfrequency(&priv->spidev, KINETIS_SPI_CLK_INIT);
+
+ /* Initialize the SPI semaphore that enforces mutually exclusive access */
+
+ sem_init(&priv->exclsem, 0, 1);
+
+ return &priv->spidev;
+}
+
+#endif /* CONFIG_KINETIS_SPI0 || CONFIG_KINETIS_SPI1 || CONFIG_KINETIS_SPI2 */
diff --git a/arch/arm/src/kinetis/kinetis_spi.h b/arch/arm/src/kinetis/kinetis_spi.h
index 19ce126d1026ff623ddaef56bebc7d892844cc4b..8222af442467f44bbd8e7e5dfcf519f26ba4a70a 100644
--- a/arch/arm/src/kinetis/kinetis_spi.h
+++ b/arch/arm/src/kinetis/kinetis_spi.h
@@ -63,8 +63,7 @@ extern "C"
* Public Data
************************************************************************************/
-struct spi_dev_s;
-enum spi_dev_e;
+struct spi_dev_s;
/****************************************************************************
* Public Function Prototypes
@@ -115,24 +114,24 @@ FAR struct spi_dev_s *kinetis_spibus_initialize(int bus);
************************************************************************************/
#ifdef CONFIG_KINETIS_SPI0
-void kinetis_spi0select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
-uint8_t kinetis_spi0status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+void kinetis_spi0select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected);
+uint8_t kinetis_spi0status(FAR struct spi_dev_s *dev, uint32_t devid);
#ifdef CONFIG_SPI_CMDDATA
-int kinetis_spi0cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+int kinetis_spi0cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
#endif
#endif
#ifdef CONFIG_KINETIS_SPI1
-void kinetis_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
-uint8_t kinetis_spi1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+void kinetis_spi1select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected);
+uint8_t kinetis_spi1status(FAR struct spi_dev_s *dev, uint32_t devid);
#ifdef CONFIG_SPI_CMDDATA
-int kinetis_spi1cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+int kinetis_spi1cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
#endif
#endif
#ifdef CONFIG_KINETIS_SPI2
-void kinetis_spi2select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
-uint8_t kinetis_spi2status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+void kinetis_spi2select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected);
+uint8_t kinetis_spi2status(FAR struct spi_dev_s *dev, uint32_t devid);
#ifdef CONFIG_SPI_CMDDATA
-int kinetis_spi2cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+int kinetis_spi2cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
#endif
#endif
diff --git a/arch/arm/src/kinetis/kinetis_start.c b/arch/arm/src/kinetis/kinetis_start.c
index 6747ce24e88661cf1f4d3604f2da3fed69ee3389..f70b9a7368955e5c999a8c53334d9d085df7202a 100644
--- a/arch/arm/src/kinetis/kinetis_start.c
+++ b/arch/arm/src/kinetis/kinetis_start.c
@@ -1,6 +1,5 @@
/****************************************************************************
* arch/arm/src/kinetis/kinetis_start.c
- * arch/arm/src/chip/kinetis_start.c
*
* Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
@@ -52,6 +51,7 @@
#include "kinetis.h"
#include "chip/kinetis_smc.h"
+#include "kinetis_mpuinit.h"
#include "kinetis_userspace.h"
#ifdef CONFIG_ARCH_FPU
@@ -327,6 +327,7 @@ void __start(void)
* can get debug output as soon as possible (This depends on clock
* configuration).
*/
+
kinetis_fpuconfig();
kinetis_lowsetup();
#ifdef USE_EARLYSERIALINIT
@@ -341,6 +342,12 @@ void __start(void)
#ifdef CONFIG_BUILD_PROTECTED
kinetis_userspace();
+#else
+# ifdef KINETIS_MPU
+ /* Disable the MPU so that all master may access all buses */
+
+ kinetis_mpudisable();
+# endif
#endif
/* Initialize other on-board resources */
diff --git a/arch/arm/src/kinetis/kinetis_tpm.h b/arch/arm/src/kinetis/kinetis_tpm.h
new file mode 100644
index 0000000000000000000000000000000000000000..03fe3b136276153621c07ede3b77389c555e72ff
--- /dev/null
+++ b/arch/arm/src/kinetis/kinetis_tpm.h
@@ -0,0 +1,58 @@
+/****************************************************************************
+ * arch/arm/src/kinetis/kinetis_tpm.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_KINETIS_TPM_H
+#define __ARCH_ARM_SRC_KINETIS_KINETIS_TPM_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include
+
+#include "chip.h"
+
+/* This file is just a wrapper around tmp header files for the Kinetis family
+ * selected by the logic in chip.h.
+ */
+
+#if defined(KINETIS_K66)
+# include "chip/kinetis_kx6tpm.h"
+#else
+# error "No TMP definitions for this Kinetis part"
+#endif
+
+#endif /* __ARCH_ARM_SRC_KINETIS_KINETIS_TPM_H */
diff --git a/arch/arm/src/kinetis/kinetis_usbdev.c b/arch/arm/src/kinetis/kinetis_usbdev.c
index c550fbd3252a60135ef66380f5b439bb8da65cb6..ace2400ae19f62f32ba9767a063e71de7b381c5a 100644
--- a/arch/arm/src/kinetis/kinetis_usbdev.c
+++ b/arch/arm/src/kinetis/kinetis_usbdev.c
@@ -1,8 +1,9 @@
/****************************************************************************
* arch/arm/src/kinetis/kinetis_usbdev.c
*
- * Copyright (C) 2011-2014, 2016 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt
+ * Copyright (C) 2011-2014, 2016-2017 Gregory Nutt. All rights reserved.
+ * Authors: Gregory Nutt
+ * David Sidrane
*
* References:
* This file derives from the STM32 USB device driver with modifications
@@ -12,6 +13,9 @@
* - Sample code provided with the Sure Electronics PIC32 board
* (which seems to have derived from Microchip PICDEM PIC18 code).
*
+ * K66 Sub-Family Reference Manual, Rev. 2, May 2015
+ * How to Implement USB Suspend/Resume - Document Number: AN5385
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -169,6 +173,7 @@
/* Endpoint register initialization parameters */
+#define KHCI_EP_DISABLED (0)
#define KHCI_EP_CONTROL (USB_ENDPT_EPHSHK | USB_ENDPT_EPTXEN | USB_ENDPT_EPRXEN)
#define KHCI_EP_BULKIN (USB_ENDPT_EPTXEN | USB_ENDPT_EPCTLDIS | USB_ENDPT_EPHSHK)
#define KHCI_EP_BULKOUT (USB_ENDPT_EPRXEN | USB_ENDPT_EPCTLDIS | USB_ENDPT_EPHSHK)
@@ -189,6 +194,10 @@
#define RESTART_DELAY (150 * CLOCKS_PER_SEC / 1000)
+#define USB0_USBTRC0_BIT6 0x40 /* Undocumented bit that is set in the
+ * Kinetis lib
+ */
+
/* USB trace ****************************************************************/
/* Trace error codes */
@@ -256,7 +265,8 @@
#define KHCI_TRACEINTID_STALL 0x0021
#define KHCI_TRACEINTID_UERR 0x0022
#define KHCI_TRACEINTID_SUSPENDED 0x0023
-#define KHCI_TRACEINTID_WAITRESET 0x0024
+#define KHCI_TRACEINTID_RESUME 0x0024
+#define KHCI_TRACEINTID_WAITRESET 0x0025
#ifdef CONFIG_USBDEV_TRACE_STRINGS
const struct trace_msg_t g_usb_trace_strings_intdecode[] =
@@ -296,7 +306,8 @@ const struct trace_msg_t g_usb_trace_strings_intdecode[] =
TRACE_STR(KHCI_TRACEINTID_STALL ), /* 0x0021 */
TRACE_STR(KHCI_TRACEINTID_UERR ), /* 0x0022 */
TRACE_STR(KHCI_TRACEINTID_SUSPENDED ), /* 0x0023 */
- TRACE_STR(KHCI_TRACEINTID_WAITRESET ), /* 0x0024 */
+ TRACE_STR(KHCI_TRACEINTID_RESUME ), /* 0x0024 */
+ TRACE_STR(KHCI_TRACEINTID_WAITRESET ), /* 0x0025 */
TRACE_STR_END
};
#endif
@@ -482,7 +493,6 @@ struct khci_usbdev_s
uint8_t ctrlstate; /* Control EP state (see enum khci_ctrlstate_e) */
uint8_t selfpowered:1; /* 1: Device is self powered */
uint8_t rwakeup:1; /* 1: Device supports remote wakeup */
- uint8_t attached:1; /* Device is attached to the host */
uint8_t ep0done:1; /* EP0 OUT already prepared */
uint8_t rxbusy:1; /* EP0 OUT data transfer in progress */
uint16_t epavail; /* Bitset of available endpoints */
@@ -508,6 +518,7 @@ static void khci_putreg(uint32_t val, uint32_t addr);
/* Suspend/Resume Helpers ***************************************************/
static void khci_suspend(struct khci_usbdev_s *priv);
+static void khci_remote_resume(struct khci_usbdev_s *priv);
static void khci_resume(struct khci_usbdev_s *priv);
/* Request Queue Management *************************************************/
@@ -606,10 +617,10 @@ static int khci_selfpowered(struct usbdev_s *dev, bool selfpowered);
static void khci_reset(struct khci_usbdev_s *priv);
static void khci_attach(struct khci_usbdev_s *priv);
-static void khci_detach(struct khci_usbdev_s *priv);
static void khci_swreset(struct khci_usbdev_s *priv);
static void khci_hwreset(struct khci_usbdev_s *priv);
-static void khci_stateinit(struct khci_usbdev_s *priv);
+static void khci_swinitalize(struct khci_usbdev_s *priv);
+static void khci_hwinitalize(struct khci_usbdev_s *priv);
static void khci_hwshutdown(struct khci_usbdev_s *priv);
/****************************************************************************
@@ -767,7 +778,6 @@ static struct khci_req_s *khci_remfirst(struct khci_queue_s *queue)
return ret;
}
-
/****************************************************************************
* Name: khci_remlast
****************************************************************************/
@@ -2715,113 +2725,82 @@ static void khci_ep0transfer(struct khci_usbdev_s *priv, uint16_t ustat)
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
- * easier.
- */
-
- struct khci_usbdev_s *priv = &g_usbdev;
uint16_t usbir;
- uint16_t otgir;
uint32_t regval;
int i;
+#ifdef CONFIG_USBOTG
+ uint16_t otgir;
+#endif
+
+ struct khci_usbdev_s *priv = (struct khci_usbdev_s *) arg;
/* Get the set of pending USB and OTG interrupts interrupts */
usbir = khci_getreg(KINETIS_USB0_ISTAT) & khci_getreg(KINETIS_USB0_INTEN);
+
+#if !defined(CONFIG_USBOTG)
+ usbtrace(TRACE_INTENTRY(KHCI_TRACEINTID_INTERRUPT), usbir);
+#else
otgir = khci_getreg(KINETIS_USB0_OTGISTAT) & khci_getreg(KINETIS_USB0_OTGICR);
usbtrace(TRACE_INTENTRY(KHCI_TRACEINTID_INTERRUPT), usbir | otgir);
-#ifdef CONFIG_USBOTG
/* Session Request Protocol (SRP) Time Out Check */
/* Check if USB OTG SRP is ready */
# warning "Missing logic"
- {
- /* Check if the 1 millisecond timer has expired */
+ {
+ /* Check if the 1 millisecond timer has expired */
- if ((otgir & USBOTG_INT_T1MSEC) != 0)
- {
- usbtrace(TRACE_INTDECODE(KHCI_TRACEINTID_T1MSEC), otgir);
+ if ((otgir & USBOTG_INT_T1MSEC) != 0)
+ {
+ usbtrace(TRACE_INTDECODE(KHCI_TRACEINTID_T1MSEC), otgir);
- /* Check for the USB OTG SRP timeout */
+ /* Check for the USB OTG SRP timeout */
# warning "Missing logic"
- {
+ {
/* Handle OTG events of the SRP timeout has expired */
# warning "Missing logic"
- }
+ }
- /* Clear Interrupt 1 msec timer Flag */
+ /* Clear Interrupt 1 msec timer Flag */
- khci_putreg(USBOTG_INT_T1MSEC, KINETIS_USB0_ISTAT);
- }
- }
+ khci_putreg(USBOTG_INT_T1MSEC, KINETIS_USB0_ISTAT);
+ }
+ }
#endif
/* Handle events while we are in the attached state */
if (priv->devstate == DEVSTATE_ATTACHED)
{
- /* Clear all USB interrupts */
-
- khci_putreg(USB_INT_ALL, KINETIS_USB0_ISTAT);
-
- /* Make sure that the USE reset and IDLE detect interrupts are enabled */
-
- regval = khci_getreg(KINETIS_USB0_INTEN);
- regval |= (USB_INT_USBRST | USB_INT_SLEEP);
- khci_putreg(regval, KINETIS_USB0_INTEN);
/* Now were are in the powered state */
priv->devstate = DEVSTATE_POWERED;
}
-#ifdef CONFIG_USBOTG
- /* Check if the ID Pin Changed State */
+ /* Service error interrupts */
- if ((otgir & USBOTG_INT_ID) != 0)
+ if ((usbir & USB_INT_ERROR) != 0)
{
- usbtrace(TRACE_INTDECODE(KHCI_TRACEINTID_OTGID), otgir);
+ usbtrace(TRACE_INTDECODE(KHCI_TRACEINTID_UERR), usbir);
+ uerr("ERROR: EIR=%04x\n", khci_getreg(KINETIS_USB0_ERRSTAT));
- /* Re-detect and re-initialize */
-#warning "Missing logic"
+ /* Clear all pending USB error interrupts */
- khci_putreg(USBOTG_INT_ID, KINETIS_USB0_ISTAT);
+ khci_putreg(USB_EINT_ALL, KINETIS_USB0_ERRSTAT);
}
-#endif
-#if 0
- /* Service the USB Activity Interrupt */
-
- if ((otgir & USBOTG_INT_ACTV) != 0)
- {
- usbtrace(TRACE_INTDECODE(KHCI_TRACEINTID_WKUP), otgir);
-
- /* Wake-up from susepnd mode */
- khci_putreg(USBOTG_INT_ACTV, KINETIS_USB0_ISTAT);
- khci_resume(priv);
- }
+ /* Service resume interrupts */
- /* It is pointless to continue servicing if the device is in suspend mode. */
-x
- if ((khci_getreg(KINETIS_USB0_CTL) & USB_USBCTRL_SUSP) != 0)
+ if ((usbir & USB_INT_RESUME) != 0)
{
- /* Just clear the interrupt and return */
-
- usbtrace(TRACE_INTDECODE(KHCI_TRACEINTID_SUSPENDED), khci_getreg(KINETIS_USB0_CTL));
- goto interrupt_exit;
+ usbtrace(TRACE_INTDECODE(KHCI_TRACEINTID_RESUME), usbir);
+ khci_resume(priv);
}
-#endif
- /* Service USB Bus Reset Interrupt. When bus reset is received during
- * suspend, ACTVIF will be set first, once the UCONbits.SUSPND is clear,
- * then the URSTIF bit will be asserted. This is why URSTIF is checked
- * after ACTVIF. The USB reset flag is masked when the USB state is in
- * DEVSTATE_DETACHED or DEVSTATE_ATTACHED, and therefore cannot cause a
- * USB reset event during these two states.
- */
+ /* Service USB Bus Reset Interrupt. */
if ((usbir & USB_INT_USBRST) != 0)
{
@@ -2831,7 +2810,13 @@ x
* hardware automatically resets the USB address, so we really just
* need reset any existing configuration/transfer states.
*/
- khci_reset(priv);
+
+ khci_swreset(priv);
+ khci_hwreset(priv);
+
+ /* Configure EP0 */
+
+ khci_ep0configure(priv);
priv->devstate = DEVSTATE_DEFAULT;
#ifdef CONFIG_USBOTG
@@ -2844,72 +2829,17 @@ x
goto interrupt_exit;
}
- /* Service IDLE interrupts */
-
- if ((usbir & USB_INT_SLEEP) != 0)
- {
- usbtrace(TRACE_INTDECODE(KHCI_TRACEINTID_IDLE), usbir);
-
#ifdef CONFIG_USBOTG
- /* If Suspended, Try to switch to Host */
-#warning "Missing logic"
-#else
- khci_suspend(priv);
-
-#endif
- khci_putreg(USB_INT_SLEEP, KINETIS_USB0_ISTAT);
- }
-
- /* Service SOF interrupts */
-
-#ifdef CONFIG_USB_SOFINTS
- if ((usbir & USB_INT_SOFTOK) != 0)
- {
- usbtrace(TRACE_INTDECODE(KHCI_TRACEINTID_SOF), 0);
-
- /* I am not sure why you would ever enable SOF interrupts */
-
- khci_putreg(USB_INT_SOFTOK, KINETIS_USB0_ISTAT);
- }
-#endif
-
- /* Service stall interrupts */
-
- if ((usbir & USB_INT_STALL) != 0)
- {
- usbtrace(TRACE_INTDECODE(KHCI_TRACEINTID_STALL), usbir);
-
- khci_ep0stall(priv);
-
- /* Clear the pending STALL interrupt */
-
- khci_putreg(USB_INT_STALL, KINETIS_USB0_ISTAT);
- }
-
- /* Service error interrupts */
+ /* Check if the ID Pin Changed State */
- if ((usbir & USB_INT_ERROR) != 0)
+ if ((otgir & USBOTG_INT_ID) != 0)
{
- usbtrace(TRACE_INTDECODE(KHCI_TRACEINTID_UERR), usbir);
- uerr("ERROR: EIR=%04x\n", khci_getreg(KINETIS_USB0_ERRSTAT));
-
- /* Clear all pending USB error interrupts */
-
- khci_putreg(USB_EINT_ALL, KINETIS_USB0_ERRSTAT);
- }
-
- /* There is no point in continuing if the host has not sent a bus reset.
- * Once bus reset is received, the device transitions into the DEFAULT
- * state and is ready for communication.
- */
+ usbtrace(TRACE_INTDECODE(KHCI_TRACEINTID_OTGID), otgir);
-#if 0
- if (priv->devstate < DEVSTATE_DEFAULT)
- {
- /* Just clear the interrupt and return */
+ /* Re-detect and re-initialize */
+#warning "Missing logic"
- usbtrace(TRACE_INTDECODE(KHCI_TRACEINTID_WAITRESET), priv->devstate);
- goto interrupt_exit;
+ khci_putreg(USBOTG_INT_ID, KINETIS_USB0_ISTAT);
}
#endif
@@ -2958,7 +2888,57 @@ x
}
}
- UNUSED(otgir); /* May not be used, depending on above conditional logic */
+ /* Service IDLE interrupts */
+
+ if ((usbir & USB_INT_SLEEP) != 0)
+ {
+ usbtrace(TRACE_INTDECODE(KHCI_TRACEINTID_IDLE), usbir);
+
+#ifdef CONFIG_USBOTG
+ /* If Suspended, Try to switch to Host */
+#warning "Missing logic"
+#else
+ khci_suspend(priv);
+
+#endif
+ khci_putreg(USB_INT_SLEEP, KINETIS_USB0_ISTAT);
+ }
+
+ /* It is pointless to continue servicing if the device is in suspend mode. */
+
+ if ((khci_getreg(KINETIS_USB0_USBCTRL) & USB_USBCTRL_SUSP) != 0)
+ {
+ /* Just clear the interrupt and return */
+
+ usbtrace(TRACE_INTDECODE(KHCI_TRACEINTID_SUSPENDED), khci_getreg(KINETIS_USB0_CTL));
+ goto interrupt_exit;
+ }
+
+ /* Service SOF interrupts */
+
+#ifdef CONFIG_USB_SOFINTS
+ if ((usbir & USB_INT_SOFTOK) != 0)
+ {
+ usbtrace(TRACE_INTDECODE(KHCI_TRACEINTID_SOF), 0);
+
+ /* I am not sure why you would ever enable SOF interrupts */
+
+ khci_putreg(USB_INT_SOFTOK, KINETIS_USB0_ISTAT);
+ }
+#endif
+
+ /* Service stall interrupts */
+
+ if ((usbir & USB_INT_STALL) != 0)
+ {
+ usbtrace(TRACE_INTDECODE(KHCI_TRACEINTID_STALL), usbir);
+
+ khci_ep0stall(priv);
+
+ /* Clear the pending STALL interrupt */
+
+ khci_putreg(USB_INT_STALL, KINETIS_USB0_ISTAT);
+ }
/* Clear the pending USB interrupt. Goto is used in the above to assure
* that all interrupt exists pass through this logic.
@@ -2966,7 +2946,11 @@ x
interrupt_exit:
kinetis_clrpend(KINETIS_IRQ_USBOTG);
+#ifdef CONFIG_USBOTG
usbtrace(TRACE_INTEXIT(KHCI_TRACEINTID_INTERRUPT), usbir | otgir);
+#else
+ usbtrace(TRACE_INTEXIT(KHCI_TRACEINTID_INTERRUPT), usbir);
+#endif
return OK;
}
@@ -2979,9 +2963,7 @@ interrupt_exit:
static void khci_suspend(struct khci_usbdev_s *priv)
{
-#if 0
uint32_t regval;
-#endif
/* Notify the class driver of the suspend event */
@@ -2990,47 +2972,40 @@ static void khci_suspend(struct khci_usbdev_s *priv)
CLASS_SUSPEND(priv->driver, &priv->usbdev);
}
-#if 0
- /* Enable the ACTV interrupt.
- *
- * NOTE: Do not clear UIRbits.ACTVIF here! Reason: ACTVIF is only
- * generated once an IDLEIF has been generated. This is a 1:1 ratio
- * interrupt generation. For every IDLEIF, there will be only one ACTVIF
- * regardless of the number of subsequent bus transitions. If the ACTIF
- * is cleared here, a problem could occur. The driver services IDLEIF
- * first because ACTIVIE=0. If this routine clears the only ACTIVIF,
- * then it can never get out of the suspend mode.
- */
-
- regval = khci_getreg(KINETIS_USB0_OTGICR);
- regval |= USBOTG_INT_ACTV;
- khci_putreg(regval, KINETIS_USB0_OTGICR);
-
/* Disable further IDLE interrupts. Once is enough. */
regval = khci_getreg(KINETIS_USB0_INTEN);
regval &= ~USB_INT_SLEEP;
khci_putreg(regval, KINETIS_USB0_INTEN);
-#endif
+
+ /* Enable Resume */
+
+ regval |= USB_INT_RESUME;
+ khci_putreg(regval, KINETIS_USB0_INTEN);
+
+ regval = khci_getreg(KINETIS_USB0_USBTRC0);
+ regval |= USB_USBTRC0_USBRESMEN;
+ khci_putreg(regval, KINETIS_USB0_USBTRC0);
/* Invoke a callback into board-specific logic. The board-specific logic
* may enter into sleep or idle modes or switch to a slower clock, etc.
*/
kinetis_usbsuspend((struct usbdev_s *)priv, false);
+
+ regval = khci_getreg(KINETIS_USB0_USBCTRL);
+ regval |= USB_USBCTRL_SUSP;
+ khci_putreg(regval, KINETIS_USB0_USBCTRL);
}
/****************************************************************************
- * Name: khci_resume
+ * Name: khci_remote_resume
****************************************************************************/
-static void khci_resume(struct khci_usbdev_s *priv)
+static void khci_remote_resume(struct khci_usbdev_s *priv)
{
- irqstate_t flags;
uint32_t regval;
- flags = enter_critical_section();
-
/* Start RESUME signaling */
regval = khci_getreg(KINETIS_USB0_CTL);
@@ -3043,33 +3018,50 @@ static void khci_resume(struct khci_usbdev_s *priv)
regval &= ~USB_CTL_RESUME;
khci_putreg(regval, KINETIS_USB0_CTL);
+}
- /* This function is called when the USB activity interrupt occurs.
+/****************************************************************************
+ * Name: khci_resume
+ ****************************************************************************/
+
+static void khci_resume(struct khci_usbdev_s *priv)
+{
+ irqstate_t flags;
+ uint32_t regval;
+
+ flags = enter_critical_section();
+
+ /* This function is called when the USB resume interrupt occurs.
* If using clock switching, this is the place to call out to
* logic to restore the original MCU core clock frequency.
*/
kinetis_usbsuspend((struct usbdev_s *)priv, true);
- /* Disable further activity interrupts */
-#if 0
- regval = khci_getreg(KINETIS_USB0_OTGICR);
- regval &= ~USBOTG_INT_ACTV;
- khci_putreg(regval, KINETIS_USB0_OTGICR);
-#endif
+ /* Unsuspend */
- /* The ACTVIF bit cannot be cleared immediately after the USB module wakes
- * up from Suspend or while the USB module is suspended. A few clock cycles
- * are required to synchronize the internal hardware state machine before
- * the ACTIVIF bit can be cleared by firmware. Clearing the ACTVIF bit
- * before the internal hardware is synchronized may not have an effect on
- * the value of ACTVIF. Additionally, if the USB module uses the clock from
- * the 96 MHz PLL source, then after clearing the SUSPND bit, the USB
- * module may not be immediately operational while waiting for the 96 MHz
- * PLL to lock.
- */
+ regval = khci_getreg(KINETIS_USB0_USBCTRL);
+ regval &= ~USB_USBCTRL_SUSP;
+ khci_putreg(regval, KINETIS_USB0_USBCTRL);
+
+ /* Enable the IDLE interrupt */
+
+ regval = khci_getreg(KINETIS_USB0_INTEN);
+ regval |= USB_INT_SLEEP;
+ khci_putreg(regval, KINETIS_USB0_INTEN);
- khci_putreg(USB_INT_SLEEP, KINETIS_USB0_ISTAT);
+ /* Disable the RESUME interrupt */
+
+ regval &= ~USB_INT_RESUME;
+ khci_putreg(regval, KINETIS_USB0_INTEN);
+
+ /* Disable the the async resume interrupt */
+
+ regval = khci_getreg(KINETIS_USB0_USBTRC0);
+ regval &= ~USB_USBTRC0_USBRESMEN;
+ khci_putreg(regval, KINETIS_USB0_USBTRC0);
+
+ khci_putreg(USB_INT_RESUME, KINETIS_USB0_ISTAT);
/* Notify the class driver of the resume event */
@@ -3156,15 +3148,15 @@ static void khci_ep0configure(struct khci_usbdev_s *priv)
struct khci_ep_s *ep0;
uint32_t bytecount;
- /* Enable the EP0 endpoint */
-
- khci_putreg(KHCI_EP_CONTROL, KINETIS_USB0_ENDPT0);
-
/* Configure the OUT BDTs. We assume that the ping-poing buffer index has
* just been reset and we expect to receive on the EVEN BDT first. Data
* toggle synchronization is not needed for SETUP packets.
*/
+ /* Disabled the Endpoint first */
+
+ khci_putreg(KHCI_EP_DISABLED, KINETIS_USB0_ENDPT0);
+
ep0 = &priv->eplist[EP0];
bytecount = (USB_SIZEOF_CTRLREQ << USB_BDT_BYTECOUNT_SHIFT);
@@ -3194,6 +3186,10 @@ static void khci_ep0configure(struct khci_usbdev_s *priv)
ep0->rxdata1 = 0;
ep0->txdata1 = 1;
+
+ /* Enable the EP0 endpoint */
+
+ khci_putreg(KHCI_EP_CONTROL, KINETIS_USB0_ENDPT0);
}
/****************************************************************************
@@ -3260,9 +3256,9 @@ static int khci_epconfigure(struct usbdev_ep_s *ep,
return -EINVAL;
}
- /* Enable the endpoint */
+ /* First disable the endpoint */
- khci_putreg(regval, KINETIS_USB0_ENDPT(epno));
+ khci_putreg(KHCI_EP_DISABLED, KINETIS_USB0_ENDPT(epno));
/* Setup up buffer descriptor table (BDT) entry/ies for this endpoint */
@@ -3333,6 +3329,8 @@ static int khci_epconfigure(struct usbdev_ep_s *ep,
ep->eplog = USB_EPOUT(epno);
}
+ khci_putreg(regval, KINETIS_USB0_ENDPT(epno));
+
return OK;
}
@@ -3368,7 +3366,7 @@ static int khci_epdisable(struct usbdev_ep_s *ep)
/* Disable the endpoint */
- khci_putreg(0, KINETIS_USB0_ENDPT(epno));
+ khci_putreg(KHCI_EP_DISABLED, KINETIS_USB0_ENDPT(epno));
/* Reset the BDTs for the endpoint. Four BDT entries per endpoint; Two
* 32-bit words per BDT.
@@ -3924,7 +3922,7 @@ static int khci_wakeup(struct usbdev_s *dev)
/* Resume normal operation. */
- khci_resume(priv);
+ khci_remote_resume(priv);
return OK;
}
@@ -3958,9 +3956,8 @@ static int khci_selfpowered(struct usbdev_s *dev, bool selfpowered)
* Name: khci_reset
*
* Description:
- * Reset the software and hardware states. If the USB controller has been
- * attached to a host, then connect to the bus as well. At the end of
- * this reset, the hardware should be in the full up, ready-to-run state.
+ * Reset the software and hardware states. At the end of this reset, the
+ * hardware should be in the full up, ready-to-run state.
*
****************************************************************************/
@@ -3974,18 +3971,9 @@ static void khci_reset(struct khci_usbdev_s *priv)
khci_hwreset(priv);
- /* khci_attach() was called, then the attach flag will be set and we
- * should also attach to the USB bus.
- */
+ /* Do the final hw attach */
- if (priv->attached)
- {
- /* usbdev_attach() has already been called.. attach to the bus
- * now
- */
-
- khci_attach(priv);
- }
+ khci_attach(priv);
}
/****************************************************************************
@@ -4004,24 +3992,23 @@ static void khci_attach(struct khci_usbdev_s *priv)
up_disable_irq(KINETIS_IRQ_USBOTG);
- /* Initialize registers to known states. */
+ /* Initialize the controller to known states. */
-#if 1
- khci_putreg(0x1,KINETIS_USB0_CTL);
- khci_putreg(0,KINETIS_USB0_USBCTRL);
-#endif
+ khci_putreg(USB_CTL_USBENSOFEN, KINETIS_USB0_CTL);
+
+ /* Configure things like: pull ups, full/low-speed mode,
+ * set the ping pong mode, and set internal transceiver
+ */
+
+ khci_putreg(0, KINETIS_USB0_USBCTRL);
/* Enable interrupts at the USB controller */
khci_putreg(ERROR_INTERRUPTS, KINETIS_USB0_ERREN);
khci_putreg(NORMAL_INTERRUPTS, KINETIS_USB0_INTEN);
- /* Configure EP0 */
-
- khci_ep0configure(priv);
-
/* Flush any pending transactions */
-#if 1
+
while ((khci_getreg(KINETIS_USB0_ISTAT) & USB_INT_TOKDNE) != 0)
{
khci_putreg(USB_INT_TOKDNE, KINETIS_USB0_ISTAT);
@@ -4053,6 +4040,10 @@ static void khci_attach(struct khci_usbdev_s *priv)
khci_putreg(regval, KINETIS_USB0_OTGCTL);
#endif
+ /* Configure EP0 */
+
+ khci_ep0configure(priv);
+
/* Transition to the attached state */
priv->devstate = DEVSTATE_ATTACHED;
@@ -4062,69 +4053,13 @@ static void khci_attach(struct khci_usbdev_s *priv)
khci_putreg(USB_EINT_ALL, KINETIS_USB0_ERRSTAT);
khci_putreg(USB_INT_ALL, KINETIS_USB0_ISTAT);
-#endif
+
+ kinetis_clrpend(KINETIS_IRQ_USBOTG);
/* Enable USB interrupts at the interrupt controller */
up_enable_irq(KINETIS_IRQ_USBOTG);
-
- /* Enable pull-up to connect the device. The host should enumerate us
- * some time after this
- */
-
- kinetis_usbpullup(&priv->usbdev, true);
- }
-}
-
-/****************************************************************************
- * Name: khci_detach
- ****************************************************************************/
-
-static void khci_detach(struct khci_usbdev_s *priv)
-{
-#ifdef CONFIG_USBOTG
- uint32_t regval;
-#endif
-
- /* Disable USB interrupts at the interrupt controller */
-
- up_disable_irq(KINETIS_IRQ_USBOTG);
-
- /* Disable the USB controller and detach from the bus. */
-
- khci_putreg(0, KINETIS_USB0_CTL);
-
- /* Mask all USB interrupts */
-
- khci_putreg(0, KINETIS_USB0_INTEN);
-
- /* We are now in the detached state */
-
- priv->attached = 0;
- priv->devstate = DEVSTATE_DETACHED;
-
-#ifdef CONFIG_USBOTG
- /* Disable the D+ Pullup */
-
- regval = khci_getreg(KINETIS_USB0_OTGCTL);
- regval &= ~USBOTG_CON_DPPULUP;
- khci_putreg(regval, KINETIS_USB0_OTGCTL);
-
- /* Disable and deactivate HNP */
-#warning Missing Logic
-
- /* Check if the ID Pin Changed State */
-
- if ((khci_getreg(KINETIS_USB0_ISTAT) & khci_getreg(KINETIS_USB0_OTGICR) & USBOTG_INT_ID) != 0)
- {
- /* Re-detect & Initialize */
-#warning "Missing logic"
-
- /* Clear ID Interrupt Flag */
-
- khci_putreg(USBOTG_INT_ID, KINETIS_USB0_ISTAT);
}
-#endif
}
/****************************************************************************
@@ -4144,9 +4079,9 @@ static void khci_swreset(struct khci_usbdev_s *priv)
CLASS_DISCONNECT(priv->driver, &priv->usbdev);
}
- /* Flush and reset endpoint states (except EP0) */
+ /* Flush and reset endpoint states */
- for (epno = 1; epno < KHCI_NENDPOINTS; epno++)
+ for (epno = 0; epno < KHCI_NENDPOINTS; epno++)
{
struct khci_ep_s *privep = &priv->eplist[epno];
@@ -4158,7 +4093,7 @@ static void khci_swreset(struct khci_usbdev_s *priv)
* for each of its configured endpoints.
*/
- khci_cancelrequests(privep, -EAGAIN);
+ khci_cancelrequests(privep, -ESHUTDOWN);
/* Reset endpoint status */
@@ -4167,18 +4102,7 @@ static void khci_swreset(struct khci_usbdev_s *priv)
privep->txnullpkt = false;
}
- /* Reset to the default address */
-
- khci_putreg(0, KINETIS_USB0_ADDR);
-
- /* Unconfigure each endpoint by clearing the endpoint control registers
- * (except EP0)
- */
-
- for (epno = 1; epno < KHCI_NENDPOINTS; epno++)
- {
- khci_putreg(0, KINETIS_USB0_ENDPT(epno));
- }
+ priv->devstate = DEVSTATE_DETACHED;
/* Reset the control state */
@@ -4196,31 +4120,79 @@ static void khci_swreset(struct khci_usbdev_s *priv)
static void khci_hwreset(struct khci_usbdev_s *priv)
{
+ int epno;
uint32_t regval;
-#define USB_FLASH_ACCESS
-#ifdef USB_FLASH_ACCESS
- /* Allow USBOTG-FS Controller to Read from FLASH */
+ /* When bus reset is received during suspend, ensure we resume */
- regval = getreg32(KINETIS_FMC_PFAPR);
- regval &= ~(FMC_PFAPR_M4AP_MASK);
- regval |= (FMC_PFAPR_RDONLY << FMC_PFAPR_M4AP_SHIFT);
- putreg32(regval, KINETIS_FMC_PFAPR);
-#endif
+ if ((khci_getreg(KINETIS_USB0_USBCTRL) & USB_USBCTRL_SUSP) != 0)
+ {
+ khci_resume(priv);
+ }
- /* Clear all of the buffer descriptor table (BDT) entries */
+ /* Unconfigure each endpoint by clearing the endpoint control registers */
- memset((void *)g_bdt, 0, sizeof(g_bdt));
+ for (epno = 0; epno < KHCI_NENDPOINTS; epno++)
+ {
+ khci_putreg(KHCI_EP_DISABLED, KINETIS_USB0_ENDPT(epno));
+ }
+
+ /* Reset the address */
+
+ khci_putreg(0, KINETIS_USB0_ADDR);
+
+ /* Assert reset request to all of the Ping Pong buffer pointers. This
+ * will reset all Even/Odd buffer pointers to the EVEN BD banks.
+ */
+
+ regval = khci_getreg(KINETIS_USB0_CTL);
+ regval |= USB_CTL_ODDRST;
+ khci_putreg(regval, KINETIS_USB0_CTL);
- /* Soft reset the USB Module */
+ /* Bring the ping pong buffer pointers out of reset */
+
+ regval &= ~USB_CTL_ODDRST;
+ khci_putreg(regval, KINETIS_USB0_CTL);
+
+ /* Enable interrupts at the USB controller */
+
+ khci_putreg(ERROR_INTERRUPTS, KINETIS_USB0_ERREN);
+ khci_putreg(NORMAL_INTERRUPTS, KINETIS_USB0_INTEN);
+}
+
+/****************************************************************************
+ * Name: khci_hwinitalize
+ *
+ * Description:
+ * Reset the hardware and leave it in a known, unready state.
+ *
+ ****************************************************************************/
+
+static void khci_hwinitalize(struct khci_usbdev_s *priv)
+{
+ uint32_t regval;
+
+ /* Initialize registers to known states. */
+
+ /* Reset USB Module */
regval = khci_getreg(KINETIS_USB0_USBTRC0);
regval |= USB_USBTRC0_USBRESET;
- khci_putreg(regval,KINETIS_USB0_USBTRC0);
+ khci_putreg(regval, KINETIS_USB0_USBTRC0);
- /* Is this really necessary? */
+ /* NOTE: This bit is always read as zero. Wait two
+ * USB clock cycles after setting this bit.That is ~42 Ns
+ */
- while (khci_getreg(KINETIS_USB0_USBTRC0) & USB_USBTRC0_USBRESET);
+ /* Clear all of the buffer descriptor table (BDT) entries */
+
+ memset((void *)g_bdt, 0, sizeof(g_bdt));
+
+ /* Enable the USB-FS to operate */
+
+ khci_putreg(0, KINETIS_USB0_CTL);
+ up_udelay(2);
+ khci_putreg(USB_CTL_USBENSOFEN, KINETIS_USB0_CTL);
/* Set the address of the buffer descriptor table (BDT)
*
@@ -4231,59 +4203,31 @@ static void khci_hwreset(struct khci_usbdev_s *priv)
khci_putreg((uint8_t)((uint32_t)g_bdt >> 24), KINETIS_USB0_BDTPAGE3);
khci_putreg((uint8_t)((uint32_t)g_bdt >> 16), KINETIS_USB0_BDTPAGE2);
- khci_putreg((uint8_t)(((uint32_t)g_bdt >> 8) & USB_BDTPAGE1_MASK), KINETIS_USB0_BDTPAGE1);
+ khci_putreg((uint8_t)(((uint32_t)g_bdt >> 8) & USB_BDTPAGE1_MASK), KINETIS_USB0_BDTPAGE1);
uinfo("BDT Address %hhx \n" ,&g_bdt);
uinfo("BDTPAGE3 %hhx\n",khci_getreg(KINETIS_USB0_BDTPAGE3));
uinfo("BDTPAGE2 %hhx\n",khci_getreg(KINETIS_USB0_BDTPAGE2));
uinfo("BDTPAGE1 %hhx\n",khci_getreg(KINETIS_USB0_BDTPAGE1));
- /* Clear any pending interrupts */
-
- khci_putreg(0xFF, KINETIS_USB0_ERRSTAT);
- khci_putreg(0xFF, KINETIS_USB0_ISTAT);
- khci_putreg(0xFF,KINETIS_USB0_OTGISTAT);
-
-#if 1
- /* Assert reset request to all of the Ping Pong buffer pointers. This
- * will reset all Even/Odd buffer pointers to the EVEN BD banks.
- */
-
- regval = khci_getreg(KINETIS_USB0_CTL);
- regval |= USB_CTL_ODDRST;
- khci_putreg(regval, KINETIS_USB0_CTL);
-
- /* Bring the ping pong buffer pointers out of reset */
-
- regval &= ~USB_CTL_ODDRST;
- khci_putreg(regval, KINETIS_USB0_CTL);
-#endif
-
-#if 1
+#if defined(USB0_USBTRC0_BIT6)
/* Undocumented bit */
regval = khci_getreg(KINETIS_USB0_USBTRC0);
- regval |= 0x40;
+ regval |= USB0_USBTRC0_BIT6;
khci_putreg(regval,KINETIS_USB0_USBTRC0);
#endif
- priv->devstate = DEVSTATE_DETACHED;
}
/****************************************************************************
- * Name: khci_stateinit
+ * Name: khci_swinitalize
****************************************************************************/
-static void khci_stateinit(struct khci_usbdev_s *priv)
+static void khci_swinitalize(struct khci_usbdev_s *priv)
{
int epno;
- /* Disconnect the device / disable the pull-up. We don't want the
- * host to enumerate us until the class driver is registered.
- */
-
- kinetis_usbpullup(&priv->usbdev, false);
-
/* Initialize the device state structure. NOTE: many fields
* have the initial value of zero and, hence, are not explicitly
* initialized here.
@@ -4292,9 +4236,16 @@ static void khci_stateinit(struct khci_usbdev_s *priv)
memset(priv, 0, sizeof(struct khci_usbdev_s));
priv->usbdev.ops = &g_devops;
priv->usbdev.ep0 = &priv->eplist[EP0].ep;
+ priv->usbdev.speed = USB_SPEED_UNKNOWN;
priv->epavail = KHCI_ENDP_ALLSET & ~KHCI_ENDP_BIT(EP0);
priv->rwakeup = 1;
+ /* Initialize the watchdog timer that is used to perform a delayed
+ * queue restart after recovering from a stall.
+ */
+
+ priv->wdog = wd_create();
+
/* Initialize the endpoint list */
for (epno = 0; epno < KHCI_NENDPOINTS; epno++)
@@ -4332,15 +4283,6 @@ static void khci_stateinit(struct khci_usbdev_s *priv)
static void khci_hwshutdown(struct khci_usbdev_s *priv)
{
-#if 0
- uint32_t regval;
-#endif
-
- /* Put the hardware and driver in its initial, unconnected state */
-
- khci_swreset(priv);
- khci_hwreset(priv);
- priv->usbdev.speed = USB_SPEED_UNKNOWN;
/* Disable all interrupts and force the USB controller into reset */
@@ -4352,18 +4294,7 @@ static void khci_hwshutdown(struct khci_usbdev_s *priv)
khci_putreg(USB_EINT_ALL, KINETIS_USB0_ERRSTAT);
khci_putreg(USB_INT_ALL, KINETIS_USB0_ISTAT);
- /* Disconnect the device / disable the pull-up */
-
- kinetis_usbpullup(&priv->usbdev, false);
-
- /* Power down the USB controller */
-#warning FIXME powerdown USB Controller
-
-#if 0
- regval = khci_getreg(KHCI_USB_PWRC);
- regval &= ~USB_PWRC_USBPWR;
- khci_putreg(regval, KHCI_USB_PWRC);
-#endif
+ kinetis_clrpend(KINETIS_IRQ_USBOTG);
}
/****************************************************************************
@@ -4376,6 +4307,13 @@ static void khci_hwshutdown(struct khci_usbdev_s *priv)
* Description:
* Initialize the USB driver
*
+ * Assumptions:
+ * - This function is called very early in the initialization sequence
+ * - PLL and GIO pin initialization is not performed here but should been in
+ * the low-level boot logic: SIM_SOPT2[PLLFLLSEL] and
+ * SIM_CLKDIV2[USBFRAC, USBDIV] will have been configured in
+ * kinetis_pllconfig.
+ *
* Input Parameters:
* None
*
@@ -4386,20 +4324,28 @@ static void khci_hwshutdown(struct khci_usbdev_s *priv)
void up_usbinitialize(void)
{
- struct khci_usbdev_s *priv = &g_usbdev;
- uint32_t regval;
-
/* 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
* easier.
*/
+ struct khci_usbdev_s *priv = &g_usbdev;
+ uint32_t regval;
+
+ usbtrace(TRACE_DEVINIT, 0);
+
+ /* Initialize the driver state structure */
+
+ khci_swinitalize(priv);
+
/* 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]
*/
+ /* 1: Select USB clock */
+
regval = getreg32(KINETIS_SIM_SOPT2);
regval &= ~(SIM_SOPT2_USBSRC);
regval |= BOARD_USB_CLKSRC;
@@ -4411,19 +4357,16 @@ void up_usbinitialize(void)
regval |= SIM_SCGC4_USBOTG;
putreg32(regval, KINETIS_SIM_SCGC4);
- usbtrace(TRACE_DEVINIT, 0);
-
- /* Initialize the driver state structure */
-
- khci_stateinit(priv);
+#if defined(BOARD_USB_FLASHACCESS)
+ /* Allow USBOTG-FS Controller to Read from FLASH */
- /* Then perform a few one-time initialization operstions. First, initialize
- * the watchdog timer that is used to perform a delayed queue restart
- * after recovering from a stall.
- */
+ regval = getreg32(KINETIS_FMC_PFAPR);
+ regval &= ~(FMC_PFAPR_M4AP_MASK);
+ regval |= (FMC_PFAPR_RDONLY << FMC_PFAPR_M4AP_SHIFT);
+ putreg32(regval, KINETIS_FMC_PFAPR);
+#endif
- priv->epstalled = 0;
- priv->wdog = wd_create();
+ khci_swreset(priv);
/* Attach USB controller interrupt handler. The hardware will not be
* initialized and interrupts will not be enabled until the class device
@@ -4431,11 +4374,12 @@ void up_usbinitialize(void)
* them when we need them later.
*/
- if (irq_attach(KINETIS_IRQ_USBOTG, khci_interrupt, NULL) != 0)
+ if (irq_attach(KINETIS_IRQ_USBOTG, khci_interrupt, priv) != 0)
{
usbtrace(TRACE_DEVERROR(KHCI_TRACEERR_IRQREGISTRATION),
(uint16_t)KINETIS_IRQ_USBOTG);
up_usbuninitialize();
+ return;
}
#ifdef CONFIG_ARCH_IRQPRIO
@@ -4443,6 +4387,8 @@ void up_usbinitialize(void)
up_prioritize_irq(KINETIS_IRQ_USBOTG, 112);
#endif
+
+ khci_hwinitalize(priv);
}
/****************************************************************************
@@ -4466,24 +4412,36 @@ void up_usbuninitialize(void)
struct khci_usbdev_s *priv = &g_usbdev;
irqstate_t flags;
+ uint32_t regval;
- flags = enter_critical_section();
usbtrace(TRACE_DEVUNINIT, 0);
+ /* Disconnect the device */
+
+ flags = enter_critical_section();
+
+ khci_swreset(priv);
+
+ kinetis_usbpullup(&priv->usbdev, false);
+
+ wd_delete(priv->wdog);
+
+ /* Put the hardware in an inactive state */
+
+ khci_hwreset(priv);
+ khci_hwshutdown(priv);
+
/* Disable and detach the USB IRQs */
up_disable_irq(KINETIS_IRQ_USBOTG);
irq_detach(KINETIS_IRQ_USBOTG);
- if (priv->driver)
- {
- usbtrace(TRACE_DEVERROR(KHCI_TRACEERR_DRIVERREGISTERED), 0);
- usbdev_unregister(priv->driver);
- }
+ /* Gate Off the USB controller */
- /* Put the hardware in an inactive state */
+ regval = getreg32(KINETIS_SIM_SCGC4);
+ regval &= ~SIM_SCGC4_USBOTG;
+ putreg32(regval, KINETIS_SIM_SCGC4);
- khci_hwshutdown(priv);
leave_critical_section(flags);
}
@@ -4540,10 +4498,7 @@ int usbdev_register(struct usbdevclass_driver_s *driver)
else
{
- /* Setup the USB controller in it initial ready-to-run state (might
- * be connected or unconnected, depending on usbdev_attach() has
- * been called).
- */
+ /* Setup the USB controller in it initial ready-to-run state */
DEBUGASSERT(priv->devstate == DEVSTATE_DETACHED);
khci_reset(priv);
@@ -4590,6 +4545,7 @@ int usbdev_unregister(struct usbdevclass_driver_s *driver)
flags = enter_critical_section();
khci_swreset(priv);
+ kinetis_usbpullup(&priv->usbdev, false);
khci_hwreset(priv);
/* Unbind the class driver */
@@ -4606,63 +4562,9 @@ int usbdev_unregister(struct usbdevclass_driver_s *driver)
*/
khci_hwshutdown(priv);
- khci_stateinit(priv);
-
- /* Unhook the driver */
+ khci_swinitalize(priv);
- priv->driver = NULL;
leave_critical_section(flags);
return OK;
}
-
-/****************************************************************************
- * Name: khci_usbattach and khci_usbdetach
- *
- * Description:
- * The USB stack must be notified when the device is attached or detached
- * by calling one of these functions.
- *
- ****************************************************************************/
-
-void khci_usbattach(void)
-{
- /* 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
- * easier.
- */
-
- struct khci_usbdev_s *priv = &g_usbdev;
-
- /* Mark that we are attached */
-
- priv->attached = 1;
-
- /* This API may be called asynchronously from other initialization
- * interfaces. In particular, we may not want to attach the bus yet...
- * that should only be done when the class driver is attached. Has
- * the class driver been attached?
- */
-
- if (priv->driver)
- {
- /* Yes.. then attach to the bus */
-
- khci_attach(priv);
- }
-}
-
-void khci_usbdetach(void)
-{
- /* 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
- * easier.
- */
-
- struct khci_usbdev_s *priv = &g_usbdev;
-
- /* Detach from the bus */
-
- khci_detach(priv);
-}
-
#endif /* CONFIG_USBDEV && CONFIG_KHCI_USB */
diff --git a/arch/arm/src/kinetis/kinetis_usbotg.h b/arch/arm/src/kinetis/kinetis_usbotg.h
index 655c7ccee9c622e1aaa6a4cb4528f52c43b7c054..6353cf7f467d7ed20c16638ee3b405221d66a90a 100644
--- a/arch/arm/src/kinetis/kinetis_usbotg.h
+++ b/arch/arm/src/kinetis/kinetis_usbotg.h
@@ -66,6 +66,4 @@ struct usbotg_bdtentry_s
struct usbdev_s;
int kinetis_usbpullup(FAR struct usbdev_s *dev, bool enable);
void kinetis_usbsuspend(FAR struct usbdev_s *dev, bool resume);
-void khci_usbattach(void);
-
#endif /* __ARCH_ARM_SRC_KINETIS_KINETIS_USBOTG_H */
diff --git a/arch/arm/src/kinetis/kinetis_vectors.S b/arch/arm/src/kinetis/kinetis_vectors.S
index 48c74c705974668caf40465d773cd2fa91daebd1..676f1cb62beae849fb9f4ebf9a43e0caeabd85a0 100644
--- a/arch/arm/src/kinetis/kinetis_vectors.S
+++ b/arch/arm/src/kinetis/kinetis_vectors.S
@@ -60,7 +60,7 @@
* stale MSP, there will most likely be a system failure.
*
* If the interrupt stack is selected, on the other hand, then the interrupt
- * handler will always set the the MSP to the interrupt stack. So when the high
+ * handler will always set the MSP to the interrupt stack. So when the high
* priority interrupt occurs, it will either use the MSP of the last privileged
* thread to run or, in the case of the nested interrupt, the interrupt stack if
* no privileged task has run.
@@ -70,7 +70,7 @@
# error Interrupt stack must be used with high priority interrupts in kernel mode
# endif
- /* Use the the BASEPRI to control interrupts is required if nested, high
+ /* Use the BASEPRI to control interrupts is required if nested, high
* priority interrupts are supported.
*/
@@ -484,7 +484,7 @@ exception_common:
.global g_intstackbase
.align 8
g_intstackalloc:
- .skip (CONFIG_ARCH_INTERRUPTSTACK & ~7)
+ .skip ((CONFIG_ARCH_INTERRUPTSTACK + 4) & ~7)
g_intstackbase:
.size g_intstackalloc, .-g_intstackalloc
#endif
diff --git a/arch/arm/src/kl/kl_spi.h b/arch/arm/src/kl/kl_spi.h
index 227ab9e6c5de91173367631ef02a9c999f742fa8..fd621858a61eee7808139f5bd4d2055f29f5921e 100644
--- a/arch/arm/src/kl/kl_spi.h
+++ b/arch/arm/src/kl/kl_spi.h
@@ -64,7 +64,6 @@ extern "C"
************************************************************************************/
struct spi_dev_s; /* Forward reference */
-enum spi_dev_e; /* Forward reference */
/****************************************************************************
* Name: kl_spibus_initialize
@@ -111,18 +110,18 @@ FAR struct spi_dev_s *kl_spibus_initialize(int port);
************************************************************************************/
#ifdef CONFIG_KL_SPI0
-void kl_spi0select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
-uint8_t kl_spi0status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+void kl_spi0select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected);
+uint8_t kl_spi0status(FAR struct spi_dev_s *dev, uint32_t devid);
#ifdef CONFIG_SPI_CMDDATA
-int kl_spi0cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+int kl_spi0cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
#endif
#endif
#ifdef CONFIG_KL_SPI1
-void kl_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
-uint8_t kl_spi1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+void kl_spi1select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected);
+uint8_t kl_spi1status(FAR struct spi_dev_s *dev, uint32_t devid);
#ifdef CONFIG_SPI_CMDDATA
-int kl_spi1cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+int kl_spi1cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
#endif
#endif
diff --git a/arch/arm/src/lpc11xx/Kconfig b/arch/arm/src/lpc11xx/Kconfig
index 46b01ab6e9e10fb6463280948fbfd525f0c58741..088188c9503389a247f0385a009bf793b24ca8e2 100644
--- a/arch/arm/src/lpc11xx/Kconfig
+++ b/arch/arm/src/lpc11xx/Kconfig
@@ -222,7 +222,7 @@ config CAN_SAM
The bus is sampled 3 times (recommended for low to medium speed buses to spikes on the bus-line).
config CAN_LOOPBACK
- bool "CAN looopback mode"
+ bool "CAN loopback mode"
default n
---help---
Enable CAN loopback mode
diff --git a/arch/arm/src/lpc11xx/lpc11_serial.c b/arch/arm/src/lpc11xx/lpc11_serial.c
index cbef799afe9d434f097f70d0412e602db196dc75..941a4475b4b148195b15b37bab2fcea93e153313 100644
--- a/arch/arm/src/lpc11xx/lpc11_serial.c
+++ b/arch/arm/src/lpc11xx/lpc11_serial.c
@@ -498,7 +498,7 @@ static void up_shutdown(struct uart_dev_s *dev)
* Description:
* Configure the UART 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
+ * 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
diff --git a/arch/arm/src/lpc11xx/lpc11_spi.h b/arch/arm/src/lpc11xx/lpc11_spi.h
index dc8edfa904b7d8fcf5bc1c20dc29219758f523b1..1a6786d2180e012ee2f0fcf6657d8e8e4a0f76d0 100644
--- a/arch/arm/src/lpc11xx/lpc11_spi.h
+++ b/arch/arm/src/lpc11xx/lpc11_spi.h
@@ -112,10 +112,10 @@ FAR struct spi_dev_s *lpc11_spibus_initialize(int port);
*
************************************************************************************/
-void lpc11_spiselect(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
-uint8_t lpc11_spistatus(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+void lpc11_spiselect(FAR struct spi_dev_s *dev, uint32_t devid, bool selected);
+uint8_t lpc11_spistatus(FAR struct spi_dev_s *dev, uint32_t devid);
#ifdef CONFIG_SPI_CMDDATA
-int lpc11_spicmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+int lpc11_spicmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
#endif
/************************************************************************************
diff --git a/arch/arm/src/lpc11xx/lpc11_ssp.h b/arch/arm/src/lpc11xx/lpc11_ssp.h
index 9910650a300b79ea7957c5a3bad7bde14deaad81..f117b1cf034d6b23a5545888779fec7280ccee26 100644
--- a/arch/arm/src/lpc11xx/lpc11_ssp.h
+++ b/arch/arm/src/lpc11xx/lpc11_ssp.h
@@ -113,18 +113,18 @@ FAR struct spi_dev_s *lpc11_sspbus_initialize(int port);
************************************************************************************/
#ifdef CONFIG_LPC11_SSP0
-void lpc11_ssp0select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
-uint8_t lpc11_ssp0status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+void lpc11_ssp0select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected);
+uint8_t lpc11_ssp0status(FAR struct spi_dev_s *dev, uint32_t devid);
#ifdef CONFIG_SPI_CMDDATA
-int lpc11_ssp0cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+int lpc11_ssp0cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
#endif
#endif
#ifdef CONFIG_LPC11_SSP1
-void lpc11_ssp1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
-uint8_t lpc11_ssp1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+void lpc11_ssp1select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected);
+uint8_t lpc11_ssp1status(FAR struct spi_dev_s *dev, uint32_t devid);
#ifdef CONFIG_SPI_CMDDATA
-int lpc11_ssp1cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+int lpc11_ssp1cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
#endif
#endif
diff --git a/arch/arm/src/lpc17xx/Kconfig b/arch/arm/src/lpc17xx/Kconfig
index f8f95f8c5dff1fabfb6f99fc3b39cc2c0bdc5223..bef6ef884c120c857c64702b483ee8994f4a1138 100644
--- a/arch/arm/src/lpc17xx/Kconfig
+++ b/arch/arm/src/lpc17xx/Kconfig
@@ -589,7 +589,7 @@ config CAN_SAM
The bus is sampled 3 times (recommended for low to medium speed buses to spikes on the bus-line).
config CAN_LOOPBACK
- bool "CAN looopback mode"
+ bool "CAN loopback mode"
default n
---help---
Enable CAN loopback mode
diff --git a/arch/arm/src/lpc17xx/lpc17_can.c b/arch/arm/src/lpc17xx/lpc17_can.c
index 11ac88cc04debf2557f3aee6b5276a6d2e157001..94f1987280c41aeadc4ee8ad8c7994231d2be2e5 100644
--- a/arch/arm/src/lpc17xx/lpc17_can.c
+++ b/arch/arm/src/lpc17xx/lpc17_can.c
@@ -57,7 +57,7 @@
#include
#include
#include
-#include
+#include
#include "up_internal.h"
#include "up_arch.h"
diff --git a/arch/arm/src/lpc17xx/lpc17_ethernet.c b/arch/arm/src/lpc17xx/lpc17_ethernet.c
index 42e046aea1cacd1d4ec680c3b93f5482e70f57f0..dd1c05d0d143f9d45a2cd6a1e6008314192cf1ed 100644
--- a/arch/arm/src/lpc17xx/lpc17_ethernet.c
+++ b/arch/arm/src/lpc17xx/lpc17_ethernet.c
@@ -1591,16 +1591,16 @@ static int lpc17_ifup(struct net_driver_s *dev)
/* Configure the MAC station address */
- regval = (uint32_t)priv->lp_dev.d_mac.ether_addr_octet[5] << 8 |
- (uint32_t)priv->lp_dev.d_mac.ether_addr_octet[4];
+ regval = (uint32_t)priv->lp_dev.d_mac.ether.ether_addr_octet[5] << 8 |
+ (uint32_t)priv->lp_dev.d_mac.ether.ether_addr_octet[4];
lpc17_putreg(regval, LPC17_ETH_SA0);
- regval = (uint32_t)priv->lp_dev.d_mac.ether_addr_octet[3] << 8 |
- (uint32_t)priv->lp_dev.d_mac.ether_addr_octet[2];
+ regval = (uint32_t)priv->lp_dev.d_mac.ether.ether_addr_octet[3] << 8 |
+ (uint32_t)priv->lp_dev.d_mac.ether.ether_addr_octet[2];
lpc17_putreg(regval, LPC17_ETH_SA1);
- regval = (uint32_t)priv->lp_dev.d_mac.ether_addr_octet[1] << 8 |
- (uint32_t)priv->lp_dev.d_mac.ether_addr_octet[0];
+ regval = (uint32_t)priv->lp_dev.d_mac.ether.ether_addr_octet[1] << 8 |
+ (uint32_t)priv->lp_dev.d_mac.ether.ether_addr_octet[0];
lpc17_putreg(regval, LPC17_ETH_SA2);
#ifdef CONFIG_NET_ICMPv6
diff --git a/arch/arm/src/lpc17xx/lpc17_spi.h b/arch/arm/src/lpc17xx/lpc17_spi.h
index c2eeea58f9e0e419b750aa7bcd986b37ab67233e..27d9ba8bb935e429e90d6ebc9aed7b28672c96f4 100644
--- a/arch/arm/src/lpc17xx/lpc17_spi.h
+++ b/arch/arm/src/lpc17xx/lpc17_spi.h
@@ -71,7 +71,6 @@ extern "C"
************************************************************************************/
struct spi_dev_s; /* Forward reference */
-enum spi_dev_e; /* Forward reference */
/************************************************************************************
* Name: lpc17_spibus_initialize
@@ -115,10 +114,10 @@ FAR struct spi_dev_s *lpc17_spibus_initialize(int port);
*
************************************************************************************/
-void lpc17_spiselect(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
-uint8_t lpc17_spistatus(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+void lpc17_spiselect(FAR struct spi_dev_s *dev, uint32_t devid, bool selected);
+uint8_t lpc17_spistatus(FAR struct spi_dev_s *dev, uint32_t devid);
#ifdef CONFIG_SPI_CMDDATA
-int lpc17_spicmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+int lpc17_spicmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
#endif
/****************************************************************************
diff --git a/arch/arm/src/lpc17xx/lpc17_ssp.h b/arch/arm/src/lpc17xx/lpc17_ssp.h
index 6ea6375b131374aa6dee3047eafe7070b5467b12..c679206ca1e475b6596e59759b14d47975fb3723 100644
--- a/arch/arm/src/lpc17xx/lpc17_ssp.h
+++ b/arch/arm/src/lpc17xx/lpc17_ssp.h
@@ -113,18 +113,18 @@ FAR struct spi_dev_s *lpc17_sspbus_initialize(int port);
************************************************************************************/
#ifdef CONFIG_LPC17_SSP0
-void lpc17_ssp0select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
-uint8_t lpc17_ssp0status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+void lpc17_ssp0select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected);
+uint8_t lpc17_ssp0status(FAR struct spi_dev_s *dev, uint32_t devid);
#ifdef CONFIG_SPI_CMDDATA
-int lpc17_ssp0cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+int lpc17_ssp0cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
#endif
#endif
#ifdef CONFIG_LPC17_SSP1
-void lpc17_ssp1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
-uint8_t lpc17_ssp1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+void lpc17_ssp1select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected);
+uint8_t lpc17_ssp1status(FAR struct spi_dev_s *dev, uint32_t devid);
#ifdef CONFIG_SPI_CMDDATA
-int lpc17_ssp1cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+int lpc17_ssp1cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
#endif
#endif
diff --git a/arch/arm/src/lpc17xx/lpc17_usbhost.c b/arch/arm/src/lpc17xx/lpc17_usbhost.c
index 42825b021322c652e1a14814994ac8ab7cabe2ce..6bb48cd8f9ffcffcfb139aff4180937c39a97bca 100644
--- a/arch/arm/src/lpc17xx/lpc17_usbhost.c
+++ b/arch/arm/src/lpc17xx/lpc17_usbhost.c
@@ -3164,7 +3164,7 @@ static void lpc17_asynch_completion(struct lpc17_usbhost_s *priv,
* Description:
* Process a request to handle a transfer descriptor. This method will
* enqueue the transfer request and return immediately. When the transfer
- * completes, the the callback will be invoked with the provided transfer.
+ * completes, the callback will be invoked with the provided transfer.
* This method is useful for receiving interrupt transfers which may come
* infrequently.
*
diff --git a/arch/arm/src/lpc17xx/lpc17_vectors.S b/arch/arm/src/lpc17xx/lpc17_vectors.S
index 6cee7d973163b2f574f5dffd2a2ffa8cdbf7b9f0..1b696a6a60b376c9ed5ab9d962ada0666004ced0 100644
--- a/arch/arm/src/lpc17xx/lpc17_vectors.S
+++ b/arch/arm/src/lpc17xx/lpc17_vectors.S
@@ -58,7 +58,7 @@
* interrupt occurs and uses this stale MSP, there will most likely be a system failure.
*
* If the interrupt stack is selected, on the other hand, then the interrupt handler will
- * always set the the MSP to the interrupt stack. So when the high priority interrupt occurs,
+ * always set the MSP to the interrupt stack. So when the high priority interrupt occurs,
* it will either use the MSP of the last privileged thread to run or, in the case of the
* nested interrupt, the interrupt stack if no privileged task has run.
*/
@@ -67,7 +67,7 @@
# error Interrupt stack must be used with high priority interrupts in kernel mode
# endif
- /* Use the the BASEPRI to control interrupts is required if nested, high
+ /* Use the BASEPRI to control interrupts is required if nested, high
* priority interrupts are supported.
*/
@@ -348,7 +348,7 @@ exception_common:
*
* Here:
* r0 = Address of the register save area
-
+ *
* NOTE: It is a requirement that up_restorefpu() preserve the value of
* r0!
*/
@@ -468,7 +468,7 @@ exception_common:
.global g_intstackbase
.align 8
g_intstackalloc:
- .skip (CONFIG_ARCH_INTERRUPTSTACK & ~7)
+ .skip ((CONFIG_ARCH_INTERRUPTSTACK + 4) & ~7)
g_intstackbase:
.size g_intstackalloc, .-g_intstackalloc
#endif
diff --git a/arch/arm/src/lpc2378/lpc23xx_spi.h b/arch/arm/src/lpc2378/lpc23xx_spi.h
index f701c9e1f98b4ca79c60abc9aefbde8851dee2db..8b5fbda37c5b14db4acfcdad1094a32a85a106bd 100644
--- a/arch/arm/src/lpc2378/lpc23xx_spi.h
+++ b/arch/arm/src/lpc2378/lpc23xx_spi.h
@@ -154,7 +154,6 @@
************************************************************************************/
struct spi_dev_s; /* Forward reference */
-enum spi_dev_e; /* Forward reference */
/****************************************************************************
* Name: lpc23_spibus_initialize
@@ -178,7 +177,7 @@ FAR struct spi_dev_s *lpc23_spibus_initialize(int port);
*
****************************************************************************/
-void lpc23xx_spiselect(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
-uint8_t lpc23xx_spistatus(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+void lpc23xx_spiselect(FAR struct spi_dev_s *dev, uint32_t devid, bool selected);
+uint8_t lpc23xx_spistatus(FAR struct spi_dev_s *dev, uint32_t devid);
#endif /* __ARCH_ARM_SRC_LPC2378_LPC23XX_SPI_H */
diff --git a/arch/arm/src/lpc31xx/Kconfig b/arch/arm/src/lpc31xx/Kconfig
index addeaf16e423c3ed1f96a91d02bda779c014078c..5f1b86bc134b96c87891d9cda32977c755d4f296 100644
--- a/arch/arm/src/lpc31xx/Kconfig
+++ b/arch/arm/src/lpc31xx/Kconfig
@@ -263,7 +263,7 @@ config LPC31_EHCI_SDIS
Selecting this option ensures that overruns/underruns of the latency
FIFO are eliminated for low bandwidth systems where the RX and TX
buffers are sufficient to contain the entire packet. Enabling stream
- disable also has the effect of ensuring the the TX latency is filled
+ disable also has the effect of ensuring the TX latency is filled
to capacity before the packet is launched onto the USB.
Note: Time duration to pre-fill the FIFO becomes significant when stream disable is active.
diff --git a/arch/arm/src/lpc31xx/lpc31.h b/arch/arm/src/lpc31xx/lpc31.h
index 4a342a9a839f5d64651a595c6f76208a8b22933e..00ce6b8e35c70801957df11c2a8601230bf93db3 100644
--- a/arch/arm/src/lpc31xx/lpc31.h
+++ b/arch/arm/src/lpc31xx/lpc31.h
@@ -185,8 +185,6 @@ void lpc31_clockconfig(void);
************************************************************************************/
struct spi_dev_s; /* Forward reference */
-enum spi_dev_e; /* Forward reference */
-
FAR struct spi_dev_s *lpc31_spibus_initialize(int port);
/************************************************************************************
@@ -218,10 +216,10 @@ FAR struct spi_dev_s *lpc31_spibus_initialize(int port);
*
************************************************************************************/
-void lpc31_spiselect(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
-uint8_t lpc31_spistatus(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+void lpc31_spiselect(FAR struct spi_dev_s *dev, uint32_t devid, bool selected);
+uint8_t lpc31_spistatus(FAR struct spi_dev_s *dev, uint32_t devid);
#ifdef CONFIG_SPI_CMDDATA
-int lpc31_spicmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+int lpc31_spicmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
#endif
/************************************************************************************
diff --git a/arch/arm/src/lpc31xx/lpc31_ehci.c b/arch/arm/src/lpc31xx/lpc31_ehci.c
index 475c4dea89d25df97bdeaf4aa8817e6e2f9dbebe..1884a412417dab7a66b166af41ed2f258e1387a7 100644
--- a/arch/arm/src/lpc31xx/lpc31_ehci.c
+++ b/arch/arm/src/lpc31xx/lpc31_ehci.c
@@ -3008,7 +3008,7 @@ static inline void lpc31_ioc_bottomhalf(void)
qh = (struct lpc31_qh_s *)lpc31_virtramaddr(lpc31_swap32(*bp) & QH_HLP_MASK);
/* If the asynchronous queue is empty, then the forward point in the
- * asynchronous queue head will point back to the the queue head.
+ * asynchronous queue head will point back to the queue head.
*/
if (qh && qh != &g_asynchead)
@@ -4362,7 +4362,7 @@ errout_with_sem:
* Description:
* Process a request to handle a transfer descriptor. This method will
* enqueue the transfer request and return immediately. When the transfer
- * completes, the the callback will be invoked with the provided transfer.
+ * completes, the callback will be invoked with the provided transfer.
* This method is useful for receiving interrupt transfers which may come
* infrequently.
*
@@ -4560,7 +4560,7 @@ static int lpc31_cancel(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep)
qh = (struct lpc31_qh_s *)lpc31_virtramaddr(lpc31_swap32(*bp) & QH_HLP_MASK);
/* If the asynchronous queue is empty, then the forward point in
- * the asynchronous queue head will point back to the the queue
+ * the asynchronous queue head will point back to the queue
* head.
*/
diff --git a/arch/arm/src/lpc31xx/lpc31_serial.c b/arch/arm/src/lpc31xx/lpc31_serial.c
index fa5f3b4563fcd8d4dc10eebddbda04f2f9defb1a..7f79a0f41ba463aee75dee6ae768fa920e8853c0 100644
--- a/arch/arm/src/lpc31xx/lpc31_serial.c
+++ b/arch/arm/src/lpc31xx/lpc31_serial.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/lpc31xx/lpc31_serial.c
*
- * Copyright (C) 2009, 2012-2013 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2009, 2012-2013, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
*
* Redistribution and use in source and binary forms, with or without
@@ -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, NULL);
+ ret = irq_attach(LPC31_IRQ_UART, up_interrupt, dev);
if (ret == OK)
{
/* Enable the interrupt (RX and TX interrupts are still disabled
@@ -453,6 +453,7 @@ static int up_attach(struct uart_dev_s *dev)
up_enable_irq(LPC31_IRQ_UART);
}
+
return ret;
}
@@ -484,9 +485,9 @@ static void up_detach(struct uart_dev_s *dev)
static int up_interrupt(int irq, void *context, FAR void *arg)
{
- struct uart_dev_s *dev = &g_uartport;
- uint8_t status;
- int passes;
+ struct uart_dev_s *dev = (struct uart_dev_s *)arg;
+ uint8_t status;
+ int passes;
/* 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/lpc31xx/lpc31_spi.c b/arch/arm/src/lpc31xx/lpc31_spi.c
index ca2544bc2654d65966bf372cdb66992fdd0bd178..871eca69da343ec2f53c266cf0ea0ac5613f07e0 100644
--- a/arch/arm/src/lpc31xx/lpc31_spi.c
+++ b/arch/arm/src/lpc31xx/lpc31_spi.c
@@ -115,11 +115,11 @@ static inline uint16_t spi_readword(FAR struct lpc31_spidev_s *priv);
static inline void spi_writeword(FAR struct lpc31_spidev_s *priv, uint16_t word);
static int spi_lock(FAR struct spi_dev_s *dev, bool lock);
-static void spi_select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
+static void spi_select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected);
static uint32_t spi_setfrequency(FAR struct spi_dev_s *dev, uint32_t frequency);
static void spi_setmode(FAR struct spi_dev_s *dev, enum spi_mode_e mode);
static void spi_setbits(FAR struct spi_dev_s *dev, int nbits);
-static uint8_t spi_status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+static uint8_t spi_status(FAR struct spi_dev_s *dev, uint32_t devid);
static uint16_t spi_send(FAR struct spi_dev_s *dev, uint16_t word);
static void spi_exchange(FAR struct spi_dev_s *dev, FAR const void *txbuffer,
FAR void *rxbuffer, size_t nwords);
@@ -482,7 +482,7 @@ static int spi_lock(FAR struct spi_dev_s *dev, bool lock)
*
****************************************************************************/
-static void spi_select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
+static void spi_select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected)
{
struct lpc31_spidev_s *priv = (struct lpc31_spidev_s *) dev;
uint8_t slave = 0;
@@ -491,15 +491,15 @@ static void spi_select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool sel
* be in board specific code..... */
switch (devid)
{
- case SPIDEV_FLASH:
+ case SPIDEV_FLASH(0):
slave = 0;
break;
- case SPIDEV_MMCSD:
+ case SPIDEV_MMCSD(0):
slave = 1;
break;
- case SPIDEV_ETHERNET:
+ case SPIDEV_ETHERNET(0):
slave = 2;
break;
@@ -689,7 +689,7 @@ static void spi_setbits(FAR struct spi_dev_s *dev, int nbits)
*
****************************************************************************/
-static uint8_t spi_status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
+static uint8_t spi_status(FAR struct spi_dev_s *dev, uint32_t devid)
{
/* FIXME: is there anyway to determine this
* it should probably be board dependant anyway */
diff --git a/arch/arm/src/lpc43xx/lpc43_allocateheap.c b/arch/arm/src/lpc43xx/lpc43_allocateheap.c
index b7a947b668ff7550ab8e4c279f6dc51d792006f5..a6a73284d144b21a5c86a24f10471c37ecf51404 100644
--- a/arch/arm/src/lpc43xx/lpc43_allocateheap.c
+++ b/arch/arm/src/lpc43xx/lpc43_allocateheap.c
@@ -186,7 +186,7 @@
#ifndef CONFIG_LPC43_BOOT_SRAM
/* Configuration A */
-/* CONFIG_RAM_START shoudl be set to the base of local SRAM, Bank 0. */
+/* CONFIG_RAM_START should be set to the base of local SRAM, Bank 0. */
# if CONFIG_RAM_START != LPC43_LOCSRAM_BANK0_BASE
# error "CONFIG_RAM_START must be set to the base address of RAM bank 0"
diff --git a/arch/arm/src/lpc43xx/lpc43_ehci.c b/arch/arm/src/lpc43xx/lpc43_ehci.c
index 5af61fa9394394de44212814d05ce3621bfa6e46..e9bb3ddcdc30cdf566882b22431b150654d6ba10 100644
--- a/arch/arm/src/lpc43xx/lpc43_ehci.c
+++ b/arch/arm/src/lpc43xx/lpc43_ehci.c
@@ -2849,7 +2849,7 @@ static inline void lpc43_ioc_bottomhalf(void)
qh = (struct lpc43_qh_s *)lpc43_virtramaddr(lpc43_swap32(*bp) & QH_HLP_MASK);
/* If the asynchronous queue is empty, then the forward point in the
- * asynchronous queue head will point back to the the queue head.
+ * asynchronous queue head will point back to the queue head.
*/
if (qh && qh != &g_asynchead)
@@ -4193,7 +4193,7 @@ errout_with_sem:
* Description:
* Process a request to handle a transfer descriptor. This method will
* enqueue the transfer request and return immediately. When the transfer
- * completes, the the callback will be invoked with the provided transfer.
+ * completes, the callback will be invoked with the provided transfer.
* This method is useful for receiving interrupt transfers which may come
* infrequently.
*
@@ -4391,7 +4391,7 @@ static int lpc43_cancel(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep)
qh = (struct lpc43_qh_s *)lpc43_virtramaddr(lpc43_swap32(*bp) & QH_HLP_MASK);
/* If the asynchronous queue is empty, then the forward point in
- * the asynchronous queue head will point back to the the queue
+ * the asynchronous queue head will point back to the queue
* head.
*/
diff --git a/arch/arm/src/lpc43xx/lpc43_ethernet.c b/arch/arm/src/lpc43xx/lpc43_ethernet.c
index 1aeca91d89e8413f983758c0d10f37be5da07e91..955c30684e147e8b048bb8e71f431bac3c23b2a6 100644
--- a/arch/arm/src/lpc43xx/lpc43_ethernet.c
+++ b/arch/arm/src/lpc43xx/lpc43_ethernet.c
@@ -572,7 +572,8 @@ static void lpc43_checksetup(void);
static void lpc43_initbuffer(FAR struct lpc43_ethmac_s *priv);
static inline uint8_t *lpc43_allocbuffer(FAR struct lpc43_ethmac_s *priv);
-static inline void lpc43_freebuffer(FAR struct lpc43_ethmac_s *priv, uint8_t *buffer);
+static inline void lpc43_freebuffer(FAR struct lpc43_ethmac_s *priv,
+ uint8_t *buffer);
static inline bool lpc43_isfreebuffer(FAR struct lpc43_ethmac_s *priv);
/* Common TX logic */
@@ -583,11 +584,13 @@ static void lpc43_dopoll(FAR struct lpc43_ethmac_s *priv);
/* Interrupt handling */
-static void lpc43_enableint(FAR struct lpc43_ethmac_s *priv, uint32_t ierbit);
-static void lpc43_disableint(FAR struct lpc43_ethmac_s *priv, uint32_t ierbit);
+static void lpc43_enableint(FAR struct lpc43_ethmac_s *priv,
+ uint32_t ierbit);
+static void lpc43_disableint(FAR struct lpc43_ethmac_s *priv,
+ uint32_t ierbit);
static void lpc43_freesegment(FAR struct lpc43_ethmac_s *priv,
- FAR struct eth_rxdesc_s *rxfirst, int segments);
+ FAR struct eth_rxdesc_s *rxfirst, int segments);
static int lpc43_recvframe(FAR struct lpc43_ethmac_s *priv);
static void lpc43_receive(FAR struct lpc43_ethmac_s *priv);
static void lpc43_freeframe(FAR struct lpc43_ethmac_s *priv);
@@ -619,7 +622,8 @@ static int lpc43_addmac(struct net_driver_s *dev, FAR const uint8_t *mac);
static int lpc43_rmmac(struct net_driver_s *dev, FAR const uint8_t *mac);
#endif
#ifdef CONFIG_NETDEV_PHY_IOCTL
-static int lpc43_ioctl(struct net_driver_s *dev, int cmd, long arg);
+static int lpc43_ioctl(struct net_driver_s *dev, int cmd,
+ unsigned long arg);
#endif
/* Descriptor Initialization */
@@ -630,8 +634,10 @@ static void lpc43_rxdescinit(FAR struct lpc43_ethmac_s *priv);
#if defined(CONFIG_NETDEV_PHY_IOCTL) && defined(CONFIG_ARCH_PHY_INTERRUPT)
static int lpc43_phyintenable(FAR struct lpc43_ethmac_s *priv);
#endif
-static int lpc43_phyread(uint16_t phydevaddr, uint16_t phyregaddr, uint16_t *value);
-static int lpc43_phywrite(uint16_t phydevaddr, uint16_t phyregaddr, uint16_t value);
+static int lpc43_phyread(uint16_t phydevaddr, uint16_t phyregaddr,
+ uint16_t *value);
+static int lpc43_phywrite(uint16_t phydevaddr, uint16_t phyregaddr,
+ uint16_t value);
#ifdef CONFIG_ETH0_PHY_DM9161
static inline int lpc43_dm9161(FAR struct lpc43_ethmac_s *priv);
#endif
@@ -1477,7 +1483,7 @@ static int lpc43_recvframe(FAR struct lpc43_ethmac_s *priv)
{
priv->segments++;
- /* Check if the there is only one segment in the frame */
+ /* Check if there is only one segment in the frame */
if (priv->segments == 1)
{
@@ -2739,7 +2745,7 @@ static void lpc43_rxdescinit(FAR struct lpc43_ethmac_s *priv)
****************************************************************************/
#ifdef CONFIG_NETDEV_PHY_IOCTL
-static int lpc43_ioctl(struct net_driver_s *dev, int cmd, long arg)
+static int lpc43_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
{
#ifdef CONFIG_ARCH_PHY_INTERRUPT
FAR struct lpc43_ethmac_s *priv = (FAR struct lpc43_ethmac_s *)dev->d_private;
@@ -3529,22 +3535,22 @@ static void lpc43_macaddress(FAR struct lpc43_ethmac_s *priv)
ninfo("%s MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
dev->d_ifname,
- dev->d_mac.ether_addr_octet[0], dev->d_mac.ether_addr_octet[1],
- dev->d_mac.ether_addr_octet[2], dev->d_mac.ether_addr_octet[3],
- dev->d_mac.ether_addr_octet[4], dev->d_mac.ether_addr_octet[5]);
+ dev->d_mac.ether.ether_addr_octet[0], dev->d_mac.ether.ether_addr_octet[1],
+ dev->d_mac.ether.ether_addr_octet[2], dev->d_mac.ether.ether_addr_octet[3],
+ dev->d_mac.ether.ether_addr_octet[4], dev->d_mac.ether.ether_addr_octet[5]);
/* Set the MAC address high register */
- regval = ((uint32_t)dev->d_mac.ether_addr_octet[5] << 8) |
- (uint32_t)dev->d_mac.ether_addr_octet[4];
+ regval = ((uint32_t)dev->d_mac.ether.ether_addr_octet[5] << 8) |
+ (uint32_t)dev->d_mac.ether.ether_addr_octet[4];
lpc43_putreg(regval, LPC43_ETH_MACA0HI);
/* Set the MAC address low register */
- regval = ((uint32_t)dev->d_mac.ether_addr_octet[3] << 24) |
- ((uint32_t)dev->d_mac.ether_addr_octet[2] << 16) |
- ((uint32_t)dev->d_mac.ether_addr_octet[1] << 8) |
- (uint32_t)dev->d_mac.ether_addr_octet[0];
+ regval = ((uint32_t)dev->d_mac.ether.ether_addr_octet[3] << 24) |
+ ((uint32_t)dev->d_mac.ether.ether_addr_octet[2] << 16) |
+ ((uint32_t)dev->d_mac.ether.ether_addr_octet[1] << 8) |
+ (uint32_t)dev->d_mac.ether.ether_addr_octet[0];
lpc43_putreg(regval, LPC43_ETH_MACA0LO);
}
diff --git a/arch/arm/src/lpc43xx/lpc43_spi.c b/arch/arm/src/lpc43xx/lpc43_spi.c
index e30b39bf25980e8df1c4dc679bf709a1c1afcc33..43e7e08052f29f5dc19ef35ef8b412deb794d7d1 100644
--- a/arch/arm/src/lpc43xx/lpc43_spi.c
+++ b/arch/arm/src/lpc43xx/lpc43_spi.c
@@ -103,7 +103,7 @@ struct lpc43_spidev_s
/* SPI methods */
static int spi_lock(FAR struct spi_dev_s *dev, bool lock);
-static void spi_select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
+static void spi_select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected);
static uint32_t spi_setfrequency(FAR struct spi_dev_s *dev, uint32_t frequency);
static void spi_setmode(FAR struct spi_dev_s *dev, enum spi_mode_e mode);
static void spi_setbits(FAR struct spi_dev_s *dev, int nbits);
diff --git a/arch/arm/src/lpc43xx/lpc43_spi.h b/arch/arm/src/lpc43xx/lpc43_spi.h
index 42ade41b1a843f3de9762fcf6ba0f3027dd79e64..d0414f9af64b142f2c44317c2ebbd7e650ba5909 100644
--- a/arch/arm/src/lpc43xx/lpc43_spi.h
+++ b/arch/arm/src/lpc43xx/lpc43_spi.h
@@ -122,11 +122,11 @@ FAR struct spi_dev_s *lpc43_spibus_initialize(int port);
*
************************************************************************************/
-void lpc43_spiselect(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
-uint8_t lpc43_spistatus(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+void lpc43_spiselect(FAR struct spi_dev_s *dev, uint32_t devid, bool selected);
+uint8_t lpc43_spistatus(FAR struct spi_dev_s *dev, uint32_t devid);
#ifdef CONFIG_SPI_CMDDATA
-int lpc43_spicmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+int lpc43_spicmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
#endif
/************************************************************************************
diff --git a/arch/arm/src/lpc43xx/lpc43_ssp.h b/arch/arm/src/lpc43xx/lpc43_ssp.h
index 1c98618cbf697c8c79fdf7580167e783bf93a2c9..5bf708859e6d54d4b416ee70ac50a73c500eaa21 100644
--- a/arch/arm/src/lpc43xx/lpc43_ssp.h
+++ b/arch/arm/src/lpc43xx/lpc43_ssp.h
@@ -121,18 +121,18 @@ FAR struct spi_dev_s *lpc43_sspbus_initialize(int port);
************************************************************************************/
#ifdef CONFIG_LPC43_SSP0
-void lpc43_ssp0select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
-uint8_t lpc43_ssp0status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+void lpc43_ssp0select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected);
+uint8_t lpc43_ssp0status(FAR struct spi_dev_s *dev, uint32_t devid);
#ifdef CONFIG_SPI_CMDDATA
-int lpc43_ssp0cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+int lpc43_ssp0cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
#endif
#endif
#ifdef CONFIG_LPC43_SSP1
-void lpc43_ssp1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
-uint8_t lpc43_ssp1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+void lpc43_ssp1select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected);
+uint8_t lpc43_ssp1status(FAR struct spi_dev_s *dev, uint32_t devid);
#ifdef CONFIG_SPI_CMDDATA
-int lpc43_ssp1cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+int lpc43_ssp1cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
#endif
#endif
diff --git a/arch/arm/src/sam34/Kconfig b/arch/arm/src/sam34/Kconfig
index e9d3a7aece43617403adaf4614e1609bd446a9b0..862b381418b3b56e1a88cb94f869ad2b4dc8d0a0 100644
--- a/arch/arm/src/sam34/Kconfig
+++ b/arch/arm/src/sam34/Kconfig
@@ -572,7 +572,6 @@ config SAM34_TWIS
bool
default n
-
config SAM34_TWIM0
bool "Two-wire Master Interface 0 (TWIM0)"
default n
@@ -1142,6 +1141,41 @@ config SAM34_SPI_REGDEBUG
endmenu # AT91SAM3/4 SPI device driver options
endif # SAM34_SPI0 || SAM34_SPI1
+if SAM34_TWIM
+
+menu "AT91SAM3/4 TWI master device driver options"
+
+config SAM34_TWIM0_FREQUENCY
+ int "TWI0 Frequency"
+ default 100000
+ depends on SAM34_TWIM0
+
+config SAM34_TWIM1_FREQUENCY
+ int "TWI1 Frequency"
+ default 100000
+ depends on SAM34_TWIM1
+
+config SAM34_TWIM2_FREQUENCY
+ int "TWI2 Frequency"
+ default 100000
+ depends on SAM34_TWIM2
+
+config SAM34_TWIM3_FREQUENCY
+ int "TWI3 Frequency"
+ default 100000
+ depends on SAM34_TWIM3
+
+config SAM34_TWI_REGDEBUG
+ bool "TWI register level debug"
+ depends on DEBUG_I2C_INFO
+ default n
+ ---help---
+ Output detailed register-level TWI device debug information.
+ Very invasive! Requires also CONFIG_DEBUG_I2C_INFO.
+
+endmenu # TWI device driver options
+endif # SAM34_TWIM
+
menu "AT91SAM3/4 EMAC device driver options"
depends on SAM34_EMAC
diff --git a/arch/arm/src/sam34/sam4cm_oneshot.c b/arch/arm/src/sam34/sam4cm_oneshot.c
index 0bf92d1fea01d48d008b56978390592b1bb50a19..04c9cf8200df34d1bb4acb12ff0e15f17699692b 100644
--- a/arch/arm/src/sam34/sam4cm_oneshot.c
+++ b/arch/arm/src/sam34/sam4cm_oneshot.c
@@ -405,7 +405,7 @@ int sam_oneshot_cancel(struct sam_oneshot_s *oneshot,
* the counter expires while we are doing this, the counter clock will be
* stopped, but the clock will not be disabled.
*
- * The expected behavior is that the the counter register will freezes at
+ * The expected behavior is that the counter register will freezes at
* a value equal to the RC register when the timer expires. The counter
* should have values between 0 and RC in all other cased.
*
diff --git a/arch/arm/src/sam34/sam4cm_tc.c b/arch/arm/src/sam34/sam4cm_tc.c
index c366118f4d02a56397a2a45c1a6ec27912de1cab..32e465cc77787e9d7567da0e81c035eba1f9887c 100644
--- a/arch/arm/src/sam34/sam4cm_tc.c
+++ b/arch/arm/src/sam34/sam4cm_tc.c
@@ -1166,7 +1166,7 @@ uint32_t sam_tc_divfreq(TC_HANDLE handle)
DEBUGASSERT(chan);
- /* Get the the TC_CMR register contents for this channel and extract the
+ /* Get the TC_CMR register contents for this channel and extract the
* TCCLKS index.
*/
diff --git a/arch/arm/src/sam34/sam4cm_tickless.c b/arch/arm/src/sam34/sam4cm_tickless.c
index 8f3ee17509e4289ad0e229c5080abcdeaa19c6f8..396a8fda8889eff498f4465d2b3da6a915ece31c 100644
--- a/arch/arm/src/sam34/sam4cm_tickless.c
+++ b/arch/arm/src/sam34/sam4cm_tickless.c
@@ -313,7 +313,7 @@ void arm_timer_initialize(void)
* any failure.
*
* Assumptions:
- * Called from the the normal tasking context. The implementation must
+ * Called from the normal tasking context. The implementation must
* provide whatever mutual exclusion is necessary for correct operation.
* This can include disabling interrupts in order to assure atomic register
* operations.
diff --git a/arch/arm/src/sam34/sam_emac.c b/arch/arm/src/sam34/sam_emac.c
index c5db8c01a441abe4babecd138ea7e3a1dbc42205..c45ea9f3838459f4552094cafb4d4255d7e80b0d 100644
--- a/arch/arm/src/sam34/sam_emac.c
+++ b/arch/arm/src/sam34/sam_emac.c
@@ -409,7 +409,7 @@ static int sam_rmmac(struct net_driver_s *dev, const uint8_t *mac);
#endif
#ifdef CONFIG_NETDEV_PHY_IOCTL
-static int sam_ioctl(struct net_driver_s *dev, int cmd, long arg);
+static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg);
#endif
/* PHY Initialization */
@@ -893,7 +893,7 @@ static int sam_txpoll(struct net_driver_s *dev)
sam_transmit(priv);
- /* Check if the there are any free TX descriptors. We cannot perform
+ /* Check if there are any free TX descriptors. We cannot perform
* the TX poll if we do not have buffering for another packet.
*/
@@ -941,7 +941,7 @@ static void sam_dopoll(struct sam_emac_s *priv)
{
struct net_driver_s *dev = &priv->dev;
- /* Check if the there are any free TX descriptors. We cannot perform the
+ /* Check if there are any free TX descriptors. We cannot perform the
* TX poll if we do not have buffering for another packet.
*/
@@ -1747,7 +1747,7 @@ static void sam_poll_work(FAR void *arg)
FAR struct sam_emac_s *priv = (FAR struct sam_emac_s *)arg;
struct net_driver_s *dev = &priv->dev;
- /* Check if the there are any free TX descriptors. We cannot perform the
+ /* Check if there are any free TX descriptors. We cannot perform the
* TX poll if we do not have buffering for another packet.
*/
@@ -2310,7 +2310,7 @@ static int sam_rmmac(struct net_driver_s *dev, const uint8_t *mac)
****************************************************************************/
#ifdef CONFIG_NETDEV_PHY_IOCTL
-static int sam_ioctl(struct net_driver_s *dev, int cmd, long arg)
+static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
{
struct sam_emac_s *priv = (struct sam_emac_s *)dev->d_private;
int ret;
@@ -3416,20 +3416,20 @@ static void sam_macaddress(struct sam_emac_s *priv)
ninfo("%s MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
dev->d_ifname,
- dev->d_mac.ether_addr_octet[0], dev->d_mac.ether_addr_octet[1],
- dev->d_mac.ether_addr_octet[2], dev->d_mac.ether_addr_octet[3],
- dev->d_mac.ether_addr_octet[4], dev->d_mac.ether_addr_octet[5]);
+ dev->d_mac.ether.ether_addr_octet[0], dev->d_mac.ether.ether_addr_octet[1],
+ dev->d_mac.ether.ether_addr_octet[2], dev->d_mac.ether.ether_addr_octet[3],
+ dev->d_mac.ether.ether_addr_octet[4], dev->d_mac.ether.ether_addr_octet[5]);
/* Set the MAC address */
- regval = (uint32_t)dev->d_mac.ether_addr_octet[0] |
- (uint32_t)dev->d_mac.ether_addr_octet[1] << 8 |
- (uint32_t)dev->d_mac.ether_addr_octet[2] << 16 |
- (uint32_t)dev->d_mac.ether_addr_octet[3] << 24;
+ regval = (uint32_t)dev->d_mac.ether.ether_addr_octet[0] |
+ (uint32_t)dev->d_mac.ether.ether_addr_octet[1] << 8 |
+ (uint32_t)dev->d_mac.ether.ether_addr_octet[2] << 16 |
+ (uint32_t)dev->d_mac.ether.ether_addr_octet[3] << 24;
sam_putreg(priv, SAM_EMAC_SAB1, regval);
- regval = (uint32_t)dev->d_mac.ether_addr_octet[4] |
- (uint32_t)dev->d_mac.ether_addr_octet[5] << 8;
+ regval = (uint32_t)dev->d_mac.ether.ether_addr_octet[4] |
+ (uint32_t)dev->d_mac.ether.ether_addr_octet[5] << 8;
sam_putreg(priv, SAM_EMAC_SAT1, regval);
}
diff --git a/arch/arm/src/sam34/sam_irq.c b/arch/arm/src/sam34/sam_irq.c
index eb6b174705990c95184462f0a59fc926ab79e8f7..24d08cff921f89d0cd5c9f57d7a9f5b330236db9 100644
--- a/arch/arm/src/sam34/sam_irq.c
+++ b/arch/arm/src/sam34/sam_irq.c
@@ -385,16 +385,6 @@ void up_irqinitialize(void)
putreg32(0, regaddr);
}
- /* Colorize the interrupt stack for debug purposes */
-
-#if defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 3
- {
- size_t intstack_size = (CONFIG_ARCH_INTERRUPTSTACK & ~3);
- up_stack_color((FAR void *)((uintptr_t)&g_intstackbase - intstack_size),
- intstack_size);
- }
-#endif
-
/* Make sure that we are using the correct vector table. The default
* vector address is 0x0000:0000 but if we are executing code that is
* positioned in SRAM or in external FLASH, then we may need to reset
diff --git a/arch/arm/src/sam34/sam_spi.c b/arch/arm/src/sam34/sam_spi.c
index 2cbe3614b65817511aef2860741fc7c54c301baa..899eb9bc2ea767b2ad32a75437a1594017687b3d 100644
--- a/arch/arm/src/sam34/sam_spi.c
+++ b/arch/arm/src/sam34/sam_spi.c
@@ -190,7 +190,7 @@ struct sam_spics_s
/* Type of board-specific SPI status function */
-typedef void (*select_t)(enum spi_dev_e devid, bool selected);
+typedef void (*select_t)(uint32_t devid, bool selected);
/* Chip select register offsetrs */
@@ -272,7 +272,7 @@ static inline uintptr_t spi_regaddr(struct sam_spics_s *spics,
/* SPI methods */
static int spi_lock(struct spi_dev_s *dev, bool lock);
-static void spi_select(struct spi_dev_s *dev, enum spi_dev_e devid,
+static void spi_select(struct spi_dev_s *dev, uint32_t devid,
bool selected);
static uint32_t spi_setfrequency(struct spi_dev_s *dev, uint32_t frequency);
static void spi_setmode(struct spi_dev_s *dev, enum spi_mode_e mode);
@@ -916,7 +916,7 @@ static int spi_lock(struct spi_dev_s *dev, bool lock)
*
****************************************************************************/
-static void spi_select(struct spi_dev_s *dev, enum spi_dev_e devid,
+static void spi_select(struct spi_dev_s *dev, uint32_t devid,
bool selected)
{
struct sam_spics_s *spics = (struct sam_spics_s *)dev;
diff --git a/arch/arm/src/sam34/sam_spi.h b/arch/arm/src/sam34/sam_spi.h
index 1d37d340d4e3edc78456394bc00754e176519df9..8cebb2f121b4864484d74c4864a3fec6baca8528 100644
--- a/arch/arm/src/sam34/sam_spi.h
+++ b/arch/arm/src/sam34/sam_spi.h
@@ -110,7 +110,6 @@ extern "C"
****************************************************************************/
struct spi_dev_s; /* Forward reference */
-enum spi_dev_e; /* Forward reference */
/****************************************************************************
* Name: sam_spibus_initialize
@@ -189,10 +188,10 @@ struct spi_dev_s *sam_spibus_initialize(int port);
****************************************************************************/
#ifdef CONFIG_SAM34_SPI0
-void sam_spi0select(enum spi_dev_e devid, bool selected);
+void sam_spi0select(uint32_t devid, bool selected);
#endif
#ifdef CONFIG_SAM34_SPI1
-void sam_spi1select(enum spi_dev_e devid, bool selected);
+void sam_spi1select(uint32_t devid, bool selected);
#endif
/****************************************************************************
@@ -211,10 +210,10 @@ void sam_spi1select(enum spi_dev_e devid, bool selected);
****************************************************************************/
#ifdef CONFIG_SAM34_SPI0
-uint8_t sam_spi0status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+uint8_t sam_spi0status(FAR struct spi_dev_s *dev, uint32_t devid);
#endif
#ifdef CONFIG_SAM34_SPI1
-uint8_t sam_spi1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+uint8_t sam_spi1status(FAR struct spi_dev_s *dev, uint32_t devid);
#endif
/****************************************************************************
@@ -243,10 +242,10 @@ uint8_t sam_spi1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
#ifdef CONFIG_SPI_CMDDATA
#ifdef CONFIG_SAM34_SPI0
-int sam_spi0cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+int sam_spi0cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
#endif
#ifdef CONFIG_SAM34_SPI1
-int sam_spi1cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+int sam_spi1cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
#endif
#endif
diff --git a/arch/arm/src/sam34/sam_twi.c b/arch/arm/src/sam34/sam_twi.c
index 7242f4744d63ef691b1e78a39f39c44fb264fc45..1b85275e8b6a2e84f28af9d599e3bd1e8ee0f384 100644
--- a/arch/arm/src/sam34/sam_twi.c
+++ b/arch/arm/src/sam34/sam_twi.c
@@ -71,19 +71,21 @@
#include "sam_gpio.h"
#include "sam_twi.h"
-#if defined(CONFIG_SAM34_TWI0) || defined(CONFIG_SAM34_TWI1)
+/* REVISIT: Missing support for TWI2 master */
+
+#if defined(CONFIG_SAM34_TWIM0) || defined(CONFIG_SAM34_TWIM1)
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Configuration ***************************************************************/
-#ifndef CONFIG_SAM34_TWI0_FREQUENCY
-# define CONFIG_SAM34_TWI0_FREQUENCY 100000
+#ifndef CONFIG_SAM34_TWIM0_FREQUENCY
+# define CONFIG_SAM34_TWIM0_FREQUENCY 100000
#endif
-#ifndef CONFIG_SAM34_TWI1_FREQUENCY
-# define CONFIG_SAM34_TWI1_FREQUENCY 100000
+#ifndef CONFIG_SAM34_TWIM1_FREQUENCY
+# define CONFIG_SAM34_TWIM1_FREQUENCY 100000
#endif
#ifndef CONFIG_DEBUG_I2C_INFO
@@ -187,11 +189,11 @@ static void twi_hw_initialize(struct twi_dev_s *priv, unsigned int pid,
* Private Data
****************************************************************************/
-#ifdef CONFIG_SAM34_TWI0
+#ifdef CONFIG_SAM34_TWIM0
static struct twi_dev_s g_twi0;
#endif
-#ifdef CONFIG_SAM34_TWI1
+#ifdef CONFIG_SAM34_TWIM1
static struct twi_dev_s g_twi1;
#endif
@@ -430,7 +432,7 @@ static void twi_wakeup(struct twi_dev_s *priv, int result)
*
****************************************************************************/
-static int twi_interrupt(int irq, FAR void *context, FAR void *arg);
+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;
@@ -901,7 +903,7 @@ struct i2c_master_s *sam_i2cbus_initialize(int bus)
flags = enter_critical_section();
-#ifdef CONFIG_SAM34_TWI0
+#ifdef CONFIG_SAM34_TWIM0
if (bus == 0)
{
/* Set up TWI0 register base address and IRQ number */
@@ -922,18 +924,18 @@ struct i2c_master_s *sam_i2cbus_initialize(int bus)
/* Select the TWI frequency, and peripheral ID */
- frequency = CONFIG_SAM34_TWI0_FREQUENCY;
+ frequency = CONFIG_SAM34_TWIM0_FREQUENCY;
pid = SAM_PID_TWI0;
}
else
#endif
-#ifdef CONFIG_SAM34_TWI1
+#ifdef CONFIG_SAM34_TWIM1
if (bus == 1)
{
/* Set up TWI1 register base address and IRQ number */
priv = &g_twi1;
- priv->base = SAM_TWI0_BASE;
+ priv->base = SAM_TWI1_BASE;
priv->irq = SAM_IRQ_TWI1;
priv->twi = 1;
@@ -948,7 +950,7 @@ struct i2c_master_s *sam_i2cbus_initialize(int bus)
/* Select the TWI frequency, and peripheral ID */
- frequency = CONFIG_SAMA5_TWI1_FREQUENCY;
+ frequency = CONFIG_SAM34_TWIM1_FREQUENCY;
pid = SAM_PID_TWI1;
}
else
@@ -1029,4 +1031,4 @@ int sam_i2cbus_uninitialize(FAR struct i2c_master_s * dev)
return OK;
}
-#endif /* CONFIG_SAM34_TWI0 || CONFIG_SAM34_TWI1 */
+#endif /* CONFIG_SAM34_TWIM0 || CONFIG_SAM34_TWIM1 */
diff --git a/arch/arm/src/sam34/sam_vectors.S b/arch/arm/src/sam34/sam_vectors.S
index 9765f614749cb8d8d96da48c4d101b31fc1c95af..4d783f4102136eea16cf09ac80dd3dd927ae591e 100644
--- a/arch/arm/src/sam34/sam_vectors.S
+++ b/arch/arm/src/sam34/sam_vectors.S
@@ -57,7 +57,7 @@
* interrupt occurs and uses this stale MSP, there will most likely be a system failure.
*
* If the interrupt stack is selected, on the other hand, then the interrupt handler will
- * always set the the MSP to the interrupt stack. So when the high priority interrupt occurs,
+ * always set the MSP to the interrupt stack. So when the high priority interrupt occurs,
* it will either use the MSP of the last privileged thread to run or, in the case of the
* nested interrupt, the interrupt stack if no privileged task has run.
*/
@@ -66,7 +66,7 @@
# error Interrupt stack must be used with high priority interrupts in kernel mode
# endif
- /* Use the the BASEPRI to control interrupts is required if nested, high
+ /* Use the BASEPRI to control interrupts is required if nested, high
* priority interrupts are supported.
*/
@@ -362,7 +362,7 @@ exception_common:
*
* Here:
* r0 = Address of the register save area
-
+ *
* NOTE: It is a requirement that up_restorefpu() preserve the value of
* r0!
*/
@@ -482,7 +482,7 @@ exception_common:
.global g_intstackbase
.align 8
g_intstackalloc:
- .skip (CONFIG_ARCH_INTERRUPTSTACK & ~7)
+ .skip ((CONFIG_ARCH_INTERRUPTSTACK + 4) & ~7)
g_intstackbase:
.size g_intstackalloc, .-g_intstackalloc
#endif
diff --git a/arch/arm/src/sama5/Kconfig b/arch/arm/src/sama5/Kconfig
index 280894d84e2e8f739887a92ca0815a398a0873e9..58b0c3860afb8de526d32ad27bc207c478a2264d 100644
--- a/arch/arm/src/sama5/Kconfig
+++ b/arch/arm/src/sama5/Kconfig
@@ -953,7 +953,7 @@ config SAMA5_LCDC_BACKCOLOR
config SAMA5_LCDC_FB_VBASE
hex "Framebuffer memory start address (virtual)"
---help---
- If you are using the the LCDC, then you must provide the virtual
+ If you are using the LCDC, then you must provide the virtual
address of the start of the framebuffer. This address must be
aligned to a 1MB bounder (i.e., the last five "digits" of the
hexadecimal address must be zero).
@@ -961,7 +961,7 @@ config SAMA5_LCDC_FB_VBASE
config SAMA5_LCDC_FB_PBASE
hex "Framebuffer memory start address (virtual)"
---help---
- If you are using the the LCDC, then you must provide the physical
+ If you are using the LCDC, then you must provide the physical
address of the start of the framebuffer. This address must be
aligned to a 1MB bounder (i.e., the last five "digits" of the
hexadecimal address must be zero).
@@ -4953,7 +4953,7 @@ config SAMA5_DDRCS_PGHEAP_OFFSET
If you are executing from DRAM, then you must have already reserved
this region with SAMA5_DDRCS_RESERVE, setting SAMA5_DDRCS_HEAP_END
so that this page cache region defined by SAMA5_DDRCS_PGHEAP_OFFSET
- and SAMA5_DDRCS_PGHEAP_SIZE does not overlap the the region of DRAM
+ and SAMA5_DDRCS_PGHEAP_SIZE does not overlap the region of DRAM
that is added to the heap. If you are not executing from DRAM, then
you must have excluding this page cache region from the heap ether
by (1) not selecting SAMA5_DDRCS_HEAP, or (2) selecting
@@ -4971,7 +4971,7 @@ config SAMA5_DDRCS_PGHEAP_SIZE
If you are executing from DRAM, then you must have already reserved
this region with SAMA5_DDRCS_RESERVE, setting SAMA5_DDRCS_HEAP_END
so that this page cache region defined by SAMA5_DDRCS_PGHEAP_OFFSET
- and SAMA5_DDRCS_PGHEAP_SIZE does not overlap the the region of DRAM
+ and SAMA5_DDRCS_PGHEAP_SIZE does not overlap the region of DRAM
that is added to the heap. If you are not executing from DRAM, then
you must have excluding this page cache region from the heap ether
by (1) not selecting SAMA5_DDRCS_HEAP, or (2) selecting
diff --git a/arch/arm/src/sama5/chip/sam_emaca.h b/arch/arm/src/sama5/chip/sam_emaca.h
index 536b0cc91447c7080dec04d6b5dc08da7a9954fb..2681b0567cbb21795b1968b53ca95d394f7e23e6 100644
--- a/arch/arm/src/sama5/chip/sam_emaca.h
+++ b/arch/arm/src/sama5/chip/sam_emaca.h
@@ -1,6 +1,6 @@
/************************************************************************************
* arch/arm/src/sama5/chip/sam_emaca.h
- * This is the form of the EMAC interface used the the SAMA5D3
+ * This is the form of the EMAC interface used the SAMA5D3
*
* Copyright (C) 2013-2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
diff --git a/arch/arm/src/sama5/chip/sam_emacb.h b/arch/arm/src/sama5/chip/sam_emacb.h
index 6b11086d3102644fb96a4fded8adb700083b79bf..7cbc75d6af82b17bd810a075c6095d74b6f475cd 100644
--- a/arch/arm/src/sama5/chip/sam_emacb.h
+++ b/arch/arm/src/sama5/chip/sam_emacb.h
@@ -1,6 +1,6 @@
/************************************************************************************
* arch/arm/src/sama5/chip/sam_emacb.h
- * This is the form of the EMAC interface used the the SAMA5D4 (and also the SAM43).
+ * This is the form of the EMAC interface used the SAMA5D4 (and also the SAM43).
* This is referred as GMAC in the documentation even though it does not support
* Gibabit Ethernet.
*
diff --git a/arch/arm/src/sama5/sam_adc.c b/arch/arm/src/sama5/sam_adc.c
index 2f9e4ee406efe1bbdbc1bdf5e9db0319dfa74c3d..66888995101017b647976c4d0aeccbc5e9df8e7b 100644
--- a/arch/arm/src/sama5/sam_adc.c
+++ b/arch/arm/src/sama5/sam_adc.c
@@ -736,7 +736,7 @@ static void sam_adc_dmacallback(DMA_HANDLE handle, void *arg, int result)
/* Check of the bottom half is keeping up with us.
*
* ready == false: Would mean that the worker thready has not ran since
- * the the last DMA callback.
+ * the last DMA callback.
* enabled == false: Means that the upper half has asked us nicely to stop
* transferring DMA data.
*/
@@ -1294,7 +1294,7 @@ static int sam_adc_settimer(struct sam_adc_s *priv, uint32_t frequency,
return ret;
}
- /* Set the timer/counter waveform mode the the clock input slected by
+ /* Set the timer/counter waveform mode the clock input slected by
* sam_tc_divisor()
*/
@@ -1448,7 +1448,7 @@ static int sam_adc_trigger(struct sam_adc_s *priv)
/* Configure to trigger using Timer/counter 0, channel 1, 2, or 3.
* NOTE: This trigger option depends on having properly configuer
* timer/counter 0 to provide this output. That is done independently
- * the the timer/counter driver.
+ * the timer/counter driver.
*/
/* Set TIOAn trigger where n=0, 1, or 2 */
diff --git a/arch/arm/src/sama5/sam_allocateheap.c b/arch/arm/src/sama5/sam_allocateheap.c
index 29dcf728f6f6ee0084b9911c3afe81211720e33e..be71204ff8bf88e212dd295a656b8082299fe0ad 100644
--- a/arch/arm/src/sama5/sam_allocateheap.c
+++ b/arch/arm/src/sama5/sam_allocateheap.c
@@ -147,7 +147,7 @@
# define SAMA5_PRIMARY_HEAP_END CONFIG_SAMA5_DDRCS_HEAP_END
#else
- /* Otherwise, add the RAM all the way to the the end of the primary memory
+ /* Otherwise, add the RAM all the way to the end of the primary memory
* region to the heap.
*/
diff --git a/arch/arm/src/sama5/sam_can.c b/arch/arm/src/sama5/sam_can.c
index 4020055e89a5f1c5609f27fd6215bdb2b0f1e40f..029a4df1c6bcb843657d52ef3ab6b5ac0e7f9120 100644
--- a/arch/arm/src/sama5/sam_can.c
+++ b/arch/arm/src/sama5/sam_can.c
@@ -60,7 +60,7 @@
#include
#include
-#include
+#include
#include "up_internal.h"
#include "up_arch.h"
diff --git a/arch/arm/src/sama5/sam_can.h b/arch/arm/src/sama5/sam_can.h
index 5a26fe83143cd6fa19b78377cf23b1c165253cf4..83a08f756bb59a93b5307cec0627a25dcb5c0928 100644
--- a/arch/arm/src/sama5/sam_can.h
+++ b/arch/arm/src/sama5/sam_can.h
@@ -45,7 +45,7 @@
#include "chip.h"
#include "chip/sam_can.h"
-#include
+#include
#if defined(CONFIG_CAN) && (defined(CONFIG_SAMA5_CAN0) || defined(CONFIG_SAMA5_CAN1))
diff --git a/arch/arm/src/sama5/sam_dbgu.c b/arch/arm/src/sama5/sam_dbgu.c
index 65242b88188d1df2962fcad90868565203ae3cf5..f1237d91445e9c17660ea1190c304cff65b2e144 100644
--- a/arch/arm/src/sama5/sam_dbgu.c
+++ b/arch/arm/src/sama5/sam_dbgu.c
@@ -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, NULL);
+ ret = irq_attach(SAM_IRQ_DBGU, dbgu_interrupt, dev);
if (ret == OK)
{
/* Enable the interrupt (RX and TX interrupts are still disabled
@@ -330,13 +330,16 @@ static void dbgu_detach(struct uart_dev_s *dev)
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;
+ struct uart_dev_s *dev = (struct uart_dev_s *)arg;
+ struct dbgu_dev_s *priv;
uint32_t pending;
uint32_t imr;
int passes;
bool handled;
+ DEBUGASSERT(dev != NULL && dev->priv != NULL);
+ priv = (struct dbgu_dev_s *)dev->priv;
+
/* Loop until there are no characters to be transferred or, until we have
* been looping for a long time.
*/
@@ -580,7 +583,7 @@ void sam_dbgu_devinitialize(void)
putreg32(DBGU_INT_ALLINTS, SAM_DBGU_IDR);
#ifdef CONFIG_SAMA5_DBGU_CONSOLE
- /* Configuration the DBGU as the the console */
+ /* Configuration the DBGU as the console */
g_dbgu_port.isconsole = true;
dbgu_configure();
diff --git a/arch/arm/src/sama5/sam_ehci.c b/arch/arm/src/sama5/sam_ehci.c
index d84f1c2dbc41f50e1c26c63c190f35c574a94bcf..407096486373f46de75e13f3f55bcd3a6787901a 100644
--- a/arch/arm/src/sama5/sam_ehci.c
+++ b/arch/arm/src/sama5/sam_ehci.c
@@ -2819,7 +2819,7 @@ static inline void sam_ioc_bottomhalf(void)
qh = (struct sam_qh_s *)sam_virtramaddr(sam_swap32(*bp) & QH_HLP_MASK);
/* If the asynchronous queue is empty, then the forward point in the
- * asynchronous queue head will point back to the the queue head.
+ * asynchronous queue head will point back to the queue head.
*/
if (qh && qh != &g_asynchead)
@@ -4183,7 +4183,7 @@ errout_with_sem:
* Description:
* Process a request to handle a transfer descriptor. This method will
* enqueue the transfer request and return immediately. When the transfer
- * completes, the the callback will be invoked with the provided transfer.
+ * completes, the callback will be invoked with the provided transfer.
* This method is useful for receiving interrupt transfers which may come
* infrequently.
*
@@ -4373,7 +4373,7 @@ static int sam_cancel(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep)
qh = (struct sam_qh_s *)sam_virtramaddr(sam_swap32(*bp) & QH_HLP_MASK);
/* If the asynchronous queue is empty, then the forward point in
- * the asynchronous queue head will point back to the the queue
+ * the asynchronous queue head will point back to the queue
* head.
*/
diff --git a/arch/arm/src/sama5/sam_emaca.c b/arch/arm/src/sama5/sam_emaca.c
index 92e18b160ae1126bf66cfa4ea77f928b42f86305..1648cab5258a357bd14018b7d74257bffd98afa9 100644
--- a/arch/arm/src/sama5/sam_emaca.c
+++ b/arch/arm/src/sama5/sam_emaca.c
@@ -414,7 +414,7 @@ static int sam_rmmac(struct net_driver_s *dev, const uint8_t *mac);
#endif
#ifdef CONFIG_NETDEV_PHY_IOCTL
-static int sam_ioctl(struct net_driver_s *dev, int cmd, long arg);
+static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg);
#endif
/* PHY Initialization */
@@ -902,7 +902,7 @@ static int sam_txpoll(struct net_driver_s *dev)
sam_transmit(priv);
- /* Check if the there are any free TX descriptors. We cannot perform
+ /* Check if there are any free TX descriptors. We cannot perform
* the TX poll if we do not have buffering for another packet.
*/
@@ -949,7 +949,7 @@ static void sam_dopoll(struct sam_emac_s *priv)
{
struct net_driver_s *dev = &priv->dev;
- /* Check if the there are any free TX descriptors. We cannot perform the
+ /* Check if there are any free TX descriptors. We cannot perform the
* TX poll if we do not have buffering for another packet.
*/
@@ -1783,7 +1783,7 @@ static void sam_poll_work(FAR void *arg)
FAR struct sam_emac_s *priv = (FAR struct sam_emac_s *)arg;
struct net_driver_s *dev = &priv->dev;
- /* Check if the there are any free TX descriptors. We cannot perform the
+ /* Check if there are any free TX descriptors. We cannot perform the
* TX poll if we do not have buffering for another packet.
*/
@@ -2346,7 +2346,7 @@ static int sam_rmmac(struct net_driver_s *dev, const uint8_t *mac)
****************************************************************************/
#ifdef CONFIG_NETDEV_PHY_IOCTL
-static int sam_ioctl(struct net_driver_s *dev, int cmd, long arg)
+static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
{
struct sam_emac_s *priv = (struct sam_emac_s *)dev->d_private;
int ret;
@@ -3458,20 +3458,20 @@ static void sam_macaddress(struct sam_emac_s *priv)
ninfo("%s MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
dev->d_ifname,
- dev->d_mac.ether_addr_octet[0], dev->d_mac.ether_addr_octet[1],
- dev->d_mac.ether_addr_octet[2], dev->d_mac.ether_addr_octet[3],
- dev->d_mac.ether_addr_octet[4], dev->d_mac.ether_addr_octet[5]);
+ dev->d_mac.ether.ether_addr_octet[0], dev->d_mac.ether.ether_addr_octet[1],
+ dev->d_mac.ether.ether_addr_octet[2], dev->d_mac.ether.ether_addr_octet[3],
+ dev->d_mac.ether.ether_addr_octet[4], dev->d_mac.ether.ether_addr_octet[5]);
/* Set the MAC address */
- regval = (uint32_t)dev->d_mac.ether_addr_octet[0] |
- (uint32_t)dev->d_mac.ether_addr_octet[1] << 8 |
- (uint32_t)dev->d_mac.ether_addr_octet[2] << 16 |
- (uint32_t)dev->d_mac.ether_addr_octet[3] << 24;
+ regval = (uint32_t)dev->d_mac.ether.ether_addr_octet[0] |
+ (uint32_t)dev->d_mac.ether.ether_addr_octet[1] << 8 |
+ (uint32_t)dev->d_mac.ether.ether_addr_octet[2] << 16 |
+ (uint32_t)dev->d_mac.ether.ether_addr_octet[3] << 24;
sam_putreg(priv, SAM_EMAC_SA1B, regval);
- regval = (uint32_t)dev->d_mac.ether_addr_octet[4] |
- (uint32_t)dev->d_mac.ether_addr_octet[5] << 8;
+ regval = (uint32_t)dev->d_mac.ether.ether_addr_octet[4] |
+ (uint32_t)dev->d_mac.ether.ether_addr_octet[5] << 8;
sam_putreg(priv, SAM_EMAC_SA1T, regval);
}
diff --git a/arch/arm/src/sama5/sam_emacb.c b/arch/arm/src/sama5/sam_emacb.c
index 3fd2f903fbbafc705b5f55db426e730875a946c1..c08725216c42b7e771d72ffb9cc9f6a491e22548 100644
--- a/arch/arm/src/sama5/sam_emacb.c
+++ b/arch/arm/src/sama5/sam_emacb.c
@@ -508,7 +508,7 @@ static int sam_rmmac(struct net_driver_s *dev, const uint8_t *mac);
#endif
#ifdef CONFIG_NETDEV_PHY_IOCTL
-static int sam_ioctl(struct net_driver_s *dev, int cmd, long arg);
+static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg);
#endif
/* PHY Initialization */
@@ -1237,7 +1237,7 @@ static int sam_txpoll(struct net_driver_s *dev)
sam_transmit(priv);
- /* Check if the there are any free TX descriptors. We cannot perform
+ /* Check if there are any free TX descriptors. We cannot perform
* the TX poll if we do not have buffering for another packet.
*/
@@ -1285,7 +1285,7 @@ static void sam_dopoll(struct sam_emac_s *priv)
{
struct net_driver_s *dev = &priv->dev;
- /* Check if the there are any free TX descriptors. We cannot perform the
+ /* Check if there are any free TX descriptors. We cannot perform the
* TX poll if we do not have buffering for another packet.
*/
@@ -2144,7 +2144,7 @@ static void sam_poll_work(FAR void *arg)
FAR struct sam_emac_s *priv = (FAR struct sam_emac_s *)arg;
struct net_driver_s *dev = &priv->dev;
- /* Check if the there are any free TX descriptors. We cannot perform the
+ /* Check if there are any free TX descriptors. We cannot perform the
* TX poll if we do not have buffering for another packet.
*/
@@ -2713,7 +2713,7 @@ static int sam_rmmac(struct net_driver_s *dev, const uint8_t *mac)
****************************************************************************/
#ifdef CONFIG_NETDEV_PHY_IOCTL
-static int sam_ioctl(struct net_driver_s *dev, int cmd, long arg)
+static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
{
struct sam_emac_s *priv = (struct sam_emac_s *)dev->d_private;
int ret;
@@ -4106,20 +4106,20 @@ static void sam_macaddress(struct sam_emac_s *priv)
ninfo("%s MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
dev->d_ifname,
- dev->d_mac.ether_addr_octet[0], dev->d_mac.ether_addr_octet[1],
- dev->d_mac.ether_addr_octet[2], dev->d_mac.ether_addr_octet[3],
- dev->d_mac.ether_addr_octet[4], dev->d_mac.ether_addr_octet[5]);
+ dev->d_mac.ether.ether_addr_octet[0], dev->d_mac.ether.ether_addr_octet[1],
+ dev->d_mac.ether.ether_addr_octet[2], dev->d_mac.ether.ether_addr_octet[3],
+ dev->d_mac.ether.ether_addr_octet[4], dev->d_mac.ether.ether_addr_octet[5]);
/* Set the MAC address */
- regval = (uint32_t)dev->d_mac.ether_addr_octet[0] |
- (uint32_t)dev->d_mac.ether_addr_octet[1] << 8 |
- (uint32_t)dev->d_mac.ether_addr_octet[2] << 16 |
- (uint32_t)dev->d_mac.ether_addr_octet[3] << 24;
+ regval = (uint32_t)dev->d_mac.ether.ether_addr_octet[0] |
+ (uint32_t)dev->d_mac.ether.ether_addr_octet[1] << 8 |
+ (uint32_t)dev->d_mac.ether.ether_addr_octet[2] << 16 |
+ (uint32_t)dev->d_mac.ether.ether_addr_octet[3] << 24;
sam_putreg(priv, SAM_EMAC_SAB1_OFFSET, regval);
- regval = (uint32_t)dev->d_mac.ether_addr_octet[4] |
- (uint32_t)dev->d_mac.ether_addr_octet[5] << 8;
+ regval = (uint32_t)dev->d_mac.ether.ether_addr_octet[4] |
+ (uint32_t)dev->d_mac.ether.ether_addr_octet[5] << 8;
sam_putreg(priv, SAM_EMAC_SAT1_OFFSET, regval);
}
diff --git a/arch/arm/src/sama5/sam_gmac.c b/arch/arm/src/sama5/sam_gmac.c
index a3d296b349515c9ae0a2c4dfa79095d67a59c045..d90996219062227d52f86da70a3a9a129b0227d8 100644
--- a/arch/arm/src/sama5/sam_gmac.c
+++ b/arch/arm/src/sama5/sam_gmac.c
@@ -339,7 +339,7 @@ static int sam_rmmac(struct net_driver_s *dev, const uint8_t *mac);
#endif
#ifdef CONFIG_NETDEV_PHY_IOCTL
-static int sam_ioctl(struct net_driver_s *dev, int cmd, long arg);
+static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg);
#endif
/* PHY Initialization */
@@ -834,7 +834,7 @@ static int sam_txpoll(struct net_driver_s *dev)
sam_transmit(priv);
- /* Check if the there are any free TX descriptors. We cannot perform
+ /* Check if there are any free TX descriptors. We cannot perform
* the TX poll if we do not have buffering for another packet.
*/
@@ -881,7 +881,7 @@ static void sam_dopoll(struct sam_gmac_s *priv)
{
struct net_driver_s *dev = &priv->dev;
- /* Check if the there are any free TX descriptors. We cannot perform the
+ /* Check if there are any free TX descriptors. We cannot perform the
* TX poll if we do not have buffering for another packet.
*/
@@ -1735,7 +1735,7 @@ static void sam_poll_work(FAR void *arg)
FAR struct sam_gmac_s *priv = (FAR struct sam_gmac_s *)arg;
struct net_driver_s *dev = &priv->dev;
- /* Check if the there are any free TX descriptors. We cannot perform the
+ /* Check if there are any free TX descriptors. We cannot perform the
* TX poll if we do not have buffering for another packet.
*/
@@ -2301,7 +2301,7 @@ static int sam_rmmac(struct net_driver_s *dev, const uint8_t *mac)
****************************************************************************/
#ifdef CONFIG_NETDEV_PHY_IOCTL
-static int sam_ioctl(struct net_driver_s *dev, int cmd, long arg)
+static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
{
struct sam_gmac_s *priv = (struct sam_gmac_s *)dev->d_private;
int ret;
@@ -3506,20 +3506,20 @@ static void sam_macaddress(struct sam_gmac_s *priv)
ninfo("%s MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
dev->d_ifname,
- dev->d_mac.ether_addr_octet[0], dev->d_mac.ether_addr_octet[1],
- dev->d_mac.ether_addr_octet[2], dev->d_mac.ether_addr_octet[3],
- dev->d_mac.ether_addr_octet[4], dev->d_mac.ether_addr_octet[5]);
+ dev->d_mac.ether.ether_addr_octet[0], dev->d_mac.ether.ether_addr_octet[1],
+ dev->d_mac.ether.ether_addr_octet[2], dev->d_mac.ether.ether_addr_octet[3],
+ dev->d_mac.ether.ether_addr_octet[4], dev->d_mac.ether.ether_addr_octet[5]);
/* Set the MAC address */
- regval = (uint32_t)dev->d_mac.ether_addr_octet[0] |
- (uint32_t)dev->d_mac.ether_addr_octet[1] << 8 |
- (uint32_t)dev->d_mac.ether_addr_octet[2] << 16 |
- (uint32_t)dev->d_mac.ether_addr_octet[3] << 24;
+ regval = (uint32_t)dev->d_mac.ether.ether_addr_octet[0] |
+ (uint32_t)dev->d_mac.ether.ether_addr_octet[1] << 8 |
+ (uint32_t)dev->d_mac.ether.ether_addr_octet[2] << 16 |
+ (uint32_t)dev->d_mac.ether.ether_addr_octet[3] << 24;
sam_putreg(priv, SAM_GMAC_SAB1, regval);
- regval = (uint32_t)dev->d_mac.ether_addr_octet[4] |
- (uint32_t)dev->d_mac.ether_addr_octet[5] << 8;
+ regval = (uint32_t)dev->d_mac.ether.ether_addr_octet[4] |
+ (uint32_t)dev->d_mac.ether.ether_addr_octet[5] << 8;
sam_putreg(priv, SAM_GMAC_SAT1, regval);
}
diff --git a/arch/arm/src/sama5/sam_hsmci.c b/arch/arm/src/sama5/sam_hsmci.c
index 3aa006d87227119ae15e9bbd91b948cb599272ad..7b4cee4749d8af6aa3be7188ae4081192bf41696 100644
--- a/arch/arm/src/sama5/sam_hsmci.c
+++ b/arch/arm/src/sama5/sam_hsmci.c
@@ -3102,7 +3102,7 @@ static void sam_callback(void *arg)
priv->cbevents = 0;
/* This function is called either from (1) the context of the calling
- * thread or from the the context of (2) card detection logic. The
+ * thread or from the context of (2) card detection logic. The
* caller may or may not have interrupts disabled (we have them
* disabled here!).
*
diff --git a/arch/arm/src/sama5/sam_irq.c b/arch/arm/src/sama5/sam_irq.c
index c8cf1f5cd5495f50c47b3c76605a7414c68b6f25..fd4dfd8c5cc246f7e28df209f7212b9c13b05ae7 100644
--- a/arch/arm/src/sama5/sam_irq.c
+++ b/arch/arm/src/sama5/sam_irq.c
@@ -431,16 +431,6 @@ void up_irqinitialize(void)
* access to the AIC.
*/
- /* Colorize the interrupt stack for debug purposes */
-
-#if defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 3
- {
- size_t intstack_size = (CONFIG_ARCH_INTERRUPTSTACK & ~3);
- up_stack_color((FAR void *)((uintptr_t)&g_intstackbase - intstack_size),
- intstack_size);
- }
-#endif
-
/* Redirect all interrupts to the AIC if so configured */
sam_aic_redirection();
diff --git a/arch/arm/src/sama5/sam_memorymap.h b/arch/arm/src/sama5/sam_memorymap.h
index 673f4f9ef36f97b207358ac8318134b160a11d6f..85612b001a8afd8a5295ef7f902e2bcf8b55c348 100644
--- a/arch/arm/src/sama5/sam_memorymap.h
+++ b/arch/arm/src/sama5/sam_memorymap.h
@@ -50,7 +50,7 @@
************************************************************************************/
/* The vectors are, by default, positioned at the beginning of the text
- * section. Under what conditions do we have to remap the these vectors?
+ * section. Under what conditions do we have to remap these vectors?
*
* 1) If we are using high vectors (CONFIG_ARCH_LOWVECTORS=n). In this case,
* the vectors will lie at virtual address 0xffff:000 and we will need
diff --git a/arch/arm/src/sama5/sam_nand.c b/arch/arm/src/sama5/sam_nand.c
index 05182120d93c847bf86a8654395e460cf0e5ba07..c7cf74f1859f11006478e46f64a55c5266974c85 100644
--- a/arch/arm/src/sama5/sam_nand.c
+++ b/arch/arm/src/sama5/sam_nand.c
@@ -1245,7 +1245,7 @@ static int nand_wait_dma(struct sam_nandcs_s *priv)
*
* Description:
* Called when one NAND DMA sequence completes. This function just wakes
- * the the waiting NAND driver logic.
+ * the waiting NAND driver logic.
*
****************************************************************************/
diff --git a/arch/arm/src/sama5/sam_ohci.c b/arch/arm/src/sama5/sam_ohci.c
index f6907d1b0f2274602b25f65898566be20edd3b92..e90c2fdde6a476c7f9bba1f70e2eeb166431f9c8 100644
--- a/arch/arm/src/sama5/sam_ohci.c
+++ b/arch/arm/src/sama5/sam_ohci.c
@@ -3531,7 +3531,7 @@ static void sam_asynch_completion(struct sam_eplist_s *eplist)
* Description:
* Process a request to handle a transfer descriptor. This method will
* enqueue the transfer request and return immediately. When the transfer
- * completes, the the callback will be invoked with the provided transfer.
+ * completes, the callback will be invoked with the provided transfer.
* This method is useful for receiving interrupt transfers which may come
* infrequently.
*
diff --git a/arch/arm/src/sama5/sam_oneshot.c b/arch/arm/src/sama5/sam_oneshot.c
index b883606982378068bcae46c1b6532106d5f88713..1bab862afaf225d260faa383002d0ca38c211267 100644
--- a/arch/arm/src/sama5/sam_oneshot.c
+++ b/arch/arm/src/sama5/sam_oneshot.c
@@ -417,7 +417,7 @@ int sam_oneshot_cancel(struct sam_oneshot_s *oneshot,
* the counter expires while we are doing this, the counter clock will be
* stopped, but the clock will not be disabled.
*
- * The expected behavior is that the the counter register will freezes at
+ * The expected behavior is that the counter register will freezes at
* a value equal to the RC register when the timer expires. The counter
* should have values between 0 and RC in all other cased.
*
diff --git a/arch/arm/src/sama5/sam_spi.c b/arch/arm/src/sama5/sam_spi.c
index 459e949cad79300e8c4ac1363b9e5c6283bdf3e1..cda2a36f9792d5338315d84dc8abfe939022949c 100644
--- a/arch/arm/src/sama5/sam_spi.c
+++ b/arch/arm/src/sama5/sam_spi.c
@@ -182,7 +182,7 @@ struct sam_spics_s
/* Type of board-specific SPI status fuction */
-typedef void (*select_t)(enum spi_dev_e devid, bool selected);
+typedef void (*select_t)(uint32_t devid, bool selected);
/* Chip select register offsetrs */
@@ -263,7 +263,7 @@ static inline uintptr_t spi_physregaddr(struct sam_spics_s *spics,
/* SPI methods */
static int spi_lock(struct spi_dev_s *dev, bool lock);
-static void spi_select(struct spi_dev_s *dev, enum spi_dev_e devid,
+static void spi_select(struct spi_dev_s *dev, uint32_t devid,
bool selected);
static uint32_t spi_setfrequency(struct spi_dev_s *dev, uint32_t frequency);
static void spi_setmode(struct spi_dev_s *dev, enum spi_mode_e mode);
@@ -905,7 +905,7 @@ static int spi_lock(struct spi_dev_s *dev, bool lock)
*
****************************************************************************/
-static void spi_select(struct spi_dev_s *dev, enum spi_dev_e devid,
+static void spi_select(struct spi_dev_s *dev, uint32_t devid,
bool selected)
{
struct sam_spics_s *spics = (struct sam_spics_s *)dev;
diff --git a/arch/arm/src/sama5/sam_spi.h b/arch/arm/src/sama5/sam_spi.h
index cf988639372d338af75e3ed7d7bec2bbac8d7828..705f2248e75fc9df41b9f3440e05e0603e57c126 100644
--- a/arch/arm/src/sama5/sam_spi.h
+++ b/arch/arm/src/sama5/sam_spi.h
@@ -104,7 +104,6 @@ extern "C"
****************************************************************************/
struct spi_dev_s; /* Forward reference */
-enum spi_dev_e; /* Forward reference */
/****************************************************************************
* Name: sam_spibus_initialize
@@ -182,10 +181,10 @@ struct spi_dev_s *sam_spibus_initialize(int port);
****************************************************************************/
#ifdef CONFIG_SAMA5_SPI0
-void sam_spi0select(enum spi_dev_e devid, bool selected);
+void sam_spi0select(uint32_t devid, bool selected);
#endif
#ifdef CONFIG_SAMA5_SPI1
-void sam_spi1select(enum spi_dev_e devid, bool selected);
+void sam_spi1select(uint32_t devid, bool selected);
#endif
/****************************************************************************
@@ -204,10 +203,10 @@ void sam_spi1select(enum spi_dev_e devid, bool selected);
****************************************************************************/
#ifdef CONFIG_SAMA5_SPI0
-uint8_t sam_spi0status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+uint8_t sam_spi0status(FAR struct spi_dev_s *dev, uint32_t devid);
#endif
#ifdef CONFIG_SAMA5_SPI1
-uint8_t sam_spi1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+uint8_t sam_spi1status(FAR struct spi_dev_s *dev, uint32_t devid);
#endif
/****************************************************************************
@@ -236,10 +235,10 @@ uint8_t sam_spi1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
#ifdef CONFIG_SPI_CMDDATA
#ifdef CONFIG_SAMA5_SPI0
-int sam_spi0cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+int sam_spi0cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
#endif
#ifdef CONFIG_SAMA5_SPI1
-int sam_spi1cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+int sam_spi1cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
#endif
#endif
diff --git a/arch/arm/src/sama5/sam_tc.c b/arch/arm/src/sama5/sam_tc.c
index 015d6bc96a5958a97d4a79b96de254631bf1fa5b..2bdff628cacd26d455c8e8d6ce93fe350ab3117c 100644
--- a/arch/arm/src/sama5/sam_tc.c
+++ b/arch/arm/src/sama5/sam_tc.c
@@ -1427,7 +1427,7 @@ uint32_t sam_tc_divfreq(TC_HANDLE handle)
DEBUGASSERT(chan);
- /* Get the the TC_CMR register contents for this channel and extract the
+ /* Get the TC_CMR register contents for this channel and extract the
* TCCLKS index.
*/
diff --git a/arch/arm/src/sama5/sam_tickless.c b/arch/arm/src/sama5/sam_tickless.c
index bb3c6785613bb8c038372f177862ce408a1737df..e77a96b304632e67e8fe42243097aebe6581185c 100644
--- a/arch/arm/src/sama5/sam_tickless.c
+++ b/arch/arm/src/sama5/sam_tickless.c
@@ -325,7 +325,7 @@ void arm_timer_initialize(void)
* any failure.
*
* Assumptions:
- * Called from the the normal tasking context. The implementation must
+ * Called from the normal tasking context. The implementation must
* provide whatever mutual exclusion is necessary for correct operation.
* This can include disabling interrupts in order to assure atomic register
* operations.
diff --git a/arch/arm/src/sama5/sam_udphs.c b/arch/arm/src/sama5/sam_udphs.c
index 3f27bd311224c04f2f47e31e2c84549779486c9f..090e10b4d84ce1fdad192fe88d05feccbf4656d2 100644
--- a/arch/arm/src/sama5/sam_udphs.c
+++ b/arch/arm/src/sama5/sam_udphs.c
@@ -1298,7 +1298,7 @@ static void sam_req_wrsetup(struct sam_usbdev_s *priv,
* When this function starts a transfer it will update the request
* 'inflight' field to indicate the size of the transfer.
*
- * When the transfer completes, the the 'inflight' field must hold the
+ * When the transfer completes, the 'inflight' field must hold the
* number of bytes that have completed the transfer. This function will
* update 'xfrd' with the new size of the transfer.
*
@@ -4554,7 +4554,7 @@ int usbdev_register(struct usbdevclass_driver_s *driver)
up_enable_irq(SAM_IRQ_UDPHS);
/* Enable pull-up to connect the device. The host should enumerate us
- * some time after this. The next thing we expect the the ENDRESET
+ * some time after this. The next thing we expect the ENDRESET
* interrupt.
*/
diff --git a/arch/arm/src/sama5/sama5d2x_pio.c b/arch/arm/src/sama5/sama5d2x_pio.c
index 3a87d3da666e42ca6ee64ef1f0ce96cf0420254b..4907529be442d0022dbf4d5eab1e6f42bf38bfcf 100644
--- a/arch/arm/src/sama5/sama5d2x_pio.c
+++ b/arch/arm/src/sama5/sama5d2x_pio.c
@@ -571,13 +571,13 @@ bool sam_pioread(pio_pinset_t pinset)
pin = sam_piopin(pinset);
/* For output PIOs, the ODSR register provides the output value to
- * drive the pin. The PDSR register, on the the other hand, provides
+ * drive the pin. The PDSR register, on the other hand, provides
* the current sensed value on a pin, whether the pin is configured
* as an input, an output or as a peripheral.
*
* There is small delay between the setting in ODSR and PDSR but
- * otherwise the they should be the same unless something external
- * is driving the pin.
+ * otherwise they should be the same unless something external is
+ * driving the pin.
*
* Let's assume that PDSR is what the caller wants.
*/
diff --git a/arch/arm/src/sama5/sama5d3x4x_pio.c b/arch/arm/src/sama5/sama5d3x4x_pio.c
index 806fb9fc089a43db8f153621f0b6da10bedfde0e..5f979f3c856f952905c1ec8ca18d929287d140eb 100644
--- a/arch/arm/src/sama5/sama5d3x4x_pio.c
+++ b/arch/arm/src/sama5/sama5d3x4x_pio.c
@@ -262,7 +262,7 @@ static void sam_pio_enableclk(pio_pinset_t cfgset)
* 1) No pins are configured as PIO inputs (peripheral inputs don't need
* clocking, and
* 2) Glitch and debounce filtering are not enabled. Currently, this can
- * only happen if the the pin is a PIO input, but we may need to
+ * only happen if the pin is a PIO input, but we may need to
* implement glitch filtering on peripheral inputs as well in the
* future???
* 3) The port is not configured for PIO interrupts. At present, the logic
@@ -816,13 +816,13 @@ bool sam_pioread(pio_pinset_t pinset)
pin = sam_piopin(pinset);
/* For output PIOs, the ODSR register provides the output value to
- * drive the pin. The PDSR register, on the the other hand, provides
+ * drive the pin. The PDSR register, on the other hand, provides
* the current sensed value on a pin, whether the pin is configured
* as an input, an output or as a peripheral.
*
* There is small delay between the setting in ODSR and PDSR but
- * otherwise the they should be the same unless something external
- * is driving the pin.
+ * otherwise they should be the same unless something external is
+ * driving the pin.
*
* Let's assume that PDSR is what the caller wants.
*/
diff --git a/arch/arm/src/samdl/sam_spi.h b/arch/arm/src/samdl/sam_spi.h
index 6185a5b3f0159b3ccefdbcb2d21a58ddc71b9c2c..7e0cbfa9e08d53a0167294d39bd9b3230b622b65 100644
--- a/arch/arm/src/samdl/sam_spi.h
+++ b/arch/arm/src/samdl/sam_spi.h
@@ -87,7 +87,6 @@ extern "C"
****************************************************************************/
struct spi_dev_s; /* Forward reference */
-enum spi_dev_e; /* Forward reference */
/****************************************************************************
* Name: sam_spibus_initialize
@@ -168,32 +167,32 @@ struct spi_dev_s *sam_spibus_initialize(int port);
****************************************************************************/
#ifdef SAMDL_HAVE_SPI0
-void sam_spi0select(FAR struct spi_dev_s *dev, enum spi_dev_e devid,
+void sam_spi0select(FAR struct spi_dev_s *dev, uint32_t devid,
bool selected);
#endif
#ifdef SAMDL_HAVE_SPI1
-void sam_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid,
+void sam_spi1select(FAR struct spi_dev_s *dev, uint32_t devid,
bool selected);
#endif
#ifdef SAMDL_HAVE_SPI2
-void sam_spi2select(FAR struct spi_dev_s *dev, enum spi_dev_e devid,
+void sam_spi2select(FAR struct spi_dev_s *dev, uint32_t devid,
bool selected);
#endif
#ifdef SAMDL_HAVE_SPI3
-void sam_spi3select(FAR struct spi_dev_s *dev, enum spi_dev_e devid,
+void sam_spi3select(FAR struct spi_dev_s *dev, uint32_t devid,
bool selected);
#endif
#ifdef SAMDL_HAVE_SPI4
-void sam_spi4select(FAR struct spi_dev_s *dev, enum spi_dev_e devid,
+void sam_spi4select(FAR struct spi_dev_s *dev, uint32_t devid,
bool selected);
#endif
#ifdef SAMDL_HAVE_SPI5
-void sam_spi5select(FAR struct spi_dev_s *dev, enum spi_dev_e devid,
+void sam_spi5select(FAR struct spi_dev_s *dev, uint32_t devid,
bool selected);
#endif
@@ -213,27 +212,27 @@ void sam_spi5select(FAR struct spi_dev_s *dev, enum spi_dev_e devid,
****************************************************************************/
#ifdef SAMDL_HAVE_SPI0
-uint8_t sam_spi0status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+uint8_t sam_spi0status(FAR struct spi_dev_s *dev, uint32_t devid);
#endif
#ifdef SAMDL_HAVE_SPI1
-uint8_t sam_spi1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+uint8_t sam_spi1status(FAR struct spi_dev_s *dev, uint32_t devid);
#endif
#ifdef SAMDL_HAVE_SPI2
-uint8_t sam_spi2status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+uint8_t sam_spi2status(FAR struct spi_dev_s *dev, uint32_t devid);
#endif
#ifdef SAMDL_HAVE_SPI3
-uint8_t sam_spi3status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+uint8_t sam_spi3status(FAR struct spi_dev_s *dev, uint32_t devid);
#endif
#ifdef SAMDL_HAVE_SPI4
-uint8_t sam_spi4status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+uint8_t sam_spi4status(FAR struct spi_dev_s *dev, uint32_t devid);
#endif
#ifdef SAMDL_HAVE_SPI5
-uint8_t sam_spi5status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+uint8_t sam_spi5status(FAR struct spi_dev_s *dev, uint32_t devid);
#endif
/****************************************************************************
@@ -262,27 +261,27 @@ uint8_t sam_spi5status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
#ifdef CONFIG_SPI_CMDDATA
#ifdef SAMDL_HAVE_SPI0
-int sam_spi0cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+int sam_spi0cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
#endif
#ifdef SAMDL_HAVE_SPI1
-int sam_spi1cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+int sam_spi1cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
#endif
#ifdef SAMDL_HAVE_SPI2
-int sam_spi2cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+int sam_spi2cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
#endif
#ifdef SAMDL_HAVE_SPI3
-int sam_spi3cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+int sam_spi3cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
#endif
#ifdef SAMDL_HAVE_SPI4
-int sam_spi4cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+int sam_spi4cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
#endif
#ifdef SAMDL_HAVE_SPI5
-int sam_spi5cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+int sam_spi5cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
#endif
#endif
diff --git a/arch/arm/src/samdl/sam_timerisr.c b/arch/arm/src/samdl/sam_timerisr.c
index abc61f355f00562dbc8cf8f764bc5e1946c06619..73dd99af15b78dc5b76eea5df7e78b9e5333f092 100644
--- a/arch/arm/src/samdl/sam_timerisr.c
+++ b/arch/arm/src/samdl/sam_timerisr.c
@@ -61,7 +61,7 @@
* system clock ticks per second. That value is a user configurable setting
* that defaults to 100 (100 ticks per second = 10 MS interval).
*
- * Then, for example, if the CPU clock is the the SysTick and
+ * Then, for example, if the CPU clock is the SysTick and
* BOARD_CPU_FREQUENCY is 48MHz and CLK_TCK is 100, then the reload value
* would be:
*
diff --git a/arch/arm/src/samdl/saml_clockconfig.c b/arch/arm/src/samdl/saml_clockconfig.c
index 11dbaff10f665a9ca76986b6b475de5642f223f3..364933501d5a5269d1349111dabdc56352a1e9c2 100644
--- a/arch/arm/src/samdl/saml_clockconfig.c
+++ b/arch/arm/src/samdl/saml_clockconfig.c
@@ -1131,7 +1131,7 @@ static inline void sam_fdpll96m_config(void)
static inline void sam_fdpll96m_refclk(void)
{
#ifdef BOARD_FDPLL96M_LOCKTIME_ENABLE
- /* Enable the GCLK that is configured to the the FDPLL lock timer */
+ /* Enable the GCLK that is configured to the FDPLL lock timer */
sam_gclk_chan_enable(GCLK_CHAN_DPLL_32K, BOARD_FDPLL96M_LOCKTIME_CLKGEN);
#endif
diff --git a/arch/arm/src/samv7/chip/sam_emac.h b/arch/arm/src/samv7/chip/sam_emac.h
index e0a0cbb9a724b21ba4df7ea2182997bc1c6502b4..c613c14f1c0cc86cdc6526b078dac12875681c93 100644
--- a/arch/arm/src/samv7/chip/sam_emac.h
+++ b/arch/arm/src/samv7/chip/sam_emac.h
@@ -1,6 +1,6 @@
/************************************************************************************
* arch/arm/src/samv7/chip/sam_emac.h
- * This is the form of the EMAC interface used the the SAMV7.
+ * This is the form of the EMAC interface used the SAMV7.
* This is referred as GMAC in the documentation even though it does not support
* Gibabit Ethernet.
*
diff --git a/arch/arm/src/samv7/sam_dac.c b/arch/arm/src/samv7/sam_dac.c
index 78a19929b5412af48185d1039f4944b4b0878f85..b1293aa5b2e9d76bb175f1622d3335d346939dbc 100644
--- a/arch/arm/src/samv7/sam_dac.c
+++ b/arch/arm/src/samv7/sam_dac.c
@@ -381,7 +381,7 @@ static int dac_timer_init(struct sam_dac_s *priv, uint32_t freq_required,
DEBUGASSERT(priv && (freq_required > 0) && (channel >= 0 && channel <= 2));
- /* Set the timer/counter waveform mode the the clock input. Use smallest
+ /* Set the timer/counter waveform mode the clock input. Use smallest
* MCK divisor of 8 to have highest clock resolution thus smallest frequency
* error. With 32 bit counter the lowest possible frequency of 1 Hz is easily
* supported.
diff --git a/arch/arm/src/samv7/sam_emac.c b/arch/arm/src/samv7/sam_emac.c
index 8905ee55546de9cb213cc68d9d6545028e9dd235..3496331898c0bc293b6209cbba1edee8c5d05684 100644
--- a/arch/arm/src/samv7/sam_emac.c
+++ b/arch/arm/src/samv7/sam_emac.c
@@ -86,6 +86,7 @@
#include "cache.h"
#include "chip/sam_pinmap.h"
+#include "chip/sam_chipid.h"
#include "sam_gpio.h"
#include "sam_periphclks.h"
#include "sam_ethernet.h"
@@ -331,7 +332,19 @@
#define EMAC_QUEUE_0 0
#define EMAC_QUEUE_1 1
#define EMAC_QUEUE_2 2
-#define EMAC_NQUEUES 3
+
+#if defined(CONFIG_ARCH_CHIP_SAMV71)
+ /* After chip version 1, the SAMV71 increased from 3 to 6 queue */
+
+# define EMAC_QUEUE_3 3
+# define EMAC_QUEUE_4 4
+# define EMAC_QUEUE_5 5
+# define EMAC_NQUEUES (g_emac_nqueues)
+# define EMAC_MAX_NQUEUES 6
+#else
+# define EMAC_NQUEUES 3
+# define EMAC_MAX_NQUEUES 3
+#endif
/* Interrupt settings */
@@ -537,7 +550,7 @@ struct sam_emac_s
/* Transfer queues */
- struct sam_queue_s xfrq[EMAC_NQUEUES];
+ struct sam_queue_s xfrq[EMAC_MAX_NQUEUES];
/* Debug stuff */
@@ -610,7 +623,7 @@ static int sam_rmmac(struct net_driver_s *dev, const uint8_t *mac);
#endif
#ifdef CONFIG_NETDEV_PHY_IOCTL
-static int sam_ioctl(struct net_driver_s *dev, int cmd, long arg);
+static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg);
#endif
/* PHY Initialization */
@@ -924,6 +937,16 @@ static uint8_t g_pktbuf1[MAX_NET_DEV_MTU + CONFIG_NET_GUARDSIZE];
/* EMAC1 peripheral state */
static struct sam_emac_s g_emac1;
+
+#endif /* CONFIG_SAMV7_EMAC1 */
+
+/* The SAMV71 may support from 3 to 6 queue, depending upon the chip
+ * revision. NOTE that this is a global setting and applies to both
+ * EMAC peripherals.
+ */
+
+#if defined(CONFIG_ARCH_CHIP_SAMV71)
+static uint8_t g_emac_nqueues = 3;
#endif
/****************************************************************************
@@ -1528,7 +1551,7 @@ static int sam_txpoll(struct net_driver_s *dev)
sam_transmit(priv, EMAC_QUEUE_0);
- /* Check if the there are any free TX descriptors. We cannot perform
+ /* Check if there are any free TX descriptors. We cannot perform
* the TX poll if we do not have buffering for another packet.
*/
@@ -1578,7 +1601,7 @@ static void sam_dopoll(struct sam_emac_s *priv, int qid)
{
struct net_driver_s *dev = &priv->dev;
- /* Check if the there are any free TX descriptors. We cannot perform the
+ /* Check if there are any free TX descriptors. We cannot perform the
* TX poll if we do not have buffering for another packet.
*/
@@ -2592,7 +2615,7 @@ static void sam_poll_work(FAR void *arg)
FAR struct sam_emac_s *priv = (FAR struct sam_emac_s *)arg;
struct net_driver_s *dev = &priv->dev;
- /* Check if the there are any free TX descriptors. We cannot perform the
+ /* Check if there are any free TX descriptors. We cannot perform the
* TX poll if we do not have buffering for another packet.
*/
@@ -2677,6 +2700,16 @@ static int sam_ifup(struct net_driver_s *dev)
sam_emac_configure(priv);
sam_queue_configure(priv, EMAC_QUEUE_1);
sam_queue_configure(priv, EMAC_QUEUE_2);
+
+#if defined(CONFIG_ARCH_CHIP_SAMV71)
+ if (g_emac_nqueues > 3)
+ {
+ sam_queue_configure(priv, EMAC_QUEUE_3);
+ sam_queue_configure(priv, EMAC_QUEUE_4);
+ sam_queue_configure(priv, EMAC_QUEUE_5);
+ }
+#endif
+
sam_queue0_configure(priv);
/* Set the MAC address (should have been configured while we were down) */
@@ -3164,7 +3197,7 @@ static int sam_rmmac(struct net_driver_s *dev, const uint8_t *mac)
****************************************************************************/
#ifdef CONFIG_NETDEV_PHY_IOCTL
-static int sam_ioctl(struct net_driver_s *dev, int cmd, long arg)
+static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
{
struct sam_emac_s *priv = (struct sam_emac_s *)dev->d_private;
int ret;
@@ -4540,10 +4573,28 @@ static void sam_emac_reset(struct sam_emac_s *priv)
sam_rxreset(priv, EMAC_QUEUE_1);
sam_rxreset(priv, EMAC_QUEUE_2);
+#if defined(CONFIG_ARCH_CHIP_SAMV71)
+ if (g_emac_nqueues > 3)
+ {
+ sam_rxreset(priv, EMAC_QUEUE_3);
+ sam_rxreset(priv, EMAC_QUEUE_4);
+ sam_rxreset(priv, EMAC_QUEUE_5);
+ }
+#endif
+
sam_txreset(priv, EMAC_QUEUE_0);
sam_txreset(priv, EMAC_QUEUE_1);
sam_txreset(priv, EMAC_QUEUE_2);
+#if defined(CONFIG_ARCH_CHIP_SAMV71)
+ if (g_emac_nqueues > 3)
+ {
+ sam_txreset(priv, EMAC_QUEUE_3);
+ sam_txreset(priv, EMAC_QUEUE_4);
+ sam_txreset(priv, EMAC_QUEUE_5);
+ }
+#endif
+
/* Disable Rx and Tx, plus the statistics registers. */
regval = sam_getreg(priv, SAM_EMAC_NCR_OFFSET);
@@ -4561,10 +4612,28 @@ static void sam_emac_reset(struct sam_emac_s *priv)
sam_rxreset(priv, EMAC_QUEUE_1);
sam_rxreset(priv, EMAC_QUEUE_2);
+#if defined(CONFIG_ARCH_CHIP_SAMV71)
+ if (g_emac_nqueues > 3)
+ {
+ sam_rxreset(priv, EMAC_QUEUE_3);
+ sam_rxreset(priv, EMAC_QUEUE_4);
+ sam_rxreset(priv, EMAC_QUEUE_5);
+ }
+#endif
+
sam_txreset(priv, EMAC_QUEUE_0);
sam_txreset(priv, EMAC_QUEUE_1);
sam_txreset(priv, EMAC_QUEUE_2);
+#if defined(CONFIG_ARCH_CHIP_SAMV71)
+ if (g_emac_nqueues > 3)
+ {
+ sam_txreset(priv, EMAC_QUEUE_3);
+ sam_txreset(priv, EMAC_QUEUE_4);
+ sam_txreset(priv, EMAC_QUEUE_5);
+ }
+#endif
+
/* Make sure that RX and TX are disabled; clear statistics registers */
sam_putreg(priv, SAM_EMAC_NCR_OFFSET, EMAC_NCR_CLRSTAT);
@@ -4599,20 +4668,20 @@ static void sam_macaddress(struct sam_emac_s *priv)
ninfo("%s MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
dev->d_ifname,
- dev->d_mac.ether_addr_octet[0], dev->d_mac.ether_addr_octet[1],
- dev->d_mac.ether_addr_octet[2], dev->d_mac.ether_addr_octet[3],
- dev->d_mac.ether_addr_octet[4], dev->d_mac.ether_addr_octet[5]);
+ dev->d_mac.ether.ether_addr_octet[0], dev->d_mac.ether.ether_addr_octet[1],
+ dev->d_mac.ether.ether_addr_octet[2], dev->d_mac.ether.ether_addr_octet[3],
+ dev->d_mac.ether.ether_addr_octet[4], dev->d_mac.ether.ether_addr_octet[5]);
/* Set the MAC address */
- regval = (uint32_t)dev->d_mac.ether_addr_octet[0] |
- (uint32_t)dev->d_mac.ether_addr_octet[1] << 8 |
- (uint32_t)dev->d_mac.ether_addr_octet[2] << 16 |
- (uint32_t)dev->d_mac.ether_addr_octet[3] << 24;
+ regval = (uint32_t)dev->d_mac.ether.ether_addr_octet[0] |
+ (uint32_t)dev->d_mac.ether.ether_addr_octet[1] << 8 |
+ (uint32_t)dev->d_mac.ether.ether_addr_octet[2] << 16 |
+ (uint32_t)dev->d_mac.ether.ether_addr_octet[3] << 24;
sam_putreg(priv, SAM_EMAC_SAB1_OFFSET, regval);
- regval = (uint32_t)dev->d_mac.ether_addr_octet[4] |
- (uint32_t)dev->d_mac.ether_addr_octet[5] << 8;
+ regval = (uint32_t)dev->d_mac.ether.ether_addr_octet[4] |
+ (uint32_t)dev->d_mac.ether.ether_addr_octet[5] << 8;
sam_putreg(priv, SAM_EMAC_SAT1_OFFSET, regval);
}
@@ -4875,12 +4944,36 @@ int sam_emac_initialize(int intf)
{
struct sam_emac_s *priv;
const struct sam_emacattr_s *attr;
+#if defined(CONFIG_ARCH_CHIP_SAMV71)
+ uint32_t regval;
+#endif
uint8_t *pktbuf;
#if defined(CONFIG_NETDEV_PHY_IOCTL) && defined(CONFIG_ARCH_PHY_INTERRUPT)
uint8_t phytype;
#endif
int ret;
+#if defined(CONFIG_ARCH_CHIP_SAMV71)
+ /* Determine if the chip has 3 or 6 queues. This logic is for the
+ * V71 only -- if you are using a different chip in the family,
+ * the version number at which to switch from 3 to 6 queues may
+ * be different. For the V71, versions 1 and higher have 6 queues.
+ *
+ * If both emacs are enabled, this code will be run twice, which
+ * should not be a problem as the result will be the same each time
+ * it is run.
+ */
+
+ regval = getreg32(SAM_CHIPID_CIDR);
+ if ((regval & CHIPID_CIDR_ARCH_MASK) == CHIPID_CIDR_ARCH_SAMV71)
+ {
+ if (((regval & CHIPID_CIDR_VERSION_MASK) >> CHIPID_CIDR_VERSION_SHIFT) > 0)
+ {
+ g_emac_nqueues = 6;
+ }
+ }
+#endif
+
#if defined(CONFIG_SAMV7_EMAC0)
if (intf == EMAC0_INTF)
{
@@ -5067,13 +5160,13 @@ int sam_emac_setmacaddr(int intf, uint8_t mac[6])
/* Copy the MAC address into the device structure */
dev = &priv->dev;
- memcpy(dev->d_mac.ether_addr_octet, mac, 6);
+ memcpy(dev->d_mac.ether.ether_addr_octet, mac, 6);
ninfo("%s MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
dev->d_ifname,
- dev->d_mac.ether_addr_octet[0], dev->d_mac.ether_addr_octet[1],
- dev->d_mac.ether_addr_octet[2], dev->d_mac.ether_addr_octet[3],
- dev->d_mac.ether_addr_octet[4], dev->d_mac.ether_addr_octet[5]);
+ dev->d_mac.ether.ether_addr_octet[0], dev->d_mac.ether.ether_addr_octet[1],
+ dev->d_mac.ether.ether_addr_octet[2], dev->d_mac.ether.ether_addr_octet[3],
+ dev->d_mac.ether.ether_addr_octet[4], dev->d_mac.ether.ether_addr_octet[5]);
return OK;
}
diff --git a/arch/arm/src/samv7/sam_hsmci.c b/arch/arm/src/samv7/sam_hsmci.c
index a83a51ecc0b3b11e841af7ba8b1e03a73d284973..544cae952434478ffb9db4e288a1d37e3dd3d892 100644
--- a/arch/arm/src/samv7/sam_hsmci.c
+++ b/arch/arm/src/samv7/sam_hsmci.c
@@ -3176,7 +3176,7 @@ static void sam_callback(void *arg)
priv->cbevents = 0;
/* This function is called either from (1) the context of the calling
- * thread or from the the context of (2) card detection logic. The
+ * thread or from the context of (2) card detection logic. The
* caller may or may not have interrupts disabled (we have them
* disabled here!).
*
diff --git a/arch/arm/src/samv7/sam_irq.c b/arch/arm/src/samv7/sam_irq.c
index f2e448932984dee2183fda3db49de3a7df6a3299..15910d24d6fd47881f9f08ef806f69842c54ecf8 100644
--- a/arch/arm/src/samv7/sam_irq.c
+++ b/arch/arm/src/samv7/sam_irq.c
@@ -381,16 +381,6 @@ void up_irqinitialize(void)
putreg32(0, regaddr);
}
- /* Colorize the interrupt stack for debug purposes */
-
-#if defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 3
- {
- size_t intstack_size = (CONFIG_ARCH_INTERRUPTSTACK & ~3);
- up_stack_color((FAR void *)((uintptr_t)&g_intstackbase - intstack_size),
- intstack_size);
- }
-#endif
-
/* Make sure that we are using the correct vector table. The default
* vector address is 0x0000:0000 but if we are executing code that is
* positioned in SRAM or in external FLASH, then we may need to reset
diff --git a/arch/arm/src/samv7/sam_mcan.c b/arch/arm/src/samv7/sam_mcan.c
index 7d16f0898df0572d7d414164d99d796848424396..d4807941a4c27422967a6f0c76b22691c3054ce1 100644
--- a/arch/arm/src/samv7/sam_mcan.c
+++ b/arch/arm/src/samv7/sam_mcan.c
@@ -56,7 +56,7 @@
#include
#include
#include
-#include
+#include
#include "cache.h"
#include "up_internal.h"
diff --git a/arch/arm/src/samv7/sam_mcan.h b/arch/arm/src/samv7/sam_mcan.h
index 07ecdd71ad37be48b9c1841aa8cbb394108edec2..3672547788ac9fdfc7b7a757f38eb46f253d30eb 100644
--- a/arch/arm/src/samv7/sam_mcan.h
+++ b/arch/arm/src/samv7/sam_mcan.h
@@ -45,7 +45,7 @@
#include "chip.h"
#include "chip/sam_mcan.h"
-#include
+#include
#if defined(CONFIG_CAN) && (defined(CONFIG_SAMV7_MCAN0) || \
defined(CONFIG_SAMV7_MCAN1))
diff --git a/arch/arm/src/samv7/sam_oneshot.c b/arch/arm/src/samv7/sam_oneshot.c
index 9a20ec17a76a4594a84b312d1bcf8f79b4d577fc..0162a4d0e664fb78a7281b5aa3137dd180385326 100644
--- a/arch/arm/src/samv7/sam_oneshot.c
+++ b/arch/arm/src/samv7/sam_oneshot.c
@@ -419,7 +419,7 @@ int sam_oneshot_cancel(struct sam_oneshot_s *oneshot,
* the counter expires while we are doing this, the counter clock will be
* stopped, but the clock will not be disabled.
*
- * The expected behavior is that the the counter register will freezes at
+ * The expected behavior is that the counter register will freezes at
* a value equal to the RC register when the timer expires. The counter
* should have values between 0 and RC in all other cased.
*
diff --git a/arch/arm/src/samv7/sam_spi.c b/arch/arm/src/samv7/sam_spi.c
index de1dec1615062afc2d96e2445739dfb397577a9d..a1df8921888b78120a856fe20fcb68c7caec0e02 100644
--- a/arch/arm/src/samv7/sam_spi.c
+++ b/arch/arm/src/samv7/sam_spi.c
@@ -181,7 +181,7 @@ struct sam_spics_s
/* Type of board-specific SPI status function */
-typedef void (*select_t)(enum spi_dev_e devid, bool selected);
+typedef void (*select_t)(uint32_t devid, bool selected);
/* Chip select register offsets */
@@ -263,7 +263,7 @@ static inline uintptr_t spi_regaddr(struct sam_spics_s *spics,
/* SPI master methods */
static int spi_lock(struct spi_dev_s *dev, bool lock);
-static void spi_select(struct spi_dev_s *dev, enum spi_dev_e devid,
+static void spi_select(struct spi_dev_s *dev, uint32_t devid,
bool selected);
static uint32_t spi_setfrequency(struct spi_dev_s *dev, uint32_t frequency);
#ifdef CONFIG_SPI_CS_DELAY_CONTROL
@@ -943,7 +943,7 @@ static int spi_lock(struct spi_dev_s *dev, bool lock)
*
****************************************************************************/
-static void spi_select(struct spi_dev_s *dev, enum spi_dev_e devid,
+static void spi_select(struct spi_dev_s *dev, uint32_t devid,
bool selected)
{
struct sam_spics_s *spics = (struct sam_spics_s *)dev;
diff --git a/arch/arm/src/samv7/sam_spi.h b/arch/arm/src/samv7/sam_spi.h
index dded6425348497f87b016f548c9f7b7b8778317f..762f34f67d4ce382bf58ffbed301a5728401996d 100644
--- a/arch/arm/src/samv7/sam_spi.h
+++ b/arch/arm/src/samv7/sam_spi.h
@@ -158,7 +158,6 @@ extern "C"
****************************************************************************/
struct spi_dev_s; /* Forward reference */
-enum spi_dev_e; /* Forward reference */
struct spi_sctrlr_s; /* Forward reference */
/****************************************************************************
@@ -255,10 +254,10 @@ FAR struct spi_sctrlr_s *sam_spi_slave_initialize(int port);
****************************************************************************/
#ifdef CONFIG_SAMV7_SPI0_MASTER
-void sam_spi0select(enum spi_dev_e devid, bool selected);
+void sam_spi0select(uint32_t devid, bool selected);
#endif
#ifdef CONFIG_SAMV7_SPI1_MASTER
-void sam_spi1select(enum spi_dev_e devid, bool selected);
+void sam_spi1select(uint32_t devid, bool selected);
#endif
/****************************************************************************
@@ -277,10 +276,10 @@ void sam_spi1select(enum spi_dev_e devid, bool selected);
****************************************************************************/
#ifdef CONFIG_SAMV7_SPI0
-uint8_t sam_spi0status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+uint8_t sam_spi0status(FAR struct spi_dev_s *dev, uint32_t devid);
#endif
#ifdef CONFIG_SAMV7_SPI1
-uint8_t sam_spi1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+uint8_t sam_spi1status(FAR struct spi_dev_s *dev, uint32_t devid);
#endif
/****************************************************************************
@@ -309,10 +308,10 @@ uint8_t sam_spi1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
#ifdef CONFIG_SPI_CMDDATA
#ifdef CONFIG_SAMV7_SPI0_MASTER
-int sam_spi0cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+int sam_spi0cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
#endif
#ifdef CONFIG_SAMV7_SPI1_MASTER
-int sam_spi1cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+int sam_spi1cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
#endif
#endif /* CONFIG_SPI_CMDDATA */
diff --git a/arch/arm/src/samv7/sam_tc.c b/arch/arm/src/samv7/sam_tc.c
index 4b9303fd5348c23ef2bf0aeda1a40c858d3de51e..91b0e36f5f09f711c0aa83ca19663d91adaf843f 100644
--- a/arch/arm/src/samv7/sam_tc.c
+++ b/arch/arm/src/samv7/sam_tc.c
@@ -1615,7 +1615,7 @@ uint32_t sam_tc_divfreq(TC_HANDLE handle)
DEBUGASSERT(chan);
- /* Get the the TC_CMR register contents for this channel and extract the
+ /* Get the TC_CMR register contents for this channel and extract the
* TCCLKS index.
*/
diff --git a/arch/arm/src/samv7/sam_tickless.c b/arch/arm/src/samv7/sam_tickless.c
index 1cda5dcc73dd4009065b75dc2d8d939ee4354482..b1b101455e42e11f789fcf4ac82250f90a1b1708 100644
--- a/arch/arm/src/samv7/sam_tickless.c
+++ b/arch/arm/src/samv7/sam_tickless.c
@@ -311,7 +311,7 @@ void arm_timer_initialize(void)
* any failure.
*
* Assumptions:
- * Called from the the normal tasking context. The implementation must
+ * Called from the normal tasking context. The implementation must
* provide whatever mutual exclusion is necessary for correct operation.
* This can include disabling interrupts in order to assure atomic register
* operations.
diff --git a/arch/arm/src/samv7/sam_usbdevhs.c b/arch/arm/src/samv7/sam_usbdevhs.c
index 4adfa117c11abfcbb08b0fb45ff124e8db3d5b63..d2904fc96ca656b0338b102de128fe6a32bbd9b2 100644
--- a/arch/arm/src/samv7/sam_usbdevhs.c
+++ b/arch/arm/src/samv7/sam_usbdevhs.c
@@ -1359,7 +1359,7 @@ static void sam_req_wrsetup(struct sam_usbdev_s *priv,
* When this function starts a transfer it will update the request
* 'inflight' field to indicate the size of the transfer.
*
- * When the transfer completes, the the 'inflight' field must hold the
+ * When the transfer completes, the 'inflight' field must hold the
* number of bytes that have completed the transfer. This function will
* update 'xfrd' with the new size of the transfer.
*
diff --git a/arch/arm/src/samv7/sam_wdt.c b/arch/arm/src/samv7/sam_wdt.c
index e662146077e9ead6939446ad654ccc05a5ecc9e3..4ce21303c33122abc65501edd8292d4ef1a9a528 100644
--- a/arch/arm/src/samv7/sam_wdt.c
+++ b/arch/arm/src/samv7/sam_wdt.c
@@ -495,9 +495,22 @@ static int sam_settimeout(FAR struct watchdog_lowerhalf_s *lower,
* NOTE: The Watchdog Mode Register (WDT_MR) can be written only once. Only
* a processor reset resets it. Writing the WDT_MR register reloads the
* timer with the newly programmed mode parameters.
+ *
+ * NOTE: The WDD Value is the lower bound of a so called Forbidden Window
+ * (see Datasheet for further Informations). To disable this Forbidden
+ * Window we have to set the WDD Value greater than or equal to WDV
+ * (according the Datasheet).
+ *
+ * When setting the WDD Value equal to WDV we have to wait at least one clock
+ * pulse of the (very slow) watchdog clock source between two resets (or the
+ * configuration and the first reset) of the watchdog.
+ *
+ * On fast systems this can lead to a direct hit of the WDD boundary and
+ * thus to a reset of the system. This is why we program the WDD Value toi
+ * WDT_MR_WDD_MAX to truly disable this Forbidden Window Feature.
*/
- regval = WDT_MR_WDV(reload) | WDT_MR_WDD(reload);
+ regval = WDT_MR_WDV(reload) | WDT_MR_WDD(WDT_MR_WDD_MAX);
#ifdef CONFIG_SAMV7_WDT_INTERRUPT
/* Generate an interrupt whent he watchdog timer expires */
diff --git a/arch/arm/src/stm32/Kconfig b/arch/arm/src/stm32/Kconfig
index 8dea045fda5cdd028f8ce58f5b56432ef5e04202..ba6bdb4b7908bace5aacd4c50864eb12b675467c 100644
--- a/arch/arm/src/stm32/Kconfig
+++ b/arch/arm/src/stm32/Kconfig
@@ -16,7 +16,7 @@ config ARCH_CHIP_STM32L151C6
select STM32_STM32L15XX
select STM32_ENERGYLITE
---help---
- STM32L 48-pin EnergyLite, 32KB FLASH, 10KB SRAM, 4KB EEPRROM
+ STM32L 48-pin EnergyLite, 32KB FLASH, 10KB SRAM, 4KB EEPROM
config ARCH_CHIP_STM32L151C8
bool "STM32L151C8"
@@ -24,7 +24,7 @@ config ARCH_CHIP_STM32L151C8
select STM32_STM32L15XX
select STM32_ENERGYLITE
---help---
- STM32L 48-pin EnergyLite, 64KB FLASH, 10KB SRAM, 4KB EEPRROM
+ STM32L 48-pin EnergyLite, 64KB FLASH, 10KB SRAM, 4KB EEPROM
config ARCH_CHIP_STM32L151CB
bool "STM32L151CB"
@@ -32,7 +32,7 @@ config ARCH_CHIP_STM32L151CB
select STM32_STM32L15XX
select STM32_ENERGYLITE
---help---
- STM32L 48-pin EnergyLite, 128KB FLASH, 16KB SRAM, 4KB EEPRROM
+ STM32L 48-pin EnergyLite, 128KB FLASH, 16KB SRAM, 4KB EEPROM
config ARCH_CHIP_STM32L151R6
bool "STM32L151R6"
@@ -40,7 +40,7 @@ config ARCH_CHIP_STM32L151R6
select STM32_STM32L15XX
select STM32_ENERGYLITE
---help---
- STM32L 64-pin EnergyLite, 32KB FLASH, 10KB SRAM, 4KB EEPRROM
+ STM32L 64-pin EnergyLite, 32KB FLASH, 10KB SRAM, 4KB EEPROM
config ARCH_CHIP_STM32L151R8
bool "STM32L151R8"
@@ -48,7 +48,7 @@ config ARCH_CHIP_STM32L151R8
select STM32_STM32L15XX
select STM32_ENERGYLITE
---help---
- STM32L 64-pin EnergyLite, 64KB FLASH, 10KB SRAM, 4KB EEPRROM
+ STM32L 64-pin EnergyLite, 64KB FLASH, 10KB SRAM, 4KB EEPROM
config ARCH_CHIP_STM32L151RB
bool "STM32L151RB"
@@ -56,7 +56,7 @@ config ARCH_CHIP_STM32L151RB
select STM32_STM32L15XX
select STM32_ENERGYLITE
---help---
- STM32L 64-pin EnergyLite, 128KB FLASH, 16KB SRAM, 4KB EEPRROM
+ STM32L 64-pin EnergyLite, 128KB FLASH, 16KB SRAM, 4KB EEPROM
config ARCH_CHIP_STM32L151V6
bool "STM32L151V6"
@@ -64,7 +64,7 @@ config ARCH_CHIP_STM32L151V6
select STM32_STM32L15XX
select STM32_ENERGYLITE
---help---
- STM32L 100-pin EnergyLite, 32KB FLASH, 10KB SRAM, 4KB EEPRROM
+ STM32L 100-pin EnergyLite, 32KB FLASH, 10KB SRAM, 4KB EEPROM
config ARCH_CHIP_STM32L151V8
bool "STM32L151V8"
@@ -72,7 +72,7 @@ config ARCH_CHIP_STM32L151V8
select STM32_STM32L15XX
select STM32_ENERGYLITE
---help---
- STM32L 100-pin EnergyLite, 64KB FLASH, 10KB SRAM, 4KB EEPRROM
+ STM32L 100-pin EnergyLite, 64KB FLASH, 10KB SRAM, 4KB EEPROM
config ARCH_CHIP_STM32L151VB
bool "STM32L151VB"
@@ -80,7 +80,7 @@ config ARCH_CHIP_STM32L151VB
select STM32_STM32L15XX
select STM32_ENERGYLITE
---help---
- STM32L 100-pin EnergyLite, 128KB FLASH, 16KB SRAM, 4KB EEPRROM
+ STM32L 100-pin EnergyLite, 128KB FLASH, 16KB SRAM, 4KB EEPROM
config ARCH_CHIP_STM32L152C6
bool "STM32L152C6"
@@ -88,8 +88,8 @@ config ARCH_CHIP_STM32L152C6
select STM32_STM32L15XX
select STM32_ENERGYLITE
---help---
- STM32L 48-pin EnergyLite, 32KB FLASH, 10KB SRAM, 4KB EEPRROM with
- 4x16 LCD interface
+ STM32L 48-pin EnergyLite, 32KB FLASH, 10KB SRAM, 4KB EEPROM with
+ 4x18 LCD interface
config ARCH_CHIP_STM32L152C8
bool "STM32L152C8"
@@ -97,8 +97,8 @@ config ARCH_CHIP_STM32L152C8
select STM32_STM32L15XX
select STM32_ENERGYLITE
---help---
- STM32L 48-pin EnergyLite, 64KB FLASH, 10KB SRAM, 4KB EEPRROM with
- 4x16 LCD interface
+ STM32L 48-pin EnergyLite, 64KB FLASH, 10KB SRAM, 4KB EEPROM with
+ 4x18 LCD interface
config ARCH_CHIP_STM32L152CB
bool "STM32L152CB"
@@ -106,8 +106,8 @@ config ARCH_CHIP_STM32L152CB
select STM32_STM32L15XX
select STM32_ENERGYLITE
---help---
- STM32L 48-pin EnergyLite, 128KB FLASH, 16KB SRAM, 4KB EEPRROM with
- 4x16 LCD interface
+ STM32L 48-pin EnergyLite, 128KB FLASH, 16KB SRAM, 4KB EEPROM with
+ 4x18 LCD interface
config ARCH_CHIP_STM32L152R6
bool "STM32L152R6"
@@ -115,7 +115,7 @@ config ARCH_CHIP_STM32L152R6
select STM32_STM32L15XX
select STM32_ENERGYLITE
---help---
- STM32L 64-pin EnergyLite, 32KB FLASH, 10KB SRAM, 4KB EEPRROM with
+ STM32L 64-pin EnergyLite, 32KB FLASH, 10KB SRAM, 4KB EEPROM with
4x32/8x28 LCD interface
config ARCH_CHIP_STM32L152R8
@@ -124,7 +124,7 @@ config ARCH_CHIP_STM32L152R8
select STM32_STM32L15XX
select STM32_ENERGYLITE
---help---
- STM32L 64-pin EnergyLite, 64KB FLASH, 10KB SRAM, 4KB EEPRROM with
+ STM32L 64-pin EnergyLite, 64KB FLASH, 10KB SRAM, 4KB EEPROM with
4x32/8x28 LCD interface
config ARCH_CHIP_STM32L152RB
@@ -133,7 +133,7 @@ config ARCH_CHIP_STM32L152RB
select STM32_STM32L15XX
select STM32_ENERGYLITE
---help---
- STM32L 64-pin EnergyLite, 128KB FLASH, 16KB SRAM, 4KB EEPRROM with
+ STM32L 64-pin EnergyLite, 128KB FLASH, 16KB SRAM, 4KB EEPROM with
4x32/8x28 LCD interface
config ARCH_CHIP_STM32L152V6
@@ -142,7 +142,7 @@ config ARCH_CHIP_STM32L152V6
select STM32_STM32L15XX
select STM32_ENERGYLITE
---help---
- STM32L 100-pin EnergyLite, 32KB FLASH, 10KB SRAM, 4KB EEPRROM with
+ STM32L 100-pin EnergyLite, 32KB FLASH, 10KB SRAM, 4KB EEPROM with
4x44/8x40 LCD interface
config ARCH_CHIP_STM32L152V8
@@ -151,7 +151,7 @@ config ARCH_CHIP_STM32L152V8
select STM32_STM32L15XX
select STM32_ENERGYLITE
---help---
- STM32L 100-pin EnergyLite, 64KB FLASH, 10KB SRAM, 4KB EEPRROM with
+ STM32L 100-pin EnergyLite, 64KB FLASH, 10KB SRAM, 4KB EEPROM with
4x44/8x40 LCD interface
config ARCH_CHIP_STM32L152VB
@@ -160,7 +160,37 @@ config ARCH_CHIP_STM32L152VB
select STM32_STM32L15XX
select STM32_ENERGYLITE
---help---
- STM32L 100-pin EnergyLite, 128KB FLASH, 16KB SRAM, 4KB EEPRROM with
+ STM32L 100-pin EnergyLite, 128KB FLASH, 16KB SRAM, 4KB EEPROM with
+ 4x44/8x40 LCD interface
+
+config ARCH_CHIP_STM32L152CC
+ bool "STM32L152CC"
+ select ARCH_CORTEXM3
+ select STM32_STM32L15XX
+ select STM32_ENERGYLITE
+ select STM32_MEDIUMPLUSDENSITY
+ ---help---
+ STM32L 48-pin EnergyLite, 256KB FLASH, 32KB SRAM, 8KB EEPROM with
+ 4x18 LCD interface
+
+config ARCH_CHIP_STM32L152RC
+ bool "STM32L152RC"
+ select ARCH_CORTEXM3
+ select STM32_STM32L15XX
+ select STM32_ENERGYLITE
+ select STM32_MEDIUMPLUSDENSITY
+ ---help---
+ STM32L 64-pin EnergyLite, 256KB FLASH, 32KB SRAM, 8KB EEPROM with
+ 4x32/8x28 LCD interface
+
+config ARCH_CHIP_STM32L152VC
+ bool "STM32L152VC"
+ select ARCH_CORTEXM3
+ select STM32_STM32L15XX
+ select STM32_ENERGYLITE
+ select STM32_MEDIUMPLUSDENSITY
+ ---help---
+ STM32L 100-pin EnergyLite, 256KB FLASH, 32KB SRAM, 8KB EEPROM with
4x44/8x40 LCD interface
config ARCH_CHIP_STM32L162ZD
@@ -171,8 +201,8 @@ config ARCH_CHIP_STM32L162ZD
select STM32_HIGHDENSITY
select STM32_HAVE_AES
---help---
- STM32L 144-pin EnergyLite, 384KB FLASH, 48KB SRAM, 12KB EEPRROM with
- 8x40 LCD interface
+ STM32L 144-pin EnergyLite, 384KB FLASH, 48KB SRAM, 12KB EEPROM with
+ 4x44/8x40 LCD interface
config ARCH_CHIP_STM32L162VE
bool "STM32L162VE"
@@ -182,8 +212,8 @@ config ARCH_CHIP_STM32L162VE
select STM32_HIGHDENSITY
select STM32_HAVE_AES
---help---
- STM32L 100-pin EnergyLite, 512KB FLASH, 80KB SRAM, 16KB EEPRROM with
- 8x40 LCD interface
+ STM32L 100-pin EnergyLite, 512KB FLASH, 80KB SRAM, 16KB EEPROM with
+ 4x44/8x40 LCD interface
config ARCH_CHIP_STM32F100C8
bool "STM32F100C8"
@@ -942,6 +972,13 @@ config ARCH_CHIP_STM32F401RE
select STM32_STM32F401
select ARCH_HAVE_FPU
+config ARCH_CHIP_STM32F410RB
+ bool "STM32F410RB"
+ select ARCH_CORTEXM4
+ select STM32_STM32F40XX
+ select STM32_STM32F410
+ select ARCH_HAVE_FPU
+
config ARCH_CHIP_STM32F411RE
bool "STM32F411RE"
select ARCH_CORTEXM4
@@ -1445,12 +1482,12 @@ config STM32_STM32F303
config STM32_STM32F33XX
bool
- default n
+ 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_OPAMP2
select STM32_HAVE_CCM
select STM32_HAVE_TIM1
select STM32_HAVE_TIM15
@@ -1493,6 +1530,7 @@ config STM32_STM32F40XX
select STM32_HAVE_TIM4
select STM32_HAVE_SPI2
select STM32_HAVE_SPI3
+ select STM32_HAVE_I2S3
select STM32_HAVE_I2C2
select STM32_HAVE_I2C3
@@ -1505,6 +1543,20 @@ config STM32_STM32F401
select STM32_HAVE_TIM9
select STM32_HAVE_TIM10
select STM32_HAVE_TIM11
+ select STM32_HAVE_SPI2
+ select STM32_HAVE_SPI3
+ select STM32_HAVE_I2S3
+
+config STM32_STM32F410
+ bool
+ default n
+ select STM32_HAVE_USART6
+ select STM32_HAVE_TIM1
+ select STM32_HAVE_TIM5
+ select STM32_HAVE_TIM6
+ select STM32_HAVE_TIM9
+ select STM32_HAVE_TIM11
+ select STM32_HAVE_SPI5
config STM32_STM32F411
bool
@@ -1515,6 +1567,9 @@ config STM32_STM32F411
select STM32_HAVE_TIM9
select STM32_HAVE_TIM10
select STM32_HAVE_TIM11
+ select STM32_HAVE_SPI2
+ select STM32_HAVE_SPI3
+ select STM32_HAVE_I2S3
select STM32_HAVE_SPI4
select STM32_HAVE_SPI5
@@ -1607,6 +1662,9 @@ config STM32_STM32F427
select STM32_HAVE_DAC2
select STM32_HAVE_RNG
select STM32_HAVE_ETHMAC
+ select STM32_HAVE_SPI2
+ select STM32_HAVE_SPI3
+ select STM32_HAVE_I2S3
select STM32_HAVE_SPI4
select STM32_HAVE_SPI5
select STM32_HAVE_SPI6
@@ -1625,6 +1683,7 @@ config STM32_STM32F429
select STM32_HAVE_UART7
select STM32_HAVE_UART8
select STM32_HAVE_TIM1
+ select STM32_HAVE_TIM5
select STM32_HAVE_TIM6
select STM32_HAVE_TIM7
select STM32_HAVE_TIM8
@@ -1642,6 +1701,9 @@ config STM32_STM32F429
select STM32_HAVE_DAC2
select STM32_HAVE_RNG
select STM32_HAVE_ETHMAC
+ select STM32_HAVE_SPI2
+ select STM32_HAVE_SPI3
+ select STM32_HAVE_I2S3
select STM32_HAVE_SPI4
select STM32_HAVE_SPI5
select STM32_HAVE_SPI6
@@ -1714,8 +1776,8 @@ config STM32_STM32F469
select STM32_HAVE_SPI4
select STM32_HAVE_SPI5
select STM32_HAVE_SPI6
- select STM32_HAVE_SAIPLL
- select STM32_HAVE_I2SPLL
+ select STM32_HAVE_SAIPLL
+ select STM32_HAVE_I2SPLL
config STM32_DFU
@@ -1907,17 +1969,33 @@ config STM32_HAVE_CAN2
bool
default n
+config STM32_HAVE_COMP1
+ bool
+ default n
+
config STM32_HAVE_COMP2
- bool
- default n
+ bool
+ default n
+
+config STM32_HAVE_COMP3
+ bool
+ default n
config STM32_HAVE_COMP4
- bool
- default n
+ bool
+ default n
+
+config STM32_HAVE_COMP5
+ bool
+ default n
config STM32_HAVE_COMP6
- bool
- default n
+ bool
+ default n
+
+config STM32_HAVE_COMP7
+ bool
+ default n
config STM32_HAVE_DAC1
bool
@@ -1951,6 +2029,10 @@ config STM32_HAVE_SPI3
bool
default n
+config STM32_HAVE_I2S3
+ bool
+ default n
+
config STM32_HAVE_SPI4
bool
default n
@@ -1971,9 +2053,21 @@ config STM32_HAVE_I2SPLL
bool
default n
-config STM32_HAVE_OPAMP
- bool
- default n
+config STM32_HAVE_OPAMP1
+ bool
+ default n
+
+config STM32_HAVE_OPAMP2
+ bool
+ default n
+
+config STM32_HAVE_OPAMP3
+ bool
+ default n
+
+config STM32_HAVE_OPAMP4
+ bool
+ default n
# These are the peripheral selections proper
@@ -2032,21 +2126,41 @@ config STM32_COMP
default n
depends on STM32_STM32L15XX
+config STM32_COMP1
+ bool "COMP1"
+ default n
+ depends on STM32_HAVE_COMP1
+
config STM32_COMP2
bool "COMP2"
default n
depends on STM32_HAVE_COMP2
+config STM32_COMP3
+ bool "COMP3"
+ default n
+ depends on STM32_HAVE_COMP3
+
config STM32_COMP4
bool "COMP4"
default n
depends on STM32_HAVE_COMP4
+config STM32_COMP5
+ bool "COMP5"
+ default n
+ depends on STM32_HAVE_COMP5
+
config STM32_COMP6
bool "COMP6"
default n
depends on STM32_HAVE_COMP6
+config STM32_COMP7
+ bool "COMP7"
+ default n
+ depends on STM32_HAVE_COMP6
+
config STM32_BKP
bool "BKP"
default n
@@ -2185,7 +2299,26 @@ config STM32_DMA2D
config STM32_OPAMP
bool "OPAMP"
default n
- depends on STM32_HAVE_OPAMP
+
+config STM32_OPAMP1
+ bool "OPAMP1"
+ default n
+ depends on STM32_HAVE_OPAMP1
+
+config STM32_OPAMP2
+ bool "OPAMP2"
+ default n
+ depends on STM32_HAVE_OPAMP2
+
+config STM32_OPAMP3
+ bool "OPAMP3"
+ default n
+ depends on STM32_HAVE_OPAMP3
+
+config STM32_OPAMP4
+ bool "OPAMP4"
+ default n
+ depends on STM32_HAVE_OPAMP4
config STM32_OTGFS
bool "OTG FS"
@@ -2237,6 +2370,13 @@ config STM32_SPI3
select SPI
select STM32_SPI
+config STM32_I2S3
+ bool "I2S3"
+ default n
+ depends on STM32_HAVE_I2S3
+ select I2S
+ select STM32_I2S
+
config STM32_SPI4
bool "SPI4"
default n
@@ -2494,6 +2634,11 @@ config STM32_SPI3_REMAP
default n
depends on STM32_STM32F10XX && STM32_SPI3 && !STM32_VALUELINE
+config STM32_I2S3_REMAP
+ bool "I2S3 Alternate Pin Mapping"
+ default n
+ depends on STM32_STM32F10XX && STM32_I2S3 && !STM32_VALUELINE
+
choice
prompt "TIM1 Alternate Pin Mappings"
depends on STM32_STM32F10XX && STM32_TIM1
@@ -2629,9 +2774,17 @@ config STM32_FLASH_PREFETCH
default y if STM32_STM32F427 || STM32_STM32F429 || STM32_STM32F446
default n
---help---
- Enable FLASH prefetch and F2 and F4 parts (FLASH pre-fetch is always enabled
- on F1 parts). Some early revisions of F4 parts do not support FLASH pre-fetch
- properly and enabling this option may interfere with ADC accuracy.
+ Enable FLASH prefetch and F2 and F4 parts (FLASH pre-fetch is always enabled
+ on F1 parts). Some early revisions of F4 parts do not support FLASH pre-fetch
+ properly and enabling this option may interfere with ADC accuracy.
+
+config STM32_FLASH_WORKAROUND_DATA_CACHE_CORRUPTION_ON_RWW
+ bool "Workaround for FLASH data cache corruption"
+ default n
+ ---help---
+ Enable the workaround to fix flash data cache corruption when reading
+ from one flash bank while writing on other flash bank. See your STM32
+ errata to check if your STM32 is affected by this problem.
choice
prompt "JTAG Configuration"
@@ -2735,36 +2888,25 @@ menu "Timer Configuration"
if SCHED_TICKLESS
-config STM32_ONESHOT
- bool
- default y
-
-config STM32_FREERUN
- bool
- default y
-
-config STM32_TICKLESS_ONESHOT
- int "Tickless one-shot timer channel"
+config STM32_TICKLESS_TIMER
+ int "Tickless hardware timer"
default 2
range 1 14
- depends on STM32_ONESHOT
---help---
- If the Tickless OS feature is enabled, the one clock must be
- assigned to provided the one-shot timer needed by the OS.
+ If the Tickless OS feature is enabled, then one clock must be
+ assigned to provided the timer needed by the OS.
-config STM32_TICKLESS_FREERUN
- int "Tickless free-running timer channel"
- default 5
- range 1 14
- depends on STM32_FREERUN
+config STM32_TICKLESS_CHANNEL
+ int "Tickless timer channel"
+ default 1
+ range 1 4
---help---
If the Tickless OS feature is enabled, the one clock must be
- assigned to provided the free-running timer needed by the OS.
+ assigned to provided the free-running timer needed by the OS
+ and one channel on that clock is needed to handle intervals.
endif # SCHED_TICKLESS
-if !SCHED_TICKLESS
-
config STM32_ONESHOT
bool "TIM one-shot wrapper"
default n
@@ -2779,8 +2921,6 @@ config STM32_FREERUN
Enable a wrapper around the low level timer/counter functions to
support a free-running timer.
-endif # !SCHED_TICKLESS
-
config STM32_ONESHOT_MAXTIMERS
int "Maximum number of oneshot timers"
default 1
@@ -5564,6 +5704,12 @@ endmenu # Timer Configuration
menu "ADC Configuration"
depends on STM32_ADC
+config STM32_ADC_NO_STARTUP_CONV
+ bool "Do not start conversion when opening ADC device"
+ default n
+ ---help---
+ Do not start conversion when opening ADC device.
+
config STM32_ADC1_DMA
bool "ADC1 DMA"
depends on STM32_ADC1 && STM32_HAVE_ADC1_DMA
@@ -6066,6 +6212,19 @@ if STM32_SERIALDRIVER
comment "Serial Driver Configuration"
+config STM32_SERIAL_RXDMA_BUFFER_SIZE
+ int "Rx DMA buffer size"
+ default 32
+ range 32 4096
+ depends on USART1_RXDMA || USART2_RXDMA || USART3_RXDMA || UART4_RXDMA || UART5_RXDMA || USART6_RXDMA || UART7_RXDMA || UART8_RXDMA
+ ---help---
+ The DMA buffer size when using RX DMA to emulate a FIFO.
+
+ When streaming data, the generic serial layer will be called
+ every time the FIFO receives half or this number of bytes.
+
+ Value given here will be rounded up to next multiple of 4 bytes.
+
config SERIAL_DISABLE_REORDERING
bool "Disable reordering of ttySx devices."
depends on STM32_USART1 || STM32_USART2 || STM32_USART3 || STM32_UART4 || STM32_UART5 || STM32_USART6 || STM32_UART7 || STM32_UART8
@@ -6140,6 +6299,66 @@ config STM32_SPI_DMA
endmenu
+menu "I2S Configuration"
+ depends on STM32_I2S3
+
+config STM32_I2S_MCK
+ bool "I2S_MCK"
+ default n
+ ---help---
+ TBD.
+
+config STM32_I2S_MAXINFLIGHT
+ int "I2S queue size"
+ default 16
+ ---help---
+ This is the total number of transfers, both RX and TX, that can be
+ enqueue before the caller is required to wait. This setting
+ determines the number certain queue data structures that will be
+ pre-allocated.
+
+comment "I2S3 Configuration"
+
+config STM32_I2S3_DATALEN
+ int "Data width (bits)"
+ default 16
+ ---help---
+ Data width in bits. This is a default value and may be change
+ via the I2S interface
+
+#if STM32_I2S
+config STM32_I2S3_RX
+ bool "Enable I2C receiver"
+ default n
+ ---help---
+ Enable I2S receipt logic
+
+config STM32_I2S3_TX
+ bool "Enable I2C transmitter"
+ default n
+ ---help---
+ Enable I2S transmission logic
+
+config STM32_I2S_DMADEBUG
+ bool "I2S DMA transfer debug"
+ depends on DEBUG_DMA
+ default n
+ ---help---
+ Enable special debug instrumentation analyze I2S DMA data transfers.
+ This logic is as non-invasive as possible: It samples DMA
+ registers at key points in the data transfer and then dumps all of
+ the registers at the end of the transfer.
+
+config STM32_I2S_REGDEBUG
+ bool "SSC Register level debug"
+ depends on DEBUG
+ default n
+ ---help---
+ Output detailed register-level SSC device debug information.
+ Very invasive! Requires also DEBUG.
+
+endmenu # I2S Configuration
+
menu "I2C Configuration"
depends on STM32_I2C
@@ -6190,6 +6409,15 @@ config STM32_I2C_DUTY16_9
default n
depends on STM32_I2C
+config STM32_I2C_DMA
+ bool "I2C DMA Support"
+ default n
+ depends on STM32_I2C && STM32_STM32F40XX && STM32_DMA1 && !I2C_POLLED
+ ---help---
+ This option enables the DMA for I2C transfers.
+ Note: The user can define CONFIG_I2C_DMAPRIO: a custom priority value for the
+ I2C dma streams, else the default priority level is set to medium.
+
endmenu
menu "SDIO Configuration"
@@ -6254,6 +6482,7 @@ config STM32_HAVE_RTC_COUNTER
config STM32_HAVE_RTC_SUBSECONDS
bool
+ select ARCH_HAVE_RTC_SUBSECONDS
default n
config RTC_MAGIC_REG
@@ -6263,10 +6492,15 @@ config RTC_MAGIC_REG
depends on RTC && !STM32_HAVE_RTC_COUNTER
config RTC_MAGIC
- hex "Value used as Magic to determine if RTC is set already"
+ hex "Value used as Magic to determine if RTC is already setup"
default 0xfacefeee
depends on RTC && !STM32_HAVE_RTC_COUNTER
+config RTC_MAGIC_TIME_SET
+ hex "Value used as Magic to determine if RTC is setup and have time set"
+ default 0xfacefeef
+ depends on RTC && !STM32_HAVE_RTC_COUNTER
+
choice
prompt "RTC clock source"
default RTC_LSECLOCK
@@ -6728,7 +6962,7 @@ config STM32_LTDC_DITHER_BLUE
config STM32_LTDC_FB_BASE
hex "Framebuffer memory start address"
---help---
- If you are using the the LTDC, then you must provide the address
+ If you are using the LTDC, then you must provide the address
of the start of the framebuffer. This address will typically
be in the SRAM or SDRAM memory region of the FSMC.
diff --git a/arch/arm/src/stm32/Make.defs b/arch/arm/src/stm32/Make.defs
index 1558c8417d5c78b8713c64a0c96fa29f62e659fe..11f5c3dc1d923da0aa56ec20fdca80c0d9b0e0b3 100644
--- a/arch/arm/src/stm32/Make.defs
+++ b/arch/arm/src/stm32/Make.defs
@@ -101,7 +101,7 @@ CHIP_ASRCS =
CHIP_CSRCS = stm32_allocateheap.c stm32_start.c stm32_rcc.c stm32_lse.c
CHIP_CSRCS += stm32_lsi.c stm32_gpio.c stm32_exti_gpio.c stm32_flash.c
CHIP_CSRCS += stm32_irq.c stm32_dma.c stm32_lowputc.c
-CHIP_CSRCS += stm32_serial.c stm32_spi.c stm32_sdio.c stm32_tim.c
+CHIP_CSRCS += stm32_serial.c stm32_spi.c stm32_i2s.c stm32_sdio.c stm32_tim.c
CHIP_CSRCS += stm32_waste.c stm32_ccm.c stm32_uid.c stm32_capture.c
ifeq ($(CONFIG_TIMER),y)
@@ -217,6 +217,18 @@ ifeq ($(CONFIG_DAC),y)
CHIP_CSRCS += stm32_dac.c
endif
+ifeq ($(CONFIG_COMP),y)
+CHIP_CSRCS += stm32_comp.c
+endif
+
+ifeq ($(CONFIG_OPAMP),y)
+CHIP_CSRCS += stm32_opamp.c
+endif
+
+ifeq ($(CONFIG_HRTIM),y)
+CHIP_CSRCS += stm32_hrtim.c
+endif
+
ifeq ($(CONFIG_STM32_1WIREDRIVER),y)
CHIP_CSRCS += stm32_1wire.c
endif
diff --git a/arch/arm/src/stm32/chip/stm32_exti.h b/arch/arm/src/stm32/chip/stm32_exti.h
index 791bed1f174fe1c876eee7bb9b86133c80ccd996..e18b60cf71bf2c7b82cb6c14f7c13d06b6732fb8 100644
--- a/arch/arm/src/stm32/chip/stm32_exti.h
+++ b/arch/arm/src/stm32/chip/stm32_exti.h
@@ -188,9 +188,9 @@
/* Pending register */
-#define EXTI_IMR_BIT(n) STM32_EXTI_BIT(n) /* 1=Selected trigger request occurred */
-#define EXTI_IMR_SHIFT (0) /* Bits 0-X: Pending bit for all lines */
-#define EXTI_IMR_MASK STM32_EXTI_MASK
+#define EXTI_PR_BIT(n) STM32_EXTI_BIT(n) /* 1=Selected trigger request occurred */
+#define EXTI_PR_SHIFT (0) /* Bits 0-X: Pending bit for all lines */
+#define EXTI_PR_MASK STM32_EXTI_MASK
/* Compatibility Definitions ********************************************************/
diff --git a/arch/arm/src/stm32/chip/stm32_flash.h b/arch/arm/src/stm32/chip/stm32_flash.h
index 218ba05fcf77323cfd689ea049f46f54965a7e29..13c966c05c261ed1a331c6b55eb2371f0618a2ea 100644
--- a/arch/arm/src/stm32/chip/stm32_flash.h
+++ b/arch/arm/src/stm32/chip/stm32_flash.h
@@ -59,16 +59,33 @@
#if defined(CONFIG_STM32_FLASH_CONFIG_DEFAULT)
# if defined(CONFIG_STM32_STM32L15XX)
+# if defined(CONFIG_STM32_HIGHDENSITY)
-/* The STM32 L15xx/L16xx can support up to 384KB of FLASH. (In reality, supported
- * L15xx parts have no more than 128KB). The program memory block is divided into
- * 96 sectors of 4 Kbytes each, and each sector is further split up into 16 pages of
- * 256 bytes each. The sector is the write protection granularity. In total, the
+/* Different STM32L1xxx MCU version are now called by different 'categories' instead
+ * of 'densities'. Cat.5 MCU can have up to 512KB of FLASH. STM32L1xxx also have
+ * data EEPROM, up to 16KB.
+ */
+
+# define STM32_FLASH_NPAGES 2048
+# define STM32_FLASH_PAGESIZE 256
+# else
+
+/* The STM32 (< Cat.5) L15xx/L16xx can support up to 384KB of FLASH. (In reality, most
+ * supported L15xx parts have no more than 128KB). The program memory block is divided
+ * into 96 sectors of 4 Kbytes each, and each sector is further split up into 16 pages
+ * of 256 bytes each. The sector is the write protection granularity. In total, the
* program memory block contains 1536 pages.
*/
-# define STM32_FLASH_NPAGES 1536
-# define STM32_FLASH_PAGESIZE 256
+# define STM32_FLASH_NPAGES 1536
+# define STM32_FLASH_PAGESIZE 256
+# endif
+
+ /* Maximum EEPROM size on Cat.5 MCU. TODO: this should be in chip config. */
+
+# ifndef STM32_EEPROM_SIZE
+# define STM32_EEPROM_SIZE (16 * 1024)
+# endif
# elif defined(CONFIG_STM32_LOWDENSITY)
# define STM32_FLASH_NPAGES 32
@@ -201,27 +218,40 @@
# elif defined(CONFIG_STM32_FLASH_CONFIG_I)
# endif
# endif
-#endif
+#endif /* !defined(CONFIG_STM32_FLASH_CONFIG_DEFAULT) */
#ifdef STM32_FLASH_PAGESIZE
# define STM32_FLASH_SIZE (STM32_FLASH_NPAGES * STM32_FLASH_PAGESIZE)
-#endif /* def STM32_FLASH_PAGESIZE */
+#endif
/* Register Offsets *****************************************************************/
-#define STM32_FLASH_ACR_OFFSET 0x0000
-#define STM32_FLASH_KEYR_OFFSET 0x0004
-#define STM32_FLASH_OPTKEYR_OFFSET 0x0008
-#define STM32_FLASH_SR_OFFSET 0x000c
-#define STM32_FLASH_CR_OFFSET 0x0010
-
-#if defined(CONFIG_STM32_STM32F10XX) || defined(CONFIG_STM32_STM32F30XX) || \
- 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
-#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX)
-# define STM32_FLASH_OPTCR_OFFSET 0x0014
+#define STM32_FLASH_ACR_OFFSET 0x0000
+#if defined(CONFIG_STM32_STM32L15XX)
+# define STM32_FLASH_PECR_OFFSET 0x0004
+# define STM32_FLASH_PDKEYR_OFFSET 0x0008
+# define STM32_FLASH_PEKEYR_OFFSET 0x000c
+# define STM32_FLASH_PRGKEYR_OFFSET 0x0010
+# define STM32_FLASH_OPTKEYR_OFFSET 0x0014
+# define STM32_FLASH_SR_OFFSET 0x0018
+# define STM32_FLASH_OBR_OFFSET 0x001c
+# define STM32_FLASH_WRPR1_OFFSET 0x0020
+# define STM32_FLASH_WRPR2_OFFSET 0x0080
+# define STM32_FLASH_WRPR3_OFFSET 0x0084
+# define STM32_FLASH_WRPR4_OFFSET 0x0088
+#else
+# define STM32_FLASH_KEYR_OFFSET 0x0004
+# define STM32_FLASH_OPTKEYR_OFFSET 0x0008
+# define STM32_FLASH_SR_OFFSET 0x000c
+# define STM32_FLASH_CR_OFFSET 0x0010
+# if defined(CONFIG_STM32_STM32F10XX) || defined(CONFIG_STM32_STM32F30XX) || \
+ 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
+# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX)
+# define STM32_FLASH_OPTCR_OFFSET 0x0014
+# endif
#endif
#if defined(CONFIG_STM32_STM32F427) || defined(CONFIG_STM32_STM32F429)
@@ -230,22 +260,36 @@
/* Register Addresses ***************************************************************/
-#define STM32_FLASH_ACR (STM32_FLASHIF_BASE+STM32_FLASH_ACR_OFFSET)
-#define STM32_FLASH_KEYR (STM32_FLASHIF_BASE+STM32_FLASH_KEYR_OFFSET)
-#define STM32_FLASH_OPTKEYR (STM32_FLASHIF_BASE+STM32_FLASH_OPTKEYR_OFFSET)
-#define STM32_FLASH_SR (STM32_FLASHIF_BASE+STM32_FLASH_SR_OFFSET)
-#define STM32_FLASH_CR (STM32_FLASHIF_BASE+STM32_FLASH_CR_OFFSET)
+#define STM32_FLASH_ACR (STM32_FLASHIF_BASE+STM32_FLASH_ACR_OFFSET)
+#if defined(CONFIG_STM32_STM32L15XX)
+# define STM32_FLASH_PECR (STM32_FLASHIF_BASE+STM32_FLASH_PECR_OFFSET)
+# define STM32_FLASH_PDKEYR (STM32_FLASHIF_BASE+STM32_FLASH_PDKEYR_OFFSET)
+# define STM32_FLASH_PEKEYR (STM32_FLASHIF_BASE+STM32_FLASH_PEKEYR_OFFSET)
+# define STM32_FLASH_PRGKEYR (STM32_FLASHIF_BASE+STM32_FLASH_PRGKEYR_OFFSET)
+# define STM32_FLASH_OPTKEYR (STM32_FLASHIF_BASE+STM32_FLASH_OPTKEYR_OFFSET)
+# define STM32_FLASH_SR (STM32_FLASHIF_BASE+STM32_FLASH_SR_OFFSET)
+# define STM32_FLASH_OBR (STM32_FLASHIF_BASE+STM32_FLASH_OBR_OFFSET)
+# define STM32_FLASH_WRPR1 (STM32_FLASHIF_BASE+STM32_FLASH_WRPR1_OFFSET)
+# define STM32_FLASH_WRPR2 (STM32_FLASHIF_BASE+STM32_FLASH_WRPR2_OFFSET)
+# define STM32_FLASH_WRPR3 (STM32_FLASHIF_BASE+STM32_FLASH_WRPR3_OFFSET)
+# define STM32_FLASH_WRPR4 (STM32_FLASHIF_BASE+STM32_FLASH_WRPR4_OFFSET)
+#else
+# define STM32_FLASH_KEYR (STM32_FLASHIF_BASE+STM32_FLASH_KEYR_OFFSET)
+# define STM32_FLASH_OPTKEYR (STM32_FLASHIF_BASE+STM32_FLASH_OPTKEYR_OFFSET)
+# define STM32_FLASH_SR (STM32_FLASHIF_BASE+STM32_FLASH_SR_OFFSET)
+# define STM32_FLASH_CR (STM32_FLASHIF_BASE+STM32_FLASH_CR_OFFSET)
-#if defined(CONFIG_STM32_STM32F10XX) || defined(CONFIG_STM32_STM32F30XX) || \
- 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)
-#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX)
-# define STM32_FLASH_OPTCR (STM32_FLASHIF_BASE+STM32_FLASH_OPTCR_OFFSET)
-#endif
-#if defined(CONFIG_STM32_STM32F427) || defined(CONFIG_STM32_STM32F429)
-# define STM32_FLASH_OPTCR1 (STM32_FLASHIF_BASE+STM32_FLASH_OPTCR1_OFFSET)
+# if defined(CONFIG_STM32_STM32F10XX) || defined(CONFIG_STM32_STM32F30XX) || \
+ 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)
+# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX)
+# define STM32_FLASH_OPTCR (STM32_FLASHIF_BASE+STM32_FLASH_OPTCR_OFFSET)
+# endif
+# if defined(CONFIG_STM32_STM32F427) || defined(CONFIG_STM32_STM32F429)
+# define STM32_FLASH_OPTCR1 (STM32_FLASHIF_BASE+STM32_FLASH_OPTCR1_OFFSET)
+# endif
#endif
/* Register Bitfield Definitions ****************************************************/
@@ -303,6 +347,34 @@
# define FLASH_SR_PGPERR (1 << 6) /* Bit 6: Programming parallelism error */
# define FLASH_SR_PGSERR (1 << 7) /* Bit 7: Programming sequence error */
# define FLASH_SR_BSY (1 << 16) /* Bit 16: Busy */
+#elif defined(CONFIG_STM32_STM32L15XX)
+# define FLASH_SR_BSY (1 << 0) /* Bit 0: Busy */
+# define FLASH_SR_EOP (1 << 1) /* Bit 1: End of operation */
+# define FLASH_SR_ENDHV (1 << 2) /* Bit 2: End of high voltage */
+# define FLASH_SR_READY (1 << 3) /* Bit 3: Flash memory module ready after low power mode */
+# define FLASH_SR_WRPERR (1 << 8) /* Bit 8: Write protection error */
+# define FLASH_SR_PGAERR (1 << 9) /* Bit 9: Programming alignment error */
+# define FLASH_SR_SIZERR (1 << 10) /* Bit 10: Size error */
+# define FLASH_SR_OPTVERR (1 << 11) /* Bit 11: Option validity error */
+# define FLASH_SR_OPTVERRUSR (1 << 12) /* Bit 12: Option UserValidity Error */
+# define FLASH_SR_RDERR (1 << 13) /* Bit 13: Read protected error */
+#endif
+
+/* Program/Erase Control Register (PECR) */
+
+#if defined(CONFIG_STM32_STM32L15XX)
+# define FLASH_PECR_PELOCK (1 << 0) /* Bit 0: PECR and data EEPROM lock */
+# define FLASH_PECR_PRGLOCK (1 << 1) /* Bit 1: Program memory lock */
+# define FLASH_PECR_OPTLOCK (1 << 2) /* Bit 2: Option bytes block lock */
+# define FLASH_PECR_PROG (1 << 3) /* Bit 3: Program memory selection */
+# define FLASH_PECR_DATA (1 << 4) /* Bit 4: Data EEPROM selection */
+# define FLASH_PECR_FTDW (1 << 8) /* Bit 8: Fixed time data write for Byte, Half Word and Word programming */
+# define FLASH_PECR_ERASE (1 << 9) /* Bit 9: Page or Double Word erase mode */
+# define FLASH_PECR_FPRG (1 << 10) /* Bit 10: Half Page/Double Word programming mode */
+# define FLASH_PECR_PARALLBANK (1 << 15) /* Bit 15: Parallel bank mode */
+# define FLASH_PECR_EOPIE (1 << 16) /* Bit 16: End of programming interrupt enable */
+# define FLASH_PECR_ERRIE (1 << 17) /* Bit 17: Error interrupt enable */
+# define FLASH_PECR_OBL_LAUNCH (1 << 18) /* Bit 18: Launch the option byte loading */
#endif
/* Flash Control Register (CR) */
@@ -324,29 +396,30 @@
# define FLASH_CR_OBL_LAUNCH (1 << 13) /* Bit 13: Force option byte loading */
# endif
#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX)
-# define FLASH_CR_PG (1 << 0) /* Bit 0: Programming */
-# define FLASH_CR_SER (1 << 1) /* Bit 1: Sector Erase */
-# define FLASH_CR_MER (1 << 2) /* Bit 2: Mass Erase sectors 0..11 */
-# define FLASH_CR_SNB_SHIFT (3) /* Bits 3-6: Sector number */
-# define FLASH_CR_SNB_MASK (15 << FLASH_CR_SNB_SHIFT)
+# define FLASH_CR_PG (1 << 0) /* Bit 0: Programming */
+# define FLASH_CR_SER (1 << 1) /* Bit 1: Sector Erase */
+# define FLASH_CR_MER (1 << 2) /* Bit 2: Mass Erase sectors 0..11 */
+# define FLASH_CR_SNB_SHIFT (3) /* Bits 3-6: Sector number */
#if defined(CONFIG_STM32_STM32F427) || defined(CONFIG_STM32_STM32F429)
+# define FLASH_CR_SNB_MASK (31 << FLASH_CR_SNB_SHIFT)
# define FLASH_CR_SNB(n) (((n % 12) << FLASH_CR_SNB_SHIFT) | ((n / 12) << 7)) /* Sector n, n=0..23 */
#else
+# define FLASH_CR_SNB_MASK (15 << FLASH_CR_SNB_SHIFT)
# define FLASH_CR_SNB(n) ((n) << FLASH_CR_SNB_SHIFT) /* Sector n, n=0..11 */
#endif
-# define FLASH_CR_PSIZE_SHIFT (8) /* Bits 8-9: Program size */
+# define FLASH_CR_PSIZE_SHIFT (8) /* Bits 8-9: Program size */
# define FLASH_CR_PSIZE_MASK (3 << FLASH_CR_PSIZE_SHIFT)
# define FLASH_CR_PSIZE_X8 (0 << FLASH_CR_PSIZE_SHIFT) /* 00 program x8 */
# define FLASH_CR_PSIZE_X16 (1 << FLASH_CR_PSIZE_SHIFT) /* 01 program x16 */
# define FLASH_CR_PSIZE_X32 (2 << FLASH_CR_PSIZE_SHIFT) /* 10 program x32 */
# define FLASH_CR_PSIZE_X64 (3 << FLASH_CR_PSIZE_SHIFT) /* 11 program x64 */
-# define FLASH_CR_STRT (1 << 16) /* Bit 16: Start Erase */
-# define FLASH_CR_EOPIE (1 << 24) /* Bit 24: End of operation interrupt enable */
-# define FLASH_CR_ERRIE (1 << 25) /* Bit 25: Error interrupt enable */
-# define FLASH_CR_LOCK (1 << 31) /* Bit 31: Lock */
+# define FLASH_CR_STRT (1 << 16) /* Bit 16: Start Erase */
+# define FLASH_CR_EOPIE (1 << 24) /* Bit 24: End of operation interrupt enable */
+# define FLASH_CR_ERRIE (1 << 25) /* Bit 25: Error interrupt enable */
+# define FLASH_CR_LOCK (1 << 31) /* Bit 31: Lock */
#endif
#if defined(CONFIG_STM32_STM32F427) || defined(CONFIG_STM32_STM32F429)
-# define FLASH_CR_MER1 (1 << 15) /* Bit 15: Mass Erase sectors 12..23 */
+# define FLASH_CR_MER1 (1 << 15) /* Bit 15: Mass Erase sectors 12..23 */
#endif
/* Flash Option Control Register (OPTCR) */
@@ -374,16 +447,15 @@
/* Flash Option Control Register (OPTCR1) */
#if defined(CONFIG_STM32_STM32F427) || defined(CONFIG_STM32_STM32F429)
-# define FLASH_OPTCR1_NWRP_SHIFT (16) /* Bits 16-27: Not write protect (high bank) */
+# define FLASH_OPTCR1_NWRP_SHIFT (16) /* Bits 16-27: Not write protect (high bank) */
# define FLASH_OPTCR1_NWRP_MASK (0xfff << FLASH_OPTCR_NWRP_SHIFT)
# define FLASH_OPTCR1_BFB2_SHIFT (4) /* Bits 4: Dual-bank Boot option byte */
# define FLASH_OPTCR1_BFB2_MASK (1 << FLASH_OPTCR_NWRP_SHIFT)
-
#endif
#if defined(CONFIG_STM32_STM32F446)
-# define FLASH_OPTCR1_NWRP_SHIFT (16) /* Bits 16-23: Not write protect (high bank) */
+# define FLASH_OPTCR1_NWRP_SHIFT (16) /* Bits 16-23: Not write protect (high bank) */
# define FLASH_OPTCR1_NWRP_MASK (0xff << FLASH_OPTCR_NWRP_SHIFT)
#endif
diff --git a/arch/arm/src/stm32/chip/stm32f30xxx_syscfg.h b/arch/arm/src/stm32/chip/stm32f30xxx_syscfg.h
index 1f19e74dcc8444fd04a6ab64577cb1f15869d100..a4bf5d184cacd81ea44f89bec69c6ff88203dcef 100644
--- a/arch/arm/src/stm32/chip/stm32f30xxx_syscfg.h
+++ b/arch/arm/src/stm32/chip/stm32f30xxx_syscfg.h
@@ -94,7 +94,7 @@
#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_DAC2_DMARMP (1 << 14) /* Bit 14: DAC channel2 DMA remap */
-#define SYSCFG_CFGR1_I2C_PBXFMP_SHIFT (0) /* Bits 16-19: Fast Mode Plus (FM+) driving capability */
+#define SYSCFG_CFGR1_I2C_PBXFMP_SHIFT (16) /* 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 */
diff --git a/arch/arm/src/stm32/chip/stm32f33xxx_adc.h b/arch/arm/src/stm32/chip/stm32f33xxx_adc.h
index ddfbd97d1f208c104233d47d3e96cd7f7309f577..b6609d08280e3f16d5976b019ab384b0ef22055e 100644
--- a/arch/arm/src/stm32/chip/stm32f33xxx_adc.h
+++ b/arch/arm/src/stm32/chip/stm32f33xxx_adc.h
@@ -49,13 +49,13 @@
* Pre-processor Definitions
****************************************************************************************************/
-#define STM32_ADC1_BASE_OFFSET 0x0000
-#define STM32_ADC2_BASE_OFFSET 0x0100
-#define STM32_ADC12_BASE_OFFSET 0x0300
+#define STM32_ADC1_OFFSET 0x0000
+#define STM32_ADC2_OFFSET 0x0100
+#define STM32_ADC12_CMN_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 */
+#define STM32_ADC1_BASE (STM32_ADC1_OFFSET+STM32_ADC12_BASE) /* ADC1 Master ADC */
+#define STM32_ADC2_BASE (STM32_ADC2_OFFSET+STM32_ADC12_BASE) /* ADC2 Slave ADC */
+#define STM32_ADC12_CMN_BASE (STM32_ADC12_CMN_OFFSET+STM32_ADC12_BASE) /* ADC1, ADC2 common */
/* Register Offsets *********************************************************************************/
@@ -151,9 +151,9 @@
#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)
+#define STM32_ADC12_CSR (STM32_ADC12_CMN_BASE+STM32_ADC_CSR_OFFSET)
+#define STM32_ADC12_CCR (STM32_ADC12_CMN_BASE+STM32_ADC_CCR_OFFSET)
+#define STM32_ADC12_CDR (STM32_ADC12_CMN_BASE+STM32_ADC_CDR_OFFSET)
/* Register Bitfield Definitions ********************************************************************/
/* ADC interrupt and status register (ISR) and ADC interrupt enable register (IER) */
diff --git a/arch/arm/src/stm32/chip/stm32f33xxx_comp.h b/arch/arm/src/stm32/chip/stm32f33xxx_comp.h
index a0803ea04bf7984ecffc3e71f7aec2a3c088a76b..0e83a1c965c3ea208af592b7bedadec2e63a0353 100644
--- a/arch/arm/src/stm32/chip/stm32f33xxx_comp.h
+++ b/arch/arm/src/stm32/chip/stm32f33xxx_comp.h
@@ -72,7 +72,8 @@
# 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_PA4 (4 << COMP_CSR_INMSEL_SHIFT) /* 0100: PA4 or */
+# define COMP_CSR_INMSEL_DAC1CH1 (4 << COMP_CSR_INMSEL_SHIFT) /* 0100: DAC1_CH1 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) */
@@ -87,32 +88,32 @@
/* 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_T1OCC (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 COMP6_CSR_OUTSEL_T2OCC (8 << COMP_CSR_INMSEL_SHIFT) /* 1000: Timer 2 OCREF CLR input (COMP6 only) */
+# define COMP2_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_T15OCC (10 << COMP_CSR_INMSEL_SHIFT) /* 1010: Timer 15 OCREF_CLR input (COMP4 only) */
+# define COMP_CSR_OUTSEL_T16CAP1 (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) */
+#define COMP_CSR_BLANKING_SHIFT (18) /* Bit 18-20: comparator output blanking source */
+#define COMP_CSR_BLANKING_MASK (7 << COMP_CSR_BLANKING_SHIFT)
+# define COMP_CSR_BLANKING_DIS (0 << COMP_CSR_BLANKING_SHIFT) /* 000: No blanking */
+# define COMP_CSR_BLANKING_T1OC5 (1 << COMP_CSR_BLANKING_SHIFT) /* 001: TIM1 OC5 as blanking source (COMP2 only) */
+# define COMP_CSR_BLANKING_T3OC4 (1 << COMP_CSR_BLANKING_SHIFT) /* 001: TIM3 OC4 as blanking source (COMP4 only) */
+# define COMP_CSR_BLANKING_T2OC3 (2 << COMP_CSR_BLANKING_SHIFT) /* 010: TIM2 OC3 as blanking source (COMP2 only) */
+# define COMP_CSR_BLANKING_T3OC3 (3 << COMP_CSR_BLANKING_SHIFT) /* 011: TIM3 OC3 as blanking source (COMP2 only) */
+# define COMP_CSR_BLANKING_T15OC1 (3 << COMP_CSR_BLANKING_SHIFT) /* 011: TIM15 OC1 as blanking source (COMP4 only) */
+# define COMP_CSR_BLANKING_T2OC4 (3 << COMP_CSR_BLANKING_SHIFT) /* 011: TIM2 OC4 as blanking source (COMP6 only) */
+# define COMP_CSR_BLANKING_T15OC2 (4 << COMP_CSR_BLANKING_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 */
diff --git a/arch/arm/src/stm32/chip/stm32f33xxx_dma.h b/arch/arm/src/stm32/chip/stm32f33xxx_dma.h
new file mode 100644
index 0000000000000000000000000000000000000000..c30bcb0472ca735c9b2b113be4bbb280e32ca220
--- /dev/null
+++ b/arch/arm/src/stm32/chip/stm32f33xxx_dma.h
@@ -0,0 +1,366 @@
+/************************************************************************************
+ * arch/arm/src/stm32/chip/stm32f33xxx_dma.h
+ *
+ * Copyright (C) 2017 Gregory Nutt. All rights reserved.
+ * Authors: Gregory Nutt
+ * 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_DMA_H
+#define __ARCH_ARM_SRC_STM32_CHIP_STM32F33XXX_DMA_H
+
+/************************************************************************************
+ * Pre-processor Definitions
+ ************************************************************************************/
+
+/* 12 Channels Total: 7 DMA1 Channels(1-7) and 5 DMA2 channels (1-5) */
+
+#define DMA1 0
+#define DMA2 1
+#define DMA3 2
+#define DMA4 3
+#define DMA5 4
+#define DMA6 5
+#define DMA7 6
+
+/* Register Offsets *****************************************************************/
+
+#define STM32_DMA_ISR_OFFSET 0x0000 /* DMA interrupt status register */
+#define STM32_DMA_IFCR_OFFSET 0x0004 /* DMA interrupt flag clear register */
+
+#define STM32_DMACHAN_OFFSET(n) (0x0014*(n))
+#define STM32_DMACHAN1_OFFSET 0x0000
+#define STM32_DMACHAN2_OFFSET 0x0014
+#define STM32_DMACHAN3_OFFSET 0x0028
+#define STM32_DMACHAN4_OFFSET 0x003c
+#define STM32_DMACHAN5_OFFSET 0x0050
+#define STM32_DMACHAN6_OFFSET 0x0064
+#define STM32_DMACHAN7_OFFSET 0x0078
+
+#define STM32_DMACHAN_CCR_OFFSET 0x0008 /* DMA channel configuration register */
+#define STM32_DMACHAN_CNDTR_OFFSET 0x000c /* DMA channel number of data register */
+#define STM32_DMACHAN_CPAR_OFFSET 0x0010 /* DMA channel peripheral address register */
+#define STM32_DMACHAN_CMAR_OFFSET 0x0014 /* DMA channel 1 memory address register */
+
+#define STM32_DMA_CCR_OFFSET(n) (STM32_DMACHAN_CCR_OFFSET+STM32_DMACHAN_OFFSET(n))
+#define STM32_DMA_CNDTR_OFFSET(n) (STM32_DMACHAN_CNDTR_OFFSET+STM32_DMACHAN_OFFSET(n))
+#define STM32_DMA_CPAR_OFFSET(n) (STM32_DMACHAN_CPAR_OFFSET+STM32_DMACHAN_OFFSET(n))
+#define STM32_DMA_CMAR_OFFSET(n) (STM32_DMACHAN_CMAR_OFFSET+STM32_DMACHAN_OFFSET(n))
+
+#define STM32_DMA_CCR1_OFFSET 0x0008 /* DMA channel 1 configuration register */
+#define STM32_DMA_CCR2_OFFSET 0x001c /* DMA channel 2 configuration register */
+#define STM32_DMA_CCR3_OFFSET 0x0030 /* DMA channel 3 configuration register */
+#define STM32_DMA_CCR4_OFFSET 0x0044 /* DMA channel 4 configuration register */
+#define STM32_DMA_CCR5_OFFSET 0x0058 /* DMA channel 5 configuration register */
+#define STM32_DMA_CCR6_OFFSET 0x006c /* DMA channel 6 configuration register */
+#define STM32_DMA_CCR7_OFFSET 0x0080 /* DMA channel 7 configuration register */
+
+#define STM32_DMA_CNDTR1_OFFSET 0x000c /* DMA channel 1 number of data register */
+#define STM32_DMA_CNDTR2_OFFSET 0x0020 /* DMA channel 2 number of data register */
+#define STM32_DMA_CNDTR3_OFFSET 0x0034 /* DMA channel 3 number of data register */
+#define STM32_DMA_CNDTR4_OFFSET 0x0048 /* DMA channel 4 number of data register */
+#define STM32_DMA_CNDTR5_OFFSET 0x005c /* DMA channel 5 number of data register */
+#define STM32_DMA_CNDTR6_OFFSET 0x0070 /* DMA channel 6 number of data register */
+#define STM32_DMA_CNDTR7_OFFSET 0x0084 /* DMA channel 7 number of data register */
+
+#define STM32_DMA_CPAR1_OFFSET 0x0010 /* DMA channel 1 peripheral address register */
+#define STM32_DMA_CPAR2_OFFSET 0x0024 /* DMA channel 2 peripheral address register */
+#define STM32_DMA_CPAR3_OFFSET 0x0038 /* DMA channel 3 peripheral address register */
+#define STM32_DMA_CPAR4_OFFSET 0x004c /* DMA channel 4 peripheral address register */
+#define STM32_DMA_CPAR5_OFFSET 0x0060 /* DMA channel 5 peripheral address register */
+#define STM32_DMA_CPAR6_OFFSET 0x0074 /* DMA channel 6 peripheral address register */
+#define STM32_DMA_CPAR7_OFFSET 0x0088 /* DMA channel 7 peripheral address register */
+
+#define STM32_DMA_CMAR1_OFFSET 0x0014 /* DMA channel 1 memory address register */
+#define STM32_DMA_CMAR2_OFFSET 0x0028 /* DMA channel 2 memory address register */
+#define STM32_DMA_CMAR3_OFFSET 0x003c /* DMA channel 3 memory address register */
+#define STM32_DMA_CMAR4_OFFSET 0x0050 /* DMA channel 4 memory address register */
+#define STM32_DMA_CMAR5_OFFSET 0x0064 /* DMA channel 5 memory address register */
+#define STM32_DMA_CMAR6_OFFSET 0x0078 /* DMA channel 6 memory address register */
+#define STM32_DMA_CMAR7_OFFSET 0x008c /* DMA channel 7 memory address register */
+
+/* Register Addresses ***************************************************************/
+
+#define STM32_DMA1_ISRC (STM32_DMA1_BASE+STM32_DMA_ISR_OFFSET)
+#define STM32_DMA1_IFCR (STM32_DMA1_BASE+STM32_DMA_IFCR_OFFSET)
+
+#define STM32_DMA1_CCR(n) (STM32_DMA1_BASE+STM32_DMA_CCR_OFFSET(n))
+#define STM32_DMA1_CCR1 (STM32_DMA1_BASE+STM32_DMA_CCR1_OFFSET)
+#define STM32_DMA1_CCR2 (STM32_DMA1_BASE+STM32_DMA_CCR2_OFFSET)
+#define STM32_DMA1_CCR3 (STM32_DMA1_BASE+STM32_DMA_CCR3_OFFSET)
+#define STM32_DMA1_CCR4 (STM32_DMA1_BASE+STM32_DMA_CCR4_OFFSET)
+#define STM32_DMA1_CCR5 (STM32_DMA1_BASE+STM32_DMA_CCR5_OFFSET)
+#define STM32_DMA1_CCR6 (STM32_DMA1_BASE+STM32_DMA_CCR6_OFFSET)
+#define STM32_DMA1_CCR7 (STM32_DMA1_BASE+STM32_DMA_CCR7_OFFSET)
+
+#define STM32_DMA1_CNDTR(n) (STM32_DMA1_BASE+STM32_DMA_CNDTR_OFFSET(n))
+#define STM32_DMA1_CNDTR1 (STM32_DMA1_BASE+STM32_DMA_CNDTR1_OFFSET)
+#define STM32_DMA1_CNDTR2 (STM32_DMA1_BASE+STM32_DMA_CNDTR2_OFFSET)
+#define STM32_DMA1_CNDTR3 (STM32_DMA1_BASE+STM32_DMA_CNDTR3_OFFSET)
+#define STM32_DMA1_CNDTR4 (STM32_DMA1_BASE+STM32_DMA_CNDTR4_OFFSET)
+#define STM32_DMA1_CNDTR5 (STM32_DMA1_BASE+STM32_DMA_CNDTR5_OFFSET)
+#define STM32_DMA1_CNDTR6 (STM32_DMA1_BASE+STM32_DMA_CNDTR6_OFFSET)
+#define STM32_DMA1_CNDTR7 (STM32_DMA1_BASE+STM32_DMA_CNDTR7_OFFSET)
+
+#define STM32_DMA1_CPAR(n) (STM32_DMA1_BASE+STM32_DMA_CPAR_OFFSET(n))
+#define STM32_DMA1_CPAR1 (STM32_DMA1_BASE+STM32_DMA_CPAR1_OFFSET)
+#define STM32_DMA1_CPAR2 (STM32_DMA1_BASE+STM32_DMA_CPAR2_OFFSET)
+#define STM32_DMA1_CPAR3 (STM32_DMA1_BASE+STM32_DMA_CPAR3_OFFSET)
+#define STM32_DMA1_CPAR4 (STM32_DMA1_BASE+STM32_DMA_CPAR4_OFFSET)
+#define STM32_DMA1_CPAR5 (STM32_DMA1_BASE+STM32_DMA_CPAR5_OFFSET)
+#define STM32_DMA1_CPAR6 (STM32_DMA1_BASE+STM32_DMA_CPAR6_OFFSET)
+#define STM32_DMA1_CPAR7 (STM32_DMA1_BASE+STM32_DMA_CPAR7_OFFSET)
+
+#define STM32_DMA1_CMAR(n) (STM32_DMA1_BASE+STM32_DMA_CMAR_OFFSET(n))
+#define STM32_DMA1_CMAR1 (STM32_DMA1_BASE+STM32_DMA_CMAR1_OFFSET)
+#define STM32_DMA1_CMAR2 (STM32_DMA1_BASE+STM32_DMA_CMAR2_OFFSET)
+#define STM32_DMA1_CMAR3 (STM32_DMA1_BASE+STM32_DMA_CMAR3_OFFSET)
+#define STM32_DMA1_CMAR4 (STM32_DMA1_BASE+STM32_DMA_CMAR4_OFFSET)
+#define STM32_DMA1_CMAR5 (STM32_DMA1_BASE+STM32_DMA_CMAR5_OFFSET)
+#define STM32_DMA1_CMAR6 (STM32_DMA1_BASE+STM32_DMA_CMAR6_OFFSET)
+#define STM32_DMA1_CMAR7 (STM32_DMA1_BASE+STM32_DMA_CMAR7_OFFSET)
+
+#define STM32_DMA2_ISRC (STM32_DMA2_BASE+STM32_DMA_ISR_OFFSET)
+#define STM32_DMA2_IFCR (STM32_DMA2_BASE+STM32_DMA_IFCR_OFFSET)
+
+#define STM32_DMA2_CCR(n) (STM32_DMA2_BASE+STM32_DMA_CCR_OFFSET(n))
+#define STM32_DMA2_CCR1 (STM32_DMA2_BASE+STM32_DMA_CCR1_OFFSET)
+#define STM32_DMA2_CCR2 (STM32_DMA2_BASE+STM32_DMA_CCR2_OFFSET)
+#define STM32_DMA2_CCR3 (STM32_DMA2_BASE+STM32_DMA_CCR3_OFFSET)
+#define STM32_DMA2_CCR4 (STM32_DMA2_BASE+STM32_DMA_CCR4_OFFSET)
+#define STM32_DMA2_CCR5 (STM32_DMA2_BASE+STM32_DMA_CCR5_OFFSET)
+
+#define STM32_DMA2_CNDTR(n) (STM32_DMA2_BASE+STM32_DMA_CNDTR_OFFSET(n))
+#define STM32_DMA2_CNDTR1 (STM32_DMA2_BASE+STM32_DMA_CNDTR1_OFFSET)
+#define STM32_DMA2_CNDTR2 (STM32_DMA2_BASE+STM32_DMA_CNDTR2_OFFSET)
+#define STM32_DMA2_CNDTR3 (STM32_DMA2_BASE+STM32_DMA_CNDTR3_OFFSET)
+#define STM32_DMA2_CNDTR4 (STM32_DMA2_BASE+STM32_DMA_CNDTR4_OFFSET)
+#define STM32_DMA2_CNDTR5 (STM32_DMA2_BASE+STM32_DMA_CNDTR5_OFFSET)
+
+#define STM32_DMA2_CPAR(n) (STM32_DMA2_BASE+STM32_DMA_CPAR_OFFSET(n))
+#define STM32_DMA2_CPAR1 (STM32_DMA2_BASE+STM32_DMA_CPAR1_OFFSET)
+#define STM32_DMA2_CPAR2 (STM32_DMA2_BASE+STM32_DMA_CPAR2_OFFSET)
+#define STM32_DMA2_CPAR3 (STM32_DMA2_BASE+STM32_DMA_CPAR3_OFFSET)
+#define STM32_DMA2_CPAR4 (STM32_DMA2_BASE+STM32_DMA_CPAR4_OFFSET)
+#define STM32_DMA2_CPAR5 (STM32_DMA2_BASE+STM32_DMA_CPAR5_OFFSET)
+
+#define STM32_DMA2_CMAR(n) (STM32_DMA2_BASE+STM32_DMA_CMAR_OFFSET(n))
+#define STM32_DMA2_CMAR1 (STM32_DMA2_BASE+STM32_DMA_CMAR1_OFFSET)
+#define STM32_DMA2_CMAR2 (STM32_DMA2_BASE+STM32_DMA_CMAR2_OFFSET)
+#define STM32_DMA2_CMAR3 (STM32_DMA2_BASE+STM32_DMA_CMAR3_OFFSET)
+#define STM32_DMA2_CMAR4 (STM32_DMA2_BASE+STM32_DMA_CMAR4_OFFSET)
+#define STM32_DMA2_CMAR5 (STM32_DMA2_BASE+STM32_DMA_CMAR5_OFFSET)
+
+/* Register Bitfield Definitions ****************************************************/
+
+#define DMA_CHAN_SHIFT(n) ((n) << 2)
+#define DMA_CHAN_MASK 0x0f
+#define DMA_CHAN_GIF_BIT (1 << 0) /* Bit 0: Channel Global interrupt flag */
+#define DMA_CHAN_TCIF_BIT (1 << 1) /* Bit 1: Channel Transfer Complete flag */
+#define DMA_CHAN_HTIF_BIT (1 << 2) /* Bit 2: Channel Half Transfer flag */
+#define DMA_CHAN_TEIF_BIT (1 << 3) /* Bit 3: Channel Transfer Error flag */
+
+/* DMA interrupt status register */
+
+#define DMA_ISR_CHAN_SHIFT(n) DMA_CHAN_SHIFT(n)
+#define DMA_ISR_CHAN_MASK(n) (DMA_CHAN_MASK << DMA_ISR_CHAN_SHIFT(n))
+#define DMA_ISR_CHAN1_SHIFT (0) /* Bits 3-0: DMA Channel 1 interrupt status */
+#define DMA_ISR_CHAN1_MASK (DMA_CHAN_MASK << DMA_ISR_CHAN1_SHIFT)
+#define DMA_ISR_CHAN2_SHIFT (4) /* Bits 7-4: DMA Channel 2 interrupt status */
+#define DMA_ISR_CHAN2_MASK (DMA_CHAN_MASK << DMA_ISR_CHAN2_SHIFT)
+#define DMA_ISR_CHAN3_SHIFT (8) /* Bits 11-8: DMA Channel 3 interrupt status */
+#define DMA_ISR_CHAN3_MASK (DMA_CHAN_MASK << DMA_ISR_CHAN3_SHIFT)
+#define DMA_ISR_CHAN4_SHIFT (12) /* Bits 15-12: DMA Channel 4 interrupt status */
+#define DMA_ISR_CHAN4_MASK (DMA_CHAN_MASK << DMA_ISR_CHAN4_SHIFT)
+#define DMA_ISR_CHAN5_SHIFT (16) /* Bits 19-16: DMA Channel 5 interrupt status */
+#define DMA_ISR_CHAN5_MASK (DMA_CHAN_MASK << DMA_ISR_CHAN5_SHIFT)
+#define DMA_ISR_CHAN6_SHIFT (20) /* Bits 23-20: DMA Channel 6 interrupt status */
+#define DMA_ISR_CHAN6_MASK (DMA_CHAN_MASK << DMA_ISR_CHAN6_SHIFT)
+#define DMA_ISR_CHAN7_SHIFT (24) /* Bits 27-24: DMA Channel 7 interrupt status */
+#define DMA_ISR_CHAN7_MASK (DMA_CHAN_MASK << DMA_ISR_CHAN7_SHIFT)
+
+#define DMA_ISR_GIF(n) (DMA_CHAN_GIF_BIT << DMA_ISR_CHAN_SHIFT(n))
+#define DMA_ISR_TCIF(n) (DMA_CHAN_TCIF_BIT << DMA_ISR_CHAN_SHIFT(n))
+#define DMA_ISR_HTIF(n) (DMA_CHAN_HTIF_BIT << DMA_ISR_CHAN_SHIFT(n))
+#define DMA_ISR_TEIF(n) (DMA_CHAN_TEIF_BIT << DMA_ISR_CHAN_SHIFT(n))
+
+/* DMA interrupt flag clear register */
+
+#define DMA_IFCR_CHAN_SHIFT(n) DMA_CHAN_SHIFT(n)
+#define DMA_IFCR_CHAN_MASK(n) (DMA_CHAN_MASK << DMA_IFCR_CHAN_SHIFT(n))
+#define DMA_IFCR_CHAN1_SHIFT (0) /* Bits 3-0: DMA Channel 1 interrupt flag clear */
+#define DMA_IFCR_CHAN1_MASK (DMA_CHAN_MASK << DMA_IFCR_CHAN1_SHIFT)
+#define DMA_IFCR_CHAN2_SHIFT (4) /* Bits 7-4: DMA Channel 2 interrupt flag clear */
+#define DMA_IFCR_CHAN2_MASK (DMA_CHAN_MASK << DMA_IFCR_CHAN2_SHIFT)
+#define DMA_IFCR_CHAN3_SHIFT (8) /* Bits 11-8: DMA Channel 3 interrupt flag clear */
+#define DMA_IFCR_CHAN3_MASK (DMA_CHAN_MASK << DMA_IFCR_CHAN3_SHIFT)
+#define DMA_IFCR_CHAN4_SHIFT (12) /* Bits 15-12: DMA Channel 4 interrupt flag clear */
+#define DMA_IFCR_CHAN4_MASK (DMA_CHAN_MASK << DMA_IFCR_CHAN4_SHIFT)
+#define DMA_IFCR_CHAN5_SHIFT (16) /* Bits 19-16: DMA Channel 5 interrupt flag clear */
+#define DMA_IFCR_CHAN5_MASK (DMA_CHAN_MASK << DMA_IFCR_CHAN5_SHIFT)
+#define DMA_IFCR_CHAN6_SHIFT (20) /* Bits 23-20: DMA Channel 6 interrupt flag clear */
+#define DMA_IFCR_CHAN6_MASK (DMA_CHAN_MASK << DMA_IFCR_CHAN6_SHIFT)
+#define DMA_IFCR_CHAN7_SHIFT (24) /* Bits 27-24: DMA Channel 7 interrupt flag clear */
+#define DMA_IFCR_CHAN7_MASK (DMA_CHAN_MASK << DMA_IFCR_CHAN7_SHIFT)
+#define DMA_IFCR_ALLCHANNELS (0x0fffffff)
+
+#define DMA_IFCR_CGIF(n) (DMA_CHAN_GIF_BIT << DMA_IFCR_CHAN_SHIFT(n))
+#define DMA_IFCR_CTCIF(n) (DMA_CHAN_TCIF_BIT << DMA_IFCR_CHAN_SHIFT(n))
+#define DMA_IFCR_CHTIF(n) (DMA_CHAN_HTIF_BIT << DMA_IFCR_CHAN_SHIFT(n))
+#define DMA_IFCR_CTEIF(n) (DMA_CHAN_TEIF_BIT << DMA_IFCR_CHAN_SHIFT(n))
+
+/* DMA channel configuration register */
+
+#define DMA_CCR_EN (1 << 0) /* Bit 0: Channel enable */
+#define DMA_CCR_TCIE (1 << 1) /* Bit 1: Transfer complete interrupt enable */
+#define DMA_CCR_HTIE (1 << 2) /* Bit 2: Half Transfer interrupt enable */
+#define DMA_CCR_TEIE (1 << 3) /* Bit 3: Transfer error interrupt enable */
+#define DMA_CCR_DIR (1 << 4) /* Bit 4: Data transfer direction */
+#define DMA_CCR_CIRC (1 << 5) /* Bit 5: Circular mode */
+#define DMA_CCR_PINC (1 << 6) /* Bit 6: Peripheral increment mode */
+#define DMA_CCR_MINC (1 << 7) /* Bit 7: Memory increment mode */
+#define DMA_CCR_PSIZE_SHIFT (8) /* Bits 8-9: Peripheral size */
+#define DMA_CCR_PSIZE_MASK (3 << DMA_CCR_PSIZE_SHIFT)
+# define DMA_CCR_PSIZE_8BITS (0 << DMA_CCR_PSIZE_SHIFT) /* 00: 8-bits */
+# define DMA_CCR_PSIZE_16BITS (1 << DMA_CCR_PSIZE_SHIFT) /* 01: 16-bits */
+# define DMA_CCR_PSIZE_32BITS (2 << DMA_CCR_PSIZE_SHIFT) /* 10: 32-bits */
+#define DMA_CCR_MSIZE_SHIFT (10) /* Bits 10-11: Memory size */
+#define DMA_CCR_MSIZE_MASK (3 << DMA_CCR_MSIZE_SHIFT)
+# define DMA_CCR_MSIZE_8BITS (0 << DMA_CCR_MSIZE_SHIFT) /* 00: 8-bits */
+# define DMA_CCR_MSIZE_16BITS (1 << DMA_CCR_MSIZE_SHIFT) /* 01: 16-bits */
+# define DMA_CCR_MSIZE_32BITS (2 << DMA_CCR_MSIZE_SHIFT) /* 10: 32-bits */
+#define DMA_CCR_PL_SHIFT (12) /* Bits 12-13: Channel Priority level */
+#define DMA_CCR_PL_MASK (3 << DMA_CCR_PL_SHIFT)
+# define DMA_CCR_PRILO (0 << DMA_CCR_PL_SHIFT) /* 00: Low */
+# define DMA_CCR_PRIMED (1 << DMA_CCR_PL_SHIFT) /* 01: Medium */
+# define DMA_CCR_PRIHI (2 << DMA_CCR_PL_SHIFT) /* 10: High */
+# define DMA_CCR_PRIVERYHI (3 << DMA_CCR_PL_SHIFT) /* 11: Very high */
+#define DMA_CCR_MEM2MEM (1 << 14) /* Bit 14: Memory to memory mode */
+
+#define DMA_CCR_ALLINTS (DMA_CCR_TEIE|DMA_CCR_HTIE|DMA_CCR_TCIE)
+
+/* DMA channel number of data register */
+
+#define DMA_CNDTR_NDT_SHIFT (0) /* Bits 15-0: Number of data to Transfer */
+#define DMA_CNDTR_NDT_MASK (0xffff << DMA_CNDTR_NDT_SHIFT)
+
+/* DMA Channel mapping. Each DMA channel has a mapping to several possible
+ * sources/sinks of data. The requests from peripherals assigned to a channel
+ * are simply OR'ed together before entering the DMA block. This means that only
+ * one request on a given channel can be enabled at once.
+ *
+ * Alternative DMA channel 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.
+ */
+
+#define STM32_DMA1_CHAN1 (0)
+#define STM32_DMA1_CHAN2 (1)
+#define STM32_DMA1_CHAN3 (2)
+#define STM32_DMA1_CHAN4 (3)
+#define STM32_DMA1_CHAN5 (4)
+#define STM32_DMA1_CHAN6 (5)
+#define STM32_DMA1_CHAN7 (6)
+
+#define STM32_DMA2_CHAN1 (7)
+#define STM32_DMA2_CHAN2 (8)
+#define STM32_DMA2_CHAN3 (9)
+#define STM32_DMA2_CHAN4 (10)
+#define STM32_DMA2_CHAN5 (11)
+
+#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
+
+#endif /* __ARCH_ARM_SRC_STM32_CHIP_STM32F33XXX_DMA_H */
diff --git a/arch/arm/src/stm32/chip/stm32f33xxx_hrtim.h b/arch/arm/src/stm32/chip/stm32f33xxx_hrtim.h
index fc22deeb25a612c243118a5e6a0f6e16afbd8993..31438fe30e22a239f82001af1e4da882aa79c22d 100644
--- a/arch/arm/src/stm32/chip/stm32f33xxx_hrtim.h
+++ b/arch/arm/src/stm32/chip/stm32f33xxx_hrtim.h
@@ -67,310 +67,190 @@
/* 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 Offsets Common for Master Timer and Timer X */
+
+#define STM32_HRTIM_TIM_CR_OFFSET 0x0000 /* HRTIM Timer Control Register */
+#define STM32_HRTIM_TIM_ISR_OFFSET 0x0004 /* HRTIM Timer Interrupt Status Register */
+#define STM32_HRTIM_TIM_ICR_OFFSET 0x0008 /* HRTIM Timer Interrupt Clear Register */
+#define STM32_HRTIM_TIM_DIER_OFFSET 0x000C /* HRTIM Timer DMA/Interrupt Enable Register */
+#define STM32_HRTIM_TIM_CNTR_OFFSET 0x0010 /* HRTIM Timer Counter Register */
+#define STM32_HRTIM_TIM_PER_OFFSET 0x0014 /* HRTIM Timer Period Register */
+#define STM32_HRTIM_TIM_REPR_OFFSET 0x0018 /* HRTIM Timer Repetition Register */
+#define STM32_HRTIM_TIM_CMP1R_OFFSET 0x001C /* HRTIM Timer Compare 1 Register */
+#define STM32_HRTIM_TIM_CMP2R_OFFSET 0x0024 /* HRTIM Timer Compare 2 Register */
+#define STM32_HRTIM_TIM_CMP3R_OFFSET 0x0028 /* HRTIM Timer Compare 3 Register */
+#define STM32_HRTIM_TIM_CMP4R_OFFSET 0x002C /* HRTIM Timer Compare 4 Register */
+
+/* Register offsets Specific for Timer A-E */
+
+#define STM32_HRTIM_TIM_CMP1CR_OFFSET 0x0020 /* HRTIM Timer Compare 1 Compound Register */
+#define STM32_HRTIM_TIM_CPT1R_OFFSET 0x0030 /* HRTIM Timer Capture 1 Register */
+#define STM32_HRTIM_TIM_CPT2R_OFFSET 0x0034 /* HRTIM Timer Capture 2 Register */
+#define STM32_HRTIM_TIM_DTR_OFFSET 0x0038 /* HRTIM Timer Deadtime Register */
+#define STM32_HRTIM_TIM_SET1R_OFFSET 0x003C /* HRTIM Timer Output1 Set Register */
+#define STM32_HRTIM_TIM_RST1R_OFFSET 0x0040 /* HRTIM Timer Output1 Reset Register */
+#define STM32_HRTIM_TIM_SET2R_OFFSET 0x0044 /* HRTIM Timer Output2 Set Register */
+#define STM32_HRTIM_TIM_RST2R_OFFSET 0x0048 /* HRTIM Timer Output2 Reset Register */
+#define STM32_HRTIM_TIM_EEFR1_OFFSET 0x004C /* HRTIM Timer External Event Filtering Register 1 */
+#define STM32_HRTIM_TIM_EEFR2_OFFSET 0x0050 /* HRTIM Timer External Event Filtering Register 2 */
+#define STM32_HRTIM_TIM_RSTR_OFFSET 0x0054 /* HRTIM Timer Reset Register */
+#define STM32_HRTIM_TIM_CHPR_OFFSET 0x0058 /* HRTIM Timer Chopper Register */
+#define STM32_HRTIM_TIM_CPT1CR_OFFSET 0x005C /* HRTIM Timer Capture 1 Control Register */
+#define STM32_HRTIM_TIM_CPT2CR_OFFSET 0x0060 /* HRTIM Timer Capture 2 Control Register */
+#define STM32_HRTIM_TIM_OUTR_OFFSET 0x0064 /* HRTIM Timer Output Register */
+#define STM32_HRTIM_TIM_FLTR_OFFSET 0x0068 /* HRTIM Timer 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 */
+#define STM32_HRTIM_CMN_CR1_OFFSET 0x0000 /* HRTIM Control Register 1 */
+#define STM32_HRTIM_CMN_CR2_OFFSET 0x0004 /* HRTIM Control Register 2 */
+#define STM32_HRTIM_CMN_ISR_OFFSET 0x0008 /* HRTIM Interrupt Status Register */
+#define STM32_HRTIM_CMN_ICR_OFFSET 0x000C /* HRTIM Interrupt Clear Register */
+#define STM32_HRTIM_CMN_IER_OFFSET 0x0010 /* HRTIM Interrupt Enable Register */
+#define STM32_HRTIM_CMN_OENR_OFFSET 0x0014 /* HRTIM Output Enable Register */
+#define STM32_HRTIM_CMN_DISR_OFFSET 0x0018 /* HRTIM Output Disable Register */
+#define STM32_HRTIM_CMN_ODSR_OFFSET 0x001C /* HRTIM Output Disable Status Register */
+#define STM32_HRTIM_CMN_BMCR_OFFSET 0x0020 /* HRTIM Burst Mode Control Register */
+#define STM32_HRTIM_CMN_BMTRGR_OFFSET 0x0024 /* HRTIM Burst Mode Trigger Register */
+#define STM32_HRTIM_CMN_BMCMPR_OFFSET 0x0028 /* HRTIM Burst Mode Compare Register */
+#define STM32_HRTIM_CMN_BMPER_OFFSET 0x002C /* HRTIM Burst Mode Period Register */
+#define STM32_HRTIM_CMN_EECR1_OFFSET 0x0030 /* HRTIM Timer External Event Control Register 1 */
+#define STM32_HRTIM_CMN_EECR2_OFFSET 0x0034 /* HRTIM Timer External Event Control Register 2 */
+#define STM32_HRTIM_CMN_EECR3_OFFSET 0x0038 /* HRTIM Timer External Event Control Register 3 */
+#define STM32_HRTIM_CMN_ADC1R_OFFSET 0x003C /* HRTIM ADC Trigger 1 Register */
+#define STM32_HRTIM_CMN_ADC2R_OFFSET 0x0040 /* HRTIM ADC Trigger 2 Register */
+#define STM32_HRTIM_CMN_ADC3R_OFFSET 0x0044 /* HRTIM ADC Trigger 3 Register */
+#define STM32_HRTIM_CMN_ADC4R_OFFSET 0x0048 /* HRTIM ADC Trigger 4 Register */
+#define STM32_HRTIM_CMN_DLLCR_OFFSET 0x004C /* HRTIM DLL Control Register */
+#define STM32_HRTIM_CMN_FLTINR1_OFFSET 0x0050 /* HRTIM Fault Input Register 1 */
+#define STM32_HRTIM_CMN_FLTINR2_OFFSET 0x0054 /* HRTIM Fault Input Register 2 */
+#define STM32_HRTIM_CMN_BDMUPDR_OFFSET 0x0058 /* HRTIM Master Timer Update Register */
+#define STM32_HRTIM_CMN_BDTAUPR_OFFSET 0x005C /* HRTIM Timer A Update Register */
+#define STM32_HRTIM_CMN_BDTBUPR_OFFSET 0x0060 /* HRTIM Timer B Update Register */
+#define STM32_HRTIM_CMN_BDTCUPR_OFFSET 0x0064 /* HRTIM Timer C Update Register */
+#define STM32_HRTIM_CMN_BDTDUPR_OFFSET 0x0068 /* HRTIM Timer D Update Register */
+#define STM32_HRTIM_CMN_BDTEUPR_OFFSET 0x006C /* HRTIM Timer E Update Register */
+#define STM32_HRTIM_CMN_BDMADR_OFFSET 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)
+/* remove ? */
+
+#define STM32_HRTIM1_TIMERA_CR (STM32_HRTIM_TIM_CR_OFFSET+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_ISR (STM32_HRTIM_TIM_ISR_OFFSET+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_ICR (STM32_HRTIM_TIM_ICR_OFFSET+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_DIER (STM32_HRTIM_TIM_DIER_OFFSET+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_CNTR (STM32_HRTIM_TIM_CNTR_OFFSET+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_PER (STM32_HRTIM_TIM_PER_OFFSET+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_REP (STM32_HRTIM_TIM_REP_OFFSET+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_CMP1R (STM32_HRTIM_TIM_CMP1R_OFFSET+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_CMP1CR (STM32_HRTIM_TIM_CMP1CR_OFFSET+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_CMP2R (STM32_HRTIM_TIM_CMP2R_OFFSET+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_CMP3R (STM32_HRTIM_TIM_CMP3R_OFFSET+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_CMP4R (STM32_HRTIM_TIM_CMP4R_OFFSET+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_CPT1R (STM32_HRTIM_TIM_CMPT1R_OFFSET+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_CPT2R (STM32_HRTIM_TIM_CMPT2R_OFFSET+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_DTR (STM32_HRTIM_TIM_DTR_OFFSET+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_SET1R (STM32_HRTIM_TIM_SET1R_OFFSET+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_RST1R (STM32_HRTIM_TIM_RST1R_OFFSET+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_SET2R (STM32_HRTIM_TIM_SET2R_OFFSET+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_RST2R (STM32_HRTIM_TIM_RST2R_OFFSET+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_EEFR1 (STM32_HRTIM_TIM_EEFR1_OFFSET+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_EEFR2 (STM32_HRTIM_TIM_EEFR2_OFFSET+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_RSTR (STM32_HRTIM_TIM_RSTR_OFFSET+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_CHPR (STM32_HRTIM_TIM_CHPR_OFFSET+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_CPT1CR (STM32_HRTIM_TIM_CPT1CR_OFFSET+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_CPT2CR (STM32_HRTIM_TIM_CPT2CR_OFFSET+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_OUTR (STM32_HRTIM_TIM_OUTR_OFFSET+STM32_HRTIM1_TIMERA_BASE)
+#define STM32_HRTIM1_TIMERA_FLTR (STM32_HRTIM_TIM_FLTR_OFFSET+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)
+#define STM32_HRTIM_CMN_CR1 (STM32_HRTIM_CMN_CR1_OFFSET+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_CR2 (STM32_HRTIM_CMN_CR2_OFFSET+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_ISR (STM32_HRTIM_CMN_ISR_OFFSET+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_ICR (STM32_HRTIM_CMN_ICR_OFFSET+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_IER (STM32_HRTIM_CMN_IER_OFFSET+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_OENR (STM32_HRTIM_CMN_OENR_OFFSET+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_DISR (STM32_HRTIM_CMN_DISR_OFFSET+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_ODSR (STM32_HRTIM_CMN_ODSR_OFFSET+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_BMCR (STM32_HRTIM_CMN_BMCR_OFFSET+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_BMTGR (STM32_HRTIM_CMN_BMTGR_OFFSET+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_BMCMPR (STM32_HRTIM_CMN_MBCMPR_OFFSET+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_BMPER (STM32_HRTIM_CMN_BMPER_OFFSET+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_EECR1 (STM32_HRTIM_CMN_EECR1_OFFSET+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_EECR2 (STM32_HRTIM_CMN_EECR2_OFFSET+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_EECR3 (STM32_HRTIM_CMN_EECR3_OFFSET+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_ADC1R (STM32_HRTIM_CMN_ADC1R_OFFSET+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_ADC2R (STM32_HRTIM_CMN_ADC2R_OFFSET+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_ADC3R (STM32_HRTIM_CMN_ADC3R_OFFSET+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_ADC4R (STM32_HRTIM_CMN_ADC4R_OFFSET+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_DLLCR (STM32_HRTIM_CMN_DLLCR_OFFSET+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_FLTINR1 (STM32_HRTIM_CMN_FTLINR1_OFFSET+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_FLTINR2 (STM32_HRTIM_CMN_FLTINR2_OFFSET+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_BDMUPDR (STM32_HRTIM_CMN_BDMUPDR_OFFSET+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_BDTAUPR (STM32_HRTIM_CMN_BDTAUPR_OFFSET+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_BDTBUPR (STM32_HRTIM_CMN_BDTBUR_OFFSET+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_BDTCUPR (STM32_HRTIM_CMN_BDTCUPR_OFFSET+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_BDTDUPR (STM32_HRTIM_CMN_BDTDUPR_OFFSET+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_BDTEUPR (STM32_HRTIM_CMN_BDTEUPR_OFFSET+STM32_HRTIM1_CMN_BASE)
+#define STM32_HRTIM_CMN_BDMADR (STM32_HRTIM_CMN_BDMADR_OFFSET+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 */
+/* Control Register Bits Common to Master Timer and Timer A-E */
+
+#define HRTIM_CMNCR_CKPSC_SHIFT 0 /* Bits 0-2: Clock prescaler */
+#define HRTIM_CMNCR_CKPSC_MASK (7 << HRTIM_CMNCR_CKPSC_SHIFT)
+# define HRTIM_CMNCR_CKPSC_NODIV (0 << HRTIM_CMNCR_CKPSC_SHIFT)
+# define HRTIM_CMNCR_CKPSC_d2 (1 << HRTIM_CMNCR_CKPSC_SHIFT)
+# define HRTIM_CMNCR_CKPSC_d4 (2 << HRTIM_CMNCR_CKPSC_SHIFT)
+# define HRTIM_CMNCR_CKPSC_d8 (3 << HRTIM_CMNCR_CKPSC_SHIFT)
+# define HRTIM_CMNCR_CKPSC_d16 (4 << HRTIM_CMNCR_CKPSC_SHIFT)
+# define HRTIM_CMNCR_CKPSC_d32 (5 << HRTIM_CMNCR_CKPSC_SHIFT)
+# define HRTIM_CMNCR_CKPSC_d64 (6 << HRTIM_CMNCR_CKPSC_SHIFT)
+# define HRTIM_CMNCR_CKPSC_d128 (7 << HRTIM_CMNCR_CKPSC_SHIFT)
+#define HRTIM_CMNCR_CONT (1 << 3) /* Bit 3: Continuous mode */
+#define HRTIM_CMNCR_RETRIG (1 << 4) /* Bit 4: Re-triggerable mode */
+#define HRTIM_CMNCR_HALF (1 << 5) /* Bit 5: Half mode */
+ /* Bits 6-9 differs */
+#define HRTIM_CMNCR_SYNCRST (1 << 10) /* Bit 10: Synchronization Resets Master */
+#define HRTIM_CMNCR_SYNCSTRTM (1 << 11) /* Bit 11: Synchronization Starts Master */
+ /* Bits 12-24 differs */
+#define HRTIM_CMNCR_DACSYNC_SHIFT 25 /* Bits 25-26: DAC Synchronization*/
+#define HRTIM_CMNCR_DACSYNC_MASK (3 << HRTIM_CMNCR_DACSYNC_SHIFT)
+# define HRTIM_CMNCR_DACSYNC_00 (0 << HRTIM_CMNCR_DACSYNC_SHIFT) /* 00: */
+# define HRTIM_CMNCR_DACSYNC_01 (1 << HRTIM_CMNCR_DACSYNC_SHIFT) /* 01: */
+# define HRTIM_CMNCR_DACSYNC_10 (2 << HRTIM_CMNCR_DACSYNC_SHIFT) /* 10: */
+# define HRTIM_CMNCR_DACSYNC_11 (3 << HRTIM_CMNCR_DACSYNC_SHIFT) /* 11: */
+#define HRTIM_CMNCR_PREEN (1 << 27) /* Bit 27: Preload enable */
+ /* Bits 29-31 differs */
+
+/* Control Register Bits specific to Master Timer */
+
+ /* Bits 0-5 common */
+ /* Bits 6-7 reserved */
+ /* Bits 10-11 common */
+#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_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_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 */
@@ -382,15 +262,10 @@
#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 */
+ /* Bits 22-24 reserved */
+ /* Bits 25-27 common */
#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_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 */
@@ -468,24 +343,11 @@
#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 */
+/* Timer A-E Control Register */
+
+ /* Bits 0-5 common */
+#define HRTIM_TIMCR_PSHPLL (1 << 6) /* Bit 6:Push-Pull mode enable */
+ /* Bits 10-11 common */
#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: */
@@ -506,13 +368,7 @@
#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 */
+ /* Bits 25-27 common */
#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: */
@@ -838,7 +694,7 @@
# 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_3 (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 */
diff --git a/arch/arm/src/stm32/chip/stm32f33xxx_opamp.h b/arch/arm/src/stm32/chip/stm32f33xxx_opamp.h
index a6940bb0550feaa2f295490e6cc450561afef149..3a254af3a806deab87e38e2f85d65c674bc0f3d6 100644
--- a/arch/arm/src/stm32/chip/stm32f33xxx_opamp.h
+++ b/arch/arm/src/stm32/chip/stm32f33xxx_opamp.h
@@ -54,7 +54,7 @@
/* Register Addresses *******************************************************************************/
-#define STM32_OPAMP2_CSR (STM32_OPAMP2_BASE+STM32_OPAMP2_CSR_OFFSET)
+#define STM32_OPAMP2_CSR (STM32_OPAMP_BASE+STM32_OPAMP2_CSR_OFFSET)
/* Register Bitfield Definitions ****************************************************/
@@ -66,7 +66,7 @@
#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_PB14 (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 */
@@ -74,7 +74,7 @@
#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_PGA (2 << OPAMP_CSR_VMSEL_SHIFT) /* 10: Resistor feedback output (PGA mode)*/
# 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 */
diff --git a/arch/arm/src/stm32/chip/stm32f33xxx_pinmap.h b/arch/arm/src/stm32/chip/stm32f33xxx_pinmap.h
index b5b97c88da098d8912e583e416cebe3ba2a17338..e0ad65fc1afc10fbf988a577f2bc09c90301daa4 100644
--- a/arch/arm/src/stm32/chip/stm32f33xxx_pinmap.h
+++ b/arch/arm/src/stm32/chip/stm32f33xxx_pinmap.h
@@ -337,9 +337,10 @@
#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)
+#undef GPIO_OPAMP2_VINP_1 /* not supported in F33XX */
+#define GPIO_OPAMP2_VINP_2 (GPIO_ANALOG|GPIO_PORTA|GPIO_PIN7)
+#define GPIO_OPAMP2_VINP_3 (GPIO_ANALOG|GPIO_PORTB|GPIO_PIN0)
+#define GPIO_OPAMP2_VINP_4 (GPIO_ANALOG|GPIO_PORTB|GPIO_PIN14)
/* TSC */
diff --git a/arch/arm/src/stm32/chip/stm32f33xxx_syscfg.h b/arch/arm/src/stm32/chip/stm32f33xxx_syscfg.h
index 6e83d0b611123e4cc30f2de1fbe204d9bd112fa8..d675d00f7bfdf20678a450314f5918fa9821442f 100644
--- a/arch/arm/src/stm32/chip/stm32f33xxx_syscfg.h
+++ b/arch/arm/src/stm32/chip/stm32f33xxx_syscfg.h
@@ -96,7 +96,7 @@
#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_SHIFT (16) /* 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 */
diff --git a/arch/arm/src/stm32/chip/stm32f40xxx_pinmap.h b/arch/arm/src/stm32/chip/stm32f40xxx_pinmap.h
index 82fb74a44811c58b27697d1aa613635372c9b22b..1f7b5944eadf3de373b6d49853d494757bf07a50 100644
--- a/arch/arm/src/stm32/chip/stm32f40xxx_pinmap.h
+++ b/arch/arm/src/stm32/chip/stm32f40xxx_pinmap.h
@@ -424,6 +424,10 @@
#define GPIO_I2C3_SCL_2 (GPIO_ALT|GPIO_AF4|GPIO_SPEED_50MHz|GPIO_OPENDRAIN|GPIO_PORTH|GPIO_PIN7)
#define GPIO_I2C3_SDA_1 (GPIO_ALT|GPIO_AF4|GPIO_SPEED_50MHz|GPIO_OPENDRAIN|GPIO_PORTC|GPIO_PIN9)
#define GPIO_I2C3_SDA_2 (GPIO_ALT|GPIO_AF4|GPIO_SPEED_50MHz|GPIO_OPENDRAIN|GPIO_PORTH|GPIO_PIN8)
+#if defined(CONFIG_STM32_STM32F411)
+# define GPIO_I2C3_SDA_3 (GPIO_ALT|GPIO_AF9|GPIO_SPEED_50MHz|GPIO_OPENDRAIN|GPIO_PORTB|GPIO_PIN4)
+# define GPIO_I2C3_SDA_4 (GPIO_ALT|GPIO_AF9|GPIO_SPEED_50MHz|GPIO_OPENDRAIN|GPIO_PORTB|GPIO_PIN8)
+#endif
#define GPIO_I2C3_SMBA_1 (GPIO_ALT|GPIO_AF4|GPIO_SPEED_50MHz|GPIO_PUSHPULL|GPIO_PORTA|GPIO_PIN9)
#define GPIO_I2C3_SMBA_2 (GPIO_ALT|GPIO_AF4|GPIO_SPEED_50MHz|GPIO_PUSHPULL|GPIO_PORTH|GPIO_PIN9)
#if defined(CONFIG_STM32_STM32F446)
@@ -611,7 +615,7 @@
#endif
#define GPIO_SPI3_MISO_1 (GPIO_ALT|GPIO_AF6|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN4)
-#define GPIO_SPI3_MISO_2 (GPIO_ALT|GPIO_AF6|GPIO_SPEED_50MHz|GPIO_PORTC|GPIO_PIN11)
+#define GPIO_SPI3_MISO_2 (GPIO_ALT|GPIO_AF6|GPIO_SPEED_50MHz|GPIO_PORTC|GPIO_PIN7)
#define GPIO_SPI3_MOSI_1 (GPIO_ALT|GPIO_AF6|GPIO_SPEED_50MHz|GPIO_PORTB|GPIO_PIN5)
#define GPIO_SPI3_MOSI_2 (GPIO_ALT|GPIO_AF6|GPIO_SPEED_50MHz|GPIO_PORTC|GPIO_PIN12)
#define GPIO_SPI3_NSS_1 (GPIO_ALT|GPIO_AF6|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN15)
diff --git a/arch/arm/src/stm32/chip/stm32f40xxx_vectors.h b/arch/arm/src/stm32/chip/stm32f40xxx_vectors.h
index b661cecbc53a867869e6fa3e971bcc984ea2636c..31546ed7e678e2b9065db3ec576eb0069efd4dac 100644
--- a/arch/arm/src/stm32/chip/stm32f40xxx_vectors.h
+++ b/arch/arm/src/stm32/chip/stm32f40xxx_vectors.h
@@ -1,7 +1,7 @@
/************************************************************************************
* arch/arm/src/stm32/chip/stm32f40xxx_vectors.h
*
- * Copyright (C) 2011-2012, 2014-2015 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2011-2012, 2014-2015, 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2016 Omni Hoverboards Inc. All rights reserved.
* Author: Gregory Nutt
* David Sidrane
@@ -58,6 +58,8 @@
# if defined(CONFIG_STM32_STM32F401) || defined(CONFIG_STM32_STM32F411) || \
defined(CONFIG_STM32_STM32F405) || defined(CONFIG_STM32_STM32F407)
# define ARMV7M_PERIPHERAL_INTERRUPTS 82
+# elif defined(CONFIG_STM32_STM32F410)
+# define ARMV7M_PERIPHERAL_INTERRUPTS 98
# elif defined(CONFIG_STM32_STM32F427)
# define ARMV7M_PERIPHERAL_INTERRUPTS 87
# elif defined(CONFIG_STM32_STM32F429)
@@ -89,18 +91,35 @@ VECTOR(stm32_dma1s4, STM32_IRQ_DMA1S4) /* Vector 16+15: DMA1 Stream 4
VECTOR(stm32_dma1s5, STM32_IRQ_DMA1S5) /* Vector 16+16: DMA1 Stream 5 global interrupt */
VECTOR(stm32_dma1s6, STM32_IRQ_DMA1S6) /* Vector 16+17: DMA1 Stream 6 global interrupt */
VECTOR(stm32_adc, STM32_IRQ_ADC) /* Vector 16+18: ADC1, ADC2, and ADC3 global interrupt */
+
+#if defined(CONFIG_STM32_STM32F410)
+UNUSED(STM32_IRQ_RESERVED19) /* Vector 16+19: Reserved */
+UNUSED(STM32_IRQ_RESERVED20) /* Vector 16+20: Reserved */
+UNUSED(STM32_IRQ_RESERVED21) /* Vector 16+21: Reserved */
+UNUSED(STM32_IRQ_RESERVED22) /* Vector 16+22: Reserved */
+#else
VECTOR(stm32_can1tx, STM32_IRQ_CAN1TX) /* Vector 16+19: CAN1 TX interrupts */
VECTOR(stm32_can1rx0, STM32_IRQ_CAN1RX0) /* Vector 16+20: CAN1 RX0 interrupts */
VECTOR(stm32_can1rx1, STM32_IRQ_CAN1RX1) /* Vector 16+21: CAN1 RX1 interrupt */
VECTOR(stm32_can1sce, STM32_IRQ_CAN1SCE) /* Vector 16+22: CAN1 SCE interrupt */
+#endif
+
VECTOR(stm32_exti95, STM32_IRQ_EXTI95) /* Vector 16+23: EXTI Line[9:5] interrupts */
VECTOR(stm32_tim1brk, STM32_IRQ_TIM1BRK) /* Vector 16+24: TIM1 Break interrupt/TIM9 global interrupt */
VECTOR(stm32_tim1up, STM32_IRQ_TIM1UP) /* Vector 16+25: TIM1 Update interrupt/TIM10 global interrupt */
VECTOR(stm32_tim1trgcom, STM32_IRQ_TIM1TRGCOM) /* Vector 16+26: TIM1 Trigger and Commutation interrupts/TIM11 global interrupt */
VECTOR(stm32_tim1cc, STM32_IRQ_TIM1CC) /* Vector 16+27: TIM1 Capture Compare interrupt */
+
+#if defined(CONFIG_STM32_STM32F410)
+UNUSED(STM32_IRQ_RESERVED28) /* Vector 16+28: Reserved */
+UNUSED(STM32_IRQ_RESERVED29) /* Vector 16+29: Reserved */
+UNUSED(STM32_IRQ_RESERVED30) /* Vector 16+30: Reserved */
+#else
VECTOR(stm32_tim2, STM32_IRQ_TIM2) /* Vector 16+28: TIM2 global interrupt */
VECTOR(stm32_tim3, STM32_IRQ_TIM3) /* Vector 16+29: TIM3 global interrupt */
VECTOR(stm32_tim4, STM32_IRQ_TIM4) /* Vector 16+30: TIM4 global interrupt */
+#endif
+
VECTOR(stm32_i2c1ev, STM32_IRQ_I2C1EV) /* Vector 16+31: I2C1 event interrupt */
VECTOR(stm32_i2c1er, STM32_IRQ_I2C1ER) /* Vector 16+32: I2C1 error interrupt */
VECTOR(stm32_i2c2ev, STM32_IRQ_I2C2EV) /* Vector 16+33: I2C2 event interrupt */
@@ -109,44 +128,102 @@ VECTOR(stm32_spi1, STM32_IRQ_SPI1) /* Vector 16+35: SPI1 global in
VECTOR(stm32_spi2, STM32_IRQ_SPI2) /* Vector 16+36: SPI2 global interrupt */
VECTOR(stm32_usart1, STM32_IRQ_USART1) /* Vector 16+37: USART1 global interrupt */
VECTOR(stm32_usart2, STM32_IRQ_USART2) /* Vector 16+38: USART2 global interrupt */
+
+#if defined(CONFIG_STM32_STM32F410)
+UNUSED(STM32_IRQ_RESERVED39) /* Vector 16+39: Reserved */
+#else
VECTOR(stm32_usart3, STM32_IRQ_USART3) /* Vector 16+39: USART3 global interrupt */
+#endif
+
VECTOR(stm32_exti1510, STM32_IRQ_EXTI1510) /* Vector 16+40: EXTI Line[15:10] interrupts */
VECTOR(stm32_rtcalrm, STM32_IRQ_RTCALRM) /* Vector 16+41: RTC alarm through EXTI line interrupt */
+
+#if defined(CONFIG_STM32_STM32F410)
+UNUSED(STM32_IRQ_RESERVED42) /* Vector 16+42: Reserved */
+UNUSED(STM32_IRQ_RESERVED43) /* Vector 16+43: Reserved */
+UNUSED(STM32_IRQ_RESERVED44) /* Vector 16+44: Reserved */
+UNUSED(STM32_IRQ_RESERVED45) /* Vector 16+45: Reserved */
+UNUSED(STM32_IRQ_RESERVED46) /* Vector 16+46: Reserved */
+#else
VECTOR(stm32_otgfswkup, STM32_IRQ_OTGFSWKUP) /* Vector 16+42: USB On-The-Go FS Wakeup through EXTI line interrupt */
VECTOR(stm32_tim8brk, STM32_IRQ_TIM8BRK) /* Vector 16+43: TIM8 Break interrupt/TIM12 global interrupt */
VECTOR(stm32_tim8up, STM32_IRQ_TIM8UP) /* Vector 16+44: TIM8 Update interrupt/TIM13 global interrupt */
VECTOR(stm32_tim8trgcom, STM32_IRQ_TIM8TRGCOM) /* Vector 16+45: TIM8 Trigger and Commutation interrupts/TIM14 global interrupt */
VECTOR(stm32_tim8cc, STM32_IRQ_TIM8CC) /* Vector 16+46: TIM8 Capture Compare interrupt */
+#endif
+
VECTOR(stm32_dma1s7, STM32_IRQ_DMA1S7) /* Vector 16+47: DMA1 Stream 7 global interrupt */
+
+#if defined(CONFIG_STM32_STM32F410)
+UNUSED(STM32_IRQ_RESERVED48) /* Vector 16+48: Reserved */
+UNUSED(STM32_IRQ_RESERVED49) /* Vector 16+49: Reserved */
+#else
VECTOR(stm32_fsmc, STM32_IRQ_FSMC) /* Vector 16+48: FSMC global interrupt */
VECTOR(stm32_sdio, STM32_IRQ_SDIO) /* Vector 16+49: SDIO global interrupt */
+#endif
+
VECTOR(stm32_tim5, STM32_IRQ_TIM5) /* Vector 16+50: TIM5 global interrupt */
+
+#if defined(CONFIG_STM32_STM32F410)
+UNUSED(STM32_IRQ_RESERVED51) /* Vector 16+51: Reserved */
+UNUSED(STM32_IRQ_RESERVED52) /* Vector 16+52: Reserved */
+UNUSED(STM32_IRQ_RESERVED53) /* Vector 16+53: Reserved */
+#else
VECTOR(stm32_spi3, STM32_IRQ_SPI3) /* Vector 16+51: SPI3 global interrupt */
VECTOR(stm32_uart4, STM32_IRQ_UART4) /* Vector 16+52: UART4 global interrupt */
VECTOR(stm32_uart5, STM32_IRQ_UART5) /* Vector 16+53: UART5 global interrupt */
+#endif
+
VECTOR(stm32_tim6, STM32_IRQ_TIM6) /* Vector 16+54: TIM6 global interrupt/DAC1 and DAC2 underrun error interrupts */
+
+#if defined(CONFIG_STM32_STM32F410)
+UNUSED(STM32_IRQ_RESERVED55) /* Vector 16+55: Reserved */
+#else
VECTOR(stm32_tim7, STM32_IRQ_TIM7) /* Vector 16+55: TIM7 global interrupt */
+#endif
+
VECTOR(stm32_dma2s0, STM32_IRQ_DMA2S0) /* Vector 16+56: DMA2 Stream 0 global interrupt */
VECTOR(stm32_dma2s1, STM32_IRQ_DMA2S1) /* Vector 16+57: DMA2 Stream 1 global interrupt */
VECTOR(stm32_dma2s2, STM32_IRQ_DMA2S2) /* Vector 16+58: DMA2 Stream 2 global interrupt */
VECTOR(stm32_dma2s3, STM32_IRQ_DMA2S3) /* Vector 16+59: DMA2 Stream 3 global interrupt */
VECTOR(stm32_dma2s4, STM32_IRQ_DMA2S4) /* Vector 16+60: DMA2 Stream 4 global interrupt */
-#if defined(CONFIG_STM32_STM32F446)
+
+#if defined(CONFIG_STM32_STM32F446) || defined(CONFIG_STM32_STM32F410)
UNUSED(STM32_IRQ_RESERVED61) /* Vector 16+61: Reserved */
UNUSED(STM32_IRQ_RESERVED62) /* Vector 16+62: Reserved */
#else
VECTOR(stm32_eth, STM32_IRQ_ETH) /* Vector 16+61: Ethernet global interrupt */
VECTOR(stm32_ethwkup, STM32_IRQ_ETHWKUP) /* Vector 16+62: Ethernet Wakeup through EXTI line interrupt */
#endif
+
+#if defined(CONFIG_STM32_STM32F410)
+UNUSED(STM32_IRQ_RESERVED63) /* Vector 16+63: Reserved */
+UNUSED(STM32_IRQ_RESERVED64) /* Vector 16+64: Reserved */
+UNUSED(STM32_IRQ_RESERVED65) /* Vector 16+65: Reserved */
+UNUSED(STM32_IRQ_RESERVED66) /* Vector 16+66: Reserved */
+UNUSED(STM32_IRQ_RESERVED67) /* Vector 16+67: Reserved */
+#else
VECTOR(stm32_can2tx, STM32_IRQ_CAN2TX) /* Vector 16+63: CAN2 TX interrupts */
VECTOR(stm32_can2rx0, STM32_IRQ_CAN2RX0) /* Vector 16+64: CAN2 RX0 interrupts */
VECTOR(stm32_can2rx1, STM32_IRQ_CAN2RX1) /* Vector 16+65: CAN2 RX1 interrupt */
VECTOR(stm32_can2sce, STM32_IRQ_CAN2SCE) /* Vector 16+66: CAN2 SCE interrupt */
VECTOR(stm32_otgfs, STM32_IRQ_OTGFS) /* Vector 16+67: USB On The Go FS global interrupt */
+#endif
+
VECTOR(stm32_dma2s5, STM32_IRQ_DMA2S5) /* Vector 16+68: DMA2 Stream 5 global interrupt */
VECTOR(stm32_dma2s6, STM32_IRQ_DMA2S6) /* Vector 16+69: DMA2 Stream 6 global interrupt */
VECTOR(stm32_dma2s7, STM32_IRQ_DMA2S7) /* Vector 16+70: DMA2 Stream 7 global interrupt */
VECTOR(stm32_usart6, STM32_IRQ_USART6) /* Vector 16+71: USART6 global interrupt */
+
+#if defined(CONFIG_STM32_STM32F410)
+UNUSED(STM32_IRQ_RESERVED72) /* Vector 16+72: Reserved */
+UNUSED(STM32_IRQ_RESERVED73) /* Vector 16+73: Reserved */
+UNUSED(STM32_IRQ_RESERVED74) /* Vector 16+74: Reserved */
+UNUSED(STM32_IRQ_RESERVED75) /* Vector 16+75: Reserved */
+UNUSED(STM32_IRQ_RESERVED76) /* Vector 16+76: Reserved */
+UNUSED(STM32_IRQ_RESERVED77) /* Vector 16+77: Reserved */
+UNUSED(STM32_IRQ_RESERVED78) /* Vector 16+78: Reserved */
+#else
VECTOR(stm32_i2c3ev, STM32_IRQ_I2C3EV) /* Vector 16+72: I2C3 event interrupt */
VECTOR(stm32_i2c3er, STM32_IRQ_I2C3ER) /* Vector 16+73: I2C3 error interrupt */
VECTOR(stm32_otghsep1out, STM32_IRQ_OTGHSEP1OUT) /* Vector 16+74: USB On The Go HS End Point 1 Out global interrupt */
@@ -154,26 +231,38 @@ VECTOR(stm32_otghsep1in, STM32_IRQ_OTGHSEP1IN) /* Vector 16+75: USB On The Go
VECTOR(stm32_otghswkup, STM32_IRQ_OTGHSWKUP) /* Vector 16+76: USB On The Go HS Wakeup through EXTI interrupt */
VECTOR(stm32_otghs, STM32_IRQ_OTGHS) /* Vector 16+77: USB On The Go HS global interrupt */
VECTOR(stm32_dcmi, STM32_IRQ_DCMI) /* Vector 16+78: DCMI global interrupt */
+#endif
+
#if defined(CONFIG_STM32_STM32F446)
UNUSED(STM32_IRQ_RESERVED79) /* Vector 16+79: Reserved */
UNUSED(STM32_IRQ_RESERVED80) /* Vector 16+80: Reserved */
#else
+# if defined(CONFIG_STM32_STM32F410)
+UNUSED(STM32_IRQ_RESERVED79) /* Vector 16+79: Reserved */
+# else
VECTOR(stm32_cryp, STM32_IRQ_CRYP) /* Vector 16+79: CRYP crypto global interrupt */
+# endif
VECTOR(stm32_hash, STM32_IRQ_HASH) /* Vector 16+80: Hash and Rng global interrupt */
#endif
+
VECTOR(stm32_fpu, STM32_IRQ_FPU) /* Vector 16+81: FPU global interrupt */
+
#if defined(CONFIG_STM32_STM32F427) || defined(CONFIG_STM32_STM32F429) || \
defined(CONFIG_STM32_STM32F469)
VECTOR(stm32_uart7, STM32_IRQ_UART7) /* Vector 16+82: UART7 interrupt */
VECTOR(stm32_uart8, STM32_IRQ_UART8) /* Vector 16+83: UART8 interrupt */
-#elif defined(CONFIG_STM32_STM32F446)
+#elif defined(CONFIG_STM32_STM32F446) || defined(CONFIG_STM32_STM32F410)
UNUSED(STM32_IRQ_RESERVED82) /* Vector 16+82: Reserved */
UNUSED(STM32_IRQ_RESERVED83) /* Vector 16+83: Reserved */
#endif
+
#if defined(CONFIG_STM32_STM32F427) || defined(CONFIG_STM32_STM32F429) || \
defined(CONFIG_STM32_STM32F446) || defined(CONFIG_STM32_STM32F469)
VECTOR(stm32_spi4, STM32_IRQ_SPI4) /* Vector 16+84: SPI4 interrupt */
+#elif defined(CONFIG_STM32_STM32F410)
+UNUSED(STM32_IRQ_RESERVED84) /* Vector 16+84: Reserved */
#endif
+
#if defined(CONFIG_STM32_STM32F427) || defined(CONFIG_STM32_STM32F429) || \
defined(CONFIG_STM32_STM32F469)
VECTOR(stm32_spi5, STM32_IRQ_SPI5) /* Vector 16+85: SPI5 interrupt */
@@ -181,27 +270,39 @@ VECTOR(stm32_spi6, STM32_IRQ_SPI6) /* Vector 16+86: SPI6 interrupt
#elif defined(CONFIG_STM32_STM32F446)
UNUSED(STM32_IRQ_RESERVED85) /* Vector 16+85: Reserved */
UNUSED(STM32_IRQ_RESERVED86) /* Vector 16+86: Reserved */
+#elif defined(CONFIG_STM32_STM32F410)
+VECTOR(stm32_spi5, STM32_IRQ_SPI5) /* Vector 16+85: SPI5 interrupt */
+UNUSED(STM32_IRQ_RESERVED86) /* Vector 16+86: Reserved */
#endif
+
#if defined(CONFIG_STM32_STM32F429) || defined(CONFIG_STM32_STM32F446) || \
defined(CONFIG_STM32_STM32F446) || defined(CONFIG_STM32_STM32F469)
VECTOR(stm32_sai1, STM32_IRQ_SAI1) /* Vector 16+87: SAI1 interrupt */
+#elif defined(CONFIG_STM32_STM32F410)
+UNUSED(STM32_IRQ_RESERVED87) /* Vector 16+87: Reserved */
#endif
+
#if defined(CONFIG_STM32_STM32F429) || defined(CONFIG_STM32_STM32F469)
VECTOR(stm32_ltdcint, STM32_IRQ_LTDCINT) /* Vector 16+88: LTDC interrupt */
VECTOR(stm32_ltdcerrint, STM32_IRQ_LTDCERRINT) /* Vector 16+89: LTDC Error interrupt */
VECTOR(stm32_dma2d, STM32_IRQ_DMA2D) /* Vector 16+90: DMA2D interrupt */
-#elif defined(CONFIG_STM32_STM32F446)
+#elif defined(CONFIG_STM32_STM32F446) || defined(CONFIG_STM32_STM32F410)
UNUSED(STM32_IRQ_RESERVED88) /* Vector 16+88: Reserved */
UNUSED(STM32_IRQ_RESERVED89) /* Vector 16+89: Reserved */
UNUSED(STM32_IRQ_RESERVED90) /* Vector 16+90: Reserved */
#endif
-#if defined(CONFIG_STM32_STM32F446)
+
+#if defined(CONFIG_STM32_STM32F410)
+UNUSED(STM32_IRQ_RESERVED91) /* Vector 16+91: Reserved */
+UNUSED(STM32_IRQ_RESERVED92) /* Vector 16+92: Reserved */
+#elif defined(CONFIG_STM32_STM32F446)
VECTOR(stm32_sai2, STM32_IRQ_SAI2) /* Vector 16+91: SAI2 Global interrupt */
VECTOR(stm32_quadspi, STM32_IRQ_QUADSPI) /* Vector 16+92: QuadSPI Global interrupt */
#elif defined(CONFIG_STM32_STM32F469)
VECTOR(stm32_quadspi, STM32_IRQ_QUADSPI) /* Vector 16+91: QuadSPI Global interrupt */
VECTOR(stm32_dsi, STM32_IRQ_DSI) /* Vector 16+92: DSI Global interrupt */
#endif
+
#if defined(CONFIG_STM32_STM32F446)
VECTOR(stm32_hdmicec, STM32_IRQ_HDMICEC) /* Vector 16+93: HDMI-CEC Global interrupt */
VECTOR(stm32_spdifrx, STM32_IRQ_SPDIFRX) /* Vector 16+94: SPDIF-Rx Global interrupt */
@@ -209,4 +310,12 @@ VECTOR(stm32_fmpi2c1, STM32_IRQ_FMPI2C1) /* Vector 16+95: FMPI2C1 event
VECTOR(stm32_fmpi2c1err, STM32_IRQ_FMPI2C1ERR) /* Vector 16+96: FMPI2C1 Error event interrupt */
#endif
+#if defined(CONFIG_STM32_STM32F410)
+UNUSED(STM32_IRQ_RESERVED93) /* Vector 16+93: Reserved */
+UNUSED(STM32_IRQ_RESERVED94) /* Vector 16+94: Reserved */
+UNUSED(STM32_IRQ_RESERVED95) /* Vector 16+95: Reserved */
+UNUSED(STM32_IRQ_RESERVED96) /* Vector 16+96: Reserved */
+UNUSED(STM32_IRQ_RESERVED97) /* Vector 16+97: Reserved */
+#endif
+
#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 31f62c8d112d2b46c96004609fdabff644755f81..4943686dac4f8828c7aae4ced7876db0fbf2bf9f 100644
--- a/arch/arm/src/stm32/gnu/stm32_vectors.S
+++ b/arch/arm/src/stm32/gnu/stm32_vectors.S
@@ -63,7 +63,7 @@
* stale MSP, there will most likely be a system failure.
*
* If the interrupt stack is selected, on the other hand, then the interrupt
- * handler will always set the the MSP to the interrupt stack. So when the high
+ * handler will always set the MSP to the interrupt stack. So when the high
* priority interrupt occurs, it will either use the MSP of the last privileged
* thread to run or, in the case of the nested interrupt, the interrupt stack if
* no privileged task has run.
@@ -73,7 +73,7 @@
# error Interrupt stack must be used with high priority interrupts in kernel mode
# endif
- /* Use the the BASEPRI to control interrupts is required if nested, high
+ /* Use the BASEPRI to control interrupts is required if nested, high
* priority interrupts are supported.
*/
@@ -497,7 +497,7 @@ exception_common:
.global g_intstackbase
.align 8
g_intstackalloc:
- .skip (CONFIG_ARCH_INTERRUPTSTACK & ~7)
+ .skip ((CONFIG_ARCH_INTERRUPTSTACK + 4) & ~7)
g_intstackbase:
.size g_intstackalloc, .-g_intstackalloc
#endif
diff --git a/arch/arm/src/stm32/iar/stm32_vectors.S b/arch/arm/src/stm32/iar/stm32_vectors.S
index cf83e7b8bff68dc69ad11110b7ad28ac23725652..52fdfb30568aae8f5cbc0155a5f9944f8a67e2c6 100644
--- a/arch/arm/src/stm32/iar/stm32_vectors.S
+++ b/arch/arm/src/stm32/iar/stm32_vectors.S
@@ -63,7 +63,7 @@
* stale MSP, there will most likely be a system failure.
*
* If the interrupt stack is selected, on the other hand, then the interrupt
- * handler will always set the the MSP to the interrupt stack. So when the high
+ * handler will always set the MSP to the interrupt stack. So when the high
* priority interrupt occurs, it will either use the MSP of the last privileged
* thread to run or, in the case of the nested interrupt, the interrupt stack if
* no privileged task has run.
@@ -73,7 +73,7 @@
# error Interrupt stack must be used with high priority interrupts in kernel mode
# endif
- /* Use the the BASEPRI to control interrupts is required if nested, high
+ /* Use the BASEPRI to control interrupts is required if nested, high
* priority interrupts are supported.
*/
@@ -1055,7 +1055,7 @@ l5:
.global g_intstackbase
.align 8
g_intstackalloc:
- .skip (CONFIG_ARCH_INTERRUPTSTACK & ~7)
+ .skip ((CONFIG_ARCH_INTERRUPTSTACK + 4) & ~7)
g_intstackbase:
.size g_intstackalloc, .-g_intstackalloc
#endif
diff --git a/arch/arm/src/stm32/stm32.h b/arch/arm/src/stm32/stm32.h
index 6680e81293f0944f42505319ae62cee9f1d3744c..11c8f5b29e31684671edae16a45cfc149dcf2130 100644
--- a/arch/arm/src/stm32/stm32.h
+++ b/arch/arm/src/stm32/stm32.h
@@ -59,6 +59,7 @@
#include "stm32_adc.h"
//#include "stm32_bkp.h"
#include "stm32_can.h"
+#include "stm32_comp.h"
#include "stm32_dbgmcu.h"
#include "stm32_dma.h"
#include "stm32_dac.h"
@@ -66,8 +67,10 @@
#include "stm32_flash.h"
#include "stm32_fsmc.h"
#include "stm32_gpio.h"
+#include "stm32_hrtim.h"
#include "stm32_i2c.h"
#include "stm32_ltdc.h"
+#include "stm32_opamp.h"
#include "stm32_pwr.h"
#include "stm32_rcc.h"
#include "stm32_rtc.h"
diff --git a/arch/arm/src/stm32/stm32_adc.c b/arch/arm/src/stm32/stm32_adc.c
index ef91b77b40f3af0047ad417cc950769f260cd574..43e349eff0a070a82606cae166fcda3bdb587d74 100644
--- a/arch/arm/src/stm32/stm32_adc.c
+++ b/arch/arm/src/stm32/stm32_adc.c
@@ -6,6 +6,7 @@
* Authors: Gregory Nutt
* Diego Sanchez
* Paul Alexander Patience
+ * Mateusz Szafoni
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -77,11 +78,12 @@
#if defined(CONFIG_STM32_ADC1) || defined(CONFIG_STM32_ADC2) || \
defined(CONFIG_STM32_ADC3) || defined(CONFIG_STM32_ADC4)
-/* This implementation is for the STM32 F1, F2, F4 and STM32L15XX only */
+/* This implementation is for the STM32 F1, F2, F3, F4 and STM32L15XX only */
#if defined(CONFIG_STM32_STM32F10XX) || defined(CONFIG_STM32_STM32F20XX) || \
- defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F37XX) || \
- defined(CONFIG_STM32_STM32F40XX) || defined(CONFIG_STM32_STM32L15XX)
+ defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX) || \
+ defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F40XX) || \
+ defined(CONFIG_STM32_STM32L15XX)
/* At the moment there is no proper implementation for timers external
* trigger in STM32L15XX May be added latter
@@ -91,6 +93,14 @@
# warning "There is no proper implementation for TIMER TRIGGERS at the moment"
#endif
+/* At the moment there is no proper implementation for HRTIMER external
+ * trigger in STM32F33XX
+ */
+
+#if defined(ADC_HAVE_HRTIMER) && defined(CONFIG_STM32_STM32F33XX)
+# warning "There is no proper implementation for HRTIMER TRIGGERS at the moment"
+#endif
+
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@@ -108,6 +118,10 @@
# define RCC_RSTR_ADC2RST RCC_AHBRSTR_ADC12RST
# define RCC_RSTR_ADC3RST RCC_AHBRSTR_ADC34RST
# define RCC_RSTR_ADC4RST RCC_AHBRSTR_ADC34RST
+#elif defined(CONFIG_STM32_STM32F33XX)
+# define STM32_RCC_RSTR STM32_RCC_AHBRSTR
+# define RCC_RSTR_ADC1RST RCC_AHBRSTR_ADC12RST
+# define RCC_RSTR_ADC2RST RCC_AHBRSTR_ADC12RST
#elif defined(CONFIG_STM32_STM32F37XX)
# define STM32_RCC_RSTR STM32_RCC_APB2RSTR
# define RCC_RSTR_ADC1RST RCC_APB2RSTR_ADCRST
@@ -124,7 +138,7 @@
/* ADC interrupts ***********************************************************/
-#ifdef CONFIG_STM32_STM32F30XX
+#if defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX)
# define STM32_ADC_DMAREG_OFFSET STM32_ADC_CFGR_OFFSET
# define ADC_DMAREG_DMA ADC_CFGR_DMAEN
# define STM32_ADC_EXTREG_OFFSET STM32_ADC_CFGR_OFFSET
@@ -226,7 +240,7 @@
(ADC_SMPR_DEFAULT << ADC_SMPR2_SMP7_SHIFT) | \
(ADC_SMPR_DEFAULT << ADC_SMPR2_SMP8_SHIFT) | \
(ADC_SMPR_DEFAULT << ADC_SMPR2_SMP9_SHIFT))
-#elif defined(CONFIG_STM32_STM32F30XX)
+#elif defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX)
# if defined(ADC_HAVE_DMA) || (ADC_MAX_SAMPLES == 1)
# define ADC_SMPR_DEFAULT ADC_SMPR_61p5
# else /* Slow down sampling frequency */
@@ -338,8 +352,8 @@ struct stm32_dev_s
/* ADC Register access */
#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F30XX) || \
- defined(CONFIG_STM32_STM32F37XX) ||defined(CONFIG_STM32_STM32F40XX) || \
- defined(CONFIG_STM32_STM32L15XX)
+ defined(CONFIG_STM32_STM32F33XX) || defined(CONFIG_STM32_STM32F37XX) || \
+ defined(CONFIG_STM32_STM32F40XX) || defined(CONFIG_STM32_STM32L15XX)
static void stm32_modifyreg32(unsigned int addr, uint32_t clrbits,
uint32_t setbits);
#endif
@@ -606,8 +620,8 @@ static struct adc_dev_s g_adcdev4 =
****************************************************************************/
#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F30XX) || \
- defined(CONFIG_STM32_STM32F37XX) ||defined(CONFIG_STM32_STM32F40XX) || \
- defined(CONFIG_STM32_STM32L15XX)
+ defined(CONFIG_STM32_STM32F33XX) || defined(CONFIG_STM32_STM32F37XX) || \
+ defined(CONFIG_STM32_STM32F40XX) || defined(CONFIG_STM32_STM32L15XX)
static void stm32_modifyreg32(unsigned int addr, uint32_t clrbits,
uint32_t setbits)
{
@@ -1242,7 +1256,7 @@ static void adc_startconv(FAR struct stm32_dev_s *priv, bool enable)
adc_enable(priv, true);
}
-#elif defined(CONFIG_STM32_STM32F30XX)
+#elif defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX)
static void adc_startconv(FAR struct stm32_dev_s *priv, bool enable)
{
uint32_t regval;
@@ -1520,7 +1534,7 @@ static void adc_select_ch_bank(FAR struct stm32_dev_s *priv,
*
****************************************************************************/
-#ifdef CONFIG_STM32_STM32F30XX
+#if defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX)
static void adc_enable(FAR struct stm32_dev_s *priv, bool enable)
{
uint32_t regval;
@@ -1699,8 +1713,8 @@ static void adc_dmaconvcallback(DMA_HANDLE handle, uint8_t isr, FAR void *arg)
* Name: adc_bind
*
* Description:
- * Bind the upper-half driver callbacks to the lower-half implementation. This
- * must be called early in order to receive ADC event notifications.
+ * Bind the upper-half driver callbacks to the lower-half implementation.
+ * This must be called early in order to receive ADC event notifications.
*
****************************************************************************/
@@ -1718,8 +1732,8 @@ static int adc_bind(FAR struct adc_dev_s *dev,
* Name: adc_reset
*
* Description:
- * Reset the ADC device. Called early to initialize the hardware. This
- * is called, before adc_setup() and on error conditions.
+ * Reset the ADC device. Called early to initialize the hardware.
+ * This is called, before adc_setup() and on error conditions.
*
* Input Parameters:
*
@@ -1751,7 +1765,7 @@ static void adc_reset(FAR struct adc_dev_s *dev)
#endif
-#ifdef CONFIG_STM32_STM32F30XX
+#if defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX)
/* Turn off the ADC so we can write the RCC bits */
@@ -1767,7 +1781,7 @@ static void adc_reset(FAR struct adc_dev_s *dev)
adc_rccreset(priv, false);
-#ifdef CONFIG_STM32_STM32F30XX
+#if defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX)
/* Set voltage regular enable to intermediate state */
@@ -1822,7 +1836,7 @@ static void adc_reset(FAR struct adc_dev_s *dev)
adc_putreg(priv, STM32_ADC_SMPR2_OFFSET, ADC_SMPR2_DEFAULT);
#endif
-#ifdef CONFIG_STM32_STM32F30XX
+#if defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX)
/* Enable the analog watchdog */
@@ -1870,7 +1884,7 @@ static void adc_reset(FAR struct adc_dev_s *dev)
adc_modifyreg(priv, STM32_ADC_IER_OFFSET, clrbits, setbits);
-#else /* ifdef CONFIG_STM32_STM32F30XX */
+#else /* CONFIG_STM32_STM32F30XX || CONFIG_STM32_STM33XX */
/* Enable the analog watchdog */
@@ -1968,7 +1982,7 @@ static void adc_reset(FAR struct adc_dev_s *dev)
/* ADC CCR configuration */
-#if defined(CONFIG_STM32_STM32F30XX)
+#if defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX)
clrbits = ADC_CCR_DUAL_MASK | ADC_CCR_DELAY_MASK | ADC_CCR_DMACFG |
ADC_CCR_MDMA_MASK | ADC_CCR_CKMODE_MASK | ADC_CCR_VREFEN |
ADC_CCR_TSEN | ADC_CCR_VBATEN;
@@ -1979,10 +1993,12 @@ static void adc_reset(FAR struct adc_dev_s *dev)
{
stm32_modifyreg32(STM32_ADC12_CCR, clrbits, setbits);
}
+#ifndef CONFIG_STM32_STM32F33XX
else
{
stm32_modifyreg32(STM32_ADC34_CCR, clrbits, setbits);
}
+#endif
#elif defined(CONFIG_STM32_STM32F20XX) || \
defined(CONFIG_STM32_STM32F40XX) || \
defined(CONFIG_STM32_STM32L15XX)
@@ -2038,11 +2054,11 @@ static void adc_reset(FAR struct adc_dev_s *dev)
aerr("ERROR: adc_timinit failed: %d\n", ret);
}
}
-#ifndef CONFIG_ADC_NO_STARTUP_CONV
+#ifndef CONFIG_STM32_ADC_NO_STARTUP_CONV
else
#endif
#endif
-#ifndef CONFIG_ADC_NO_STARTUP_CONV
+#ifndef CONFIG_STM32_ADC_NO_STARTUP_CONV
{
adc_startconv(priv, true);
}
@@ -2050,7 +2066,7 @@ static void adc_reset(FAR struct adc_dev_s *dev)
leave_critical_section(flags);
-#ifdef CONFIG_STM32_STM32F30XX
+#if defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX)
ainfo("ISR: 0x%08x CR: 0x%08x CFGR: 0x%08x\n",
adc_getreg(priv, STM32_ADC_ISR_OFFSET),
adc_getreg(priv, STM32_ADC_CR_OFFSET),
@@ -2067,7 +2083,7 @@ static void adc_reset(FAR struct adc_dev_s *dev)
adc_getreg(priv, STM32_ADC_SQR2_OFFSET),
adc_getreg(priv, STM32_ADC_SQR3_OFFSET));
-#if defined(CONFIG_STM32_STM32F30XX)
+#if defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX)
ainfo("SQR4: 0x%08x\n", adc_getreg(priv, STM32_ADC_SQR4_OFFSET));
#elif defined(CONFIG_STM32_STM32L15XX)
ainfo("SQR4: 0x%08x SQR5: 0x%08x\n",
@@ -2075,15 +2091,17 @@ static void adc_reset(FAR struct adc_dev_s *dev)
adc_getreg(priv, STM32_ADC_SQR5_OFFSET));
#endif
-#if defined(CONFIG_STM32_STM32F30XX)
+#if defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX)
if (priv->base == STM32_ADC1_BASE || priv->base == STM32_ADC2_BASE)
{
ainfo("CCR: 0x%08x\n", getreg32(STM32_ADC12_CCR));
}
+#ifndef CONFIG_STM32_STM32F33XX
else
{
ainfo("CCR: 0x%08x\n", getreg32(STM32_ADC34_CCR));
}
+#endif
#elif defined(CONFIG_STM32_STM32F20XX) || \
defined(CONFIG_STM32_STM32F40XX) || \
defined(CONFIG_STM32_STM32L15XX)
@@ -3085,8 +3103,9 @@ struct adc_dev_s *stm32_adcinitialize(int intf, FAR const uint8_t *chanlist,
}
#endif /* CONFIG_STM32_STM32F10XX || CONFIG_STM32_STM32F20XX ||
- * CONFIG_STM32_STM32F30XX || CONFIG_STM32_STM32F47XX ||
- * CONFIG_STM32_STM32F40XX || CONFIG_STM32_STM32L15XX
+ * CONFIG_STM32_STM32F30XX || CONFIG_STM32_STM32F33XX ||
+ * CONFIG_STM32_STM32F47XX || CONFIG_STM32_STM32F40XX ||
+ * CONFIG_STM32_STM32L15XX
*/
#endif /* CONFIG_STM32_ADC1 || CONFIG_STM32_ADC2 ||
* CONFIG_STM32_ADC3 || CONFIG_STM32_ADC4
diff --git a/arch/arm/src/stm32/stm32_allocateheap.c b/arch/arm/src/stm32/stm32_allocateheap.c
index 3e6a73f2cd7ff4b9633da762021fd351fe172555..a6a9161244140ef49ad69ec8094a9b79bb678b24 100644
--- a/arch/arm/src/stm32/stm32_allocateheap.c
+++ b/arch/arm/src/stm32/stm32_allocateheap.c
@@ -353,7 +353,7 @@
/* The STM32 F2 and the STM32 F401/F411 have no CCM SRAM */
# if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F401) || \
- defined(CONFIG_STM32_STM32F411)
+ defined(CONFIG_STM32_STM32F411) || defined(CONFIG_STM32_STM32F410)
# undef CONFIG_STM32_CCMEXCLUDE
# define CONFIG_STM32_CCMEXCLUDE 1
# endif
@@ -362,6 +362,8 @@
# if defined(CONFIG_STM32_STM32F401)
# define SRAM1_END 0x20018000
+# elif defined(CONFIG_STM32_STM32F410)
+# define SRAM1_END 0x20008000
# elif defined(CONFIG_STM32_STM32F427) || defined(CONFIG_STM32_STM32F429)
# define SRAM1_END 0x20030000
# elif defined(CONFIG_STM32_STM32F446)
diff --git a/arch/arm/src/stm32/stm32_bbsram.c b/arch/arm/src/stm32/stm32_bbsram.c
index a401feca56284f3ead3738b774fe59a67f8f376d..f1e0b6d311f66becdfa8f104dc0fb8d5d42fcdf9 100644
--- a/arch/arm/src/stm32/stm32_bbsram.c
+++ b/arch/arm/src/stm32/stm32_bbsram.c
@@ -612,7 +612,7 @@ static int stm32_bbsram_ioctl(FAR struct file *filep, int cmd,
* This function will remove the remove the file from the file system
* it will zero the contents and time stamp. It will leave the fileno
* and pointer to the BBSRAM intact.
- * It should be called called on the the file used for the crash dump
+ * It should be called called on the file used for the crash dump
* to remove it from visibility in the file system after it is created or
* read thus arming it.
*
diff --git a/arch/arm/src/stm32/stm32_can.c b/arch/arm/src/stm32/stm32_can.c
index d90e5cd06da76fda8f9035824de0505b0d11101e..9e23a48f36a381e89ec6f4ac454953879bebb70b 100644
--- a/arch/arm/src/stm32/stm32_can.c
+++ b/arch/arm/src/stm32/stm32_can.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/stm32/stm32_can.c
*
- * Copyright (C) 2011, 2016 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2011, 2016-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
*
* Copyright (C) 2016 Omni Hoverboards Inc. All rights reserved.
@@ -53,7 +53,7 @@
#include
#include
#include
-#include
+#include
#include "up_internal.h"
#include "up_arch.h"
@@ -74,10 +74,6 @@
#define INAK_TIMEOUT 65535
-/* Mailboxes ****************************************************************/
-
-#define CAN_ALL_MAILBOXES (CAN_TSR_TME0 | CAN_TSR_TME1 | CAN_TSR_TME2)
-
/* Bit timing ***************************************************************/
#define CAN_BIT_QUANTA (CONFIG_CAN_TSEG1 + CONFIG_CAN_TSEG2 + 1)
@@ -172,6 +168,12 @@ static int stm32can_bittiming(FAR struct stm32_can_s *priv);
static int stm32can_cellinit(FAR struct stm32_can_s *priv);
static int stm32can_filterinit(FAR struct stm32_can_s *priv);
+/* TX mailbox status */
+
+static bool stm32can_txmb0empty(uint32_t tsr_regval);
+static bool stm32can_txmb1empty(uint32_t tsr_regval);
+static bool stm32can_txmb2empty(uint32_t tsr_regval);
+
/****************************************************************************
* Private Data
****************************************************************************/
@@ -1170,15 +1172,15 @@ static int stm32can_send(FAR struct can_dev_s *dev,
/* Select one empty transmit mailbox */
regval = stm32can_getreg(priv, STM32_CAN_TSR_OFFSET);
- if ((regval & CAN_TSR_TME0) != 0 && (regval & CAN_TSR_RQCP0) == 0)
+ if (stm32can_txmb0empty(regval))
{
txmb = 0;
}
- else if ((regval & CAN_TSR_TME1) != 0 && (regval & CAN_TSR_RQCP1) == 0)
+ else if (stm32can_txmb1empty(regval))
{
txmb = 1;
}
- else if ((regval & CAN_TSR_TME2) != 0 && (regval & CAN_TSR_RQCP2) == 0)
+ else if (stm32can_txmb2empty(regval))
{
txmb = 2;
}
@@ -1321,7 +1323,8 @@ static bool stm32can_txready(FAR struct can_dev_s *dev)
regval = stm32can_getreg(priv, STM32_CAN_TSR_OFFSET);
caninfo("CAN%d TSR: %08x\n", priv->port, regval);
- return (regval & CAN_ALL_MAILBOXES) != 0;
+ return stm32can_txmb0empty(regval) || stm32can_txmb1empty(regval) ||
+ stm32can_txmb2empty(regval);
}
/****************************************************************************
@@ -1352,7 +1355,8 @@ static bool stm32can_txempty(FAR struct can_dev_s *dev)
regval = stm32can_getreg(priv, STM32_CAN_TSR_OFFSET);
caninfo("CAN%d TSR: %08x\n", priv->port, regval);
- return (regval & CAN_ALL_MAILBOXES) == CAN_ALL_MAILBOXES;
+ return stm32can_txmb0empty(regval) && stm32can_txmb1empty(regval) &&
+ stm32can_txmb2empty(regval);
}
/****************************************************************************
@@ -1553,14 +1557,9 @@ static int stm32can_txinterrupt(int irq, FAR void *context, FAR void *arg)
stm32can_putreg(priv, STM32_CAN_TSR_OFFSET, CAN_TSR_RQCP0);
- /* Check for errors */
-
- if ((regval & CAN_TSR_TXOK0) != 0)
- {
- /* Tell the upper half that the tansfer is finished. */
+ /* Tell the upper half that the transfer is finished. */
- (void)can_txdone(dev);
- }
+ (void)can_txdone(dev);
}
/* Check for RQCP1: Request completed mailbox 1 */
@@ -1573,14 +1572,9 @@ static int stm32can_txinterrupt(int irq, FAR void *context, FAR void *arg)
stm32can_putreg(priv, STM32_CAN_TSR_OFFSET, CAN_TSR_RQCP1);
- /* Check for errors */
-
- if ((regval & CAN_TSR_TXOK1) != 0)
- {
- /* Tell the upper half that the tansfer is finished. */
+ /* Tell the upper half that the transfer is finished. */
- (void)can_txdone(dev);
- }
+ (void)can_txdone(dev);
}
/* Check for RQCP2: Request completed mailbox 2 */
@@ -1593,14 +1587,9 @@ static int stm32can_txinterrupt(int irq, FAR void *context, FAR void *arg)
stm32can_putreg(priv, STM32_CAN_TSR_OFFSET, CAN_TSR_RQCP2);
- /* Check for errors */
-
- if ((regval & CAN_TSR_TXOK2) != 0)
- {
- /* Tell the upper half that the tansfer is finished. */
+ /* Tell the upper half that the transfer is finished. */
- (void)can_txdone(dev);
- }
+ (void)can_txdone(dev);
}
return OK;
@@ -2111,6 +2100,57 @@ static int stm32can_delstdfilter(FAR struct stm32_can_s *priv, int arg)
return -ENOTTY;
}
+/****************************************************************************
+ * Name: stm32can_txmb0empty
+ *
+ * Input Parameter:
+ * tsr_regval - value of CAN transmit status register
+ *
+ * Returned Value:
+ * Returns true if mailbox 0 is empty and can be used for sending.
+ *
+ ****************************************************************************/
+
+static bool stm32can_txmb0empty(uint32_t tsr_regval)
+{
+ return (tsr_regval & CAN_TSR_TME0) != 0 &&
+ (tsr_regval & CAN_TSR_RQCP0) == 0;
+}
+
+/****************************************************************************
+ * Name: stm32can_txmb1empty
+ *
+ * Input Parameter:
+ * tsr_regval - value of CAN transmit status register
+ *
+ * Returned Value:
+ * Returns true if mailbox 1 is empty and can be used for sending.
+ *
+ ****************************************************************************/
+
+static bool stm32can_txmb1empty(uint32_t tsr_regval)
+{
+ return (tsr_regval & CAN_TSR_TME1) != 0 &&
+ (tsr_regval & CAN_TSR_RQCP1) == 0;
+}
+
+/****************************************************************************
+ * Name: stm32can_txmb2empty
+ *
+ * Input Parameter:
+ * tsr_regval - value of CAN transmit status register
+ *
+ * Returned Value:
+ * Returns true if mailbox 2 is empty and can be used for sending.
+ *
+ ****************************************************************************/
+
+static bool stm32can_txmb2empty(uint32_t tsr_regval)
+{
+ return (tsr_regval & CAN_TSR_TME2) != 0 &&
+ (tsr_regval & CAN_TSR_RQCP2) == 0;
+}
+
/****************************************************************************
* Public Functions
****************************************************************************/
diff --git a/arch/arm/src/stm32/stm32_can.h b/arch/arm/src/stm32/stm32_can.h
index 765dc95c0ca0ed3acf645eaf64777df65831de14..f06231ab60a49fc50e24d8dbf233b0732838cfe0 100644
--- a/arch/arm/src/stm32/stm32_can.h
+++ b/arch/arm/src/stm32/stm32_can.h
@@ -45,7 +45,7 @@
#include "chip.h"
#include "chip/stm32_can.h"
-#include
+#include
/************************************************************************************
* Pre-processor Definitions
diff --git a/arch/arm/src/stm32/stm32_comp.c b/arch/arm/src/stm32/stm32_comp.c
new file mode 100644
index 0000000000000000000000000000000000000000..b580f853987cb8390de8047e5eac783717aec101
--- /dev/null
+++ b/arch/arm/src/stm32/stm32_comp.c
@@ -0,0 +1,1037 @@
+/****************************************************************************
+ * arch/arm/src/stm32/stm32_comp.c
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include
+
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+
+#include "chip.h"
+#include "stm32_gpio.h"
+#include "stm32_comp.h"
+
+/* Some COMP peripheral must be enabled */
+/* Up to 7 comparators in STM32F3 Series */
+
+#if defined(CONFIG_STM32_COMP1) || defined(CONFIG_STM32_COMP2) || \
+ defined(CONFIG_STM32_COMP3) || defined(CONFIG_STM32_COMP4) || \
+ defined(CONFIG_STM32_COMP5) || defined(CONFIG_STM32_COMP6) || \
+ defined(CONFIG_STM32_COMP7)
+
+#ifndef CONFIG_STM32_SYSCFG
+# error "SYSCFG clock enable must be set"
+#endif
+
+/* @TODO: support for STM32F30XX and STM32F37XX comparators */
+
+#if defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX) || \
+ defined(CONFIG_STM32_STM32F37XX)
+
+/* Currently only STM32F33XX supported */
+
+#if defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F37XX)
+# error "Not supported yet"
+#endif
+
+#if defined(CONFIG_STM32_STM32F33XX)
+# if defined(CONFIG_STM32_COMP1) || defined(CONFIG_STM32_COMP3) || \
+ defined(CONFIG_STM32_COMP5) || defined(CONFIG_STM32_COMP7)
+# error "STM32F33 supports only COMP2, COMP4 and COMP6"
+# endif
+#endif
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* COMP2 default configuration **********************************************/
+
+#ifdef CONFIG_STM32_COMP2
+# ifndef COMP2_BLANLKING
+# define COMP2_BLANKING COMP_BLANKING_DEFAULT
+# endif
+# ifndef COMP2_POL
+# define COMP2_POL COMP_BLANKING_DEFAULT
+# endif
+# ifndef COMP2_INM
+# define COMP2_INM COMP_INM_DEFAULT
+# endif
+# ifndef COMP2_OUTSEL
+# define COMP2_OUTSEL COMP_OUTSEL_DEFAULT
+# endif
+# ifndef COMP2_LOCK
+# define COMP2_LOCK COMP_LOCK_DEFAULT
+# endif
+#endif
+
+/* COMP4 default configuration **********************************************/
+
+#ifdef CONFIG_STM32_COMP4
+# ifndef COMP4_BLANLKING
+# define COMP4_BLANKING COMP_BLANKING_DEFAULT
+# endif
+# ifndef COMP4_POL
+# define COMP4_POL COMP_BLANKING_DEFAULT
+# endif
+# ifndef COMP4_INM
+# define COMP4_INM COMP_INM_DEFAULT
+# endif
+# ifndef COMP4_OUTSEL
+# define COMP4_OUTSEL COMP_OUTSEL_DEFAULT
+# endif
+# ifndef COMP4_LOCK
+# define COMP4_LOCK COMP_LOCK_DEFAULT
+# endif
+#endif
+
+/* COMP6 default configuration **********************************************/
+
+#ifdef CONFIG_STM32_COMP6
+# ifndef COMP6_BLANLKING
+# define COMP6_BLANKING COMP_BLANKING_DEFAULT
+# endif
+# ifndef COMP6_POL
+# define COMP6_POL COMP_BLANKING_DEFAULT
+# endif
+# ifndef COMP6_INM
+# define COMP6_INM COMP_INM_DEFAULT
+# endif
+# ifndef COMP6_OUTSEL
+# define COMP6_OUTSEL COMP_OUTSEL_DEFAULT
+# endif
+# ifndef COMP6_LOCK
+# define COMP6_LOCK COMP_LOCK_DEFAULT
+# endif
+#endif
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+/* This structure describes the configuration of one COMP device */
+
+struct stm32_comp_s
+{
+ uint8_t blanking; /* Blanking source */
+ uint8_t pol; /* Output polarity */
+ uint8_t inm; /* Inverting input selection */
+ uint8_t out; /* Comparator output */
+ uint8_t lock; /* Comparator Lock */
+ uint32_t csr; /* Control and status register */
+#ifndef CONFIG_STM32_STM32F33XX
+ uint8_t mode; /* Comparator mode */
+ uint8_t hyst; /* Comparator hysteresis */
+ /* @TODO: Window mode + INP selection */
+#endif
+};
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+/* COMP Register access */
+
+static inline void comp_modify_csr(FAR struct stm32_comp_s *priv,
+ uint32_t clearbits, uint32_t setbits);
+static inline uint32_t comp_getreg_csr(FAR struct stm32_comp_s *priv);
+static inline void comp_putreg_csr(FAR struct stm32_comp_s *priv,
+ uint32_t value);
+static bool stm32_complock_get(FAR struct stm32_comp_s *priv);
+static int stm32_complock(FAR struct stm32_comp_s *priv, bool lock);
+
+/* COMP Driver Methods */
+
+static void comp_shutdown(FAR struct comp_dev_s *dev);
+static int comp_setup(FAR struct comp_dev_s *dev);
+static int comp_read(FAR struct comp_dev_s *dev);
+static int comp_ioctl(FAR struct comp_dev_s *dev, int cmd, unsigned long arg);
+
+/* Initialization */
+
+static int stm32_compconfig(FAR struct stm32_comp_s *priv);
+static int stm32_compenable(FAR struct stm32_comp_s *priv, bool enable);
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static const struct comp_ops_s g_compops =
+{
+ .ao_shutdown = comp_shutdown,
+ .ao_setup = comp_setup,
+ .ao_read = comp_read,
+ .ao_ioctl = comp_ioctl,
+};
+
+#ifdef CONFIG_STM32_COMP1
+static struct stm32_comp_s g_comp1priv =
+{
+ .blanking = COMP1_BLANKING,
+ .pol = COMP1_POL,
+ .inm = COMP1_INM,
+ .out = COMP1_OUTSEL,
+ .lock = COMP1_LOCK,
+ .csr = STM32_COMP1_CSR,
+#ifndef CONFIG_STM32_STM32F33XX
+ .mode = COMP1_MODE,
+ .hyst = COMP1_HYST,
+#endif
+};
+
+static struct comp_dev_s g_comp1dev =
+{
+ .ad_ops = &g_compops,
+ .ad_priv = &g_comp1priv,
+};
+#endif
+
+#ifdef CONFIG_STM32_COMP2
+static struct stm32_comp_s g_comp2priv =
+{
+ .blanking = COMP2_BLANKING,
+ .pol = COMP2_POL,
+ .inm = COMP2_INM,
+ .out = COMP2_OUTSEL,
+ .lock = COMP2_LOCK,
+ .csr = STM32_COMP2_CSR,
+#ifndef CONFIG_STM32_STM32F33XX
+ .mode = COMP2_MODE,
+ .hyst = COMP2_HYST,
+#endif
+};
+
+static struct comp_dev_s g_comp2dev =
+{
+ .ad_ops = &g_compops,
+ .ad_priv = &g_comp2priv,
+};
+#endif
+
+#ifdef CONFIG_STM32_COMP3
+static struct stm32_comp_s g_comp3priv =
+{
+ .blanking = COMP3_BLANKING,
+ .pol = COMP3_POL,
+ .inm = COMP3_INM,
+ .out = COMP3_OUTSEL,
+ .lock = COMP3_LOCK,
+ .csr = STM32_COMP3_CSR,
+#ifndef CONFIG_STM32_STM32F33XX
+ .mode = COMP3_MODE,
+ .hyst = COMP3_HYST,
+#endif
+};
+
+static struct comp_dev_s g_comp3dev =
+{
+ .ad_ops = &g_compops,
+ .ad_priv = &g_comp3priv,
+};
+#endif
+
+#ifdef CONFIG_STM32_COMP4
+static struct stm32_comp_s g_comp4priv =
+{
+ .blanking = COMP4_BLANKING,
+ .pol = COMP4_POL,
+ .inm = COMP4_INM,
+ .out = COMP4_OUTSEL,
+ .lock = COMP4_LOCK,
+ .csr = STM32_COMP4_CSR,
+#ifndef CONFIG_STM32_STM32F33XX
+ .mode = COMP4_MODE,
+ .hyst = COMP4_HYST,
+#endif
+};
+
+static struct comp_dev_s g_comp4dev =
+{
+ .ad_ops = &g_compops,
+ .ad_priv = &g_comp4priv,
+};
+#endif
+
+#ifdef CONFIG_STM32_COMP5
+static struct stm32_comp_s g_comp5priv =
+{
+ .blanking = COMP5_BLANKING,
+ .pol = COMP5_POL,
+ .inm = COMP5_INM,
+ .out = COMP5_OUTSEL,
+ .lock = COMP5_LOCK,
+ .csr = STM32_COMP5_CSR,
+#ifndef CONFIG_STM32_STM32F33XX
+ .mode = COMP5_MODE,
+ .hyst = COMP5_HYST,
+#endif
+};
+
+static struct comp_dev_s g_comp5dev =
+{
+ .ad_ops = &g_compops,
+ .ad_priv = &g_comp5priv,
+};
+#endif
+
+#ifdef CONFIG_STM32_COMP6
+static struct stm32_comp_s g_comp6priv =
+{
+ .blanking = COMP6_BLANKING,
+ .pol = COMP6_POL,
+ .inm = COMP6_INM,
+ .out = COMP6_OUTSEL,
+ .lock = COMP6_LOCK,
+ .csr = STM32_COMP6_CSR,
+#ifndef CONFIG_STM32_STM32F33XX
+ .mode = COMP6_MODE,
+ .hyst = COMP6_HYST,
+#endif
+};
+
+static struct comp_dev_s g_comp6dev =
+{
+ .ad_ops = &g_compops,
+ .ad_priv = &g_comp6priv,
+};
+#endif
+
+#ifdef CONFIG_STM32_COMP7
+static struct stm32_comp_s g_comp7priv =
+{
+ .blanking = COMP7_BLANKING,
+ .pol = COMP7_POL,
+ .inm = COMP7_INM,
+ .out = COMP7_OUTSEL,
+ .lock = COMP7_LOCK,
+ .csr = STM32_COMP7_CSR,
+#ifndef CONFIG_STM32_STM32F33XX
+ .mode = COMP7_MODE,
+ .hyst = COMP7_HYST,
+#endif
+};
+
+static struct comp_dev_s g_comp7dev =
+{
+ .ad_ops = &g_compops,
+ .ad_priv = &g_comp7priv,
+};
+#endif
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: comp_modify_csr
+ *
+ * Description:
+ * Modify the value of a 32-bit COMP CSR register (not atomic).
+ *
+ * Input Parameters:
+ * priv - A reference to the COMP structure
+ * clrbits - The bits to clear
+ * setbits - The bits to set
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+static inline void comp_modify_csr(FAR struct stm32_comp_s *priv,
+ uint32_t clearbits, uint32_t setbits)
+{
+ uint32_t csr = priv->csr;
+
+ modifyreg32(csr, clearbits, setbits);
+}
+
+/****************************************************************************
+ * Name: comp_getreg_csr
+ *
+ * Description:
+ * Read the value of an COMP CSR register
+ *
+ * Input Parameters:
+ * priv - A reference to the COMP structure
+ *
+ * Returned Value:
+ * The current contents of the COMP CSR register
+ *
+ ****************************************************************************/
+
+static inline uint32_t comp_getreg_csr(FAR struct stm32_comp_s *priv)
+{
+ uint32_t csr = priv->csr;
+
+ return getreg32(csr);
+}
+
+/****************************************************************************
+ * Name: comp_putreg_csr
+ *
+ * Description:
+ * Write a value to an COMP register.
+ *
+ * Input Parameters:
+ * priv - A reference to the COMP structure
+ * value - The value to write to the COMP CSR register
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+static inline void comp_putreg_csr(FAR struct stm32_comp_s *priv,
+ uint32_t value)
+{
+ uint32_t csr = priv->csr;
+
+ putreg32(value, csr);
+}
+
+/****************************************************************************
+ * Name: stm32_comp_complock_get
+ *
+ * Description:
+ * Get COMP lock bit state
+ *
+ * Input Parameters:
+ * priv - A reference to the COMP structure
+ *
+ * Returned Value:
+ * True if COMP locked, false if not locked
+ *
+ ****************************************************************************/
+
+static bool stm32_complock_get(FAR struct stm32_comp_s *priv)
+{
+ uint32_t regval;
+
+ regval = comp_getreg_csr(priv);
+
+ return (((regval & COMP_CSR_LOCK) == 0) ? false : true);
+}
+
+/****************************************************************************
+ * Name: stm32_complock
+ *
+ * Description:
+ * Lock comparator CSR register
+ *
+ * Input Parameters:
+ * priv - A reference to the COMP structure
+ * enable - lock flag
+ *
+ * Returned Value:
+ * 0 on success, a negated errno value on failure
+ *
+ ****************************************************************************/
+
+static int stm32_complock(FAR struct stm32_comp_s *priv, bool lock)
+{
+ bool current;
+
+ current = stm32_complock_get(priv);
+
+ if (current)
+ {
+ if (lock == false)
+ {
+ aerr("ERROR: COMP LOCK can be cleared only by a system reset\n");
+
+ return -EPERM;
+ }
+ }
+ else
+ {
+ if (lock == true)
+ {
+ comp_modify_csr(priv, 0, COMP_CSR_LOCK);
+
+ priv->lock = COMP_LOCK_RO;
+ }
+ }
+
+ return OK;
+}
+
+/****************************************************************************
+ * Name: stm32_compconfig
+ *
+ * Description:
+ * Configure comparator and used I/Os
+ *
+ * Input Parameters:
+ * priv - A reference to the COMP structure
+ *
+ * Returned Value:
+ * 0 on success, a negated errno value on failure
+ *
+ * REVISIT: Where to config comparator output pin ?
+ *
+ ****************************************************************************/
+
+static int stm32_compconfig(FAR struct stm32_comp_s *priv)
+{
+ uint32_t regval = 0;
+ int index;
+
+ /* Get comparator index */
+
+ switch (priv->csr)
+ {
+#ifdef CONFIG_STM32_COMP1
+ case STM32_COMP1_CSR:
+ index = 1;
+ break;
+#endif
+
+ case STM32_COMP2_CSR:
+ index = 2;
+ break;
+
+#ifdef CONFIG_STM32_COMP3
+ case STM32_COMP3_CSR:
+ index = 3;
+ break;
+#endif
+
+ case STM32_COMP4_CSR:
+ index = 4;
+ break;
+
+#ifdef CONFIG_STM32_COMP5
+ case STM32_COMP5_CSR:
+ index = 5;
+ break;
+#endif
+
+ case STM32_COMP6_CSR:
+ index = 6;
+ break;
+
+#ifdef CONFIG_STM32_COMP7
+ case STM32_COMP7_CSR:
+ index = 7;
+ break;
+#endif
+
+ default:
+ return -EINVAL;
+ }
+
+ /* Configure non inverting input */
+
+ switch (index)
+ {
+#ifdef CONFIG_STM32_COMP2
+ case 2:
+ stm32_configgpio(GPIO_COMP2_INP);
+ break;
+#endif
+
+#ifdef CONFIG_STM32_COMP4
+ case 4:
+ stm32_configgpio(GPIO_COMP4_INP);
+ break;
+#endif
+
+#ifdef CONFIG_STM32_COMP6
+ case 6:
+ stm32_configgpio(GPIO_COMP6_INP);
+ break;
+#endif
+
+ default:
+ return -EINVAL;
+ }
+
+ /* Set Comparator inverting input */
+
+ switch (priv->inm)
+ {
+ case COMP_INMSEL_1P4VREF:
+ regval |= COMP_CSR_INMSEL_1P4VREF;
+ break;
+
+ case COMP_INMSEL_1P2VREF:
+ regval |= COMP_CSR_INMSEL_1P2VREF;
+ break;
+
+ case COMP_INMSEL_3P4VREF:
+ regval |= COMP_CSR_INMSEL_3P4VREF;
+ break;
+
+ case COMP_INMSEL_VREF:
+ regval |= COMP_CSR_INMSEL_VREF;
+ break;
+
+ case COMP_INMSEL_DAC1CH1:
+ regval |= COMP_CSR_INMSEL_DAC1CH1;
+ break;
+
+ case COMP_INMSEL_DAC1CH2:
+ regval |= COMP_CSR_INMSEL_DAC1CH2;
+ break;
+
+ case COMP_INMSEL_PIN:
+ {
+ /* INMSEL PIN configuration dependent on COMP index */
+
+ switch (index)
+ {
+#ifdef CONFIG_STM32_COMP2
+ case 2:
+ {
+ stm32_configgpio(GPIO_COMP2_INM);
+ regval |= COMP_CSR_INMSEL_PA2;
+ break;
+ }
+#endif
+#ifdef CONFIG_STM32_COMP4
+ case 4:
+ {
+ /* COMP4_INM can be PB2 or PA4 */
+
+ stm32_configgpio(GPIO_COMP4_INM);
+ regval |= (GPIO_COMP4_INM == GPIO_COMP4_INM_1 ? COMP_CSR_INMSEL_PB2 : COMP_CSR_INMSEL_PA4);
+ break;
+ }
+#endif
+#ifdef CONFIG_STM32_COMP6
+ case 6:
+ {
+ /* COMP6_INM can be PB15 or PA4 */
+
+ stm32_configgpio(GPIO_COMP6_INM);
+ regval |= (GPIO_COMP6_INM == GPIO_COMP6_INM_1 ? COMP_CSR_INMSEL_PB15 : COMP_CSR_INMSEL_PA4);
+ break;
+ }
+#endif
+ default :
+ return -EINVAL;
+ }
+
+ break;
+ }
+
+ default:
+ return -EINVAL;
+ }
+
+ /* Set Comparator output selection */
+
+ switch (priv->out)
+ {
+ case COMP_OUTSEL_NOSEL:
+ regval |= COMP_CSR_OUTSEL_NOSEL;
+ break;
+
+ case COMP_OUTSEL_BRKACTH:
+ regval |= COMP_CSR_OUTSEL_BRKACTH;
+ break;
+
+ case COMP_OUTSEL_BRK2:
+ regval |= COMP_CSR_OUTSEL_BRK2;
+ break;
+
+ case COMP_OUTSEL_T1OCC:
+ regval |= COMP_CSR_OUTSEL_T1OCC;
+ break;
+
+ case COMP_OUTSEL_T3CAP3:
+ regval |= COMP_CSR_OUTSEL_T3CAP3;
+ break;
+
+ case COMP_OUTSEL_T2CAP2:
+ regval |= COMP_CSR_OUTSEL_T2CAP2;
+ break;
+
+ case COMP_OUTSEL_T1CAP1:
+ regval |= COMP_CSR_OUTSEL_T1CAP1;
+ break;
+
+ case COMP_OUTSEL_T2CAP4:
+ regval |= COMP_CSR_OUTSEL_T2CAP4;
+ break;
+
+ case COMP_OUTSEL_T15CAP2:
+ regval |= COMP_CSR_OUTSEL_T15CAP2;
+ break;
+
+ case COMP_OUTSEL_T2OCC:
+ if (index == 2)
+ {
+ regval |= COMP2_CSR_OUTSEL_T2OCC;
+ }
+ else if (index == 6)
+ {
+ regval |= COMP6_CSR_OUTSEL_T2OCC;
+ }
+
+ break;
+
+ case COMP_OUTSEL_T16OCC:
+ regval |= COMP_CSR_OUTSEL_T16OCC;
+ break;
+
+ case COMP_OUTSEL_T3CAP1:
+ regval |= COMP_CSR_OUTSEL_T3CAP1;
+ break;
+
+ case COMP_OUTSEL_T15OCC:
+ regval |= COMP_CSR_OUTSEL_T15OCC;
+ break;
+
+ case COMP_OUTSEL_T16CAP1:
+ regval |= COMP_CSR_OUTSEL_T16CAP1;
+ break;
+
+ case COMP_OUTSEL_T3OCC:
+ regval |= COMP_CSR_OUTSEL_T3OCC;
+ break;
+
+ default:
+ return -EINVAL;
+ }
+
+ /* Set Comparator output polarity */
+
+ regval |= (priv->pol == COMP_POL_INVERTED ? COMP_CSR_POL : 0);
+
+ /* Set Comparator output blanking source */
+
+ switch (priv->blanking)
+ {
+ case COMP_BLANKING_DIS:
+ regval |= COMP_CSR_BLANKING_DIS;
+ break;
+
+ case COMP_BLANKING_T1OC5:
+ regval |= COMP_CSR_BLANKING_T1OC5;
+ break;
+
+ case COMP_BLANKING_T3OC4:
+ regval |= COMP_CSR_BLANKING_T3OC4;
+ break;
+
+ case COMP_BLANKING_T2OC3:
+ regval |= COMP_CSR_BLANKING_T2OC3;
+ break;
+
+ case COMP_BLANKING_T15OC1:
+ regval |= COMP_CSR_BLANKING_T15OC1;
+ break;
+
+ case COMP_BLANKING_T2OC4:
+ regval |= COMP_CSR_BLANKING_T2OC4;
+ break;
+
+ case COMP_BLANKING_T15OC2:
+ regval |= COMP_CSR_BLANKING_T15OC1;
+ break;
+
+ default:
+ return -EINVAL;
+ }
+
+ /* Save CSR register */
+
+ comp_putreg_csr(priv, regval);
+
+ /* Enable Comparator */
+
+ stm32_compenable(priv, true);
+
+ /* Lock Comparator if needed */
+
+ if (priv->lock == COMP_LOCK_RO)
+ {
+ stm32_complock(priv, true);
+ }
+
+ return OK;
+}
+
+/****************************************************************************
+ * Name: stm32_compenable
+ *
+ * Description:
+ * Enable/disable comparator
+ *
+ * Input Parameters:
+ * priv - A reference to the COMP structure
+ * enable - enable/disable flag
+ *
+ * Returned Value:
+ * 0 on success, a negated errno value on failure
+ *
+ ****************************************************************************/
+
+static int stm32_compenable(FAR struct stm32_comp_s *priv, bool enable)
+{
+ bool lock;
+
+ ainfo("enable: %d\n", enable ? 1 : 0);
+
+ lock = stm32_complock_get(priv);
+
+ if (lock)
+ {
+ aerr("ERROR: Comparator locked!\n");
+
+ return -EPERM;
+ }
+ else
+ {
+ if (enable)
+ {
+ /* Enable the COMP */
+
+ comp_modify_csr(priv, 0, COMP_CSR_COMPEN);
+ }
+ else
+ {
+ /* Disable the COMP */
+
+ comp_modify_csr(priv, COMP_CSR_COMPEN, 0);
+ }
+ }
+
+ return OK;
+}
+
+/****************************************************************************
+ * Name: adc_setup
+ *
+ * Description:
+ * Configure the COMP. This method is called the first time that the COMP
+ * device is opened. This will occur when the port is first opened.
+ * This setup includes configuring and attaching COMP interrupts.
+ * Interrupts are all disabled upon return.
+ *
+ * Input Parameters:
+ *
+ * Returned Value:
+ *
+ ****************************************************************************/
+
+static int comp_setup(FAR struct comp_dev_s *dev)
+{
+#warning "Missing logic"
+ return OK;
+}
+
+/****************************************************************************
+ * Name: comp_shutdown
+ *
+ * Description:
+ * Disable the COMP. This method is called when the COMP device is closed.
+ * This method reverses the operation the setup method.
+ * Works only if COMP device is not locked.
+ *
+ * Input Parameters:
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+static void comp_shutdown(FAR struct comp_dev_s *dev)
+{
+#warning "Missing logic"
+}
+
+/****************************************************************************
+ * Name: comp_read
+ *
+ * Description:
+ * Get the COMP output state.
+ *
+ * Input Parameters:
+ *
+ * Returned Value:
+ * 0 if output is low (non-inverting input below inverting input),
+ * 1 if output is high (non inverting input above inverting input).
+ *
+ ****************************************************************************/
+
+static int comp_read(FAR struct comp_dev_s *dev)
+{
+ FAR struct stm32_comp_s *priv;
+ uint32_t regval;
+
+ priv = dev->ad_priv;
+ regval = comp_getreg_csr(priv);
+
+ return (((regval & COMP_CSR_OUT) == 0) ? 0 : 1);
+}
+
+/****************************************************************************
+ * Name: comp_ioctl
+ *
+ * Description:
+ * All ioctl calls will be routed through this method.
+ *
+ * Input Parameters:
+ * dev - pointer to device structure used by the driver
+ * cmd - command
+ * arg - arguments passed with command
+ *
+ * Returned Value:
+ * Zero on success; a negated errno value on failure.
+ *
+ ****************************************************************************/
+
+static int comp_ioctl(FAR struct comp_dev_s *dev, int cmd, unsigned long arg)
+{
+#warning "Missing logic"
+ return -ENOTTY;
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: stm32_compinitialize
+ *
+ * Description:
+ * Initialize the COMP.
+ *
+ * Input Parameters:
+ * intf - The COMP interface number.
+ *
+ * Returned Value:
+ * Valid COMP device structure reference on succcess; a NULL on failure.
+ *
+ * Assumptions:
+ * 1. Clock to the COMP block has enabled,
+ * 2. Board-specific logic has already configured
+ *
+ ****************************************************************************/
+
+FAR struct comp_dev_s* stm32_compinitialize(int intf)
+{
+ FAR struct comp_dev_s *dev;
+ FAR struct stm32_comp_s *comp;
+ int ret;
+
+ switch (intf)
+ {
+#ifdef CONFIG_STM32_COMP1
+ case 1:
+ ainfo("COMP1 selected\n");
+ dev = &g_comp1dev;
+ break;
+#endif
+
+#ifdef CONFIG_STM32_COMP2
+ case 2:
+ ainfo("COMP2 selected\n");
+ dev = &g_comp2dev;
+ break;
+#endif
+
+#ifdef CONFIG_STM32_COMP3
+ case 3:
+ ainfo("COMP3 selected\n");
+ dev = &g_comp3dev;
+ break;
+#endif
+
+#ifdef CONFIG_STM32_COMP4
+ case 4:
+ ainfo("COMP4 selected\n");
+ dev = &g_comp4dev;
+ break;
+#endif
+
+#ifdef CONFIG_STM32_COMP5
+ case 5:
+ ainfo("COMP5 selected\n");
+ dev = &g_comp5dev;
+ break;
+#endif
+
+#ifdef CONFIG_STM32_COMP6
+ case 6:
+ ainfo("COMP6 selected\n");
+ dev = &g_comp6dev;
+ break;
+#endif
+
+#ifdef CONFIG_STM32_COMP7
+ case 7:
+ ainfo("COMP7 selected\n");
+ dev = &g_comp7dev;
+ break;
+#endif
+
+ default:
+ aerr("ERROR: No COMP interface defined\n");
+ return NULL;
+ }
+
+ /* Configure selected comparator */
+
+ comp = dev->ad_priv;
+
+ ret = stm32_compconfig(comp);
+ if (ret < 0)
+ {
+ aerr("ERROR: Failed to initialize COMP%d: %d\n", intf, ret);
+ errno = -ret;
+ return NULL;
+ }
+
+ return dev;
+}
+
+#endif /* CONFIG_STM32_STM32F30XX || CONFIG_STM32_STM32F33XX ||
+ * CONFIG_STM32_STM32F37XX*/
+
+#endif /* CONFIG_STM32_COMP2 || CONFIG_STM32_COMP4 ||
+ * CONFIG_STM32_COMP6 */
diff --git a/arch/arm/src/stm32/stm32_comp.h b/arch/arm/src/stm32/stm32_comp.h
new file mode 100644
index 0000000000000000000000000000000000000000..ab28cac186a79f9ed99285abe411abee160fee41
--- /dev/null
+++ b/arch/arm/src/stm32/stm32_comp.h
@@ -0,0 +1,217 @@
+/************************************************************************************
+ * arch/arm/src/stm32/stm32_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_STM32_COMP_H
+#define __ARCH_ARM_SRC_STM32_STM32_COMP_H
+
+/************************************************************************************
+ * Included Files
+ ************************************************************************************/
+
+#include
+
+#include "chip.h"
+
+#ifdef CONFIG_STM32_COMP
+
+#if defined(CONFIG_STM32_STM32F30XX)
+# error "COMP support for STM32F30XX not implemented yet"
+#elif defined(CONFIG_STM32_STM32F33XX)
+# include "chip/stm32f33xxx_comp.h"
+#elif defined(CONFIG_STM32_STM32F37XX)
+# error "COMP support for STM32F37XX ot implemented yet"
+#endif
+
+/************************************************************************************
+ * Pre-processor definitions
+ ************************************************************************************/
+
+#define COMP_BLANKING_DEFAULT COMP_BLANKING_DIS /* No blanking */
+#define COMP_POL_DEFAULT COMP_POL_NONINVERT /* Output is not inverted */
+#define COMP_INM_DEFAULT COMP_INMSEL_1P4VREF /* 1/4 of Vrefint as INM */
+#define COMP_OUTSEL_DEFAULT COMP_OUTSEL_NOSEL /* Output not selected */
+#define COMP_LOCK_DEFAULT COMP_LOCK_RW /* Do not lock CSR register */
+
+#ifndef CONFIG_STM32_STM32F33XX
+#define COMP_MODE_DEFAULT
+#define COMP_HYST_DEFAULT
+#define COMP_WINMODE_DEFAULT
+#endif
+
+/************************************************************************************
+ * Public Types
+ ************************************************************************************/
+
+/* Blanking source */
+
+enum stm32_comp_blanking_e
+{
+ COMP_BLANKING_DIS,
+#if defined(CONFIG_STM32_STM32F33XX)
+ COMP_BLANKING_T1OC5,
+ COMP_BLANKING_T3OC4,
+ COMP_BLANKING_T2OC3,
+ COMP_BLANKING_T3OC3,
+ COMP_BLANKING_T15OC1,
+ COMP_BLANKING_T2OC4,
+ COMP_BLANKING_T15OC2,
+#endif
+};
+
+/* Output polarisation */
+
+enum stm32_comp_pol_e
+{
+ COMP_POL_NONINVERT,
+ COMP_POL_INVERTED
+};
+
+/* Inverting input */
+
+enum stm32_comp_inm_e
+{
+ COMP_INMSEL_1P4VREF,
+ COMP_INMSEL_1P2VREF,
+ COMP_INMSEL_3P4VREF,
+ COMP_INMSEL_VREF,
+ COMP_INMSEL_DAC1CH1,
+ COMP_INMSEL_DAC1CH2,
+ COMP_INMSEL_PIN
+};
+
+/* Output selection */
+
+enum stm32_comp_outsel_e
+{
+ COMP_OUTSEL_NOSEL,
+#if defined(CONFIG_STM32_STM32F33XX)
+ COMP_OUTSEL_BRKACTH,
+ COMP_OUTSEL_BRK2,
+ COMP_OUTSEL_T1OCC, /* COMP2 only */
+ COMP_OUTSEL_T3CAP3, /* COMP4 only */
+ COMP_OUTSEL_T2CAP2, /* COMP6 only */
+ COMP_OUTSEL_T1CAP1, /* COMP2 only */
+ COMP_OUTSEL_T2CAP4, /* COMP2 only */
+ COMP_OUTSEL_T15CAP2, /* COMP4 only */
+ COMP_OUTSEL_T2OCC, /* COMP6 only */
+ COMP_OUTSEL_T16OCC, /* COMP2 only */
+ COMP_OUTSEL_T3CAP1, /* COMP2 only */
+ COMP_OUTSEL_T15OCC, /* COMP4 only */
+ COMP_OUTSEL_T16CAP1, /* COMP6 only */
+ COMP_OUTSEL_T3OCC, /* COMP2 and COMP4 only */
+#endif
+};
+
+/* CSR register lock state */
+
+enum stm32_comp_lock_e
+{
+ COMP_LOCK_RW,
+ COMP_LOCK_RO
+};
+
+#ifndef CONFIG_STM32_STM32F33XX
+
+/* Hysteresis */
+
+enum stm32_comp_hyst_e
+{
+ COMP_HYST_DIS,
+ COMP_HYST_LOW,
+ COMP_HYST_MEDIUM,
+ COMP_HYST_HIGH
+};
+
+/* Power/Speed Modes */
+
+enum stm32_comp_mode_e
+{
+ COMP_MODE_HIGHSPEED,
+ COMP_MODE_MEDIUMSPEED,
+ COMP_MODE_LOWPOWER,
+ COMP_MODE_ULTRALOWPOWER
+};
+
+/* Window mode */
+
+enum stm32_comp_winmode_e
+{
+ COMP_WINMODE_DIS,
+ COMP_WINMODE_EN
+};
+
+#endif
+
+/************************************************************************************
+ * Public Function Prototypes
+ ************************************************************************************/
+
+#ifndef __ASSEMBLY__
+#ifdef __cplusplus
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+/****************************************************************************
+* Name: stm32_compinitialize
+*
+* Description:
+* Initialize the COMP.
+*
+* Input Parameters:
+* intf - The COMP interface number.
+*
+* Returned Value:
+* Valid COMP device structure reference on succcess; a NULL on failure.
+*
+* Assumptions:
+* 1. Clock to the COMP block has enabled,
+* 2. Board-specific logic has already configured
+*
+****************************************************************************/
+
+FAR struct comp_dev_s* stm32_compinitialize(int intf);
+
+#undef EXTERN
+#ifdef __cplusplus
+}
+#endif
+#endif /* __ASSEMBLY__ */
+
+#endif /* CONFIG_STM23_COMP */
+#endif /* __ARCH_ARM_SRC_STM32_STM32_COMP_H */
diff --git a/arch/arm/src/stm32/stm32_dma.c b/arch/arm/src/stm32/stm32_dma.c
index 0de9cdcc3b8df55c4bb1985f5ea0ea42a1145367..9118c586d4898e70bb3486cf1602531ffed4237c 100644
--- a/arch/arm/src/stm32/stm32_dma.c
+++ b/arch/arm/src/stm32/stm32_dma.c
@@ -56,9 +56,10 @@
*/
#if defined(CONFIG_STM32_STM32L15XX) || defined(CONFIG_STM32_STM32F10XX) || \
- defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX) || \
- defined(CONFIG_STM32_STM32F37XX)
+ defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F37XX)
# include "stm32f10xxx_dma.c"
+#elif defined(CONFIG_STM32_STM32F33XX)
+# include "stm32f33xxx_dma.c"
#elif defined(CONFIG_STM32_STM32F20XX)
# include "stm32f20xxx_dma.c"
#elif defined(CONFIG_STM32_STM32F40XX)
diff --git a/arch/arm/src/stm32/stm32_dma.h b/arch/arm/src/stm32/stm32_dma.h
index 36c21f3ca60dac26256368a80d4b97a7faaa6ad5..ceee4e0867cd5a8988431526339a1e3431b42031 100644
--- a/arch/arm/src/stm32/stm32_dma.h
+++ b/arch/arm/src/stm32/stm32_dma.h
@@ -48,9 +48,10 @@
/* 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_STM32F33XX) || \
- defined(CONFIG_STM32_STM32F37XX)
+ defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F37XX)
# include "chip/stm32f10xxx_dma.h"
+#elif defined(CONFIG_STM32_STM32F33XX)
+# include "chip/stm32f33xxx_dma.h"
#elif defined(CONFIG_STM32_STM32F20XX)
# include "chip/stm32f20xxx_dma.h"
#elif defined(CONFIG_STM32_STM32F40XX)
@@ -93,7 +94,7 @@
typedef FAR void *DMA_HANDLE;
/* Description:
- * This is the type of the callback that is used to inform the user of the the
+ * This is the type of the callback that is used to inform the user of the
* completion of the DMA.
*
* Input Parameters:
diff --git a/arch/arm/src/stm32/stm32_eth.c b/arch/arm/src/stm32/stm32_eth.c
index 7703a9a745e803e3e95aafa6cdbd169c2c5195f1..77493cd880c7f13a007b60e04ef7aee96cee11cd 100644
--- a/arch/arm/src/stm32/stm32_eth.c
+++ b/arch/arm/src/stm32/stm32_eth.c
@@ -54,6 +54,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -90,9 +91,7 @@
# error "Logic to support multiple Ethernet interfaces is incomplete"
#endif
-/* If processing is not done at the interrupt level, then work queue support
- * is required.
- */
+/* Work queue support is required. */
#if !defined(CONFIG_SCHED_WORKQUEUE)
# error Work queue support is required
@@ -191,6 +190,42 @@
# endif
#endif
+/* These definitions are used to enable the PHY interrupts */
+
+#if defined(CONFIG_NETDEV_PHY_IOCTL) && defined(CONFIG_ARCH_PHY_INTERRUPT)
+# if defined( CONFIG_ETH0_PHY_AM79C874)
+# error missing logic
+# elif defined( CONFIG_ETH0_PHY_KS8721)
+# error missing logic
+# elif defined( CONFIG_ETH0_PHY_KSZ8041)
+# error missing logic
+# elif defined( CONFIG_ETH0_PHY_KSZ8051)
+# error missing logic
+# elif defined( CONFIG_ETH0_PHY_KSZ8061)
+# error missing logic
+# elif defined( CONFIG_ETH0_PHY_KSZ8081)
+# define MII_INT_REG MII_KSZ8081_INT
+# define MII_INT_SETEN MII_KSZ80x1_INT_LDEN | MII_KSZ80x1_INT_LUEN
+# define MII_INT_CLREN 0
+# elif defined( CONFIG_ETH0_PHY_KSZ90x1)
+# error missing logic
+# elif defined( CONFIG_ETH0_PHY_DP83848C)
+# error missing logic
+# elif defined( CONFIG_ETH0_PHY_LAN8720)
+# error missing logic
+# elif defined( CONFIG_ETH0_PHY_LAN8740)
+# error missing logic
+# elif defined( CONFIG_ETH0_PHY_LAN8740A)
+# error missing logic
+# elif defined( CONFIG_ETH0_PHY_LAN8742A)
+# error missing logic
+# elif defined( CONFIG_ETH0_PHY_DM9161)
+# error missing logic
+# else
+# error unknown PHY
+# endif
+#endif
+
#ifdef CONFIG_STM32_ETH_PTP
# warning "CONFIG_STM32_ETH_PTP is not yet supported"
#endif
@@ -637,7 +672,8 @@ static void stm32_checksetup(void);
static void stm32_initbuffer(FAR struct stm32_ethmac_s *priv);
static inline uint8_t *stm32_allocbuffer(FAR struct stm32_ethmac_s *priv);
-static inline void stm32_freebuffer(FAR struct stm32_ethmac_s *priv, uint8_t *buffer);
+static inline void stm32_freebuffer(FAR struct stm32_ethmac_s *priv,
+ uint8_t *buffer);
static inline bool stm32_isfreebuffer(FAR struct stm32_ethmac_s *priv);
/* Common TX logic */
@@ -648,11 +684,13 @@ static void stm32_dopoll(FAR struct stm32_ethmac_s *priv);
/* Interrupt handling */
-static void stm32_enableint(FAR struct stm32_ethmac_s *priv, uint32_t ierbit);
-static void stm32_disableint(FAR struct stm32_ethmac_s *priv, uint32_t ierbit);
+static void stm32_enableint(FAR struct stm32_ethmac_s *priv,
+ uint32_t ierbit);
+static void stm32_disableint(FAR struct stm32_ethmac_s *priv,
+ uint32_t ierbit);
static void stm32_freesegment(FAR struct stm32_ethmac_s *priv,
- FAR struct eth_rxdesc_s *rxfirst, int segments);
+ FAR struct eth_rxdesc_s *rxfirst, int segments);
static int stm32_recvframe(FAR struct stm32_ethmac_s *priv);
static void stm32_receive(FAR struct stm32_ethmac_s *priv);
static void stm32_freeframe(FAR struct stm32_ethmac_s *priv);
@@ -684,7 +722,8 @@ static int stm32_addmac(struct net_driver_s *dev, FAR const uint8_t *mac);
static int stm32_rmmac(struct net_driver_s *dev, FAR const uint8_t *mac);
#endif
#ifdef CONFIG_NETDEV_PHY_IOCTL
-static int stm32_ioctl(struct net_driver_s *dev, int cmd, long arg);
+static int stm32_ioctl(struct net_driver_s *dev, int cmd,
+ unsigned long arg);
#endif
/* Descriptor Initialization */
@@ -699,9 +738,11 @@ static int stm32_phyintenable(FAR struct stm32_ethmac_s *priv);
#endif
#if defined(CONFIG_STM32_AUTONEG) || defined(CONFIG_NETDEV_PHY_IOCTL) || \
defined(CONFIG_ETH0_PHY_DM9161)
-static int stm32_phyread(uint16_t phydevaddr, uint16_t phyregaddr, uint16_t *value);
+static int stm32_phyread(uint16_t phydevaddr, uint16_t phyregaddr,
+ uint16_t *value);
#endif
-static int stm32_phywrite(uint16_t phydevaddr, uint16_t phyregaddr, uint16_t value);
+static int stm32_phywrite(uint16_t phydevaddr, uint16_t phyregaddr,
+ uint16_t value);
#ifdef CONFIG_ETH0_PHY_DM9161
static inline int stm32_dm9161(FAR struct stm32_ethmac_s *priv);
#endif
@@ -1547,7 +1588,7 @@ static int stm32_recvframe(FAR struct stm32_ethmac_s *priv)
{
priv->segments++;
- /* Check if the there is only one segment in the frame */
+ /* Check if there is only one segment in the frame */
if (priv->segments == 1)
{
@@ -2807,7 +2848,7 @@ static void stm32_rxdescinit(FAR struct stm32_ethmac_s *priv)
****************************************************************************/
#ifdef CONFIG_NETDEV_PHY_IOCTL
-static int stm32_ioctl(struct net_driver_s *dev, int cmd, long arg)
+static int stm32_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
{
#ifdef CONFIG_ARCH_PHY_INTERRUPT
FAR struct stm32_ethmac_s *priv = (FAR struct stm32_ethmac_s *)dev->d_private;
@@ -2885,8 +2926,19 @@ static int stm32_ioctl(struct net_driver_s *dev, int cmd, long arg)
#if defined(CONFIG_NETDEV_PHY_IOCTL) && defined(CONFIG_ARCH_PHY_INTERRUPT)
static int stm32_phyintenable(struct stm32_ethmac_s *priv)
{
-#warning Missing logic
- return -ENOSYS;
+ uint16_t phyval;
+ int ret;
+
+ ret = stm32_phyread(CONFIG_STM32_PHYADDR, MII_INT_REG, &phyval);
+ if (ret == OK)
+ {
+ /* Enable link up/down interrupts */
+
+ ret = stm32_phywrite(CONFIG_STM32_PHYADDR, MII_INT_REG,
+ (phyval & ~MII_INT_CLREN) | MII_INT_SETEN);
+ }
+
+ return ret;
}
#endif
@@ -3670,22 +3722,22 @@ static void stm32_macaddress(FAR struct stm32_ethmac_s *priv)
ninfo("%s MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
dev->d_ifname,
- dev->d_mac.ether_addr_octet[0], dev->d_mac.ether_addr_octet[1],
- dev->d_mac.ether_addr_octet[2], dev->d_mac.ether_addr_octet[3],
- dev->d_mac.ether_addr_octet[4], dev->d_mac.ether_addr_octet[5]);
+ dev->d_mac.ether.ether_addr_octet[0], dev->d_mac.ether.ether_addr_octet[1],
+ dev->d_mac.ether.ether_addr_octet[2], dev->d_mac.ether.ether_addr_octet[3],
+ dev->d_mac.ether.ether_addr_octet[4], dev->d_mac.ether.ether_addr_octet[5]);
/* Set the MAC address high register */
- regval = ((uint32_t)dev->d_mac.ether_addr_octet[5] << 8) |
- (uint32_t)dev->d_mac.ether_addr_octet[4];
+ regval = ((uint32_t)dev->d_mac.ether.ether_addr_octet[5] << 8) |
+ (uint32_t)dev->d_mac.ether.ether_addr_octet[4];
stm32_putreg(regval, STM32_ETH_MACA0HR);
/* Set the MAC address low register */
- regval = ((uint32_t)dev->d_mac.ether_addr_octet[3] << 24) |
- ((uint32_t)dev->d_mac.ether_addr_octet[2] << 16) |
- ((uint32_t)dev->d_mac.ether_addr_octet[1] << 8) |
- (uint32_t)dev->d_mac.ether_addr_octet[0];
+ regval = ((uint32_t)dev->d_mac.ether.ether_addr_octet[3] << 24) |
+ ((uint32_t)dev->d_mac.ether.ether_addr_octet[2] << 16) |
+ ((uint32_t)dev->d_mac.ether.ether_addr_octet[1] << 8) |
+ (uint32_t)dev->d_mac.ether.ether_addr_octet[0];
stm32_putreg(regval, STM32_ETH_MACA0LR);
}
diff --git a/arch/arm/src/stm32/stm32_flash.c b/arch/arm/src/stm32/stm32_flash.c
index 9ac38a19a137f81185880877f823f862a274745a..1dae18724c562a5405aa6ad9b1b45175015352b3 100644
--- a/arch/arm/src/stm32/stm32_flash.c
+++ b/arch/arm/src/stm32/stm32_flash.c
@@ -47,6 +47,10 @@
#include
#include
+
+#include
+#include
+#include
#include
#include "stm32_flash.h"
@@ -55,10 +59,10 @@
#include "up_arch.h"
-/* Only for the STM32F[1|3|4]0xx family for now */
+/* Only for the STM32F[1|3|4]0xx family and STM32L15xx (EEPROM only) for now */
#if defined(CONFIG_STM32_STM32F10XX) || defined(CONFIG_STM32_STM32F30XX) || \
- defined (CONFIG_STM32_STM32F40XX)
+ defined (CONFIG_STM32_STM32F40XX) || defined(CONFIG_STM32_STM32L15XX)
#if defined(CONFIG_STM32_FLASH_CONFIG_DEFAULT) && \
(defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX))
@@ -69,25 +73,53 @@
* Pre-processor Definitions
************************************************************************************/
-#define FLASH_KEY1 0x45670123
-#define FLASH_KEY2 0xCDEF89AB
+#if defined(CONFIG_STM32_STM32L15XX)
+# define FLASH_KEY1 0x8C9DAEBF
+# define FLASH_KEY2 0x13141516
+#else
+# define FLASH_KEY1 0x45670123
+# define FLASH_KEY2 0xCDEF89AB
+#endif
#if defined(CONFIG_STM32_STM32F10XX) || defined(CONFIG_STM32_STM32F30XX)
-#define FLASH_CR_PAGE_ERASE FLASH_CR_PER
-#define FLASH_SR_WRITE_PROTECTION_ERROR FLASH_SR_WRPRT_ERR
+# define FLASH_CR_PAGE_ERASE FLASH_CR_PER
+# define FLASH_SR_WRITE_PROTECTION_ERROR FLASH_SR_WRPRT_ERR
#elif defined(CONFIG_STM32_STM32F40XX)
-#define FLASH_CR_PAGE_ERASE FLASH_CR_SER
-#define FLASH_SR_WRITE_PROTECTION_ERROR FLASH_SR_WRPERR
+# define FLASH_CR_PAGE_ERASE FLASH_CR_SER
+# define FLASH_SR_WRITE_PROTECTION_ERROR FLASH_SR_WRPERR
+#endif
+
+#if defined(CONFIG_STM32_STM32L15XX)
+# define EEPROM_KEY1 0x89ABCDEF
+# define EEPROM_KEY2 0x02030405
#endif
/************************************************************************************
- * Private Functions
+ * Private Data
************************************************************************************/
+static sem_t g_sem = SEM_INITIALIZER(1);
+
/************************************************************************************
- * Public Functions
+ * Private Functions
************************************************************************************/
-void stm32_flash_unlock(void)
+
+static void sem_lock(void)
+{
+ while (sem_wait(&g_sem) < 0)
+ {
+ DEBUGASSERT(errno == EINTR);
+ }
+}
+
+static inline void sem_unlock(void)
+{
+ sem_post(&g_sem);
+}
+
+#if !defined(CONFIG_STM32_STM32L15XX)
+
+static void flash_unlock(void)
{
while (getreg32(STM32_FLASH_SR) & FLASH_SR_BSY)
{
@@ -103,14 +135,256 @@ void stm32_flash_unlock(void)
}
}
-void stm32_flash_lock(void)
+static void flash_lock(void)
{
modifyreg32(STM32_FLASH_CR, 0, FLASH_CR_LOCK);
}
+#endif /* !defined(CONFIG_STM32_STM32L15XX) */
-#if defined(CONFIG_STM32_STM32F10XX) || defined(CONFIG_STM32_STM32F30XX)
+#if defined(CONFIG_STM32_FLASH_WORKAROUND_DATA_CACHE_CORRUPTION_ON_RWW)
+static void data_cache_disable(void)
+{
+ modifyreg32(STM32_FLASH_ACR, FLASH_ACR_DCEN, 0);
+}
+
+static void data_cache_enable(void)
+{
+ /* Reset data cache */
+
+ modifyreg32(STM32_FLASH_ACR, 0, FLASH_ACR_DCRST);
+
+ /* Enable data cache */
+
+ modifyreg32(STM32_FLASH_ACR, 0, FLASH_ACR_DCEN);
+}
+#endif /* defined(CONFIG_STM32_FLASH_WORKAROUND_DATA_CACHE_CORRUPTION_ON_RWW) */
+
+#if defined(CONFIG_STM32_STM32L15XX)
+
+static void stm32_eeprom_unlock(void)
+{
+ while (getreg32(STM32_FLASH_SR) & FLASH_SR_BSY)
+ {
+ up_waste();
+ }
+
+ if (getreg32(STM32_FLASH_PECR) & FLASH_PECR_PELOCK)
+ {
+ /* Unlock sequence */
+
+ putreg32(EEPROM_KEY1, STM32_FLASH_PEKEYR);
+ putreg32(EEPROM_KEY2, STM32_FLASH_PEKEYR);
+ }
+}
+
+static void stm32_eeprom_lock(void)
+{
+ modifyreg32(STM32_FLASH_PECR, 0, FLASH_PECR_PELOCK);
+}
+
+static void flash_unlock(void)
+{
+ if (getreg32(STM32_FLASH_PECR) & FLASH_PECR_PRGLOCK)
+ {
+ stm32_eeprom_unlock();
+
+ /* Unlock sequence */
+
+ putreg32(FLASH_KEY1, STM32_FLASH_PRGKEYR);
+ putreg32(FLASH_KEY2, STM32_FLASH_PRGKEYR);
+ }
+}
+
+static void flash_lock(void)
+{
+ modifyreg32(STM32_FLASH_PECR, 0, FLASH_PECR_PRGLOCK);
+ stm32_eeprom_lock();
+}
+
+static ssize_t stm32_eeprom_erase_write(size_t addr, const void *buf,
+ size_t buflen)
+{
+ const char *cbuf = buf;
+ size_t i;
+
+ if (buflen == 0)
+ {
+ return 0;
+ }
+
+ /* Check for valid address range */
+
+ if (addr >= STM32_EEPROM_BASE)
+ {
+ addr -= STM32_EEPROM_BASE;
+ }
+
+ if (addr >= STM32_EEPROM_SIZE)
+ {
+ return -EINVAL;
+ }
+
+ /* TODO: Voltage range must be range 1 or 2. Erase/program not allowed in
+ * range 3.
+ */
+
+ stm32_eeprom_unlock();
+
+ /* Clear pending status flags. */
+
+ putreg32(FLASH_SR_WRPERR | FLASH_SR_PGAERR |
+ FLASH_SR_SIZERR | FLASH_SR_OPTVERR |
+ FLASH_SR_OPTVERRUSR | FLASH_SR_RDERR, STM32_FLASH_SR);
+
+ /* Enable automatic erasing (by disabling 'fixed time' programming). */
+
+ modifyreg32(STM32_FLASH_PECR, FLASH_PECR_FTDW, 0);
+ /* Write buffer to EEPROM data memory. */
+
+ addr += STM32_EEPROM_BASE;
+ i = 0;
+ while (i < buflen)
+ {
+ uint32_t writeval;
+ size_t left = buflen - i;
+
+ if ((addr & 0x03) == 0x00 && left >= 4)
+ {
+ /* Read/erase/write word */
+
+ writeval = cbuf ? *(uint32_t *)cbuf : 0;
+ putreg32(writeval, addr);
+ }
+ else if ((addr & 0x01) == 0x00 && left >= 2)
+ {
+ /* Read/erase/write half-word */
+
+ writeval = cbuf ? *(uint16_t *)cbuf : 0;
+ putreg16(writeval, addr);
+ }
+ else
+ {
+ /* Read/erase/write byte */
+
+ writeval = cbuf ? *(uint8_t *)cbuf : 0;
+ putreg8(writeval, addr);
+ }
+
+ /* ... and wait to complete. */
+
+ while (getreg32(STM32_FLASH_SR) & FLASH_SR_BSY)
+ {
+ up_waste();
+ }
+
+ /* Verify */
+
+ /* We do not check Options Byte invalid flags FLASH_SR_OPTVERR
+ * and FLASH_SR_OPTVERRUSR for EEPROM erase/write. They are unrelated
+ * and STM32L standard library does not check for these either.
+ */
+
+ if (getreg32(STM32_FLASH_SR) & (FLASH_SR_WRPERR | FLASH_SR_PGAERR |
+ FLASH_SR_SIZERR | FLASH_SR_RDERR))
+ {
+ stm32_eeprom_lock();
+ return -EROFS;
+ }
+
+ if ((addr & 0x03) == 0x00 && left >= 4)
+ {
+ if (getreg32(addr) != writeval)
+ {
+ stm32_eeprom_lock();
+ return -EIO;
+ }
+
+ addr += 4;
+ i += 4;
+ cbuf += !!(cbuf) * 4;
+ }
+ else if ((addr & 0x01) == 0x00 && left >= 2)
+ {
+ if (getreg16(addr) != writeval)
+ {
+ stm32_eeprom_lock();
+ return -EIO;
+ }
+
+ addr += 2;
+ i += 2;
+ cbuf += !!(cbuf) * 2;
+ }
+ else
+ {
+ if (getreg8(addr) != writeval)
+ {
+ stm32_eeprom_lock();
+ return -EIO;
+ }
+
+ addr += 1;
+ i += 1;
+ cbuf += !!(cbuf) * 1;
+ }
+ }
+
+ stm32_eeprom_lock();
+ return buflen;
+}
+
+#endif /* defined(CONFIG_STM32_STM32L15XX) */
+
+/************************************************************************************
+ * Public Functions
+ ************************************************************************************/
+
+void stm32_flash_unlock(void)
+{
+ sem_lock();
+ flash_unlock();
+ sem_unlock();
+}
+
+void stm32_flash_lock(void)
+{
+ sem_lock();
+ flash_lock();
+ sem_unlock();
+}
+
+#if defined(CONFIG_STM32_STM32L15XX)
+
+size_t stm32_eeprom_size(void)
+{
+ return STM32_EEPROM_SIZE;
+}
+
+size_t stm32_eeprom_getaddress(void)
+{
+ return STM32_EEPROM_BASE;
+}
+
+ssize_t stm32_eeprom_write(size_t addr, const void *buf, size_t buflen)
+{
+ if (!buf)
+ {
+ return -EINVAL;
+ }
+
+ return stm32_eeprom_erase_write(addr, buf, buflen);
+}
+
+ssize_t stm32_eeprom_erase(size_t addr, size_t eraselen)
+{
+ return stm32_eeprom_erase_write(addr, NULL, eraselen);
+}
+
+#endif /* defined(CONFIG_STM32_STM32L15XX) */
+
+#if defined(CONFIG_STM32_STM32F10XX) || defined(CONFIG_STM32_STM32F30XX)
size_t up_progmem_pagesize(size_t page)
{
return STM32_FLASH_PAGESIZE;
@@ -206,6 +480,8 @@ size_t up_progmem_getaddress(size_t page)
#endif /* def CONFIG_STM32_STM32F40XX */
+#if !defined(CONFIG_STM32_STM32L15XX)
+
size_t up_progmem_npages(void)
{
return STM32_FLASH_NPAGES;
@@ -217,30 +493,33 @@ bool up_progmem_isuniform(void)
return true;
#else
return false;
-#endif /* def STM32_FLASH_PAGESIZE */
+#endif
}
ssize_t up_progmem_erasepage(size_t page)
{
#if defined(CONFIG_STM32_STM32F10XX) || defined(CONFIG_STM32_STM32F30XX)
size_t page_address;
-#endif /* defined(CONFIG_STM32_STM32F10XX) || defined(CONFIG_STM32_STM32F30XX) */
+#endif
if (page >= STM32_FLASH_NPAGES)
{
return -EFAULT;
}
+ sem_lock();
+
#if !defined(CONFIG_STM32_STM32F40XX)
if (!(getreg32(STM32_RCC_CR) & RCC_CR_HSION))
{
+ sem_unlock();
return -EPERM;
}
#endif
/* Get flash ready and begin erasing single page */
- stm32_flash_unlock();
+ flash_unlock();
modifyreg32(STM32_FLASH_CR, 0, FLASH_CR_PAGE_ERASE);
@@ -259,6 +538,7 @@ ssize_t up_progmem_erasepage(size_t page)
while (getreg32(STM32_FLASH_SR) & FLASH_SR_BSY) up_waste();
modifyreg32(STM32_FLASH_CR, FLASH_CR_PAGE_ERASE, 0);
+ sem_unlock();
/* Verify */
if (up_progmem_ispageerased(page) == 0)
@@ -320,16 +600,23 @@ ssize_t up_progmem_write(size_t addr, const void *buf, size_t count)
return -EFAULT;
}
+ sem_lock();
+
#if !defined(CONFIG_STM32_STM32F40XX)
if (!(getreg32(STM32_RCC_CR) & RCC_CR_HSION))
{
+ sem_unlock();
return -EPERM;
}
#endif
/* Get flash ready and begin flashing */
- stm32_flash_unlock();
+ flash_unlock();
+
+#if defined(CONFIG_STM32_FLASH_WORKAROUND_DATA_CACHE_CORRUPTION_ON_RWW)
+ data_cache_disable();
+#endif
modifyreg32(STM32_FLASH_CR, 0, FLASH_CR_PG);
@@ -351,19 +638,29 @@ ssize_t up_progmem_write(size_t addr, const void *buf, size_t count)
if (getreg32(STM32_FLASH_SR) & FLASH_SR_WRITE_PROTECTION_ERROR)
{
modifyreg32(STM32_FLASH_CR, FLASH_CR_PG, 0);
+ sem_unlock();
return -EROFS;
}
if (getreg16(addr) != *hword)
{
modifyreg32(STM32_FLASH_CR, FLASH_CR_PG, 0);
+ sem_unlock();
return -EIO;
}
}
modifyreg32(STM32_FLASH_CR, FLASH_CR_PG, 0);
+
+#if defined(CONFIG_STM32_FLASH_WORKAROUND_DATA_CACHE_CORRUPTION_ON_RWW)
+ data_cache_enable();
+#endif
+
+ sem_unlock();
return written;
}
+#endif /* !defined(CONFIG_STM32_STM32L15XX) */
+
#endif /* defined(CONFIG_STM32_STM32F10XX) || defined(CONFIG_STM32_STM32F30XX) || \
- defined (CONFIG_STM32_STM32F40XX) */
+ defined(CONFIG_STM32_STM32F40XX) || defined(CONFIG_STM32_STM32L15XX) */
diff --git a/arch/arm/src/stm32/stm32_flash.h b/arch/arm/src/stm32/stm32_flash.h
index 10c5cc189ed8ee159aa0d0bc5ee900867d6064b4..6da1b0b70343096d86ca20bcf1e400ccfdf32638 100644
--- a/arch/arm/src/stm32/stm32_flash.h
+++ b/arch/arm/src/stm32/stm32_flash.h
@@ -46,4 +46,60 @@
#include "chip.h"
#include "chip/stm32_flash.h"
+/************************************************************************************
+ * Public Function Prototypes
+ ************************************************************************************/
+
+/************************************************************************************
+ * Name: stm32_eeprom_size
+ *
+ * Description:
+ * Get EEPROM data memory size
+ *
+ * Returns:
+ * Length of EEPROM memory region
+ *
+ ************************************************************************************/
+
+size_t stm32_eeprom_size(void);
+
+/************************************************************************************
+ * Name: stm32_eeprom_getaddress
+ *
+ * Description:
+ * Get EEPROM data memory address
+ *
+ * Returns:
+ * Address of EEPROM memory region
+ *
+ ************************************************************************************/
+
+size_t stm32_eeprom_getaddress(void);
+
+/************************************************************************************
+ * Name: stm32_eeprom_write
+ *
+ * Description:
+ * Write buffer to EEPROM data memory address
+ *
+ * Returns:
+ * Number of written bytes or error code.
+ *
+ ************************************************************************************/
+
+ssize_t stm32_eeprom_write(size_t addr, const void *buf, size_t buflen);
+
+/************************************************************************************
+ * Name: stm32_eeprom_erase
+ *
+ * Description:
+ * Erase memory on EEPROM data memory address
+ *
+ * Returns:
+ * Number of erased bytes or error code.
+ *
+ ************************************************************************************/
+
+ssize_t stm32_eeprom_erase(size_t addr, size_t eraselen);
+
#endif /* __ARCH_ARM_SRC_STM32_STM32_FLASH_H */
diff --git a/arch/arm/src/stm32/stm32_freerun.c b/arch/arm/src/stm32/stm32_freerun.c
index 673b0412d7813f64d6ce6c5caa4d9f6296bbe7eb..f631aa0aa5e22bbafc49b5a8aa1c446fbf1063c6 100644
--- a/arch/arm/src/stm32/stm32_freerun.c
+++ b/arch/arm/src/stm32/stm32_freerun.c
@@ -137,6 +137,7 @@ int stm32_freerun_initialize(struct stm32_freerun_s *freerun, int chan,
*/
freerun->chan = chan;
+ freerun->width = STM32_TIM_GETWIDTH(freerun->tch);
freerun->running = false;
#ifdef CONFIG_CLOCK_TIMEKEEPING
@@ -153,7 +154,7 @@ int stm32_freerun_initialize(struct stm32_freerun_s *freerun, int chan,
/* Set timer period */
- STM32_TIM_SETPERIOD(freerun->tch, UINT32_MAX);
+ STM32_TIM_SETPERIOD(freerun->tch, (uint32_t)((1ull << freerun->width) - 1));
/* Start the counter */
@@ -248,7 +249,8 @@ int stm32_freerun_counter(struct stm32_freerun_s *freerun,
* usecs = (ticks * USEC_PER_SEC) / frequency;
*/
- usec = ((((uint64_t)overflow << 32) + (uint64_t)counter) * USEC_PER_SEC) /
+ usec = ((((uint64_t)overflow << freerun->width) +
+ (uint64_t)counter) * USEC_PER_SEC) /
freerun->frequency;
/* And return the value of the timer */
diff --git a/arch/arm/src/stm32/stm32_freerun.h b/arch/arm/src/stm32/stm32_freerun.h
index bc7609666cfe40a91b2b6ad22c7f17f314b80292..b263367d16c681be546401c4d8a9da646511ae8d 100644
--- a/arch/arm/src/stm32/stm32_freerun.h
+++ b/arch/arm/src/stm32/stm32_freerun.h
@@ -63,6 +63,7 @@
struct stm32_freerun_s
{
uint8_t chan; /* The timer/counter in use */
+ uint8_t width; /* Width of timer (16- or 32-bits) */
bool running; /* True: the timer is running */
FAR struct stm32_tim_dev_s *tch; /* Handle returned by stm32_tim_init() */
uint32_t frequency;
diff --git a/arch/arm/src/stm32/stm32_hrtim.c b/arch/arm/src/stm32/stm32_hrtim.c
new file mode 100644
index 0000000000000000000000000000000000000000..a99f37fc5f1cbbe1bd222f959ad9eff5d238dd27
--- /dev/null
+++ b/arch/arm/src/stm32/stm32_hrtim.c
@@ -0,0 +1,1908 @@
+/****************************************************************************
+ * arch/arm/src/stm32/stm32_hrtim.c
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include
+
+#include
+#include
+#include
+#include
+
+#include
+
+#include "chip.h"
+#include "stm32.h"
+#include "stm32_gpio.h"
+#include "stm32_hrtim.h"
+
+#if defined(CONFIG_STM32_HRTIM1)
+
+/* Only STM32F33XXX */
+
+#if defined(CONFIG_STM32_STM32F33XX)
+
+#ifdef CONFIG_STM32_HRTIM_ADC
+# error HRTIM ADC Triggering not supported yet
+#endif
+
+#ifdef CONFIG_STM32_HRTIM_FAULT
+# error HRTIM Faults not supported yet
+#endif
+
+#ifdef CONFIG_STM32_HRTIM_EEV
+# error HRTIM External Events not supported yet
+#endif
+
+#ifdef CONFIG_STM32_HRTIM_BURST
+# error HRTIM Burst mode not supported yet
+#endif
+
+#ifdef CONFIG_STM32_HRTIM_IRQ
+# error HRTIM Interrupts not supported yet
+#endif
+
+#ifdef CONFIG_STM32_HRTIM_DMA
+# error HRTIM DMA not supported yet
+#endif
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* HRTIM default configuration **********************************************/
+
+#ifndef HRTIM_TIMER_MASTER
+# define HRTIM_MASTER_PRESCALER HRTIM_PRESCALER_2
+#endif
+
+/* HRTIM clock source configuration */
+
+#ifdef CONFIG_STM32_HRTIM_CLK_FROM_PLL
+# if STM32_SYSCLK_SW == RCC_CFGR_SW_PLL
+# if (STM32_RCC_CFGR_PPRE2 != RCC_CFGR_PPRE2_HCLK) && \
+ (STM32_RCC_CFGR_PPRE2 != RCC_CFGR_PPRE2_HCLKd2)
+# error "APB2 prescaler factor can not be greater than 2"
+# else
+# define HRTIM_HAVE_CLK_FROM_PLL 1
+# define HRTIM_CLOCK 2*STM32_PLL_FREQUENCY
+# endif
+# else
+# error "Clock system must be set to PLL"
+# endif
+#else
+# define HRTIM_HAVE_CLK_FROM_APB2 1
+# if STM32_RCC_CFGR_PPRE2 == RCC_CFGR_PPRE2_HCLK
+# define HRTIM_CLOCK STM32_PCLK2_FREQUENCY
+# else
+# define HRTIM_CLOCK 2*STM32_PCLK2_FREQUENCY
+# endif
+#endif
+
+#if defined(CONFIG_STM32_HRTIM_TIMA) || defined(CONFIG_STM32_HRTIM_TIMB) || \
+ defined(CONFIG_STM32_HRTIM_TIMC) || defined(CONFIG_STM32_HRTIM_TIMD) || \
+ defined(CONFIG_STM32_HRTIM_TIME)
+# define HRTIM_HAVE_SLAVE 1
+#endif
+
+#if defined(CONFIG_STM32_HRTIM_TIMA_PWM) || defined(CONFIG_STM32_HRTIM_TIMB_PWM) || \
+ defined(CONFIG_STM32_HRTIM_TIMC_PWM) || defined(CONFIG_STM32_HRTIM_TIMD_PWM) || \
+ defined(CONFIG_STM32_HRTIM_TIME_PWM)
+# define HRTIM_HAVE_PWM 1
+#endif
+
+#if defined(CONFIG_STM32_HRTIM_TIMA_CAP) || defined(CONFIG_STM32_HRTIM_TIMB_CAP) || \
+ defined(CONFIG_STM32_HRTIM_TIMC_CAP) || defined(CONFIG_STM32_HRTIM_TIMD_CAP) || \
+ defined(CONFIG_STM32_HRTIM_TIME_CAP)
+# define HRTIM_HAVE_CAPTURE 1
+#endif
+
+#if defined(CONFIG_STM32_HRTIM_TIMA_DT) || defined(CONFIG_STM32_HRTIM_TIMB_DT) || \
+ defined(CONFIG_STM32_HRTIM_TIMC_DT) || defined(CONFIG_STM32_HRTIM_TIMD_DT) || \
+ defined(CONFIG_STM32_HRTIM_TIME_DT)
+# define HRTIM_HAVE_DEADTIME 1
+#endif
+
+#if defined(CONFIG_STM32_HRTIM_TIMA_CHOP) || defined(CONFIG_STM32_HRTIM_TIMB_CHOP) || \
+ defined(CONFIG_STM32_HRTIM_TIMC_CHOP) || defined(CONFIG_STM32_HRTIM_TIMD_CHOP) || \
+ defined(CONFIG_STM32_HRTIM_TIME_CHOP)
+# define HRTIM_HAVE_CHOPPER 1
+#endif
+
+#if defined(CONFIG_STM32_HRTIM_SCOUT) || defined(CONFIG_STM32_HRTIM_SCIN)
+# define HRTIM_HAVE_SYNC 1
+#endif
+
+#if defined(CONFIG_STM32_HRTIM_FAULT1) || defined(CONFIG_STM32_HRTIM_FAULT2) || \
+ defined(CONFIG_STM32_HRTIM_FAULT3) || defined(CONFIG_STM32_HRTIM_FAULT4) || \
+ defined(CONFIG_STM32_HRTIM_FAULT5)
+# define HRTIM_HAVE_FAULTS 1
+#endif
+
+#if defined(CONFIG_STM32_HRTIM_EEV1) || defined(CONFIG_STM32_HRTIM_EEV2) || \
+ defined(CONFIG_STM32_HRTIM_EEV3) || defined(CONFIG_STM32_HRTIM_EEV4) || \
+ defined(CONFIG_STM32_HRTIM_EEV5) || defined(CONFIG_STM32_HRTIM_EEV6) || \
+ defined(CONFIG_STM32_HRTIM_EEV7) || defined(CONFIG_STM32_HRTIM_EEV8) || \
+ defined(CONFIG_STM32_HRTIM_EEV9) || defined(CONFIG_STM32_HRTIM_EEV10)
+# define HRTIM_HAVE_EEV 1
+#endif
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+#ifdef HRTIM_HAVE_PWM
+
+/* HRTIM TimerX Single Output Set/Reset Configuration */
+
+struct stm32_hrtim_timout_s
+{
+ uint32_t set; /* Set events*/
+ uint32_t rst; /* Reset events*/
+};
+
+/* HRTIM TimerX Output Chopper Configuration */
+
+#ifdef HRTIM_HAVE_CHOPPER
+struct stm32_hrtim_chopper_s
+{
+ uint32_t reserved; /* reserved for future use */
+};
+#endif
+
+/* HRTIM TimerX Output Deadtime Configuration*/
+
+#ifdef HRTIM_HAVE_DEADTIME
+struct stm32_hrtim_deadtime_s
+{
+ uint32_t reserved; /* reserved for future use */
+};
+#endif
+
+/* HRTIM Timer PWM structure */
+
+struct stm32_hrtim_pwm_s
+{
+ struct stm32_hrtim_timout_s ch1; /* Channel 1 Set/Reset configuration*/
+ struct stm32_hrtim_timout_s ch2; /* Channel 2 Set/Reset configuration */
+
+#ifdef HRTIM_HAVE_CHOPPER
+ struct stm32_hrtim_chopper_s chp;
+#endif
+#ifdef HRTIM_HAVE_DEADTIME
+ struct stm32_hrtim_deadtime_s dt;
+#endif
+};
+
+#endif
+
+#ifdef HRTIM_HAVE_CAPTURE
+struct stm32_hrtim_capture_s
+{
+ uint32_t reserved; /* reserved for future use */
+}
+#endif
+
+/* Common data structure for Master Timer and Slave Timers*/
+
+struct stm32_hrtim_timcmn_s
+{
+ uint16_t cmp[4]; /* Compare registers */
+ uint32_t base; /* The base adress of the timer */
+ uint32_t frequency; /* Current frequency setting */
+ uint32_t pclk; /* The frequency of the peripheral clock
+ * that drives the timer module */
+#ifdef CONFIG_STM32_HRTIM_DMA
+ uint32_t dmaburst;
+#endif
+};
+
+/* Master Timer and Slave Timers structure */
+
+struct stm32_hrtim_tim_s
+{
+ struct stm32_hrtim_timcmn_s tim; /* Common Timer data */
+ FAR void *priv; /* Timer private data */
+};
+
+/* Master Timer private data structure */
+
+struct stm32_hrtim_master_priv_s
+{
+ uint32_t reserved; /* reserved for future use */
+};
+
+/* Slave Timer (A-E) private data structure */
+
+struct stm32_hrtim_slave_priv_s
+{
+ uint32_t reset; /* Timer reset events */
+#ifdef HRTIM_HAVE_PWM
+ struct stm32_hrtim_pwm_s pwm; /* PWM configuration */
+#endif
+#ifdef HRTIM_HAVE_CAPTURE
+ struct stm32_hrtim_capture_s cap; /* Capture configuration */
+#endif
+};
+
+#ifdef HRTIM_HAVE_FAULTS
+
+/* Structure describes single HRTIM Fault configuration */
+
+struct stm32_hrtim_fault_cfg_s
+{
+ uint8_t pol:1; /* Fault poalrity */
+ uint8_t src:1; /* Fault source */
+ uint8_t filter:4; /* Fault filter */
+ uint8_t flts:1; /* Fault Sampling clock division */
+ uint8_t lock:1; /* Fault lock */
+};
+
+/* Structure describes HRTIM Faults configuration */
+
+struct stm32_hrtim_faults_s
+{
+#ifdef CONFIG_STM32_HRTIM_FAULT1
+ struct stm32_hrtim_fault_cfg_s flt1;
+#endif
+#ifdef CONFIG_STM32_HRTIM_FAULT2
+ struct stm32_hrtim_fault_cfg_s flt2;
+#endif
+#ifdef CONFIG_STM32_HRTIM_FAULT3
+ struct stm32_hrtim_fault_cfg_s flt3;
+#endif
+#ifdef CONFIG_STM32_HRTIM_FAULT4
+ struct stm32_hrtim_fault_cfg_s flt4;
+#endif
+#ifdef CONFIG_STM32_HRTIM_FAULT5
+ struct stm32_hrtim_fault_cfg_s flt5;
+#endif
+};
+#endif
+
+#ifdef HRTIM_HAVE_EEV
+
+/* Structure describes single HRTIM External Event configuration */
+
+struct stm32_hrtim_eev_cfg_s
+{
+ uint8_t filter:4; /* External Event filter */
+ uint8_t src:4; /* External Event source */
+ uint8_t pol:1; /* External Event polarity */
+ uint8_t sen:1; /* External Event sensivity */
+ uint8_t mode:1; /* External Event mode */
+ uint8_t _res:5;
+};
+
+/* Structure describes HRTIM External Events configuration */
+
+struct stm32_hrtim_eev_s
+{
+#ifdef CONFIG_STM32_HRTIM_EEV1
+ struct stm32_hrtim_eev_cfg_s eev1;
+#endif
+#ifdef CONFIG_STM32_HRTIM_EEV2
+ struct stm32_hrtim_eev_cfg_s eev2;
+#endif
+#ifdef CONFIG_STM32_HRTIM_EEV3
+ struct stm32_hrtim_eev_cfg_s eev3;
+#endif
+#ifdef CONFIG_STM32_HRTIM_EEV4
+ struct stm32_hrtim_eev_cfg_s eev4;
+#endif
+#ifdef CONFIG_STM32_HRTIM_EEV5
+ struct stm32_hrtim_eev_cfg_s eev5;
+#endif
+#ifdef CONFIG_STM32_HRTIM_EEV6
+ struct stm32_hrtim_eev_cfg_s eev6;
+#endif
+#ifdef CONFIG_STM32_HRTIM_EEV7
+ struct stm32_hrtim_eev_cfg_s eev7;
+#endif
+#ifdef CONFIG_STM32_HRTIM_EEV8
+ struct stm32_hrtim_eev_cfg_s eev8;
+#endif
+#ifdef CONFIG_STM32_HRTIM_EEV9
+ struct stm32_hrtim_eev_cfg_s eev9;
+#endif
+#ifdef CONFIG_STM32_HRTIM_EEV10
+ struct stm32_hrtim_eev_cfg_s eev10;
+#endif
+};
+#endif
+
+/* This structure describes the configuration of HRTIM device */
+
+struct stm32_hrtim_s
+{
+ uint32_t base; /* Base adress of HRTIM block */
+ struct stm32_hrtim_tim_s *master; /* Master Timer */
+#ifdef CONFIG_STM32_HRTIM_TIMA
+ struct stm32_hrtim_tim_s *tima; /* HRTIM Timer A */
+#endif
+#ifdef CONFIG_STM32_HRTIM_TIMB
+ struct stm32_hrtim_tim_s *timb; /* HRTIM Timer B */
+#endif
+#ifdef CONFIG_STM32_HRTIM_TIMC
+ struct stm32_hrtim_tim_s *timc; /* HRTIM Timer C */
+#endif
+#ifdef CONFIG_STM32_HRTIM_TIMD
+ struct stm32_hrtim_tim_s *timd; /* HRTIM Timer D */
+#endif
+#ifdef CONFIG_STM32_HRTIM_TIME
+ struct stm32_hrtim_tim_s *time; /* HRTIM Timer E */
+#endif
+#ifdef HRTIM_HAVE_FAULTS
+ struct stm32_hrtim_faults_s *flt;
+#endif
+#ifdef HRTIM_HAVE_EEV
+ struct stm32_hrtim_eev_s *eev;
+#endif
+};
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+/* HRTIM Driver Methods */
+
+static int stm32_hrtim_open(FAR struct file *filep);
+static int stm32_hrtim_close(FAR struct file *filep);
+static int stm32_hrtim_ioctl(FAR struct file *filep, int cmd, unsigned long arg);
+
+/* HRTIM Register access */
+
+#ifdef HRTIM_HAVE_CLK_FROM_PLL
+static void stm32_modifyreg32(unsigned int addr, uint32_t clrbits,
+ uint32_t setbits);
+#endif
+static uint32_t hrtim_getreg(FAR struct stm32_hrtim_s *priv, int offset);
+static void hrtim_putreg(FAR struct stm32_hrtim_s *priv, int offset,
+ uint32_t value);
+static void hrtim_modifyreg(FAR struct stm32_hrtim_s *priv, int offset,
+ uint32_t clrbits, uint32_t setbits);
+static void hrtim_tim_putreg(FAR struct stm32_hrtim_s *priv, uint8_t index,
+ int offset, uint32_t value);
+static void hrtim_tim_modifyreg(FAR struct stm32_hrtim_s *priv, uint8_t index,
+ int offset, uint32_t clrbits, uint32_t setbits);
+
+/* HRTIM helper */
+
+static uint32_t hrtim_tim_getreg(FAR struct stm32_hrtim_s *priv, uint8_t index,
+ int offset);
+static FAR struct stm32_hrtim_tim_s *hrtim_tim_get(FAR struct stm32_hrtim_s *priv,
+ uint8_t index);
+
+/* Configuration */
+
+static int hrtim_dll_cal(FAR struct stm32_hrtim_s *priv);
+static int hrtim_tim_clock_config(FAR struct stm32_hrtim_s *priv, uint8_t index,
+ uint8_t pre);
+static int hrtim_tim_clocks_config(FAR struct stm32_hrtim_s *priv);
+#if defined(HRTIM_HAVE_CAPTURE) || defined(HRTIM_HAVE_PWM) || defined(HRTIM_HAVE_SYNC)
+static int hrtim_gpios_config(FAR struct stm32_hrtim_s *priv);
+#endif
+static void hrtim_preload_config(FAR struct stm32_hrtim_s *priv);
+#if defined(HRTIM_HAVE_CAPTURE)
+static int hrtim_inputs_config(FAR struct stm32_hrtim_s *priv);
+#endif
+#if defined(HRTIM_HAVE_SYNC)
+static int hrtim_synch_config(FAR struct stm32_hrtim_s *priv);
+#endif
+#if defined(HRTIM_HAVE_PWM)
+static int hrtim_outputs_config(FAR struct stm32_hrtim_s *priv);
+#endif
+#ifdef HRTIM_HAVE_ADC
+static int hrtim_adc_config(FAR struct stm32_hrtim_s *priv);
+#endif
+#ifdef HRTIM_HAVE_FAULTS
+static int hrtim_faults_config(FAR struct stm32_hrtim_s *priv);
+#endif
+#ifdef HRTIM_HAVE_EEV
+static int hrtim_eev_config(FAR struct stm32_hrtim_s *priv);
+#endif
+#ifdef HRTIM_HAVE_INTERRUPTS
+static int hrtim_irq_config(FAR struct stm32_hrtim_s *priv);
+#endif
+
+/* Initialization */
+
+static int stm32_hrtimconfig(FAR struct stm32_hrtim_s *priv);
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static const struct file_operations hrtim_fops =
+{
+ stm32_hrtim_open, /* open */
+ stm32_hrtim_close, /* close */
+ NULL, /* read */
+ NULL, /* write */
+ NULL, /* seek */
+ stm32_hrtim_ioctl /* ioctl */
+#ifndef CONFIG_DISABLE_POLL
+ , NULL /* poll */
+#endif
+#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
+ , NULL /* unlink */
+#endif
+};
+
+/* Master Timer data */
+
+static struct stm32_hrtim_tim_s g_master =
+{
+ .tim =
+ {
+ .base = STM32_HRTIM1_MASTER_BASE,
+ .pclk = HRTIM_CLOCK/HRTIM_MASTER_PRESCALER
+ },
+ .priv = NULL,
+};
+
+/* NOTE: only TIMER A data defined at this time */
+
+#ifdef CONFIG_STM32_HRTIM_TIMA
+
+/* Timer A private data */
+
+static struct stm32_hrtim_slave_priv_s g_tima_priv =
+{
+#ifdef CONFIG_STM32_HRTIM_TIMA_PWM
+ .pwm =
+ {
+ .ch1 =
+ {
+ .set = HRTIM_TIMA_CH1_SET,
+ .rst = HRTIM_TIMA_CH1_RST
+ },
+ .ch2 =
+ {
+ .set = HRTIM_TIMA_CH2_SET,
+ .rst = HRTIM_TIMA_CH2_RST
+ },
+#ifdef CONFIG_STM32_HRTIM_TIMA_CHOP
+ .chp =
+ {
+ .reserved = 0
+ },
+#endif
+#ifdef CONFIG_STM32_HRTIM_TIMA_DT
+ .dt =
+ {
+ .reserved = 0
+ }
+#endif
+ },
+#endif
+#ifdef CONFIG_STM32_HRTIM_TIMA_CAP
+ .cap =
+ {
+ .reserved = 0
+ }
+#endif
+};
+
+/* Timer A data */
+
+static struct stm32_hrtim_tim_s g_tima =
+{
+ .tim =
+ {
+ .base = STM32_HRTIM1_TIMERA_BASE,
+ .pclk = HRTIM_CLOCK/HRTIM_TIMA_PRESCALER
+ },
+ .priv = &g_tima_priv
+};
+
+#endif
+
+/* Faults data */
+#ifdef HRTIM_HAVE_FAULTS
+struct stm32_hrtim_faults_s g_flt =
+{
+#warning "missing faults data"
+};
+#endif
+
+/* External Events data */
+
+#ifdef HRTIM_HAVE_EEV
+struct stm32_hrtim_eev_s g_eev =
+{
+#warning "missing eev data"
+};
+#endif
+
+/* HRTIM1 private data */
+
+static struct stm32_hrtim_s g_hrtim1priv =
+{
+ .master = &g_master,
+ .base = STM32_HRTIM1_BASE,
+#ifdef CONFIG_STM32_HRTIM_TIMA
+ .tima = &g_tima,
+#endif
+#ifdef CONFIG_STM32_HRTIM_TIMB
+ .timb = &g_timb,
+#endif
+#ifdef CONFIG_STM32_HRTIM_TIMC
+ .timc = &g_timc,
+#endif
+#ifdef CONFIG_STM32_HRTIM_TIMD
+ .timd = &g_timd,
+#endif
+#ifdef CONFIG_STM32_HRTIM_TIME
+ .time = &g_time,
+#endif
+#ifdef HRTIM_HAVE_FAULTS
+ .flt = &g_flt;
+#endif
+#ifdef HRTIM_HAVE_EEV
+ .flt = &g_eev;
+#endif
+};
+
+struct hrtim_dev_s g_hrtim1dev =
+{
+ .hd_priv = &g_hrtim1priv,
+};
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: stm32_hrtim_open
+ *
+ * Description:
+ * This function is called whenever the HRTIM device is opened.
+ *
+ ****************************************************************************/
+
+static int stm32_hrtim_open(FAR struct file *filep)
+{
+#warning "stm32_hrtim_open: missing logic"
+ return OK;
+}
+
+/****************************************************************************
+ * Name: stm32_hrtim_close
+ *
+ * Description:
+ * This function is called when the HRTIM device is closed.
+ *
+ ****************************************************************************/
+
+static int stm32_hrtim_close(FAR struct file *filep)
+{
+#warning "smt32_hrtim_close: missing logic"
+ return OK;
+}
+
+/****************************************************************************
+ * Name: stm32_hrtim_ioctl
+ *
+ * Description:
+ * The standard ioctl method. This is where ALL of the HRTIM work is done.
+ *
+ ****************************************************************************/
+
+static int stm32_hrtim_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
+{
+ FAR struct inode *inode = filep->f_inode;
+ FAR struct hrtim_dev_s *dev;
+ FAR struct stm32_hrtim_s *hrtim;
+ int ret;
+
+ tmrinfo("cmd: %d arg: %ld\n", cmd, arg);
+ dev = inode->i_private;
+ DEBUGASSERT(dev != NULL);
+ hrtim = dev->hd_priv;
+
+ UNUSED(hrtim);
+
+#warning "smt32_hrtim_ioctl: missing logic"
+
+ /* Handle HRTIM ioctl commands */
+
+ switch (cmd)
+ {
+
+ default:
+ {
+ ret = -ENOSYS;
+ break;
+ }
+ }
+
+ return ret;
+}
+
+/****************************************************************************
+ * Name: stm32_modifyreg32
+ *
+ * Description:
+ * Modify the value of a 32-bit register (not atomic).
+ *
+ * Input Parameters:
+ * addr - The address of the register
+ * clrbits - The bits to clear
+ * setbits - The bits to set
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+#ifdef HRTIM_HAVE_CLK_FROM_PLL
+static void stm32_modifyreg32(unsigned int addr, uint32_t clrbits,
+ uint32_t setbits)
+{
+ putreg32((getreg32(addr) & ~clrbits) | setbits, addr);
+}
+#endif
+
+/****************************************************************************
+ * Name: hrtim_getreg
+ *
+ * Description:
+ * Read the value of an HRTIM register.
+ *
+ * Input Parameters:
+ * priv - A reference to the HRTIM block
+ * offset - The offset to the register to read
+ *
+ * Returned Value:
+ * The current contents of the specified register
+ *
+ ****************************************************************************/
+
+static uint32_t hrtim_getreg(FAR struct stm32_hrtim_s *priv, int offset)
+{
+ return getreg32(priv->base + offset);
+}
+
+/****************************************************************************
+ * Name: hrtim_putreg
+ *
+ * Description:
+ * Write a value to an HRTIM register.
+ *
+ * Input Parameters:
+ * priv - A reference to the HRTIM block
+ * offset - The offset to the register to write to
+ * value - The value to write to the register
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+static void hrtim_putreg(FAR struct stm32_hrtim_s *priv, int offset,
+ uint32_t value)
+{
+ putreg32(value, priv->base + offset);
+}
+
+/****************************************************************************
+ * Name: hrtim__modifyreg
+ *
+ * Description:
+ * Modify the value of an HRTIM register (not atomic).
+ *
+ * Input Parameters:
+ * priv - A reference to the HRTIM block
+ * offset - The offset to the register to modify
+ * clrbits - The bits to clear
+ * setbits - The bits to set
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+static void hrtim_modifyreg(FAR struct stm32_hrtim_s *priv, int offset,
+ uint32_t clrbits, uint32_t setbits)
+{
+ hrtim_putreg(priv, offset, (hrtim_getreg(priv, offset) & ~clrbits) | setbits);
+}
+
+
+/****************************************************************************
+ * Name: hrtim_tim_get
+ *
+ * Description:
+ * Get Timer data structure for given HRTIM Timer index
+ *
+ * Input Parameters:
+ * priv - A reference to the HRTIM block
+ * index - An HRTIM Timer index to get
+ *
+ * Returned Value:
+ * Base adress offset for given timer index
+ *
+ ****************************************************************************/
+
+static FAR struct stm32_hrtim_tim_s *hrtim_tim_get(FAR struct stm32_hrtim_s *priv, uint8_t index)
+{
+ FAR struct stm32_hrtim_tim_s *tim;
+
+ switch (index)
+ {
+ case HRTIM_TIMER_MASTER:
+ {
+ tim = priv->master;
+ break;
+ }
+
+#ifdef CONFIG_STM32_HRTIM_TIMA
+ case HRTIM_TIMER_TIMA:
+ {
+ tim = priv->tima;
+ break;
+ }
+#endif
+
+#ifdef CONFIG_STM32_HRTIM_TIMB
+ case HRTIM_TIMER_TIMB:
+ {
+ tim = &priv->timb;
+ break;
+ }
+#endif
+
+#ifdef CONFIG_STM32_HRTIM_TIMC
+ case HRTIM_TIMER_TIMC:
+ {
+ tim = &priv->timc;
+ break;
+ }
+#endif
+
+#ifdef CONFIG_STM32_HRTIM_TIMD
+ case HRTIM_TIMER_TIMD:
+ {
+ tim = &priv->timd;
+ break;
+ }
+#endif
+
+#ifdef CONFIG_STM32_HRTIM_TIME
+ case HRTIM_TIMER_TIME:
+ {
+ tim = &priv->time;
+ break;
+ }
+#endif
+
+ default:
+ {
+ tmrerr("ERROR: No such timerx index: %d\n", index);
+ tim = NULL;
+ }
+ }
+
+ return tim;
+}
+
+/****************************************************************************
+ * Name: hrtim_base_get
+ *
+ * Description:
+ * Get base adress offset for given HRTIM Timer index
+ *
+ * Input Parameters:
+ * priv - A reference to the HRTIM block
+ * index - An HRTIM Timer index to get
+ *
+ * Returned Value:
+ * Base adress offset for given timer index
+ *
+ ****************************************************************************/
+
+static uint32_t hrtim_base_get(FAR struct stm32_hrtim_s* priv, uint8_t index)
+{
+ FAR struct stm32_hrtim_tim_s* tim;
+ uint32_t base;
+
+ tim = hrtim_tim_get(priv,index);
+ if (tim == NULL)
+ {
+ base = 0;
+ goto errout;
+ }
+
+ base = tim->tim.base;
+
+errout:
+ return base;
+}
+
+/****************************************************************************
+ * Name: hrtim_tim_getreg
+ *
+ * Description:
+ * Read the value of an HRTIM Timer register.
+ *
+ * Input Parameters:
+ * priv - A reference to the HRTIM block
+ * tim - An HRTIM timer index
+ * offset - The offset to the register to read
+ *
+ * Returned Value:
+ * The current contents of the specified register
+ *
+ ****************************************************************************/
+
+static uint32_t hrtim_tim_getreg(FAR struct stm32_hrtim_s *priv, uint8_t index,
+ int offset)
+{
+ uint32_t base;
+
+ base = hrtim_base_get(priv, index);
+ if (base < 0)
+ {
+ return 0;
+ }
+
+ return getreg32(base + offset);
+}
+
+/****************************************************************************
+ * Name: hrtim_tim_putreg
+ *
+ * Description:
+ * Write a value to an HRTIM Timer register.
+ *
+ * Input Parameters:
+ * priv - A reference to the HRTIM block
+ * index - An HRTIM timer index
+ * offset - The offset to the register to write to
+ * value - The value to write to the register
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+static void hrtim_tim_putreg(FAR struct stm32_hrtim_s *priv, uint8_t index,
+ int offset, uint32_t value)
+{
+ uint32_t base;
+
+ base = hrtim_base_get(priv, index);
+ if (base > 0)
+ {
+ putreg32(value, base + offset);
+ }
+}
+
+/****************************************************************************
+ * Name: hrtim_tim_modifyreg
+ *
+ * Description:
+ * Modify the value of an HRTIM Timer register (not atomic).
+ *
+ * Input Parameters:
+ * priv - A reference to the HRTIM block
+ * index - An HRTIM timer index
+ * offset - The offset to the register to modify
+ * clrbits - The bits to clear
+ * setbits - The bits to set
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+static void hrtim_tim_modifyreg(FAR struct stm32_hrtim_s *priv, uint8_t index,
+ int offset, uint32_t clrbits, uint32_t setbits)
+{
+ hrtim_tim_putreg(priv, index, offset,
+ (hrtim_tim_getreg(priv, index, offset) & ~clrbits) | setbits);
+}
+
+/****************************************************************************
+ * Name: stm32_dll_cal
+ *
+ * Description:
+ * Calibrate HRTIM DLL
+ *
+ * Input Parameters:
+ * priv - A reference to the HRTIM structure
+ *
+ * Returned Value:
+ * 0 on success, a negated errno value on failure
+ *
+ ****************************************************************************/
+
+static int hrtim_dll_cal(FAR struct stm32_hrtim_s *priv)
+{
+ uint32_t regval = 0;
+
+#ifdef CONFIG_STM32_HRTIM_PERIODIC_CAL
+
+ /* Configure calibration rate */
+
+ regval |= HRTIM_DLLCR_CAL_RATE;
+
+ /* Enable Periodic calibration */
+
+ regval |= HRTIM_DLLCR_CALEN;
+
+#endif
+
+ /* DLL Calibration Start */
+
+ regval |= HRTIM_DLLCR_CAL;
+
+ hrtim_putreg(priv, STM32_HRTIM_CMN_DLLCR, regval);
+
+ /* Wait for HRTIM ready flag */
+
+ while(!(hrtim_getreg(priv, STM32_HRTIM_CMN_ISR) & HRTIM_ISR_DLLRDY));
+
+ return OK;
+}
+
+/****************************************************************************
+ * Name: stm32_tim_clock_config
+ *
+ * Description:
+ * Configure HRTIM Timer clock
+ *
+ * Input Parameters:
+ * priv - A reference to the HRTIM structure
+ * index - An HRTIM timer index
+ *
+ * Returned Value:
+ * 0 on success, a negated errno value on failure
+ *
+ ****************************************************************************/
+
+static int hrtim_tim_clock_config(FAR struct stm32_hrtim_s *priv, uint8_t index, uint8_t pre)
+{
+ int ret = OK;
+ uint32_t regval = 0;
+
+ regval = hrtim_tim_getreg(priv, index, STM32_HRTIM_TIM_CR_OFFSET);
+
+ switch (pre)
+ {
+ case HRTIM_PRESCALER_1:
+ {
+ regval |= HRTIM_CMNCR_CKPSC_NODIV;
+ break;
+ }
+ case HRTIM_PRESCALER_2:
+ {
+ regval |= HRTIM_CMNCR_CKPSC_d2;
+ break;
+ }
+ case HRTIM_PRESCALER_4:
+ {
+ regval |= HRTIM_CMNCR_CKPSC_d4;
+ break;
+ }
+ case HRTIM_PRESCALER_8:
+ {
+ regval |= HRTIM_CMNCR_CKPSC_d8;
+ break;
+ }
+ case HRTIM_PRESCALER_16:
+ {
+ regval |= HRTIM_CMNCR_CKPSC_d16;
+ break;
+ }
+ case HRTIM_PRESCALER_32:
+ {
+ regval |= HRTIM_CMNCR_CKPSC_d32;
+ break;
+ }
+ case HRTIM_PRESCALER_64:
+ {
+ regval |= HRTIM_CMNCR_CKPSC_d64;
+ break;
+ }
+ case HRTIM_PRESCALER_128:
+ {
+ regval |= HRTIM_CMNCR_CKPSC_d128;
+ break;
+ }
+ default:
+ {
+ tmrerr("ERROR: invalid prescaler value %d for timer %d\n", index,
+ pre);
+ ret = -EINVAL;
+ goto errout;
+ }
+ }
+
+errout:
+ return ret;
+}
+
+/****************************************************************************
+ * Name: stm32_tim_clocks_config
+ *
+ * Description:
+ * Configure HRTIM Timers Clocks
+ *
+ * Input Parameters:
+ * priv - A reference to the HRTIM structure
+ *
+ * Returned Value:
+ * 0 on success, a negated errno value on failure
+ *
+ ****************************************************************************/
+
+static int hrtim_tim_clocks_config(FAR struct stm32_hrtim_s *priv)
+{
+ int ret = OK;
+
+ /* Configure Master Timer clock */
+
+ ret = hrtim_tim_clock_config(priv, HRTIM_TIMER_MASTER, HRTIM_MASTER_PRESCALER);
+ if (ret < 0)
+ {
+ goto errout;
+ }
+
+ /* Configure Timer A clock */
+
+#ifdef CONFIG_STM32_HRTIM_TIMA
+ ret = hrtim_tim_clock_config(priv, HRTIM_TIMER_TIMA, HRTIM_TIMA_PRESCALER);
+ if (ret < 0)
+ {
+ goto errout;
+ }
+#endif
+
+ /* Configure Timer B clock */
+
+#ifdef CONFIG_STM32_HRTIM_TIMB
+ ret = hrtim_tim_clock_config(priv, HRTIM_TIMER_TIMB, HRTIM_TIMB_PRESCALER);
+ if (ret < 0)
+ {
+ goto errout;
+ }
+#endif
+
+ /* Configure Timer C clock */
+
+#ifdef CONFIG_STM32_HRTIM_TIMC
+ ret = hrtim_tim_clock_config(priv, HRTIM_TIMER_TIMC, HRTIM_TIMC_PRESCALER);
+ if (ret < 0)
+ {
+ goto errout;
+ }
+#endif
+
+ /* Configure Timer D clock */
+
+#ifdef CONFIG_STM32_HRTIM_TIMD
+ ret = hrtim_tim_clock_config(priv, HRTIM_TIMER_TIMD, HRTIM_TIMD_PRESCALER);
+ if (ret < 0)
+ {
+ goto errout;
+ }
+#endif
+
+ /* Configure Timer E clock */
+
+#ifdef CONFIG_STM32_HRTIM_TIME
+ ret = hrtim_tim_clock_config(priv, HRTIM_TIMER_TIME, HRTIM_TIME_PRESCALER);
+ if (ret < 0)
+ {
+ goto errout;
+ }
+#endif
+
+errout:
+ return ret;
+}
+
+/****************************************************************************
+ * Name: stm32_gpios_config
+ *
+ * Description:
+ * Configure HRTIM GPIO
+ *
+ * Input Parameters:
+ * priv - A reference to the HRTIM structure
+ *
+ * Returned Value:
+ * 0 on success, a negated errno value on failure
+ *
+ ****************************************************************************/
+
+#if defined(HRTIM_HAVE_CAPTURE) || defined(HRTIM_HAVE_PWM) || defined(HRTIM_HAVE_SYNC)
+static int hrtim_gpios_config(FAR struct stm32_hrtim_s *priv)
+{
+#ifdef HRTIM_HAVE_EEV
+ FAR struct stm32_hrtim_eev_s* eev = priv->eev;
+#endif
+#ifdef HRTIM_HAVE_FAULTS
+ FAR struct stm32_hrtim_faults_s* flt = priv->flt;
+#endif
+
+ /* Configure Timer A Outputs */
+
+#ifdef CONFIG_STM32_HRTIM_TIMA_PWM_CH1
+ stm32_configgpio(GPIO_HRTIM1_CHA1);
+#endif
+
+#ifdef CONFIG_STM32_HRTIM_TIMA_PWM_CH2
+ stm32_configgpio(GPIO_HRTIM1_CHA2);
+#endif
+
+ /* Configure Timer B Outputs */
+
+#ifdef CONFIG_STM32_HRTIM_TIMB_PWM_CH1
+ stm32_configgpio(GPIO_HRTIM1_CHB1);
+#endif
+
+#ifdef CONFIG_STM32_HRTIM_TIMB_PWM_CH2
+ stm32_configgpio(GPIO_HRTIM1_CHB2);
+#endif
+
+ /* Configure Timer C Outputs */
+
+#ifdef CONFIG_STM32_HRTIM_TIMC_PWM_CH1
+ stm32_configgpio(GPIO_HRTIM1_CHC1);
+#endif
+
+#ifdef CONFIG_STM32_HRTIM_TIMC_PWM_CH2
+ stm32_configgpio(GPIO_HRTIM1_CHC2);
+#endif
+
+ /* Configure Timer D Outputs */
+
+#ifdef CONFIG_STM32_HRTIM_TIMD_PWM_CH1
+ stm32_configgpio(GPIO_HRTIM1_CHD1);
+#endif
+
+#ifdef CONFIG_STM32_HRTIM_TIMD_PWM_CH2
+ stm32_configgpio(GPIO_HRTIM1_CHD2);
+#endif
+
+ /* Configure Timer E Outputs */
+
+#ifdef CONFIG_STM32_HRTIM_TIME_PWM_CH1
+ stm32_configgpio(GPIO_HRTIM1_CHE1);
+#endif
+
+#ifdef CONFIG_STM32_HRTIM_TIME_PWM_CH2
+ stm32_configgpio(GPIO_HRTIM1_CHE2);
+#endif
+ /* Configure SCOUT */
+
+#ifdef CONFIG_STM32_HRTIM_SCOUT
+ stm32_configgpio(GPIO_HRTIM1_SCOUT);
+#endif
+
+ /* Configure SCIN */
+
+#ifdef CONFIG_STM32_HRTIM_SCIN
+ stm32_configgpio(GPIO_HRTIM1_SCIN);
+#endif
+
+ /* Configure Faults Inputs */
+
+#ifdef CONFIG_STM32_HRTIM_FAULT1
+ if (flt->flt1.src == HRTIM_FAULT_PIN)
+ {
+ stm32_configgpio(GPIO_HRTIM1_FLT1);
+ }
+#endif
+
+#ifdef CONFIG_STM32_HRTIM_FAULT2
+ if (flt->flt2.src == HRTIM_FAULT_PIN)
+ {
+ stm32_configgpio(GPIO_HRTIM1_FLT2);
+ }
+#endif
+
+#ifdef CONFIG_STM32_HRTIM_FAULT3
+ if (flt->flt3.src == HRTIM_FAULT_PIN)
+ {
+ stm32_configgpio(GPIO_HRTIM1_FLT3);
+ }
+#endif
+
+#ifdef CONFIG_STM32_HRTIM_FAULT4
+ if (flt->flt4.src == HRTIM_FAULT_PIN)
+ {
+ stm32_configgpio(GPIO_HRTIM1_FLT4);
+ }
+#endif
+
+#ifdef CONFIG_STM32_HRTIM_FAULT5
+ if (flt->flt5.src == HRTIM_FAULT_PIN)
+ {
+ stm32_configgpio(GPIO_HRTIM1_FLT5);
+ }
+#endif
+
+ /* Configure External Events Inputs */
+
+#ifdef CONFIG_STM32_HRTIM_EEV1
+ if (eev->eev1.src == HRTIM_EEV_SRC_PIN)
+ {
+ stm32_configgpio(GPIO_HRTIM1_EEV1);
+ }
+#endif
+
+#ifdef CONFIG_STM32_HRTIM_EEV2
+ if (eev->eev2.src == HRTIM_EEV_SRC_PIN)
+ {
+ stm32_configgpio(GPIO_HRTIM1_EEV2);
+ }
+#endif
+
+#ifdef CONFIG_STM32_HRTIM_EEV3
+ if (eev->eev3.src == HRTIM_EEV_SRC_PIN)
+ {
+ stm32_configgpio(GPIO_HRTIM1_EEV3);
+ }
+#endif
+
+#ifdef CONFIG_STM32_HRTIM_EEV4
+ if (eev->eev4.src == HRTIM_EEV_SRC_PIN)
+ {
+ stm32_configgpio(GPIO_HRTIM1_EEV4);
+ }
+#endif
+
+#ifdef CONFIG_STM32_HRTIM_EEV5
+ if (eev->eev5.src == HRTIM_EEV_SRC_PIN)
+ {
+ stm32_configgpio(GPIO_HRTIM1_EEV5);
+ }
+#endif
+
+#ifdef CONFIG_STM32_HRTIM_EEV6
+ if (eev->eev6.src == HRTIM_EEV_SRC_PIN)
+ {
+ stm32_configgpio(GPIO_HRTIM1_EEV6);
+ }
+#endif
+
+#ifdef CONFIG_STM32_HRTIM_EEV7
+ if (eev->eev7.src == HRTIM_EEV_SRC_PIN)
+ {
+ stm32_configgpio(GPIO_HRTIM1_EEV7);
+ }
+#endif
+
+#ifdef CONFIG_STM32_HRTIM_EEV8
+ if (eev->eev8.src == HRTIM_EEV_SRC_PIN)
+ {
+ stm32_configgpio(GPIO_HRTIM1_EEV8);
+ }
+#endif
+
+#ifdef CONFIG_STM32_HRTIM_EEV9
+ if (eev->eev9.src == HRTIM_EEV_SRC_PIN)
+ {
+ stm32_configgpio(GPIO_HRTIM1_EEV9);
+ }
+#endif
+
+#ifdef CONFIG_STM32_HRTIM_EEV10
+ if (eev->eev10.src == HRTIM_EEV_SRC_PIN)
+ {
+ stm32_configgpio(GPIO_HRTIM1_EEV10);
+ }
+#endif
+
+ return OK;
+}
+#endif
+
+/****************************************************************************
+ * Name: stm32_inputs_config
+ *
+ * Description:
+ * Configure HRTIM Inputs
+ *
+ * Input Parameters:
+ * priv - A reference to the HRTIM structure
+ *
+ * Returned Value:
+ * 0 on success, a negated errno value on failure
+ *
+ ****************************************************************************/
+
+#if defined(HRTIM_HAVE_CAPTURE)
+static int hrtim_inputs_config(FAR struct stm32_hrtim_s *priv)
+{
+#warning "hrtim_inputs_config: missing logic"
+
+ /* source */
+
+ /* polarity */
+
+ /* edge-sensitivity */
+
+ return OK;
+}
+#endif
+
+
+/****************************************************************************
+ * Name: stm32_synch_config
+ *
+ * Description:
+ * Configure HRTIM Synchronization Input/Output
+ *
+ * Input Parameters:
+ * priv - A reference to the HRTIM structure
+ *
+ * Returned Value:
+ * 0 on success, a negated errno value on failure
+ *
+ ****************************************************************************/
+
+#if defined(HRTIM_HAVE_SYNC)
+static int hrtim_synch_config(FAR struct stm32_hrtim_s *priv)
+{
+#warning "hrtim_synch_config: missing logic"
+ return OK;
+}
+#endif
+
+/****************************************************************************
+ * Name: stm32_tim_outputs_config
+ *
+ * Description:
+ * Configure HRTIM Slave Timer Outputs (CH1 and CH2)
+ *
+ * Input Parameters:
+ * priv - A reference to the HRTIM structure
+ *
+ * Returned Value:
+ * 0 on success, a negated errno value on failure
+ *
+ ****************************************************************************/
+
+#if defined(HRTIM_HAVE_PWM)
+static int hrtim_tim_outputs_config(FAR struct stm32_hrtim_s *priv, uint8_t index)
+{
+ FAR struct stm32_hrtim_tim_s* tim;
+ FAR struct stm32_hrtim_slave_priv_s* slave;
+
+ int ret = OK;
+ uint32_t regval = 0;
+
+ /* Master Timer has no outputs */
+
+ if (index == HRTIM_TIMER_MASTER)
+ {
+ ret = -EINVAL;
+ goto errout;
+ }
+
+ /* Get Timer data strucutre */
+
+ tim = hrtim_tim_get(priv, index);
+ if (tim == NULL)
+ {
+ ret = -EINVAL;
+ goto errout;
+ }
+
+ slave = (struct stm32_hrtim_slave_priv_s*)tim->priv;
+
+ /* Configure CH1 SET events */
+
+ regval = slave->pwm.ch1.set;
+ hrtim_tim_putreg(priv, index, STM32_HRTIM_TIM_SET1R_OFFSET, regval);
+
+ /* Configure CH1 RESET events */
+
+ regval = slave->pwm.ch1.rst;
+ hrtim_tim_putreg(priv, index, STM32_HRTIM_TIM_RST1R_OFFSET, regval);
+
+ /* Configure CH2 SET events */
+
+ regval = slave->pwm.ch2.set;
+ hrtim_tim_putreg(priv, index, STM32_HRTIM_TIM_SET2R_OFFSET, regval);
+
+ /* Configure CH2 RESET events */
+
+ regval = slave->pwm.ch2.rst;
+ hrtim_tim_putreg(priv, index, STM32_HRTIM_TIM_RST2R_OFFSET, regval);
+
+errout:
+ return ret;
+}
+#endif
+
+/****************************************************************************
+ * Name: stm32_outputs_config
+ *
+ * Description:
+ * Configure HRTIM Outputs
+ *
+ * Input Parameters:
+ * priv - A reference to the HRTIM structure
+ *
+ * Returned Value:
+ * 0 on success, a negated errno value on failure
+ *
+ ****************************************************************************/
+
+#if defined(HRTIM_HAVE_PWM)
+static int hrtim_outputs_config(FAR struct stm32_hrtim_s *priv)
+{
+ int ret = OK;
+
+ /* Configure HRTIM TIMER A Outputs */
+
+#ifdef CONFIG_STM32_HRTIM_TIMA_PWM
+ ret = hrtim_tim_outputs_config(priv, HRTIM_TIMER_TIMA);
+ if (ret < 0)
+ {
+ goto errout;
+ }
+#endif
+
+ /* Configure HRTIM TIMER B Outputs */
+
+#ifdef CONFIG_STM32_HRTIM_TIMB_PWM
+ ret = hrtim_tim_outputs_config(priv, HRTIM_TIMER_TIMB);
+ if (ret < 0)
+ {
+ goto errout;
+ }
+#endif
+
+ /* Configure HRTIM TIMER C Outputs */
+
+#ifdef CONFIG_STM32_HRTIM_TIMC_PWM
+ ret = hrtim_tim_outputs_config(priv, HRTIM_TIMER_TIMC);
+ if (ret < 0)
+ {
+ goto errout;
+ }
+#endif
+
+ /* Configure HRTIM TIMER D Outputs */
+
+#ifdef CONFIG_STM32_HRTIM_TIMD_PWM
+ ret = hrtim_tim_outputs_config(priv, HRTIM_TIMER_TIMD);
+ if (ret < 0)
+ {
+ goto errout;
+ }
+#endif
+
+ /* Configure HRTIM TIMER E Outputs */
+
+#ifdef CONFIG_STM32_HRTIM_TIME_PWM
+ ret = hrtim_tim_outputs_config(priv, HRTIM_TIMER_TIME);
+ if (ret < 0)
+ {
+ goto errout;
+ }
+#endif
+
+errout:
+ return ret;
+}
+#endif
+
+/****************************************************************************
+ * Name: stm32_adc_config
+ *
+ * Description:
+ * Configure HRTIM ADC triggers
+ *
+ * Input Parameters:
+ * priv - A reference to the HRTIM structure
+ *
+ * Returned Value:
+ * 0 on success, a negated errno value on failure
+ *
+ ****************************************************************************/
+
+#ifdef HRTIM_HAVE_ADC
+static int hrtim_adc_config(FAR struct stm32_hrtim_s *priv)
+{
+#warning "hrtim_adc_config: missing logic"
+ return OK;
+}
+#endif
+
+/****************************************************************************
+ * Name: stm32_faults_config
+ *
+ * Description:
+ * Configure HRTIM Faults
+ *
+ * Input Parameters:
+ * priv - A reference to the HRTIM structure
+ *
+ * Returned Value:
+ * 0 on success, a negated errno value on failure
+ *
+ ****************************************************************************/
+
+#ifdef HRTIM_HAVE_FAULTS
+static int hrtim_faults_config(FAR struct stm32_hrtim_s *priv)
+{
+#warning "hrtim_faults_config: missing logic"
+ return OK;
+}
+#endif
+
+/****************************************************************************
+ * Name: stm32_eev_config
+ *
+ * Description:
+ * Configure HRTIM External Events
+ *
+ * Input Parameters:
+ * priv - A reference to the HRTIM structure
+ *
+ * Returned Value:
+ * 0 on success, a negated errno value on failure
+ *
+ ****************************************************************************/
+
+#ifdef HRTIM_HAVE_EEV
+static int hrtim_eev_config(FAR struct stm32_hrtim_s *priv)
+{
+#warning "hrtim_eev_confi: missing logic"
+ return OK;
+}
+#endif
+
+/****************************************************************************
+ * Name: stm32_irq_config
+ *
+ * Description:
+ * Configure HRTIM interrupts
+ *
+ * Input Parameters:
+ * priv - A reference to the HRTIM structure
+ *
+ * Returned Value:
+ * 0 on success, a negated errno value on failure
+ *
+ ****************************************************************************/
+
+#ifdef HRTIM_HAVE_INTERRUPTS
+static int hrtim_irq_config(FAR struct stm32_hrtim_s *priv)
+{
+#warning "hrtim_irq_config: missing logic"
+ return OK;
+}
+#endif
+
+/****************************************************************************
+ * Name: stm32_preload_config
+ *
+ * Description:
+ * Configure HRTIM preload registers
+ *
+ * Input Parameters:
+ * priv - A reference to the HRTIM structure
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+static void hrtim_preload_config(FAR struct stm32_hrtim_s *priv)
+{
+
+#ifndef CONFIG_STM32_HRTIM_MASTER_PRELOAD_DIS
+ hrtim_tim_modifyreg(priv, HRTIM_TIMER_MASTER, STM32_HRTIM_TIM_CR_OFFSET,
+ 0, HRTIM_CMNCR_PREEN);
+#endif
+
+#if defined(CONFIG_ST32_HRTIM_TIMA) && defined(CONFIG_STM32_HRTIM_TIMA_PRELOAD_DIS)
+ hrtim_tim_modifyreg(priv, HRTIM_TIMER_TIMA, STM32_HRTIM_TIM_CR_OFFSET,
+ 0, HRTIM_CMNCR_PREEN);
+#endif
+
+#if defined(CONFIG_ST32_HRTIM_TIMB) && defined(CONFIG_STM32_HRTIM_TIMB_PRELOAD_DIS)
+ hrtim_tim_modifyreg(priv, HRTIM_TIMER_TIMB, STM32_HRTIM_TIM_CR_OFFSET,
+ 0, HRTIM_CMNCR_PREEN);
+#endif
+
+#if defined(CONFIG_ST32_HRTIM_TIMC) && defined(CONFIG_STM32_HRTIM_TIMC_PRELOAD_DIS)
+ hrtim_tim_modifyreg(priv, HRTIM_TIMER_TIMC, STM32_HRTIM_TIM_CR_OFFSET,
+ 0, HRTIM_CMNCR_PREEN);
+#endif
+
+#if defined(CONFIG_ST32_HRTIM_TIMD) && defined(CONFIG_STM32_HRTIM_TIMD_PRELOAD_DIS)
+ hrtim_tim_modifyreg(priv, HRTIM_TIMER_TIMD, STM32_HRTIM_TIM_CR_OFFSET,
+ 0, HRTIM_CMNCR_PREEN);
+#endif
+
+#if defined(CONFIG_ST32_HRTIM_TIME) && defined(CONFIG_STM32_HRTIM_TIME_PRELOAD_DIS)
+ hrtim_tim_modifyreg(priv, HRTIM_TIMER_TIME, STM32_HRTIM_TIM_CR_OFFSET,
+ 0, HRTIM_CMNCR_PREEN);
+#endif
+
+}
+
+/****************************************************************************
+ * Name: stm32_hrtimconfig
+ *
+ * Description:
+ * Configure HRTIM
+ *
+ * Input Parameters:
+ * priv - A reference to the HRTIM structure
+ *
+ * Returned Value:
+ * 0 on success, a negated errno value on failure
+ *
+ ****************************************************************************/
+
+static int stm32_hrtimconfig(FAR struct stm32_hrtim_s *priv)
+{
+ int ret;
+ uint32_t regval = 0;
+
+ /* Configure PLL VCO output as HRTIM clock source */
+
+#ifdef HRTIM_HAVE_CLK_FROM_PLL
+ stm32_modifyreg32(STM32_RCC_CFGR3, 0, RCC_CFGR3_HRTIM1SW);
+#endif
+
+ /* HRTIM DLL calibration */
+
+ ret = hrtim_dll_cal(priv);
+ if (ret != OK)
+ {
+ tmrerr("ERROR: HRTIM DLL calibration failed!\n");
+ goto errout;
+ }
+
+ /* Configure Timers Clocks */
+
+ ret = hrtim_tim_clocks_config(priv);
+ if (ret != OK)
+ {
+ tmrerr("ERROR: HRTIM timers clock configuration failed!\n");
+ goto errout;
+ }
+
+ /* Configure HRTIM GPIOs */
+
+#if defined(HRTIM_HAVE_CAPTURE) || defined(HRTIM_HAVE_PWM) || defined(HRTIM_HAVE_SYNC)
+ ret = hrtim_gpios_config(priv);
+ if (ret != OK)
+ {
+ tmrerr("ERROR: HRTIM GPIOs configuration failed!\n");
+ goto errout;
+ }
+#endif
+
+ /* Configure HRTIM inputs */
+
+#if defined(HRTIM_HAVE_CAPTURE)
+ ret = hrtim_inputs_config(priv);
+ if (ret != OK)
+ {
+ tmrerr("ERROR: HRTIM inputs configuration failed!\n");
+ goto errout;
+ }
+#endif
+
+ /* Configure Synchronisation IOs */
+
+#if defined(HRTIM_HAVE_SYNC)
+ ret = hrtim_synch_config(priv);
+ if (ret != OK)
+ {
+ tmrerr("ERROR: HRTIM synchronisation configuration failed!\n");
+ goto errout;
+ }
+#endif
+
+ /* Configure HRTIM outputs GPIOs */
+
+#if defined(HRTIM_HAVE_PWM)
+ ret = hrtim_outputs_config(priv);
+ if (ret != OK)
+ {
+ tmrerr("ERROR: HRTIM outputs configuration failed!\n");
+ goto errout;
+ }
+#endif
+
+ /* Configure ADC triggers */
+
+#ifdef HRTIM_HAVE_ADC
+ ret = hrtim_adc_config(priv);
+ if (ret != OK)
+ {
+ tmrerr("ERROR: HRTIM ADC configuration failed!\n");
+ goto errout;
+ }
+#endif
+
+ /* Configure Faults */
+
+#ifdef HRTIM_HAVE_FAULTS
+ ret = hrtim_faults_config(priv);
+ if (ret != OK)
+ {
+ tmrerr("ERROR: HRTIM faults configuration failed!\n");
+ goto errout;
+ }
+#endif
+
+ /* Configure Events */
+
+#ifdef HRTIM_HAVE_EEV
+ ret = hrtim_eev_config(priv);
+ if (ret != OK)
+ {
+ tmrerr("ERROR: HRTIM EEV configuration failed!\n");
+ goto errout;
+ }
+#endif
+
+ /* Configure interrupts */
+
+#ifdef HRTIM_HAVE_INTERRUPTS
+ ret = hrtim_irq_config(priv);
+ if (ret != OK)
+ {
+ tmrerr("ERROR: HRTIM IRQ configuration failed!\n");
+ goto errout;
+ }
+#endif
+
+ /* Enable registers preload */
+
+ hrtim_preload_config(priv);
+
+ /* Enable Master Timer */
+
+ regval |= HRTIM_MCR_MCEN;
+
+ /* Enable Slave Timers */
+
+#ifdef CONFIG_STM32_HRTIM_TIMA
+ regval |= HRTIM_MCR_TACEN;
+#endif
+
+#ifdef CONFIG_STM32_HRTIM_TIMB
+ regval |= HRTIM_MCR_TBCEN;
+#endif
+
+#ifdef CONFIG_STM32_HRTIM_TIMC
+ regval |= HRTIM_MCR_TCCEN;
+#endif
+
+#ifdef CONFIG_STM32_HRTIM_TIMD
+ regval |= HRTIM_MCR_TDCEN;
+#endif
+
+#ifdef CONFIG_STM32_HRTIM_TIME
+ regval |= HRTIM_MCR_TECEN;
+#endif
+
+ /* Write enable bits at once */
+
+ hrtim_tim_modifyreg(priv, HRTIM_TIMER_MASTER, STM32_HRTIM_TIM_CR_OFFSET, 0, regval);
+
+errout:
+ return ret;
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: stm32_hrtiminitialize
+ *
+ * Description:
+ * Initialize the HRTIM.
+ *
+ * Returned Value:
+ * Valid HRTIM device structure reference on succcess; a NULL on failure.
+ *
+ * Assumptions:
+ * 1. Clock to the HRTIM block has enabled,
+ * 2. Board-specific logic has already configured
+ *
+ ****************************************************************************/
+
+FAR struct hrtim_dev_s* stm32_hrtiminitialize(void)
+{
+ FAR struct hrtim_dev_s *dev;
+ FAR struct stm32_hrtim_s *hrtim;
+ int ret;
+
+ dev = &g_hrtim1dev;
+
+ hrtim = dev->hd_priv;
+
+ ret = stm32_hrtimconfig(hrtim);
+ if (ret < 0)
+ {
+ tmrerr("ERROR: Failed to initialize HRTIM1: %d\n", ret);
+ errno = -ret;
+ return NULL;
+ }
+
+ return dev;
+}
+
+/****************************************************************************
+ * Name: hrtim_register
+ ****************************************************************************/
+
+int hrtim_register(FAR const char *path, FAR struct hrtim_dev_s *dev)
+{
+ int ret ;
+
+ /* Initialize the HRTIM device structure */
+
+ dev->hd_ocount = 0;
+
+ /* Initialize semaphores */
+
+ sem_init(&dev->hd_closesem, 0, 1);
+
+ /* Register the HRTIM character driver */
+
+ ret = register_driver(path, &hrtim_fops, 0444, dev);
+ if (ret < 0)
+ {
+ sem_destroy(&dev->hd_closesem);
+ }
+
+ return ret;
+}
+
+#endif /* CONFIG_STM32_STM32F33XX */
+
+#endif /* CONFIG_STM32_HRTIM1 */
diff --git a/arch/arm/src/stm32/stm32_hrtim.h b/arch/arm/src/stm32/stm32_hrtim.h
new file mode 100644
index 0000000000000000000000000000000000000000..e20d71e6307050da4911da2151187e9564bdfd6a
--- /dev/null
+++ b/arch/arm/src/stm32/stm32_hrtim.h
@@ -0,0 +1,305 @@
+/************************************************************************************
+ * arch/arm/src/stm32/stm32_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_STM32_HRTIM_H
+#define __ARCH_ARM_SRC_STM32_STM32_HRTIM_H
+
+/************************************************************************************
+ * Included Files
+ ************************************************************************************/
+
+#include
+
+#include "chip.h"
+
+#ifdef CONFIG_STM32_HRTIM1
+
+#if defined(CONFIG_STM32_STM32F33XX)
+# include "chip/stm32f33xxx_hrtim.h"
+#else
+# error
+#endif
+
+/************************************************************************************
+ * Pre-processor definitions
+ ************************************************************************************/
+
+/************************************************************************************
+ * Public Types
+ ************************************************************************************/
+
+/* HRTIM Timer X index */
+
+enum stm32_hrtim_tim_e
+{
+ HRTIM_TIMER_MASTER,
+#ifdef CONFIG_STM32_HRTIM_TIMA
+ HRTIM_TIMER_TIMA,
+#endif
+#ifdef CONFIG_STM32_HRTIM_TIMB
+ HRTIM_TIMER_TIMB,
+#endif
+#ifdef CONFIG_STM32_HRTIM_TIMC
+ HRTIM_TIMER_TIMC,
+#endif
+#ifdef CONFIG_STM32_HRTIM_TIMD
+ HRTIM_TIMER_TIMD,
+#endif
+#ifdef CONFIG_STM32_HRTIM_TIME
+ HRTIM_TIMER_TIME,
+#endif
+};
+
+/* Source which can force the Tx1/Tx2 output to its inactive state */
+
+enum stm32_hrtim_out_rst_e
+{
+ HRTIM_OUT_RST_UPDATE = (1 << 0),
+ HRTIM_OUT_RST_EXTEVNT10 = (1 << 1),
+ HRTIM_OUT_RST_EXTEVNT9 = (1 << 2),
+ HRTIM_OUT_RST_EXTEVNT8 = (1 << 3),
+ HRTIM_OUT_RST_EXTEVNT7 = (1 << 4),
+ HRTIM_OUT_RST_EXTEVNT6 = (1 << 5),
+ HRTIM_OUT_RST_EXTEVNT5 = (1 << 6),
+ HRTIM_OUT_RST_EXTEVNT4 = (1 << 7),
+ HRTIM_OUT_RST_EXTEVNT3 = (1 << 8),
+ HRTIM_OUT_RST_EXTEVNT2 = (1 << 9),
+ HRTIM_OUT_RST_EXTEVNT1 = (1 << 10),
+ HRTIM_OUT_RST_TIMEVNT9 = (1 << 11),
+ HRTIM_OUT_RST_TIMEVNT8 = (1 << 12),
+ HRTIM_OUT_RST_TIMEVNT7 = (1 << 13),
+ HRTIM_OUT_RST_TIMEVNT6 = (1 << 14),
+ HRTIM_OUT_RST_TIMEVNT5 = (1 << 15),
+ HRTIM_OUT_RST_TIMEVNT4 = (1 << 16),
+ HRTIM_OUT_RST_TIMEVNT3 = (1 << 17),
+ HRTIM_OUT_RST_TIMEVNT2 = (1 << 18),
+ HRTIM_OUT_RST_TIMEVNT1 = (1 << 19),
+ HRTIM_OUT_RST_MSTCMP4 = (1 << 20),
+ HRTIM_OUT_RST_MSTCMP3 = (1 << 21),
+ HRTIM_OUT_RST_MSTCMP2 = (1 << 22),
+ HRTIM_OUT_RST_MSTCMP1 = (1 << 23),
+ HRTIM_OUT_RST_MSTPER = (1 << 24),
+ HRTIM_OUT_RST_CMP4 = (1 << 25),
+ HRTIM_OUT_RST_CMP3 = (1 << 26),
+ HRTIM_OUT_RST_CMP2 = (1 << 27),
+ HRTIM_OUT_RST_CMP1 = (1 << 28),
+ HRTIM_OUT_RST_PER = (1 << 29),
+ HRTIM_OUT_RST_RESYNC = (1 << 30),
+ HRTIM_OUT_RST_SOFT = (1 << 31),
+};
+
+/* Source which can force the Tx1/Tx2 output to its active state */
+
+enum stm32_hrtim_out_set_e
+{
+ HRTIM_OUT_SET_UPDATE = (1 << 0),
+ HRTIM_OUT_SET_EXTEVNT10 = (1 << 1),
+ HRTIM_OUT_SET_EXTEVNT9 = (1 << 2),
+ HRTIM_OUT_SET_EXTEVNT8 = (1 << 3),
+ HRTIM_OUT_SET_EXTEVNT7 = (1 << 4),
+ HRTIM_OUT_SET_EXTEVNT6 = (1 << 5),
+ HRTIM_OUT_SET_EXTEVNT5 = (1 << 6),
+ HRTIM_OUT_SET_EXTEVNT4 = (1 << 7),
+ HRTIM_OUT_SET_EXTEVNT3 = (1 << 8),
+ HRTIM_OUT_SET_EXTEVNT2 = (1 << 9),
+ HRTIM_OUT_SET_EXTEVNT1 = (1 << 10),
+ HRTIM_OUT_SET_TIMEVNT9 = (1 << 11),
+ HRTIM_OUT_SET_TIMEVNT8 = (1 << 12),
+ HRTIM_OUT_SET_TIMEVNT7 = (1 << 13),
+ HRTIM_OUT_SET_TIMEVNT6 = (1 << 14),
+ HRTIM_OUT_SET_TIMEVNT5 = (1 << 15),
+ HRTIM_OUT_SET_TIMEVNT4 = (1 << 16),
+ HRTIM_OUT_SET_TIMEVNT3 = (1 << 17),
+ HRTIM_OUT_SET_TIMEVNT2 = (1 << 18),
+ HRTIM_OUT_SET_TIMEVNT1 = (1 << 19),
+ HRTIM_OUT_SET_MSTCMP4 = (1 << 20),
+ HRTIM_OUT_SET_MSTCMP3 = (1 << 21),
+ HRTIM_OUT_SET_MSTCMP2 = (1 << 22),
+ HRTIM_OUT_SET_MSTCMP1 = (1 << 23),
+ HRTIM_OUT_SET_MSTPER = (1 << 24),
+ HRTIM_OUT_SET_CMP4 = (1 << 25),
+ HRTIM_OUT_SET_CMP3 = (1 << 26),
+ HRTIM_OUT_SET_CMP2 = (1 << 27),
+ HRTIM_OUT_SET_CMP1 = (1 << 28),
+ HRTIM_OUT_SET_PER = (1 << 29),
+ HRTIM_OUT_SET_RESYNC = (1 << 30),
+ HRTIM_OUT_SET_SOFT = (1 << 31),
+};
+
+/* Events that can reset TimerX Counter */
+
+enum stm32_hrtim_tim_rst_e
+{
+ /* Timer owns events */
+
+ HRTIM_RST_UPDT,
+ HRTIM_RST_CMP4,
+ HRTIM_RST_CMP2,
+
+ /* Master Timer Events */
+
+ HRTIM_RST_MSTCMP4,
+ HRTIM_RST_MSTCMP3,
+ HRTIM_RST_MSTCMP2,
+ HRTIM_RST_MSTCMP1,
+ HRTIM_RST_MSTPER,
+
+ /* TimerX events */
+
+ HRTIM_RST_TECMP4,
+ HRTIM_RST_TECMP2,
+ HRTIM_RST_TECMP1,
+ HRTIM_RST_TDCMP4,
+ HRTIM_RST_TDCMP2,
+ HRTIM_RST_TDCMP1,
+ HRTIM_RST_TCCMP4,
+ HRTIM_RST_TCCMP2,
+ HRTIM_RST_TCCMP1,
+ HRTIM_RST_TBCMP4,
+ HRTIM_RST_TBCMP2,
+ HRTIM_RST_TBCMP1,
+ HRTIM_RST_TACMP4,
+ HRTIM_RST_TACMP2,
+ HRTIM_RST_TACMP1,
+
+ /* External Events */
+
+ HRTIM_RST_EXTEVNT10,
+ HRTIM_RST_EXTEVNT9,
+ HRTIM_RST_EXTEVNT8,
+ HRTIM_RST_EXTEVNT7,
+ HRTIM_RST_EXTEVNT6,
+ HRTIM_RST_EXTEVNT5,
+ HRTIM_RST_EXTEVNT4,
+ HRTIM_RST_EXTEVNT3,
+ HRTIM_RST_EXTEVNT2,
+ HRTIM_RST_EXTEVNT1,
+};
+
+/* HRTIM Timer X prescaler */
+
+enum stm32_hrtim_tim_prescaler_e
+{
+ HRTIM_PRESCALER_1,
+ HRTIM_PRESCALER_2,
+ HRTIM_PRESCALER_4,
+ HRTIM_PRESCALER_8,
+ HRTIM_PRESCALER_16,
+ HRTIM_PRESCALER_32,
+ HRTIM_PRESCALER_64,
+ HRTIM_PRESCALER_128,
+};
+
+/* HRTIM Fault Source */
+
+enum stm32_hrtim_fault_src_e
+{
+ HRTIM_FAULT_SRC_PIN,
+ HRTIM_FAULT_SRC_INTERNAL
+};
+
+/* HRTIM External Event Source
+ * NOTE: according to Table 82 from STM32F334XX Manual
+ */
+
+enum stm32_hrtim_eev_src_e
+{
+ HRTIM_EEV_SRC_PIN,
+ HRTIM_EEV_SRC_ANALOG,
+ HRTIM_EEV_SRC_TRGO,
+ HRTIM_EEV_SRC_ADC
+};
+
+struct hrtim_dev_s
+{
+#ifdef CONFIG_HRTIM
+ /* Fields managed by common upper half HRTIM logic */
+
+ uint8_t hd_ocount; /* The number of times the device has been opened */
+ sem_t hd_closesem; /* Locks out new opens while close is in progress */
+#endif
+
+ /* Fields provided by lower half HRTIM logic */
+
+ FAR void *hd_priv; /* Used by the arch-specific logic */
+};
+
+/************************************************************************************
+ * Public Function Prototypes
+ ************************************************************************************/
+
+#ifndef __ASSEMBLY__
+#ifdef __cplusplus
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+/****************************************************************************
+ * Name: stm32_hrtiminitialize
+ *
+ * Description:
+ * Initialize the HRTIM.
+ *
+ * Input Parameters:
+ * None
+ *
+ * Returned Value:
+ * Valid HRTIM device structure reference on succcess; a NULL on failure.
+ *
+ * Assumptions:
+ * 1. Clock to the HRTIM block has enabled,
+ * 2. Board-specific logic has already configured
+ *
+ ****************************************************************************/
+
+FAR struct hrtim_dev_s* stm32_hrtiminitialize(void);
+
+/****************************************************************************
+ * Name: hrtim_register
+ ****************************************************************************/
+
+int hrtim_register(FAR const char *path, FAR struct hrtim_dev_s *dev);
+
+#undef EXTERN
+#ifdef __cplusplus
+}
+#endif
+#endif /* __ASSEMBLY__ */
+
+#endif /* CONFIG_STM32_HRTIM1 */
+#endif /* __ARCH_ARM_SRC_STM32_STM32_HRTIM_H */
diff --git a/arch/arm/src/stm32/stm32_i2c.c b/arch/arm/src/stm32/stm32_i2c.c
index 666ad304ad3fef88ca1f3f4f5063581cee2190eb..5f3e1c2c5c9ef28c2d7a7b1430b770c61bf90f3a 100644
--- a/arch/arm/src/stm32/stm32_i2c.c
+++ b/arch/arm/src/stm32/stm32_i2c.c
@@ -230,7 +230,6 @@ 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 *, void *); /* Interrupt handler */
uint32_t ev_irq; /* Event IRQ */
uint32_t er_irq; /* Error IRQ */
#endif
@@ -313,18 +312,10 @@ static inline uint32_t stm32_i2c_disablefsmc(FAR struct stm32_i2c_priv_s *priv);
static inline void stm32_i2c_enablefsmc(uint32_t ahbenr);
#endif /* I2C1_FSMC_CONFLICT */
-static int stm32_i2c_isr(struct stm32_i2c_priv_s * priv);
+static int stm32_i2c_isr_process(struct stm32_i2c_priv_s * priv);
#ifndef CONFIG_I2C_POLLED
-#ifdef CONFIG_STM32_I2C1
-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, FAR void *arg);
-#endif
-#ifdef CONFIG_STM32_I2C3
-static int stm32_i2c3_isr(int irq, void *context, FAR void *arg);
-#endif
+static int stm32_i2c_isr(int irq, void *context, FAR void *arg);
#endif /* !CONFIG_I2C_POLLED */
static int stm32_i2c_init(FAR struct stm32_i2c_priv_s *priv);
@@ -379,7 +370,6 @@ static const struct stm32_i2c_config_s stm32_i2c1_config =
.scl_pin = GPIO_I2C1_SCL,
.sda_pin = GPIO_I2C1_SDA,
#ifndef CONFIG_I2C_POLLED
- .isr = stm32_i2c1_isr,
.ev_irq = STM32_IRQ_I2C1EV,
.er_irq = STM32_IRQ_I2C1ER
#endif
@@ -409,7 +399,6 @@ static const struct stm32_i2c_config_s stm32_i2c2_config =
.scl_pin = GPIO_I2C2_SCL,
.sda_pin = GPIO_I2C2_SDA,
#ifndef CONFIG_I2C_POLLED
- .isr = stm32_i2c2_isr,
.ev_irq = STM32_IRQ_I2C2EV,
.er_irq = STM32_IRQ_I2C2ER
#endif
@@ -439,7 +428,6 @@ static const struct stm32_i2c_config_s stm32_i2c3_config =
.scl_pin = GPIO_I2C3_SCL,
.sda_pin = GPIO_I2C3_SDA,
#ifndef CONFIG_I2C_POLLED
- .isr = stm32_i2c3_isr,
.ev_irq = STM32_IRQ_I2C3EV,
.er_irq = STM32_IRQ_I2C3ER
#endif
@@ -678,7 +666,7 @@ static inline int stm32_i2c_sem_waitdone(FAR struct stm32_i2c_priv_s *priv)
* reports that it is done.
*/
- stm32_i2c_isr(priv);
+ stm32_i2c_isr_process(priv);
}
/* Loop until the transfer is complete. */
@@ -1172,14 +1160,14 @@ static inline void stm32_i2c_enablefsmc(uint32_t ahbenr)
#endif /* I2C1_FSMC_CONFLICT */
/************************************************************************************
- * Name: stm32_i2c_isr
+ * Name: stm32_i2c_isr_process
*
* Description:
* Common Interrupt Service Routine
*
************************************************************************************/
-static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv)
+static int stm32_i2c_isr_process(struct stm32_i2c_priv_s *priv)
{
uint32_t status = stm32_i2c_getstatus(priv);
@@ -1459,55 +1447,22 @@ static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv)
}
/************************************************************************************
- * Name: stm32_i2c1_isr
+ * Name: stm32_i2c_isr
*
* Description:
- * I2C1 interrupt service routine
+ * Common I2C interrupt service routine
*
************************************************************************************/
#ifndef CONFIG_I2C_POLLED
-#ifdef CONFIG_STM32_I2C1
-static int stm32_i2c1_isr(int irq, void *context, FAR void *arg)
-{
- return stm32_i2c_isr(&stm32_i2c1_priv);
-}
-#endif
-
-/************************************************************************************
- * Name: stm32_i2c2_isr
- *
- * Description:
- * I2C2 interrupt service routine
- *
- ************************************************************************************/
-
-#ifdef CONFIG_STM32_I2C2
-static int stm32_i2c2_isr(int irq, void *context, FAR void *arg)
+static int stm32_i2c_isr(int irq, void *context, FAR void *arg)
{
- return stm32_i2c_isr(&stm32_i2c2_priv);
-}
-#endif
+ struct stm32_i2c_priv_s *priv = (struct stm32_i2c_priv_s *)arg;
-/************************************************************************************
- * Name: stm32_i2c3_isr
- *
- * Description:
- * I2C2 interrupt service routine
- *
- ************************************************************************************/
-
-#ifdef CONFIG_STM32_I2C3
-static int stm32_i2c3_isr(int irq, void *context, FAR void *arg)
-{
- return stm32_i2c_isr(&stm32_i2c3_priv);
+ DEBUGASSERT(priv != NULL);
+ return stm32_i2c_isr_process(priv);
}
#endif
-#endif
-
-/************************************************************************************
- * Private Initialization and Deinitialization
- ************************************************************************************/
/************************************************************************************
* Name: stm32_i2c_init
@@ -1543,8 +1498,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, NULL);
- irq_attach(priv->config->er_irq, priv->config->isr, NULL);
+ irq_attach(priv->config->ev_irq, stm32_i2c_isr, priv);
+ irq_attach(priv->config->er_irq, stm32_i2c_isr, priv);
up_enable_irq(priv->config->ev_irq);
up_enable_irq(priv->config->er_irq);
#endif
diff --git a/arch/arm/src/stm32/stm32_i2c_alt.c b/arch/arm/src/stm32/stm32_i2c_alt.c
index 9112b0840769acc6d3f464834bbc5873cb673449..21f6696732365c5d3c46aa5b9761f60b481c5cb6 100644
--- a/arch/arm/src/stm32/stm32_i2c_alt.c
+++ b/arch/arm/src/stm32/stm32_i2c_alt.c
@@ -257,7 +257,6 @@ 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 *, void *); /* Interrupt handler */
uint32_t ev_irq; /* Event IRQ */
uint32_t er_irq; /* Error IRQ */
#endif
@@ -342,18 +341,10 @@ static inline uint32_t stm32_i2c_disablefsmc(FAR struct stm32_i2c_priv_s *priv);
static inline void stm32_i2c_enablefsmc(uint32_t ahbenr);
#endif /* I2C1_FSMC_CONFLICT */
-static int stm32_i2c_isr(struct stm32_i2c_priv_s * priv);
+static int stm32_i2c_isr_process(struct stm32_i2c_priv_s * priv);
#ifndef CONFIG_I2C_POLLED
-#ifdef CONFIG_STM32_I2C1
-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, FAR void *arg);
-#endif
-#ifdef CONFIG_STM32_I2C3
-static int stm32_i2c3_isr(int irq, void *context, FAR void *arg);
-#endif
+static int stm32_i2c_isr(int irq, void *context, FAR void *arg);
#endif /* !CONFIG_I2C_POLLED */
static int stm32_i2c_init(FAR struct stm32_i2c_priv_s *priv);
@@ -387,7 +378,6 @@ static const struct stm32_i2c_config_s stm32_i2c1_config =
.scl_pin = GPIO_I2C1_SCL,
.sda_pin = GPIO_I2C1_SDA,
#ifndef CONFIG_I2C_POLLED
- .isr = stm32_i2c1_isr,
.ev_irq = STM32_IRQ_I2C1EV,
.er_irq = STM32_IRQ_I2C1ER
#endif
@@ -417,7 +407,6 @@ static const struct stm32_i2c_config_s stm32_i2c2_config =
.scl_pin = GPIO_I2C2_SCL,
.sda_pin = GPIO_I2C2_SDA,
#ifndef CONFIG_I2C_POLLED
- .isr = stm32_i2c2_isr,
.ev_irq = STM32_IRQ_I2C2EV,
.er_irq = STM32_IRQ_I2C2ER
#endif
@@ -447,7 +436,6 @@ static const struct stm32_i2c_config_s stm32_i2c3_config =
.scl_pin = GPIO_I2C3_SCL,
.sda_pin = GPIO_I2C3_SDA,
#ifndef CONFIG_I2C_POLLED
- .isr = stm32_i2c3_isr,
.ev_irq = STM32_IRQ_I2C3EV,
.er_irq = STM32_IRQ_I2C3ER
#endif
@@ -686,7 +674,7 @@ static int stm32_i2c_sem_waitdone(FAR struct stm32_i2c_priv_s *priv)
* reports that it is done.
*/
- stm32_i2c_isr(priv);
+ stm32_i2c_isr_process(priv);
}
/* Loop until the transfer is complete. */
@@ -1180,7 +1168,7 @@ static inline void stm32_i2c_enablefsmc(uint32_t ahbenr)
#endif /* I2C1_FSMC_CONFLICT */
/************************************************************************************
- * Name: stm32_i2c_isr
+ * Name: stm32_i2c_isr_process
*
* Description:
* Common interrupt service routine (ISR) that handles I2C protocol logic.
@@ -1202,8 +1190,11 @@ static inline void stm32_i2c_enablefsmc(uint32_t ahbenr)
*
************************************************************************************/
-static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv)
+static int stm32_i2c_isr_process(struct stm32_i2c_priv_s *priv)
{
+#ifndef CONFIG_I2C_POLLED
+ uint32_t regval;
+#endif
uint32_t status;
i2cinfo("I2C ISR called\n");
@@ -1867,7 +1858,6 @@ static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv)
#else
/* Clear all interrupts */
- uint32_t regval;
regval = stm32_i2c_getreg(priv, STM32_I2C_CR2_OFFSET);
regval &= ~I2C_CR2_ALLINTS;
stm32_i2c_putreg(priv, STM32_I2C_CR2_OFFSET, regval);
@@ -1890,55 +1880,22 @@ static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv)
}
/************************************************************************************
- * Name: stm32_i2c1_isr
+ * Name: stm32_i2c_isr
*
* Description:
- * I2C1 interrupt service routine
+ * Common I2C interrupt service routine
*
************************************************************************************/
#ifndef CONFIG_I2C_POLLED
-#ifdef CONFIG_STM32_I2C1
-static int stm32_i2c1_isr(int irq, void *context, FAR void *arg)
+static int stm32_i2c_isr(int irq, void *context, FAR void *arg)
{
- return stm32_i2c_isr(&stm32_i2c1_priv);
-}
-#endif
+ struct stm32_i2c_priv_s *priv = (struct stm32_i2c_priv_s *)arg;
-/************************************************************************************
- * Name: stm32_i2c2_isr
- *
- * Description:
- * I2C2 interrupt service routine
- *
- ************************************************************************************/
-
-#ifdef CONFIG_STM32_I2C2
-static int stm32_i2c2_isr(int irq, void *context, FAR void *arg)
-{
- return stm32_i2c_isr(&stm32_i2c2_priv);
-}
-#endif
-
-/************************************************************************************
- * Name: stm32_i2c3_isr
- *
- * Description:
- * I2C2 interrupt service routine
- *
- ************************************************************************************/
-
-#ifdef CONFIG_STM32_I2C3
-static int stm32_i2c3_isr(int irq, void *context, FAR void *arg)
-{
- return stm32_i2c_isr(&stm32_i2c3_priv);
+ DEBUGASSERT(priv != NULL);
+ return stm32_i2c_isr_process(priv);
}
#endif
-#endif
-
-/************************************************************************************
- * Private Initialization and Deinitialization
- ************************************************************************************/
/************************************************************************************
* Name: stm32_i2c_init
@@ -1974,8 +1931,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, NULL);
- irq_attach(priv->config->er_irq, priv->config->isr, NULL);
+ irq_attach(priv->config->ev_irq, stm32_i2c_isr, priv);
+ irq_attach(priv->config->er_irq, stm32_i2c_isr, priv);
up_enable_irq(priv->config->ev_irq);
up_enable_irq(priv->config->er_irq);
#endif
diff --git a/arch/arm/src/stm32/stm32_i2s.c b/arch/arm/src/stm32/stm32_i2s.c
new file mode 100644
index 0000000000000000000000000000000000000000..0f246f576345e88a00f41fbb7701a8e331de011d
--- /dev/null
+++ b/arch/arm/src/stm32/stm32_i2s.c
@@ -0,0 +1,2658 @@
+/****************************************************************************
+ * arm/arm/src/stm32/stm32_i2s.c
+ *
+ * Copyright (C) 2017 Gregory Nutt. All rights reserved.
+ * Author: Taras Drozdovskiy
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * The external functions, stm32_spi1/2/3select and stm32_spi1/2/3status
+ * must be provided by board-specific logic. They are implementations of
+ * the select and status methods of the SPI interface defined by struct
+ * spi_ops_s (see include/nuttx/spi/spi.h). All other methods (including
+ * up_spiinitialize()) are provided by common STM32 logic. To use this
+ * common SPI logic on your board:
+ *
+ * 1. Provide logic in stm32_boardinitialize() to configure I2S chip select
+ * pins.
+ * 2. Provide stm32_i2s2/3select() and stm32_i2s2/3status() functions in your
+ * board-specific logic. These functions will perform chip selection and
+ * status operations using GPIOs in the way your board is configured.
+ * 3. Add a calls to up_spiinitialize() in your low level application
+ * initialization logic
+ * 4. The handle returned by stm32_i2sdev_initialize() may then be used to
+ * bind the I2S driver to higher level logic
+ *
+ ****************************************************c***********************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "up_internal.h"
+#include "up_arch.h"
+
+#if defined(CONFIG_STM32_I2S2) || defined(CONFIG_STM32_I2S3)
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* Configuration ************************************************************/
+
+#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_STM32_I2S_MAXINFLIGHT
+# define CONFIG_STM32_I2S_MAXINFLIGHT 16
+#endif
+
+/* Assume no RX/TX support until we learn better */
+
+#undef I2S_HAVE_RX
+#undef I2S_HAVE_TX
+
+/* Check for I2S RX support */
+
+# if defined(CONFIG_STM32_I2S3_RX)
+# define I2S_HAVE_RX 1
+
+# ifdef CONFIG_STM32_I2S_MCK
+# define I2S_HAVE_MCK 1
+# endif
+
+# endif
+
+/* Check for I2S3 TX support */
+
+# if defined(CONFIG_STM32_I2S3_TX)
+# define I2S_HAVE_TX 1
+
+# ifdef CONFIG_STM32_I2S_MCK
+# define I2S_HAVE_MCK 1
+# endif
+
+# endif
+
+/* Configuration ********************************************************************/
+/* I2S interrupts */
+
+#ifdef CONFIG_STM32_SPI_INTERRUPTS
+# error "Interrupt driven I2S not yet supported"
+#endif
+
+/* Can't have both interrupt driven SPI and SPI DMA */
+
+#if defined(CONFIG_STM32_SPI_INTERRUPTS) && defined(CONFIG_STM32_SPI_DMA)
+# error "Cannot enable both interrupt mode and DMA mode for SPI"
+#endif
+
+/* SPI DMA priority */
+
+#ifdef CONFIG_STM32_SPI_DMA
+
+# if defined(CONFIG_SPI_DMAPRIO)
+# define SPI_DMA_PRIO CONFIG_SPI_DMAPRIO
+# elif defined(CONFIG_STM32_STM32F10XX) || defined(CONFIG_STM32_STM32L15XX)
+# define SPI_DMA_PRIO DMA_CCR_PRIMED
+# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX)
+# define SPI_DMA_PRIO DMA_SCR_PRIMED
+# else
+# error "Unknown STM32 DMA"
+# endif
+
+# if defined(CONFIG_STM32_STM32F10XX) || defined(CONFIG_STM32_STM32L15XX)
+# if (SPI_DMA_PRIO & ~DMA_CCR_PL_MASK) != 0
+# error "Illegal value for CONFIG_SPI_DMAPRIO"
+# endif
+# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX)
+# if (SPI_DMA_PRIO & ~DMA_SCR_PL_MASK) != 0
+# error "Illegal value for CONFIG_SPI_DMAPRIO"
+# endif
+# else
+# error "Unknown STM32 DMA"
+# endif
+
+#endif
+
+/* DMA channel configuration */
+
+#if defined(CONFIG_STM32_STM32F10XX) || defined(CONFIG_STM32_STM32F30XX) || \
+ defined(CONFIG_STM32_STM32L15XX)
+# define SPI_RXDMA16_CONFIG (SPI_DMA_PRIO|DMA_CCR_MSIZE_16BITS|DMA_CCR_PSIZE_16BITS|DMA_CCR_MINC )
+# define SPI_RXDMA8_CONFIG (SPI_DMA_PRIO|DMA_CCR_MSIZE_8BITS |DMA_CCR_PSIZE_8BITS |DMA_CCR_MINC )
+# define SPI_RXDMA16NULL_CONFIG (SPI_DMA_PRIO|DMA_CCR_MSIZE_8BITS |DMA_CCR_PSIZE_16BITS )
+# define SPI_RXDMA8NULL_CONFIG (SPI_DMA_PRIO|DMA_CCR_MSIZE_8BITS |DMA_CCR_PSIZE_8BITS )
+# define SPI_TXDMA16_CONFIG (SPI_DMA_PRIO|DMA_CCR_MSIZE_16BITS|DMA_CCR_PSIZE_16BITS|DMA_CCR_MINC|DMA_CCR_DIR)
+# define SPI_TXDMA8_CONFIG (SPI_DMA_PRIO|DMA_CCR_MSIZE_8BITS |DMA_CCR_PSIZE_8BITS |DMA_CCR_MINC|DMA_CCR_DIR)
+# define SPI_TXDMA16NULL_CONFIG (SPI_DMA_PRIO|DMA_CCR_MSIZE_8BITS |DMA_CCR_PSIZE_16BITS |DMA_CCR_DIR)
+# define SPI_TXDMA8NULL_CONFIG (SPI_DMA_PRIO|DMA_CCR_MSIZE_8BITS |DMA_CCR_PSIZE_8BITS |DMA_CCR_DIR)
+#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX)
+# define SPI_RXDMA16_CONFIG (SPI_DMA_PRIO|DMA_SCR_MSIZE_16BITS|DMA_SCR_PSIZE_16BITS|DMA_SCR_MINC|DMA_SCR_DIR_P2M)
+# define SPI_RXDMA8_CONFIG (SPI_DMA_PRIO|DMA_SCR_MSIZE_8BITS |DMA_SCR_PSIZE_8BITS |DMA_SCR_MINC|DMA_SCR_DIR_P2M)
+# define SPI_RXDMA16NULL_CONFIG (SPI_DMA_PRIO|DMA_SCR_MSIZE_8BITS |DMA_SCR_PSIZE_16BITS |DMA_SCR_DIR_P2M)
+# define SPI_RXDMA8NULL_CONFIG (SPI_DMA_PRIO|DMA_SCR_MSIZE_8BITS |DMA_SCR_PSIZE_8BITS |DMA_SCR_DIR_P2M)
+# define SPI_TXDMA16_CONFIG (SPI_DMA_PRIO|DMA_SCR_MSIZE_16BITS|DMA_SCR_PSIZE_16BITS|DMA_SCR_MINC|DMA_SCR_DIR_M2P)
+# define SPI_TXDMA8_CONFIG (SPI_DMA_PRIO|DMA_SCR_MSIZE_8BITS |DMA_SCR_PSIZE_8BITS |DMA_SCR_MINC|DMA_SCR_DIR_M2P)
+# define SPI_TXDMA16NULL_CONFIG (SPI_DMA_PRIO|DMA_SCR_MSIZE_8BITS |DMA_SCR_PSIZE_16BITS |DMA_SCR_DIR_M2P)
+# define SPI_TXDMA8NULL_CONFIG (SPI_DMA_PRIO|DMA_SCR_MSIZE_8BITS |DMA_SCR_PSIZE_8BITS |DMA_SCR_DIR_M2P)
+#else
+# error "Unknown STM32 DMA"
+#endif
+
+/* Debug *******************************************************************/
+/* Check if SSC debug is enabled (non-standard.. no support in
+ * include/debug.h
+ */
+
+#ifndef CONFIG_DEBUG_I2S_INFO
+# undef CONFIG_STM32_I2S_DMADEBUG
+# undef CONFIG_STM32_I2S_REGDEBUG
+# undef CONFIG_STM32_I2S_QDEBUG
+# undef CONFIG_STM32_I2S_DUMPBUFFERS
+#endif
+
+/* The I2S can handle most any bit width from 8 to 32. However, the DMA
+ * logic here is constrained to byte, half-word, and word sizes.
+ */
+
+#ifndef CONFIG_STM32_I2S3_DATALEN
+# define CONFIG_STM32_I2S3_DATALEN 16
+#endif
+
+#if CONFIG_STM32_I2S3_DATALEN == 8
+# define STM32_I2S3_DATAMASK 0
+#elif CONFIG_STM32_I2S3_DATALEN == 16
+# define STM32_I2S3_DATAMASK 1
+#elif CONFIG_STM32_I2S3_DATALEN < 8 || CONFIG_STM32_I2S3_DATALEN > 16
+# error Invalid value for CONFIG_STM32_I2S3_DATALEN
+#else
+# error Valid but supported value for CONFIG_STM32_I2S3_DATALEN
+#endif
+
+/* Check if we need to build RX and/or TX support */
+
+#if defined(I2S_HAVE_RX) || defined(I2S_HAVE_TX)
+
+#ifndef CONFIG_DEBUG_DMA
+# undef CONFIG_STM32_I2S_DMADEBUG
+#endif
+
+#define DMA_INITIAL 0
+#define DMA_AFTER_SETUP 1
+#define DMA_AFTER_START 2
+#define DMA_CALLBACK 3
+#define DMA_TIMEOUT 3
+#define DMA_END_TRANSFER 4
+#define DMA_NSAMPLES 5
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+/* I2S buffer container */
+
+struct stm32_buffer_s
+{
+ struct stm32_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 DMA 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 */
+};
+
+/* This structure describes the state of one receiver or transmitter transport */
+
+struct stm32_transport_s
+{
+ DMA_HANDLE dma; /* I2S DMA handle */
+ WDOG_ID dog; /* Watchdog that handles DMA 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 */
+
+#ifdef CONFIG_STM32_I2S_DMADEBUG
+ struct stm32_dmaregs_s dmaregs[DMA_NSAMPLES];
+#endif
+};
+
+/* The state of the one I2S peripheral */
+
+struct stm32_i2s_s
+{
+ struct i2s_dev_s dev; /* Externally visible I2S interface */
+ uintptr_t base; /* I2S controller register base address */
+ sem_t exclsem; /* Assures mutually exclusive acess to I2S */
+ uint8_t datalen; /* Data width (8 or 16) */
+#ifdef CONFIG_DEBUG_FEATURES
+ uint8_t align; /* Log2 of data width (0 or 1) */
+#endif
+ uint8_t rxenab:1; /* True: RX transfers enabled */
+ uint8_t txenab:1; /* True: TX transfers enabled */
+ uint8_t i2sno:6; /* I2S controller number (0 or 1) */
+#ifdef I2S_HAVE_MCK
+ uint32_t samplerate; /* Data sample rate (determines only MCK divider) */
+#endif
+ uint32_t rxccr; /* DMA control register for RX transfers */
+ uint32_t txccr; /* DMA control register for TX transfers */
+#ifdef I2S_HAVE_RX
+ struct stm32_transport_s rx; /* RX transport state */
+#endif
+#ifdef I2S_HAVE_TX
+ struct stm32_transport_s tx; /* TX transport state */
+#endif
+
+ /* Pre-allocated pool of buffer containers */
+
+ sem_t bufsem; /* Buffer wait semaphore */
+ struct stm32_buffer_s *freelist; /* A list a free buffer containers */
+ struct stm32_buffer_s containers[CONFIG_STM32_I2S_MAXINFLIGHT];
+
+ /* Debug stuff */
+
+#ifdef CONFIG_STM32_I2S_REGDEBUG
+ bool wr; /* Last was a write */
+ uint32_t regaddr; /* Last address */
+ uint16_t regval; /* Last value */
+ int count; /* Number of times */
+#endif /* CONFIG_STM32_I2S_REGDEBUG */
+};
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+/* Register helpers */
+
+#ifdef CONFIG_STM32_I2S_REGDEBUG
+static bool i2s_checkreg(struct stm32_i2s_s *priv, bool wr, uint16_t regval,
+ uint32_t regaddr);
+#else
+# define i2s_checkreg(priv,wr,regval,regaddr) (false)
+#endif
+
+static inline uint16_t i2s_getreg(struct stm32_i2s_s *priv, uint8_t offset);
+static inline void i2s_putreg(struct stm32_i2s_s *priv, uint8_t offset,
+ uint16_t regval);
+
+#if defined(CONFIG_DEBUG_I2S_INFO)
+static void i2s_dump_regs(struct stm32_i2s_s *priv, const char *msg);
+#else
+# define i2s_dump_regs(s,m)
+#endif
+
+#ifdef CONFIG_STM32_I2S_DUMPBUFFERS
+# define i2s_init_buffer(b,s) memset(b, 0x55, s);
+# define i2s_dump_buffer(m,b,s) lib_dumpbuffer(m,b,s)
+#else
+# define i2s_init_buffer(b,s)
+# define i2s_dump_buffer(m,b,s)
+#endif
+
+/* Semaphore helpers */
+
+static void i2s_exclsem_take(struct stm32_i2s_s *priv);
+#define i2s_exclsem_give(priv) sem_post(&priv->exclsem)
+
+static void i2s_bufsem_take(struct stm32_i2s_s *priv);
+#define i2s_bufsem_give(priv) sem_post(&priv->bufsem)
+
+/* Buffer container helpers */
+
+static struct stm32_buffer_s *
+ i2s_buf_allocate(struct stm32_i2s_s *priv);
+static void i2s_buf_free(struct stm32_i2s_s *priv,
+ struct stm32_buffer_s *bfcontainer);
+static void i2s_buf_initialize(struct stm32_i2s_s *priv);
+
+/* DMA support */
+
+#ifdef CONFIG_STM32_I2S_DMADEBUG
+static void i2s_dma_sampleinit(struct stm32_i2s_s *priv,
+ struct stm32_transport_s *xpt);
+#endif
+
+#if defined(CONFIG_STM32_I2S_DMADEBUG) && defined(I2S_HAVE_RX)
+# define i2s_rxdma_sample(s,i) stm32_dmasample((s)->rx.dma, &(s)->rx.dmaregs[i])
+# define i2s_rxdma_sampleinit(s) i2s_dma_sampleinit(s, &(s)->rx)
+static void i2s_rxdma_sampledone(struct stm32_i2s_s *priv, int result);
+
+#else
+# define i2s_rxdma_sample(s,i)
+# define i2s_rxdma_sampleinit(s)
+# define i2s_rxdma_sampledone(s,r)
+
+#endif
+
+#if defined(CONFIG_STM32_I2S_DMADEBUG) && defined(I2S_HAVE_TX)
+# define i2s_txdma_sample(s,i) stm32_dmasample((s)->tx.dma, &(s)->tx.dmaregs[i])
+# define i2s_txdma_sampleinit(s) i2s_dma_sampleinit(s, &(s)->tx)
+static void i2s_txdma_sampledone(struct stm32_i2s_s *priv, int result);
+
+#else
+# define i2s_txdma_sample(s,i)
+# define i2s_txdma_sampleinit(s)
+# define i2s_txdma_sampledone(s,r)
+
+#endif
+
+#ifdef I2S_HAVE_RX
+static void i2s_rxdma_timeout(int argc, uint32_t arg);
+static int i2s_rxdma_setup(struct stm32_i2s_s *priv);
+static void i2s_rx_worker(void *arg);
+static void i2s_rx_schedule(struct stm32_i2s_s *priv, int result);
+static void i2s_rxdma_callback(DMA_HANDLE handle, uint8_t result, void *arg);
+#endif
+#ifdef I2S_HAVE_TX
+static void i2s_txdma_timeout(int argc, uint32_t arg);
+static int i2s_txdma_setup(struct stm32_i2s_s *priv);
+static void i2s_tx_worker(void *arg);
+static void i2s_tx_schedule(struct stm32_i2s_s *priv, int result);
+static void i2s_txdma_callback(DMA_HANDLE handle, uint8_t result, void *arg);
+#endif
+
+/* I2S methods (and close friends) */
+
+static int i2s_checkwidth(struct stm32_i2s_s *priv, int bits);
+
+static uint32_t stm32_i2s_rxsamplerate(struct i2s_dev_s *dev, uint32_t rate);
+static uint32_t stm32_i2s_rxdatawidth(struct i2s_dev_s *dev, int bits);
+static int stm32_i2s_receive(struct i2s_dev_s *dev, struct ap_buffer_s *apb,
+ i2s_callback_t callback, void *arg, uint32_t timeout);
+static uint32_t stm32_i2s_txsamplerate(struct i2s_dev_s *dev, uint32_t rate);
+static uint32_t stm32_i2s_txdatawidth(struct i2s_dev_s *dev, int bits);
+static int stm32_i2s_send(struct i2s_dev_s *dev, struct ap_buffer_s *apb,
+ i2s_callback_t callback, void *arg,
+ uint32_t timeout);
+
+/* Initialization */
+
+static uint32_t i2s_mckdivider(struct stm32_i2s_s *priv);
+static int i2s_dma_flags(struct stm32_i2s_s *priv);
+static int i2s_dma_allocate(struct stm32_i2s_s *priv);
+static void i2s_dma_free(struct stm32_i2s_s *priv);
+#ifdef CONFIG_STM32_I2S2
+static void i2s2_configure(struct stm32_i2s_s *priv);
+#endif
+#ifdef CONFIG_STM32_I2S3
+static void i2s3_configure(struct stm32_i2s_s *priv);
+#endif
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/* I2S device operations */
+
+static const struct i2s_ops_s g_i2sops =
+{
+ /* Receiver methods */
+
+ .i2s_rxsamplerate = stm32_i2s_rxsamplerate,
+ .i2s_rxdatawidth = stm32_i2s_rxdatawidth,
+ .i2s_receive = stm32_i2s_receive,
+
+ /* Transmitter methods */
+
+ .i2s_txsamplerate = stm32_i2s_txsamplerate,
+ .i2s_txdatawidth = stm32_i2s_txdatawidth,
+ .i2s_send = stm32_i2s_send,
+};
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: i2s_checkreg
+ *
+ * Description:
+ * Check if the current register access is a duplicate of the preceding.
+ *
+ * Input Parameters:
+ * regval - The value to be written
+ * regaddr - The address of the register to write to
+ *
+ * Returned Value:
+ * true: This is the first register access of this type.
+ * flase: This is the same as the preceding register access.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_STM32_I2S_REGDEBUG
+static bool i2s_checkreg(struct stm32_i2s_s *priv, bool wr, uint16_t regval,
+ uint32_t regaddr)
+{
+ if (wr == priv->wr && /* Same kind of access? */
+ regval == priv->regval && /* Same value? */
+ regaddr == priv->regaddr) /* Same address? */
+ {
+ /* Yes, then just keep a count of the number of times we did this. */
+
+ priv->count++;
+ return false;
+ }
+ else
+ {
+ /* Did we do the previous operation more than once? */
+
+ if (priv->count > 0)
+ {
+ /* Yes... show how many times we did it */
+
+ i2sinfo("...[Repeats %d times]...\n", priv->count);
+ }
+
+ /* Save information about the new access */
+
+ priv->wr = wr;
+ priv->regval = regval;
+ priv->regaddr = regaddr;
+ priv->count = 0;
+ }
+
+ /* Return true if this is the first time that we have done this operation */
+
+ return true;
+}
+#endif
+
+/****************************************************************************
+ * Name: i2s_getreg
+ *
+ * Description:
+ * Get the contents of the I2S register at offset
+ *
+ * Input Parameters:
+ * priv - private I2S device structure
+ * offset - offset to the register of interest
+ *
+ * Returned Value:
+ * The contents of the 16-bit register
+ *
+ ****************************************************************************/
+
+static inline uint16_t i2s_getreg(FAR struct stm32_i2s_s *priv,
+ uint8_t offset)
+{
+ uint32_t regaddr = priv->base + offset;
+ uint16_t regval = getreg16(regaddr);
+
+#ifdef CONFIG_STM32_I2S_REGDEBUG
+ if (i2s_checkreg(priv, false, regval, regaddr))
+ {
+ i2sinfo("%08x->%04x\n", regaddr, regval);
+ }
+#endif
+
+ return regval;
+}
+
+/****************************************************************************
+ * Name: spi_putreg
+ *
+ * Description:
+ * Write a 16-bit value to the SPI register at offset
+ *
+ * Input Parameters:
+ * priv - private SPI device structure
+ * offset - offset to the register of interest
+ * value - the 16-bit value to be written
+ *
+ * Returned Value:
+ * The contents of the 16-bit register
+ *
+ ****************************************************************************/
+
+static inline void i2s_putreg(FAR struct stm32_i2s_s *priv, uint8_t offset,
+ uint16_t regval)
+{
+ uint32_t regaddr = priv->base + offset;
+
+#ifdef CONFIG_STM32_I2S_REGDEBUG
+ if (i2s_checkreg(priv, true, regval, regaddr))
+ {
+ i2sinfo("%08x<-%04x\n", regaddr, regval);
+ }
+#endif
+
+ putreg16(regval, regaddr);
+}
+
+/****************************************************************************
+ * Name: i2s_dump_regs
+ *
+ * Description:
+ * Dump the contents of all I2S registers
+ *
+ * Input Parameters:
+ * priv - The I2S controller to dump
+ * msg - Message to print before the register data
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+#if defined(CONFIG_DEBUG_I2S)
+static void i2s_dump_regs(struct stm32_i2s_s *priv, const char *msg)
+{
+ i2sinfo("I2S%d: %s\n", priv->i2sno, msg);
+ i2sinfo(" CR1:%04x CR2:%04x SR:%04x DR:%04x\n",
+ i2s_getreg(priv, STM32_SPI_CR1_OFFSET),
+ i2s_getreg(priv, STM32_SPI_CR2_OFFSET),
+ i2s_getreg(priv, STM32_SPI_SR_OFFSET),
+ i2s_getreg(priv, STM32_SPI_DR_OFFSET));
+ i2sinfo(" I2SCFGR:%04x I2SPR:%04x\n",
+ i2s_getreg(priv, STM32_SPI_I2SCFGR_OFFSET),
+ i2s_getreg(priv, STM32_SPI_I2SPR_OFFSET));
+}
+#endif
+
+/****************************************************************************
+ * Name: i2s_exclsem_take
+ *
+ * Description:
+ * Take the exclusive access semaphore handling any exceptional conditions
+ *
+ * Input Parameters:
+ * priv - A reference to the i2s peripheral state
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+static void i2s_exclsem_take(struct stm32_i2s_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: i2s_bufsem_take
+ *
+ * Description:
+ * Take the buffer semaphore handling any exceptional conditions
+ *
+ * Input Parameters:
+ * priv - A reference to the i2s peripheral state
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+static void i2s_bufsem_take(struct stm32_i2s_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: i2s_buf_allocate
+ *
+ * Description:
+ * Allocate a buffer container by removing the one at the head of the
+ * free list
+ *
+ * Input Parameters:
+ * priv - I2S 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 I2S state structure.
+ * That would result in a deadlock!
+ *
+ ****************************************************************************/
+
+static struct stm32_buffer_s *i2s_buf_allocate(struct stm32_i2s_s *priv)
+{
+ struct stm32_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.
+ */
+
+ i2s_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: i2s_buf_free
+ *
+ * Description:
+ * Free buffer container by adding it to the head of the free list
+ *
+ * Input Parameters:
+ * priv - I2S state instance
+ * bfcontainer - The buffer container to be freed
+ *
+ * Returned Value:
+ * None
+ *
+ * Assumptions:
+ * The caller has exclusive access to the I2S state structure
+ *
+ ****************************************************************************/
+
+static void i2s_buf_free(struct stm32_i2s_s *priv, struct stm32_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 */
+
+ i2s_bufsem_give(priv);
+}
+
+/****************************************************************************
+ * Name: i2s_buf_initialize
+ *
+ * Description:
+ * Initialize the buffer container allocator by adding all of the
+ * pre-allocated buffer containers to the free list
+ *
+ * Input Parameters:
+ * priv - I2S state instance
+ *
+ * Returned Value:
+ * None
+ *
+ * Assumptions:
+ * Called early in I2S initialization so that there are no issues with
+ * concurrency.
+ *
+ ****************************************************************************/
+
+static void i2s_buf_initialize(struct stm32_i2s_s *priv)
+{
+ int i;
+
+ priv->freelist = NULL;
+ sem_init(&priv->bufsem, 0, CONFIG_STM32_I2S_MAXINFLIGHT);
+
+ for (i = 0; i < CONFIG_STM32_I2S_MAXINFLIGHT; i++)
+ {
+ i2s_buf_free(priv, &priv->containers[i]);
+ }
+}
+
+/****************************************************************************
+ * Name: i2s_dma_sampleinit
+ *
+ * Description:
+ * Initialize sampling of DMA registers (if CONFIG_STM32_I2S_DMADEBUG)
+ *
+ * Input Parameters:
+ * priv - I2S state instance
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+#if defined(CONFIG_STM32_I2S_DMADEBUG)
+static void i2s_dma_sampleinit(struct stm32_i2s_s *priv,
+ struct stm32_transport_s *xpt)
+{
+ /* Put contents of register samples into a known state */
+
+ memset(xpt->dmaregs, 0xff, DMA_NSAMPLES * sizeof(struct stm32_dmaregs_s));
+
+ /* Then get the initial samples */
+
+ stm32_dmasample(xpt->dma, &xpt->dmaregs[DMA_INITIAL]);
+}
+#endif
+
+/****************************************************************************
+ * Name: i2s_rxdma_sampledone
+ *
+ * Description:
+ * Dump sampled RX DMA registers
+ *
+ * Input Parameters:
+ * priv - I2S state instance
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+#if defined(CONFIG_STM32_I2S_DMADEBUG) && defined(I2S_HAVE_RX)
+static void i2s_rxdma_sampledone(struct stm32_i2s_s *priv, int result)
+{
+ i2sinfo("result: %d\n", result);
+
+ /* Sample the final registers */
+
+ stm32_dmasample(priv->rx.dma, &priv->rx.dmaregs[DMA_END_TRANSFER]);
+
+ /* Then dump the sampled DMA registers */
+ /* Initial register values */
+
+ stm32_dmadump(priv->rx.dma, &priv->rx.dmaregs[DMA_INITIAL],
+ "RX: Initial Registers");
+
+ /* Register values after DMA setup */
+
+ stm32_dmadump(priv->rx.dma, &priv->rx.dmaregs[DMA_AFTER_SETUP],
+ "RX: After DMA Setup");
+
+ /* Register values after DMA start */
+
+ stm32_dmadump(priv->rx.dma, &priv->rx.dmaregs[DMA_AFTER_START],
+ "RX: After DMA Start");
+
+ /* Register values at the time of the TX and RX DMA callbacks
+ * -OR- DMA timeout.
+ *
+ * If the DMA timedout, then there will not be any RX DMA
+ * callback samples. There is probably no TX DMA callback
+ * samples either, but we don't know for sure.
+ */
+
+ if (result == -ETIMEDOUT || result == -EINTR)
+ {
+ stm32_dmadump(priv->rx.dma, &priv->rx.dmaregs[DMA_TIMEOUT],
+ "RX: At DMA timeout");
+ }
+ else
+ {
+ stm32_dmadump(priv->rx.dma, &priv->rx.dmaregs[DMA_CALLBACK],
+ "RX: At DMA callback");
+ }
+
+ stm32_dmadump(priv->rx.dma, &priv->rx.dmaregs[DMA_END_TRANSFER],
+ "RX: At End-of-Transfer");
+
+ i2s_dump_regs(priv, "RX: At End-of-Transfer");
+}
+#endif
+
+/****************************************************************************
+ * Name: i2s_txdma_sampledone
+ *
+ * Description:
+ * Dump sampled DMA registers
+ *
+ * Input Parameters:
+ * priv - I2S state instance
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+#if defined(CONFIG_STM32_I2S_DMADEBUG) && defined(I2S_HAVE_TX)
+static void i2s_txdma_sampledone(struct stm32_i2s_s *priv, int result)
+{
+ i2sinfo("result: %d\n", result);
+
+ /* Sample the final registers */
+
+ stm32_dmasample(priv->tx.dma, &priv->tx.dmaregs[DMA_END_TRANSFER]);
+
+ /* Then dump the sampled DMA registers */
+ /* Initial register values */
+
+ stm32_dmadump(priv->tx.dma, &priv->tx.dmaregs[DMA_INITIAL],
+ "TX: Initial Registers");
+
+ /* Register values after DMA setup */
+
+ stm32_dmadump(priv->tx.dma, &priv->tx.dmaregs[DMA_AFTER_SETUP],
+ "TX: After DMA Setup");
+
+ /* Register values after DMA start */
+
+ stm32_dmadump(priv->tx.dma, &priv->tx.dmaregs[DMA_AFTER_START],
+ "TX: After DMA Start");
+
+ /* Register values at the time of the TX and RX DMA callbacks
+ * -OR- DMA timeout.
+ */
+
+ if (result == -ETIMEDOUT || result == -EINTR)
+ {
+ stm32_dmadump(priv->tx.dma, &priv->tx.dmaregs[DMA_TIMEOUT],
+ "TX: At DMA timeout");
+ }
+ else
+ {
+ stm32_dmadump(priv->tx.dma, &priv->tx.dmaregs[DMA_CALLBACK],
+ "TX: At DMA callback");
+ }
+
+ stm32_dmadump(priv->tx.dma, &priv->tx.dmaregs[DMA_END_TRANSFER],
+ "TX: At End-of-Transfer");
+
+ i2s_dump_regs(priv, "TX: At End-of-Transfer");
+}
+#endif
+
+/****************************************************************************
+ * Name: i2s_rxdma_timeout
+ *
+ * Description:
+ * The RX watchdog timeout without completion of the RX DMA.
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifdef I2S_HAVE_RX
+static void i2s_rxdma_timeout(int argc, uint32_t arg)
+{
+ struct stm32_i2s_s *priv = (struct stm32_i2s_s *)arg;
+ DEBUGASSERT(priv != NULL);
+
+ /* Sample DMA registers at the time of the timeout */
+
+ i2s_rxdma_sample(priv, DMA_TIMEOUT);
+
+ /* Cancel the DMA */
+
+ stm32_dmastop(priv->rx.dma);
+
+ /* Then schedule completion of the transfer to occur on the worker thread.
+ * NOTE: stm32_dmastop() will call the DMA complete callback with an error
+ * of -EINTR. So the following is just insurance and should have no
+ * effect if the worker is already schedule.
+ */
+
+ i2s_rx_schedule(priv, -ETIMEDOUT);
+}
+#endif
+
+/****************************************************************************
+ * Name: i2s_rxdma_setup
+ *
+ * Description:
+ * Setup and initiate the next RX DMA transfer
+ *
+ * Input Parameters:
+ * priv - I2S state instance
+ *
+ * Returned Value:
+ * OK on success; a negated errno value on failure
+ *
+ * Assumptions:
+ * Interrupts are disabled
+ *
+ ****************************************************************************/
+
+#ifdef I2S_HAVE_RX
+static int i2s_rxdma_setup(struct stm32_i2s_s *priv)
+{
+ struct stm32_buffer_s *bfcontainer;
+ struct ap_buffer_s *apb;
+ uintptr_t samp;
+ uint32_t timeout;
+ bool notimeout;
+ int ret;
+
+ /* If there is already an active transmission in progress, then bail
+ * returning success.
+ */
+
+ if (!sq_empty(&priv->rx.act))
+ {
+ return OK;
+ }
+
+ /* If there are no pending transfer, then bail returning success */
+
+ if (sq_empty(&priv->rx.pend))
+ {
+ return OK;
+ }
+
+ /* Initialize DMA register sampling */
+
+ i2s_rxdma_sampleinit(priv);
+
+ /* Loop, adding each pending DMA */
+
+ timeout = 0;
+ notimeout = false;
+
+ do
+ {
+ /* Remove the pending RX transfer at the head of the RX pending queue. */
+
+ bfcontainer = (struct stm32_buffer_s *)sq_remfirst(&priv->rx.pend);
+ DEBUGASSERT(bfcontainer && bfcontainer->apb);
+
+ apb = bfcontainer->apb;
+ DEBUGASSERT(((uintptr_t)apb->samp % priv->align) == 0);
+
+ /* No data received yet */
+
+ apb->nbytes = 0;
+ apb->curbyte = 0;
+ samp = (uintptr_t)&apb->samp[apb->curbyte];
+
+ /* Configure the RX DMA */
+
+ stm32_dmasetup(priv->rx.dma, priv->base + STM32_SPI_DR_OFFSET,
+ (uint32_t)samp, apb->nmaxbytes, priv->rxccr);
+
+ /* Increment the DMA timeout */
+
+ if (bfcontainer->timeout > 0)
+ {
+ timeout += bfcontainer->timeout;
+ }
+ else
+ {
+ notimeout = true;
+ }
+
+ /* Add the container to the list of active DMAs */
+
+ sq_addlast((sq_entry_t *)bfcontainer, &priv->rx.act);
+ }
+#if 1 /* REVISIT: Chained RX transfers */
+ while (0);
+#else
+ while (!sq_empty(&priv->rx.pend));
+#endif
+
+ /* Sample DMA registers */
+
+ i2s_rxdma_sample(priv, DMA_AFTER_SETUP);
+
+ /* Start the DMA, saving the container as the current active transfer */
+
+ stm32_dmastart(priv->rx.dma, i2s_rxdma_callback, priv, false);
+
+ i2s_rxdma_sample(priv, DMA_AFTER_START);
+
+ /* Enable the receiver */
+
+ i2s_putreg(priv, STM32_SPI_CR2_OFFSET,
+ i2s_getreg(priv, STM32_SPI_CR2_OFFSET) | SPI_CR2_RXDMAEN);
+
+ /* Start a watchdog to catch DMA timeouts */
+
+ if (!notimeout)
+ {
+ ret = wd_start(priv->rx.dog, timeout, (wdentry_t)i2s_rxdma_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", errno);
+ }
+ }
+
+ return OK;
+}
+#endif
+
+/****************************************************************************
+ * Name: i2s_rx_worker
+ *
+ * Description:
+ * RX transfer done worker
+ *
+ * Input Parameters:
+ * arg - the I2S device instance cast to void*
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+#ifdef I2S_HAVE_RX
+static void i2s_rx_worker(void *arg)
+{
+ struct stm32_i2s_s *priv = (struct stm32_i2s_s *)arg;
+ struct stm32_buffer_s *bfcontainer;
+ struct ap_buffer_s *apb;
+ irqstate_t flags;
+
+ DEBUGASSERT(priv);
+
+ /* When the transfer was started, the active buffer containers were removed
+ * from the rx.pend queue and saved in the rx.act queue. We get here when the
+ * DMA is finished... either successfully, with a DMA error, or with a DMA
+ * timeout.
+ *
+ * In any case, the buffer containers in rx.act will be moved to the end
+ * of the rx.done queue and rx.act queue will be emptied before this worker
+ * is started.
+ *
+ * REVISIT: Normal DMA callback processing should restart the DMA
+ * immediately to avoid audio artifacts at the boundaries between DMA
+ * transfers. Unfortunately, the DMA callback occurs at the interrupt
+ * level and we cannot call dma_rxsetup() from the interrupt level.
+ * So we have to start the next DMA here.
+ */
+
+ i2sinfo("rx.act.head=%p rx.done.head=%p\n",
+ priv->rx.act.head, priv->rx.done.head);
+
+ /* Check if the DMA is IDLE */
+
+ if (sq_empty(&priv->rx.act))
+ {
+#ifdef CONFIG_STM32_I2S_DMADEBUG
+ bfcontainer = (struct stm32_buffer_s *)sq_peek(&priv->rx.done);
+ if (bfcontainer)
+ {
+ /* Dump the DMA registers */
+
+ i2s_rxdma_sampledone(priv, bfcontainer->result);
+ }
+#endif
+
+ /* Then start the next DMA. This must be done with interrupts
+ * disabled.
+ */
+
+ flags = enter_critical_section();
+ (void)i2s_rxdma_setup(priv);
+ leave_critical_section(flags);
+ }
+
+ /* Process each buffer in the rx.done queue */
+
+ while (sq_peek(&priv->rx.done) != NULL)
+ {
+ /* Remove the buffer container from the rx.done queue. NOTE that
+ * interrupts must be enabled to do this because the rx.done queue is
+ * also modified from the interrupt level.
+ */
+
+ flags = enter_critical_section();
+ bfcontainer = (struct stm32_buffer_s *)sq_remfirst(&priv->rx.done);
+ leave_critical_section(flags);
+
+ DEBUGASSERT(bfcontainer && bfcontainer->apb && bfcontainer->callback);
+ apb = bfcontainer->apb;
+
+ /* If the DMA was successful, then update the number of valid bytes in
+ * the audio buffer.
+ */
+
+ if (bfcontainer->result == OK)
+ {
+ apb->nbytes = apb->nmaxbytes;
+ }
+
+ i2s_dump_buffer("Received", apb->samp, apb->nbytes);
+
+ /* Perform the RX transfer done callback */
+
+ bfcontainer->callback(&priv->dev, 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(apb);
+
+ /* And release the buffer container */
+
+ i2s_buf_free(priv, bfcontainer);
+ }
+}
+#endif
+
+/****************************************************************************
+ * Name: i2s_rx_schedule
+ *
+ * Description:
+ * An RX DMA completion or timeout has occurred. Schedule processing on
+ * the working thread.
+ *
+ * Input Parameters:
+ * handle - The DMA handler
+ * arg - A pointer to the chip select struction
+ * result - The result of the DMA transfer
+ *
+ * Returned Value:
+ * None
+ *
+ * Assumptions:
+ * Interrupts are disabled
+ *
+ ****************************************************************************/
+
+#ifdef I2S_HAVE_RX
+static void i2s_rx_schedule(struct stm32_i2s_s *priv, int result)
+{
+ struct stm32_buffer_s *bfcontainer;
+ int ret;
+
+ /* Upon entry, the transfer(s) that just completed are the ones in the
+ * priv->rx.act queue. NOTE: In certain conditions, this function may
+ * be called an additional time, hence, we can't assert this to be true.
+ * For example, in the case of a timeout, this function will be called by
+ * both indirectly via the stm32_dmastop() logic and directly via the
+ * i2s_rxdma_timeout() logic.
+ */
+
+ /* Move all entries from the rx.act queue to the rx.done queue */
+
+ while (!sq_empty(&priv->rx.act))
+ {
+ /* Remove the next buffer container from the rx.act list */
+
+ bfcontainer = (struct stm32_buffer_s *)sq_remfirst(&priv->rx.act);
+
+ /* Report the result of the transfer */
+
+ bfcontainer->result = result;
+
+ /* Add the completed buffer container to the tail of the rx.done queue */
+
+ sq_addlast((sq_entry_t *)bfcontainer, &priv->rx.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->rx.work))
+ {
+ /* Schedule the TX DMA done processing to occur on the worker thread. */
+
+ ret = work_queue(HPWORK, &priv->rx.work, i2s_rx_worker, priv, 0);
+ if (ret != 0)
+ {
+ i2serr("ERROR: Failed to queue RX work: %d\n", ret);
+ }
+ }
+}
+#endif
+
+/****************************************************************************
+ * Name: i2s_rxdma_callback
+ *
+ * Description:
+ * This callback function is invoked at the completion of the I2S RX DMA.
+ *
+ * Input Parameters:
+ * handle - The DMA handler
+ * arg - A pointer to the chip select struction
+ * result - The result of the DMA transfer
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+#ifdef I2S_HAVE_RX
+static void i2s_rxdma_callback(DMA_HANDLE handle, uint8_t result, void *arg)
+{
+ struct stm32_i2s_s *priv = (struct stm32_i2s_s *)arg;
+ DEBUGASSERT(priv != NULL);
+
+ /* Cancel the watchdog timeout */
+
+ (void)wd_cancel(priv->rx.dog);
+
+ /* Sample DMA registers at the time of the DMA completion */
+
+ i2s_rxdma_sample(priv, DMA_CALLBACK);
+
+ /* REVISIT: We would like to the next DMA started here so that we do not
+ * get audio glitches at the boundaries between DMA transfers.
+ * Unfortunately, we cannot call stm32_dmasetup() from an interrupt handler!
+ */
+
+ /* Then schedule completion of the transfer to occur on the worker thread */
+
+ i2s_rx_schedule(priv, result);
+}
+#endif
+
+/****************************************************************************
+ * Name: i2s_txdma_timeout
+ *
+ * Description:
+ * The RX watchdog timeout without completion of the RX DMA.
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifdef I2S_HAVE_TX
+static void i2s_txdma_timeout(int argc, uint32_t arg)
+{
+ struct stm32_i2s_s *priv = (struct stm32_i2s_s *)arg;
+ DEBUGASSERT(priv != NULL);
+
+ /* Sample DMA registers at the time of the timeout */
+
+ i2s_txdma_sample(priv, DMA_TIMEOUT);
+
+ /* Cancel the DMA */
+
+ stm32_dmastop(priv->tx.dma);
+
+ /* Then schedule completion of the transfer to occur on the worker thread.
+ * NOTE: stm32_dmastop() will call the DMA complete callback with an error
+ * of -EINTR. So the following is just insurance and should have no
+ * effect if the worker is already schedule.
+ */
+
+ i2s_tx_schedule(priv, -ETIMEDOUT);
+}
+#endif
+
+/****************************************************************************
+ * Name: i2s_txdma_setup
+ *
+ * Description:
+ * Setup and initiate the next TX DMA transfer
+ *
+ * Input Parameters:
+ * priv - I2S state instance
+ *
+ * Returned Value:
+ * OK on success; a negated errno value on failure
+ *
+ * Assumptions:
+ * Interrupts are disabled
+ *
+ ****************************************************************************/
+
+#ifdef I2S_HAVE_TX
+static int i2s_txdma_setup(struct stm32_i2s_s *priv)
+{
+ struct stm32_buffer_s *bfcontainer;
+ struct ap_buffer_s *apb;
+ uintptr_t samp;
+ uint32_t timeout;
+ apb_samp_t nbytes;
+ bool notimeout;
+ int ret;
+
+ /* If there is already an active transmission in progress, then bail
+ * returning success.
+ */
+
+ if (!sq_empty(&priv->tx.act))
+ {
+ return OK;
+ }
+
+ /* If there are no pending transfer, then bail returning success */
+
+ if (sq_empty(&priv->tx.pend))
+ {
+ return OK;
+ }
+
+ /* Initialize DMA register sampling */
+
+ i2s_txdma_sampleinit(priv);
+
+ /* Loop, adding each pending DMA */
+
+ timeout = 0;
+ notimeout = false;
+
+ do
+ {
+ /* Remove the pending TX transfer at the head of the TX pending queue. */
+
+ bfcontainer = (struct stm32_buffer_s *)sq_remfirst(&priv->tx.pend);
+ DEBUGASSERT(bfcontainer && bfcontainer->apb);
+
+ apb = bfcontainer->apb;
+
+ /* Get the transfer information, accounting for any data offset */
+
+ samp = (uintptr_t)&apb->samp[apb->curbyte];
+ nbytes = apb->nbytes - apb->curbyte;
+ DEBUGASSERT((samp & priv->align) == 0 && (nbytes & priv->align) == 0);
+
+ /* Configure DMA stream */
+
+ stm32_dmasetup(priv->tx.dma, priv->base + STM32_SPI_DR_OFFSET,
+ (uint32_t)samp, nbytes/2, priv->txccr);
+
+ /* Increment the DMA timeout */
+ if (bfcontainer->timeout > 0)
+ {
+ timeout += bfcontainer->timeout;
+ }
+ else
+ {
+ notimeout = true;
+ }
+
+ /* Add the container to the list of active DMAs */
+
+ sq_addlast((sq_entry_t *)bfcontainer, &priv->tx.act);
+ }
+#if 1 /* REVISIT: Chained TX transfers */
+ while (0);
+#else
+ while (!sq_empty(&priv->tx.pend));
+#endif
+
+ /* Sample DMA registers */
+
+ i2s_txdma_sample(priv, DMA_AFTER_SETUP);
+
+ /* Start the DMA, saving the container as the current active transfer */
+
+ stm32_dmastart(priv->tx.dma, i2s_txdma_callback, priv, true);
+
+ i2s_txdma_sample(priv, DMA_AFTER_START);
+
+ /* Enable the transmitter */
+
+ i2s_putreg(priv, STM32_SPI_CR2_OFFSET, i2s_getreg(priv, STM32_SPI_CR2_OFFSET) | SPI_CR2_TXDMAEN);
+
+ /* Start a watchdog to catch DMA timeouts */
+
+ if (!notimeout)
+ {
+ ret = wd_start(priv->tx.dog, timeout, (wdentry_t)i2s_txdma_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", errno);
+ }
+ }
+
+ return OK;
+}
+#endif
+
+/****************************************************************************
+ * Name: i2s_tx_worker
+ *
+ * Description:
+ * TX transfer done worker
+ *
+ * Input Parameters:
+ * arg - the I2S device instance cast to void*
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+#ifdef I2S_HAVE_TX
+static void i2s_tx_worker(void *arg)
+{
+ struct stm32_i2s_s *priv = (struct stm32_i2s_s *)arg;
+ struct stm32_buffer_s *bfcontainer;
+ irqstate_t flags;
+
+ DEBUGASSERT(priv);
+
+ /* When the transfer was started, the active buffer containers were removed
+ * from the tx.pend queue and saved in the tx.act queue. We get here when the
+ * DMA is finished... either successfully, with a DMA error, or with a DMA
+ * timeout.
+ *
+ * In any case, the buffer containers in tx.act will be moved to the end
+ * of the tx.done queue and tx.act will be emptied before this worker is
+ * started.
+ *
+ * REVISIT: Normal DMA callback processing should restart the DMA
+ * immediately to avoid audio artifacts at the boundaries between DMA
+ * transfers. Unfortunately, the DMA callback occurs at the interrupt
+ * level and we cannot call dma_txsetup() from the interrupt level.
+ * So we have to start the next DMA here.
+ */
+
+ i2sinfo("tx.act.head=%p tx.done.head=%p\n",
+ priv->tx.act.head, priv->tx.done.head);
+
+ /* Check if the DMA is IDLE */
+
+ if (sq_empty(&priv->tx.act))
+ {
+#ifdef CONFIG_STM32_I2S_DMADEBUG
+ bfcontainer = (struct stm32_buffer_s *)sq_peek(&priv->tx.done);
+ if (bfcontainer)
+ {
+ /* Dump the DMA registers */
+
+ i2s_txdma_sampledone(priv, bfcontainer->result);
+ }
+#endif
+
+ /* Then start the next DMA. This must be done with interrupts
+ * disabled.
+ */
+
+ flags = enter_critical_section();
+ (void)i2s_txdma_setup(priv);
+ leave_critical_section(flags);
+ }
+
+ /* Process each buffer in the tx.done queue */
+
+ while (sq_peek(&priv->tx.done) != NULL)
+ {
+ /* Remove the buffer container from the tx.done queue. NOTE that
+ * interupts must be enabled to do this because the tx.done queue is
+ * also modified from the interrupt level.
+ */
+
+ flags = enter_critical_section();
+ bfcontainer = (struct stm32_buffer_s *)sq_remfirst(&priv->tx.done);
+ leave_critical_section(flags);
+
+ /* Perform the TX 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 */
+
+ i2s_buf_free(priv, bfcontainer);
+ }
+}
+#endif
+
+/****************************************************************************
+ * Name: i2s_tx_schedule
+ *
+ * Description:
+ * An TX DMA completion or timeout has occurred. Schedule processing on
+ * the working thread.
+ *
+ * Input Parameters:
+ * handle - The DMA handler
+ * arg - A pointer to the chip select struction
+ * result - The result of the DMA transfer
+ *
+ * Returned Value:
+ * None
+ *
+ * Assumptions:
+ * - Interrupts are disabled
+ * - The TX timeout has been canceled.
+ *
+ ****************************************************************************/
+
+#ifdef I2S_HAVE_TX
+static void i2s_tx_schedule(struct stm32_i2s_s *priv, int result)
+{
+ struct stm32_buffer_s *bfcontainer;
+ int ret;
+
+ /* Upon entry, the transfer(s) that just completed are the ones in the
+ * priv->tx.act queue. NOTE: In certain conditions, this function may
+ * be called an additional time, hence, we can't assert this to be true.
+ * For example, in the case of a timeout, this function will be called by
+ * both indirectly via the stm32_dmastop() logic and directly via the
+ * i2s_txdma_timeout() logic.
+ */
+
+ /* Move all entries from the tx.act queue to the tx.done queue */
+
+ while (!sq_empty(&priv->tx.act))
+ {
+ /* Remove the next buffer container from the tx.act list */
+
+ bfcontainer = (struct stm32_buffer_s *)sq_remfirst(&priv->tx.act);
+
+ /* Report the result of the transfer */
+
+ bfcontainer->result = result;
+
+ /* Add the completed buffer container to the tail of the tx.done queue */
+
+ sq_addlast((sq_entry_t *)bfcontainer, &priv->tx.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->tx.work))
+ {
+ /* Schedule the TX DMA done processing to occur on the worker thread. */
+
+ ret = work_queue(HPWORK, &priv->tx.work, i2s_tx_worker, priv, 0);
+ if (ret != 0)
+ {
+ i2serr("ERROR: Failed to queue TX work: %d\n", ret);
+ }
+ }
+}
+#endif
+
+/****************************************************************************
+ * Name: i2s_txdma_callback
+ *
+ * Description:
+ * This callback function is invoked at the completion of the I2S TX DMA.
+ *
+ * Input Parameters:
+ * handle - The DMA handler
+ * arg - A pointer to the chip select struction
+ * result - The result of the DMA transfer
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+#ifdef I2S_HAVE_TX
+static void i2s_txdma_callback(DMA_HANDLE handle, uint8_t result, void *arg)
+{
+ struct stm32_i2s_s *priv = (struct stm32_i2s_s *)arg;
+ DEBUGASSERT(priv != NULL);
+
+ /* Cancel the watchdog timeout */
+
+ (void)wd_cancel(priv->tx.dog);
+
+ /* Sample DMA registers at the time of the DMA completion */
+
+ i2s_txdma_sample(priv, DMA_CALLBACK);
+
+ /* REVISIT: We would like to the next DMA started here so that we do not
+ * get audio glitches at the boundaries between DMA transfers.
+ * Unfortunately, we cannot call stm32_dmasetup() from an interrupt handler!
+ */
+
+ /* Then schedule completion of the transfer to occur on the worker thread */
+
+ i2s_tx_schedule(priv, result);
+}
+#endif
+
+/****************************************************************************
+ * Name: i2s_checkwidth
+ *
+ * Description:
+ * Check for a valid bit width. The I2S is capable of handling most any
+ * bit width from 8 to 16, but the DMA logic in this driver is constrained
+ * to 8- and 16-bit data widths
+ *
+ * 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 int i2s_checkwidth(struct stm32_i2s_s *priv, int bits)
+{
+ /* The I2S can handle most any bit width from 8 to 32. However, the DMA
+ * logic here is constrained to byte, half-word, and word sizes.
+ */
+
+ switch (bits)
+ {
+ case 8:
+#ifdef CONFIG_DEBUG
+ priv->align = 0;
+#endif
+ break;
+
+ case 16:
+#ifdef CONFIG_DEBUG
+ priv->align = 1;
+#endif
+ break;
+
+ default:
+ i2serr("ERROR: Unsupported or invalid data width: %d\n", bits);
+ return (bits < 8 || bits > 16) ? -EINVAL : -ENOSYS;
+ }
+
+ /* Save the new data width */
+
+ priv->datalen = bits;
+ return OK;
+}
+
+/****************************************************************************
+ * Name: stm32_i2s_rxsamplerate
+ *
+ * Description:
+ * Set the I2S RX sample rate. NOTE: This will have no effect if (1) the
+ * driver does not support an I2C receiver or if (2) the sample rate is
+ * driven by the I2C frame clock. This may also have unexpected side-
+ * effects of the RX sample is coupled with the 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 stm32_i2s_rxsamplerate(struct i2s_dev_s *dev, uint32_t rate)
+{
+#if defined(I2S_HAVE_RX) && defined(I2S_HAVE_MCK)
+ struct stm32_i2s_s *priv = (struct stm32_i2s_s *)dev;
+ DEBUGASSERT(priv && priv->samplerate > 0 && rate > 0);
+
+ /* Check if the receiver is driven by the MCK */
+
+ if (priv->samplerate != rate)
+ {
+ /* Save the new sample rate and update the MCK divider */
+
+ priv->samplerate = rate;
+ return i2s_mckdivider(priv);
+ }
+#endif
+
+ return 0;
+}
+
+/****************************************************************************
+ * Name: stm32_i2s_rxdatawidth
+ *
+ * Description:
+ * Set the I2S RX data width. The RX 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 stm32_i2s_rxdatawidth(struct i2s_dev_s *dev, int bits)
+{
+#ifdef I2S_HAVE_RX
+ struct stm32_i2s_s *priv = (struct stm32_i2s_s *)dev;
+ int ret;
+
+ DEBUGASSERT(priv && bits > 1);
+
+ /* Check if this is a bit width that we are configured to handle */
+
+ ret = i2s_checkwidth(priv, bits);
+ if (ret < 0)
+ {
+ i2serr("ERROR: i2s_checkwidth failed: %d\n", ret);
+ return 0;
+ }
+
+ /* Update the DMA flags */
+
+ ret = i2s_dma_flags(priv);
+ if (ret < 0)
+ {
+ i2serr("ERROR: i2s_dma_flags failed: %d\n", ret);
+ return 0;
+ }
+
+#endif
+
+ return 0;
+}
+
+/****************************************************************************
+ * Name: stm32_i2s_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 stm32_i2s_receive(struct i2s_dev_s *dev, struct ap_buffer_s *apb,
+ i2s_callback_t callback, void *arg, uint32_t timeout)
+{
+ struct stm32_i2s_s *priv = (struct stm32_i2s_s *)dev;
+#ifdef I2S_HAVE_RX
+ struct stm32_buffer_s *bfcontainer;
+ irqstate_t flags;
+ int ret;
+#endif
+
+ DEBUGASSERT(priv && apb && ((uintptr_t)apb->samp & priv->align) == 0);
+ i2sinfo("apb=%p nmaxbytes=%d arg=%p timeout=%d\n",
+ apb, apb->nmaxbytes, arg, timeout);
+
+ i2s_init_buffer(apb->samp, apb->nmaxbytes);
+
+#ifdef I2S_HAVE_RX
+ /* Allocate a buffer container in advance */
+
+ bfcontainer = i2s_buf_allocate(priv);
+ DEBUGASSERT(bfcontainer);
+
+ /* Get exclusive access to the I2S driver data */
+
+ i2s_exclsem_take(priv);
+
+ /* Has the RX channel been enabled? */
+
+ if (!priv->rxenab)
+ {
+ i2serr("ERROR: I2S%d has no receiver\n", priv->i2sno);
+ ret = -EAGAIN;
+ goto errout_with_exclsem;
+ }
+
+ /* 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 RX pending queue */
+
+ flags = enter_critical_section();
+ sq_addlast((sq_entry_t *)bfcontainer, &priv->rx.pend);
+
+ /* Then start the next transfer. If there is already a transfer in progess,
+ * then this will do nothing.
+ */
+
+ ret = i2s_rxdma_setup(priv);
+ DEBUGASSERT(ret == OK);
+ leave_critical_section(flags);
+ i2s_exclsem_give(priv);
+ return OK;
+
+errout_with_exclsem:
+ i2s_exclsem_give(priv);
+ i2s_buf_free(priv, bfcontainer);
+ return ret;
+
+#else
+ i2serr("ERROR: I2S%d has no receiver\n", priv->i2sno);
+ UNUSED(priv);
+ return -ENOSYS;
+#endif
+}
+
+static int roundf(float num)
+{
+ if(((int)(num + 0.5f)) > num)
+ {
+ return num + 1;
+ }
+
+ return num;
+}
+
+/****************************************************************************
+ * Name: stm32_i2s_txsamplerate
+ *
+ * Description:
+ * Set the I2S TX sample rate. NOTE: This will have no effect if (1) the
+ * driver does not support an I2C transmitter or if (2) the sample rate is
+ * driven by the I2C frame clock. This may also have unexpected side-
+ * effects of the TX sample is coupled with the RX 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 stm32_i2s_txsamplerate(struct i2s_dev_s *dev, uint32_t rate)
+{
+#if defined(I2S_HAVE_TX) && defined(I2S_HAVE_MCK)
+ struct stm32_i2s_s *priv = (struct stm32_i2s_s *)dev;
+
+ DEBUGASSERT(priv && priv->samplerate > 0 && rate > 0);
+
+ /* Check if the receiver is driven by the MCK/2 */
+
+ if (priv->samplerate != rate)
+ {
+ /* Save the new sample rate and update the MCK/2 divider */
+
+ priv->samplerate = rate;
+ return i2s_mckdivider(priv);
+ }
+#endif
+
+ return 0;
+}
+
+/****************************************************************************
+ * Name: stm32_i2s_txdatawidth
+ *
+ * Description:
+ * Set the I2S TX data width. The TX 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 stm32_i2s_txdatawidth(struct i2s_dev_s *dev, int bits)
+{
+#ifdef I2S_HAVE_TX
+ struct stm32_i2s_s *priv = (struct stm32_i2s_s *)dev;
+ int ret;
+
+ i2sinfo("Data width bits of tx = %d\n",bits);
+ DEBUGASSERT(priv && bits > 1);
+
+ /* Check if this is a bit width that we are configured to handle */
+
+ ret = i2s_checkwidth(priv, bits);
+ if (ret < 0)
+ {
+ i2serr("ERROR: i2s_checkwidth failed: %d\n", ret);
+ return 0;
+ }
+
+ /* Upate the DMA flags */
+
+ ret = i2s_dma_flags(priv);
+ if (ret < 0)
+ {
+ i2serr("ERROR: i2s_dma_flags failed: %d\n", ret);
+ return 0;
+ }
+#endif
+
+ return 0;
+}
+
+/****************************************************************************
+ * Name: stm32_i2s_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 stm32_i2s_send(struct i2s_dev_s *dev, struct ap_buffer_s *apb,
+ i2s_callback_t callback, void *arg, uint32_t timeout)
+{
+ struct stm32_i2s_s *priv = (struct stm32_i2s_s *)dev;
+#ifdef I2S_HAVE_TX
+ struct stm32_buffer_s *bfcontainer;
+ irqstate_t flags;
+ int ret;
+#endif
+
+ /* Make sure that we have valid pointers that that the data has uint32_t
+ * alignment.
+ */
+
+ DEBUGASSERT(priv && apb);
+ i2sinfo("apb=%p nbytes=%d arg=%p timeout=%d\n",
+ apb, apb->nbytes - apb->curbyte, arg, timeout);
+
+ i2s_dump_buffer("Sending", &apb->samp[apb->curbyte],
+ apb->nbytes - apb->curbyte);
+ DEBUGASSERT(((uintptr_t)&apb->samp[apb->curbyte] & priv->align) == 0);
+
+#ifdef I2S_HAVE_TX
+ /* Allocate a buffer container in advance */
+
+ bfcontainer = i2s_buf_allocate(priv);
+ DEBUGASSERT(bfcontainer);
+
+ /* Get exclusive access to the I2S driver data */
+
+ i2s_exclsem_take(priv);
+
+ /* Has the TX channel been enabled? */
+
+ if (!priv->txenab)
+ {
+ i2serr("ERROR: I2S%d has no transmitter\n", priv->i2sno);
+ ret = -EAGAIN;
+ goto errout_with_exclsem;
+ }
+
+ /* 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 TX pending queue */
+
+ flags = enter_critical_section();
+ sq_addlast((sq_entry_t *)bfcontainer, &priv->tx.pend);
+
+ /* Then start the next transfer. If there is already a transfer in progess,
+ * then this will do nothing.
+ */
+
+ ret = i2s_txdma_setup(priv);
+ DEBUGASSERT(ret == OK);
+ leave_critical_section(flags);
+ i2s_exclsem_give(priv);
+ return OK;
+
+errout_with_exclsem:
+ i2s_exclsem_give(priv);
+ i2s_buf_free(priv, bfcontainer);
+ return ret;
+
+#else
+ i2serr("ERROR: I2S%d has no transmitter\n", priv->i2sno);
+ UNUSED(priv);
+ return -ENOSYS;
+#endif
+}
+
+/****************************************************************************
+ * Name: i2s_mckdivider
+ *
+ * Description:
+ * Setup the MCK divider based on the currently selected data width and
+ * the sample rate
+ *
+ * Input Parameter:
+ * priv - I2C device structure (only the sample rate and data length is
+ * needed at this point).
+ *
+ * Returned Value:
+ * The current bitrate
+ *
+ ****************************************************************************/
+
+static uint32_t i2s_mckdivider(struct stm32_i2s_s *priv)
+{
+#ifdef I2S_HAVE_MCK
+ uint32_t bitrate;
+ uint32_t regval;
+
+ uint16_t pllr = 5, plln = 256, div = 12, odd = 1;
+
+ DEBUGASSERT(priv && priv->samplerate > 0 && priv->datalen > 0);
+
+ /* A zero sample rate means to disable the MCK/2 clock */
+
+ if (priv->samplerate == 0)
+ {
+ bitrate = 0;
+ regval = 0;
+ }
+ else
+ {
+ int R, n, Od;
+ int Napprox;
+ int diff;
+ int diff_min = 500000000;
+
+ for (Od = 0; Od <= 1; ++Od)
+ {
+ for (R = 2; R <= 7; ++R)
+ {
+ for (n = 2; n <= 256; ++n)
+ {
+ Napprox = roundf(priv->samplerate / 1000000.0f * (8 * 32 * R * (2 * n + Od)));
+ if ((Napprox > 432) || (Napprox < 50))
+ {
+ continue;
+ }
+
+ diff = abs(priv->samplerate - 1000000 * Napprox / (8 * 32 * R * (2 * n + Od)));
+ if (diff_min > diff)
+ {
+ diff_min = diff;
+ plln = Napprox;
+ pllr = R;
+ div = n;
+ odd = Od;
+ }
+ }
+ }
+ }
+
+ /* Calculate the new bitrate in Hz */
+
+ bitrate = priv->samplerate * priv->datalen;
+ }
+
+ /* Configure MCK divider */
+
+ /* Disable I2S */
+
+ i2s_putreg(priv, STM32_SPI_I2SCFGR_OFFSET, 0);
+
+ /* I2S clock configuration */
+
+ putreg32((getreg32(STM32_RCC_CR) & (~RCC_CR_PLLI2SON)), STM32_RCC_CR);
+
+ /* PLLI2S clock used as I2S clock source */
+
+ putreg32(((getreg32(STM32_RCC_CFGR)) & (~RCC_CFGR_I2SSRC)), STM32_RCC_CFGR);
+ regval = (pllr << 28) | (plln << 6);
+ putreg32(regval, STM32_RCC_PLLI2SCFGR);
+
+ /* Enable PLLI2S and wait until it is ready */
+
+ putreg32((getreg32(STM32_RCC_CR) | RCC_CR_PLLI2SON), STM32_RCC_CR);
+ while (!(getreg32(STM32_RCC_CR) & RCC_CR_PLLI2SRDY));
+
+ i2s_putreg(priv, STM32_SPI_I2SPR_OFFSET,
+ div | (odd << 8) | SPI_I2SPR_MCKOE);
+ i2s_putreg(priv, STM32_SPI_I2SCFGR_OFFSET,
+ SPI_I2SCFGR_I2SMOD | SPI_I2SCFGR_I2SCFG_MTX | SPI_I2SCFGR_I2SE);
+
+ putreg32(((getreg32(STM32_DMA1_HIFCR)) | 0x80000000 /* DMA_HIFCR_CTCIF7 */),
+ STM32_DMA1_HIFCR);
+
+ return bitrate;
+#else
+ return 0;
+#endif
+}
+
+/****************************************************************************
+ * Name: i2s_dma_flags
+ *
+ * Description:
+ * Determine DMA FLAGS based on PID and data width
+ *
+ * Input Parameters:
+ * priv - Partially initialized I2C device structure.
+ *
+ * Returned Value:
+ * OK on success; a negated errno value on failure
+ *
+ ****************************************************************************/
+
+static int i2s_dma_flags(struct stm32_i2s_s *priv)
+{
+ switch (priv->datalen)
+ {
+ case 8:
+ /* Reconfigure the RX DMA (and TX DMA if applicable) */
+ priv->rxccr = SPI_RXDMA8_CONFIG;
+ priv->txccr = SPI_TXDMA8_CONFIG;
+ break;
+
+ case 16:
+ priv->rxccr = SPI_RXDMA16_CONFIG;
+ priv->txccr = SPI_TXDMA16_CONFIG;
+ break;
+
+ default:
+ i2serr("ERROR: Unsupported data width: %d\n", priv->datalen);
+ return -ENOSYS;
+ }
+
+ return OK;
+}
+
+/****************************************************************************
+ * Name: i2s_dma_allocate
+ *
+ * Description:
+ * Allocate I2S DMA channels
+ *
+ * Input Parameters:
+ * priv - Partially initialized I2S device structure. This function
+ * will complete the DMA specific portions of the initialization
+ *
+ * Returned Value:
+ * OK on success; A negated errno value on failure.
+ *
+ ****************************************************************************/
+
+static int i2s_dma_allocate(struct stm32_i2s_s *priv)
+{
+ int ret;
+
+ /* Get the DMA flags for this channel */
+
+ ret = i2s_dma_flags(priv);
+ if (ret < 0)
+ {
+ i2serr("ERROR: i2s_dma_flags failed: %d\n", ret);
+ return ret;
+ }
+
+ /* Allocate DMA channels. These allocations exploit that fact that
+ * I2S2 is managed by DMA1 and I2S3 is managed by DMA2. Hence,
+ * the I2S number (i2sno) is the same as the DMA number.
+ */
+
+#ifdef I2S_HAVE_RX
+ if (priv->rxenab)
+ {
+ /* Allocate an RX DMA channel */
+
+ priv->rx.dma = stm32_dmachannel(DMAMAP_SPI3_RX_2);
+ if (!priv->rx.dma)
+ {
+ i2serr("ERROR: Failed to allocate the RX DMA channel\n");
+ goto errout;
+ }
+
+ /* Create a watchdog time to catch RX DMA timeouts */
+
+ priv->rx.dog = wd_create();
+ if (!priv->rx.dog)
+ {
+ i2serr("ERROR: Failed to create the RX DMA watchdog\n");
+ goto errout;
+ }
+ }
+#endif
+
+#ifdef I2S_HAVE_TX
+ if (priv->txenab)
+ {
+ /* Allocate a TX DMA channel */
+
+ priv->tx.dma = stm32_dmachannel(DMAMAP_SPI3_TX_2);
+ if (!priv->tx.dma)
+ {
+ i2serr("ERROR: Failed to allocate the TX DMA channel\n");
+ goto errout;
+ }
+
+ /* Create a watchdog time to catch TX DMA timeouts */
+
+ priv->tx.dog = wd_create();
+ if (!priv->tx.dog)
+ {
+ i2serr("ERROR: Failed to create the TX DMA watchdog\n");
+ goto errout;
+ }
+ }
+#endif
+
+ /* Success exit */
+
+ return OK;
+
+ /* Error exit */
+
+errout:
+ i2s_dma_free(priv);
+ return -ENOMEM;
+}
+
+/****************************************************************************
+ * Name: i2s_dma_free
+ *
+ * Description:
+ * Release DMA-related resources allocated by i2s_dma_allocate()
+ *
+ * Input Parameters:
+ * priv - Partially initialized I2C device structure.
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+static void i2s_dma_free(struct stm32_i2s_s *priv)
+{
+#ifdef I2S_HAVE_TX
+ if (priv->tx.dog)
+ {
+ wd_delete(priv->tx.dog);
+ }
+
+ if (priv->tx.dma)
+ {
+ stm32_dmafree(priv->tx.dma);
+ }
+#endif
+
+#ifdef I2S_HAVE_RX
+ if (priv->rx.dog)
+ {
+ wd_delete(priv->rx.dog);
+ }
+
+ if (priv->rx.dma)
+ {
+ stm32_dmafree(priv->rx.dma);
+ }
+#endif
+}
+
+/****************************************************************************
+ * Name: i2s2_configure
+ *
+ * Description:
+ * Configure I2S2
+ *
+ * Input Parameters:
+ * priv - Partially initialized I2C device structure. These functions
+ * will complete the I2S specific portions of the initialization
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_STM32_I2S2
+static void i2s2_configure(struct stm32_i2s_s *priv)
+{
+ /* Configure multiplexed pins as connected on the board. Chip
+ * select pins must be selected by board-specific logic.
+ */
+
+ priv->base = STM32_I2S2_BASE;
+
+#ifdef CONFIG_STM32_I2S2_RX
+ priv->rxenab = true;
+
+ if ((i2s_getreg(priv, STM32_SPI_CR1_OFFSET) & SPI_CR1_SPE) == 0)
+ {
+ /* Configure I2S2 pins: MCK, SD, CK, WS */
+
+ stm32_configgpio(GPIO_I2S2_MCK);
+ stm32_configgpio(GPIO_I2S2_SD);
+ stm32_configgpio(GPIO_I2S2_CK);
+ stm32_configgpio(GPIO_I2S2_WS);
+ }
+#endif /* CONFIG_STM32_I2S2_RX */
+
+#ifdef CONFIG_STM32_I2S2_TX
+ priv->txenab = true;
+
+ /* Only configure if the port is not already configured */
+
+ if ((i2s_getreg(priv, STM32_SPI_CR1_OFFSET) & SPI_CR1_SPE) == 0)
+ {
+ /* Configure I2S2 pins: MCK, SD, CK, WS */
+
+ stm32_configgpio(GPIO_I2S2_MCK);
+ stm32_configgpio(GPIO_I2S2_SD);
+ stm32_configgpio(GPIO_I2S2_CK);
+ stm32_configgpio(GPIO_I2S2_WS);
+ }
+#endif /* CONFIG_STM32_I2S2_TX */
+
+ /* Configure driver state specific to this I2S peripheral */
+
+ priv->datalen = CONFIG_STM32_I2S2_DATALEN;
+#ifdef CONFIG_DEBUG
+ priv->align = STM32_I2S2_DATAMASK;
+#endif
+}
+#endif /* CONFIG_STM32_I2S2 */
+
+/****************************************************************************
+ * Name: i2s3_configure
+ *
+ * Description:
+ * Configure I2S3
+ *
+ * Input Parameters:
+ * priv - Partially initialized I2C device structure. These functions
+ * will complete the I2S specific portions of the initialization
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_STM32_I2S3
+static void i2s3_configure(struct stm32_i2s_s *priv)
+{
+ /* Configure multiplexed pins as connected on the board. Chip
+ * select pins must be selected by board-specific logic.
+ */
+
+ priv->base = STM32_I2S3_BASE;
+
+#ifdef CONFIG_STM32_I2S3_RX
+ priv->rxenab = true;
+
+ if ((i2s_getreg(priv, STM32_SPI_CR1_OFFSET) & SPI_CR1_SPE) == 0)
+ {
+ /* Configure I2S3 pins: MCK, SD, CK, WS */
+
+ stm32_configgpio(GPIO_I2S3_MCK);
+ stm32_configgpio(GPIO_I2S3_SD);
+ stm32_configgpio(GPIO_I2S3_CK);
+ stm32_configgpio(GPIO_I2S3_WS);
+ }
+#endif /* CONFIG_STM32_I2S3_RX */
+
+#ifdef CONFIG_STM32_I2S3_TX
+ priv->txenab = true;
+
+ /* Only configure if the port is not already configured */
+
+ if ((i2s_getreg(priv, STM32_SPI_CR1_OFFSET) & SPI_CR1_SPE) == 0)
+ {
+ /* Configure I2S3 pins: MCK, SD, CK, WS */
+
+ stm32_configgpio(GPIO_I2S3_MCK);
+ stm32_configgpio(GPIO_I2S3_SD);
+ stm32_configgpio(GPIO_I2S3_CK);
+ stm32_configgpio(GPIO_I2S3_WS);
+ }
+#endif /* CONFIG_STM32_I2S3_TX */
+
+ /* Configure driver state specific to this I2S peripheral */
+
+ priv->datalen = CONFIG_STM32_I2S3_DATALEN;
+#ifdef CONFIG_DEBUG
+ priv->align = STM32_I2S3_DATAMASK;
+#endif
+}
+#endif /* CONFIG_STM32_I2S3 */
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/************************************************************************************
+ * Name: stm32_i2sdev_initialize
+ *
+ * Description:
+ * Initialize the selected i2S port
+ *
+ * Input Parameter:
+ * Port number (for hardware that has mutiple I2S interfaces)
+ *
+ * Returned Value:
+ * Valid I2S device structure reference on succcess; a NULL on failure
+ *
+ ************************************************************************************/
+
+FAR struct i2s_dev_s *stm32_i2sdev_initialize(int port)
+{
+ FAR struct stm32_i2s_s *priv = NULL;
+ irqstate_t flags;
+ int ret;
+
+ /* The support STM32 parts have only a single I2S port */
+
+ i2sinfo("port: %d\n", port);
+
+ /* Allocate a new state structure for this chip select. NOTE that there
+ * is no protection if the same chip select is used in two different
+ * chip select structures.
+ */
+
+ priv = (struct stm32_i2s_s *)zalloc(sizeof(struct stm32_i2s_s));
+ if (!priv)
+ {
+ i2serr("ERROR: Failed to allocate a chip select structure\n");
+ return NULL;
+ }
+
+ /* Set up the initial state for this chip select structure. Other fields
+ * were zeroed by zalloc().
+ */
+
+ /* Initialize the common parts for the I2S device structure */
+
+ sem_init(&priv->exclsem, 0, 1);
+ priv->dev.ops = &g_i2sops;
+ priv->i2sno = port;
+
+ /* Initialize buffering */
+
+ i2s_buf_initialize(priv);
+
+ flags = enter_critical_section();
+
+#ifdef CONFIG_STM32_I2S2
+ if (port == 2)
+ {
+ /* Select I2S2 */
+
+ i2s2_configure(priv);
+ }
+ else
+#endif
+#ifdef CONFIG_STM32_I2S3
+ if (port == 3)
+ {
+ /* Select I2S3 */
+
+ i2s3_configure(priv);
+ }
+ else
+#endif
+ {
+ i2serr("ERROR: Unsupported I2S port: %d\n", port);
+ return NULL;
+ }
+
+ /* Allocate DMA channels */
+
+ ret = i2s_dma_allocate(priv);
+ if (ret < 0)
+ {
+ goto errout_with_alloc;
+ }
+
+ leave_critical_section(flags);
+ i2s_dump_regs(priv, "After initialization");
+
+ /* Success exit */
+
+ return &priv->dev;
+
+ /* Failure exits */
+
+errout_with_alloc:
+ sem_destroy(&priv->exclsem);
+ kmm_free(priv);
+ return NULL;
+}
+#endif /* I2S_HAVE_RX || I2S_HAVE_TX */
+
+#endif /* CONFIG_STM32_I2S2 || CONFIG_STM32_I2S3 */
diff --git a/arch/arm/src/stm32/stm32_i2s.h b/arch/arm/src/stm32/stm32_i2s.h
new file mode 100644
index 0000000000000000000000000000000000000000..5e6d51b817f27a51b50c628663b149d6d56cb420
--- /dev/null
+++ b/arch/arm/src/stm32/stm32_i2s.h
@@ -0,0 +1,90 @@
+/************************************************************************************
+ * arch/arm/src/stm32/stm32_i2s.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_STM32_I2S_H
+#define __ARCH_ARM_SRC_STM32_I2S_H
+
+/************************************************************************************
+ * Included Files
+ ************************************************************************************/
+
+#include
+#include
+
+#include "chip.h"
+#include "chip/stm32_i2s.h"
+
+#ifndef __ASSEMBLY__
+
+/************************************************************************************
+ * Public Data
+ ************************************************************************************/
+
+#undef EXTERN
+#if defined(__cplusplus)
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+/************************************************************************************
+ * Public Function Prototypes
+ ************************************************************************************/
+
+/************************************************************************************
+ * Name: stm32_i2sdev_initialize
+ *
+ * Description:
+ * Initialize the selected I2S port
+ *
+ * Input Parameter:
+ * Port number (for hardware that has mutiple I2S interfaces)
+ *
+ * Returned Value:
+ * Valid I2S device structure reference on succcess; a NULL on failure
+ *
+ ************************************************************************************/
+
+FAR struct i2s_dev_s *stm32_i2sdev_initialize(int port);
+
+#undef EXTERN
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* __ASSEMBLY__ */
+#endif /* __ARCH_ARM_SRC_STM32_I2S_H */
diff --git a/arch/arm/src/stm32/stm32_irq.c b/arch/arm/src/stm32/stm32_irq.c
index 051c9829794730b96495714c5f918c994dfdd80e..2a51836a52a390f773ed650ea2c9baa97b38eb01 100644
--- a/arch/arm/src/stm32/stm32_irq.c
+++ b/arch/arm/src/stm32/stm32_irq.c
@@ -310,16 +310,6 @@ void up_irqinitialize(void)
putreg32(0xffffffff, NVIC_IRQ_CLEAR(i));
}
- /* Colorize the interrupt stack for debug purposes */
-
-#if defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 3
- {
- size_t intstack_size = (CONFIG_ARCH_INTERRUPTSTACK & ~3);
- up_stack_color((FAR void *)((uintptr_t)&g_intstackbase - intstack_size),
- intstack_size);
- }
-#endif
-
/* The standard location for the vector table is at the beginning of FLASH
* at address 0x0800:0000. If we are using the STMicro DFU bootloader, then
* the vector table will be offset to a different location in FLASH and we
diff --git a/arch/arm/src/stm32/stm32_iwdg.c b/arch/arm/src/stm32/stm32_iwdg.c
index 1cdf8e47bc07fc5fd68c88ae9b2917e57c6e0267..7b114fefa59084ae61c84e51ffcbaac8eb90b795 100644
--- a/arch/arm/src/stm32/stm32_iwdg.c
+++ b/arch/arm/src/stm32/stm32_iwdg.c
@@ -271,10 +271,6 @@ static void stm32_putreg(uint16_t val, uint32_t addr)
* Input Parameters:
* priv - A pointer the internal representation of the "lower-half"
* driver state structure.
- * timeout - The new timeout value in milliseconds.
- *
- * Returned Values:
- * Zero on success; a negated errno value on failure.
*
****************************************************************************/
@@ -634,8 +630,8 @@ static int stm32_settimeout(FAR struct watchdog_lowerhalf_s *lower,
* Name: stm32_iwdginitialize
*
* Description:
- * Initialize the IWDG watchdog time. The watchdog timer is initialized and
- * registers as 'devpath. The initial state of the watchdog time is
+ * Initialize the IWDG watchdog timer. The watchdog timer is initialized and
+ * registers as 'devpath'. The initial state of the watchdog timer is
* disabled.
*
* Input Parameters:
@@ -665,7 +661,7 @@ void stm32_iwdginitialize(FAR const char *devpath, uint32_t lsifreq)
priv->started = false;
/* Make sure that the LSI oscillator is enabled. NOTE: The LSI oscillator
- * is enabled here but is not disabled by this file (because this file does
+ * is enabled here but is not disabled by this file, because this file does
* not know the global usage of the oscillator. Any clock management
* logic (say, as part of a power management scheme) needs handle other
* LSI controls outside of this file.
@@ -685,9 +681,9 @@ void stm32_iwdginitialize(FAR const char *devpath, uint32_t lsifreq)
(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 IWDG counter either continues to work normally or stops, depending
- * on DBG_WIDG_STOP configuration bit in DBG module.
+ * on DBG_IWDG_STOP configuration bit in DBG module.
*/
#if defined(CONFIG_STM32_JTAG_FULL_ENABLE) || \
@@ -695,7 +691,7 @@ void stm32_iwdginitialize(FAR const char *devpath, uint32_t lsifreq)
defined(CONFIG_STM32_JTAG_SW_ENABLE)
{
#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F30XX) || \
- defined(CONFIG_STM32_STM32F40XX)
+ defined(CONFIG_STM32_STM32F40XX) || defined(CONFIG_STM32_STM32L15XX)
uint32_t cr = getreg32(STM32_DBGMCU_APB1_FZ);
cr |= DBGMCU_APB1_IWDGSTOP;
putreg32(cr, STM32_DBGMCU_APB1_FZ);
diff --git a/arch/arm/src/stm32/stm32_ltdc.c b/arch/arm/src/stm32/stm32_ltdc.c
index 2573730172c3902b17a23815eaea7512f119d8bb..22b650c598b1f624840a7479fee6edbc66786d6e 100644
--- a/arch/arm/src/stm32/stm32_ltdc.c
+++ b/arch/arm/src/stm32/stm32_ltdc.c
@@ -3014,7 +3014,7 @@ static int stm32_getblendmode(FAR struct ltdc_layer_s *layer, uint32_t *mode)
* On error - -EINVAL
*
* Procedure Information:
- * If the srcxpos and srcypos unequal the the xpos and ypos of the area
+ * If the srcxpos and srcypos unequal the xpos and ypos of the area
* structure this acts like moving the visible area to another position on
* the screen during the next update operation.
*
diff --git a/arch/arm/src/stm32/stm32_oneshot.c b/arch/arm/src/stm32/stm32_oneshot.c
index ab8d2a4034802e7437896fa1f8cf7017dd344193..ba76bf65b9dba5a1075f63f26b88380dc0f3ef54 100644
--- a/arch/arm/src/stm32/stm32_oneshot.c
+++ b/arch/arm/src/stm32/stm32_oneshot.c
@@ -393,7 +393,7 @@ int stm32_oneshot_cancel(struct stm32_oneshot_s *oneshot,
* If the counter expires while we are doing this, the counter clock will
* be stopped, but the clock will not be disabled.
*
- * The expected behavior is that the the counter register will freezes at
+ * The expected behavior is that the counter register will freezes at
* a value equal to the RC register when the timer expires. The counter
* should have values between 0 and RC in all other cased.
*
diff --git a/arch/arm/src/stm32/stm32_opamp.c b/arch/arm/src/stm32/stm32_opamp.c
new file mode 100644
index 0000000000000000000000000000000000000000..e79e8ed8068845ea906423062e4e591446921173
--- /dev/null
+++ b/arch/arm/src/stm32/stm32_opamp.c
@@ -0,0 +1,1418 @@
+/****************************************************************************
+ * arch/arm/src/stm32/stm32_opamp.c
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include
+
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+
+#include "chip.h"
+#include "stm32_gpio.h"
+#include "stm32_opamp.h"
+
+/* OPAMP "upper half" support must be enabled */
+
+#ifdef CONFIG_STM32_OPAMP
+
+/* Some OPAMP peripheral must be enabled */
+/* Up to 4 OPAMPs in STM32F3 Series */
+
+#if defined(CONFIG_STM32_OPAMP1) || defined(CONFIG_STM32_OPAMP2) || \
+ defined(CONFIG_STM32_OPAMP3) || defined(CONFIG_STM32_OPAMP4)
+
+#ifndef CONFIG_STM32_SYSCFG
+# error "SYSCFG clock enable must be set"
+#endif
+
+/* @TODO: support for STM32F30XX opamps */
+
+#if defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX)
+
+/* Currently only STM32F33XX supported */
+
+#if defined(CONFIG_STM32_STM32F30XX)
+# error "Not supported yet"
+#endif
+
+#if defined(CONFIG_STM32_STM32F33XX)
+# if defined(CONFIG_STM32_OPAMP1) || defined(CONFIG_STM32_OPAMP3) || \
+ defined(CONFIG_STM32_OPAMP4)
+# error "STM32F33 supports only OPAMP2"
+# endif
+#endif
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* OPAMPs default configuration *********************************************/
+
+#ifdef CONFIG_STM32_OPAMP1
+# ifndef OPAMP1_MODE
+# define OPAMP1_MODE OPAMP_MODE_DEFAULT
+# endif
+# ifndef OPAMP1_MUX
+# define OPAMP1_MUX OPAMP_MUX_DEFAULT
+# endif
+# ifndef OPAMP1_USERCAL
+# define OPAMP1_USERCAL OPAMP_USERCAL_DEFAULT
+# endif
+# ifndef OPAMP1_LOCK
+# define OPAMP1_LOCK OPAMP_LOCK_DEFAULT
+# endif
+# ifndef OPAMP1_GAIN
+# define OPAMP1_GAIN OPAMP_GAIN_DEFAULT
+# endif
+#endif
+#ifdef CONFIG_STM32_OPAMP2
+# ifndef OPAMP2_MODE
+# define OPAMP2_MODE OPAMP_MODE_DEFAULT
+# endif
+# ifndef OPAMP2_MUX
+# define OPAMP2_MUX OPAMP_MUX_DEFAULT
+# endif
+# ifndef OPAMP2_USERCAL
+# define OPAMP2_USERCAL OPAMP_USERCAL_DEFAULT
+# endif
+# ifndef OPAMP2_LOCK
+# define OPAMP2_LOCK OPAMP_LOCK_DEFAULT
+# endif
+# ifndef OPAMP2_GAIN
+# define OPAMP2_GAIN OPAMP_GAIN_DEFAULT
+# endif
+#endif
+#ifdef CONFIG_STM32_OPAMP3
+# ifndef OPAMP3_MODE
+# define OPAMP3_MODE OPAMP_MODE_DEFAULT
+# endif
+# ifndef OPAMP3_MUX
+# define OPAMP3_MUX OPAMP_MUX_DEFAULT
+# endif
+# ifndef OPAMP3_USERCAL
+# define OPAMP3_USERCAL OPAMP_USERCAL_DEFAULT
+# endif
+# ifndef OPAMP3_LOCK
+# define OPAMP3_LOCK OPAMP_LOCK_DEFAULT
+# endif
+# ifndef OPAMP3_GAIN
+# define OPAMP3_GAIN OPAMP_GAIN_DEFAULT
+# endif
+#endif
+#ifdef CONFIG_STM32_OPAMP4
+# ifndef OPAMP4_MODE
+# define OPAMP4_MODE OPAMP_MODE_DEFAULT
+# endif
+# ifndef OPAMP4_MUX
+# define OPAMP4_MUX OPAMP_MUX_DEFAULT
+# endif
+# ifndef OPAMP4_USERCAL
+# define OPAMP4_USERCAL OPAMP_USERCAL_DEFAULT
+# endif
+# ifndef OPAMP4_LOCK
+# define OPAMP4_LOCK OPAMP_LOCK_DEFAULT
+# endif
+# ifndef OPAMP4_GAIN
+# define OPAMP4_GAIN OPAMP_GAIN_DEFAULT
+# endif
+#endif
+
+/* Some assertions *******************************************************/
+
+/* Check OPAMPs inputs selection */
+
+#ifdef CONFIG_STM32_OPAMP1
+# if (OPAMP1_MODE == OPAMP_MODE_FOLLOWER)
+# define OPAMP1_VMSEL OPAMP1_VMSEL_FOLLOWER
+# endif
+# if (OPAMP1_MODE == OPAMP_MODE_PGA)
+# define OPAMP1_VMSEL OPAMP1_VMSEL_PGA
+# endif
+# if (OPAMP1_MODE == OPAMP_MODE_STANDALONE)
+# ifndef OPAMP1_VMSEL
+# error "OPAMP1_VMSEL must be selected in standalone mode!"
+# endif
+# endif
+# ifndef OPAMP1_VPSEL
+# error "OPAMP1_VPSEL must be slected in standalone mode!"
+# endif
+#endif
+#ifdef CONFIG_STM32_OPAMP2
+# if (OPAMP2_MODE == OPAMP_MODE_FOLLOWER)
+# define OPAMP2_VMSEL OPAMP2_VMSEL_FOLLOWER
+# endif
+# if (OPAMP2_MODE == OPAMP_MODE_PGA)
+# define OPAMP2_VMSEL OPAMP2_VMSEL_PGA
+# endif
+# if (OPAMP2_MODE == OPAMP_MODE_STANDALONE)
+# ifndef OPAMP2_VMSEL
+# error "OPAMP2_VMSEL must be selected in standalone mode!"
+# endif
+# endif
+# ifndef OPAMP2_VPSEL
+# error "OPAMP2_VPSEL must be slected in standalone mode!"
+# endif
+#endif
+#ifdef CONFIG_STM32_OPAMP3
+# if (OPAMP3_MODE == OPAMP_MODE_FOLLOWER)
+# define OPAMP3_VMSEL OPAMP3_VMSEL_FOLLOWER
+# endif
+# if (OPAMP3_MODE == OPAMP_MODE_PGA)
+# define OPAMP3_VMSEL OPAMP3_VMSEL_PGA
+# endif
+# if (OPAMP3_MODE == OPAMP_MODE_STANDALONE)
+# ifndef OPAMP3_VMSEL
+# error "OPAMP3_VMSEL must be selected in standalone mode!"
+# endif
+# endif
+# ifndef OPAMP3_VPSEL
+# error "OPAMP3_VPSEL must be slected in standalone mode!"
+# endif
+#endif
+#ifdef CONFIG_STM32_OPAMP4
+# if (OPAMP4_MODE == OPAMP_MODE_FOLLOWER)
+# define OPAMP4_VMSEL OPAMP4_VMSEL_FOLLOWER
+# endif
+# if (OPAMP4_MODE == OPAMP_MODE_PGA)
+# define OPAMP4_VMSEL OPAMP4_VMSEL_PGA
+# endif
+# if (OPAMP4_MODE == OPAMP_MODE_STANDALONE)
+# ifndef OPAMP4_VMSEL
+# error "OPAMP4_VMSEL must be selected in standalone mode!"
+# endif
+# endif
+# ifndef OPAMP4_VPSEL
+# error "OPAMP4_VPSEL must be slected in standalone mode!"
+# endif
+#endif
+
+/* When OPAMP MUX enabled, make sure that secondary selection inputs are configured */
+
+#ifdef CONFIG_STM32_OPAMP1
+# if (OPAMP1_MUX == OPAMP_MUX_ENABLE)
+# if !defined(OPAMP1_VMSSEL) || !defined(OPAMP1_VPSSEL)
+# error "OPAMP1_VMSSEL and OPAMP1_VPSSEL must be selected when OPAMP1 MUX enabled!"
+# endif
+# endif
+#endif
+#ifdef CONFIG_STM32_OPAMP2
+# if (OPAMP2_MUX == OPAMP_MUX_ENABLE)
+# if !defined(OPAMP2_VMSSEL) || !defined(OPAMP2_VPSSEL)
+# error "OPAMP2_VMSSEL and OPAMP2_VPSSEL must be selected when OPAMP2 MUX enabled!"
+# endif
+# endif
+#endif
+#ifdef CONFIG_STM32_OPAMP3
+# if (OPAMP3_MUX == OPAMP_MUX_ENABLE)
+# if !defined(OPAMP3_VMSSEL) || !defined(OPAMP3_VPSSEL)
+# error "OPAMP3_VMSSEL and OPAMP3_VPSSEL must be selected when OPAMP3 MUX enabled!"
+# endif
+# endif
+#endif
+#ifdef CONFIG_STM32_OPAMP4
+# if (OPAMP4_MUX == OPAMP_MUX_ENABLE)
+# if !defined(OPAMP4_VMSSEL) || !defined(OPAMP4_VPSSEL)
+# error "OPAMP4_VMSSEL and OPAMP4_VPSSEL must be selected when OPAMP4 MUX enabled!"
+# endif
+# endif
+#endif
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+/* This structure describes the configuration of one OPAMP device */
+
+struct stm32_opamp_s
+{
+ uint32_t csr; /* Control and status register */
+
+ uint8_t lock:1; /* OPAMP lock */
+ uint8_t mux:1; /* Timer controlled MUX mode */
+ uint8_t mode:2; /* OPAMP mode */
+ uint8_t gain:4; /* OPAMP gain in PGA mode */
+
+ uint8_t vm_sel:2; /* Inverting input selection */
+ uint8_t vp_sel:2; /* Non inverting input selection */
+ uint8_t vms_sel:2; /* Inverting input secondary selection (MUX mode) */
+ uint8_t vps_sel:2; /* Non inverting input secondary selection (Mux mode) */
+
+ uint16_t trim_n:5; /* Offset trimming value (NMOS) */
+ uint16_t trim_p:5; /* Offset trimming value (PMOS) */
+ uint16_t _reserved:6; /* reserved for calibration */
+};
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+/* OPAMP Register access */
+
+static inline void opamp_modify_csr(FAR struct stm32_opamp_s *priv,
+ uint32_t clearbits, uint32_t setbits);
+static inline uint32_t opamp_getreg_csr(FAR struct stm32_opamp_s* priv);
+static inline void opamp_putreg_csr(FAR struct stm32_opamp_s* priv,
+ uint32_t value);
+static bool stm32_opamplock_get(FAR struct stm32_opamp_s *priv);
+static int stm32_opamplock(FAR struct stm32_opamp_s *priv, bool lock);
+
+/* Initialization */
+
+static int stm32_opampconfig(FAR struct stm32_opamp_s *priv);
+static int stm32_opampenable(FAR struct stm32_opamp_s *priv, bool enable);
+static int stm32_opampgain_set(FAR struct stm32_opamp_s *priv, uint8_t gain);
+#if 0
+static int stm32_opampcalibrate(FAR struct stm32_opamp_s *priv);
+#endif
+
+/* OPAMP Driver Methods */
+
+static void opamp_shutdown(FAR struct opamp_dev_s *dev);
+static int opamp_setup(FAR struct opamp_dev_s *dev);
+static int opamp_ioctl(FAR struct opamp_dev_s *dev, int cmd, unsigned long arg);
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static const struct opamp_ops_s g_opampops =
+{
+ .ao_shutdown = opamp_shutdown,
+ .ao_setup = opamp_setup,
+ .ao_ioctl = opamp_ioctl
+};
+
+#ifdef CONFIG_STM32_OPAMP1
+static struct stm32_opamp_s g_opamp1priv =
+{
+ .csr = STM32_OPAMP1_CSR,
+ .lock = OPAMP1_LOCK,
+ .mux = OPAMP1_MUX,
+ .mode = OPAMP1_MODE,
+ .vm_sel = OPAMP1_VMSEL,
+ .vp_sel = OPAMP1_VPSEL,
+#if OPAMP1_MUX == OPAMP_MUX_ENABLE
+ .vms_sel = OPAMP1_VMSSEL,
+ .vps_sel = OPAMP1_VPSSEL,
+#endif
+ .gain = OPAMP1_GAIN
+};
+
+static struct opamp_dev_s g_opamp1dev =
+{
+ .ad_ops = &g_opampops,
+ .ad_priv = &g_opamp1priv
+};
+#endif
+
+#ifdef CONFIG_STM32_OPAMP2
+static struct stm32_opamp_s g_opamp2priv =
+{
+ .csr = STM32_OPAMP2_CSR,
+ .lock = OPAMP2_LOCK,
+ .mux = OPAMP2_MUX,
+ .mode = OPAMP2_MODE,
+ .vm_sel = OPAMP2_VMSEL,
+ .vp_sel = OPAMP2_VPSEL,
+#if OPAMP2_MUX == OPAMP_MUX_ENABLE
+ .vms_sel = OPAMP2_VMSSEL,
+ .vps_sel = OPAMP2_VPSSEL,
+#endif
+ .gain = OPAMP2_GAIN
+};
+
+static struct opamp_dev_s g_opamp2dev =
+ {
+ .ad_ops = &g_opampops,
+ .ad_priv = &g_opamp2priv
+ };
+#endif
+
+#ifdef CONFIG_STM32_OPAMP3
+static struct stm32_opamp_s g_opamp3priv =
+{
+ .csr = STM32_OPAMP3_CSR,
+ .lock = OPAMP3_LOCK,
+ .mux = OPAMP3_MUX,
+ .mode = OPAMP3_MODE,
+ .vm_sel = OPAMP3_VMSEL,
+ .vp_sel = OPAMP3_VPSEL,
+#if OPAMP3_MUX == OPAMP_MUX_ENABLE
+ .vms_sel = OPAMP3_VMSSEL,
+ .vps_sel = OPAMP3_VPSSEL,
+#endif
+ .gain = OPAMP3_GAIN
+};
+
+static struct opamp_dev_s g_opamp3dev =
+{
+ .ad_ops = &g_opampops,
+ .ad_priv = &g_opamp3priv
+};
+#endif
+
+#ifdef CONFIG_STM32_OPAMP4
+static struct stm32_opamp_s g_opamp4priv =
+{
+ .csr = STM32_OPAMP4_CSR,
+ .lock = OPAMP4_LOCK,
+ .mux = OPAMP4_MUX,
+ .mode = OPAMP4_MODE,
+ .vm_sel = OPAMP4_VMSEL,
+ .vp_sel = OPAMP4_VPSEL,
+#if OPAMP4_MUX == OPAMP_MUX_ENABLE
+ .vms_sel = OPAMP4_VMSSEL,
+ .vps_sel = OPAMP4_VPSSEL,
+#endif
+ .gain = OPAMP4_GAIN
+};
+
+static struct opamp_dev_s g_opamp4dev =
+{
+ .ad_ops = &g_opampops,
+ .ad_priv = &g_opamp4priv
+};
+#endif
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: opamp_modify_csr
+ *
+ * Description:
+ * Modify the value of a 32-bit OPAMP CSR register (not atomic).
+ *
+ * Input Parameters:
+ * priv - A reference to the OPAMP structure
+ * clrbits - The bits to clear
+ * setbits - The bits to set
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+static inline void opamp_modify_csr(FAR struct stm32_opamp_s *priv,
+ uint32_t clearbits, uint32_t setbits)
+{
+ uint32_t csr = priv->csr;
+
+ modifyreg32(csr, clearbits, setbits);
+}
+
+/****************************************************************************
+ * Name: opamp_getreg_csr
+ *
+ * Description:
+ * Read the value of an OPAMP CSR register
+ *
+ * Input Parameters:
+ * priv - A reference to the OPAMP structure
+ *
+ * Returned Value:
+ * The current contents of the OPAMP CSR register
+ *
+ ****************************************************************************/
+
+static inline uint32_t opamp_getreg_csr(FAR struct stm32_opamp_s *priv)
+{
+ uint32_t csr = priv->csr;
+
+ return getreg32(csr);
+}
+
+/****************************************************************************
+ * Name: opamp_putreg_csr
+ *
+ * Description:
+ * Write a value to an OPAMP register.
+ *
+ * Input Parameters:
+ * priv - A reference to the OPAMP structure
+ * value - The value to write to the OPAMP CSR register
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+static inline void opamp_putreg_csr(FAR struct stm32_opamp_s *priv,
+ uint32_t value)
+{
+ uint32_t csr = priv->csr;
+
+ putreg32(value, csr);
+}
+
+/****************************************************************************
+ * Name: stm32_opamp_opamplock_get
+ *
+ * Description:
+ * Get OPAMP lock bit state
+ *
+ * Input Parameters:
+ * priv - A reference to the OPAMP structure
+ *
+ * Returned Value:
+ * True if OPAMP locked, false if not locked
+ *
+ ****************************************************************************/
+
+static bool stm32_opamplock_get(FAR struct stm32_opamp_s *priv)
+{
+ uint32_t regval;
+
+ regval = opamp_getreg_csr(priv);
+
+ return (((regval & OPAMP_CSR_LOCK) == 0) ? false : true);
+}
+
+/****************************************************************************
+ * Name: stm32_opamplock
+ *
+ * Description:
+ * Lock OPAMP CSR register
+ *
+ * Input Parameters:
+ * priv - A reference to the OPAMP structure
+ * enable - lock flag
+ *
+ * Returned Value:
+ * 0 on success, a negated errno value on failure
+ *
+ ****************************************************************************/
+
+static int stm32_opamplock(FAR struct stm32_opamp_s *priv, bool lock)
+{
+ bool current;
+
+ current = stm32_opamplock_get(priv);
+
+ if (current)
+ {
+ if (lock == false)
+ {
+ aerr("ERROR: OPAMP LOCK can be cleared only by a system reset\n");
+
+ return -EPERM;
+ }
+ }
+ else
+ {
+ if (lock == true)
+ {
+ opamp_modify_csr(priv, 0, OPAMP_CSR_LOCK);
+
+ priv->lock = OPAMP_LOCK_RO;
+ }
+ }
+
+ return OK;
+}
+
+/****************************************************************************
+ * Name: stm32_opampconfig
+ *
+ * Description:
+ * Configure OPAMP and used I/Os
+ *
+ * Input Parameters:
+ * priv - A reference to the OPAMP structure
+ *
+ * Returned Value:
+ * 0 on success, a negated errno value on failure
+ *
+ ****************************************************************************/
+
+static int stm32_opampconfig(FAR struct stm32_opamp_s *priv)
+{
+ uint32_t regval = 0;
+ int index;
+
+ /* Get OPAMP index */
+
+ switch (priv->csr)
+ {
+#ifdef CONFIG_STM32_OPAMP1
+ case STM32_OPAMP1_CSR:
+ index = 1;
+ break;
+#endif
+
+#ifdef CONFIG_STM32_OPAMP2
+ case STM32_OPAMP2_CSR:
+ index = 2;
+ break;
+#endif
+
+#ifdef CONFIG_STM32_OPAMP3
+ case STM32_OPAMP3_CSR:
+ index = 3;
+ break;
+#endif
+
+#ifdef CONFIG_STM32_OPAMP4
+ case STM32_OPAMP4_CSR:
+ index = 4;
+ break;
+#endif
+
+ default:
+ return -EINVAL;
+ }
+
+ /* Configure non inverting input */
+
+ switch (index)
+ {
+#ifdef CONFIG_STM32_OPAMP1
+ case 1:
+ {
+ switch (priv->vp_sel)
+ {
+ case OPAMP1_VPSEL_PA7:
+ stm32_configgpio(GPIO_OPAMP1_VINP_1);
+ regval |= OPAMP_CSR_VPSEL_PA7;
+ break;
+
+ case OPAMP1_VPSEL_PA5:
+ stm32_configgpio(GPIO_OPAMP1_VINP_2);
+ regval |= OPAMP_CSR_VPSEL_PA5;
+ break;
+
+ case OPAMP1_VPSEL_PA3:
+ stm32_configgpio(GPIO_OPAMP1_VINP_3);
+ regval |= OPAMP_CSR_VPSEL_PA3;
+ break;
+
+ case OPAMP1_VPSEL_PA1:
+ stm32_configgpio(GPIO_OPAMP1_VINP_4);
+ regval |= OPAMP_CSR_VPSEL_PA1;
+ break;
+
+ default:
+ return -EINVAL;
+ }
+ break;
+ }
+#endif
+
+#ifdef CONFIG_STM32_OPAMP2
+ case 2:
+ {
+ switch (priv->vp_sel)
+ {
+#ifndef CONFIG_STM32_STM32F33XX
+ case OPAMP2_VPSEL_PD14:
+ stm32_configgpio(GPIO_OPAMP2_VINP_1);
+ regval |= OPAMP_CSR_VPSEL_PD14;
+ break;
+#endif
+ case OPAMP2_VPSEL_PB14:
+ stm32_configgpio(GPIO_OPAMP2_VINP_2);
+ regval |= OPAMP_CSR_VPSEL_PB14;
+ break;
+
+ case OPAMP2_VPSEL_PB0:
+ stm32_configgpio(GPIO_OPAMP2_VINP_3);
+ regval |= OPAMP_CSR_VPSEL_PB0;
+ break;
+
+ case OPAMP2_VPSEL_PA7:
+ stm32_configgpio(GPIO_OPAMP2_VINP_4);
+ regval |= OPAMP_CSR_VPSEL_PA7;
+ break;
+
+ default:
+ return -EINVAL;
+ }
+ break;
+ }
+#endif
+
+#ifdef CONFIG_STM32_OPAMP3
+ case 3:
+ {
+ switch (priv->vp_sel)
+ {
+ case OPAMP3_VPSEL_PB13:
+ stm32_configgpio(GPIO_OPAMP3_VINP_1);
+ regval |= OPAMP_CSR_VPSEL_PB13;
+ break;
+
+ case OPAMP3_VPSEL_PA5:
+ stm32_configgpio(GPIO_OPAMP3_VINP_2);
+ regval |= OPAMP_CSR_VPSEL_PA5;
+ break;
+
+ case OPAMP3_VPSEL_PA1:
+ stm32_configgpio(GPIO_OPAMP3_VINP_3);
+ regval |= OPAMP_CSR_VPSEL_PA1;
+ break;
+
+ case OPAMP3_VPSEL_PB0:
+ stm32_configgpio(GPIO_OPAMP3_VINP_4);
+ regval |= OPAMP_CSR_VPSEL_PB0;
+ break;
+
+ default:
+ return -EINVAL;
+ }
+ break;
+ }
+#endif
+
+#ifdef CONFIG_STM32_OPAMP4
+ case 4:
+ {
+ switch (priv->vp_sel)
+ {
+ case OPAMP4_VPSEL_PD11:
+ stm32_configgpio(GPIO_OPAMP4_VINP_1);
+ regval |= OPAMP_CSR_VPSEL_PD11;
+ break;
+
+ case OPAMP4_VPSEL_PB11:
+ stm32_configgpio(GPIO_OPAMP4_VINP_2);
+ regval |= OPAMP_CSR_VPSEL_PB11;
+ break;
+
+ case OPAMP4_VPSEL_PA4:
+ stm32_configgpio(GPIO_OPAMP4_VINP_3);
+ regval |= OPAMP_CSR_VPSEL_PA4;
+ break;
+
+ case OPAMP4_VPSEL_PB13:
+ stm32_configgpio(GPIO_OPAMP4_VINP_4;
+ regval |= OPAMP_CSR_VPSEL_PB13;
+ break;
+
+ default:
+ return -EINVAL;
+ }
+ break;
+ }
+#endif
+
+ default:
+ return -EINVAL;
+ }
+
+ /* Configure inverting input */
+
+ switch (index)
+ {
+#ifdef CONFIG_STM32_OPAMP1
+ case 1:
+ {
+ switch (priv->vm_sel)
+ {
+ case OPAMP1_VSEL_PC5:
+ stm32_configgpio(GPIO_OPAMP1_VINM_1);
+ regval |= OPAMP_CSR_VMSEL_PC5;
+ break;
+
+ case OPAMP1_VMSEL_PA3:
+ stm32_configgpio(GPIO_OPAMP1_VINM_2);
+ regval |= OPAMP_CSR_VMSEL_PA3;
+ break;
+
+ case OPAMP1_VMSEL_PGAMODE:
+ regval |= OPAMP_CSR_VMSEL_PGA;
+ break;
+
+ case OPAMP1_VMSEL_FOLLOWER:
+ regval |= OPAMP_CSR_VMSEL_FOLLOWER;
+ break;
+
+ default:
+ return -EINVAL;
+ }
+ break;
+ }
+#endif
+
+#ifdef CONFIG_STM32_OPAMP2
+ case 2:
+ {
+ switch (priv->vm_sel)
+ {
+ case OPAMP2_VMSEL_PC5:
+ stm32_configgpio(GPIO_OPAMP2_VINM_1);
+ regval |= OPAMP_CSR_VMSEL_PC5;
+ break;
+
+ case OPAMP2_VMSEL_PA5:
+ stm32_configgpio(GPIO_OPAMP2_VINM_2);
+ regval |= OPAMP_CSR_VMSEL_PA5;
+ break;
+
+ case OPAMP2_VMSEL_PGAMODE:
+ regval |= OPAMP_CSR_VMSEL_PGA;
+ break;
+
+ case OPAMP2_VMSEL_FOLLOWER:
+ regval |= OPAMP_CSR_VMSEL_FOLLOWER;
+ break;
+
+ default:
+ return -EINVAL;
+ }
+ break;
+ }
+#endif
+
+#ifdef CONFIG_STM32_OPAMP3
+ case 3:
+ {
+ switch (priv->vm_sel)
+ {
+ case OPAMP3_VMSEL_PB10:
+ stm32_configgpio(GPIO_OPAMP3_VINM_1);
+ regval |= OPAMP_CSR_VMSEL_PB10;
+ break;
+
+ case OPAMP3_VMSEL_PB2:
+ stm32_configgpio(GPIO_OPAMP3_VINM_2);
+ regval |= OPAMP_CSR_VMSEL_PB2;
+ break;
+
+ case OPAMP3_VMSEL_PGAMODE:
+ regval |= OPAMP_CSR_VMSEL_PGA;
+ break;
+
+ case OPAMP3_VMSEL_FOLLOWER:
+ regval |= OPAMP_CSR_VMSEL_FOLLOWER;
+ break;
+
+ default:
+ return -EINVAL;
+ }
+ break;
+ }
+#endif
+
+#ifdef CONFIG_STM32_OPAMP4
+ case 4:
+ {
+ switch (priv->vm_sel)
+ {
+ case OPAMP4_VMSEL_PB10:
+ stm32_configgpio(GPIO_OPAMP4_VINM_1);
+ regval |= OPAMP_CSR_VMSEL_PB10;
+ break;
+
+ case OPAMP4_VMSEL_PD8:
+ stm32_configgpio(GPIO_OPAMP4_VINM_2);
+ regval |= OPAMP_CSR_VMSEL_PD8;
+ break;
+
+ case OPAMP4_VMSEL_PGAMODE:
+ regval |= OPAMP_CSR_VMSEL_PGA;
+ break;
+
+ case OPAMP4_VMSEL_FOLLOWER:
+ regval |= OPAMP_CSR_VMSEL_FOLLOWER;
+ break;
+
+ default:
+ return -EINVAL;
+ }
+ break;
+ }
+#endif
+
+ default:
+ return -EINVAL;
+ }
+
+ if (priv->mux == 1)
+ {
+ /* Enable Timer controled Mux mode */
+
+ regval |= OPAMP_CSR_TCMEN;
+
+ /* Configure non inverting secondary input */
+
+ switch (index)
+ {
+#ifdef CONFIG_STM32_OPAMP1
+ case 1:
+ {
+ switch (priv->vps_sel)
+ {
+ case OPAMP1_VPSEL_PA7:
+ stm32_configgpio(GPIO_OPAMP1_VINP_1);
+ regval |= OPAMP_CSR_VPSSEL_PA7;
+ break;
+
+ case OPAMP1_VPSEL_PA5:
+ stm32_configgpio(GPIO_OPAMP1_VINP_2);
+ regval |= OPAMP_CSR_VPSSEL_PA5;
+ break;
+
+ case OPAMP1_VPSEL_PA3:
+ stm32_configgpio(GPIO_OPAMP1_VINP_3);
+ regval |= OPAMP_CSR_VPSSEL_PA3;
+ break;
+
+ case OPAMP1_VPSEL_PA1:
+ stm32_configgpio(GPIO_OPAMP1_VINP_4);
+ regval |= OPAMP_CSR_VPSSEL_PA1;
+ break;
+
+ default:
+ return -EINVAL;
+ }
+ break;
+ }
+#endif
+
+#ifdef CONFIG_STM32_OPAMP2
+ case 2:
+ {
+ switch (priv->vps_sel)
+ {
+#ifndef CONFIG_STM32_STM32F33XX
+ case OPAMP2_VPSEL_PD14:
+ stm32_configgpio(GPIO_OPAMP2_VINP_1);
+ regval |= OPAMP_CSR_VPSSEL_PD14;
+ break;
+#endif
+ case OPAMP2_VPSEL_PB14:
+ stm32_configgpio(GPIO_OPAMP2_VINP_2);
+ regval |= OPAMP_CSR_VPSSEL_PB14;
+ break;
+
+ case OPAMP2_VPSEL_PB0:
+ stm32_configgpio(GPIO_OPAMP2_VINP_3);
+ regval |= OPAMP_CSR_VPSSEL_PB0;
+ break;
+
+ case OPAMP2_VPSEL_PA7:
+ stm32_configgpio(GPIO_OPAMP2_VINP_4);
+ regval |= OPAMP_CSR_VPSSEL_PA7;
+ break;
+
+ default:
+ return -EINVAL;
+ }
+ break;
+ }
+#endif
+
+#ifdef CONFIG_STM32_OPAMP3
+ case 3:
+ {
+ switch (priv->vps_sel)
+ {
+ case OPAMP3_VPSEL_PB13:
+ stm32_configgpio(GPIO_OPAMP3_VINP_1);
+ regval |= OPAMP_CSR_VPSSEL_PB13;
+ break;
+
+ case OPAMP3_VPSEL_PA5:
+ stm32_configgpio(GPIO_OPAMP3_VINP_2);
+ regval |= OPAMP_CSR_VPSSEL_PA5;
+ break;
+
+ case OPAMP3_VPSEL_PA1:
+ stm32_configgpio(GPIO_OPAMP3_VINP_3);
+ regval |= OPAMP_CSR_VPSSEL_PA1;
+ break;
+
+ case OPAMP3_VPSEL_PB0:
+ stm32_configgpio(GPIO_OPAMP3_VINP_4);
+ regval |= OPAMP_CSR_VPSSEL_PB0;
+ break;
+
+ default:
+ return -EINVAL;
+ }
+ break;
+ }
+#endif
+
+#ifdef CONFIG_STM32_OPAMP4
+ case 4:
+ {
+ switch (priv->vps_sel)
+ {
+ case OPAMP4_VPSEL_PD11:
+ stm32_configgpio(GPIO_OPAMP4_VINP_1);
+ regval |= OPAMP_CSR_VPSSEL_PD11;
+ break;
+
+ case OPAMP4_VPSEL_PB11:
+ stm32_configgpio(GPIO_OPAMP4_VINP_2);
+ regval |= OPAMP_CSR_VPSSEL_PB11;
+ break;
+
+ case OPAMP4_VPSEL_PA4:
+ stm32_configgpio(GPIO_OPAMP4_VINP_3);
+ regval |= OPAMP_CSR_VPSSEL_PA4;
+ break;
+
+ case OPAMP4_VPSEL_PB13:
+ stm32_configgpio(GPIO_OPAMP4_VINP_4);
+ regval |= OPAMP_CSR_VPSSEL_PB13;
+ break;
+
+ default:
+ return -EINVAL;
+ }
+ break;
+ }
+#endif
+
+ default:
+ return -EINVAL;
+ }
+
+ /* Configure inverting secondary input */
+
+ switch (index)
+ {
+#ifdef CONFIG_STM32_OPAMP1
+ case 1:
+ {
+ switch (priv->vms_sel)
+ {
+ case OPAMP1_VSEL_PC5:
+ stm32_configgpio(GPIO_OPAMP1_VINM_1);
+ regval &= ~OPAMP_CSR_VMSSEL;
+ break;
+
+ case OPAMP1_VMSEL_PA3:
+ stm32_configgpio(GPIO_OPAMP1_VINM_2);
+ regval |= OPAMP_CSR_VMSSEL;
+ break;
+
+ default:
+ return -EINVAL;
+ }
+ break;
+ }
+#endif
+
+#ifdef CONFIG_STM32_OPAMP2
+ case 2:
+ {
+ switch (priv->vms_sel)
+ {
+ case OPAMP2_VMSEL_PC5:
+ stm32_configgpio(GPIO_OPAMP2_VINM_1);
+ regval &= ~OPAMP_CSR_VMSSEL;
+ break;
+
+ case OPAMP2_VMSEL_PA5:
+ stm32_configgpio(GPIO_OPAMP2_VINM_2);
+ regval |= OPAMP_CSR_VMSSEL;
+ break;
+
+ default:
+ return -EINVAL;
+ }
+ break;
+ }
+#endif
+
+#ifdef CONFIG_STM32_OPAMP3
+ case 3:
+ {
+ switch (priv->vms_sel)
+ {
+ case OPAMP3_VMSEL_PB10:
+ stm32_configgpio(GPIO_OPAMP3_VINM_1);
+ regval &= ~OPAMP_CSR_VMSSEL;
+ break;
+
+ case OPAMP3_VMSEL_PB2:
+ stm32_configgpio(GPIO_OPAMP3_VINM_2);
+ regval |= OPAMP_CSR_VMSSEL;
+ break;
+
+ default:
+ return -EINVAL;
+ }
+ break;
+ }
+#endif
+
+#ifdef CONFIG_STM32_OPAMP4
+ case 4:
+ {
+ switch (priv->vms_sel)
+ {
+ case OPAMP4_VMSEL_PB10:
+ stm32_configgpio(GPIO_OPAMP4_VINM_1);
+ regval &= ~OPAMP_CSR_VMSSEL;
+ break;
+
+ case OPAMP4_VMSEL_PD8:
+ stm32_configgpio(GPIO_OPAMP4_VINM_2);
+ regval |= OPAMP_CSR_VMSSEL;
+ break;
+
+ default:
+ return -EINVAL;
+ }
+ break;
+ }
+#endif
+
+ default:
+ return -EINVAL;
+ }
+ }
+
+ /* Save CSR register */
+
+ opamp_putreg_csr(priv, regval);
+
+ /* Configure defaul gain in PGA mode */
+
+ stm32_opampgain_set(priv, priv->gain);
+
+ /* Enable OPAMP */
+
+ stm32_opampenable(priv, true);
+
+ /* TODO: OPAMP user calibration */
+ /* stm32_opampcalibrate(priv); */
+
+
+ /* Lock OPAMP if needed */
+
+ if (priv->lock == OPAMP_LOCK_RO)
+ {
+ stm32_opamplock(priv, true);
+ }
+
+ return OK;
+}
+
+/****************************************************************************
+ * Name: stm32_opampenable
+ *
+ * Description:
+ * Enable/disable OPAMP
+ *
+ * Input Parameters:
+ * priv - A reference to the OPAMP structure
+ * enable - enable/disable flag
+ *
+ * Returned Value:
+ * 0 on success, a negated errno value on failure
+ *
+ ****************************************************************************/
+
+static int stm32_opampenable(FAR struct stm32_opamp_s *priv, bool enable)
+{
+ bool lock;
+
+ ainfo("enable: %d\n", enable ? 1 : 0);
+
+ lock = stm32_opamplock_get(priv);
+
+ if (lock)
+ {
+ aerr("ERROR: OPAMP locked!\n");
+
+ return -EPERM;
+ }
+ else
+ {
+ if (enable)
+ {
+ /* Enable the OPAMP */
+
+ opamp_modify_csr(priv, 0, OPAMP_CSR_OPAMPEN);
+ }
+ else
+ {
+ /* Disable the OPAMP */
+
+ opamp_modify_csr(priv, OPAMP_CSR_OPAMPEN, 0);
+ }
+ }
+
+ return OK;
+}
+
+/****************************************************************************
+ * Name: stm32_opampgain_set
+ *
+ * Description:
+ * Set OPAMP gain
+ *
+ * Input Parameters:
+ * priv - A reference to the OPAMP structure
+ * gain - OPAMP gain
+ *
+ * Returned Value:
+ * 0 on success, a negated errno value on failure
+ *
+ ****************************************************************************/
+
+static int stm32_opampgain_set(FAR struct stm32_opamp_s *priv, uint8_t gain)
+{
+ bool lock;
+ uint32_t regval = 0;
+
+ lock = stm32_opamplock_get(priv);
+
+ if (lock)
+ {
+ aerr("ERROR: OPAMP locked!\n");
+ return -EPERM;
+ }
+
+ regval = opamp_getreg_csr(priv);
+
+ switch (gain)
+ {
+ case OPAMP_GAIN_2:
+ regval |= OPAMP_CSR_PGAGAIN_2;
+ break;
+ case OPAMP_GAIN_4:
+ regval |= OPAMP_CSR_PGAGAIN_4;
+ break;
+ case OPAMP_GAIN_8:
+ regval |= OPAMP_CSR_PGAGAIN_8;
+ break;
+ case OPAMP_GAIN_2_VM0:
+ regval |= OPAMP_CSR_PGAGAIN_2VM0;
+ break;
+ case OPAMP_GAIN_4_VM0:
+ regval |= OPAMP_CSR_PGAGAIN_4VM0;
+ break;
+ case OPAMP_GAIN_8_VM0:
+ regval |= OPAMP_CSR_PGAGAIN_8VM0;
+ break;
+ case OPAMP_GAIN_16_VM0:
+ regval |= OPAMP_CSR_PGAGAIN_16VM0;
+ break;
+ case OPAMP_GAIN_2_VM1:
+ regval |= OPAMP_CSR_PGAGAIN_2VM1;
+ break;
+ case OPAMP_GAIN_4_VM1:
+ regval |= OPAMP_CSR_PGAGAIN_4VM1;
+ break;
+ case OPAMP_GAIN_8_VM1:
+ regval |= OPAMP_CSR_PGAGAIN_8VM1;
+ break;
+ case OPAMP_GAIN_16_VM1:
+ regval |= OPAMP_CSR_PGAGAIN_16VM1;
+ break;
+ default:
+ aerr("ERROR: Unsupported OPAMP gain\n");
+ return -EINVAL;
+ }
+
+ /* Update gain in OPAMP device structure */
+
+ priv->gain = gain;
+
+ return OK;
+
+}
+
+#if 0
+static int stm32_opampcalibrate(FAR struct stm32_opamp_s *priv)
+{
+#warning "Missing logic"
+ return OK;
+}
+#endif
+
+/****************************************************************************
+ * Name: opamp_shutdown
+ *
+ * Description:
+ * Disable the OPAMP. This method is called when the OPAMP device is closed.
+ * This method reverses the operation the setup method.
+ * Works only if OPAMP device is not locked.
+ *
+ * Input Parameters:
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+static void opamp_shutdown(FAR struct opamp_dev_s *dev)
+{
+#warning "Missing logic"
+}
+
+/****************************************************************************
+ * Name: opamp_setup
+ *
+ * Description:
+ * Configure the OPAMP. This method is called the first time that the OPAMP
+ * device is opened. This will occur when the port is first opened.
+ * This setup includes configuring and attaching OPAMP interrupts.
+ * Interrupts are all disabled upon return.
+ *
+ * Input Parameters:
+ *
+ * Returned Value:
+ *
+ ****************************************************************************/
+
+static int opamp_setup(FAR struct opamp_dev_s *dev)
+{
+#warning "Missing logic"
+ return OK;
+}
+
+/****************************************************************************
+ * Name: opamp_ioctl
+ *
+ * Description:
+ * All ioctl calls will be routed through this method.
+ *
+ * Input Parameters:
+ * dev - pointer to device structure used by the driver
+ * cmd - command
+ * arg - arguments passed with command
+ *
+ * Returned Value:
+ *
+ ****************************************************************************/
+
+static int opamp_ioctl(FAR struct opamp_dev_s* dev, int cmd, unsigned long arg)
+{
+#warning "Missing logic"
+ return -ENOTTY;
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: stm32_opampinitialize
+ *
+ * Description:
+ * Initialize the OPAMP.
+ *
+ * Input Parameters:
+ * intf - The OPAMP interface number.
+ *
+ * Returned Value:
+ * Valid OPAMP device structure reference on succcess; a NULL on failure.
+ *
+ * Assumptions:
+ * 1. Clock to the OPAMP block has enabled,
+ * 2. Board-specific logic has already configured
+ *
+ ****************************************************************************/
+
+FAR struct opamp_dev_s* stm32_opampinitialize(int intf)
+{
+ FAR struct opamp_dev_s *dev;
+ FAR struct stm32_opamp_s *opamp;
+ int ret;
+
+ switch (intf)
+ {
+#ifdef CONFIG_STM32_OPAMP1
+ case 1:
+ ainfo("OPAMP1 selected\n");
+ dev = &g_opamp1dev;
+ break;
+#endif
+
+#ifdef CONFIG_STM32_OPAMP2
+ case 2:
+ ainfo("OPAMP2 selected\n");
+ dev = &g_opamp2dev;
+ break;
+#endif
+
+#ifdef CONFIG_STM32_OPAMP3
+ case 3:
+ ainfo("OPAMP3 selected\n");
+ dev = &g_opamp3dev;
+ break;
+#endif
+
+#ifdef CONFIG_STM32_OPAMP4
+ case 4:
+ ainfo("OPAMP4 selected\n");
+ dev = &g_opamp4dev;
+ break;
+#endif
+
+ default:
+ aerr("ERROR: No OPAMP interface defined\n");
+ return NULL;
+ }
+
+ /* Configure selected OPAMP */
+
+ opamp = dev->ad_priv;
+
+ ret = stm32_opampconfig(opamp);
+ if (ret < 0)
+ {
+ aerr("ERROR: Failed to initialize OPAMP%d: %d\n", intf, ret);
+ errno = -ret;
+ return NULL;
+ }
+
+ return dev;
+}
+
+#endif /* CONFIG_STM32_STM32F30XX || CONFIG_STM32_STM32F33XX*/
+
+#endif /* CONFIG_STM32_OPAMP1 || CONFIG_STM32_OPAMP2 ||
+ * CONFIG_STM32_OPAMP3 || CONFIG_STM32_OPAMP4
+ */
+
+#endif /* CONFIG_STM32_OPAMP */
diff --git a/arch/arm/src/stm32/stm32_opamp.h b/arch/arm/src/stm32/stm32_opamp.h
new file mode 100644
index 0000000000000000000000000000000000000000..94af6990f9c7151066784c890d32455fc8bbade2
--- /dev/null
+++ b/arch/arm/src/stm32/stm32_opamp.h
@@ -0,0 +1,231 @@
+/************************************************************************************
+ * arch/arm/src/stm32/stm32_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_STM32_OPAMP_H
+#define __ARCH_ARM_SRC_STM32_STM32_OPAMP_H
+
+/************************************************************************************
+ * Included Files
+ ************************************************************************************/
+
+#include
+
+#include "chip.h"
+
+#ifdef CONFIG_STM32_OPAMP
+
+#if defined(CONFIG_STM32_STM32F30XX)
+# error "OPAMP support for STM32F30XX not implemented yet"
+#elif defined(CONFIG_STM32_STM32F33XX)
+# include "chip/stm32f33xxx_opamp.h"
+#endif
+
+#include
+
+/************************************************************************************
+ * Pre-processor definitions
+ ************************************************************************************/
+
+/* OPAMP operation mode */
+
+#define OPAMP_MODE_STANDALONE 0
+#define OPAMP_MODE_FOLLOWER 1
+#define OPAMP_MODE_PGA 2
+
+/* Timer controlled Mux mode */
+
+#define OPAMP_MUX_DISABLE 0
+#define OPAMP_MUX_ENABLE 1
+
+/* User callibration */
+
+#define OPAMP_USERCAL_DISABLE 0
+#define OPAMP_USERCAL_ENABLE 1
+
+/* Default configuration */
+
+#define OPAMP_MODE_DEFAULT OPAMP_MODE_STANDALONE /* Standalone mode */
+#define OPAMP_MUX_DEFAULT OPAMP_MUX_DISABLE /* MUX disabled */
+#define OPAMP_USERCAL_DEFAULT OPAMP_USERCAL_DISABLE /* User calibration disabled */
+#define OPAMP_GAIN_DEFAULT OPAMP_GAIN_2 /* Gain in PGA mode = 2 */
+#define OPAMP_LOCK_DEFAULT OPAMP_LOCK_RW /* Do not lock CSR register */
+
+/************************************************************************************
+ * Public Types
+ ************************************************************************************/
+
+/* CSR register lock state */
+
+enum stm32_opamp_lock_e
+{
+ OPAMP_LOCK_RW,
+ OPAMP_LOCK_RO
+};
+
+/* Gain in PGA mode */
+
+enum stm32_opamp_gain_e
+{
+ OPAMP_GAIN_2,
+ OPAMP_GAIN_4,
+ OPAMP_GAIN_8,
+ OPAMP_GAIN_2_VM0,
+ OPAMP_GAIN_4_VM0,
+ OPAMP_GAIN_8_VM0,
+ OPAMP_GAIN_16_VM0,
+ OPAMP_GAIN_2_VM1,
+ OPAMP_GAIN_4_VM1,
+ OPAMP_GAIN_8_VM1,
+ OPAMP_GAIN_16_VM1
+};
+
+/* Input selection and secondary input selection use the same GPIOs */
+
+#ifdef CONFIG_STM32_OPAMP1
+enum stm32_opamp1_vpsel_e
+{
+ OPAMP1_VPSEL_PA7,
+ OPAMP1_VPSEL_PA5,
+ OPAMP1_VPSEL_PA3,
+ OPAMP1_VPSEL_PA1
+};
+
+enum stm32_opamp1_vmsel_e
+{
+ OPAMP1_VMSEL_PC5,
+ OPAMP1_VMSEL_PA3,
+ OPAMP1_VMSEL_PGAMODE,
+ OPAMP1_VMSEL_FOLLOWER,
+};
+#endif
+
+#ifdef CONFIG_STM32_OPAMP2
+enum stm32_opamp2_vpsel_e
+{
+#ifndef CONFIG_STM32_STM32F33XX
+ /* TODO: STM32F303xB/C and STM32F358C devices only */
+ OPAMP2_VPSEL_PD14,
+#endif
+ OPAMP2_VPSEL_PB14,
+ OPAMP2_VPSEL_PB0,
+ OPAMP2_VPSEL_PA7
+};
+
+enum stm32_opamp2_vmsel_e
+{
+ OPAMP2_VMSEL_PC5,
+ OPAMP2_VMSEL_PA5,
+ OPAMP2_VMSEL_PGAMODE,
+ OPAMP2_VMSEL_FOLLOWER
+};
+#endif
+
+#ifdef CONFIG_STM32_OPAMP3
+enum stm32_opamp3_vpsel_e
+{
+ OPAMP3_VPSEL_PB13,
+ OPAMP3_VPSEL_PA5,
+ OPAMP3_VPSEL_PA1,
+ OPAMP3_VPSEL_PB0
+};
+
+enum stm32_opamp3_vmsel_e
+{
+ OPAMP3_VMSEL_PB10,
+ OPAMP3_VMSEL_PB2,
+ OPAMP3_VMSEL_PGAMODE,
+ OPAMP3_VMSEL_FOLLOWER
+};
+#endif
+
+#ifdef CONFIG_STM32_OPAMP4
+enum stm32_opamp4_vpsel_e
+{
+ OPAMP4_VPSEL_PD11,
+ OPAMP4_VPSEL_PB11,
+ OPAMP4_VPSEL_PA4,
+ OPAMP4_VPSEL_PB13
+};
+
+enum stm32_opamp4_vmsel_e
+{
+ OPAMP4_VMSEL_PB10,
+ OPAMP4_VMSEL_PD8,
+ OPAMP4_VMSEL_PGAMODE,
+ OPAMP4_VMSEL_FOLLOWER
+};
+#endif
+
+/************************************************************************************
+ * Public Function Prototypes
+ ************************************************************************************/
+
+#ifndef __ASSEMBLY__
+#ifdef __cplusplus
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+/****************************************************************************
+* Name: stm32_opampinitialize
+*
+* Description:
+* Initialize the OPAMP.
+*
+* Input Parameters:
+* intf - The OPAMP interface number.
+*
+* Returned Value:
+* Valid OPAMP device structure reference on succcess; a NULL on failure.
+*
+* Assumptions:
+* 1. Clock to the OPAMP block has enabled,
+* 2. Board-specific logic has already configured
+*
+****************************************************************************/
+
+FAR struct opamp_dev_s* stm32_opampinitialize(int intf);
+
+#undef EXTERN
+#ifdef __cplusplus
+}
+#endif
+#endif /* __ASSEMBLY__ */
+
+#endif /* CONFIG_STM32_OPAMP */
+#endif /* __ARCH_ARM_SRC_STM32_STM32_OPAMP_H */
diff --git a/arch/arm/src/stm32/stm32_otgfsdev.c b/arch/arm/src/stm32/stm32_otgfsdev.c
index 47b212c3c289c6eb87cd136c060f756662da50ba..4d23392912a22b578d9f380bdf43bd06e40190c8 100644
--- a/arch/arm/src/stm32/stm32_otgfsdev.c
+++ b/arch/arm/src/stm32/stm32_otgfsdev.c
@@ -5238,7 +5238,7 @@ static void stm32_hwinitialize(FAR struct stm32_usbdev_s *priv)
# endif
#else
- /* In the case of the the all others the meaning of the bit is No VBUS
+ /* In the case of the all others the meaning of the bit is No VBUS
* Sense when Set
*/
diff --git a/arch/arm/src/stm32/stm32_otgfshost.c b/arch/arm/src/stm32/stm32_otgfshost.c
index 7451289b27748e8603ff39f4ca9001e309b0cae6..bf3bbc8b91021ee45d11832d22a86b9a2fb99d89 100644
--- a/arch/arm/src/stm32/stm32_otgfshost.c
+++ b/arch/arm/src/stm32/stm32_otgfshost.c
@@ -212,6 +212,7 @@ struct stm32_chan_s
uint8_t eptype; /* See OTGFS_EPTYPE_* definitions */
uint8_t funcaddr; /* Device function address */
uint8_t speed; /* Device speed */
+ uint8_t interval; /* Interrupt/isochronous EP polling interval */
uint8_t pid; /* Data PID */
uint8_t npackets; /* Number of packets (for data toggle) */
bool inuse; /* True: This channel is "in use" */
@@ -1210,6 +1211,7 @@ static int stm32_ctrlchan_alloc(FAR struct stm32_usbhost_s *priv,
chan->eptype = OTGFS_EPTYPE_CTRL;
chan->funcaddr = funcaddr;
chan->speed = speed;
+ chan->interval = 0;
chan->maxpacket = STM32_EP0_DEF_PACKET_SIZE;
chan->indata1 = false;
chan->outdata1 = false;
@@ -1234,6 +1236,7 @@ static int stm32_ctrlchan_alloc(FAR struct stm32_usbhost_s *priv,
chan->eptype = OTGFS_EPTYPE_CTRL;
chan->funcaddr = funcaddr;
chan->speed = speed;
+ chan->interval = 0;
chan->maxpacket = STM32_EP0_DEF_PACKET_SIZE;
chan->indata1 = false;
chan->outdata1 = false;
@@ -1363,6 +1366,7 @@ static int stm32_xfrep_alloc(FAR struct stm32_usbhost_s *priv,
chan->eptype = epdesc->xfrtype;
chan->funcaddr = hport->funcaddr;
chan->speed = hport->speed;
+ chan->interval = epdesc->interval;
chan->maxpacket = epdesc->mxpacketsize;
chan->indata1 = false;
chan->outdata1 = false;
@@ -1893,6 +1897,8 @@ static ssize_t stm32_in_transfer(FAR struct stm32_usbhost_s *priv, int chidx,
}
else
{
+ useconds_t delay;
+
/* Get the elapsed time. Has the timeout elapsed?
* if not then try again.
*/
@@ -1907,13 +1913,64 @@ static ssize_t stm32_in_transfer(FAR struct stm32_usbhost_s *priv, int chidx,
return (ssize_t)ret;
}
- /* Wait a bit before retrying after a NAK.
+ /* Wait a bit before retrying after a NAK. */
+
+ if (chan->eptype == OTGFS_HCCHAR_EPTYP_INTR)
+ {
+ /* For interrupt (and isochronous) endpoints, the
+ * polling rate is determined by the bInterval field
+ * of the endpoint descriptor (in units of frames
+ * which we treat as milliseconds here).
+ */
+
+ if (chan->interval > 0)
+ {
+ /* Convert the delay to units of microseconds */
+
+ delay = (useconds_t)chan->interval * 1000;
+ }
+ else
+ {
+ /* Out of range! For interrupt endpoints, the valid
+ * range is 1-255 frames. Assume one frame.
+ */
+
+ delay = 1000;
+ }
+ }
+ else
+ {
+ /* For Isochronous endpoints, bInterval must be 1. Bulk
+ * endpoints do not have a polling interval. Rather,
+ * the should wait until data is received.
+ *
+ * REVISIT: For bulk endpoints this 1 msec delay is only
+ * intended to give the CPU a break from the bulk EP tight
+ * polling loop. But are there performance issues?
+ */
+
+ delay = 1000;
+ }
+
+ /* Wait for the next polling interval. For interrupt and
+ * isochronous endpoints, this is necessaryto assure the
+ * polling interval. It is used in other cases only to
+ * prevent the polling from consuming too much CPU bandwith.
+ *
+ * Small delays could require more resolution than is provided
+ * by the system timer. For example, if the system timer
+ * resolution is 10MS, then usleep(1000) will actually request
+ * a delay 20MS (due to both quantization and rounding).
*
- * REVISIT: This is intended to give the CPU a break from
- * the tight polling loop. But are there performance issues?
+ * REVISIT: So which is better? To ignore tiny delays and
+ * hog the system bandwidth? Or to wait for an excessive
+ * amount and destroy system throughput?
*/
- usleep(1000);
+ if (delay > CONFIG_USEC_PER_TICK)
+ {
+ usleep(delay - CONFIG_USEC_PER_TICK);
+ }
}
}
else
@@ -1932,7 +1989,7 @@ static ssize_t stm32_in_transfer(FAR struct stm32_usbhost_s *priv, int chidx,
{
/* Successfully received another chunk of data... add that to the
* runing total. Then continue reading until we read 'buflen'
- * bytes of data or until the the devices NAKs (implying a short
+ * bytes of data or until the devices NAKs (implying a short
* packet).
*/
@@ -2189,8 +2246,8 @@ static ssize_t stm32_out_transfer(FAR struct stm32_usbhost_s *priv, int chidx,
/* Check for a special case: If (1) the transfer was NAKed and (2)
* no Tx FIFO empty or Rx FIFO not-empty event occurred, then we
* should be able to just flush the Rx and Tx FIFOs and try again.
- * We can detect this latter case because the then the transfer
- * buffer pointer and buffer size will be unaltered.
+ * We can detect this latter case because then the transfer buffer
+ * pointer and buffer size will be unaltered.
*/
elapsed = clock_systimer() - start;
@@ -4584,7 +4641,7 @@ static ssize_t stm32_transfer(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep
* Description:
* Process a request to handle a transfer descriptor. This method will
* enqueue the transfer request and return immediately. When the transfer
- * completes, the the callback will be invoked with the provided transfer.
+ * completes, the callback will be invoked with the provided transfer.
* This method is useful for receiving interrupt transfers which may come
* infrequently.
*
diff --git a/arch/arm/src/stm32/stm32_otghsdev.c b/arch/arm/src/stm32/stm32_otghsdev.c
index 97474f2f435b6f908bb86a38a73232da9e1a2a5f..ba02546aac666d32d646025c615384076d970ab6 100644
--- a/arch/arm/src/stm32/stm32_otghsdev.c
+++ b/arch/arm/src/stm32/stm32_otghsdev.c
@@ -5319,20 +5319,22 @@ static void stm32_hwinitialize(FAR struct stm32_usbdev_s *priv)
stm32_putreg(0xbfffffff, STM32_OTGHS_GINTSTS);
+#ifndef BOARD_ENABLE_USBOTG_HSULPI
/* Disable the ULPI Clock enable in RCC AHB1 Register. This must
* be done because if both the ULPI and the FS PHY clock enable bits
* are set at the same time, the ARM never awakens from WFI due to
* some bug / errata in the chip.
*/
- regval = stm32_getreg(STM32_RCC_AHB1LPENR);
+ regval = stm32_getreg(STM32_RCC_AHB1LPENR);
regval &= ~RCC_AHB1ENR_OTGHSULPIEN;
stm32_putreg(regval, STM32_RCC_AHB1LPENR);
+#endif
/* Enable the interrupts in the INTMSK */
- regval = (OTGHS_GINT_RXFLVL | OTGHS_GINT_USBSUSP | OTGHS_GINT_ENUMDNE |
- OTGHS_GINT_IEP | OTGHS_GINT_OEP | OTGHS_GINT_USBRST);
+ regval = (OTGHS_GINT_RXFLVL | OTGHS_GINT_USBSUSP | OTGHS_GINT_ENUMDNE |
+ OTGHS_GINT_IEP | OTGHS_GINT_OEP | OTGHS_GINT_USBRST);
#ifdef CONFIG_USBDEV_ISOCHRONOUS
regval |= (OTGHS_GINT_IISOIXFR | OTGHS_GINT_IISOOXFR);
diff --git a/arch/arm/src/stm32/stm32_otghshost.c b/arch/arm/src/stm32/stm32_otghshost.c
index 85092d89a96b27c9587cb84aad32e706a21c989f..1836808764445d2988aff76afb2ca2cab661b97f 100644
--- a/arch/arm/src/stm32/stm32_otghshost.c
+++ b/arch/arm/src/stm32/stm32_otghshost.c
@@ -217,6 +217,7 @@ struct stm32_chan_s
uint8_t eptype; /* See OTGHS_EPTYPE_* definitions */
uint8_t funcaddr; /* Device function address */
uint8_t speed; /* Device speed */
+ uint8_t interval; /* Interrupt/isochronous EP polling interval */
uint8_t pid; /* Data PID */
uint8_t npackets; /* Number of packets (for data toggle) */
bool inuse; /* True: This channel is "in use" */
@@ -1215,6 +1216,7 @@ static int stm32_ctrlchan_alloc(FAR struct stm32_usbhost_s *priv,
chan->eptype = OTGHS_EPTYPE_CTRL;
chan->funcaddr = funcaddr;
chan->speed = speed;
+ chan->interval = 0;
chan->maxpacket = STM32_EP0_DEF_PACKET_SIZE;
chan->indata1 = false;
chan->outdata1 = false;
@@ -1239,6 +1241,7 @@ static int stm32_ctrlchan_alloc(FAR struct stm32_usbhost_s *priv,
chan->eptype = OTGHS_EPTYPE_CTRL;
chan->funcaddr = funcaddr;
chan->speed = speed;
+ chan->interval = 0;
chan->maxpacket = STM32_EP0_DEF_PACKET_SIZE;
chan->indata1 = false;
chan->outdata1 = false;
@@ -1368,6 +1371,7 @@ static int stm32_xfrep_alloc(FAR struct stm32_usbhost_s *priv,
chan->eptype = epdesc->xfrtype;
chan->funcaddr = hport->funcaddr;
chan->speed = hport->speed;
+ chan->interval = epdesc->interval;
chan->maxpacket = epdesc->mxpacketsize;
chan->indata1 = false;
chan->outdata1 = false;
@@ -1898,6 +1902,8 @@ static ssize_t stm32_in_transfer(FAR struct stm32_usbhost_s *priv, int chidx,
}
else
{
+ useconds_t delay;
+
/* Get the elapsed time. Has the timeout elapsed?
* if not then try again.
*/
@@ -1912,13 +1918,64 @@ static ssize_t stm32_in_transfer(FAR struct stm32_usbhost_s *priv, int chidx,
return (ssize_t)ret;
}
- /* Wait a bit before retrying after a NAK.
+ /* Wait a bit before retrying after a NAK. */
+
+ if (chan->eptype == OTGFS_HCCHAR_EPTYP_INTR)
+ {
+ /* For interrupt (and isochronous) endpoints, the
+ * polling rate is determined by the bInterval field
+ * of the endpoint descriptor (in units of frames
+ * which we treat as milliseconds here).
+ */
+
+ if (chan->interval > 0)
+ {
+ /* Convert the delay to units of microseconds */
+
+ delay = (useconds_t)chan->interval * 1000;
+ }
+ else
+ {
+ /* Out of range! For interrupt endpoints, the valid
+ * range is 1-255 frames. Assume one frame.
+ */
+
+ delay = 1000;
+ }
+ }
+ else
+ {
+ /* For Isochronous endpoints, bInterval must be 1. Bulk
+ * endpoints do not have a polling interval. Rather,
+ * the should wait until data is received.
+ *
+ * REVISIT: For bulk endpoints this 1 msec delay is only
+ * intended to give the CPU a break from the bulk EP tight
+ * polling loop. But are there performance issues?
+ */
+
+ delay = 1000;
+ }
+
+ /* Wait for the next polling interval. For interrupt and
+ * isochronous endpoints, this is necessaryto assure the
+ * polling interval. It is used in other cases only to
+ * prevent the polling from consuming too much CPU bandwith.
+ *
+ * Small delays could require more resolution than is provided
+ * by the system timer. For example, if the system timer
+ * resolution is 10MS, then usleep(1000) will actually request
+ * a delay 20MS (due to both quantization and rounding).
*
- * REVISIT: This is intended to give the CPU a break from
- * the tight polling loop. But are there performance issues?
+ * REVISIT: So which is better? To ignore tiny delays and
+ * hog the system bandwidth? Or to wait for an excessive
+ * amount and destroy system throughput?
*/
- usleep(1000);
+ if (delay > CONFIG_USEC_PER_TICK)
+ {
+ usleep(delay - CONFIG_USEC_PER_TICK);
+ }
}
}
else
@@ -1937,7 +1994,7 @@ static ssize_t stm32_in_transfer(FAR struct stm32_usbhost_s *priv, int chidx,
{
/* Successfully received another chunk of data... add that to the
* runing total. Then continue reading until we read 'buflen'
- * bytes of data or until the the devices NAKs (implying a short
+ * bytes of data or until the devices NAKs (implying a short
* packet).
*/
@@ -2194,8 +2251,8 @@ static ssize_t stm32_out_transfer(FAR struct stm32_usbhost_s *priv, int chidx,
/* Check for a special case: If (1) the transfer was NAKed and (2)
* no Tx FIFO empty or Rx FIFO not-empty event occurred, then we
* should be able to just flush the Rx and Tx FIFOs and try again.
- * We can detect this latter case because the then the transfer
- * buffer pointer and buffer size will be unaltered.
+ * We can detect this latter case because then the transfer buffer
+ * pointer and buffer size will be unaltered.
*/
elapsed = clock_systimer() - start;
@@ -4589,7 +4646,7 @@ static ssize_t stm32_transfer(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep
* Description:
* Process a request to handle a transfer descriptor. This method will
* enqueue the transfer request and return immediately. When the transfer
- * completes, the the callback will be invoked with the provided transfer.
+ * completes, the callback will be invoked with the provided transfer.
* This method is useful for receiving interrupt transfers which may come
* infrequently.
*
diff --git a/arch/arm/src/stm32/stm32_pwm.c b/arch/arm/src/stm32/stm32_pwm.c
index 85ed3554fc956e29017bc57454536ab1512c5500..8f66239a11df482075c7bfe87703a9fb3fa7968e 100644
--- a/arch/arm/src/stm32/stm32_pwm.c
+++ b/arch/arm/src/stm32/stm32_pwm.c
@@ -1301,7 +1301,7 @@ static int pwm_timer(FAR struct stm32_pwmtimer_s *priv,
timclk = priv->pclk / prescaler;
reload = timclk / info->frequency;
- if (reload < 1)
+ if (reload < 2)
{
reload = 1;
}
@@ -1309,6 +1309,10 @@ static int pwm_timer(FAR struct stm32_pwmtimer_s *priv,
{
reload = 65535;
}
+ else
+ {
+ reload--;
+ }
pwminfo("TIM%u PCLK: %u frequency: %u TIMCLK: %u prescaler: %u reload: %u\n",
priv->timid, priv->pclk, info->frequency, timclk, prescaler, reload);
diff --git a/arch/arm/src/stm32/stm32_qencoder.c b/arch/arm/src/stm32/stm32_qencoder.c
index e2245075b9142e0ca7f1815e02f4e64f73cb7f38..126ef24987c9eb384bcf22ac00c0c915de16682d 100644
--- a/arch/arm/src/stm32/stm32_qencoder.c
+++ b/arch/arm/src/stm32/stm32_qencoder.c
@@ -693,17 +693,17 @@ static int stm32_interrupt(int irq, FAR void *context, FAR void *arg)
stm32_putreg16(priv, STM32_GTIM_SR_OFFSET, regval & ~GTIM_SR_UIF);
/* Check the direction bit in the CR1 register and add or subtract the
- * maximum value, as appropriate.
+ * maximum value + 1, as appropriate.
*/
regval = stm32_getreg16(priv, STM32_GTIM_CR1_OFFSET);
if ((regval & ATIM_CR1_DIR) != 0)
{
- priv->position -= (int32_t)0x0000ffff;
+ priv->position -= (int32_t)0x00010000;
}
else
{
- priv->position += (int32_t)0x0000ffff;
+ priv->position += (int32_t)0x00010000;
}
return OK;
diff --git a/arch/arm/src/stm32/stm32_rcc.c b/arch/arm/src/stm32/stm32_rcc.c
index 3cb57ae6a0e26c91c8c368a4f23c52c9c7c47cf0..be152ff8d85825b4bc5e77d990f79d20c9af7e22 100644
--- a/arch/arm/src/stm32/stm32_rcc.c
+++ b/arch/arm/src/stm32/stm32_rcc.c
@@ -131,7 +131,7 @@ static inline void rcc_resetbkp(void)
stm32_pwr_initbkp(false);
regval = getreg32(RTC_MAGIC_REG);
- if (regval != RTC_MAGIC)
+ if (regval != RTC_MAGIC && regval != RTC_MAGIC_TIME_SET)
{
stm32_pwr_enablebkp(true);
diff --git a/arch/arm/src/stm32/stm32_rcc.h b/arch/arm/src/stm32/stm32_rcc.h
index d331ab90b6429525f38a03ca46990bc2a621588b..79949cd60ca3d16fbd0ce0688114fbd3fec379ac 100644
--- a/arch/arm/src/stm32/stm32_rcc.h
+++ b/arch/arm/src/stm32/stm32_rcc.h
@@ -33,8 +33,8 @@
*
************************************************************************************/
-#ifndef __ARCH_ARM_SRC_STM32_STM32_RRC_H
-#define __ARCH_ARM_SRC_STM32_STM32_RRC_H
+#ifndef __ARCH_ARM_SRC_STM32_STM32_RCC_H
+#define __ARCH_ARM_SRC_STM32_STM32_RCC_H
/************************************************************************************
* Included Files
@@ -299,11 +299,7 @@ void stm32_clockenable(void);
* Name: stm32_rcc_enablelse
*
* Description:
- * Enable the External Low-Speed (LSE) Oscillator and, if the RTC is
- * configured, setup the LSE as the RTC clock source, and enable the RTC.
- *
- * For the STM32L15X family, this will also select the LSE as the clock source of
- * the LCD.
+ * Enable the External Low-Speed (LSE) Oscillator.
*
* Input Parameters:
* None
@@ -340,4 +336,4 @@ void stm32_rcc_disablelsi(void);
}
#endif
#endif /* __ASSEMBLY__ */
-#endif /* __ARCH_ARM_SRC_STM32_STM32_RRC_H */
+#endif /* __ARCH_ARM_SRC_STM32_STM32_RCC_H */
diff --git a/arch/arm/src/stm32/stm32_rng.c b/arch/arm/src/stm32/stm32_rng.c
index ccbbd96dd72ce689895e499919cf0a8f9b1aca5a..6588814d6c3a3672af4f774d0670bd1e765bb00a 100644
--- a/arch/arm/src/stm32/stm32_rng.c
+++ b/arch/arm/src/stm32/stm32_rng.c
@@ -46,6 +46,7 @@
#include
#include
+#include
#include
#include
@@ -97,13 +98,20 @@ static const struct file_operations g_rngops =
#ifndef CONFIG_DISABLE_POLL
, 0 /* poll */
#endif
+#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
+ , 0 /* unlink */
+#endif
};
/****************************************************************************
* Private functions
****************************************************************************/
-static int stm32_rng_initialize()
+/****************************************************************************
+ * Name: stm32_rng_initialize
+ ****************************************************************************/
+
+static int stm32_rng_initialize(void)
{
uint32_t regval;
@@ -133,7 +141,11 @@ static int stm32_rng_initialize()
return OK;
}
-static void stm32_enable()
+/****************************************************************************
+ * Name: stm32_enable
+ ****************************************************************************/
+
+static void stm32_enable(void)
{
uint32_t regval;
@@ -144,7 +156,11 @@ static void stm32_enable()
putreg32(regval, STM32_RNG_CR);
}
-static void stm32_disable()
+/****************************************************************************
+ * Name: stm32_disable
+ ****************************************************************************/
+
+static void stm32_disable(void)
{
uint32_t regval;
regval = getreg32(STM32_RNG_CR);
@@ -152,6 +168,10 @@ static void stm32_disable()
putreg32(regval, STM32_RNG_CR);
}
+/****************************************************************************
+ * Name: stm32_interrupt
+ ****************************************************************************/
+
static int stm32_interrupt(int irq, void *context, FAR void *arg)
{
uint32_t rngsr;
@@ -234,11 +254,14 @@ static ssize_t stm32_read(struct file *filep, char *buffer, size_t buflen)
{
/* We've got the semaphore. */
- /* Initialize semaphore with 0 for blocking until the buffer is filled from
- * interrupts.
+ /* Initialize the operation semaphore with 0 for blocking until the
+ * buffer is filled from interrupts. The readsem semaphore is used
+ * for signaling and, hence, should not have priority inheritance
+ * enabled.
*/
- sem_init(&g_rngdev.rd_readsem, 0, 1);
+ sem_init(&g_rngdev.rd_readsem, 0, 0);
+ sem_setprotocol(&g_rngdev.rd_readsem, SEM_PRIO_NONE);
g_rngdev.rd_buflen = buflen;
g_rngdev.rd_buf = buffer;
diff --git a/arch/arm/src/stm32/stm32_rtc.h b/arch/arm/src/stm32/stm32_rtc.h
index 119e5e54dfce5466d294e4a30e108faf69ebae1b..d228a3c4589d3ed5b6c2db0a206ce0dbfd196d92 100644
--- a/arch/arm/src/stm32/stm32_rtc.h
+++ b/arch/arm/src/stm32/stm32_rtc.h
@@ -83,11 +83,16 @@
# define CONFIG_RTC_MAGIC (0xfacefeee)
#endif
+#if !defined(CONFIG_RTC_MAGIC_TIME_SET)
+# define CONFIG_RTC_MAGIC_TIME_SET (CONFIG_RTC_MAGIC + 1)
+#endif
+
#if !defined(CONFIG_RTC_MAGIC_REG)
# define CONFIG_RTC_MAGIC_REG (0)
#endif
#define RTC_MAGIC CONFIG_RTC_MAGIC
+#define RTC_MAGIC_TIME_SET CONFIG_RTC_MAGIC_TIME_SET
#define RTC_MAGIC_REG STM32_RTC_BKR(CONFIG_RTC_MAGIC_REG)
/****************************************************************************
diff --git a/arch/arm/src/stm32/stm32_rtc_lowerhalf.c b/arch/arm/src/stm32/stm32_rtc_lowerhalf.c
index feaa3f53951a1605cc53df3b3015bfdca6aec437..548b7fa81b06aedcbb73d827e4ea120217fabffb 100644
--- a/arch/arm/src/stm32/stm32_rtc_lowerhalf.c
+++ b/arch/arm/src/stm32/stm32_rtc_lowerhalf.c
@@ -49,6 +49,8 @@
#include
#include
+#include "up_arch.h"
+
#include "chip.h"
#include "stm32_rtc.h"
@@ -111,6 +113,7 @@ static int stm32_rdtime(FAR struct rtc_lowerhalf_s *lower,
FAR struct rtc_time *rtctime);
static int stm32_settime(FAR struct rtc_lowerhalf_s *lower,
FAR const struct rtc_time *rtctime);
+static bool stm32_havesettime(FAR struct rtc_lowerhalf_s *lower);
#ifdef CONFIG_RTC_ALARM
static int stm32_setalarm(FAR struct rtc_lowerhalf_s *lower,
@@ -130,6 +133,7 @@ static const struct rtc_ops_s g_rtc_ops =
{
.rdtime = stm32_rdtime,
.settime = stm32_settime,
+ .havesettime = stm32_havesettime,
#ifdef CONFIG_RTC_ALARM
.setalarm = stm32_setalarm,
.setrelative = stm32_setrelative,
@@ -345,6 +349,25 @@ static int stm32_settime(FAR struct rtc_lowerhalf_s *lower,
#endif
}
+/****************************************************************************
+ * Name: stm32_havesettime
+ *
+ * Description:
+ * Implements the havesettime() method of the RTC driver interface
+ *
+ * Input Parameters:
+ * lower - A reference to RTC lower half driver state structure
+ *
+ * Returned Value:
+ * Returns true if RTC date-time have been previously set.
+ *
+ ****************************************************************************/
+
+static bool stm32_havesettime(FAR struct rtc_lowerhalf_s *lower)
+{
+ return getreg32(RTC_MAGIC_REG) == RTC_MAGIC_TIME_SET;
+}
+
/****************************************************************************
* Name: stm32_setalarm
*
diff --git a/arch/arm/src/stm32/stm32_rtcc.c b/arch/arm/src/stm32/stm32_rtcc.c
index b7155854965cb572de63fc65e3209937c3253782..9adc62433c19c2ebe5c29edb2c0fe817ab8ca931 100644
--- a/arch/arm/src/stm32/stm32_rtcc.c
+++ b/arch/arm/src/stm32/stm32_rtcc.c
@@ -600,7 +600,7 @@ int up_rtc_initialize(void)
stm32_pwr_enablebkp(true);
- if (regval != RTC_MAGIC)
+ if (regval != RTC_MAGIC && regval != RTC_MAGIC_TIME_SET)
{
/* Some boards do not have the external 32khz oscillator installed, for those
* boards we must fallback to the crummy internal RC clock or the external high
@@ -712,7 +712,7 @@ int up_rtc_initialize(void)
* has been writing to to back-up date register DR0.
*/
- if (regval != RTC_MAGIC)
+ if (regval != RTC_MAGIC && regval != RTC_MAGIC_TIME_SET)
{
rtcinfo("Do setup\n");
@@ -928,6 +928,40 @@ int up_rtc_getdatetime(FAR struct tm *tp)
}
#endif
+/************************************************************************************
+ * Name: up_rtc_getdatetime_with_subseconds
+ *
+ * Description:
+ * Get the current date and time from the date/time RTC. This interface
+ * is only supported by the date/time RTC hardware implementation.
+ * It is used to replace the system timer. It is only used by the RTOS during
+ * initialization to set up the system time when CONFIG_RTC and CONFIG_RTC_DATETIME
+ * are selected (and CONFIG_RTC_HIRES is not).
+ *
+ * NOTE: This interface exposes sub-second accuracy capability of RTC hardware.
+ * This interface allow maintaining timing accuracy when system time needs constant
+ * resynchronization with RTC, for example on MCU with low-power state that
+ * stop system timer.
+ *
+ * Input Parameters:
+ * tp - The location to return the high resolution time value.
+ * nsec - The location to return the subsecond time value.
+ *
+ * Returned Value:
+ * Zero (OK) on success; a negated errno on failure
+ *
+ ************************************************************************************/
+
+#ifdef CONFIG_ARCH_HAVE_RTC_SUBSECONDS
+# ifndef CONFIG_STM32_HAVE_RTC_SUBSECONDS
+# error "Invalid config, enable CONFIG_STM32_HAVE_RTC_SUBSECONDS."
+# endif
+int up_rtc_getdatetime_with_subseconds(FAR struct tm *tp, FAR long *nsec)
+{
+ return stm32_rtc_getdatetime_with_subseconds(tp, nsec);
+}
+#endif
+
/************************************************************************************
* Name: stm32_rtc_setdatetime
*
@@ -1004,6 +1038,15 @@ int stm32_rtc_setdatetime(FAR const struct tm *tp)
ret = rtc_synchwait();
}
+ /* Remember that the RTC is initialized and had its time set. */
+
+ if (getreg32(RTC_MAGIC_REG) != RTC_MAGIC_TIME_SET)
+ {
+ stm32_pwr_enablebkp(true);
+ putreg32(RTC_MAGIC_TIME_SET, RTC_MAGIC_REG);
+ stm32_pwr_enablebkp(false);
+ }
+
/* Re-enable the write protection for RTC registers */
rtc_wprlock();
diff --git a/arch/arm/src/stm32/stm32_sdio.c b/arch/arm/src/stm32/stm32_sdio.c
index 01d533ba704c169177ddbd75b43558e18d438109..db95c008e91118f2db824bc767033bfcf4bf5ee7 100644
--- a/arch/arm/src/stm32/stm32_sdio.c
+++ b/arch/arm/src/stm32/stm32_sdio.c
@@ -300,6 +300,8 @@
# endif
#endif
+#define STM32_SDIO_USE_DEFAULT_BLOCKSIZE ((uint8_t)-1)
+
/****************************************************************************
* Private Types
****************************************************************************/
@@ -333,6 +335,12 @@ struct stm32_dev_s
size_t remaining; /* Number of bytes remaining in the transfer */
uint32_t xfrmask; /* Interrupt enables for data transfer */
+ /* Fixed transfer block size support */
+
+#ifdef CONFIG_SDIO_BLOCKSETUP
+ uint8_t block_size;
+#endif
+
/* DMA data transfer support */
bool widebus; /* Required for DMA support */
@@ -443,6 +451,10 @@ static int stm32_attach(FAR struct sdio_dev_s *dev);
static int stm32_sendcmd(FAR struct sdio_dev_s *dev, uint32_t cmd,
uint32_t arg);
+#ifdef CONFIG_SDIO_BLOCKSETUP
+static void stm32_blocksetup(FAR struct sdio_dev_s *dev,
+ unsigned int blocklen, unsigned int nblocks);
+#endif
static int stm32_recvsetup(FAR struct sdio_dev_s *dev, FAR uint8_t *buffer,
size_t nbytes);
static int stm32_sendsetup(FAR struct sdio_dev_s *dev,
@@ -456,8 +468,6 @@ static int stm32_recvlong(FAR struct sdio_dev_s *dev, uint32_t cmd,
uint32_t rlong[4]);
static int stm32_recvshort(FAR struct sdio_dev_s *dev, uint32_t cmd,
uint32_t *rshort);
-static int stm32_recvnotimpl(FAR struct sdio_dev_s *dev, uint32_t cmd,
- uint32_t *rnotimpl);
/* EVENT handler */
@@ -507,7 +517,7 @@ struct stm32_dev_s g_sdiodev =
.attach = stm32_attach,
.sendcmd = stm32_sendcmd,
#ifdef CONFIG_SDIO_BLOCKSETUP
- .blocksetup = stm32_blocksetup, /* Not implemented yet */
+ .blocksetup = stm32_blocksetup,
#endif
.recvsetup = stm32_recvsetup,
.sendsetup = stm32_sendsetup,
@@ -516,8 +526,8 @@ struct stm32_dev_s g_sdiodev =
.recvR1 = stm32_recvshortcrc,
.recvR2 = stm32_recvlong,
.recvR3 = stm32_recvshort,
- .recvR4 = stm32_recvnotimpl,
- .recvR5 = stm32_recvnotimpl,
+ .recvR4 = stm32_recvshort,
+ .recvR5 = stm32_recvshortcrc,
.recvR6 = stm32_recvshortcrc,
.recvR7 = stm32_recvshort,
.waitenable = stm32_waitenable,
@@ -1015,7 +1025,7 @@ static void stm32_dataconfig(uint32_t timeout, uint32_t dlen, uint32_t dctrl)
regval = getreg32(STM32_SDIO_DCTRL);
regval &= ~(SDIO_DCTRL_DTDIR | SDIO_DCTRL_DTMODE | SDIO_DCTRL_DBLOCKSIZE_MASK);
dctrl &= (SDIO_DCTRL_DTDIR | SDIO_DCTRL_DTMODE | SDIO_DCTRL_DBLOCKSIZE_MASK);
- regval |= (dctrl | SDIO_DCTRL_DTEN);
+ regval |= (dctrl | SDIO_DCTRL_DTEN | SDIO_DCTRL_SDIOEN);
putreg32(regval, STM32_SDIO_DCTRL);
}
@@ -1865,6 +1875,34 @@ static int stm32_sendcmd(FAR struct sdio_dev_s *dev, uint32_t cmd, uint32_t arg)
return OK;
}
+/****************************************************************************
+ * Name: stm32_blocksetup
+ *
+ * Description:
+ * Configure block size and the number of blocks for next transfer
+ *
+ * Input Parameters:
+ * dev - An instance of the SDIO device interface
+ * blocklen - The selected block size.
+ * nblocklen - The number of blocks to transfer
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_SDIO_BLOCKSETUP
+static void stm32_blocksetup(FAR struct sdio_dev_s *dev,
+ unsigned int blocklen, unsigned int nblocks)
+{
+ struct stm32_dev_s *priv = (struct stm32_dev_s *)dev;
+
+ /* Configure block size for next transfer */
+
+ priv->block_size = stm32_log2(blocklen);
+}
+#endif
+
/****************************************************************************
* Name: stm32_recvsetup
*
@@ -1911,7 +1949,17 @@ static int stm32_recvsetup(FAR struct sdio_dev_s *dev, FAR uint8_t *buffer,
/* Then set up the SDIO data path */
- dblocksize = stm32_log2(nbytes) << SDIO_DCTRL_DBLOCKSIZE_SHIFT;
+#ifdef CONFIG_SDIO_BLOCKSETUP
+ if (priv->block_size != STM32_SDIO_USE_DEFAULT_BLOCKSIZE)
+ {
+ dblocksize = priv->block_size << SDIO_DCTRL_DBLOCKSIZE_SHIFT;
+ }
+ else
+#endif
+ {
+ dblocksize = stm32_log2(nbytes) << SDIO_DCTRL_DBLOCKSIZE_SHIFT;
+ }
+
stm32_dataconfig(SDIO_DTIMER_DATATIMEOUT, nbytes, dblocksize | SDIO_DCTRL_DTDIR);
/* And enable interrupts */
@@ -1965,7 +2013,17 @@ static int stm32_sendsetup(FAR struct sdio_dev_s *dev, FAR const uint8_t *buffer
/* Then set up the SDIO data path */
- dblocksize = stm32_log2(nbytes) << SDIO_DCTRL_DBLOCKSIZE_SHIFT;
+#ifdef CONFIG_SDIO_BLOCKSETUP
+ if (priv->block_size != STM32_SDIO_USE_DEFAULT_BLOCKSIZE)
+ {
+ dblocksize = priv->block_size << SDIO_DCTRL_DBLOCKSIZE_SHIFT;
+ }
+ else
+#endif
+ {
+ dblocksize = stm32_log2(nbytes) << SDIO_DCTRL_DBLOCKSIZE_SHIFT;
+ }
+
stm32_dataconfig(SDIO_DTIMER_DATATIMEOUT, nbytes, dblocksize);
/* Enable TX interrupts */
@@ -2061,15 +2119,13 @@ static int stm32_waitresponse(FAR struct sdio_dev_s *dev, uint32_t cmd)
case MMCSD_R1_RESPONSE:
case MMCSD_R1B_RESPONSE:
case MMCSD_R2_RESPONSE:
+ case MMCSD_R4_RESPONSE:
+ case MMCSD_R5_RESPONSE:
case MMCSD_R6_RESPONSE:
events = SDIO_RESPDONE_STA;
timeout = SDIO_LONGTIMEOUT;
break;
- case MMCSD_R4_RESPONSE:
- case MMCSD_R5_RESPONSE:
- return -ENOSYS;
-
case MMCSD_R3_RESPONSE:
case MMCSD_R7_RESPONSE:
events = SDIO_RESPDONE_STA;
@@ -2161,6 +2217,7 @@ static int stm32_recvshortcrc(FAR struct sdio_dev_s *dev, uint32_t cmd, uint32_t
else if ((cmd & MMCSD_RESPONSE_MASK) != MMCSD_R1_RESPONSE &&
(cmd & MMCSD_RESPONSE_MASK) != MMCSD_R1B_RESPONSE &&
+ (cmd & MMCSD_RESPONSE_MASK) != MMCSD_R5_RESPONSE &&
(cmd & MMCSD_RESPONSE_MASK) != MMCSD_R6_RESPONSE)
{
mcerr("ERROR: Wrong response CMD=%08x\n", cmd);
@@ -2276,6 +2333,7 @@ static int stm32_recvshort(FAR struct sdio_dev_s *dev, uint32_t cmd, uint32_t *r
#ifdef CONFIG_DEBUG_MEMCARD_INFO
if ((cmd & MMCSD_RESPONSE_MASK) != MMCSD_R3_RESPONSE &&
+ (cmd & MMCSD_RESPONSE_MASK) != MMCSD_R4_RESPONSE &&
(cmd & MMCSD_RESPONSE_MASK) != MMCSD_R7_RESPONSE)
{
mcerr("ERROR: Wrong response CMD=%08x\n", cmd);
@@ -2301,15 +2359,8 @@ static int stm32_recvshort(FAR struct sdio_dev_s *dev, uint32_t cmd, uint32_t *r
{
*rshort = getreg32(STM32_SDIO_RESP1);
}
- return ret;
-}
-
-/* MMC responses not supported */
-static int stm32_recvnotimpl(FAR struct sdio_dev_s *dev, uint32_t cmd, uint32_t *rnotimpl)
-{
- putreg32(SDIO_RESPDONE_ICR | SDIO_CMDDONE_ICR, STM32_SDIO_ICR);
- return -ENOSYS;
+ return ret;
}
/****************************************************************************
@@ -2670,7 +2721,17 @@ static int stm32_dmarecvsetup(FAR struct sdio_dev_s *dev, FAR uint8_t *buffer,
/* Then set up the SDIO data path */
- dblocksize = stm32_log2(buflen) << SDIO_DCTRL_DBLOCKSIZE_SHIFT;
+#ifdef CONFIG_SDIO_BLOCKSETUP
+ if (priv->block_size != STM32_SDIO_USE_DEFAULT_BLOCKSIZE)
+ {
+ dblocksize = priv->block_size << SDIO_DCTRL_DBLOCKSIZE_SHIFT;
+ }
+ else
+#endif
+ {
+ dblocksize = stm32_log2(buflen) << SDIO_DCTRL_DBLOCKSIZE_SHIFT;
+ }
+
stm32_dataconfig(SDIO_DTIMER_DATATIMEOUT, buflen, dblocksize | SDIO_DCTRL_DTDIR);
/* Configure the RX DMA */
@@ -2739,7 +2800,17 @@ static int stm32_dmasendsetup(FAR struct sdio_dev_s *dev,
/* Then set up the SDIO data path */
- dblocksize = stm32_log2(buflen) << SDIO_DCTRL_DBLOCKSIZE_SHIFT;
+#ifdef CONFIG_SDIO_BLOCKSETUP
+ if (priv->block_size != STM32_SDIO_USE_DEFAULT_BLOCKSIZE)
+ {
+ dblocksize = priv->block_size << SDIO_DCTRL_DBLOCKSIZE_SHIFT;
+ }
+ else
+#endif
+ {
+ dblocksize = stm32_log2(buflen) << SDIO_DCTRL_DBLOCKSIZE_SHIFT;
+ }
+
stm32_dataconfig(SDIO_DTIMER_DATATIMEOUT, buflen, dblocksize);
/* Configure the TX DMA */
diff --git a/arch/arm/src/stm32/stm32_serial.c b/arch/arm/src/stm32/stm32_serial.c
index a6a2d07b51bb51b584b4b731f40c24a6e54e76d6..7aa362c38f59057705e311d0ab8f0b8f64bc870f 100644
--- a/arch/arm/src/stm32/stm32_serial.c
+++ b/arch/arm/src/stm32/stm32_serial.c
@@ -182,8 +182,14 @@
* When streaming data, the generic serial layer will be called
* every time the FIFO receives half this number of bytes.
*/
-
-# define RXDMA_BUFFER_SIZE 32
+# if !defined(CONFIG_STM32_SERIAL_RXDMA_BUFFER_SIZE)
+# define CONFIG_STM32_SERIAL_RXDMA_BUFFER_SIZE 32
+# endif
+# define RXDMA_MUTIPLE 4
+# define RXDMA_MUTIPLE_MASK (RXDMA_MUTIPLE -1)
+# define RXDMA_BUFFER_SIZE ((CONFIG_STM32_SERIAL_RXDMA_BUFFER_SIZE \
+ + RXDMA_MUTIPLE_MASK) \
+ & ~RXDMA_MUTIPLE_MASK)
/* DMA priority */
@@ -1044,10 +1050,10 @@ static inline void up_serialout(struct up_dev_s *priv, int offset, uint32_t valu
}
/****************************************************************************
- * Name: up_restoreusartint
+ * Name: up_setusartint
****************************************************************************/
-static void up_restoreusartint(struct up_dev_s *priv, uint16_t ie)
+static inline void up_setusartint(struct up_dev_s *priv, uint16_t ie)
{
uint32_t cr;
@@ -1068,12 +1074,31 @@ static void up_restoreusartint(struct up_dev_s *priv, uint16_t ie)
up_serialout(priv, STM32_USART_CR3_OFFSET, cr);
}
+/****************************************************************************
+ * Name: up_restoreusartint
+ ****************************************************************************/
+
+static void up_restoreusartint(struct up_dev_s *priv, uint16_t ie)
+{
+ irqstate_t flags;
+
+ flags = enter_critical_section();
+
+ up_setusartint(priv, ie);
+
+ leave_critical_section(flags);
+}
+
/****************************************************************************
* Name: up_disableusartint
****************************************************************************/
-static inline void up_disableusartint(struct up_dev_s *priv, uint16_t *ie)
+static void up_disableusartint(struct up_dev_s *priv, uint16_t *ie)
{
+ irqstate_t flags;
+
+ flags = enter_critical_section();
+
if (ie)
{
uint32_t cr1;
@@ -1110,7 +1135,9 @@ static inline void up_disableusartint(struct up_dev_s *priv, uint16_t *ie)
/* Disable all interrupts */
- up_restoreusartint(priv, 0);
+ up_setusartint(priv, 0);
+
+ leave_critical_section(flags);
}
/****************************************************************************
@@ -2250,7 +2277,9 @@ static bool up_rxflowcontrol(struct uart_dev_s *dev,
unsigned int nbuffered, bool upper)
{
struct up_dev_s *priv = (struct up_dev_s *)dev->priv;
+#if !(defined(CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS) && defined(CONFIG_STM32_FLOWCONTROL_BROKEN))
uint16_t ie;
+#endif
#if defined(CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS) && defined(CONFIG_STM32_FLOWCONTROL_BROKEN)
if (priv->iflow && (priv->rts_gpio != 0))
diff --git a/arch/arm/src/stm32/stm32_spi.h b/arch/arm/src/stm32/stm32_spi.h
index a9d336cb8607317fd3115ae07a18fd77687e5c6a..9c757db523ea5122eaa14a150798c16ab794df06 100644
--- a/arch/arm/src/stm32/stm32_spi.h
+++ b/arch/arm/src/stm32/stm32_spi.h
@@ -64,8 +64,7 @@ extern "C"
* Public Data
************************************************************************************/
-struct spi_dev_s;
-enum spi_dev_e;
+struct spi_dev_s;
/************************************************************************************
* Public Functions
@@ -117,39 +116,39 @@ FAR struct spi_dev_s *stm32_spibus_initialize(int bus);
************************************************************************************/
#ifdef CONFIG_STM32_SPI1
-void stm32_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
-uint8_t stm32_spi1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
-int stm32_spi1cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+void stm32_spi1select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected);
+uint8_t stm32_spi1status(FAR struct spi_dev_s *dev, uint32_t devid);
+int stm32_spi1cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
#endif
#ifdef CONFIG_STM32_SPI2
-void stm32_spi2select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
-uint8_t stm32_spi2status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
-int stm32_spi2cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+void stm32_spi2select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected);
+uint8_t stm32_spi2status(FAR struct spi_dev_s *dev, uint32_t devid);
+int stm32_spi2cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
#endif
#ifdef CONFIG_STM32_SPI3
-void stm32_spi3select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
-uint8_t stm32_spi3status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
-int stm32_spi3cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+void stm32_spi3select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected);
+uint8_t stm32_spi3status(FAR struct spi_dev_s *dev, uint32_t devid);
+int stm32_spi3cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
#endif
#ifdef CONFIG_STM32_SPI4
-void stm32_spi4select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
-uint8_t stm32_spi4status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
-int stm32_spi4cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+void stm32_spi4select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected);
+uint8_t stm32_spi4status(FAR struct spi_dev_s *dev, uint32_t devid);
+int stm32_spi4cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
#endif
#ifdef CONFIG_STM32_SPI5
-void stm32_spi5select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
-uint8_t stm32_spi5status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
-int stm32_spi5cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+void stm32_spi5select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected);
+uint8_t stm32_spi5status(FAR struct spi_dev_s *dev, uint32_t devid);
+int stm32_spi5cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
#endif
#ifdef CONFIG_STM32_SPI6
-void stm32_spi6select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
-uint8_t stm32_spi6status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
-int stm32_spi6cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+void stm32_spi6select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected);
+uint8_t stm32_spi6status(FAR struct spi_dev_s *dev, uint32_t devid);
+int stm32_spi6cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
#endif
/************************************************************************************
diff --git a/arch/arm/src/stm32/stm32_tickless.c b/arch/arm/src/stm32/stm32_tickless.c
index fafa9bcadfdbcd530304779cdcddcb38e9d8b92e..6d7a004693b3338af62457037780ef0d4734b60a 100644
--- a/arch/arm/src/stm32/stm32_tickless.c
+++ b/arch/arm/src/stm32/stm32_tickless.c
@@ -2,7 +2,9 @@
* arch/arm/src/stm32/stm32_tickless.c
*
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt
+ * Copyright (C) 2017 Ansync Labs. All rights reserved.
+ * Authors: Gregory Nutt
+ * Konstantin Berezenko
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -55,24 +57,19 @@
*
****************************************************************************/
/****************************************************************************
- * SAM34 Timer Usage
- *
- * This current implementation uses two timers: A one-shot timer to provide
- * the timed events and a free running timer to provide the current time.
- * Since timers are a limited resource, that could be an issue on some
- * systems.
- *
- * We could do the job with a single timer if we were to keep the single
- * timer in a free-running at all times. The STM32 timer/counters have
- * 16-bit/32-bit counters with the capability to generate a compare interrupt
- * when the timer matches a compare value but also to continue counting
- * without stopping (giving another, different interrupt when the timer
- * rolls over from 0xffffffff to zero). So we could potentially just set
- * the compare at the number of ticks you want PLUS the current value of
- * timer. Then you could have both with a single timer: An interval timer
- * and a free-running counter with the same timer!
- *
- * Patches are welcome!
+ * STM32 Timer Usage
+ *
+ * This implementation uses one timer: A free running timer to provide
+ * the current time and a capture/compare channel for timed-events.
+ * The STM32 has both 16-bit and 32-bit timers so to keep things consistent
+ * we limit the timer counters to a 16-bit range. BASIC timers that
+ * are found on some STM32 chips (timers 6 and 7) are incompatible with this
+ * implementation because they don't have capture/compare channels. There
+ * are two interrupts generated from our timer, the overflow interrupt which
+ * drives the timing handler and the capture/compare interrupt which drives
+ * the interval handler. There are some low level timer control functions
+ * implemented here because the API of stm32_tim.c does not provide adequate
+ * control over capture/compare interrupts.
*
****************************************************************************/
@@ -84,12 +81,15 @@
#include
#include
+#include
+#include
#include
#include
-#include "stm32_oneshot.h"
-#include "stm32_freerun.h"
+#include "up_arch.h"
+
+#include "stm32_tim.h"
#ifdef CONFIG_SCHED_TICKLESS
@@ -97,30 +97,24 @@
* Pre-processor Definitions
****************************************************************************/
-#ifndef CONFIG_STM32_ONESHOT
-# error CONFIG_STM32_ONESHOT must be selected for the Tickless OS option
-#endif
-
-#ifndef CONFIG_STM32_FREERUN
-# error CONFIG_STM32_FREERUN must be selected for the Tickless OS option
-#endif
-
-#ifndef CONFIG_STM32_TICKLESS_FREERUN
-# error CONFIG_STM32_TICKLESS_FREERUN must be selected for the Tickless OS option
-#endif
-
-#ifndef CONFIG_STM32_TICKLESS_ONESHOT
-# error CONFIG_STM32_TICKLESS_ONESHOT must be selected for the Tickless OS option
-#endif
-
/****************************************************************************
* Private Types
****************************************************************************/
struct stm32_tickless_s
{
- struct stm32_oneshot_s oneshot;
- struct stm32_freerun_s freerun;
+ uint8_t timer; /* The timer/counter in use */
+ uint8_t channel; /* The timer channel to use for intervals */
+ FAR struct stm32_tim_dev_s *tch; /* Handle returned by stm32_tim_init() */
+ uint32_t frequency;
+#ifdef CONFIG_CLOCK_TIMEKEEPING
+ uint64_t counter_mask;
+#else
+ uint32_t overflow; /* Timer counter overflow */
+#endif
+ volatile bool pending; /* True: pending task */
+ uint32_t period; /* Interval period */
+ uint32_t base;
};
/****************************************************************************
@@ -133,11 +127,159 @@ static struct stm32_tickless_s g_tickless;
* Private Functions
****************************************************************************/
+/************************************************************************************
+ * Name: stm32_getreg16
+ *
+ * Description:
+ * Get a 16-bit register value by offset
+ *
+ ************************************************************************************/
+
+static inline uint16_t stm32_getreg16(uint8_t offset)
+{
+ return getreg16(g_tickless.base + offset);
+}
+
+/************************************************************************************
+ * Name: stm32_putreg16
+ *
+ * Description:
+ * Put a 16-bit register value by offset
+ *
+ ************************************************************************************/
+
+static inline void stm32_putreg16(uint8_t offset, uint16_t value)
+{
+ putreg16(value, g_tickless.base + offset);
+}
+
+/************************************************************************************
+ * Name: stm32_modifyreg16
+ *
+ * Description:
+ * Modify a 16-bit register value by offset
+ *
+ ************************************************************************************/
+
+static inline void stm32_modifyreg16(uint8_t offset, uint16_t clearbits,
+ uint16_t setbits)
+{
+ modifyreg16(g_tickless.base + offset, clearbits, setbits);
+}
+
+/************************************************************************************
+ * Name: stm32_tickless_enableint
+ ************************************************************************************/
+
+static inline void stm32_tickless_enableint(int channel)
+{
+ stm32_modifyreg16(STM32_BTIM_DIER_OFFSET, 0, 1 << channel);
+}
+
+/************************************************************************************
+ * Name: stm32_tickless_disableint
+ ************************************************************************************/
+
+static inline void stm32_tickless_disableint(int channel)
+{
+ stm32_modifyreg16(STM32_BTIM_DIER_OFFSET, 1 << channel, 0);
+}
+
+/************************************************************************************
+ * Name: stm32_tickless_ackint
+ ************************************************************************************/
+
+static inline void stm32_tickless_ackint(int channel)
+{
+ stm32_putreg16(STM32_BTIM_SR_OFFSET, ~(1 << channel));
+}
+
+/************************************************************************************
+ * Name: stm32_tickless_getint
+ ************************************************************************************/
+
+static inline uint16_t stm32_tickless_getint(void)
+{
+ return stm32_getreg16(STM32_BTIM_SR_OFFSET);
+}
+
+/************************************************************************************
+ * Name: stm32_tickless_setchannel
+ ************************************************************************************/
+
+static int stm32_tickless_setchannel(uint8_t channel)
+{
+ uint16_t ccmr_orig = 0;
+ uint16_t ccmr_val = 0;
+ uint16_t ccmr_mask = 0xff;
+ uint16_t ccer_val = stm32_getreg16(STM32_GTIM_CCER_OFFSET);
+ uint8_t ccmr_offset = STM32_GTIM_CCMR1_OFFSET;
+
+ /* Further we use range as 0..3; if channel=0 it will also overflow here */
+
+ if (--channel > 4)
+ {
+ return -EINVAL;
+ }
+
+ /* Assume that channel is disabled and polarity is active high */
+
+ ccer_val &= ~(3 << (channel << 2));
+
+ /* This function is not supported on basic timers. To enable or
+ * disable it, simply set its clock to valid frequency or zero.
+ */
+
+#if STM32_NBTIM > 0
+ if (g_tickless.base == STM32_TIM6_BASE
+#endif
+#if STM32_NBTIM > 1
+ || g_tickless.base == STM32_TIM7_BASE
+#endif
+#if STM32_NBTIM > 0
+ )
+ {
+ return -EINVAL;
+ }
+#endif
+
+ /* Frozen mode because we don't want to change the GPIO, preload register
+ * disabled.
+ */
+
+ ccmr_val = (ATIM_CCMR_MODE_FRZN << ATIM_CCMR1_OC1M_SHIFT);
+
+ /* Set polarity */
+
+ ccer_val |= ATIM_CCER_CC1P << (channel << 2);
+
+ /* Define its position (shift) and get register offset */
+
+ if ((channel & 1) != 0)
+ {
+ ccmr_val <<= 8;
+ ccmr_mask <<= 8;
+ }
+
+ if (channel > 1)
+ {
+ ccmr_offset = STM32_GTIM_CCMR2_OFFSET;
+ }
+
+ ccmr_orig = stm32_getreg16(ccmr_offset);
+ ccmr_orig &= ~ccmr_mask;
+ ccmr_orig |= ccmr_val;
+ stm32_putreg16(ccmr_offset, ccmr_orig);
+ stm32_putreg16(STM32_GTIM_CCER_OFFSET, ccer_val);
+
+ return OK;
+}
+
/****************************************************************************
- * Name: stm32_oneshot_handler
+ * Name: stm32_interval_handler
*
* Description:
- * Called when the one shot timer expires
+ * Called when the timer counter matches the compare register
*
* Input Parameters:
* None
@@ -151,12 +293,78 @@ static struct stm32_tickless_s g_tickless;
*
****************************************************************************/
-static void stm32_oneshot_handler(void *arg)
+static void stm32_interval_handler(void)
{
tmrinfo("Expired...\n");
+
+ /* Disable the compare interrupt now. */
+
+ stm32_tickless_disableint(g_tickless.channel);
+ stm32_tickless_ackint(g_tickless.channel);
+
+ g_tickless.pending = false;
+
sched_timer_expiration();
}
+/****************************************************************************
+ * Name: stm32_timing_handler
+ *
+ * Description:
+ * Timer interrupt callback. When the freerun timer counter overflows,
+ * this interrupt will occur. We will just increment an overflow count.
+ *
+ * Input Parameters:
+ * None
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+#ifndef CONFIG_CLOCK_TIMEKEEPING
+static void stm32_timing_handler(void)
+{
+ g_tickless.overflow++;
+
+ STM32_TIM_ACKINT(g_tickless.tch, 0);
+}
+#endif /* CONFIG_CLOCK_TIMEKEEPING */
+
+/****************************************************************************
+ * Name: stm32_tickless_handler
+ *
+ * Description:
+ * Generic interrupt handler for this timer. It checks the source of the
+ * interrupt and fires the appropriate handler.
+ *
+ * Input Parameters:
+ * None
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+static int stm32_tickless_handler(int irq, void *context, void *arg)
+{
+ int interrupt_flags = stm32_tickless_getint();
+
+#ifndef CONFIG_CLOCK_TIMEKEEPING
+ if (interrupt_flags & ATIM_SR_UIF)
+ {
+ stm32_timing_handler();
+ }
+#endif /* CONFIG_CLOCK_TIMEKEEPING */
+
+ if (interrupt_flags & (1 << g_tickless.channel))
+ {
+ stm32_interval_handler();
+ }
+
+ return OK;
+}
+
/****************************************************************************
* Public Functions
****************************************************************************/
@@ -188,55 +396,172 @@ static void stm32_oneshot_handler(void *arg)
void arm_timer_initialize(void)
{
-#ifdef CONFIG_SCHED_TICKLESS_LIMIT_MAX_SLEEP
- uint64_t max_delay;
+ switch (CONFIG_STM32_TICKLESS_TIMER)
+ {
+#ifdef CONFIG_STM32_TIM1
+ case 1:
+ g_tickless.base = STM32_TIM1_BASE;
+ break;
#endif
- int ret;
- /* Initialize the one-shot timer */
+#ifdef CONFIG_STM32_TIM2
+ case 2:
+ g_tickless.base = STM32_TIM2_BASE;
+ break;
+#endif
- ret = stm32_oneshot_initialize(&g_tickless.oneshot,
- CONFIG_STM32_TICKLESS_ONESHOT,
- CONFIG_USEC_PER_TICK);
- if (ret < 0)
- {
- tmrerr("ERROR: stm32_oneshot_initialize failed\n");
- PANIC();
- }
+#ifdef CONFIG_STM32_TIM3
+ case 3:
+ g_tickless.base = STM32_TIM3_BASE;
+ break;
+#endif
-#ifdef CONFIG_SCHED_TICKLESS_LIMIT_MAX_SLEEP
- /* Get the maximum delay of the one-shot timer in microseconds */
+#ifdef CONFIG_STM32_TIM4
+ case 4:
+ g_tickless.base = STM32_TIM4_BASE;
+ break;
+#endif
+#ifdef CONFIG_STM32_TIM5
+ case 5:
+ g_tickless.base = STM32_TIM5_BASE;
+ break;
+#endif
- ret = stm32_oneshot_max_delay(&g_tickless.oneshot, &max_delay);
- if (ret < 0)
- {
- tmrerr("ERROR: stm32_oneshot_max_delay failed\n");
- PANIC();
- }
+#ifdef CONFIG_STM32_TIM6
+ case 6:
- /* Convert this to configured clock ticks for use by the OS timer logic */
+ /* Basic timers not supported by this implementation */
- max_delay /= CONFIG_USEC_PER_TICK;
- if (max_delay > UINT32_MAX)
- {
- g_oneshot_maxticks = UINT32_MAX;
+ ASSERT(0);
+ break;
+#endif
+
+#ifdef CONFIG_STM32_TIM7
+ case 7:
+
+ /* Basic timers not supported by this implementation */
+
+ ASSERT(0);
+ break;
+#endif
+
+#ifdef CONFIG_STM32_TIM8
+ case 8:
+ g_tickless.base = STM32_TIM8_BASE;
+ break;
+#endif
+
+#ifdef CONFIG_STM32_TIM9
+ case 9:
+ g_tickless.base = STM32_TIM9_BASE;
+ break;
+#endif
+#ifdef CONFIG_STM32_TIM10
+ case 10:
+ g_tickless.base = STM32_TIM10_BASE;
+ break;
+#endif
+
+#ifdef CONFIG_STM32_TIM11
+ case 11:
+ g_tickless.base = STM32_TIM11_BASE;
+ break;
+#endif
+#ifdef CONFIG_STM32_TIM12
+ case 12:
+ g_tickless.base = STM32_TIM12_BASE;
+ break;
+#endif
+#ifdef CONFIG_STM32_TIM13
+ case 13:
+ g_tickless.base = STM32_TIM13_BASE;
+ break;
+#endif
+
+#ifdef CONFIG_STM32_TIM14
+ case 14:
+ g_tickless.base = STM32_TIM14_BASE;
+ break;
+#endif
+#ifdef CONFIG_STM32_TIM15
+ case 15:
+ g_tickless.base = STM32_TIM15_BASE;
+ break;
+#endif
+
+#ifdef CONFIG_STM32_TIM16
+ case 16:
+ g_tickless.base = STM32_TIM16_BASE;
+ break;
+#endif
+
+#ifdef CONFIG_STM32_TIM17
+ case 17:
+ g_tickless.base = STM32_TIM17_BASE;
+ break;
+#endif
+
+ default:
+ ASSERT(0);
}
- else
+
+ /* Get the TC frequency that corresponds to the requested resolution */
+
+ g_tickless.frequency = USEC_PER_SEC / (uint32_t)CONFIG_USEC_PER_TICK;
+ g_tickless.timer = CONFIG_STM32_TICKLESS_TIMER;
+ g_tickless.channel = CONFIG_STM32_TICKLESS_CHANNEL;
+ g_tickless.pending = false;
+ g_tickless.period = 0;
+
+ tmrinfo("timer=%d channel=%d frequency=%d Hz\n",
+ g_tickless.timer, g_tickless.channel, g_tickless.frequency);
+
+ g_tickless.tch = stm32_tim_init(g_tickless.timer);
+ if (!g_tickless.tch)
{
- g_oneshot_maxticks = max_delay;
+ tmrerr("ERROR: Failed to allocate TIM%d\n", g_tickless.timer);
+ ASSERT(0);
}
+
+ STM32_TIM_SETCLOCK(g_tickless.tch, g_tickless.frequency);
+
+#ifdef CONFIG_CLOCK_TIMEKEEPING
+
+ /* Should this be changed to 0xffff because we use 16 bit timers? */
+
+ g_tickless.counter_mask = 0xffffffffull;
+#else
+ g_tickless.overflow = 0;
+
+ /* Set up to receive the callback when the counter overflow occurs */
+
+ STM32_TIM_SETISR(g_tickless.tch, stm32_tickless_handler, NULL, 0);
#endif
- /* Initialize the free-running timer */
+ /* Initialize interval to zero */
- ret = stm32_freerun_initialize(&g_tickless.freerun,
- CONFIG_STM32_TICKLESS_FREERUN,
- CONFIG_USEC_PER_TICK);
- if (ret < 0)
- {
- tmrerr("ERROR: stm32_freerun_initialize failed\n");
- PANIC();
- }
+ STM32_TIM_SETCOMPARE(g_tickless.tch, g_tickless.channel, 0);
+
+ /* Setup compare channel for the interval timing */
+
+ stm32_tickless_setchannel(g_tickless.channel);
+
+ /* Set timer period */
+
+ STM32_TIM_SETPERIOD(g_tickless.tch, UINT16_MAX);
+
+ /* Initialize the counter */
+
+ STM32_TIM_SETMODE(g_tickless.tch, STM32_TIM_MODE_UP);
+
+#ifdef CONFIG_SCHED_TICKLESS_LIMIT_MAX_SLEEP
+ g_oneshot_maxticks = UINT16_MAX;
+#endif
+
+ /* Start the timer */
+
+ STM32_TIM_ACKINT(g_tickless.tch, 0);
+ STM32_TIM_ENABLEINT(g_tickless.tch, 0);
}
/****************************************************************************
@@ -265,7 +590,7 @@ void arm_timer_initialize(void)
* any failure.
*
* Assumptions:
- * Called from the the normal tasking context. The implementation must
+ * Called from the normal tasking context. The implementation must
* provide whatever mutual exclusion is necessary for correct operation.
* This can include disabling interrupts in order to assure atomic register
* operations.
@@ -276,14 +601,84 @@ void arm_timer_initialize(void)
int up_timer_gettime(FAR struct timespec *ts)
{
- return stm32_freerun_counter(&g_tickless.freerun, ts);
+ uint64_t usec;
+ uint32_t counter;
+ uint32_t verify;
+ uint32_t overflow;
+ uint32_t sec;
+ int pending;
+ irqstate_t flags;
+
+ DEBUGASSERT(g_tickless.tch && ts);
+
+ /* Temporarily disable the overflow counter. NOTE that we have to be
+ * careful here because stm32_tc_getpending() will reset the pending
+ * interrupt status. If we do not handle the overflow here then, it will
+ * be lost.
+ */
+
+ flags = enter_critical_section();
+
+ overflow = g_tickless.overflow;
+ counter = STM32_TIM_GETCOUNTER(g_tickless.tch);
+ pending = STM32_TIM_CHECKINT(g_tickless.tch, 0);
+ verify = STM32_TIM_GETCOUNTER(g_tickless.tch);
+
+ /* If an interrupt was pending before we re-enabled interrupts,
+ * then the overflow needs to be incremented.
+ */
+
+ if (pending)
+ {
+ STM32_TIM_ACKINT(g_tickless.tch, 0);
+
+ /* Increment the overflow count and use the value of the
+ * guaranteed to be AFTER the overflow occurred.
+ */
+
+ overflow++;
+ counter = verify;
+
+ /* Update tickless overflow counter. */
+
+ g_tickless.overflow = overflow;
+ }
+
+ leave_critical_section(flags);
+
+ tmrinfo("counter=%lu (%lu) overflow=%lu, pending=%i\n",
+ (unsigned long)counter, (unsigned long)verify,
+ (unsigned long)overflow, pending);
+ tmrinfo("frequency=%u\n", g_tickless.frequency);
+
+ /* Convert the whole thing to units of microseconds.
+ *
+ * frequency = ticks / second
+ * seconds = ticks * frequency
+ * usecs = (ticks * USEC_PER_SEC) / frequency;
+ */
+
+ usec = ((((uint64_t)overflow << 16) + (uint64_t)counter) * USEC_PER_SEC) /
+ g_tickless.frequency;
+
+ /* And return the value of the timer */
+
+ sec = (uint32_t)(usec / USEC_PER_SEC);
+ ts->tv_sec = sec;
+ ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
+
+ tmrinfo("usec=%llu ts=(%u, %lu)\n",
+ usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
+
+ return OK;
}
#else
int up_timer_getcounter(FAR uint64_t *cycles)
{
- return stm32_freerun_counter(&g_tickless.freerun, cycles);
+ *cycles = (uint64_t)STM32_TIM_GETCOUNTER(g_tickless.tch);
+ return OK;
}
#endif /* CONFIG_CLOCK_TIMEKEEPING */
@@ -306,7 +701,7 @@ int up_timer_getcounter(FAR uint64_t *cycles)
void up_timer_getmask(FAR uint64_t *mask)
{
DEBUGASSERT(mask != NULL);
- *mask = g_tickless.freerun.counter_mask;
+ *mask = g_tickless.counter_mask;
}
#endif /* CONFIG_CLOCK_TIMEKEEPING */
@@ -348,7 +743,101 @@ void up_timer_getmask(FAR uint64_t *mask)
int up_timer_cancel(FAR struct timespec *ts)
{
- return stm32_oneshot_cancel(&g_tickless.oneshot, ts);
+ irqstate_t flags;
+ uint64_t usec;
+ uint64_t sec;
+ uint64_t nsec;
+ uint32_t count;
+ uint32_t period;
+
+ /* Was the timer running? */
+
+ flags = enter_critical_section();
+ if (!g_tickless.pending)
+ {
+ /* No.. Just return zero timer remaining and successful cancellation.
+ * This function may execute at a high rate with no timer running
+ * (as when pre-emption is enabled and disabled).
+ */
+
+ if (ts)
+ {
+ ts->tv_sec = 0;
+ ts->tv_nsec = 0;
+ }
+
+ leave_critical_section(flags);
+ return OK;
+ }
+
+ /* Yes.. Get the timer counter and period registers and disable the compare interrupt.
+ *
+ */
+
+ tmrinfo("Cancelling...\n");
+
+ /* Disable the interrupt. */
+
+ stm32_tickless_disableint(g_tickless.channel);
+
+ count = STM32_TIM_GETCOUNTER(g_tickless.tch);
+ period = g_tickless.period;
+
+ g_tickless.pending = false;
+ leave_critical_section(flags);
+
+ /* Did the caller provide us with a location to return the time
+ * remaining?
+ */
+
+ if (ts != NULL)
+ {
+ /* Yes.. then calculate and return the time remaining on the
+ * oneshot timer.
+ */
+
+ tmrinfo("period=%lu count=%lu\n",
+ (unsigned long)period, (unsigned long)count);
+
+ if (count > period)
+ {
+ /* Handle rollover */
+
+ period += UINT16_MAX;
+ }
+ else if (count == period)
+ {
+ /* No time remaining */
+
+ ts->tv_sec = 0;
+ ts->tv_nsec = 0;
+ return OK;
+ }
+
+ /* The total time remaining is the difference. Convert that
+ * to units of microseconds.
+ *
+ * frequency = ticks / second
+ * seconds = ticks * frequency
+ * usecs = (ticks * USEC_PER_SEC) / frequency;
+ */
+
+ usec = (((uint64_t)(period - count)) * USEC_PER_SEC) /
+ g_tickless.frequency;
+
+ /* Return the time remaining in the correct form */
+
+ sec = usec / USEC_PER_SEC;
+ nsec = ((usec) - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
+
+ ts->tv_sec = (time_t)sec;
+ ts->tv_nsec = (unsigned long)nsec;
+
+ tmrinfo("remaining (%lu, %lu)\n",
+ (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
+ }
+
+ return OK;
}
/****************************************************************************
@@ -378,6 +867,65 @@ int up_timer_cancel(FAR struct timespec *ts)
int up_timer_start(FAR const struct timespec *ts)
{
- return stm32_oneshot_start(&g_tickless.oneshot, stm32_oneshot_handler, NULL, ts);
+ uint64_t usec;
+ uint64_t period;
+ uint32_t count;
+ irqstate_t flags;
+
+ tmrinfo("handler=%p arg=%p, ts=(%lu, %lu)\n",
+ handler, arg, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
+ DEBUGASSERT(ts);
+ DEBUGASSERT(g_tickless.tch);
+
+ /* Was an interval already running? */
+
+ flags = enter_critical_section();
+ if (g_tickless.pending)
+ {
+ /* Yes.. then cancel it */
+
+ tmrinfo("Already running... cancelling\n");
+ (void)up_timer_cancel(NULL);
+ }
+
+ /* Express the delay in microseconds */
+
+ usec = (uint64_t)ts->tv_sec * USEC_PER_SEC +
+ (uint64_t)(ts->tv_nsec / NSEC_PER_USEC);
+
+ /* Get the timer counter frequency and determine the number of counts need
+ * to achieve the requested delay.
+ *
+ * frequency = ticks / second
+ * ticks = seconds * frequency
+ * = (usecs * frequency) / USEC_PER_SEC;
+ */
+
+ period = (usec * (uint64_t)g_tickless.frequency) / USEC_PER_SEC;
+ count = STM32_TIM_GETCOUNTER(g_tickless.tch);
+
+ tmrinfo("usec=%llu period=%08llx\n", usec, period);
+ DEBUGASSERT(period <= UINT16_MAX);
+
+ /* Set interval compare value. Rollover is fine,
+ * channel will trigger on the next period. (uint16_t) cast
+ * handles the overflow.
+ */
+
+ g_tickless.period = (uint16_t)(period + count);
+
+ STM32_TIM_SETCOMPARE(g_tickless.tch, g_tickless.channel,
+ g_tickless.period);
+
+ /* Enable interrupts. We should get the callback when the interrupt
+ * occurs.
+ */
+
+ stm32_tickless_ackint(g_tickless.channel);
+ stm32_tickless_enableint(g_tickless.channel);
+
+ g_tickless.pending = true;
+ leave_critical_section(flags);
+ return OK;
}
#endif /* CONFIG_SCHED_TICKLESS */
diff --git a/arch/arm/src/stm32/stm32_tim.c b/arch/arm/src/stm32/stm32_tim.c
index 5590992827056fbcd0da75eafa59f7cbeed2c5ec..d4a4ed2559926ed6042a7bbf240c760751aa458c 100644
--- a/arch/arm/src/stm32/stm32_tim.c
+++ b/arch/arm/src/stm32/stm32_tim.c
@@ -334,22 +334,23 @@ static void stm32_tim_gpioconfig(uint32_t cfg, stm32_tim_channel_t mode);
/* Timer methods */
-static int stm32_tim_setmode(FAR struct stm32_tim_dev_s *dev, stm32_tim_mode_t mode);
-static int stm32_tim_setclock(FAR struct stm32_tim_dev_s *dev, uint32_t freq);
+static int stm32_tim_setmode(FAR struct stm32_tim_dev_s *dev, stm32_tim_mode_t mode);
+static int stm32_tim_setclock(FAR struct stm32_tim_dev_s *dev, uint32_t freq);
static void stm32_tim_setperiod(FAR struct stm32_tim_dev_s *dev,
uint32_t period);
static uint32_t stm32_tim_getcounter(FAR struct stm32_tim_dev_s *dev);
-static int stm32_tim_setchannel(FAR struct stm32_tim_dev_s *dev, uint8_t channel,
- stm32_tim_channel_t mode);
-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, xcpt_t handler,
- void *arg, int source);
+static int stm32_tim_getwidth(FAR struct stm32_tim_dev_s *dev);
+static int stm32_tim_setchannel(FAR struct stm32_tim_dev_s *dev, uint8_t channel,
+ stm32_tim_channel_t mode);
+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, 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);
-static int stm32_tim_checkint(FAR struct stm32_tim_dev_s *dev, int source);
+static int stm32_tim_checkint(FAR struct stm32_tim_dev_s *dev, int source);
/************************************************************************************
* Private Data
@@ -361,6 +362,7 @@ static const struct stm32_tim_ops_s stm32_tim_ops =
.setclock = stm32_tim_setclock,
.setperiod = stm32_tim_setperiod,
.getcounter = stm32_tim_getcounter,
+ .getwidth = stm32_tim_getwidth,
.setchannel = stm32_tim_setchannel,
.setcompare = stm32_tim_setcompare,
.getcapture = stm32_tim_getcapture,
@@ -904,6 +906,41 @@ static uint32_t stm32_tim_getcounter(FAR struct stm32_tim_dev_s *dev)
return stm32_getreg32(dev, STM32_BTIM_CNT_OFFSET);
}
+/************************************************************************************
+ * Name: stm32_tim_getwidth
+ ************************************************************************************/
+
+static int stm32_tim_getwidth(FAR struct stm32_tim_dev_s *dev)
+{
+ /* Only TIM2 and TIM5 timers may be 32-bits in width
+ *
+ * Reference Table 2 of en.DM00042534.pdf
+ */
+
+ switch (((struct stm32_tim_priv_s *)dev)->base)
+ {
+ /* TIM2 is 32-bits on all except F10x, L0x, and L1x lines */
+
+#if defined(CONFIG_STM32_TIM2) && !defined(STM32_STM32F10XX) && \
+ !defined(STM32_STM32L15XX)
+ case STM32_TIM2_BASE:
+ return 32;
+#endif
+
+ /* TIM5 is 32-bits on all except F10x lines */
+
+#if defined(CONFIG_STM32_TIM5) && !defined(STM32_STM32F10XX)
+ case STM32_TIM5_BASE:
+ return 32;
+#endif
+
+ /* All others are 16-bit times */
+
+ default:
+ return 16;
+ }
+}
+
/************************************************************************************
* Name: stm32_tim_setchannel
************************************************************************************/
diff --git a/arch/arm/src/stm32/stm32_tim.h b/arch/arm/src/stm32/stm32_tim.h
index 921baebc6c34415252cac0ab516ecfb301de1d3b..5b9422f3ee5511faab6a09a3dead2363ca53355f 100644
--- a/arch/arm/src/stm32/stm32_tim.h
+++ b/arch/arm/src/stm32/stm32_tim.h
@@ -61,6 +61,7 @@
#define STM32_TIM_SETCLOCK(d,freq) ((d)->ops->setclock(d,freq))
#define STM32_TIM_SETPERIOD(d,period) ((d)->ops->setperiod(d,period))
#define STM32_TIM_GETCOUNTER(d) ((d)->ops->getcounter(d))
+#define STM32_TIM_GETWIDTH(d) ((d)->ops->getwidth(d))
#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))
@@ -166,6 +167,7 @@ struct stm32_tim_ops_s
/* General and Advanced Timers Adds */
+ int (*getwidth)(FAR struct stm32_tim_dev_s *dev);
int (*setchannel)(FAR struct stm32_tim_dev_s *dev, uint8_t channel,
stm32_tim_channel_t mode);
int (*setcompare)(FAR struct stm32_tim_dev_s *dev, uint8_t channel,
diff --git a/arch/arm/src/stm32/stm32_waste.h b/arch/arm/src/stm32/stm32_waste.h
index 4d13700ea2c78efc855c9af4ab7dcc21a79c01c4..6c800c756f7eb713219584df4c32461aa1c76ad8 100644
--- a/arch/arm/src/stm32/stm32_waste.h
+++ b/arch/arm/src/stm32/stm32_waste.h
@@ -76,4 +76,4 @@ void up_waste(void);
#endif
#endif /* __ASSEMBLY__ */
-#endif /* __ARCH_ARM_SRC_STM32_STM32_RRC_H */
+#endif /* __ARCH_ARM_SRC_STM32_STM32_WASTE_H */
diff --git a/arch/arm/src/stm32/stm32_wwdg.c b/arch/arm/src/stm32/stm32_wwdg.c
index a299de8c991461b0c44d75f7e92d389a8d7f37f5..c0cb34f1f71409d540472a51b4d86119fce919f2 100644
--- a/arch/arm/src/stm32/stm32_wwdg.c
+++ b/arch/arm/src/stm32/stm32_wwdg.c
@@ -734,8 +734,8 @@ static int stm32_ioctl(FAR struct watchdog_lowerhalf_s *lower, int cmd,
* Name: stm32_wwdginitialize
*
* Description:
- * Initialize the WWDG watchdog time. The watchdog timer is initialized and
- * registers as 'devpath. The initial state of the watchdog time is
+ * Initialize the WWDG watchdog timer. The watchdog timer is initialized and
+ * registers as 'devpath'. The initial state of the watchdog timer is
* disabled.
*
* Input Parameters:
@@ -753,7 +753,7 @@ void stm32_wwdginitialize(FAR const char *devpath)
wdinfo("Entry: devpath=%s\n", devpath);
- /* NOTE we assume that clocking to the IWDG has already been provided by
+ /* NOTE we assume that clocking to the WWDG has already been provided by
* the RCC initialization logic.
*/
@@ -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-M core halted),
* the WWDG counter either continues to work normally or stops, depending
* on DBG_WWDG_STOP configuration bit in DBG module.
*/
@@ -790,7 +790,7 @@ void stm32_wwdginitialize(FAR const char *devpath)
defined(CONFIG_STM32_JTAG_SW_ENABLE)
{
#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F30XX) || \
- defined(CONFIG_STM32_STM32F40XX)
+ defined(CONFIG_STM32_STM32F40XX) || defined(CONFIG_STM32_STM32L15XX)
uint32_t cr = getreg32(STM32_DBGMCU_APB1_FZ);
cr |= DBGMCU_APB1_WWDGSTOP;
putreg32(cr, STM32_DBGMCU_APB1_FZ);
diff --git a/arch/arm/src/stm32/stm32f10xxx_dma.c b/arch/arm/src/stm32/stm32f10xxx_dma.c
index 1e6751ee56358ed0a069e308d120a7cc66ea61b8..65136a450f68fc4646c574c4f34146c0a36fc2d4 100644
--- a/arch/arm/src/stm32/stm32f10xxx_dma.c
+++ b/arch/arm/src/stm32/stm32f10xxx_dma.c
@@ -57,7 +57,8 @@
#if defined(CONFIG_STM32_STM32F10XX) || defined(CONFIG_STM32_STM32F30XX) || \
- defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32L15XX)
+ defined(CONFIG_STM32_STM32F33XX) || defined(CONFIG_STM32_STM32F37XX) || \
+ defined(CONFIG_STM32_STM32L15XX)
/****************************************************************************
* Pre-processor Definitions
diff --git a/arch/arm/src/stm32/stm32f20xxx_rcc.c b/arch/arm/src/stm32/stm32f20xxx_rcc.c
index a45241ed85b0d09e6ccdf47a5feb8a9741139f91..fac0dc911d09c1dbe964ccb01b4eb1ca13f02d76 100644
--- a/arch/arm/src/stm32/stm32f20xxx_rcc.c
+++ b/arch/arm/src/stm32/stm32f20xxx_rcc.c
@@ -193,10 +193,16 @@ static inline void rcc_enableahb1(void)
#endif
#ifdef CONFIG_STM32_OTGHS
- /* USB OTG HS */
+#ifdef BOARD_ENABLE_USBOTG_HSULPI
+ /* Enable clocking for USB OTG HS and external PHY */
regval |= (RCC_AHB1ENR_OTGHSEN | RCC_AHB1ENR_OTGHSULPIEN);
+#else
+ /* Enable only clocking for USB OTG HS */
+
+ regval |= (RCC_AHB1ENR_OTGHSEN);
#endif
+#endif /* CONFIG_STM32_OTGHS */
putreg32(regval, STM32_RCC_AHB1ENR); /* Enable peripherals */
}
diff --git a/arch/arm/src/stm32/stm32f30xxx_i2c.c b/arch/arm/src/stm32/stm32f30xxx_i2c.c
index ba7c02ea651761fced6ba43592079c030b6d0025..e779c040ede6995dc642c4ec5991c9d7c5594282 100644
--- a/arch/arm/src/stm32/stm32f30xxx_i2c.c
+++ b/arch/arm/src/stm32/stm32f30xxx_i2c.c
@@ -222,7 +222,6 @@ 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 *, void *); /* Interrupt handler */
uint32_t ev_irq; /* Event IRQ */
uint32_t er_irq; /* Error IRQ */
#endif
@@ -301,17 +300,9 @@ static inline void stm32_i2c_sendstart(FAR struct stm32_i2c_priv_s *priv);
static inline void stm32_i2c_clrstart(FAR struct stm32_i2c_priv_s *priv);
static inline void stm32_i2c_sendstop(FAR struct stm32_i2c_priv_s *priv);
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);
+static int stm32_i2c_isr_process(struct stm32_i2c_priv_s * priv);
#ifndef CONFIG_I2C_POLLED
-#ifdef CONFIG_STM32_I2C1
-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, FAR void *arg);
-#endif
-#ifdef CONFIG_STM32_I2C3
-static int stm32_i2c3_isr(int irq, void *context, FAR void *arg);
-#endif
+static int stm32_i2c_isr(int irq, void *context, FAR void *arg);
#endif
static int stm32_i2c_init(FAR struct stm32_i2c_priv_s *priv);
static int stm32_i2c_deinit(FAR struct stm32_i2c_priv_s *priv);
@@ -327,7 +318,7 @@ static int stm32_i2c_reset(FAR struct i2c_master_s *dev);
/* Device Structures, Instantiation */
-const struct i2c_ops_s stm32_i2c_ops =
+static const struct i2c_ops_s stm32_i2c_ops =
{
.transfer = stm32_i2c_transfer
#ifdef CONFIG_I2C_RESET
@@ -344,13 +335,12 @@ static const struct stm32_i2c_config_s stm32_i2c1_config =
.scl_pin = GPIO_I2C1_SCL,
.sda_pin = GPIO_I2C1_SDA,
#ifndef CONFIG_I2C_POLLED
- .isr = stm32_i2c1_isr,
.ev_irq = STM32_IRQ_I2C1EV,
.er_irq = STM32_IRQ_I2C1ER
#endif
};
-struct stm32_i2c_priv_s stm32_i2c1_priv =
+static struct stm32_i2c_priv_s stm32_i2c1_priv =
{
.ops = &stm32_i2c_ops,
.config = &stm32_i2c1_config,
@@ -374,13 +364,12 @@ static const struct stm32_i2c_config_s stm32_i2c2_config =
.scl_pin = GPIO_I2C2_SCL,
.sda_pin = GPIO_I2C2_SDA,
#ifndef CONFIG_I2C_POLLED
- .isr = stm32_i2c2_isr,
.ev_irq = STM32_IRQ_I2C2EV,
.er_irq = STM32_IRQ_I2C2ER
#endif
};
-struct stm32_i2c_priv_s stm32_i2c2_priv =
+static struct stm32_i2c_priv_s stm32_i2c2_priv =
{
.ops = &stm32_i2c_ops,
.config = &stm32_i2c2_config,
@@ -404,13 +393,12 @@ static const struct stm32_i2c_config_s stm32_i2c3_config =
.scl_pin = GPIO_I2C3_SCL,
.sda_pin = GPIO_I2C3_SDA,
#ifndef CONFIG_I2C_POLLED
- .isr = stm32_i2c3_isr,
.ev_irq = STM32_IRQ_I2C3EV,
.er_irq = STM32_IRQ_I2C3ER
#endif
};
-struct stm32_i2c_priv_s stm32_i2c3_priv =
+static struct stm32_i2c_priv_s stm32_i2c3_priv =
{
.ops = &stm32_i2c_ops,
.config = &stm32_i2c3_config,
@@ -712,7 +700,7 @@ static inline int stm32_i2c_sem_waitdone(FAR struct stm32_i2c_priv_s *priv)
* reports that it is done.
*/
- stm32_i2c_isr(priv);
+ stm32_i2c_isr_process(priv);
}
/* Loop until the transfer is complete. */
@@ -1243,7 +1231,7 @@ static inline uint32_t stm32_i2c_getstatus(FAR struct stm32_i2c_priv_s *priv)
}
/************************************************************************************
- * Name: stm32_i2c_isr
+ * Name: stm32_i2c_isr_startmessage
*
* Description:
* Common logic when a message is started. Just adds the even to the trace buffer
@@ -1276,14 +1264,14 @@ static inline void stm32_i2c_clearinterrupts(struct stm32_i2c_priv_s *priv)
}
/************************************************************************************
- * Name: stm32_i2c_isr
+ * Name: stm32_i2c_isr_process
*
* Description:
* Common Interrupt Service Routine
*
************************************************************************************/
-static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv)
+static int stm32_i2c_isr_process(struct stm32_i2c_priv_s *priv)
{
uint32_t status = stm32_i2c_getstatus(priv);
@@ -1485,56 +1473,23 @@ static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv)
}
/************************************************************************************
- * Name: stm32_i2c1_isr
+ * Name: stm32_i2c_isr
*
* Description:
- * I2C1 interrupt service routine
+ * Common I2C interrupt service routine
*
************************************************************************************/
#ifndef CONFIG_I2C_POLLED
-#ifdef CONFIG_STM32_I2C1
-static int stm32_i2c1_isr(int irq, void *context, FAR void *arg)
+static int stm32_i2c_isr(int irq, void *context, FAR void *arg)
{
- return stm32_i2c_isr(&stm32_i2c1_priv);
-}
-#endif
-
-/************************************************************************************
- * Name: stm32_i2c2_isr
- *
- * Description:
- * I2C2 interrupt service routine
- *
- ************************************************************************************/
+ struct stm32_i2c_priv_s *priv = (struct stm32_i2c_priv_s *)arg;
-#ifdef CONFIG_STM32_I2C2
-static int stm32_i2c2_isr(int irq, void *context, FAR void *arg)
-{
- return stm32_i2c_isr(&stm32_i2c2_priv);
+ DEBUGASSERT(priv != NULL);
+ return stm32_i2c_isr_process(priv);
}
#endif
-/************************************************************************************
- * Name: stm32_i2c3_isr
- *
- * Description:
- * I2C2 interrupt service routine
- *
- ************************************************************************************/
-
-#ifdef CONFIG_STM32_I2C3
-static int stm32_i2c3_isr(int irq, void *context, FAR void *arg)
-{
- return stm32_i2c_isr(&stm32_i2c3_priv);
-}
-#endif
-#endif
-
-/************************************************************************************
- * Private Initialization and Deinitialization
- ************************************************************************************/
-
/************************************************************************************
* Name: stm32_i2c_init
*
@@ -1569,8 +1524,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, NULL);
- irq_attach(priv->config->er_irq, priv->config->isr, NULL);
+ irq_attach(priv->config->ev_irq, stm32_i2c_isr, priv);
+ irq_attach(priv->config->er_irq, stm32_i2c_isr, priv);
up_enable_irq(priv->config->ev_irq);
up_enable_irq(priv->config->er_irq);
#endif
diff --git a/arch/arm/src/stm32/stm32f33xxx_dma.c b/arch/arm/src/stm32/stm32f33xxx_dma.c
new file mode 100644
index 0000000000000000000000000000000000000000..af8601a0fb6d78a2d90c1a8b73a895fc6b6667b8
--- /dev/null
+++ b/arch/arm/src/stm32/stm32f33xxx_dma.c
@@ -0,0 +1,696 @@
+/****************************************************************************
+ * arch/arm/src/stm32/stm32f33xxx_dma.c
+ *
+ * Copyright (C) 2017 Gregory Nutt. All rights reserved.
+ * Authors: Gregory Nutt
+ * 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
+ ****************************************************************************/
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+
+#include "up_arch.h"
+#include "up_internal.h"
+#include "sched/sched.h"
+#include "chip.h"
+#include "stm32_dma.h"
+#include "stm32.h"
+
+#if defined(CONFIG_STM32_DMA1) && defined(CONFIG_STM32_STM32F33XX)
+
+#ifndef CONFIG_ARCH_DMA
+# warning "STM32 DMA enabled but CONFIG_ARCH_DMA disabled"
+#endif
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define DMA1_NCHANNELS 7
+#define DMA_NCHANNELS DMA1_NCHANNELS
+
+#ifndef CONFIG_DMA_PRI
+# define CONFIG_DMA_PRI NVIC_SYSH_PRIORITY_DEFAULT
+#endif
+
+/* Convert the DMA channel base address to the DMA register block address */
+
+#define DMA_BASE(ch) (ch & 0xfffffc00)
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+/* This structure descibes one DMA channel */
+
+struct stm32_dma_s
+{
+ uint8_t chan; /* DMA channel number (0-6) */
+ uint8_t irq; /* DMA channel IRQ number */
+ sem_t sem; /* Used to wait for DMA channel to become available */
+ uint32_t base; /* DMA register channel base address */
+ dma_callback_t callback; /* Callback invoked when the DMA completes */
+ void *arg; /* Argument passed to callback function */
+};
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/* This array describes the state of each DMA */
+
+static struct stm32_dma_s g_dma[DMA_NCHANNELS] =
+{
+ {
+ .chan = 0,
+ .irq = STM32_IRQ_DMA1CH1,
+ .base = STM32_DMA1_BASE + STM32_DMACHAN_OFFSET(0),
+ },
+ {
+ .chan = 1,
+ .irq = STM32_IRQ_DMA1CH2,
+ .base = STM32_DMA1_BASE + STM32_DMACHAN_OFFSET(1),
+ },
+ {
+ .chan = 2,
+ .irq = STM32_IRQ_DMA1CH3,
+ .base = STM32_DMA1_BASE + STM32_DMACHAN_OFFSET(2),
+ },
+ {
+ .chan = 3,
+ .irq = STM32_IRQ_DMA1CH4,
+ .base = STM32_DMA1_BASE + STM32_DMACHAN_OFFSET(3),
+ },
+ {
+ .chan = 4,
+ .irq = STM32_IRQ_DMA1CH5,
+ .base = STM32_DMA1_BASE + STM32_DMACHAN_OFFSET(4),
+ },
+ {
+ .chan = 5,
+ .irq = STM32_IRQ_DMA1CH6,
+ .base = STM32_DMA1_BASE + STM32_DMACHAN_OFFSET(5),
+ },
+ {
+ .chan = 6,
+ .irq = STM32_IRQ_DMA1CH7,
+ .base = STM32_DMA1_BASE + STM32_DMACHAN_OFFSET(6),
+ },
+};
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * DMA register access functions
+ ****************************************************************************/
+
+/* Get non-channel register from DMA1 or DMA2 */
+
+static inline uint32_t dmabase_getreg(struct stm32_dma_s *dmach, uint32_t offset)
+{
+ return getreg32(DMA_BASE(dmach->base) + offset);
+}
+
+/* Write to non-channel register in DMA1 or DMA2 */
+
+static inline void dmabase_putreg(struct stm32_dma_s *dmach, uint32_t offset, uint32_t value)
+{
+ putreg32(value, DMA_BASE(dmach->base) + offset);
+}
+
+/* Get channel register from DMA1 or DMA2 */
+
+static inline uint32_t dmachan_getreg(struct stm32_dma_s *dmach, uint32_t offset)
+{
+ return getreg32(dmach->base + offset);
+}
+
+/* Write to channel register in DMA1 or DMA2 */
+
+static inline void dmachan_putreg(struct stm32_dma_s *dmach, uint32_t offset, uint32_t value)
+{
+ putreg32(value, dmach->base + offset);
+}
+
+/************************************************************************************
+ * Name: stm32_dmatake() and stm32_dmagive()
+ *
+ * Description:
+ * Used to get exclusive access to a DMA channel.
+ *
+ ************************************************************************************/
+
+static void stm32_dmatake(FAR struct stm32_dma_s *dmach)
+{
+ /* Take the semaphore (perhaps waiting) */
+
+ while (sem_wait(&dmach->sem) != 0)
+ {
+ /* The only case that an error should occur here is if the wait was awakened
+ * by a signal.
+ */
+
+ ASSERT(errno == EINTR);
+ }
+}
+
+static inline void stm32_dmagive(FAR struct stm32_dma_s *dmach)
+{
+ (void)sem_post(&dmach->sem);
+}
+
+/************************************************************************************
+ * Name: stm32_dmachandisable
+ *
+ * Description:
+ * Disable the DMA channel
+ *
+ ************************************************************************************/
+
+static void stm32_dmachandisable(struct stm32_dma_s *dmach)
+{
+ uint32_t regval;
+
+ /* Disable all interrupts at the DMA controller */
+
+ regval = dmachan_getreg(dmach, STM32_DMACHAN_CCR_OFFSET);
+ regval &= ~DMA_CCR_ALLINTS;
+
+ /* Disable the DMA channel */
+
+ regval &= ~DMA_CCR_EN;
+ dmachan_putreg(dmach, STM32_DMACHAN_CCR_OFFSET, regval);
+
+ /* Clear pending channel interrupts */
+
+ dmabase_putreg(dmach, STM32_DMA_IFCR_OFFSET, DMA_ISR_CHAN_MASK(dmach->chan));
+}
+
+/************************************************************************************
+ * Name: stm32_dmainterrupt
+ *
+ * Description:
+ * DMA interrupt handler
+ *
+ ************************************************************************************/
+
+static int stm32_dmainterrupt(int irq, void *context, FAR void *arg)
+{
+ struct stm32_dma_s *dmach;
+ uint32_t isr;
+ int chndx = 0;
+
+ /* Get the channel structure from the interrupt number */
+
+ if (irq >= STM32_IRQ_DMA1CH1 && irq <= STM32_IRQ_DMA1CH7)
+ {
+ chndx = irq - STM32_IRQ_DMA1CH1;
+ }
+ else
+ {
+ PANIC();
+ }
+ dmach = &g_dma[chndx];
+
+ /* Get the interrupt status (for this channel only) */
+
+ isr = dmabase_getreg(dmach, STM32_DMA_ISR_OFFSET) & DMA_ISR_CHAN_MASK(dmach->chan);
+
+ /* Clear the interrupts we are handling */
+
+ dmabase_putreg(dmach, STM32_DMA_IFCR_OFFSET, isr);
+
+ /* Invoke the callback */
+
+ if (dmach->callback)
+ {
+ dmach->callback(dmach, isr >> DMA_ISR_CHAN_SHIFT(dmach->chan), dmach->arg);
+ }
+ return OK;
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: stm32_dmainitialize
+ *
+ * Description:
+ * Initialize the DMA subsystem
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+void weak_function up_dmainitialize(void)
+{
+ struct stm32_dma_s *dmach;
+ int chndx;
+
+ /* Initialize each DMA channel */
+
+ for (chndx = 0; chndx < DMA_NCHANNELS; chndx++)
+ {
+ dmach = &g_dma[chndx];
+ sem_init(&dmach->sem, 0, 1);
+
+ /* Attach DMA interrupt vectors */
+
+ (void)irq_attach(dmach->irq, stm32_dmainterrupt, NULL);
+
+ /* Disable the DMA channel */
+
+ stm32_dmachandisable(dmach);
+
+ /* Enable the IRQ at the NVIC (still disabled at the DMA controller) */
+
+ up_enable_irq(dmach->irq);
+
+#ifdef CONFIG_ARCH_IRQPRIO
+ /* Set the interrupt priority */
+
+ up_prioritize_irq(dmach->irq, CONFIG_DMA_PRI);
+#endif
+ }
+}
+
+/****************************************************************************
+ * Name: stm32_dmachannel
+ *
+ * Description:
+ * Allocate a DMA channel. This function gives the caller mutually
+ * exclusive access to the DMA channel specified by the 'chndx' argument.
+ * DMA channels are shared on the STM32: Devices sharing the same DMA
+ * channel cannot do DMA concurrently! See the DMACHAN_* definitions in
+ * stm32_dma.h.
+ *
+ * If the DMA channel is not available, then stm32_dmachannel() will wait
+ * until the holder of the channel relinquishes the channel by calling
+ * stm32_dmafree(). WARNING: If you have two devices sharing a DMA
+ * channel and the code never releases the channel, the stm32_dmachannel
+ * call for the other will hang forever in this function! Don't let your
+ * design do that!
+ *
+ * Hmm.. I suppose this interface could be extended to make a non-blocking
+ * version. Feel free to do that if that is what you need.
+ *
+ * Input parameter:
+ * chndx - Identifies the stream/channel resource. For the STM32 F1, this
+ * is simply the channel number as provided by the DMACHAN_* definitions
+ * in chip/stm32f10xxx_dma.h.
+ *
+ * Returned Value:
+ * Provided that 'chndx' is valid, this function ALWAYS returns a non-NULL,
+ * void* DMA channel handle. (If 'chndx' is invalid, the function will
+ * assert if debug is enabled or do something ignorant otherwise).
+ *
+ * Assumptions:
+ * - The caller does not hold he DMA channel.
+ * - The caller can wait for the DMA channel to be freed if it is no
+ * available.
+ *
+ ****************************************************************************/
+
+DMA_HANDLE stm32_dmachannel(unsigned int chndx)
+{
+ struct stm32_dma_s *dmach = &g_dma[chndx];
+
+ DEBUGASSERT(chndx < DMA_NCHANNELS);
+
+ /* Get exclusive access to the DMA channel -- OR wait until the channel
+ * is available if it is currently being used by another driver
+ */
+
+ stm32_dmatake(dmach);
+
+ /* The caller now has exclusive use of the DMA channel */
+
+ return (DMA_HANDLE)dmach;
+}
+
+/****************************************************************************
+ * Name: stm32_dmafree
+ *
+ * Description:
+ * Release a DMA channel. If another thread is waiting for this DMA channel
+ * in a call to stm32_dmachannel, then this function will re-assign the
+ * DMA channel to that thread and wake it up. NOTE: The 'handle' used
+ * in this argument must NEVER be used again until stm32_dmachannel() is
+ * called again to re-gain access to the channel.
+ *
+ * Returned Value:
+ * None
+ *
+ * Assumptions:
+ * - The caller holds the DMA channel.
+ * - There is no DMA in progress
+ *
+ ****************************************************************************/
+
+void stm32_dmafree(DMA_HANDLE handle)
+{
+ struct stm32_dma_s *dmach = (struct stm32_dma_s *)handle;
+
+ DEBUGASSERT(handle != NULL);
+
+ /* Release the channel */
+
+ stm32_dmagive(dmach);
+}
+
+/****************************************************************************
+ * Name: stm32_dmasetup
+ *
+ * Description:
+ * Configure DMA before using
+ *
+ ****************************************************************************/
+
+void stm32_dmasetup(DMA_HANDLE handle, uint32_t paddr, uint32_t maddr,
+ size_t ntransfers, uint32_t ccr)
+{
+ struct stm32_dma_s *dmach = (struct stm32_dma_s *)handle;
+ uint32_t regval;
+
+ /* Then DMA_CNDTRx register can only be modified if the DMA channel is
+ * disabled.
+ */
+
+ regval = dmachan_getreg(dmach, STM32_DMACHAN_CCR_OFFSET);
+ regval &= ~(DMA_CCR_EN);
+ dmachan_putreg(dmach, STM32_DMACHAN_CCR_OFFSET, regval);
+
+ /* Set the peripheral register address in the DMA_CPARx register. The data
+ * will be moved from/to this address to/from the memory after the
+ * peripheral event.
+ */
+
+ dmachan_putreg(dmach, STM32_DMACHAN_CPAR_OFFSET, paddr);
+
+ /* Set the memory address in the DMA_CMARx register. The data will be
+ * written to or read from this memory after the peripheral event.
+ */
+
+ dmachan_putreg(dmach, STM32_DMACHAN_CMAR_OFFSET, maddr);
+
+ /* Configure the total number of data to be transferred in the DMA_CNDTRx
+ * register. After each peripheral event, this value will be decremented.
+ */
+
+ dmachan_putreg(dmach, STM32_DMACHAN_CNDTR_OFFSET, ntransfers);
+
+ /* Configure the channel priority using the PL[1:0] bits in the DMA_CCRx
+ * register. Configure data transfer direction, circular mode, peripheral & memory
+ * incremented mode, peripheral & memory data size, and interrupt after
+ * half and/or full transfer in the DMA_CCRx register.
+ */
+
+ regval = dmachan_getreg(dmach, STM32_DMACHAN_CCR_OFFSET);
+ regval &= ~(DMA_CCR_MEM2MEM | DMA_CCR_PL_MASK | DMA_CCR_MSIZE_MASK |
+ DMA_CCR_PSIZE_MASK | DMA_CCR_MINC | DMA_CCR_PINC | DMA_CCR_CIRC |
+ DMA_CCR_DIR);
+ ccr &= (DMA_CCR_MEM2MEM | DMA_CCR_PL_MASK | DMA_CCR_MSIZE_MASK |
+ DMA_CCR_PSIZE_MASK | DMA_CCR_MINC | DMA_CCR_PINC | DMA_CCR_CIRC |
+ DMA_CCR_DIR);
+ regval |= ccr;
+ dmachan_putreg(dmach, STM32_DMACHAN_CCR_OFFSET, regval);
+}
+
+/****************************************************************************
+ * Name: stm32_dmastart
+ *
+ * Description:
+ * Start the DMA transfer
+ *
+ * Assumptions:
+ * - DMA handle allocated by stm32_dmachannel()
+ * - No DMA in progress
+ *
+ ****************************************************************************/
+
+void stm32_dmastart(DMA_HANDLE handle, dma_callback_t callback,
+ void *arg, bool half)
+{
+ struct stm32_dma_s *dmach = (struct stm32_dma_s *)handle;
+ uint32_t ccr;
+
+ DEBUGASSERT(handle != NULL);
+
+ /* Save the callback info. This will be invoked whent the DMA commpletes */
+
+ dmach->callback = callback;
+ dmach->arg = arg;
+
+ /* Activate the channel by setting the ENABLE bit in the DMA_CCRx register.
+ * As soon as the channel is enabled, it can serve any DMA request from the
+ * peripheral connected on the channel.
+ */
+
+ ccr = dmachan_getreg(dmach, STM32_DMACHAN_CCR_OFFSET);
+ ccr |= DMA_CCR_EN;
+
+ /* In normal mode, interrupt at either half or full completion. In circular mode,
+ * always interrupt on buffer wrap, and optionally interrupt at the halfway point.
+ */
+
+ if ((ccr & DMA_CCR_CIRC) == 0)
+ {
+ /* Once half of the bytes are transferred, the half-transfer flag (HTIF) is
+ * set and an interrupt is generated if the Half-Transfer Interrupt Enable
+ * bit (HTIE) is set. At the end of the transfer, the Transfer Complete Flag
+ * (TCIF) is set and an interrupt is generated if the Transfer Complete
+ * Interrupt Enable bit (TCIE) is set.
+ */
+
+ ccr |= (half ? (DMA_CCR_HTIE | DMA_CCR_TEIE) : (DMA_CCR_TCIE | DMA_CCR_TEIE));
+ }
+ else
+ {
+ /* In nonstop mode, when the transfer completes it immediately resets
+ * and starts again. The transfer-complete interrupt is thus always
+ * enabled, and the half-complete interrupt can be used in circular
+ * mode to determine when the buffer is half-full, or in double-buffered
+ * mode to determine when one of the two buffers is full.
+ */
+
+ ccr |= (half ? DMA_CCR_HTIE : 0) | DMA_CCR_TCIE | DMA_CCR_TEIE;
+ }
+
+ dmachan_putreg(dmach, STM32_DMACHAN_CCR_OFFSET, ccr);
+}
+
+/****************************************************************************
+ * Name: stm32_dmastop
+ *
+ * Description:
+ * Cancel the DMA. After stm32_dmastop() is called, the DMA channel is
+ * reset and stm32_dmasetup() must be called before stm32_dmastart() can be
+ * called again
+ *
+ * Assumptions:
+ * - DMA handle allocated by stm32_dmachannel()
+ *
+ ****************************************************************************/
+
+void stm32_dmastop(DMA_HANDLE handle)
+{
+ struct stm32_dma_s *dmach = (struct stm32_dma_s *)handle;
+ stm32_dmachandisable(dmach);
+}
+
+/****************************************************************************
+ * Name: stm32_dmaresidual
+ *
+ * Description:
+ * Returns the number of bytes remaining to be transferred
+ *
+ * Assumptions:
+ * - DMA handle allocated by stm32_dmachannel()
+ *
+ ****************************************************************************/
+
+size_t stm32_dmaresidual(DMA_HANDLE handle)
+{
+ struct stm32_dma_s *dmach = (struct stm32_dma_s *)handle;
+
+ return dmachan_getreg(dmach, STM32_DMACHAN_CNDTR_OFFSET);
+}
+
+/****************************************************************************
+ * Name: stm32_dmacapable
+ *
+ * Description:
+ * Check if the DMA controller can transfer data to/from given memory
+ * address. This depends on the internal connections in the ARM bus matrix
+ * of the processor. Note that this only applies to memory addresses, it
+ * will return false for any peripheral address.
+ *
+ * Returned value:
+ * True, if transfer is possible.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_STM32_DMACAPABLE
+bool stm32_dmacapable(uint32_t maddr, uint32_t count, uint32_t ccr)
+{
+ uint32_t transfer_size;
+ uint32_t mend;
+
+ /* Verify that the address conforms to the memory transfer size.
+ * Transfers to/from memory performed by the DMA controller are
+ * required to be aligned to their size.
+ *
+ * See ST RM0090 rev4, section 9.3.11
+ *
+ * Compute mend inline to avoid a possible non-constant integer
+ * multiply.
+ */
+
+ switch (ccr & DMA_CCR_MSIZE_MASK)
+ {
+ case DMA_CCR_MSIZE_8BITS:
+ transfer_size = 1;
+ mend = maddr + count - 1;
+ break;
+
+ case DMA_CCR_MSIZE_16BITS:
+ transfer_size = 2;
+ mend = maddr + (count << 1) - 1;
+ break;
+
+ case DMA_CCR_MSIZE_32BITS:
+ transfer_size = 4;
+ mend = maddr + (count << 2) - 1;
+ break;
+
+ default:
+ return false;
+ }
+
+ if ((maddr & (transfer_size - 1)) != 0)
+ {
+ return false;
+ }
+
+ /* Verify that the transfer is to a memory region that supports DMA. */
+
+ if ((maddr & STM32_REGION_MASK) != (mend & STM32_REGION_MASK))
+ {
+ return false;
+ }
+
+ switch (maddr & STM32_REGION_MASK)
+ {
+ case STM32_SRAM_BASE:
+ case STM32_CODE_BASE:
+ /* All RAM and flash is supported */
+
+ return true;
+
+ default:
+ /* Everything else is unsupported by DMA */
+
+ return false;
+ }
+}
+#endif
+
+/****************************************************************************
+ * Name: stm32_dmasample
+ *
+ * Description:
+ * Sample DMA register contents
+ *
+ * Assumptions:
+ * - DMA handle allocated by stm32_dmachannel()
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_DEBUG_DMA_INFO
+void stm32_dmasample(DMA_HANDLE handle, struct stm32_dmaregs_s *regs)
+{
+ struct stm32_dma_s *dmach = (struct stm32_dma_s *)handle;
+ irqstate_t flags;
+
+ flags = enter_critical_section();
+ regs->isr = dmabase_getreg(dmach, STM32_DMA_ISR_OFFSET);
+ regs->ccr = dmachan_getreg(dmach, STM32_DMACHAN_CCR_OFFSET);
+ regs->cndtr = dmachan_getreg(dmach, STM32_DMACHAN_CNDTR_OFFSET);
+ regs->cpar = dmachan_getreg(dmach, STM32_DMACHAN_CPAR_OFFSET);
+ regs->cmar = dmachan_getreg(dmach, STM32_DMACHAN_CMAR_OFFSET);
+ leave_critical_section(flags);
+}
+#endif
+
+/****************************************************************************
+ * Name: stm32_dmadump
+ *
+ * Description:
+ * Dump previously sampled DMA register contents
+ *
+ * Assumptions:
+ * - DMA handle allocated by stm32_dmachannel()
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_DEBUG_DMA_INFO
+void stm32_dmadump(DMA_HANDLE handle, const struct stm32_dmaregs_s *regs,
+ const char *msg)
+{
+ struct stm32_dma_s *dmach = (struct stm32_dma_s *)handle;
+ uint32_t dmabase = DMA_BASE(dmach->base);
+
+ dmainfo("DMA Registers: %s\n", msg);
+ dmainfo(" ISRC[%08x]: %08x\n", dmabase + STM32_DMA_ISR_OFFSET, regs->isr);
+ dmainfo(" CCR[%08x]: %08x\n", dmach->base + STM32_DMACHAN_CCR_OFFSET, regs->ccr);
+ dmainfo(" CNDTR[%08x]: %08x\n", dmach->base + STM32_DMACHAN_CNDTR_OFFSET, regs->cndtr);
+ dmainfo(" CPAR[%08x]: %08x\n", dmach->base + STM32_DMACHAN_CPAR_OFFSET, regs->cpar);
+ dmainfo(" CMAR[%08x]: %08x\n", dmach->base + STM32_DMACHAN_CMAR_OFFSET, regs->cmar);
+}
+#endif
+
+#endif /* CONFIG_STM32_DMA1 && CONFIG_STM32_STM32F33XX */
diff --git a/arch/arm/src/stm32/stm32f33xxx_rcc.c b/arch/arm/src/stm32/stm32f33xxx_rcc.c
index 82923a7ef869c6ac5e8a0aad660ba7078ca56e77..6254294f5e2f372f3307d3a7a1ec53475867c2f0 100644
--- a/arch/arm/src/stm32/stm32f33xxx_rcc.c
+++ b/arch/arm/src/stm32/stm32f33xxx_rcc.c
@@ -332,9 +332,7 @@ static inline void rcc_enableapb2(void)
#ifdef CONFIG_STM32_HRTIM1
/* HRTIM1 Timer clock enable */
-#ifdef CONFIG_STM32_FORCEPOWER
regval |= RCC_APB2ENR_HRTIM1EN;
-#endif
#endif
putreg32(regval, STM32_RCC_APB2ENR);
diff --git a/arch/arm/src/stm32/stm32f40xxx_i2c.c b/arch/arm/src/stm32/stm32f40xxx_i2c.c
index c0d1a2d6fd01b911746bb6cf985e3d54530b92bb..1eccabd4cd571f972255a48c0ff10ddb98736853 100644
--- a/arch/arm/src/stm32/stm32f40xxx_i2c.c
+++ b/arch/arm/src/stm32/stm32f40xxx_i2c.c
@@ -63,7 +63,6 @@
* - 1 x 10 bit addresses + 1 x 7 bit address (?)
* - plus the broadcast address (general call)
* - Multi-master support
- * - DMA (to get rid of too many CPU wake-ups and interventions)
* - Be ready for IPMI
*/
@@ -95,6 +94,7 @@
#include "stm32_rcc.h"
#include "stm32_i2c.h"
#include "stm32_waste.h"
+#include "stm32_dma.h"
/* At least one I2C peripheral must be enabled */
@@ -162,6 +162,21 @@
#define MKI2C_OUTPUT(p) (((p) & (GPIO_PORT_MASK | GPIO_PIN_MASK)) | I2C_OUTPUT)
+/* I2C DMA priority */
+
+#ifdef CONFIG_STM32_I2C_DMA
+
+# if defined(CONFIG_I2C_DMAPRIO)
+# if (CONFIG_I2C_DMAPRIO & ~DMA_SCR_PL_MASK) != 0
+# error "Illegal value for CONFIG_I2C_DMAPRIO"
+# endif
+# define I2C_DMA_PRIO CONFIG_I2C_DMAPRIO
+# else
+# define I2C_DMA_PRIO DMA_SCR_PRIMED
+# endif
+
+#endif
+
/* Debug ****************************************************************************/
/* I2C event trace logic. NOTE: trace uses the internal, non-standard, low-level
@@ -230,7 +245,6 @@ 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 *, void *); /* Interrupt handler */
uint32_t ev_irq; /* Event IRQ */
uint32_t er_irq; /* Error IRQ */
#endif
@@ -253,7 +267,7 @@ struct stm32_i2c_priv_s
struct i2c_msg_s *msgv; /* Message list */
uint8_t *ptr; /* Current message buffer */
uint32_t frequency; /* Current I2C frequency */
- int dcnt; /* Current message length */
+ volatile int dcnt; /* Current message length */
uint16_t flags; /* Current message flags */
bool check_addr_ACK; /* Flag to signal if on next interrupt address has ACKed */
uint8_t total_msg_len; /* Flag to signal a short read sequence */
@@ -270,6 +284,15 @@ struct stm32_i2c_priv_s
#endif
uint32_t status; /* End of transfer SR2|SR1 status */
+
+ /* I2C DMA support */
+
+#ifdef CONFIG_STM32_I2C_DMA
+ DMA_HANDLE txdma; /* TX DMA handle */
+ DMA_HANDLE rxdma; /* RX DMA handle */
+ uint8_t txch; /* TX DMA channel */
+ uint8_t rxch; /* RX DMA channel */
+#endif
};
/************************************************************************************
@@ -315,18 +338,10 @@ static inline uint32_t stm32_i2c_disablefsmc(FAR struct stm32_i2c_priv_s *priv);
static inline void stm32_i2c_enablefsmc(uint32_t ahbenr);
#endif /* I2C1_FSMC_CONFLICT */
-static int stm32_i2c_isr(struct stm32_i2c_priv_s * priv);
+static int stm32_i2c_isr_process(struct stm32_i2c_priv_s *priv);
#ifndef CONFIG_I2C_POLLED
-#ifdef CONFIG_STM32_I2C1
-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, FAR void *arg);
-#endif
-#ifdef CONFIG_STM32_I2C3
-static int stm32_i2c3_isr(int irq, void *context, FAR void *arg);
-#endif
+static int stm32_i2c_isr(int irq, void *context, FAR void *arg);
#endif /* !CONFIG_I2C_POLLED */
static int stm32_i2c_init(FAR struct stm32_i2c_priv_s *priv);
@@ -337,6 +352,13 @@ static int stm32_i2c_transfer(FAR struct i2c_master_s *dev, FAR struct i2c_msg_s
static int stm32_i2c_reset(FAR struct i2c_master_s *dev);
#endif
+/* DMA support */
+
+#ifdef CONFIG_STM32_I2C_DMA
+static void stm32_i2c_dmarxcallback(DMA_HANDLE handle, uint8_t status, void *arg);
+static void stm32_i2c_dmatxcallback(DMA_HANDLE handle, uint8_t status, void *arg);
+#endif
+
/************************************************************************************
* Private Data
************************************************************************************/
@@ -381,7 +403,6 @@ static const struct stm32_i2c_config_s stm32_i2c1_config =
.scl_pin = GPIO_I2C1_SCL,
.sda_pin = GPIO_I2C1_SDA,
#ifndef CONFIG_I2C_POLLED
- .isr = stm32_i2c1_isr,
.ev_irq = STM32_IRQ_I2C1EV,
.er_irq = STM32_IRQ_I2C1ER
#endif
@@ -398,7 +419,16 @@ static struct stm32_i2c_priv_s stm32_i2c1_priv =
.ptr = NULL,
.dcnt = 0,
.flags = 0,
- .status = 0
+ .status = 0,
+#ifdef CONFIG_STM32_I2C_DMA
+# ifndef CONFIG_STM32_DMA1
+# error "I2C1 enabled with DMA but corresponding DMA controller 1 is not enabled!"
+# endif
+ /* TODO: ch for i2c 1 and 2 could be *X_2 based on stream priority */
+
+ .rxch = DMAMAP_I2C1_RX,
+ .txch = DMAMAP_I2C1_TX,
+#endif
};
#endif
@@ -411,7 +441,6 @@ static const struct stm32_i2c_config_s stm32_i2c2_config =
.scl_pin = GPIO_I2C2_SCL,
.sda_pin = GPIO_I2C2_SDA,
#ifndef CONFIG_I2C_POLLED
- .isr = stm32_i2c2_isr,
.ev_irq = STM32_IRQ_I2C2EV,
.er_irq = STM32_IRQ_I2C2ER
#endif
@@ -428,7 +457,14 @@ static struct stm32_i2c_priv_s stm32_i2c2_priv =
.ptr = NULL,
.dcnt = 0,
.flags = 0,
- .status = 0
+ .status = 0,
+#ifdef CONFIG_STM32_I2C_DMA
+# ifndef CONFIG_STM32_DMA1
+# error "I2C2 enabled with DMA but corresponding DMA controller 1 is not enabled!"
+# endif
+ .rxch = DMAMAP_I2C2_RX,
+ .txch = DMAMAP_I2C2_TX,
+#endif
};
#endif
@@ -441,7 +477,6 @@ static const struct stm32_i2c_config_s stm32_i2c3_config =
.scl_pin = GPIO_I2C3_SCL,
.sda_pin = GPIO_I2C3_SDA,
#ifndef CONFIG_I2C_POLLED
- .isr = stm32_i2c3_isr,
.ev_irq = STM32_IRQ_I2C3EV,
.er_irq = STM32_IRQ_I2C3ER
#endif
@@ -458,7 +493,14 @@ static struct stm32_i2c_priv_s stm32_i2c3_priv =
.ptr = NULL,
.dcnt = 0,
.flags = 0,
- .status = 0
+ .status = 0,
+#ifdef CONFIG_STM32_I2C_DMA
+# ifndef CONFIG_STM32_DMA1
+# error "I2C3 enabled with DMA but corresponding DMA controller 1 is not enabled!"
+# endif
+ .rxch = DMAMAP_I2C3_RX,
+ .txch = DMAMAP_I2C3_TX,
+#endif
};
#endif
@@ -521,7 +563,7 @@ static inline void stm32_i2c_sem_wait(FAR struct stm32_i2c_priv_s *priv)
{
while (sem_wait(&priv->sem_excl) != 0)
{
- ASSERT(errno == EINTR);
+ DEBUGASSERT(errno == EINTR);
}
}
@@ -680,7 +722,7 @@ static inline int stm32_i2c_sem_waitdone(FAR struct stm32_i2c_priv_s *priv)
* reports that it is done.
*/
- stm32_i2c_isr(priv);
+ stm32_i2c_isr_process(priv);
}
/* Loop until the transfer is complete. */
@@ -1175,16 +1217,22 @@ static inline void stm32_i2c_enablefsmc(uint32_t ahbenr)
#endif /* I2C1_FSMC_CONFLICT */
/************************************************************************************
- * Name: stm32_i2c_isr
+ * Name: stm32_i2c_isr_process
*
* Description:
* Common Interrupt Service Routine
*
************************************************************************************/
-static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv)
+static int stm32_i2c_isr_process(struct stm32_i2c_priv_s *priv)
{
uint32_t status;
+#ifndef CONFIG_I2C_POLLED
+ uint32_t regval;
+#endif
+#ifdef CONFIG_STM32_I2C_DMA
+ uint16_t cr2;
+#endif
i2cinfo("I2C ISR called\n");
@@ -1201,6 +1249,15 @@ static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv)
priv->status = status;
+ /* Any new message should begin with "Start" condition
+ * Situation priv->msgc == 0 came from DMA RX handler and should be managed
+ */
+
+ if (priv->dcnt == -1 && priv->msgc != 0 && (status & I2C_SR1_SB) == 0)
+ {
+ return OK;
+ }
+
/* Check if this is a new transmission so to set up the
* trace table accordingly.
*/
@@ -1228,6 +1285,23 @@ static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv)
* stm32_i2c_sem_waitdone() waiting process.
*/
+#ifdef CONFIG_STM32_I2C_DMA
+ /* If ISR gets called (ex. polling mode) while DMA is still in
+ * progress, we should just return and let the DMA finish.
+ */
+
+ cr2 = stm32_i2c_getreg(priv, STM32_I2C_CR2_OFFSET);
+ if ((cr2 & I2C_CR2_DMAEN) != 0)
+ {
+#ifdef CONFIG_DEBUG_I2C_INFO
+ size_t left = stm32_dmaresidual(priv->rxdma);
+
+ i2cinfo("DMA in progress: %ld [bytes] remainining. Returning.\n", left);
+#endif
+ return OK;
+ }
+#endif
+
if (priv->dcnt == -1 && priv->msgc > 0)
{
i2cinfo("Switch to new message\n");
@@ -1439,9 +1513,16 @@ static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv)
status |= (stm32_i2c_getreg(priv, STM32_I2C_SR2_OFFSET) << 16);
- /* Send Stop */
+ /* Send Stop/Restart */
- stm32_i2c_sendstop(priv);
+ if (priv->msgc > 0)
+ {
+ stm32_i2c_sendstart(priv);
+ }
+ else
+ {
+ stm32_i2c_sendstop(priv);
+ }
i2cinfo("Address ACKed beginning data reception\n");
i2cinfo("short read N=1: programming stop bit\n");
@@ -1484,6 +1565,46 @@ static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv)
/* Trace */
stm32_i2c_traceevent(priv, I2CEVENT_ADDRESS_ACKED, 0);
+
+#ifdef CONFIG_STM32_I2C_DMA
+ /* DMA only when not doing a short read */
+
+ i2cinfo("Starting dma transfer and disabling interrupts\n");
+
+ /* The DMA must be initialized and enabled before the I2C data transfer.
+ * The DMAEN bit must be set in the I2C_CR2 register before the ADDR event.
+ */
+
+ stm32_dmasetup(priv->rxdma, priv->config->base+STM32_I2C_DR_OFFSET,
+ (uint32_t) priv->ptr, priv->dcnt,
+ DMA_SCR_DIR_P2M |
+ DMA_SCR_MSIZE_8BITS |
+ DMA_SCR_PSIZE_8BITS |
+ DMA_SCR_MINC |
+ I2C_DMA_PRIO);
+
+ /* Do not enable the ITBUFEN bit in the I2C_CR2 register if DMA is
+ * used.
+ */
+
+ stm32_i2c_modifyreg(priv, STM32_I2C_CR2_OFFSET, I2C_CR2_ITBUFEN, 0);
+
+#ifndef CONFIG_I2C_POLLED
+ /* Now let DMA do all the work, disable i2c interrupts */
+
+ regval = stm32_i2c_getreg(priv, STM32_I2C_CR2_OFFSET);
+ regval &= ~I2C_CR2_ALLINTS;
+ stm32_i2c_putreg(priv, STM32_I2C_CR2_OFFSET, regval);
+#endif
+
+ /* The user can generate a Stop condition in the DMA Transfer Complete
+ * interrupt routine if enabled. This will be done in the dma rx callback
+ * Start DMA.
+ */
+
+ stm32_dmastart(priv->rxdma, stm32_i2c_dmarxcallback, priv, false);
+ stm32_i2c_modifyreg(priv, STM32_I2C_CR2_OFFSET, 0, I2C_CR2_DMAEN);
+#endif
}
}
@@ -1520,19 +1641,67 @@ static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv)
if (priv->dcnt >= 1)
{
- /* Transmitting message. Send byte == write data into write register */
+#ifdef CONFIG_STM32_I2C_DMA
+ /* if DMA is enabled, only makes sense to make use of it for longer
+ than 1 B transfers.. */
- stm32_i2c_putreg(priv, STM32_I2C_DR_OFFSET, *priv->ptr++);
+ if (priv->dcnt > 1)
+ {
+ i2cinfo("Starting dma transfer and disabling interrupts\n");
- /* Decrease current message length */
+ /* The DMA must be initialized and enabled before the I2C data transfer.
+ * The DMAEN bit must be set in the I2C_CR2 register before the ADDR event.
+ */
- stm32_i2c_traceevent(priv, I2CEVENT_WRITE_TO_DR, priv->dcnt);
- priv->dcnt--;
+ stm32_dmasetup(priv->txdma, priv->config->base+STM32_I2C_DR_OFFSET,
+ (uint32_t) priv->ptr, priv->dcnt,
+ DMA_SCR_DIR_M2P |
+ DMA_SCR_MSIZE_8BITS |
+ DMA_SCR_PSIZE_8BITS |
+ DMA_SCR_MINC |
+ I2C_DMA_PRIO );
+
+ /* Do not enable the ITBUFEN bit in the I2C_CR2 register if DMA is
+ * used.
+ */
+
+ stm32_i2c_modifyreg(priv, STM32_I2C_CR2_OFFSET, I2C_CR2_ITBUFEN, 0);
+
+#ifndef CONFIG_I2C_POLLED
+ /* Now let DMA do all the work, disable i2c interrupts */
+
+ regval = stm32_i2c_getreg(priv, STM32_I2C_CR2_OFFSET);
+ regval &= ~I2C_CR2_ALLINTS;
+ stm32_i2c_putreg(priv, STM32_I2C_CR2_OFFSET, regval);
+#endif
+
+ /* In the interrupt routine after the EOT interrupt, disable DMA
+ * requests then wait for a BTF event before programming the Stop
+ * condition. To do this, we'll just call the ISR again in
+ * dma tx callback, in which point we fall into the msgc==0 case
+ * which ultimately sends the stop..TODO: but we don't explicitly
+ * wait for BTF bit being set...
+ * Start DMA.
+ */
+
+ stm32_i2c_modifyreg(priv, STM32_I2C_CR2_OFFSET, 0, I2C_CR2_DMAEN);
+ stm32_dmastart(priv->txdma, stm32_i2c_dmatxcallback, priv, false);
+ }
+ else
+#endif /* CONFIG_STM32_I2C_DMA */
+ {
+ /* Transmitting message. Send byte == write data into write register */
+ stm32_i2c_putreg(priv, STM32_I2C_DR_OFFSET, *priv->ptr++);
+
+ /* Decrease current message length */
+
+ stm32_i2c_traceevent(priv, I2CEVENT_WRITE_TO_DR, priv->dcnt);
+ priv->dcnt--;
+ }
}
else if (priv->dcnt == 0)
{
-
/* After last byte, check what to do based on next message flags */
if (priv->msgc == 0)
@@ -1663,7 +1832,17 @@ static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv)
{
i2cinfo("short read N=2: DR and SR full setting stop bit and reading twice\n");
- stm32_i2c_sendstop(priv);
+ /* Send Stop/Restart */
+
+ if (priv->msgc > 0)
+ {
+ stm32_i2c_sendstart(priv);
+ }
+ else
+ {
+ stm32_i2c_sendstop(priv);
+ }
+
*priv->ptr++ = stm32_i2c_getreg(priv, STM32_I2C_DR_OFFSET);
priv->dcnt--;
*priv->ptr++ = stm32_i2c_getreg(priv, STM32_I2C_DR_OFFSET);
@@ -1678,6 +1857,7 @@ static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv)
stm32_i2c_traceevent(priv, I2CEVENT_READ_2, 0);
}
+#ifndef CONFIG_STM32_I2C_DMA
/* Case total message length >= 3 */
else if (priv->dcnt >= 4 && priv->total_msg_len >= 3)
@@ -1739,9 +1919,16 @@ static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv)
stm32_i2c_traceevent(priv, I2CEVENT_READ_3, priv->dcnt);
- /* Program stop */
+ /* Program Stop/Restart */
- stm32_i2c_sendstop(priv);
+ if (priv->msgc > 0)
+ {
+ stm32_i2c_sendstart(priv);
+ }
+ else
+ {
+ stm32_i2c_sendstop(priv);
+ }
/* read dcnt = 2 */
@@ -1757,6 +1944,7 @@ static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv)
priv->dcnt = -1;
}
+#endif /* CONFIG_STM32_I2C_DMA */
/* Error handling for read mode */
@@ -1765,7 +1953,8 @@ static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv)
i2cinfo("I2C read mode no correct state detected\n");
i2cinfo(" state %i, dcnt=%i\n", status, priv->dcnt);
- /* set condition to terminate ISR and wake waiting thread */
+ /* Set condition to terminate ISR and wake waiting thread */
+
priv->dcnt = -1;
priv->msgc = 0;
stm32_i2c_traceevent(priv, I2CEVENT_READ_ERROR, 0);
@@ -1804,9 +1993,9 @@ static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv)
else
{
- #ifdef CONFIG_I2C_POLLED
+#ifdef CONFIG_I2C_POLLED
stm32_i2c_traceevent(priv, I2CEVENT_POLL_DEV_NOT_RDY, 0);
- #else
+#else
/* Read rest of the state */
status |= (stm32_i2c_getreg(priv, STM32_I2C_SR2_OFFSET) << 16);
@@ -1814,12 +2003,12 @@ static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv)
i2cinfo(" No correct state detected(start bit, read or write) \n");
i2cinfo(" state %i\n", status);
- /* set condition to terminate ISR and wake waiting thread */
+ /* Set condition to terminate ISR and wake waiting thread */
priv->dcnt = -1;
priv->msgc = 0;
stm32_i2c_traceevent(priv, I2CEVENT_STATE_ERROR, 0);
- #endif
+#endif
}
/* Messages handling(2/2)
@@ -1842,12 +2031,11 @@ static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv)
priv->msgv = NULL;
- #ifdef CONFIG_I2C_POLLED
+#ifdef CONFIG_I2C_POLLED
priv->intstate = INTSTATE_DONE;
- #else
+#else
/* Clear all interrupts */
- uint32_t regval;
regval = stm32_i2c_getreg(priv, STM32_I2C_CR2_OFFSET);
regval &= ~I2C_CR2_ALLINTS;
stm32_i2c_putreg(priv, STM32_I2C_CR2_OFFSET, regval);
@@ -1863,62 +2051,118 @@ static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv)
sem_post(&priv->sem_isr);
priv->intstate = INTSTATE_DONE;
}
- #endif
+#endif
}
return OK;
}
/************************************************************************************
- * Name: stm32_i2c1_isr
+ * Name: stm32_i2c_isr
*
* Description:
- * I2C1 interrupt service routine
+ * Common I2C interrupt service routine
*
************************************************************************************/
#ifndef CONFIG_I2C_POLLED
-#ifdef CONFIG_STM32_I2C1
-static int stm32_i2c1_isr(int irq, void *context, FAR void *arg)
+static int stm32_i2c_isr(int irq, void *context, FAR void *arg)
{
- return stm32_i2c_isr(&stm32_i2c1_priv);
+ struct stm32_i2c_priv_s *priv = (struct stm32_i2c_priv_s *)arg;
+
+ DEBUGASSERT(priv != NULL);
+ return stm32_i2c_isr_process(priv);
}
#endif
-/************************************************************************************
- * Name: stm32_i2c2_isr
+/*****************************************************************************
+ * Name: stm32_i2c_dmarxcallback
*
* Description:
- * I2C2 interrupt service routine
+ * Called when the RX DMA completes
*
- ************************************************************************************/
+ *****************************************************************************/
-#ifdef CONFIG_STM32_I2C2
-static int stm32_i2c2_isr(int irq, void *context, FAR void *arg)
+#ifdef CONFIG_STM32_I2C_DMA
+static void stm32_i2c_dmarxcallback(DMA_HANDLE handle, uint8_t status, void *arg)
{
- return stm32_i2c_isr(&stm32_i2c2_priv);
-}
+#ifndef CONFIG_I2C_POLLED
+ uint32_t regval;
#endif
-/************************************************************************************
- * Name: stm32_i2c3_isr
+ i2cinfo("DMA rx callback, status = %d \n", status);
+
+ FAR struct stm32_i2c_priv_s *priv = (FAR struct stm32_i2c_priv_s *)arg;
+
+ priv->dcnt = -1;
+
+ /* The user can generate a Stop condition in the DMA Transfer Complete
+ * interrupt routine if enabled.
+ */
+
+ if (priv->msgc > 0)
+ {
+ stm32_i2c_sendstart(priv);
+ }
+ else
+ {
+ stm32_i2c_sendstop(priv);
+ }
+
+ /* Let the I2C periph know to stop DMA transfers, also is used by ISR to check
+ * if DMA is done.
+ */
+
+ stm32_i2c_modifyreg(priv, STM32_I2C_CR2_OFFSET, I2C_CR2_DMAEN, 0);
+
+#ifndef CONFIG_I2C_POLLED
+ /* Re-enable interrupts */
+
+ regval = stm32_i2c_getreg(priv, STM32_I2C_CR2_OFFSET);
+ regval |= (I2C_CR2_ITERREN | I2C_CR2_ITEVFEN);
+ stm32_i2c_putreg(priv, STM32_I2C_CR2_OFFSET, regval);
+#endif
+
+ /* let the ISR routine take care of shutting down or switching to next msg */
+
+ stm32_i2c_isr_process(priv);
+}
+#endif /* ifdef CONFIG_STM32_I2C_DMA */
+
+/*****************************************************************************
+ * Name: stm32_i2c_dmarxcallback
*
* Description:
- * I2C2 interrupt service routine
+ * Called when the RX DMA completes
*
- ************************************************************************************/
+ *****************************************************************************/
-#ifdef CONFIG_STM32_I2C3
-static int stm32_i2c3_isr(int irq, void *context, FAR void *arg)
+#ifdef CONFIG_STM32_I2C_DMA
+static void stm32_i2c_dmatxcallback(DMA_HANDLE handle, uint8_t status, void *arg)
{
- return stm32_i2c_isr(&stm32_i2c3_priv);
-}
-#endif
+#ifndef CONFIG_I2C_POLLED
+ uint32_t regval;
#endif
-/************************************************************************************
- * Private Initialization and Deinitialization
- ************************************************************************************/
+ i2cinfo("DMA tx callback, status = %d \n", status);
+
+ FAR struct stm32_i2c_priv_s *priv = (FAR struct stm32_i2c_priv_s *)arg;
+
+ priv->dcnt = 0;
+
+ /* In the interrupt routine after the EOT interrupt, disable DMA requests */
+
+ stm32_i2c_modifyreg(priv, STM32_I2C_CR2_OFFSET, I2C_CR2_DMAEN, 0);
+
+#ifndef CONFIG_I2C_POLLED
+ /* re-enable interrupts */
+
+ regval = stm32_i2c_getreg(priv, STM32_I2C_CR2_OFFSET);
+ regval |= (I2C_CR2_ITERREN | I2C_CR2_ITEVFEN);
+ stm32_i2c_putreg(priv, STM32_I2C_CR2_OFFSET, regval);
+#endif
+}
+#endif /* ifdef CONFIG_STM32_I2C_DMA */
/************************************************************************************
* Name: stm32_i2c_init
@@ -1954,8 +2198,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, NULL);
- irq_attach(priv->config->er_irq, priv->config->isr, NULL);
+ irq_attach(priv->config->ev_irq, stm32_i2c_isr, priv);
+ irq_attach(priv->config->er_irq, stm32_i2c_isr, priv);
up_enable_irq(priv->config->ev_irq);
up_enable_irq(priv->config->er_irq);
#endif
@@ -1972,6 +2216,15 @@ static int stm32_i2c_init(FAR struct stm32_i2c_priv_s *priv)
stm32_i2c_setclock(priv, 100000);
+#ifdef CONFIG_STM32_I2C_DMA
+ /* If, in the I2C_CR2 register, the LAST bit is set, I2C automatically
+ * sends a NACK after the next byte following EOT_1.
+ * Clear DMA en just in case.
+ */
+
+ stm32_i2c_modifyreg(priv, STM32_I2C_CR2_OFFSET, I2C_CR2_DMAEN, I2C_CR2_LAST);
+#endif
+
/* Enable I2C */
stm32_i2c_putreg(priv, STM32_I2C_CR1_OFFSET, I2C_CR1_PE);
@@ -1991,6 +2244,7 @@ static int stm32_i2c_deinit(FAR struct stm32_i2c_priv_s *priv)
/* Disable I2C */
stm32_i2c_putreg(priv, STM32_I2C_CR1_OFFSET, 0);
+ stm32_i2c_putreg(priv, STM32_I2C_CR2_OFFSET, 0);
/* Unconfigure GPIO pins */
@@ -2006,6 +2260,13 @@ static int stm32_i2c_deinit(FAR struct stm32_i2c_priv_s *priv)
irq_detach(priv->config->er_irq);
#endif
+#ifdef CONFIG_STM32_I2C_DMA
+ /* Disable DMA */
+
+ stm32_dmastop(priv->txdma);
+ stm32_dmastop(priv->rxdma);
+#endif
+
/* Disable clocking */
modifyreg32(STM32_RCC_APB1ENR, priv->config->clk_bit, 0);
@@ -2035,7 +2296,15 @@ static int stm32_i2c_transfer(FAR struct i2c_master_s *dev, FAR struct i2c_msg_s
#endif
int ret = 0;
- ASSERT(count);
+ DEBUGASSERT(count);
+
+#ifdef CONFIG_STM32_I2C_DMA
+ /* stop DMA just in case */
+
+ stm32_i2c_modifyreg(priv, STM32_I2C_CR2_OFFSET, I2C_CR2_DMAEN, 0);
+ stm32_dmastop(priv->rxdma);
+ stm32_dmastop(priv->txdma);
+#endif
#ifdef I2C1_FSMC_CONFLICT
/* Disable FSMC that shares a pin with I2C1 (LBAR) */
@@ -2246,11 +2515,11 @@ static int stm32_i2c_reset(FAR struct i2c_master_s *dev)
uint32_t frequency;
int ret = ERROR;
- ASSERT(dev);
+ DEBUGASSERT(dev);
/* Our caller must own a ref */
- ASSERT(priv->refs > 0);
+ DEBUGASSERT(priv->refs > 0);
/* Lock out other clients */
@@ -2412,6 +2681,19 @@ FAR struct i2c_master_s *stm32_i2cbus_initialize(int port)
{
stm32_i2c_sem_init(priv);
stm32_i2c_init(priv);
+
+#ifdef CONFIG_STM32_I2C_DMA
+ /* Get DMA channels. NOTE: stm32_dmachannel() will always assign the DMA channel.
+ * if the channel is not available, then stm32_dmachannel() will block and wait
+ * until the channel becomes available. WARNING: If you have another device sharing
+ * a DMA channel with SPI and the code never releases that channel, then the call
+ * to stm32_dmachannel() will hang forever in this function! Don't let your
+ * design do that!
+ */
+ priv->rxdma = stm32_dmachannel(priv->rxch);
+ priv->txdma = stm32_dmachannel(priv->txch);
+ DEBUGASSERT(priv->rxdma && priv->txdma);
+#endif /* #ifdef CONFIG_STM32_I2C_DMA */
}
leave_critical_section(flags);
@@ -2431,7 +2713,7 @@ int stm32_i2cbus_uninitialize(FAR struct i2c_master_s *dev)
FAR struct stm32_i2c_priv_s *priv = (struct stm32_i2c_priv_s *)dev;
irqstate_t flags;
- ASSERT(dev);
+ DEBUGASSERT(dev);
/* Decrement reference count and check for underflow */
@@ -2454,6 +2736,11 @@ int stm32_i2cbus_uninitialize(FAR struct i2c_master_s *dev)
stm32_i2c_deinit(priv);
+#ifdef CONFIG_STM32_I2C_DMA
+ stm32_dmafree(priv->rxdma);
+ stm32_dmafree(priv->txdma);
+#endif
+
/* Release unused resources */
stm32_i2c_sem_destroy(priv);
diff --git a/arch/arm/src/stm32/stm32f40xxx_rcc.c b/arch/arm/src/stm32/stm32f40xxx_rcc.c
index adda863ccaee96969f0ad2c8936bc77007e3cb8a..dfed9d8fceac07b7812196b4f7e22cf8f24635aa 100644
--- a/arch/arm/src/stm32/stm32f40xxx_rcc.c
+++ b/arch/arm/src/stm32/stm32f40xxx_rcc.c
@@ -215,10 +215,15 @@ static inline void rcc_enableahb1(void)
#endif
#ifdef CONFIG_STM32_OTGHS
- /* USB OTG HS */
+#ifdef BOARD_ENABLE_USBOTG_HSULPI
+ /* Enable clocking for USB OTG HS and external PHY */
- regval |= RCC_AHB1ENR_OTGHSEN;
+ regval |= (RCC_AHB1ENR_OTGHSEN | RCC_AHB1ENR_OTGHSULPIEN);
+#else
+ /* Enable only clocking for USB OTG HS */
+ regval |= RCC_AHB1ENR_OTGHSEN;
+#endif
#endif /* CONFIG_STM32_OTGHS */
#ifdef CONFIG_STM32_DMA2D
diff --git a/arch/arm/src/stm32/stm32f40xxx_rtcc.c b/arch/arm/src/stm32/stm32f40xxx_rtcc.c
index 4e8cfc773be597c0450b439fb7d83ab061d13c0a..e15c995a6cf4e627e484f7da18540c5d2563879c 100644
--- a/arch/arm/src/stm32/stm32f40xxx_rtcc.c
+++ b/arch/arm/src/stm32/stm32f40xxx_rtcc.c
@@ -894,7 +894,7 @@ int up_rtc_initialize(void)
stm32_pwr_enablebkp(true);
- if (regval != RTC_MAGIC)
+ if (regval != RTC_MAGIC && regval != RTC_MAGIC_TIME_SET)
{
/* Some boards do not have the external 32khz oscillator installed,
* for those boards we must fallback to the crummy internal RC clock
@@ -1011,7 +1011,7 @@ int up_rtc_initialize(void)
* has been writing to to back-up date register DR0.
*/
- if (regval != RTC_MAGIC)
+ if (regval != RTC_MAGIC && regval != RTC_MAGIC_TIME_SET)
{
rtcinfo("Do setup\n");
@@ -1287,6 +1287,15 @@ int stm32_rtc_setdatetime(FAR const struct tm *tp)
ret = rtc_synchwait();
}
+ /* Remember that the RTC is initialized and had its time set. */
+
+ if (getreg32(RTC_MAGIC_REG) != RTC_MAGIC_TIME_SET)
+ {
+ stm32_pwr_enablebkp(true);
+ putreg32(RTC_MAGIC_TIME_SET, RTC_MAGIC_REG);
+ stm32_pwr_enablebkp(false);
+ }
+
/* Re-enable the write protection for RTC registers */
rtc_wprlock();
@@ -1345,7 +1354,7 @@ int stm32_rtc_setalarm(FAR struct alm_setalarm_s *alminfo)
ASSERT(alminfo != NULL);
DEBUGASSERT(RTC_ALARM_LAST > alminfo->as_id);
- /* Make sure the the alarm interrupt is enabled at the NVIC */
+ /* Make sure the alarm interrupt is enabled at the NVIC */
rtc_enable_alarm();
@@ -1362,7 +1371,7 @@ int stm32_rtc_setalarm(FAR struct alm_setalarm_s *alminfo)
(rtc_bin2bcd(alminfo->as_time.tm_min) << RTC_ALRMR_MNU_SHIFT) |
(rtc_bin2bcd(alminfo->as_time.tm_hour) << RTC_ALRMR_HU_SHIFT) |
(rtc_bin2bcd(alminfo->as_time.tm_mday) << RTC_ALRMR_DU_SHIFT);
-
+
/* Set the alarm in hardware and enable interrupts from the RTC */
switch (alminfo->as_id)
diff --git a/arch/arm/src/stm32/stm32l15xxx_rcc.c b/arch/arm/src/stm32/stm32l15xxx_rcc.c
index 51a163d99a1a4a9f712b702eb65821a49a1e613d..8640934e9903cbc18d89c388161091bfd0260c32 100644
--- a/arch/arm/src/stm32/stm32l15xxx_rcc.c
+++ b/arch/arm/src/stm32/stm32l15xxx_rcc.c
@@ -480,7 +480,11 @@ static inline bool stm32_rcc_enablehse(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);
@@ -524,6 +528,8 @@ static void stm32_stdclockconfig(void)
#if defined(CONFIG_RTC_HSECLOCK) || defined(CONFIG_LCD_HSECLOCK)
uint16_t pwrcr;
#endif
+ uint32_t pwr_vos;
+ bool flash_1ws;
/* Enable PWR clock from APB1 to give access to PWR_CR register */
@@ -537,12 +543,39 @@ static void stm32_stdclockconfig(void)
* Range 1: PLLVCO up to 96MHz in range 1 (1.8V)
* Range 2: PLLVCO up to 48MHz in range 2 (1.5V) (default)
* Range 3: PLLVCO up to 24MHz in range 3 (1.2V)
+ *
+ * Range 1: SYSCLK up to 32Mhz
+ * Range 2: SYSCLK up to 16Mhz
+ * Range 3: SYSCLK up to 4.2Mhz
+ *
+ * Range 1: Flash 1WS if SYSCLK > 16Mhz
+ * Range 2: Flash 1WS if SYSCLK > 8Mhz
+ * Range 3: Flash 1WS if SYSCLK > 2.1Mhz
*/
-#if STM32_PLL_FREQUENCY > 48000000
- stm32_pwr_setvos(PWR_CR_VOS_SCALE_1);
+ pwr_vos = PWR_CR_VOS_SCALE_2;
+ flash_1ws = false;
+
+#ifdef STM32_PLL_FREQUENCY
+ if (STM32_PLL_FREQUENCY > 48000000)
+ {
+ pwr_vos = PWR_CR_VOS_SCALE_1;
+ }
#endif
+ if (STM32_SYSCLK_FREQUENCY > 16000000)
+ {
+ pwr_vos = PWR_CR_VOS_SCALE_1;
+ }
+
+ if ((pwr_vos == PWR_CR_VOS_SCALE_1 && STM32_SYSCLK_FREQUENCY > 16000000) ||
+ (pwr_vos == PWR_CR_VOS_SCALE_2 && STM32_SYSCLK_FREQUENCY > 8000000))
+ {
+ flash_1ws = true;
+ }
+
+ stm32_pwr_setvos(pwr_vos);
+
#if defined(CONFIG_RTC_HSECLOCK) || defined(CONFIG_LCD_HSECLOCK)
/* If RTC / LCD selects HSE as clock source, the RTC prescaler
* needs to be set before HSEON bit is set.
@@ -579,12 +612,11 @@ static void stm32_stdclockconfig(void)
#endif
- /* Enable the source clock for the PLL (via HSE or HSI), HSE, and HSI.
- * NOTE that only PLL, HSE, or HSI are supported for the system clock
- * in this implementation
- */
+ /* Enable the source clock for the PLL (via HSE or HSI), HSE, and HSI. */
+
+#if (STM32_SYSCLK_SW == RCC_CFGR_SW_HSE) || \
+ ((STM32_SYSCLK_SW == RCC_CFGR_SW_PLL) && (STM32_CFGR_PLLSRC == RCC_CFGR_PLLSRC))
-#if (STM32_CFGR_PLLSRC == RCC_CFGR_PLLSRC) || (STM32_SYSCLK_SW == RCC_CFGR_SW_HSE)
/* The PLL is using the HSE, or the HSE is the system clock. In either
* case, we need to enable HSE clocking.
*/
@@ -599,7 +631,9 @@ static void stm32_stdclockconfig(void)
return;
}
-#elif (STM32_CFGR_PLLSRC == 0) || (STM32_SYSCLK_SW == RCC_CFGR_SW_HSI)
+#elif (STM32_SYSCLK_SW == RCC_CFGR_SW_HSI) || \
+ ((STM32_SYSCLK_SW == RCC_CFGR_SW_PLL) && STM32_CFGR_PLLSRC == 0)
+
/* The PLL is using the HSI, or the HSI is the system clock. In either
* case, we need to enable HSI clocking.
*/
@@ -616,6 +650,8 @@ static void stm32_stdclockconfig(void)
#endif
+#if (STM32_SYSCLK_SW != RCC_CFGR_SW_MSI)
+
/* Increasing the CPU frequency (in the same voltage range):
*
* After reset, the used clock is the MSI (2 MHz) with 0 WS configured in the
@@ -643,7 +679,15 @@ static void stm32_stdclockconfig(void)
regval |= FLASH_ACR_ACC64; /* 64-bit access mode */
putreg32(regval, STM32_FLASH_ACR);
- regval |= FLASH_ACR_LATENCY; /* One wait state */
+ if (flash_1ws)
+ {
+ regval |= FLASH_ACR_LATENCY; /* One wait state */
+ }
+ else
+ {
+ regval &= ~FLASH_ACR_LATENCY; /* Zero wait state */
+ }
+
putreg32(regval, STM32_FLASH_ACR);
/* Enable FLASH prefetch */
@@ -651,6 +695,8 @@ static void stm32_stdclockconfig(void)
regval |= FLASH_ACR_PRFTEN;
putreg32(regval, STM32_FLASH_ACR);
+#endif /* STM32_SYSCLK_SW != RCC_CFGR_SW_MSI */
+
/* Set the HCLK source/divider */
regval = getreg32(STM32_RCC_CFGR);
diff --git a/arch/arm/src/stm32f0/Kconfig b/arch/arm/src/stm32f0/Kconfig
new file mode 100644
index 0000000000000000000000000000000000000000..a330dda62499b00e73aa07df4e83231f810e5abd
--- /dev/null
+++ b/arch/arm/src/stm32f0/Kconfig
@@ -0,0 +1,1482 @@
+#
+# For a description of the syntax of this configuration file,
+# see the file kconfig-language.txt in the NuttX tools repository.
+#
+
+comment "STM32F0xx Configuration Options"
+
+choice
+ prompt "ST STM32F0XX Chip Selection"
+ default ARCH_CHIP_STM32F051R8
+ depends on ARCH_CHIP_STM32F0
+
+config ARCH_CHIP_STM32F030C6
+ bool "STM32F030C6"
+ select STM32F0_STM32F03X
+ select STM32F0_VALUELINE
+
+config ARCH_CHIP_STM32F030C8
+ bool "STM32F030C8"
+ select STM32F0_STM32F03X
+ select STM32F0_VALUELINE
+
+config ARCH_CHIP_STM32F030CC
+ bool "STM32F030CC"
+ select STM32F0_STM32F03X
+ select STM32F0_VALUELINE
+
+config ARCH_CHIP_STM32F030F4
+ bool "STM32F030F4"
+ select STM32F0_STM32F03X
+ select STM32F0_VALUELINE
+
+config ARCH_CHIP_STM32F030K6
+ bool "STM32F030K6"
+ select STM32F0_STM32F03X
+ select STM32F0_VALUELINE
+
+config ARCH_CHIP_STM32F030R8
+ bool "STM32F030R8"
+ select STM32F0_STM32F03X
+ select STM32F0_VALUELINE
+
+config ARCH_CHIP_STM32F030RC
+ bool "STM32F030RC"
+ select STM32F0_STM32F03X
+ select STM32F0_VALUELINE
+
+config ARCH_CHIP_STM32F031C4
+ bool "STM32F031C4"
+ select STM32F0_STM32F03X
+ select STM32F0_ACCESSLINE
+
+config ARCH_CHIP_STM32F031C6
+ bool "STM32F031C6"
+ select STM32F0_STM32F03X
+ select STM32F0_ACCESSLINE
+
+config ARCH_CHIP_STM32F031E6
+ bool "STM32F031E6"
+ select STM32F0_STM32F03X
+ select STM32F0_ACCESSLINE
+
+config ARCH_CHIP_STM32F031F4
+ bool "STM32F031F4"
+ select STM32F0_STM32F03X
+ select STM32F0_ACCESSLINE
+
+config ARCH_CHIP_STM32F031F6
+ bool "STM32F031F6"
+ select STM32F0_STM32F03X
+ select STM32F0_ACCESSLINE
+
+config ARCH_CHIP_STM32F031G4
+ bool "STM32F031G4"
+ select STM32F0_STM32F03X
+ select STM32F0_ACCESSLINE
+
+config ARCH_CHIP_STM32F031G6
+ bool "STM32F031G6"
+ select STM32F0_STM32F03X
+ select STM32F0_ACCESSLINE
+
+config ARCH_CHIP_STM32F031K4
+ bool "STM32F031K4"
+ select STM32F0_STM32F03X
+ select STM32F0_ACCESSLINE
+
+config ARCH_CHIP_STM32F031K6
+ bool "STM32F031K6"
+ select STM32F0_STM32F03X
+ select STM32F0_ACCESSLINE
+
+config ARCH_CHIP_STM32F038C6
+ bool "STM32F038C6"
+ select STM32F0_STM32F03X
+ select STM32F0_LOWVOLTLINE
+
+config ARCH_CHIP_STM32F038E6
+ bool "STM32F038E6"
+ select STM32F0_STM32F03X
+ select STM32F0_LOWVOLTLINE
+
+config ARCH_CHIP_STM32F038F6
+ bool "STM32F038F6"
+ select STM32F0_STM32F03X
+ select STM32F0_LOWVOLTLINE
+
+config ARCH_CHIP_STM32F038G6
+ bool "STM32F038G6"
+ select STM32F0_STM32F03X
+ select STM32F0_LOWVOLTLINE
+
+config ARCH_CHIP_STM32F038K6
+ bool "STM32F038K6"
+ select STM32F0_STM32F03X
+ select STM32F0_LOWVOLTLINE
+
+config ARCH_CHIP_STM32F042C4
+ bool "STM32F042C4"
+ select STM32F0_STM32F04X
+ select STM32F0_USBLINE
+
+config ARCH_CHIP_STM32F042C6
+ bool "STM32F042C6"
+ select STM32F0_STM32F04X
+ select STM32F0_USBLINE
+
+config ARCH_CHIP_STM32F042F4
+ bool "STM32F042F4"
+ select STM32F0_STM32F04X
+ select STM32F0_USBLINE
+
+config ARCH_CHIP_STM32F042F6
+ bool "STM32F042F6"
+ select STM32F0_STM32F04X
+ select STM32F0_USBLINE
+
+config ARCH_CHIP_STM32F042G4
+ bool "STM32F042G4"
+ select STM32F0_STM32F04X
+ select STM32F0_USBLINE
+
+config ARCH_CHIP_STM32F042G6
+ bool "STM32F042G6"
+ select STM32F0_STM32F04X
+ select STM32F0_USBLINE
+
+config ARCH_CHIP_STM32F042K4
+ bool "STM32F042K4"
+ select STM32F0_STM32F04X
+ select STM32F0_USBLINE
+
+config ARCH_CHIP_STM32F042K6
+ bool "STM32F042K6"
+ select STM32F0_STM32F04X
+ select STM32F0_USBLINE
+
+config ARCH_CHIP_STM32F042T6
+ bool "STM32F042T6"
+ select STM32F0_STM32F04X
+ select STM32F0_USBLINE
+
+config ARCH_CHIP_STM32F048C6
+ bool "STM32F048C6"
+ select STM32F0_STM32F04X
+ select STM32F0_LOWVOLTLINE
+
+config ARCH_CHIP_STM32F048G6
+ bool "STM32F048G6"
+ select STM32F0_STM32F04X
+ select STM32F0_LOWVOLTLINE
+
+config ARCH_CHIP_STM32F048T6
+ bool "STM32F048T6"
+ select STM32F0_STM32F04X
+ select STM32F0_LOWVOLTLINE
+
+config ARCH_CHIP_STM32F051C4
+ bool "STM32F051C4"
+ select STM32F0_STM32F05X
+ select STM32F0_ACCESSLINE
+
+config ARCH_CHIP_STM32F051C6
+ bool "STM32F051C6"
+ select STM32F0_STM32F05X
+ select STM32F0_ACCESSLINE
+
+config ARCH_CHIP_STM32F051C8
+ bool "STM32F051C8"
+ select STM32F0_STM32F05X
+ select STM32F0_ACCESSLINE
+
+config ARCH_CHIP_STM32F051K4
+ bool "STM32F051K4"
+ select STM32F0_STM32F05X
+ select STM32F0_ACCESSLINE
+
+config ARCH_CHIP_STM32F051K6
+ bool "STM32F051K6"
+ select STM32F0_STM32F05X
+ select STM32F0_ACCESSLINE
+
+config ARCH_CHIP_STM32F051K8
+ bool "STM32F051K8"
+ select STM32F0_STM32F05X
+ select STM32F0_ACCESSLINE
+
+config ARCH_CHIP_STM32F051R4
+ bool "STM32F051R4"
+ select STM32F0_STM32F05X
+ select STM32F0_ACCESSLINE
+
+config ARCH_CHIP_STM32F051R6
+ bool "STM32F051R6"
+ select STM32F0_STM32F05X
+ select STM32F0_ACCESSLINE
+
+config ARCH_CHIP_STM32F051R8
+ bool "STM32F051R8"
+ select STM32F0_STM32F05X
+ select STM32F0_ACCESSLINE
+
+config ARCH_CHIP_STM32F051T8
+ bool "STM32F051T8"
+ select STM32F0_STM32F05X
+ select STM32F0_ACCESSLINE
+
+config ARCH_CHIP_STM32F058C8
+ bool "STM32F058C8"
+ select STM32F0_STM32F05X
+ select STM32F0_LOWVOLTLINE
+
+config ARCH_CHIP_STM32F058R8
+ bool "STM32F058R8"
+ select STM32F0_STM32F05X
+ select STM32F0_LOWVOLTLINE
+
+config ARCH_CHIP_STM32F058T8
+ bool "STM32F058T8"
+ select STM32F0_STM32F05X
+ select STM32F0_LOWVOLTLINE
+
+config ARCH_CHIP_STM32F070C6
+ bool "STM32F070C6"
+ select STM32F0_STM32F07X
+ select STM32F0_VALUELINE
+
+config ARCH_CHIP_STM32F070CB
+ bool "STM32F070CB"
+ select STM32F0_STM32F07X
+ select STM32F0_VALUELINE
+
+config ARCH_CHIP_STM32F070F6
+ bool "STM32F070F6"
+ select STM32F0_STM32F07X
+ select STM32F0_VALUELINE
+
+config ARCH_CHIP_STM32F070RB
+ bool "STM32F070RB"
+ select STM32F0_STM32F07X
+ select STM32F0_VALUELINE
+
+config ARCH_CHIP_STM32F071C8
+ bool "STM32F071C8"
+ select STM32F0_STM32F07X
+ select STM32F0_ACCESSLINE
+
+config ARCH_CHIP_STM32F071CB
+ bool "STM32F071CB"
+ select STM32F0_STM32F07X
+ select STM32F0_ACCESSLINE
+
+config ARCH_CHIP_STM32F071RB
+ bool "STM32F071RB"
+ select STM32F0_STM32F07X
+ select STM32F0_ACCESSLINE
+
+config ARCH_CHIP_STM32F071V8
+ bool "STM32F071V8"
+ select STM32F0_STM32F07X
+ select STM32F0_ACCESSLINE
+
+config ARCH_CHIP_STM32F071VB
+ bool "STM32F071VB"
+ select STM32F0_STM32F07X
+ select STM32F0_ACCESSLINE
+
+config ARCH_CHIP_STM32F072C8
+ bool "STM32F072C8"
+ select STM32F0_STM32F07X
+ select STM32F0_USBLINE
+
+config ARCH_CHIP_STM32F072CB
+ bool "STM32F072CB"
+ select STM32F0_STM32F07X
+ select STM32F0_USBLINE
+
+config ARCH_CHIP_STM32F072R8
+ bool "STM32F072R8"
+ select STM32F0_STM32F07X
+ select STM32F0_USBLINE
+
+config ARCH_CHIP_STM32F072RB
+ bool "STM32F072RB"
+ select STM32F0_STM32F07X
+ select STM32F0_USBLINE
+
+config ARCH_CHIP_STM32F072V8
+ bool "STM32F072V8"
+ select STM32F0_STM32F07X
+ select STM32F0_USBLINE
+
+config ARCH_CHIP_STM32F072VB
+ bool "STM32F072VB"
+ select STM32F0_STM32F07X
+ select STM32F0_USBLINE
+
+config ARCH_CHIP_STM32F078CB
+ bool "STM32F078CB"
+ select STM32F0_STM32F07X
+ select STM32F0_LOWVOLTLINE
+
+config ARCH_CHIP_STM32F078RB
+ bool "STM32F078RB"
+ select STM32F0_STM32F07X
+ select STM32F0_LOWVOLTLINE
+
+config ARCH_CHIP_STM32F078VB
+ bool "STM32F078VB"
+ select STM32F0_STM32F07X
+ select STM32F0_LOWVOLTLINE
+
+config ARCH_CHIP_STM32F091CB
+ bool "STM32F091CB"
+ select STM32F0_STM32F09X
+ select STM32F0_ACCESSLINE
+
+config ARCH_CHIP_STM32F091CC
+ bool "STM32F091CC"
+ select STM32F0_STM32F09X
+ select STM32F0_ACCESSLINE
+
+config ARCH_CHIP_STM32F091RB
+ bool "STM32F091RB"
+ select STM32F0_STM32F09X
+ select STM32F0_ACCESSLINE
+
+config ARCH_CHIP_STM32F091RC
+ bool "STM32F091RC"
+ select STM32F0_STM32F09X
+ select STM32F0_ACCESSLINE
+
+config ARCH_CHIP_STM32F091VB
+ bool "STM32F091VB"
+ select STM32F0_STM32F09X
+ select STM32F0_ACCESSLINE
+
+config ARCH_CHIP_STM32F091VC
+ bool "STM32F091VC"
+ select STM32F0_STM32F09X
+ select STM32F0_ACCESSLINE
+
+config ARCH_CHIP_STM32F098CC
+ bool "STM32F098CC"
+ select STM32F0_STM32F09X
+ select STM32F0_LOWVOLTLINE
+
+config ARCH_CHIP_STM32F098RC
+ bool "STM32F098RC"
+ select STM32F0_STM32F09X
+ select STM32F0_LOWVOLTLINE
+
+config ARCH_CHIP_STM32F098VC
+ bool "STM32F098VC"
+ select STM32F0_STM32F09X
+ select STM32F0_LOWVOLTLINE
+
+endchoice
+
+config ARCH_FAMILY_STM32F0XX
+ bool
+
+choice
+ prompt "Override Flash Size Designator"
+ default STM32F0_FLASH_CONFIG_DEFAULT
+ depends on ARCH_CHIP_STM32
+ ---help---
+ STM32F series parts numbering (sans the package type) ends with a number or letter
+ that designates the FLASH size.
+
+ Designator Size in KiB
+ 4 16
+ 6 32
+ 8 64
+ B 128
+ C 256
+ D 384
+ E 512
+ F 768
+ G 1024
+ I 2048
+
+ This configuration option defaults to using the configuration based on that designator
+ or the default smaller size if there is no last character designator is present in the
+ STM32 Chip Selection.
+
+ Examples:
+ If the STM32F407VE is chosen, the Flash configuration would be 'E', if a variant of
+ the part with a 2048 KiB Flash is released in the future one could simply select
+ the 'I' designator here.
+
+ If an STM32F42xxx or Series parts is chosen the default Flash configuration will be 'G'
+ and can be set herein to 'I' to choose the larger FLASH part.
+
+config STM32F0_FLASH_CONFIG_DEFAULT
+ bool "Default"
+
+config STM32F0_FLASH_CONFIG_4
+ bool "4 16KiB"
+
+config STM32F0_FLASH_CONFIG_6
+ bool "6 32KiB"
+
+config STM32F0_FLASH_CONFIG_8
+ bool "8 64KiB"
+
+config STM32F0_FLASH_CONFIG_B
+ bool "B 128KiB"
+
+config STM32F0_FLASH_CONFIG_C
+ bool "C 256KiB"
+
+config STM32F0_FLASH_CONFIG_D
+ bool "D 384KiB"
+
+config STM32F0_FLASH_CONFIG_E
+ bool "E 512KiB"
+
+config STM32F0_FLASH_CONFIG_F
+ bool "F 768KiB"
+
+config STM32F0_FLASH_CONFIG_G
+ bool "G 1024KiB"
+
+config STM32F0_FLASH_CONFIG_I
+ bool "I 2048KiB"
+
+endchoice
+
+config STM32F0_STM32F03X
+ bool
+ default n
+
+config STM32F0_STM32F04X
+ bool
+ default n
+
+config STM32F0_STM32F05X
+ bool
+ default n
+
+config STM32F0_STM32F07X
+ bool
+ default n
+
+config STM32F0_STM32F09X
+ bool
+ default n
+ select STM32F0_HAVE_HSI48
+
+config STM32F0_VALUELINE
+ bool
+ default n
+ select STM32F0_HAVE_USART3
+ select STM32F0_HAVE_USART4
+ select STM32F0_HAVE_USART5
+ select STM32F0_HAVE_TIM1
+ select STM32F0_HAVE_TIM2
+ select STM32F0_HAVE_TIM3
+ select STM32F0_HAVE_TIM6
+ select STM32F0_HAVE_TIM7
+ select STM32F0_HAVE_TIM14
+ select STM32F0_HAVE_TIM15
+ select STM32F0_HAVE_TIM16
+ select STM32F0_HAVE_TIM17
+ select STM32F0_HAVE_SPI2 if STM32F0_HIGHDENSITY
+ select STM32F0_HAVE_SPI3 if STM32F0_HIGHDENSITY
+
+config STM32F0_ACCESSLINE
+ bool
+ default n
+ select STM32F0_HAVE_USART3
+ select STM32F0_HAVE_USART4
+ select STM32F0_HAVE_USART5
+ select STM32F0_HAVE_TIM1
+ select STM32F0_HAVE_TIM2
+ select STM32F0_HAVE_TIM3
+ select STM32F0_HAVE_TIM6
+ select STM32F0_HAVE_TIM7
+ select STM32F0_HAVE_TIM14
+ select STM32F0_HAVE_TIM15
+ select STM32F0_HAVE_TIM16
+ select STM32F0_HAVE_TIM17
+ select STM32F0_HAVE_ADC2
+ select STM32F0_HAVE_CAN1
+ select STM32F0_HAVE_SPI2
+ select STM32F0_HAVE_SPI3
+
+config STM32F0_LOWVOLTLINE
+ bool
+ default n
+ select STM32F0_HAVE_USART3
+ select STM32F0_HAVE_USART4
+ select STM32F0_HAVE_USART5
+ select STM32F0_HAVE_TIM1
+ select STM32F0_HAVE_TIM2
+ select STM32F0_HAVE_TIM3
+ select STM32F0_HAVE_TIM6
+ select STM32F0_HAVE_TIM7
+ select STM32F0_HAVE_TIM14
+ select STM32F0_HAVE_TIM15
+ select STM32F0_HAVE_TIM16
+ select STM32F0_HAVE_TIM17
+ select STM32F0_HAVE_ADC2
+ select STM32F0_HAVE_CAN1
+ select STM32F0_HAVE_SPI2
+ select STM32F0_HAVE_SPI3
+
+config STM32F0_USBLINE
+ bool
+ default n
+ select STM32F0_HAVE_HSI48
+ select STM32F0_HAVE_USART3
+ select STM32F0_HAVE_USART4
+ select STM32F0_HAVE_TIM1
+ select STM32F0_HAVE_TIM2
+ select STM32F0_HAVE_TIM3
+ select STM32F0_HAVE_TIM6
+ select STM32F0_HAVE_TIM7
+ select STM32F0_HAVE_TIM14
+ select STM32F0_HAVE_TIM15
+ select STM32F0_HAVE_TIM16
+ select STM32F0_HAVE_TIM17
+ select STM32F0_HAVE_ADC2
+ select STM32F0_HAVE_CAN1
+ select STM32F0_HAVE_SPI2
+ select STM32F0_HAVE_SPI3
+ select STM32F0_HAVE_USBDEV
+
+config STM32F0_DFU
+ bool "DFU bootloader"
+ default n
+ depends on !STM32F0_VALUELINE
+ ---help---
+ Configure and position code for use with the STMicro DFU bootloader. Do
+ not select this option if you will load code using JTAG/SWM.
+
+
+choice
+ prompt "SysTick clock source"
+ default STM32F0_SYSTICK_CORECLK
+
+config STM32F0_SYSTICK_CORECLK
+ bool "Cortex-M0 core clock"
+
+config STM32F0_SYSTICK_CORECLK_DIV16
+ bool "Cortex-M0 core clock divided by 16"
+
+endchoice
+
+
+menu "STM32 Peripheral Support"
+
+# These "hidden" settings determine is a peripheral option is available for the
+# selection MCU
+
+config STM32F0_HAVE_CCM
+ bool
+ default n
+
+config STM32F0_HAVE_HSI48
+ bool
+ default n
+
+config STM32F0_HAVE_USBDEV
+ bool
+ default n
+
+config STM32F0_HAVE_FSMC
+ bool
+ default n
+
+config STM32F0_HAVE_HRTIM1
+ bool
+ default n
+
+config STM32F0_HAVE_USART3
+ bool
+ default n
+
+config STM32F0_HAVE_USART4
+ bool
+ default n
+
+config STM32F0_HAVE_USART5
+ bool
+ default n
+
+config STM32F0_HAVE_USART6
+ bool
+ default n
+
+config STM32F0_HAVE_USART7
+ bool
+ default n
+
+config STM32F0_HAVE_USART8
+ bool
+ default n
+
+config STM32F0_HAVE_TIM1
+ bool
+ default n
+
+config STM32F0_HAVE_TIM2
+ bool
+ default n
+
+config STM32F0_HAVE_TIM3
+ bool
+ default n
+
+config STM32F0_HAVE_TIM6
+ bool
+ default n
+
+config STM32F0_HAVE_TIM7
+ bool
+ default n
+
+config STM32F0_HAVE_TIM14
+ bool
+ default n
+
+config STM32F0_HAVE_TIM15
+ bool
+ default n
+
+config STM32F0_HAVE_TIM16
+ bool
+ default n
+
+config STM32F0_HAVE_TIM17
+ bool
+ default n
+
+config STM32F0_HAVE_TSC
+ bool
+ default n
+
+config STM32F0_HAVE_ADC2
+ bool
+ default n
+
+config STM32F0_HAVE_ADC3
+ bool
+ default n
+
+config STM32F0_HAVE_ADC4
+ bool
+ default n
+
+config STM32F0_HAVE_ADC1_DMA
+ bool
+ default n
+
+config STM32F0_HAVE_ADC2_DMA
+ bool
+ default n
+
+config STM32F0_HAVE_ADC3_DMA
+ bool
+ default n
+
+config STM32F0_HAVE_ADC4_DMA
+ bool
+ default n
+
+config STM32F0_HAVE_SDADC1
+ bool
+ default n
+
+config STM32F0_HAVE_SDADC2
+ bool
+ default n
+
+config STM32F0_HAVE_SDADC3
+ bool
+ default n
+
+config STM32F0_HAVE_SDADC1_DMA
+ bool
+ default n
+
+config STM32F0_HAVE_SDADC2_DMA
+ bool
+ default n
+
+config STM32F0_HAVE_SDADC3_DMA
+ bool
+ default n
+
+config STM32F0_HAVE_CAN1
+ bool
+ default n
+
+config STM32F0_HAVE_COMP1
+ bool
+ default n
+
+config STM32F0_HAVE_COMP2
+ bool
+ default n
+
+config STM32F0_HAVE_COMP3
+ bool
+ default n
+
+config STM32F0_HAVE_COMP4
+ bool
+ default n
+
+config STM32F0_HAVE_COMP5
+ bool
+ default n
+
+config STM32F0_HAVE_COMP6
+ bool
+ default n
+
+config STM32F0_HAVE_COMP7
+ bool
+ default n
+
+config STM32F0_HAVE_DAC1
+ bool
+ default n
+
+config STM32F0_HAVE_DAC2
+ bool
+ default n
+
+config STM32F0_HAVE_RNG
+ bool
+ default n
+
+config STM32F0_HAVE_I2C2
+ bool
+ default n
+
+config STM32F0_HAVE_I2C3
+ bool
+ default n
+
+config STM32F0_HAVE_SPI2
+ bool
+ default n
+
+config STM32F0_HAVE_SPI3
+ bool
+ default n
+
+config STM32F0_HAVE_SPI4
+ bool
+ default n
+
+config STM32F0_HAVE_SPI5
+ bool
+ default n
+
+config STM32F0_HAVE_SPI6
+ bool
+ default n
+
+config STM32F0_HAVE_SAIPLL
+ bool
+ default n
+
+config STM32F0_HAVE_I2SPLL
+ bool
+ default n
+
+config STM32F0_HAVE_OPAMP1
+ bool
+ default n
+
+config STM32F0_HAVE_OPAMP2
+ bool
+ default n
+
+config STM32F0_HAVE_OPAMP3
+ bool
+ default n
+
+config STM32F0_HAVE_OPAMP4
+ bool
+ default n
+
+# These are the peripheral selections proper
+
+config STM32F0_ADC1
+ bool "ADC1"
+ default n
+ select STM32F0_ADC
+
+config STM32F0_ADC2
+ bool "ADC2"
+ default n
+ select STM32F0_ADC
+ depends on STM32F0_HAVE_ADC2
+
+config STM32F0_ADC3
+ bool "ADC3"
+ default n
+ select STM32F0_ADC
+ depends on STM32F0_HAVE_ADC3
+
+config STM32F0_ADC4
+ bool "ADC4"
+ default n
+ select STM32F0_ADC
+ depends on STM32F0_HAVE_ADC4
+
+config STM32F0_SDADC1
+ bool "SDADC1"
+ default n
+ select STM32F0_SDADC
+ depends on STM32F0_HAVE_SDADC1
+
+config STM32F0_SDADC2
+ bool "SDADC2"
+ default n
+ select STM32F0_SDADC
+ depends on STM32F0_HAVE_SDADC2
+
+config STM32F0_SDADC3
+ bool "SDADC3"
+ default n
+ select STM32F0_SDADC
+ depends on STM32F0_HAVE_SDADC3
+
+config STM32F0_COMP
+ bool "COMP"
+ default n
+
+config STM32F0_COMP1
+ bool "COMP1"
+ default n
+ depends on STM32F0_HAVE_COMP1
+
+config STM32F0_COMP2
+ bool "COMP2"
+ default n
+ depends on STM32F0_HAVE_COMP2
+
+config STM32F0_COMP3
+ bool "COMP3"
+ default n
+ depends on STM32F0_HAVE_COMP3
+
+config STM32F0_COMP4
+ bool "COMP4"
+ default n
+ depends on STM32F0_HAVE_COMP4
+
+config STM32F0_COMP5
+ bool "COMP5"
+ default n
+ depends on STM32F0_HAVE_COMP5
+
+config STM32F0_COMP6
+ bool "COMP6"
+ default n
+ depends on STM32F0_HAVE_COMP6
+
+config STM32F0_COMP7
+ bool "COMP7"
+ default n
+ depends on STM32F0_HAVE_COMP6
+
+config STM32F0_BKP
+ bool "BKP"
+ default n
+
+config STM32F0_BKPSRAM
+ bool "Enable BKP RAM Domain"
+ default n
+
+config STM32F0_CAN1
+ bool "CAN1"
+ default n
+ select CAN
+ select STM32F0_CAN
+ depends on STM32F0_HAVE_CAN1
+
+config STM32F0_CEC
+ bool "CEC"
+ default n
+ depends on STM32F0_VALUELINE
+
+config STM32F0_CRC
+ bool "CRC"
+ default n
+
+config STM32F0_CRYP
+ bool "CRYP"
+ default n
+ depends on STM32F0_STM32F207 || STM32F0_STM32F40XX
+
+config STM32F0_DMA1
+ bool "DMA1"
+ default n
+ select ARCH_DMA
+
+config STM32F0_DMA2
+ bool "DMA2"
+ default n
+ select ARCH_DMA
+ depends on !STM32F0_VALUELINE || (STM32F0_VALUELINE && STM32F0_HIGHDENSITY)
+
+config STM32F0_DAC1
+ bool "DAC1"
+ default n
+ depends on STM32F0_HAVE_DAC1
+ select STM32F0_DAC
+
+config STM32F0_DAC2
+ bool "DAC2"
+ default n
+ depends on STM32F0_HAVE_DAC2
+ select STM32F0_DAC
+
+config STM32F0_FSMC
+ bool "FSMC"
+ default n
+ depends on STM32F0_HAVE_FSMC
+
+config STM32F0_HASH
+ bool "HASH"
+ default n
+ depends on STM32F0_STM32F207 || STM32F0_STM32F40XX
+
+config STM32F0_HRTIM1
+ bool "HRTIM1"
+ default n
+ depends on STM32F0_HAVE_HRTIM1
+
+config STM32F0_I2C1
+ bool "I2C1"
+ default n
+ select STM32F0_I2C
+
+config STM32F0_I2C2
+ bool "I2C2"
+ default n
+ depends on STM32F0_HAVE_I2C2
+ select STM32F0_I2C
+
+config STM32F0_I2C3
+ bool "I2C3"
+ default n
+ depends on STM32F0_HAVE_I2C3
+ select STM32F0_I2C
+
+config STM32F0_PWR
+ bool "PWR"
+ default n
+
+config STM32F0_RNG
+ bool "RNG"
+ default n
+ depends on STM32F0_HAVE_RNG
+ select ARCH_HAVE_RNG
+
+config STM32F0_SDIO
+ bool "SDIO"
+ default n
+ depends on !STM32F0_CONNECTIVITYLINE && !STM32F0_VALUELINE
+ select ARCH_HAVE_SDIO
+ select ARCH_HAVE_SDIOWAIT_WRCOMPLETE
+ select SDIO_PREFLIGHT
+
+config STM32F0_SPI1
+ bool "SPI1"
+ default n
+ select SPI
+ select STM32F0_SPI
+
+config STM32F0_SPI2
+ bool "SPI2"
+ default n
+ depends on STM32F0_HAVE_SPI2
+ select SPI
+ select STM32F0_SPI
+
+config STM32F0_SPI3
+ bool "SPI3"
+ default n
+ depends on STM32F0_HAVE_SPI3
+ select SPI
+ select STM32F0_SPI
+
+config STM32F0_SPI4
+ bool "SPI4"
+ default n
+ depends on STM32F0_HAVE_SPI4
+ select SPI
+ select STM32F0_SPI
+
+config STM32F0_SPI5
+ bool "SPI5"
+ default n
+ depends on STM32F0_HAVE_SPI5
+ select SPI
+ select STM32F0_SPI
+
+config STM32F0_SPI6
+ bool "SPI6"
+ default n
+ depends on STM32F0_HAVE_SPI6
+ select SPI
+ select STM32F0_SPI
+
+config STM32F0_SYSCFG
+ bool "SYSCFG"
+ default y
+
+config STM32F0_TIM1
+ bool "TIM1"
+ default n
+ depends on STM32F0_HAVE_TIM1
+
+config STM32F0_TIM2
+ bool "TIM2"
+ default n
+
+config STM32F0_TIM3
+ bool "TIM3"
+ default n
+ depends on STM32F0_HAVE_TIM3
+
+config STM32F0_TIM6
+ bool "TIM6"
+ default n
+ depends on STM32F0_HAVE_TIM6
+
+config STM32F0_TIM7
+ bool "TIM7"
+ default n
+ depends on STM32F0_HAVE_TIM7
+
+config STM32F0_TIM14
+ bool "TIM14"
+ default n
+ depends on STM32F0_HAVE_TIM14
+
+config STM32F0_TIM15
+ bool "TIM15"
+ default n
+ depends on STM32F0_HAVE_TIM15
+
+config STM32F0_TIM16
+ bool "TIM16"
+ default n
+ depends on STM32F0_HAVE_TIM16
+
+config STM32F0_TIM17
+ bool "TIM17"
+ default n
+ depends on STM32F0_HAVE_TIM17
+
+config STM32F0_TSC
+ bool "TSC"
+ default n
+ depends on STM32F0_HAVE_TSC
+
+config STM32F0_USART1
+ bool "USART1"
+ default n
+ select STM32F0_USART
+
+config STM32F0_USART2
+ bool "USART2"
+ default n
+ select STM32F0_USART
+
+config STM32F0_USART3
+ bool "USART3"
+ default n
+ depends on STM32F0_HAVE_USART3
+ select STM32F0_USART
+
+config STM32F0_USART4
+ bool "USART4"
+ default n
+ depends on STM32F0_HAVE_USART4
+ select STM32F0_USART
+
+config STM32F0_USART5
+ bool "USART5"
+ default n
+ depends on STM32F0_HAVE_USART5
+ select STM32F0_USART
+
+config STM32F0_USART6
+ bool "USART6"
+ default n
+ depends on STM32F0_HAVE_USART6
+ select STM32F0_USART
+
+config STM32F0_USART7
+ bool "USART7"
+ default n
+ depends on STM32F0_HAVE_USART7
+ select STM32F0_USART
+
+config STM32F0_USART8
+ bool "USART8"
+ default n
+ depends on STM32F0_HAVE_USART8
+ select STM32F0_USART
+
+config STM32F0_USB
+ bool "USB Device"
+ default n
+ depends on STM32F0_HAVE_USBDEV
+ select USBDEV
+
+config STM32F0_IWDG
+ bool "IWDG"
+ default n
+ select WATCHDOG
+
+config STM32F0_WWDG
+ bool "WWDG"
+ default n
+ select WATCHDOG
+
+endmenu
+
+config STM32F0_ADC
+ bool
+
+config STM32F0_SDADC
+ bool
+
+config STM32F0_DAC
+ bool
+
+config STM32F0_SPI
+ bool
+
+config STM32F0_I2C
+ bool
+
+config STM32F0_CAN
+ bool
+
+config STM32F0_USART
+ bool
+
+config STM32F0_SERIALDRIVER
+ bool
+
+config STM32F0_1WIREDRIVER
+ bool
+
+menu "U[S]ART Configuration"
+ depends on STM32F0_USART
+
+comment "U[S]ART Device Configuration"
+
+choice
+ prompt "USART1 Driver Configuration"
+ default STM32F0_USART1_SERIALDRIVER
+ depends on STM32F0_USART1
+
+config STM32F0_USART1_SERIALDRIVER
+ bool "Standard serial driver"
+ select USART1_SERIALDRIVER
+ select ARCH_HAVE_SERIAL_TERMIOS
+ select STM32F0_SERIALDRIVER
+
+config STM32F0_USART1_1WIREDRIVER
+ bool "1-Wire driver"
+ select STM32F0_1WIREDRIVER
+
+endchoice # USART1 Driver Configuration
+
+if STM32F0_USART1_SERIALDRIVER
+
+config USART1_RS485
+ bool "RS-485 on USART1"
+ default n
+ ---help---
+ Enable RS-485 interface on USART1. Your board config will have to
+ provide GPIO_USART1_RS485_DIR pin definition.
+
+config USART1_RS485_DIR_POLARITY
+ int "USART1 RS-485 DIR pin polarity"
+ default 1
+ range 0 1
+ depends on USART1_RS485
+ ---help---
+ Polarity of DIR pin for RS-485 on USART1. Set to state on DIR pin which
+ enables TX (0 - low / nTXEN, 1 - high / TXEN).
+
+endif # STM32F0_USART1_SERIALDRIVER
+
+choice
+ prompt "USART2 Driver Configuration"
+ default STM32F0_USART2_SERIALDRIVER
+ depends on STM32F0_USART2
+
+config STM32F0_USART2_SERIALDRIVER
+ bool "Standard serial driver"
+ select USART2_SERIALDRIVER
+ select ARCH_HAVE_SERIAL_TERMIOS
+ select STM32F0_SERIALDRIVER
+
+config STM32F0_USART2_1WIREDRIVER
+ bool "1-Wire driver"
+ select STM32F0_1WIREDRIVER
+
+endchoice # USART2 Driver Configuration
+
+if STM32F0_USART2_SERIALDRIVER
+
+config USART2_RS485
+ bool "RS-485 on USART2"
+ default n
+ ---help---
+ Enable RS-485 interface on USART2. Your board config will have to
+ provide GPIO_USART2_RS485_DIR pin definition.
+
+config USART2_RS485_DIR_POLARITY
+ int "USART2 RS-485 DIR pin polarity"
+ default 1
+ range 0 1
+ depends on USART2_RS485
+ ---help---
+ Polarity of DIR pin for RS-485 on USART2. Set to state on DIR pin which
+ enables TX (0 - low / nTXEN, 1 - high / TXEN).
+
+endif # STM32F0_USART2_SERIALDRIVER
+
+choice
+ prompt "USART3 Driver Configuration"
+ default STM32F0_USART3_SERIALDRIVER
+ depends on STM32F0_USART3
+
+config STM32F0_USART3_SERIALDRIVER
+ bool "Standard serial driver"
+ select USART3_SERIALDRIVER
+ select ARCH_HAVE_SERIAL_TERMIOS
+ select STM32F0_SERIALDRIVER
+
+config STM32F0_USART3_1WIREDRIVER
+ bool "1-Wire driver"
+ select STM32F0_1WIREDRIVER
+
+endchoice # USART3 Driver Configuration
+
+if STM32F0_USART3_SERIALDRIVER
+
+config USART3_RS485
+ bool "RS-485 on USART3"
+ default n
+ ---help---
+ Enable RS-485 interface on USART3. Your board config will have to
+ provide GPIO_USART3_RS485_DIR pin definition.
+
+config USART3_RS485_DIR_POLARITY
+ int "USART3 RS-485 DIR pin polarity"
+ default 1
+ range 0 1
+ depends on USART3_RS485
+ ---help---
+ Polarity of DIR pin for RS-485 on USART3. Set to state on DIR pin which
+ enables TX (0 - low / nTXEN, 1 - high / TXEN).
+
+endif # STM32F0_USART3_SERIALDRIVER
+
+
+choice
+ prompt "USART4 Driver Configuration"
+ default STM32F0_USART4_SERIALDRIVER
+ depends on STM32F0_USART4
+
+config STM32F0_USART4_SERIALDRIVER
+ bool "Standard serial driver"
+ select USART4_SERIALDRIVER
+ select ARCH_HAVE_SERIAL_TERMIOS
+ select STM32F0_SERIALDRIVER
+
+config STM32F0_USART4_1WIREDRIVER
+ bool "1-Wire driver"
+ select STM32F0_1WIREDRIVER
+
+endchoice # USART4 Driver Configuration
+
+if STM32F0_USART4_SERIALDRIVER
+
+config USART4_RS485
+ bool "RS-485 on USART4"
+ default n
+ ---help---
+ Enable RS-485 interface on USART4. Your board config will have to
+ provide GPIO_USART4_RS485_DIR pin definition.
+
+config USART4_RS485_DIR_POLARITY
+ int "USART4 RS-485 DIR pin polarity"
+ default 1
+ range 0 1
+ depends on USART4_RS485
+ ---help---
+ Polarity of DIR pin for RS-485 on USART4. Set to state on DIR pin which
+ enables TX (0 - low / nTXEN, 1 - high / TXEN).
+
+endif # STM32F0_USART4_SERIALDRIVER
+
+
+choice
+ prompt "USART5 Driver Configuration"
+ default STM32F0_USART5_SERIALDRIVER
+ depends on STM32F0_USART5
+
+config STM32F0_USART5_SERIALDRIVER
+ bool "Standard serial driver"
+ select USART5_SERIALDRIVER
+ select ARCH_HAVE_SERIAL_TERMIOS
+ select STM32F0_SERIALDRIVER
+
+config STM32F0_USART5_1WIREDRIVER
+ bool "1-Wire driver"
+ select STM32F0_1WIREDRIVER
+
+endchoice # USART5 Driver Configuration
+
+if STM32F0_USART5_SERIALDRIVER
+
+config USART5_RS485
+ bool "RS-485 on USART5"
+ default n
+ ---help---
+ Enable RS-485 interface on USART5. Your board config will have to
+ provide GPIO_USART5_RS485_DIR pin definition.
+
+config USART5_RS485_DIR_POLARITY
+ int "USART5 RS-485 DIR pin polarity"
+ default 1
+ range 0 1
+ depends on USART5_RS485
+ ---help---
+ Polarity of DIR pin for RS-485 on USART5. Set to state on DIR pin which
+ enables TX (0 - low / nTXEN, 1 - high / TXEN).
+
+endif # STM32F0_USART5_SERIALDRIVER
+
+
+choice
+ prompt "USART6 Driver Configuration"
+ default STM32F0_USART6_SERIALDRIVER
+ depends on STM32F0_USART6
+
+config STM32F0_USART6_SERIALDRIVER
+ bool "Standard serial driver"
+ select USART6_SERIALDRIVER
+ select ARCH_HAVE_SERIAL_TERMIOS
+ select STM32F0_SERIALDRIVER
+
+config STM32F0_USART6_1WIREDRIVER
+ bool "1-Wire driver"
+ select STM32F0_1WIREDRIVER
+
+endchoice # USART6 Driver Configuration
+
+if STM32F0_USART6_SERIALDRIVER
+
+config USART6_RS485
+ bool "RS-485 on USART6"
+ default n
+ ---help---
+ Enable RS-485 interface on USART6. Your board config will have to
+ provide GPIO_USART6_RS485_DIR pin definition.
+
+config USART6_RS485_DIR_POLARITY
+ int "USART6 RS-485 DIR pin polarity"
+ default 1
+ range 0 1
+ depends on USART6_RS485
+ ---help---
+ Polarity of DIR pin for RS-485 on USART6. Set to state on DIR pin which
+ enables TX (0 - low / nTXEN, 1 - high / TXEN).
+
+endif # STM32F0_USART6_SERIALDRIVER
+
+choice
+ prompt "USART7 Driver Configuration"
+ default STM32F0_USART7_SERIALDRIVER
+ depends on STM32F0_USART7
+
+config STM32F0_USART7_SERIALDRIVER
+ bool "Standard serial driver"
+ select USART7_SERIALDRIVER
+ select ARCH_HAVE_SERIAL_TERMIOS
+ select STM32F0_SERIALDRIVER
+
+config STM32F0_USART7_1WIREDRIVER
+ bool "1-Wire driver"
+ select STM32F0_1WIREDRIVER
+
+endchoice # USART7 Driver Configuration
+
+if STM32F0_USART7_SERIALDRIVER
+
+config USART7_RS485
+ bool "RS-485 on USART7"
+ default n
+ ---help---
+ Enable RS-485 interface on USART7. Your board config will have to
+ provide GPIO_USART7_RS485_DIR pin definition.
+
+config USART7_RS485_DIR_POLARITY
+ int "USART7 RS-485 DIR pin polarity"
+ default 1
+ range 0 1
+ depends on USART7_RS485
+ ---help---
+ Polarity of DIR pin for RS-485 on USART7. Set to state on DIR pin which
+ enables TX (0 - low / nTXEN, 1 - high / TXEN).
+
+endif # STM32F0_USART7_SERIALDRIVER
+
+choice
+ prompt "USART8 Driver Configuration"
+ default STM32F0_USART8_SERIALDRIVER
+ depends on STM32F0_USART8
+
+config STM32F0_USART8_SERIALDRIVER
+ bool "Standard serial driver"
+ select USART8_SERIALDRIVER
+ select ARCH_HAVE_SERIAL_TERMIOS
+ select STM32F0_SERIALDRIVER
+
+config STM32F0_USART8_1WIREDRIVER
+ bool "1-Wire driver"
+ select STM32F0_1WIREDRIVER
+
+endchoice # USART8 Driver Configuration
+
+if STM32F0_USART8_SERIALDRIVER
+
+config USART8_RS485
+ bool "RS-485 on USART8"
+ default n
+ ---help---
+ Enable RS-485 interface on USART8. Your board config will have to
+ provide GPIO_USART8_RS485_DIR pin definition.
+
+config USART8_RS485_DIR_POLARITY
+ int "USART8 RS-485 DIR pin polarity"
+ default 1
+ range 0 1
+ depends on USART8_RS485
+ ---help---
+ Polarity of DIR pin for RS-485 on USART8. Set to state on DIR pin which
+ enables TX (0 - low / nTXEN, 1 - high / TXEN).
+
+endif # STM32F0_USART8_SERIALDRIVER
+
+endmenu
diff --git a/arch/arm/src/stm32f0/Make.defs b/arch/arm/src/stm32f0/Make.defs
new file mode 100644
index 0000000000000000000000000000000000000000..408c7b77e85b53d383ffbf00248defa80701c010
--- /dev/null
+++ b/arch/arm/src/stm32f0/Make.defs
@@ -0,0 +1,112 @@
+############################################################################
+# arch/arm/src/stm32f0/Make.defs
+#
+# Copyright (C) 2017 Gregory Nutt. All rights reserved.
+# Author: Gregory Nutt
+# Alan Carvalho de Assis