YAHAL
Yet Another Hardware Abstraction Library
Loading...
Searching...
No Matches
gpio_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// GPIO implementation for ESP8266.
15//
16#ifndef _GPIO_ESP8266_H_
17#define _GPIO_ESP8266_H_
18
19#include "gpio_interface.h"
20
22{
23public:
24 explicit gpio_esp8266(gpio_pin_t gpio = 0xffff);
25 ~gpio_esp8266() override = default;
26
27 // No copy, assignment is value passing
28 gpio_esp8266 (const gpio_esp8266&) = delete;
29 gpio_esp8266& operator= (const gpio_esp8266 & lhs) {
30 this->gpioWrite(lhs.operator bool());
31 return *this;
32 };
33
34 // Get and Set the GPIO number during runtime
35 void setGpio(gpio_pin_t gpio) override;
36 gpio_pin_t getGpio() const override;
37
38 // Generic GPIO methods
39 void gpioMode (gpio_mode_t mode) override;
40 bool gpioRead () const override;
41 void gpioWrite (bool value) override;
42 void gpioToggle() override;
43
44 // Interrupt handling
45 // Interrupt handling
46 void gpioAttachIrq (gpio_mode_t mode,
47 function<void()> handler) override;
48 void gpioDetachIrq () override;
49 void gpioEnableIrq () override;
50 void gpioDisableIrq() override;
51
52 // Special functions of ESP8266
53 void brightnessControl(bool);
54 void setBrightness(uint8_t);
55
56 using gpio_interface::operator =;
57 using gpio_interface::operator bool;
58
59 // IRQ handlers are our best friends
60 friend void gpio_irq_handler(gpio_esp8266 *);
61
62private:
63 gpio_pin_t _gpio;
64 uint32_t _mask;
65
66 function<void()> intHandler[16];
67 uint16_t intMode[16];
68 const static uint8_t GPIO_TO_IOMUX[];
69 void handleInterrupt();
70};
71
72void gpio_irq_handler(gpio_esp8266 *);
73
74#endif // _GPIO_ESP8266_H_