Commit Graph

193 Commits (87bc6de65a3943d2f1cdba22da70af6b592e2ec7)

Author SHA1 Message Date
Jamie Smith 87bc6de65a
Add Arduino Nicla Sense ME support (#271)
* Port over Nicla Sense ME arduino target

* Re-add button1

* Fix missing licenses, fix I2C assignment, fix LoRa module descriptions
2024-05-16 01:12:55 -07:00
Jamie Smith 699437ecf9
Allow Mbed CE to be built as an Arduino core (#206)
* Various changes for Arduino core support

* Apply Arduino Mbed TLS patches

* Apply linker script patch, add missing CXX standard

* Fix SDBlockDevice compile error, fix "no rule to make mbed-target-config.h"

* Fix missing source file for RPi Pico

* Fix missing licenses
2024-01-13 10:01:45 -08:00
Jamie Smith 69d95b598a
Make DMA SPI driver aware of CPU cache, fix data corruption and other SPI issues on STM32H7 (#199)
* Handle cache alignment in DMA SPI driver

* Fix build on cache-less devices

* Fix a couple things I missed

* Run formatter, improve CacheAlignedBuffer docs

* Add missing license identifiers to source files

* Make CacheAlignedBuffer heap-allocatable, try and add exclusion for Nordic license in scancode_evaluate.py

* Formatting, docs, revert accidental change

* Update code blocks to pass spell checker
2023-12-19 10:21:47 -08:00
Jamie Smith 28815b13d3
DMA SPI support for STM32 devices (#162)
* Start on STM32 DMA SPI

* Update all objects.hs, add interrupt function

* Initial DMA code should be ready to test out...

* Fix SPI interrupt-mode IRQ handlers, add SPI::transfer_and_wait

* Fix CMake error when building for STM32WL processors

* Now builds on all STM devices!

* Properly support STM32U5 / DMA IP v3

* Start on STM32F4 support, fix hardfault on IP v1 and v3 due to incorrect indexing

* Fix Rx-only transfers, add abort code, fix incorrect channel assignments for DMA IP v1 devices

* Start on STM32H7 SPI DMA

* Fixes for H7: Correctly manage data cache, keep SPI ISR enabled

* Implement DMA SPI header constants for all remaining STM32 families.  Also add support for freeing DMA channels

* Try and fix build on STM32G0

* Fix build on STM32G0

* Add SPI_32BIT_WORDS label, start on fixing SPI docs

* SPI: Implement reference counting so that DMA channels get freed properly

* Fix issue where SPI data could get corrupted (by TI mode turning on) depending on memory layout (if your spis pointer & 0x10 was nonzero)

* Mark DMA channels as unallocated when SPI bus is freed

* Simplify spi_abort_asynch()

* Fix some rebase issues, fix failing to allocate DMA channel on STM32U5

* Fix DMA getting stuck on STM32F4, F7, and F2
2023-11-02 20:16:45 -07:00
Jamie Smith 1ed5f1f149
SPI Driver API bugfixes and cleanup, part 2 (#180)
* Make it so that SPI::select() works correctly with async stuff

* Add more overloads for SPI functions, make sure that SPI::abort_transfer() correctly toggles CS

* SPI: Implement reference counting so that DMA channels get freed properly

* Fix initialization of SPI peripheral structures

* Update docs a bit

* Use a mutex to protect SPI::_peripherals instead of a critical section, because spi_free() may not be ISR safe

* Style fixes
2023-08-25 09:14:00 -07:00
Jamie Smith 785e3fb87b
Improve usability and documentation of the SPI API (#165)
* Make TRANSACTION_QUEUE_SIZE_SPI a proper option instead of a weird macro

* Document DMAUsage constant

* Copy over reworked SPI header

* Spelling -_-

* Document SPI event flags
2023-06-25 19:44:34 -07:00
Jamie Smith 3f7d67c64c
Synchronize upstream changes - May 2023 edition (#160)
* fix STM32L1 FLASH_SIZE for cat.3 devices with DEV_ID 0x436

* Fix mesh connect semaphore not releasing causing blockage

* Add support of NSAPI_ICMP sockets in Nanostack

* STM32F1: add MCU_STM32F103xD support

* STM32F1: add MCU_STM32F103xG support

* test: Disable failing tests due to echo server

Some tests are failing as echo.mbedcloudtesting.com is not serving TLS
requests anymore.

Signed-off-by: Saheer Babu <saheer.babu@arm.com>

* Check CAN DLC length value

* Fix default interface ID only being used partially

If user sets the default interface ID for a socket (e.g. using setsockopt
with SOCKET_INTERFACE_SELECT), the default interface should take over
other interface selection mechanisms as a interface is bound to the socket.
This applies for both IPv6 local and global scopes for unicast messages
but not for multicast messages as these are bound to a multicast interface
using SOCKET_IPV6_MULTICAST_IF socket option.

* Targets: NXP: IMXRT: Fixed GCC_ARM lds syntax.

Signed-off-by: Yilin Sun <imi415@imi.moe>

* CAN: read only up to 8 bytes

If HAL implementation writes more than 8 bytes of data, error immediately.
CANMessage defines only 8 bytes of data, lenght cannot be > 8.

This fixes https://github.com/ARMmbed/mbed-os/issues/15361

Signed-off-by: Martin Kojtal <martin.kojtal@arm.com>

* STM32F303xC: add RAM_CCM in GCC linker script

* fix(drivers/emac): Remove incorrect RMII RX ER initialization

* fix(drivers/emac): Add missing SPDX indetifier to ST driver files

* fixed compiler inline issue

* Update Mbed version block

* removed HSE speed limitation for STM32G431RB

* Added HSE range validation for STM32g431xB

* added support for 4, 8 and 16MHz

* M487: Remove unused variable 'u32EscapeFrame'

Remove unused variable 'u32EscapeFrame' in BSP m480_ccap.h to avoid warnings

* force FIFO IRQ for FDCan RX on H7

* Add hardware CRC support to STM32G4

* add support for Nucleo-H745ZI

* Update MAX32670 peripheral drivers with final ones that use by SDK

Signed-off-by: Sadik.Ozer <sadik.ozer@analog.com>

* MAX32670 apply mbed required changes on peripheral drivers

Signed-off-by: Sadik.Ozer <sadik.ozer@analog.com>

* M467: Support CAN bus

1.  Update BSP CANFD driver
2.  Notes for implementation
    (1) Each CANFD instance supports two IRQ lines. Use only line 0. Line 1 is not used.
    (2) For Rx disabling multiple filter handles,
        1)  Map all filter handles to filter handle 0
        2)  Use Rx FIFO 0 for filter handle 0
    (3) For Rx enabling multiple filter handles,
        1)  Use Rx FIFO 0 for filter handle 0
        2)  Use Rx FIFO 1 for filter handle through first invoking can_filter()
        3)  Use dedicated Rx Buffer for other filter handles
        NOTE: H/W supports mask on Rx FIFO 0/1 but not on dedicated Rx Buffer.
    (4) For Tx, use only dedicated Tx Buffer. BSP CANFD driver doesn't support Tx FIFO/Queue.
    (5) Support no CAN FD.

* Fix 'new[]' array freed with 'delete'

The array _scratch_buf is allocated using new[] in line 761 of
mbed-os/storage/kvstore/securestore/source/SecureStore.cpp.
But it was freed using delete.

* Define default parameters of functions of derived class the same as the base class

The member function bringup() of class ThreadInterface redefines
parameter stack's default value to IPV6_STACK from the inherited default value
DEFAULT_STACK (in Interface).
The default value will be resolved statically, not by dispatch, so this
can cause confusion.
Similar arguments apply to LoWPANNDInterface and WisunInterface.

* Avoid calling virtual functions from constructors and destructors

Virtual functions are resolved statically (not dynamically) in
constructors and destructors for the same class. The call should be made
explicitly static by qualifying it using the scope resolution operator.

* Fix potentially overrunning write of sprintf

Format string "%d" requires 12 bytes (including the null terminator).
Also, use snprintf instead of sprintf to prevent buffer overflow.

* Fix system_clock.c location

Signed-off-by: Jasper Jonker <jasper.jonker@wingtra.com>

* Fix variable name

Signed-off-by: Jasper <jasper.jonker@wingtra.com>

* Change storage-class of secret_buf to static

Storing the address of a local variable (`secret_buf`)
in non-local memory (`prf_ptr->secret`) can cause a
dangling pointer bug if the address is used after the function returns.

* fix compiling errors of FATFileSystem when exFAT was enabled

* Add OSPI support for STM32H7

* Nuvoton: Enable extending sampling time for ADC/EADC

For all Nuvoton targets, enable extending sampling time in ADC/EADC clocks on per-pin basis.

---------

Signed-off-by: Saheer Babu <saheer.babu@arm.com>
Signed-off-by: Yilin Sun <imi415@imi.moe>
Signed-off-by: Martin Kojtal <martin.kojtal@arm.com>
Signed-off-by: Sadik.Ozer <sadik.ozer@analog.com>
Signed-off-by: Jasper Jonker <jasper.jonker@wingtra.com>
Signed-off-by: Jasper <jasper.jonker@wingtra.com>
Co-authored-by: caodd <caodd1993@qq.com>
Co-authored-by: YannCharbon <yann.charbon@ik.me>
Co-authored-by: Jerome Coutant <jerome.coutant@st.com>
Co-authored-by: Saheer Babu <saheer.babu@arm.com>
Co-authored-by: Martyx00 <martin.petran@protonmail.com>
Co-authored-by: Yilin Sun <imi415@imi.moe>
Co-authored-by: Martin Kojtal <martin.kojtal@arm.com>
Co-authored-by: akiroz <akiroz.vectis@gmail.com>
Co-authored-by: Charles <hallard04@free.fr>
Co-authored-by: Leonard Chiang <leochiang2002@gmail.com>
Co-authored-by: Chun-Chieh Li <ccli8@nuvoton.com>
Co-authored-by: jmcloud <jmcloud@tesla.com>
Co-authored-by: Augusto Zanellato <augusto.zanellato@gmail.com>
Co-authored-by: Sadik.Ozer <sadik.ozer@analog.com>
Co-authored-by: Mingjie Shen <shen497@purdue.edu>
Co-authored-by: Jasper Jonker <jasper.jonker@wingtra.com>
Co-authored-by: wdx04 <wdx04@outlook.com>
2023-05-17 01:18:28 -07:00
Jamie Smith ffc33676d1
Lots of usability improvements for the I2C API. Better docs and new top-level functions. (#64)
* Lots of usability improvements for the I2C API.  Better docs and new top-level functions.

* Document frequencies

* Tabs to spaces

* More style fixes

* Run astyle

* Clean up docs

* Add note about addressing, change 10 bit to 11 bit

* Fix spellcheck

* Fix paste error

* Oops, fix accidental change
2022-10-02 21:27:33 -07:00
Jamie Smith d83dbc2ac4 Fix ABI differences between mbed-baremetal and mbed-os, remove PlatformMutex 2022-09-14 00:25:30 -07:00
yutotnh 236194f7c3
add: PwmOut::read_pulsewitdth_us() for compatibility 2022-06-23 21:59:03 +09:00
yutotnh 6a4ba443ea
rename: read_pulsewitdth_us to read_pulsewidth_us 2022-06-21 23:25:43 +09:00
Hari Limaye f4e5359710 GPIO: Use uintptr_t for gpio_irq_api context
The HAL gpio_irq_api stores object IDs, which serve as a form of context
for the dispatch of the interrupt handler in the drivers level
InterruptIn Class. The way this is achieved is that the InterruptIn
Class casts its address to uint32_t, which is stored as the ID.
This results in compilation failure when the size of an object pointer
is greater than uint32_t, for example when building on a PC for unit
testing.

In order to allow Unit Testing of the InterruptIn Class, we replace the
use of uint32_t with uintptr_t (type capable of holding a pointer),
which allows portability and expresses intentions more clearly.
In aid of this latter goal, we also replace the use of the name "id"
with "context", to improve clarity - these are addresses of the context
related to that callback.
2022-01-26 18:12:52 +00:00
Hari Limaye b493a15a53 CAN: Use uintptr_t for can_irq_ids
The HAL can_api stores an array of IDs in order to dispatch interrupts
to the correct CAN object. The drivers level CAN Class casts a pointer
to itself to an uint32_t, which is stored as the ID and then cast back
to a CAN * in order to call the correct handler. This results in
compilation failure when the size of an object pointer is greater than
uint32_t, for example when building on a PC for unit testing.

In order to allow Unit Testing of the CAN Class, we replace the use of
uint32_t with uintptr_t (type capable of holding a pointer), which
allows portability and expresses intentions more clearly. In aid of this
latter goal, we also replace the use of the name "id" with "context",
to improve clarity. These are addresses of the context related to that
callback.
2021-09-17 13:36:43 +01:00
Lingkai Dong e04a16fd9f QSPI: Move destructor into source file
This allows the entire QSPI class to be mocked/faked for unit testing
purpose, without dependencies from the real implementation such as
`qspi_free()` from the HAL.
2021-09-10 09:46:02 +01:00
Vladimir Korneev 4b34f567af Fix hanging with multiple I2C buses
Make the _mutex non-static and remove _owner and acquire()

When two or more I2C buses are used then static__mutex and _owner are
shared between all I2C class instances in the program. That
wastes time to reconfigure periphery on every transfer.

Make _mutex non-static. Remove _owner and acquire() method
because in non-static case they have no practical meaning.
2021-06-20 20:34:00 +03:00
Martin Kojtal ae79b61765
Merge pull request #14675 from 0xc0170/fix_i2c_start
i2c: `start()` should aquire the bus
2021-06-07 20:49:58 +02:00
Sebastian Stockhammer 77b5ffc2f6 Remove shadowing member variables
- The variables shadow SerialBase::_tx_enabled and SerialBase::_rx_enabled
- Update interrupts when input/output is enabled to avoid infinite congestion
- Update comments
2021-05-19 09:01:06 +02:00
Martin Kojtal 3af058af8b i2c: `start()` should aquire the bus
From the history it looks like aquire was not added explicitely to start. I do not see
why as it's the condition that must be sent when communication is initiated.

write/read/transfer invoke `aquire()`
2021-05-18 12:28:13 +01:00
George Beckstein be077713b3 Implement polymorphism for CAN 2021-05-04 01:11:32 -04:00
George Psimenos 0b4fdb5e70 Remove ownership in OSPI driver 2021-03-18 17:12:19 +00:00
George Psimenos a28a8684c9 Remove ownership in QSPI driver 2021-03-17 13:26:25 +00:00
Harrison Mutai 619ca54735 Remove lock from enable_* function overrides 2021-01-21 11:09:50 +00:00
Harrison Mutai 0214a156e7 Implement override of enable_* functions 2021-01-21 10:20:49 +00:00
Martin Kojtal be295e42a4
Merge pull request #13917 from LDong-Arm/move_SFDP
Move SFDP to blockdevice
2020-12-10 13:03:23 +00:00
Martin Kojtal 4c94b4b495
Merge pull request #14005 from kjbracey-arm/teinsert
Correct/clarify TimerEvent::insert documentation
2020-12-09 14:18:06 +00:00
Kevin Bracey cf66a6ed13 Correct/clarify TimerEvent::insert documentation
There was much confusion over the functionality of the original
`TimerEvent::insert` call which was described as "Set relative timestamp
of the internal event".

This then extended to my Chrono conversion, meaning the new `insert`
call is not equivalent.

Clarify the original documentation, correct the deprecation messages,
and add more notes on conversion.

No functional change, as the new Chrono API makes more sense - it's just
different from the old API.

Problem actually spotted when I saw the strange code `convert_timestamp`
was producing for the 32-bit->64-bit timestamp conversion. The caller of
it was actually making the mistake of issuing
"TimerEvent::insert(rel_timeout)`, meaning they'd also misunderstood the
documentation, and were not getting the timeout they expected.

(Chrono would have prevented that mistake as durations and time points
are incompatible types).
2020-12-07 16:28:52 +02:00
Lingkai Dong 5d2fbdc11e Move SFDP into blockdevice where it belongs to 2020-11-26 17:31:31 +00:00
Martin Kojtal 61e4b55a22
Merge pull request #13947 from LDong-Arm/erase_algorithm_fix
Fix erase type determination for [Q/O/]BlockDevice::erase()
2020-11-26 15:53:03 +00:00
Lingkai Dong c41f7cb864 Fix integer type warnings in SFDP and *SPIFBlockDevice 2020-11-26 10:28:58 +00:00
Lingkai Dong e0bd9a1c6a sfdp_iterate_next_largest_erase_type: return -1 if no erase type is applicable 2020-11-25 13:34:01 +00:00
Lingkai Dong ac86aff928 sfdp_iterate_next_largest_erase_type: do not modify type_mask
The supported erase types of a given flash region are indicated
in bitfields of the variable `type_mask`. Even if an erase type
is unused for the current chunk (e.g. size too large, unaligned, etc.),
its bitfield should NOT be cleared - the same erase type might
actually be useful for the next chunk.

The function argument is now a value instead of a reference.
2020-11-24 18:07:34 +00:00
Martin Kojtal 57bbb4739b
Merge pull request #13085 from pea-pod/remove-deprecated-mbed-assert
Change MBED_STATIC_ASSERTs version for built-in
2020-11-24 13:38:07 +00:00
Lingkai Dong 52627dbc59 sfdp_iterate_next_largest_erase_type: fix size check and add alignment check 2020-11-23 15:45:43 +00:00
Evelyne Donnaes b7c6bd34f5 Updated CMakeLists.txt 2020-11-12 15:34:47 +00:00
Evelyne Donnaes 9964212f9e Moved USB drivers under drivers/usb 2020-11-12 14:57:00 +00:00
Martin Kojtal f333c3ead1
Merge pull request #13699 from boraozgen/bugfix/sfdp-find-addr-region
Fix sfdp_find_addr_region algorithm
2020-11-12 08:43:02 +00:00
Martin Kojtal e8a3282181
Merge pull request #13816 from pennam/patch-stm32-usbhs-pull
STM32: allow HS USB endpoints and increase USB OTG_HS endpoints number
2020-11-11 08:27:19 +00:00
Martino Facchin db7954bc9b STM32: allow high speed USB endpoints 2020-11-10 17:22:28 +01:00
Hugues Kamba 794e32df74 CMake: Use relative paths to list source files and directories
The absolute path is still required for listing linker
files as they are referenced from a function in the top
level CMake input source file.
2020-11-09 12:32:30 +00:00
Hugues Kamba bf84a5b329 CMake: Rename CMake targets
* mbed-os renamed mbed-core
* mbed-os-<COMPONENT> renamed mbed-<COMPONENT>
2020-11-06 17:25:22 +00:00
Hugues Kamba fa98689639 CMake: Componentize Mbed OS into multiple CMake targets (#13732)
Aside from the core mbed-os CMake target, a number of targets have been created so they can optionally be included by application executables that require them using `target_link_libraries()`.

Co-authored-by: Martin Kojtal <martin.kojtal@arm.com>
Co-authored-by: Rajkumar Kanagaraj <rajkumar.kanagaraj@arm.com>
2020-11-06 17:25:21 +00:00
Bora Özgen 7f0716ad60 Fix sfdp_find_addr_region algorithm
sfdp_find_addr_region() was causing issues with SPI
flashes with sector table parsed from SFDP (in
particular SST26VF016B).

In particular, it was returning -1 when address 0 is
passed (probably also if the address in the first
region). I do not know why the search algorithm is
written to search from the higher to lower regions,
but it was obvious that it would fail for the first
region. Also it was harder to read due to the index
manipulation.
2020-11-03 14:23:02 +01:00
pea-pod 507181d262 Change MBED_STATIC_ASSERTs version for built-in 2020-10-27 08:30:40 -05:00
Martin Kojtal 21652971a5
Merge pull request #12644 from macronix/macronix_ospi
Add OSPI driver to support the Octa mode of Macronix octaflash MX25LM51245G
2020-09-30 16:07:20 +01:00
Lingkai Dong 7a8460a759 drivers/SFDP: mbed-trace header is now always available
This reverts commit 183ca7729c.

Now the "mbed_trace.h" header is always available and maps
trace functions to dummy macros when tracing is disabled.
2020-09-21 15:40:38 +01:00
rogeryou 48524f25ae add opsi driver 2020-09-16 11:27:23 +08:00
Martin Kojtal 468372e759
Merge pull request #13492 from talorion/fix-PwmOut-resets-after-suspend
Fix pwm out resets after suspend
2020-09-10 12:40:18 +01:00
Martin Kojtal b2ac60924c
Merge pull request #13476 from talorion/bugfix/fix-warnings
Fix trivial compiler Warnings
2020-09-07 09:58:41 +01:00
Lingkai Dong 183ca7729c drivers/SFDP should compile without mbed-trace
The library "drivers" is a core one available to bare metal.
It should not depend on mbed-trace which is an optional library.
2020-09-02 15:50:25 +01:00
talorion 6625bdb9f3 fixed resets after suspend 2020-09-02 13:39:16 +02:00