Skip to content
Snippets Groups Projects
Select Git revision
  • ch3/genapi-refactor
  • ctx default
  • master protected
  • rahix/bhi160-cleanup
  • schneider/ble-hid
  • schneider/bsec
  • schneider/212-reset-hardware-when-entering-repl
  • schneider/exnostat-remove-gapple
  • schneider/g-watch
  • schneider/ble-time
  • schneider/bonding-fail-if-full
  • schneider/bonding-naming
  • schneider/rng-btle
  • schneider/trng-enable-fix
  • schneider/sdk-0.2.1-12
  • schneider/ble-critical-section
  • schneider/covid-tracing
  • schneider/ble-fixes-2020-3
  • schneider/spo2-playground
  • schneider/mpy-portstate
  • schneider/fix-ble-mac-write
  • v1.15
  • v1.14
  • v1.13
  • 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
40 results

.cproject

Blame
  • Forked from card10 / firmware
    Source project has a limited visibility.
    dispatcher.c 732 B
    #include <stdlib.h>
    #include "sema.h"
    #include "api/dispatcher.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 |= 0x24;
    
    	return ret;
    }
    
    api_id_t api_dispatcher_poll()
    {
    	api_id_t id = 0;
    	while (SEMA_GetSema(_API_SEMAPHORE) == E_BUSY) {}
    
    	if (API_CALL_MEM->call_flag != _API_FLAG_CALLING) {
    		SEMA_FreeSema(_API_SEMAPHORE);
    		return 0;
    	}
    
    	id = API_CALL_MEM->id;
    	__api_dispatch_call(id, API_CALL_MEM->buffer);
    	API_CALL_MEM->call_flag = _API_FLAG_RETURNED;
    
    	SEMA_FreeSema(_API_SEMAPHORE);
    
    	/* Notify the caller that we returned */
    	__SEV();
    	__WFE();
    
    	return id;
    }