Skip to content
Snippets Groups Projects
Select Git revision
  • 3a4db97cecfe43bc83659d53f23cc26d4706b57e
  • 5.1-flow3r default
  • v5.1-flow3r
  • v4.2.5
  • v5.1
  • v5.1-rc2
  • v4.4.5
  • v5.1-rc1
  • v5.0.2
  • v5.1-beta1
  • v5.2-dev
  • v4.3.5
  • v5.0.1
  • v4.4.4
  • v4.1.4
  • v5.0
  • v5.0-rc1
  • v4.4.3
  • v4.3.4
  • v4.2.4
  • v5.0-beta1
  • v5.1-dev
22 results

set-submodules-to-github.sh

Blame
  • support.c 2.02 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" );
    	}
    }
    
    /*
     * 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 fokused 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;
    }