Skip to content
Snippets Groups Projects
Select Git revision
  • 4d7be7df9d41f769a4c783604dc15d88c7dcddaa
  • master default protected
  • add-utime-unix_time-expansion
  • add-monotonic-time
  • add-digiclk
  • genofire/rockets-state
  • genofire/ble-follow-py
  • plaetzchen/ios-workaround
  • blinkisync-as-preload
  • genofire/haule-ble-fs-deactive
  • schneider/max30001-pycardium
  • schneider/max30001-epicaridum
  • schneider/max30001
  • schneider/stream-locks
  • schneider/fundamental-test
  • schneider/ble-buffers
  • schneider/maxim-sdk-update
  • ch3/splashscreen
  • koalo/bhi160-works-but-dirty
  • koalo/wip/i2c-for-python
  • renze/safe_mode
  • 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
34 results

init.gdb

Blame
  • Forked from card10 / firmware
    Source project has a limited visibility.
    bhi.c 12.51 KiB
    #include <stdio.h>
    #include <string.h>
    
    #include "gpio.h"
    #include "bhy_uc_driver.h"
    #include "bhy.h"
    #include "pmic.h"
    
    #include "FreeRTOS.h"
    #include "task.h"
    #include "semphr.h"
    #include "queue.h"
    
    #include "api/interrupt-sender.h"
    #include "epicardium.h"
    #include "modules/log.h"
    #include "modules/modules.h"
    #include "modules/stream.h"
    
    /* Ticks to wait when trying to acquire lock */
    #define LOCK_WAIT pdMS_TO_TICKS(BHI160_MUTEX_WAIT_MS)
    
    /* BHI160 Firmware Blob.  Contents are defined in libcard10. */
    extern uint8_t bhy1_fw[];
    
    /* Interrupt Pin */
    static const gpio_cfg_t bhi160_interrupt_pin = {
    	PORT_0, PIN_13, GPIO_FUNC_IN, GPIO_PAD_PULL_UP
    };
    
    /* Axis remapping matrices */
    static int8_t bhi160_mapping_matrix[3 * 3] = { 0, -1, 0, 1, 0, 0, 0, 0, 1 };
    static int8_t bmm150_mapping_matrix[3 * 3] = { -1, 0, 0, 0, 1, 0, 0, 0, -1 };
    
    /*
     * From the official docs:
     *
     *    The sic matrix should be calculated for customer platform by logging
     *    uncalibrated magnetometer data.  The sic matrix here is only an example
     *    array (identity matrix). Customer should generate their own matrix.  This
     *    affects magnetometer fusion performance.
     *
     * TODO: Get data for card10
     */
    /* clang-format off */
    static float bhi160_sic_array[3 * 3] = { 1.0, 0.0, 0.0,
                                             0.0, 1.0, 0.0,
                                             0.0, 0.0, 1.0 };
    /* clang-format on */
    
    /* BHI160 Fifo */
    static uint8_t bhi160_fifo[BHI160_FIFO_SIZE];
    static size_t start_index = 0;
    
    /* BHI160 Task ID */
    static TaskHandle_t bhi160_task_id = NULL;
    
    /* BHI160 Mutex */
    static StaticSemaphore_t bhi160_mutex_data;
    static SemaphoreHandle_t bhi160_mutex = NULL;
    
    /* Streams */
    static struct stream_info bhi160_streams[10];
    
    /* Active */
    static bool bhi160_sensor_active[10] = { 0 };
    
    /* -- Utilities -------------------------------------------------------- {{{ */
    /*
     * Retrieve the data size for a sensor.  This value is needed for the creation