Browse Source

esp8266: Provide a dedicated variable to disable ets_loop_iter.

So ets_loop_iter is now only disabled when using machine.disable_irq.
pull/2147/head
Damien George 9 years ago
parent
commit
927388e80e
  1. 6
      esp8266/ets_alt_task.c
  2. 1
      esp8266/ets_alt_task.h
  3. 14
      esp8266/modmachine.c

6
esp8266/ets_alt_task.c

@ -1,11 +1,11 @@
#include <stdio.h>
#include "xtirq.h"
#include "osapi.h"
#include "os_type.h"
#include "ets_sys.h"
#include <esp_sdk_ver.h>
#include "etshal.h"
#include "user_interface.h"
#include "ets_alt_task.h"
// Use standard ets_task or alternative impl
#define USE_ETS_TASK 0
@ -108,8 +108,10 @@ bool ets_post(uint8 prio, os_signal_t sig, os_param_t param) {
#endif
}
int ets_loop_iter_disable = 0;
bool ets_loop_iter(void) {
if (query_irq() != 0) {
if (ets_loop_iter_disable) {
return false;
}
//static unsigned cnt;

1
esp8266/ets_alt_task.h

@ -1 +1,2 @@
extern int ets_loop_iter_disable;
bool ets_loop_iter(void);

14
esp8266/modmachine.c

@ -191,13 +191,21 @@ const mp_obj_type_t esp_timer_type = {
.locals_dict = (mp_obj_t)&esp_timer_locals_dict,
};
// this bit is unused in the Xtensa PS register
#define ETS_LOOP_ITER_BIT (12)
STATIC mp_obj_t machine_disable_irq(void) {
return mp_obj_new_int(disable_irq());
uint32_t state = disable_irq();
state = (state & ~(1 << ETS_LOOP_ITER_BIT)) | (ets_loop_iter_disable << ETS_LOOP_ITER_BIT);
ets_loop_iter_disable = 1;
return mp_obj_new_int(state);
}
MP_DEFINE_CONST_FUN_OBJ_0(machine_disable_irq_obj, machine_disable_irq);
STATIC mp_obj_t machine_enable_irq(mp_obj_t state) {
enable_irq(mp_obj_get_int(state));
STATIC mp_obj_t machine_enable_irq(mp_obj_t state_in) {
uint32_t state = mp_obj_get_int(state_in);
ets_loop_iter_disable = (state >> ETS_LOOP_ITER_BIT) & 1;
enable_irq(state & ~(1 << ETS_LOOP_ITER_BIT));
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_1(machine_enable_irq_obj, machine_enable_irq);

Loading…
Cancel
Save