Skip to content
Snippets Groups Projects
Select Git revision
  • acb6085c8b81649ea7a63fd88e12b5202ee0e421
  • master default
  • test
  • rahix/hw-lock-new-mutex
  • dx/somewhat-more-dynamic-config
  • schneider/sdk-0.2.1-7
  • schneider/bsec
  • dx/meh-bdf-to-stm
  • 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

settings.py

Blame
  • Forked from card10 / firmware
    Source project has a limited visibility.
    dispatcher.c 1.14 KiB
    #include <stdlib.h>
    #include "sema.h"
    #include "api/dispatcher.h"
    #include "max32665.h"
    
    int api_dispatcher_init()
    {
    	int ret;
    
    	ret                     = SEMA_Init(NULL);
    	API_CALL_MEM->call_flag = _API_FLAG_IDLE;
    
    	/*
    	 * Enable TX events for both cores.
    	 * TODO: Is this the right place?
    	 */
    	MXC_GCR->evten |=
    		MXC_F_GCR_EVTEN_CPU0TXEVENT | MXC_F_GCR_EVTEN_CPU1TXEVENT;
    
    	return ret;
    }
    
    static bool event_ready = false;
    
    bool api_dispatcher_poll_once()
    {
    	if (event_ready) {
    		return false;
    	}
    
    	while (SEMA_GetSema(_API_SEMAPHORE) == E_BUSY) {
    	}
    
    	if (API_CALL_MEM->call_flag != _API_FLAG_CALLING) {
    		SEMA_FreeSema(_API_SEMAPHORE);
    		return false;
    	}
    
    	event_ready = true;
    	return true;
    }
    
    bool api_dispatcher_poll()
    {
    	if (event_ready) {
    		return true;
    	}
    
    	return api_dispatcher_poll_once();
    }
    
    api_id_t api_dispatcher_exec()
    {
    	if (!event_ready) {
    		return 0;
    	}
    
    	GPIO_OutClr(&debug_pin_1);
    
    	api_id_t id = API_CALL_MEM->id;
    	__api_dispatch_call(id, API_CALL_MEM->buffer);
    	API_CALL_MEM->call_flag = _API_FLAG_RETURNED;
    
    	event_ready = false;
    	SEMA_FreeSema(_API_SEMAPHORE);
    
    	/* Notify the caller that we returned */
    	__SEV();
    	__WFE();
    
    	return id;
    }