YAHAL
Yet Another Hardware Abstraction Library
Loading...
Searching...
No Matches
timer_esp8266.h
1// ---------------------------------------------
2// This file is part of
3// _ _ __ _ _ __ __
4// ( \/ ) /__\ ( )_( ) /__\ ( )
5// \ / /(__)\ ) _ ( /(__)\ )(__
6// (__)(__)(__)(_) (_)(__)(__)(____)
7//
8// Yet Another HW Abstraction Library
9// Copyright (C) Andreas Terstegge
10// BSD Licensed (see file LICENSE)
11//
12// ---------------------------------------------
13//
14// Timer implementation for ESP8266.
15//
16#ifndef _TIMER_ESP8266_H_
17#define _TIMER_ESP8266_H_
18
19#include "timer_interface.h"
20
22public:
24 ~timer_esp8266() override;
25
26 void setPeriod(uint32_t us, TIMER::timer_mode mode) override;
27 uint32_t getPeriod() override;
28
29 void setCallback(function<void()> f) override;
30
31 void start() override;
32 void stop() override;
33 bool isRunning() override;
34
35 uint32_t getCounter();
36 void resetCounter();
37
38 friend void timer_irq_handler(timer_esp8266 *);
39
40private:
41 function<void()> _handler;
42 uint32_t _period_us; // load value in us
43 uint32_t _period_load;
44 uint32_t _divider;
45};
46
47void timer_irq_handler(timer_esp8266 *);
48
49#endif // _TIMER_ESP8266_H_