refactor tree, add ecad, mcad

This commit is contained in:
2019-08-28 23:23:48 -07:00
parent d5ddd76bef
commit ae837eef12
45 changed files with 4629 additions and 169 deletions

View File

@@ -28,7 +28,8 @@
#include "Application/ButtonManager.h"
#include "Application/ScreenManager.h"
#include "Application/Screens/DisplayTimeScreen.h"
#include "Application/Screens/AnalogTimeScreen.h"
#include "Application/Screens/BigDigitalTimeScreen.h"
#include "Application/Screens/DebugScreen.h"
#include "Application/Screens/MenuScreen.h"
#include "Application/Screens/SetTimeScreen.h"
@@ -39,13 +40,13 @@
// TODO: Don't include this here.
#include "stm32l0xx.h"
using Common::Time;
using BSP::Time;
static Common::Schedule::LowPowerTaskScheduler<5> g_sched;
static BSP::Schedule::LowPowerTaskScheduler<5> g_sched;
static BSP::SpiDriver g_spi(g_sched);
static BSP::DisplayDriver g_display(g_sched, g_spi);
static BSP::LptimPwm g_lptim_pwm(LPTIM1);
static BSP::ButtonManager g_btn_manager(g_sched, 2, 1, 0, Time::millis(1));
static BSP::ButtonManager g_btn_manager(g_sched, 0, 1, 2, Time::millis(1));
static ScreenManager g_screen_manager(g_sched, g_display, g_btn_manager);
static SetTimeScreen g_set_time_screen(g_display, g_screen_manager);
@@ -72,7 +73,7 @@ static MenuScreen g_main_menu_screen(g_display,
std::initializer_list<MenuScreenItem>({MenuScreenItem("Apps", g_settings_menu_screen),
MenuScreenItem("Settings", g_settings_menu_screen)}));
static DisplayTimeScreen g_display_time_screen(g_display, g_screen_manager, g_main_menu_screen);
static AnalogTimeScreen g_display_time_screen(g_display, g_screen_manager, g_main_menu_screen);
extern "C" void __cxa_pure_virtual() { while(1) {} }
@@ -121,7 +122,45 @@ void SystemInit()
/*!< Reset HSEBYP bit (disable HSE bypass) */
CLR(RCC->CR,
RCC_CR_HSEBYP);
RCC_CR_HSEBYP)
;
/* (1) Test if PLL is used as System clock */
/* (2) Select HSI as system clock */
/* (3) Wait for HSI switched */
/* (4) Disable the PLL */
/* (5) Wait until PLLRDY is cleared */
/* (6) Set latency to 1 wait state */
/* (7) Set the PLL multiplier to 24 and divider by 3 */
/* (8) Enable the PLL */
/* (9) Wait until PLLRDY is set */
/* (10) Select PLL as system clock */
/* (11) Wait until the PLL is switched on */
// SET(RCC->CR, RCC_CR_HSION);
// while((RCC->CR & RCC_CR_HSIRDY) != 0) {}
// if ((RCC->CFGR & RCC_CFGR_SWS) == RCC_CFGR_SWS_PLL) /* (1) */
// {
// RCC->CFGR = (RCC->CFGR & (uint32_t) (~RCC_CFGR_SW)) | RCC_CFGR_SW_HSI; /* (2) */
// while ((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_HSI) /* (3) */
// { /* For robust implementation, add here time-out management */ }
// }
// RCC->CR &= (uint32_t)(~RCC_CR_PLLON);/* (4) */
// while((RCC->CR & RCC_CR_PLLRDY) != 0) /* (5) */
// { /* For robust implementation, add here time-out management */ }
// FLASH->ACR |= FLASH_ACR_LATENCY; /* (6) */
// RCC->CFGR = RCC->CFGR & ((~(RCC_CFGR_PLLMUL| RCC_CFGR_PLLDIV )) | (RCC_CFGR_PLLMUL24 | RCC_CFGR_PLLDIV2)); /* (7) */
// RCC->CR |= RCC_CR_PLLON; /* (8) */
// while ((RCC->CR & RCC_CR_PLLRDY) == 0) /* (9) */
// { /* For robust implementation, add here time-out management */ }
// RCC->CFGR |= (uint32_t) (RCC_CFGR_SW_PLL); /* (10) */
// while ((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_PLL) /* (11) */
// { /* For robust implementation, add here time-out management */ }
/*!< Reset
* PLLSRC (HSI16 is the PLL source),
@@ -129,7 +168,7 @@ void SystemInit()
* Don't touch PLLDIV[1:0], since 0 is undefined
*/
CLR(RCC->CFGR,
RCC_CFGR_PLLSRC | RCC_CFGR_PLLMUL | RCC_CFGR_PLLDIV);
RCC_CFGR_PLLSRC | RCC_CFGR_PLLMUL | RCC_CFGR_PLLDIV);
/*!< Disable all interrupts */
RCC->CIER = 0x00000000;
@@ -170,7 +209,7 @@ static void _init(void)
g_screen_manager.set_root_screen(g_display_time_screen);
// Enqueue each of the tasks
Common::Schedule::NextTime asap = Common::Schedule::NextTime::asap();
BSP::Schedule::NextTime asap = BSP::Schedule::NextTime::asap();
g_sched.add_task(g_spi, asap);
g_sched.add_task(g_btn_manager, asap);
g_sched.add_task(g_display, asap);