Skip to content
Snippets Groups Projects
Select Git revision
  • 278df494efaf1652883a37ffec47a4f8f07c2bc1
  • master default protected
  • backslash
  • nickname-match-configs
  • genofire/leds_rgb_get_state
  • 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
  • ios-workarounds
  • schneider/fundamental-test
  • schneider/ble-buffers
  • schneider/maxim-sdk-update
  • ch3/splashscreen
  • koalo/bhi160-works-but-dirty
  • koalo/wip/i2c-for-python
  • 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

ble.c

Blame
  • Forked from card10 / firmware
    Source project has a limited visibility.
    ble.c 4.98 KiB
    #include "wsf_types.h"
    #include "wsf_os.h"
    #include "wsf_buf.h"
    #include "wsf_timer.h"
    #include "wsf_trace.h"
    #include "app_ui.h"
    #include "ll_api.h"
    #include "sch_api.h"
    #include "fit/fit_api.h"
    #include "mxc_config.h"
    #include "gcr_regs.h"
    #include "mcr_regs.h"
    #include "hci_core.h"
    
    #include "FreeRTOS.h"
    #include "timers.h"
    
    #include <stdio.h>
    #include <string.h>
    
    /* Task ID for the ble handler */
    static TaskHandle_t ble_task_id = NULL;
    
    /* Number of WSF buffer pools */
    #define WSF_BUF_POOLS              6
    
    /*! Free memory for pool buffers (use word elements for word alignment). */
    static uint32_t mainBufMem[3584/sizeof(uint32_t)+96];
    
    /*! Default pool descriptor. */
    static wsfBufPoolDesc_t mainPoolDesc[WSF_BUF_POOLS] =
    {
      {  16,  8 },
      {  32,  4 },
      {  64,  4 },
      { 128,  4 },
      { 256,  4 },
      { 384,  4 }
    };
    
    
    static void PlatformInit(void)
    {
        /* Change the pullup on the RST pin to 25K */
        /* TODO: Is this really needed? */
        MXC_MCR->ctrl = 0x202;
    
        /* Set VREGO_D to 1.3V */
        *((volatile uint32_t*)0x40004410) = 0x50;
    
        /* Set TX LDO to 1.1V and enable LDO. Set RX LDO to 0.9V and enable LDO */
        MXC_GCR->btleldocn = 0xD9; // TX 1.1V RX 0.9V
    
        /* Power up the 32MHz XO */
        MXC_GCR->clkcn |= MXC_F_GCR_CLKCN_X32M_EN;
    
        /* Enable peripheral clocks */
        /* TODO: Is this really needed? */
        MXC_GCR->perckcn0 &= ~(MXC_F_GCR_PERCKCN0_GPIO0D | MXC_F_GCR_PERCKCN0_GPIO1D);  // Clear GPIO0 and GPIO1 Disable
        MXC_GCR->perckcn1 &= ~(MXC_F_GCR_PERCKCN1_BTLED | MXC_F_GCR_PERCKCN1_TRNGD );  // Clear BTLE and ICACHE0 disable
    }
    
    static void myTrace(const char *pStr, va_list args)
    {
        extern uint8_t wsfCsNesting;
    
        if (wsfCsNesting == 0)
        {
            vprintf(pStr, args);
            printf("\r\n");