ESP3D  3.0
Firmware for ESP boards connected to 3D Printer
hal.h
Go to the documentation of this file.
1 /*
2  hal.h - esp3d hal class
3 
4  Copyright (c) 2014 Luc Lebosse. All rights reserved.
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Lesser General Public
8  License as published by the Free Software Foundation; either
9  version 2.1 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public
17  License along with this library; if not, write to the Free Software
18  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20 
21 #ifndef _ESP3D_HAL_H
22 #define _ESP3D_HAL_H
23 //be sure correct IDE and settings are used for ESP8266 or ESP32
24 #if !(defined( ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32))
25 #error Oops! Make sure you have 'ESP8266 or ESP32' compatible board selected from the 'Tools -> Boards' menu.
26 #endif // ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32
27 #if defined(ARDUINO_ARCH_ESP8266)
28 #include "ESP8266WiFi.h"
29 #endif //ARDUINO_ARCH_ESP8266
30 #if defined(ARDUINO_ARCH_ESP32)
31 #include "WiFi.h"
32 #endif //ARDUINO_ARCH_ESP32
33 #include <Arduino.h>
34 
35 class Hal
36 {
37 public:
38  Hal();
39  ~Hal();
40  static bool begin();
41  static void end();
42  static void wait (uint32_t milliseconds);
43  static uint16_t getChipID();
44  static bool has_temperature_sensor();
45  static float temperature();
46  static bool is_pin_usable(uint pin);
47  static void clearAnalogChannels();
48  static void pinMode(uint8_t pin, uint8_t mode);
49  static int analogRead(uint8_t pin);
50  static bool analogWrite(uint8_t pin, uint value);
51  static void analogWriteFreq(uint32_t freq);
52  static void analogWriteRange(uint32_t range);
53  static void toneESP(uint8_t pin, unsigned int frequency, unsigned int duration, bool sync = true);
54  static void no_tone(uint8_t pin);
55 private:
56  static void wdtFeed();
57  static uint32_t _analogWriteRange;
58  static uint32_t _analogWriteFreq;
59 #if defined(ARDUINO_ARCH_ESP32)
60  static int getAnalogWriteChannel(uint8_t pin);
61 #endif //ARDUINO_ARCH_ESP32
62 };
63 #endif //_ESP3D_HAL_H
Hal::wait
static void wait(uint32_t milliseconds)
Definition: hal.cpp:226
Hal::Hal
Hal()
Definition: hal.cpp:47
Hal::end
static void end()
Definition: hal.cpp:207
Hal::analogWriteRange
static void analogWriteRange(uint32_t range)
Definition: hal.cpp:186
Hal::is_pin_usable
static bool is_pin_usable(uint pin)
Definition: hal.cpp:268
Hal::temperature
static float temperature()
Definition: hal.cpp:258
Hal::analogWriteFreq
static void analogWriteFreq(uint32_t freq)
Definition: hal.cpp:179
Hal::analogWrite
static bool analogWrite(uint8_t pin, uint value)
Definition: hal.cpp:141
Hal::getChipID
static uint16_t getChipID()
Definition: hal.cpp:238
Hal::begin
static bool begin()
Definition: hal.cpp:195
Hal::~Hal
~Hal()
Definition: hal.cpp:53
Hal
Definition: hal.h:35
Hal::clearAnalogChannels
static void clearAnalogChannels()
Definition: hal.cpp:57
Hal::analogRead
static int analogRead(uint8_t pin)
Definition: hal.cpp:112
Hal::has_temperature_sensor
static bool has_temperature_sensor()
Definition: hal.cpp:248
Hal::pinMode
static void pinMode(uint8_t pin, uint8_t mode)
Definition: hal.cpp:69
Hal::toneESP
static void toneESP(uint8_t pin, unsigned int frequency, unsigned int duration, bool sync=true)
Definition: hal.cpp:80
Hal::no_tone
static void no_tone(uint8_t pin)
Definition: hal.cpp:99