Skip to content
Snippets Groups Projects
Select Git revision
  • 9ced463ca86103af692d6ef45f906f06a6d611ab
  • main default protected
  • blm_dev_chan
  • release/1.4.0 protected
  • widgets_draw
  • return_of_melodic_demo
  • task_cleanup
  • mixer2
  • dx/fb-save-restore
  • dx/dldldld
  • fpletz/flake
  • dx/jacksense-headset-mic-only
  • release/1.3.0 protected
  • fil3s-limit-filesize
  • allow-reloading-sunmenu
  • wifi-json-error-handling
  • app_text_viewer
  • shoegaze-fps
  • media_has_video_has_audio
  • fil3s-media
  • more-accurate-battery
  • v1.4.0
  • v1.3.0
  • v1.2.0
  • v1.2.0+rc1
  • v1.1.1
  • v1.1.0
  • v1.1.0+rc1
  • v1.0.0
  • v1.0.0+rc6
  • v1.0.0+rc5
  • v1.0.0+rc4
  • v1.0.0+rc3
  • v1.0.0+rc2
  • v1.0.0+rc1
35 results

network.pyi

Blame
  • 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();