Skip to content
Snippets Groups Projects
Select Git revision
  • d2986026b9ba3d971c3982f7839338f0662cb97f
  • master default protected
  • backslash
  • nickname-match-configs
  • genofire/leds_rgb_get_state
  • genofire/rockets-state
  • genofire/ble-follow-py
  • plaetzchen/ios-workaround
  • blinkisync-as-preload
  • genofire/haule-ble-fs-deactive
  • schneider/max30001-pycardium
  • schneider/max30001-epicaridum
  • schneider/max30001
  • schneider/stream-locks
  • ios-workarounds
  • schneider/fundamental-test
  • schneider/ble-buffers
  • schneider/maxim-sdk-update
  • ch3/splashscreen
  • koalo/bhi160-works-but-dirty
  • koalo/wip/i2c-for-python
  • 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
34 results

dispatcher.c

Blame
  • Forked from card10 / firmware
    Source project has a limited visibility.
    dispatcher.c 831 B
    #include "modules/log.h"
    
    #include "api/dispatcher.h"
    
    #include "FreeRTOS.h"
    #include "task.h"
    #include "semphr.h"
    
    #define TIMEOUT pdMS_TO_TICKS(2000)
    
    TaskHandle_t dispatcher_task_id;
    
    static StaticSemaphore_t api_mutex_data;
    SemaphoreHandle_t api_mutex = NULL;
    
    void dispatcher_mutex_init(void)
    {
    	api_mutex = xSemaphoreCreateMutexStatic(&api_mutex_data);
    }
    
    /*
     * API dispatcher task.  This task will sleep until an API call is issued and
     * then wake up to dispatch it.
     */
    void vApiDispatcher(void *pvParameters)
    {
    	LOG_DEBUG("dispatcher", "Ready.");
    	while (1) {
    		if (api_dispatcher_poll()) {
    			if (xSemaphoreTake(api_mutex, TIMEOUT) != pdTRUE) {
    				LOG_ERR("dispatcher", "API mutex blocked");
    				continue;
    			}
    			api_dispatcher_exec();
    			xSemaphoreGive(api_mutex);
    		}
    		ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
    	}
    }