From d746752ba0b065439482ea45fcbe0814cada4d92 Mon Sep 17 00:00:00 2001 From: stefaandesmet2003 Date: Tue, 9 Jan 2018 00:07:48 +0100 Subject: [PATCH 01/14] working code for sigma delta generator provide a simple interface to attach/detach pins to the sigma-delta generator, and get/set the 2 parameters prescaler & target --- cores/esp8266/core_esp8266_sigma_delta.c | 154 +++++++++++++++++++++++ cores/esp8266/sigma_delta.h | 107 +++++++++++++++- 2 files changed, 256 insertions(+), 5 deletions(-) create mode 100644 cores/esp8266/core_esp8266_sigma_delta.c diff --git a/cores/esp8266/core_esp8266_sigma_delta.c b/cores/esp8266/core_esp8266_sigma_delta.c new file mode 100644 index 0000000000..eaa0dc483a --- /dev/null +++ b/cores/esp8266/core_esp8266_sigma_delta.c @@ -0,0 +1,154 @@ +/* +/****************************************************************************** + * Sigma delta module + +This module controls the esp8266 internal sigma delta source +Each pin can be connected to the sigma delta source +The target duty and frequency can be modified via the register GPIO_SIGMA_DELTA + +THE TARGET FREQUENCY IS DEFINED AS: + +FREQ = 80,000,000/prescaler * target /256 HZ, 0> GPSDT) & 0xFF); +} + +/****************************************************************************** + * FunctionName : sigma_delta_setTarget + * Description : set the target (duty cycle) for the sigma-delta source + * Parameters : uint8 target, 0-255, duty cycle = target/256 + * Returns : none +*******************************************************************************/ +void ICACHE_FLASH_ATTR sigma_delta_setTarget(uint8_t target) +{ + uint32_t reg = GPSD; + + reg = (reg & ~(0xFF << GPSDT)) | ((target & 0xFF) << GPSDT); + GPSD = reg; +} + +/****************************************************************************** + * FunctionName : sigma_delta_getPrescaler + * Description : get the prescaler value from the GPIO_SIGMA_DELTA register + * Parameters : none + * Returns : uint8 prescaler, CLK_DIV , 0-255 +*******************************************************************************/ +uint8_t ICACHE_FLASH_ATTR sigma_delta_getPrescaler(uint8_t prescaler) +{ + return (uint8_t)((GPSD >> GPSDP) & 0xFF); +} + +/****************************************************************************** + * FunctionName : sigma_delta_setPrescaler + * Description : set the clock divider for the sigma-delta source + * Parameters : uint8 prescaler, 0-255, divides the 80MHz base clock by this amount + * Returns : none +*******************************************************************************/ +void ICACHE_FLASH_ATTR sigma_delta_setPrescaler(uint8_t prescaler) +{ + uint32_t reg = GPSD; + + reg = (reg & ~(0xFF << GPSDP)) | ((prescaler & 0xFF) << GPSDP); + GPSD = reg; +} diff --git a/cores/esp8266/sigma_delta.h b/cores/esp8266/sigma_delta.h index 2e8bdc092f..3af2ac8080 100644 --- a/cores/esp8266/sigma_delta.h +++ b/cores/esp8266/sigma_delta.h @@ -18,15 +18,112 @@ License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + + /* +/****************************************************************************** + * Info Sigma delta module + +This module controls the esp8266 internal sigma delta source +Each pin can be connected to the sigma delta source +The target duty and frequency can be modified via the register GPIO_SIGMA_DELTA + +THE TARGET FREQUENCY IS DEFINED AS: + +FREQ = 80,000,000/prescaler * target /256 HZ, 00;target=target-5) + { + sigma_delta_setTarget(target); + delay(10); + } + + } + Serial.println("detaching builtin led & playing a blinkie\n"); + sigma_delta_detachPin(BUILTIN_LED); + for (iRepeat=0;iRepeat<20;iRepeat++) + { + digitalWrite(BUILTIN_LED,!digitalRead(BUILTIN_LED)); + delay(500); + } + +} + +*******************************************************************************/ #ifndef SIGMA_DELTA_H #define SIGMA_DELTA_H -#include +#ifdef __cplusplus +extern "C" { +#endif + +void sigma_delta_enable(void); +void sigma_delta_disable(void); +void sigma_delta_attachPin(uint8_t pin); +void sigma_delta_detachPin(uint8_t pin); +bool sigma_delta_isPinAttached(uint8_t pin); +uint8_t sigma_delta_getTarget(void); +void sigma_delta_setTarget(uint8_t target); +uint8_t sigma_delta_getPrescaler(void); +void sigma_delta_setPrescaler(uint8_t prescaler); -void sigma_delta_close(uint32_t gpio); -void set_sigma_target(uint8_t target); -void set_sigma_prescale(uint8_t prescale); -void set_sigma_duty_312KHz(uint8_t duty); +#ifdef __cplusplus +} +#endif #endif//SIGMA_DELTA_H From 85b932343abf42b0bb1c582cccd034f631b57446 Mon Sep 17 00:00:00 2001 From: stefaandesmet2003 Date: Thu, 11 Jan 2018 00:08:54 +0100 Subject: [PATCH 02/14] removed example code from header file --- sigma_delta.h | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 sigma_delta.h diff --git a/sigma_delta.h b/sigma_delta.h new file mode 100644 index 0000000000..6ed66191d5 --- /dev/null +++ b/sigma_delta.h @@ -0,0 +1,72 @@ +/* + sigma_delta.h - esp8266 sigma-delta source + + Copyright (c) 2014 Ivan Grokhotkov. All rights reserved. + This file is part of the esp8266 core for Arduino environment. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + /* +/****************************************************************************** + * Info Sigma delta module + +This module controls the esp8266 internal sigma delta source +Each pin can be connected to the sigma delta source +The target duty and frequency can be modified via the register GPIO_SIGMA_DELTA + +THE TARGET FREQUENCY IS DEFINED AS: + +FREQ = 80,000,000/prescaler * target /256 HZ, 0 Date: Thu, 11 Jan 2018 00:14:17 +0100 Subject: [PATCH 03/14] example for the esp8266 sigma delta generator hardware --- .../SigmaDeltaDemo/SigmaDeltaDemo.ino | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 libraries/esp8266/examples/SigmaDeltaDemo/SigmaDeltaDemo.ino diff --git a/libraries/esp8266/examples/SigmaDeltaDemo/SigmaDeltaDemo.ino b/libraries/esp8266/examples/SigmaDeltaDemo/SigmaDeltaDemo.ino new file mode 100644 index 0000000000..bc1390807f --- /dev/null +++ b/libraries/esp8266/examples/SigmaDeltaDemo/SigmaDeltaDemo.ino @@ -0,0 +1,84 @@ +/* + Sigma Delta Generator example + + This example demonstrates the use of the ESP8266 internal hardware sigma delta source. + Each GPIO pin or multiple pins can be connected to the one sigma delta source. + THE sigma delta output frequency is defined by the ESP8266 hardware as: + + FREQ = 80,000,000/prescaler * target /256 HZ, 00;target=target-5) + { + sigma_delta_setTarget(target); + delay(10); + } + + } + Serial.println("detaching builtin led & playing a blinkie\n"); + sigma_delta_detachPin(BUILTIN_LED); + for (iRepeat=0;iRepeat<20;iRepeat++) + { + digitalWrite(BUILTIN_LED,!digitalRead(BUILTIN_LED)); + delay(500); + } + +} From c5351a0877519a16bcd1d7d62d9a3be0b37ae38c Mon Sep 17 00:00:00 2001 From: stefaandesmet2003 Date: Tue, 23 Jan 2018 21:51:40 +0100 Subject: [PATCH 04/14] modified interface in line with ESP32 implementation --- cores/esp8266/core_esp8266_sigma_delta.c | 114 +++++++++++------------ cores/esp8266/sigma_delta.h | 96 ++++--------------- 2 files changed, 76 insertions(+), 134 deletions(-) diff --git a/cores/esp8266/core_esp8266_sigma_delta.c b/cores/esp8266/core_esp8266_sigma_delta.c index eaa0dc483a..37d1fca33d 100644 --- a/cores/esp8266/core_esp8266_sigma_delta.c +++ b/cores/esp8266/core_esp8266_sigma_delta.c @@ -1,32 +1,3 @@ -/* -/****************************************************************************** - * Sigma delta module - -This module controls the esp8266 internal sigma delta source -Each pin can be connected to the sigma delta source -The target duty and frequency can be modified via the register GPIO_SIGMA_DELTA - -THE TARGET FREQUENCY IS DEFINED AS: - -FREQ = 80,000,000/prescaler * target /256 HZ, 0> GPSDT) & 0xFF); + (void) channel; + + uint32_t prescaler = ((uint32_t)10000000/(freq*32)) - 1; + + if(prescaler > 0xFF) { + prescaler = 0xFF; + } + sigmaDeltaEnable(); + sigmaDeltaSetPrescaler ((uint8_t) prescaler); + //sigmaDeltaSetTarget ((uint8_t) 0x80); // 50% duty cycle + + return 10000000/((prescaler + 1) * 32); } /****************************************************************************** - * FunctionName : sigma_delta_setTarget - * Description : set the target (duty cycle) for the sigma-delta source - * Parameters : uint8 target, 0-255, duty cycle = target/256 + * FunctionName : sigmaDeltaWrite + * Description : set the duty cycle for the sigma-delta source + * Parameters : uint8 duty, 0-255, duty cycle = target/256, + * channel = unused, for compatibility with ESP32 * Returns : none *******************************************************************************/ -void ICACHE_FLASH_ATTR sigma_delta_setTarget(uint8_t target) +void ICACHE_FLASH_ATTR sigmaDeltaWrite(uint8_t channel, uint8_t duty) { uint32_t reg = GPSD; + (void) channel; - reg = (reg & ~(0xFF << GPSDT)) | ((target & 0xFF) << GPSDT); + reg = (reg & ~(0xFF << GPSDT)) | ((duty & 0xFF) << GPSDT); GPSD = reg; + } - /****************************************************************************** - * FunctionName : sigma_delta_getPrescaler - * Description : get the prescaler value from the GPIO_SIGMA_DELTA register - * Parameters : none - * Returns : uint8 prescaler, CLK_DIV , 0-255 + * FunctionName : sigmaDeltaRead + * Description : set the duty cycle for the sigma-delta source + * Parameters : none, channel = unused, for compatibility with ESP32 + * Returns : uint8_t duty cycle value 0..255 *******************************************************************************/ -uint8_t ICACHE_FLASH_ATTR sigma_delta_getPrescaler(uint8_t prescaler) +uint8_t ICACHE_FLASH_ATTR sigmaDeltaRead(uint8_t channel) { - return (uint8_t)((GPSD >> GPSDP) & 0xFF); + (void) channel; + return (uint8_t)((GPSD >> GPSDT) & 0xFF); } /****************************************************************************** - * FunctionName : sigma_delta_setPrescaler + * FunctionName : sigmaDeltaSetPrescaler * Description : set the clock divider for the sigma-delta source * Parameters : uint8 prescaler, 0-255, divides the 80MHz base clock by this amount * Returns : none *******************************************************************************/ -void ICACHE_FLASH_ATTR sigma_delta_setPrescaler(uint8_t prescaler) +void ICACHE_FLASH_ATTR sigmaDeltaSetPrescaler(uint8_t prescaler) { uint32_t reg = GPSD; reg = (reg & ~(0xFF << GPSDP)) | ((prescaler & 0xFF) << GPSDP); GPSD = reg; } + +/****************************************************************************** + * FunctionName : sigmaDeltaGetPrescaler + * Description : get the prescaler value from the GPIO_SIGMA_DELTA register + * Parameters : none + * Returns : uint8 prescaler, CLK_DIV , 0-255 +*******************************************************************************/ +uint8_t ICACHE_FLASH_ATTR sigmaDeltaGetPrescaler(uint8_t prescaler) +{ + return (uint8_t)((GPSD >> GPSDP) & 0xFF); +} diff --git a/cores/esp8266/sigma_delta.h b/cores/esp8266/sigma_delta.h index 3af2ac8080..ee7a06927b 100644 --- a/cores/esp8266/sigma_delta.h +++ b/cores/esp8266/sigma_delta.h @@ -31,77 +31,16 @@ THE TARGET FREQUENCY IS DEFINED AS: FREQ = 80,000,000/prescaler * target /256 HZ, 00;target=target-5) - { - sigma_delta_setTarget(target); - delay(10); - } - - } - Serial.println("detaching builtin led & playing a blinkie\n"); - sigma_delta_detachPin(BUILTIN_LED); - for (iRepeat=0;iRepeat<20;iRepeat++) - { - digitalWrite(BUILTIN_LED,!digitalRead(BUILTIN_LED)); - delay(500); - } - -} +3. sigmaDeltaWrite(0,dc) : set the output signal duty cycle, duty cycle = dc/256 *******************************************************************************/ @@ -112,15 +51,20 @@ void loop() { extern "C" { #endif -void sigma_delta_enable(void); -void sigma_delta_disable(void); -void sigma_delta_attachPin(uint8_t pin); -void sigma_delta_detachPin(uint8_t pin); -bool sigma_delta_isPinAttached(uint8_t pin); -uint8_t sigma_delta_getTarget(void); -void sigma_delta_setTarget(uint8_t target); -uint8_t sigma_delta_getPrescaler(void); -void sigma_delta_setPrescaler(uint8_t prescaler); +//channel parameter is unused (only for ESP32 compatibility) freq 1220-312500 duty 0-255 +void sigmaDeltaEnable(void); +void sigmaDeltaDisable(void); +uint32_t sigmaDeltaSetup(uint8_t channel, uint32_t freq); +void sigmaDeltaWrite(uint8_t channel, uint8_t duty); +uint8_t sigmaDeltaRead(uint8_t channel = 0); +void sigmaDeltaAttachPin(uint8_t pin, uint8_t channel = 0); +void sigmaDeltaDetachPin(uint8_t pin); +bool sigmaDeltaIsPinAttached(uint8_t pin); + +// alternative way to control the sigma delta generator frequency +uint8_t sigmaDeltaGetPrescaler(void); +void sigmaDeltaSetPrescaler(uint8_t prescaler); + #ifdef __cplusplus } From a1f88866371bb4134fd89e7c28f7846afda24bf5 Mon Sep 17 00:00:00 2001 From: stefaandesmet2003 Date: Tue, 23 Jan 2018 21:52:39 +0100 Subject: [PATCH 05/14] modified interface in line with ESP32 implementation --- .../SigmaDeltaDemo/SigmaDeltaDemo.ino | 62 +++++-------------- 1 file changed, 15 insertions(+), 47 deletions(-) diff --git a/libraries/esp8266/examples/SigmaDeltaDemo/SigmaDeltaDemo.ino b/libraries/esp8266/examples/SigmaDeltaDemo/SigmaDeltaDemo.ino index bc1390807f..3df61310c5 100644 --- a/libraries/esp8266/examples/SigmaDeltaDemo/SigmaDeltaDemo.ino +++ b/libraries/esp8266/examples/SigmaDeltaDemo/SigmaDeltaDemo.ino @@ -1,84 +1,52 @@ -/* - Sigma Delta Generator example - - This example demonstrates the use of the ESP8266 internal hardware sigma delta source. - Each GPIO pin or multiple pins can be connected to the one sigma delta source. - THE sigma delta output frequency is defined by the ESP8266 hardware as: +/* Any copyright is dedicated to the Public Domain. */ - FREQ = 80,000,000/prescaler * target /256 HZ, 00;target=target-5) + for (duty=255; duty>0;duty=duty-5) { - sigma_delta_setTarget(target); + sigmaDeltaWrite(0,duty); delay(10); } } Serial.println("detaching builtin led & playing a blinkie\n"); - sigma_delta_detachPin(BUILTIN_LED); + sigmaDeltaDetachPin(BUILTIN_LED); for (iRepeat=0;iRepeat<20;iRepeat++) { digitalWrite(BUILTIN_LED,!digitalRead(BUILTIN_LED)); delay(500); } -} +} From 385b7a2c5d16fbce8268e58f8a612b33e57f0d73 Mon Sep 17 00:00:00 2001 From: stefaandesmet2003 Date: Fri, 9 Mar 2018 19:35:00 +0100 Subject: [PATCH 06/14] changes requested by earlphilhower cleanup --- cores/esp8266/core_esp8266_sigma_delta.c | 30 ++++++++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/cores/esp8266/core_esp8266_sigma_delta.c b/cores/esp8266/core_esp8266_sigma_delta.c index 37d1fca33d..183b94e034 100644 --- a/cores/esp8266/core_esp8266_sigma_delta.c +++ b/cores/esp8266/core_esp8266_sigma_delta.c @@ -1,3 +1,24 @@ +/* + core_esp8266_sigma_delta.c - sigma delta library for esp8266 + + Copyright (c) 2014 Ivan Grokhotkov. All rights reserved. + This file is part of the esp8266 core for Arduino environment. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "Arduino.h" // using pinMode // definitions in esp8266_peri.h style @@ -29,7 +50,7 @@ void ICACHE_FLASH_ATTR sigmaDeltaDisable() } /****************************************************************************** - * FunctionName : sigma_delta_attachPin + * FunctionName : sigmaDeltaAttachPin * Description : connects the sigma delta source to a physical output pin * Parameters : pin (0..15), channel = unused, for compatibility with ESP32 * Returns : none @@ -46,7 +67,7 @@ void ICACHE_FLASH_ATTR sigmaDeltaAttachPin(uint8_t pin, uint8_t channel) } /****************************************************************************** - * FunctionName : sigma_delta_detachPin + * FunctionName : sigmaDeltaDetachPin * Description : disconnects the sigma delta source from a physical output pin * Parameters : pin (0..16) * Returns : none @@ -93,7 +114,6 @@ uint32_t ICACHE_FLASH_ATTR sigmaDeltaSetup(uint8_t channel, uint32_t freq) } sigmaDeltaEnable(); sigmaDeltaSetPrescaler ((uint8_t) prescaler); - //sigmaDeltaSetTarget ((uint8_t) 0x80); // 50% duty cycle return 10000000/((prescaler + 1) * 32); } @@ -116,8 +136,8 @@ void ICACHE_FLASH_ATTR sigmaDeltaWrite(uint8_t channel, uint8_t duty) } /****************************************************************************** * FunctionName : sigmaDeltaRead - * Description : set the duty cycle for the sigma-delta source - * Parameters : none, channel = unused, for compatibility with ESP32 + * Description : get the duty cycle for the sigma-delta source + * Parameters : channel = unused, for compatibility with ESP32 * Returns : uint8_t duty cycle value 0..255 *******************************************************************************/ uint8_t ICACHE_FLASH_ATTR sigmaDeltaRead(uint8_t channel) From a60f9494878b0ed5a6fb533ee09d78b085149020 Mon Sep 17 00:00:00 2001 From: stefaandesmet2003 Date: Fri, 9 Mar 2018 19:47:27 +0100 Subject: [PATCH 07/14] update for travis style_check --- .../SigmaDeltaDemo/SigmaDeltaDemo.ino | 98 +++++++++---------- 1 file changed, 47 insertions(+), 51 deletions(-) diff --git a/libraries/esp8266/examples/SigmaDeltaDemo/SigmaDeltaDemo.ino b/libraries/esp8266/examples/SigmaDeltaDemo/SigmaDeltaDemo.ino index 3df61310c5..45f312404b 100644 --- a/libraries/esp8266/examples/SigmaDeltaDemo/SigmaDeltaDemo.ino +++ b/libraries/esp8266/examples/SigmaDeltaDemo/SigmaDeltaDemo.ino @@ -1,52 +1,48 @@ -/* Any copyright is dedicated to the Public Domain. */ - -#include "sigma_delta.h" - -void setup() { - - Serial.begin(115200); - pinMode(BUILTIN_LED,OUTPUT); // blinkie & sigma-delta mix - uint32_t reqFreq = 1000; - uint32_t realFreq; - - realFreq = sigmaDeltaSetup(0,reqFreq); // chose a low frequency - - Serial.println(); - Serial.println("Start Sigma Delta Example\n"); - Serial.printf("Frequency = %u\n",realFreq); - -} - -void loop() { - - uint8_t duty, iRepeat; - - Serial.println("Attaching the built in led to the sigma delta source now\n"); - Serial.printf("Current duty = %i, prescaler = %i\n",sigmaDeltaRead(),sigmaDeltaGetPrescaler()); - sigmaDeltaAttachPin(BUILTIN_LED); - - Serial.println("dimming builtin led...\n"); - for (iRepeat=0;iRepeat<10;iRepeat++) - { - for (duty=0; duty<255;duty=duty+5) - { - sigmaDeltaWrite(0,duty); - delay(10); - } - - for (duty=255; duty>0;duty=duty-5) - { - sigmaDeltaWrite(0,duty); - delay(10); - } - - } - Serial.println("detaching builtin led & playing a blinkie\n"); - sigmaDeltaDetachPin(BUILTIN_LED); - for (iRepeat=0;iRepeat<20;iRepeat++) - { - digitalWrite(BUILTIN_LED,!digitalRead(BUILTIN_LED)); - delay(500); - } - +/* Any copyright is dedicated to the Public Domain. */ + +#include "sigma_delta.h" + +void setup() { + + Serial.begin(115200); + pinMode(BUILTIN_LED, OUTPUT); // blinkie & sigma-delta mix + uint32_t reqFreq = 1000; + uint32_t realFreq; + + realFreq = sigmaDeltaSetup(0, reqFreq); // chose a low frequency + + Serial.println(); + Serial.println("Start Sigma Delta Example\n"); + Serial.printf("Frequency = %u\n", realFreq); + +} + +void loop() { + + uint8_t duty, iRepeat; + + Serial.println("Attaching the built in led to the sigma delta source now\n"); + Serial.printf("Current duty = %i, prescaler = %i\n", sigmaDeltaRead(), sigmaDeltaGetPrescaler()); + sigmaDeltaAttachPin(BUILTIN_LED); + + Serial.println("dimming builtin led...\n"); + for (iRepeat = 0; iRepeat < 10; iRepeat++) { + for (duty=0; duty < 255; duty = duty + 5) { + sigmaDeltaWrite(0, duty); + delay(10); + } + + for (duty= 255; duty > 0; duty = duty - 5) { + sigmaDeltaWrite(0, duty); + delay(10); + } + + } + Serial.println("detaching builtin led & playing a blinkie\n"); + sigmaDeltaDetachPin(BUILTIN_LED); + for (iRepeat = 0; iRepeat < 20; iRepeat++) { + digitalWrite(BUILTIN_LED, !digitalRead(BUILTIN_LED)); + delay(500); + } + } From 717bdc3652ed3c1ccb7695f9b5f7dec13fc1d145 Mon Sep 17 00:00:00 2001 From: stefaandesmet2003 Date: Fri, 9 Mar 2018 20:00:40 +0100 Subject: [PATCH 08/14] remove unused parameter in sigmaDeltaGetPrescaler() --- cores/esp8266/core_esp8266_sigma_delta.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/esp8266/core_esp8266_sigma_delta.c b/cores/esp8266/core_esp8266_sigma_delta.c index 183b94e034..1e16d041e4 100644 --- a/cores/esp8266/core_esp8266_sigma_delta.c +++ b/cores/esp8266/core_esp8266_sigma_delta.c @@ -166,7 +166,7 @@ void ICACHE_FLASH_ATTR sigmaDeltaSetPrescaler(uint8_t prescaler) * Parameters : none * Returns : uint8 prescaler, CLK_DIV , 0-255 *******************************************************************************/ -uint8_t ICACHE_FLASH_ATTR sigmaDeltaGetPrescaler(uint8_t prescaler) +uint8_t ICACHE_FLASH_ATTR sigmaDeltaGetPrescaler(void) { return (uint8_t)((GPSD >> GPSDP) & 0xFF); } From 4c7ad74773b22d39ecba1181cff6683761dbbcef Mon Sep 17 00:00:00 2001 From: stefaandesmet2003 Date: Fri, 9 Mar 2018 20:26:43 +0100 Subject: [PATCH 09/14] travis doesn't like compiler warnings --- cores/esp8266/core_esp8266_sigma_delta.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cores/esp8266/core_esp8266_sigma_delta.c b/cores/esp8266/core_esp8266_sigma_delta.c index 1e16d041e4..d101401c2e 100644 --- a/cores/esp8266/core_esp8266_sigma_delta.c +++ b/cores/esp8266/core_esp8266_sigma_delta.c @@ -27,6 +27,8 @@ #define GPSDP 8 // prescaler, 8 bits #define GPSDE 16 // enable +void sigmaDeltaSetPrescaler(uint8_t prescaler); // avoids compiler warning + /****************************************************************************** * FunctionName : sigmaDeltaEnable * Description : enable the internal sigma delta source From 0a1189e2fc51882146fc1a987477057ebbf9a151 Mon Sep 17 00:00:00 2001 From: stefaandesmet2003 Date: Fri, 9 Mar 2018 21:29:27 +0100 Subject: [PATCH 10/14] correct comment for travis --- cores/esp8266/sigma_delta.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cores/esp8266/sigma_delta.h b/cores/esp8266/sigma_delta.h index ee7a06927b..6792f931cb 100644 --- a/cores/esp8266/sigma_delta.h +++ b/cores/esp8266/sigma_delta.h @@ -19,8 +19,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - /* -/****************************************************************************** + /******************************************************************************* * Info Sigma delta module This module controls the esp8266 internal sigma delta source From 83aeecdcf57cc2e7a50e615159ad15dd84c5c76a Mon Sep 17 00:00:00 2001 From: stefaandesmet2003 Date: Fri, 9 Mar 2018 21:30:58 +0100 Subject: [PATCH 11/14] changed BUILTIN_LED to LED_BUILTIN travis complains about BUILTIN_LED being deprecated --- .../esp8266/examples/SigmaDeltaDemo/SigmaDeltaDemo.ino | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libraries/esp8266/examples/SigmaDeltaDemo/SigmaDeltaDemo.ino b/libraries/esp8266/examples/SigmaDeltaDemo/SigmaDeltaDemo.ino index 45f312404b..b255d8ca83 100644 --- a/libraries/esp8266/examples/SigmaDeltaDemo/SigmaDeltaDemo.ino +++ b/libraries/esp8266/examples/SigmaDeltaDemo/SigmaDeltaDemo.ino @@ -5,7 +5,7 @@ void setup() { Serial.begin(115200); - pinMode(BUILTIN_LED, OUTPUT); // blinkie & sigma-delta mix + pinMode(LED_BUILTIN, OUTPUT); // blinkie & sigma-delta mix uint32_t reqFreq = 1000; uint32_t realFreq; @@ -23,7 +23,7 @@ void loop() { Serial.println("Attaching the built in led to the sigma delta source now\n"); Serial.printf("Current duty = %i, prescaler = %i\n", sigmaDeltaRead(), sigmaDeltaGetPrescaler()); - sigmaDeltaAttachPin(BUILTIN_LED); + sigmaDeltaAttachPin(LED_BUILTIN); Serial.println("dimming builtin led...\n"); for (iRepeat = 0; iRepeat < 10; iRepeat++) { @@ -39,10 +39,12 @@ void loop() { } Serial.println("detaching builtin led & playing a blinkie\n"); - sigmaDeltaDetachPin(BUILTIN_LED); + sigmaDeltaDetachPin(LED_BUILTIN); for (iRepeat = 0; iRepeat < 20; iRepeat++) { - digitalWrite(BUILTIN_LED, !digitalRead(BUILTIN_LED)); + digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); delay(500); } + + uint8_t prescaler = sigmaDeltaGetPrescaler(); } From 4ebb183481a434233a7038ab94be6b05f1184dd2 Mon Sep 17 00:00:00 2001 From: stefaandesmet2003 Date: Fri, 9 Mar 2018 22:07:12 +0100 Subject: [PATCH 12/14] remove unused test code --- libraries/esp8266/examples/SigmaDeltaDemo/SigmaDeltaDemo.ino | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libraries/esp8266/examples/SigmaDeltaDemo/SigmaDeltaDemo.ino b/libraries/esp8266/examples/SigmaDeltaDemo/SigmaDeltaDemo.ino index b255d8ca83..6fe2678164 100644 --- a/libraries/esp8266/examples/SigmaDeltaDemo/SigmaDeltaDemo.ino +++ b/libraries/esp8266/examples/SigmaDeltaDemo/SigmaDeltaDemo.ino @@ -43,8 +43,5 @@ void loop() { for (iRepeat = 0; iRepeat < 20; iRepeat++) { digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); delay(500); - } - - uint8_t prescaler = sigmaDeltaGetPrescaler(); - + } } From ab7204c77916541786812d337678a1499daf814d Mon Sep 17 00:00:00 2001 From: Stefaan De Smet Date: Sat, 10 Mar 2018 10:13:49 +0100 Subject: [PATCH 13/14] for travis style_check --- .../SigmaDeltaDemo/SigmaDeltaDemo.ino | 94 +++++++++---------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/libraries/esp8266/examples/SigmaDeltaDemo/SigmaDeltaDemo.ino b/libraries/esp8266/examples/SigmaDeltaDemo/SigmaDeltaDemo.ino index 6fe2678164..acb4410f61 100644 --- a/libraries/esp8266/examples/SigmaDeltaDemo/SigmaDeltaDemo.ino +++ b/libraries/esp8266/examples/SigmaDeltaDemo/SigmaDeltaDemo.ino @@ -1,47 +1,47 @@ -/* Any copyright is dedicated to the Public Domain. */ - -#include "sigma_delta.h" - -void setup() { - - Serial.begin(115200); - pinMode(LED_BUILTIN, OUTPUT); // blinkie & sigma-delta mix - uint32_t reqFreq = 1000; - uint32_t realFreq; - - realFreq = sigmaDeltaSetup(0, reqFreq); // chose a low frequency - - Serial.println(); - Serial.println("Start Sigma Delta Example\n"); - Serial.printf("Frequency = %u\n", realFreq); - -} - -void loop() { - - uint8_t duty, iRepeat; - - Serial.println("Attaching the built in led to the sigma delta source now\n"); - Serial.printf("Current duty = %i, prescaler = %i\n", sigmaDeltaRead(), sigmaDeltaGetPrescaler()); - sigmaDeltaAttachPin(LED_BUILTIN); - - Serial.println("dimming builtin led...\n"); - for (iRepeat = 0; iRepeat < 10; iRepeat++) { - for (duty=0; duty < 255; duty = duty + 5) { - sigmaDeltaWrite(0, duty); - delay(10); - } - - for (duty= 255; duty > 0; duty = duty - 5) { - sigmaDeltaWrite(0, duty); - delay(10); - } - - } - Serial.println("detaching builtin led & playing a blinkie\n"); - sigmaDeltaDetachPin(LED_BUILTIN); - for (iRepeat = 0; iRepeat < 20; iRepeat++) { - digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); - delay(500); - } -} +/* Any copyright is dedicated to the Public Domain. */ + +#include "sigma_delta.h" + +void setup() { + + Serial.begin(115200); + pinMode(LED_BUILTIN, OUTPUT); // blinkie & sigma-delta mix + uint32_t reqFreq = 1000; + uint32_t realFreq; + + realFreq = sigmaDeltaSetup(0, reqFreq); // chose a low frequency + + Serial.println(); + Serial.println("Start Sigma Delta Example\n"); + Serial.printf("Frequency = %u\n", realFreq); + +} + +void loop() { + + uint8_t duty, iRepeat; + + Serial.println("Attaching the built in led to the sigma delta source now\n"); + Serial.printf("Current duty = %i, prescaler = %i\n", sigmaDeltaRead(), sigmaDeltaGetPrescaler()); + sigmaDeltaAttachPin(LED_BUILTIN); + + Serial.println("dimming builtin led...\n"); + for (iRepeat = 0; iRepeat < 10; iRepeat++) { + for (duty=0; duty < 255; duty = duty + 5) { + sigmaDeltaWrite(0, duty); + delay(10); + } + + for (duty= 255; duty > 0; duty = duty - 5) { + sigmaDeltaWrite(0, duty); + delay(10); + } + + } + Serial.println("detaching builtin led & playing a blinkie\n"); + sigmaDeltaDetachPin(LED_BUILTIN); + for (iRepeat = 0; iRepeat < 20; iRepeat++) { + digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); + delay(500); + } +} From d67fa534ffe21881b3249c2b704be521b31a5de3 Mon Sep 17 00:00:00 2001 From: Stefaan De Smet Date: Sat, 10 Mar 2018 10:31:41 +0100 Subject: [PATCH 14/14] another attempt for travis style_check --- libraries/esp8266/examples/SigmaDeltaDemo/SigmaDeltaDemo.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/esp8266/examples/SigmaDeltaDemo/SigmaDeltaDemo.ino b/libraries/esp8266/examples/SigmaDeltaDemo/SigmaDeltaDemo.ino index acb4410f61..e5286ccb05 100644 --- a/libraries/esp8266/examples/SigmaDeltaDemo/SigmaDeltaDemo.ino +++ b/libraries/esp8266/examples/SigmaDeltaDemo/SigmaDeltaDemo.ino @@ -27,12 +27,12 @@ void loop() { Serial.println("dimming builtin led...\n"); for (iRepeat = 0; iRepeat < 10; iRepeat++) { - for (duty=0; duty < 255; duty = duty + 5) { + for (duty = 0; duty < 255; duty = duty + 5) { sigmaDeltaWrite(0, duty); delay(10); } - for (duty= 255; duty > 0; duty = duty - 5) { + for (duty = 255; duty > 0; duty = duty - 5) { sigmaDeltaWrite(0, duty); delay(10); }