Browse Source

Fix ESP32 servos, platformio.ini, etc. (#14247)

pull/1/head
felixstorm 6 years ago
committed by Scott Lahteine
parent
commit
9439fab7fd
  1. 3
      Marlin/src/HAL/HAL_ESP32/HAL.cpp
  2. 6
      Marlin/src/HAL/HAL_ESP32/HAL_Servo_ESP32.cpp
  3. 3
      Marlin/src/HAL/HAL_ESP32/i2s.cpp
  4. 6
      Marlin/src/HAL/HAL_ESP32/i2s.h
  5. 16
      Marlin/src/pins/pins_ESP32.h
  6. 8
      platformio.ini

3
Marlin/src/HAL/HAL_ESP32/HAL.cpp

@ -193,6 +193,9 @@ void HAL_adc_start_conversion(uint8_t adc_pin) {
} }
void analogWrite(int pin, int value) { void analogWrite(int pin, int value) {
if (!PWM_PIN(pin)) return;
static int cnt_channel = 1, static int cnt_channel = 1,
pin_to_channel[40] = {}; pin_to_channel[40] = {};
if (pin_to_channel[pin] == 0) { if (pin_to_channel[pin] == 0) {

6
Marlin/src/HAL/HAL_ESP32/HAL_Servo_ESP32.cpp

@ -27,7 +27,9 @@
#include "HAL_Servo_ESP32.h" #include "HAL_Servo_ESP32.h"
int Servo::channel_next_free = 0; // Adjacent channels (0/1, 2/3 etc.) share the same timer and therefore the same frequency and resolution settings on ESP32,
// so we only allocate servo channels up high to avoid side effects with regards to analogWrite (fans, leds, laser pwm etc.)
int Servo::channel_next_free = 12;
Servo::Servo() { Servo::Servo() {
this->channel = channel_next_free++; this->channel = channel_next_free++;
@ -42,7 +44,7 @@ int8_t Servo::attach(const int pin) {
return true; return true;
} }
void Servo::detach() { ledcDetachPin(this->pin) } void Servo::detach() { ledcDetachPin(this->pin); }
int Servo::read() { return this->degrees; } int Servo::read() { return this->degrees; }

3
Marlin/src/HAL/HAL_ESP32/i2s.cpp

@ -21,10 +21,11 @@
*/ */
#ifdef ARDUINO_ARCH_ESP32 #ifdef ARDUINO_ARCH_ESP32
#include "../../inc/MarlinConfigPre.h"
#include "i2s.h" #include "i2s.h"
#include "../shared/Marduino.h" #include "../shared/Marduino.h"
#include "../../core/macros.h"
#include "driver/periph_ctrl.h" #include "driver/periph_ctrl.h"
#include "rom/lldesc.h" #include "rom/lldesc.h"
#include "soc/i2s_struct.h" #include "soc/i2s_struct.h"

6
Marlin/src/HAL/HAL_ESP32/i2s.h

@ -33,9 +33,3 @@ uint8_t i2s_state(uint8_t pin);
void i2s_write(uint8_t pin, uint8_t val); void i2s_write(uint8_t pin, uint8_t val);
void i2s_push_sample(); void i2s_push_sample();
// pin definitions
#define I2S_WS 25
#define I2S_BCK 26
#define I2S_DATA 27

16
Marlin/src/pins/pins_ESP32.h

@ -30,18 +30,24 @@
#define BOARD_NAME "Espressif ESP32" #define BOARD_NAME "Espressif ESP32"
//
// I2S (steppers & other output-only pins)
//
#define I2S_STEPPER_STREAM
#define I2S_WS 25
#define I2S_BCK 26
#define I2S_DATA 27
// //
// Limit Switches // Limit Switches
// //
#define X_MIN_PIN 34 #define X_MIN_PIN 34
#define Y_MIN_PIN 35 #define Y_MIN_PIN 35
#define Z_MIN_PIN 15 #define Z_MIN_PIN 15
// //
// Steppers // Steppers
// //
#define I2S_STEPPER_STREAM
#define X_STEP_PIN 128 #define X_STEP_PIN 128
#define X_DIR_PIN 129 #define X_DIR_PIN 129
#define X_ENABLE_PIN 130 #define X_ENABLE_PIN 130

8
platformio.ini

@ -403,10 +403,10 @@ lib_ignore =
# Espressif ESP32 # Espressif ESP32
# #
[env:esp32] [env:esp32]
platform = https://github.com/platformio/platform-espressif32.git ; #feature/stage platform = espressif32
board = esp32dev board = esp32dev
framework = arduino framework = arduino
upload_speed = 115200 upload_speed = 115200
monitor_speed = 115200 monitor_speed = 115200
upload_port = /dev/ttyUSB0 upload_port = /dev/ttyUSB0
lib_deps = lib_deps =

Loading…
Cancel
Save