Skip to content

Commit

Permalink
Move timer ISR handlers and PWM handler into RAM (fix #819)
Browse files Browse the repository at this point in the history
  • Loading branch information
igrr committed Oct 6, 2015
1 parent 0873ae2 commit 0c703b3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
15 changes: 6 additions & 9 deletions cores/esp8266/core_esp8266_timer.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
/*
timer.c - Timer1 library for esp8266
Copyright (c) 2015 Hristo Gochkov. 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
Expand All @@ -29,13 +29,13 @@

static volatile timercallback timer1_user_cb = NULL;

void timer1_isr_handler(void *para){
void ICACHE_RAM_ATTR timer1_isr_handler(void *para){
if ((T1C & ((1 << TCAR) | (1 << TCIT))) == 0) TEIE &= ~TEIE1;//edge int disable
T1I = 0;
if (timer1_user_cb) {
// to make ISR compatible to Arduino AVR model where interrupts are disabled
// we disable them before we call the client ISR
uint32_t savedPS = xt_rsil(15); // stop other interrupts
uint32_t savedPS = xt_rsil(15); // stop other interrupts
timer1_user_cb();
xt_wsr_ps(savedPS);
}
Expand All @@ -61,7 +61,7 @@ void timer1_enable(uint8_t divider, uint8_t int_type, uint8_t reload){
T1I = 0;
}

void timer1_write(uint32_t ticks){
void ICACHE_RAM_ATTR timer1_write(uint32_t ticks){
T1L = ((ticks)& 0x7FFFFF);
if ((T1C & (1 << TCIT)) == 0) TEIE |= TEIE1;//edge int enable
}
Expand All @@ -76,7 +76,7 @@ void timer1_disable(){

static volatile timercallback timer0_user_cb = NULL;

void timer0_isr_handler(void* para){
void ICACHE_RAM_ATTR timer0_isr_handler(void* para){
if (timer0_user_cb) {
// to make ISR compatible to Arduino AVR model where interrupts are disabled
// we disable them before we call the client ISR
Expand All @@ -99,6 +99,3 @@ void timer0_detachInterrupt() {
timer0_user_cb = NULL;
ETS_CCOMPARE0_DISABLE();
}



6 changes: 3 additions & 3 deletions cores/esp8266/core_esp8266_wiring_pwm.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
/*
pwm.c - analogWrite implementation for esp8266
Copyright (c) 2015 Hristo Gochkov. 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
Expand Down Expand Up @@ -88,7 +88,7 @@ void prep_pwm_steps(){
ETS_FRC1_INTR_ENABLE();
}

void pwm_timer_isr(){
void ICACHE_RAM_ATTR pwm_timer_isr(){
static uint8_t current_step = 0;
static uint8_t stepcount = 0;
static uint16_t steps[17];
Expand Down

0 comments on commit 0c703b3

Please sign in to comment.