Skip to content
Snippets Groups Projects
Select Git revision
  • 5bf96e93fa6c5a5f2272b3c41ea1aef94e933cbc
  • ctx default
  • master protected
  • rahix/bhi160-cleanup
  • schneider/ble-hid
  • schneider/bsec
  • schneider/212-reset-hardware-when-entering-repl
  • schneider/exnostat-remove-gapple
  • schneider/g-watch
  • schneider/ble-time
  • schneider/bonding-fail-if-full
  • schneider/bonding-naming
  • schneider/rng-btle
  • schneider/trng-enable-fix
  • schneider/sdk-0.2.1-12
  • schneider/ble-critical-section
  • schneider/covid-tracing
  • schneider/ble-fixes-2020-3
  • schneider/spo2-playground
  • schneider/mpy-portstate
  • schneider/fix-ble-mac-write
  • v1.15
  • v1.14
  • v1.13
  • v1.12
  • v1.11
  • v1.10
  • v1.9
  • v1.8
  • v1.7
  • v1.6
  • v1.5
  • v1.4
  • v1.3
  • v1.2
  • v1.1
  • v1.0
  • release-1
  • bootloader-v1
  • v0.0
40 results

main.c

Blame
  • Forked from card10 / firmware
    Source project has a limited visibility.
    main.c 1.93 KiB
    /*******************************************************************************
     * License: TBD
     ******************************************************************************/
    
    /***** Includes *****/
    #include "card10.h"
    #include "bootloader-9a0d158.h"
    #include "display.h"
    #include "GUI_Paint.h"
    #include "pmic.h"
    
    
    #include "flc.h"
    #include "icc.h"
    #include "tmr_utils.h"
    
    #include <stdio.h>
    #include <stdint.h>
    #include <string.h>
    #include <stdbool.h>
    
    /***** Definitions *****/
    
    /***** Globals *****/
    static void pmic_button(bool falling)
    {
    	if (falling) {
    		printf("Resetting ...\n");
    		/*
    		 * Give the UART fifo time to clear.
    		 * TODO: Do this properly
    		 */
    		for (int i = 0; i < 0x1000000; i++) {
    			__asm volatile("nop");
    		}
    		MXC_GCR->rstr0 = MXC_F_GCR_RSTR0_SYSTEM;
    	}
    }
    
    
    int main(void)
    {
    
        card10_init();
        pmic_set_button_callback(pmic_button);
    
        printf("Erasing bootloader.\n");
        Paint_DrawString_EN(0, 16*0, "Erasing bootloader", &Font16, 0x0000, 0xffff);
        LCD_Update();
    
        ICC_Disable();
    
        int ret = FLC_MultiPageErase(0x10000000, 0x10000000 + 1024*64-1);
        if(ret != E_NO_ERROR) {
            printf("FLC_MultiPageErase failed with %d\n", ret);
            Paint_DrawString_EN(0, 16*1, "Fail.", &Font16, 0x0000, 0xffff);
            LCD_Update();
            while(1);
        }
    
    
        printf("Writing bootloader.\n");
        Paint_DrawString_EN(0, 16*0, "Writing bootloader ", &Font16, 0x0000, 0xffff);
        LCD_Update();
    
        ret = FLC_Write(0x10000000, sizeof(bootloader_data), (uint32_t *)bootloader_data);
        if(ret != E_NO_ERROR) {
            printf("FLC_Write failed with %d\n", ret);
            Paint_DrawString_EN(0, 16*1, "Fail.", &Font16, 0x0000, 0xffff);
            LCD_Update();