From de0c4049832d559c229de5752767dacf70d03c72 Mon Sep 17 00:00:00 2001 From: Jamie Smith Date: Sun, 21 Jul 2024 00:16:51 -0700 Subject: [PATCH] Synchronize changes with Mbed upstream: July 2024 edition (#309) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * remove stdio checks in serial init if no console is available * STM32WL fix set preamble length to 8 * Add target support for XDOT_MAX32670 * TARGET_STM: only mask CAN rx interrupt after rx interrupt, not all CAN interrupts * Sleep Radio in between DC scheduled * Nuvoton HUSBD support endpoint write ZLP * USBCDC: support ZLP * Don't overlap STM32 FDCAN RAM sections * allow to override antenna gain * TFM: Fix undeclared function tfm_ns_interface_init ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] * NUVOTON: CAN: Fix filter mask NOTE: This fix only targets CAN (M453/M487), not CAN-FD (M467). NOTE: NUC472 CAN doesn't support filter. * NUVOTON: CAN: Fix Rx interrupt doesn't work Major modifications: 1. Handle Rx interrupt based on Message Object interrupt (CAN_IIDR=0x0001~0x0020) instead of CAN_STATUS.RxOK 2. Also handle Tx interrupt following above for consistency Other related modifications: 1. Fix signature type error in CAN_CLR_INT_PENDING_BIT() 2. Add CAN_CLR_INT_PENDING_ONLY_BIT() which doesn't clear NewDat flag so that user can fetch received message in thread context NOTE: This fix only targets CAN (NUC472/M453/M487), not CAN-FD (M467). * NUVOTON: CAN: Fix Message Object number for Tx and recognition of Rx interrupt 1. The same Message Object number cannot use for both Tx and Rx simultaneously. For Tx, Message Object number 31 is reserved instead of 0. For Rx, Message Object numbers 0~30 are used and for filters. 2. NewDat bit (CAN_IsNewDataReceived()) isn't exclusive to Rx. Recognize Rx interrupt by Message Object number other than 31. NOTE: This fix only targets CAN (NUC472/M453/M487), not CAN-FD (M467). * NUVOTON: CAN: Fix filter mask being zero On mask being zero, it means any match, not exact match. NOTE: This fix only targets CAN (M453/M487), not CAN-FD (M467). NOTE: NUC472 CAN doesn't support filter. * Allow custom TCXO control parameter Allow custom TCXO control parameter * NUVOTON: EMAC: Fix undeclared function mbed_error_printf ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] * NUVOTON: AnalogIn: Fix undeclared function gpio_set ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] * NUVOTON: CAN: Fix undeclared function gpio_set ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] * NUVOTON: AnalogOut: Fix undeclared function gpio_set ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] * NUVOTON: SPI: Fix undeclared function gpio_set ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] * NUVOTON: I2C: Fix undeclared function gpio_set ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] * NUVOTON: Serial: Fix undeclared function gpio_set ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] * Add separate flags for I2C slave transfer in progress Fixes ARMmbed/mbed-os#15498 Adds 2 boolean flags to the STM32 `i2c_s` object to indicate whether a transfer is in progress, separate from the existing "transfer pending" flags. `i2c_slave_write`, `i2c_slave_read` and their associated callbacks are modified to use these flags in addition to the pending flags. The original behavior of the pending flags is preserved. * ESP8266: Fix accessing uninitialized variable * Added missing delete * Add ability to change number of status registers for macronix QSPIF devices * correct scan parameters types * skip CRC when initializing TDBStore Problem: The build_ram_table() function of TDBStore loops over every entry, calculates the checksum and compares them to the stored checksum in the entry header to ensure integrity. For larger TDBStores (e.g. 8 MiB or more) in external single-SPI flash devices this check can take very long, thus rendering it unusable in some cases. Solution: The suggested solution skips the time consuming CRC of the data. After reading the key and calculating its CRC, it sets next_offset to the beginning of the next entry, thereby skipping the data. While this skips the integrity check, it significantly reduces the initial building of the RAM table. The data CRC can be enabled or disabled with a compiler flag. Contribution is provided on behalf of BIOTRONIK. * Added missing check for replay protection pointer before allocating new variable Problem: If a key with write-once flag is being set in a SecureStore without rollback-protection store (i.e. _rbp_kv == NULL), additional memory will be allocated for the variable _ih->key. The memory will not be deleted, though, as the delete in line 434 only happens if a rollback-protection store exists (i.e. _rbp_kv != NULL) Solution: Only allocate the memory if _rbp_kv != NULL Contribution is provided on behalf of BIOTRONIK. * Increase AT timeout to 10s in AT_CellularSMS::send_sms For some devices sending can be slow (as an example see SIM800, it can be up to 60s), command is being run properly but default timeout is returning an invalid error. See https://www.elecrow.com/wiki/images/2/20/SIM800_Series_AT_Command_Manual_V1.09.pdf * Increase AT timeout to 10s in AT_CellularSMS::get_sms When SMS list is big and baudrate is not fast enough, with default timeout we can suffer from timeout error while getting a sms because method is parsing the full list and this takes long. * Fix AT_CellularSMS::list_messages breaking in text mode when CRLF is contained in SMS payload text When parsing SMS, it can happen that we receive CRLF in the SMS payload (happened to me when receiving provider texts). As an example, we can receive: """ Hello World! """ With previous implementation, second consume_to_stop_tag was stopping in and rest of the code was failing for obvious reasons. With this commit we consume the full payload as bytes. * Add missing SPDX identifier to a bajillion Nuvoton source files + some others * More license fixes, upgrade M451 legacy PinNames.h, add MCU description * Fix some more legacy pin names --------- Co-authored-by: Jost, Chris <79271064+chrJost@users.noreply.github.com> Co-authored-by: Charles Co-authored-by: Leon Lindenfelser Co-authored-by: Pavel Sorejs Co-authored-by: cyliang tw Co-authored-by: jmcloud Co-authored-by: Chun-Chieh Li Co-authored-by: Adam Gausmann Co-authored-by: Mingjie Shen Co-authored-by: Matthias Goebel Co-authored-by: danielzhang Co-authored-by: Mathieu Camélique Co-authored-by: David Alonso de la Torre --- .../include/ble/gap/ScanParameters.h | 8 +- .../cellular/framework/API/ATHandler.h | 13 ++ .../source/framework/AT/AT_CellularSMS.cpp | 24 ++- .../source/framework/device/ATHandler.cpp | 40 ++++ .../UNITTESTS/doubles/ATHandler_stub.cpp | 9 + .../AT/at_cellularsms/at_cellularsmstest.cpp | 12 +- .../TARGET_M460/m460_eth.c | 1 + .../TARGET_M480/m480_eth.c | 1 + .../TARGET_NUC472/nuc472_eth.c | 1 + .../COMPONENT_SX126X/SX126X_LoRaRadio.cpp | 2 +- .../lora/COMPONENT_SX126X/mbed_lib.json | 4 + .../ESP8266/ESP8266.cpp | 2 +- .../lorawan/lorastack/mac/LoRaMac.cpp | 3 + .../lorawan/lorastack/phy/LoRaPHYAS923.cpp | 4 + .../lorawan/lorastack/phy/LoRaPHYAU915.cpp | 4 + .../lorawan/lorastack/phy/LoRaPHYCN470.cpp | 4 + .../lorawan/lorastack/phy/LoRaPHYCN779.cpp | 4 + .../lorawan/lorastack/phy/LoRaPHYEU433.cpp | 4 + .../lorawan/lorastack/phy/LoRaPHYEU868.cpp | 4 + .../lorawan/lorastack/phy/LoRaPHYIN865.cpp | 4 + .../lorawan/lorastack/phy/LoRaPHYKR920.cpp | 4 + .../lorawan/lorastack/phy/LoRaPHYUS915.cpp | 11 +- connectivity/lorawan/mbed_lib.json | 3 +- drivers/usb/include/usb/USBCDC.h | 1 + drivers/usb/source/USBCDC.cpp | 26 ++- .../TARGET_TFM_V8M/src/tfm_mbed_boot.c | 2 + .../blockdevice/COMPONENT_QSPIF/mbed_lib.json | 9 +- .../source/QSPIFBlockDevice.cpp | 8 +- .../securestore/source/SecureStore.cpp | 2 +- storage/kvstore/tdbstore/source/TDBStore.cpp | 5 + .../TARGET_MAX32670EVKIT/PeripheralNames.h | 2 + .../TARGET_MAX32670EVKIT/PinNames.h | 2 + .../TARGET_XDOT_MAX32670/CMakeLists.txt | 16 ++ .../TARGET_XDOT_MAX32670/PeripheralNames.h | 74 +++++++ .../TARGET_XDOT_MAX32670/PinNames.h | 191 ++++++++++++++++++ .../TARGET_XDOT_MAX32670/SystemInit.c | 116 +++++++++++ .../TARGET_NUVOTON/TARGET_M251/analogin_api.c | 1 + .../TARGET_M251/analogout_api.c | 1 + targets/TARGET_NUVOTON/TARGET_M251/i2c_api.c | 1 + .../TARGET_NUVOTON/TARGET_M251/pwmout_api.c | 1 + .../TARGET_NUVOTON/TARGET_M251/serial_api.c | 1 + targets/TARGET_NUVOTON/TARGET_M251/spi_api.c | 1 + .../TARGET_NUVOTON/TARGET_M251/watchdog_api.c | 3 +- .../TARGET_NUVOTON/TARGET_M261/analogin_api.c | 1 + .../TARGET_M261/analogout_api.c | 1 + targets/TARGET_NUVOTON/TARGET_M261/can_api.c | 2 + targets/TARGET_NUVOTON/TARGET_M261/i2c_api.c | 1 + .../TARGET_NUVOTON/TARGET_M261/pwmout_api.c | 1 + .../TARGET_NUVOTON/TARGET_M261/serial_api.c | 1 + targets/TARGET_NUVOTON/TARGET_M261/spi_api.c | 1 + .../TARGET_M451/PeripheralNames.h | 1 + .../TARGET_M451/PeripheralPins.c | 1 + .../TARGET_M451/PeripheralPins.h | 1 + targets/TARGET_NUVOTON/TARGET_M451/PinNames.h | 32 +-- .../TARGET_NUVOTON/TARGET_M451/PortNames.h | 1 + .../TARGET_NUVOTON/TARGET_M451/analogin_api.c | 2 + .../TARGET_M451/analogout_api.c | 1 + targets/TARGET_NUVOTON/TARGET_M451/can_api.c | 42 +++- targets/TARGET_NUVOTON/TARGET_M451/device.h | 1 + .../TARGET_M451/device/StdDriver/m451_acmp.c | 4 +- .../TARGET_M451/device/StdDriver/m451_acmp.h | 4 +- .../TARGET_M451/device/StdDriver/m451_can.c | 19 +- .../TARGET_M451/device/StdDriver/m451_can.h | 6 +- .../TARGET_M451/device/StdDriver/m451_clk.c | 4 +- .../TARGET_M451/device/StdDriver/m451_dac.c | 4 +- .../TARGET_M451/device/StdDriver/m451_eadc.c | 4 +- .../TARGET_M451/device/StdDriver/m451_fmc.c | 4 +- .../TARGET_M451/device/StdDriver/m451_gpio.c | 4 +- .../TARGET_M451/device/StdDriver/m451_i2c.c | 4 +- .../TARGET_M451/device/StdDriver/m451_i2c.h | 4 +- .../TARGET_M451/device/StdDriver/m451_otg.h | 4 +- .../TARGET_M451/device/StdDriver/m451_pdma.c | 4 +- .../TARGET_M451/device/StdDriver/m451_pdma.h | 4 +- .../TARGET_M451/device/StdDriver/m451_pwm.c | 4 +- .../TARGET_M451/device/StdDriver/m451_pwm.h | 4 +- .../TARGET_M451/device/StdDriver/m451_spi.c | 4 +- .../TARGET_M451/device/StdDriver/m451_spi.h | 4 +- .../TARGET_M451/device/StdDriver/m451_sys.c | 4 +- .../TARGET_M451/device/StdDriver/m451_tk.c | 4 +- .../TARGET_M451/device/StdDriver/m451_tk.h | 4 +- .../TARGET_M451/device/StdDriver/m451_usbd.c | 4 +- .../TARGET_M451/device/StdDriver/m451_usbd.h | 4 +- .../TARGET_NUVOTON/TARGET_M451/device/cmsis.h | 1 + .../TARGET_M451/device/cmsis_nvic.h | 1 + targets/TARGET_NUVOTON/TARGET_M451/dma.h | 1 + targets/TARGET_NUVOTON/TARGET_M451/dma_api.c | 1 + .../TARGET_NUVOTON/TARGET_M451/flash_api.c | 1 + targets/TARGET_NUVOTON/TARGET_M451/gpio_api.c | 1 + .../TARGET_NUVOTON/TARGET_M451/gpio_irq_api.c | 1 + .../TARGET_NUVOTON/TARGET_M451/gpio_object.h | 1 + targets/TARGET_NUVOTON/TARGET_M451/i2c_api.c | 2 + .../TARGET_NUVOTON/TARGET_M451/lp_ticker.c | 1 + .../TARGET_M451/mbed_overrides.c | 1 + targets/TARGET_NUVOTON/TARGET_M451/objects.h | 1 + targets/TARGET_NUVOTON/TARGET_M451/pinmap.c | 1 + targets/TARGET_NUVOTON/TARGET_M451/port_api.c | 1 + .../TARGET_NUVOTON/TARGET_M451/pwmout_api.c | 2 + .../TARGET_NUVOTON/TARGET_M451/reset_reason.c | 1 + targets/TARGET_NUVOTON/TARGET_M451/rtc_api.c | 1 + .../TARGET_NUVOTON/TARGET_M451/serial_api.c | 2 + targets/TARGET_NUVOTON/TARGET_M451/sleep.c | 1 + targets/TARGET_NUVOTON/TARGET_M451/spi_api.c | 1 + .../TARGET_NUVOTON/TARGET_M451/us_ticker.c | 1 + targets/TARGET_NUVOTON/TARGET_M480/can_api.c | 60 ++++-- .../device/StdDriver/inc/m480_can.h | 2 +- .../device/StdDriver/src/m480_can.c | 20 +- .../TARGET_NANO100/PeripheralNames.h | 1 + .../TARGET_NANO100/PeripheralPins.c | 1 + .../TARGET_NANO100/PeripheralPins.h | 1 + .../TARGET_NUVOTON/TARGET_NANO100/PinNames.h | 34 ++-- .../TARGET_NUVOTON/TARGET_NANO100/PortNames.h | 1 + .../TARGET_NANO100/analogin_api.c | 2 + .../TARGET_NANO100/analogout_api.c | 1 + .../TARGET_NUVOTON/TARGET_NANO100/device.h | 1 + .../device/StdDriver/nano100_clk.c | 1 + .../device/StdDriver/nano100_clk.h | 1 + .../device/StdDriver/nano100_crc.h | 1 + .../device/StdDriver/nano100_ebi.c | 1 + .../device/StdDriver/nano100_pdma.h | 1 + .../device/StdDriver/nano100_rtc.c | 1 + .../device/StdDriver/nano100_rtc.h | 1 + .../device/StdDriver/nano100_scuart.c | 1 + .../device/StdDriver/nano100_scuart.h | 1 + .../device/StdDriver/nano100_sys.c | 1 + .../device/StdDriver/nano100_timer.h | 1 + .../device/StdDriver/nano100_uart.c | 1 + .../device/StdDriver/nano100_uart.h | 1 + .../device/StdDriver/nano100_wdt.c | 1 + .../device/StdDriver/nano100_wdt.h | 1 + .../device/StdDriver/nano100_wwdt.c | 1 + .../device/StdDriver/nano100_wwdt.h | 1 + .../TARGET_NANO100/device/cmsis.h | 1 + .../TARGET_NANO100/device/cmsis_nvic.c | 1 + .../TARGET_NANO100/device/cmsis_nvic.h | 1 + .../device/startup_Nano100Series.c | 1 + targets/TARGET_NUVOTON/TARGET_NANO100/dma.h | 1 + .../TARGET_NUVOTON/TARGET_NANO100/dma_api.c | 1 + .../TARGET_NUVOTON/TARGET_NANO100/gpio_api.c | 1 + .../TARGET_NANO100/gpio_irq_api.c | 1 + .../TARGET_NANO100/gpio_object.h | 1 + .../TARGET_NUVOTON/TARGET_NANO100/i2c_api.c | 2 + .../TARGET_NUVOTON/TARGET_NANO100/lp_ticker.c | 1 + .../TARGET_NANO100/mbed_overrides.c | 1 + .../TARGET_NUVOTON/TARGET_NANO100/objects.h | 1 + .../TARGET_NUVOTON/TARGET_NANO100/pinmap.c | 1 + .../TARGET_NUVOTON/TARGET_NANO100/port_api.c | 1 + .../TARGET_NANO100/pwmout_api.c | 2 + .../TARGET_NANO100/reset_reason.c | 1 + .../TARGET_NUVOTON/TARGET_NANO100/rtc_api.c | 1 + .../TARGET_NANO100/serial_api.c | 2 + targets/TARGET_NUVOTON/TARGET_NANO100/sleep.c | 1 + .../TARGET_NUVOTON/TARGET_NANO100/spi_api.c | 1 + .../TARGET_NUVOTON/TARGET_NANO100/us_ticker.c | 1 + .../TARGET_NANO100/watchdog_api.c | 1 + .../TARGET_NUC472/PeripheralNames.h | 1 + .../TARGET_NUC472/PeripheralPins.c | 1 + .../TARGET_NUC472/PeripheralPins.h | 1 + .../TARGET_NUVOTON/TARGET_NUC472/PinNames.h | 34 ++-- .../TARGET_NUVOTON/TARGET_NUC472/PortNames.h | 1 + .../TARGET_NUC472/analogin_api.c | 2 + .../TARGET_NUVOTON/TARGET_NUC472/can_api.c | 53 ++++- .../TARGET_NUC472/crypto/crypto-misc.cpp | 1 + .../TARGET_NUC472/crypto/crypto-misc.h | 1 + targets/TARGET_NUVOTON/TARGET_NUC472/device.h | 1 + .../device/StdDriver/nuc472_adc.c | 1 + .../device/StdDriver/nuc472_adc.h | 1 + .../device/StdDriver/nuc472_can.c | 25 ++- .../device/StdDriver/nuc472_can.h | 3 +- .../device/StdDriver/nuc472_cap.h | 1 + .../device/StdDriver/nuc472_clk.c | 1 + .../device/StdDriver/nuc472_clk.h | 1 + .../device/StdDriver/nuc472_emac.c | 1 + .../device/StdDriver/nuc472_emac.h | 1 + .../device/StdDriver/nuc472_fmc.c | 1 + .../device/StdDriver/nuc472_fmc.h | 1 + .../device/StdDriver/nuc472_pdma.c | 1 + .../device/StdDriver/nuc472_pdma.h | 1 + .../device/StdDriver/nuc472_ps2.c | 1 + .../device/StdDriver/nuc472_ps2.h | 1 + .../device/StdDriver/nuc472_pwm.h | 1 + .../device/StdDriver/nuc472_rtc.c | 1 + .../device/StdDriver/nuc472_rtc.h | 1 + .../device/StdDriver/nuc472_sd.c | 1 + .../device/StdDriver/nuc472_sd.h | 1 + .../device/StdDriver/nuc472_sys.c | 1 + .../device/StdDriver/nuc472_sys.h | 1 + .../device/StdDriver/nuc472_timer.c | 1 + .../device/StdDriver/nuc472_timer.h | 1 + .../device/StdDriver/nuc472_uart.c | 1 + .../device/StdDriver/nuc472_uart.h | 1 + .../device/StdDriver/nuc472_wdt.c | 1 + .../device/StdDriver/nuc472_wdt.h | 1 + .../device/StdDriver/nuc472_wwdt.c | 1 + .../device/StdDriver/nuc472_wwdt.h | 1 + .../TARGET_NUC472/device/cmsis.h | 1 + .../TARGET_NUC472/device/cmsis_nvic.h | 1 + .../TARGET_NUC472/device/system_NUC472_442.c | 1 + .../TARGET_NUC472/device/system_NUC472_442.h | 1 + targets/TARGET_NUVOTON/TARGET_NUC472/dma.h | 1 + .../TARGET_NUVOTON/TARGET_NUC472/dma_api.c | 1 + .../TARGET_NUVOTON/TARGET_NUC472/flash_api.c | 1 + .../TARGET_NUVOTON/TARGET_NUC472/gpio_api.c | 1 + .../TARGET_NUC472/gpio_irq_api.c | 1 + .../TARGET_NUC472/gpio_object.h | 1 + .../TARGET_NUVOTON/TARGET_NUC472/i2c_api.c | 2 + .../TARGET_NUVOTON/TARGET_NUC472/lp_ticker.c | 1 + .../TARGET_NUC472/mbed_overrides.c | 1 + .../TARGET_NUVOTON/TARGET_NUC472/objects.h | 1 + targets/TARGET_NUVOTON/TARGET_NUC472/pinmap.c | 1 + .../TARGET_NUVOTON/TARGET_NUC472/port_api.c | 1 + .../TARGET_NUVOTON/TARGET_NUC472/pwmout_api.c | 2 + .../TARGET_NUC472/reset_reason.c | 1 + .../TARGET_NUVOTON/TARGET_NUC472/rtc_api.c | 1 + .../TARGET_NUVOTON/TARGET_NUC472/serial_api.c | 2 + targets/TARGET_NUVOTON/TARGET_NUC472/sleep.c | 1 + .../TARGET_NUVOTON/TARGET_NUC472/spi_api.c | 1 + .../TARGET_NUVOTON/TARGET_NUC472/us_ticker.c | 1 + .../TARGET_NUC472/watchdog_api.c | 1 + .../TARGET_NUVOTON/USBEndpoints_Nuvoton.cpp | 14 ++ targets/TARGET_NUVOTON/nu_bitutil.h | 1 + targets/TARGET_NUVOTON/nu_miscutil.c | 1 + targets/TARGET_NUVOTON/nu_miscutil.h | 1 + targets/TARGET_NUVOTON/nu_modutil.c | 1 + targets/TARGET_NUVOTON/nu_modutil.h | 1 + targets/TARGET_NUVOTON/nu_timer.c | 1 + targets/TARGET_NUVOTON/nu_timer.h | 4 +- targets/TARGET_STM/TARGET_STM32F1/objects.h | 3 + targets/TARGET_STM/TARGET_STM32F2/objects.h | 3 + targets/TARGET_STM/TARGET_STM32F4/objects.h | 2 + targets/TARGET_STM/TARGET_STM32L1/objects.h | 2 + targets/TARGET_STM/can_api.c | 18 +- targets/TARGET_STM/i2c_api.c | 12 +- targets/TARGET_STM/serial_api.c | 3 + targets/TARGET_STM/stm_i2c_api.h | 2 + targets/cmsis_mcu_descriptions.json5 | 94 +++++++++ targets/targets.json5 | 13 +- 236 files changed, 1204 insertions(+), 170 deletions(-) create mode 100755 targets/TARGET_Maxim/TARGET_MAX32670/TARGET_XDOT_MAX32670/CMakeLists.txt create mode 100755 targets/TARGET_Maxim/TARGET_MAX32670/TARGET_XDOT_MAX32670/PeripheralNames.h create mode 100755 targets/TARGET_Maxim/TARGET_MAX32670/TARGET_XDOT_MAX32670/PinNames.h create mode 100755 targets/TARGET_Maxim/TARGET_MAX32670/TARGET_XDOT_MAX32670/SystemInit.c diff --git a/connectivity/FEATURE_BLE/include/ble/gap/ScanParameters.h b/connectivity/FEATURE_BLE/include/ble/gap/ScanParameters.h index f6d1d82cfd8..5628c8967b3 100644 --- a/connectivity/FEATURE_BLE/include/ble/gap/ScanParameters.h +++ b/connectivity/FEATURE_BLE/include/ble/gap/ScanParameters.h @@ -82,7 +82,7 @@ class ScanParameters { /** * Get the scan interval. */ - const scan_window_t &getInterval() const + const scan_interval_t &getInterval() const { return interval; } @@ -90,7 +90,7 @@ class ScanParameters { /** * Get the scan window. */ - const scan_interval_t &getWindow() const + const scan_window_t &getWindow() const { return window; } @@ -121,8 +121,8 @@ class ScanParameters { */ ScanParameters( phy_t phy = phy_t::LE_1M, - scan_window_t scan_interval = scan_interval_t::min(), - scan_interval_t scan_window = scan_window_t::min(), + scan_interval_t scan_interval = scan_interval_t::min(), + scan_window_t scan_window = scan_window_t::min(), bool active_scanning = false, own_address_type_t own_address_type = own_address_type_t::RANDOM, scanning_filter_policy_t scanning_filter_policy = scanning_filter_policy_t::NO_FILTER diff --git a/connectivity/cellular/include/cellular/framework/API/ATHandler.h b/connectivity/cellular/include/cellular/framework/API/ATHandler.h index 7222daf47a0..02499118ccc 100644 --- a/connectivity/cellular/include/cellular/framework/API/ATHandler.h +++ b/connectivity/cellular/include/cellular/framework/API/ATHandler.h @@ -318,6 +318,13 @@ class ATHandler { */ void skip_param(ssize_t len, uint32_t count); + /** Consumes the given length from the reading buffer even if the stop tag has been found + * + * @param len length to be consumed from reading buffer + * @param count number of parameters to be skipped + */ + void skip_param_bytes(ssize_t len, uint32_t count); + /** Reads given number of bytes from receiving buffer without checking any subparameter delimiters, such as comma. * * @param buf output buffer for the read @@ -408,6 +415,12 @@ class ATHandler { */ bool consume_to_stop_tag(); + /** Consumes the received content until current stop tag is found even if stop tag has been found previously + * + * @return true if stop tag is found, false otherwise + */ + bool consume_to_stop_tag_even_found(); + /** Return the last 3GPP error code. * @return last 3GPP error code */ diff --git a/connectivity/cellular/source/framework/AT/AT_CellularSMS.cpp b/connectivity/cellular/source/framework/AT/AT_CellularSMS.cpp index 79ebc908733..c7ad6a537b3 100644 --- a/connectivity/cellular/source/framework/AT/AT_CellularSMS.cpp +++ b/connectivity/cellular/source/framework/AT/AT_CellularSMS.cpp @@ -420,6 +420,7 @@ nsapi_size_or_error_t AT_CellularSMS::send_sms(const char *phone_number, const c } _at.lock(); + _at.set_at_timeout(10s); int write_size = 0; @@ -437,6 +438,7 @@ nsapi_size_or_error_t AT_CellularSMS::send_sms(const char *phone_number, const c // sending can be cancelled by giving character (IRA 27). _at.cmd_start(ESC); _at.cmd_stop(); + _at.restore_at_timeout(); _at.unlock(); return write_size; } @@ -482,6 +484,7 @@ nsapi_size_or_error_t AT_CellularSMS::send_sms(const char *phone_number, const c pdu_str = create_pdu(phone_number, message + i * concatenated_sms_length, pdu_len, sms_count, i + 1, header_len); if (!pdu_str) { + _at.restore_at_timeout(); _at.unlock(); return NSAPI_ERROR_NO_MEMORY; } @@ -509,6 +512,7 @@ nsapi_size_or_error_t AT_CellularSMS::send_sms(const char *phone_number, const c // sending can be cancelled by giving character (IRA 27). _at.cmd_start(ESC); _at.cmd_stop(); + _at.restore_at_timeout(); _at.unlock(); delete [] pdu_str; return msg_write_len; @@ -523,6 +527,7 @@ nsapi_size_or_error_t AT_CellularSMS::send_sms(const char *phone_number, const c delete [] pdu_str; remaining_len -= concatenated_sms_length; if (_at.get_last_error() != NSAPI_ERROR_OK) { + _at.restore_at_timeout(); return _at.unlock_return_error(); } } @@ -530,6 +535,7 @@ nsapi_size_or_error_t AT_CellularSMS::send_sms(const char *phone_number, const c _sms_message_ref_number++; nsapi_error_t ret = _at.get_last_error(); + _at.restore_at_timeout(); _at.unlock(); return (ret == NSAPI_ERROR_OK) ? msg_len : ret; @@ -697,6 +703,7 @@ nsapi_size_or_error_t AT_CellularSMS::get_sms(char *buf, uint16_t len, char *pho } _at.lock(); + _at.set_at_timeout(10s); nsapi_size_or_error_t err = list_messages(); if (err == NSAPI_ERROR_OK) { @@ -710,6 +717,7 @@ nsapi_size_or_error_t AT_CellularSMS::get_sms(char *buf, uint16_t len, char *pho *buf_size = info->msg_size; } free_linked_list(); + _at.restore_at_timeout(); _at.unlock(); return NSAPI_ERROR_PARAMETER; } @@ -734,6 +742,7 @@ nsapi_size_or_error_t AT_CellularSMS::get_sms(char *buf, uint16_t len, char *pho free_linked_list(); + _at.restore_at_timeout(); _at.unlock(); // update error only when there really was an error, otherwise we return the length @@ -1027,6 +1036,7 @@ nsapi_error_t AT_CellularSMS::list_messages() int index = 0; int length = 0; char *pdu = NULL; + char buffer[32]; // 32 > SMS_STATUS_SIZE, SMS_MAX_PHONE_NUMBER_SIZE, SMS_MAX_TIME_STAMP_SIZE _at.resp_start("+CMGL:"); while (_at.info_resp()) { @@ -1049,8 +1059,18 @@ nsapi_error_t AT_CellularSMS::list_messages() // +CMGL: ,,,[],[][,,][ // +CMGL: ,,,[],[][,,][...]] index = _at.read_int(); - (void)_at.consume_to_stop_tag(); // consume until - (void)_at.consume_to_stop_tag(); // consume until + _at.read_string(buffer, SMS_STATUS_SIZE); + _at.read_string(buffer, SMS_MAX_PHONE_NUMBER_SIZE); + _at.skip_param(); // + _at.read_string(buffer, SMS_MAX_TIME_STAMP_SIZE); + _at.read_int(); + int size = _at.read_int(); // length + _at.consume_to_stop_tag(); // consume until end of header + if (size > 0) { + // we can not use skip param because we already consumed stop tag + _at.skip_param_bytes(size, 1); + } + _at.consume_to_stop_tag_even_found(); // consume until -> data } if (index >= 0) { diff --git a/connectivity/cellular/source/framework/device/ATHandler.cpp b/connectivity/cellular/source/framework/device/ATHandler.cpp index 034d586a142..7388bd4eb4a 100644 --- a/connectivity/cellular/source/framework/device/ATHandler.cpp +++ b/connectivity/cellular/source/framework/device/ATHandler.cpp @@ -484,6 +484,26 @@ void ATHandler::skip_param(ssize_t len, uint32_t count) return; } +void ATHandler::skip_param_bytes(ssize_t len, uint32_t count) +{ + if (!ok_to_proceed()) { + return; + } + + for (uint32_t i = 0; i < count; i++) { + ssize_t read_len = 0; + while (read_len < len) { + int c = get_char(); + if (c == -1) { + set_error(NSAPI_ERROR_DEVICE_ERROR); + return; + } + read_len++; + } + } + return; +} + ssize_t ATHandler::read_bytes(uint8_t *buf, size_t len) { if (!ok_to_proceed()) { @@ -1093,6 +1113,26 @@ bool ATHandler::consume_to_stop_tag() return false; } + +bool ATHandler::consume_to_stop_tag_even_found() +{ + if (_error_found) { + return true; + } + + if (!_is_fh_usable) { + _last_err = NSAPI_ERROR_BUSY; + return true; + } + + if (consume_to_tag((const char *)_stop_tag->tag, true)) { + return true; + } + + clear_error(); + return false; +} + // consume by size needed? void ATHandler::resp_stop() diff --git a/connectivity/cellular/tests/UNITTESTS/doubles/ATHandler_stub.cpp b/connectivity/cellular/tests/UNITTESTS/doubles/ATHandler_stub.cpp index c5b9c7ce673..1f11e035085 100644 --- a/connectivity/cellular/tests/UNITTESTS/doubles/ATHandler_stub.cpp +++ b/connectivity/cellular/tests/UNITTESTS/doubles/ATHandler_stub.cpp @@ -201,6 +201,10 @@ void ATHandler::skip_param(ssize_t len, uint32_t count) { } +void ATHandler::skip_param_bytes(ssize_t len, uint32_t count) +{ +} + ssize_t ATHandler::read_bytes(uint8_t *buf, size_t len) { return ATHandler_stub::ssize_value; @@ -301,6 +305,11 @@ bool ATHandler::consume_to_stop_tag() return ATHandler_stub::bool_value; } +bool ATHandler::consume_to_stop_tag_even_found() +{ + return ATHandler_stub::bool_value; +} + void ATHandler::resp_stop() { if (ATHandler_stub::resp_stop_success_count > 0) { diff --git a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularsms/at_cellularsmstest.cpp b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularsms/at_cellularsmstest.cpp index 4f4b1d9bc02..87c56bd197c 100644 --- a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularsms/at_cellularsmstest.cpp +++ b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularsms/at_cellularsmstest.cpp @@ -155,8 +155,16 @@ TEST_F(TestAT_CellularSMS, test_AT_CellularSMS_get_sms) ATHandler_stub::resp_info_false_counter = 1; ATHandler_stub::resp_info_true_counter2 = 2; ATHandler_stub::int_value = 11; - ATHandler_stub::read_string_index = 4; - ATHandler_stub::read_string_table[4] = ""; + ATHandler_stub::read_string_index = (3 * 2) + (2 * 2); // 3 read_string in list_messages + 2 read_string in read_sms_from_index + ATHandler_stub::read_string_table[10] = ""; + // list_messages + ATHandler_stub::read_string_table[9] = "1"; // status + ATHandler_stub::read_string_table[8] = "+00611223344"; // phone + ATHandler_stub::read_string_table[7] = "24/12/12,11:15:00+04"; // timestamp + ATHandler_stub::read_string_table[6] = "1"; // status + ATHandler_stub::read_string_table[5] = "+00611223344"; // phone + ATHandler_stub::read_string_table[4] = "24/12/12,11:15:00+04"; // timestamp + // read_sms_from_index ATHandler_stub::read_string_table[3] = "REC READ"; ATHandler_stub::read_string_table[2] = "09/01/12,11:15:00+04"; ATHandler_stub::read_string_table[1] = "REC READ"; diff --git a/connectivity/drivers/emac/TARGET_NUVOTON_EMAC/TARGET_M460/m460_eth.c b/connectivity/drivers/emac/TARGET_NUVOTON_EMAC/TARGET_M460/m460_eth.c index 591de2204f2..275a3af904e 100644 --- a/connectivity/drivers/emac/TARGET_NUVOTON_EMAC/TARGET_M460/m460_eth.c +++ b/connectivity/drivers/emac/TARGET_NUVOTON_EMAC/TARGET_M460/m460_eth.c @@ -20,6 +20,7 @@ //#include #include "m460_eth.h" #include "mbed_toolchain.h" +#include "mbed_interface.h" //#define NU_TRACE #include "numaker_eth_hal.h" diff --git a/connectivity/drivers/emac/TARGET_NUVOTON_EMAC/TARGET_M480/m480_eth.c b/connectivity/drivers/emac/TARGET_NUVOTON_EMAC/TARGET_M480/m480_eth.c index 6543beac6fa..30de209f81c 100644 --- a/connectivity/drivers/emac/TARGET_NUVOTON_EMAC/TARGET_M480/m480_eth.c +++ b/connectivity/drivers/emac/TARGET_NUVOTON_EMAC/TARGET_M480/m480_eth.c @@ -20,6 +20,7 @@ #include #include "m480_eth.h" #include "mbed_toolchain.h" +#include "mbed_interface.h" //#define NU_TRACE #include "numaker_eth_hal.h" diff --git a/connectivity/drivers/emac/TARGET_NUVOTON_EMAC/TARGET_NUC472/nuc472_eth.c b/connectivity/drivers/emac/TARGET_NUVOTON_EMAC/TARGET_NUC472/nuc472_eth.c index 209fb024724..d9dbb51d779 100644 --- a/connectivity/drivers/emac/TARGET_NUVOTON_EMAC/TARGET_NUC472/nuc472_eth.c +++ b/connectivity/drivers/emac/TARGET_NUVOTON_EMAC/TARGET_NUC472/nuc472_eth.c @@ -20,6 +20,7 @@ #include #include "nuc472_eth.h" #include "mbed_toolchain.h" +#include "mbed_interface.h" //#define NU_TRACE #include "numaker_eth_hal.h" diff --git a/connectivity/drivers/lora/COMPONENT_SX126X/SX126X_LoRaRadio.cpp b/connectivity/drivers/lora/COMPONENT_SX126X/SX126X_LoRaRadio.cpp index 6033074c78d..26fd8f42908 100644 --- a/connectivity/drivers/lora/COMPONENT_SX126X/SX126X_LoRaRadio.cpp +++ b/connectivity/drivers/lora/COMPONENT_SX126X/SX126X_LoRaRadio.cpp @@ -437,7 +437,7 @@ void SX126X_LoRaRadio::cold_start_wakeup() if (MBED_CONF_SX126X_LORA_DRIVER_XTAL == 0) { #endif caliberation_params_t calib_param; - set_dio3_as_tcxo_ctrl(TCXO_CTRL_1_7V, 320); //5 ms + set_dio3_as_tcxo_ctrl(MBED_CONF_SX126X_LORA_DRIVER_TCXO_CTRL, 320); //5 ms calib_param.value = 0x7F; write_opmode_command(RADIO_CALIBRATE, &calib_param.value, 1); } diff --git a/connectivity/drivers/lora/COMPONENT_SX126X/mbed_lib.json b/connectivity/drivers/lora/COMPONENT_SX126X/mbed_lib.json index 6fcdf16f05b..5e068ea0525 100644 --- a/connectivity/drivers/lora/COMPONENT_SX126X/mbed_lib.json +++ b/connectivity/drivers/lora/COMPONENT_SX126X/mbed_lib.json @@ -38,6 +38,10 @@ "help": "Default: -1 = use crystal-select, TXCO = 0, XTAL = 1", "value": -1 }, + "tcxo-ctrl": { + "help": "TCXO Control voltage. Default: TCXO control TCXO_CTRL_1_7V (RAK4630 use TCXO_CTRL_3_0V)", + "value": "TCXO_CTRL_1_7V" + }, "spi-mosi": { "value": "NC" }, diff --git a/connectivity/drivers/wifi/COMPONENT_ESPRESSIF_ESP8266/ESP8266/ESP8266.cpp b/connectivity/drivers/wifi/COMPONENT_ESPRESSIF_ESP8266/ESP8266/ESP8266.cpp index 12439e9180c..ee11fdefea0 100644 --- a/connectivity/drivers/wifi/COMPONENT_ESPRESSIF_ESP8266/ESP8266/ESP8266.cpp +++ b/connectivity/drivers/wifi/COMPONENT_ESPRESSIF_ESP8266/ESP8266/ESP8266.cpp @@ -1190,7 +1190,7 @@ bool ESP8266::get_sntp_config(bool *enable, int *timezone, char *server0, &tmp, timezone, server0, server1, server2) && _parser.recv("OK\n"); _smutex.unlock(); - *enable = tmp ? true : false; + *enable = (done && tmp) ? true : false; return done; } diff --git a/connectivity/lorawan/lorastack/mac/LoRaMac.cpp b/connectivity/lorawan/lorastack/mac/LoRaMac.cpp index 7ea1ec2f195..fca30bad90b 100644 --- a/connectivity/lorawan/lorastack/mac/LoRaMac.cpp +++ b/connectivity/lorawan/lorastack/mac/LoRaMac.cpp @@ -1137,6 +1137,9 @@ lorawan_status_t LoRaMac::schedule_tx() if (backoff_time != 0) { tr_debug("DC enforced: Transmitting in %lu ms", backoff_time); _can_cancel_tx = true; + if (_device_class != CLASS_C) { + _lora_phy->put_radio_to_sleep(); + } _lora_time.start(_params.timers.backoff_timer, backoff_time); } return LORAWAN_STATUS_OK; diff --git a/connectivity/lorawan/lorastack/phy/LoRaPHYAS923.cpp b/connectivity/lorawan/lorastack/phy/LoRaPHYAS923.cpp index 41d7053053f..753e6154a81 100644 --- a/connectivity/lorawan/lorastack/phy/LoRaPHYAS923.cpp +++ b/connectivity/lorawan/lorastack/phy/LoRaPHYAS923.cpp @@ -187,7 +187,11 @@ /*! * Default antenna gain */ +#ifdef LORAPHY_ANTENNA_GAIN +#define AS923_DEFAULT_ANTENNA_GAIN LORAPHY_ANTENNA_GAIN +#else #define AS923_DEFAULT_ANTENNA_GAIN 2.15f +#endif /*! * ADR Ack limit diff --git a/connectivity/lorawan/lorastack/phy/LoRaPHYAU915.cpp b/connectivity/lorawan/lorastack/phy/LoRaPHYAU915.cpp index 24c8519000a..82f2e36864b 100644 --- a/connectivity/lorawan/lorastack/phy/LoRaPHYAU915.cpp +++ b/connectivity/lorawan/lorastack/phy/LoRaPHYAU915.cpp @@ -96,7 +96,11 @@ /*! * Default antenna gain */ +#ifdef LORAPHY_ANTENNA_GAIN +#define AU915_DEFAULT_ANTENNA_GAIN LORAPHY_ANTENNA_GAIN +#else #define AU915_DEFAULT_ANTENNA_GAIN 2.15f +#endif /*! * ADR Ack limit diff --git a/connectivity/lorawan/lorastack/phy/LoRaPHYCN470.cpp b/connectivity/lorawan/lorastack/phy/LoRaPHYCN470.cpp index 3385cfe6693..47a9c8e65f8 100644 --- a/connectivity/lorawan/lorastack/phy/LoRaPHYCN470.cpp +++ b/connectivity/lorawan/lorastack/phy/LoRaPHYCN470.cpp @@ -95,7 +95,11 @@ /*! * Default antenna gain */ +#ifdef LORAPHY_ANTENNA_GAIN +#define CN470_DEFAULT_ANTENNA_GAIN LORAPHY_ANTENNA_GAIN +#else #define CN470_DEFAULT_ANTENNA_GAIN 2.15f +#endif /*! * ADR Ack limit diff --git a/connectivity/lorawan/lorastack/phy/LoRaPHYCN779.cpp b/connectivity/lorawan/lorastack/phy/LoRaPHYCN779.cpp index d19e95efb13..6d60c6dafb6 100644 --- a/connectivity/lorawan/lorastack/phy/LoRaPHYCN779.cpp +++ b/connectivity/lorawan/lorastack/phy/LoRaPHYCN779.cpp @@ -107,7 +107,11 @@ /*! * Default antenna gain */ +#ifdef LORAPHY_ANTENNA_GAIN +#define CN779_DEFAULT_ANTENNA_GAIN LORAPHY_ANTENNA_GAIN +#else #define CN779_DEFAULT_ANTENNA_GAIN 2.15f +#endif /*! * ADR Ack limit diff --git a/connectivity/lorawan/lorastack/phy/LoRaPHYEU433.cpp b/connectivity/lorawan/lorastack/phy/LoRaPHYEU433.cpp index 50d60ffd507..b22ac6b8ab9 100644 --- a/connectivity/lorawan/lorastack/phy/LoRaPHYEU433.cpp +++ b/connectivity/lorawan/lorastack/phy/LoRaPHYEU433.cpp @@ -107,7 +107,11 @@ /*! * Default antenna gain */ +#ifdef LORAPHY_ANTENNA_GAIN +#define EU433_DEFAULT_ANTENNA_GAIN LORAPHY_ANTENNA_GAIN +#else #define EU433_DEFAULT_ANTENNA_GAIN 2.15f +#endif /*! * ADR Ack limit diff --git a/connectivity/lorawan/lorastack/phy/LoRaPHYEU868.cpp b/connectivity/lorawan/lorastack/phy/LoRaPHYEU868.cpp index ba1301c015b..5a7f0fd8dfc 100644 --- a/connectivity/lorawan/lorastack/phy/LoRaPHYEU868.cpp +++ b/connectivity/lorawan/lorastack/phy/LoRaPHYEU868.cpp @@ -107,7 +107,11 @@ /*! * Default antenna gain */ +#ifdef LORAPHY_ANTENNA_GAIN +#define EU868_DEFAULT_ANTENNA_GAIN LORAPHY_ANTENNA_GAIN +#else #define EU868_DEFAULT_ANTENNA_GAIN 2.15f +#endif /*! * ADR Ack limit diff --git a/connectivity/lorawan/lorastack/phy/LoRaPHYIN865.cpp b/connectivity/lorawan/lorastack/phy/LoRaPHYIN865.cpp index bdcfcc24a3f..4f5e2fbbd16 100644 --- a/connectivity/lorawan/lorastack/phy/LoRaPHYIN865.cpp +++ b/connectivity/lorawan/lorastack/phy/LoRaPHYIN865.cpp @@ -107,7 +107,11 @@ /*! * Default antenna gain */ +#ifdef LORAPHY_ANTENNA_GAIN +#define IN865_DEFAULT_ANTENNA_GAIN LORAPHY_ANTENNA_GAIN +#else #define IN865_DEFAULT_ANTENNA_GAIN 2.15f +#endif /*! * ADR Ack limit diff --git a/connectivity/lorawan/lorastack/phy/LoRaPHYKR920.cpp b/connectivity/lorawan/lorastack/phy/LoRaPHYKR920.cpp index e5df591e613..1de90021861 100644 --- a/connectivity/lorawan/lorastack/phy/LoRaPHYKR920.cpp +++ b/connectivity/lorawan/lorastack/phy/LoRaPHYKR920.cpp @@ -111,7 +111,11 @@ /*! * Default antenna gain */ +#ifdef LORAPHY_ANTENNA_GAIN +#define KR920_DEFAULT_ANTENNA_GAIN LORAPHY_ANTENNA_GAIN +#else #define KR920_DEFAULT_ANTENNA_GAIN 2.15f +#endif /*! * ADR Ack limit diff --git a/connectivity/lorawan/lorastack/phy/LoRaPHYUS915.cpp b/connectivity/lorawan/lorastack/phy/LoRaPHYUS915.cpp index 9882b5ea6c3..f32ed93e59f 100644 --- a/connectivity/lorawan/lorastack/phy/LoRaPHYUS915.cpp +++ b/connectivity/lorawan/lorastack/phy/LoRaPHYUS915.cpp @@ -94,6 +94,15 @@ */ #define US915_DEFAULT_MAX_ERP 30.0f +/*! + * Default antenna gain + */ +#ifdef LORAPHY_ANTENNA_GAIN +#define US915_DEFAULT_ANTENNA_GAIN LORAPHY_ANTENNA_GAIN +#else +#define US915_DEFAULT_ANTENNA_GAIN 0.00f +#endif + /*! * ADR Ack limit */ @@ -299,7 +308,7 @@ LoRaPHYUS915::LoRaPHYUS915() phy_params.max_tx_power = US915_MAX_TX_POWER; phy_params.default_tx_power = US915_DEFAULT_TX_POWER; phy_params.default_max_eirp = 0; - phy_params.default_antenna_gain = 0; + phy_params.default_antenna_gain = US915_DEFAULT_ANTENNA_GAIN; phy_params.adr_ack_limit = US915_ADR_ACK_LIMIT; phy_params.adr_ack_delay = US915_ADR_ACK_DELAY; phy_params.max_rx_window = US915_MAX_RX_WINDOW; diff --git a/connectivity/lorawan/mbed_lib.json b/connectivity/lorawan/mbed_lib.json index 3b8bcbb58e1..576f4092afd 100644 --- a/connectivity/lorawan/mbed_lib.json +++ b/connectivity/lorawan/mbed_lib.json @@ -102,7 +102,8 @@ "target_overrides": { "STM32WL": { "wakeup-time": 3, - "max-sys-rx-error": 10 + "max-sys-rx-error": 10, + "downlink-preamble-length": 8 } } } diff --git a/drivers/usb/include/usb/USBCDC.h b/drivers/usb/include/usb/USBCDC.h index 777b352ad00..8e75b567093 100644 --- a/drivers/usb/include/usb/USBCDC.h +++ b/drivers/usb/include/usb/USBCDC.h @@ -230,6 +230,7 @@ class USBCDC: public USBDevice { uint8_t _rx_buffer[CDC_MAX_PACKET_SIZE]; uint8_t *_rx_buf; uint32_t _rx_size; + bool _trans_zlp; }; /** @}*/ diff --git a/drivers/usb/source/USBCDC.cpp b/drivers/usb/source/USBCDC.cpp index 9cf1ed04d9e..c42bead6d51 100644 --- a/drivers/usb/source/USBCDC.cpp +++ b/drivers/usb/source/USBCDC.cpp @@ -39,7 +39,7 @@ class USBCDC::AsyncWrite: public AsyncOp { AsyncWrite(USBCDC *serial, uint8_t *buf, uint32_t size): serial(serial), tx_buf(buf), tx_size(size), result(false) { - + need_zlp = (size % CDC_MAX_PACKET_SIZE == 0) ? true : false; } virtual ~AsyncWrite() @@ -59,6 +59,12 @@ class USBCDC::AsyncWrite: public AsyncOp { tx_size -= actual_size; tx_buf += actual_size; if (tx_size == 0) { + // For ZLP case, not ending yet and need one more time to invoke process to send zero packet. + if (need_zlp) { + need_zlp = false; + serial->_send_isr_start(); + return false; + } result = true; return true; } @@ -72,6 +78,7 @@ class USBCDC::AsyncWrite: public AsyncOp { uint8_t *tx_buf; uint32_t tx_size; bool result; + bool need_zlp; }; class USBCDC::AsyncRead: public AsyncOp { @@ -186,6 +193,7 @@ void USBCDC::_init() _rx_in_progress = false; _rx_buf = _rx_buffer; _rx_size = 0; + _trans_zlp = false; } void USBCDC::callback_reset() @@ -383,10 +391,16 @@ void USBCDC::send_nb(uint8_t *buffer, uint32_t size, uint32_t *actual, bool now) uint32_t free = sizeof(_tx_buffer) - _tx_size; uint32_t write_size = free > size ? size : free; if (size > 0) { - memcpy(_tx_buf, buffer, write_size); + memcpy(_tx_buf + _tx_size, buffer, write_size); } _tx_size += write_size; *actual = write_size; + + /* Enable ZLP flag as while send_nb() zero size */ + if (size == 0) { + _trans_zlp = true; + } + if (now) { _send_isr_start(); } @@ -404,6 +418,14 @@ void USBCDC::_send_isr_start() _tx_in_progress = true; } } + + /* Send ZLP write start */ + if (!_tx_in_progress && _trans_zlp) { + if (USBDevice::write_start(_bulk_in, _tx_buffer, 0)) { + _tx_in_progress = true; + _trans_zlp = false; + } + } } /* diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/TARGET_TFM_V8M/src/tfm_mbed_boot.c b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/TARGET_TFM_V8M/src/tfm_mbed_boot.c index 87bcbbbf66d..6016a2ec465 100644 --- a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/TARGET_TFM_V8M/src/tfm_mbed_boot.c +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/TARGET_TFM_V8M/src/tfm_mbed_boot.c @@ -18,6 +18,8 @@ #include "mbed_error.h" #include "tfm_ns_interface.h" +int32_t tfm_ns_interface_init(void); + void mbed_tfm_init(void) { /* diff --git a/storage/blockdevice/COMPONENT_QSPIF/mbed_lib.json b/storage/blockdevice/COMPONENT_QSPIF/mbed_lib.json index ca461079e81..b8082723fe7 100644 --- a/storage/blockdevice/COMPONENT_QSPIF/mbed_lib.json +++ b/storage/blockdevice/COMPONENT_QSPIF/mbed_lib.json @@ -18,11 +18,16 @@ "QSPI_POLARITY_MODE": 0, "QSPI_FREQ": "40000000", "QSPI_MIN_READ_SIZE": "1", - "QSPI_MIN_PROG_SIZE": "1" + "QSPI_MIN_PROG_SIZE": "1", + "QSPI_MACRONIX_NUM_STATUS_REGISTER": { + "help": "For most of Macronix QSPI flashes, they only have 2 status registers. However, some, e.g. MX25R6435F, have 3. This option can be used to control how many status registers the flash is assumed to have.", + "value": "2" + } }, "target_overrides": { "MX25R6435F": { - "QSPI_FREQ": "8000000" + "QSPI_FREQ": "8000000", + "QSPI_MACRONIX_NUM_STATUS_REGISTER":"3" }, "MX25L51245G": { "QSPI_FREQ": "8000000" diff --git a/storage/blockdevice/COMPONENT_QSPIF/source/QSPIFBlockDevice.cpp b/storage/blockdevice/COMPONENT_QSPIF/source/QSPIFBlockDevice.cpp index e1dabf46a1c..1954f5182d4 100644 --- a/storage/blockdevice/COMPONENT_QSPIF/source/QSPIFBlockDevice.cpp +++ b/storage/blockdevice/COMPONENT_QSPIF/source/QSPIFBlockDevice.cpp @@ -25,6 +25,10 @@ #define MBED_CONF_MBED_TRACE_ENABLE 0 #endif +#ifndef MBED_CONF_QSPI_MACRONIX_NUM_STATUS_REGISTER +#define MBED_CONF_QSPI_MACRONIX_NUM_STATUS_REGISTER 2 +#endif + #include "mbed-trace/mbed_trace.h" #define TRACE_GROUP "QSPIF" @@ -1108,12 +1112,12 @@ int QSPIFBlockDevice::_handle_vendor_quirks() break; case 0xc2: // Macronix devices have several quirks: - // 1. Have one status register and 2 config registers, with a nonstandard instruction for reading the config registers + // 1. Have one status register and several config registers, with a nonstandard instruction for reading the config registers // 2. Require setting a "fast mode" bit in config register 2 to operate at higher clock rates // 3. Should never attempt to enable 4-byte addressing (it causes reads and writes to fail) tr_debug("Applying quirks for macronix"); _needs_fast_mode = true; - _num_status_registers = 3; + _num_status_registers = MBED_CONF_QSPI_MACRONIX_NUM_STATUS_REGISTER; _read_status_reg_2_inst = QSPIF_INST_RDCR; break; case 0x9d: diff --git a/storage/kvstore/securestore/source/SecureStore.cpp b/storage/kvstore/securestore/source/SecureStore.cpp index be14c105f09..fc2d2d5de38 100644 --- a/storage/kvstore/securestore/source/SecureStore.cpp +++ b/storage/kvstore/securestore/source/SecureStore.cpp @@ -290,7 +290,7 @@ int SecureStore::set_start(set_handle_t *handle, const char *key, size_t final_d goto fail; } - if (create_flags & (REQUIRE_REPLAY_PROTECTION_FLAG | WRITE_ONCE_FLAG)) { + if (_rbp_kv && (create_flags & (REQUIRE_REPLAY_PROTECTION_FLAG | WRITE_ONCE_FLAG))) { _ih->key = new char[strlen(key) + 1]; strcpy(_ih->key, key); } diff --git a/storage/kvstore/tdbstore/source/TDBStore.cpp b/storage/kvstore/tdbstore/source/TDBStore.cpp index 7d8d8822f32..50f490cf370 100644 --- a/storage/kvstore/tdbstore/source/TDBStore.cpp +++ b/storage/kvstore/tdbstore/source/TDBStore.cpp @@ -374,6 +374,10 @@ int TDBStore::read_record(uint8_t area, uint32_t offset, char *key, if (calc_hash) { hash = calc_crc(hash, chunk_size, dest_buf); +#ifdef KVSTORE_RAM_TABLE_NO_CRC_CHECK + next_offset = align_up(offset + total_size, _prog_size); + return ret; +#endif /* KVSTORE_RAM_TABLE_NO_CRC_CHECK */ } user_key_ptr += chunk_size; @@ -1165,6 +1169,7 @@ int TDBStore::deinit() delete[] ram_table; delete[] _work_buf; delete[] _key_buf; + delete reinterpret_cast(_inc_set_handle); } _is_initialized = false; diff --git a/targets/TARGET_Maxim/TARGET_MAX32670/TARGET_MAX32670EVKIT/PeripheralNames.h b/targets/TARGET_Maxim/TARGET_MAX32670/TARGET_MAX32670EVKIT/PeripheralNames.h index b7d88f92c0d..ca7145bab88 100644 --- a/targets/TARGET_Maxim/TARGET_MAX32670/TARGET_MAX32670EVKIT/PeripheralNames.h +++ b/targets/TARGET_Maxim/TARGET_MAX32670/TARGET_MAX32670EVKIT/PeripheralNames.h @@ -29,6 +29,8 @@ * property whatsoever. Maxim Integrated Products, Inc. retains all * ownership rights. ******************************************************************************* + * + * @copyright SPDX-License-Identifier: MIT */ #ifndef MBED_PERIPHERALNAMES_H diff --git a/targets/TARGET_Maxim/TARGET_MAX32670/TARGET_MAX32670EVKIT/PinNames.h b/targets/TARGET_Maxim/TARGET_MAX32670/TARGET_MAX32670EVKIT/PinNames.h index 700d81641ef..1bbe7364e10 100644 --- a/targets/TARGET_Maxim/TARGET_MAX32670/TARGET_MAX32670EVKIT/PinNames.h +++ b/targets/TARGET_Maxim/TARGET_MAX32670/TARGET_MAX32670EVKIT/PinNames.h @@ -29,6 +29,8 @@ * property whatsoever. Maxim Integrated Products, Inc. retains all * ownership rights. ******************************************************************************* + * + * @copyright SPDX-License-Identifier: MIT */ /* MBED TARGET LIST: MAX32670EVKIT */ diff --git a/targets/TARGET_Maxim/TARGET_MAX32670/TARGET_XDOT_MAX32670/CMakeLists.txt b/targets/TARGET_Maxim/TARGET_MAX32670/TARGET_XDOT_MAX32670/CMakeLists.txt new file mode 100755 index 00000000000..9868e2e692b --- /dev/null +++ b/targets/TARGET_Maxim/TARGET_MAX32670/TARGET_XDOT_MAX32670/CMakeLists.txt @@ -0,0 +1,16 @@ +add_library(mbed-xdot-max32670 INTERFACE) + +target_include_directories(mbed-xdot-max32670 + INTERFACE + . +) + +target_link_libraries(mbed-xdot-max32670 + INTERFACE + mbed-max32670 +) + +target_sources(mbed-xdot-max32670 + INTERFACE + SystemInit.c +) diff --git a/targets/TARGET_Maxim/TARGET_MAX32670/TARGET_XDOT_MAX32670/PeripheralNames.h b/targets/TARGET_Maxim/TARGET_MAX32670/TARGET_XDOT_MAX32670/PeripheralNames.h new file mode 100755 index 00000000000..ca7145bab88 --- /dev/null +++ b/targets/TARGET_Maxim/TARGET_MAX32670/TARGET_XDOT_MAX32670/PeripheralNames.h @@ -0,0 +1,74 @@ +/******************************************************************************* + * Copyright (C) Maxim Integrated Products, Inc., All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of Maxim Integrated + * Products, Inc. shall not be used except as stated in the Maxim Integrated + * Products, Inc. Branding Policy. + * + * The mere transfer of this software does not imply any licenses + * of trade secrets, proprietary technology, copyrights, patents, + * trademarks, maskwork rights, or any other form of intellectual + * property whatsoever. Maxim Integrated Products, Inc. retains all + * ownership rights. + ******************************************************************************* + * + * @copyright SPDX-License-Identifier: MIT + */ + +#ifndef MBED_PERIPHERALNAMES_H +#define MBED_PERIPHERALNAMES_H + +#include "cmsis.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + UART_0 = MXC_BASE_UART0, + UART_1 = MXC_BASE_UART1, + UART_2 = MXC_BASE_UART2, + UART_3 = MXC_BASE_UART3, +#if defined(MBED_CONF_TARGET_STDIO_UART) + STDIO_UART = MBED_CONF_TARGET_STDIO_UART, +#else + STDIO_UART = UART_0, +#endif +} UARTName; + +typedef enum { + I2C_0 = MXC_BASE_I2C0, + I2C_1 = MXC_BASE_I2C1, + I2C_2 = MXC_BASE_I2C2, +} I2CName; + +typedef enum { + SPI_0 = MXC_BASE_SPI0, + SPI_1 = MXC_BASE_SPI1, + SPI_2 = MXC_BASE_SPI2, +} SPIName; + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/targets/TARGET_Maxim/TARGET_MAX32670/TARGET_XDOT_MAX32670/PinNames.h b/targets/TARGET_Maxim/TARGET_MAX32670/TARGET_XDOT_MAX32670/PinNames.h new file mode 100755 index 00000000000..2d26b7ca605 --- /dev/null +++ b/targets/TARGET_Maxim/TARGET_MAX32670/TARGET_XDOT_MAX32670/PinNames.h @@ -0,0 +1,191 @@ +/******************************************************************************* + * Copyright (C) 2022 Maxim Integrated Products, Inc., All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of Maxim Integrated + * Products, Inc. shall not be used except as stated in the Maxim Integrated + * Products, Inc. Branding Policy. + * + * The mere transfer of this software does not imply any licenses + * of trade secrets, proprietary technology, copyrights, patents, + * trademarks, maskwork rights, or any other form of intellectual + * property whatsoever. Maxim Integrated Products, Inc. retains all + * ownership rights. + ******************************************************************************* + * + * @copyright SPDX-License-Identifier: MIT + */ + +/* MBED TARGET LIST: MAX32670EVKIT */ + +#ifndef MBED_PINNAMES_H +#define MBED_PINNAMES_H + +#include "cmsis.h" +#include "gpio_regs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + PIN_INPUT = 0, + PIN_OUTPUT = 1 +} PinDirection; + +#define PORT_SHIFT 12 + +#define PINNAME_TO_PORT(name) ((unsigned int)(name) >> PORT_SHIFT) +#define PINNAME_TO_PIN(name) ((unsigned int)(name) & ~(0xFFFFFFFF << PORT_SHIFT)) +#define NOT_CONNECTED (int)0xFFFFFFFF + +typedef enum { + // Port 0 + P0_0 = (0 << PORT_SHIFT), + P0_1, P0_2, P0_3, P0_4, P0_5, P0_6, P0_7, P0_8, P0_9, P0_10, P0_11, P0_12, P0_13, P0_14, P0_15, + P0_16, P0_17, P0_18, P0_19, P0_20, P0_21, P0_22, P0_23,P0_24, P0_25, P0_26, P0_27, P0_28, P0_29, P0_30, P0_31, + + // Port 1 + P1_0 = (1 << PORT_SHIFT), + P1_1, P1_2, P1_3, P1_4, P1_5, P1_6, P1_7, P1_8, P1_9, P1_10, P1_11, P1_12, P1_13, P1_14, P1_15, + P1_16, P1_17, P1_18, P1_19, P1_20, P1_21, P1_22, P1_23,P1_24, P1_25, P1_26, P1_27, P1_28, P1_29, P1_30, P1_31, + + // USB bridge connected UART pins +#if defined(MBED_CONF_TARGET_STDIO_UART_TX) + CONSOLE_TX = MBED_CONF_TARGET_STDIO_UART_TX, +#else + CONSOLE_TX = P0_29, +#endif // MBED_CONF_TARGET_STDIO_UART_TX + +#if defined(MBED_CONF_TARGET_STDIO_UART_RX) + CONSOLE_RX = MBED_CONF_TARGET_STDIO_UART_RX, +#else + CONSOLE_RX = P0_28, +#endif // MBED_CONF_TARGET_STDIO_UART_RX + + STDIO_UART_TX = CONSOLE_TX, + STDIO_UART_RX = CONSOLE_RX, + +// ----- Start of xDot external pin definitions ----- + WAKE = P0_19, + GPIO0 = P0_30, + GPIO1 = P0_27, + GPIO2 = P0_26, + GPIO3 = P0_25, + + // AT command port UART + UART_RX = P0_8, + UART_TX = P0_9, + UART_CTS = P0_10, + UART_RTS = P0_11, + + UART0_RX = UART_RX, + UART0_TX = UART_TX, + UART0_CTS = UART_CTS, + UART0_RTS = UART_RTS, + + // debug UART + UART1_RX = P0_28, + UART1_TX = P0_29, + + // SwD + SWDIO = P0_0, + SWCLK = P0_1, + + // I2C + I2C1_SCL = P0_12, + I2C1_SDA = P0_13, + + // SPI + SPI0_SCK = P0_4, + SPI0_MOSI = P0_3, + SPI0_MISO = P0_2, + SPI0_SS = P0_5, +// ----- End of xDot external pin definitions ----- + +// ----- Start of xDot dedicated internal pins. ----- + MEM_PWR_EN = P0_24, // Power to EEPROM, Flash & Secure element + FLASH_CS = P0_23, + + // EEPROM and SE I2C + I2C0_SCL = P0_6, + I2C0_SDA = P0_7, + SE_SDA = I2C0_SDA, + SE_SCL = I2C0_SCL, + + // SX1262 + SPI1_SCK = P0_16, + SPI1_MOSI = P0_15, + SPI1_MISO = P0_14, + SPI1_SS = P0_17, + LORA_MISO = SPI1_MISO, + LORA_MOSI = SPI1_MOSI, + LORA_SCK = SPI1_SCK, + LORA_NSS = SPI1_SS, + + LORA_RESET = P0_20, + LORA_BUSY = P0_21, + LORA_DIO1 = P0_22, + + RF_SW_CTRL = P0_18, // RF switch, active high +// ----- End of xDot dedicated internal pins. ----- + +// ----- Start of aliases for MAX32670 serial_api.c ----- +// The xDot does not use these serial UARTs or the serial_api +// code. These pins are used on the xDot as detailed above. + UART0B_RX = P0_24, + UART0B_TX = P0_25, + + UART1B_RX = P0_2, + UART1B_TX = P0_3, + + UART2B_RX = P0_14, + UART2B_TX = P0_15, +// ----- end of aliases for MAX32670 serial_api.c ----- + + // Not connected + NC = NOT_CONNECTED +} PinName; + +#define LED1 P0_30 +#define I2C_SCL I2C1_SCL +#define I2C_SDA I2C1_SDA +#define SPI_MISO SPI0_MISO +#define SPI_MOSI SPI0_MOSI +#define SPI_SCK SPI0_SCK +#define SPI_NSS SPI0_SS + +typedef enum { + PullNone = 0, + PullUp = 1, + PullDown = 2, + PullDefault = PullUp +} PinMode; + +typedef enum { + LED_ON = 0, + LED_OFF = 1 +} LedStates; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/targets/TARGET_Maxim/TARGET_MAX32670/TARGET_XDOT_MAX32670/SystemInit.c b/targets/TARGET_Maxim/TARGET_MAX32670/TARGET_XDOT_MAX32670/SystemInit.c new file mode 100755 index 00000000000..022d0ebf961 --- /dev/null +++ b/targets/TARGET_Maxim/TARGET_MAX32670/TARGET_XDOT_MAX32670/SystemInit.c @@ -0,0 +1,116 @@ +/* mbed Microcontroller Library + ******************************************************************************* + * Copyright (c) 2023, MultiTech Systems + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of MultiTech 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 HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************* + * + * @copyright SPDX-License-Identifier: MIT + */ + +#include +#include +#include +#include "max32670.h" +#include "gcr_regs.h" +#include "mxc_sys.h" +#include "pwrseq_regs.h" + +#define XDOT_ERFO_FREQ 24000000 // Change to 24000000 for xDot 1.5 Rev A + +void SystemCoreClockUpdateXdot(void) +{ + uint32_t base_freq, div, clk_src; + + // Get the clock source and frequency + clk_src = (MXC_GCR->clkctrl & MXC_F_GCR_CLKCTRL_SYSCLK_SEL); + switch (clk_src) + { + case MXC_S_GCR_CLKCTRL_SYSCLK_SEL_EXTCLK: + base_freq = EXTCLK_FREQ; + break; + case MXC_S_GCR_CLKCTRL_SYSCLK_SEL_ERFO: + base_freq = XDOT_ERFO_FREQ; + break; + case MXC_S_GCR_CLKCTRL_SYSCLK_SEL_INRO: + base_freq = INRO_FREQ; + break; + case MXC_S_GCR_CLKCTRL_SYSCLK_SEL_IPO: + base_freq = IPO_FREQ; + break; + case MXC_S_GCR_CLKCTRL_SYSCLK_SEL_IBRO: + base_freq = IBRO_FREQ; + break; + case MXC_S_GCR_CLKCTRL_SYSCLK_SEL_ERTCO: + base_freq = ERTCO_FREQ; + break; + default: + // Codes 001 and 111 are reserved. + // This code should never execute, however, initialize to safe value. + base_freq = HIRC_FREQ; + break; + } + // Get the clock divider + if (clk_src == MXC_S_GCR_CLKCTRL_SYSCLK_SEL_IPO) + { + base_freq = base_freq >> ((MXC_GCR->clkctrl & MXC_F_GCR_CLKCTRL_IPO_DIV)>> MXC_F_GCR_CLKCTRL_IPO_DIV_POS); + } + div = (MXC_GCR->clkctrl & MXC_F_GCR_CLKCTRL_SYSCLK_DIV) >> MXC_F_GCR_CLKCTRL_SYSCLK_DIV_POS; + + SystemCoreClock = base_freq >> div; +} + +int PreInit(void) +{ + return 0; +} + +void SystemInit(void) +{ + /* Make sure interrupts are enabled. */ + __enable_irq(); + +#if (__FPU_PRESENT == 1) + /* Enable FPU on Cortex-M4, which occupies coprocessor slots 10 & 11 */ + /* Grant full access, per "Table B3-24 CPACR bit assignments". */ + /* DDI0403D "ARMv7-M Architecture Reference Manual" */ + SCB->CPACR |= SCB_CPACR_CP10_Msk | SCB_CPACR_CP11_Msk; + __DSB(); + __ISB(); +#endif + + MXC_PWRSEQ->lpcn &= ~(1 << 31); // Ensure ERTCO is on + + MXC_SYS_Clock_Select(MXC_SYS_CLOCK_IPO); + SystemCoreClockUpdateXdot(); + + // Increase drive strength of I2C_SE bus and Mem Pwr En. + // Note: Mem Pwr En doesn't help, higher drive strength on se i2c pins seems to though + MXC_GPIO0->ds0 |= (1 << 6) | (1 << 7) | (1 << 24); + MXC_GPIO0->ds1 |= (1 << 6) | (1 << 7) | (1 << 24); + + MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_GPIO0); + MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_GPIO1); +} diff --git a/targets/TARGET_NUVOTON/TARGET_M251/analogin_api.c b/targets/TARGET_NUVOTON/TARGET_M251/analogin_api.c index 3ffc27b4b26..127560816b2 100644 --- a/targets/TARGET_NUVOTON/TARGET_M251/analogin_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M251/analogin_api.c @@ -23,6 +23,7 @@ #include "cmsis.h" #include "pinmap.h" #include "PeripheralPins.h" +#include "gpio_api.h" #include "nu_modutil.h" #include "hal/PinNameAliases.h" diff --git a/targets/TARGET_NUVOTON/TARGET_M251/analogout_api.c b/targets/TARGET_NUVOTON/TARGET_M251/analogout_api.c index 96da2699db8..ee7e991b375 100644 --- a/targets/TARGET_NUVOTON/TARGET_M251/analogout_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M251/analogout_api.c @@ -23,6 +23,7 @@ #include "cmsis.h" #include "pinmap.h" #include "PeripheralPins.h" +#include "gpio_api.h" #include "nu_modutil.h" /* Maximum DAC modules */ diff --git a/targets/TARGET_NUVOTON/TARGET_M251/i2c_api.c b/targets/TARGET_NUVOTON/TARGET_M251/i2c_api.c index e0ea4152717..42e32116f5f 100644 --- a/targets/TARGET_NUVOTON/TARGET_M251/i2c_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M251/i2c_api.c @@ -23,6 +23,7 @@ #include "cmsis.h" #include "pinmap.h" #include "PeripheralPins.h" +#include "gpio_api.h" #include "nu_modutil.h" #include "nu_miscutil.h" #include "nu_bitutil.h" diff --git a/targets/TARGET_NUVOTON/TARGET_M251/pwmout_api.c b/targets/TARGET_NUVOTON/TARGET_M251/pwmout_api.c index 8bf50a261b4..90f1d2d12e3 100644 --- a/targets/TARGET_NUVOTON/TARGET_M251/pwmout_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M251/pwmout_api.c @@ -23,6 +23,7 @@ #include "cmsis.h" #include "pinmap.h" #include "PeripheralPins.h" +#include "gpio_api.h" #include "nu_modutil.h" #include "nu_miscutil.h" #include "nu_bitutil.h" diff --git a/targets/TARGET_NUVOTON/TARGET_M251/serial_api.c b/targets/TARGET_NUVOTON/TARGET_M251/serial_api.c index aefd9673197..7b63fcf226f 100644 --- a/targets/TARGET_NUVOTON/TARGET_M251/serial_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M251/serial_api.c @@ -24,6 +24,7 @@ #include "mbed_error.h" #include "mbed_assert.h" #include "PeripheralPins.h" +#include "gpio_api.h" #include "nu_modutil.h" #include "nu_bitutil.h" #include diff --git a/targets/TARGET_NUVOTON/TARGET_M251/spi_api.c b/targets/TARGET_NUVOTON/TARGET_M251/spi_api.c index 25eeb2d1c32..b3f7897ec96 100644 --- a/targets/TARGET_NUVOTON/TARGET_M251/spi_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M251/spi_api.c @@ -23,6 +23,7 @@ #include "cmsis.h" #include "pinmap.h" #include "PeripheralPins.h" +#include "gpio_api.h" #include "nu_modutil.h" #include "nu_miscutil.h" #include "nu_bitutil.h" diff --git a/targets/TARGET_NUVOTON/TARGET_M251/watchdog_api.c b/targets/TARGET_NUVOTON/TARGET_M251/watchdog_api.c index 65f86685d22..93abee3c584 100644 --- a/targets/TARGET_NUVOTON/TARGET_M251/watchdog_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M251/watchdog_api.c @@ -1,5 +1,6 @@ /* - * Copyright (c) 2019-2020 Nuvoton Technology Corporation + * Copyright (c) 2019-2020 Nuvoton Technology Corporation + * SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/targets/TARGET_NUVOTON/TARGET_M261/analogin_api.c b/targets/TARGET_NUVOTON/TARGET_M261/analogin_api.c index 36cea1f003a..ee8058807a4 100644 --- a/targets/TARGET_NUVOTON/TARGET_M261/analogin_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M261/analogin_api.c @@ -22,6 +22,7 @@ #include "cmsis.h" #include "pinmap.h" #include "PeripheralPins.h" +#include "gpio_api.h" #include "nu_modutil.h" #include "hal/PinNameAliases.h" diff --git a/targets/TARGET_NUVOTON/TARGET_M261/analogout_api.c b/targets/TARGET_NUVOTON/TARGET_M261/analogout_api.c index f4554122e7f..02aa47f32ef 100644 --- a/targets/TARGET_NUVOTON/TARGET_M261/analogout_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M261/analogout_api.c @@ -22,6 +22,7 @@ #include "cmsis.h" #include "pinmap.h" #include "PeripheralPins.h" +#include "gpio_api.h" #include "nu_modutil.h" /* Maximum DAC modules */ diff --git a/targets/TARGET_NUVOTON/TARGET_M261/can_api.c b/targets/TARGET_NUVOTON/TARGET_M261/can_api.c index fa04232ee46..0b1ccc5ea92 100644 --- a/targets/TARGET_NUVOTON/TARGET_M261/can_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M261/can_api.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2022 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +24,7 @@ #include "cmsis.h" #include "pinmap.h" #include "PeripheralPins.h" + #include "gpio_api.h" #include "nu_modutil.h" #include "nu_miscutil.h" #include "nu_bitutil.h" diff --git a/targets/TARGET_NUVOTON/TARGET_M261/i2c_api.c b/targets/TARGET_NUVOTON/TARGET_M261/i2c_api.c index 4e1752fd29c..597326edeb0 100644 --- a/targets/TARGET_NUVOTON/TARGET_M261/i2c_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M261/i2c_api.c @@ -22,6 +22,7 @@ #include "cmsis.h" #include "pinmap.h" #include "PeripheralPins.h" +#include "gpio_api.h" #include "nu_modutil.h" #include "nu_miscutil.h" #include "nu_bitutil.h" diff --git a/targets/TARGET_NUVOTON/TARGET_M261/pwmout_api.c b/targets/TARGET_NUVOTON/TARGET_M261/pwmout_api.c index ef07b168e53..f62cba8ac60 100644 --- a/targets/TARGET_NUVOTON/TARGET_M261/pwmout_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M261/pwmout_api.c @@ -22,6 +22,7 @@ #include "cmsis.h" #include "pinmap.h" #include "PeripheralPins.h" +#include "gpio_api.h" #include "nu_modutil.h" #include "nu_miscutil.h" #include "nu_bitutil.h" diff --git a/targets/TARGET_NUVOTON/TARGET_M261/serial_api.c b/targets/TARGET_NUVOTON/TARGET_M261/serial_api.c index a57c20204d4..5fad8f8b97b 100644 --- a/targets/TARGET_NUVOTON/TARGET_M261/serial_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M261/serial_api.c @@ -23,6 +23,7 @@ #include "mbed_error.h" #include "mbed_assert.h" #include "PeripheralPins.h" +#include "gpio_api.h" #include "nu_modutil.h" #include "nu_bitutil.h" #include diff --git a/targets/TARGET_NUVOTON/TARGET_M261/spi_api.c b/targets/TARGET_NUVOTON/TARGET_M261/spi_api.c index 313781728b7..addcf26f87b 100644 --- a/targets/TARGET_NUVOTON/TARGET_M261/spi_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M261/spi_api.c @@ -23,6 +23,7 @@ #include "mbed_error.h" #include "pinmap.h" #include "PeripheralPins.h" +#include "gpio_api.h" #include "nu_modutil.h" #include "nu_miscutil.h" #include "nu_bitutil.h" diff --git a/targets/TARGET_NUVOTON/TARGET_M451/PeripheralNames.h b/targets/TARGET_NUVOTON/TARGET_M451/PeripheralNames.h index 511482ea734..7772d14820a 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/PeripheralNames.h +++ b/targets/TARGET_NUVOTON/TARGET_M451/PeripheralNames.h @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_M451/PeripheralPins.c b/targets/TARGET_NUVOTON/TARGET_M451/PeripheralPins.c index 695528f5751..09813a66fdd 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/PeripheralPins.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/PeripheralPins.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_M451/PeripheralPins.h b/targets/TARGET_NUVOTON/TARGET_M451/PeripheralPins.h index 0e6d9a30b19..beaaf74afa6 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/PeripheralPins.h +++ b/targets/TARGET_NUVOTON/TARGET_M451/PeripheralPins.h @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_M451/PinNames.h b/targets/TARGET_NUVOTON/TARGET_M451/PinNames.h index 69e66da23e0..6f1b1fe0f1b 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/PinNames.h +++ b/targets/TARGET_NUVOTON/TARGET_M451/PinNames.h @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -132,9 +133,6 @@ typedef enum { D13 = PC_5, D14 = PE_5, D15 = PE_4, - - I2C_SCL = D15, - I2C_SDA = D14, // NOTE: board-specific naming // UART naming @@ -152,25 +150,27 @@ typedef enum { #endif SERIAL_TX = CONSOLE_TX, SERIAL_RX = CONSOLE_RX, - // LED naming - LED1 = PD_2, - LED2 = PD_3, - LED3 = PD_7, - LED4 = LED1, // No real LED. Just for passing ATS. - LED_RED = LED2, - LED_GREEN = LED3, - LED_BLUE = LED1, - // Button naming - SW2 = PA_15, - SW3 = PA_14, - BUTTON1 = SW2, - BUTTON2 = SW3, // Force PinName to 32-bit required by NU_PINNAME_BIND(...) FORCE_ENUM_PINNAME_32BIT = 0x7FFFFFFF, } PinName; +// LEDs +#define LED1 PD_2 +#define LED2 PD_3 +#define LED3 PD_7 + +// Button naming +#define SW2 PA_15 +#define SW3 PA_14 +#define BUTTON1 SW2 +#define BUTTON2 SW3 + +// I2C +#define I2C_SCL D15 +#define I2C_SDA D14 + #ifdef __cplusplus } #endif diff --git a/targets/TARGET_NUVOTON/TARGET_M451/PortNames.h b/targets/TARGET_NUVOTON/TARGET_M451/PortNames.h index 3adf2f8a53a..55ae9b83031 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/PortNames.h +++ b/targets/TARGET_NUVOTON/TARGET_M451/PortNames.h @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_M451/analogin_api.c b/targets/TARGET_NUVOTON/TARGET_M451/analogin_api.c index b559d77aa11..0b5cea93ff1 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/analogin_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/analogin_api.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +22,7 @@ #include "cmsis.h" #include "pinmap.h" #include "PeripheralPins.h" +#include "gpio_api.h" #include "nu_modutil.h" #include "hal/PinNameAliases.h" diff --git a/targets/TARGET_NUVOTON/TARGET_M451/analogout_api.c b/targets/TARGET_NUVOTON/TARGET_M451/analogout_api.c index 54a0c633dc9..c0a72fa5c12 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/analogout_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/analogout_api.c @@ -22,6 +22,7 @@ #include "cmsis.h" #include "pinmap.h" #include "PeripheralPins.h" +#include "gpio_api.h" #include "nu_modutil.h" /* Maximum DAC modules */ diff --git a/targets/TARGET_NUVOTON/TARGET_M451/can_api.c b/targets/TARGET_NUVOTON/TARGET_M451/can_api.c index fa2e7c2e21e..20faf87a1aa 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/can_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/can_api.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,17 +24,30 @@ #include "cmsis.h" #include "pinmap.h" #include "PeripheralPins.h" + #include "gpio_api.h" #include "nu_modutil.h" #include "nu_miscutil.h" #include "nu_bitutil.h" #include "mbed_critical.h" + #include "mbed_error.h" #define NU_CAN_DEBUG 0 #define CAN_NUM 1 + /* Reserve Message Object number 31 for Tx */ +#define NU_CAN_MSG_OBJ_NUM_TX 31 + +/* Max number of message ID filter handle */ +#define NU_CAN_MAXNUM_HNDL NU_CAN_MSG_OBJ_NUM_TX + +/* Convert to string literal */ +#define NU_STR_(X) #X +#define NU_STR(X) NU_STR_(X) + static uintptr_t can_irq_contexts[CAN_NUM] = {0}; static can_irq_handler can0_irq_handler; +extern void CAN_CLR_INT_PENDING_ONLY_BIT(CAN_T *tCAN, uint32_t u32MsgNum); static const struct nu_modinit_s can_modinit_tab[] = { {CAN_0, CAN0_MODULE, 0, 0, CAN0_RST, CAN0_IRQn, NULL}, @@ -125,12 +139,10 @@ static void can_irq(CANName name, int id) /**************************/ if(can->STATUS & CAN_STATUS_RXOK_Msk) { can->STATUS &= ~CAN_STATUS_RXOK_Msk; /* Clear Rx Ok status*/ - can0_irq_handler(can_irq_contexts[id], IRQ_RX); } if(can->STATUS & CAN_STATUS_TXOK_Msk) { can->STATUS &= ~CAN_STATUS_TXOK_Msk; /* Clear Tx Ok status*/ - can0_irq_handler(can_irq_contexts[id], IRQ_TX); } /**************************/ @@ -143,6 +155,14 @@ static void can_irq(CANName name, int id) if(can->STATUS & CAN_STATUS_BOFF_Msk) { can0_irq_handler(can_irq_contexts[id], IRQ_BUS); } + } else if (u8IIDRstatus >= 1 && u8IIDRstatus <= 32) { + if ((u8IIDRstatus - 1) != NU_CAN_MSG_OBJ_NUM_TX) { + can0_irq_handler(can_irq_contexts[id], IRQ_RX); + CAN_CLR_INT_PENDING_ONLY_BIT(can, (u8IIDRstatus -1)); + } else { + can0_irq_handler(can_irq_contexts[id], IRQ_TX); + CAN_CLR_INT_PENDING_BIT(can, (u8IIDRstatus -1)); + } } else if (u8IIDRstatus!=0) { can0_irq_handler(can_irq_contexts[id], IRQ_OVERRUN); @@ -213,6 +233,9 @@ void can_irq_set(can_t *obj, CanIrqType irq, uint32_t enable) int can_write(can_t *obj, CAN_Message msg, int cc) { + /* Unused */ + (void) cc; + STR_CANMSG_T CMsg; CMsg.IdType = (uint32_t)msg.format; @@ -221,7 +244,7 @@ int can_write(can_t *obj, CAN_Message msg, int cc) CMsg.DLC = msg.len; memcpy((void *)&CMsg.Data[0],(const void *)&msg.data[0], (unsigned int)8); - return CAN_Transmit((CAN_T *)NU_MODBASE(obj->can), cc, &CMsg); + return CAN_Transmit((CAN_T *)NU_MODBASE(obj->can), NU_CAN_MSG_OBJ_NUM_TX, &CMsg); } int can_read(can_t *obj, CAN_Message *msg, int handle) @@ -285,16 +308,19 @@ int can_mode(can_t *obj, CanMode mode) int can_filter(can_t *obj, uint32_t id, uint32_t mask, CANFormat format, int32_t handle) { - uint32_t numask = mask; - if( numask == 0x0000 ) - { - return CAN_SetRxMsg((CAN_T *)NU_MODBASE(obj->can), handle, (uint32_t)format, id); + /* Check validity of filter handle */ + if (handle < 0 || handle >= NU_CAN_MAXNUM_HNDL) { + /* NOTE: 0 is ambiguous, error or filter handle 0. */ + error("Support max " NU_STR(NU_CAN_MAXNUM_HNDL) " CAN filters"); + return 0; } + + uint32_t numask = mask; if( format == CANStandard ) { numask = (mask << 18); } - numask = (numask | CAN_IF_MASK2_MDIR_Msk | CAN_IF_MASK2_MXTD_Msk); + numask = (numask | ((CAN_IF_MASK2_MDIR_Msk | CAN_IF_MASK2_MXTD_Msk) << 16)); return CAN_SetRxMsgAndMsk((CAN_T *)NU_MODBASE(obj->can), handle, (uint32_t)format, id, numask); } diff --git a/targets/TARGET_NUVOTON/TARGET_M451/device.h b/targets/TARGET_NUVOTON/TARGET_M451/device.h index 2f05e05becc..7ecc5d505f2 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/device.h +++ b/targets/TARGET_NUVOTON/TARGET_M451/device.h @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_acmp.c b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_acmp.c index 6b5edd12906..4819e54ec53 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_acmp.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_acmp.c @@ -5,8 +5,8 @@ * $Date: 15/08/11 10:26a $ * @brief M451 series Analog Comparator(ACMP) driver source file * - * @note - * Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. + * @copyright SPDX-License-Identifier: Apache-2.0 + * @copyright Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #include "M451Series.h" diff --git a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_acmp.h b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_acmp.h index 67857f42d1a..74f28d8505c 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_acmp.h +++ b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_acmp.h @@ -5,8 +5,8 @@ * $Date: 15/08/11 10:26a $ * @brief M451 Series ACMP Driver Header File * - * @note - * Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. + * @copyright SPDX-License-Identifier: Apache-2.0 + * @copyright Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. * ******************************************************************************/ #ifndef __ACMP_H__ diff --git a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_can.c b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_can.c index 7cc61939cf8..34aa768c398 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_can.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_can.c @@ -5,8 +5,8 @@ * $Date: 15/08/11 10:26a $ * @brief M451 series CAN driver source file * - * @note - * Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. + * @copyright SPDX-License-Identifier: Apache-2.0 + * @copyright Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #include "M451Series.h" @@ -981,7 +981,7 @@ int32_t CAN_Receive(CAN_T *tCAN, uint32_t u32MsgNum , STR_CANMSG_T* pCanMsg) * * @details An interrupt remains pending until the application software has cleared it. */ -void CAN_CLR_INT_PENDING_BIT(CAN_T *tCAN, uint8_t u32MsgNum) +void CAN_CLR_INT_PENDING_BIT(CAN_T *tCAN, uint32_t u32MsgNum) { uint32_t u32MsgIfNum; @@ -994,6 +994,19 @@ void CAN_CLR_INT_PENDING_BIT(CAN_T *tCAN, uint8_t u32MsgNum) ReleaseIF(tCAN, u32MsgIfNum); } +/* Clone of CAN_CLR_INT_PENDING_BIT() with NewDat not cleared */ +void CAN_CLR_INT_PENDING_ONLY_BIT(CAN_T *tCAN, uint32_t u32MsgNum) +{ + uint32_t u32MsgIfNum; + + if((u32MsgIfNum = LockIF_TL(tCAN)) == 2) + u32MsgIfNum = 0; + + tCAN->IF[u32MsgIfNum].CMASK = CAN_IF_CMASK_CLRINTPND_Msk; + tCAN->IF[u32MsgIfNum].CREQ = 1 + u32MsgNum; + + ReleaseIF(tCAN, u32MsgIfNum); +} /*@}*/ /* end of group CAN_EXPORTED_FUNCTIONS */ diff --git a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_can.h b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_can.h index d2427af227b..cccac31eba7 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_can.h +++ b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_can.h @@ -5,8 +5,8 @@ * $Date: 15/08/11 10:26a $ * @brief M451 Series CAN Driver Header File * - * @note - * Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. + * @copyright SPDX-License-Identifier: Apache-2.0 + * @copyright Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. * ******************************************************************************/ #ifndef __CAN_H__ @@ -148,7 +148,7 @@ typedef struct uint32_t CAN_SetBaudRate(CAN_T *tCAN, uint32_t u32BaudRate); uint32_t CAN_Open(CAN_T *tCAN, uint32_t u32BaudRate, uint32_t u32Mode); void CAN_Close(CAN_T *tCAN); -void CAN_CLR_INT_PENDING_BIT(CAN_T *tCAN, uint8_t u32MsgNum); +void CAN_CLR_INT_PENDING_BIT(CAN_T *tCAN, uint32_t u32MsgNum); void CAN_EnableInt(CAN_T *tCAN, uint32_t u32Mask); void CAN_DisableInt(CAN_T *tCAN, uint32_t u32Mask); int32_t CAN_Transmit(CAN_T *tCAN, uint32_t u32MsgNum , STR_CANMSG_T* pCanMsg); diff --git a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_clk.c b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_clk.c index eae295ea443..b5ca9825972 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_clk.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_clk.c @@ -5,8 +5,8 @@ * $Date: 15/08/11 10:26a $ * @brief M451 series CLK driver source file * - * @note - * Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. + * @copyright SPDX-License-Identifier: Apache-2.0 + * @copyright Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #include "M451Series.h" diff --git a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_dac.c b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_dac.c index 4baffbd8012..e82d2764b8c 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_dac.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_dac.c @@ -5,8 +5,8 @@ * $Date: 15/08/11 10:26a $ * @brief M451 series DAC driver source file * - * @note - * Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. + * @copyright SPDX-License-Identifier: Apache-2.0 + * @copyright Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #include "M451Series.h" diff --git a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_eadc.c b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_eadc.c index 741e51dcc0f..a9d1c469a3c 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_eadc.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_eadc.c @@ -5,8 +5,8 @@ * $Date: 15/08/11 10:26a $ * @brief M451 series EADC driver source file * - * @note - * Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. + * @copyright SPDX-License-Identifier: Apache-2.0 + * @copyright Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #include "M451Series.h" diff --git a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_fmc.c b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_fmc.c index 01fcb84e95b..82d364cfe3a 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_fmc.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_fmc.c @@ -5,8 +5,8 @@ * $Date: 15/08/11 10:26a $ * @brief M451 series FMC driver source file * - * @note - * Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. + * @copyright SPDX-License-Identifier: Apache-2.0 + * @copyright Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ //* Includes ------------------------------------------------------------------*/ diff --git a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_gpio.c b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_gpio.c index 7300e4eb9fc..1c27d887987 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_gpio.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_gpio.c @@ -5,8 +5,8 @@ * $Date: 15/08/11 10:26a $ * @brief M451 series GPIO driver source file * - * @note - * Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. + * @copyright SPDX-License-Identifier: Apache-2.0 + * @copyright Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #include "M451Series.h" diff --git a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_i2c.c b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_i2c.c index ad77a32c20f..bc9cf6ea537 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_i2c.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_i2c.c @@ -5,8 +5,8 @@ * $Date: 15/08/11 10:26a $ * @brief M451 series I2C driver source file * - * @note - * Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. + * @copyright SPDX-License-Identifier: Apache-2.0 + * @copyright Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #include "M451Series.h" diff --git a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_i2c.h b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_i2c.h index 3d30c66b74d..ba0caea3876 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_i2c.h +++ b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_i2c.h @@ -5,8 +5,8 @@ * $Date: 15/08/11 10:26a $ * @brief M451 Series I2C Driver Header File * - * @note - * Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. + * @copyright SPDX-License-Identifier: Apache-2.0 + * @copyright Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. * ******************************************************************************/ #ifndef __I2C_H__ diff --git a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_otg.h b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_otg.h index 4137650aa5c..d4bcae8c213 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_otg.h +++ b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_otg.h @@ -5,8 +5,8 @@ * $Date: 15/08/11 10:26a $ * @brief M451 Series OTG Driver Header File * - * @note - * Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. + * @copyright SPDX-License-Identifier: Apache-2.0 + * @copyright Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. * ******************************************************************************/ #ifndef __OTG_H__ diff --git a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_pdma.c b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_pdma.c index 53f4420c1c6..dc6bb58bcd6 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_pdma.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_pdma.c @@ -5,8 +5,8 @@ * $Date: 15/08/11 10:26a $ * @brief M451 series PDMA driver source file * - * @note - * Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. + * @copyright SPDX-License-Identifier: Apache-2.0 + * @copyright Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #include "M451Series.h" diff --git a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_pdma.h b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_pdma.h index 7ca4b45a9e4..57d5cb959d5 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_pdma.h +++ b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_pdma.h @@ -5,8 +5,8 @@ * $Date: 15/08/11 10:26a $ * @brief M451 series PDMA driver header file * - * @note - * Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. + * @copyright SPDX-License-Identifier: Apache-2.0 + * @copyright Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #ifndef __PDMA_H__ #define __PDMA_H__ diff --git a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_pwm.c b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_pwm.c index c250fa7cc56..10e1c0ae0d3 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_pwm.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_pwm.c @@ -5,8 +5,8 @@ * $Date: 15/08/11 10:26a $ * @brief M451 series PWM driver source file * - * @note - * Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. + * @copyright SPDX-License-Identifier: Apache-2.0 + * @copyright Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #include "M451Series.h" diff --git a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_pwm.h b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_pwm.h index 3c3629a8e79..5cef664bca4 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_pwm.h +++ b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_pwm.h @@ -5,8 +5,8 @@ * $Date: 15/08/11 10:26a $ * @brief M451 series PWM driver header file * - * @note - * Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. + * @copyright SPDX-License-Identifier: Apache-2.0 + * @copyright Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #ifndef __PWM_H__ #define __PWM_H__ diff --git a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_spi.c b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_spi.c index ad30b8e39a9..1ca5432cbb3 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_spi.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_spi.c @@ -5,8 +5,8 @@ * $Date: 15/08/11 10:26a $ * @brief M451 series SPI driver source file * - * @note - * Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. + * @copyright SPDX-License-Identifier: Apache-2.0 + * @copyright Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #include "M451Series.h" /** @addtogroup Standard_Driver Standard Driver diff --git a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_spi.h b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_spi.h index 02d2469190a..4628f2c5efe 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_spi.h +++ b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_spi.h @@ -5,8 +5,8 @@ * $Date: 15/08/11 10:26a $ * @brief M451 series SPI driver header file * - * @note - * Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. + * @copyright SPDX-License-Identifier: Apache-2.0 + * @copyright Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #ifndef __SPI_H__ #define __SPI_H__ diff --git a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_sys.c b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_sys.c index bc127c7e3fd..ab5403104e3 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_sys.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_sys.c @@ -5,8 +5,8 @@ * $Date: 15/08/11 10:26a $ * @brief M451 series SYS driver source file * - * @note - * Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. + * @copyright SPDX-License-Identifier: Apache-2.0 + * @copyright Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #include "M451Series.h" diff --git a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_tk.c b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_tk.c index 4dcd0dc97d9..c524e4a3504 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_tk.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_tk.c @@ -5,8 +5,8 @@ * $Date: 15/08/24 4:54p $ * @brief M451 series TK driver source file * - * @note - * Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. + * @copyright SPDX-License-Identifier: Apache-2.0 + * @copyright Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. * *****************************************************************************/ #include "M451Series.h" diff --git a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_tk.h b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_tk.h index ccbbadf6574..74e9fa4fbfc 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_tk.h +++ b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_tk.h @@ -5,8 +5,8 @@ * $Date: 15/08/24 4:52p $ * @brief M451 Series TK Driver Header File * - * @note - * Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. + * @copyright SPDX-License-Identifier: Apache-2.0 + * @copyright Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. * ******************************************************************************/ #ifndef __TK_H__ diff --git a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_usbd.c b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_usbd.c index dc6d513bc57..83f6569410d 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_usbd.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_usbd.c @@ -5,8 +5,8 @@ * $Date: 15/08/21 3:34p $ * @brief M451 series USBD driver source file * - * @note - * Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. + * @copyright SPDX-License-Identifier: Apache-2.0 + * @copyright Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #include diff --git a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_usbd.h b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_usbd.h index 51e8d55e013..8800857196f 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_usbd.h +++ b/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_usbd.h @@ -4,8 +4,8 @@ * @version 2.0.0 * @date 10, January, 2014 * - * @note - * Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. + * @copyright SPDX-License-Identifier: Apache-2.0 + * @copyright Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved. ******************************************************************************/ #ifndef __USBD_H__ #define __USBD_H__ diff --git a/targets/TARGET_NUVOTON/TARGET_M451/device/cmsis.h b/targets/TARGET_NUVOTON/TARGET_M451/device/cmsis.h index dd9d4efc233..934404e1c90 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/device/cmsis.h +++ b/targets/TARGET_NUVOTON/TARGET_M451/device/cmsis.h @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_M451/device/cmsis_nvic.h b/targets/TARGET_NUVOTON/TARGET_M451/device/cmsis_nvic.h index 92712dbf79c..e8ba5b20398 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/device/cmsis_nvic.h +++ b/targets/TARGET_NUVOTON/TARGET_M451/device/cmsis_nvic.h @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_M451/dma.h b/targets/TARGET_NUVOTON/TARGET_M451/dma.h index 465003246ba..bbf1f007bc9 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/dma.h +++ b/targets/TARGET_NUVOTON/TARGET_M451/dma.h @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_M451/dma_api.c b/targets/TARGET_NUVOTON/TARGET_M451/dma_api.c index 212a5e02a7c..c65debc27d9 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/dma_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/dma_api.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_M451/flash_api.c b/targets/TARGET_NUVOTON/TARGET_M451/flash_api.c index 591b82a1e06..ac683a6a810 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/flash_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/flash_api.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_M451/gpio_api.c b/targets/TARGET_NUVOTON/TARGET_M451/gpio_api.c index e0c59e75b46..dace43ec7e3 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/gpio_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/gpio_api.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2020 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_M451/gpio_irq_api.c b/targets/TARGET_NUVOTON/TARGET_M451/gpio_irq_api.c index 5eea6a4ada2..0d864ff67f8 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/gpio_irq_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/gpio_irq_api.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_M451/gpio_object.h b/targets/TARGET_NUVOTON/TARGET_M451/gpio_object.h index 6337fd5cd04..d39347d9c2a 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/gpio_object.h +++ b/targets/TARGET_NUVOTON/TARGET_M451/gpio_object.h @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_M451/i2c_api.c b/targets/TARGET_NUVOTON/TARGET_M451/i2c_api.c index 452131c791c..9f6743e8a83 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/i2c_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/i2c_api.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +22,7 @@ #include "cmsis.h" #include "pinmap.h" #include "PeripheralPins.h" +#include "gpio_api.h" #include "nu_modutil.h" #include "nu_miscutil.h" #include "nu_bitutil.h" diff --git a/targets/TARGET_NUVOTON/TARGET_M451/lp_ticker.c b/targets/TARGET_NUVOTON/TARGET_M451/lp_ticker.c index 10b1ee2469d..ba205ed1d80 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/lp_ticker.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/lp_ticker.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_M451/mbed_overrides.c b/targets/TARGET_NUVOTON/TARGET_M451/mbed_overrides.c index 5571cd2998d..7e51a92347b 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/mbed_overrides.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/mbed_overrides.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_M451/objects.h b/targets/TARGET_NUVOTON/TARGET_M451/objects.h index acb2158e9c3..140ba39d9e2 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/objects.h +++ b/targets/TARGET_NUVOTON/TARGET_M451/objects.h @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_M451/pinmap.c b/targets/TARGET_NUVOTON/TARGET_M451/pinmap.c index dcd10b6dc23..95d2190d180 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/pinmap.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/pinmap.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_M451/port_api.c b/targets/TARGET_NUVOTON/TARGET_M451/port_api.c index 84278d0dbb1..7e2cd323521 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/port_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/port_api.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_M451/pwmout_api.c b/targets/TARGET_NUVOTON/TARGET_M451/pwmout_api.c index 74323159d4c..894ef868626 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/pwmout_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/pwmout_api.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +22,7 @@ #include "cmsis.h" #include "pinmap.h" #include "PeripheralPins.h" +#include "gpio_api.h" #include "nu_modutil.h" #include "nu_miscutil.h" #include "nu_bitutil.h" diff --git a/targets/TARGET_NUVOTON/TARGET_M451/reset_reason.c b/targets/TARGET_NUVOTON/TARGET_M451/reset_reason.c index 91c29b6512a..4a2351a670f 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/reset_reason.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/reset_reason.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2017-2018 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_M451/rtc_api.c b/targets/TARGET_NUVOTON/TARGET_M451/rtc_api.c index b026d52334d..1538c5622b1 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/rtc_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/rtc_api.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_M451/serial_api.c b/targets/TARGET_NUVOTON/TARGET_M451/serial_api.c index 7d7bce7e7a9..6dcf7572f4e 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/serial_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/serial_api.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +23,7 @@ #include "mbed_error.h" #include "mbed_assert.h" #include "PeripheralPins.h" +#include "gpio_api.h" #include "nu_modutil.h" #include "nu_bitutil.h" #include diff --git a/targets/TARGET_NUVOTON/TARGET_M451/sleep.c b/targets/TARGET_NUVOTON/TARGET_M451/sleep.c index ae41314636a..3399dc8bdee 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/sleep.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/sleep.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_M451/spi_api.c b/targets/TARGET_NUVOTON/TARGET_M451/spi_api.c index a43b8756960..d6ec1b2fb9b 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/spi_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/spi_api.c @@ -22,6 +22,7 @@ #include "cmsis.h" #include "pinmap.h" #include "PeripheralPins.h" +#include "gpio_api.h" #include "nu_modutil.h" #include "nu_miscutil.h" #include "nu_bitutil.h" diff --git a/targets/TARGET_NUVOTON/TARGET_M451/us_ticker.c b/targets/TARGET_NUVOTON/TARGET_M451/us_ticker.c index bf7cd866cea..02065e3be85 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/us_ticker.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/us_ticker.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_M480/can_api.c b/targets/TARGET_NUVOTON/TARGET_M480/can_api.c index 771cb6d9ff8..c4910180c5e 100644 --- a/targets/TARGET_NUVOTON/TARGET_M480/can_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M480/can_api.c @@ -30,10 +30,21 @@ #include "nu_miscutil.h" #include "nu_bitutil.h" #include "mbed_critical.h" +#include "mbed_error.h" #define NU_CAN_DEBUG 0 #define CAN_NUM 2 +/* Reserve Message Object number 31 for Tx */ +#define NU_CAN_MSG_OBJ_NUM_TX 31 + +/* Max number of message ID filter handle */ +#define NU_CAN_MAXNUM_HNDL NU_CAN_MSG_OBJ_NUM_TX + +/* Convert to string literal */ +#define NU_STR_(X) #X +#define NU_STR(X) NU_STR_(X) + static uintptr_t can_irq_contexts[CAN_NUM] = {0}; static can_irq_handler can0_irq_handler; static can_irq_handler can1_irq_handler; @@ -43,6 +54,7 @@ extern void CAN_EnterInitMode(CAN_T *tCAN, uint8_t u8Mask); extern void CAN_LeaveInitMode(CAN_T *tCAN); extern void CAN_LeaveTestMode(CAN_T *tCAN); extern void CAN_EnterTestMode(CAN_T *tCAN, uint8_t u8TestMask); +extern void CAN_CLR_INT_PENDING_ONLY_BIT(CAN_T *tCAN, uint32_t u32MsgNum); static const struct nu_modinit_s can_modinit_tab[] = { {CAN_0, CAN0_MODULE, 0, 0, CAN0_RST, CAN0_IRQn, NULL}, @@ -139,19 +151,10 @@ static void can_irq(CANName name, int id) /**************************/ if(can->STATUS & CAN_STATUS_RXOK_Msk) { can->STATUS &= ~CAN_STATUS_RXOK_Msk; /* Clear Rx Ok status*/ - if(id) - can1_irq_handler(can_irq_contexts[id], IRQ_RX); - else - can0_irq_handler(can_irq_contexts[id], IRQ_RX); } if(can->STATUS & CAN_STATUS_TXOK_Msk) { can->STATUS &= ~CAN_STATUS_TXOK_Msk; /* Clear Tx Ok status*/ - if(id) - can1_irq_handler(can_irq_contexts[id], IRQ_TX); - else - can0_irq_handler(can_irq_contexts[id], IRQ_TX); - } /**************************/ @@ -170,6 +173,24 @@ static void can_irq(CANName name, int id) else can0_irq_handler(can_irq_contexts[id], IRQ_BUS); } + } else if (u8IIDRstatus >= 1 && u8IIDRstatus <= 32) { + if ((u8IIDRstatus - 1) != NU_CAN_MSG_OBJ_NUM_TX) { + if (id) { + can1_irq_handler(can_irq_contexts[id], IRQ_RX); + } + else { + can0_irq_handler(can_irq_contexts[id], IRQ_RX); + } + CAN_CLR_INT_PENDING_ONLY_BIT(can, (u8IIDRstatus -1)); + } else { + if (id) { + can1_irq_handler(can_irq_contexts[id], IRQ_TX); + } + else { + can0_irq_handler(can_irq_contexts[id], IRQ_TX); + } + CAN_CLR_INT_PENDING_BIT(can, (u8IIDRstatus -1)); + } } else if (u8IIDRstatus!=0) { if(id) @@ -178,7 +199,6 @@ static void can_irq(CANName name, int id) can0_irq_handler(can_irq_contexts[id], IRQ_OVERRUN); CAN_CLR_INT_PENDING_BIT(can, ((can->IIDR) -1)); /* Clear Interrupt Pending */ - } else if(can->WU_STATUS == 1) { can->WU_STATUS = 0; /* Write '0' to clear */ @@ -263,6 +283,9 @@ void can_irq_set(can_t *obj, CanIrqType irq, uint32_t enable) int can_write(can_t *obj, CAN_Message msg, int cc) { + /* Unused */ + (void) cc; + STR_CANMSG_T CMsg; CMsg.IdType = (uint32_t)msg.format; @@ -271,7 +294,7 @@ int can_write(can_t *obj, CAN_Message msg, int cc) CMsg.DLC = msg.len; memcpy((void *)&CMsg.Data[0],(const void *)&msg.data[0], (unsigned int)8); - return CAN_Transmit((CAN_T *)(NU_MODBASE(obj->can)), cc, &CMsg); + return CAN_Transmit((CAN_T *)(NU_MODBASE(obj->can)), NU_CAN_MSG_OBJ_NUM_TX, &CMsg); } int can_read(can_t *obj, CAN_Message *msg, int handle) @@ -293,6 +316,7 @@ int can_read(can_t *obj, CAN_Message *msg, int handle) int can_mode(can_t *obj, CanMode mode) { int success = 0; + switch (mode) { case MODE_RESET: CAN_LeaveTestMode((CAN_T*)NU_MODBASE(obj->can)); @@ -326,22 +350,24 @@ int can_mode(can_t *obj, CanMode mode) } - return success; } int can_filter(can_t *obj, uint32_t id, uint32_t mask, CANFormat format, int32_t handle) { - uint32_t numask = mask; - if( numask == 0x0000 ) - { - return CAN_SetRxMsg((CAN_T *)NU_MODBASE(obj->can), handle, (uint32_t)format, id); + /* Check validity of filter handle */ + if (handle < 0 || handle >= NU_CAN_MAXNUM_HNDL) { + /* NOTE: 0 is ambiguous, error or filter handle 0. */ + error("Support max " NU_STR(NU_CAN_MAXNUM_HNDL) " CAN filters"); + return 0; } + + uint32_t numask = mask; if( format == CANStandard ) { numask = (mask << 18); } - numask = (numask | CAN_IF_MASK2_MDIR_Msk | CAN_IF_MASK2_MXTD_Msk); + numask = (numask | ((CAN_IF_MASK2_MDIR_Msk | CAN_IF_MASK2_MXTD_Msk) << 16)); return CAN_SetRxMsgAndMsk((CAN_T *)NU_MODBASE(obj->can), handle, (uint32_t)format, id, numask); } diff --git a/targets/TARGET_NUVOTON/TARGET_M480/device/StdDriver/inc/m480_can.h b/targets/TARGET_NUVOTON/TARGET_M480/device/StdDriver/inc/m480_can.h index 0aca5fd8471..552f0a78d17 100644 --- a/targets/TARGET_NUVOTON/TARGET_M480/device/StdDriver/inc/m480_can.h +++ b/targets/TARGET_NUVOTON/TARGET_M480/device/StdDriver/inc/m480_can.h @@ -155,7 +155,7 @@ typedef struct uint32_t CAN_SetBaudRate(CAN_T *tCAN, uint32_t u32BaudRate); uint32_t CAN_Open(CAN_T *tCAN, uint32_t u32BaudRate, uint32_t u32Mode); void CAN_Close(CAN_T *tCAN); -void CAN_CLR_INT_PENDING_BIT(CAN_T *tCAN, uint8_t u32MsgNum); +void CAN_CLR_INT_PENDING_BIT(CAN_T *tCAN, uint32_t u32MsgNum); void CAN_EnableInt(CAN_T *tCAN, uint32_t u32Mask); void CAN_DisableInt(CAN_T *tCAN, uint32_t u32Mask); int32_t CAN_Transmit(CAN_T *tCAN, uint32_t u32MsgNum, STR_CANMSG_T* pCanMsg); diff --git a/targets/TARGET_NUVOTON/TARGET_M480/device/StdDriver/src/m480_can.c b/targets/TARGET_NUVOTON/TARGET_M480/device/StdDriver/src/m480_can.c index f2993436175..3930e570df4 100644 --- a/targets/TARGET_NUVOTON/TARGET_M480/device/StdDriver/src/m480_can.c +++ b/targets/TARGET_NUVOTON/TARGET_M480/device/StdDriver/src/m480_can.c @@ -1264,7 +1264,7 @@ int32_t CAN_Receive(CAN_T *tCAN, uint32_t u32MsgNum, STR_CANMSG_T* pCanMsg) * * @details An interrupt remains pending until the application software has cleared it. */ -void CAN_CLR_INT_PENDING_BIT(CAN_T *tCAN, uint8_t u32MsgNum) +void CAN_CLR_INT_PENDING_BIT(CAN_T *tCAN, uint32_t u32MsgNum) { uint32_t u32MsgIfNum; @@ -1282,6 +1282,24 @@ void CAN_CLR_INT_PENDING_BIT(CAN_T *tCAN, uint8_t u32MsgNum) ReleaseIF(tCAN, u32MsgIfNum); } +/* Clone of CAN_CLR_INT_PENDING_BIT() with NewDat not cleared */ +void CAN_CLR_INT_PENDING_ONLY_BIT(CAN_T *tCAN, uint32_t u32MsgNum) +{ + uint32_t u32MsgIfNum; + + if((u32MsgIfNum = LockIF_TL(tCAN)) == 2ul) + { + u32MsgIfNum = 0ul; + } + else + { + } + + tCAN->IF[u32MsgIfNum].CMASK = CAN_IF_CMASK_CLRINTPND_Msk; + tCAN->IF[u32MsgIfNum].CREQ = 1ul + u32MsgNum; + + ReleaseIF(tCAN, u32MsgIfNum); +} /*@}*/ /* end of group CAN_EXPORTED_FUNCTIONS */ diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/PeripheralNames.h b/targets/TARGET_NUVOTON/TARGET_NANO100/PeripheralNames.h index 60f57d63b7a..239a427aaec 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/PeripheralNames.h +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/PeripheralNames.h @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2017 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/PeripheralPins.c b/targets/TARGET_NUVOTON/TARGET_NANO100/PeripheralPins.c index 32d95de44fd..76b7ccdd576 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/PeripheralPins.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/PeripheralPins.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2017 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/PeripheralPins.h b/targets/TARGET_NUVOTON/TARGET_NANO100/PeripheralPins.h index f7e23d0e7b6..980c8d3dcf9 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/PeripheralPins.h +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/PeripheralPins.h @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2017 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/PinNames.h b/targets/TARGET_NUVOTON/TARGET_NANO100/PinNames.h index b4d980db77c..660cf8fa28c 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/PinNames.h +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/PinNames.h @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2017 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -108,9 +109,6 @@ typedef enum { D13 = PC_1, D14 = PC_8, D15 = PC_9, - - I2C_SCL = D15, - I2C_SDA = D14, // NOTE: other board-specific naming // UART naming @@ -127,26 +125,28 @@ typedef enum { STDIO_UART_RX = CONSOLE_RX, #endif SERIAL_TX = CONSOLE_TX, - SERIAL_RX = CONSOLE_RX, - // LED naming - LED1 = PE_11, - LED2 = PE_10, - LED3 = PE_9, - LED4 = LED1, - LED_RED = LED3, - LED_GREEN = LED1, - LED_YELLOW = LED2, - // Button naming - SW1 = PE_5, - SW2 = PE_6, - BUTTON1 = SW1, - BUTTON2 = SW2, + SERIAL_RX = CONSOLE_RX, // Force PinName to 32-bit required by NU_PINNAME_BIND(...) FORCE_ENUM_PINNAME_32BIT = 0x7FFFFFFF, } PinName; +// LEDs +#define LED1 PE_11 +#define LED2 PE_10 +#define LED3 PE_9 + +// Button naming +#define SW1 PE_5 +#define SW2 PE_6 +#define BUTTON1 SW1 +#define BUTTON2 SW2 + +// I2C +#define I2C_SCL D15 +#define I2C_SDA D14 + #ifdef __cplusplus } #endif diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/PortNames.h b/targets/TARGET_NUVOTON/TARGET_NANO100/PortNames.h index 3adf2f8a53a..55ae9b83031 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/PortNames.h +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/PortNames.h @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/analogin_api.c b/targets/TARGET_NUVOTON/TARGET_NANO100/analogin_api.c index 2ca7160ceee..d3008a91009 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/analogin_api.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/analogin_api.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2017 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +23,7 @@ #include "cmsis.h" #include "pinmap.h" #include "PeripheralPins.h" +#include "gpio_api.h" #include "nu_modutil.h" #include "hal/PinNameAliases.h" diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/analogout_api.c b/targets/TARGET_NUVOTON/TARGET_NANO100/analogout_api.c index 896014e71c4..92119d8ca37 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/analogout_api.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/analogout_api.c @@ -22,6 +22,7 @@ #include "cmsis.h" #include "pinmap.h" #include "PeripheralPins.h" +#include "gpio_api.h" #include "nu_modutil.h" /* Maximum DAC modules */ diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/device.h b/targets/TARGET_NUVOTON/TARGET_NANO100/device.h index 2f05e05becc..7ecc5d505f2 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/device.h +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/device.h @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_clk.c b/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_clk.c index 3f763078b0f..2d2e25b5394 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_clk.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_clk.c @@ -6,6 +6,7 @@ * @brief NANO100 series CLK driver source file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_clk.h b/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_clk.h index 5de59ab28a4..a7ee715fa4c 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_clk.h +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_clk.h @@ -6,6 +6,7 @@ * @brief Nano100 series CLK driver header file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #ifndef __CLK_H__ diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_crc.h b/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_crc.h index 1b27e7775a5..104e7a6d7cc 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_crc.h +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_crc.h @@ -6,6 +6,7 @@ * @brief Nano100 series CRC driver header file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #ifndef __CRC_H__ diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_ebi.c b/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_ebi.c index 50f4d92e403..1cf7ba0158e 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_ebi.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_ebi.c @@ -6,6 +6,7 @@ * @brief NANO100 series EBI driver source file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #include "Nano100Series.h" diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_pdma.h b/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_pdma.h index 94b4c9a78bd..a7559cb0e1a 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_pdma.h +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_pdma.h @@ -6,6 +6,7 @@ * @brief Nano100 series PDMA driver header file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #ifndef __PDMA_H__ diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_rtc.c b/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_rtc.c index 80cd0072c28..5f4417cd4c8 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_rtc.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_rtc.c @@ -6,6 +6,7 @@ * @brief Nano100 series RTC driver source file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_rtc.h b/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_rtc.h index 35652799b2c..d30adf2e9b7 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_rtc.h +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_rtc.h @@ -6,6 +6,7 @@ * @brief Nano100 series RTC driver header file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #ifndef __RTC_H__ diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_scuart.c b/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_scuart.c index fc77986b5ec..a890a31a062 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_scuart.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_scuart.c @@ -6,6 +6,7 @@ * @brief Nano100 series Smartcard UART mode (SCUART) driver source file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #include "Nano100Series.h" diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_scuart.h b/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_scuart.h index debc2c48423..72f0ad9cf53 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_scuart.h +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_scuart.h @@ -6,6 +6,7 @@ * @brief Nano100 series Smartcard UART mode (SCUART) driver header file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #ifndef __SCUART_H__ diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_sys.c b/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_sys.c index 81020901365..5539010ed49 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_sys.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_sys.c @@ -6,6 +6,7 @@ * @brief NANO100 series SYS driver source file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_timer.h b/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_timer.h index 35f4a148938..615c95859a9 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_timer.h +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_timer.h @@ -6,6 +6,7 @@ * @brief Nano100 series TIMER driver header file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #ifndef __TIMER_H__ diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_uart.c b/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_uart.c index 5936de75860..e618b46a5a3 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_uart.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_uart.c @@ -6,6 +6,7 @@ * @brief Nano100 series Smartcard UART mode (UART) driver source file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_uart.h b/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_uart.h index 23dab9640fa..06c9c7c1928 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_uart.h +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_uart.h @@ -6,6 +6,7 @@ * @brief Nano100 Series uart control header file. * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_wdt.c b/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_wdt.c index ca833c19492..e83a2056b04 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_wdt.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_wdt.c @@ -6,6 +6,7 @@ * @brief Nano100 series WDT driver source file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #include "Nano100Series.h" diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_wdt.h b/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_wdt.h index e1d38ab486b..060435071bc 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_wdt.h +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_wdt.h @@ -6,6 +6,7 @@ * @brief Nano100 series WDT driver header file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #ifndef __WDT_H__ diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_wwdt.c b/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_wwdt.c index dc84280d95c..9a1069842ff 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_wwdt.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_wwdt.c @@ -6,6 +6,7 @@ * @brief Nano100 series WWDT driver source file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #include "Nano100Series.h" diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_wwdt.h b/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_wwdt.h index edbe93a8e41..dbe56f77ee9 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_wwdt.h +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/device/StdDriver/nano100_wwdt.h @@ -6,6 +6,7 @@ * @brief Nano100 series WWDT driver header file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #ifndef __WWDT_H__ diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/device/cmsis.h b/targets/TARGET_NUVOTON/TARGET_NANO100/device/cmsis.h index 9d23802c145..2d00f4046da 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/device/cmsis.h +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/device/cmsis.h @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2017 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/device/cmsis_nvic.c b/targets/TARGET_NUVOTON/TARGET_NANO100/device/cmsis_nvic.c index f05d4c9eb14..b604448f9b5 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/device/cmsis_nvic.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/device/cmsis_nvic.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2017 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/device/cmsis_nvic.h b/targets/TARGET_NUVOTON/TARGET_NANO100/device/cmsis_nvic.h index f74aa8079d7..53bccccc8a7 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/device/cmsis_nvic.h +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/device/cmsis_nvic.h @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2017 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/device/startup_Nano100Series.c b/targets/TARGET_NUVOTON/TARGET_NANO100/device/startup_Nano100Series.c index 57f1f81e877..bb160c5078d 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/device/startup_Nano100Series.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/device/startup_Nano100Series.c @@ -6,6 +6,7 @@ * @brief CMSIS ARM Cortex-M0 Core Device Startup File * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/dma.h b/targets/TARGET_NUVOTON/TARGET_NANO100/dma.h index d0aa76b3391..be8e9f3aed4 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/dma.h +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/dma.h @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/dma_api.c b/targets/TARGET_NUVOTON/TARGET_NANO100/dma_api.c index 650fbbb6f6e..c24accc9275 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/dma_api.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/dma_api.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2017 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/gpio_api.c b/targets/TARGET_NUVOTON/TARGET_NANO100/gpio_api.c index b83a74da320..93171e82f90 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/gpio_api.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/gpio_api.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2020 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/gpio_irq_api.c b/targets/TARGET_NUVOTON/TARGET_NANO100/gpio_irq_api.c index 031e3b6a361..8b7a3514701 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/gpio_irq_api.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/gpio_irq_api.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2017 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/gpio_object.h b/targets/TARGET_NUVOTON/TARGET_NANO100/gpio_object.h index 957789c5a5a..a13cfa5a307 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/gpio_object.h +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/gpio_object.h @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2017 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/i2c_api.c b/targets/TARGET_NUVOTON/TARGET_NANO100/i2c_api.c index 72aa9cda7a1..04b3560f781 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/i2c_api.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/i2c_api.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2017 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +22,7 @@ #include "cmsis.h" #include "pinmap.h" #include "PeripheralPins.h" +#include "gpio_api.h" #include "nu_modutil.h" #include "nu_miscutil.h" #include "nu_bitutil.h" diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/lp_ticker.c b/targets/TARGET_NUVOTON/TARGET_NANO100/lp_ticker.c index 190e4358bbd..ef9c2585b77 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/lp_ticker.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/lp_ticker.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2017 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/mbed_overrides.c b/targets/TARGET_NUVOTON/TARGET_NANO100/mbed_overrides.c index a88d2b52e8f..c5478ffa859 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/mbed_overrides.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/mbed_overrides.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2017 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/objects.h b/targets/TARGET_NUVOTON/TARGET_NANO100/objects.h index bf605a6cfe0..024df05adec 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/objects.h +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/objects.h @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2017 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/pinmap.c b/targets/TARGET_NUVOTON/TARGET_NANO100/pinmap.c index c364c066af1..8fc69211d2e 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/pinmap.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/pinmap.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2017 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/port_api.c b/targets/TARGET_NUVOTON/TARGET_NANO100/port_api.c index 9de24498a57..13d614b02c2 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/port_api.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/port_api.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2017 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/pwmout_api.c b/targets/TARGET_NUVOTON/TARGET_NANO100/pwmout_api.c index 8ba1f40dd43..daaa3e9d448 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/pwmout_api.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/pwmout_api.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2017 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +22,7 @@ #include "cmsis.h" #include "pinmap.h" #include "PeripheralPins.h" +#include "gpio_api.h" #include "nu_modutil.h" #include "nu_miscutil.h" #include "nu_bitutil.h" diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/reset_reason.c b/targets/TARGET_NUVOTON/TARGET_NANO100/reset_reason.c index a2ea29c464c..a9fe9783b35 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/reset_reason.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/reset_reason.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2017-2018 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/rtc_api.c b/targets/TARGET_NUVOTON/TARGET_NANO100/rtc_api.c index 2a117468f12..648bdd69759 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/rtc_api.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/rtc_api.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2017 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/serial_api.c b/targets/TARGET_NUVOTON/TARGET_NANO100/serial_api.c index 2da2c9d3606..31b55ed668e 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/serial_api.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/serial_api.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2017 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +23,7 @@ #include "mbed_error.h" #include "mbed_assert.h" #include "PeripheralPins.h" +#include "gpio_api.h" #include "nu_modutil.h" #include "nu_bitutil.h" #include diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/sleep.c b/targets/TARGET_NUVOTON/TARGET_NANO100/sleep.c index 2de2ab58818..1bdc199c5c6 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/sleep.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/sleep.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2017 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/spi_api.c b/targets/TARGET_NUVOTON/TARGET_NANO100/spi_api.c index fe8c4e79e61..68be50ace50 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/spi_api.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/spi_api.c @@ -22,6 +22,7 @@ #include "cmsis.h" #include "pinmap.h" #include "PeripheralPins.h" +#include "gpio_api.h" #include "nu_modutil.h" #include "nu_miscutil.h" #include "nu_bitutil.h" diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/us_ticker.c b/targets/TARGET_NUVOTON/TARGET_NANO100/us_ticker.c index 4a3f0e56c22..b8f2a8d2b34 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/us_ticker.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/us_ticker.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2017 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/watchdog_api.c b/targets/TARGET_NUVOTON/TARGET_NANO100/watchdog_api.c index f5432386bd8..c5f733ff201 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/watchdog_api.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/watchdog_api.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2017-2018 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/PeripheralNames.h b/targets/TARGET_NUVOTON/TARGET_NUC472/PeripheralNames.h index 475bd62678f..32b512a1427 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/PeripheralNames.h +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/PeripheralNames.h @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/PeripheralPins.c b/targets/TARGET_NUVOTON/TARGET_NUC472/PeripheralPins.c index b7813987f3a..a735d9914a6 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/PeripheralPins.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/PeripheralPins.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/PeripheralPins.h b/targets/TARGET_NUVOTON/TARGET_NUC472/PeripheralPins.h index 53bde3dc39e..2a4e5d62245 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/PeripheralPins.h +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/PeripheralPins.h @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/PinNames.h b/targets/TARGET_NUVOTON/TARGET_NUC472/PinNames.h index 852a193b8ab..a75d2007f99 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/PinNames.h +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/PinNames.h @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -115,9 +116,6 @@ typedef enum { D14 = PD_12, D15 = PD_10, - I2C_SCL = D15, - I2C_SDA = D14, - // NOTE: other board-specific naming // UART naming CONSOLE_TX = PD_5, @@ -133,26 +131,28 @@ typedef enum { STDIO_UART_RX = CONSOLE_RX, #endif SERIAL_TX = CONSOLE_TX, - SERIAL_RX = CONSOLE_RX, - // LED naming - LED1 = PD_9, - LED2 = PA_4, - LED3 = PD_8, - LED4 = LED1, // No real LED. Just for passing ATS. - LED_RED = LED1, - LED_GREEN = LED2, - LED_BLUE = LED3, - // Button naming - SW1 = PC_12, - SW2 = PC_13, - BUTTON1 = SW1, - BUTTON2 = SW2, + SERIAL_RX = CONSOLE_RX, // Force PinName to 32-bit required by NU_PINNAME_BIND(...) FORCE_ENUM_PINNAME_32BIT = 0x7FFFFFFF, } PinName; +// LEDs +#define LED1 PD_9 +#define LED2 PA_4 +#define LED3 PD_8 + +// Button naming +#define SW1 PC_12 +#define SW2 PC_13 +#define BUTTON1 SW1 +#define BUTTON2 SW2 + +// I2C +#define I2C_SCL D15 +#define I2C_SDA D14 + #ifdef __cplusplus } #endif diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/PortNames.h b/targets/TARGET_NUVOTON/TARGET_NUC472/PortNames.h index bab6204339c..a7e046cd2b3 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/PortNames.h +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/PortNames.h @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/analogin_api.c b/targets/TARGET_NUVOTON/TARGET_NUC472/analogin_api.c index 88bfd03b919..a7d2844169c 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/analogin_api.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/analogin_api.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +22,7 @@ #include "cmsis.h" #include "pinmap.h" #include "PeripheralPins.h" +#include "gpio_api.h" #include "nu_modutil.h" #include "hal/PinNameAliases.h" diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/can_api.c b/targets/TARGET_NUVOTON/TARGET_NUC472/can_api.c index 7ea08e771eb..3b33bd61b91 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/can_api.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/can_api.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,18 +24,31 @@ #include "cmsis.h" #include "pinmap.h" #include "PeripheralPins.h" + #include "gpio_api.h" #include "nu_modutil.h" #include "nu_miscutil.h" #include "nu_bitutil.h" #include "mbed_critical.h" + #include "mbed_error.h" #define NU_CAN_DEBUG 0 #define CAN_NUM 2 + /* Reserve Message Object number 31 for Tx */ +#define NU_CAN_MSG_OBJ_NUM_TX 31 + +/* Convert to string literal */ +#define NU_STR_(X) #X +#define NU_STR(X) NU_STR_(X) + +/* Max number of message ID filter handle */ +#define NU_CAN_MAXNUM_HNDL NU_CAN_MSG_OBJ_NUM_TX + static uintptr_t can_irq_contexts[CAN_NUM] = {0}; static can_irq_handler can0_irq_handler; static can_irq_handler can1_irq_handler; + extern void CAN_CLR_INT_PENDING_ONLY_BIT(CAN_T *tCAN, uint32_t u32MsgNum); static const struct nu_modinit_s can_modinit_tab[] = { {CAN_0, CAN0_MODULE, 0, 0, CAN0_RST, CAN0_IRQn, NULL}, @@ -133,19 +147,10 @@ static void can_irq(CANName name, int id) /**************************/ if(can->STATUS & CAN_STATUS_RXOK_Msk) { can->STATUS &= ~CAN_STATUS_RXOK_Msk; /* Clear Rx Ok status*/ - if(id) - can1_irq_handler(can_irq_contexts[id] , IRQ_RX); - else - can0_irq_handler(can_irq_contexts[id], IRQ_RX); } if(can->STATUS & CAN_STATUS_TXOK_Msk) { can->STATUS &= ~CAN_STATUS_TXOK_Msk; /* Clear Tx Ok status*/ - if(id) - can1_irq_handler(can_irq_contexts[id] , IRQ_TX); - else - can0_irq_handler(can_irq_contexts[id], IRQ_TX); - } /**************************/ @@ -164,6 +169,24 @@ static void can_irq(CANName name, int id) else can0_irq_handler(can_irq_contexts[id], IRQ_BUS); } + } else if (u8IIDRstatus >= 1 && u8IIDRstatus <= 32) { + if ((u8IIDRstatus - 1) != NU_CAN_MSG_OBJ_NUM_TX) { + if (id) { + can1_irq_handler(can_irq_contexts[id], IRQ_RX); + } + else { + can0_irq_handler(can_irq_contexts[id], IRQ_RX); + } + CAN_CLR_INT_PENDING_ONLY_BIT(can, (u8IIDRstatus -1)); + } else { + if (id) { + can1_irq_handler(can_irq_contexts[id], IRQ_TX); + } + else { + can0_irq_handler(can_irq_contexts[id], IRQ_TX); + } + CAN_CLR_INT_PENDING_BIT(can, (u8IIDRstatus -1)); + } } else if (u8IIDRstatus!=0) { if(id) @@ -263,6 +286,9 @@ void can_irq_set(can_t *obj, CanIrqType irq, uint32_t enable) int can_write(can_t *obj, CAN_Message msg, int cc) { + /* Unused */ + (void) cc; + STR_CANMSG_T CMsg; CMsg.IdType = (uint32_t)msg.format; @@ -271,7 +297,7 @@ int can_write(can_t *obj, CAN_Message msg, int cc) CMsg.DLC = msg.len; memcpy((void *)&CMsg.Data[0],(const void *)&msg.data[0], (unsigned int)8); - return CAN_Transmit((CAN_T *)NU_MODBASE(obj->can), cc, &CMsg); + return CAN_Transmit((CAN_T *)NU_MODBASE(obj->can), NU_CAN_MSG_OBJ_NUM_TX, &CMsg); } int can_read(can_t *obj, CAN_Message *msg, int handle) @@ -335,6 +361,13 @@ int can_mode(can_t *obj, CanMode mode) int can_filter(can_t *obj, uint32_t id, uint32_t mask, CANFormat format, int32_t handle) { + /* Check validity of filter handle */ + if (handle < 0 || handle >= NU_CAN_MAXNUM_HNDL) { + /* NOTE: 0 is ambiguous, error or filter handle 0. */ + error("Support max " NU_STR(NU_CAN_MAXNUM_HNDL) " CAN filters"); + return 0; + } + return CAN_SetRxMsg((CAN_T *)NU_MODBASE(obj->can), handle , (uint32_t)format, id); } diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/crypto/crypto-misc.cpp b/targets/TARGET_NUVOTON/TARGET_NUC472/crypto/crypto-misc.cpp index 567b131306a..ad276d69762 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/crypto/crypto-misc.cpp +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/crypto/crypto-misc.cpp @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/crypto/crypto-misc.h b/targets/TARGET_NUVOTON/TARGET_NUC472/crypto/crypto-misc.h index 09b57266581..d7b48e60f10 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/crypto/crypto-misc.h +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/crypto/crypto-misc.h @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/device.h b/targets/TARGET_NUVOTON/TARGET_NUC472/device.h index 2f05e05becc..7ecc5d505f2 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/device.h +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/device.h @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_adc.c b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_adc.c index 8c57095d3a7..a206af154d8 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_adc.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_adc.c @@ -6,6 +6,7 @@ * @brief NUC472/NUC442 ADC driver source file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #include "NUC472_442.h" diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_adc.h b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_adc.h index 62251a16979..d74c1e86734 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_adc.h +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_adc.h @@ -6,6 +6,7 @@ * @brief NUC472/NUC442 ADC driver header file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #ifndef __ADC_H__ diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_can.c b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_can.c index 673d8846973..7c1bd7d1401 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_can.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_can.c @@ -6,6 +6,7 @@ * @brief NUC472/NUC442 CAN driver source file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ @@ -716,7 +717,7 @@ int32_t CAN_Receive(CAN_T *tCAN, uint32_t u32MsgNum , STR_CANMSG_T* pCanMsg) * @return None * */ -void CAN_CLR_INT_PENDING_BIT(CAN_T *tCAN, uint8_t u32MsgNum) +void CAN_CLR_INT_PENDING_BIT(CAN_T *tCAN, uint32_t u32MsgNum) { uint32_t u32MsgIfNum = 0; uint32_t u32IFBusyCount = 0; @@ -738,6 +739,28 @@ void CAN_CLR_INT_PENDING_BIT(CAN_T *tCAN, uint8_t u32MsgNum) } +/* Clone of CAN_CLR_INT_PENDING_BIT() with NewDat not cleared */ +void CAN_CLR_INT_PENDING_ONLY_BIT(CAN_T *tCAN, uint32_t u32MsgNum) +{ + uint32_t u32MsgIfNum = 0; + uint32_t u32IFBusyCount = 0; + + while(u32IFBusyCount < 0x10000000) { + if((tCAN->IF[0].CREQ & CAN_IF_CREQ_BUSY_Msk) == 0) { + u32MsgIfNum = 0; + break; + } else if((tCAN->IF[1].CREQ & CAN_IF_CREQ_BUSY_Msk) == 0) { + u32MsgIfNum = 1; + break; + } + + u32IFBusyCount++; + } + + tCAN->IF[u32MsgIfNum].CMASK = CAN_IF_CMASK_CLRINTPND_Msk; + tCAN->IF[u32MsgIfNum].CREQ = 1 + u32MsgNum; + +} /*@}*/ /* end of group NUC472_442_CAN_EXPORTED_FUNCTIONS */ diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_can.h b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_can.h index 65e63fa7474..ae7f4b7bb82 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_can.h +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_can.h @@ -6,6 +6,7 @@ * @brief NUC472/NUC442 CAN driver header file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #ifndef __CAN_H__ @@ -143,7 +144,7 @@ uint32_t CAN_SetBaudRate(CAN_T *tCAN, uint32_t u32BaudRate); uint32_t CAN_Open(CAN_T *tCAN, uint32_t u32BaudRate, uint32_t u32Mode); int32_t CAN_Transmit(CAN_T *tCAN, uint32_t u32MsgNum , STR_CANMSG_T* pCanMsg); int32_t CAN_Receive(CAN_T *tCAN, uint32_t u32MsgNum , STR_CANMSG_T* pCanMsg); -void CAN_CLR_INT_PENDING_BIT(CAN_T *tCAN, uint8_t u32MsgNum); +void CAN_CLR_INT_PENDING_BIT(CAN_T *tCAN, uint32_t u32MsgNum); void CAN_EnableInt(CAN_T *tCAN, uint32_t u32Mask); void CAN_DisableInt(CAN_T *tCAN, uint32_t u32Mask); int32_t CAN_SetMultiRxMsg(CAN_T *tCAN, uint32_t u32MsgNum , uint32_t u32MsgCount, uint32_t u32IDType, uint32_t u32ID); diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_cap.h b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_cap.h index 9e28c6dcd13..b20dc1f90f5 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_cap.h +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_cap.h @@ -6,6 +6,7 @@ * @brief NUC470 series Image Capture Driver Header File * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. * ******************************************************************************/ diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_clk.c b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_clk.c index 790c9405d67..b32620b8b97 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_clk.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_clk.c @@ -6,6 +6,7 @@ * @brief NUC472/NUC442 CLK driver source file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_clk.h b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_clk.h index bdb19ded092..f923fc67371 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_clk.h +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_clk.h @@ -6,6 +6,7 @@ * @brief NUC472/NUC442 CLK Header File * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. ******************************************************************************/ #ifndef __CLK_H__ diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_emac.c b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_emac.c index e4643e84009..9bcf10be4aa 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_emac.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_emac.c @@ -6,6 +6,7 @@ * @brief NUC472/NUC442 EMAC driver source file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #include diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_emac.h b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_emac.h index fa9f10e3e8a..e67d5cd127f 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_emac.h +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_emac.h @@ -6,6 +6,7 @@ * @brief NUC472/NUC442 EMAC driver header file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #ifndef __EMAC_H__ diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_fmc.c b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_fmc.c index 4d4d33cc19a..7c9daee1810 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_fmc.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_fmc.c @@ -6,6 +6,7 @@ * @brief NUC472/NUC442 FMC driver source file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_fmc.h b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_fmc.h index 886ea69eab9..195645c163c 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_fmc.h +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_fmc.h @@ -6,6 +6,7 @@ * @brief NUC472/NUC442 Flash Memory Controller Driver Header File * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. * ******************************************************************************/ diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_pdma.c b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_pdma.c index e3dbbc05d8e..7cf5d145db0 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_pdma.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_pdma.c @@ -6,6 +6,7 @@ * @brief NUC472/NUC442 PDMA driver source file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #include "NUC472_442.h" diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_pdma.h b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_pdma.h index ba0a99189a7..3f0d6e8b651 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_pdma.h +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_pdma.h @@ -6,6 +6,7 @@ * @brief NUC472/NUC442 PDMA driver header file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #ifndef __PDMA_H__ diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_ps2.c b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_ps2.c index bced66f6e2f..a41b866dae1 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_ps2.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_ps2.c @@ -6,6 +6,7 @@ * @brief NUC472/NUC442 PS2 driver source file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_ps2.h b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_ps2.h index 4ca07916c01..7f01387507e 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_ps2.h +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_ps2.h @@ -6,6 +6,7 @@ * @brief NUC472/NUC442 PS2 Driver Header File * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. ******************************************************************************/ #ifndef __PS2_H__ diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_pwm.h b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_pwm.h index 2585a5db9c6..5fb3f3f78b0 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_pwm.h +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_pwm.h @@ -6,6 +6,7 @@ * @brief NUC472/NUC442 PWM driver header file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #ifndef __PWM_H__ diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_rtc.c b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_rtc.c index 2267a3980b2..76cc0e249b7 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_rtc.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_rtc.c @@ -6,6 +6,7 @@ * @brief NUC472/NUC442 RTC driver source file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_rtc.h b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_rtc.h index 1965b2081d6..936f504ca9a 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_rtc.h +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_rtc.h @@ -6,6 +6,7 @@ * @brief NUC472/NUC442 RTC driver header file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_sd.c b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_sd.c index 9d9b17ff830..bc723f1a359 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_sd.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_sd.c @@ -6,6 +6,7 @@ * @brief NUC472/NUC442 SD driver source file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #include diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_sd.h b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_sd.h index 27a4c4978dd..1c79e68dcd2 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_sd.h +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_sd.h @@ -6,6 +6,7 @@ * @brief NUC472/NUC442 SD driver header file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #include diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_sys.c b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_sys.c index 1b9570016f1..2c66edf8fe4 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_sys.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_sys.c @@ -6,6 +6,7 @@ * @brief NUC472/NUC442 SYS driver source file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_sys.h b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_sys.h index bf6cc6995bf..1f0e4d2c7c9 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_sys.h +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_sys.h @@ -6,6 +6,7 @@ * @brief NUC472/NUC442 SYS Header File * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. ******************************************************************************/ diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_timer.c b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_timer.c index 6f3d4ad48e4..c4859cc6c5c 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_timer.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_timer.c @@ -6,6 +6,7 @@ * @brief NUC472/NUC442 TIMER driver source file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #include "NUC472_442.h" diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_timer.h b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_timer.h index 5c270959006..29afe5a8dd5 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_timer.h +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_timer.h @@ -6,6 +6,7 @@ * @brief NUC472/NUC442 TIMER driver header file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #ifndef __TIMER_H__ diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_uart.c b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_uart.c index 84b6c0a30c6..cad66b133cf 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_uart.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_uart.c @@ -6,6 +6,7 @@ * @brief NUC472/NUC442 UART driver source file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_uart.h b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_uart.h index e6e6f73bd78..8b1d09a6a4f 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_uart.h +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_uart.h @@ -6,6 +6,7 @@ * @brief NUC472/NUC442 UART driver header file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_wdt.c b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_wdt.c index 4a9c34ac67e..d98cb54ac22 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_wdt.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_wdt.c @@ -6,6 +6,7 @@ * @brief NUC472/NUC442 WDT driver source file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #include "NUC472_442.h" diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_wdt.h b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_wdt.h index 552be640699..e984c7efb08 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_wdt.h +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_wdt.h @@ -6,6 +6,7 @@ * @brief NUC472/NUC442 WDT driver header file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #ifndef __WDT_H__ diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_wwdt.c b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_wwdt.c index 5359baaccf2..54b1e0b3d9b 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_wwdt.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_wwdt.c @@ -6,6 +6,7 @@ * @brief NUC472/NUC442 WWDT driver source file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #include "NUC472_442.h" diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_wwdt.h b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_wwdt.h index cf3e543521a..ac0e7d09ce0 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_wwdt.h +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_wwdt.h @@ -6,6 +6,7 @@ * @brief NUC472/NUC442 WWDT driver header file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #ifndef __WWDT_H__ diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/device/cmsis.h b/targets/TARGET_NUVOTON/TARGET_NUC472/device/cmsis.h index 3ec85e40846..eb95997dd48 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/device/cmsis.h +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/device/cmsis.h @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/device/cmsis_nvic.h b/targets/TARGET_NUVOTON/TARGET_NUC472/device/cmsis_nvic.h index 6a492639aca..e276fc7dc26 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/device/cmsis_nvic.h +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/device/cmsis_nvic.h @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/device/system_NUC472_442.c b/targets/TARGET_NUVOTON/TARGET_NUC472/device/system_NUC472_442.c index 56a5fb8cdae..bee5615ae1b 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/device/system_NUC472_442.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/device/system_NUC472_442.c @@ -6,6 +6,7 @@ * @brief NUC472/NUC442 system clock init code and assert handler * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/device/system_NUC472_442.h b/targets/TARGET_NUVOTON/TARGET_NUC472/device/system_NUC472_442.h index d78e9cdf6da..43efa793545 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/device/system_NUC472_442.h +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/device/system_NUC472_442.h @@ -6,6 +6,7 @@ * @brief NUC472/NUC442 system clock definition file * * @note + * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #ifndef __SYSTEM_NUC472_442_H__ diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/dma.h b/targets/TARGET_NUVOTON/TARGET_NUC472/dma.h index 465003246ba..bbf1f007bc9 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/dma.h +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/dma.h @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/dma_api.c b/targets/TARGET_NUVOTON/TARGET_NUC472/dma_api.c index bc8dde16805..00205a15577 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/dma_api.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/dma_api.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/flash_api.c b/targets/TARGET_NUVOTON/TARGET_NUC472/flash_api.c index 8da24b1b296..f39fefbb9c4 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/flash_api.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/flash_api.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/gpio_api.c b/targets/TARGET_NUVOTON/TARGET_NUC472/gpio_api.c index e0c59e75b46..dace43ec7e3 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/gpio_api.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/gpio_api.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2020 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/gpio_irq_api.c b/targets/TARGET_NUVOTON/TARGET_NUC472/gpio_irq_api.c index 05380708d60..de5c6dec5a8 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/gpio_irq_api.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/gpio_irq_api.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/gpio_object.h b/targets/TARGET_NUVOTON/TARGET_NUC472/gpio_object.h index 719006bf134..46c5a246c24 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/gpio_object.h +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/gpio_object.h @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/i2c_api.c b/targets/TARGET_NUVOTON/TARGET_NUC472/i2c_api.c index e88835cc65e..bf68282d562 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/i2c_api.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/i2c_api.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +22,7 @@ #include "cmsis.h" #include "pinmap.h" #include "PeripheralPins.h" +#include "gpio_api.h" #include "nu_modutil.h" #include "nu_miscutil.h" #include "nu_bitutil.h" diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/lp_ticker.c b/targets/TARGET_NUVOTON/TARGET_NUC472/lp_ticker.c index 44e367d2c12..8911aba2785 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/lp_ticker.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/lp_ticker.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/mbed_overrides.c b/targets/TARGET_NUVOTON/TARGET_NUC472/mbed_overrides.c index 2e2375bc1e2..58125a4a228 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/mbed_overrides.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/mbed_overrides.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/objects.h b/targets/TARGET_NUVOTON/TARGET_NUC472/objects.h index 54ea4f6a7cb..bd14dfc9192 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/objects.h +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/objects.h @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2019 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/pinmap.c b/targets/TARGET_NUVOTON/TARGET_NUC472/pinmap.c index cd2cc107a06..cb4530dd4ec 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/pinmap.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/pinmap.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/port_api.c b/targets/TARGET_NUVOTON/TARGET_NUC472/port_api.c index c04f2335415..c42c164c1be 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/port_api.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/port_api.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/pwmout_api.c b/targets/TARGET_NUVOTON/TARGET_NUC472/pwmout_api.c index aa81799abea..5622291e695 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/pwmout_api.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/pwmout_api.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +22,7 @@ #include "cmsis.h" #include "pinmap.h" #include "PeripheralPins.h" +#include "gpio_api.h" #include "nu_modutil.h" #include "nu_miscutil.h" #include "nu_bitutil.h" diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/reset_reason.c b/targets/TARGET_NUVOTON/TARGET_NUC472/reset_reason.c index 2f8f5bc5158..1c48077aa34 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/reset_reason.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/reset_reason.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2017-2018 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/rtc_api.c b/targets/TARGET_NUVOTON/TARGET_NUC472/rtc_api.c index 6bcf87fba0c..a4701e17a41 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/rtc_api.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/rtc_api.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/serial_api.c b/targets/TARGET_NUVOTON/TARGET_NUC472/serial_api.c index 6c1f8889b0c..f1b16beea49 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/serial_api.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/serial_api.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +23,7 @@ #include "mbed_error.h" #include "mbed_assert.h" #include "PeripheralPins.h" +#include "gpio_api.h" #include "nu_modutil.h" #include "nu_bitutil.h" #include diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/sleep.c b/targets/TARGET_NUVOTON/TARGET_NUC472/sleep.c index 321377702a7..8aed5c4b8be 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/sleep.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/sleep.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/spi_api.c b/targets/TARGET_NUVOTON/TARGET_NUC472/spi_api.c index 6ce546a7967..705bf684136 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/spi_api.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/spi_api.c @@ -22,6 +22,7 @@ #include "cmsis.h" #include "pinmap.h" #include "PeripheralPins.h" +#include "gpio_api.h" #include "nu_modutil.h" #include "nu_miscutil.h" #include "nu_bitutil.h" diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/us_ticker.c b/targets/TARGET_NUVOTON/TARGET_NUC472/us_ticker.c index 0b147639377..31e666d7596 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/us_ticker.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/us_ticker.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/watchdog_api.c b/targets/TARGET_NUVOTON/TARGET_NUC472/watchdog_api.c index 21d67aa6c32..2633da9af75 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/watchdog_api.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/watchdog_api.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2017-2018 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/USBEndpoints_Nuvoton.cpp b/targets/TARGET_NUVOTON/USBEndpoints_Nuvoton.cpp index f057247ac99..314c8971479 100644 --- a/targets/TARGET_NUVOTON/USBEndpoints_Nuvoton.cpp +++ b/targets/TARGET_NUVOTON/USBEndpoints_Nuvoton.cpp @@ -915,11 +915,13 @@ static volatile int epComplete = 0; #define HSUSBD_GET_EP_MAX_PAYLOAD(ep) HSUSBD->EP[ep].EPMPS #define HSUSBD_GET_EP_DATA_COUNT(ep) (HSUSBD->EP[ep].EPDATCNT & 0xFFFFF) #define HSUSBD_SET_EP_SHORT_PACKET(ep) HSUSBD->EP[ep].EPRSPCTL = ((HSUSBD->EP[ep].EPRSPCTL & 0x10) | 0x40) +#define HSUSBD_SET_EP_ZERO_PACKET(ep) HSUSBD->EP[ep].EPRSPCTL = ((HSUSBD->EP[ep].EPRSPCTL & 0x10) | 0x20) #define HSUSBD_GET_EP_INT_EN(ep) HSUSBD->EP[ep].EPINTEN #elif defined (TARGET_NUC472) #define USBD_GET_EP_MAX_PAYLOAD(ep) *((__IO uint32_t *) ((uint32_t)&USBD->EPAMPS + (uint32_t)(ep*0x28))) #define USBD_GET_EP_DATA_COUNT(ep) *((__IO uint32_t *) ((uint32_t)&USBD->EPADATCNT + (uint32_t)(ep*0x28))) #define USBD_SET_EP_SHORT_PACKET(ep) *((__IO uint32_t *) ((uint32_t)&USBD->EPARSPCTL + (uint32_t)(ep*0x28))) = ((*((__IO uint32_t *)((uint32_t)&USBD->EPARSPCTL+(uint32_t)(ep*0x28))) & 0x10) | 0x40) +#define USBD_SET_EP_ZERO_PACKET(ep) *((__IO uint32_t *) ((uint32_t)&USBD->EPARSPCTL + (uint32_t)(ep*0x28))) = (*((__IO uint32_t *)((uint32_t)&USBD->EPARSPCTL+(uint32_t)(ep*0x28))) & 0x10) #define USBD_SET_EP_BUF_FLUSH(ep) *((__IO uint32_t *) ((uint32_t)&USBD->EPARSPCTL + (uint32_t)(ep*0x28))) = USBD_EPRSPCTL_FLUSH_Msk #define USBD_GET_EP_INT_EN(ep) *((__IO uint32_t *) ((uint32_t)&USBD->EPAINTEN + (uint32_t)(ep*0x28))) #define USBD_GET_EP_INT(ep) *((__IO uint32_t *) ((uint32_t)&USBD->EPAINTSTS + (uint32_t)(ep*0x28))) @@ -1699,6 +1701,18 @@ bool USBPhyHw::endpoint_write(usb_ep_t endpoint, uint8_t *data, uint32_t size) if (size > mps) return false; + /* Send Zero packet */ + if (size == 0) { +#if defined (TARGET_NUC472) + USBD_SET_EP_ZERO_PACKET(ep_hw_index); + USBD_ENABLE_EP_INT(ep_hw_index, USBD_GET_EP_INT_EN(ep_hw_index) | USBD_EPINTEN_TXPKIEN_Msk); +#elif defined (TARGET_M480) || defined (TARGET_M460) + HSUSBD_SET_EP_ZERO_PACKET(ep_hw_index); + HSUSBD->EP[ep_hw_index].EPINTEN |= HSUSBD_EPINTEN_TXPKIEN_Msk; +#endif + return true; + } + #if defined (TARGET_NUC472) if(USBD_GET_EP_DATA_COUNT(ep_hw_index) & 0xFFFF) { diff --git a/targets/TARGET_NUVOTON/nu_bitutil.h b/targets/TARGET_NUVOTON/nu_bitutil.h index 7ca88993547..270ab4924ea 100644 --- a/targets/TARGET_NUVOTON/nu_bitutil.h +++ b/targets/TARGET_NUVOTON/nu_bitutil.h @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/nu_miscutil.c b/targets/TARGET_NUVOTON/nu_miscutil.c index 3edf3e149fd..2ea9b0ca4df 100644 --- a/targets/TARGET_NUVOTON/nu_miscutil.c +++ b/targets/TARGET_NUVOTON/nu_miscutil.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/nu_miscutil.h b/targets/TARGET_NUVOTON/nu_miscutil.h index fd1cc9e9977..73df9dd3728 100644 --- a/targets/TARGET_NUVOTON/nu_miscutil.h +++ b/targets/TARGET_NUVOTON/nu_miscutil.h @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/nu_modutil.c b/targets/TARGET_NUVOTON/nu_modutil.c index 2743996320e..71bcef15e1d 100644 --- a/targets/TARGET_NUVOTON/nu_modutil.c +++ b/targets/TARGET_NUVOTON/nu_modutil.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/nu_modutil.h b/targets/TARGET_NUVOTON/nu_modutil.h index 60602e1d13f..52646f3b51c 100644 --- a/targets/TARGET_NUVOTON/nu_modutil.h +++ b/targets/TARGET_NUVOTON/nu_modutil.h @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/nu_timer.c b/targets/TARGET_NUVOTON/nu_timer.c index ef3d3489caf..eb04d3e1c8c 100644 --- a/targets/TARGET_NUVOTON/nu_timer.c +++ b/targets/TARGET_NUVOTON/nu_timer.c @@ -1,5 +1,6 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/targets/TARGET_NUVOTON/nu_timer.h b/targets/TARGET_NUVOTON/nu_timer.h index 4b9f359e2e6..ada6f653d06 100644 --- a/targets/TARGET_NUVOTON/nu_timer.h +++ b/targets/TARGET_NUVOTON/nu_timer.h @@ -1,7 +1,7 @@ /* mbed Microcontroller Library * Copyright (c) 2015-2016 Nuvoton - * - * Licensed under the Apache License, Version 2.0 (the "License"); + * SPDX-License-Identifier: Apache-2.0 + ** Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * diff --git a/targets/TARGET_STM/TARGET_STM32F1/objects.h b/targets/TARGET_STM/TARGET_STM32F1/objects.h index 621880d3b7c..f254c0565a8 100644 --- a/targets/TARGET_STM/TARGET_STM32F1/objects.h +++ b/targets/TARGET_STM/TARGET_STM32F1/objects.h @@ -2,6 +2,7 @@ ******************************************************************************* * Copyright (c) 2016, STMicroelectronics * All rights reserved. + * SPDX-License-Identifier: BSD-3-Clause * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -99,6 +100,8 @@ struct i2c_s { uint8_t slave; volatile uint8_t pending_slave_tx_master_rx; volatile uint8_t pending_slave_rx_maxter_tx; + volatile uint8_t slave_tx_transfer_in_progress; + volatile uint8_t slave_rx_transfer_in_progress; uint8_t *slave_rx_buffer; volatile uint16_t slave_rx_buffer_size; volatile uint16_t slave_rx_count; diff --git a/targets/TARGET_STM/TARGET_STM32F2/objects.h b/targets/TARGET_STM/TARGET_STM32F2/objects.h index 765a5019423..1ad59e96713 100644 --- a/targets/TARGET_STM/TARGET_STM32F2/objects.h +++ b/targets/TARGET_STM/TARGET_STM32F2/objects.h @@ -2,6 +2,7 @@ ******************************************************************************* * Copyright (c) 2016, STMicroelectronics * All rights reserved. + * SPDX-License-Identifier: BSD-3-Clause * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -114,6 +115,8 @@ struct i2c_s { uint8_t slave; volatile uint8_t pending_slave_tx_master_rx; volatile uint8_t pending_slave_rx_maxter_tx; + volatile uint8_t slave_tx_transfer_in_progress; + volatile uint8_t slave_rx_transfer_in_progress; uint8_t *slave_rx_buffer; volatile uint16_t slave_rx_buffer_size; volatile uint16_t slave_rx_count; diff --git a/targets/TARGET_STM/TARGET_STM32F4/objects.h b/targets/TARGET_STM/TARGET_STM32F4/objects.h index 1a9f9d30e89..58fb19094dc 100644 --- a/targets/TARGET_STM/TARGET_STM32F4/objects.h +++ b/targets/TARGET_STM/TARGET_STM32F4/objects.h @@ -88,6 +88,8 @@ struct i2c_s { uint8_t slave; volatile uint8_t pending_slave_tx_master_rx; volatile uint8_t pending_slave_rx_maxter_tx; + volatile uint8_t slave_tx_transfer_in_progress; + volatile uint8_t slave_rx_transfer_in_progress; uint8_t *slave_rx_buffer; volatile uint16_t slave_rx_buffer_size; volatile uint16_t slave_rx_count; diff --git a/targets/TARGET_STM/TARGET_STM32L1/objects.h b/targets/TARGET_STM/TARGET_STM32L1/objects.h index 89cc310e8ac..5dad0793363 100644 --- a/targets/TARGET_STM/TARGET_STM32L1/objects.h +++ b/targets/TARGET_STM/TARGET_STM32L1/objects.h @@ -85,6 +85,8 @@ struct i2c_s { uint8_t slave; volatile uint8_t pending_slave_tx_master_rx; volatile uint8_t pending_slave_rx_maxter_tx; + volatile uint8_t slave_tx_transfer_in_progress; + volatile uint8_t slave_rx_transfer_in_progress; uint8_t *slave_rx_buffer; volatile uint16_t slave_rx_buffer_size; volatile uint16_t slave_rx_count; diff --git a/targets/TARGET_STM/can_api.c b/targets/TARGET_STM/can_api.c index 73bfa81f346..7cd93cc3933 100644 --- a/targets/TARGET_STM/can_api.c +++ b/targets/TARGET_STM/can_api.c @@ -183,8 +183,11 @@ static void _can_init_freq_direct(can_t *obj, const can_pinmap_t *pinmap, int hz obj->CanHandle.Init.DataTimeSeg1 = 0x1; // Not used - only in FDCAN obj->CanHandle.Init.DataTimeSeg2 = 0x1; // Not used - only in FDCAN #ifdef TARGET_STM32H7 - /* Message RAM offset is only supported in STM32H7 platforms of supported FDCAN platforms */ - obj->CanHandle.Init.MessageRAMOffset = 0; + /* Message RAM offset is only supported in STM32H7 platforms of supported FDCAN platforms + * Total RAM size is 2560 words, each FDCAN object allocates approx 300 words, so offset each by + * 512 to make sure RAM sections don't overlap if using multiple FDCAN instances on one chip + */ + obj->CanHandle.Init.MessageRAMOffset = obj->index * 512; /* The number of Standard and Extended ID filters are initialized to the maximum possile extent * for STM32H7 platforms @@ -1216,13 +1219,12 @@ static void can_irq(CANName name, int id) tmp1 = __HAL_CAN_MSG_PENDING(&CanHandle, CAN_FIFO0); tmp2 = __HAL_CAN_GET_IT_SOURCE(&CanHandle, CAN_IT_FMP0); - // In legacy can (bxCAN and earlier), reading is the only way to clear rx interrupt. But can_read has mutex locks - // since mutexes cannot be used in ISR context, rx interrupt is masked here to temporary disable it - // rx interrupts will be unamsked in read operation. reads must be deffered to thread context. - // refer to the CAN receive interrupt problem due to mutex and resolution section of README doc. - __HAL_CAN_DISABLE_IT(&CanHandle, CAN_IT_FMP0); - if ((tmp1 != 0) && tmp2) { + // In legacy can (bxCAN and earlier), reading is the only way to clear rx interrupt. But can_read has mutex locks + // since mutexes cannot be used in ISR context, rx interrupt is masked here to temporary disable it + // rx interrupts will be unamsked in read operation. reads must be deffered to thread context. + // refer to the CAN receive interrupt problem due to mutex and resolution section of README doc. + __HAL_CAN_DISABLE_IT(&CanHandle, CAN_IT_FMP0); irq_handler(can_irq_contexts[id], IRQ_RX); } diff --git a/targets/TARGET_STM/i2c_api.c b/targets/TARGET_STM/i2c_api.c index a355efe4a84..b5f197db638 100644 --- a/targets/TARGET_STM/i2c_api.c +++ b/targets/TARGET_STM/i2c_api.c @@ -2,6 +2,7 @@ ******************************************************************************* * Copyright (c) 2015-2021, STMicroelectronics * All rights reserved. + * SPDX-License-Identifier: BSD-3-Clause * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -563,6 +564,8 @@ void i2c_init_internal(i2c_t *obj, const i2c_pinmap_t *pinmap) obj_s->slave = 0; obj_s->pending_slave_tx_master_rx = 0; obj_s->pending_slave_rx_maxter_tx = 0; + obj_s->slave_tx_transfer_in_progress = 0; + obj_s->slave_rx_transfer_in_progress = 0; #endif obj_s->event = 0; @@ -1618,6 +1621,7 @@ void HAL_I2C_SlaveTxCpltCallback(I2C_HandleTypeDef *I2cHandle) i2c_t *obj = get_i2c_obj(I2cHandle); struct i2c_s *obj_s = I2C_S(obj); obj_s->pending_slave_tx_master_rx = 0; + obj_s->slave_tx_transfer_in_progress = 0; } void HAL_I2C_SlaveRxCpltCallback(I2C_HandleTypeDef *I2cHandle) @@ -1632,9 +1636,11 @@ void HAL_I2C_SlaveRxCpltCallback(I2C_HandleTypeDef *I2cHandle) HAL_I2C_Slave_Seq_Receive_IT(I2cHandle, &(obj_s->slave_rx_buffer[obj_s->slave_rx_count]), 1, I2C_NEXT_FRAME); } else { obj_s->pending_slave_rx_maxter_tx = 0; + obj_s->slave_rx_transfer_in_progress = 0; } } else { obj_s->pending_slave_rx_maxter_tx = 0; + obj_s->slave_rx_transfer_in_progress = 0; } } @@ -1688,12 +1694,13 @@ int i2c_slave_read(i2c_t *obj, char *data, int length) _length = length; } + obj_s->slave_rx_transfer_in_progress = 1; /* Always use I2C_NEXT_FRAME as slave will just adapt to master requests */ ret = HAL_I2C_Slave_Seq_Receive_IT(handle, (uint8_t *) data, _length, I2C_NEXT_FRAME); if (ret == HAL_OK) { timeout = BYTE_TIMEOUT_US * (_length + 1); - while (obj_s->pending_slave_rx_maxter_tx && (--timeout != 0)) { + while (obj_s->slave_rx_transfer_in_progress && (--timeout != 0)) { wait_us(1); } @@ -1718,12 +1725,13 @@ int i2c_slave_write(i2c_t *obj, const char *data, int length) int ret = 0; uint32_t timeout = 0; + obj_s->slave_tx_transfer_in_progress = 1; /* Always use I2C_NEXT_FRAME as slave will just adapt to master requests */ ret = HAL_I2C_Slave_Seq_Transmit_IT(handle, (uint8_t *) data, length, I2C_NEXT_FRAME); if (ret == HAL_OK) { timeout = BYTE_TIMEOUT_US * (length + 1); - while (obj_s->pending_slave_tx_master_rx && (--timeout != 0)) { + while (obj_s->slave_tx_transfer_in_progress && (--timeout != 0)) { wait_us(1); } diff --git a/targets/TARGET_STM/serial_api.c b/targets/TARGET_STM/serial_api.c index edb73485a8e..7e93769bbd0 100644 --- a/targets/TARGET_STM/serial_api.c +++ b/targets/TARGET_STM/serial_api.c @@ -2,6 +2,7 @@ ******************************************************************************* * Copyright (c) 2017, STMicroelectronics * All rights reserved. + * SPDX-License-Identifier: BSD-3-Clause * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -207,6 +208,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) uint8_t stdio_config = false; +#if defined(MBED_CONF_TARGET_CONSOLE_UART) if ((tx == CONSOLE_TX) || (rx == CONSOLE_RX)) { stdio_config = true; } else { @@ -214,6 +216,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) error("Error: new serial object is using same UART as STDIO"); } } +#endif const serial_pinmap_t explicit_uart_pinmap = {peripheral, tx, tx_function, rx, rx_function, stdio_config}; diff --git a/targets/TARGET_STM/stm_i2c_api.h b/targets/TARGET_STM/stm_i2c_api.h index 7ae17f4b83b..c2bce54e8e9 100644 --- a/targets/TARGET_STM/stm_i2c_api.h +++ b/targets/TARGET_STM/stm_i2c_api.h @@ -68,6 +68,8 @@ struct i2c_s { uint8_t slave; volatile uint8_t pending_slave_tx_master_rx; volatile uint8_t pending_slave_rx_maxter_tx; + volatile uint8_t slave_tx_transfer_in_progress; + volatile uint8_t slave_rx_transfer_in_progress; uint8_t *slave_rx_buffer; volatile uint16_t slave_rx_buffer_size; volatile uint16_t slave_rx_count; diff --git a/targets/cmsis_mcu_descriptions.json5 b/targets/cmsis_mcu_descriptions.json5 index 6807c9c613d..641a65f03e6 100644 --- a/targets/cmsis_mcu_descriptions.json5 +++ b/targets/cmsis_mcu_descriptions.json5 @@ -2435,6 +2435,100 @@ "sub_family": null, "vendor": "Maxim:23" }, + "MAX32670": { + "algorithms": [ + { + "default": true, + "file_name": "Flash/MAX32670.FLM", + "ram_size": null, + "ram_start": null, + "size": 393215, + "start": 268435456, + "style": "Keil" + }, + { + "default": false, + "file_name": "FlashIAR/FlashMAX32670.flash", + "ram_size": 524288, + "ram_start": 536870912, + "size": 1048576, + "start": 268435456, + "style": "IAR" + } + ], + "family": "MAX32670 family", + "from_pack": { + "pack": "MAX32670", + "url": "http://www.mxim.net/microcontroller/pack/", + "vendor": "Maxim", + "version": "1.1.0" + }, + "memories": { + "IRAM1": { + "access": { + "execute": true, + "non_secure": false, + "non_secure_callable": false, + "peripheral": false, + "read": true, + "secure": false, + "write": true + }, + "default": true, + "p_name": null, + "size": 163839, + "start": 536870912, + "startup": false + }, + "IROM1": { + "access": { + "execute": true, + "non_secure": false, + "non_secure_callable": false, + "peripheral": false, + "read": true, + "secure": false, + "write": false + }, + "default": true, + "p_name": null, + "size": 393215, + "start": 268435456, + "startup": true + } + }, + "name": "MAX32670", + "processors": [ + { + "address": null, + "ap": 0, + "apid": null, + "core": "CortexM4", + "default_reset_sequence": null, + "dp": 0, + "fpu": "SinglePrecision", + "mpu": "NotPresent", + "name": "Cortex-M4", + "svd": null, + "unit": 0 + }, + { + "address": null, + "ap": 0, + "apid": null, + "core": "CortexM4", + "default_reset_sequence": null, + "dp": 0, + "fpu": "SinglePrecision", + "mpu": "NotPresent", + "name": "Cortex-M4", + "svd": null, + "unit": 1 + } + ], + "sub_family": null, + "vendor": "Maxim:23" + }, "MIMXRT1052DVL6A": { "algorithms": [ { diff --git a/targets/targets.json5 b/targets/targets.json5 index 0da6094070e..dbca8a0445b 100644 --- a/targets/targets.json5 +++ b/targets/targets.json5 @@ -6573,7 +6573,8 @@ "std", "small" ] - } + }, + "device_name": "MAX32670" }, "MAX32670EVKIT": { "inherits": [ @@ -6590,6 +6591,16 @@ ], "image_url": "https://os.mbed.com/media/uploads/sadik_maxim/max32670evkit_daplink_fw_update.png" }, + "XDOT_MAX32670": { + "inherits": [ + "MAX32670" + ], + "bootloader_supported": true, + "detect_code": [ + "0351" + ], + "image_url": "https://os.mbed.com/media/cache/platforms/xDot_Developer_Kit_with_xdot.png.250x250_q85.png" + }, // SiLabs EFM32 Targets--------------------------------------------------------------------------------------------- "EFM32": {