Commit Graph

18 Commits (125f1693422257164a0557b070af3a9ec2833e18)

Author SHA1 Message Date
Przemyslaw Stekiel 13dff4ae3d Relax us ticker frequency requirement.
This change is required by the Samsung S111(S5JS100). On this board timer clock used for us ticker operates at 26MHz.
According to current requirements, 8 MHz is the top limit for us ticker timer.

This change relaxes top limit to 100 MHz, but only for 32-bit timers.

Ticker common layer schedules one interrupt per timer rollover to trace elapsed time. We need to ensure that this operation is not performed too frequently. I.e. in case of 16-bit timer at 32 MHz, the timer rollover will happen after ~2 ms. This may cause that there will be no time for other tasks. That is why we increase the top limit, but only for 32-bit timers.
2019-08-02 13:13:38 +02:00
Kevin Bracey 57310729d4 wait_us optimization
As the timer code became more generic, coping with initialization on
demand, and variable width and speed us_ticker_api implementations,
wait_us has gradually gotten slower and slower.

Some platforms have reportedly seen overhead of wait_us() increase from
10µs to 30µs. These changes should fully reverse that drop, and even
make it better than ever.

Add fast paths for platforms that provide compile-time information about
us_ticker. Speed and code size is improved further if:

* Timer has >= 2^32 microsecond range, or better still is 32-bit 1MHz.
* Platform implements us_ticker_read() as a macro
* Timer is initialised at boot, rather than first use

The latter initialisation option is the default for STM, as this has
always been the case.
2019-06-14 10:22:08 +03:00
Martin Kojtal 406f9508d3 hal: add spdx license 2018-11-28 10:39:51 +00:00
Przemyslaw Stekiel 629718bc7f Remove requirements for ticker free function 2018-08-14 08:08:11 +02:00
Przemyslaw Stekiel 28d8f4595f Add requirements and pseudo code for HAL ticker_free() function. 2018-07-25 08:54:50 +02:00
Martin Kojtal 483427a285 hal: astyle update 2018-06-29 10:36:36 +01:00
Bartek Szatkowski ba963b4453 Rename lp_us tests to common and hf to microsecond 2018-05-25 12:20:09 -05:00
Steven Cartmell 18943a9693 Add lp/us ticker free() function implementation for NRF5 2018-05-25 12:17:49 -05:00
Steven Cartmell 2894152efe Add free function to lp/us ticker HAL API 2018-05-25 12:17:49 -05:00
Przemyslaw Stekiel a8eee0fb1a Modify requirement for the ticker_init function.
Current version:
The function ticker_init resets the internal count and disables the ticker interrupt.

Proposed version:
The function ticker_init allows the ticker to keep counting and disables the ticker interrupt.

This is a result of the following discussion:
https://github.com/ARMmbed/mbed-os/pull/5233#pullrequestreview-86677815
2018-05-25 12:17:49 -05:00
Przemyslaw Stekiel 0ae7b82c07 Add minor modifications of lp/us tickers tests desctiption in ticker header files.
Add one potential bug to the test description.
Fix test function names to be consistant with desctiption and test header.
Fix typos.
2018-05-25 12:04:32 -05:00
Russ Butler 03d7141797 Add documentation for the HAL Ticker API
Add documentation and test header for the HAL Ticker API.
2018-05-25 12:04:32 -05:00
Przemyslaw Stekiel 5da5b28f96 Add API to set ticker IRQ handler.
This API is added primarily for testing purposes, to be able to test HAL drivers without using upper layers to handle ticker interrupt.
By default IRQ handler is set to ticker_irq_handler() for us ticker and lp ticker - original one.

Usage example (setting custom ticker irq handler):

void my_irq_handler(const ticker_data_t *const) {
 // handle interrupt
}

ticker_irq_handler_type old_handler = set_us_ticker_irq_handler(my_irq_handler);

Respectively for lp timer set_lp_ticker_irq_handler() API should be used.
2017-10-30 10:38:38 +01:00
Russ Butler ec55b82acf Update ticker to map closely to hardware
Allow tickers to specify their native frequency and number of bits.
This allows the conversion to happen in common code rather than in
each vendor's implementation.
2017-10-05 11:57:12 -05:00
Martin Kojtal 10ea63b8e7 Ticker: add fire interrupt now function
fire_interrupt function should be used for events in the past. As we have now
64bit timestamp, we can figure out what is in the past, and ask a target to invoke
an interrupt immediately. The previous attemps in the target HAL tickers were not ideal, as it can wrap around easily (16 or 32 bit counters). This new
functionality should solve this problem.

set_interrupt for tickers in HAL code should not handle anything but the next match interrupt. If it was in the past is handled by the upper layer.

It is possible that we are setting next event to the close future, so once it is set it is already in the past. Therefore we add a check after set interrupt to verify it is in future.
If it is not, we fire interrupt immediately. This results in
two events - first one immediate, correct one. The second one might be scheduled in far future (almost entire ticker range),
that should be discarded.

