Commit 7039ad0a authored by Projects's avatar Projects

EM2 enabled.

parent c5c435e9
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
#include <em_gpio.h> #include <em_gpio.h>
#include <em_timer.h> #include <em_timer.h>
#include "sleep.h"
static int backlight_level; static int backlight_level;
void backlight_init(void) void backlight_init(void)
...@@ -101,10 +103,13 @@ void backlight_set_level(int level) ...@@ -101,10 +103,13 @@ void backlight_set_level(int level)
if(level <= 0) { if(level <= 0) {
TIMER_Enable(TIMER1, false); TIMER_Enable(TIMER1, false);
level = 0; // in case level is negative level = 0; // in case level is negative
SLEEP_SleepBlockEnd(sleepEM2);
} else { } else {
// Reenable the timer, if it was turned off previously // Reenable the timer, if it was turned off previously
if(backlight_level == 0) if(backlight_level == 0) {
SLEEP_SleepBlockBegin(sleepEM2);
TIMER_Enable(TIMER1, true); TIMER_Enable(TIMER1, true);
}
if(level > BL_MAX_LEVEL) if(level > BL_MAX_LEVEL)
level = BL_MAX_LEVEL; level = BL_MAX_LEVEL;
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <em_cmu.h> #include <em_cmu.h>
#include <em_gpio.h> #include <em_gpio.h>
#include <em_timer.h> #include <em_timer.h>
#include <sleep.h>
void buzzer_init(void) void buzzer_init(void)
{ {
...@@ -82,12 +83,14 @@ void buzzer_init(void) ...@@ -82,12 +83,14 @@ void buzzer_init(void)
void buzzer_enable(void) void buzzer_enable(void)
{ {
SLEEP_SleepBlockBegin(sleepEM2);
TIMER_Enable(TIMER2, true); TIMER_Enable(TIMER2, true);
} }
void buzzer_disable(void) void buzzer_disable(void)
{ {
TIMER_Enable(TIMER2, false); TIMER_Enable(TIMER2, false);
SLEEP_SleepBlockEnd(sleepEM2);
} }
void buzzer_set_freq(int frequency) void buzzer_set_freq(int frequency)
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "em_ebi.h" #include "em_ebi.h"
#include "em_cmu.h" #include "em_cmu.h"
#include "em_usart.h" #include "em_usart.h"
#include "sleep.h"
#include "dmactrl.h" #include "dmactrl.h"
#include "lcd.h" #include "lcd.h"
#include "lcd_dma.h" #include "lcd_dma.h"
...@@ -62,6 +63,7 @@ static void lcd_dma_tx_complete(unsigned int channel, bool primary, void *user) ...@@ -62,6 +63,7 @@ static void lcd_dma_tx_complete(unsigned int channel, bool primary, void *user)
dma_transfer_active = false; dma_transfer_active = false;
#ifdef FREERTOS #ifdef FREERTOS
SLEEP_SleepBlockEnd(sleepEM2);
xSemaphoreGive(lcd_sem); xSemaphoreGive(lcd_sem);
#endif /* FREERTOS */ #endif /* FREERTOS */
} }
...@@ -126,6 +128,7 @@ void lcd_dma_send_frame(void) ...@@ -126,6 +128,7 @@ void lcd_dma_send_frame(void)
#endif /* else FREERTOS */ #endif /* else FREERTOS */
dma_transfer_active = true; dma_transfer_active = true;
SLEEP_SleepBlockBegin(sleepEM2);
DMA_ActivateScatterGather(DMA_CHANNEL, true, dma_cfg_block, DMA_TRANSFERS); DMA_ActivateScatterGather(DMA_CHANNEL, true, dma_cfg_block, DMA_TRANSFERS);
// semaphore is given back in the DMA transfer finished interrupt // semaphore is given back in the DMA transfer finished interrupt
......
...@@ -464,7 +464,7 @@ bool EE_Init(uint32_t numberOfPages) ...@@ -464,7 +464,7 @@ bool EE_Init(uint32_t numberOfPages)
else else
{ {
/* Transfer variables from active to receiving page. */ /* Transfer variables from active to receiving page. */
EE_TransferPage(NULL, NULL); EE_TransferPage(NULL, 0);
} }
/* Initialization completed successfully */ /* Initialization completed successfully */
......
...@@ -89,7 +89,7 @@ extern "C" { ...@@ -89,7 +89,7 @@ extern "C" {
/* Available options when configUSE_TICKLESS_IDLE set to 1 /* Available options when configUSE_TICKLESS_IDLE set to 1
* or configUSE_SLEEP_MODE_IN_IDLE set to 1 : * or configUSE_SLEEP_MODE_IN_IDLE set to 1 :
* 1 - EM1, 2 - EM2, 3 - EM3, timer in EM3 is not very accurate*/ * 1 - EM1, 2 - EM2, 3 - EM3, timer in EM3 is not very accurate*/
#define configSLEEP_MODE ( 1 ) #define configSLEEP_MODE ( 2 )
/* Definition used only if configUSE_TICKLESS_IDLE == 0 */ /* Definition used only if configUSE_TICKLESS_IDLE == 0 */
#define configUSE_SLEEP_MODE_IN_IDLE ( 1 ) #define configUSE_SLEEP_MODE_IN_IDLE ( 1 )
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include "blight_task.h" #include "blight_task.h"
///> Number of ticks when the watch is considered active since active_reset() ///> Number of ticks when the watch is considered active since active_reset()
#define ACTIVE_STATE_TICKS 10000 #define ACTIVE_STATE_TICKS (10000 / portTICK_RATE_MS)
enum watch_state current_state = IDLE; enum watch_state current_state = IDLE;
static xTimerHandle timer_handle; static xTimerHandle timer_handle;
...@@ -87,7 +87,6 @@ static void state_handler(enum watch_state state) ...@@ -87,7 +87,6 @@ static void state_handler(enum watch_state state)
case IDLE: case IDLE:
auto_backlight_enable(false); auto_backlight_enable(false);
backlight_set_level(0); backlight_set_level(0);
// TODO switch frequency? goto sleep?
break; break;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment