Skip to content
Snippets Groups Projects
Select Git revision
  • 128e627d4f00825fca423ff44b552e9a04c61f19
  • master default protected
  • fix/macos-meta-files-in-menu
  • koalo/bhi160
  • genofire/ble-rewrite
  • rahix/simple_menu
  • ch3/splashscreen
  • koalo/bhi160-works-but-dirty
  • ios-workarounds
  • koalo/wip/i2c-for-python
  • renze/safe_mode
  • renze/hatchery_apps
  • schneider/fundamental-test
  • koalo/factory-reset
  • msgctl/gfx_rle
  • msgctl/faultscreen
  • msgctl/textbuffer_api
  • schneider/bonding
  • schneider/bootloader-update-9a0d158
  • schneider/bsec
  • rahix/bma
  • 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

caller.c

Blame
  • Forked from card10 / firmware
    1774 commits behind the upstream repository.
    caller.c 764 B
    #include <stdlib.h>
    #include "sema.h"
    #include "api/caller.h"
    
    void*_api_call_start(api_id_t id, uintptr_t size)
    {
    	while (SEMA_GetSema(_API_SEMAPHORE) == E_BUSY) {}
    
    	/* TODO: Check flag */
    
    	API_CALL_MEM->id = id;
    	return API_CALL_MEM->buffer;
    }
    
    void*_api_call_transact(void*buffer)
    {
    	API_CALL_MEM->call_flag = _API_FLAG_CALLING;
    	SEMA_FreeSema(_API_SEMAPHORE);
    
    	/* Notify the dispather of the new call */
    	__SEV();
    	__WFE();
    
    	while (1) {
    		/* Wait for the dispather to return */
    		__WFE();
    
    		while (SEMA_GetSema(_API_SEMAPHORE) == E_BUSY) {}
    		if (API_CALL_MEM->call_flag == _API_FLAG_RETURNED) {
    			break;
    		}
    		SEMA_FreeSema(_API_SEMAPHORE);
    	}
    
    	API_CALL_MEM->call_flag = _API_FLAG_IDLE;
    	SEMA_FreeSema(_API_SEMAPHORE);
    
    	return API_CALL_MEM->buffer;
    }