The specification for the fire_interrupts are:
- should set pending bit for the ticker interrupt (as soon as possible),
the event we are scheduling is already in the past, and we do not want to skip
any events
- no arguments are provided, neither return value, not needed
- ticker should be initialized prior calling this function (no need to check if it is already initialized)

All our targets provide this new functionality, removing old misleading if (timestamp is in the past) checks.
2017-07-13 12:23:25 +01:00
Jimmy Brisson f1a78027d3 Add tags to our code 2016-10-04 15:02:44 -05:00
Sam Grove 301b77c4b2 For drivers, events, hal, platform, rtos and mbed.h add one level of path to make sure specific and unique includes files are found. 2016-10-01 02:11:36 -05:00
Christopher Haster 15904b7544 restructure - Split hal into drivers+platform+hal
hal/common/AnalogIn.cpp -> drivers/AnalogIn.cpp
hal/api/AnalogIn.h -> drivers/AnalogIn.h
hal/api/AnalogOut.h -> drivers/AnalogOut.h
hal/common/BusIn.cpp -> drivers/BusIn.cpp
hal/api/BusIn.h -> drivers/BusIn.h
hal/common/BusInOut.cpp -> drivers/BusInOut.cpp
hal/api/BusInOut.h -> drivers/BusInOut.h
hal/common/BusOut.cpp -> drivers/BusOut.cpp
hal/api/BusOut.h -> drivers/BusOut.h
hal/common/CAN.cpp -> drivers/CAN.cpp
hal/api/CAN.h -> drivers/CAN.h
hal/api/CircularBuffer.h -> drivers/CircularBuffer.h
hal/api/DigitalIn.h -> drivers/DigitalIn.h
hal/api/DigitalInOut.h -> drivers/DigitalInOut.h
hal/api/DigitalOut.h -> drivers/DigitalOut.h
hal/api/DirHandle.h -> drivers/DirHandle.h
hal/common/Ethernet.cpp -> drivers/Ethernet.cpp
hal/api/Ethernet.h -> drivers/Ethernet.h
hal/common/FileBase.cpp -> drivers/FileBase.cpp
hal/api/FileBase.h -> drivers/FileBase.h
hal/api/FileHandle.h -> drivers/FileHandle.h
hal/common/FileLike.cpp -> drivers/FileLike.cpp
hal/api/FileLike.h -> drivers/FileLike.h
hal/common/FilePath.cpp -> drivers/FilePath.cpp
hal/api/FilePath.h -> drivers/FilePath.h
hal/common/FileSystemLike.cpp -> drivers/FileSystemLike.cpp
hal/api/FileSystemLike.h -> drivers/FileSystemLike.h
hal/common/I2C.cpp -> drivers/I2C.cpp
hal/api/I2C.h -> drivers/I2C.h
hal/common/I2CSlave.cpp -> drivers/I2CSlave.cpp
hal/api/I2CSlave.h -> drivers/I2CSlave.h
hal/common/InterruptIn.cpp -> drivers/InterruptIn.cpp
hal/api/InterruptIn.h -> drivers/InterruptIn.h
hal/common/InterruptManager.cpp -> drivers/InterruptManager.cpp
hal/api/InterruptManager.h -> drivers/InterruptManager.h
hal/common/LocalFileSystem.cpp -> drivers/LocalFileSystem.cpp
hal/api/LocalFileSystem.h -> drivers/LocalFileSystem.h
hal/api/LowPowerTicker.h -> drivers/LowPowerTicker.h
hal/api/LowPowerTimeout.h -> drivers/LowPowerTimeout.h
hal/api/LowPowerTimer.h -> drivers/LowPowerTimer.h
hal/api/PortIn.h -> drivers/PortIn.h
hal/api/PortInOut.h -> drivers/PortInOut.h
hal/api/PortOut.h -> drivers/PortOut.h
hal/api/PwmOut.h -> drivers/PwmOut.h
hal/common/RawSerial.cpp -> drivers/RawSerial.cpp
hal/api/RawSerial.h -> drivers/RawSerial.h
hal/common/SPI.cpp -> drivers/SPI.cpp
hal/api/SPI.h -> drivers/SPI.h
hal/common/SPISlave.cpp -> drivers/SPISlave.cpp
hal/api/SPISlave.h -> drivers/SPISlave.h
hal/common/Serial.cpp -> drivers/Serial.cpp
hal/api/Serial.h -> drivers/Serial.h
hal/common/SerialBase.cpp -> drivers/SerialBase.cpp
hal/api/SerialBase.h -> drivers/SerialBase.h
hal/common/Stream.cpp -> drivers/Stream.cpp
hal/api/Stream.h -> drivers/Stream.h
hal/common/Ticker.cpp -> drivers/Ticker.cpp
hal/api/Ticker.h -> drivers/Ticker.h
hal/common/Timeout.cpp -> drivers/Timeout.cpp
hal/api/Timeout.h -> drivers/Timeout.h
hal/common/Timer.cpp -> drivers/Timer.cpp
hal/api/Timer.h -> drivers/Timer.h
hal/common/TimerEvent.cpp -> drivers/TimerEvent.cpp
hal/api/TimerEvent.h -> drivers/TimerEvent.h
hal/api/Transaction.h -> drivers/Transaction.h
hal/api/can_helper.h -> drivers/can_helper.h
hal/.yotta_ignore
hal/CMakeLists.txt
hal/hal/analogin_api.h -> hal/analogin_api.h
hal/hal/analogout_api.h -> hal/analogout_api.h
hal/hal/buffer.h -> hal/buffer.h
hal/hal/can_api.h -> hal/can_api.h
hal/hal/dma_api.h -> hal/dma_api.h
hal/hal/ethernet_api.h -> hal/ethernet_api.h
hal/hal/gpio_api.h -> hal/gpio_api.h
hal/hal/gpio_irq_api.h -> hal/gpio_irq_api.h
hal/hal/i2c_api.h -> hal/i2c_api.h
hal/hal/lp_ticker_api.h -> hal/lp_ticker_api.h
hal/common/mbed_gpio.c -> hal/mbed_gpio.c
hal/common/mbed_lp_ticker_api.c -> hal/mbed_lp_ticker_api.c
hal/common/mbed_pinmap_common.c -> hal/mbed_pinmap_common.c
hal/common/mbed_ticker_api.c -> hal/mbed_ticker_api.c
hal/common/mbed_us_ticker_api.c -> hal/mbed_us_ticker_api.c
hal/module.json
hal/hal/pinmap.h -> hal/pinmap.h
hal/hal/port_api.h -> hal/port_api.h
hal/hal/pwmout_api.h -> hal/pwmout_api.h
hal/hal/rtc_api.h -> hal/rtc_api.h
hal/hal/serial_api.h -> hal/serial_api.h
hal/hal/sleep_api.h -> hal/sleep_api.h
hal/hal/spi_api.h -> hal/spi_api.h
hal/hal/storage_abstraction/Driver_Common.h -> hal/storage_abstraction/Driver_Common.h
hal/hal/storage_abstraction/Driver_Storage.h -> hal/storage_abstraction/Driver_Storage.h
hal/hal/ticker_api.h -> hal/ticker_api.h
hal/hal/trng_api.h -> hal/trng_api.h
hal/hal/us_ticker_api.h -> hal/us_ticker_api.h
hal/api/mbed.h -> mbed.h
hal/api/CThunk.h -> platform/CThunk.h
hal/common/CallChain.cpp -> platform/CallChain.cpp
hal/api/CallChain.h -> platform/CallChain.h
hal/api/Callback.h -> platform/Callback.h
hal/api/FunctionPointer.h -> platform/FunctionPointer.h
hal/api/PlatformMutex.h -> platform/PlatformMutex.h
hal/api/SingletonPtr.h -> platform/SingletonPtr.h
hal/api/critical.h -> platform/critical.h
hal/common/mbed_alloc_wrappers.cpp -> platform/mbed_alloc_wrappers.cpp
hal/common/mbed_assert.c -> platform/mbed_assert.c
hal/api/mbed_assert.h -> platform/mbed_assert.h
hal/common/mbed_board.c -> platform/mbed_board.c
hal/common/mbed_critical.c -> platform/mbed_critical.c
hal/api/mbed_debug.h -> platform/mbed_debug.h
hal/common/mbed_error.c -> platform/mbed_error.c
hal/api/mbed_error.h -> platform/mbed_error.h
hal/common/mbed_interface.c -> platform/mbed_interface.c
hal/api/mbed_interface.h -> platform/mbed_interface.h
hal/common/mbed_mem_trace.c -> platform/mbed_mem_trace.c
hal/api/mbed_mem_trace.h -> platform/mbed_mem_trace.h
hal/common/mbed_rtc_time.cpp -> platform/mbed_rtc_time.cpp
hal/common/mbed_semihost_api.c -> platform/mbed_semihost_api.c
hal/api/mbed_stats.h -> platform/mbed_stats.h
hal/common/mbed_wait_api_no_rtos.c -> platform/mbed_wait_api_no_rtos.c
hal/common/mbed_wait_api_rtos.cpp -> platform/mbed_wait_api_rtos.cpp
hal/api/platform.h -> platform/platform.h
hal/common/retarget.cpp -> platform/retarget.cpp
hal/api/rtc_time.h -> platform/rtc_time.h
hal/api/semihost_api.h -> platform/semihost_api.h
hal/api/toolchain.h -> platform/toolchain.h
hal/api/wait_api.h -> platform/wait_api.h
2016-09-30 19:18:09 -05:00