Example #1
0
void Init() {
    PWR_Init();
    CLOCK_Init();
    UART_Initialize();
    printf("Start\n");
    Initialize_ButtonMatrix();
    SPIFlash_Init(); //This must come before LCD_Init() for 7e

    LCD_Init();
    CHAN_Init();

    SPITouch_Init();
    SOUND_Init();
    BACKLIGHT_Init();
    BACKLIGHT_Brightness(1);
    AUTODIMMER_Init();
    SPI_FlashBlockWriteEnable(1); //Enable writing to all banks of SPIFlash

    PPMin_TIM_Init();
#ifdef MODULAR
    //Force protocol to none to initialize RAM
    Model.protocol = PROTOCOL_NONE;
    PROTOCOL_Init(1);
#endif
#if HAS_RTC
    RTC_Init();        // Watchdog must be running in case something goes wrong (e.g no crystal)
#endif
}
Example #2
0
void PWR_Shutdown()
{
    printf("Shutdown\n");
    BACKLIGHT_Brightness(0);
    rcc_set_sysclk_source(RCC_CFGR_SW_SYSCLKSEL_HSICLK);
    rcc_wait_for_osc_ready(HSI);
    while(1) ;
}
Example #3
0
static const char *backlight_select_cb(guiObject_t *obj, int dir, void *data)
{
    (void)data;
    (void)obj;
    u8 changed;
    Transmitter.backlight = GUI_TextSelectHelper(Transmitter.backlight,
                                  MIN_BRIGHTNESS, 10, dir, 1, 1, &changed);
    if (changed)
        BACKLIGHT_Brightness(Transmitter.backlight);
    if (Transmitter.backlight == 0)
        return _tr("Off");
    sprintf(tempstring, "%d", Transmitter.backlight);
    return tempstring;
}
Example #4
0
int main() {
    PWR_Init();
    CLOCK_Init();
    UART_Initialize();
    if(PWR_CheckPowerSwitch()) PWR_Shutdown();
#if SPI_BOOTLOADER
    Initialize_ButtonMatrix();
    SPIFlash_Init(); //This must come before LCD_Init() for 7e
    SPI_FlashBlockWriteEnable(1); //Enable writing to all banks of SPIFlash
    LCD_Init();
    LCD_Clear(0x0000);
    BACKLIGHT_Init();
    BACKLIGHT_Brightness(5);
    LCD_SetFont(0);
    LCD_SetFontColor(0xffff);
    dump_bootloader(0);
#else
    dump_bootloader(1);
#endif
}
Example #5
0
int main() {

    Init();
#ifndef MODULAR
    //Banner();
#endif
    if(PWR_CheckPowerSwitch()) PWR_Shutdown();

    LCD_Clear(0x0000);
#ifdef TEST_ADC
    ADC_ScanChannels(); while(1);
#endif
    u32 buttons = ScanButtons();
    if(CHAN_ButtonIsPressed(buttons, BUT_ENTER) || !FS_Mount(NULL, NULL)) {
        LCD_DrawUSBLogo(LCD_WIDTH, LCD_HEIGHT);
        USB_Connect();
        LCD_Clear(0x0000);
        FS_Mount(NULL, NULL);
    }

    CONFIG_LoadTx();
    SPI_ProtoInit();
    CONFIG_ReadDisplay();
    CONFIG_ReadModel(CONFIG_GetCurrentModel());
    CONFIG_ReadLang(Transmitter.language);

    BACKLIGHT_Brightness(Transmitter.backlight);
    LCD_Contrast(Transmitter.contrast);
    LCD_SetFont(DEFAULT_FONT.font);
    LCD_SetFontColor(DEFAULT_FONT.font_color);

#if !HAS_EXTENDED_AUDIO
    // If Extended Audio is present, move startup msg to Splash page to allow additional audio hardware initialization time
    MUSIC_Play(MUSIC_STARTUP);
#else
    if (Transmitter.splash_delay < 5)
        MUSIC_Play(MUSIC_STARTUP); // if no splash page startup msg is used force playing here
#endif
    GUI_HandleButtons(1);

    MIXER_Init();
    PAGE_Init();

    CLOCK_StartWatchdog();

#if HAS_DATALOG
    DATALOG_Init();
#endif

    priority_ready = 0;
    CLOCK_SetMsecCallback(LOW_PRIORITY, LOW_PRIORITY_MSEC);
    CLOCK_SetMsecCallback(MEDIUM_PRIORITY, MEDIUM_PRIORITY_MSEC);

    // We need to wait until we've actually measured the ADC before proceeding
    while(! (priority_ready & (1 << LOW_PRIORITY)))
        ;

    //Only do this after we've initialized all channel data so the saftey works
    PROTOCOL_InitModules();
    GUI_DrawScreen();

#ifdef HAS_EVENT_LOOP
    start_event_loop();
#else
    while(1) {
        if(priority_ready) {
            EventLoop();
        }
        //This does not appear to have any impact on power
        //and has been disabled in common/devo/power.c
        //but it helps a huge amount for the emulator
        PWR_Sleep();
    }
#endif
}
Example #6
0
int main() {
    
    Init();
#ifndef MODULAR
    //Banner();
#endif
    if(PWR_CheckPowerSwitch()) PWR_Shutdown();

    LCD_Clear(0x0000);
#ifdef TEST_ADC
    ADC_ScanChannels(); while(1);
#endif
    u32 buttons = ScanButtons();
    if(CHAN_ButtonIsPressed(buttons, BUT_ENTER) || !FS_Mount(NULL, NULL)) {
        LCD_DrawUSBLogo(LCD_WIDTH, LCD_HEIGHT);
        USB_Connect();
        LCD_Clear(0x0000);
        FS_Mount(NULL, NULL);
    }
    
    CONFIG_LoadTx();
    SPI_ProtoInit();
    CONFIG_ReadDisplay();
    CONFIG_ReadModel(CONFIG_GetCurrentModel());
    CONFIG_ReadLang(Transmitter.language);

    BACKLIGHT_Brightness(Transmitter.brightness);
    LCD_Contrast(Transmitter.contrast);
    LCD_SetFont(DEFAULT_FONT.font);
    LCD_SetFontColor(DEFAULT_FONT.font_color);

    MUSIC_Play(MUSIC_STARTUP);
    GUI_HandleButtons(1);

    MIXER_Init();
    PAGE_Init();
    
    CLOCK_StartWatchdog();

#if DATALOG_ENABLED
    DATALOG_Init();
#endif

    priority_ready = 0;
    CLOCK_SetMsecCallback(LOW_PRIORITY, LOW_PRIORITY_MSEC);
    CLOCK_SetMsecCallback(MEDIUM_PRIORITY, MEDIUM_PRIORITY_MSEC);

    // We need to wait until we've actually measured the ADC before proceeding
    while(! (priority_ready & (1 << LOW_PRIORITY)))
        ;

    //Only do this after we've initialized all channel data so the saftey works
    PROTOCOL_Init(0);
    GUI_DrawScreen();

#ifdef HAS_EVENT_LOOP
    start_event_loop();
#else
    while(1) {
        if(priority_ready) {
            EventLoop();
        }
        //PWR_Sleep();  //This does not appear to have any impact on power
    }
#endif
}
Example #7
0
int main() {

    Init();
#ifndef ENABLE_MODULAR
    //Banner();
#endif
    if(PWR_CheckPowerSwitch()) PWR_Shutdown();

    LCD_Clear(0x0000);
#ifdef TEST_ADC
    ADC_ScanChannels(); while(1);
#endif
    u32 buttons = ScanButtons();
    if (CHAN_ButtonIsPressed(buttons, BUT_ENTER) || !FS_Init()) {
        LCD_DrawUSBLogo(LCD_WIDTH, LCD_HEIGHT);
        USB_Connect();
        LCD_Clear(0x0000);
        FS_Init();
    }

    CONFIG_LoadTx();
    SPI_ProtoInit();
    CONFIG_ReadDisplay();
    CONFIG_ReadModel(CONFIG_GetCurrentModel());
    CONFIG_ReadLang(Transmitter.language);

    BACKLIGHT_Brightness(Transmitter.backlight);
    LCD_Contrast(Transmitter.contrast);
    LCD_SetFont(DEFAULT_FONT.font);
    LCD_SetFontColor(DEFAULT_FONT.font_color);

    GUI_HandleButtons(1);

    MIXER_Init();
    PAGE_Init();

    CLOCK_StartWatchdog();

#if HAS_DATALOG
    DATALOG_Init();
#endif

    priority_ready = 0;
    CLOCK_SetMsecCallback(LOW_PRIORITY, LOW_PRIORITY_MSEC);
    CLOCK_SetMsecCallback(MEDIUM_PRIORITY, MEDIUM_PRIORITY_MSEC);

    // We need to wait until we've actually measured the ADC before proceeding
    while(! (priority_ready & (1 << LOW_PRIORITY)))
        PWR_Sleep();

    //Only do this after we've initialized all channel data so the saftey works
    PROTOCOL_InitModules();
    GUI_DrawScreen();

    // Add startup delay to make sure audio player is initialized
    // AUDIO_Init() has already been called by CONFIG_ReadModel()
#if HAS_EXTENDED_AUDIO
    audio_queue_time = CLOCK_getms() + 1500;
    num_audio=1;
    next_audio=1;
#if (LCD_WIDTH == 480) || (LCD_WIDTH == 320)
    if(Display.background.drawn_background)
        while(CLOCK_getms() < audio_queue_time - 1200);
#endif
    AUDIO_SetVolume(); // Initial setting of voice volume
#endif

    MUSIC_Play(MUSIC_STARTUP);

#ifdef HAS_EVENT_LOOP
    start_event_loop();
#else
    while(1) {
        if(priority_ready) {
            EventLoop();
        }
        //This does not appear to have any impact on power
        //and has been disabled in common/devo/power.c
        //but it helps a huge amount for the emulator
        PWR_Sleep();
    }
#endif
}