Skip to content
Snippets Groups Projects
Select Git revision
  • ee7f15a0776d0fb4e6286fd3ccbba6c0512a9246
  • master default protected
  • patch-2
  • patch-1
  • add_menu_vibration
  • close_sensor_on_keyboard_interrupt
  • schneider/standby
  • genofire/ble-follow-py
  • plaetzchen/ios-workaround
  • blinkisync-as-preload
  • 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.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
35 results

pb.h

Blame
  • Forked from card10 / firmware
    Source project has a limited visibility.
    caller.c 1.15 KiB
    #include <stdlib.h>
    #include "sema.h"
    #include "api/caller.h"
    
    #define MXC_ASSERT_ENABLE
    #include "mxc_assert.h"
    
    void *_api_call_start(api_id_t id, uintptr_t size)
    {
    	GPIO_OutSet(&debug_pin_1);
    	while (SEMA_GetSema(_API_SEMAPHORE) == E_BUSY) {
    	}
    
    	if (API_CALL_MEM->call_flag != _API_FLAG_IDLE) {
    		/*
    		 * The only way this can happen is if a call was issued from an
    		 * interrupt hander while another call is still happening.  This
    		 * has to be prevented at all cost!
    		 */
    		mxc_assert(
    			"API recalled during ongoing call!",
    			__FILE__,
    			__LINE__
    		);
    	}
    
    	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);
    
    	GPIO_OutSet(&debug_pin_0);
    	/* 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;
    }