Skip to content

Conversation

@mikee47
Copy link
Contributor

@mikee47 mikee47 commented Aug 18, 2019

Polled Timers are a new feature, based heavily on the esp8266 Arduino project's PolledTimeout.h
https://github.com/esp8266/Arduino/blob/master/cores/esp8266/PolledTimeout.h.

PR #1830 added muldiv and introduced the use of std::ratio which makes use of C++ language features
to perform compile-time calculations and parameter checking. This PR builds on that using the new
NanoTime library. I felt this warranted new development since existing solutions are either C-based
or not suited for embedded use. This also forms a core part of the Sming timer framework.

This PR moves the existing ElapseTimer and CycleCounter classes into Core. I've taken care to avoid
any extraneous dependencies in these timers which means they're appropriate for use in lower-level
code (Components, drivers, etc.).

The goal is to provide a consistent, logical framework for all timers.

More information can be found in the docs under 'timers'.

@mikee47
Copy link
Contributor Author

mikee47 commented Aug 18, 2019

Quite a few structuraly rearrangements here but I'm feeling quite confident that it's the right direction in support of ESP32. Moving all the low-level stuff into separate drivers simplifies the class implementations without sacrificing performance or bloating the firmware.

This PR has been pulled out of a larger development with some additions for Sming, which I'll summarise briefly so you've got an idea where I'm going:

  • Documentation on how Sming works (multitasking, interupts, memory, timers, tasks, etc.)
  • Classes to support task management. i.e. a simple way to have one or more continuous background activities.
  • I2S hardware driver. Pretty much a rewrite using an IDF-style API with Arduino support layer and some additional optimisations.
  • Port of the ESP8266Audio libraries plus sample applications.
  • Asynchronous I2C driver model. i.e. a proper device stack using classes to implement devices on a bus using asynchronous interrupt-based transfers.

Polled timers are something that can simplify and streamline driver code so it needs to be somewhere accessible, Core seems like the right place though as always totally open to suggestions.

@mikee47
Copy link
Contributor Author

mikee47 commented Aug 18, 2019

Note before merging I'll need to update the migration docs. for this and expand on timers.rst.

@slaff slaff added this to the 4.0.0 milestone Aug 19, 2019
@slaff
Copy link
Contributor

slaff commented Aug 25, 2019

Note before merging I'll need to update the migration docs. for this and expand on timers.rst.

Ping me when this PR is ready.

@mikee47 mikee47 changed the title Add hw_timer driver and introduce Polled Timers [WIP] Add hw_timer driver and introduce Polled Timers Aug 25, 2019
@mikee47
Copy link
Contributor Author

mikee47 commented Sep 11, 2019

I'm splitting this PR as it's become quite complex.

@mikee47 mikee47 force-pushed the feature/PolledTimer branch from 9e1ffb6 to c4966dd Compare September 12, 2019 08:05
@mikee47 mikee47 changed the title [WIP] Add hw_timer driver and introduce Polled Timers Introduce Clock framework and Polled Timers Sep 12, 2019
@mikee47 mikee47 force-pushed the feature/PolledTimer branch from c4966dd to 04ea8fd Compare September 12, 2019 08:20
`NanoTime` provides time calculation support and base template classes for Clocks and Time Sources.
`Platform/Clocks.h` parameterises all clock sources

`PolledTimer.h` provides template class for implementing polled (elapse and timeout) timers

`Platform/Timers.h` defines available timer types

Add implementation of `esp_get_count()' to `esp_clk.h`, together with `ets_get_cpu_frequency` declaration.
@mikee47 mikee47 force-pushed the feature/PolledTimer branch from 04ea8fd to 3e92bcd Compare September 12, 2019 08:27
@mikee47
Copy link
Contributor Author

mikee47 commented Sep 12, 2019

@slaff Quite a lot of changes here and new concepts so feedback on the general approach very welcome.

@mikee47 mikee47 force-pushed the feature/PolledTimer branch from ef6c486 to b484d6d Compare September 12, 2019 16:30
@slaff
Copy link
Contributor

slaff commented Sep 13, 2019

@mikee47 Is this PR tested and ready?

@mikee47
Copy link
Contributor Author

mikee47 commented Sep 13, 2019

@slaff Yes indeed.

@slaff slaff removed the 3 - Review label Sep 13, 2019
@slaff slaff merged commit 1f77fe5 into SmingHub:develop Sep 13, 2019
@mikee47 mikee47 deleted the feature/PolledTimer branch September 13, 2019 14:52
@slaff slaff mentioned this pull request Sep 28, 2019
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants