int main() { // ==== Setup clock ==== Clk.UpdateFreqValues(); uint8_t ClkResult = FAILURE; Clk.SetupFlashLatency(12); // Setup Flash Latency for clock in MHz // 12 MHz/6 = 2; 2*192 = 384; 384/8 = 48 (preAHB divider); 384/8 = 48 (USB clock) Clk.SetupPLLDividers(6, 192, pllSysDiv8, 8); // 48/4 = 12 MHz core clock. APB1 & APB2 clock derive on AHB clock Clk.SetupBusDividers(ahbDiv4, apbDiv1, apbDiv1); if((ClkResult = Clk.SwitchToPLL()) == 0) Clk.HSIDisable(); Clk.UpdateFreqValues(); // ==== Init OS ==== halInit(); chSysInit(); // ==== Init Hard & Soft ==== App.PThd = chThdSelf(); Uart.Init(115200); Uart.Printf("\rLockNFC3 F205 AHB freq=%uMHz", Clk.AHBFreqHz/1000000); // Report problem with clock if any if(ClkResult) Uart.Printf("Clock failure\r"); LedService.Init(); LedService.StartSequence(lsqBlinkGreenX2); Led.Init(); Led.StartSequence(lsqDoorClose); Sensors.Init(); Pn.Init(); SD.Init(); // SD-card init App.IDStore.Load(); // Init Srorage of IDs SndList.Init(); App.ReadConfig(); // Read config from SD-card Sound.Init(); Sound.SetVolume(250); Sound.RegisterAppThd(chThdSelf()); Sound.Play("alive.wav"); #if USB_ENABLED MassStorage.Init(); // Init USB MassStorage device #endif // ==== Main cycle ==== App.ITask(); }
int main(void) { // ==== Init Vcore & clock system ==== SetupVCore(vcore1V5); Clk.UpdateFreqValues(); // ==== Init OS ==== halInit(); chSysInit(); // ==== Init Hard & Soft ==== Uart.Init(115200); Uart.Printf("\rLocket AHB=%u", Clk.AHBFreqHz); App.InitThread(); // App.LoadSettings(); // PinSensors.Init(); // Beeper.Init(); // Beeper.StartSequence(bsqBeepBeep); Led.Init(); Led.StartSequence(lsqStart); // Vibro.Init(); // Vibro.StartSequence(vsqBrrBrr); // PinSetupOut(GPIOB, 8, omPushPull, pudNone); // PinClear(GPIOB, 8); // PwmPin_t IPin; // IPin.Init(GPIOB, 8, TIM4, 3, 22); // IPin.SetFreqHz(450); // IPin.Set(11); // Radio.Init(); // Main cycle App.ITask(); }