From 68a8a0c4458654f2445fb24cbb709a554f1c5968 Mon Sep 17 00:00:00 2001 From: Niclas Finne Date: Thu, 12 Oct 2017 23:52:03 +0200 Subject: [PATCH 1/6] energest: removed energest types for LEDs --- os/dev/leds.c | 31 ++----------------------------- os/sys/energest.h | 3 --- 2 files changed, 2 insertions(+), 32 deletions(-) diff --git a/os/dev/leds.c b/os/dev/leds.c index c815e100d..9273ad9ca 100644 --- a/os/dev/leds.c +++ b/os/dev/leds.c @@ -32,40 +32,13 @@ #include "dev/leds.h" #include "sys/clock.h" -#include "sys/energest.h" static unsigned char leds; /*---------------------------------------------------------------------------*/ -static void +static inline void show_leds(unsigned char new_leds) { - unsigned char changed; - changed = leds ^ new_leds; - leds = new_leds; - - if(changed & LEDS_GREEN) { - /* Green did change */ - if(leds & LEDS_GREEN) { - ENERGEST_ON(ENERGEST_TYPE_LED_GREEN); - } else { - ENERGEST_OFF(ENERGEST_TYPE_LED_GREEN); - } - } - if(changed & LEDS_YELLOW) { - if(leds & LEDS_YELLOW) { - ENERGEST_ON(ENERGEST_TYPE_LED_YELLOW); - } else { - ENERGEST_OFF(ENERGEST_TYPE_LED_YELLOW); - } - } - if(changed & LEDS_RED) { - if(leds & LEDS_RED) { - ENERGEST_ON(ENERGEST_TYPE_LED_RED); - } else { - ENERGEST_OFF(ENERGEST_TYPE_LED_RED); - } - } - leds_arch_set(leds); + leds_arch_set(new_leds); } /*---------------------------------------------------------------------------*/ void diff --git a/os/sys/energest.h b/os/sys/energest.h index 8296041b3..3b52d0c83 100644 --- a/os/sys/energest.h +++ b/os/sys/energest.h @@ -51,9 +51,6 @@ enum energest_type { ENERGEST_TYPE_CPU, ENERGEST_TYPE_LPM, ENERGEST_TYPE_IRQ, - ENERGEST_TYPE_LED_GREEN, - ENERGEST_TYPE_LED_YELLOW, - ENERGEST_TYPE_LED_RED, ENERGEST_TYPE_TRANSMIT, ENERGEST_TYPE_LISTEN, From 8b930bfa06a76e487bb18d0b3eb1f59f51a580b6 Mon Sep 17 00:00:00 2001 From: Niclas Finne Date: Thu, 12 Oct 2017 23:53:31 +0200 Subject: [PATCH 2/6] energest: removed energest types for reading/writing flash --- arch/platform/sky/dev/xmem.c | 8 -------- os/sys/energest.h | 2 -- 2 files changed, 10 deletions(-) diff --git a/arch/platform/sky/dev/xmem.c b/arch/platform/sky/dev/xmem.c index 1efc6e91b..21814ad04 100644 --- a/arch/platform/sky/dev/xmem.c +++ b/arch/platform/sky/dev/xmem.c @@ -170,8 +170,6 @@ xmem_pread(void *_p, int size, unsigned long offset) wait_ready(); - ENERGEST_ON(ENERGEST_TYPE_FLASH_READ); - s = splhigh(); SPI_FLASH_ENABLE(); @@ -191,8 +189,6 @@ xmem_pread(void *_p, int size, unsigned long offset) SPI_FLASH_DISABLE(); splx(s); - ENERGEST_OFF(ENERGEST_TYPE_FLASH_READ); - return size; } /*---------------------------------------------------------------------------*/ @@ -231,8 +227,6 @@ xmem_pwrite(const void *_buf, int size, unsigned long addr) const unsigned long end = addr + size; unsigned long i, next_page; - ENERGEST_ON(ENERGEST_TYPE_FLASH_WRITE); - for(i = addr; i < end;) { next_page = (i | 0xff) + 1; if(next_page > end) { @@ -242,8 +236,6 @@ xmem_pwrite(const void *_buf, int size, unsigned long addr) i = next_page; } - ENERGEST_OFF(ENERGEST_TYPE_FLASH_WRITE); - return size; } /*---------------------------------------------------------------------------*/ diff --git a/os/sys/energest.h b/os/sys/energest.h index 3b52d0c83..680360265 100644 --- a/os/sys/energest.h +++ b/os/sys/energest.h @@ -54,8 +54,6 @@ enum energest_type { ENERGEST_TYPE_TRANSMIT, ENERGEST_TYPE_LISTEN, - ENERGEST_TYPE_FLASH_READ, - ENERGEST_TYPE_FLASH_WRITE, ENERGEST_TYPE_SENSORS, From 7317316942c3a9425410322bd4aefa73b38a0f1f Mon Sep 17 00:00:00 2001 From: Niclas Finne Date: Thu, 12 Oct 2017 23:57:38 +0200 Subject: [PATCH 3/6] energest: removed energest type ENERGEST_TYPE_IRQ --- arch/cpu/arm/common/sys/mtarch.c | 4 --- arch/cpu/cc2538/clock.c | 4 --- arch/cpu/cc2538/dev/cc2538-rf.c | 8 ------ arch/cpu/cc2538/dev/crypto.c | 5 ---- arch/cpu/cc2538/dev/gpio.c | 5 ---- arch/cpu/cc2538/dev/pka.c | 5 ---- arch/cpu/cc2538/dev/uart.c | 5 ---- arch/cpu/cc2538/lpm.c | 25 ------------------- arch/cpu/cc2538/rtimer-arch.c | 5 ---- arch/cpu/cc2538/usb/usb-arch.c | 5 ---- arch/cpu/cc26xx-cc13xx/dev/cc26xx-uart.c | 5 ---- arch/cpu/cc26xx-cc13xx/dev/gpio-interrupt.c | 5 ---- arch/cpu/cc26xx-cc13xx/dev/soc-rtc.c | 5 ---- arch/cpu/cc26xx-cc13xx/dev/soc-trng.c | 4 --- arch/cpu/cc26xx-cc13xx/lpm.c | 22 ---------------- arch/cpu/cc26xx-cc13xx/rf-core/rf-core.c | 8 ------ arch/cpu/msp430/cc2420-arch-sfd.c | 3 +-- arch/cpu/msp430/cc2420-arch.c | 4 --- arch/cpu/msp430/cc2520-arch-sfd.c | 3 +-- arch/cpu/msp430/cc2520-arch.c | 4 --- arch/cpu/msp430/f1xxx/clock.c | 4 --- arch/cpu/msp430/f1xxx/rtimer-arch.c | 5 ---- arch/cpu/msp430/f1xxx/uart1.c | 8 ------ arch/cpu/msp430/f2xxx/uart0.c | 6 ----- arch/cpu/msp430/f2xxx/uart1.c | 6 ----- arch/cpu/msp430/f5xxx/clock.c | 4 --- arch/cpu/msp430/f5xxx/rtimer-arch.c | 5 ---- arch/cpu/msp430/f5xxx/uart0.c | 3 --- arch/cpu/msp430/f5xxx/uart1.c | 3 --- arch/cpu/nrf52832/dev/uart0.c | 4 --- arch/platform/jn516x/dev/clock.c | 5 ---- arch/platform/jn516x/dev/rtimer-arch-slow.c | 5 ---- arch/platform/jn516x/dev/rtimer-arch.c | 3 --- arch/platform/sky/contiki-sky-main.c | 11 -------- arch/platform/sky/dev/button-sensor.c | 3 --- .../srf06-cc26xx/sensortag/reed-relay.c | 1 - os/sys/energest.h | 1 - 37 files changed, 2 insertions(+), 209 deletions(-) diff --git a/arch/cpu/arm/common/sys/mtarch.c b/arch/cpu/arm/common/sys/mtarch.c index b5acf2bb1..6bf011411 100644 --- a/arch/cpu/arm/common/sys/mtarch.c +++ b/arch/cpu/arm/common/sys/mtarch.c @@ -68,8 +68,6 @@ __attribute__ ((__naked__)) void svcall_handler(void) { - /* This is a controlled system handler, so do not use ENERGEST_TYPE_IRQ. */ - /* * Decide whether to switch to the main thread or to a process thread, * depending on the type of the thread preempted by SVCall. @@ -124,8 +122,6 @@ __attribute__ ((__naked__)) void pendsv_handler(void) { - /* This is a controlled system handler, so do not use ENERGEST_TYPE_IRQ. */ - /* * Return without doing anything if PendSV has not preempted a process thread. * This can occur either because PendSV has preempted the main thread, in diff --git a/arch/cpu/cc2538/clock.c b/arch/cpu/cc2538/clock.c index 109b479c8..2842a3be8 100644 --- a/arch/cpu/cc2538/clock.c +++ b/arch/cpu/cc2538/clock.c @@ -241,11 +241,7 @@ clock_adjust(void) void clock_isr(void) { - ENERGEST_ON(ENERGEST_TYPE_IRQ); - update_ticks(); - - ENERGEST_OFF(ENERGEST_TYPE_IRQ); } /*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/cc2538/dev/cc2538-rf.c b/arch/cpu/cc2538/dev/cc2538-rf.c index 942aca2db..09d72397f 100644 --- a/arch/cpu/cc2538/dev/cc2538-rf.c +++ b/arch/cpu/cc2538/dev/cc2538-rf.c @@ -1060,16 +1060,12 @@ PROCESS_THREAD(cc2538_rf_process, ev, data) void cc2538_rf_rx_tx_isr(void) { - ENERGEST_ON(ENERGEST_TYPE_IRQ); - if(!poll_mode) { process_poll(&cc2538_rf_process); } /* We only acknowledge FIFOP so we can safely wipe out the entire SFR */ REG(RFCORE_SFR_RFIRQF0) = 0; - - ENERGEST_OFF(ENERGEST_TYPE_IRQ); } /*---------------------------------------------------------------------------*/ /** @@ -1091,8 +1087,6 @@ cc2538_rf_rx_tx_isr(void) void cc2538_rf_err_isr(void) { - ENERGEST_ON(ENERGEST_TYPE_IRQ); - PRINTF("RF Error: 0x%08lx\n", REG(RFCORE_SFR_RFERRF)); /* If the error is not an RX FIFO overflow, set a flag */ @@ -1103,8 +1097,6 @@ cc2538_rf_err_isr(void) REG(RFCORE_SFR_RFERRF) = 0; process_poll(&cc2538_rf_process); - - ENERGEST_OFF(ENERGEST_TYPE_IRQ); } /*---------------------------------------------------------------------------*/ void diff --git a/arch/cpu/cc2538/dev/crypto.c b/arch/cpu/cc2538/dev/crypto.c index cdb137369..6b0240ec3 100644 --- a/arch/cpu/cc2538/dev/crypto.c +++ b/arch/cpu/cc2538/dev/crypto.c @@ -36,7 +36,6 @@ * Implementation of the cc2538 AES/SHA cryptoprocessor driver */ #include "contiki.h" -#include "sys/energest.h" #include "dev/sys-ctrl.h" #include "dev/nvic.h" #include "dev/crypto.h" @@ -59,8 +58,6 @@ static volatile struct process *notification_process = NULL; void crypto_isr(void) { - ENERGEST_ON(ENERGEST_TYPE_IRQ); - NVIC_ClearPendingIRQ(AES_IRQn); NVIC_DisableIRQ(AES_IRQn); @@ -68,8 +65,6 @@ crypto_isr(void) process_poll((struct process *)notification_process); notification_process = NULL; } - - ENERGEST_OFF(ENERGEST_TYPE_IRQ); } /*---------------------------------------------------------------------------*/ static bool diff --git a/arch/cpu/cc2538/dev/gpio.c b/arch/cpu/cc2538/dev/gpio.c index eb561c757..a09ca6dc3 100644 --- a/arch/cpu/cc2538/dev/gpio.c +++ b/arch/cpu/cc2538/dev/gpio.c @@ -36,7 +36,6 @@ * Implementation of the cc2538 GPIO controller */ #include "contiki.h" -#include "sys/energest.h" #include "dev/leds.h" #include "dev/gpio.h" #include "dev/nvic.h" @@ -90,8 +89,6 @@ gpio_port_isr(uint8_t port) lpm_exit(); - ENERGEST_ON(ENERGEST_TYPE_IRQ); - base = GPIO_PORT_TO_BASE(port); int_status = GPIO_GET_MASKED_INT_STATUS(base); power_up_int_status = GPIO_GET_POWER_UP_INT_STATUS(port); @@ -100,8 +97,6 @@ gpio_port_isr(uint8_t port) GPIO_CLEAR_INTERRUPT(base, int_status); GPIO_CLEAR_POWER_UP_INTERRUPT(port, power_up_int_status); - - ENERGEST_OFF(ENERGEST_TYPE_IRQ); } /*---------------------------------------------------------------------------*/ #define GPIO_PORT_ISR(lowercase_port, uppercase_port) \ diff --git a/arch/cpu/cc2538/dev/pka.c b/arch/cpu/cc2538/dev/pka.c index 7858eb95b..62e481dfd 100644 --- a/arch/cpu/cc2538/dev/pka.c +++ b/arch/cpu/cc2538/dev/pka.c @@ -40,7 +40,6 @@ * Implementation of the cc2538 PKA engine driver */ #include "contiki.h" -#include "sys/energest.h" #include "dev/pka.h" #include "dev/sys-ctrl.h" #include "dev/nvic.h" @@ -62,8 +61,6 @@ static volatile struct process *notification_process = NULL; void pka_isr(void) { - ENERGEST_ON(ENERGEST_TYPE_IRQ); - NVIC_ClearPendingIRQ(PKA_IRQn); NVIC_DisableIRQ(PKA_IRQn); @@ -71,8 +68,6 @@ pka_isr(void) process_poll((struct process *)notification_process); notification_process = NULL; } - - ENERGEST_OFF(ENERGEST_TYPE_IRQ); } /*---------------------------------------------------------------------------*/ static bool diff --git a/arch/cpu/cc2538/dev/uart.c b/arch/cpu/cc2538/dev/uart.c index 04f17e27f..ff24733cd 100644 --- a/arch/cpu/cc2538/dev/uart.c +++ b/arch/cpu/cc2538/dev/uart.c @@ -36,7 +36,6 @@ * Implementation of the cc2538 UART driver */ #include "contiki.h" -#include "sys/energest.h" #include "dev/sys-ctrl.h" #include "dev/ioc.h" #include "dev/gpio.h" @@ -363,8 +362,6 @@ uart_isr(uint8_t uart) uint32_t uart_base; uint16_t mis; - ENERGEST_ON(ENERGEST_TYPE_IRQ); - uart_base = uart_regs[uart].base; /* Store the current MIS and clear all flags early, except the RTM flag. @@ -387,8 +384,6 @@ uart_isr(uint8_t uart) /* ISR triggered due to some error condition */ reset(uart_base); } - - ENERGEST_OFF(ENERGEST_TYPE_IRQ); } /*---------------------------------------------------------------------------*/ #define UART_ISR(u) void uart##u##_isr(void) { uart_isr(u); } diff --git a/arch/cpu/cc2538/lpm.c b/arch/cpu/cc2538/lpm.c index b825c1ced..9e21fe4dc 100644 --- a/arch/cpu/cc2538/lpm.c +++ b/arch/cpu/cc2538/lpm.c @@ -51,18 +51,6 @@ #if LPM_CONF_ENABLE != 0 /*---------------------------------------------------------------------------*/ -#if ENERGEST_CONF_ON -static unsigned long irq_energest = 0; - -#define ENERGEST_IRQ_SAVE(a) do { \ - a = energest_type_time(ENERGEST_TYPE_IRQ); } while(0) -#define ENERGEST_IRQ_RESTORE(a) do { \ - energest_type_set(ENERGEST_TYPE_IRQ, a); } while(0) -#else -#define ENERGEST_IRQ_SAVE(a) do {} while(0) -#define ENERGEST_IRQ_RESTORE(a) do {} while(0) -#endif -/*---------------------------------------------------------------------------*/ /* * Deep Sleep thresholds in rtimer ticks (~30.5 usec) * @@ -130,9 +118,6 @@ enter_pm0(void) { ENERGEST_SWITCH(ENERGEST_TYPE_CPU, ENERGEST_TYPE_LPM); - /* We are only interested in IRQ energest while idle or in LPM */ - ENERGEST_IRQ_RESTORE(irq_energest); - /* Remember the current time so we can keep stats when we wake up */ if(LPM_CONF_STATS) { sleep_enter_time = RTIMER_NOW(); @@ -143,9 +128,6 @@ enter_pm0(void) /* We reach here when the interrupt context that woke us up has returned */ LPM_STATS_ADD(0, RTIMER_NOW() - sleep_enter_time); - /* Remember IRQ energest for next pass */ - ENERGEST_IRQ_SAVE(irq_energest); - ENERGEST_SWITCH(ENERGEST_TYPE_LPM, ENERGEST_TYPE_CPU); } /*---------------------------------------------------------------------------*/ @@ -233,9 +215,6 @@ lpm_exit() /* Restore PMCTL to PM0 for next pass */ REG(SYS_CTRL_PMCTL) = SYS_CTRL_PMCTL_PM0; - /* Remember IRQ energest for next pass */ - ENERGEST_IRQ_SAVE(irq_energest); - ENERGEST_SWITCH(ENERGEST_TYPE_LPM, ENERGEST_TYPE_CPU); } /*---------------------------------------------------------------------------*/ @@ -307,8 +286,6 @@ lpm_enter() REG(SYS_CTRL_PMCTL) = SYS_CTRL_PMCTL_PM1; } - /* We are only interested in IRQ energest while idle or in LPM */ - ENERGEST_IRQ_RESTORE(irq_energest); ENERGEST_SWITCH(ENERGEST_TYPE_CPU, ENERGEST_TYPE_LPM); /* Remember the current time so we can keep stats when we wake up */ @@ -333,8 +310,6 @@ lpm_enter() REG(SYS_CTRL_PMCTL) = SYS_CTRL_PMCTL_PM0; - /* Remember IRQ energest for next pass */ - ENERGEST_IRQ_SAVE(irq_energest); ENERGEST_SWITCH(ENERGEST_TYPE_LPM, ENERGEST_TYPE_CPU); } else { /* All clear. Assert WFI and drop to PM1/2. This is now un-interruptible */ diff --git a/arch/cpu/cc2538/rtimer-arch.c b/arch/cpu/cc2538/rtimer-arch.c index e7e950f7f..4f9739902 100644 --- a/arch/cpu/cc2538/rtimer-arch.c +++ b/arch/cpu/cc2538/rtimer-arch.c @@ -37,7 +37,6 @@ * */ #include "contiki.h" -#include "sys/energest.h" #include "sys/rtimer.h" #include "dev/nvic.h" #include "dev/smwdthrosc.h" @@ -143,16 +142,12 @@ rtimer_isr() */ lpm_exit(); - ENERGEST_ON(ENERGEST_TYPE_IRQ); - next_trigger = 0; NVIC_ClearPendingIRQ(SMT_IRQn); NVIC_DisableIRQ(SMT_IRQn); rtimer_run_next(); - - ENERGEST_OFF(ENERGEST_TYPE_IRQ); } /*---------------------------------------------------------------------------*/ /** @} */ diff --git a/arch/cpu/cc2538/usb/usb-arch.c b/arch/cpu/cc2538/usb/usb-arch.c index d5431a436..43da33946 100644 --- a/arch/cpu/cc2538/usb/usb-arch.c +++ b/arch/cpu/cc2538/usb/usb-arch.c @@ -37,7 +37,6 @@ * the cc2530 driver written by Philippe Retornaz */ #include "contiki.h" -#include "energest.h" #include "usb-arch.h" #include "usb-api.h" #include "dev/usb-regs.h" @@ -1257,8 +1256,6 @@ usb_isr(void) uint8_t common_if = REG(USB_CIF) & REG(USB_CIE); uint8_t i; - ENERGEST_ON(ENERGEST_TYPE_IRQ); - if(ep_in_if) { /* EP0 flag is in the IN Interrupt Flags register */ if(ep_in_if & USB_IIF_EP0IF) { @@ -1287,8 +1284,6 @@ usb_isr(void) if(common_if & USB_CIF_SUSPENDIF) { notify_process(USB_EVENT_SUSPEND); } - - ENERGEST_OFF(ENERGEST_TYPE_IRQ); } /*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/cc26xx-cc13xx/dev/cc26xx-uart.c b/arch/cpu/cc26xx-cc13xx/dev/cc26xx-uart.c index 771353235..d466e9293 100644 --- a/arch/cpu/cc26xx-cc13xx/dev/cc26xx-uart.c +++ b/arch/cpu/cc26xx-cc13xx/dev/cc26xx-uart.c @@ -46,7 +46,6 @@ #include "uart.h" #include "lpm.h" #include "ti-lib.h" -#include "sys/energest.h" #include #include @@ -366,8 +365,6 @@ cc26xx_uart_isr(void) char the_char; uint32_t flags; - ENERGEST_ON(ENERGEST_TYPE_IRQ); - power_and_clock(); /* Read out the masked interrupt status */ @@ -389,8 +386,6 @@ cc26xx_uart_isr(void) } } } - - ENERGEST_OFF(ENERGEST_TYPE_IRQ); } /*---------------------------------------------------------------------------*/ /** @} */ diff --git a/arch/cpu/cc26xx-cc13xx/dev/gpio-interrupt.c b/arch/cpu/cc26xx-cc13xx/dev/gpio-interrupt.c index 41ac5b5c6..348d0646a 100644 --- a/arch/cpu/cc26xx-cc13xx/dev/gpio-interrupt.c +++ b/arch/cpu/cc26xx-cc13xx/dev/gpio-interrupt.c @@ -38,7 +38,6 @@ /*---------------------------------------------------------------------------*/ #include "ioc.h" #include "gpio-interrupt.h" -#include "sys/energest.h" #include "lpm.h" #include "ti-lib.h" @@ -83,8 +82,6 @@ gpio_interrupt_isr(void) uint32_t pin_mask; uint8_t i; - ENERGEST_ON(ENERGEST_TYPE_IRQ); - /* Read interrupt flags */ pin_mask = (HWREG(GPIO_BASE + GPIO_O_EVFLAGS31_0) & GPIO_DIO_ALL_MASK); @@ -98,8 +95,6 @@ gpio_interrupt_isr(void) handlers[i](i); } } - - ENERGEST_OFF(ENERGEST_TYPE_IRQ); } /*---------------------------------------------------------------------------*/ /** @} */ diff --git a/arch/cpu/cc26xx-cc13xx/dev/soc-rtc.c b/arch/cpu/cc26xx-cc13xx/dev/soc-rtc.c index 110a584c5..8de930a9c 100644 --- a/arch/cpu/cc26xx-cc13xx/dev/soc-rtc.c +++ b/arch/cpu/cc26xx-cc13xx/dev/soc-rtc.c @@ -37,7 +37,6 @@ */ /*---------------------------------------------------------------------------*/ #include "contiki.h" -#include "sys/energest.h" #include "rtimer.h" #include "lpm.h" @@ -146,8 +145,6 @@ soc_rtc_isr(void) { uint32_t next; - ENERGEST_ON(ENERGEST_TYPE_IRQ); - last_isr_time = RTIMER_NOW(); /* Adjust the s/w tick counter irrespective of which event trigger this */ @@ -177,8 +174,6 @@ soc_rtc_isr(void) ti_lib_aon_rtc_channel_disable(AON_RTC_CH2); HWREG(AON_RTC_BASE + AON_RTC_O_EVFLAGS) = AON_RTC_EVFLAGS_CH2; } - - ENERGEST_OFF(ENERGEST_TYPE_IRQ); } /*---------------------------------------------------------------------------*/ /** @} */ diff --git a/arch/cpu/cc26xx-cc13xx/dev/soc-trng.c b/arch/cpu/cc26xx-cc13xx/dev/soc-trng.c index 33a217be8..2fea8418d 100644 --- a/arch/cpu/cc26xx-cc13xx/dev/soc-trng.c +++ b/arch/cpu/cc26xx-cc13xx/dev/soc-trng.c @@ -284,8 +284,6 @@ PROCESS_THREAD(soc_trng_process, ev, data) void soc_trng_isr(void) { - ENERGEST_ON(ENERGEST_TYPE_IRQ); - ti_lib_trng_disable(); disable_number_ready_interrupt(); @@ -294,8 +292,6 @@ soc_trng_isr(void) ti_lib_trng_enable(); process_post(&soc_trng_process, rng_ready_event, NULL); - - ENERGEST_OFF(ENERGEST_TYPE_IRQ); } /*---------------------------------------------------------------------------*/ void diff --git a/arch/cpu/cc26xx-cc13xx/lpm.c b/arch/cpu/cc26xx-cc13xx/lpm.c index 0b368beb6..48ded636e 100644 --- a/arch/cpu/cc26xx-cc13xx/lpm.c +++ b/arch/cpu/cc26xx-cc13xx/lpm.c @@ -56,18 +56,6 @@ #include #include /*---------------------------------------------------------------------------*/ -#if ENERGEST_CONF_ON -static unsigned long irq_energest = 0; - -#define ENERGEST_IRQ_SAVE(a) do { \ - a = energest_type_time(ENERGEST_TYPE_IRQ); } while(0) -#define ENERGEST_IRQ_RESTORE(a) do { \ - energest_type_set(ENERGEST_TYPE_IRQ, a); } while(0) -#else -#define ENERGEST_IRQ_SAVE(a) do {} while(0) -#define ENERGEST_IRQ_RESTORE(a) do {} while(0) -#endif -/*---------------------------------------------------------------------------*/ LIST(modules_list); /*---------------------------------------------------------------------------*/ /* PDs that may stay on in deep sleep */ @@ -197,8 +185,6 @@ wake_up(void) { lpm_registered_module_t *module; - /* Remember IRQ energest for next pass */ - ENERGEST_IRQ_SAVE(irq_energest); ENERGEST_SWITCH(ENERGEST_TYPE_LPM, ENERGEST_TYPE_CPU); /* Sync so that we get the latest values before adjusting recharge settings */ @@ -389,17 +375,11 @@ lpm_sleep(void) { ENERGEST_SWITCH(ENERGEST_TYPE_CPU, ENERGEST_TYPE_LPM); - /* We are only interested in IRQ energest while idle or in LPM */ - ENERGEST_IRQ_RESTORE(irq_energest); - /* Just to be on the safe side, explicitly disable Deep Sleep */ HWREG(NVIC_SYS_CTRL) &= ~(NVIC_SYS_CTRL_SLEEPDEEP); ti_lib_prcm_sleep(); - /* Remember IRQ energest for next pass */ - ENERGEST_IRQ_SAVE(irq_energest); - ENERGEST_SWITCH(ENERGEST_TYPE_LPM, ENERGEST_TYPE_CPU); } /*---------------------------------------------------------------------------*/ @@ -505,8 +485,6 @@ deep_sleep(void) ti_lib_pwr_ctrl_source_set(PWRCTRL_PWRSRC_ULDO); } - /* We are only interested in IRQ energest while idle or in LPM */ - ENERGEST_IRQ_RESTORE(irq_energest); ENERGEST_SWITCH(ENERGEST_TYPE_CPU, ENERGEST_TYPE_LPM); /* Sync the AON interface to ensure all writes have gone through. */ diff --git a/arch/cpu/cc26xx-cc13xx/rf-core/rf-core.c b/arch/cpu/cc26xx-cc13xx/rf-core/rf-core.c index 834a0578b..2baa883ad 100644 --- a/arch/cpu/cc26xx-cc13xx/rf-core/rf-core.c +++ b/arch/cpu/cc26xx-cc13xx/rf-core/rf-core.c @@ -567,8 +567,6 @@ rx_nok_isr(void) void cc26xx_rf_cpe1_isr(void) { - ENERGEST_ON(ENERGEST_TYPE_IRQ); - PRINTF("RF Error\n"); if(!rf_core_is_accessible()) { @@ -579,15 +577,11 @@ cc26xx_rf_cpe1_isr(void) /* Clear INTERNAL_ERROR interrupt flag */ HWREG(RFC_DBELL_NONBUF_BASE + RFC_DBELL_O_RFCPEIFG) = 0x7FFFFFFF; - - ENERGEST_OFF(ENERGEST_TYPE_IRQ); } /*---------------------------------------------------------------------------*/ void cc26xx_rf_cpe0_isr(void) { - ENERGEST_ON(ENERGEST_TYPE_IRQ); - if(!rf_core_is_accessible()) { printf("RF ISR called but RF not ready... PANIC!!\n"); if(rf_core_power_up() != RF_CORE_CMD_OK) { @@ -619,8 +613,6 @@ cc26xx_rf_cpe0_isr(void) } ti_lib_int_master_enable(); - - ENERGEST_OFF(ENERGEST_TYPE_IRQ); } /*---------------------------------------------------------------------------*/ /** @} */ diff --git a/arch/cpu/msp430/cc2420-arch-sfd.c b/arch/cpu/msp430/cc2420-arch-sfd.c index 6cd7d2606..6ab9a1365 100644 --- a/arch/cpu/msp430/cc2420-arch-sfd.c +++ b/arch/cpu/msp430/cc2420-arch-sfd.c @@ -42,7 +42,7 @@ extern volatile uint16_t cc2420_sfd_end_time; ISR(TIMERB1, cc2420_timerb1_interrupt) { int tbiv; - ENERGEST_ON(ENERGEST_TYPE_IRQ); + /* always read TBIV to clear IFG */ tbiv = TBIV; /* read and discard tbiv to avoid "variable set but not used" warning */ @@ -54,7 +54,6 @@ ISR(TIMERB1, cc2420_timerb1_interrupt) cc2420_sfd_counter = 0; cc2420_sfd_end_time = TBCCR1; } - ENERGEST_OFF(ENERGEST_TYPE_IRQ); } /*---------------------------------------------------------------------------*/ void diff --git a/arch/cpu/msp430/cc2420-arch.c b/arch/cpu/msp430/cc2420-arch.c index 7da8892a9..8a6f0234d 100644 --- a/arch/cpu/msp430/cc2420-arch.c +++ b/arch/cpu/msp430/cc2420-arch.c @@ -50,13 +50,9 @@ /*---------------------------------------------------------------------------*/ ISR(CC2420_IRQ, cc2420_port1_interrupt) { - ENERGEST_ON(ENERGEST_TYPE_IRQ); - if(cc2420_interrupt()) { LPM4_EXIT; } - - ENERGEST_OFF(ENERGEST_TYPE_IRQ); } /*---------------------------------------------------------------------------*/ void diff --git a/arch/cpu/msp430/cc2520-arch-sfd.c b/arch/cpu/msp430/cc2520-arch-sfd.c index 5e7bee813..e2671ca58 100644 --- a/arch/cpu/msp430/cc2520-arch-sfd.c +++ b/arch/cpu/msp430/cc2520-arch-sfd.c @@ -41,7 +41,7 @@ extern volatile uint16_t cc2520_sfd_end_time; ISR(TIMERB1, cc2520_timerb1_interrupt) { int tbiv; - ENERGEST_ON(ENERGEST_TYPE_IRQ); + /* always read TBIV to clear IFG */ tbiv = TBIV; /* read and discard tbiv to avoid "variable set but not used" warning */ @@ -53,7 +53,6 @@ ISR(TIMERB1, cc2520_timerb1_interrupt) cc2520_sfd_counter = 0; cc2520_sfd_end_time = TBCCR1; } - ENERGEST_OFF(ENERGEST_TYPE_IRQ); } /*---------------------------------------------------------------------------*/ void diff --git a/arch/cpu/msp430/cc2520-arch.c b/arch/cpu/msp430/cc2520-arch.c index d57e7571a..855f8bc7e 100644 --- a/arch/cpu/msp430/cc2520-arch.c +++ b/arch/cpu/msp430/cc2520-arch.c @@ -49,13 +49,9 @@ /*---------------------------------------------------------------------------*/ ISR(CC2520_IRQ, cc2520_port1_interrupt) { - ENERGEST_ON(ENERGEST_TYPE_IRQ); - if(cc2520_interrupt()) { LPM4_EXIT; } - - ENERGEST_OFF(ENERGEST_TYPE_IRQ); } /*---------------------------------------------------------------------------*/ void diff --git a/arch/cpu/msp430/f1xxx/clock.c b/arch/cpu/msp430/f1xxx/clock.c index 9b2a7562b..d372dc4e4 100644 --- a/arch/cpu/msp430/f1xxx/clock.c +++ b/arch/cpu/msp430/f1xxx/clock.c @@ -63,8 +63,6 @@ read_tar(void) /*---------------------------------------------------------------------------*/ ISR(TIMERA1, timera1) { - ENERGEST_ON(ENERGEST_TYPE_IRQ); - watchdog_start(); if(TAIV == 2) { @@ -106,8 +104,6 @@ ISR(TIMERA1, timera1) }*/ watchdog_stop(); - - ENERGEST_OFF(ENERGEST_TYPE_IRQ); } /*---------------------------------------------------------------------------*/ clock_time_t diff --git a/arch/cpu/msp430/f1xxx/rtimer-arch.c b/arch/cpu/msp430/f1xxx/rtimer-arch.c index 95a4b9375..5d94dadc4 100644 --- a/arch/cpu/msp430/f1xxx/rtimer-arch.c +++ b/arch/cpu/msp430/f1xxx/rtimer-arch.c @@ -39,7 +39,6 @@ #include "contiki.h" -#include "sys/energest.h" #include "sys/rtimer.h" #include "sys/process.h" #include "dev/watchdog.h" @@ -56,8 +55,6 @@ /*---------------------------------------------------------------------------*/ ISR(TIMERA0, timera0) { - ENERGEST_ON(ENERGEST_TYPE_IRQ); - watchdog_start(); rtimer_run_next(); @@ -67,8 +64,6 @@ ISR(TIMERA0, timera0) } watchdog_stop(); - - ENERGEST_OFF(ENERGEST_TYPE_IRQ); } /*---------------------------------------------------------------------------*/ void diff --git a/arch/cpu/msp430/f1xxx/uart1.c b/arch/cpu/msp430/f1xxx/uart1.c index 946d2724a..0de1a9761 100644 --- a/arch/cpu/msp430/f1xxx/uart1.c +++ b/arch/cpu/msp430/f1xxx/uart1.c @@ -33,7 +33,6 @@ */ #include "contiki.h" -#include "sys/energest.h" #include "dev/uart1.h" #include "dev/watchdog.h" #include "sys/ctimer.h" @@ -239,7 +238,6 @@ uart1_init(unsigned long ubr) ISR(UART1RX, uart1_rx_interrupt) { uint8_t c; - ENERGEST_ON(ENERGEST_TYPE_IRQ); if(!(URXIFG1 & IFG2)) { /* Edge detect if IFG not set? */ @@ -261,23 +259,17 @@ ISR(UART1RX, uart1_rx_interrupt) } } } - - ENERGEST_OFF(ENERGEST_TYPE_IRQ); } #endif /* !RX_WITH_DMA */ /*---------------------------------------------------------------------------*/ #if TX_WITH_INTERRUPT ISR(UART1TX, uart1_tx_interrupt) { - ENERGEST_ON(ENERGEST_TYPE_IRQ); - if(ringbuf_elements(&txbuf) == 0) { transmitting = 0; } else { TXBUF1 = ringbuf_get(&txbuf); } - - ENERGEST_OFF(ENERGEST_TYPE_IRQ); } #endif /* TX_WITH_INTERRUPT */ /*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/msp430/f2xxx/uart0.c b/arch/cpu/msp430/f2xxx/uart0.c index c369c94e5..cfe9e5904 100644 --- a/arch/cpu/msp430/f2xxx/uart0.c +++ b/arch/cpu/msp430/f2xxx/uart0.c @@ -35,7 +35,6 @@ #include #include "contiki.h" -#include "sys/energest.h" #include "dev/uart0.h" #include "dev/watchdog.h" #include "lib/ringbuf.h" @@ -186,7 +185,6 @@ ISR(USCIAB0RX, uart0_rx_interrupt) { uint8_t c; - ENERGEST_ON(ENERGEST_TYPE_IRQ); if(UCA0STAT & UCRXERR) { c = UCA0RXBUF; /* Clear error flags by forcing a dummy read. */ } else { @@ -197,14 +195,12 @@ ISR(USCIAB0RX, uart0_rx_interrupt) } } } - ENERGEST_OFF(ENERGEST_TYPE_IRQ); } #endif /* !RX_WITH_DMA */ /*---------------------------------------------------------------------------*/ #if TX_WITH_INTERRUPT ISR(USCIAB0TX, uart0_tx_interrupt) { - ENERGEST_ON(ENERGEST_TYPE_IRQ); if((IFG2 & UCA0TXIFG)) { if(ringbuf_elements(&txbuf) == 0) { @@ -216,8 +212,6 @@ ISR(USCIAB0TX, uart0_tx_interrupt) /* In a stand-alone app won't work without this. Is the UG misleading? */ IFG2 &= ~UCA0TXIFG; - - ENERGEST_OFF(ENERGEST_TYPE_IRQ); } #endif /* TX_WITH_INTERRUPT */ /*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/msp430/f2xxx/uart1.c b/arch/cpu/msp430/f2xxx/uart1.c index 7377f59e5..5a94726b9 100644 --- a/arch/cpu/msp430/f2xxx/uart1.c +++ b/arch/cpu/msp430/f2xxx/uart1.c @@ -33,7 +33,6 @@ */ #include "contiki.h" #include -#include "sys/energest.h" #include "dev/uart1.h" #include "dev/watchdog.h" #include "lib/ringbuf.h" @@ -119,7 +118,6 @@ uart1_init(unsigned long ubr) ISR(USCIAB1RX, uart1_rx_interrupt) { uint8_t c; - ENERGEST_ON(ENERGEST_TYPE_IRQ); /* Check status register for receive errors. */ if(UCA0STAT & UCRXERR) { @@ -132,13 +130,11 @@ ISR(USCIAB1RX, uart1_rx_interrupt) } } } - ENERGEST_OFF(ENERGEST_TYPE_IRQ); } /*---------------------------------------------------------------------------*/ #if TX_WITH_INTERRUPT ISR(USCIAB1TX, uart1_tx_interrupt) { - ENERGEST_ON(ENERGEST_TYPE_IRQ); if(IFG2 & UCA0TXIFG) { if(ringbuf_elements(&txbuf) == 0) { transmitting = 0; @@ -146,8 +142,6 @@ ISR(USCIAB1TX, uart1_tx_interrupt) UCA0TXBUF = ringbuf_get(&txbuf); } } - - ENERGEST_OFF(ENERGEST_TYPE_IRQ); } #endif /* TX_WITH_INTERRUPT */ /*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/msp430/f5xxx/clock.c b/arch/cpu/msp430/f5xxx/clock.c index 1def811e6..e61aec1e9 100644 --- a/arch/cpu/msp430/f5xxx/clock.c +++ b/arch/cpu/msp430/f5xxx/clock.c @@ -63,8 +63,6 @@ read_tar(void) /*---------------------------------------------------------------------------*/ ISR(TIMER1_A1, timera1) { - ENERGEST_ON(ENERGEST_TYPE_IRQ); - /* watchdog_start(); */ if(TA1IV == 2) { @@ -106,8 +104,6 @@ ISR(TIMER1_A1, timera1) }*/ /* watchdog_stop(); */ - - ENERGEST_OFF(ENERGEST_TYPE_IRQ); } /*---------------------------------------------------------------------------*/ clock_time_t diff --git a/arch/cpu/msp430/f5xxx/rtimer-arch.c b/arch/cpu/msp430/f5xxx/rtimer-arch.c index 80f50ae8d..7ed8e9cc3 100644 --- a/arch/cpu/msp430/f5xxx/rtimer-arch.c +++ b/arch/cpu/msp430/f5xxx/rtimer-arch.c @@ -37,7 +37,6 @@ */ #include "contiki.h" -#include "sys/energest.h" #include "sys/rtimer.h" #include "sys/process.h" #include "dev/watchdog.h" @@ -54,8 +53,6 @@ /*---------------------------------------------------------------------------*/ ISR(TIMER1_A0, timera0) { - ENERGEST_ON(ENERGEST_TYPE_IRQ); - watchdog_start(); rtimer_run_next(); @@ -65,8 +62,6 @@ ISR(TIMER1_A0, timera0) } watchdog_stop(); - - ENERGEST_OFF(ENERGEST_TYPE_IRQ); } /*---------------------------------------------------------------------------*/ void diff --git a/arch/cpu/msp430/f5xxx/uart0.c b/arch/cpu/msp430/f5xxx/uart0.c index 563da896f..8bab9f40f 100644 --- a/arch/cpu/msp430/f5xxx/uart0.c +++ b/arch/cpu/msp430/f5xxx/uart0.c @@ -35,7 +35,6 @@ #include "contiki.h" #include -#include "sys/energest.h" #include "dev/uart0.h" #include "dev/watchdog.h" #include "isr_compat.h" @@ -103,7 +102,6 @@ ISR(USCI_A0, uart0_rx_interrupt) { uint8_t c; - ENERGEST_ON(ENERGEST_TYPE_IRQ); if(UCA0IV == 2) { if(UCA0STAT & UCRXERR) { c = UCA0RXBUF; /* Clear error flags by forcing a dummy read. */ @@ -116,6 +114,5 @@ ISR(USCI_A0, uart0_rx_interrupt) } } } - ENERGEST_OFF(ENERGEST_TYPE_IRQ); } /*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/msp430/f5xxx/uart1.c b/arch/cpu/msp430/f5xxx/uart1.c index 4937ff025..c2312859f 100644 --- a/arch/cpu/msp430/f5xxx/uart1.c +++ b/arch/cpu/msp430/f5xxx/uart1.c @@ -35,7 +35,6 @@ #include "contiki.h" #include -#include "sys/energest.h" #include "dev/uart1.h" #include "dev/watchdog.h" #include "isr_compat.h" @@ -157,7 +156,6 @@ ISR(USCI_A1, uart1_rx_interrupt) { uint8_t c; - ENERGEST_ON(ENERGEST_TYPE_IRQ); if(UCA1IV == 2) { if(UCA1STAT & UCRXERR) { c = UCA1RXBUF; /* Clear error flags by forcing a dummy read. */ @@ -170,7 +168,6 @@ ISR(USCI_A1, uart1_rx_interrupt) } } } - ENERGEST_OFF(ENERGEST_TYPE_IRQ); } #endif /* !RX_WITH_DMA */ /*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/nrf52832/dev/uart0.c b/arch/cpu/nrf52832/dev/uart0.c index df9c7b9e3..846feab18 100644 --- a/arch/cpu/nrf52832/dev/uart0.c +++ b/arch/cpu/nrf52832/dev/uart0.c @@ -63,8 +63,6 @@ static uint8_t txbuf_data[TXBUFSIZE]; static void uart_event_handler(nrf_drv_uart_event_t * p_event, void * p_context) { - ENERGEST_ON(ENERGEST_TYPE_IRQ); - if (p_event->type == NRF_DRV_UART_EVT_RX_DONE) { if (uart0_input_handler != NULL) { uart0_input_handler(p_event->data.rxtx.p_data[0]); @@ -76,8 +74,6 @@ uart_event_handler(nrf_drv_uart_event_t * p_event, void * p_context) nrf_drv_uart_tx(&c, 1); } } - - ENERGEST_OFF(ENERGEST_TYPE_IRQ); } /*---------------------------------------------------------------------------*/ void diff --git a/arch/platform/jn516x/dev/clock.c b/arch/platform/jn516x/dev/clock.c index 8b2c316c0..eec23166a 100644 --- a/arch/platform/jn516x/dev/clock.c +++ b/arch/platform/jn516x/dev/clock.c @@ -42,7 +42,6 @@ #include #include #include "contiki.h" -#include "sys/energest.h" #include "sys/clock.h" #include "sys/etimer.h" #include "rtimer-arch.h" @@ -130,8 +129,6 @@ clockTimerISR(uint32 u32Device, uint32 u32ItemBitmap) return; } - ENERGEST_ON(ENERGEST_TYPE_IRQ); - if(u32Device == CLOCK_TIMER_ISR_DEV) { check_etimers(); } @@ -139,8 +136,6 @@ clockTimerISR(uint32 u32Device, uint32 u32ItemBitmap) if(u32Device == OVERFLOW_TIMER_ISR_DEV) { check_rtimer_overflow(clock()); } - - ENERGEST_OFF(ENERGEST_TYPE_IRQ); } /*---------------------------------------------------------------------------*/ void diff --git a/arch/platform/jn516x/dev/rtimer-arch-slow.c b/arch/platform/jn516x/dev/rtimer-arch-slow.c index 588edc341..facbfb94f 100644 --- a/arch/platform/jn516x/dev/rtimer-arch-slow.c +++ b/arch/platform/jn516x/dev/rtimer-arch-slow.c @@ -43,7 +43,6 @@ #include #include #include "dev/watchdog.h" -#include "sys/energest.h" #include "sys/process.h" #if RTIMER_USE_32KHZ @@ -75,8 +74,6 @@ timerISR(uint32 u32Device, uint32 u32ItemBitmap) return; } - ENERGEST_ON(ENERGEST_TYPE_IRQ); - if(u32ItemBitmap & TICK_TIMER_MASK) { /* 32-bit overflow happened; restart the timer */ uint32_t ticks_late = WRAPAROUND_VALUE - u64AHI_WakeTimerReadLarge(TICK_TIMER); @@ -104,8 +101,6 @@ timerISR(uint32 u32Device, uint32 u32ItemBitmap) process_nevents(); } } - - ENERGEST_OFF(ENERGEST_TYPE_IRQ); } /*---------------------------------------------------------------------------*/ void diff --git a/arch/platform/jn516x/dev/rtimer-arch.c b/arch/platform/jn516x/dev/rtimer-arch.c index f74fa3fd7..e72c63d99 100644 --- a/arch/platform/jn516x/dev/rtimer-arch.c +++ b/arch/platform/jn516x/dev/rtimer-arch.c @@ -44,7 +44,6 @@ #include #include #include "dev/watchdog.h" -#include "sys/energest.h" #include "sys/process.h" #if !RTIMER_USE_32KHZ @@ -71,7 +70,6 @@ rtimer_arch_run_next(uint32 u32DeviceId, uint32 u32ItemBitmap) return; } - ENERGEST_ON(ENERGEST_TYPE_IRQ); vAHI_TickTimerIntPendClr(); vAHI_TickTimerIntEnable(0); /* @@ -90,7 +88,6 @@ rtimer_arch_run_next(uint32 u32DeviceId, uint32 u32ItemBitmap) vAHI_TickTimerIntEnable(1); vAHI_TickTimerInterval(scheduled_time); } - ENERGEST_OFF(ENERGEST_TYPE_IRQ); } /*---------------------------------------------------------------------------*/ void diff --git a/arch/platform/sky/contiki-sky-main.c b/arch/platform/sky/contiki-sky-main.c index 38ca8dc68..8b20c7cd5 100644 --- a/arch/platform/sky/contiki-sky-main.c +++ b/arch/platform/sky/contiki-sky-main.c @@ -335,8 +335,6 @@ main(int argc, char **argv) if(process_nevents() != 0 || uart1_active()) { splx(s); /* Re-enable interrupts. */ } else { - static unsigned long irq_energest = 0; - #if DCOSYNCH_CONF_ENABLED /* before going down to sleep possibly do some management */ if(timer_expired(&mgt_timer)) { @@ -351,10 +349,6 @@ main(int argc, char **argv) /* Re-enable interrupts and go to sleep atomically. */ ENERGEST_SWITCH(ENERGEST_TYPE_CPU, ENERGEST_TYPE_LPM); - /* We only want to measure the processing done in IRQs when we - are asleep, so we discard the processing time done when we - were awake. */ - energest_type_set(ENERGEST_TYPE_IRQ, irq_energest); watchdog_stop(); /* check if the DCO needs to be on - if so - only LPM 1 */ if (msp430_dco_required) { @@ -367,11 +361,6 @@ main(int argc, char **argv) interrupt that sets the wake up flag. */ } - /* We get the current processing time for interrupts that was - done during the LPM and store it for next time around. */ - dint(); - irq_energest = energest_type_time(ENERGEST_TYPE_IRQ); - eint(); watchdog_start(); ENERGEST_SWITCH(ENERGEST_TYPE_LPM, ENERGEST_TYPE_CPU); } diff --git a/arch/platform/sky/dev/button-sensor.c b/arch/platform/sky/dev/button-sensor.c index 4a0d07acc..9aa03f48d 100644 --- a/arch/platform/sky/dev/button-sensor.c +++ b/arch/platform/sky/dev/button-sensor.c @@ -46,8 +46,6 @@ HWCONF_IRQ(BUTTON, 2, 7); /*---------------------------------------------------------------------------*/ ISR(PORT2, irq_p2) { - ENERGEST_ON(ENERGEST_TYPE_IRQ); - if(BUTTON_CHECK_IRQ()) { if(timer_expired(&debouncetimer)) { timer_set(&debouncetimer, CLOCK_SECOND / 4); @@ -56,7 +54,6 @@ ISR(PORT2, irq_p2) } } P2IFG = 0x00; - ENERGEST_OFF(ENERGEST_TYPE_IRQ); } /*---------------------------------------------------------------------------*/ static int diff --git a/arch/platform/srf06-cc26xx/sensortag/reed-relay.c b/arch/platform/srf06-cc26xx/sensortag/reed-relay.c index 8cecad9d6..736b2170a 100644 --- a/arch/platform/srf06-cc26xx/sensortag/reed-relay.c +++ b/arch/platform/srf06-cc26xx/sensortag/reed-relay.c @@ -63,7 +63,6 @@ static void reed_interrupt_handler(uint8_t ioid) { if(!timer_expired(&debouncetimer)) { - ENERGEST_OFF(ENERGEST_TYPE_IRQ); return; } diff --git a/os/sys/energest.h b/os/sys/energest.h index 680360265..635779d55 100644 --- a/os/sys/energest.h +++ b/os/sys/energest.h @@ -50,7 +50,6 @@ typedef struct { enum energest_type { ENERGEST_TYPE_CPU, ENERGEST_TYPE_LPM, - ENERGEST_TYPE_IRQ, ENERGEST_TYPE_TRANSMIT, ENERGEST_TYPE_LISTEN, From fafe4bb1f3a08529094fe9d69bc33ed02c536ab2 Mon Sep 17 00:00:00 2001 From: Niclas Finne Date: Thu, 12 Oct 2017 23:59:11 +0200 Subject: [PATCH 4/6] energest: replaced some energest on/off with ENERGEST_SWITCH() --- arch/cpu/cc2538/dev/cc2538-rf.c | 6 ++---- arch/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c | 6 ++---- arch/cpu/cc26xx-cc13xx/rf-core/prop-mode.c | 6 ++---- arch/dev/cc1200/cc1200.c | 3 +-- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/arch/cpu/cc2538/dev/cc2538-rf.c b/arch/cpu/cc2538/dev/cc2538-rf.c index 09d72397f..5e6661b3e 100644 --- a/arch/cpu/cc2538/dev/cc2538-rf.c +++ b/arch/cpu/cc2538/dev/cc2538-rf.c @@ -638,8 +638,7 @@ transmit(unsigned short transmit_len) } /* Start the transmission */ - ENERGEST_OFF(ENERGEST_TYPE_LISTEN); - ENERGEST_ON(ENERGEST_TYPE_TRANSMIT); + ENERGEST_SWITCH(ENERGEST_TYPE_LISTEN, ENERGEST_TYPE_TRANSMIT); CC2538_RF_CSP_ISTXON(); @@ -658,8 +657,7 @@ transmit(unsigned short transmit_len) while(REG(RFCORE_XREG_FSMSTAT1) & RFCORE_XREG_FSMSTAT1_TX_ACTIVE); ret = RADIO_TX_OK; } - ENERGEST_OFF(ENERGEST_TYPE_TRANSMIT); - ENERGEST_ON(ENERGEST_TYPE_LISTEN); + ENERGEST_SWITCH(ENERGEST_TYPE_TRANSMIT, ENERGEST_TYPE_LISTEN); if(was_off) { off(); diff --git a/arch/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c b/arch/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c index ae9a91f81..d4c1c27e5 100644 --- a/arch/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c +++ b/arch/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c @@ -946,8 +946,7 @@ transmit(unsigned short transmit_len) if(ret) { /* If we enter here, TX actually started */ - ENERGEST_OFF(ENERGEST_TYPE_LISTEN); - ENERGEST_ON(ENERGEST_TYPE_TRANSMIT); + ENERGEST_SWITCH(ENERGEST_TYPE_LISTEN, ENERGEST_TYPE_TRANSMIT); /* Idle away while the command is running */ while((cmd.status & RF_CORE_RADIO_OP_MASKED_STATUS) @@ -985,8 +984,7 @@ transmit(unsigned short transmit_len) * Update ENERGEST state here, before a potential call to off(), which * will correctly update it if required. */ - ENERGEST_OFF(ENERGEST_TYPE_TRANSMIT); - ENERGEST_ON(ENERGEST_TYPE_LISTEN); + ENERGEST_SWITCH(ENERGEST_TYPE_TRANSMIT, ENERGEST_TYPE_LISTEN); /* * Disable LAST_FG_COMMAND_DONE interrupt. We don't really care about it diff --git a/arch/cpu/cc26xx-cc13xx/rf-core/prop-mode.c b/arch/cpu/cc26xx-cc13xx/rf-core/prop-mode.c index fb2099ed7..61581f20a 100644 --- a/arch/cpu/cc26xx-cc13xx/rf-core/prop-mode.c +++ b/arch/cpu/cc26xx-cc13xx/rf-core/prop-mode.c @@ -706,8 +706,7 @@ transmit(unsigned short transmit_len) if(ret) { /* If we enter here, TX actually started */ - ENERGEST_OFF(ENERGEST_TYPE_LISTEN); - ENERGEST_ON(ENERGEST_TYPE_TRANSMIT); + ENERGEST_SWITCH(ENERGEST_TYPE_LISTEN, ENERGEST_TYPE_TRANSMIT); watchdog_periodic(); @@ -737,8 +736,7 @@ transmit(unsigned short transmit_len) * Update ENERGEST state here, before a potential call to off(), which * will correctly update it if required. */ - ENERGEST_OFF(ENERGEST_TYPE_TRANSMIT); - ENERGEST_ON(ENERGEST_TYPE_LISTEN); + ENERGEST_SWITCH(ENERGEST_TYPE_TRANSMIT, ENERGEST_TYPE_LISTEN); /* * Disable LAST_FG_COMMAND_DONE interrupt. We don't really care about it diff --git a/arch/dev/cc1200/cc1200.c b/arch/dev/cc1200/cc1200.c index c1492317d..78f379161 100644 --- a/arch/dev/cc1200/cc1200.c +++ b/arch/dev/cc1200/cc1200.c @@ -1970,8 +1970,7 @@ idle_tx_rx(const uint8_t *payload, uint16_t payload_len) TX_LEDS_OFF(); - ENERGEST_OFF(ENERGEST_TYPE_TRANSMIT); - ENERGEST_ON(ENERGEST_TYPE_LISTEN); + ENERGEST_SWITCH(ENERGEST_TYPE_TRANSMIT, ENERGEST_TYPE_LISTEN); return RADIO_TX_OK; From 888a04e70fe2eb0c513b018f70204ecfac2d0ffe Mon Sep 17 00:00:00 2001 From: Niclas Finne Date: Fri, 13 Oct 2017 00:05:31 +0200 Subject: [PATCH 5/6] energest: removed support for ENERGEST_CONF_LEVELDEVICE_LEVELS --- arch/dev/cc2420/cc2420.c | 3 --- os/sys/energest.c | 28 ---------------------------- os/sys/energest.h | 13 ------------- 3 files changed, 44 deletions(-) diff --git a/arch/dev/cc2420/cc2420.c b/arch/dev/cc2420/cc2420.c index 89aee6b75..a9f56d8a9 100644 --- a/arch/dev/cc2420/cc2420.c +++ b/arch/dev/cc2420/cc2420.c @@ -695,9 +695,6 @@ cc2420_transmit(unsigned short payload_len) accurate measurement of the transmission time.*/ wait_for_transmission(); -#ifdef ENERGEST_CONF_LEVELDEVICE_LEVELS - ENERGEST_OFF_LEVEL(ENERGEST_TYPE_TRANSMIT,cc2420_get_txpower()); -#endif ENERGEST_OFF(ENERGEST_TYPE_TRANSMIT); if(receive_on) { ENERGEST_ON(ENERGEST_TYPE_LISTEN); diff --git a/os/sys/energest.c b/os/sys/energest.c index 925c9500c..391781bd7 100644 --- a/os/sys/energest.c +++ b/os/sys/energest.c @@ -45,9 +45,6 @@ int energest_total_count; energest_t energest_total_time[ENERGEST_TYPE_MAX]; rtimer_clock_t energest_current_time[ENERGEST_TYPE_MAX]; -#ifdef ENERGEST_CONF_LEVELDEVICE_LEVELS -energest_t energest_leveldevice_current_leveltime[ENERGEST_CONF_LEVELDEVICE_LEVELS]; -#endif unsigned char energest_current_mode[ENERGEST_TYPE_MAX]; /*---------------------------------------------------------------------------*/ @@ -59,45 +56,20 @@ energest_init(void) energest_total_time[i].current = energest_current_time[i] = 0; energest_current_mode[i] = 0; } -#ifdef ENERGEST_CONF_LEVELDEVICE_LEVELS - for(i = 0; i < ENERGEST_CONF_LEVELDEVICE_LEVELS; ++i) { - energest_leveldevice_current_leveltime[i].current = 0; - } -#endif } /*---------------------------------------------------------------------------*/ unsigned long energest_type_time(int type) { - /* Note: does not support ENERGEST_CONF_LEVELDEVICE_LEVELS! */ -#ifndef ENERGEST_CONF_LEVELDEVICE_LEVELS - if(energest_current_mode[type]) { - rtimer_clock_t now = RTIMER_NOW(); - energest_total_time[type].current += (rtimer_clock_t) - (now - energest_current_time[type]); - energest_current_time[type] = now; - } -#endif /* ENERGEST_CONF_LEVELDEVICE_LEVELS */ return energest_total_time[type].current; } /*---------------------------------------------------------------------------*/ -unsigned long -energest_leveldevice_leveltime(int powerlevel) -{ -#ifdef ENERGEST_CONF_LEVELDEVICE_LEVELS - return energest_leveldevice_current_leveltime[powerlevel].current; -#else - return 0; -#endif -} -/*---------------------------------------------------------------------------*/ void energest_type_set(int type, unsigned long val) { energest_total_time[type].current = val; } /*---------------------------------------------------------------------------*/ -/* Note: does not support ENERGEST_CONF_LEVELDEVICE_LEVELS! */ void energest_flush(void) { diff --git a/os/sys/energest.h b/os/sys/energest.h index 635779d55..9bda6efc5 100644 --- a/os/sys/energest.h +++ b/os/sys/energest.h @@ -63,9 +63,6 @@ enum energest_type { void energest_init(void); unsigned long energest_type_time(int type); -#ifdef ENERGEST_CONF_LEVELDEVICE_LEVELS -unsigned long energest_leveldevice_leveltime(int powerlevel); -#endif void energest_type_set(int type, unsigned long value); void energest_flush(void); @@ -75,10 +72,6 @@ extern energest_t energest_total_time[ENERGEST_TYPE_MAX]; extern rtimer_clock_t energest_current_time[ENERGEST_TYPE_MAX]; extern unsigned char energest_current_mode[ENERGEST_TYPE_MAX]; -#ifdef ENERGEST_CONF_LEVELDEVICE_LEVELS -extern energest_t energest_leveldevice_current_leveltime[ENERGEST_CONF_LEVELDEVICE_LEVELS]; -#endif - #define ENERGEST_ON(type) do { \ /*++energest_total_count;*/ \ energest_current_time[type] = RTIMER_NOW(); \ @@ -91,11 +84,6 @@ extern energest_t energest_leveldevice_current_leveltime[ENERGEST_CONF_LEVELDEVI energest_current_mode[type] = 0; \ } while(0) -#define ENERGEST_OFF_LEVEL(type,level) do { \ - energest_leveldevice_current_leveltime[level].current += (rtimer_clock_t)(RTIMER_NOW() - \ - energest_current_time[type]); \ - energest_current_mode[type] = 0; \ - } while(0) #define ENERGEST_SWITCH(type_off, type_on) do { \ rtimer_clock_t energest_local_variable_now = RTIMER_NOW(); \ @@ -111,7 +99,6 @@ extern energest_t energest_leveldevice_current_leveltime[ENERGEST_CONF_LEVELDEVI #else /* ENERGEST_CONF_ON */ #define ENERGEST_ON(type) do { } while(0) #define ENERGEST_OFF(type) do { } while(0) -#define ENERGEST_OFF_LEVEL(type,level) do { } while(0) #define ENERGEST_SWITCH(type_off, type_on) do { } while(0) #endif /* ENERGEST_CONF_ON */ From 18b5f6d66761760dabfc5019574f67686e8c82a4 Mon Sep 17 00:00:00 2001 From: Niclas Finne Date: Fri, 13 Oct 2017 00:08:53 +0200 Subject: [PATCH 6/6] energest: made energest more configurable * energest time defaults to rtimer but can be configured via ENERGEST_CONF_CURRENT_TIME and ENERGEST_CONF_SECOND. * Additional energest types can be added by platform and application using ENERGEST_CONF_PLATFORM_ADDITIONS and ENERGEST_CONF_ADDITIONS. * Energest times are now 64 bit and thereby non-wrapping in most systems. * Removed unused energest types for serial and sensors. --- arch/cpu/msp430/f1xxx/clock.c | 2 - arch/cpu/msp430/f5xxx/clock.c | 2 - os/sys/compower.c | 4 +- os/sys/compower.h | 2 +- os/sys/energest.c | 39 +++++----- os/sys/energest.h | 130 +++++++++++++++++++++++++--------- 6 files changed, 114 insertions(+), 65 deletions(-) diff --git a/arch/cpu/msp430/f1xxx/clock.c b/arch/cpu/msp430/f1xxx/clock.c index d372dc4e4..74832da0d 100644 --- a/arch/cpu/msp430/f1xxx/clock.c +++ b/arch/cpu/msp430/f1xxx/clock.c @@ -30,7 +30,6 @@ */ #include "contiki.h" -#include "sys/energest.h" #include "sys/clock.h" #include "sys/etimer.h" #include "rtimer-arch.h" @@ -87,7 +86,6 @@ ISR(TIMERA1, timera1) #endif if(count % CLOCK_CONF_SECOND == 0) { ++seconds; - energest_flush(); } last_tar = read_tar(); } diff --git a/arch/cpu/msp430/f5xxx/clock.c b/arch/cpu/msp430/f5xxx/clock.c index e61aec1e9..74560bc35 100644 --- a/arch/cpu/msp430/f5xxx/clock.c +++ b/arch/cpu/msp430/f5xxx/clock.c @@ -30,7 +30,6 @@ */ #include "contiki.h" -#include "sys/energest.h" #include "sys/clock.h" #include "sys/etimer.h" #include "rtimer-arch.h" @@ -87,7 +86,6 @@ ISR(TIMER1_A1, timera1) #endif if(count % CLOCK_CONF_SECOND == 0) { ++seconds; - energest_flush(); } last_tar = read_tar(); } diff --git a/os/sys/compower.c b/os/sys/compower.c index 206fab81d..7c13881ee 100644 --- a/os/sys/compower.c +++ b/os/sys/compower.c @@ -59,8 +59,8 @@ compower_init(void) void compower_accumulate(struct compower_activity *e) { - static uint32_t last_listen, last_transmit; - uint32_t listen, transmit; + static uint64_t last_listen, last_transmit; + uint64_t listen, transmit; energest_flush(); diff --git a/os/sys/compower.h b/os/sys/compower.h index d05c58f18..407e8b57e 100644 --- a/os/sys/compower.h +++ b/os/sys/compower.h @@ -62,7 +62,7 @@ * with no user-visible elements. */ struct compower_activity { - uint32_t listen, transmit; + uint64_t listen, transmit; }; /** diff --git a/os/sys/energest.c b/os/sys/energest.c index 391781bd7..b698f089d 100644 --- a/os/sys/energest.c +++ b/os/sys/energest.c @@ -42,9 +42,8 @@ #if ENERGEST_CONF_ON -int energest_total_count; -energest_t energest_total_time[ENERGEST_TYPE_MAX]; -rtimer_clock_t energest_current_time[ENERGEST_TYPE_MAX]; +uint64_t energest_total_time[ENERGEST_TYPE_MAX]; +uint64_t energest_current_time[ENERGEST_TYPE_MAX]; unsigned char energest_current_mode[ENERGEST_TYPE_MAX]; /*---------------------------------------------------------------------------*/ @@ -58,36 +57,30 @@ energest_init(void) } } /*---------------------------------------------------------------------------*/ -unsigned long -energest_type_time(int type) -{ - return energest_total_time[type].current; -} -/*---------------------------------------------------------------------------*/ -void -energest_type_set(int type, unsigned long val) -{ - energest_total_time[type].current = val; -} -/*---------------------------------------------------------------------------*/ void energest_flush(void) { - rtimer_clock_t now; + uint64_t now; int i; for(i = 0; i < ENERGEST_TYPE_MAX; i++) { if(energest_current_mode[i]) { - now = RTIMER_NOW(); - energest_total_time[i].current += (rtimer_clock_t) - (now - energest_current_time[i]); + now = ENERGEST_CURRENT_TIME(); + energest_total_time[i].current += now - energest_current_time[i]; energest_current_time[i] = now; } } } /*---------------------------------------------------------------------------*/ #else /* ENERGEST_CONF_ON */ -void energest_type_set(int type, unsigned long val) {} -void energest_init(void) {} -unsigned long energest_type_time(int type) { return 0; } -void energest_flush(void) {} + +void +energest_init(void) +{ +} + +void +energest_flush(void) +{ +} + #endif /* ENERGEST_CONF_ON */ diff --git a/os/sys/energest.h b/os/sys/energest.h index 9bda6efc5..f5f336d47 100644 --- a/os/sys/energest.h +++ b/os/sys/energest.h @@ -40,66 +40,126 @@ #ifndef ENERGEST_H_ #define ENERGEST_H_ -#include "sys/rtimer.h" +#include "contiki.h" -typedef struct { - /* unsigned long cumulative[2];*/ - unsigned long current; -} energest_t; +#ifndef ENERGEST_CURRENT_TIME +#ifdef ENERGEST_CONF_CURRENT_TIME +#define ENERGEST_CURRENT_TIME ENERGEST_CONF_CURRENT_TIME +#else +#define ENERGEST_CURRENT_TIME RTIMER_NOW +#define ENERGEST_SECOND RTIMER_SECOND +#endif /* ENERGEST_CONF_TIME */ +#endif /* ENERGEST_TIME */ -enum energest_type { +#ifndef ENERGEST_SECOND +#ifdef ENERGEST_CONF_SECOND +#define ENERGEST_SECOND ENERGEST_CONF_SECOND +#else /* ENERGEST_CONF_SECOND */ +#define ENERGEST_SECOND RTIMER_SECOND +#endif /* ENERGEST_CONF_SECOND */ +#endif /* ENERGEST_SECOND */ + +/* + * Optional support for more energest types. + * + * #define ENERGEST_CONF_PLATFORM_ADDITIONS TYPE_NAME1, TYPE_NAME2 + * + * #define ENERGEST_CONF_ADDITIONS TYPE_NAME3, TYPE_NAME4 + */ +typedef enum energest_type { ENERGEST_TYPE_CPU, ENERGEST_TYPE_LPM, ENERGEST_TYPE_TRANSMIT, ENERGEST_TYPE_LISTEN, +#ifdef ENERGEST_CONF_PLATFORM_ADDITIONS + ENERGEST_CONF_PLATFORM_ADDITIONS, +#endif /* ENERGEST_CONF_PLATFORM_ADDITIONS */ - ENERGEST_TYPE_SENSORS, - - ENERGEST_TYPE_SERIAL, +#ifdef ENERGEST_CONF_ADDITIONS + ENERGEST_CONF_ADDITIONS, +#endif /* ENERGEST_CONF_ADDITIONS */ ENERGEST_TYPE_MAX -}; +} energest_type_t; void energest_init(void); -unsigned long energest_type_time(int type); -void energest_type_set(int type, unsigned long value); void energest_flush(void); #if ENERGEST_CONF_ON -/*extern int energest_total_count;*/ -extern energest_t energest_total_time[ENERGEST_TYPE_MAX]; -extern rtimer_clock_t energest_current_time[ENERGEST_TYPE_MAX]; + +extern uint64_t energest_total_time[ENERGEST_TYPE_MAX]; +extern uint64_t energest_current_time[ENERGEST_TYPE_MAX]; extern unsigned char energest_current_mode[ENERGEST_TYPE_MAX]; -#define ENERGEST_ON(type) do { \ - /*++energest_total_count;*/ \ - energest_current_time[type] = RTIMER_NOW(); \ - energest_current_mode[type] = 1; \ - } while(0) +static inline uint64_t +energest_type_time(energest_type_t type) +{ + return energest_total_time[type]; +} -#define ENERGEST_OFF(type) if(energest_current_mode[type] != 0) do { \ - energest_total_time[type].current += (rtimer_clock_t)(RTIMER_NOW() - \ - energest_current_time[type]); \ - energest_current_mode[type] = 0; \ - } while(0) +static inline void +energest_type_set(energest_type_t type, uint64_t value) +{ + energest_total_time[type] = value; +} +static inline void +energest_on(energest_type_t type) +{ + if(energest_current_mode[type] == 0) { + energest_current_time[type] = ENERGEST_CURRENT_TIME(); + energest_current_mode[type] = 1; + } +} +#define ENERGEST_ON(type) energest_on(type) -#define ENERGEST_SWITCH(type_off, type_on) do { \ - rtimer_clock_t energest_local_variable_now = RTIMER_NOW(); \ - if(energest_current_mode[type_off] != 0) { \ - energest_total_time[type_off].current += (rtimer_clock_t)(energest_local_variable_now - \ - energest_current_time[type_off]); \ - energest_current_mode[type_off] = 0; \ - } \ - energest_current_time[type_on] = energest_local_variable_now; \ - energest_current_mode[type_on] = 1; \ - } while(0) +static inline void +energest_off(energest_type_t type) +{ + if(energest_current_mode[type] != 0) { + energest_total_time[type].current += + ENERGEST_CURRENT_TIME() - energest_current_time[type]; + energest_current_mode[type] = 0; + } +} +#define ENERGEST_OFF(type) energest_off(type) + +static inline void +energest_switch(energest_type_t type_off, energest_type_t type_on) +{ + uint64_t energest_local_variable_now = ENERGEST_CURRENT_TIME(); + if(energest_current_mode[type_off] != 0) { + energest_total_time[type_off].current += + energest_local_variable_now - energest_current_time[type_off]; + energest_current_mode[type_off] = 0; + } + if(energest_current_mode[type_on] == 0) { + energest_current_time[type_on] = energest_local_variable_now; + energest_current_mode[type_on] = 1; + } +} +#define ENERGEST_SWITCH(type_off, type_on) energest_switch(type_off, type_on) #else /* ENERGEST_CONF_ON */ + +static inline uint64_t energest_type_time(energest_type_t type) { return 0; } + +static inline void energest_type_set(energest_type_t type, uint64_t time) { } + +static inline void energest_on(energest_type_t type) { } + +static inline void energest_off(energest_type_t type) { } + +static inline void energest_switch(energest_type_t type_off, + energest_type_t type_on) +{ +} + #define ENERGEST_ON(type) do { } while(0) #define ENERGEST_OFF(type) do { } while(0) #define ENERGEST_SWITCH(type_off, type_on) do { } while(0) + #endif /* ENERGEST_CONF_ON */ #endif /* ENERGEST_H_ */