Skip to content
Snippets Groups Projects
Select Git revision
  • 128e627d4f00825fca423ff44b552e9a04c61f19
  • master default protected
  • q3k/splitflap
  • q3k/fix-crt
  • q3k/delet-jailbreak
  • q3k/ci-move-to-dockerhub
  • q3k/ci-notify-off-master
  • q3k/fb3
  • q3k/fix-ci
  • q3k/l0dables
  • q3k/fatfs-seek-tell
  • q3k/ci-lint
  • q3k/cube
  • q3k/fb2
  • q3k/copying
  • q3k/ci
  • q3k/nix
  • q3k/binbash
  • rahix/malloc
  • freertos-btle
  • rahix/bhi
21 results

dispatcher.c

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;
    }