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

__init__.py

Blame
  • support.c 3.07 KiB
    /*
     * FreeRTOS support functions
     */
    
    #include "FreeRTOS.h"
    #include "task.h"
    
    #include "api/dispatcher.h"
    
    #include "card10.h"
    
    extern TaskHandle_t dispatcher_task_id;
    
    /*
     * This hook is called before FreeRTOS enters tickless idle.
     */
    void pre_idle_sleep(TickType_t xExpectedIdleTime)
    {
    	if (xExpectedIdleTime > 0) {
    		/*
    		 * WFE because the other core should be able to notify
    		 * epicardium if it wants to issue an API call.
    		 */
    
    		/*
    		 * TODO: Ensure this is actually correct and does not have any
    		 * race conditions.
    		 */
    		__asm volatile("dsb" ::: "memory");
    		__asm volatile("wfe");
    		__asm volatile("isb");
    		GPIO_OutClr(&debug_pin_0);
    	}
    }
    
    /*
     * This hook is called after FreeRTOS exits tickless idle.
     */
    void post_idle_sleep(TickType_t xExpectedIdleTime)
    {
    	/* Check whether a new API call was issued. */
    	if (api_dispatcher_poll_once()) {
    		xTaskNotifyGive(dispatcher_task_id);
    	}
    
    	/*
    	 * Do card10 house keeping. e.g. polling the i2c devices if they
    	 * triggered an interrupt.
    	 *
    	 * TODO: Do this in a more task focused way (high/low ISR)
    	 */
    	card10_poll();
    }
    
    void vApplicationGetIdleTaskMemory(
    	StaticTask_t **ppxIdleTaskTCBBuffer,
    	StackType_t **ppxIdleTaskStackBuffer,
    	uint32_t *pulIdleTaskStackSize
    ) {
    	/*
    	 * If the buffers to be provided to the Idle task are declared inside this
    	 * function then they must be declared static - otherwise they will be allocated on
    	 * the stack and so not exists after this function exits.
    	 */
    	static StaticTask_t xIdleTaskTCB;
    	static StackType_t uxIdleTaskStack[configMINIMAL_STACK_SIZE];
    
    	/*
    	 * Pass out a pointer to the StaticTask_t structure in which the Idle task's
    	 * ktate will be stored.
    	 */
    	*ppxIdleTaskTCBBuffer = &xIdleTaskTCB;
    
    	/* Pass out the array that will be used as the Idle task's stack. */
    	*ppxIdleTaskStackBuffer = uxIdleTaskStack;
    
    	/*
    	 * Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer.
    	 * Note that, as the array is necessarily of type StackType_t,
    	 * configMINIMAL_STACK_SIZE is specified in words, not bytes.
    	 */
    	*pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
    }
    
    void vApplicationGetTimerTaskMemory(
    	StaticTask_t **ppxTimerTaskTCBBuffer,
    	StackType_t **ppxTimerTaskStackBuffer,
    	uint32_t *pulTimerTaskStackSize
    ) {
    	/*
    	 * If the buffers to be provided to the Timer task are declared inside
    	 * this function then they must be declared static - otherwise they will
    	 * be allocated on the stack and so not exists after this function
    	 * exits.
    	 */
    	static StaticTask_t xTimerTaskTCB;
    	static StackType_t uxTimerTaskStack[configTIMER_TASK_STACK_DEPTH];
    
    	/*
    	 * Pass out a pointer to the StaticTask_t structure in which the Timer
    	 * task's state will be stored.
    	 */
    	*ppxTimerTaskTCBBuffer = &xTimerTaskTCB;
    
    	/* Pass out the array that will be used as the Timer task's stack. */
    	*ppxTimerTaskStackBuffer = uxTimerTaskStack;
    
    	/*
    	 * Pass out the size of the array pointed to by
    	 * *ppxTimerTaskStackBuffer.  Note that, as the array is necessarily of
    	 * type StackType_t, configMINIMAL_STACK_SIZE is specified in words, not
    	 * bytes.
    	 */
    	*pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
    }