Esempio n. 1
0
int main(void) {
    // ==== Setup clock frequency ====
    uint8_t ClkResult = 1;
    Clk.SetupFlashLatency(64);  // Setup Flash Latency for clock in MHz
    Clk.EnablePrefetch();
    // 12 MHz/6 = 2; 2*192 = 384; 384/6 = 64 (preAHB divider); 384/8 = 48 (USB clock)
    Clk.SetupPLLDividers(6, 192, pllSysDiv6, 8);
    // 64/1 = 64 MHz core clock. APB1 & APB2 clock derive on AHB clock; APB1max = 42MHz, APB2max = 84MHz
    // Keep APB freq at 32 MHz to left peripheral settings untouched
    Clk.SetupBusDividers(ahbDiv1, apbDiv2, apbDiv2);
    if((ClkResult = Clk.SwitchToPLL()) == 0) Clk.HSIDisable();
    Clk.UpdateFreqValues();

    // Init OS
    halInit();
    chSysInit();

    // ==== Init hardware ====
    Uart.Init(115200, UART_GPIO, UART_TX_PIN, UART_GPIO, UART_RX_PIN);
    Uart.Printf("\r%S %S", APP_NAME, APP_VERSION);
    Clk.PrintFreqs();
    if(ClkResult != 0) Uart.Printf("\rXTAL failure");

    App.InitThread();
    // Leds
    LedAux.Init();
    for(uint8_t i=0; i<4; i++) {
        Led[i].Init();
//        for(uint8_t j=0; j<250; j++) {
//            Led[i].Set(j);
//            chThdSleepMilliseconds(4);
//        }
//        Led[i].Set(0);
    }

    // Debug: init CS2 as output
    PinSetupOut(GPIOC, 13, omPushPull, pudNone);

    // ==== USB ====
    UsbAu.Init();
    UsbAu.Connect();

    Pcm.Init();

    // Main cycle
    App.ITask();
}
Esempio n. 2
0
int main(void) {
    // ==== Init Vcore & clock system ====
    SetupVCore(vcore1V5);
//    Clk.SetMSI4MHz();
    Clk.SetupFlashLatency(16);
    Clk.SwitchToHSI();
    Clk.UpdateFreqValues();

    // Init OS
    halInit();
    chSysInit();
    App.InitThread();

    // ==== Init hardware ====
    Uart.Init(115200, UART_GPIO, UART_TX_PIN);//, UART_GPIO, UART_RX_PIN);
    Uart.Printf("\r%S %S\r", APP_NAME , BUILD_TIME);
    Clk.PrintFreqs();

    Effects.Init();

    if(Radio.Init() == OK) {
//        Effects.AllTogetherSmoothly(clGreen, 45);
//        chEvtWaitAny(EVT_LEDS_DONE);
//        Effects.AllTogetherSmoothly(clBlack, 45);
//        chEvtWaitAny(EVT_LEDS_DONE);
    }
    else {
        Effects.AllTogetherNow(clRed);
        chThdSleepMilliseconds(180);
        Effects.AllTogetherNow(clBlack);
        chThdSleepMilliseconds(180);
        Effects.AllTogetherNow(clRed);
        chThdSleepMilliseconds(180);
        Effects.AllTogetherNow(clBlack);
        chThdSleepMilliseconds(180);
        Effects.AllTogetherNow(clRed);
        chThdSleepMilliseconds(180);
        Effects.AllTogetherNow(clBlack);
    }

//    Effects.ChunkRunningRandom(clGreen, 2, 180);
    Effects.ChunkRunningRandom(clYellow, 2, 0);

    // Main cycle
    App.ITask();
}
Esempio n. 3
0
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();
}