Skip to content
Snippets Groups Projects
Select Git revision
  • a124a36d0cf83390f6328ac1a8a46006d98bd1d6
  • master default protected
  • Stormwind
  • patch-1
  • schneider/bsec
  • dx/meh-bdf-to-stm
  • dx/somewhat-more-dynamic-config
  • rahix/proper-sleep
  • dx/flatten-config-module
  • genofire/ble-follow-py
  • schneider/ble-stability
  • schneider/ble-stability-new-phy
  • add_menu_vibration
  • plaetzchen/ios-workaround
  • blinkisync-as-preload
  • schneider/max30001-pycardium
  • schneider/max30001-epicaridum
  • schneider/max30001
  • schneider/stream-locks
  • schneider/fundamental-test
  • schneider/ble-buffers
  • 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
37 results

hardware.c

Blame
  • Forked from card10 / firmware
    Source project has a limited visibility.
    hardware.c 5.29 KiB
    #include "epicardium.h"
    
    #include "api/dispatcher.h"
    #include "api/interrupt-sender.h"
    #include "usb/epc_usb.h"
    #include "modules/filesystem.h"
    #include "modules/log.h"
    #include "modules/modules.h"
    #include "modules/stream.h"
    
    #include "card10.h"
    #include "display.h"
    #include "leds.h"
    #include "pb.h"
    #include "pmic.h"
    #include "portexpander.h"
    
    #include "gpio.h"
    #include "i2c.h"
    #include "rtc.h"
    #include "spi.h"
    #include "trng.h"
    #include "wdt.h"
    
    /*
     * Early init is called at the very beginning and is meant for modules which
     * absolutely need to start as soon as possible.  hardware_early_init() blocks
     * which means code in here should be fast.
     */
    int hardware_early_init(void)
    {
    	/*
    	 * Watchdog timer
    	 */
    	watchdog_init();
    
    	/*
    	 * I2C bus for onboard peripherals (ie. PMIC, BMA400, BHI160, BME680,
    	 * ...)
    	 */
    	I2C_Shutdown(MXC_I2C1_BUS0);
    	I2C_Init(MXC_I2C1_BUS0, I2C_FAST_MODE, NULL);
    
    #ifndef CARD10_DEBUG_CORE1
    	/*
    	 * SAO I2C bus
    	 */
    	I2C_Shutdown(MXC_I2C0_BUS0);
    	I2C_Init(MXC_I2C0_BUS0, I2C_FAST_MODE, NULL);
    #endif
    
    	/*
    	 * GPIO peripheral.
    	 */
    	GPIO_Init();
    
    	/* Set the power hold pin, so the PMIC does not turn off again */
    	const gpio_cfg_t pwr_hold_pin = {
    		PORT_0, PIN_30, GPIO_FUNC_OUT, GPIO_PAD_NONE
    	};
    	GPIO_Config(&pwr_hold_pin);
    	GPIO_OutSet(&pwr_hold_pin);
    
    	/*
    	 * PMIC (MAX77650)
    	 */
    	pmic_init();
    	pmic_set_led(0, 0);
    	pmic_set_led(1, 0);
    	pmic_set_led(2, 0);