summaryrefslogtreecommitdiff
path: root/ports/esp8266/ets_alt_task.c
diff options
context:
space:
mode:
Diffstat (limited to 'ports/esp8266/ets_alt_task.c')
-rw-r--r--ports/esp8266/ets_alt_task.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/ports/esp8266/ets_alt_task.c b/ports/esp8266/ets_alt_task.c
index 0b1615d65..ce27758c1 100644
--- a/ports/esp8266/ets_alt_task.c
+++ b/ports/esp8266/ets_alt_task.c
@@ -25,9 +25,9 @@ static void (*idle_cb)(void *);
static void *idle_arg;
#if ESP_SDK_VERSION >= 010500
-# define FIRST_PRIO 0
+#define FIRST_PRIO 0
#else
-# define FIRST_PRIO 0x14
+#define FIRST_PRIO 0x14
#endif
#define LAST_PRIO 0x20
#define PRIO2ID(prio) ((prio) - FIRST_PRIO)
@@ -38,7 +38,9 @@ static inline int prio2id(uint8_t prio) {
int id = PRIO2ID(prio);
if (id < 0 || id >= MP_ARRAY_SIZE(emu_tasks)) {
printf("task prio out of range: %d\n", prio);
- while (1);
+ while (1) {
+ ;
+ }
}
return id;
}
@@ -62,9 +64,9 @@ void dump_tasks(void) {
bool ets_task(os_task_t task, uint8 prio, os_event_t *queue, uint8 qlen) {
static unsigned cnt;
printf("#%d ets_task(%p, %d, %p, %d)\n", cnt++, task, prio, queue, qlen);
-#if USE_ETS_TASK
+ #if USE_ETS_TASK
return _ets_task(task, prio, queue, qlen);
-#else
+ #else
int id = prio2id(prio);
emu_tasks[id].task = task;
emu_tasks[id].queue = queue;
@@ -72,14 +74,14 @@ bool ets_task(os_task_t task, uint8 prio, os_event_t *queue, uint8 qlen) {
emu_tasks[id].i_get = 0;
emu_tasks[id].i_put = 0;
return true;
-#endif
+ #endif
}
bool ets_post(uint8 prio, os_signal_t sig, os_param_t param) {
// static unsigned cnt; printf("#%d ets_post(%d, %x, %x)\n", cnt++, prio, sig, param);
-#if USE_ETS_TASK
+ #if USE_ETS_TASK
return _ets_post(prio, sig, param);
-#else
+ #else
ets_intr_lock();
const int id = prio2id(prio);
@@ -105,7 +107,7 @@ bool ets_post(uint8 prio, os_signal_t sig, os_param_t param) {
ets_intr_unlock();
return 0;
-#endif
+ #endif
}
int ets_loop_iter_disable = 0;
@@ -193,7 +195,7 @@ void ets_timer_init() {
ets_isr_attach(10, my_timer_isr, NULL);
SET_PERI_REG_MASK(0x3FF00004, 4);
ETS_INTR_ENABLE(10);
- ets_task((os_task_t)0x40002E3C, 0x1f, (os_event_t*)0x3FFFDDC0, 4);
+ ets_task((os_task_t)0x40002E3C, 0x1f, (os_event_t *)0x3FFFDDC0, 4);
WRITE_PERI_REG(PERIPHS_TIMER_BASEDDR + 0x30, 0);
WRITE_PERI_REG(PERIPHS_TIMER_BASEDDR + 0x28, 0x88);
@@ -203,19 +205,19 @@ void ets_timer_init() {
#endif
bool ets_run(void) {
-#if USE_ETS_TASK
+ #if USE_ETS_TASK
#if SDK_BELOW_1_1_1
ets_isr_attach(10, my_timer_isr, NULL);
#endif
_ets_run();
-#else
+ #else
// ets_timer_init();
- *(char*)0x3FFFC6FC = 0;
+ *(char *)0x3FFFC6FC = 0;
ets_intr_lock();
printf("ets_alt_task: ets_run\n");
-#if DEBUG
+ #if DEBUG
dump_tasks();
-#endif
+ #endif
ets_intr_unlock();
while (1) {
if (!ets_loop_iter()) {
@@ -224,11 +226,11 @@ bool ets_run(void) {
if (idle_cb) {
idle_cb(idle_arg);
}
- asm("waiti 0");
+ asm ("waiti 0");
ets_intr_unlock();
}
}
-#endif
+ #endif
}
void ets_set_idle_cb(void (*handler)(void *), void *arg) {