Skip to content
Snippets Groups Projects
Select Git revision
  • a907a06e437b0fc01f55c1229750b0931a0660d1
  • master default protected
  • card10_nickname_fix
  • genofire/ble-card10-timeread
  • schneider/fundamental-test
  • schneider/ble-buffers
  • ios-workarounds
  • schneider/maxim-sdk-update
  • rahix/simple_menu
  • ch3/splashscreen
  • koalo/bhi160-works-but-dirty
  • koalo/wip/i2c-for-python
  • renze/safe_mode
  • renze/hatchery_apps
  • koalo/factory-reset
  • msgctl/gfx_rle
  • msgctl/faultscreen
  • msgctl/textbuffer_api
  • schneider/bonding
  • schneider/bootloader-update-9a0d158
  • schneider/bsec
  • v1.5
  • v1.4
  • v1.3
  • v1.2
  • v1.1
  • v1.0
  • release-1
  • bootloader-v1
  • v0.0
30 results

bhi160.py

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();
            while(1);
        }
        ICC_Enable();
    
        printf("Done.\n");
        Paint_DrawString_EN(0, 16*1, "Done.", &Font16, 0x0000, 0xffff);
        Paint_DrawString_EN(0, 16*2, "Please restart", &Font16, 0x0000, 0xffff);
        LCD_Update();
    
        while (1) {
            card10_poll();
        }
    }