Folder structure change + Fix broken Projects (#103)
* Update folder structure * Correct project files * Move test folder * Some changes after Yuki's commentspull/104/head
parent
98bfc38bf3
commit
a9b2aac4e9
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,128 +1,128 @@
|
||||
/*
|
||||
* FreeRTOS Kernel V10.3.0
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* http://www.FreeRTOS.org
|
||||
* http://aws.amazon.com/freertos
|
||||
*
|
||||
* 1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
|
||||
#ifndef FREERTOS_CONFIG_H
|
||||
#define FREERTOS_CONFIG_H
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Application specific definitions.
|
||||
*
|
||||
* These definitions should be adjusted for your particular hardware and
|
||||
* application requirements.
|
||||
*
|
||||
* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
|
||||
* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. See
|
||||
* http://www.freertos.org/a00110.html
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
#define configUSE_PREEMPTION 1
|
||||
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
|
||||
#define configUSE_IDLE_HOOK 1
|
||||
#define configUSE_TICK_HOOK 1
|
||||
#define configUSE_DAEMON_TASK_STARTUP_HOOK 1
|
||||
#define configTICK_RATE_HZ ( 1000 ) /* In this non-real time simulated environment the tick frequency has to be at least a multiple of the Win32 tick frequency, and therefore very slow. */
|
||||
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 70 ) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the win32 thread. */
|
||||
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 52 * 1024 ) )
|
||||
#define configMAX_TASK_NAME_LEN ( 12 )
|
||||
#define configUSE_TRACE_FACILITY 1
|
||||
#define configUSE_16_BIT_TICKS 0
|
||||
#define configIDLE_SHOULD_YIELD 1
|
||||
#define configUSE_MUTEXES 1
|
||||
#define configCHECK_FOR_STACK_OVERFLOW 0
|
||||
#define configUSE_RECURSIVE_MUTEXES 1
|
||||
#define configQUEUE_REGISTRY_SIZE 20
|
||||
#define configUSE_MALLOC_FAILED_HOOK 1
|
||||
#define configUSE_APPLICATION_TASK_TAG 1
|
||||
#define configUSE_COUNTING_SEMAPHORES 1
|
||||
#define configUSE_ALTERNATIVE_API 0
|
||||
#define configUSE_QUEUE_SETS 1
|
||||
#define configUSE_TASK_NOTIFICATIONS 1
|
||||
#define configSUPPORT_STATIC_ALLOCATION 1
|
||||
#define configINITIAL_TICK_COUNT ( ( TickType_t ) 0 ) /* For test. */
|
||||
#define configSTREAM_BUFFER_TRIGGER_LEVEL_TEST_MARGIN 1 /* As there are a lot of tasks running. */
|
||||
|
||||
/* Software timer related configuration options. */
|
||||
#define configUSE_TIMERS 1
|
||||
#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
|
||||
#define configTIMER_QUEUE_LENGTH 20
|
||||
#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 )
|
||||
|
||||
#define configMAX_PRIORITIES ( 7 )
|
||||
|
||||
/* Run time stats gathering configuration options. */
|
||||
unsigned long ulGetRunTimeCounterValue( void ); /* Prototype of function that returns run time counter. */
|
||||
void vConfigureTimerForRunTimeStats( void ); /* Prototype of function that initialises the run time counter. */
|
||||
#define configGENERATE_RUN_TIME_STATS 1
|
||||
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() vConfigureTimerForRunTimeStats()
|
||||
#define portGET_RUN_TIME_COUNTER_VALUE() ulGetRunTimeCounterValue()
|
||||
|
||||
/* Co-routine related configuration options. */
|
||||
#define configUSE_CO_ROUTINES 1
|
||||
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
|
||||
|
||||
/* This demo makes use of one or more example stats formatting functions. These
|
||||
format the raw data provided by the uxTaskGetSystemState() function in to human
|
||||
readable ASCII form. See the notes in the implementation of vTaskList() within
|
||||
FreeRTOS/Source/tasks.c for limitations. */
|
||||
#define configUSE_STATS_FORMATTING_FUNCTIONS 1
|
||||
|
||||
/* Set the following definitions to 1 to include the API function, or zero
|
||||
to exclude the API function. In most cases the linker will remove unused
|
||||
functions anyway. */
|
||||
#define INCLUDE_vTaskPrioritySet 1
|
||||
#define INCLUDE_uxTaskPriorityGet 1
|
||||
#define INCLUDE_vTaskDelete 1
|
||||
#define INCLUDE_vTaskCleanUpResources 0
|
||||
#define INCLUDE_vTaskSuspend 1
|
||||
#define INCLUDE_vTaskDelayUntil 1
|
||||
#define INCLUDE_vTaskDelay 1
|
||||
#define INCLUDE_uxTaskGetStackHighWaterMark 1
|
||||
#define INCLUDE_xTaskGetSchedulerState 1
|
||||
#define INCLUDE_xTimerGetTimerDaemonTaskHandle 1
|
||||
#define INCLUDE_xTaskGetIdleTaskHandle 1
|
||||
#define INCLUDE_xTaskGetHandle 1
|
||||
#define INCLUDE_eTaskGetState 1
|
||||
#define INCLUDE_xSemaphoreGetMutexHolder 1
|
||||
#define INCLUDE_xTimerPendFunctionCall 1
|
||||
#define INCLUDE_xTaskAbortDelay 1
|
||||
|
||||
/* It is a good idea to define configASSERT() while developing. configASSERT()
|
||||
uses the same semantics as the standard C assert() macro. */
|
||||
extern void vAssertCalled( unsigned long ulLine, const char * const pcFileName );
|
||||
#define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __LINE__, __FILE__ )
|
||||
|
||||
#define configINCLUDE_MESSAGE_BUFFER_AMP_DEMO 0
|
||||
#if ( configINCLUDE_MESSAGE_BUFFER_AMP_DEMO == 1 )
|
||||
extern void vGenerateCoreBInterrupt( void * xUpdatedMessageBuffer );
|
||||
#define sbSEND_COMPLETED( pxStreamBuffer ) vGenerateCoreBInterrupt( pxStreamBuffer )
|
||||
#endif /* configINCLUDE_MESSAGE_BUFFER_AMP_DEMO */
|
||||
|
||||
/* Include the FreeRTOS+Trace FreeRTOS trace macro definitions. */
|
||||
/* #include "trcRecorder.h" */
|
||||
|
||||
#endif /* FREERTOS_CONFIG_H */
|
||||
/*
|
||||
* FreeRTOS Kernel V10.3.0
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* http://www.FreeRTOS.org
|
||||
* http://aws.amazon.com/freertos
|
||||
*
|
||||
* 1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
|
||||
#ifndef FREERTOS_CONFIG_H
|
||||
#define FREERTOS_CONFIG_H
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Application specific definitions.
|
||||
*
|
||||
* These definitions should be adjusted for your particular hardware and
|
||||
* application requirements.
|
||||
*
|
||||
* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
|
||||
* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. See
|
||||
* http://www.freertos.org/a00110.html
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
#define configUSE_PREEMPTION 1
|
||||
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
|
||||
#define configUSE_IDLE_HOOK 1
|
||||
#define configUSE_TICK_HOOK 1
|
||||
#define configUSE_DAEMON_TASK_STARTUP_HOOK 1
|
||||
#define configTICK_RATE_HZ ( 1000 ) /* In this non-real time simulated environment the tick frequency has to be at least a multiple of the Win32 tick frequency, and therefore very slow. */
|
||||
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 70 ) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the win32 thread. */
|
||||
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 52 * 1024 ) )
|
||||
#define configMAX_TASK_NAME_LEN ( 12 )
|
||||
#define configUSE_TRACE_FACILITY 1
|
||||
#define configUSE_16_BIT_TICKS 0
|
||||
#define configIDLE_SHOULD_YIELD 1
|
||||
#define configUSE_MUTEXES 1
|
||||
#define configCHECK_FOR_STACK_OVERFLOW 0
|
||||
#define configUSE_RECURSIVE_MUTEXES 1
|
||||
#define configQUEUE_REGISTRY_SIZE 20
|
||||
#define configUSE_MALLOC_FAILED_HOOK 1
|
||||
#define configUSE_APPLICATION_TASK_TAG 1
|
||||
#define configUSE_COUNTING_SEMAPHORES 1
|
||||
#define configUSE_ALTERNATIVE_API 0
|
||||
#define configUSE_QUEUE_SETS 1
|
||||
#define configUSE_TASK_NOTIFICATIONS 1
|
||||
#define configSUPPORT_STATIC_ALLOCATION 1
|
||||
#define configINITIAL_TICK_COUNT ( ( TickType_t ) 0 ) /* For test. */
|
||||
#define configSTREAM_BUFFER_TRIGGER_LEVEL_TEST_MARGIN 1 /* As there are a lot of tasks running. */
|
||||
|
||||
/* Software timer related configuration options. */
|
||||
#define configUSE_TIMERS 1
|
||||
#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
|
||||
#define configTIMER_QUEUE_LENGTH 20
|
||||
#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 )
|
||||
|
||||
#define configMAX_PRIORITIES ( 7 )
|
||||
|
||||
/* Run time stats gathering configuration options. */
|
||||
unsigned long ulGetRunTimeCounterValue( void ); /* Prototype of function that returns run time counter. */
|
||||
void vConfigureTimerForRunTimeStats( void ); /* Prototype of function that initialises the run time counter. */
|
||||
#define configGENERATE_RUN_TIME_STATS 1
|
||||
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() vConfigureTimerForRunTimeStats()
|
||||
#define portGET_RUN_TIME_COUNTER_VALUE() ulGetRunTimeCounterValue()
|
||||
|
||||
/* Co-routine related configuration options. */
|
||||
#define configUSE_CO_ROUTINES 1
|
||||
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
|
||||
|
||||
/* This demo makes use of one or more example stats formatting functions. These
|
||||
format the raw data provided by the uxTaskGetSystemState() function in to human
|
||||
readable ASCII form. See the notes in the implementation of vTaskList() within
|
||||
FreeRTOS/Source/tasks.c for limitations. */
|
||||
#define configUSE_STATS_FORMATTING_FUNCTIONS 1
|
||||
|
||||
/* Set the following definitions to 1 to include the API function, or zero
|
||||
to exclude the API function. In most cases the linker will remove unused
|
||||
functions anyway. */
|
||||
#define INCLUDE_vTaskPrioritySet 1
|
||||
#define INCLUDE_uxTaskPriorityGet 1
|
||||
#define INCLUDE_vTaskDelete 1
|
||||
#define INCLUDE_vTaskCleanUpResources 0
|
||||
#define INCLUDE_vTaskSuspend 1
|
||||
#define INCLUDE_vTaskDelayUntil 1
|
||||
#define INCLUDE_vTaskDelay 1
|
||||
#define INCLUDE_uxTaskGetStackHighWaterMark 1
|
||||
#define INCLUDE_xTaskGetSchedulerState 1
|
||||
#define INCLUDE_xTimerGetTimerDaemonTaskHandle 1
|
||||
#define INCLUDE_xTaskGetIdleTaskHandle 1
|
||||
#define INCLUDE_xTaskGetHandle 1
|
||||
#define INCLUDE_eTaskGetState 1
|
||||
#define INCLUDE_xSemaphoreGetMutexHolder 1
|
||||
#define INCLUDE_xTimerPendFunctionCall 1
|
||||
#define INCLUDE_xTaskAbortDelay 1
|
||||
|
||||
/* It is a good idea to define configASSERT() while developing. configASSERT()
|
||||
uses the same semantics as the standard C assert() macro. */
|
||||
extern void vAssertCalled( unsigned long ulLine, const char * const pcFileName );
|
||||
#define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __LINE__, __FILE__ )
|
||||
|
||||
#define configINCLUDE_MESSAGE_BUFFER_AMP_DEMO 0
|
||||
#if ( configINCLUDE_MESSAGE_BUFFER_AMP_DEMO == 1 )
|
||||
extern void vGenerateCoreBInterrupt( void * xUpdatedMessageBuffer );
|
||||
#define sbSEND_COMPLETED( pxStreamBuffer ) vGenerateCoreBInterrupt( pxStreamBuffer )
|
||||
#endif /* configINCLUDE_MESSAGE_BUFFER_AMP_DEMO */
|
||||
|
||||
/* Include the FreeRTOS+Trace FreeRTOS trace macro definitions. */
|
||||
/* #include "trcRecorder.h" */
|
||||
|
||||
#endif /* FREERTOS_CONFIG_H */
|
@ -1,162 +1,162 @@
|
||||
/*
|
||||
* FreeRTOS Kernel V10.3.0
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* http://www.FreeRTOS.org
|
||||
* http://aws.amazon.com/freertos
|
||||
*
|
||||
* 1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
#ifndef PORTMACRO_H
|
||||
#define PORTMACRO_H
|
||||
|
||||
#include <Windows.h>
|
||||
#include <WinBase.h>
|
||||
|
||||
/******************************************************************************
|
||||
Defines
|
||||
******************************************************************************/
|
||||
/* Type definitions. */
|
||||
#define portCHAR char
|
||||
#define portFLOAT float
|
||||
#define portDOUBLE double
|
||||
#define portLONG long
|
||||
#define portSHORT short
|
||||
#define portSTACK_TYPE size_t
|
||||
#define portBASE_TYPE long
|
||||
#define portPOINTER_SIZE_TYPE size_t
|
||||
|
||||
typedef portSTACK_TYPE StackType_t;
|
||||
typedef long BaseType_t;
|
||||
typedef unsigned long UBaseType_t;
|
||||
|
||||
|
||||
#if( configUSE_16_BIT_TICKS == 1 )
|
||||
typedef uint16_t TickType_t;
|
||||
#define portMAX_DELAY ( TickType_t ) 0xffff
|
||||
#else
|
||||
typedef uint32_t TickType_t;
|
||||
#define portMAX_DELAY ( TickType_t ) 0xffffffffUL
|
||||
|
||||
/* 32/64-bit tick type on a 32/64-bit architecture, so reads of the tick
|
||||
count do not need to be guarded with a critical section. */
|
||||
#define portTICK_TYPE_IS_ATOMIC 1
|
||||
#endif
|
||||
|
||||
/* Hardware specifics. */
|
||||
#define portSTACK_GROWTH ( -1 )
|
||||
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
|
||||
#define portINLINE
|
||||
|
||||
#if defined( __x86_64__) || defined( _M_X64 )
|
||||
#define portBYTE_ALIGNMENT 8
|
||||
#else
|
||||
#define portBYTE_ALIGNMENT 4
|
||||
#endif
|
||||
|
||||
#define portYIELD() vPortGenerateSimulatedInterrupt( portINTERRUPT_YIELD )
|
||||
|
||||
|
||||
extern volatile BaseType_t xInsideInterrupt;
|
||||
#define portSOFTWARE_BARRIER() while( xInsideInterrupt != pdFALSE )
|
||||
|
||||
|
||||
/* Simulated interrupts return pdFALSE if no context switch should be performed,
|
||||
or a non-zero number if a context switch should be performed. */
|
||||
#define portYIELD_FROM_ISR( x ) ( void ) x
|
||||
#define portEND_SWITCHING_ISR( x ) portYIELD_FROM_ISR( ( x ) )
|
||||
|
||||
void vPortCloseRunningThread( void *pvTaskToDelete, volatile BaseType_t *pxPendYield );
|
||||
void vPortDeleteThread( void *pvThreadToDelete );
|
||||
#define portCLEAN_UP_TCB( pxTCB ) vPortDeleteThread( pxTCB )
|
||||
#define portPRE_TASK_DELETE_HOOK( pvTaskToDelete, pxPendYield ) vPortCloseRunningThread( ( pvTaskToDelete ), ( pxPendYield ) )
|
||||
#define portDISABLE_INTERRUPTS() vPortEnterCritical()
|
||||
#define portENABLE_INTERRUPTS() vPortExitCritical()
|
||||
|
||||
/* Critical section handling. */
|
||||
void vPortEnterCritical( void );
|
||||
void vPortExitCritical( void );
|
||||
|
||||
#define portENTER_CRITICAL() vPortEnterCritical()
|
||||
#define portEXIT_CRITICAL() vPortExitCritical()
|
||||
|
||||
#ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION
|
||||
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
|
||||
#endif
|
||||
|
||||
#if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1
|
||||
|
||||
/* Check the configuration. */
|
||||
#if( configMAX_PRIORITIES > 32 )
|
||||
#error configUSE_PORT_OPTIMISED_TASK_SELECTION can only be set to 1 when configMAX_PRIORITIES is less than or equal to 32. It is very rare that a system requires more than 10 to 15 difference priorities as tasks that share a priority will time slice.
|
||||
#endif
|
||||
|
||||
/* Store/clear the ready priorities in a bit map. */
|
||||
#define portRECORD_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) |= ( 1UL << ( uxPriority ) )
|
||||
#define portRESET_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) &= ~( 1UL << ( uxPriority ) )
|
||||
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) \
|
||||
__asm volatile( "bsr %1, %0\n\t" \
|
||||
:"=r"(uxTopPriority) : "rm"(uxReadyPriorities) : "cc" )
|
||||
#else
|
||||
/* BitScanReverse returns the bit position of the most significant '1'
|
||||
in the word. */
|
||||
#define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) _BitScanReverse( ( DWORD * ) &( uxTopPriority ), ( uxReadyPriorities ) )
|
||||
#endif /* __GNUC__ */
|
||||
|
||||
#endif /* taskRECORD_READY_PRIORITY */
|
||||
|
||||
#ifndef __GNUC__
|
||||
__pragma( warning( disable:4211 ) ) /* Nonstandard extension used, as extern is only nonstandard to MSVC. */
|
||||
#endif
|
||||
|
||||
|
||||
/* Task function macros as described on the FreeRTOS.org WEB site. */
|
||||
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void * pvParameters )
|
||||
#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters )
|
||||
|
||||
#define portINTERRUPT_YIELD ( 0UL )
|
||||
#define portINTERRUPT_TICK ( 1UL )
|
||||
|
||||
/*
|
||||
* Raise a simulated interrupt represented by the bit mask in ulInterruptMask.
|
||||
* Each bit can be used to represent an individual interrupt - with the first
|
||||
* two bits being used for the Yield and Tick interrupts respectively.
|
||||
*/
|
||||
void vPortGenerateSimulatedInterrupt( uint32_t ulInterruptNumber );
|
||||
|
||||
/*
|
||||
* Install an interrupt handler to be called by the simulated interrupt handler
|
||||
* thread. The interrupt number must be above any used by the kernel itself
|
||||
* (at the time of writing the kernel was using interrupt numbers 0, 1, and 2
|
||||
* as defined above). The number must also be lower than 32.
|
||||
*
|
||||
* Interrupt handler functions must return a non-zero value if executing the
|
||||
* handler resulted in a task switch being required.
|
||||
*/
|
||||
void vPortSetInterruptHandler( uint32_t ulInterruptNumber, uint32_t (*pvHandler)( void ) );
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* FreeRTOS Kernel V10.3.0
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* http://www.FreeRTOS.org
|
||||
* http://aws.amazon.com/freertos
|
||||
*
|
||||
* 1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
#ifndef PORTMACRO_H
|
||||
#define PORTMACRO_H
|
||||
|
||||
#include <Windows.h>
|
||||
#include <WinBase.h>
|
||||
|
||||
/******************************************************************************
|
||||
Defines
|
||||
******************************************************************************/
|
||||
/* Type definitions. */
|
||||
#define portCHAR char
|
||||
#define portFLOAT float
|
||||
#define portDOUBLE double
|
||||
#define portLONG long
|
||||
#define portSHORT short
|
||||
#define portSTACK_TYPE size_t
|
||||
#define portBASE_TYPE long
|
||||
#define portPOINTER_SIZE_TYPE size_t
|
||||
|
||||
typedef portSTACK_TYPE StackType_t;
|
||||
typedef long BaseType_t;
|
||||
typedef unsigned long UBaseType_t;
|
||||
|
||||
|
||||
#if( configUSE_16_BIT_TICKS == 1 )
|
||||
typedef uint16_t TickType_t;
|
||||
#define portMAX_DELAY ( TickType_t ) 0xffff
|
||||
#else
|
||||
typedef uint32_t TickType_t;
|
||||
#define portMAX_DELAY ( TickType_t ) 0xffffffffUL
|
||||
|
||||
/* 32/64-bit tick type on a 32/64-bit architecture, so reads of the tick
|
||||
count do not need to be guarded with a critical section. */
|
||||
#define portTICK_TYPE_IS_ATOMIC 1
|
||||
#endif
|
||||
|
||||
/* Hardware specifics. */
|
||||
#define portSTACK_GROWTH ( -1 )
|
||||
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
|
||||
#define portINLINE
|
||||
|
||||
#if defined( __x86_64__) || defined( _M_X64 )
|
||||
#define portBYTE_ALIGNMENT 8
|
||||
#else
|
||||
#define portBYTE_ALIGNMENT 4
|
||||
#endif
|
||||
|
||||
#define portYIELD() vPortGenerateSimulatedInterrupt( portINTERRUPT_YIELD )
|
||||
|
||||
|
||||
extern volatile BaseType_t xInsideInterrupt;
|
||||
#define portSOFTWARE_BARRIER() while( xInsideInterrupt != pdFALSE )
|
||||
|
||||
|
||||
/* Simulated interrupts return pdFALSE if no context switch should be performed,
|
||||
or a non-zero number if a context switch should be performed. */
|
||||
#define portYIELD_FROM_ISR( x ) ( void ) x
|
||||
#define portEND_SWITCHING_ISR( x ) portYIELD_FROM_ISR( ( x ) )
|
||||
|
||||
void vPortCloseRunningThread( void *pvTaskToDelete, volatile BaseType_t *pxPendYield );
|
||||
void vPortDeleteThread( void *pvThreadToDelete );
|
||||
#define portCLEAN_UP_TCB( pxTCB ) vPortDeleteThread( pxTCB )
|
||||
#define portPRE_TASK_DELETE_HOOK( pvTaskToDelete, pxPendYield ) vPortCloseRunningThread( ( pvTaskToDelete ), ( pxPendYield ) )
|
||||
#define portDISABLE_INTERRUPTS() vPortEnterCritical()
|
||||
#define portENABLE_INTERRUPTS() vPortExitCritical()
|
||||
|
||||
/* Critical section handling. */
|
||||
void vPortEnterCritical( void );
|
||||
void vPortExitCritical( void );
|
||||
|
||||
#define portENTER_CRITICAL() vPortEnterCritical()
|
||||
#define portEXIT_CRITICAL() vPortExitCritical()
|
||||
|
||||
#ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION
|
||||
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
|
||||
#endif
|
||||
|
||||
#if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1
|
||||
|
||||
/* Check the configuration. */
|
||||
#if( configMAX_PRIORITIES > 32 )
|
||||
#error configUSE_PORT_OPTIMISED_TASK_SELECTION can only be set to 1 when configMAX_PRIORITIES is less than or equal to 32. It is very rare that a system requires more than 10 to 15 difference priorities as tasks that share a priority will time slice.
|
||||
#endif
|
||||
|
||||
/* Store/clear the ready priorities in a bit map. */
|
||||
#define portRECORD_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) |= ( 1UL << ( uxPriority ) )
|
||||
#define portRESET_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) &= ~( 1UL << ( uxPriority ) )
|
||||
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) \
|
||||
__asm volatile( "bsr %1, %0\n\t" \
|
||||
:"=r"(uxTopPriority) : "rm"(uxReadyPriorities) : "cc" )
|
||||
#else
|
||||
/* BitScanReverse returns the bit position of the most significant '1'
|
||||
in the word. */
|
||||
#define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) _BitScanReverse( ( DWORD * ) &( uxTopPriority ), ( uxReadyPriorities ) )
|
||||
#endif /* __GNUC__ */
|
||||
|
||||
#endif /* taskRECORD_READY_PRIORITY */
|
||||
|
||||
#ifndef __GNUC__
|
||||
__pragma( warning( disable:4211 ) ) /* Nonstandard extension used, as extern is only nonstandard to MSVC. */
|
||||
#endif
|
||||
|
||||
|
||||
/* Task function macros as described on the FreeRTOS.org WEB site. */
|
||||
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void * pvParameters )
|
||||
#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters )
|
||||
|
||||
#define portINTERRUPT_YIELD ( 0UL )
|
||||
#define portINTERRUPT_TICK ( 1UL )
|
||||
|
||||
/*
|
||||
* Raise a simulated interrupt represented by the bit mask in ulInterruptMask.
|
||||
* Each bit can be used to represent an individual interrupt - with the first
|
||||
* two bits being used for the Yield and Tick interrupts respectively.
|
||||
*/
|
||||
void vPortGenerateSimulatedInterrupt( uint32_t ulInterruptNumber );
|
||||
|
||||
/*
|
||||
* Install an interrupt handler to be called by the simulated interrupt handler
|
||||
* thread. The interrupt number must be above any used by the kernel itself
|
||||
* (at the time of writing the kernel was using interrupt numbers 0, 1, and 2
|
||||
* as defined above). The number must also be lower than 32.
|
||||
*
|
||||
* Interrupt handler functions must return a non-zero value if executing the
|
||||
* handler resulted in a task switch being required.
|
||||
*/
|
||||
void vPortSetInterruptHandler( uint32_t ulInterruptNumber, uint32_t (*pvHandler)( void ) );
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,50 +0,0 @@
|
||||
/*********************************************************
|
||||
DllData file -- generated by MIDL compiler
|
||||
|
||||
DO NOT ALTER THIS FILE
|
||||
|
||||
This file is regenerated by MIDL on every IDL file compile.
|
||||
|
||||
To completely reconstruct this file, delete it and rerun MIDL
|
||||
on all the IDL files in this DLL, specifying this file for the
|
||||
/dlldata command line option
|
||||
|
||||
*********************************************************/
|
||||
|
||||
#define PROXY_DELEGATION
|
||||
|
||||
#include <rpcproxy.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
EXTERN_PROXY_FILE( HLink )
|
||||
EXTERN_PROXY_FILE( HolographicSpaceInterop )
|
||||
EXTERN_PROXY_FILE( homepagesetting )
|
||||
EXTERN_PROXY_FILE( htiface )
|
||||
EXTERN_PROXY_FILE( htiframe )
|
||||
EXTERN_PROXY_FILE( windows2Eui2Examl2Ehosting2Edesktopwindowxamlsource )
|
||||
EXTERN_PROXY_FILE( windows2Eui2Examl2Ehosting2Ereferencetracker )
|
||||
|
||||
|
||||
PROXYFILE_LIST_START
|
||||
/* Start of list */
|
||||
REFERENCE_PROXY_FILE( HLink ),
|
||||
REFERENCE_PROXY_FILE( HolographicSpaceInterop ),
|
||||
REFERENCE_PROXY_FILE( homepagesetting ),
|
||||
REFERENCE_PROXY_FILE( htiface ),
|
||||
REFERENCE_PROXY_FILE( htiframe ),
|
||||
REFERENCE_PROXY_FILE( windows2Eui2Examl2Ehosting2Edesktopwindowxamlsource ),
|
||||
REFERENCE_PROXY_FILE( windows2Eui2Examl2Ehosting2Ereferencetracker ),
|
||||
/* End of list */
|
||||
PROXYFILE_LIST_END
|
||||
|
||||
|
||||
DLLDATA_ROUTINES( aProxyFileList, GET_DLL_CLSID )
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C" */
|
||||
#endif
|
||||
|
||||
/* end of generated dlldata file */
|
@ -1,667 +0,0 @@
|
||||
/*
|
||||
Copyright 2001, 2002 Georges Menie (www.menie.org)
|
||||
stdarg version contributed by Christian Ettinger
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Changes for the FreeRTOS ports:
|
||||
|
||||
- The dot in "%-8.8s"
|
||||
- The specifiers 'l' (long) and 'L' (long long)
|
||||
- The specifier 'u' for unsigned
|
||||
- Dot notation for IP addresses:
|
||||
sprintf("IP = %xip\n", 0xC0A80164);
|
||||
will produce "IP = 192.168.1.100\n"
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
|
||||
#define PAD_RIGHT 1
|
||||
#define PAD_ZERO 2
|
||||
|
||||
/*
|
||||
* Return 1 for readable, 2 for writeable, 3 for both.
|
||||
* Function must be provided by the application.
|
||||
*/
|
||||
extern BaseType_t xApplicationMemoryPermissions( uint32_t aAddress );
|
||||
|
||||
extern void vOutputChar( const char cChar, const TickType_t xTicksToWait );
|
||||
static const TickType_t xTicksToWait = pdMS_TO_TICKS( 20 );
|
||||
|
||||
struct xPrintFlags
|
||||
{
|
||||
int base;
|
||||
int width;
|
||||
int printLimit;
|
||||
unsigned
|
||||
pad : 8,
|
||||
letBase : 8,
|
||||
isSigned : 1,
|
||||
isNumber : 1,
|
||||
long32 : 1,
|
||||
long64 : 1;
|
||||
};
|
||||
|
||||
struct SStringBuf
|
||||
{
|
||||
char *str;
|
||||
const char *orgStr;
|
||||
const char *nulPos;
|
||||
int curLen;
|
||||
struct xPrintFlags flags;
|
||||
};
|
||||
|
||||
static void strbuf_init( struct SStringBuf *apStr, char *apBuf, const char *apMaxStr )
|
||||
{
|
||||
apStr->str = apBuf;
|
||||
apStr->orgStr = apBuf;
|
||||
apStr->nulPos = apMaxStr-1;
|
||||
apStr->curLen = 0;
|
||||
|
||||
memset( &apStr->flags, '\0', sizeof( apStr->flags ) );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static BaseType_t strbuf_printchar( struct SStringBuf *apStr, int c )
|
||||
{
|
||||
if( apStr->str == NULL )
|
||||
{
|
||||
vOutputChar( ( char ) c, xTicksToWait );
|
||||
apStr->curLen++;
|
||||
return pdTRUE;
|
||||
}
|
||||
if( apStr->str < apStr->nulPos )
|
||||
{
|
||||
*( apStr->str++ ) = c;
|
||||
apStr->curLen++;
|
||||
return pdTRUE;
|
||||
}
|
||||
if( apStr->str == apStr->nulPos )
|
||||
{
|
||||
*( apStr->str++ ) = '\0';
|
||||
}
|
||||
return pdFALSE;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static portINLINE BaseType_t strbuf_printchar_inline( struct SStringBuf *apStr, int c )
|
||||
{
|
||||
if( apStr->str == NULL )
|
||||
{
|
||||
vOutputChar( ( char ) c, xTicksToWait );
|
||||
if( c == 0 )
|
||||
{
|
||||
return pdFALSE;
|
||||
}
|
||||
apStr->curLen++;
|
||||
return pdTRUE;
|
||||
}
|
||||
if( apStr->str < apStr->nulPos )
|
||||
{
|
||||
*(apStr->str++) = c;
|
||||
if( c == 0 )
|
||||
{
|
||||
return pdFALSE;
|
||||
}
|
||||
apStr->curLen++;
|
||||
return pdTRUE;
|
||||
}
|
||||
if( apStr->str == apStr->nulPos )
|
||||
{
|
||||
*( apStr->str++ ) = '\0';
|
||||
}
|
||||
return pdFALSE;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static portINLINE int i2hex( int aCh )
|
||||
{
|
||||
int iResult;
|
||||
|
||||
if( aCh < 10 )
|
||||
{
|
||||
iResult = '0' + aCh;
|
||||
}
|
||||
else
|
||||
{
|
||||
iResult = 'A' + aCh - 10;
|
||||
}
|
||||
|
||||
return iResult;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static BaseType_t prints(struct SStringBuf *apBuf, const char *apString )
|
||||
{
|
||||
register int padchar = ' ';
|
||||
int i,len;
|
||||
|
||||
if( xApplicationMemoryPermissions( ( uint32_t )apString ) == 0 )
|
||||
{
|
||||
/* The user has probably made a mistake with the parameter
|
||||
for '%s', the memory is not readbale. */
|
||||
apString = "INV_MEM";
|
||||
}
|
||||
|
||||
if( apBuf->flags.width > 0 )
|
||||
{
|
||||
register int len = 0;
|
||||
register const char *ptr;
|
||||
for( ptr = apString; *ptr; ++ptr )
|
||||
{
|
||||
++len;
|
||||
}
|
||||
|
||||
if( len >= apBuf->flags.width )
|
||||
{
|
||||
apBuf->flags.width = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
apBuf->flags.width -= len;
|
||||
}
|
||||
|
||||
if( apBuf->flags.pad & PAD_ZERO )
|
||||
{
|
||||
padchar = '0';
|
||||
}
|
||||
}
|
||||
if( ( apBuf->flags.pad & PAD_RIGHT ) == 0 )
|
||||
{
|
||||
for( ; apBuf->flags.width > 0; --apBuf->flags.width )
|
||||
{
|
||||
if( strbuf_printchar( apBuf, padchar ) == 0 )
|
||||
{
|
||||
return pdFALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( ( apBuf->flags.isNumber == pdTRUE ) && ( apBuf->flags.pad == pdTRUE ) )
|
||||
{
|
||||
/* The string to print represents an integer number.
|
||||
* In this case, printLimit is the min number of digits to print
|
||||
* If the length of the number to print is less than the min nb of i
|
||||
* digits to display, we add 0 before printing the number
|
||||
*/
|
||||
len = strlen( apString );
|
||||
|
||||
if( len < apBuf->flags.printLimit )
|
||||
{
|
||||
i = apBuf->flags.printLimit - len;
|
||||
for( ; i; i-- )
|
||||
{
|
||||
if( strbuf_printchar( apBuf, '0' ) == 0 )
|
||||
{
|
||||
return pdFALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* The string to print is not the result of a number conversion to ascii.
|
||||
* For a string, printLimit is the max number of characters to display
|
||||
*/
|
||||
for( ; apBuf->flags.printLimit && *apString ; ++apString, --apBuf->flags.printLimit )
|
||||
{
|
||||
if( !strbuf_printchar( apBuf, *apString ) )
|
||||
{
|
||||
return pdFALSE;
|
||||
}
|
||||
}
|
||||
|
||||
for( ; apBuf->flags.width > 0; --apBuf->flags.width )
|
||||
{
|
||||
if( !strbuf_printchar( apBuf, padchar ) )
|
||||
{
|
||||
return pdFALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return pdTRUE;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* the following should be enough for 32 bit int */
|
||||
#define PRINT_BUF_LEN 12 /* to print 4294967296 */
|
||||
|
||||
#if SPRINTF_LONG_LONG
|
||||
#warning 64-bit libraries will be included as well
|
||||
static BaseType_t printll( struct SStringBuf *apBuf, long long i )
|
||||
{
|
||||
char print_buf[ 2 * PRINT_BUF_LEN ];
|
||||
register char *s;
|
||||
register int t, neg = 0;
|
||||
register unsigned long long u = i;
|
||||
lldiv_t lldiv_result;
|
||||
|
||||
/* typedef struct
|
||||
* {
|
||||
* long long int quot; // quotient
|
||||
* long long int rem; // remainder
|
||||
* } lldiv_t;
|
||||
*/
|
||||
|
||||
apBuf->flags.isNumber = pdTRUE; /* Parameter for prints */
|
||||
if( i == 0LL )
|
||||
{
|
||||
print_buf[ 0 ] = '0';
|
||||
print_buf[ 1 ] = '\0';
|
||||
return prints( apBuf, print_buf );
|
||||
}
|
||||
|
||||
if( ( apBuf->flags.isSigned == pdTRUE ) && ( apBuf->flags.base == 10 ) && ( i < 0LL ) )
|
||||
{
|
||||
neg = 1;
|
||||
u = -i;
|
||||
}
|
||||
|
||||
s = print_buf + sizeof( print_buf ) - 1;
|
||||
|
||||
*s = '\0';
|
||||
/* 18446744073709551616 */
|
||||
while( u != 0 )
|
||||
{
|
||||
lldiv_result = lldiv( u, ( unsigned long long ) apBuf->flags.base );
|
||||
t = lldiv_result.rem;
|
||||
if( t >= 10 )
|
||||
{
|
||||
t += apBuf->flags.letBase - '0' - 10;
|
||||
}
|
||||
*( --s ) = t + '0';
|
||||
u = lldiv_result.quot;
|
||||
}
|
||||
|
||||
if( neg != 0 )
|
||||
{
|
||||
if( ( apBuf->flags.width != 0 ) && ( apBuf->flags.pad & PAD_ZERO ) )
|
||||
{
|
||||
if( !strbuf_printchar( apBuf, '-' ) )
|
||||
{
|
||||
return pdFALSE;
|
||||
}
|
||||
--apBuf->flags.width;
|
||||
}
|
||||
else
|
||||
{
|
||||
*( --s ) = '-';
|
||||
}
|
||||
}
|
||||
|
||||
return prints( apBuf, s );
|
||||
}
|
||||
#endif /* SPRINTF_LONG_LONG */
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static BaseType_t printi( struct SStringBuf *apBuf, int i )
|
||||
{
|
||||
char print_buf[ PRINT_BUF_LEN ];
|
||||
register char *s;
|
||||
register int t, neg = 0;
|
||||
register unsigned int u = i;
|
||||
register unsigned base = apBuf->flags.base;
|
||||
|
||||
apBuf->flags.isNumber = pdTRUE; /* Parameter for prints */
|
||||
|
||||
if( i == 0 )
|
||||
{
|
||||
print_buf[ 0 ] = '0';
|
||||
print_buf[ 1 ] = '\0';
|
||||
return prints( apBuf, print_buf );
|
||||
}
|
||||
|
||||
if( ( apBuf->flags.isSigned == pdTRUE ) && ( base == 10 ) && ( i < 0 ) )
|
||||
{
|
||||
neg = 1;
|
||||
u = -i;
|
||||
}
|
||||
|
||||
s = print_buf + sizeof( print_buf ) - 1;
|
||||
|
||||
*s = '\0';
|
||||
switch( base )
|
||||
{
|
||||
case 16:
|
||||
while( u != 0 )
|
||||
{
|
||||
t = u & 0xF;
|
||||
if( t >= 10 )
|
||||
{
|
||||
t += apBuf->flags.letBase - '0' - 10;
|
||||
}
|
||||
*( --s ) = t + '0';
|
||||
u >>= 4;
|
||||
}
|
||||
break;
|
||||
|
||||
case 8:
|
||||
case 10:
|
||||
/* GCC compiles very efficient */
|
||||
while( u )
|
||||
{
|
||||
t = u % base;
|
||||
*( --s ) = t + '0';
|
||||
u /= base;
|
||||
}
|
||||
break;
|
||||
/*
|
||||
// The generic case, not yet in use
|
||||
default:
|
||||
while( u )
|
||||
{
|
||||
t = u % base;
|
||||
if( t >= 10)
|
||||
{
|
||||
t += apBuf->flags.letBase - '0' - 10;
|
||||
}
|
||||
*( --s ) = t + '0';
|
||||
u /= base;
|
||||
}
|
||||
break;
|
||||
*/
|
||||
}
|
||||
|
||||
if( neg != 0 )
|
||||
{
|
||||
if( apBuf->flags.width && (apBuf->flags.pad & PAD_ZERO ) )
|
||||
{
|
||||
if( strbuf_printchar( apBuf, '-' ) == 0 )
|
||||
{
|
||||
return pdFALSE;
|
||||
}
|
||||
--apBuf->flags.width;
|
||||
}
|
||||
else
|
||||
{
|
||||
*( --s ) = '-';
|
||||
}
|
||||
}
|
||||
|
||||
return prints( apBuf, s );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static BaseType_t printIp(struct SStringBuf *apBuf, unsigned i )
|
||||
{
|
||||
char print_buf[16];
|
||||
|
||||
sprintf( print_buf, "%u.%u.%u.%u",
|
||||
i >> 24,
|
||||
( i >> 16 ) & 0xff,
|
||||
( i >> 8 ) & 0xff,
|
||||
i & 0xff );
|
||||
apBuf->flags.isNumber = pdTRUE; /* Parameter for prints */
|
||||
prints( apBuf, print_buf );
|
||||
|
||||
return pdTRUE;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void tiny_print( struct SStringBuf *apBuf, const char *format, va_list args )
|
||||
{
|
||||
char scr[2];
|
||||
|
||||
for( ; ; )
|
||||
{
|
||||
int ch = *( format++ );
|
||||
|
||||
if( ch != '%' )
|
||||
{
|
||||
do
|
||||
{
|
||||
/* Put the most like flow in a small loop */
|
||||
if( strbuf_printchar_inline( apBuf, ch ) == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
ch = *( format++ );
|
||||
} while( ch != '%' );
|
||||
}
|
||||
ch = *( format++ );
|
||||
/* Now ch has character after '%', format pointing to next */
|
||||
|
||||
if( ch == '\0' )
|
||||
{
|
||||
break;
|
||||
}
|
||||
if( ch == '%' )
|
||||
{
|
||||
if( strbuf_printchar( apBuf, ch ) == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
memset( &apBuf->flags, '\0', sizeof( apBuf->flags ) );
|
||||
|
||||
if( ch == '-' )
|
||||
{
|
||||
ch = *( format++ );
|
||||
apBuf->flags.pad = PAD_RIGHT;
|
||||
}
|
||||
while( ch == '0' )
|
||||
{
|
||||
ch = *( format++ );
|
||||
apBuf->flags.pad |= PAD_ZERO;
|
||||
}
|
||||
if( ch == '*' )
|
||||
{
|
||||
ch = *( format++ );
|
||||
apBuf->flags.width = va_arg( args, int );
|
||||
}
|
||||
else
|
||||
{
|
||||
while( ch >= '0' && ch <= '9' )
|
||||
{
|
||||
apBuf->flags.width *= 10;
|
||||
apBuf->flags.width += ch - '0';
|
||||
ch = *( format++ );
|
||||
}
|
||||
}
|
||||
if( ch == '.' )
|
||||
{
|
||||
ch = *( format++ );
|
||||
if( ch == '*' )
|
||||
{
|
||||
apBuf->flags.printLimit = va_arg( args, int );
|
||||
ch = *( format++ );
|
||||
}
|
||||
else
|
||||
{
|
||||
while( ch >= '0' && ch <= '9' )
|
||||
{
|
||||
apBuf->flags.printLimit *= 10;
|
||||
apBuf->flags.printLimit += ch - '0';
|
||||
ch = *( format++ );
|
||||
}
|
||||
}
|
||||
}
|
||||
if( apBuf->flags.printLimit == 0 )
|
||||
{
|
||||
apBuf->flags.printLimit--; /* -1: make it unlimited */
|
||||
}
|
||||
if( ch == 's' )
|
||||
{
|
||||
register char *s = ( char * )va_arg( args, int );
|
||||
if( prints( apBuf, s ? s : "(null)" ) == 0 )
|
||||
{
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if( ch == 'c' )
|
||||
{
|
||||
/* char are converted to int then pushed on the stack */
|
||||
scr[0] = ( char ) va_arg( args, int );
|
||||
|
||||
if( strbuf_printchar( apBuf, scr[0] ) == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
if( ch == 'l' )
|
||||
{
|
||||
ch = *( format++ );
|
||||
apBuf->flags.long32 = 1;
|
||||
/* Makes not difference as u32 == long */
|
||||
}
|
||||
if( ch == 'L' )
|
||||
{
|
||||
ch = *( format++ );
|
||||
apBuf->flags.long64 = 1;
|
||||
/* Does make a difference */
|
||||
}
|
||||
apBuf->flags.base = 10;
|
||||
apBuf->flags.letBase = 'a';
|
||||
|
||||
if( ch == 'd' || ch == 'u' )
|
||||
{
|
||||
apBuf->flags.isSigned = ( ch == 'd' );
|
||||
#if SPRINTF_LONG_LONG
|
||||
if( apBuf->flags.long64 != pdFALSE )
|
||||
{
|
||||
if( printll( apBuf, va_arg( args, long long ) ) == 0 )
|
||||
{
|
||||
break;
|
||||
}
|
||||
} else
|
||||
#endif /* SPRINTF_LONG_LONG */
|
||||
if( printi( apBuf, va_arg( args, int ) ) == 0 )
|
||||
{
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
apBuf->flags.base = 16; /* From here all hexadecimal */
|
||||
|
||||
if( ch == 'x' && format[0] == 'i' && format[1] == 'p' )
|
||||
{
|
||||
format += 2; /* eat the "xi" of "xip" */
|
||||
/* Will use base 10 again */
|
||||
if( printIp( apBuf, va_arg( args, int ) ) == 0 )
|
||||
{
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if( ch == 'x' || ch == 'X' || ch == 'p' || ch == 'o' )
|
||||
{
|
||||
if( ch == 'X' )
|
||||
{
|
||||
apBuf->flags.letBase = 'A';
|
||||
}
|
||||
else if( ch == 'o' )
|
||||
{
|
||||
apBuf->flags.base = 8;
|
||||
}
|
||||
#if SPRINTF_LONG_LONG
|
||||
if( apBuf->flags.long64 != pdFALSE )
|
||||
{
|
||||
if( printll( apBuf, va_arg( args, long long ) ) == 0 )
|
||||
{
|
||||
break;
|
||||
}
|
||||
} else
|
||||
#endif /* SPRINTF_LONG_LONG */
|
||||
if( printi( apBuf, va_arg( args, int ) ) == 0 )
|
||||
{
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
strbuf_printchar( apBuf, '\0' );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
int vsnprintf( char *apBuf, size_t aMaxLen, const char *apFmt, va_list args )
|
||||
{
|
||||
struct SStringBuf strBuf;
|
||||
strbuf_init( &strBuf, apBuf, ( const char* )apBuf + aMaxLen );
|
||||
tiny_print( &strBuf, apFmt, args );
|
||||
|
||||
return strBuf.curLen;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
int snprintf( char *apBuf, size_t aMaxLen, const char *apFmt, ... )
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start( args, apFmt );
|
||||
struct SStringBuf strBuf;
|
||||
strbuf_init( &strBuf, apBuf, ( const char* )apBuf + aMaxLen );
|
||||
tiny_print( &strBuf, apFmt, args );
|
||||
va_end( args );
|
||||
|
||||
return strBuf.curLen;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
int sprintf( char *apBuf, const char *apFmt, ... )
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start( args, apFmt );
|
||||
struct SStringBuf strBuf;
|
||||
strbuf_init( &strBuf, apBuf, ( const char * )apBuf + 1024 );
|
||||
tiny_print( &strBuf, apFmt, args );
|
||||
va_end( args );
|
||||
|
||||
return strBuf.curLen;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
int vsprintf( char *apBuf, const char *apFmt, va_list args )
|
||||
{
|
||||
struct SStringBuf strBuf;
|
||||
strbuf_init( &strBuf, apBuf, ( const char* ) apBuf + 1024 );
|
||||
tiny_print( &strBuf, apFmt, args );
|
||||
|
||||
return strBuf.curLen;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
const char *mkSize (unsigned long long aSize, char *apBuf, int aLen)
|
||||
{
|
||||
static char retString[33];
|
||||
size_t gb, mb, kb, sb;
|
||||
|
||||
if (apBuf == NULL) {
|
||||
apBuf = retString;
|
||||
aLen = sizeof( retString );
|
||||
}
|
||||
gb = aSize / (1024*1024*1024);
|
||||
aSize -= gb * (1024*1024*1024);
|
||||
mb = aSize / (1024*1024);
|
||||
aSize -= mb * (1024*1024);
|
||||
kb = aSize / (1024);
|
||||
aSize -= kb * (1024);
|
||||
sb = aSize;
|
||||
if( gb )
|
||||
{
|
||||
snprintf (apBuf, aLen, "%u.%02u GB", ( unsigned ) gb, ( unsigned ) ( ( 100 * mb ) / 1024ul ) );
|
||||
}
|
||||
else if( mb )
|
||||
{
|
||||
snprintf (apBuf, aLen, "%u.%02u MB", ( unsigned ) mb, ( unsigned ) ( ( 100 * kb) / 1024ul ) );
|
||||
}
|
||||
else if( kb != 0ul )
|
||||
{
|
||||
snprintf (apBuf, aLen, "%u.%02u KB", ( unsigned ) kb, ( unsigned ) ( ( 100 * sb) / 1024ul ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf (apBuf, aLen, "%u bytes", ( unsigned ) sb);
|
||||
}
|
||||
return apBuf;
|
||||
}
|
Loading…
Reference in New Issue