diff --git a/cores/esp8266/core_esp8266_sigma_delta.c.unused b/cores/esp8266/core_esp8266_sigma_delta.c.unused deleted file mode 100644 index 04230211e..000000000 --- a/cores/esp8266/core_esp8266_sigma_delta.c.unused +++ /dev/null @@ -1,192 +0,0 @@ -/* -/****************************************************************************** - * MODULEName : set_sigma MODULE - -EACH PIN CAN CONNET TO A SIGMA-DELTA , ALL PINS SHEARS THE SAME SIGMA-DELTA SOURCE. - -THE TARGET DUTY AND FREQUENCY CAN BE MODIFIED VIA THE REG ADDR GPIO_SIGMA_DELTA - -THE TARGET FREQUENCY IS DEFINED AS: - -FREQ = 80,000,000/prescale * target /256 HZ, 0> GPIO_SIGMA_DELTA_LSB) -#define GPIO_SIGMA_DELTA_SET(x) (((x) << GPIO_SIGMA_DELTA_LSB) & GPIO_SIGMA_DELTA_MASK) - - -#define GPIO_SIGMA_DELTA_TARGET_MSB 7 -#define GPIO_SIGMA_DELTA_TARGET_LSB 0 -#define GPIO_SIGMA_DELTA_TARGET_MASK (0x000000FF<> GPIO_SIGMA_DELTA_TARGET_LSB) -#define GPIO_SIGMA_DELTA_TARGET_SET(x) (((x) << GPIO_SIGMA_DELTA_TARGET_LSB) & GPIO_SIGMA_DELTA_TARGET_MASK) - - -#define GPIO_SIGMA_DELTA_PRESCALE_MSB 15 -#define GPIO_SIGMA_DELTA_PRESCALE_LSB 8 -#define GPIO_SIGMA_DELTA_PRESCALE_MASK (0x000000FF<> GPIO_SIGMA_DELTA_PRESCALE_LSB) -#define GPIO_SIGMA_DELTA_PRESCALE_SET(x) (((x) << GPIO_SIGMA_DELTA_PRESCALE_LSB) & GPIO_SIGMA_DELTA_PRESCALE_MASK) - - -/****************************************************************************** - * FunctionName : sigma_delta_setup - * Description : Init Pin Config for Sigma_delta , change pin source to sigma-delta - * Parameters : uint32 GPIO_MUX, GPIO MUX REG ,DEFINED IN EAGLE_SOC.H, e.g.: PERIPHS_IO_MUX_MTCK_U - uint32 GPIO_NUM, GPIO NUM ACCORDING TO THE MUX NUM , e.g.: 13 for MTCK - uint32 GPIO_FUNC, GPIO PIN FUNC , DEFINED IN EAGLE_SOC.H , e.g.: FUNC_GPIO13 - * Returns : none -*******************************************************************************/ -void ICACHE_FLASH_ATTR -sigma_delta_setup(uint32 GPIO_MUX,uint32 GPIO_NUM,uint32 GPIO_FUNC) -{ - //============================================================================ - //STEP 1: SIGMA-DELTA CONFIG;REG SETUP - GPIO_REG_WRITE(GPIO_SIGMA_DELTA, - (GPIO_REG_READ(GPIO_PIN_ADDR(GPIO_ID_PIN(GPIO_SIGMA_DELTA_NUM))) &(~GPIO_SIGMA_DELTA_SETTING_MASK))| - GPIO_SIGMA_DELTA_SET(GPIO_SIGMA_DELTA_ENABLE)| - GPIO_SIGMA_DELTA_TARGET_SET(0x00)| - GPIO_SIGMA_DELTA_PRESCALE_SET(0x00) ); - - //============================================================================ - - //STEP 2: PIN FUNC CONFIG :SET PIN TO GPIO MODE AND ENABLE OUTPUT - PIN_FUNC_SELECT(GPIO_MUX, GPIO_FUNC); - gpio_output_set(0,0,0x1<128)?(256-duty):duty; - prescale = (target==0)?0:(target-1); - - //freq = 80000 (khz) /256 /duty_target * (prescale+1) - set_sigma_target(duty);//SET DUTY TARGET - set_sigma_prescale(prescale);//SET CLK DIV - -} - diff --git a/cores/esp8266/core_esp8266_waveform.c b/cores/esp8266/core_esp8266_waveform.c index 360730bbd..d4d5f5a71 100644 --- a/cores/esp8266/core_esp8266_waveform.c +++ b/cores/esp8266/core_esp8266_waveform.c @@ -102,13 +102,6 @@ static inline ICACHE_RAM_ATTR uint32_t min_u32(uint32_t a, uint32_t b) { return b; } -static inline ICACHE_RAM_ATTR uint32_t min_s32(int32_t a, int32_t b) { - if (a < b) { - return a; - } - return b; -} - static inline ICACHE_RAM_ATTR void ReloadTimer(uint32_t a) { // Below a threshold you actually miss the edge IRQ, so ensure enough time if (a > 32) { @@ -251,7 +244,8 @@ static ICACHE_RAM_ATTR void timer1Interrupt() { // Check for toggles now = GetCycleCount(); - if (now >= wave->nextServiceCycle) { + int32_t cyclesToGo = wave->nextServiceCycle - now; + if (cyclesToGo < 0) { wave->state = !wave->state; if (wave->state) { SetGPIO(wave->gpioMask);