diff --git a/Software/VNA_embedded/.cproject b/Software/VNA_embedded/.cproject
index 41f3bde..3cc9c10 100644
--- a/Software/VNA_embedded/.cproject
+++ b/Software/VNA_embedded/.cproject
@@ -1,812 +1,268 @@
-
-
+ size_t xMessageBufferNextLengthBytes( MessageBufferHandle_t xMessageBuffer ) ); ++ * Returns the length (in bytes) of the next message in a message buffer. + * Useful if xMessageBufferReceive() returned 0 because the size of the buffer + * passed into xMessageBufferReceive() was too small to hold the next message. + * + * @param xMessageBuffer The handle of the message buffer being queried. + * + * @return The length (in bytes) of the next message in the message buffer, or 0 + * if the message buffer is empty. + * + * \defgroup xMessageBufferNextLengthBytes xMessageBufferNextLengthBytes + * \ingroup MessageBufferManagement + */ +#define xMessageBufferNextLengthBytes( xMessageBuffer ) xStreamBufferNextMessageLengthBytes( ( StreamBufferHandle_t ) xMessageBuffer ) PRIVILEGED_FUNCTION; /** * message_buffer.h diff --git a/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/include/mpu_prototypes.h b/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/include/mpu_prototypes.h index a08d748..79a185b 100644 --- a/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/include/mpu_prototypes.h +++ b/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/include/mpu_prototypes.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.0.1 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.3.1 + * 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 @@ -38,116 +38,121 @@ #define MPU_PROTOTYPES_H /* MPU versions of tasks.h API functions. */ -BaseType_t MPU_xTaskCreate( TaskFunction_t pxTaskCode, const char * const pcName, const uint16_t usStackDepth, void * const pvParameters, UBaseType_t uxPriority, TaskHandle_t * const pxCreatedTask ); -TaskHandle_t MPU_xTaskCreateStatic( TaskFunction_t pxTaskCode, const char * const pcName, const uint32_t ulStackDepth, void * const pvParameters, UBaseType_t uxPriority, StackType_t * const puxStackBuffer, StaticTask_t * const pxTaskBuffer ); -BaseType_t MPU_xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition, TaskHandle_t *pxCreatedTask ); -BaseType_t MPU_xTaskCreateRestrictedStatic( const TaskParameters_t * const pxTaskDefinition, TaskHandle_t *pxCreatedTask ); -void MPU_vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const pxRegions ); -void MPU_vTaskDelete( TaskHandle_t xTaskToDelete ); -void MPU_vTaskDelay( const TickType_t xTicksToDelay ); -void MPU_vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xTimeIncrement ); -BaseType_t MPU_xTaskAbortDelay( TaskHandle_t xTask ); -UBaseType_t MPU_uxTaskPriorityGet( TaskHandle_t xTask ); -eTaskState MPU_eTaskGetState( TaskHandle_t xTask ); -void MPU_vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xGetFreeStackSpace, eTaskState eState ); -void MPU_vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority ); -void MPU_vTaskSuspend( TaskHandle_t xTaskToSuspend ); -void MPU_vTaskResume( TaskHandle_t xTaskToResume ); -void MPU_vTaskStartScheduler( void ); -void MPU_vTaskSuspendAll( void ); -BaseType_t MPU_xTaskResumeAll( void ); -TickType_t MPU_xTaskGetTickCount( void ); -UBaseType_t MPU_uxTaskGetNumberOfTasks( void ); -char * MPU_pcTaskGetName( TaskHandle_t xTaskToQuery ); -TaskHandle_t MPU_xTaskGetHandle( const char *pcNameToQuery ); -UBaseType_t MPU_uxTaskGetStackHighWaterMark( TaskHandle_t xTask ); -void MPU_vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxHookFunction ); -TaskHookFunction_t MPU_xTaskGetApplicationTaskTag( TaskHandle_t xTask ); -void MPU_vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet, BaseType_t xIndex, void *pvValue ); -void * MPU_pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery, BaseType_t xIndex ); -BaseType_t MPU_xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter ); -TaskHandle_t MPU_xTaskGetIdleTaskHandle( void ); -UBaseType_t MPU_uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const UBaseType_t uxArraySize, uint32_t * const pulTotalRunTime ); -void MPU_vTaskList( char * pcWriteBuffer ); -void MPU_vTaskGetRunTimeStats( char *pcWriteBuffer ); -BaseType_t MPU_xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue ); -BaseType_t MPU_xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait ); -uint32_t MPU_ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait ); -BaseType_t MPU_xTaskNotifyStateClear( TaskHandle_t xTask ); -BaseType_t MPU_xTaskIncrementTick( void ); -TaskHandle_t MPU_xTaskGetCurrentTaskHandle( void ); -void MPU_vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ); -BaseType_t MPU_xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait ); -void MPU_vTaskMissedYield( void ); -BaseType_t MPU_xTaskGetSchedulerState( void ); +BaseType_t MPU_xTaskCreate( TaskFunction_t pxTaskCode, const char * const pcName, const uint16_t usStackDepth, void * const pvParameters, UBaseType_t uxPriority, TaskHandle_t * const pxCreatedTask ) FREERTOS_SYSTEM_CALL; +TaskHandle_t MPU_xTaskCreateStatic( TaskFunction_t pxTaskCode, const char * const pcName, const uint32_t ulStackDepth, void * const pvParameters, UBaseType_t uxPriority, StackType_t * const puxStackBuffer, StaticTask_t * const pxTaskBuffer ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition, TaskHandle_t *pxCreatedTask ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskCreateRestrictedStatic( const TaskParameters_t * const pxTaskDefinition, TaskHandle_t *pxCreatedTask ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const pxRegions ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskDelete( TaskHandle_t xTaskToDelete ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskDelay( const TickType_t xTicksToDelay ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xTimeIncrement ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskAbortDelay( TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxTaskPriorityGet( const TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL; +eTaskState MPU_eTaskGetState( TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xGetFreeStackSpace, eTaskState eState ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskSuspend( TaskHandle_t xTaskToSuspend ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskResume( TaskHandle_t xTaskToResume ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskStartScheduler( void ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskSuspendAll( void ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskResumeAll( void ) FREERTOS_SYSTEM_CALL; +TickType_t MPU_xTaskGetTickCount( void ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxTaskGetNumberOfTasks( void ) FREERTOS_SYSTEM_CALL; +char * MPU_pcTaskGetName( TaskHandle_t xTaskToQuery ) FREERTOS_SYSTEM_CALL; +TaskHandle_t MPU_xTaskGetHandle( const char *pcNameToQuery ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL; +configSTACK_DEPTH_TYPE MPU_uxTaskGetStackHighWaterMark2( TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxHookFunction ) FREERTOS_SYSTEM_CALL; +TaskHookFunction_t MPU_xTaskGetApplicationTaskTag( TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet, BaseType_t xIndex, void *pvValue ) FREERTOS_SYSTEM_CALL; +void * MPU_pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery, BaseType_t xIndex ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter ) FREERTOS_SYSTEM_CALL; +TaskHandle_t MPU_xTaskGetIdleTaskHandle( void ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const UBaseType_t uxArraySize, uint32_t * const pulTotalRunTime ) FREERTOS_SYSTEM_CALL; +uint32_t MPU_ulTaskGetIdleRunTimeCounter( void ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskList( char * pcWriteBuffer ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskGetRunTimeStats( char *pcWriteBuffer ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +uint32_t MPU_ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskNotifyStateClear( TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL; +uint32_t MPU_ulTaskNotifyValueClear( TaskHandle_t xTask, uint32_t ulBitsToClear ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskIncrementTick( void ) FREERTOS_SYSTEM_CALL; +TaskHandle_t MPU_xTaskGetCurrentTaskHandle( void ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskMissedYield( void ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskGetSchedulerState( void ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskCatchUpTicks( TickType_t xTicksToCatchUp ) FREERTOS_SYSTEM_CALL; /* MPU versions of queue.h API functions. */ -BaseType_t MPU_xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQueue, TickType_t xTicksToWait, const BaseType_t xCopyPosition ); -BaseType_t MPU_xQueueReceive( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait ); -BaseType_t MPU_xQueuePeek( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait ); -BaseType_t MPU_xQueueSemaphoreTake( QueueHandle_t xQueue, TickType_t xTicksToWait ); -UBaseType_t MPU_uxQueueMessagesWaiting( const QueueHandle_t xQueue ); -UBaseType_t MPU_uxQueueSpacesAvailable( const QueueHandle_t xQueue ); -void MPU_vQueueDelete( QueueHandle_t xQueue ); -QueueHandle_t MPU_xQueueCreateMutex( const uint8_t ucQueueType ); -QueueHandle_t MPU_xQueueCreateMutexStatic( const uint8_t ucQueueType, StaticQueue_t *pxStaticQueue ); -QueueHandle_t MPU_xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount ); -QueueHandle_t MPU_xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount, StaticQueue_t *pxStaticQueue ); -void* MPU_xQueueGetMutexHolder( QueueHandle_t xSemaphore ); -BaseType_t MPU_xQueueTakeMutexRecursive( QueueHandle_t xMutex, TickType_t xTicksToWait ); -BaseType_t MPU_xQueueGiveMutexRecursive( QueueHandle_t pxMutex ); -void MPU_vQueueAddToRegistry( QueueHandle_t xQueue, const char *pcName ); -void MPU_vQueueUnregisterQueue( QueueHandle_t xQueue ); -const char * MPU_pcQueueGetName( QueueHandle_t xQueue ); -QueueHandle_t MPU_xQueueGenericCreate( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, const uint8_t ucQueueType ); -QueueHandle_t MPU_xQueueGenericCreateStatic( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, uint8_t *pucQueueStorage, StaticQueue_t *pxStaticQueue, const uint8_t ucQueueType ); -QueueSetHandle_t MPU_xQueueCreateSet( const UBaseType_t uxEventQueueLength ); -BaseType_t MPU_xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet ); -BaseType_t MPU_xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet ); -QueueSetMemberHandle_t MPU_xQueueSelectFromSet( QueueSetHandle_t xQueueSet, const TickType_t xTicksToWait ); -BaseType_t MPU_xQueueGenericReset( QueueHandle_t xQueue, BaseType_t xNewQueue ); -void MPU_vQueueSetQueueNumber( QueueHandle_t xQueue, UBaseType_t uxQueueNumber ); -UBaseType_t MPU_uxQueueGetQueueNumber( QueueHandle_t xQueue ); -uint8_t MPU_ucQueueGetQueueType( QueueHandle_t xQueue ); +BaseType_t MPU_xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQueue, TickType_t xTicksToWait, const BaseType_t xCopyPosition ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xQueueReceive( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xQueuePeek( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xQueueSemaphoreTake( QueueHandle_t xQueue, TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxQueueMessagesWaiting( const QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxQueueSpacesAvailable( const QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL; +void MPU_vQueueDelete( QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL; +QueueHandle_t MPU_xQueueCreateMutex( const uint8_t ucQueueType ) FREERTOS_SYSTEM_CALL; +QueueHandle_t MPU_xQueueCreateMutexStatic( const uint8_t ucQueueType, StaticQueue_t *pxStaticQueue ) FREERTOS_SYSTEM_CALL; +QueueHandle_t MPU_xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount ) FREERTOS_SYSTEM_CALL; +QueueHandle_t MPU_xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount, StaticQueue_t *pxStaticQueue ) FREERTOS_SYSTEM_CALL; +TaskHandle_t MPU_xQueueGetMutexHolder( QueueHandle_t xSemaphore ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xQueueTakeMutexRecursive( QueueHandle_t xMutex, TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xQueueGiveMutexRecursive( QueueHandle_t pxMutex ) FREERTOS_SYSTEM_CALL; +void MPU_vQueueAddToRegistry( QueueHandle_t xQueue, const char *pcName ) FREERTOS_SYSTEM_CALL; +void MPU_vQueueUnregisterQueue( QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL; +const char * MPU_pcQueueGetName( QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL; +QueueHandle_t MPU_xQueueGenericCreate( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, const uint8_t ucQueueType ) FREERTOS_SYSTEM_CALL; +QueueHandle_t MPU_xQueueGenericCreateStatic( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, uint8_t *pucQueueStorage, StaticQueue_t *pxStaticQueue, const uint8_t ucQueueType ) FREERTOS_SYSTEM_CALL; +QueueSetHandle_t MPU_xQueueCreateSet( const UBaseType_t uxEventQueueLength ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet ) FREERTOS_SYSTEM_CALL; +QueueSetMemberHandle_t MPU_xQueueSelectFromSet( QueueSetHandle_t xQueueSet, const TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xQueueGenericReset( QueueHandle_t xQueue, BaseType_t xNewQueue ) FREERTOS_SYSTEM_CALL; +void MPU_vQueueSetQueueNumber( QueueHandle_t xQueue, UBaseType_t uxQueueNumber ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxQueueGetQueueNumber( QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL; +uint8_t MPU_ucQueueGetQueueType( QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL; /* MPU versions of timers.h API functions. */ -TimerHandle_t MPU_xTimerCreate( const char * const pcTimerName, const TickType_t xTimerPeriodInTicks, const UBaseType_t uxAutoReload, void * const pvTimerID, TimerCallbackFunction_t pxCallbackFunction ); -TimerHandle_t MPU_xTimerCreateStatic( const char * const pcTimerName, const TickType_t xTimerPeriodInTicks, const UBaseType_t uxAutoReload, void * const pvTimerID, TimerCallbackFunction_t pxCallbackFunction, StaticTimer_t *pxTimerBuffer ); -void * MPU_pvTimerGetTimerID( const TimerHandle_t xTimer ); -void MPU_vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID ); -BaseType_t MPU_xTimerIsTimerActive( TimerHandle_t xTimer ); -TaskHandle_t MPU_xTimerGetTimerDaemonTaskHandle( void ); -BaseType_t MPU_xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, TickType_t xTicksToWait ); -const char * MPU_pcTimerGetName( TimerHandle_t xTimer ); -TickType_t MPU_xTimerGetPeriod( TimerHandle_t xTimer ); -TickType_t MPU_xTimerGetExpiryTime( TimerHandle_t xTimer ); -BaseType_t MPU_xTimerCreateTimerTask( void ); -BaseType_t MPU_xTimerGenericCommand( TimerHandle_t xTimer, const BaseType_t xCommandID, const TickType_t xOptionalValue, BaseType_t * const pxHigherPriorityTaskWoken, const TickType_t xTicksToWait ); +TimerHandle_t MPU_xTimerCreate( const char * const pcTimerName, const TickType_t xTimerPeriodInTicks, const UBaseType_t uxAutoReload, void * const pvTimerID, TimerCallbackFunction_t pxCallbackFunction ) FREERTOS_SYSTEM_CALL; +TimerHandle_t MPU_xTimerCreateStatic( const char * const pcTimerName, const TickType_t xTimerPeriodInTicks, const UBaseType_t uxAutoReload, void * const pvTimerID, TimerCallbackFunction_t pxCallbackFunction, StaticTimer_t *pxTimerBuffer ) FREERTOS_SYSTEM_CALL; +void * MPU_pvTimerGetTimerID( const TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL; +void MPU_vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTimerIsTimerActive( TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL; +TaskHandle_t MPU_xTimerGetTimerDaemonTaskHandle( void ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +const char * MPU_pcTimerGetName( TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL; +void MPU_vTimerSetReloadMode( TimerHandle_t xTimer, const UBaseType_t uxAutoReload ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxTimerGetReloadMode( TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL; +TickType_t MPU_xTimerGetPeriod( TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL; +TickType_t MPU_xTimerGetExpiryTime( TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTimerCreateTimerTask( void ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTimerGenericCommand( TimerHandle_t xTimer, const BaseType_t xCommandID, const TickType_t xOptionalValue, BaseType_t * const pxHigherPriorityTaskWoken, const TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; /* MPU versions of event_group.h API functions. */ -EventGroupHandle_t MPU_xEventGroupCreate( void ); -EventGroupHandle_t MPU_xEventGroupCreateStatic( StaticEventGroup_t *pxEventGroupBuffer ); -EventBits_t MPU_xEventGroupWaitBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToWaitFor, const BaseType_t xClearOnExit, const BaseType_t xWaitForAllBits, TickType_t xTicksToWait ); -EventBits_t MPU_xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear ); -EventBits_t MPU_xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet ); -EventBits_t MPU_xEventGroupSync( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, const EventBits_t uxBitsToWaitFor, TickType_t xTicksToWait ); -void MPU_vEventGroupDelete( EventGroupHandle_t xEventGroup ); -UBaseType_t MPU_uxEventGroupGetNumber( void* xEventGroup ); +EventGroupHandle_t MPU_xEventGroupCreate( void ) FREERTOS_SYSTEM_CALL; +EventGroupHandle_t MPU_xEventGroupCreateStatic( StaticEventGroup_t *pxEventGroupBuffer ) FREERTOS_SYSTEM_CALL; +EventBits_t MPU_xEventGroupWaitBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToWaitFor, const BaseType_t xClearOnExit, const BaseType_t xWaitForAllBits, TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +EventBits_t MPU_xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear ) FREERTOS_SYSTEM_CALL; +EventBits_t MPU_xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet ) FREERTOS_SYSTEM_CALL; +EventBits_t MPU_xEventGroupSync( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, const EventBits_t uxBitsToWaitFor, TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +void MPU_vEventGroupDelete( EventGroupHandle_t xEventGroup ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxEventGroupGetNumber( void* xEventGroup ) FREERTOS_SYSTEM_CALL; /* MPU versions of message/stream_buffer.h API functions. */ -size_t MPU_xStreamBufferSend( StreamBufferHandle_t xStreamBuffer, const void *pvTxData, size_t xDataLengthBytes, TickType_t xTicksToWait ); -size_t MPU_xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer, const void *pvTxData, size_t xDataLengthBytes, BaseType_t * const pxHigherPriorityTaskWoken ); -size_t MPU_xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer, void *pvRxData, size_t xBufferLengthBytes, TickType_t xTicksToWait ); -size_t MPU_xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer, void *pvRxData, size_t xBufferLengthBytes, BaseType_t * const pxHigherPriorityTaskWoken ); -void MPU_vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ); -BaseType_t MPU_xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer ); -BaseType_t MPU_xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer ); -BaseType_t MPU_xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ); -size_t MPU_xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer ); -size_t MPU_xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer ); -BaseType_t MPU_xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer, size_t xTriggerLevel ); -StreamBufferHandle_t MPU_xStreamBufferGenericCreate( size_t xBufferSizeBytes, size_t xTriggerLevelBytes, BaseType_t xIsMessageBuffer ); -StreamBufferHandle_t MPU_xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes, size_t xTriggerLevelBytes, BaseType_t xIsMessageBuffer, uint8_t * const pucStreamBufferStorageArea, StaticStreamBuffer_t * const pxStaticStreamBuffer ); +size_t MPU_xStreamBufferSend( StreamBufferHandle_t xStreamBuffer, const void *pvTxData, size_t xDataLengthBytes, TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +size_t MPU_xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer, void *pvRxData, size_t xBufferLengthBytes, TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +size_t MPU_xStreamBufferNextMessageLengthBytes( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL; +void MPU_vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL; +size_t MPU_xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL; +size_t MPU_xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer, size_t xTriggerLevel ) FREERTOS_SYSTEM_CALL; +StreamBufferHandle_t MPU_xStreamBufferGenericCreate( size_t xBufferSizeBytes, size_t xTriggerLevelBytes, BaseType_t xIsMessageBuffer ) FREERTOS_SYSTEM_CALL; +StreamBufferHandle_t MPU_xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes, size_t xTriggerLevelBytes, BaseType_t xIsMessageBuffer, uint8_t * const pucStreamBufferStorageArea, StaticStreamBuffer_t * const pxStaticStreamBuffer ) FREERTOS_SYSTEM_CALL; diff --git a/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/include/mpu_wrappers.h b/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/include/mpu_wrappers.h index 1e97ae4..87a2f2c 100644 --- a/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/include/mpu_wrappers.h +++ b/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/include/mpu_wrappers.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.0.1 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.3.1 + * 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 @@ -67,6 +67,7 @@ only for ports that are using the MPU. */ #define pcTaskGetName MPU_pcTaskGetName #define xTaskGetHandle MPU_xTaskGetHandle #define uxTaskGetStackHighWaterMark MPU_uxTaskGetStackHighWaterMark + #define uxTaskGetStackHighWaterMark2 MPU_uxTaskGetStackHighWaterMark2 #define vTaskSetApplicationTaskTag MPU_vTaskSetApplicationTaskTag #define xTaskGetApplicationTaskTag MPU_xTaskGetApplicationTaskTag #define vTaskSetThreadLocalStoragePointer MPU_vTaskSetThreadLocalStoragePointer @@ -76,10 +77,13 @@ only for ports that are using the MPU. */ #define uxTaskGetSystemState MPU_uxTaskGetSystemState #define vTaskList MPU_vTaskList #define vTaskGetRunTimeStats MPU_vTaskGetRunTimeStats + #define ulTaskGetIdleRunTimeCounter MPU_ulTaskGetIdleRunTimeCounter #define xTaskGenericNotify MPU_xTaskGenericNotify #define xTaskNotifyWait MPU_xTaskNotifyWait #define ulTaskNotifyTake MPU_ulTaskNotifyTake #define xTaskNotifyStateClear MPU_xTaskNotifyStateClear + #define ulTaskNotifyValueClear MPU_ulTaskNotifyValueClear + #define xTaskCatchUpTicks MPU_xTaskCatchUpTicks #define xTaskGetCurrentTaskHandle MPU_xTaskGetCurrentTaskHandle #define vTaskSetTimeOutState MPU_vTaskSetTimeOutState @@ -124,6 +128,8 @@ only for ports that are using the MPU. */ #define xTimerGetTimerDaemonTaskHandle MPU_xTimerGetTimerDaemonTaskHandle #define xTimerPendFunctionCall MPU_xTimerPendFunctionCall #define pcTimerGetName MPU_pcTimerGetName + #define vTimerSetReloadMode MPU_vTimerSetReloadMode + #define uxTimerGetReloadMode MPU_uxTimerGetReloadMode #define xTimerGetPeriod MPU_xTimerGetPeriod #define xTimerGetExpiryTime MPU_xTimerGetExpiryTime #define xTimerGenericCommand MPU_xTimerGenericCommand @@ -140,9 +146,8 @@ only for ports that are using the MPU. */ /* Map standard message/stream_buffer.h API functions to the MPU equivalents. */ #define xStreamBufferSend MPU_xStreamBufferSend - #define xStreamBufferSendFromISR MPU_xStreamBufferSendFromISR #define xStreamBufferReceive MPU_xStreamBufferReceive - #define xStreamBufferReceiveFromISR MPU_xStreamBufferReceiveFromISR + #define xStreamBufferNextMessageLengthBytes MPU_xStreamBufferNextMessageLengthBytes #define vStreamBufferDelete MPU_vStreamBufferDelete #define xStreamBufferIsFull MPU_xStreamBufferIsFull #define xStreamBufferIsEmpty MPU_xStreamBufferIsEmpty @@ -159,12 +164,14 @@ only for ports that are using the MPU. */ (useful when using statically allocated objects). */ #define PRIVILEGED_FUNCTION #define PRIVILEGED_DATA __attribute__((section("privileged_data"))) + #define FREERTOS_SYSTEM_CALL #else /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */ /* Ensure API functions go in the privileged execution section. */ #define PRIVILEGED_FUNCTION __attribute__((section("privileged_functions"))) #define PRIVILEGED_DATA __attribute__((section("privileged_data"))) + #define FREERTOS_SYSTEM_CALL __attribute__((section( "freertos_system_calls"))) #endif /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */ @@ -172,6 +179,7 @@ only for ports that are using the MPU. */ #define PRIVILEGED_FUNCTION #define PRIVILEGED_DATA + #define FREERTOS_SYSTEM_CALL #define portUSING_MPU_WRAPPERS 0 #endif /* portUSING_MPU_WRAPPERS */ diff --git a/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/include/portable.h b/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/include/portable.h index 8aac353..47ceab9 100644 --- a/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/include/portable.h +++ b/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/include/portable.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.0.1 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.3.1 + * 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 @@ -84,6 +84,14 @@ must be set in the compiler's include path. */ #define portNUM_CONFIGURABLE_REGIONS 1 #endif +#ifndef portHAS_STACK_OVERFLOW_CHECKING + #define portHAS_STACK_OVERFLOW_CHECKING 0 +#endif + +#ifndef portARCH_NAME + #define portARCH_NAME NULL +#endif + #ifdef __cplusplus extern "C" { #endif @@ -97,18 +105,39 @@ extern "C" { * */ #if( portUSING_MPU_WRAPPERS == 1 ) - StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION; + #if( portHAS_STACK_OVERFLOW_CHECKING == 1 ) + StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, StackType_t *pxEndOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION; + #else + StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION; + #endif #else - StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) PRIVILEGED_FUNCTION; + #if( portHAS_STACK_OVERFLOW_CHECKING == 1 ) + StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, StackType_t *pxEndOfStack, TaskFunction_t pxCode, void *pvParameters ) PRIVILEGED_FUNCTION; + #else + StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) PRIVILEGED_FUNCTION; + #endif #endif -/* Used by heap_5.c. */ +/* Used by heap_5.c to define the start address and size of each memory region +that together comprise the total FreeRTOS heap space. */ typedef struct HeapRegion { uint8_t *pucStartAddress; size_t xSizeInBytes; } HeapRegion_t; +/* Used to pass information about the heap out of vPortGetHeapStats(). */ +typedef struct xHeapStats +{ + size_t xAvailableHeapSpaceInBytes; /* The total heap size currently available - this is the sum of all the free blocks, not the largest block that can be allocated. */ + size_t xSizeOfLargestFreeBlockInBytes; /* The maximum size, in bytes, of all the free blocks within the heap at the time vPortGetHeapStats() is called. */ + size_t xSizeOfSmallestFreeBlockInBytes; /* The minimum size, in bytes, of all the free blocks within the heap at the time vPortGetHeapStats() is called. */ + size_t xNumberOfFreeBlocks; /* The number of free memory blocks within the heap at the time vPortGetHeapStats() is called. */ + size_t xMinimumEverFreeBytesRemaining; /* The minimum amount of total free memory (sum of all free blocks) there has been in the heap since the system booted. */ + size_t xNumberOfSuccessfulAllocations; /* The number of calls to pvPortMalloc() that have returned a valid memory block. */ + size_t xNumberOfSuccessfulFrees; /* The number of calls to vPortFree() that has successfully freed a block of memory. */ +} HeapStats_t; + /* * Used to define multiple heap regions for use by heap_5.c. This function * must be called before any calls to pvPortMalloc() - not creating a task, @@ -122,6 +151,11 @@ typedef struct HeapRegion */ void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ) PRIVILEGED_FUNCTION; +/* + * Returns a HeapStats_t structure filled with information about the current + * heap state. + */ +void vPortGetHeapStats( HeapStats_t *pxHeapStats ); /* * Map to the memory management routines required for the port. diff --git a/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/include/projdefs.h b/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/include/projdefs.h index d4aa198..75d4155 100644 --- a/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/include/projdefs.h +++ b/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/include/projdefs.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.0.1 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.3.1 + * 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 diff --git a/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/include/queue.h b/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/include/queue.h index 2895205..fb82315 100644 --- a/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/include/queue.h +++ b/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/include/queue.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.0.1 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.3.1 + * 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 @@ -37,27 +37,29 @@ extern "C" { #endif +#include "task.h" /** * Type by which queues are referenced. For example, a call to xQueueCreate() * returns an QueueHandle_t variable that can then be used as a parameter to * xQueueSend(), xQueueReceive(), etc. */ -typedef void * QueueHandle_t; +struct QueueDefinition; /* Using old naming convention so as not to break kernel aware debuggers. */ +typedef struct QueueDefinition * QueueHandle_t; /** * Type by which queue sets are referenced. For example, a call to * xQueueCreateSet() returns an xQueueSet variable that can then be used as a * parameter to xQueueSelectFromSet(), xQueueAddToSet(), etc. */ -typedef void * QueueSetHandle_t; +typedef struct QueueDefinition * QueueSetHandle_t; /** * Queue sets can contain both queues and semaphores, so the * QueueSetMemberHandle_t is defined as a type to be used where a parameter or * return value can be either an QueueHandle_t or an SemaphoreHandle_t. */ -typedef void * QueueSetMemberHandle_t; +typedef struct QueueDefinition * QueueSetMemberHandle_t; /* For internal use only. */ #define queueSEND_TO_BACK ( ( BaseType_t ) 0 ) @@ -1282,7 +1284,7 @@ uint32_t ulVarToSend, ulValReceived; // name of the yield function required is port specific. if( xHigherPriorityTaskWokenByPost ) { - taskYIELD_YIELD_FROM_ISR(); + portYIELD_FROM_ISR(); } } @@ -1414,15 +1416,15 @@ QueueHandle_t xQueueCreateMutexStatic( const uint8_t ucQueueType, StaticQueue_t QueueHandle_t xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount ) PRIVILEGED_FUNCTION; QueueHandle_t xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount, StaticQueue_t *pxStaticQueue ) PRIVILEGED_FUNCTION; BaseType_t xQueueSemaphoreTake( QueueHandle_t xQueue, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; -void* xQueueGetMutexHolder( QueueHandle_t xSemaphore ) PRIVILEGED_FUNCTION; -void* xQueueGetMutexHolderFromISR( QueueHandle_t xSemaphore ) PRIVILEGED_FUNCTION; +TaskHandle_t xQueueGetMutexHolder( QueueHandle_t xSemaphore ) PRIVILEGED_FUNCTION; +TaskHandle_t xQueueGetMutexHolderFromISR( QueueHandle_t xSemaphore ) PRIVILEGED_FUNCTION; /* * For internal use only. Use xSemaphoreTakeMutexRecursive() or * xSemaphoreGiveMutexRecursive() instead of calling these functions directly. */ BaseType_t xQueueTakeMutexRecursive( QueueHandle_t xMutex, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; -BaseType_t xQueueGiveMutexRecursive( QueueHandle_t pxMutex ) PRIVILEGED_FUNCTION; +BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex ) PRIVILEGED_FUNCTION; /* * Reset a queue back to its original empty state. The return value is now @@ -1453,7 +1455,7 @@ BaseType_t xQueueGiveMutexRecursive( QueueHandle_t pxMutex ) PRIVILEGED_FUNCTION * preferably in ROM/Flash), not on the stack. */ #if( configQUEUE_REGISTRY_SIZE > 0 ) - void vQueueAddToRegistry( QueueHandle_t xQueue, const char *pcName ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + void vQueueAddToRegistry( QueueHandle_t xQueue, const char *pcQueueName ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ #endif /* diff --git a/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/include/semphr.h b/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/include/semphr.h index 0f58285..ff21a39 100644 --- a/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/include/semphr.h +++ b/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/include/semphr.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.0.1 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.3.1 + * 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 diff --git a/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/include/stack_macros.h b/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/include/stack_macros.h index e8515b3..c505574 100644 --- a/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/include/stack_macros.h +++ b/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/include/stack_macros.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.0.1 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.3.1 + * 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 @@ -82,10 +82,10 @@ const uint32_t * const pulStack = ( uint32_t * ) pxCurrentTCB->pxStack; \ const uint32_t ulCheckValue = ( uint32_t ) 0xa5a5a5a5; \ \ - if( ( pulStack[ 0 ] != ulCheckValue ) || \ - ( pulStack[ 1 ] != ulCheckValue ) || \ - ( pulStack[ 2 ] != ulCheckValue ) || \ - ( pulStack[ 3 ] != ulCheckValue ) ) \ + if( ( pulStack[ 0 ] != ulCheckValue ) || \ + ( pulStack[ 1 ] != ulCheckValue ) || \ + ( pulStack[ 2 ] != ulCheckValue ) || \ + ( pulStack[ 3 ] != ulCheckValue ) ) \ { \ vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ } \ diff --git a/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/include/stream_buffer.h b/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/include/stream_buffer.h index f967dd2..3605703 100644 --- a/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/include/stream_buffer.h +++ b/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/include/stream_buffer.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.0.1 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.3.1 + * 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 @@ -43,7 +43,7 @@ * (such as xStreamBufferSend()) inside a critical section and set the send * block time to 0. Likewise, if there are to be multiple different readers * then the application writer must place each call to a reading API function - * (such as xStreamBufferRead()) inside a critical section section and set the + * (such as xStreamBufferReceive()) inside a critical section section and set the * receive block time to 0. * */ @@ -51,6 +51,10 @@ #ifndef STREAM_BUFFER_H #define STREAM_BUFFER_H +#ifndef INC_FREERTOS_H + #error "include FreeRTOS.h must appear in source files before include stream_buffer.h" +#endif + #if defined( __cplusplus ) extern "C" { #endif @@ -61,7 +65,8 @@ extern "C" { * then be used as a parameter to xStreamBufferSend(), xStreamBufferReceive(), * etc. */ -typedef void * StreamBufferHandle_t; +struct StreamBufferDef_t; +typedef struct StreamBufferDef_t * StreamBufferHandle_t; /** @@ -220,7 +225,7 @@ size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer, const void *pvTxData, size_t xDataLengthBytes, TickType_t xTicksToWait ); -
+* * Sends bytes to a stream buffer. The bytes are copied into the stream buffer. * @@ -236,7 +241,7 @@ size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer, * (such as xStreamBufferSend()) inside a critical section and set the send * block time to 0. Likewise, if there are to be multiple different readers * then the application writer must place each call to a reading API function - * (such as xStreamBufferRead()) inside a critical section and set the receive + * (such as xStreamBufferReceive()) inside a critical section and set the receive * block time to 0. * * Use xStreamBufferSend() to write to a stream buffer from a task. Use @@ -317,7 +322,7 @@ size_t xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer, const void *pvTxData, size_t xDataLengthBytes, BaseType_t *pxHigherPriorityTaskWoken ); -
+* * Interrupt safe version of the API function that sends a stream of bytes to * the stream buffer. @@ -334,7 +339,7 @@ size_t xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer, * (such as xStreamBufferSend()) inside a critical section and set the send * block time to 0. Likewise, if there are to be multiple different readers * then the application writer must place each call to a reading API function - * (such as xStreamBufferRead()) inside a critical section and set the receive + * (such as xStreamBufferReceive()) inside a critical section and set the receive * block time to 0. * * Use xStreamBufferSend() to write to a stream buffer from a task. Use @@ -434,7 +439,7 @@ size_t xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer, * (such as xStreamBufferSend()) inside a critical section and set the send * block time to 0. Likewise, if there are to be multiple different readers * then the application writer must place each call to a reading API function - * (such as xStreamBufferRead()) inside a critical section and set the receive + * (such as xStreamBufferReceive()) inside a critical section and set the receive * block time to 0. * * Use xStreamBufferReceive() to read from a stream buffer from a task. Use @@ -839,6 +844,8 @@ StreamBufferHandle_t xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes, uint8_t * const pucStreamBufferStorageArea, StaticStreamBuffer_t * const pxStaticStreamBuffer ) PRIVILEGED_FUNCTION; +size_t xStreamBufferNextMessageLengthBytes( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; + #if( configUSE_TRACE_FACILITY == 1 ) void vStreamBufferSetStreamBufferNumber( StreamBufferHandle_t xStreamBuffer, UBaseType_t uxStreamBufferNumber ) PRIVILEGED_FUNCTION; UBaseType_t uxStreamBufferGetStreamBufferNumber( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; diff --git a/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/include/task.h b/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/include/task.h index df7ce95..4b8639c 100644 --- a/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/include/task.h +++ b/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/include/task.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.0.1 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.3.1 + * 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 @@ -43,11 +43,19 @@ extern "C" { * MACROS AND DEFINITIONS *----------------------------------------------------------*/ -#define tskKERNEL_VERSION_NUMBER "V10.0.1" +#define tskKERNEL_VERSION_NUMBER "V10.3.1" #define tskKERNEL_VERSION_MAJOR 10 -#define tskKERNEL_VERSION_MINOR 0 +#define tskKERNEL_VERSION_MINOR 3 #define tskKERNEL_VERSION_BUILD 1 +/* MPU region parameters passed in ulParameters + * of MemoryRegion_t struct. */ +#define tskMPU_REGION_READ_ONLY ( 1UL << 0UL ) +#define tskMPU_REGION_READ_WRITE ( 1UL << 1UL ) +#define tskMPU_REGION_EXECUTE_NEVER ( 1UL << 2UL ) +#define tskMPU_REGION_NORMAL_MEMORY ( 1UL << 3UL ) +#define tskMPU_REGION_DEVICE_MEMORY ( 1UL << 4UL ) + /** * task. h * @@ -58,7 +66,8 @@ extern "C" { * \defgroup TaskHandle_t TaskHandle_t * \ingroup Tasks */ -typedef void * TaskHandle_t; +struct tskTaskControlBlock; /* The old naming convention is used to prevent breaking kernel aware debuggers. */ +typedef struct tskTaskControlBlock* TaskHandle_t; /* * Defines the prototype to which the application task hook function must @@ -74,7 +83,7 @@ typedef enum eBlocked, /* The task being queried is in the Blocked state. */ eSuspended, /* The task being queried is in the Suspended state, or is in the Blocked state with an infinite time out. */ eDeleted, /* The task being queried has been deleted, but its TCB has not yet been freed. */ - eInvalid /* Used as an 'invalid state' value. */ + eInvalid /* Used as an 'invalid state' value. */ } eTaskState; /* Actions that can be performed when vTaskNotify() is called. */ @@ -113,7 +122,7 @@ typedef struct xTASK_PARAMETERS { TaskFunction_t pvTaskCode; const char * const pcName; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ - uint16_t usStackDepth; + configSTACK_DEPTH_TYPE usStackDepth; void *pvParameters; UBaseType_t uxPriority; StackType_t *puxStackBuffer; @@ -135,7 +144,7 @@ typedef struct xTASK_STATUS UBaseType_t uxBasePriority; /* The priority to which the task will return if the task's current priority has been inherited to avoid unbounded priority inversion when obtaining a mutex. Only valid if configUSE_MUTEXES is defined as 1 in FreeRTOSConfig.h. */ uint32_t ulRunTimeCounter; /* The total run time allocated to the task so far, as defined by the run time stats clock. See http://www.freertos.org/rtos-run-time-stats.html. Only valid when configGENERATE_RUN_TIME_STATS is defined as 1 in FreeRTOSConfig.h. */ StackType_t *pxStackBase; /* Points to the lowest address of the task's stack area. */ - uint16_t usStackHighWaterMark; /* The minimum amount of stack space that has remained for the task since the task was created. The closer this value is to zero the closer the task has come to overflowing its stack. */ + configSTACK_DEPTH_TYPE usStackHighWaterMark; /* The minimum amount of stack space that has remained for the task since the task was created. The closer this value is to zero the closer the task has come to overflowing its stack. */ } TaskStatus_t; /* Possible return values for eTaskConfirmSleepModeStatus(). */ @@ -305,13 +314,13 @@ is used in assert() statements. */ // an automatic stack variable it might no longer exist, or at least have been corrupted, by the time // the new task attempts to access it. xTaskCreate( vTaskCode, "NAME", STACK_SIZE, &ucParameterToPass, tskIDLE_PRIORITY, &xHandle ); - configASSERT( xHandle ); + configASSERT( xHandle ); // Use the handle to delete the task. - if( xHandle != NULL ) - { - vTaskDelete( xHandle ); - } + if( xHandle != NULL ) + { + vTaskDelete( xHandle ); + } } * \defgroup xTaskCreate xTaskCreate @@ -375,9 +384,9 @@ is used in assert() statements. */ * memory to be allocated dynamically. * * @return If neither pxStackBuffer or pxTaskBuffer are NULL, then the task will - * be created and pdPASS is returned. If either pxStackBuffer or pxTaskBuffer - * are NULL then the task will not be created and - * errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY is returned. + * be created and a handle to the created task is returned. If either + * pxStackBuffer or pxTaskBuffer are NULL then the task will not be created and + * NULL is returned. * * Example usage:
@@ -489,9 +498,9 @@ static const TaskParameters_t xCheckTaskParameters =
// for full information.
{
// Base address Length Parameters
- { cReadWriteArray, 32, portMPU_REGION_READ_WRITE },
- { cReadOnlyArray, 32, portMPU_REGION_READ_ONLY },
- { cPrivilegedOnlyAccessArray, 128, portMPU_REGION_PRIVILEGED_READ_WRITE }
+ { cReadWriteArray, 32, portMPU_REGION_READ_WRITE },
+ { cReadOnlyArray, 32, portMPU_REGION_READ_ONLY },
+ { cPrivilegedOnlyAccessArray, 128, portMPU_REGION_PRIVILEGED_READ_WRITE }
}
};
@@ -575,9 +584,9 @@ static const TaskParameters_t xCheckTaskParameters =
// for full information.
{
// Base address Length Parameters
- { cReadWriteArray, 32, portMPU_REGION_READ_WRITE },
- { cReadOnlyArray, 32, portMPU_REGION_READ_ONLY },
- { cPrivilegedOnlyAccessArray, 128, portMPU_REGION_PRIVILEGED_READ_WRITE }
+ { cReadWriteArray, 32, portMPU_REGION_READ_WRITE },
+ { cReadOnlyArray, 32, portMPU_REGION_READ_ONLY },
+ { cPrivilegedOnlyAccessArray, 128, portMPU_REGION_PRIVILEGED_READ_WRITE }
}
&xTaskBuffer; // Holds the task's data structure.
@@ -822,6 +831,11 @@ void vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xT
* task will leave the Blocked state, and return from whichever function call
* placed the task into the Blocked state.
*
+ * There is no 'FromISR' version of this function as an interrupt would need to
+ * know which object a task was blocked on in order to know which actions to
+ * take. For example, if the task was blocked on a queue the interrupt handler
+ * would then need to know if the queue was locked.
+ *
* @param xTask The handle of the task to remove from the Blocked state.
*
* @return If the task referenced by xTask was not in the Blocked state then
@@ -834,7 +848,7 @@ BaseType_t xTaskAbortDelay( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
/**
* task. h
- * UBaseType_t uxTaskPriorityGet( TaskHandle_t xTask );
+ * UBaseType_t uxTaskPriorityGet( const TaskHandle_t xTask );
*
* INCLUDE_uxTaskPriorityGet must be defined as 1 for this function to be available.
* See the configuration section for more information.
@@ -877,15 +891,15 @@ BaseType_t xTaskAbortDelay( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
* \defgroup uxTaskPriorityGet uxTaskPriorityGet
* \ingroup TaskCtrl
*/
-UBaseType_t uxTaskPriorityGet( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
+UBaseType_t uxTaskPriorityGet( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
/**
* task. h
- * UBaseType_t uxTaskPriorityGetFromISR( TaskHandle_t xTask );
+ * UBaseType_t uxTaskPriorityGetFromISR( const TaskHandle_t xTask );
*
* A version of uxTaskPriorityGet() that can be used from an ISR.
*/
-UBaseType_t uxTaskPriorityGetFromISR( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
+UBaseType_t uxTaskPriorityGetFromISR( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
/**
* task. h
@@ -1412,6 +1426,12 @@ TaskHandle_t xTaskGetHandle( const char *pcNameToQuery ) PRIVILEGED_FUNCTION; /*
* a value of 1 means 4 bytes) since the task started. The smaller the returned
* number the closer the task has come to overflowing its stack.
*
+ * uxTaskGetStackHighWaterMark() and uxTaskGetStackHighWaterMark2() are the
+ * same except for their return type. Using configSTACK_DEPTH_TYPE allows the
+ * user to determine the return type. It gets around the problem of the value
+ * overflowing on 8-bit types without breaking backward compatibility for
+ * applications that expect an 8-bit return type.
+ *
* @param xTask Handle of the task associated with the stack to be checked.
* Set xTask to NULL to check the stack of the calling task.
*
@@ -1421,6 +1441,33 @@ TaskHandle_t xTaskGetHandle( const char *pcNameToQuery ) PRIVILEGED_FUNCTION; /*
*/
UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
+/**
+ * task.h
+ * configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark2( TaskHandle_t xTask );
+ *
+ * INCLUDE_uxTaskGetStackHighWaterMark2 must be set to 1 in FreeRTOSConfig.h for
+ * this function to be available.
+ *
+ * Returns the high water mark of the stack associated with xTask. That is,
+ * the minimum free stack space there has been (in words, so on a 32 bit machine
+ * a value of 1 means 4 bytes) since the task started. The smaller the returned
+ * number the closer the task has come to overflowing its stack.
+ *
+ * uxTaskGetStackHighWaterMark() and uxTaskGetStackHighWaterMark2() are the
+ * same except for their return type. Using configSTACK_DEPTH_TYPE allows the
+ * user to determine the return type. It gets around the problem of the value
+ * overflowing on 8-bit types without breaking backward compatibility for
+ * applications that expect an 8-bit return type.
+ *
+ * @param xTask Handle of the task associated with the stack to be checked.
+ * Set xTask to NULL to check the stack of the calling task.
+ *
+ * @return The smallest amount of free stack space there has been (in words, so
+ * actual spaces on the stack rather than bytes) since the task referenced by
+ * xTask was created.
+ */
+configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark2( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
+
/* When using trace macros it is sometimes necessary to include task.h before
FreeRTOS.h. When this is done TaskHookFunction_t will not yet have been defined,
so the following two prototypes will cause a compilation error. This can be
@@ -1443,9 +1490,20 @@ constant. */
* task.h
* void xTaskGetApplicationTaskTag( TaskHandle_t xTask );
*
- * Returns the pxHookFunction value assigned to the task xTask.
+ * Returns the pxHookFunction value assigned to the task xTask. Do not
+ * call from an interrupt service routine - call
+ * xTaskGetApplicationTaskTagFromISR() instead.
*/
TaskHookFunction_t xTaskGetApplicationTaskTag( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
+
+ /**
+ * task.h
+ * void xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask );
+ *
+ * Returns the pxHookFunction value assigned to the task xTask. Can
+ * be called from an interrupt service routine.
+ */
+ TaskHookFunction_t xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
#endif /* configUSE_APPLICATION_TASK_TAG ==1 */
#endif /* ifdef configUSE_APPLICATION_TASK_TAG */
@@ -1683,6 +1741,36 @@ void vTaskList( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unquali
*/
void vTaskGetRunTimeStats( char *pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
+/**
+* task. h
+* uint32_t ulTaskGetIdleRunTimeCounter( void );
+*
+* configGENERATE_RUN_TIME_STATS and configUSE_STATS_FORMATTING_FUNCTIONS
+* must both be defined as 1 for this function to be available. The application
+* must also then provide definitions for
+* portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and portGET_RUN_TIME_COUNTER_VALUE()
+* to configure a peripheral timer/counter and return the timers current count
+* value respectively. The counter should be at least 10 times the frequency of
+* the tick count.
+*
+* Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total
+* accumulated execution time being stored for each task. The resolution
+* of the accumulated time value depends on the frequency of the timer
+* configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro.
+* While uxTaskGetSystemState() and vTaskGetRunTimeStats() writes the total
+* execution time of each task into a buffer, ulTaskGetIdleRunTimeCounter()
+* returns the total execution time of just the idle task.
+*
+* @return The total run time of the idle task. This is the amount of time the
+* idle task has actually been executing. The unit of time is dependent on the
+* frequency configured using the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and
+* portGET_RUN_TIME_COUNTER_VALUE() macros.
+*
+* \defgroup ulTaskGetIdleRunTimeCounter ulTaskGetIdleRunTimeCounter
+* \ingroup TaskUtils
+*/
+uint32_t ulTaskGetIdleRunTimeCounter( void ) PRIVILEGED_FUNCTION;
+
/**
* task. h
* BaseType_t xTaskNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction );
@@ -2118,6 +2206,121 @@ uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait
*/
BaseType_t xTaskNotifyStateClear( TaskHandle_t xTask );
+/**
+* task. h
+* uint32_t ulTaskNotifyValueClear( TaskHandle_t xTask, uint32_t ulBitsToClear );
+*
+* Clears the bits specified by the ulBitsToClear bit mask in the notification
+* value of the task referenced by xTask.
+*
+* Set ulBitsToClear to 0xffffffff (UINT_MAX on 32-bit architectures) to clear
+* the notification value to 0. Set ulBitsToClear to 0 to query the task's
+* notification value without clearing any bits.
+*
+* @return The value of the target task's notification value before the bits
+* specified by ulBitsToClear were cleared.
+* \defgroup ulTaskNotifyValueClear ulTaskNotifyValueClear
+* \ingroup TaskNotifications
+*/
+uint32_t ulTaskNotifyValueClear( TaskHandle_t xTask, uint32_t ulBitsToClear ) PRIVILEGED_FUNCTION;
+
+/**
+ * task.h
+ * void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut )
+ *
+ * Capture the current time for future use with xTaskCheckForTimeOut().
+ *
+ * @param pxTimeOut Pointer to a timeout object into which the current time
+ * is to be captured. The captured time includes the tick count and the number
+ * of times the tick count has overflowed since the system first booted.
+ * \defgroup vTaskSetTimeOutState vTaskSetTimeOutState
+ * \ingroup TaskCtrl
+ */
+void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION;
+
+/**
+ * task.h
+ * BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait );
+ *
+ * Determines if pxTicksToWait ticks has passed since a time was captured
+ * using a call to vTaskSetTimeOutState(). The captured time includes the tick
+ * count and the number of times the tick count has overflowed.
+ *
+ * @param pxTimeOut The time status as captured previously using
+ * vTaskSetTimeOutState. If the timeout has not yet occurred, it is updated
+ * to reflect the current time status.
+ * @param pxTicksToWait The number of ticks to check for timeout i.e. if
+ * pxTicksToWait ticks have passed since pxTimeOut was last updated (either by
+ * vTaskSetTimeOutState() or xTaskCheckForTimeOut()), the timeout has occurred.
+ * If the timeout has not occurred, pxTIcksToWait is updated to reflect the
+ * number of remaining ticks.
+ *
+ * @return If timeout has occurred, pdTRUE is returned. Otherwise pdFALSE is
+ * returned and pxTicksToWait is updated to reflect the number of remaining
+ * ticks.
+ *
+ * @see https://www.freertos.org/xTaskCheckForTimeOut.html
+ *
+ * Example Usage:
+ *
+ // Driver library function used to receive uxWantedBytes from an Rx buffer
+ // that is filled by a UART interrupt. If there are not enough bytes in the
+ // Rx buffer then the task enters the Blocked state until it is notified that
+ // more data has been placed into the buffer. If there is still not enough
+ // data then the task re-enters the Blocked state, and xTaskCheckForTimeOut()
+ // is used to re-calculate the Block time to ensure the total amount of time
+ // spent in the Blocked state does not exceed MAX_TIME_TO_WAIT. This
+ // continues until either the buffer contains at least uxWantedBytes bytes,
+ // or the total amount of time spent in the Blocked state reaches
+ // MAX_TIME_TO_WAIT – at which point the task reads however many bytes are
+ // available up to a maximum of uxWantedBytes.
+
+ size_t xUART_Receive( uint8_t *pucBuffer, size_t uxWantedBytes )
+ {
+ size_t uxReceived = 0;
+ TickType_t xTicksToWait = MAX_TIME_TO_WAIT;
+ TimeOut_t xTimeOut;
+
+ // Initialize xTimeOut. This records the time at which this function
+ // was entered.
+ vTaskSetTimeOutState( &xTimeOut );
+
+ // Loop until the buffer contains the wanted number of bytes, or a
+ // timeout occurs.
+ while( UART_bytes_in_rx_buffer( pxUARTInstance ) < uxWantedBytes )
+ {
+ // The buffer didn't contain enough data so this task is going to
+ // enter the Blocked state. Adjusting xTicksToWait to account for
+ // any time that has been spent in the Blocked state within this
+ // function so far to ensure the total amount of time spent in the
+ // Blocked state does not exceed MAX_TIME_TO_WAIT.
+ if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) != pdFALSE )
+ {
+ //Timed out before the wanted number of bytes were available,
+ // exit the loop.
+ break;
+ }
+
+ // Wait for a maximum of xTicksToWait ticks to be notified that the
+ // receive interrupt has placed more data into the buffer.
+ ulTaskNotifyTake( pdTRUE, xTicksToWait );
+ }
+
+ // Attempt to read uxWantedBytes from the receive buffer into pucBuffer.
+ // The actual number of bytes read (which might be less than
+ // uxWantedBytes) is returned.
+ uxReceived = UART_read_from_receive_buffer( pxUARTInstance,
+ pucBuffer,
+ uxWantedBytes );
+
+ return uxReceived;
+ }
+
+ * \defgroup xTaskCheckForTimeOut xTaskCheckForTimeOut
+ * \ingroup TaskCtrl
+ */
+BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait ) PRIVILEGED_FUNCTION;
+
/*-----------------------------------------------------------
* SCHEDULER INTERNALS AVAILABLE FOR PORTING PURPOSES
*----------------------------------------------------------*/
@@ -2221,7 +2424,7 @@ void vTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem, const Tick
* Sets the pointer to the current TCB to the TCB of the highest priority task
* that is ready to run.
*/
-void vTaskSwitchContext( void ) PRIVILEGED_FUNCTION;
+portDONT_DISCARD void vTaskSwitchContext( void ) PRIVILEGED_FUNCTION;
/*
* THESE FUNCTIONS MUST NOT BE USED FROM APPLICATION CODE. THEY ARE USED BY
@@ -2234,17 +2437,6 @@ TickType_t uxTaskResetEventItemValue( void ) PRIVILEGED_FUNCTION;
*/
TaskHandle_t xTaskGetCurrentTaskHandle( void ) PRIVILEGED_FUNCTION;
-/*
- * Capture the current time status for future reference.
- */
-void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION;
-
-/*
- * Compare the time status now with that previously captured to see if the
- * timeout has expired.
- */
-BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait ) PRIVILEGED_FUNCTION;
-
/*
* Shortcut used by the queue implementation to prevent unnecessary call to
* taskYIELD();
@@ -2300,8 +2492,21 @@ void vTaskSetTaskNumber( TaskHandle_t xTask, const UBaseType_t uxHandle ) PRIVIL
*/
void vTaskStepTick( const TickType_t xTicksToJump ) PRIVILEGED_FUNCTION;
+/* Correct the tick count value after the application code has held
+interrupts disabled for an extended period. xTicksToCatchUp is the number
+of tick interrupts that have been missed due to interrupts being disabled.
+Its value is not computed automatically, so must be computed by the
+application writer.
+
+This function is similar to vTaskStepTick(), however, unlike
+vTaskStepTick(), xTaskCatchUpTicks() may move the tick count forward past a
+time at which a task should be removed from the blocked state. That means
+tasks may have to be removed from the blocked state as the tick count is
+moved. */
+BaseType_t xTaskCatchUpTicks( TickType_t xTicksToCatchUp ) PRIVILEGED_FUNCTION;
+
/*
- * Only avilable when configUSE_TICKLESS_IDLE is set to 1.
+ * Only available when configUSE_TICKLESS_IDLE is set to 1.
* Provided for use within portSUPPRESS_TICKS_AND_SLEEP() to allow the port
* specific sleep function to determine if it is ok to proceed with the sleep,
* and if it is ok to proceed, if it is ok to sleep indefinitely.
@@ -2320,7 +2525,7 @@ eSleepModeStatus eTaskConfirmSleepModeStatus( void ) PRIVILEGED_FUNCTION;
* For internal use only. Increment the mutex held count when a mutex is
* taken and return the handle of the task that has taken the mutex.
*/
-void *pvTaskIncrementMutexHeldCount( void ) PRIVILEGED_FUNCTION;
+TaskHandle_t pvTaskIncrementMutexHeldCount( void ) PRIVILEGED_FUNCTION;
/*
* For internal use only. Same as vTaskSetTimeOutState(), but without a critial
diff --git a/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/include/timers.h b/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/include/timers.h
index 7e2eceb..9ee2a0c 100644
--- a/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/include/timers.h
+++ b/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/include/timers.h
@@ -1,6 +1,6 @@
/*
- * FreeRTOS Kernel V10.0.1
- * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * FreeRTOS Kernel V10.3.1
+ * 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
@@ -73,7 +73,8 @@ or interrupt version of the queue send function should be used. */
* reference the subject timer in calls to other software timer API functions
* (for example, xTimerStart(), xTimerReset(), etc.).
*/
-typedef void * TimerHandle_t;
+struct tmrTimerControl; /* The old naming convention is used to prevent breaking kernel aware debuggers. */
+typedef struct tmrTimerControl * TimerHandle_t;
/*
* Defines the prototype to which timer callback functions must conform.
@@ -120,7 +121,7 @@ typedef void (*PendedFunction_t)( void *, uint32_t );
* after 100 ticks, then xTimerPeriodInTicks should be set to 100.
* Alternatively, if the timer must expire after 500ms, then xPeriod can be set
* to ( 500 / portTICK_PERIOD_MS ) provided configTICK_RATE_HZ is less than or
- * equal to 1000.
+ * equal to 1000. Time timer period must be greater than 0.
*
* @param uxAutoReload If uxAutoReload is set to pdTRUE then the timer will
* expire repeatedly with a frequency set by the xTimerPeriodInTicks parameter.
@@ -137,9 +138,9 @@ typedef void (*PendedFunction_t)( void *, uint32_t );
* which is "void vCallbackFunction( TimerHandle_t xTimer );".
*
* @return If the timer is successfully created then a handle to the newly
- * created timer is returned. If the timer cannot be created (because either
- * there is insufficient FreeRTOS heap remaining to allocate the timer
- * structures, or the timer period was set to 0) then NULL is returned.
+ * created timer is returned. If the timer cannot be created because there is
+ * insufficient FreeRTOS heap remaining to allocate the timer
+ * structures then NULL is returned.
*
* Example usage:
* @verbatim
@@ -266,7 +267,7 @@ typedef void (*PendedFunction_t)( void *, uint32_t );
* after 100 ticks, then xTimerPeriodInTicks should be set to 100.
* Alternatively, if the timer must expire after 500ms, then xPeriod can be set
* to ( 500 / portTICK_PERIOD_MS ) provided configTICK_RATE_HZ is less than or
- * equal to 1000.
+ * equal to 1000. The timer period must be greater than 0.
*
* @param uxAutoReload If uxAutoReload is set to pdTRUE then the timer will
* expire repeatedly with a frequency set by the xTimerPeriodInTicks parameter.
@@ -1230,6 +1231,37 @@ BaseType_t xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, void *pvPar
*/
const char * pcTimerGetName( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
+/**
+ * void vTimerSetReloadMode( TimerHandle_t xTimer, const UBaseType_t uxAutoReload );
+ *
+ * Updates a timer to be either an auto-reload timer, in which case the timer
+ * automatically resets itself each time it expires, or a one-shot timer, in
+ * which case the timer will only expire once unless it is manually restarted.
+ *
+ * @param xTimer The handle of the timer being updated.
+ *
+ * @param uxAutoReload If uxAutoReload is set to pdTRUE then the timer will
+ * expire repeatedly with a frequency set by the timer's period (see the
+ * xTimerPeriodInTicks parameter of the xTimerCreate() API function). If
+ * uxAutoReload is set to pdFALSE then the timer will be a one-shot timer and
+ * enter the dormant state after it expires.
+ */
+void vTimerSetReloadMode( TimerHandle_t xTimer, const UBaseType_t uxAutoReload ) PRIVILEGED_FUNCTION;
+
+/**
+* UBaseType_t uxTimerGetReloadMode( TimerHandle_t xTimer );
+*
+* Queries a timer to determine if it is an auto-reload timer, in which case the timer
+* automatically resets itself each time it expires, or a one-shot timer, in
+* which case the timer will only expire once unless it is manually restarted.
+*
+* @param xTimer The handle of the timer being queried.
+*
+* @return If the timer is an auto-reload timer then pdTRUE is returned, otherwise
+* pdFALSE is returned.
+*/
+UBaseType_t uxTimerGetReloadMode( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
+
/**
* TickType_t xTimerGetPeriod( TimerHandle_t xTimer );
*
diff --git a/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/list.c b/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/list.c
index e3a54e3..0e0e72d 100644
--- a/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/list.c
+++ b/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/list.c
@@ -1,6 +1,6 @@
/*
- * FreeRTOS Kernel V10.0.1
- * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * FreeRTOS Kernel V10.3.1
+ * 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
@@ -39,7 +39,7 @@ void vListInitialise( List_t * const pxList )
/* The list structure contains a list item which is used to mark the
end of the list. To initialise the list the list end is inserted
as the only list entry. */
- pxList->pxIndex = ( ListItem_t * ) &( pxList->xListEnd ); /*lint !e826 !e740 The mini list structure is used as the list end to save RAM. This is checked and valid. */
+ pxList->pxIndex = ( ListItem_t * ) &( pxList->xListEnd ); /*lint !e826 !e740 !e9087 The mini list structure is used as the list end to save RAM. This is checked and valid. */
/* The list end value is the highest possible value in the list to
ensure it remains at the end of the list. */
@@ -47,8 +47,8 @@ void vListInitialise( List_t * const pxList )
/* The list end next and previous pointers point to itself so we know
when the list is empty. */
- pxList->xListEnd.pxNext = ( ListItem_t * ) &( pxList->xListEnd ); /*lint !e826 !e740 The mini list structure is used as the list end to save RAM. This is checked and valid. */
- pxList->xListEnd.pxPrevious = ( ListItem_t * ) &( pxList->xListEnd );/*lint !e826 !e740 The mini list structure is used as the list end to save RAM. This is checked and valid. */
+ pxList->xListEnd.pxNext = ( ListItem_t * ) &( pxList->xListEnd ); /*lint !e826 !e740 !e9087 The mini list structure is used as the list end to save RAM. This is checked and valid. */
+ pxList->xListEnd.pxPrevious = ( ListItem_t * ) &( pxList->xListEnd );/*lint !e826 !e740 !e9087 The mini list structure is used as the list end to save RAM. This is checked and valid. */
pxList->uxNumberOfItems = ( UBaseType_t ) 0U;
@@ -62,7 +62,7 @@ void vListInitialise( List_t * const pxList )
void vListInitialiseItem( ListItem_t * const pxItem )
{
/* Make sure the list item is not recorded as being on a list. */
- pxItem->pvContainer = NULL;
+ pxItem->pxContainer = NULL;
/* Write known values into the list item if
configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
@@ -94,7 +94,7 @@ ListItem_t * const pxIndex = pxList->pxIndex;
pxIndex->pxPrevious = pxNewListItem;
/* Remember which list the item is in. */
- pxNewListItem->pvContainer = ( void * ) pxList;
+ pxNewListItem->pxContainer = pxList;
( pxList->uxNumberOfItems )++;
}
@@ -114,7 +114,7 @@ const TickType_t xValueOfInsertion = pxNewListItem->xItemValue;
/* Insert the new list item into the list, sorted in xItemValue order.
If the list already contains a list item with the same item value then the
- new list item should be placed after it. This ensures that TCB's which are
+ new list item should be placed after it. This ensures that TCBs which are
stored in ready lists (all of which have the same xItemValue value) get a
share of the CPU. However, if the xItemValue is the same as the back marker
the iteration loop below will not end. Therefore the value is checked
@@ -127,18 +127,18 @@ const TickType_t xValueOfInsertion = pxNewListItem->xItemValue;
{
/* *** NOTE ***********************************************************
If you find your application is crashing here then likely causes are
- listed below. In addition see http://www.freertos.org/FAQHelp.html for
+ listed below. In addition see https://www.freertos.org/FAQHelp.html for
more tips, and ensure configASSERT() is defined!
- http://www.freertos.org/a00110.html#configASSERT
+ https://www.freertos.org/a00110.html#configASSERT
1) Stack overflow -
- see http://www.freertos.org/Stacks-and-stack-overflow-checking.html
+ see https://www.freertos.org/Stacks-and-stack-overflow-checking.html
2) Incorrect interrupt priority assignment, especially on Cortex-M
parts where numerically high priority values denote low actual
interrupt priorities, which can seem counter intuitive. See
- http://www.freertos.org/RTOS-Cortex-M3-M4.html and the definition
+ https://www.freertos.org/RTOS-Cortex-M3-M4.html and the definition
of configMAX_SYSCALL_INTERRUPT_PRIORITY on
- http://www.freertos.org/a00110.html
+ https://www.freertos.org/a00110.html
3) Calling an API function from within a critical section or when
the scheduler is suspended, or calling an API function that does
not end in "FromISR" from an interrupt.
@@ -147,7 +147,7 @@ const TickType_t xValueOfInsertion = pxNewListItem->xItemValue;
before vTaskStartScheduler() has been called?).
**********************************************************************/
- for( pxIterator = ( ListItem_t * ) &( pxList->xListEnd ); pxIterator->pxNext->xItemValue <= xValueOfInsertion; pxIterator = pxIterator->pxNext ) /*lint !e826 !e740 The mini list structure is used as the list end to save RAM. This is checked and valid. */
+ for( pxIterator = ( ListItem_t * ) &( pxList->xListEnd ); pxIterator->pxNext->xItemValue <= xValueOfInsertion; pxIterator = pxIterator->pxNext ) /*lint !e826 !e740 !e9087 The mini list structure is used as the list end to save RAM. This is checked and valid. *//*lint !e440 The iterator moves to a different value, not xValueOfInsertion. */
{
/* There is nothing to do here, just iterating to the wanted
insertion position. */
@@ -161,7 +161,7 @@ const TickType_t xValueOfInsertion = pxNewListItem->xItemValue;
/* Remember which list the item is in. This allows fast removal of the
item later. */
- pxNewListItem->pvContainer = ( void * ) pxList;
+ pxNewListItem->pxContainer = pxList;
( pxList->uxNumberOfItems )++;
}
@@ -171,7 +171,7 @@ UBaseType_t uxListRemove( ListItem_t * const pxItemToRemove )
{
/* The list item knows which list it is in. Obtain the list from the list
item. */
-List_t * const pxList = ( List_t * ) pxItemToRemove->pvContainer;
+List_t * const pxList = pxItemToRemove->pxContainer;
pxItemToRemove->pxNext->pxPrevious = pxItemToRemove->pxPrevious;
pxItemToRemove->pxPrevious->pxNext = pxItemToRemove->pxNext;
@@ -189,7 +189,7 @@ List_t * const pxList = ( List_t * ) pxItemToRemove->pvContainer;
mtCOVERAGE_TEST_MARKER();
}
- pxItemToRemove->pvContainer = NULL;
+ pxItemToRemove->pxContainer = NULL;
( pxList->uxNumberOfItems )--;
return pxList->uxNumberOfItems;
diff --git a/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c b/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c
index e18d94e..9e1d1a8 100644
--- a/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c
+++ b/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c
@@ -1,6 +1,6 @@
/*
- * FreeRTOS Kernel V10.0.1
- * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * FreeRTOS Kernel V10.3.1
+ * 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
@@ -576,14 +576,14 @@ void xPortSysTickHandler( void )
should not be executed again. However, the original expected idle
time variable must remain unmodified, so a copy is taken. */
xModifiableIdleTime = xExpectedIdleTime;
- configPRE_SLEEP_PROCESSING( &xModifiableIdleTime );
+ configPRE_SLEEP_PROCESSING( xModifiableIdleTime );
if( xModifiableIdleTime > 0 )
{
__asm volatile( "dsb" ::: "memory" );
__asm volatile( "wfi" );
__asm volatile( "isb" );
}
- configPOST_SLEEP_PROCESSING( &xExpectedIdleTime );
+ configPOST_SLEEP_PROCESSING( xExpectedIdleTime );
/* Re-enable interrupts to allow the interrupt that brought the MCU
out of sleep mode to execute immediately. see comments above
@@ -664,7 +664,7 @@ void xPortSysTickHandler( void )
vTaskStepTick( ulCompleteTickPeriods );
portNVIC_SYSTICK_LOAD_REG = ulTimerCountsForOneTick - 1UL;
- /* Exit with interrpts enabled. */
+ /* Exit with interrupts enabled. */
__asm volatile( "cpsie i" ::: "memory" );
}
}
diff --git a/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F/portmacro.h b/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F/portmacro.h
index 335732f..e1e7fad 100644
--- a/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F/portmacro.h
+++ b/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F/portmacro.h
@@ -1,6 +1,6 @@
/*
- * FreeRTOS Kernel V10.0.1
- * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * FreeRTOS Kernel V10.3.1
+ * 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
@@ -233,6 +233,7 @@ portFORCE_INLINE static void vPortSetBASEPRI( uint32_t ulNewMaskValue )
}
/*-----------------------------------------------------------*/
+#define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" )
#ifdef __cplusplus
}
diff --git a/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/queue.c b/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/queue.c
index f6d1450..e35055f 100644
--- a/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/queue.c
+++ b/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/queue.c
@@ -1,6 +1,6 @@
/*
- * FreeRTOS Kernel V10.0.1
- * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * FreeRTOS Kernel V10.3.1
+ * 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
@@ -41,11 +41,11 @@ task.h is included from an application file. */
#include "croutine.h"
#endif
-/* Lint e961 and e750 are suppressed as a MISRA exception justified because the
-MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined for the
-header files above, but not in this file, in order to generate the correct
-privileged Vs unprivileged linkage and placement. */
-#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750. */
+/* Lint e9021, e961 and e750 are suppressed as a MISRA exception justified
+because the MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined
+for the header files above, but not in this file, in order to generate the
+correct privileged Vs unprivileged linkage and placement. */
+#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750 !e9021. */
/* Constants used with the cRxLock and cTxLock structure members. */
@@ -56,17 +56,26 @@ privileged Vs unprivileged linkage and placement. */
pcTail members are used as pointers into the queue storage area. When the
Queue_t structure is used to represent a mutex pcHead and pcTail pointers are
not necessary, and the pcHead pointer is set to NULL to indicate that the
-pcTail pointer actually points to the mutex holder (if any). Map alternative
-names to the pcHead and pcTail structure members to ensure the readability of
-the code is maintained despite this dual use of two structure members. An
-alternative implementation would be to use a union, but use of a union is
-against the coding standard (although an exception to the standard has been
-permitted where the dual use also significantly changes the type of the
-structure member). */
-#define pxMutexHolder pcTail
+structure instead holds a pointer to the mutex holder (if any). Map alternative
+names to the pcHead and structure member to ensure the readability of the code
+is maintained. The QueuePointers_t and SemaphoreData_t types are used to form
+a union as their usage is mutually exclusive dependent on what the queue is
+being used for. */
#define uxQueueType pcHead
#define queueQUEUE_IS_MUTEX NULL
+typedef struct QueuePointers
+{
+ int8_t *pcTail; /*< Points to the byte at the end of the queue storage area. Once more byte is allocated than necessary to store the queue items, this is used as a marker. */
+ int8_t *pcReadFrom; /*< Points to the last place that a queued item was read from when the structure is used as a queue. */
+} QueuePointers_t;
+
+typedef struct SemaphoreData
+{
+ TaskHandle_t xMutexHolder; /*< The handle of the task that holds the mutex. */
+ UBaseType_t uxRecursiveCallCount;/*< Maintains a count of the number of times a recursive mutex has been recursively 'taken' when the structure is used as a mutex. */
+} SemaphoreData_t;
+
/* Semaphores do not actually store or copy data, so have an item size of
zero. */
#define queueSEMAPHORE_QUEUE_ITEM_LENGTH ( ( UBaseType_t ) 0 )
@@ -83,18 +92,17 @@ zero. */
/*
* Definition of the queue used by the scheduler.
* Items are queued by copy, not reference. See the following link for the
- * rationale: http://www.freertos.org/Embedded-RTOS-Queues.html
+ * rationale: https://www.freertos.org/Embedded-RTOS-Queues.html
*/
-typedef struct QueueDefinition
+typedef struct QueueDefinition /* The old naming convention is used to prevent breaking kernel aware debuggers. */
{
int8_t *pcHead; /*< Points to the beginning of the queue storage area. */
- int8_t *pcTail; /*< Points to the byte at the end of the queue storage area. Once more byte is allocated than necessary to store the queue items, this is used as a marker. */
int8_t *pcWriteTo; /*< Points to the free next place in the storage area. */
- union /* Use of a union is an exception to the coding standard to ensure two mutually exclusive structure members don't appear simultaneously (wasting RAM). */
+ union
{
- int8_t *pcReadFrom; /*< Points to the last place that a queued item was read from when the structure is used as a queue. */
- UBaseType_t uxRecursiveCallCount;/*< Maintains a count of the number of times a recursive mutex has been recursively 'taken' when the structure is used as a mutex. */
+ QueuePointers_t xQueue; /*< Data required exclusively when this structure is used as a queue. */
+ SemaphoreData_t xSemaphore; /*< Data required exclusively when this structure is used as a semaphore. */
} u;
List_t xTasksWaitingToSend; /*< List of tasks that are blocked waiting to post onto this queue. Stored in priority order. */
@@ -195,7 +203,7 @@ static void prvCopyDataFromQueue( Queue_t * const pxQueue, void * const pvBuffer
* Checks to see if a queue is a member of a queue set, and if so, notifies
* the queue set that the queue contains data.
*/
- static BaseType_t prvNotifyQueueSetContainer( const Queue_t * const pxQueue, const BaseType_t xCopyPosition ) PRIVILEGED_FUNCTION;
+ static BaseType_t prvNotifyQueueSetContainer( const Queue_t * const pxQueue ) PRIVILEGED_FUNCTION;
#endif
/*
@@ -246,16 +254,16 @@ static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength, const UBaseT
BaseType_t xQueueGenericReset( QueueHandle_t xQueue, BaseType_t xNewQueue )
{
-Queue_t * const pxQueue = ( Queue_t * ) xQueue;
+Queue_t * const pxQueue = xQueue;
configASSERT( pxQueue );
taskENTER_CRITICAL();
{
- pxQueue->pcTail = pxQueue->pcHead + ( pxQueue->uxLength * pxQueue->uxItemSize );
+ pxQueue->u.xQueue.pcTail = pxQueue->pcHead + ( pxQueue->uxLength * pxQueue->uxItemSize ); /*lint !e9016 Pointer arithmetic allowed on char types, especially when it assists conveying intent. */
pxQueue->uxMessagesWaiting = ( UBaseType_t ) 0U;
pxQueue->pcWriteTo = pxQueue->pcHead;
- pxQueue->u.pcReadFrom = pxQueue->pcHead + ( ( pxQueue->uxLength - ( UBaseType_t ) 1U ) * pxQueue->uxItemSize );
+ pxQueue->u.xQueue.pcReadFrom = pxQueue->pcHead + ( ( pxQueue->uxLength - 1U ) * pxQueue->uxItemSize ); /*lint !e9016 Pointer arithmetic allowed on char types, especially when it assists conveying intent. */
pxQueue->cRxLock = queueUNLOCKED;
pxQueue->cTxLock = queueUNLOCKED;
@@ -321,13 +329,14 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
the real queue and semaphore structures. */
volatile size_t xSize = sizeof( StaticQueue_t );
configASSERT( xSize == sizeof( Queue_t ) );
+ ( void ) xSize; /* Keeps lint quiet when configASSERT() is not defined. */
}
#endif /* configASSERT_DEFINED */
/* The address of a statically allocated queue was passed in, use it.
The address of a statically allocated storage area was also passed in
but is already set. */
- pxNewQueue = ( Queue_t * ) pxStaticQueue; /*lint !e740 Unusual cast is ok as the structures are designed to have the same alignment, and the size is checked by an assert. */
+ pxNewQueue = ( Queue_t * ) pxStaticQueue; /*lint !e740 !e9087 Unusual cast is ok as the structures are designed to have the same alignment, and the size is checked by an assert. */
if( pxNewQueue != NULL )
{
@@ -345,6 +354,7 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
else
{
traceQUEUE_CREATE_FAILED( ucQueueType );
+ mtCOVERAGE_TEST_MARKER();
}
return pxNewQueue;
@@ -363,25 +373,28 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
configASSERT( uxQueueLength > ( UBaseType_t ) 0 );
- if( uxItemSize == ( UBaseType_t ) 0 )
- {
- /* There is not going to be a queue storage area. */
- xQueueSizeInBytes = ( size_t ) 0;
- }
- else
- {
- /* Allocate enough space to hold the maximum number of items that
- can be in the queue at any time. */
- xQueueSizeInBytes = ( size_t ) ( uxQueueLength * uxItemSize ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */
- }
+ /* Allocate enough space to hold the maximum number of items that
+ can be in the queue at any time. It is valid for uxItemSize to be
+ zero in the case the queue is used as a semaphore. */
+ xQueueSizeInBytes = ( size_t ) ( uxQueueLength * uxItemSize ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */
- pxNewQueue = ( Queue_t * ) pvPortMalloc( sizeof( Queue_t ) + xQueueSizeInBytes );
+ /* Allocate the queue and storage area. Justification for MISRA
+ deviation as follows: pvPortMalloc() always ensures returned memory
+ blocks are aligned per the requirements of the MCU stack. In this case
+ pvPortMalloc() must return a pointer that is guaranteed to meet the
+ alignment requirements of the Queue_t structure - which in this case
+ is an int8_t *. Therefore, whenever the stack alignment requirements
+ are greater than or equal to the pointer to char requirements the cast
+ is safe. In other cases alignment requirements are not strict (one or
+ two bytes). */
+ pxNewQueue = ( Queue_t * ) pvPortMalloc( sizeof( Queue_t ) + xQueueSizeInBytes ); /*lint !e9087 !e9079 see comment above. */
if( pxNewQueue != NULL )
{
/* Jump past the queue structure to find the location of the queue
storage area. */
- pucQueueStorage = ( ( uint8_t * ) pxNewQueue ) + sizeof( Queue_t );
+ pucQueueStorage = ( uint8_t * ) pxNewQueue;
+ pucQueueStorage += sizeof( Queue_t ); /*lint !e9016 Pointer arithmetic allowed on char types, especially when it assists conveying intent. */
#if( configSUPPORT_STATIC_ALLOCATION == 1 )
{
@@ -397,6 +410,7 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
else
{
traceQUEUE_CREATE_FAILED( ucQueueType );
+ mtCOVERAGE_TEST_MARKER();
}
return pxNewQueue;
@@ -457,11 +471,11 @@ static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength, const UBaseT
correctly for a generic queue, but this function is creating a
mutex. Overwrite those members that need to be set differently -
in particular the information required for priority inheritance. */
- pxNewQueue->pxMutexHolder = NULL;
+ pxNewQueue->u.xSemaphore.xMutexHolder = NULL;
pxNewQueue->uxQueueType = queueQUEUE_IS_MUTEX;
/* In case this is a recursive mutex. */
- pxNewQueue->u.uxRecursiveCallCount = 0;
+ pxNewQueue->u.xSemaphore.uxRecursiveCallCount = 0;
traceCREATE_MUTEX( pxNewQueue );
@@ -481,13 +495,13 @@ static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength, const UBaseT
QueueHandle_t xQueueCreateMutex( const uint8_t ucQueueType )
{
- Queue_t *pxNewQueue;
+ QueueHandle_t xNewQueue;
const UBaseType_t uxMutexLength = ( UBaseType_t ) 1, uxMutexSize = ( UBaseType_t ) 0;
- pxNewQueue = ( Queue_t * ) xQueueGenericCreate( uxMutexLength, uxMutexSize, ucQueueType );
- prvInitialiseMutex( pxNewQueue );
+ xNewQueue = xQueueGenericCreate( uxMutexLength, uxMutexSize, ucQueueType );
+ prvInitialiseMutex( ( Queue_t * ) xNewQueue );
- return pxNewQueue;
+ return xNewQueue;
}
#endif /* configUSE_MUTEXES */
@@ -497,17 +511,17 @@ static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength, const UBaseT
QueueHandle_t xQueueCreateMutexStatic( const uint8_t ucQueueType, StaticQueue_t *pxStaticQueue )
{
- Queue_t *pxNewQueue;
+ QueueHandle_t xNewQueue;
const UBaseType_t uxMutexLength = ( UBaseType_t ) 1, uxMutexSize = ( UBaseType_t ) 0;
/* Prevent compiler warnings about unused parameters if
configUSE_TRACE_FACILITY does not equal 1. */
( void ) ucQueueType;
- pxNewQueue = ( Queue_t * ) xQueueGenericCreateStatic( uxMutexLength, uxMutexSize, NULL, pxStaticQueue, ucQueueType );
- prvInitialiseMutex( pxNewQueue );
+ xNewQueue = xQueueGenericCreateStatic( uxMutexLength, uxMutexSize, NULL, pxStaticQueue, ucQueueType );
+ prvInitialiseMutex( ( Queue_t * ) xNewQueue );
- return pxNewQueue;
+ return xNewQueue;
}
#endif /* configUSE_MUTEXES */
@@ -515,9 +529,10 @@ static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength, const UBaseT
#if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) )
- void* xQueueGetMutexHolder( QueueHandle_t xSemaphore )
+ TaskHandle_t xQueueGetMutexHolder( QueueHandle_t xSemaphore )
{
- void *pxReturn;
+ TaskHandle_t pxReturn;
+ Queue_t * const pxSemaphore = ( Queue_t * ) xSemaphore;
/* This function is called by xSemaphoreGetMutexHolder(), and should not
be called directly. Note: This is a good way of determining if the
@@ -526,9 +541,9 @@ static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength, const UBaseT
following critical section exiting and the function returning. */
taskENTER_CRITICAL();
{
- if( ( ( Queue_t * ) xSemaphore )->uxQueueType == queueQUEUE_IS_MUTEX )
+ if( pxSemaphore->uxQueueType == queueQUEUE_IS_MUTEX )
{
- pxReturn = ( void * ) ( ( Queue_t * ) xSemaphore )->pxMutexHolder;
+ pxReturn = pxSemaphore->u.xSemaphore.xMutexHolder;
}
else
{
@@ -545,9 +560,9 @@ static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength, const UBaseT
#if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) )
- void* xQueueGetMutexHolderFromISR( QueueHandle_t xSemaphore )
+ TaskHandle_t xQueueGetMutexHolderFromISR( QueueHandle_t xSemaphore )
{
- void *pxReturn;
+ TaskHandle_t pxReturn;
configASSERT( xSemaphore );
@@ -556,7 +571,7 @@ static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength, const UBaseT
not required here. */
if( ( ( Queue_t * ) xSemaphore )->uxQueueType == queueQUEUE_IS_MUTEX )
{
- pxReturn = ( void * ) ( ( Queue_t * ) xSemaphore )->pxMutexHolder;
+ pxReturn = ( ( Queue_t * ) xSemaphore )->u.xSemaphore.xMutexHolder;
}
else
{
@@ -578,25 +593,25 @@ static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength, const UBaseT
configASSERT( pxMutex );
- /* If this is the task that holds the mutex then pxMutexHolder will not
+ /* If this is the task that holds the mutex then xMutexHolder will not
change outside of this task. If this task does not hold the mutex then
pxMutexHolder can never coincidentally equal the tasks handle, and as
this is the only condition we are interested in it does not matter if
pxMutexHolder is accessed simultaneously by another task. Therefore no
mutual exclusion is required to test the pxMutexHolder variable. */
- if( pxMutex->pxMutexHolder == ( void * ) xTaskGetCurrentTaskHandle() ) /*lint !e961 Not a redundant cast as TaskHandle_t is a typedef. */
+ if( pxMutex->u.xSemaphore.xMutexHolder == xTaskGetCurrentTaskHandle() )
{
traceGIVE_MUTEX_RECURSIVE( pxMutex );
- /* uxRecursiveCallCount cannot be zero if pxMutexHolder is equal to
+ /* uxRecursiveCallCount cannot be zero if xMutexHolder is equal to
the task handle, therefore no underflow check is required. Also,
uxRecursiveCallCount is only modified by the mutex holder, and as
there can only be one, no mutual exclusion is required to modify the
uxRecursiveCallCount member. */
- ( pxMutex->u.uxRecursiveCallCount )--;
+ ( pxMutex->u.xSemaphore.uxRecursiveCallCount )--;
/* Has the recursive call count unwound to 0? */
- if( pxMutex->u.uxRecursiveCallCount == ( UBaseType_t ) 0 )
+ if( pxMutex->u.xSemaphore.uxRecursiveCallCount == ( UBaseType_t ) 0 )
{
/* Return the mutex. This will automatically unblock any other
task that might be waiting to access the mutex. */
@@ -638,9 +653,9 @@ static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength, const UBaseT
traceTAKE_MUTEX_RECURSIVE( pxMutex );
- if( pxMutex->pxMutexHolder == ( void * ) xTaskGetCurrentTaskHandle() ) /*lint !e961 Cast is not redundant as TaskHandle_t is a typedef. */
+ if( pxMutex->u.xSemaphore.xMutexHolder == xTaskGetCurrentTaskHandle() )
{
- ( pxMutex->u.uxRecursiveCallCount )++;
+ ( pxMutex->u.xSemaphore.uxRecursiveCallCount )++;
xReturn = pdPASS;
}
else
@@ -652,7 +667,7 @@ static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength, const UBaseT
before reaching here. */
if( xReturn != pdFAIL )
{
- ( pxMutex->u.uxRecursiveCallCount )++;
+ ( pxMutex->u.xSemaphore.uxRecursiveCallCount )++;
}
else
{
@@ -726,7 +741,7 @@ BaseType_t xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQ
{
BaseType_t xEntryTimeSet = pdFALSE, xYieldRequired;
TimeOut_t xTimeOut;
-Queue_t * const pxQueue = ( Queue_t * ) xQueue;
+Queue_t * const pxQueue = xQueue;
configASSERT( pxQueue );
configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) );
@@ -738,9 +753,9 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
#endif
- /* This function relaxes the coding standard somewhat to allow return
- statements within the function itself. This is done in the interest
- of execution time efficiency. */
+ /*lint -save -e904 This function relaxes the coding standard somewhat to
+ allow return statements within the function itself. This is done in the
+ interest of execution time efficiency. */
for( ;; )
{
taskENTER_CRITICAL();
@@ -752,13 +767,23 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
if( ( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) || ( xCopyPosition == queueOVERWRITE ) )
{
traceQUEUE_SEND( pxQueue );
- xYieldRequired = prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition );
#if ( configUSE_QUEUE_SETS == 1 )
{
+ const UBaseType_t uxPreviousMessagesWaiting = pxQueue->uxMessagesWaiting;
+
+ xYieldRequired = prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition );
+
if( pxQueue->pxQueueSetContainer != NULL )
{
- if( prvNotifyQueueSetContainer( pxQueue, xCopyPosition ) != pdFALSE )
+ if( ( xCopyPosition == queueOVERWRITE ) && ( uxPreviousMessagesWaiting != ( UBaseType_t ) 0 ) )
+ {
+ /* Do not notify the queue set as an existing item
+ was overwritten in the queue so the number of items
+ in the queue has not changed. */
+ mtCOVERAGE_TEST_MARKER();
+ }
+ else if( prvNotifyQueueSetContainer( pxQueue ) != pdFALSE )
{
/* The queue is a member of a queue set, and posting
to the queue set caused a higher priority task to
@@ -805,6 +830,8 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
}
#else /* configUSE_QUEUE_SETS */
{
+ xYieldRequired = prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition );
+
/* If there was a task waiting for data to arrive on the
queue then unblock it now. */
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )
@@ -916,7 +943,7 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
traceQUEUE_SEND_FAILED( pxQueue );
return errQUEUE_FULL;
}
- }
+ } /*lint -restore */
}
/*-----------------------------------------------------------*/
@@ -924,7 +951,7 @@ BaseType_t xQueueGenericSendFromISR( QueueHandle_t xQueue, const void * const pv
{
BaseType_t xReturn;
UBaseType_t uxSavedInterruptStatus;
-Queue_t * const pxQueue = ( Queue_t * ) xQueue;
+Queue_t * const pxQueue = xQueue;
configASSERT( pxQueue );
configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) );
@@ -956,6 +983,7 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
if( ( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) || ( xCopyPosition == queueOVERWRITE ) )
{
const int8_t cTxLock = pxQueue->cTxLock;
+ const UBaseType_t uxPreviousMessagesWaiting = pxQueue->uxMessagesWaiting;
traceQUEUE_SEND_FROM_ISR( pxQueue );
@@ -974,7 +1002,14 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
{
if( pxQueue->pxQueueSetContainer != NULL )
{
- if( prvNotifyQueueSetContainer( pxQueue, xCopyPosition ) != pdFALSE )
+ if( ( xCopyPosition == queueOVERWRITE ) && ( uxPreviousMessagesWaiting != ( UBaseType_t ) 0 ) )
+ {
+ /* Do not notify the queue set as an existing item
+ was overwritten in the queue so the number of items
+ in the queue has not changed. */
+ mtCOVERAGE_TEST_MARKER();
+ }
+ else if( prvNotifyQueueSetContainer( pxQueue ) != pdFALSE )
{
/* The queue is a member of a queue set, and posting
to the queue set caused a higher priority task to
@@ -1047,6 +1082,9 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
{
mtCOVERAGE_TEST_MARKER();
}
+
+ /* Not used in this path. */
+ ( void ) uxPreviousMessagesWaiting;
}
#endif /* configUSE_QUEUE_SETS */
}
@@ -1075,7 +1113,7 @@ BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue, BaseType_t * const pxHigherP
{
BaseType_t xReturn;
UBaseType_t uxSavedInterruptStatus;
-Queue_t * const pxQueue = ( Queue_t * ) xQueue;
+Queue_t * const pxQueue = xQueue;
/* Similar to xQueueGenericSendFromISR() but used with semaphores where the
item size is 0. Don't directly wake a task that was blocked on a queue
@@ -1092,7 +1130,7 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
/* Normally a mutex would not be given from an interrupt, especially if
there is a mutex holder, as priority inheritance makes no sense for an
interrupts, only tasks. */
- configASSERT( !( ( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) && ( pxQueue->pxMutexHolder != NULL ) ) );
+ configASSERT( !( ( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) && ( pxQueue->u.xSemaphore.xMutexHolder != NULL ) ) );
/* RTOS ports that support interrupt nesting have the concept of a maximum
system call (or maximum API call) interrupt priority. Interrupts that are
@@ -1139,7 +1177,7 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
{
if( pxQueue->pxQueueSetContainer != NULL )
{
- if( prvNotifyQueueSetContainer( pxQueue, queueSEND_TO_BACK ) != pdFALSE )
+ if( prvNotifyQueueSetContainer( pxQueue ) != pdFALSE )
{
/* The semaphore is a member of a queue set, and
posting to the queue set caused a higher priority
@@ -1240,7 +1278,7 @@ BaseType_t xQueueReceive( QueueHandle_t xQueue, void * const pvBuffer, TickType_
{
BaseType_t xEntryTimeSet = pdFALSE;
TimeOut_t xTimeOut;
-Queue_t * const pxQueue = ( Queue_t * ) xQueue;
+Queue_t * const pxQueue = xQueue;
/* Check the pointer is not NULL. */
configASSERT( ( pxQueue ) );
@@ -1256,10 +1294,10 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
}
#endif
- /* This function relaxes the coding standard somewhat to allow return
- statements within the function itself. This is done in the interest
- of execution time efficiency. */
+ /*lint -save -e904 This function relaxes the coding standard somewhat to
+ allow return statements within the function itself. This is done in the
+ interest of execution time efficiency. */
for( ;; )
{
taskENTER_CRITICAL();
@@ -1373,7 +1411,7 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
mtCOVERAGE_TEST_MARKER();
}
}
- }
+ } /*lint -restore */
}
/*-----------------------------------------------------------*/
@@ -1381,7 +1419,7 @@ BaseType_t xQueueSemaphoreTake( QueueHandle_t xQueue, TickType_t xTicksToWait )
{
BaseType_t xEntryTimeSet = pdFALSE;
TimeOut_t xTimeOut;
-Queue_t * const pxQueue = ( Queue_t * ) xQueue;
+Queue_t * const pxQueue = xQueue;
#if( configUSE_MUTEXES == 1 )
BaseType_t xInheritanceOccurred = pdFALSE;
@@ -1402,10 +1440,9 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
#endif
- /* This function relaxes the coding standard somewhat to allow return
+ /*lint -save -e904 This function relaxes the coding standard somewhat to allow return
statements within the function itself. This is done in the interest
of execution time efficiency. */
-
for( ;; )
{
taskENTER_CRITICAL();
@@ -1430,7 +1467,7 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
{
/* Record the information required to implement
priority inheritance should it become necessary. */
- pxQueue->pxMutexHolder = ( int8_t * ) pvTaskIncrementMutexHeldCount(); /*lint !e961 Cast is not redundant as TaskHandle_t is a typedef. */
+ pxQueue->u.xSemaphore.xMutexHolder = pvTaskIncrementMutexHeldCount();
}
else
{
@@ -1518,7 +1555,7 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
{
taskENTER_CRITICAL();
{
- xInheritanceOccurred = xTaskPriorityInherit( ( void * ) pxQueue->pxMutexHolder );
+ xInheritanceOccurred = xTaskPriorityInherit( pxQueue->u.xSemaphore.xMutexHolder );
}
taskEXIT_CRITICAL();
}
@@ -1577,7 +1614,7 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
again, but only as low as the next highest priority
task that is waiting for the same mutex. */
uxHighestWaitingPriority = prvGetDisinheritPriorityAfterTimeout( pxQueue );
- vTaskPriorityDisinheritAfterTimeout( ( void * ) pxQueue->pxMutexHolder, uxHighestWaitingPriority );
+ vTaskPriorityDisinheritAfterTimeout( pxQueue->u.xSemaphore.xMutexHolder, uxHighestWaitingPriority );
}
taskEXIT_CRITICAL();
}
@@ -1592,7 +1629,7 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
mtCOVERAGE_TEST_MARKER();
}
}
- }
+ } /*lint -restore */
}
/*-----------------------------------------------------------*/
@@ -1601,7 +1638,7 @@ BaseType_t xQueuePeek( QueueHandle_t xQueue, void * const pvBuffer, TickType_t x
BaseType_t xEntryTimeSet = pdFALSE;
TimeOut_t xTimeOut;
int8_t *pcOriginalReadPosition;
-Queue_t * const pxQueue = ( Queue_t * ) xQueue;
+Queue_t * const pxQueue = xQueue;
/* Check the pointer is not NULL. */
configASSERT( ( pxQueue ) );
@@ -1618,10 +1655,9 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
#endif
- /* This function relaxes the coding standard somewhat to allow return
- statements within the function itself. This is done in the interest
- of execution time efficiency. */
-
+ /*lint -save -e904 This function relaxes the coding standard somewhat to
+ allow return statements within the function itself. This is done in the
+ interest of execution time efficiency. */
for( ;; )
{
taskENTER_CRITICAL();
@@ -1635,13 +1671,13 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
/* Remember the read position so it can be reset after the data
is read from the queue as this function is only peeking the
data, not removing it. */
- pcOriginalReadPosition = pxQueue->u.pcReadFrom;
+ pcOriginalReadPosition = pxQueue->u.xQueue.pcReadFrom;
prvCopyDataFromQueue( pxQueue, pvBuffer );
traceQUEUE_PEEK( pxQueue );
/* The data is not being removed, so reset the read pointer. */
- pxQueue->u.pcReadFrom = pcOriginalReadPosition;
+ pxQueue->u.xQueue.pcReadFrom = pcOriginalReadPosition;
/* The data is being left in the queue, so see if there are
any other tasks waiting for the data. */
@@ -1742,7 +1778,7 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
mtCOVERAGE_TEST_MARKER();
}
}
- }
+ } /*lint -restore */
}
/*-----------------------------------------------------------*/
@@ -1750,7 +1786,7 @@ BaseType_t xQueueReceiveFromISR( QueueHandle_t xQueue, void * const pvBuffer, Ba
{
BaseType_t xReturn;
UBaseType_t uxSavedInterruptStatus;
-Queue_t * const pxQueue = ( Queue_t * ) xQueue;
+Queue_t * const pxQueue = xQueue;
configASSERT( pxQueue );
configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) );
@@ -1842,7 +1878,7 @@ BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue, void * const pvBuffer )
BaseType_t xReturn;
UBaseType_t uxSavedInterruptStatus;
int8_t *pcOriginalReadPosition;
-Queue_t * const pxQueue = ( Queue_t * ) xQueue;
+Queue_t * const pxQueue = xQueue;
configASSERT( pxQueue );
configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) );
@@ -1873,9 +1909,9 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
/* Remember the read position so it can be reset as nothing is
actually being removed from the queue. */
- pcOriginalReadPosition = pxQueue->u.pcReadFrom;
+ pcOriginalReadPosition = pxQueue->u.xQueue.pcReadFrom;
prvCopyDataFromQueue( pxQueue, pvBuffer );
- pxQueue->u.pcReadFrom = pcOriginalReadPosition;
+ pxQueue->u.xQueue.pcReadFrom = pcOriginalReadPosition;
xReturn = pdPASS;
}
@@ -1910,9 +1946,8 @@ UBaseType_t uxReturn;
UBaseType_t uxQueueSpacesAvailable( const QueueHandle_t xQueue )
{
UBaseType_t uxReturn;
-Queue_t *pxQueue;
+Queue_t * const pxQueue = xQueue;
- pxQueue = ( Queue_t * ) xQueue;
configASSERT( pxQueue );
taskENTER_CRITICAL();
@@ -1928,10 +1963,10 @@ Queue_t *pxQueue;
UBaseType_t uxQueueMessagesWaitingFromISR( const QueueHandle_t xQueue )
{
UBaseType_t uxReturn;
+Queue_t * const pxQueue = xQueue;
- configASSERT( xQueue );
-
- uxReturn = ( ( Queue_t * ) xQueue )->uxMessagesWaiting;
+ configASSERT( pxQueue );
+ uxReturn = pxQueue->uxMessagesWaiting;
return uxReturn;
} /*lint !e818 Pointer cannot be declared const as xQueue is a typedef not pointer. */
@@ -1939,7 +1974,7 @@ UBaseType_t uxReturn;
void vQueueDelete( QueueHandle_t xQueue )
{
-Queue_t * const pxQueue = ( Queue_t * ) xQueue;
+Queue_t * const pxQueue = xQueue;
configASSERT( pxQueue );
traceQUEUE_DELETE( pxQueue );
@@ -2021,9 +2056,9 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
other tasks that are waiting for the same mutex. For this purpose,
return the priority of the highest priority task that is waiting for the
mutex. */
- if( listCURRENT_LIST_LENGTH( &( pxQueue->xTasksWaitingToReceive ) ) > 0 )
+ if( listCURRENT_LIST_LENGTH( &( pxQueue->xTasksWaitingToReceive ) ) > 0U )
{
- uxHighestPriorityOfWaitingTasks = configMAX_PRIORITIES - listGET_ITEM_VALUE_OF_HEAD_ENTRY( &( pxQueue->xTasksWaitingToReceive ) );
+ uxHighestPriorityOfWaitingTasks = ( UBaseType_t ) configMAX_PRIORITIES - ( UBaseType_t ) listGET_ITEM_VALUE_OF_HEAD_ENTRY( &( pxQueue->xTasksWaitingToReceive ) );
}
else
{
@@ -2052,8 +2087,8 @@ UBaseType_t uxMessagesWaiting;
if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX )
{
/* The mutex is no longer being held. */
- xReturn = xTaskPriorityDisinherit( ( void * ) pxQueue->pxMutexHolder );
- pxQueue->pxMutexHolder = NULL;
+ xReturn = xTaskPriorityDisinherit( pxQueue->u.xSemaphore.xMutexHolder );
+ pxQueue->u.xSemaphore.xMutexHolder = NULL;
}
else
{
@@ -2064,9 +2099,9 @@ UBaseType_t uxMessagesWaiting;
}
else if( xPosition == queueSEND_TO_BACK )
{
- ( void ) memcpy( ( void * ) pxQueue->pcWriteTo, pvItemToQueue, ( size_t ) pxQueue->uxItemSize ); /*lint !e961 !e418 MISRA exception as the casts are only redundant for some ports, plus previous logic ensures a null pointer can only be passed to memcpy() if the copy size is 0. */
- pxQueue->pcWriteTo += pxQueue->uxItemSize;
- if( pxQueue->pcWriteTo >= pxQueue->pcTail ) /*lint !e946 MISRA exception justified as comparison of pointers is the cleanest solution. */
+ ( void ) memcpy( ( void * ) pxQueue->pcWriteTo, pvItemToQueue, ( size_t ) pxQueue->uxItemSize ); /*lint !e961 !e418 !e9087 MISRA exception as the casts are only redundant for some ports, plus previous logic ensures a null pointer can only be passed to memcpy() if the copy size is 0. Cast to void required by function signature and safe as no alignment requirement and copy length specified in bytes. */
+ pxQueue->pcWriteTo += pxQueue->uxItemSize; /*lint !e9016 Pointer arithmetic on char types ok, especially in this use case where it is the clearest way of conveying intent. */
+ if( pxQueue->pcWriteTo >= pxQueue->u.xQueue.pcTail ) /*lint !e946 MISRA exception justified as comparison of pointers is the cleanest solution. */
{
pxQueue->pcWriteTo = pxQueue->pcHead;
}
@@ -2077,11 +2112,11 @@ UBaseType_t uxMessagesWaiting;
}
else
{
- ( void ) memcpy( ( void * ) pxQueue->u.pcReadFrom, pvItemToQueue, ( size_t ) pxQueue->uxItemSize ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */
- pxQueue->u.pcReadFrom -= pxQueue->uxItemSize;
- if( pxQueue->u.pcReadFrom < pxQueue->pcHead ) /*lint !e946 MISRA exception justified as comparison of pointers is the cleanest solution. */
+ ( void ) memcpy( ( void * ) pxQueue->u.xQueue.pcReadFrom, pvItemToQueue, ( size_t ) pxQueue->uxItemSize ); /*lint !e961 !e9087 !e418 MISRA exception as the casts are only redundant for some ports. Cast to void required by function signature and safe as no alignment requirement and copy length specified in bytes. Assert checks null pointer only used when length is 0. */
+ pxQueue->u.xQueue.pcReadFrom -= pxQueue->uxItemSize;
+ if( pxQueue->u.xQueue.pcReadFrom < pxQueue->pcHead ) /*lint !e946 MISRA exception justified as comparison of pointers is the cleanest solution. */
{
- pxQueue->u.pcReadFrom = ( pxQueue->pcTail - pxQueue->uxItemSize );
+ pxQueue->u.xQueue.pcReadFrom = ( pxQueue->u.xQueue.pcTail - pxQueue->uxItemSize );
}
else
{
@@ -2119,16 +2154,16 @@ static void prvCopyDataFromQueue( Queue_t * const pxQueue, void * const pvBuffer
{
if( pxQueue->uxItemSize != ( UBaseType_t ) 0 )
{
- pxQueue->u.pcReadFrom += pxQueue->uxItemSize;
- if( pxQueue->u.pcReadFrom >= pxQueue->pcTail ) /*lint !e946 MISRA exception justified as use of the relational operator is the cleanest solutions. */
+ pxQueue->u.xQueue.pcReadFrom += pxQueue->uxItemSize; /*lint !e9016 Pointer arithmetic on char types ok, especially in this use case where it is the clearest way of conveying intent. */
+ if( pxQueue->u.xQueue.pcReadFrom >= pxQueue->u.xQueue.pcTail ) /*lint !e946 MISRA exception justified as use of the relational operator is the cleanest solutions. */
{
- pxQueue->u.pcReadFrom = pxQueue->pcHead;
+ pxQueue->u.xQueue.pcReadFrom = pxQueue->pcHead;
}
else
{
mtCOVERAGE_TEST_MARKER();
}
- ( void ) memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.pcReadFrom, ( size_t ) pxQueue->uxItemSize ); /*lint !e961 !e418 MISRA exception as the casts are only redundant for some ports. Also previous logic ensures a null pointer can only be passed to memcpy() when the count is 0. */
+ ( void ) memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.xQueue.pcReadFrom, ( size_t ) pxQueue->uxItemSize ); /*lint !e961 !e418 !e9087 MISRA exception as the casts are only redundant for some ports. Also previous logic ensures a null pointer can only be passed to memcpy() when the count is 0. Cast to void required by function signature and safe as no alignment requirement and copy length specified in bytes. */
}
}
/*-----------------------------------------------------------*/
@@ -2154,7 +2189,7 @@ static void prvUnlockQueue( Queue_t * const pxQueue )
{
if( pxQueue->pxQueueSetContainer != NULL )
{
- if( prvNotifyQueueSetContainer( pxQueue, queueSEND_TO_BACK ) != pdFALSE )
+ if( prvNotifyQueueSetContainer( pxQueue ) != pdFALSE )
{
/* The queue is a member of a queue set, and posting to
the queue set caused a higher priority task to unblock.
@@ -2277,9 +2312,10 @@ BaseType_t xReturn;
BaseType_t xQueueIsQueueEmptyFromISR( const QueueHandle_t xQueue )
{
BaseType_t xReturn;
+Queue_t * const pxQueue = xQueue;
- configASSERT( xQueue );
- if( ( ( Queue_t * ) xQueue )->uxMessagesWaiting == ( UBaseType_t ) 0 )
+ configASSERT( pxQueue );
+ if( pxQueue->uxMessagesWaiting == ( UBaseType_t ) 0 )
{
xReturn = pdTRUE;
}
@@ -2316,9 +2352,10 @@ BaseType_t xReturn;
BaseType_t xQueueIsQueueFullFromISR( const QueueHandle_t xQueue )
{
BaseType_t xReturn;
+Queue_t * const pxQueue = xQueue;
- configASSERT( xQueue );
- if( ( ( Queue_t * ) xQueue )->uxMessagesWaiting == ( ( Queue_t * ) xQueue )->uxLength )
+ configASSERT( pxQueue );
+ if( pxQueue->uxMessagesWaiting == pxQueue->uxLength )
{
xReturn = pdTRUE;
}
@@ -2336,7 +2373,7 @@ BaseType_t xReturn;
BaseType_t xQueueCRSend( QueueHandle_t xQueue, const void *pvItemToQueue, TickType_t xTicksToWait )
{
BaseType_t xReturn;
- Queue_t * const pxQueue = ( Queue_t * ) xQueue;
+ Queue_t * const pxQueue = xQueue;
/* If the queue is already full we may have to block. A critical section
is required to prevent an interrupt removing something from the queue
@@ -2413,7 +2450,7 @@ BaseType_t xReturn;
BaseType_t xQueueCRReceive( QueueHandle_t xQueue, void *pvBuffer, TickType_t xTicksToWait )
{
BaseType_t xReturn;
- Queue_t * const pxQueue = ( Queue_t * ) xQueue;
+ Queue_t * const pxQueue = xQueue;
/* If the queue is already empty we may have to block. A critical section
is required to prevent an interrupt adding something to the queue
@@ -2450,17 +2487,17 @@ BaseType_t xReturn;
if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 )
{
/* Data is available from the queue. */
- pxQueue->u.pcReadFrom += pxQueue->uxItemSize;
- if( pxQueue->u.pcReadFrom >= pxQueue->pcTail )
+ pxQueue->u.xQueue.pcReadFrom += pxQueue->uxItemSize;
+ if( pxQueue->u.xQueue.pcReadFrom >= pxQueue->u.xQueue.pcTail )
{
- pxQueue->u.pcReadFrom = pxQueue->pcHead;
+ pxQueue->u.xQueue.pcReadFrom = pxQueue->pcHead;
}
else
{
mtCOVERAGE_TEST_MARKER();
}
--( pxQueue->uxMessagesWaiting );
- ( void ) memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.pcReadFrom, ( unsigned ) pxQueue->uxItemSize );
+ ( void ) memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.xQueue.pcReadFrom, ( unsigned ) pxQueue->uxItemSize );
xReturn = pdPASS;
@@ -2502,7 +2539,7 @@ BaseType_t xReturn;
BaseType_t xQueueCRSendFromISR( QueueHandle_t xQueue, const void *pvItemToQueue, BaseType_t xCoRoutinePreviouslyWoken )
{
- Queue_t * const pxQueue = ( Queue_t * ) xQueue;
+ Queue_t * const pxQueue = xQueue;
/* Cannot block within an ISR so if there is no space on the queue then
exit without doing anything. */
@@ -2551,24 +2588,24 @@ BaseType_t xReturn;
BaseType_t xQueueCRReceiveFromISR( QueueHandle_t xQueue, void *pvBuffer, BaseType_t *pxCoRoutineWoken )
{
BaseType_t xReturn;
- Queue_t * const pxQueue = ( Queue_t * ) xQueue;
+ Queue_t * const pxQueue = xQueue;
/* We cannot block from an ISR, so check there is data available. If
not then just leave without doing anything. */
if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 )
{
/* Copy the data from the queue. */
- pxQueue->u.pcReadFrom += pxQueue->uxItemSize;
- if( pxQueue->u.pcReadFrom >= pxQueue->pcTail )
+ pxQueue->u.xQueue.pcReadFrom += pxQueue->uxItemSize;
+ if( pxQueue->u.xQueue.pcReadFrom >= pxQueue->u.xQueue.pcTail )
{
- pxQueue->u.pcReadFrom = pxQueue->pcHead;
+ pxQueue->u.xQueue.pcReadFrom = pxQueue->pcHead;
}
else
{
mtCOVERAGE_TEST_MARKER();
}
--( pxQueue->uxMessagesWaiting );
- ( void ) memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.pcReadFrom, ( unsigned ) pxQueue->uxItemSize );
+ ( void ) memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.xQueue.pcReadFrom, ( unsigned ) pxQueue->uxItemSize );
if( ( *pxCoRoutineWoken ) == pdFALSE )
{
@@ -2699,7 +2736,7 @@ BaseType_t xReturn;
void vQueueWaitForMessageRestricted( QueueHandle_t xQueue, TickType_t xTicksToWait, const BaseType_t xWaitIndefinitely )
{
- Queue_t * const pxQueue = ( Queue_t * ) xQueue;
+ Queue_t * const pxQueue = xQueue;
/* This function should not be called by application code hence the
'Restricted' in its name. It is not part of the public API. It is
@@ -2842,7 +2879,7 @@ BaseType_t xReturn;
#if ( configUSE_QUEUE_SETS == 1 )
- static BaseType_t prvNotifyQueueSetContainer( const Queue_t * const pxQueue, const BaseType_t xCopyPosition )
+ static BaseType_t prvNotifyQueueSetContainer( const Queue_t * const pxQueue )
{
Queue_t *pxQueueSetContainer = pxQueue->pxQueueSetContainer;
BaseType_t xReturn = pdFALSE;
@@ -2859,7 +2896,7 @@ BaseType_t xReturn;
traceQUEUE_SEND( pxQueueSetContainer );
/* The data copied is the handle of the queue that contains data. */
- xReturn = prvCopyDataToQueue( pxQueueSetContainer, &pxQueue, xCopyPosition );
+ xReturn = prvCopyDataToQueue( pxQueueSetContainer, &pxQueue, queueSEND_TO_BACK );
if( cTxLock == queueUNLOCKED )
{
diff --git a/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/stream_buffer.c b/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/stream_buffer.c
index c0ef727..c88e4ea 100644
--- a/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/stream_buffer.c
+++ b/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/stream_buffer.c
@@ -1,6 +1,6 @@
/*
- * FreeRTOS Kernel V10.0.1
- * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * FreeRTOS Kernel V10.3.1
+ * 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
@@ -43,11 +43,11 @@ task.h is included from an application file. */
#error configUSE_TASK_NOTIFICATIONS must be set to 1 to build stream_buffer.c
#endif
-/* Lint e961 and e750 are suppressed as a MISRA exception justified because the
-MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined for the
-header files above, but not in this file, in order to generate the correct
-privileged Vs unprivileged linkage and placement. */
-#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750. */
+/* Lint e961, e9021 and e750 are suppressed as a MISRA exception justified
+because the MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined
+for the header files above, but not in this file, in order to generate the
+correct privileged Vs unprivileged linkage and placement. */
+#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750 !e9021. */
/* If the user has not provided application specific Rx notification macros,
or #defined the notification macros away, them provide default implementations
@@ -129,7 +129,7 @@ that uses task notifications. */
/*lint -restore (9026) */
/* The number of bytes used to hold the length of a message in the buffer. */
-#define sbBYTES_TO_STORE_MESSAGE_LENGTH ( sizeof( size_t ) )
+#define sbBYTES_TO_STORE_MESSAGE_LENGTH ( sizeof( configMESSAGE_BUFFER_LENGTH_TYPE ) )
/* Bits stored in the ucFlags field of the stream buffer. */
#define sbFLAGS_IS_MESSAGE_BUFFER ( ( uint8_t ) 1 ) /* Set if the stream buffer was created as a message buffer, in which case it holds discrete messages rather than a stream. */
@@ -138,7 +138,7 @@ that uses task notifications. */
/*-----------------------------------------------------------*/
/* Structure that hold state information on the buffer. */
-typedef struct xSTREAM_BUFFER /*lint !e9058 Style convention uses tag. */
+typedef struct StreamBufferDef_t /*lint !e9058 Style convention uses tag. */
{
volatile size_t xTail; /* Index to the next item to read within the buffer. */
volatile size_t xHead; /* Index to the next item to write within the buffer. */
@@ -200,7 +200,7 @@ static size_t prvWriteMessageToBuffer( StreamBuffer_t * const pxStreamBuffer,
static size_t prvReadBytesFromBuffer( StreamBuffer_t *pxStreamBuffer,
uint8_t *pucData,
size_t xMaxCount,
- size_t xBytesAvailable ); PRIVILEGED_FUNCTION
+ size_t xBytesAvailable ) PRIVILEGED_FUNCTION;
/*
* Called by both pxStreamBufferCreate() and pxStreamBufferCreateStatic() to
@@ -210,7 +210,7 @@ static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer,
uint8_t * const pucBuffer,
size_t xBufferSizeBytes,
size_t xTriggerLevelBytes,
- BaseType_t xIsMessageBuffer ) PRIVILEGED_FUNCTION;
+ uint8_t ucFlags ) PRIVILEGED_FUNCTION;
/*-----------------------------------------------------------*/
@@ -219,19 +219,31 @@ static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer,
StreamBufferHandle_t xStreamBufferGenericCreate( size_t xBufferSizeBytes, size_t xTriggerLevelBytes, BaseType_t xIsMessageBuffer )
{
uint8_t *pucAllocatedMemory;
+ uint8_t ucFlags;
/* In case the stream buffer is going to be used as a message buffer
(that is, it will hold discrete messages with a little meta data that
says how big the next message is) check the buffer will be large enough
to hold at least one message. */
- configASSERT( xBufferSizeBytes > sbBYTES_TO_STORE_MESSAGE_LENGTH );
+ if( xIsMessageBuffer == pdTRUE )
+ {
+ /* Is a message buffer but not statically allocated. */
+ ucFlags = sbFLAGS_IS_MESSAGE_BUFFER;
+ configASSERT( xBufferSizeBytes > sbBYTES_TO_STORE_MESSAGE_LENGTH );
+ }
+ else
+ {
+ /* Not a message buffer and not statically allocated. */
+ ucFlags = 0;
+ configASSERT( xBufferSizeBytes > 0 );
+ }
configASSERT( xTriggerLevelBytes <= xBufferSizeBytes );
/* A trigger level of 0 would cause a waiting task to unblock even when
the buffer was empty. */
if( xTriggerLevelBytes == ( size_t ) 0 )
{
- xTriggerLevelBytes = ( size_t ) 1; /*lint !e9044 Parameter modified to ensure it doesn't have a dangerous value. */
+ xTriggerLevelBytes = ( size_t ) 1;
}
/* A stream buffer requires a StreamBuffer_t structure and a buffer.
@@ -251,7 +263,7 @@ static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer,
pucAllocatedMemory + sizeof( StreamBuffer_t ), /* Storage area follows. */ /*lint !e9016 Indexing past structure valid for uint8_t pointer, also storage area has no alignment requirement. */
xBufferSizeBytes,
xTriggerLevelBytes,
- xIsMessageBuffer );
+ ucFlags );
traceSTREAM_BUFFER_CREATE( ( ( StreamBuffer_t * ) pucAllocatedMemory ), xIsMessageBuffer );
}
@@ -260,7 +272,7 @@ static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer,
traceSTREAM_BUFFER_CREATE_FAILED( xIsMessageBuffer );
}
- return ( StreamBufferHandle_t * ) pucAllocatedMemory; /*lint !e9087 !e826 Safe cast as allocated memory is aligned. */
+ return ( StreamBufferHandle_t ) pucAllocatedMemory; /*lint !e9087 !e826 Safe cast as allocated memory is aligned. */
}
#endif /* configSUPPORT_DYNAMIC_ALLOCATION */
@@ -276,6 +288,7 @@ static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer,
{
StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) pxStaticStreamBuffer; /*lint !e740 !e9087 Safe cast as StaticStreamBuffer_t is opaque Streambuffer_t. */
StreamBufferHandle_t xReturn;
+ uint8_t ucFlags;
configASSERT( pucStreamBufferStorageArea );
configASSERT( pxStaticStreamBuffer );
@@ -285,7 +298,18 @@ static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer,
the buffer was empty. */
if( xTriggerLevelBytes == ( size_t ) 0 )
{
- xTriggerLevelBytes = ( size_t ) 1; /*lint !e9044 Function parameter deliberately modified to ensure it is in range. */
+ xTriggerLevelBytes = ( size_t ) 1;
+ }
+
+ if( xIsMessageBuffer != pdFALSE )
+ {
+ /* Statically allocated message buffer. */
+ ucFlags = sbFLAGS_IS_MESSAGE_BUFFER | sbFLAGS_IS_STATICALLY_ALLOCATED;
+ }
+ else
+ {
+ /* Statically allocated stream buffer. */
+ ucFlags = sbFLAGS_IS_STATICALLY_ALLOCATED;
}
/* In case the stream buffer is going to be used as a message buffer
@@ -301,7 +325,7 @@ static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer,
message buffer structure. */
volatile size_t xSize = sizeof( StaticStreamBuffer_t );
configASSERT( xSize == sizeof( StreamBuffer_t ) );
- }
+ } /*lint !e529 xSize is referenced is configASSERT() is defined. */
#endif /* configASSERT_DEFINED */
if( ( pucStreamBufferStorageArea != NULL ) && ( pxStaticStreamBuffer != NULL ) )
@@ -310,7 +334,7 @@ static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer,
pucStreamBufferStorageArea,
xBufferSizeBytes,
xTriggerLevelBytes,
- xIsMessageBuffer );
+ ucFlags );
/* Remember this was statically allocated in case it is ever deleted
again. */
@@ -334,7 +358,7 @@ static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer,
void vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer )
{
-StreamBuffer_t * pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */
+StreamBuffer_t * pxStreamBuffer = xStreamBuffer;
configASSERT( pxStreamBuffer );
@@ -360,15 +384,15 @@ StreamBuffer_t * pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9
{
/* The structure and buffer were not allocated dynamically and cannot be
freed - just scrub the structure so future use will assert. */
- memset( pxStreamBuffer, 0x00, sizeof( StreamBuffer_t ) );
+ ( void ) memset( pxStreamBuffer, 0x00, sizeof( StreamBuffer_t ) );
}
}
/*-----------------------------------------------------------*/
BaseType_t xStreamBufferReset( StreamBufferHandle_t xStreamBuffer )
{
-StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */
-BaseType_t xReturn = pdFAIL, xIsMessageBuffer;
+StreamBuffer_t * const pxStreamBuffer = xStreamBuffer;
+BaseType_t xReturn = pdFAIL;
#if( configUSE_TRACE_FACILITY == 1 )
UBaseType_t uxStreamBufferNumber;
@@ -385,35 +409,30 @@ BaseType_t xReturn = pdFAIL, xIsMessageBuffer;
#endif
/* Can only reset a message buffer if there are no tasks blocked on it. */
- if( pxStreamBuffer->xTaskWaitingToReceive == NULL )
+ taskENTER_CRITICAL();
{
- if( pxStreamBuffer->xTaskWaitingToSend == NULL )
+ if( pxStreamBuffer->xTaskWaitingToReceive == NULL )
{
- if( ( pxStreamBuffer->ucFlags & sbFLAGS_IS_MESSAGE_BUFFER ) != ( uint8_t ) 0 )
+ if( pxStreamBuffer->xTaskWaitingToSend == NULL )
{
- xIsMessageBuffer = pdTRUE;
- }
- else
- {
- xIsMessageBuffer = pdFALSE;
- }
+ prvInitialiseNewStreamBuffer( pxStreamBuffer,
+ pxStreamBuffer->pucBuffer,
+ pxStreamBuffer->xLength,
+ pxStreamBuffer->xTriggerLevelBytes,
+ pxStreamBuffer->ucFlags );
+ xReturn = pdPASS;
- prvInitialiseNewStreamBuffer( pxStreamBuffer,
- pxStreamBuffer->pucBuffer,
- pxStreamBuffer->xLength,
- pxStreamBuffer->xTriggerLevelBytes,
- xIsMessageBuffer );
- xReturn = pdPASS;
+ #if( configUSE_TRACE_FACILITY == 1 )
+ {
+ pxStreamBuffer->uxStreamBufferNumber = uxStreamBufferNumber;
+ }
+ #endif
- #if( configUSE_TRACE_FACILITY == 1 )
- {
- pxStreamBuffer->uxStreamBufferNumber = uxStreamBufferNumber;
+ traceSTREAM_BUFFER_RESET( xStreamBuffer );
}
- #endif
-
- traceSTREAM_BUFFER_RESET( xStreamBuffer );
}
}
+ taskEXIT_CRITICAL();
return xReturn;
}
@@ -421,7 +440,7 @@ BaseType_t xReturn = pdFAIL, xIsMessageBuffer;
BaseType_t xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer, size_t xTriggerLevel )
{
-StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */
+StreamBuffer_t * const pxStreamBuffer = xStreamBuffer;
BaseType_t xReturn;
configASSERT( pxStreamBuffer );
@@ -429,7 +448,7 @@ BaseType_t xReturn;
/* It is not valid for the trigger level to be 0. */
if( xTriggerLevel == ( size_t ) 0 )
{
- xTriggerLevel = ( size_t ) 1; /*lint !e9044 Parameter modified to ensure it doesn't have a dangerous value. */
+ xTriggerLevel = ( size_t ) 1;
}
/* The trigger level is the number of bytes that must be in the stream
@@ -450,7 +469,7 @@ BaseType_t xReturn;
size_t xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer )
{
-const StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */
+const StreamBuffer_t * const pxStreamBuffer = xStreamBuffer;
size_t xSpace;
configASSERT( pxStreamBuffer );
@@ -474,7 +493,7 @@ size_t xSpace;
size_t xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer )
{
-const StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */
+const StreamBuffer_t * const pxStreamBuffer = xStreamBuffer;
size_t xReturn;
configASSERT( pxStreamBuffer );
@@ -489,7 +508,7 @@ size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer,
size_t xDataLengthBytes,
TickType_t xTicksToWait )
{
-StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */
+StreamBuffer_t * const pxStreamBuffer = xStreamBuffer;
size_t xReturn, xSpace = 0;
size_t xRequiredSpace = xDataLengthBytes;
TimeOut_t xTimeOut;
@@ -504,6 +523,9 @@ TimeOut_t xTimeOut;
if( ( pxStreamBuffer->ucFlags & sbFLAGS_IS_MESSAGE_BUFFER ) != ( uint8_t ) 0 )
{
xRequiredSpace += sbBYTES_TO_STORE_MESSAGE_LENGTH;
+
+ /* Overflow? */
+ configASSERT( xRequiredSpace > xDataLengthBytes );
}
else
{
@@ -540,7 +562,7 @@ TimeOut_t xTimeOut;
taskEXIT_CRITICAL();
traceBLOCKING_ON_STREAM_BUFFER_SEND( xStreamBuffer );
- ( void ) xTaskNotifyWait( ( uint32_t ) 0, UINT32_MAX, NULL, xTicksToWait );
+ ( void ) xTaskNotifyWait( ( uint32_t ) 0, ( uint32_t ) 0, NULL, xTicksToWait );
pxStreamBuffer->xTaskWaitingToSend = NULL;
} while( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE );
@@ -590,7 +612,7 @@ size_t xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer,
size_t xDataLengthBytes,
BaseType_t * const pxHigherPriorityTaskWoken )
{
-StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */
+StreamBuffer_t * const pxStreamBuffer = xStreamBuffer;
size_t xReturn, xSpace;
size_t xRequiredSpace = xDataLengthBytes;
@@ -657,7 +679,7 @@ static size_t prvWriteMessageToBuffer( StreamBuffer_t * const pxStreamBuffer,
stream of bytes rather than discrete messages. Write as many bytes as
possible. */
xShouldWrite = pdTRUE;
- xDataLengthBytes = configMIN( xDataLengthBytes, xSpace ); /*lint !e9044 Function parameter modified to ensure it is capped to available space. */
+ xDataLengthBytes = configMIN( xDataLengthBytes, xSpace );
}
else if( xSpace >= xRequiredSpace )
{
@@ -693,7 +715,7 @@ size_t xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer,
size_t xBufferLengthBytes,
TickType_t xTicksToWait )
{
-StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */
+StreamBuffer_t * const pxStreamBuffer = xStreamBuffer;
size_t xReceivedLength = 0, xBytesAvailable, xBytesToStoreMessageLength;
configASSERT( pvRxData );
@@ -746,7 +768,7 @@ size_t xReceivedLength = 0, xBytesAvailable, xBytesToStoreMessageLength;
{
/* Wait for data to be available. */
traceBLOCKING_ON_STREAM_BUFFER_RECEIVE( xStreamBuffer );
- ( void ) xTaskNotifyWait( ( uint32_t ) 0, UINT32_MAX, NULL, xTicksToWait );
+ ( void ) xTaskNotifyWait( ( uint32_t ) 0, ( uint32_t ) 0, NULL, xTicksToWait );
pxStreamBuffer->xTaskWaitingToReceive = NULL;
/* Recheck the data available after blocking. */
@@ -792,12 +814,56 @@ size_t xReceivedLength = 0, xBytesAvailable, xBytesToStoreMessageLength;
}
/*-----------------------------------------------------------*/
+size_t xStreamBufferNextMessageLengthBytes( StreamBufferHandle_t xStreamBuffer )
+{
+StreamBuffer_t * const pxStreamBuffer = xStreamBuffer;
+size_t xReturn, xBytesAvailable, xOriginalTail;
+configMESSAGE_BUFFER_LENGTH_TYPE xTempReturn;
+
+ configASSERT( pxStreamBuffer );
+
+ /* Ensure the stream buffer is being used as a message buffer. */
+ if( ( pxStreamBuffer->ucFlags & sbFLAGS_IS_MESSAGE_BUFFER ) != ( uint8_t ) 0 )
+ {
+ xBytesAvailable = prvBytesInBuffer( pxStreamBuffer );
+ if( xBytesAvailable > sbBYTES_TO_STORE_MESSAGE_LENGTH )
+ {
+ /* The number of bytes available is greater than the number of bytes
+ required to hold the length of the next message, so another message
+ is available. Return its length without removing the length bytes
+ from the buffer. A copy of the tail is stored so the buffer can be
+ returned to its prior state as the message is not actually being
+ removed from the buffer. */
+ xOriginalTail = pxStreamBuffer->xTail;
+ ( void ) prvReadBytesFromBuffer( pxStreamBuffer, ( uint8_t * ) &xTempReturn, sbBYTES_TO_STORE_MESSAGE_LENGTH, xBytesAvailable );
+ xReturn = ( size_t ) xTempReturn;
+ pxStreamBuffer->xTail = xOriginalTail;
+ }
+ else
+ {
+ /* The minimum amount of bytes in a message buffer is
+ ( sbBYTES_TO_STORE_MESSAGE_LENGTH + 1 ), so if xBytesAvailable is
+ less than sbBYTES_TO_STORE_MESSAGE_LENGTH the only other valid
+ value is 0. */
+ configASSERT( xBytesAvailable == 0 );
+ xReturn = 0;
+ }
+ }
+ else
+ {
+ xReturn = 0;
+ }
+
+ return xReturn;
+}
+/*-----------------------------------------------------------*/
+
size_t xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer,
void *pvRxData,
size_t xBufferLengthBytes,
BaseType_t * const pxHigherPriorityTaskWoken )
{
-StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */
+StreamBuffer_t * const pxStreamBuffer = xStreamBuffer;
size_t xReceivedLength = 0, xBytesAvailable, xBytesToStoreMessageLength;
configASSERT( pvRxData );
@@ -856,6 +922,7 @@ static size_t prvReadMessageFromBuffer( StreamBuffer_t *pxStreamBuffer,
size_t xBytesToStoreMessageLength )
{
size_t xOriginalTail, xReceivedLength, xNextMessageLength;
+configMESSAGE_BUFFER_LENGTH_TYPE xTempNextMessageLength;
if( xBytesToStoreMessageLength != ( size_t ) 0 )
{
@@ -864,7 +931,8 @@ size_t xOriginalTail, xReceivedLength, xNextMessageLength;
returned to its prior state if the length of the message is too
large for the provided buffer. */
xOriginalTail = pxStreamBuffer->xTail;
- ( void ) prvReadBytesFromBuffer( pxStreamBuffer, ( uint8_t * ) &xNextMessageLength, xBytesToStoreMessageLength, xBytesAvailable );
+ ( void ) prvReadBytesFromBuffer( pxStreamBuffer, ( uint8_t * ) &xTempNextMessageLength, xBytesToStoreMessageLength, xBytesAvailable );
+ xNextMessageLength = ( size_t ) xTempNextMessageLength;
/* Reduce the number of bytes available by the number of bytes just
read out. */
@@ -901,7 +969,7 @@ size_t xOriginalTail, xReceivedLength, xNextMessageLength;
BaseType_t xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer )
{
-const StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */
+const StreamBuffer_t * const pxStreamBuffer = xStreamBuffer;
BaseType_t xReturn;
size_t xTail;
@@ -926,7 +994,7 @@ BaseType_t xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer )
{
BaseType_t xReturn;
size_t xBytesToStoreMessageLength;
-const StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */
+const StreamBuffer_t * const pxStreamBuffer = xStreamBuffer;
configASSERT( pxStreamBuffer );
@@ -959,7 +1027,7 @@ const StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer
BaseType_t xStreamBufferSendCompletedFromISR( StreamBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken )
{
-StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */
+StreamBuffer_t * const pxStreamBuffer = xStreamBuffer;
BaseType_t xReturn;
UBaseType_t uxSavedInterruptStatus;
@@ -989,7 +1057,7 @@ UBaseType_t uxSavedInterruptStatus;
BaseType_t xStreamBufferReceiveCompletedFromISR( StreamBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken )
{
-StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */
+StreamBuffer_t * const pxStreamBuffer = xStreamBuffer;
BaseType_t xReturn;
UBaseType_t uxSavedInterruptStatus;
@@ -1032,7 +1100,7 @@ size_t xNextHead, xFirstLength;
/* Write as many bytes as can be written in the first write. */
configASSERT( ( xNextHead + xFirstLength ) <= pxStreamBuffer->xLength );
- memcpy( ( void* ) ( &( pxStreamBuffer->pucBuffer[ xNextHead ] ) ), ( const void * ) pucData, xFirstLength ); /*lint !e9087 memcpy() requires void *. */
+ ( void ) memcpy( ( void* ) ( &( pxStreamBuffer->pucBuffer[ xNextHead ] ) ), ( const void * ) pucData, xFirstLength ); /*lint !e9087 memcpy() requires void *. */
/* If the number of bytes written was less than the number that could be
written in the first write... */
@@ -1040,7 +1108,7 @@ size_t xNextHead, xFirstLength;
{
/* ...then write the remaining bytes to the start of the buffer. */
configASSERT( ( xCount - xFirstLength ) <= pxStreamBuffer->xLength );
- memcpy( ( void * ) pxStreamBuffer->pucBuffer, ( const void * ) &( pucData[ xFirstLength ] ), xCount - xFirstLength ); /*lint !e9087 memcpy() requires void *. */
+ ( void ) memcpy( ( void * ) pxStreamBuffer->pucBuffer, ( const void * ) &( pucData[ xFirstLength ] ), xCount - xFirstLength ); /*lint !e9087 memcpy() requires void *. */
}
else
{
@@ -1083,7 +1151,7 @@ size_t xCount, xFirstLength, xNextTail;
read. Asserts check bounds of read and write. */
configASSERT( xFirstLength <= xMaxCount );
configASSERT( ( xNextTail + xFirstLength ) <= pxStreamBuffer->xLength );
- memcpy( ( void * ) pucData, ( const void * ) &( pxStreamBuffer->pucBuffer[ xNextTail ] ), xFirstLength ); /*lint !e9087 memcpy() requires void *. */
+ ( void ) memcpy( ( void * ) pucData, ( const void * ) &( pxStreamBuffer->pucBuffer[ xNextTail ] ), xFirstLength ); /*lint !e9087 memcpy() requires void *. */
/* If the total number of wanted bytes is greater than the number
that could be read in the first read... */
@@ -1091,7 +1159,7 @@ size_t xCount, xFirstLength, xNextTail;
{
/*...then read the remaining bytes from the start of the buffer. */
configASSERT( xCount <= xMaxCount );
- memcpy( ( void * ) &( pucData[ xFirstLength ] ), ( void * ) ( pxStreamBuffer->pucBuffer ), xCount - xFirstLength ); /*lint !e9087 memcpy() requires void *. */
+ ( void ) memcpy( ( void * ) &( pucData[ xFirstLength ] ), ( void * ) ( pxStreamBuffer->pucBuffer ), xCount - xFirstLength ); /*lint !e9087 memcpy() requires void *. */
}
else
{
@@ -1142,7 +1210,7 @@ static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer,
uint8_t * const pucBuffer,
size_t xBufferSizeBytes,
size_t xTriggerLevelBytes,
- BaseType_t xIsMessageBuffer )
+ uint8_t ucFlags )
{
/* Assert here is deliberately writing to the entire buffer to ensure it can
be written to without generating exceptions, and is setting the buffer to a
@@ -1154,25 +1222,21 @@ static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer,
result in confusion as to what is actually being observed. */
const BaseType_t xWriteValue = 0x55;
configASSERT( memset( pucBuffer, ( int ) xWriteValue, xBufferSizeBytes ) == pucBuffer );
- }
+ } /*lint !e529 !e438 xWriteValue is only used if configASSERT() is defined. */
#endif
- memset( ( void * ) pxStreamBuffer, 0x00, sizeof( StreamBuffer_t ) ); /*lint !e9087 memset() requires void *. */
+ ( void ) memset( ( void * ) pxStreamBuffer, 0x00, sizeof( StreamBuffer_t ) ); /*lint !e9087 memset() requires void *. */
pxStreamBuffer->pucBuffer = pucBuffer;
pxStreamBuffer->xLength = xBufferSizeBytes;
pxStreamBuffer->xTriggerLevelBytes = xTriggerLevelBytes;
-
- if( xIsMessageBuffer != pdFALSE )
- {
- pxStreamBuffer->ucFlags |= sbFLAGS_IS_MESSAGE_BUFFER;
- }
+ pxStreamBuffer->ucFlags = ucFlags;
}
#if ( configUSE_TRACE_FACILITY == 1 )
UBaseType_t uxStreamBufferGetStreamBufferNumber( StreamBufferHandle_t xStreamBuffer )
{
- return ( ( StreamBuffer_t * ) xStreamBuffer )->uxStreamBufferNumber;
+ return xStreamBuffer->uxStreamBufferNumber;
}
#endif /* configUSE_TRACE_FACILITY */
@@ -1182,7 +1246,7 @@ static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer,
void vStreamBufferSetStreamBufferNumber( StreamBufferHandle_t xStreamBuffer, UBaseType_t uxStreamBufferNumber )
{
- ( ( StreamBuffer_t * ) xStreamBuffer )->uxStreamBufferNumber = uxStreamBufferNumber;
+ xStreamBuffer->uxStreamBufferNumber = uxStreamBufferNumber;
}
#endif /* configUSE_TRACE_FACILITY */
@@ -1192,7 +1256,7 @@ static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer,
uint8_t ucStreamBufferGetStreamBufferType( StreamBufferHandle_t xStreamBuffer )
{
- return ( ( StreamBuffer_t * )xStreamBuffer )->ucFlags | sbFLAGS_IS_MESSAGE_BUFFER;
+ return ( xStreamBuffer->ucFlags & sbFLAGS_IS_MESSAGE_BUFFER );
}
#endif /* configUSE_TRACE_FACILITY */
diff --git a/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/tasks.c b/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/tasks.c
index 9e1cb9b..f93fca0 100644
--- a/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/tasks.c
+++ b/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/tasks.c
@@ -1,6 +1,6 @@
/*
- * FreeRTOS Kernel V10.0.1
- * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * FreeRTOS Kernel V10.3.1
+ * 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
@@ -40,11 +40,11 @@ task.h is included from an application file. */
#include "timers.h"
#include "stack_macros.h"
-/* Lint e961 and e750 are suppressed as a MISRA exception justified because the
-MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined for the
-header files above, but not in this file, in order to generate the correct
-privileged Vs unprivileged linkage and placement. */
-#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750. */
+/* Lint e9021, e961 and e750 are suppressed as a MISRA exception justified
+because the MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined
+for the header files above, but not in this file, in order to generate the
+correct privileged Vs unprivileged linkage and placement. */
+#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750 !e9021. */
/* Set configUSE_STATS_FORMATTING_FUNCTIONS to 2 to include the stats formatting
functions but without including stdio.h here. */
@@ -75,24 +75,7 @@ functions but without including stdio.h here. */
*/
#define tskSTACK_FILL_BYTE ( 0xa5U )
-/* Sometimes the FreeRTOSConfig.h settings only allow a task to be created using
-dynamically allocated RAM, in which case when any task is deleted it is known
-that both the task's stack and TCB need to be freed. Sometimes the
-FreeRTOSConfig.h settings only allow a task to be created using statically
-allocated RAM, in which case when any task is deleted it is known that neither
-the task's stack or TCB should be freed. Sometimes the FreeRTOSConfig.h
-settings allow a task to be created using either statically or dynamically
-allocated RAM, in which case a member of the TCB is used to record whether the
-stack and/or TCB were allocated statically or dynamically, so when a task is
-deleted the RAM that was allocated dynamically is freed again and no attempt is
-made to free the RAM that was allocated statically.
-tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE is only true if it is possible for a
-task to be created using either statically or dynamically allocated RAM. Note
-that if portUSING_MPU_WRAPPERS is 1 then a protected task can be created with
-a statically allocated stack and a dynamically allocated TCB.
-!!!NOTE!!! If the definition of tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE is
-changed then the definition of StaticTask_t must also be updated. */
-#define tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
+/* Bits used to recored how a task's stack and TCB were allocated. */
#define tskDYNAMICALLY_ALLOCATED_STACK_AND_TCB ( ( uint8_t ) 0 )
#define tskSTATICALLY_ALLOCATED_STACK_ONLY ( ( uint8_t ) 1 )
#define tskSTATICALLY_ALLOCATED_STACK_AND_TCB ( ( uint8_t ) 2 )
@@ -100,7 +83,7 @@ changed then the definition of StaticTask_t must also be updated. */
/* If any of the following are set then task stacks are filled with a known
value so the high water mark can be determined. If none of the following are
set then don't fill the stack so there is no unnecessary dependency on memset. */
-#if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) || ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) )
+#if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) || ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark2 == 1 ) )
#define tskSET_NEW_STACKS_TO_KNOWN_VALUE 1
#else
#define tskSET_NEW_STACKS_TO_KNOWN_VALUE 0
@@ -245,7 +228,7 @@ count overflows. */
* task should be used in place of the parameter. This macro simply checks to
* see if the parameter is NULL and returns a pointer to the appropriate TCB.
*/
-#define prvGetTCBFromHandle( pxHandle ) ( ( ( pxHandle ) == NULL ) ? ( TCB_t * ) pxCurrentTCB : ( TCB_t * ) ( pxHandle ) )
+#define prvGetTCBFromHandle( pxHandle ) ( ( ( pxHandle ) == NULL ) ? pxCurrentTCB : ( pxHandle ) )
/* The item value of the event list item is normally used to hold the priority
of the task to which it belongs (coded to allow it to be held in reverse
@@ -266,7 +249,7 @@ to its original value when it is released. */
* and stores task state information, including a pointer to the task's context
* (the task's run time environment, including register values)
*/
-typedef struct tskTaskControlBlock
+typedef struct tskTaskControlBlock /* The old naming convention is used to prevent breaking kernel aware debuggers. */
{
volatile StackType_t *pxTopOfStack; /*< Points to the location of the last item placed on the tasks stack. THIS MUST BE THE FIRST MEMBER OF THE TCB STRUCT. */
@@ -317,7 +300,10 @@ typedef struct tskTaskControlBlock
responsible for resulting newlib operation. User must be familiar with
newlib and must provide system-wide implementations of the necessary
stubs. Be warned that (at the time of writing) the current newlib design
- implements a system-wide malloc() that must be provided with locks. */
+ implements a system-wide malloc() that must be provided with locks.
+
+ See the third party link http://www.nadler.com/embedded/newlibAndFreeRTOS.html
+ for additional information. */
struct _reent xNewLib_reent;
#endif
@@ -326,9 +312,9 @@ typedef struct tskTaskControlBlock
volatile uint8_t ucNotifyState;
#endif
- /* See the comments above the definition of
+ /* See the comments in FreeRTOS.h with the definition of
tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE. */
- #if( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) /*lint !e731 Macro has been consolidated for readability reasons. */
+ #if( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) /*lint !e731 !e9029 Macro has been consolidated for readability reasons. */
uint8_t ucStaticallyAllocated; /*< Set to pdTRUE if the task is a statically allocated to ensure no attempt is made to free the memory. */
#endif
@@ -336,6 +322,10 @@ typedef struct tskTaskControlBlock
uint8_t ucDelayAborted;
#endif
+ #if( configUSE_POSIX_ERRNO == 1 )
+ int iTaskErrno;
+ #endif
+
} tskTCB;
/* The old tskTCB name is maintained above then typedefed to the new TCB_t name
@@ -344,36 +334,44 @@ typedef tskTCB TCB_t;
/*lint -save -e956 A manual analysis and inspection has been used to determine
which static variables must be declared volatile. */
-
PRIVILEGED_DATA TCB_t * volatile pxCurrentTCB = NULL;
-/* Lists for ready and blocked tasks. --------------------*/
-PRIVILEGED_DATA static List_t pxReadyTasksLists[ configMAX_PRIORITIES ] = {0}; /*< Prioritised ready tasks. */
-PRIVILEGED_DATA static List_t xDelayedTaskList1 = {0}; /*< Delayed tasks. */
-PRIVILEGED_DATA static List_t xDelayedTaskList2 = {0}; /*< Delayed tasks (two lists are used - one for delays that have overflowed the current tick count. */
-PRIVILEGED_DATA static List_t * volatile pxDelayedTaskList = NULL; /*< Points to the delayed task list currently being used. */
-PRIVILEGED_DATA static List_t * volatile pxOverflowDelayedTaskList = NULL; /*< Points to the delayed task list currently being used to hold tasks that have overflowed the current tick count. */
-PRIVILEGED_DATA static List_t xPendingReadyList = {0}; /*< Tasks that have been readied while the scheduler was suspended. They will be moved to the ready list when the scheduler is resumed. */
+/* Lists for ready and blocked tasks. --------------------
+xDelayedTaskList1 and xDelayedTaskList2 could be move to function scople but
+doing so breaks some kernel aware debuggers and debuggers that rely on removing
+the static qualifier. */
+PRIVILEGED_DATA static List_t pxReadyTasksLists[ configMAX_PRIORITIES ];/*< Prioritised ready tasks. */
+PRIVILEGED_DATA static List_t xDelayedTaskList1; /*< Delayed tasks. */
+PRIVILEGED_DATA static List_t xDelayedTaskList2; /*< Delayed tasks (two lists are used - one for delays that have overflowed the current tick count. */
+PRIVILEGED_DATA static List_t * volatile pxDelayedTaskList; /*< Points to the delayed task list currently being used. */
+PRIVILEGED_DATA static List_t * volatile pxOverflowDelayedTaskList; /*< Points to the delayed task list currently being used to hold tasks that have overflowed the current tick count. */
+PRIVILEGED_DATA static List_t xPendingReadyList; /*< Tasks that have been readied while the scheduler was suspended. They will be moved to the ready list when the scheduler is resumed. */
#if( INCLUDE_vTaskDelete == 1 )
- PRIVILEGED_DATA static List_t xTasksWaitingTermination = {0}; /*< Tasks that have been deleted - but their memory not yet freed. */
+ PRIVILEGED_DATA static List_t xTasksWaitingTermination; /*< Tasks that have been deleted - but their memory not yet freed. */
PRIVILEGED_DATA static volatile UBaseType_t uxDeletedTasksWaitingCleanUp = ( UBaseType_t ) 0U;
#endif
#if ( INCLUDE_vTaskSuspend == 1 )
- PRIVILEGED_DATA static List_t xSuspendedTaskList = {0}; /*< Tasks that are currently suspended. */
+ PRIVILEGED_DATA static List_t xSuspendedTaskList; /*< Tasks that are currently suspended. */
#endif
+/* Global POSIX errno. Its value is changed upon context switching to match
+the errno of the currently running task. */
+#if ( configUSE_POSIX_ERRNO == 1 )
+ int FreeRTOS_errno = 0;
+#endif
+
/* Other file private variables. --------------------------------*/
PRIVILEGED_DATA static volatile UBaseType_t uxCurrentNumberOfTasks = ( UBaseType_t ) 0U;
PRIVILEGED_DATA static volatile TickType_t xTickCount = ( TickType_t ) configINITIAL_TICK_COUNT;
PRIVILEGED_DATA static volatile UBaseType_t uxTopReadyPriority = tskIDLE_PRIORITY;
PRIVILEGED_DATA static volatile BaseType_t xSchedulerRunning = pdFALSE;
-PRIVILEGED_DATA static volatile UBaseType_t uxPendedTicks = ( UBaseType_t ) 0U;
+PRIVILEGED_DATA static volatile TickType_t xPendedTicks = ( TickType_t ) 0U;
PRIVILEGED_DATA static volatile BaseType_t xYieldPending = pdFALSE;
PRIVILEGED_DATA static volatile BaseType_t xNumOfOverflows = ( BaseType_t ) 0;
PRIVILEGED_DATA static UBaseType_t uxTaskNumber = ( UBaseType_t ) 0U;
@@ -392,6 +390,8 @@ PRIVILEGED_DATA static volatile UBaseType_t uxSchedulerSuspended = ( UBaseType_t
#if ( configGENERATE_RUN_TIME_STATS == 1 )
+ /* Do not move these variables to function scope as doing so prevents the
+ code working with debuggers that need to remove the static qualifier. */
PRIVILEGED_DATA static uint32_t ulTaskSwitchedInTime = 0UL; /*< Holds the value of a timer/counter the last time a task was switched in. */
PRIVILEGED_DATA static uint32_t ulTotalRunTime = 0UL; /*< Holds the total amount of execution time as defined by the run time counter clock. */
@@ -403,15 +403,21 @@ PRIVILEGED_DATA static volatile UBaseType_t uxSchedulerSuspended = ( UBaseType_t
/* Callback function prototypes. --------------------------*/
#if( configCHECK_FOR_STACK_OVERFLOW > 0 )
+
extern void vApplicationStackOverflowHook( TaskHandle_t xTask, char *pcTaskName );
+
#endif
#if( configUSE_TICK_HOOK > 0 )
- extern void vApplicationTickHook( void );
+
+ extern void vApplicationTickHook( void ); /*lint !e526 Symbol not defined as it is an application callback. */
+
#endif
#if( configSUPPORT_STATIC_ALLOCATION == 1 )
- extern void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize );
+
+ extern void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize ); /*lint !e526 Symbol not defined as it is an application callback. */
+
#endif
/* File private functions. --------------------------------*/
@@ -501,9 +507,9 @@ static void prvAddCurrentTaskToDelayedList( TickType_t xTicksToWait, const BaseT
* This function determines the 'high water mark' of the task stack by
* determining how much of the stack remains at the original preset value.
*/
-#if ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) )
+#if ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark2 == 1 ) )
- static uint16_t prvTaskCheckFreeStackSpace( const uint8_t * pucStackByte ) PRIVILEGED_FUNCTION;
+ static configSTACK_DEPTH_TYPE prvTaskCheckFreeStackSpace( const uint8_t * pucStackByte ) PRIVILEGED_FUNCTION;
#endif
@@ -593,6 +599,7 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB ) PRIVILEGED_FUNCTION;
structure. */
volatile size_t xSize = sizeof( StaticTask_t );
configASSERT( xSize == sizeof( TCB_t ) );
+ ( void ) xSize; /* Prevent lint warning when configASSERT() is not used. */
}
#endif /* configASSERT_DEFINED */
@@ -601,16 +608,16 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB ) PRIVILEGED_FUNCTION;
{
/* The memory used for the task's TCB and stack are passed into this
function - use them. */
- pxNewTCB = ( TCB_t * ) pxTaskBuffer; /*lint !e740 Unusual cast is ok as the structures are designed to have the same alignment, and the size is checked by an assert. */
+ pxNewTCB = ( TCB_t * ) pxTaskBuffer; /*lint !e740 !e9087 Unusual cast is ok as the structures are designed to have the same alignment, and the size is checked by an assert. */
pxNewTCB->pxStack = ( StackType_t * ) puxStackBuffer;
- #if( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) /*lint !e731 Macro has been consolidated for readability reasons. */
+ #if( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) /*lint !e731 !e9029 Macro has been consolidated for readability reasons. */
{
/* Tasks can be created statically or dynamically, so note this
task was created statically in case the task is later deleted. */
pxNewTCB->ucStaticallyAllocated = tskSTATICALLY_ALLOCATED_STACK_AND_TCB;
}
- #endif /* configSUPPORT_DYNAMIC_ALLOCATION */
+ #endif /* tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE */
prvInitialiseNewTask( pxTaskCode, pcName, ulStackDepth, pvParameters, uxPriority, &xReturn, pxNewTCB, NULL );
prvAddNewTaskToReadyList( pxNewTCB );
@@ -652,7 +659,7 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB ) PRIVILEGED_FUNCTION;
task was created statically in case the task is later deleted. */
pxNewTCB->ucStaticallyAllocated = tskSTATICALLY_ALLOCATED_STACK_AND_TCB;
}
- #endif /* configSUPPORT_DYNAMIC_ALLOCATION */
+ #endif /* tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE */
prvInitialiseNewTask( pxTaskDefinition->pvTaskCode,
pxTaskDefinition->pcName,
@@ -693,14 +700,14 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB ) PRIVILEGED_FUNCTION;
/* Store the stack location in the TCB. */
pxNewTCB->pxStack = pxTaskDefinition->puxStackBuffer;
- #if( configSUPPORT_STATIC_ALLOCATION == 1 )
+ #if( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 )
{
/* Tasks can be created statically or dynamically, so note
this task had a statically allocated stack in case it is
later deleted. The TCB was allocated dynamically. */
pxNewTCB->ucStaticallyAllocated = tskSTATICALLY_ALLOCATED_STACK_ONLY;
}
- #endif
+ #endif /* tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE */
prvInitialiseNewTask( pxTaskDefinition->pvTaskCode,
pxTaskDefinition->pcName,
@@ -763,12 +770,12 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB ) PRIVILEGED_FUNCTION;
StackType_t *pxStack;
/* Allocate space for the stack used by the task being created. */
- pxStack = ( StackType_t * ) pvPortMalloc( ( ( ( size_t ) usStackDepth ) * sizeof( StackType_t ) ) ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */
+ pxStack = pvPortMalloc( ( ( ( size_t ) usStackDepth ) * sizeof( StackType_t ) ) ); /*lint !e9079 All values returned by pvPortMalloc() have at least the alignment required by the MCU's stack and this allocation is the stack. */
if( pxStack != NULL )
{
/* Allocate space for the TCB. */
- pxNewTCB = ( TCB_t * ) pvPortMalloc( sizeof( TCB_t ) ); /*lint !e961 MISRA exception as the casts are only redundant for some paths. */
+ pxNewTCB = ( TCB_t * ) pvPortMalloc( sizeof( TCB_t ) ); /*lint !e9087 !e9079 All values returned by pvPortMalloc() have at least the alignment required by the MCU's stack, and the first member of TCB_t is always a pointer to the task's stack. */
if( pxNewTCB != NULL )
{
@@ -791,13 +798,13 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB ) PRIVILEGED_FUNCTION;
if( pxNewTCB != NULL )
{
- #if( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) /*lint !e731 Macro has been consolidated for readability reasons. */
+ #if( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) /*lint !e9029 !e731 Macro has been consolidated for readability reasons. */
{
/* Tasks can be created statically or dynamically, so note this
task was created dynamically in case it is later deleted. */
pxNewTCB->ucStaticallyAllocated = tskDYNAMICALLY_ALLOCATED_STACK_AND_TCB;
}
- #endif /* configSUPPORT_STATIC_ALLOCATION */
+ #endif /* tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE */
prvInitialiseNewTask( pxTaskCode, pcName, ( uint32_t ) usStackDepth, pvParameters, uxPriority, pxCreatedTask, pxNewTCB, NULL );
prvAddNewTaskToReadyList( pxNewTCB );
@@ -854,8 +861,8 @@ UBaseType_t x;
by the port. */
#if( portSTACK_GROWTH < 0 )
{
- pxTopOfStack = pxNewTCB->pxStack + ( ulStackDepth - ( uint32_t ) 1 );
- pxTopOfStack = ( StackType_t * ) ( ( ( portPOINTER_SIZE_TYPE ) pxTopOfStack ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) ); /*lint !e923 MISRA exception. Avoiding casts between pointers and integers is not practical. Size differences accounted for using portPOINTER_SIZE_TYPE type. */
+ pxTopOfStack = &( pxNewTCB->pxStack[ ulStackDepth - ( uint32_t ) 1 ] );
+ pxTopOfStack = ( StackType_t * ) ( ( ( portPOINTER_SIZE_TYPE ) pxTopOfStack ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) ); /*lint !e923 !e9033 !e9078 MISRA exception. Avoiding casts between pointers and integers is not practical. Size differences accounted for using portPOINTER_SIZE_TYPE type. Checked by assert(). */
/* Check the alignment of the calculated top of stack is correct. */
configASSERT( ( ( ( portPOINTER_SIZE_TYPE ) pxTopOfStack & ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) == 0UL ) );
@@ -882,26 +889,35 @@ UBaseType_t x;
#endif /* portSTACK_GROWTH */
/* Store the task name in the TCB. */
- for( x = ( UBaseType_t ) 0; x < ( UBaseType_t ) configMAX_TASK_NAME_LEN; x++ )
+ if( pcName != NULL )
{
- pxNewTCB->pcTaskName[ x ] = pcName[ x ];
+ for( x = ( UBaseType_t ) 0; x < ( UBaseType_t ) configMAX_TASK_NAME_LEN; x++ )
+ {
+ pxNewTCB->pcTaskName[ x ] = pcName[ x ];
- /* Don't copy all configMAX_TASK_NAME_LEN if the string is shorter than
- configMAX_TASK_NAME_LEN characters just in case the memory after the
- string is not accessible (extremely unlikely). */
- if( pcName[ x ] == 0x00 )
- {
- break;
- }
- else
- {
- mtCOVERAGE_TEST_MARKER();
+ /* Don't copy all configMAX_TASK_NAME_LEN if the string is shorter than
+ configMAX_TASK_NAME_LEN characters just in case the memory after the
+ string is not accessible (extremely unlikely). */
+ if( pcName[ x ] == ( char ) 0x00 )
+ {
+ break;
+ }
+ else
+ {
+ mtCOVERAGE_TEST_MARKER();
+ }
}
+
+ /* Ensure the name string is terminated in the case that the string length
+ was greater or equal to configMAX_TASK_NAME_LEN. */
+ pxNewTCB->pcTaskName[ configMAX_TASK_NAME_LEN - 1 ] = '\0';
+ }
+ else
+ {
+ /* The task has not been given a name, so just ensure there is a NULL
+ terminator when it is read out. */
+ pxNewTCB->pcTaskName[ 0 ] = 0x00;
}
-
- /* Ensure the name string is terminated in the case that the string length
- was greater or equal to configMAX_TASK_NAME_LEN. */
- pxNewTCB->pcTaskName[ configMAX_TASK_NAME_LEN - 1 ] = '\0';
/* This is used as an array index so must ensure it's not too large. First
remove the privilege bit if one is present. */
@@ -980,7 +996,9 @@ UBaseType_t x;
#if ( configUSE_NEWLIB_REENTRANT == 1 )
{
- /* Initialise this task's Newlib reent structure. */
+ /* Initialise this task's Newlib reent structure.
+ See the third party link http://www.nadler.com/embedded/newlibAndFreeRTOS.html
+ for additional information. */
_REENT_INIT_PTR( ( &( pxNewTCB->xNewLib_reent ) ) );
}
#endif
@@ -997,15 +1015,53 @@ UBaseType_t x;
the top of stack variable is updated. */
#if( portUSING_MPU_WRAPPERS == 1 )
{
- pxNewTCB->pxTopOfStack = pxPortInitialiseStack( pxTopOfStack, pxTaskCode, pvParameters, xRunPrivileged );
+ /* If the port has capability to detect stack overflow,
+ pass the stack end address to the stack initialization
+ function as well. */
+ #if( portHAS_STACK_OVERFLOW_CHECKING == 1 )
+ {
+ #if( portSTACK_GROWTH < 0 )
+ {
+ pxNewTCB->pxTopOfStack = pxPortInitialiseStack( pxTopOfStack, pxNewTCB->pxStack, pxTaskCode, pvParameters, xRunPrivileged );
+ }
+ #else /* portSTACK_GROWTH */
+ {
+ pxNewTCB->pxTopOfStack = pxPortInitialiseStack( pxTopOfStack, pxNewTCB->pxEndOfStack, pxTaskCode, pvParameters, xRunPrivileged );
+ }
+ #endif /* portSTACK_GROWTH */
+ }
+ #else /* portHAS_STACK_OVERFLOW_CHECKING */
+ {
+ pxNewTCB->pxTopOfStack = pxPortInitialiseStack( pxTopOfStack, pxTaskCode, pvParameters, xRunPrivileged );
+ }
+ #endif /* portHAS_STACK_OVERFLOW_CHECKING */
}
#else /* portUSING_MPU_WRAPPERS */
{
- pxNewTCB->pxTopOfStack = pxPortInitialiseStack( pxTopOfStack, pxTaskCode, pvParameters );
+ /* If the port has capability to detect stack overflow,
+ pass the stack end address to the stack initialization
+ function as well. */
+ #if( portHAS_STACK_OVERFLOW_CHECKING == 1 )
+ {
+ #if( portSTACK_GROWTH < 0 )
+ {
+ pxNewTCB->pxTopOfStack = pxPortInitialiseStack( pxTopOfStack, pxNewTCB->pxStack, pxTaskCode, pvParameters );
+ }
+ #else /* portSTACK_GROWTH */
+ {
+ pxNewTCB->pxTopOfStack = pxPortInitialiseStack( pxTopOfStack, pxNewTCB->pxEndOfStack, pxTaskCode, pvParameters );
+ }
+ #endif /* portSTACK_GROWTH */
+ }
+ #else /* portHAS_STACK_OVERFLOW_CHECKING */
+ {
+ pxNewTCB->pxTopOfStack = pxPortInitialiseStack( pxTopOfStack, pxTaskCode, pvParameters );
+ }
+ #endif /* portHAS_STACK_OVERFLOW_CHECKING */
}
#endif /* portUSING_MPU_WRAPPERS */
- if( ( void * ) pxCreatedTask != NULL )
+ if( pxCreatedTask != NULL )
{
/* Pass the handle out in an anonymous way. The handle can be used to
change the created task's priority, delete the created task, etc.*/
@@ -1113,7 +1169,7 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB )
being deleted. */
pxTCB = prvGetTCBFromHandle( xTaskToDelete );
- /* Remove task from the ready list. */
+ /* Remove task from the ready/delayed list. */
if( uxListRemove( &( pxTCB->xStateListItem ) ) == ( UBaseType_t ) 0 )
{
taskRESET_READY_PRIORITY( pxTCB->uxPriority );
@@ -1153,6 +1209,10 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB )
check the xTasksWaitingTermination list. */
++uxDeletedTasksWaitingCleanUp;
+ /* Call the delete hook before portPRE_TASK_DELETE_HOOK() as
+ portPRE_TASK_DELETE_HOOK() does not return in the Win32 port. */
+ traceTASK_DELETE( pxTCB );
+
/* The pre-delete hook is primarily for the Windows simulator,
in which Windows specific clean up operations are performed,
after which it is not possible to yield away from this task -
@@ -1163,14 +1223,13 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB )
else
{
--uxCurrentNumberOfTasks;
+ traceTASK_DELETE( pxTCB );
prvDeleteTCB( pxTCB );
/* Reset the next expected unblock time in case it referred to
the task that has just been deleted. */
prvResetNextTaskUnblockTime();
}
-
- traceTASK_DELETE( pxTCB );
}
taskEXIT_CRITICAL();
@@ -1322,13 +1381,13 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB )
#endif /* INCLUDE_vTaskDelay */
/*-----------------------------------------------------------*/
-#if( ( INCLUDE_eTaskGetState == 1 ) || ( configUSE_TRACE_FACILITY == 1 ) )
+#if( ( INCLUDE_eTaskGetState == 1 ) || ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_xTaskAbortDelay == 1 ) )
eTaskState eTaskGetState( TaskHandle_t xTask )
{
eTaskState eReturn;
- List_t *pxStateList;
- const TCB_t * const pxTCB = ( TCB_t * ) xTask;
+ List_t const * pxStateList, *pxDelayedList, *pxOverflowedDelayedList;
+ const TCB_t * const pxTCB = xTask;
configASSERT( pxTCB );
@@ -1341,11 +1400,13 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB )
{
taskENTER_CRITICAL();
{
- pxStateList = ( List_t * ) listLIST_ITEM_CONTAINER( &( pxTCB->xStateListItem ) );
+ pxStateList = listLIST_ITEM_CONTAINER( &( pxTCB->xStateListItem ) );
+ pxDelayedList = pxDelayedTaskList;
+ pxOverflowedDelayedList = pxOverflowDelayedTaskList;
}
taskEXIT_CRITICAL();
- if( ( pxStateList == pxDelayedTaskList ) || ( pxStateList == pxOverflowDelayedTaskList ) )
+ if( ( pxStateList == pxDelayedList ) || ( pxStateList == pxOverflowedDelayedList ) )
{
/* The task being queried is referenced from one of the Blocked
lists. */
@@ -1356,11 +1417,30 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB )
else if( pxStateList == &xSuspendedTaskList )
{
/* The task being queried is referenced from the suspended
- list. Is it genuinely suspended or is it block
+ list. Is it genuinely suspended or is it blocked
indefinitely? */
if( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) == NULL )
{
- eReturn = eSuspended;
+ #if( configUSE_TASK_NOTIFICATIONS == 1 )
+ {
+ /* The task does not appear on the event list item of
+ and of the RTOS objects, but could still be in the
+ blocked state if it is waiting on its notification
+ rather than waiting on an object. */
+ if( pxTCB->ucNotifyState == taskWAITING_NOTIFICATION )
+ {
+ eReturn = eBlocked;
+ }
+ else
+ {
+ eReturn = eSuspended;
+ }
+ }
+ #else
+ {
+ eReturn = eSuspended;
+ }
+ #endif
}
else
{
@@ -1395,15 +1475,15 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB )
#if ( INCLUDE_uxTaskPriorityGet == 1 )
- UBaseType_t uxTaskPriorityGet( TaskHandle_t xTask )
+ UBaseType_t uxTaskPriorityGet( const TaskHandle_t xTask )
{
- TCB_t *pxTCB;
+ TCB_t const *pxTCB;
UBaseType_t uxReturn;
taskENTER_CRITICAL();
{
- /* If null is passed in here then it is the priority of the that
- called uxTaskPriorityGet() that is being queried. */
+ /* If null is passed in here then it is the priority of the task
+ that called uxTaskPriorityGet() that is being queried. */
pxTCB = prvGetTCBFromHandle( xTask );
uxReturn = pxTCB->uxPriority;
}
@@ -1417,9 +1497,9 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB )
#if ( INCLUDE_uxTaskPriorityGet == 1 )
- UBaseType_t uxTaskPriorityGetFromISR( TaskHandle_t xTask )
+ UBaseType_t uxTaskPriorityGetFromISR( const TaskHandle_t xTask )
{
- TCB_t *pxTCB;
+ TCB_t const *pxTCB;
UBaseType_t uxReturn, uxSavedInterruptState;
/* RTOS ports that support interrupt nesting have the concept of a
@@ -1437,7 +1517,7 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB )
separate interrupt safe API to ensure interrupt entry is as fast and as
simple as possible. More information (albeit Cortex-M specific) is
provided on the following link:
- http://www.freertos.org/RTOS-Cortex-M3-M4.html */
+ https://www.freertos.org/RTOS-Cortex-M3-M4.html */
portASSERT_IF_INTERRUPT_PRIORITY_INVALID();
uxSavedInterruptState = portSET_INTERRUPT_MASK_FROM_ISR();
@@ -1697,7 +1777,7 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB )
/* The scheduler is not running, but the task that was pointed
to by pxCurrentTCB has just been suspended and pxCurrentTCB
must be adjusted to point to a different task. */
- if( listCURRENT_LIST_LENGTH( &xSuspendedTaskList ) == uxCurrentNumberOfTasks )
+ if( listCURRENT_LIST_LENGTH( &xSuspendedTaskList ) == uxCurrentNumberOfTasks ) /*lint !e931 Right has no side effect, just volatile. */
{
/* No other tasks are ready, so set pxCurrentTCB back to
NULL so when the next task is created pxCurrentTCB will
@@ -1725,7 +1805,7 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB )
static BaseType_t prvTaskIsTaskSuspended( const TaskHandle_t xTask )
{
BaseType_t xReturn = pdFALSE;
- const TCB_t * const pxTCB = ( TCB_t * ) xTask;
+ const TCB_t * const pxTCB = xTask;
/* Accesses xPendingReadyList so must be called from a critical
section. */
@@ -1770,14 +1850,14 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB )
void vTaskResume( TaskHandle_t xTaskToResume )
{
- TCB_t * const pxTCB = ( TCB_t * ) xTaskToResume;
+ TCB_t * const pxTCB = xTaskToResume;
/* It does not make sense to resume the calling task. */
configASSERT( xTaskToResume );
/* The parameter cannot be NULL as it is impossible to resume the
currently executing task. */
- if( ( pxTCB != NULL ) && ( pxTCB != pxCurrentTCB ) )
+ if( ( pxTCB != pxCurrentTCB ) && ( pxTCB != NULL ) )
{
taskENTER_CRITICAL();
{
@@ -1825,7 +1905,7 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB )
BaseType_t xTaskResumeFromISR( TaskHandle_t xTaskToResume )
{
BaseType_t xYieldRequired = pdFALSE;
- TCB_t * const pxTCB = ( TCB_t * ) xTaskToResume;
+ TCB_t * const pxTCB = xTaskToResume;
UBaseType_t uxSavedInterruptStatus;
configASSERT( xTaskToResume );
@@ -1845,7 +1925,7 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB )
separate interrupt safe API to ensure interrupt entry is as fast and as
simple as possible. More information (albeit Cortex-M specific) is
provided on the following link:
- http://www.freertos.org/RTOS-Cortex-M3-M4.html */
+ https://www.freertos.org/RTOS-Cortex-M3-M4.html */
portASSERT_IF_INTERRUPT_PRIORITY_INVALID();
uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();
@@ -1910,7 +1990,7 @@ BaseType_t xReturn;
configIDLE_TASK_NAME,
ulIdleTaskStackSize,
( void * ) NULL, /*lint !e961. The cast is not redundant for all compilers. */
- ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ),
+ portPRIVILEGE_BIT, /* In effect ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ), but tskIDLE_PRIORITY is zero. */
pxIdleTaskStackBuffer,
pxIdleTaskTCBBuffer ); /*lint !e961 MISRA exception, justified as it is not a redundant explicit cast to all supported compilers. */
@@ -1930,7 +2010,7 @@ BaseType_t xReturn;
configIDLE_TASK_NAME,
configMINIMAL_STACK_SIZE,
( void * ) NULL,
- ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ),
+ portPRIVILEGE_BIT, /* In effect ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ), but tskIDLE_PRIORITY is zero. */
&xIdleTaskHandle ); /*lint !e961 MISRA exception, justified as it is not a redundant explicit cast to all supported compilers. */
}
#endif /* configSUPPORT_STATIC_ALLOCATION */
@@ -1969,14 +2049,16 @@ BaseType_t xReturn;
#if ( configUSE_NEWLIB_REENTRANT == 1 )
{
/* Switch Newlib's _impure_ptr variable to point to the _reent
- structure specific to the task that will run first. */
+ structure specific to the task that will run first.
+ See the third party link http://www.nadler.com/embedded/newlibAndFreeRTOS.html
+ for additional information. */
_impure_ptr = &( pxCurrentTCB->xNewLib_reent );
}
#endif /* configUSE_NEWLIB_REENTRANT */
xNextTaskUnblockTime = portMAX_DELAY;
xSchedulerRunning = pdTRUE;
- xTickCount = ( TickType_t ) 0U;
+ xTickCount = ( TickType_t ) configINITIAL_TICK_COUNT;
/* If configGENERATE_RUN_TIME_STATS is defined then the following
macro must be defined to configure the timer/counter used to generate
@@ -1986,6 +2068,8 @@ BaseType_t xReturn;
FreeRTOSConfig.h file. */
portCONFIGURE_TIMER_FOR_RUN_TIME_STATS();
+ traceTASK_SWITCHED_IN();
+
/* Setting up the timer tick is hardware specific and thus in the
portable interface. */
if( xPortStartScheduler() != pdFALSE )
@@ -2029,7 +2113,18 @@ void vTaskSuspendAll( void )
BaseType_t. Please read Richard Barry's reply in the following link to a
post in the FreeRTOS support forum before reporting this as a bug! -
http://goo.gl/wu4acr */
+
+ /* portSOFRWARE_BARRIER() is only implemented for emulated/simulated ports that
+ do not otherwise exhibit real time behaviour. */
+ portSOFTWARE_BARRIER();
+
+ /* The scheduler is suspended if uxSchedulerSuspended is non-zero. An increment
+ is used to allow calls to vTaskSuspendAll() to nest. */
++uxSchedulerSuspended;
+
+ /* Enforces ordering for ports and optimised compilers that may otherwise place
+ the above increment elsewhere. */
+ portMEMORY_BARRIER();
}
/*----------------------------------------------------------*/
@@ -2122,7 +2217,7 @@ BaseType_t xAlreadyYielded = pdFALSE;
appropriate ready list. */
while( listLIST_IS_EMPTY( &xPendingReadyList ) == pdFALSE )
{
- pxTCB = ( TCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( ( &xPendingReadyList ) );
+ pxTCB = listGET_OWNER_OF_HEAD_ENTRY( ( &xPendingReadyList ) ); /*lint !e9079 void * is used as this macro is used with timers and co-routines too. Alignment is known to be fine as the type of the pointer stored and retrieved is the same. */
( void ) uxListRemove( &( pxTCB->xEventListItem ) );
( void ) uxListRemove( &( pxTCB->xStateListItem ) );
prvAddTaskToReadyList( pxTCB );
@@ -2155,9 +2250,9 @@ BaseType_t xAlreadyYielded = pdFALSE;
not slip, and that any delayed tasks are resumed at the correct
time. */
{
- UBaseType_t uxPendedCounts = uxPendedTicks; /* Non-volatile copy. */
+ TickType_t xPendedCounts = xPendedTicks; /* Non-volatile copy. */
- if( uxPendedCounts > ( UBaseType_t ) 0U )
+ if( xPendedCounts > ( TickType_t ) 0U )
{
do
{
@@ -2169,10 +2264,10 @@ BaseType_t xAlreadyYielded = pdFALSE;
{
mtCOVERAGE_TEST_MARKER();
}
- --uxPendedCounts;
- } while( uxPendedCounts > ( UBaseType_t ) 0U );
+ --xPendedCounts;
+ } while( xPendedCounts > ( TickType_t ) 0U );
- uxPendedTicks = 0;
+ xPendedTicks = 0;
}
else
{
@@ -2239,7 +2334,7 @@ UBaseType_t uxSavedInterruptStatus;
system call interrupt priority. FreeRTOS maintains a separate interrupt
safe API to ensure interrupt entry is as fast and as simple as possible.
More information (albeit Cortex-M specific) is provided on the following
- link: http://www.freertos.org/RTOS-Cortex-M3-M4.html */
+ link: https://www.freertos.org/RTOS-Cortex-M3-M4.html */
portASSERT_IF_INTERRUPT_PRIORITY_INVALID();
uxSavedInterruptStatus = portTICK_TYPE_SET_INTERRUPT_MASK_FROM_ISR();
@@ -2279,19 +2374,21 @@ TCB_t *pxTCB;
TCB_t *pxNextTCB, *pxFirstTCB, *pxReturn = NULL;
UBaseType_t x;
char cNextChar;
+ BaseType_t xBreakLoop;
/* This function is called with the scheduler suspended. */
if( listCURRENT_LIST_LENGTH( pxList ) > ( UBaseType_t ) 0 )
{
- listGET_OWNER_OF_NEXT_ENTRY( pxFirstTCB, pxList );
+ listGET_OWNER_OF_NEXT_ENTRY( pxFirstTCB, pxList ); /*lint !e9079 void * is used as this macro is used with timers and co-routines too. Alignment is known to be fine as the type of the pointer stored and retrieved is the same. */
do
{
- listGET_OWNER_OF_NEXT_ENTRY( pxNextTCB, pxList );
+ listGET_OWNER_OF_NEXT_ENTRY( pxNextTCB, pxList ); /*lint !e9079 void * is used as this macro is used with timers and co-routines too. Alignment is known to be fine as the type of the pointer stored and retrieved is the same. */
/* Check each character in the name looking for a match or
mismatch. */
+ xBreakLoop = pdFALSE;
for( x = ( UBaseType_t ) 0; x < ( UBaseType_t ) configMAX_TASK_NAME_LEN; x++ )
{
cNextChar = pxNextTCB->pcTaskName[ x ];
@@ -2299,19 +2396,24 @@ TCB_t *pxTCB;
if( cNextChar != pcNameToQuery[ x ] )
{
/* Characters didn't match. */
- break;
+ xBreakLoop = pdTRUE;
}
- else if( cNextChar == 0x00 )
+ else if( cNextChar == ( char ) 0x00 )
{
/* Both strings terminated, a match must have been
found. */
pxReturn = pxNextTCB;
- break;
+ xBreakLoop = pdTRUE;
}
else
{
mtCOVERAGE_TEST_MARKER();
}
+
+ if( xBreakLoop != pdFALSE )
+ {
+ break;
+ }
}
if( pxReturn != NULL )
@@ -2392,7 +2494,7 @@ TCB_t *pxTCB;
}
( void ) xTaskResumeAll();
- return ( TaskHandle_t ) pxTCB;
+ return pxTCB;
}
#endif /* INCLUDE_xTaskGetHandle */
@@ -2504,11 +2606,29 @@ implementations require configUSE_TICKLESS_IDLE to be set to a value other than
#endif /* configUSE_TICKLESS_IDLE */
/*----------------------------------------------------------*/
+BaseType_t xTaskCatchUpTicks( TickType_t xTicksToCatchUp )
+{
+BaseType_t xYieldRequired = pdFALSE;
+
+ /* Must not be called with the scheduler suspended as the implementation
+ relies on xPendedTicks being wound down to 0 in xTaskResumeAll(). */
+ configASSERT( uxSchedulerSuspended == 0 );
+
+ /* Use xPendedTicks to mimic xTicksToCatchUp number of ticks occurring when
+ the scheduler is suspended so the ticks are executed in xTaskResumeAll(). */
+ vTaskSuspendAll();
+ xPendedTicks += xTicksToCatchUp;
+ xYieldRequired = xTaskResumeAll();
+
+ return xYieldRequired;
+}
+/*----------------------------------------------------------*/
+
#if ( INCLUDE_xTaskAbortDelay == 1 )
BaseType_t xTaskAbortDelay( TaskHandle_t xTask )
{
- TCB_t *pxTCB = ( TCB_t * ) xTask;
+ TCB_t *pxTCB = xTask;
BaseType_t xReturn;
configASSERT( pxTCB );
@@ -2535,6 +2655,10 @@ implementations require configUSE_TICKLESS_IDLE to be set to a value other than
if( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) != NULL )
{
( void ) uxListRemove( &( pxTCB->xEventListItem ) );
+
+ /* This lets the task know it was forcibly removed from the
+ blocked state so it should not re-evaluate its block time and
+ then block again. */
pxTCB->ucDelayAborted = pdTRUE;
}
else
@@ -2633,7 +2757,7 @@ BaseType_t xSwitchRequired = pdFALSE;
item at the head of the delayed list. This is the time
at which the task at the head of the delayed list must
be removed from the Blocked state. */
- pxTCB = ( TCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxDelayedTaskList );
+ pxTCB = listGET_OWNER_OF_HEAD_ENTRY( pxDelayedTaskList ); /*lint !e9079 void * is used as this macro is used with timers and co-routines too. Alignment is known to be fine as the type of the pointer stored and retrieved is the same. */
xItemValue = listGET_LIST_ITEM_VALUE( &( pxTCB->xStateListItem ) );
if( xConstTickCount < xItemValue )
@@ -2644,7 +2768,7 @@ BaseType_t xSwitchRequired = pdFALSE;
state - so record the item value in
xNextTaskUnblockTime. */
xNextTaskUnblockTime = xItemValue;
- break;
+ break; /*lint !e9011 Code structure here is deedmed easier to understand with multiple breaks. */
}
else
{
@@ -2711,7 +2835,7 @@ BaseType_t xSwitchRequired = pdFALSE;
{
/* Guard against the tick hook being called when the pended tick
count is being unwound (when the scheduler is being unlocked). */
- if( uxPendedTicks == ( UBaseType_t ) 0U )
+ if( xPendedTicks == ( TickType_t ) 0 )
{
vApplicationTickHook();
}
@@ -2721,10 +2845,23 @@ BaseType_t xSwitchRequired = pdFALSE;
}
}
#endif /* configUSE_TICK_HOOK */
+
+ #if ( configUSE_PREEMPTION == 1 )
+ {
+ if( xYieldPending != pdFALSE )
+ {
+ xSwitchRequired = pdTRUE;
+ }
+ else
+ {
+ mtCOVERAGE_TEST_MARKER();
+ }
+ }
+ #endif /* configUSE_PREEMPTION */
}
else
{
- ++uxPendedTicks;
+ ++xPendedTicks;
/* The tick hook gets called at regular intervals, even if the
scheduler is locked. */
@@ -2735,19 +2872,6 @@ BaseType_t xSwitchRequired = pdFALSE;
#endif
}
- #if ( configUSE_PREEMPTION == 1 )
- {
- if( xYieldPending != pdFALSE )
- {
- xSwitchRequired = pdTRUE;
- }
- else
- {
- mtCOVERAGE_TEST_MARKER();
- }
- }
- #endif /* configUSE_PREEMPTION */
-
return xSwitchRequired;
}
/*-----------------------------------------------------------*/
@@ -2766,13 +2890,15 @@ BaseType_t xSwitchRequired = pdFALSE;
}
else
{
- xTCB = ( TCB_t * ) xTask;
+ xTCB = xTask;
}
/* Save the hook function in the TCB. A critical section is required as
the value can be accessed from an interrupt. */
taskENTER_CRITICAL();
+ {
xTCB->pxTaskTag = pxHookFunction;
+ }
taskEXIT_CRITICAL();
}
@@ -2783,24 +2909,17 @@ BaseType_t xSwitchRequired = pdFALSE;
TaskHookFunction_t xTaskGetApplicationTaskTag( TaskHandle_t xTask )
{
- TCB_t *xTCB;
+ TCB_t *pxTCB;
TaskHookFunction_t xReturn;
- /* If xTask is NULL then we are setting our own task hook. */
- if( xTask == NULL )
- {
- xTCB = ( TCB_t * ) pxCurrentTCB;
- }
- else
- {
- xTCB = ( TCB_t * ) xTask;
- }
+ /* If xTask is NULL then set the calling task's hook. */
+ pxTCB = prvGetTCBFromHandle( xTask );
/* Save the hook function in the TCB. A critical section is required as
the value can be accessed from an interrupt. */
taskENTER_CRITICAL();
{
- xReturn = xTCB->pxTaskTag;
+ xReturn = pxTCB->pxTaskTag;
}
taskEXIT_CRITICAL();
@@ -2810,6 +2929,31 @@ BaseType_t xSwitchRequired = pdFALSE;
#endif /* configUSE_APPLICATION_TASK_TAG */
/*-----------------------------------------------------------*/
+#if ( configUSE_APPLICATION_TASK_TAG == 1 )
+
+ TaskHookFunction_t xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask )
+ {
+ TCB_t *pxTCB;
+ TaskHookFunction_t xReturn;
+ UBaseType_t uxSavedInterruptStatus;
+
+ /* If xTask is NULL then set the calling task's hook. */
+ pxTCB = prvGetTCBFromHandle( xTask );
+
+ /* Save the hook function in the TCB. A critical section is required as
+ the value can be accessed from an interrupt. */
+ uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();
+ {
+ xReturn = pxTCB->pxTaskTag;
+ }
+ portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );
+
+ return xReturn;
+ }
+
+#endif /* configUSE_APPLICATION_TASK_TAG */
+/*-----------------------------------------------------------*/
+
#if ( configUSE_APPLICATION_TASK_TAG == 1 )
BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter )
@@ -2820,11 +2964,11 @@ BaseType_t xSwitchRequired = pdFALSE;
/* If xTask is NULL then we are calling our own task hook. */
if( xTask == NULL )
{
- xTCB = ( TCB_t * ) pxCurrentTCB;
+ xTCB = pxCurrentTCB;
}
else
{
- xTCB = ( TCB_t * ) xTask;
+ xTCB = xTask;
}
if( xTCB->pxTaskTag != NULL )
@@ -2857,43 +3001,59 @@ void vTaskSwitchContext( void )
#if ( configGENERATE_RUN_TIME_STATS == 1 )
{
- #ifdef portALT_GET_RUN_TIME_COUNTER_VALUE
- portALT_GET_RUN_TIME_COUNTER_VALUE( ulTotalRunTime );
- #else
- ulTotalRunTime = portGET_RUN_TIME_COUNTER_VALUE();
- #endif
+ #ifdef portALT_GET_RUN_TIME_COUNTER_VALUE
+ portALT_GET_RUN_TIME_COUNTER_VALUE( ulTotalRunTime );
+ #else
+ ulTotalRunTime = portGET_RUN_TIME_COUNTER_VALUE();
+ #endif
- /* Add the amount of time the task has been running to the
- accumulated time so far. The time the task started running was
- stored in ulTaskSwitchedInTime. Note that there is no overflow
- protection here so count values are only valid until the timer
- overflows. The guard against negative values is to protect
- against suspect run time stat counter implementations - which
- are provided by the application, not the kernel. */
- if( ulTotalRunTime > ulTaskSwitchedInTime )
- {
- pxCurrentTCB->ulRunTimeCounter += ( ulTotalRunTime - ulTaskSwitchedInTime );
- }
- else
- {
- mtCOVERAGE_TEST_MARKER();
- }
- ulTaskSwitchedInTime = ulTotalRunTime;
+ /* Add the amount of time the task has been running to the
+ accumulated time so far. The time the task started running was
+ stored in ulTaskSwitchedInTime. Note that there is no overflow
+ protection here so count values are only valid until the timer
+ overflows. The guard against negative values is to protect
+ against suspect run time stat counter implementations - which
+ are provided by the application, not the kernel. */
+ if( ulTotalRunTime > ulTaskSwitchedInTime )
+ {
+ pxCurrentTCB->ulRunTimeCounter += ( ulTotalRunTime - ulTaskSwitchedInTime );
+ }
+ else
+ {
+ mtCOVERAGE_TEST_MARKER();
+ }
+ ulTaskSwitchedInTime = ulTotalRunTime;
}
#endif /* configGENERATE_RUN_TIME_STATS */
/* Check for stack overflow, if configured. */
taskCHECK_FOR_STACK_OVERFLOW();
+ /* Before the currently running task is switched out, save its errno. */
+ #if( configUSE_POSIX_ERRNO == 1 )
+ {
+ pxCurrentTCB->iTaskErrno = FreeRTOS_errno;
+ }
+ #endif
+
/* Select a new task to run using either the generic C or port
optimised asm code. */
- taskSELECT_HIGHEST_PRIORITY_TASK();
+ taskSELECT_HIGHEST_PRIORITY_TASK(); /*lint !e9079 void * is used as this macro is used with timers and co-routines too. Alignment is known to be fine as the type of the pointer stored and retrieved is the same. */
traceTASK_SWITCHED_IN();
+ /* After the new task is switched in, update the global errno. */
+ #if( configUSE_POSIX_ERRNO == 1 )
+ {
+ FreeRTOS_errno = pxCurrentTCB->iTaskErrno;
+ }
+ #endif
+
#if ( configUSE_NEWLIB_REENTRANT == 1 )
{
/* Switch Newlib's _impure_ptr variable to point to the _reent
- structure specific to this task. */
+ structure specific to this task.
+ See the third party link http://www.nadler.com/embedded/newlibAndFreeRTOS.html
+ for additional information. */
_impure_ptr = &( pxCurrentTCB->xNewLib_reent );
}
#endif /* configUSE_NEWLIB_REENTRANT */
@@ -2993,7 +3153,7 @@ BaseType_t xReturn;
This function assumes that a check has already been made to ensure that
pxEventList is not empty. */
- pxUnblockedTCB = ( TCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxEventList );
+ pxUnblockedTCB = listGET_OWNER_OF_HEAD_ENTRY( pxEventList ); /*lint !e9079 void * is used as this macro is used with timers and co-routines too. Alignment is known to be fine as the type of the pointer stored and retrieved is the same. */
configASSERT( pxUnblockedTCB );
( void ) uxListRemove( &( pxUnblockedTCB->xEventListItem ) );
@@ -3001,6 +3161,20 @@ BaseType_t xReturn;
{
( void ) uxListRemove( &( pxUnblockedTCB->xStateListItem ) );
prvAddTaskToReadyList( pxUnblockedTCB );
+
+ #if( configUSE_TICKLESS_IDLE != 0 )
+ {
+ /* If a task is blocked on a kernel object then xNextTaskUnblockTime
+ might be set to the blocked task's time out time. If the task is
+ unblocked for a reason other than a timeout xNextTaskUnblockTime is
+ normally left unchanged, because it is automatically reset to a new
+ value when the tick count equals xNextTaskUnblockTime. However if
+ tickless idling is used it might be more important to enter sleep mode
+ at the earliest possible time - so reset xNextTaskUnblockTime here to
+ ensure it is updated at the earliest possible time. */
+ prvResetNextTaskUnblockTime();
+ }
+ #endif
}
else
{
@@ -3025,20 +3199,6 @@ BaseType_t xReturn;
xReturn = pdFALSE;
}
- #if( configUSE_TICKLESS_IDLE != 0 )
- {
- /* If a task is blocked on a kernel object then xNextTaskUnblockTime
- might be set to the blocked task's time out time. If the task is
- unblocked for a reason other than a timeout xNextTaskUnblockTime is
- normally left unchanged, because it is automatically reset to a new
- value when the tick count equals xNextTaskUnblockTime. However if
- tickless idling is used it might be more important to enter sleep mode
- at the earliest possible time - so reset xNextTaskUnblockTime here to
- ensure it is updated at the earliest possible time. */
- prvResetNextTaskUnblockTime();
- }
- #endif
-
return xReturn;
}
/*-----------------------------------------------------------*/
@@ -3056,10 +3216,24 @@ TCB_t *pxUnblockedTCB;
/* Remove the event list form the event flag. Interrupts do not access
event flags. */
- pxUnblockedTCB = ( TCB_t * ) listGET_LIST_ITEM_OWNER( pxEventListItem );
+ pxUnblockedTCB = listGET_LIST_ITEM_OWNER( pxEventListItem ); /*lint !e9079 void * is used as this macro is used with timers and co-routines too. Alignment is known to be fine as the type of the pointer stored and retrieved is the same. */
configASSERT( pxUnblockedTCB );
( void ) uxListRemove( pxEventListItem );
+ #if( configUSE_TICKLESS_IDLE != 0 )
+ {
+ /* If a task is blocked on a kernel object then xNextTaskUnblockTime
+ might be set to the blocked task's time out time. If the task is
+ unblocked for a reason other than a timeout xNextTaskUnblockTime is
+ normally left unchanged, because it is automatically reset to a new
+ value when the tick count equals xNextTaskUnblockTime. However if
+ tickless idling is used it might be more important to enter sleep mode
+ at the earliest possible time - so reset xNextTaskUnblockTime here to
+ ensure it is updated at the earliest possible time. */
+ prvResetNextTaskUnblockTime();
+ }
+ #endif
+
/* Remove the task from the delayed list and add it to the ready list. The
scheduler is suspended so interrupts will not be accessing the ready
lists. */
@@ -3111,7 +3285,7 @@ BaseType_t xReturn;
const TickType_t xElapsedTime = xConstTickCount - pxTimeOut->xTimeOnEntering;
#if( INCLUDE_xTaskAbortDelay == 1 )
- if( pxCurrentTCB->ucDelayAborted != pdFALSE )
+ if( pxCurrentTCB->ucDelayAborted != ( uint8_t ) pdFALSE )
{
/* The delay was aborted, which is not the same as a time out,
but has the same result. */
@@ -3171,11 +3345,11 @@ void vTaskMissedYield( void )
UBaseType_t uxTaskGetTaskNumber( TaskHandle_t xTask )
{
UBaseType_t uxReturn;
- TCB_t *pxTCB;
+ TCB_t const *pxTCB;
if( xTask != NULL )
{
- pxTCB = ( TCB_t * ) xTask;
+ pxTCB = xTask;
uxReturn = pxTCB->uxTaskNumber;
}
else
@@ -3193,11 +3367,11 @@ void vTaskMissedYield( void )
void vTaskSetTaskNumber( TaskHandle_t xTask, const UBaseType_t uxHandle )
{
- TCB_t *pxTCB;
+ TCB_t * pxTCB;
if( xTask != NULL )
{
- pxTCB = ( TCB_t * ) xTask;
+ pxTCB = xTask;
pxTCB->uxTaskNumber = uxHandle;
}
}
@@ -3226,7 +3400,7 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters )
/* In case a task that has a secure context deletes itself, in which case
the idle task is responsible for deleting the task's secure context, if
any. */
- portTASK_CALLS_SECURE_FUNCTIONS();
+ portALLOCATE_SECURE_CONTEXT( configMINIMAL_SECURE_STACK_SIZE );
for( ;; )
{
@@ -3340,6 +3514,8 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters )
const UBaseType_t uxNonApplicationTasks = 1;
eSleepModeStatus eReturn = eStandardSleep;
+ /* This function must be called from a critical section. */
+
if( listCURRENT_LIST_LENGTH( &xPendingReadyList ) != 0 )
{
/* A task was made ready while the scheduler was suspended. */
@@ -3381,6 +3557,7 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters )
if( xIndex < configNUM_THREAD_LOCAL_STORAGE_POINTERS )
{
pxTCB = prvGetTCBFromHandle( xTaskToSet );
+ configASSERT( pxTCB != NULL );
pxTCB->pvThreadLocalStoragePointers[ xIndex ] = pvValue;
}
}
@@ -3468,13 +3645,13 @@ static void prvCheckTasksWaitingTermination( void )
{
TCB_t *pxTCB;
- /* uxDeletedTasksWaitingCleanUp is used to prevent vTaskSuspendAll()
+ /* uxDeletedTasksWaitingCleanUp is used to prevent taskENTER_CRITICAL()
being called too often in the idle task. */
while( uxDeletedTasksWaitingCleanUp > ( UBaseType_t ) 0U )
{
taskENTER_CRITICAL();
{
- pxTCB = ( TCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( ( &xTasksWaitingTermination ) );
+ pxTCB = listGET_OWNER_OF_HEAD_ENTRY( ( &xTasksWaitingTermination ) ); /*lint !e9079 void * is used as this macro is used with timers and co-routines too. Alignment is known to be fine as the type of the pointer stored and retrieved is the same. */
( void ) uxListRemove( &( pxTCB->xStateListItem ) );
--uxCurrentNumberOfTasks;
--uxDeletedTasksWaitingCleanUp;
@@ -3593,7 +3770,7 @@ static void prvCheckTasksWaitingTermination( void )
if( listCURRENT_LIST_LENGTH( pxList ) > ( UBaseType_t ) 0 )
{
- listGET_OWNER_OF_NEXT_ENTRY( pxFirstTCB, pxList );
+ listGET_OWNER_OF_NEXT_ENTRY( pxFirstTCB, pxList ); /*lint !e9079 void * is used as this macro is used with timers and co-routines too. Alignment is known to be fine as the type of the pointer stored and retrieved is the same. */
/* Populate an TaskStatus_t structure within the
pxTaskStatusArray array for each task that is referenced from
@@ -3601,7 +3778,7 @@ static void prvCheckTasksWaitingTermination( void )
meaning of each TaskStatus_t structure member. */
do
{
- listGET_OWNER_OF_NEXT_ENTRY( pxNextTCB, pxList );
+ listGET_OWNER_OF_NEXT_ENTRY( pxNextTCB, pxList ); /*lint !e9079 void * is used as this macro is used with timers and co-routines too. Alignment is known to be fine as the type of the pointer stored and retrieved is the same. */
vTaskGetInfo( ( TaskHandle_t ) pxNextTCB, &( pxTaskStatusArray[ uxTask ] ), pdTRUE, eState );
uxTask++;
} while( pxNextTCB != pxFirstTCB );
@@ -3617,9 +3794,9 @@ static void prvCheckTasksWaitingTermination( void )
#endif /* configUSE_TRACE_FACILITY */
/*-----------------------------------------------------------*/
-#if ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) )
+#if ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark2 == 1 ) )
- static uint16_t prvTaskCheckFreeStackSpace( const uint8_t * pucStackByte )
+ static configSTACK_DEPTH_TYPE prvTaskCheckFreeStackSpace( const uint8_t * pucStackByte )
{
uint32_t ulCount = 0U;
@@ -3631,10 +3808,50 @@ static void prvCheckTasksWaitingTermination( void )
ulCount /= ( uint32_t ) sizeof( StackType_t ); /*lint !e961 Casting is not redundant on smaller architectures. */
- return ( uint16_t ) ulCount;
+ return ( configSTACK_DEPTH_TYPE ) ulCount;
}
-#endif /* ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) ) */
+#endif /* ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark2 == 1 ) ) */
+/*-----------------------------------------------------------*/
+
+#if ( INCLUDE_uxTaskGetStackHighWaterMark2 == 1 )
+
+ /* uxTaskGetStackHighWaterMark() and uxTaskGetStackHighWaterMark2() are the
+ same except for their return type. Using configSTACK_DEPTH_TYPE allows the
+ user to determine the return type. It gets around the problem of the value
+ overflowing on 8-bit types without breaking backward compatibility for
+ applications that expect an 8-bit return type. */
+ configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark2( TaskHandle_t xTask )
+ {
+ TCB_t *pxTCB;
+ uint8_t *pucEndOfStack;
+ configSTACK_DEPTH_TYPE uxReturn;
+
+ /* uxTaskGetStackHighWaterMark() and uxTaskGetStackHighWaterMark2() are
+ the same except for their return type. Using configSTACK_DEPTH_TYPE
+ allows the user to determine the return type. It gets around the
+ problem of the value overflowing on 8-bit types without breaking
+ backward compatibility for applications that expect an 8-bit return
+ type. */
+
+ pxTCB = prvGetTCBFromHandle( xTask );
+
+ #if portSTACK_GROWTH < 0
+ {
+ pucEndOfStack = ( uint8_t * ) pxTCB->pxStack;
+ }
+ #else
+ {
+ pucEndOfStack = ( uint8_t * ) pxTCB->pxEndOfStack;
+ }
+ #endif
+
+ uxReturn = prvTaskCheckFreeStackSpace( pucEndOfStack );
+
+ return uxReturn;
+ }
+
+#endif /* INCLUDE_uxTaskGetStackHighWaterMark2 */
/*-----------------------------------------------------------*/
#if ( INCLUDE_uxTaskGetStackHighWaterMark == 1 )
@@ -3675,7 +3892,9 @@ static void prvCheckTasksWaitingTermination( void )
portCLEAN_UP_TCB( pxTCB );
/* Free up the memory allocated by the scheduler for the task. It is up
- to the task to free any memory allocated at the application level. */
+ to the task to free any memory allocated at the application level.
+ See the third party link http://www.nadler.com/embedded/newlibAndFreeRTOS.html
+ for additional information. */
#if ( configUSE_NEWLIB_REENTRANT == 1 )
{
_reclaim_reent( &( pxTCB->xNewLib_reent ) );
@@ -3689,7 +3908,7 @@ static void prvCheckTasksWaitingTermination( void )
vPortFree( pxTCB->pxStack );
vPortFree( pxTCB );
}
- #elif( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) /*lint !e731 Macro has been consolidated for readability reasons. */
+ #elif( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) /*lint !e731 !e9029 Macro has been consolidated for readability reasons. */
{
/* The task could have been allocated statically or dynamically, so
check what was statically allocated before trying to free the
@@ -3739,7 +3958,7 @@ TCB_t *pxTCB;
the item at the head of the delayed list. This is the time at
which the task at the head of the delayed list should be removed
from the Blocked state. */
- ( pxTCB ) = ( TCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxDelayedTaskList );
+ ( pxTCB ) = listGET_OWNER_OF_HEAD_ENTRY( pxDelayedTaskList ); /*lint !e9079 void * is used as this macro is used with timers and co-routines too. Alignment is known to be fine as the type of the pointer stored and retrieved is the same. */
xNextTaskUnblockTime = listGET_LIST_ITEM_VALUE( &( ( pxTCB )->xStateListItem ) );
}
}
@@ -3794,7 +4013,7 @@ TCB_t *pxTCB;
BaseType_t xTaskPriorityInherit( TaskHandle_t const pxMutexHolder )
{
- TCB_t * const pxMutexHolderTCB = ( TCB_t * ) pxMutexHolder;
+ TCB_t * const pxMutexHolderTCB = pxMutexHolder;
BaseType_t xReturn = pdFALSE;
/* If the mutex was given back by an interrupt while the queue was
@@ -3825,7 +4044,10 @@ TCB_t *pxTCB;
{
if( uxListRemove( &( pxMutexHolderTCB->xStateListItem ) ) == ( UBaseType_t ) 0 )
{
- taskRESET_READY_PRIORITY( pxMutexHolderTCB->uxPriority );
+ /* It is known that the task is in its ready list so
+ there is no need to check again and the port level
+ reset macro can be called directly. */
+ portRESET_READY_PRIORITY( pxMutexHolderTCB->uxPriority, uxTopReadyPriority );
}
else
{
@@ -3881,7 +4103,7 @@ TCB_t *pxTCB;
BaseType_t xTaskPriorityDisinherit( TaskHandle_t const pxMutexHolder )
{
- TCB_t * const pxTCB = ( TCB_t * ) pxMutexHolder;
+ TCB_t * const pxTCB = pxMutexHolder;
BaseType_t xReturn = pdFALSE;
if( pxMutexHolder != NULL )
@@ -3905,7 +4127,7 @@ TCB_t *pxTCB;
the mutex. If the mutex is held by a task then it cannot be
given from an interrupt, and if a mutex is given by the
holding task then it must be the running state task. Remove
- the holding task from the ready list. */
+ the holding task from the ready/delayed list. */
if( uxListRemove( &( pxTCB->xStateListItem ) ) == ( UBaseType_t ) 0 )
{
taskRESET_READY_PRIORITY( pxTCB->uxPriority );
@@ -3961,7 +4183,7 @@ TCB_t *pxTCB;
void vTaskPriorityDisinheritAfterTimeout( TaskHandle_t const pxMutexHolder, UBaseType_t uxHighestPriorityWaitingTask )
{
- TCB_t * const pxTCB = ( TCB_t * ) pxMutexHolder;
+ TCB_t * const pxTCB = pxMutexHolder;
UBaseType_t uxPriorityUsedOnEntry, uxPriorityToUse;
const UBaseType_t uxOnlyOneMutexHeld = ( UBaseType_t ) 1;
@@ -4026,7 +4248,10 @@ TCB_t *pxTCB;
{
if( uxListRemove( &( pxTCB->xStateListItem ) ) == ( UBaseType_t ) 0 )
{
- taskRESET_READY_PRIORITY( pxTCB->uxPriority );
+ /* It is known that the task is in its ready list so
+ there is no need to check again and the port level
+ reset macro can be called directly. */
+ portRESET_READY_PRIORITY( pxTCB->uxPriority, uxTopReadyPriority );
}
else
{
@@ -4139,7 +4364,7 @@ TCB_t *pxTCB;
}
/* Terminate. */
- pcBuffer[ x ] = 0x00;
+ pcBuffer[ x ] = ( char ) 0x00;
/* Return the new end of string. */
return &( pcBuffer[ x ] );
@@ -4153,7 +4378,7 @@ TCB_t *pxTCB;
void vTaskList( char * pcWriteBuffer )
{
TaskStatus_t *pxTaskStatusArray;
- volatile UBaseType_t uxArraySize, x;
+ UBaseType_t uxArraySize, x;
char cStatus;
/*
@@ -4182,7 +4407,7 @@ TCB_t *pxTCB;
/* Make sure the write buffer does not contain a string. */
- *pcWriteBuffer = 0x00;
+ *pcWriteBuffer = ( char ) 0x00;
/* Take a snapshot of the number of tasks in case it changes while this
function is executing. */
@@ -4191,7 +4416,7 @@ TCB_t *pxTCB;
/* Allocate an array index for each task. NOTE! if
configSUPPORT_DYNAMIC_ALLOCATION is set to 0 then pvPortMalloc() will
equate to NULL. */
- pxTaskStatusArray = pvPortMalloc( uxCurrentNumberOfTasks * sizeof( TaskStatus_t ) );
+ pxTaskStatusArray = pvPortMalloc( uxCurrentNumberOfTasks * sizeof( TaskStatus_t ) ); /*lint !e9079 All values returned by pvPortMalloc() have at least the alignment required by the MCU's stack and this allocation allocates a struct that has the alignment requirements of a pointer. */
if( pxTaskStatusArray != NULL )
{
@@ -4218,9 +4443,10 @@ TCB_t *pxTCB;
case eDeleted: cStatus = tskDELETED_CHAR;
break;
+ case eInvalid: /* Fall through. */
default: /* Should not get here, but it is included
to prevent static checking errors. */
- cStatus = 0x00;
+ cStatus = ( char ) 0x00;
break;
}
@@ -4229,8 +4455,8 @@ TCB_t *pxTCB;
pcWriteBuffer = prvWriteNameToBuffer( pcWriteBuffer, pxTaskStatusArray[ x ].pcTaskName );
/* Write the rest of the string. */
- sprintf( pcWriteBuffer, "\t%c\t%u\t%u\t%u\r\n", cStatus, ( unsigned int ) pxTaskStatusArray[ x ].uxCurrentPriority, ( unsigned int ) pxTaskStatusArray[ x ].usStackHighWaterMark, ( unsigned int ) pxTaskStatusArray[ x ].xTaskNumber );
- pcWriteBuffer += strlen( pcWriteBuffer );
+ sprintf( pcWriteBuffer, "\t%c\t%u\t%u\t%u\r\n", cStatus, ( unsigned int ) pxTaskStatusArray[ x ].uxCurrentPriority, ( unsigned int ) pxTaskStatusArray[ x ].usStackHighWaterMark, ( unsigned int ) pxTaskStatusArray[ x ].xTaskNumber ); /*lint !e586 sprintf() allowed as this is compiled with many compilers and this is a utility function only - not part of the core kernel implementation. */
+ pcWriteBuffer += strlen( pcWriteBuffer ); /*lint !e9016 Pointer arithmetic ok on char pointers especially as in this case where it best denotes the intent of the code. */
}
/* Free the array again. NOTE! If configSUPPORT_DYNAMIC_ALLOCATION
@@ -4251,7 +4477,7 @@ TCB_t *pxTCB;
void vTaskGetRunTimeStats( char *pcWriteBuffer )
{
TaskStatus_t *pxTaskStatusArray;
- volatile UBaseType_t uxArraySize, x;
+ UBaseType_t uxArraySize, x;
uint32_t ulTotalTime, ulStatsAsPercentage;
#if( configUSE_TRACE_FACILITY != 1 )
@@ -4286,7 +4512,7 @@ TCB_t *pxTCB;
*/
/* Make sure the write buffer does not contain a string. */
- *pcWriteBuffer = 0x00;
+ *pcWriteBuffer = ( char ) 0x00;
/* Take a snapshot of the number of tasks in case it changes while this
function is executing. */
@@ -4295,7 +4521,7 @@ TCB_t *pxTCB;
/* Allocate an array index for each task. NOTE! If
configSUPPORT_DYNAMIC_ALLOCATION is set to 0 then pvPortMalloc() will
equate to NULL. */
- pxTaskStatusArray = pvPortMalloc( uxCurrentNumberOfTasks * sizeof( TaskStatus_t ) );
+ pxTaskStatusArray = pvPortMalloc( uxCurrentNumberOfTasks * sizeof( TaskStatus_t ) ); /*lint !e9079 All values returned by pvPortMalloc() have at least the alignment required by the MCU's stack and this allocation allocates a struct that has the alignment requirements of a pointer. */
if( pxTaskStatusArray != NULL )
{
@@ -4306,7 +4532,7 @@ TCB_t *pxTCB;
ulTotalTime /= 100UL;
/* Avoid divide by zero errors. */
- if( ulTotalTime > 0 )
+ if( ulTotalTime > 0UL )
{
/* Create a human readable table from the binary data. */
for( x = 0; x < uxArraySize; x++ )
@@ -4331,7 +4557,7 @@ TCB_t *pxTCB;
{
/* sizeof( int ) == sizeof( long ) so a smaller
printf() library can be used. */
- sprintf( pcWriteBuffer, "\t%u\t\t%u%%\r\n", ( unsigned int ) pxTaskStatusArray[ x ].ulRunTimeCounter, ( unsigned int ) ulStatsAsPercentage );
+ sprintf( pcWriteBuffer, "\t%u\t\t%u%%\r\n", ( unsigned int ) pxTaskStatusArray[ x ].ulRunTimeCounter, ( unsigned int ) ulStatsAsPercentage ); /*lint !e586 sprintf() allowed as this is compiled with many compilers and this is a utility function only - not part of the core kernel implementation. */
}
#endif
}
@@ -4347,12 +4573,12 @@ TCB_t *pxTCB;
{
/* sizeof( int ) == sizeof( long ) so a smaller
printf() library can be used. */
- sprintf( pcWriteBuffer, "\t%u\t\t<1%%\r\n", ( unsigned int ) pxTaskStatusArray[ x ].ulRunTimeCounter );
+ sprintf( pcWriteBuffer, "\t%u\t\t<1%%\r\n", ( unsigned int ) pxTaskStatusArray[ x ].ulRunTimeCounter ); /*lint !e586 sprintf() allowed as this is compiled with many compilers and this is a utility function only - not part of the core kernel implementation. */
}
#endif
}
- pcWriteBuffer += strlen( pcWriteBuffer );
+ pcWriteBuffer += strlen( pcWriteBuffer ); /*lint !e9016 Pointer arithmetic ok on char pointers especially as in this case where it best denotes the intent of the code. */
}
}
else
@@ -4389,7 +4615,7 @@ TickType_t uxReturn;
#if ( configUSE_MUTEXES == 1 )
- void *pvTaskIncrementMutexHeldCount( void )
+ TaskHandle_t pvTaskIncrementMutexHeldCount( void )
{
/* If xSemaphoreCreateMutex() is called before any tasks have been created
then pxCurrentTCB will be NULL. */
@@ -4561,7 +4787,7 @@ TickType_t uxReturn;
uint8_t ucOriginalNotifyState;
configASSERT( xTaskToNotify );
- pxTCB = ( TCB_t * ) xTaskToNotify;
+ pxTCB = xTaskToNotify;
taskENTER_CRITICAL();
{
@@ -4604,6 +4830,14 @@ TickType_t uxReturn;
/* The task is being notified without its notify value being
updated. */
break;
+
+ default:
+ /* Should not get here if all enums are handled.
+ Artificially force an assert by testing a value the
+ compiler can't assume is const. */
+ configASSERT( pxTCB->ulNotifiedValue == ~0UL );
+
+ break;
}
traceTASK_NOTIFY();
@@ -4687,7 +4921,7 @@ TickType_t uxReturn;
http://www.freertos.org/RTOS-Cortex-M3-M4.html */
portASSERT_IF_INTERRUPT_PRIORITY_INVALID();
- pxTCB = ( TCB_t * ) xTaskToNotify;
+ pxTCB = xTaskToNotify;
uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();
{
@@ -4729,6 +4963,13 @@ TickType_t uxReturn;
/* The task is being notified without its notify value being
updated. */
break;
+
+ default:
+ /* Should not get here if all enums are handled.
+ Artificially force an assert by testing a value the
+ compiler can't assume is const. */
+ configASSERT( pxTCB->ulNotifiedValue == ~0UL );
+ break;
}
traceTASK_NOTIFY_FROM_ISR();
@@ -4760,13 +5001,11 @@ TickType_t uxReturn;
{
*pxHigherPriorityTaskWoken = pdTRUE;
}
- else
- {
- /* Mark that a yield is pending in case the user is not
- using the "xHigherPriorityTaskWoken" parameter to an ISR
- safe FreeRTOS function. */
- xYieldPending = pdTRUE;
- }
+
+ /* Mark that a yield is pending in case the user is not
+ using the "xHigherPriorityTaskWoken" parameter to an ISR
+ safe FreeRTOS function. */
+ xYieldPending = pdTRUE;
}
else
{
@@ -4810,7 +5049,7 @@ TickType_t uxReturn;
http://www.freertos.org/RTOS-Cortex-M3-M4.html */
portASSERT_IF_INTERRUPT_PRIORITY_INVALID();
- pxTCB = ( TCB_t * ) xTaskToNotify;
+ pxTCB = xTaskToNotify;
uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();
{
@@ -4850,13 +5089,11 @@ TickType_t uxReturn;
{
*pxHigherPriorityTaskWoken = pdTRUE;
}
- else
- {
- /* Mark that a yield is pending in case the user is not
- using the "xHigherPriorityTaskWoken" parameter in an ISR
- safe FreeRTOS function. */
- xYieldPending = pdTRUE;
- }
+
+ /* Mark that a yield is pending in case the user is not
+ using the "xHigherPriorityTaskWoken" parameter in an ISR
+ safe FreeRTOS function. */
+ xYieldPending = pdTRUE;
}
else
{
@@ -4868,7 +5105,6 @@ TickType_t uxReturn;
}
#endif /* configUSE_TASK_NOTIFICATIONS */
-
/*-----------------------------------------------------------*/
#if( configUSE_TASK_NOTIFICATIONS == 1 )
@@ -4902,6 +5138,41 @@ TickType_t uxReturn;
#endif /* configUSE_TASK_NOTIFICATIONS */
/*-----------------------------------------------------------*/
+#if( configUSE_TASK_NOTIFICATIONS == 1 )
+
+ uint32_t ulTaskNotifyValueClear( TaskHandle_t xTask, uint32_t ulBitsToClear )
+ {
+ TCB_t *pxTCB;
+ uint32_t ulReturn;
+
+ /* If null is passed in here then it is the calling task that is having
+ its notification state cleared. */
+ pxTCB = prvGetTCBFromHandle( xTask );
+
+ taskENTER_CRITICAL();
+ {
+ /* Return the notification as it was before the bits were cleared,
+ then clear the bit mask. */
+ ulReturn = pxCurrentTCB->ulNotifiedValue;
+ pxTCB->ulNotifiedValue &= ~ulBitsToClear;
+ }
+ taskEXIT_CRITICAL();
+
+ return ulReturn;
+ }
+
+#endif /* configUSE_TASK_NOTIFICATIONS */
+/*-----------------------------------------------------------*/
+
+#if( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) )
+
+ uint32_t ulTaskGetIdleRunTimeCounter( void )
+ {
+ return xIdleTaskHandle->ulRunTimeCounter;
+ }
+
+#endif
+/*-----------------------------------------------------------*/
static void prvAddCurrentTaskToDelayedList( TickType_t xTicksToWait, const BaseType_t xCanBlockIndefinitely )
{
@@ -4923,7 +5194,7 @@ const TickType_t xConstTickCount = xTickCount;
{
/* The current task must be in a ready list, so there is no need to
check, and the port reset macro can be called directly. */
- portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority );
+ portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority ); /*lint !e931 pxCurrentTCB cannot change as it is the calling task. pxCurrentTCB->uxPriority and uxTopReadyPriority cannot change as called with scheduler suspended or in a critical section. */
}
else
{
@@ -5027,12 +5298,12 @@ when performing module tests). */
#include "freertos_tasks_c_additions.h"
- static void freertos_tasks_c_additions_init( void )
- {
- #ifdef FREERTOS_TASKS_C_ADDITIONS_INIT
+ #ifdef FREERTOS_TASKS_C_ADDITIONS_INIT
+ static void freertos_tasks_c_additions_init( void )
+ {
FREERTOS_TASKS_C_ADDITIONS_INIT();
- #endif
- }
+ }
+ #endif
#endif
diff --git a/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/timers.c b/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/timers.c
index 8a5d99c..d10c832 100644
--- a/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/timers.c
+++ b/Software/VNA_embedded/Middlewares/Third_Party/FreeRTOS/Source/timers.c
@@ -1,6 +1,6 @@
/*
- * FreeRTOS Kernel V10.0.1
- * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * FreeRTOS Kernel V10.3.1
+ * 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
@@ -42,11 +42,11 @@ task.h is included from an application file. */
#error configUSE_TIMERS must be set to 1 to make the xTimerPendFunctionCall() function available.
#endif
-/* Lint e961 and e750 are suppressed as a MISRA exception justified because the
-MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined for the
-header files above, but not in this file, in order to generate the correct
-privileged Vs unprivileged linkage and placement. */
-#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750. */
+/* Lint e9021, e961 and e750 are suppressed as a MISRA exception justified
+because the MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined
+for the header files above, but not in this file, in order to generate the
+correct privileged Vs unprivileged linkage and placement. */
+#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e9021 !e961 !e750. */
/* This entire source file will be skipped if the application is not configured
@@ -64,22 +64,23 @@ defining trmTIMER_SERVICE_TASK_NAME in FreeRTOSConfig.h. */
#define configTIMER_SERVICE_TASK_NAME "Tmr Svc"
#endif
+/* Bit definitions used in the ucStatus member of a timer structure. */
+#define tmrSTATUS_IS_ACTIVE ( ( uint8_t ) 0x01 )
+#define tmrSTATUS_IS_STATICALLY_ALLOCATED ( ( uint8_t ) 0x02 )
+#define tmrSTATUS_IS_AUTORELOAD ( ( uint8_t ) 0x04 )
+
/* The definition of the timers themselves. */
-typedef struct tmrTimerControl
+typedef struct tmrTimerControl /* The old naming convention is used to prevent breaking kernel aware debuggers. */
{
const char *pcTimerName; /*<< Text name. This is not used by the kernel, it is included simply to make debugging easier. */ /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
ListItem_t xTimerListItem; /*<< Standard linked list item as used by all kernel features for event management. */
TickType_t xTimerPeriodInTicks;/*<< How quickly and often the timer expires. */
- UBaseType_t uxAutoReload; /*<< Set to pdTRUE if the timer should be automatically restarted once expired. Set to pdFALSE if the timer is, in effect, a one-shot timer. */
void *pvTimerID; /*<< An ID to identify the timer. This allows the timer to be identified when the same callback is used for multiple timers. */
TimerCallbackFunction_t pxCallbackFunction; /*<< The function that will be called when the timer expires. */
#if( configUSE_TRACE_FACILITY == 1 )
UBaseType_t uxTimerNumber; /*<< An ID assigned by trace tools such as FreeRTOS+Trace */
#endif
-
- #if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
- uint8_t ucStaticallyAllocated; /*<< Set to pdTRUE if the timer was created statically so no attempt is made to free the memory again if the timer is later deleted. */
- #endif
+ uint8_t ucStatus; /*<< Holds bits to say if the timer was statically allocated or not, and if it is active or not. */
} xTIMER;
/* The old xTIMER name is maintained above then typedefed to the new Timer_t
@@ -127,11 +128,14 @@ which static variables must be declared volatile. */
/* The list in which active timers are stored. Timers are referenced in expire
time order, with the nearest expiry time at the front of the list. Only the
-timer service task is allowed to access these lists. */
-PRIVILEGED_DATA static List_t xActiveTimerList1 = {0};
-PRIVILEGED_DATA static List_t xActiveTimerList2 = {0};
-PRIVILEGED_DATA static List_t *pxCurrentTimerList = NULL;
-PRIVILEGED_DATA static List_t *pxOverflowTimerList = NULL;
+timer service task is allowed to access these lists.
+xActiveTimerList1 and xActiveTimerList2 could be at function scope but that
+breaks some kernel aware debuggers, and debuggers that reply on removing the
+static qualifier. */
+PRIVILEGED_DATA static List_t xActiveTimerList1;
+PRIVILEGED_DATA static List_t xActiveTimerList2;
+PRIVILEGED_DATA static List_t *pxCurrentTimerList;
+PRIVILEGED_DATA static List_t *pxOverflowTimerList;
/* A queue that is used to send commands to the timer service task. */
PRIVILEGED_DATA static QueueHandle_t xTimerQueue = NULL;
@@ -162,7 +166,7 @@ static void prvCheckForValidListAndQueue( void ) PRIVILEGED_FUNCTION;
* task. Other tasks communicate with the timer service task using the
* xTimerQueue queue.
*/
-static void prvTimerTask( void *pvParameters ) PRIVILEGED_FUNCTION;
+static portTASK_FUNCTION_PROTO( prvTimerTask, pvParameters ) PRIVILEGED_FUNCTION;
/*
* Called by the timer service task to interpret and process a command it
@@ -178,7 +182,7 @@ static BaseType_t prvInsertTimerInActiveList( Timer_t * const pxTimer, const Tic
/*
* An active timer has reached its expire time. Reload the timer if it is an
- * auto reload timer, then call its callback.
+ * auto-reload timer, then call its callback.
*/
static void prvProcessExpiredTimer( const TickType_t xNextExpireTime, const TickType_t xTimeNow ) PRIVILEGED_FUNCTION;
@@ -283,26 +287,21 @@ BaseType_t xReturn = pdFAIL;
{
Timer_t *pxNewTimer;
- pxNewTimer = ( Timer_t * ) pvPortMalloc( sizeof( Timer_t ) );
+ pxNewTimer = ( Timer_t * ) pvPortMalloc( sizeof( Timer_t ) ); /*lint !e9087 !e9079 All values returned by pvPortMalloc() have at least the alignment required by the MCU's stack, and the first member of Timer_t is always a pointer to the timer's mame. */
if( pxNewTimer != NULL )
{
+ /* Status is thus far zero as the timer is not created statically
+ and has not been started. The auto-reload bit may get set in
+ prvInitialiseNewTimer. */
+ pxNewTimer->ucStatus = 0x00;
prvInitialiseNewTimer( pcTimerName, xTimerPeriodInTicks, uxAutoReload, pvTimerID, pxCallbackFunction, pxNewTimer );
-
- #if( configSUPPORT_STATIC_ALLOCATION == 1 )
- {
- /* Timers can be created statically or dynamically, so note this
- timer was created dynamically in case the timer is later
- deleted. */
- pxNewTimer->ucStaticallyAllocated = pdFALSE;
- }
- #endif /* configSUPPORT_STATIC_ALLOCATION */
}
return pxNewTimer;
}
-#endif /* configSUPPORT_STATIC_ALLOCATION */
+#endif /* configSUPPORT_DYNAMIC_ALLOCATION */
/*-----------------------------------------------------------*/
#if( configSUPPORT_STATIC_ALLOCATION == 1 )
@@ -323,24 +322,22 @@ BaseType_t xReturn = pdFAIL;
structure. */
volatile size_t xSize = sizeof( StaticTimer_t );
configASSERT( xSize == sizeof( Timer_t ) );
+ ( void ) xSize; /* Keeps lint quiet when configASSERT() is not defined. */
}
#endif /* configASSERT_DEFINED */
/* A pointer to a StaticTimer_t structure MUST be provided, use it. */
configASSERT( pxTimerBuffer );
- pxNewTimer = ( Timer_t * ) pxTimerBuffer; /*lint !e740 Unusual cast is ok as the structures are designed to have the same alignment, and the size is checked by an assert. */
+ pxNewTimer = ( Timer_t * ) pxTimerBuffer; /*lint !e740 !e9087 StaticTimer_t is a pointer to a Timer_t, so guaranteed to be aligned and sized correctly (checked by an assert()), so this is safe. */
if( pxNewTimer != NULL )
{
- prvInitialiseNewTimer( pcTimerName, xTimerPeriodInTicks, uxAutoReload, pvTimerID, pxCallbackFunction, pxNewTimer );
+ /* Timers can be created statically or dynamically so note this
+ timer was created statically in case it is later deleted. The
+ auto-reload bit may get set in prvInitialiseNewTimer(). */
+ pxNewTimer->ucStatus = tmrSTATUS_IS_STATICALLY_ALLOCATED;
- #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
- {
- /* Timers can be created statically or dynamically so note this
- timer was created statically in case it is later deleted. */
- pxNewTimer->ucStaticallyAllocated = pdTRUE;
- }
- #endif /* configSUPPORT_DYNAMIC_ALLOCATION */
+ prvInitialiseNewTimer( pcTimerName, xTimerPeriodInTicks, uxAutoReload, pvTimerID, pxCallbackFunction, pxNewTimer );
}
return pxNewTimer;
@@ -369,10 +366,13 @@ static void prvInitialiseNewTimer( const char * const pcTimerName, /*lint !e97
parameters. */
pxNewTimer->pcTimerName = pcTimerName;
pxNewTimer->xTimerPeriodInTicks = xTimerPeriodInTicks;
- pxNewTimer->uxAutoReload = uxAutoReload;
pxNewTimer->pvTimerID = pvTimerID;
pxNewTimer->pxCallbackFunction = pxCallbackFunction;
vListInitialiseItem( &( pxNewTimer->xTimerListItem ) );
+ if( uxAutoReload != pdFALSE )
+ {
+ pxNewTimer->ucStatus |= tmrSTATUS_IS_AUTORELOAD;
+ }
traceTIMER_CREATE( pxNewTimer );
}
}
@@ -392,7 +392,7 @@ DaemonTaskMessage_t xMessage;
/* Send a command to the timer service task to start the xTimer timer. */
xMessage.xMessageID = xCommandID;
xMessage.u.xTimerParameters.xMessageValue = xOptionalValue;
- xMessage.u.xTimerParameters.pxTimer = ( Timer_t * ) xTimer;
+ xMessage.u.xTimerParameters.pxTimer = xTimer;
if( xCommandID < tmrFIRST_FROM_ISR_COMMAND )
{
@@ -432,16 +432,61 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void )
TickType_t xTimerGetPeriod( TimerHandle_t xTimer )
{
-Timer_t *pxTimer = ( Timer_t * ) xTimer;
+Timer_t *pxTimer = xTimer;
configASSERT( xTimer );
return pxTimer->xTimerPeriodInTicks;
}
/*-----------------------------------------------------------*/
+void vTimerSetReloadMode( TimerHandle_t xTimer, const UBaseType_t uxAutoReload )
+{
+Timer_t * pxTimer = xTimer;
+
+ configASSERT( xTimer );
+ taskENTER_CRITICAL();
+ {
+ if( uxAutoReload != pdFALSE )
+ {
+ pxTimer->ucStatus |= tmrSTATUS_IS_AUTORELOAD;
+ }
+ else
+ {
+ pxTimer->ucStatus &= ~tmrSTATUS_IS_AUTORELOAD;
+ }
+ }
+ taskEXIT_CRITICAL();
+}
+/*-----------------------------------------------------------*/
+
+UBaseType_t uxTimerGetReloadMode( TimerHandle_t xTimer )
+{
+Timer_t * pxTimer = xTimer;
+UBaseType_t uxReturn;
+
+ configASSERT( xTimer );
+ taskENTER_CRITICAL();
+ {
+ if( ( pxTimer->ucStatus & tmrSTATUS_IS_AUTORELOAD ) == 0 )
+ {
+ /* Not an auto-reload timer. */
+ uxReturn = ( UBaseType_t ) pdFALSE;
+ }
+ else
+ {
+ /* Is an auto-reload timer. */
+ uxReturn = ( UBaseType_t ) pdTRUE;
+ }
+ }
+ taskEXIT_CRITICAL();
+
+ return uxReturn;
+}
+/*-----------------------------------------------------------*/
+
TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer )
{
-Timer_t * pxTimer = ( Timer_t * ) xTimer;
+Timer_t * pxTimer = xTimer;
TickType_t xReturn;
configASSERT( xTimer );
@@ -452,7 +497,7 @@ TickType_t xReturn;
const char * pcTimerGetName( TimerHandle_t xTimer ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
{
-Timer_t *pxTimer = ( Timer_t * ) xTimer;
+Timer_t *pxTimer = xTimer;
configASSERT( xTimer );
return pxTimer->pcTimerName;
@@ -462,16 +507,16 @@ Timer_t *pxTimer = ( Timer_t * ) xTimer;
static void prvProcessExpiredTimer( const TickType_t xNextExpireTime, const TickType_t xTimeNow )
{
BaseType_t xResult;
-Timer_t * const pxTimer = ( Timer_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxCurrentTimerList );
+Timer_t * const pxTimer = ( Timer_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxCurrentTimerList ); /*lint !e9087 !e9079 void * is used as this macro is used with tasks and co-routines too. Alignment is known to be fine as the type of the pointer stored and retrieved is the same. */
/* Remove the timer from the list of active timers. A check has already
been performed to ensure the list is not empty. */
( void ) uxListRemove( &( pxTimer->xTimerListItem ) );
traceTIMER_EXPIRED( pxTimer );
- /* If the timer is an auto reload timer then calculate the next
+ /* If the timer is an auto-reload timer then calculate the next
expiry time and re-insert the timer in the list of active timers. */
- if( pxTimer->uxAutoReload == ( UBaseType_t ) pdTRUE )
+ if( ( pxTimer->ucStatus & tmrSTATUS_IS_AUTORELOAD ) != 0 )
{
/* The timer is inserted into a list using a time relative to anything
other than the current time. It will therefore be inserted into the
@@ -491,6 +536,7 @@ Timer_t * const pxTimer = ( Timer_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxCurrentTi
}
else
{
+ pxTimer->ucStatus &= ~tmrSTATUS_IS_ACTIVE;
mtCOVERAGE_TEST_MARKER();
}
@@ -499,7 +545,7 @@ Timer_t * const pxTimer = ( Timer_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxCurrentTi
}
/*-----------------------------------------------------------*/
-static void prvTimerTask( void *pvParameters )
+static portTASK_FUNCTION( prvTimerTask, pvParameters )
{
TickType_t xNextExpireTime;
BaseType_t xListWasEmpty;
@@ -747,11 +793,12 @@ TickType_t xTimeNow;
switch( xMessage.xMessageID )
{
case tmrCOMMAND_START :
- case tmrCOMMAND_START_FROM_ISR :
- case tmrCOMMAND_RESET :
- case tmrCOMMAND_RESET_FROM_ISR :
+ case tmrCOMMAND_START_FROM_ISR :
+ case tmrCOMMAND_RESET :
+ case tmrCOMMAND_RESET_FROM_ISR :
case tmrCOMMAND_START_DONT_TRACE :
/* Start or restart a timer. */
+ pxTimer->ucStatus |= tmrSTATUS_IS_ACTIVE;
if( prvInsertTimerInActiveList( pxTimer, xMessage.u.xTimerParameters.xMessageValue + pxTimer->xTimerPeriodInTicks, xTimeNow, xMessage.u.xTimerParameters.xMessageValue ) != pdFALSE )
{
/* The timer expired before it was added to the active
@@ -759,7 +806,7 @@ TickType_t xTimeNow;
pxTimer->pxCallbackFunction( ( TimerHandle_t ) pxTimer );
traceTIMER_EXPIRED( pxTimer );
- if( pxTimer->uxAutoReload == ( UBaseType_t ) pdTRUE )
+ if( ( pxTimer->ucStatus & tmrSTATUS_IS_AUTORELOAD ) != 0 )
{
xResult = xTimerGenericCommand( pxTimer, tmrCOMMAND_START_DONT_TRACE, xMessage.u.xTimerParameters.xMessageValue + pxTimer->xTimerPeriodInTicks, NULL, tmrNO_DELAY );
configASSERT( xResult );
@@ -778,12 +825,13 @@ TickType_t xTimeNow;
case tmrCOMMAND_STOP :
case tmrCOMMAND_STOP_FROM_ISR :
- /* The timer has already been removed from the active list.
- There is nothing to do here. */
+ /* The timer has already been removed from the active list. */
+ pxTimer->ucStatus &= ~tmrSTATUS_IS_ACTIVE;
break;
case tmrCOMMAND_CHANGE_PERIOD :
case tmrCOMMAND_CHANGE_PERIOD_FROM_ISR :
+ pxTimer->ucStatus |= tmrSTATUS_IS_ACTIVE;
pxTimer->xTimerPeriodInTicks = xMessage.u.xTimerParameters.xMessageValue;
configASSERT( ( pxTimer->xTimerPeriodInTicks > 0 ) );
@@ -797,29 +845,28 @@ TickType_t xTimeNow;
break;
case tmrCOMMAND_DELETE :
- /* The timer has already been removed from the active list,
- just free up the memory if the memory was dynamically
- allocated. */
- #if( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 0 ) )
+ #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
{
- /* The timer can only have been allocated dynamically -
- free it again. */
- vPortFree( pxTimer );
- }
- #elif( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
- {
- /* The timer could have been allocated statically or
- dynamically, so check before attempting to free the
- memory. */
- if( pxTimer->ucStaticallyAllocated == ( uint8_t ) pdFALSE )
+ /* The timer has already been removed from the active list,
+ just free up the memory if the memory was dynamically
+ allocated. */
+ if( ( pxTimer->ucStatus & tmrSTATUS_IS_STATICALLY_ALLOCATED ) == ( uint8_t ) 0 )
{
vPortFree( pxTimer );
}
else
{
- mtCOVERAGE_TEST_MARKER();
+ pxTimer->ucStatus &= ~tmrSTATUS_IS_ACTIVE;
}
}
+ #else
+ {
+ /* If dynamic allocation is not enabled, the memory
+ could not have been dynamically allocated. So there is
+ no need to free the memory - just mark the timer as
+ "not active". */
+ pxTimer->ucStatus &= ~tmrSTATUS_IS_ACTIVE;
+ }
#endif /* configSUPPORT_DYNAMIC_ALLOCATION */
break;
@@ -848,7 +895,7 @@ BaseType_t xResult;
xNextExpireTime = listGET_ITEM_VALUE_OF_HEAD_ENTRY( pxCurrentTimerList );
/* Remove the timer from the list. */
- pxTimer = ( Timer_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxCurrentTimerList );
+ pxTimer = ( Timer_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxCurrentTimerList ); /*lint !e9087 !e9079 void * is used as this macro is used with tasks and co-routines too. Alignment is known to be fine as the type of the pointer stored and retrieved is the same. */
( void ) uxListRemove( &( pxTimer->xTimerListItem ) );
traceTIMER_EXPIRED( pxTimer );
@@ -857,7 +904,7 @@ BaseType_t xResult;
have not yet been switched. */
pxTimer->pxCallbackFunction( ( TimerHandle_t ) pxTimer );
- if( pxTimer->uxAutoReload == ( UBaseType_t ) pdTRUE )
+ if( ( pxTimer->ucStatus & tmrSTATUS_IS_AUTORELOAD ) != 0 )
{
/* Calculate the reload value, and if the reload value results in
the timer going into the same timer list then it has already expired
@@ -944,28 +991,32 @@ static void prvCheckForValidListAndQueue( void )
BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer )
{
-BaseType_t xTimerIsInActiveList;
-Timer_t *pxTimer = ( Timer_t * ) xTimer;
+BaseType_t xReturn;
+Timer_t *pxTimer = xTimer;
configASSERT( xTimer );
/* Is the timer in the list of active timers? */
taskENTER_CRITICAL();
{
- /* Checking to see if it is in the NULL list in effect checks to see if
- it is referenced from either the current or the overflow timer lists in
- one go, but the logic has to be reversed, hence the '!'. */
- xTimerIsInActiveList = ( BaseType_t ) !( listIS_CONTAINED_WITHIN( NULL, &( pxTimer->xTimerListItem ) ) ); /*lint !e961. Cast is only redundant when NULL is passed into the macro. */
+ if( ( pxTimer->ucStatus & tmrSTATUS_IS_ACTIVE ) == 0 )
+ {
+ xReturn = pdFALSE;
+ }
+ else
+ {
+ xReturn = pdTRUE;
+ }
}
taskEXIT_CRITICAL();
- return xTimerIsInActiveList;
+ return xReturn;
} /*lint !e818 Can't be pointer to const due to the typedef. */
/*-----------------------------------------------------------*/
void *pvTimerGetTimerID( const TimerHandle_t xTimer )
{
-Timer_t * const pxTimer = ( Timer_t * ) xTimer;
+Timer_t * const pxTimer = xTimer;
void *pvReturn;
configASSERT( xTimer );
@@ -982,7 +1033,7 @@ void *pvReturn;
void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID )
{
-Timer_t * const pxTimer = ( Timer_t * ) xTimer;
+Timer_t * const pxTimer = xTimer;
configASSERT( xTimer );
diff --git a/Software/VNA_embedded/New_configuration.cfg b/Software/VNA_embedded/New_configuration.cfg
deleted file mode 100644
index 87ae1cd..0000000
--- a/Software/VNA_embedded/New_configuration.cfg
+++ /dev/null
@@ -1,36 +0,0 @@
-# This is an VNA_embedded board with a single STM32L432KCUx chip
-#
-# Generated by System Workbench for STM32
-# Take care that such file, as generated, may be overridden without any early notice. Please have a look to debug launch configuration setup(s)
-
-source [find interface/stlink.cfg]
-
-set WORKAREASIZE 0x8000
-
-transport select "hla_swd"
-
-set CHIPNAME STM32G432CBUx
-set BOARDNAME VNA_embedded
-
-# CHIPNAMES state
-set CHIPNAME_CPU0_ACTIVATED 1
-
-# Enable debug when in low power modes
-set ENABLE_LOW_POWER 1
-
-# Stop Watchdog counters when halt
-set STOP_WATCHDOG 1
-
-# STlink Debug clock frequency
-set CLOCK_FREQ 8000
-
-# use hardware reset, connect under reset
-# connect_assert_srst needed if low power mode application running (WFI...)
-reset_config srst_only srst_nogate connect_assert_srst
-set CONNECT_UNDER_RESET 1
-
-# BCTM CPU variables
-
-
-
-source [find target/stm32g4x.cfg]
diff --git a/Software/VNA_embedded/STM32G431CBUx_FLASH.ld b/Software/VNA_embedded/STM32G431CBUX_FLASH.ld
similarity index 50%
rename from Software/VNA_embedded/STM32G431CBUx_FLASH.ld
rename to Software/VNA_embedded/STM32G431CBUX_FLASH.ld
index 79f439c..8dbfaf1 100644
--- a/Software/VNA_embedded/STM32G431CBUx_FLASH.ld
+++ b/Software/VNA_embedded/STM32G431CBUX_FLASH.ld
@@ -1,189 +1,185 @@
-/*
-******************************************************************************
-**
-
-** File : LinkerScript.ld
-**
-** Author : Auto-generated by Ac6 System Workbench
-**
-** Abstract : Linker script for STM32G431CBUx series
-** 128Kbytes FLASH and 32Kbytes RAM
-**
-** Set heap size, stack size and stack location according
-** to application requirements.
-**
-** Set memory bank area and size if external memory is used.
-**
-** Target : STMicroelectronics STM32
-**
-** Distribution: The file is distributed “as is,†without any warranty
-** of any kind.
-**
-*****************************************************************************
-** @attention
-**
-** © COPYRIGHT(c) 2014 Ac6
-**
-** Redistribution and use in source and binary forms, with or without modification,
-** are permitted provided that the following conditions are met:
-** 1. Redistributions of source code must retain the above copyright notice,
-** this list of conditions and the following disclaimer.
-** 2. Redistributions in binary form must reproduce the above copyright notice,
-** this list of conditions and the following disclaimer in the documentation
-** and/or other materials provided with the distribution.
-** 3. Neither the name of Ac6 nor the names of its contributors
-** may be used to endorse or promote products derived from this software
-** without specific prior written permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-**
-*****************************************************************************
-*/
-
-/* Entry Point */
-ENTRY(Reset_Handler)
-
-/* Highest address of the user mode stack */
-_estack = 0x20008000; /* end of RAM */
-/* Generate a link error if heap and stack don't fit into RAM */
-_Min_Heap_Size = 0x200; /* required amount of heap */
-_Min_Stack_Size = 0x400; /* required amount of stack */
-
-/* Specify the memory areas */
-MEMORY
-{
-RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K
-FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 128K
-}
-
-/* Define output sections */
-SECTIONS
-{
- /* The startup code goes first into FLASH */
- .isr_vector :
- {
- . = ALIGN(4);
- KEEP(*(.isr_vector)) /* Startup code */
- . = ALIGN(4);
- } >FLASH
-
- /* The program code and other data goes into FLASH */
- .text :
- {
- . = ALIGN(4);
- *(.text) /* .text sections (code) */
- *(.text*) /* .text* sections (code) */
- *(.glue_7) /* glue arm to thumb code */
- *(.glue_7t) /* glue thumb to arm code */
- *(.eh_frame)
-
- KEEP (*(.init))
- KEEP (*(.fini))
-
- . = ALIGN(4);
- _etext = .; /* define a global symbols at end of code */
- } >FLASH
-
- /* Constant data goes into FLASH */
- .rodata :
- {
- . = ALIGN(4);
- *(.rodata) /* .rodata sections (constants, strings, etc.) */
- *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
- . = ALIGN(4);
- } >FLASH
-
- .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
- .ARM : {
- __exidx_start = .;
- *(.ARM.exidx*)
- __exidx_end = .;
- } >FLASH
-
- .preinit_array :
- {
- PROVIDE_HIDDEN (__preinit_array_start = .);
- KEEP (*(.preinit_array*))
- PROVIDE_HIDDEN (__preinit_array_end = .);
- } >FLASH
- .init_array :
- {
- PROVIDE_HIDDEN (__init_array_start = .);
- KEEP (*(SORT(.init_array.*)))
- KEEP (*(.init_array*))
- PROVIDE_HIDDEN (__init_array_end = .);
- } >FLASH
- .fini_array :
- {
- PROVIDE_HIDDEN (__fini_array_start = .);
- KEEP (*(SORT(.fini_array.*)))
- KEEP (*(.fini_array*))
- PROVIDE_HIDDEN (__fini_array_end = .);
- } >FLASH
-
- /* used by the startup to initialize data */
- _sidata = LOADADDR(.data);
-
- /* Initialized data sections goes into RAM, load LMA copy after code */
- .data :
- {
- . = ALIGN(4);
- _sdata = .; /* create a global symbol at data start */
- *(.data) /* .data sections */
- *(.data*) /* .data* sections */
-
- . = ALIGN(4);
- _edata = .; /* define a global symbol at data end */
- } >RAM AT> FLASH
-
-
- /* Uninitialized data section */
- . = ALIGN(4);
- .bss :
- {
- /* This is used by the startup in order to initialize the .bss secion */
- _sbss = .; /* define a global symbol at bss start */
- __bss_start__ = _sbss;
- *(.bss)
- *(.bss*)
- *(COMMON)
-
- . = ALIGN(4);
- _ebss = .; /* define a global symbol at bss end */
- __bss_end__ = _ebss;
- } >RAM
-
- /* User_heap_stack section, used to check that there is enough RAM left */
- ._user_heap_stack :
- {
- . = ALIGN(8);
- PROVIDE ( end = . );
- PROVIDE ( _end = . );
- . = . + _Min_Heap_Size;
- . = . + _Min_Stack_Size;
- . = ALIGN(8);
- } >RAM
-
-
-
- /* Remove information from the standard libraries */
- /DISCARD/ :
- {
- libc.a ( * )
- libm.a ( * )
- libgcc.a ( * )
- }
-
- .ARM.attributes 0 : { *(.ARM.attributes) }
-}
-
-
+/*
+******************************************************************************
+**
+** @file : LinkerScript.ld
+**
+** @author : Auto-generated by STM32CubeIDE
+**
+** @brief : Linker script for STM32G431CBUx Device from STM32G4 series
+** 128Kbytes FLASH
+** 32Kbytes RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used
+**
+** Target : STMicroelectronics STM32
+**
+** Distribution: The file is distributed as is, without any warranty
+** of any kind.
+**
+******************************************************************************
+** @attention
+**
+** Copyright (c) 2022 STMicroelectronics.
+** All rights reserved.
+**
+** This software is licensed under terms that can be found in the LICENSE file
+** in the root directory of this software component.
+** If no LICENSE file comes with this software, it is provided AS-IS.
+**
+******************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Highest address of the user mode stack */
+_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
+
+_Min_Heap_Size = 0x200 ; /* required amount of heap */
+_Min_Stack_Size = 0x400 ; /* required amount of stack */
+
+/* Memories definition */
+MEMORY
+{
+ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K
+ FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 128K
+}
+
+/* Sections */
+SECTIONS
+{
+ /* The startup code into "FLASH" Rom type memory */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >FLASH
+
+ /* The program code and other data into "FLASH" Rom type memory */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data into "FLASH" Rom type memory */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.extab : {
+ . = ALIGN(4);
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM : {
+ . = ALIGN(4);
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ . = ALIGN(4);
+ } >FLASH
+
+ .preinit_array :
+ {
+ . = ALIGN(4);
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ . = ALIGN(4);
+ } >FLASH
+
+ .init_array :
+ {
+ . = ALIGN(4);
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ . = ALIGN(4);
+ } >FLASH
+
+ .fini_array :
+ {
+ . = ALIGN(4);
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ . = ALIGN(4);
+ } >FLASH
+
+ /* Used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections into "RAM" Ram type memory */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+ *(.RamFunc) /* .RamFunc sections */
+ *(.RamFunc*) /* .RamFunc* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+
+ } >RAM AT> FLASH
+
+ /* Uninitialized data section into "RAM" Ram type memory */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss section */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+ /* Remove information from the compiler libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
diff --git a/Software/VNA_embedded/Src/app_freertos.c b/Software/VNA_embedded/Src/app_freertos.c
index c3e077d..28bd50e 100644
--- a/Software/VNA_embedded/Src/app_freertos.c
+++ b/Software/VNA_embedded/Src/app_freertos.c
@@ -6,13 +6,12 @@
******************************************************************************
* @attention
*
- * © Copyright (c) 2020 STMicroelectronics.
- * All rights reserved.
+ * Copyright (c) 2022 STMicroelectronics.
+ * All rights reserved.
*
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
@@ -50,7 +49,7 @@
/* Private function prototypes -----------------------------------------------*/
/* USER CODE BEGIN FunctionPrototypes */
-
+
/* USER CODE END FunctionPrototypes */
/* GetIdleTaskMemory prototype (linked to static allocation support) */
@@ -59,19 +58,18 @@ void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackTy
/* USER CODE BEGIN GET_IDLE_TASK_MEMORY */
static StaticTask_t xIdleTaskTCBBuffer;
static StackType_t xIdleStack[configMINIMAL_STACK_SIZE];
-
+
void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize )
{
*ppxIdleTaskTCBBuffer = &xIdleTaskTCBBuffer;
*ppxIdleTaskStackBuffer = &xIdleStack[0];
*pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
/* place for user code */
-}
+}
/* USER CODE END GET_IDLE_TASK_MEMORY */
/* Private application code --------------------------------------------------*/
/* USER CODE BEGIN Application */
-
+
/* USER CODE END Application */
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Software/VNA_embedded/Src/main.c b/Software/VNA_embedded/Src/main.c
index d1e597b..51c7663 100644
--- a/Software/VNA_embedded/Src/main.c
+++ b/Software/VNA_embedded/Src/main.c
@@ -6,22 +6,19 @@
******************************************************************************
* @attention
*
- * © Copyright (c) 2020 STMicroelectronics.
- * All rights reserved.
+ * Copyright (c) 2022 STMicroelectronics.
+ * All rights reserved.
*
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
-
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "cmsis_os.h"
-#include "usbpd.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
@@ -35,7 +32,6 @@
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
-
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
@@ -132,8 +128,6 @@ int main(void)
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
- /* USBPD initialisation ---------------------------------*/
- MX_USBPD_Init();
/* USER CODE BEGIN RTOS_MUTEX */
/* add mutexes, ... */
@@ -164,7 +158,6 @@ int main(void)
osKernelStart();
/* We should never get here as control is now taken by the scheduler */
-
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
@@ -184,12 +177,12 @@ void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
- RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
/** Configure the main internal regulator output voltage
*/
HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1_BOOST);
- /** Initializes the CPU, AHB and APB busses clocks
+ /** Initializes the RCC Oscillators according to the specified parameters
+ * in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_HSI48;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
@@ -206,7 +199,7 @@ void SystemClock_Config(void)
{
Error_Handler();
}
- /** Initializes the CPU, AHB and APB busses clocks
+ /** Initializes the CPU, AHB and APB buses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
@@ -215,19 +208,7 @@ void SystemClock_Config(void)
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
- if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_7) != HAL_OK)
- {
- Error_Handler();
- }
- /** Initializes the peripherals clocks
- */
- PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART3|RCC_PERIPHCLK_I2C2
- |RCC_PERIPHCLK_USB|RCC_PERIPHCLK_ADC12;
- PeriphClkInit.Usart3ClockSelection = RCC_USART3CLKSOURCE_PCLK1;
- PeriphClkInit.I2c2ClockSelection = RCC_I2C2CLKSOURCE_PCLK1;
- PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;
- PeriphClkInit.Adc12ClockSelection = RCC_ADC12CLKSOURCE_SYSCLK;
- if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
+ if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK)
{
Error_Handler();
}
@@ -254,7 +235,7 @@ static void MX_ADC1_Init(void)
/** Common config
*/
hadc1.Instance = ADC1;
- hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1;
+ hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV4;
hadc1.Init.Resolution = ADC_RESOLUTION_12B;
hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
hadc1.Init.GainCompensation = 0;
@@ -438,7 +419,6 @@ static void MX_TIM1_Init(void)
TIM_ClockConfigTypeDef sClockSourceConfig = {0};
TIM_MasterConfigTypeDef sMasterConfig = {0};
- TIM_BreakDeadTimeConfigTypeDef sBreakDeadTimeConfig = {0};
/* USER CODE BEGIN TIM1_Init 1 */
@@ -466,12 +446,6 @@ static void MX_TIM1_Init(void)
{
Error_Handler();
}
- sBreakDeadTimeConfig.BreakAFMode = TIM_BREAK_AFMODE_INPUT;
- sBreakDeadTimeConfig.Break2AFMode = TIM_BREAK_AFMODE_INPUT;
- if (HAL_TIMEx_ConfigBreakDeadTime(&htim1, &sBreakDeadTimeConfig) != HAL_OK)
- {
- Error_Handler();
- }
/* USER CODE BEGIN TIM1_Init 2 */
/* USER CODE END TIM1_Init 2 */
@@ -549,9 +523,26 @@ static void MX_UCPD1_Init(void)
/* USER CODE END UCPD1_Init 0 */
+ LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
+
/* Peripheral clock enable */
LL_APB1_GRP2_EnableClock(LL_APB1_GRP2_PERIPH_UCPD1);
+ LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOB);
+ /**UCPD1 GPIO Configuration
+ PB4 ------> UCPD1_CC2
+ PB6 ------> UCPD1_CC1
+ */
+ GPIO_InitStruct.Pin = LL_GPIO_PIN_4;
+ GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
+ GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
+ LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
+
+ GPIO_InitStruct.Pin = LL_GPIO_PIN_6;
+ GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
+ GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
+ LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
+
/* UCPD1 DMA Init */
/* UCPD1_RX Init */
@@ -687,6 +678,7 @@ static void MX_USB_PCD_Init(void)
*/
static void MX_DMA_Init(void)
{
+
/* DMA controller clock enable */
__HAL_RCC_DMAMUX1_CLK_ENABLE();
__HAL_RCC_DMA1_CLK_ENABLE();
@@ -782,13 +774,12 @@ static void MX_GPIO_Init(void)
/* USER CODE BEGIN Header_StartDefaultTask */
/**
* @brief Function implementing the defaultTask thread.
- * @param argument: Not used
+ * @param argument: Not used
* @retval None
*/
/* USER CODE END Header_StartDefaultTask */
void StartDefaultTask(void const * argument)
{
-
/* USER CODE BEGIN 5 */
App_Start();
/* Infinite loop */
@@ -828,7 +819,10 @@ void Error_Handler(void)
{
/* USER CODE BEGIN Error_Handler_Debug */
/* User can add his own implementation to report the HAL error return state */
-
+ __disable_irq();
+ while (1)
+ {
+ }
/* USER CODE END Error_Handler_Debug */
}
@@ -844,9 +838,8 @@ void assert_failed(uint8_t *file, uint32_t line)
{
/* USER CODE BEGIN 6 */
/* User can add his own implementation to report the file name and line number,
- tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+ ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Software/VNA_embedded/Src/stm32g4xx_hal_msp.c b/Software/VNA_embedded/Src/stm32g4xx_hal_msp.c
index de401e9..ae1f1e5 100644
--- a/Software/VNA_embedded/Src/stm32g4xx_hal_msp.c
+++ b/Software/VNA_embedded/Src/stm32g4xx_hal_msp.c
@@ -1,19 +1,18 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
- * File Name : stm32g4xx_hal_msp.c
- * Description : This file provides code for the MSP Initialization
- * and de-Initialization codes.
+ * @file stm32g4xx_hal_msp.c
+ * @brief This file provides code for the MSP Initialization
+ * and de-Initialization codes.
******************************************************************************
* @attention
*
- * © Copyright (c) 2020 STMicroelectronics.
- * All rights reserved.
+ * Copyright (c) 2022 STMicroelectronics.
+ * All rights reserved.
*
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
@@ -35,7 +34,7 @@ extern DMA_HandleTypeDef hdma_spi1_tx;
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN Define */
-
+
/* USER CODE END Define */
/* Private macro -------------------------------------------------------------*/
@@ -92,11 +91,21 @@ void HAL_MspInit(void)
*/
void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
{
+ RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
if(hadc->Instance==ADC1)
{
/* USER CODE BEGIN ADC1_MspInit 0 */
/* USER CODE END ADC1_MspInit 0 */
+ /** Initializes the peripherals clocks
+ */
+ PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC12;
+ PeriphClkInit.Adc12ClockSelection = RCC_ADC12CLKSOURCE_SYSCLK;
+ if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
+ {
+ Error_Handler();
+ }
+
/* Peripheral clock enable */
__HAL_RCC_ADC12_CLK_ENABLE();
/* USER CODE BEGIN ADC1_MspInit 1 */
@@ -137,11 +146,20 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc)
void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
+ RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
if(hi2c->Instance==I2C2)
{
/* USER CODE BEGIN I2C2_MspInit 0 */
/* USER CODE END I2C2_MspInit 0 */
+ /** Initializes the peripherals clocks
+ */
+ PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_I2C2;
+ PeriphClkInit.I2c2ClockSelection = RCC_I2C2CLKSOURCE_PCLK1;
+ if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
+ {
+ Error_Handler();
+ }
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
@@ -457,11 +475,21 @@ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base)
void HAL_UART_MspInit(UART_HandleTypeDef* huart)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
+ RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
if(huart->Instance==USART3)
{
/* USER CODE BEGIN USART3_MspInit 0 */
/* USER CODE END USART3_MspInit 0 */
+ /** Initializes the peripherals clocks
+ */
+ PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART3;
+ PeriphClkInit.Usart3ClockSelection = RCC_USART3CLKSOURCE_PCLK1;
+ if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
+ {
+ Error_Handler();
+ }
+
/* Peripheral clock enable */
__HAL_RCC_USART3_CLK_ENABLE();
@@ -531,23 +559,20 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
*/
void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd)
{
- GPIO_InitTypeDef GPIO_InitStruct = {0};
+ RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
if(hpcd->Instance==USB)
{
/* USER CODE BEGIN USB_MspInit 0 */
/* USER CODE END USB_MspInit 0 */
-
- __HAL_RCC_GPIOA_CLK_ENABLE();
- /**USB GPIO Configuration
- PA11 ------> USB_DM
- PA12 ------> USB_DP
- */
- GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12;
- GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
- HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+ /** Initializes the peripherals clocks
+ */
+ PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB;
+ PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;
+ if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
+ {
+ Error_Handler();
+ }
/* Peripheral clock enable */
__HAL_RCC_USB_CLK_ENABLE();
@@ -573,13 +598,6 @@ void HAL_PCD_MspDeInit(PCD_HandleTypeDef* hpcd)
/* USER CODE END USB_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_USB_CLK_DISABLE();
-
- /**USB GPIO Configuration
- PA11 ------> USB_DM
- PA12 ------> USB_DP
- */
- HAL_GPIO_DeInit(GPIOA, GPIO_PIN_11|GPIO_PIN_12);
-
/* USER CODE BEGIN USB_MspDeInit 1 */
/* USER CODE END USB_MspDeInit 1 */
@@ -591,4 +609,3 @@ void HAL_PCD_MspDeInit(PCD_HandleTypeDef* hpcd)
/* USER CODE END 1 */
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Software/VNA_embedded/Src/stm32g4xx_hal_timebase_tim.c b/Software/VNA_embedded/Src/stm32g4xx_hal_timebase_tim.c
index a2ee498..448c061 100644
--- a/Software/VNA_embedded/Src/stm32g4xx_hal_timebase_tim.c
+++ b/Software/VNA_embedded/Src/stm32g4xx_hal_timebase_tim.c
@@ -1,18 +1,17 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
- * @file stm32g4xx_hal_timebase_TIM.c
+ * @file stm32g4xx_hal_timebase_TIM.c
* @brief HAL time base based on the hardware TIM.
******************************************************************************
* @attention
*
- * © Copyright (c) 2020 STMicroelectronics.
- * All rights reserved.
+ * Copyright (c) 2022 STMicroelectronics.
+ * All rights reserved.
*
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
@@ -45,12 +44,7 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
uint32_t uwTimclock = 0;
uint32_t uwPrescalerValue = 0;
uint32_t pFLatency;
-
- /*Configure the TIM17 IRQ priority */
- HAL_NVIC_SetPriority(TIM1_TRG_COM_TIM17_IRQn, TickPriority ,0);
-
- /* Enable the TIM17 global Interrupt */
- HAL_NVIC_EnableIRQ(TIM1_TRG_COM_TIM17_IRQn);
+ HAL_StatusTypeDef status = HAL_OK;
/* Enable TIM17 clock */
__HAL_RCC_TIM17_CLK_ENABLE();
@@ -60,9 +54,8 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
/* Compute TIM17 clock */
uwTimclock = HAL_RCC_GetPCLK2Freq();
-
/* Compute the prescaler value to have TIM17 counter clock equal to 1MHz */
- uwPrescalerValue = (uint32_t) ((uwTimclock / 1000000) - 1);
+ uwPrescalerValue = (uint32_t) ((uwTimclock / 1000000U) - 1U);
/* Initialize TIM17 */
htim17.Instance = TIM17;
@@ -73,18 +66,35 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
+ ClockDivision = 0
+ Counter direction = Up
*/
- htim17.Init.Period = (1000000 / 1000) - 1;
+ htim17.Init.Period = (1000000U / 1000U) - 1U;
htim17.Init.Prescaler = uwPrescalerValue;
htim17.Init.ClockDivision = 0;
htim17.Init.CounterMode = TIM_COUNTERMODE_UP;
- if(HAL_TIM_Base_Init(&htim17) == HAL_OK)
+
+ status = HAL_TIM_Base_Init(&htim17);
+ if (status == HAL_OK)
{
/* Start the TIM time Base generation in interrupt mode */
- return HAL_TIM_Base_Start_IT(&htim17);
+ status = HAL_TIM_Base_Start_IT(&htim17);
+ if (status == HAL_OK)
+ {
+ /* Enable the TIM17 global Interrupt */
+ HAL_NVIC_EnableIRQ(TIM1_TRG_COM_TIM17_IRQn);
+ /* Configure the SysTick IRQ priority */
+ if (TickPriority < (1UL << __NVIC_PRIO_BITS))
+ {
+ /* Configure the TIM IRQ priority */
+ HAL_NVIC_SetPriority(TIM1_TRG_COM_TIM17_IRQn, TickPriority, 0U);
+ uwTickPrio = TickPriority;
+ }
+ else
+ {
+ status = HAL_ERROR;
+ }
+ }
}
-
- /* Return function status */
- return HAL_ERROR;
+ /* Return function status */
+ return status;
}
/**
@@ -111,4 +121,3 @@ void HAL_ResumeTick(void)
__HAL_TIM_ENABLE_IT(&htim17, TIM_IT_UPDATE);
}
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Software/VNA_embedded/Src/stm32g4xx_it.c b/Software/VNA_embedded/Src/stm32g4xx_it.c
index bcf8bc7..b1e3206 100644
--- a/Software/VNA_embedded/Src/stm32g4xx_it.c
+++ b/Software/VNA_embedded/Src/stm32g4xx_it.c
@@ -6,13 +6,12 @@
******************************************************************************
* @attention
*
- * © Copyright (c) 2020 STMicroelectronics.
- * All rights reserved.
+ * Copyright (c) 2022 STMicroelectronics.
+ * All rights reserved.
*
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
@@ -21,7 +20,6 @@
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "stm32g4xx_it.h"
-#include "cmsis_os.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
@@ -33,7 +31,7 @@
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
-
+
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
@@ -78,7 +76,9 @@ void NMI_Handler(void)
/* USER CODE END NonMaskableInt_IRQn 0 */
/* USER CODE BEGIN NonMaskableInt_IRQn 1 */
-
+ while (1)
+ {
+ }
/* USER CODE END NonMaskableInt_IRQn 1 */
}
@@ -249,4 +249,4 @@ void UCPD1_IRQHandler(void)
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
+
diff --git a/Software/VNA_embedded/Src/syscalls.c b/Software/VNA_embedded/Src/syscalls.c
index d457e10..8370509 100644
--- a/Software/VNA_embedded/Src/syscalls.c
+++ b/Software/VNA_embedded/Src/syscalls.c
@@ -1,204 +1,155 @@
-/**
-*****************************************************************************
-**
-** File : syscalls.c
-**
-** Abstract : System Workbench Minimal System calls file
-**
-** For more information about which c-functions
-** need which of these lowlevel functions
-** please consult the Newlib libc-manual
-**
-** Environment : System Workbench for MCU
-**
-** Distribution: The file is distributed “as is,†without any warranty
-** of any kind.
-**
-*****************************************************************************
-**
-** © COPYRIGHT(c) 2014 Ac6
-**
-** Redistribution and use in source and binary forms, with or without modification,
-** are permitted provided that the following conditions are met:
-** 1. Redistributions of source code must retain the above copyright notice,
-** this list of conditions and the following disclaimer.
-** 2. Redistributions in binary form must reproduce the above copyright notice,
-** this list of conditions and the following disclaimer in the documentation
-** and/or other materials provided with the distribution.
-** 3. Neither the name of Ac6 nor the names of its contributors
-** may be used to endorse or promote products derived from this software
-** without specific prior written permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-**
-*****************************************************************************
-*/
-
-/* Includes */
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-
-/* Variables */
-//#undef errno
-extern int errno;
-extern int __io_putchar(int ch) __attribute__((weak));
-extern int __io_getchar(void) __attribute__((weak));
-
-register char * stack_ptr asm("sp");
-
-char *__env[1] = { 0 };
-char **environ = __env;
-
-
-/* Functions */
-void initialise_monitor_handles()
-{
-}
-
-int _getpid(void)
-{
- return 1;
-}
-
-int _kill(int pid, int sig)
-{
- errno = EINVAL;
- return -1;
-}
-
-void _exit (int status)
-{
- _kill(status, -1);
- while (1) {} /* Make sure we hang here */
-}
-
-__attribute__((weak)) int _read(int file, char *ptr, int len)
-{
- int DataIdx;
-
- for (DataIdx = 0; DataIdx < len; DataIdx++)
- {
- *ptr++ = __io_getchar();
- }
-
-return len;
-}
-
-__attribute__((weak)) int _write(int file, char *ptr, int len)
-{
- int DataIdx;
-
- for (DataIdx = 0; DataIdx < len; DataIdx++)
- {
- __io_putchar(*ptr++);
- }
- return len;
-}
-
-caddr_t _sbrk(int incr)
-{
- extern char end asm("end");
- static char *heap_end;
- char *prev_heap_end;
-
- if (heap_end == 0)
- heap_end = &end;
-
- prev_heap_end = heap_end;
- if (heap_end + incr > stack_ptr)
- {
-// write(1, "Heap and stack collision\n", 25);
-// abort();
- errno = ENOMEM;
- return (caddr_t) -1;
- }
-
- heap_end += incr;
-
- return (caddr_t) prev_heap_end;
-}
-
-int _close(int file)
-{
- return -1;
-}
-
-
-int _fstat(int file, struct stat *st)
-{
- st->st_mode = S_IFCHR;
- return 0;
-}
-
-int _isatty(int file)
-{
- return 1;
-}
-
-int _lseek(int file, int ptr, int dir)
-{
- return 0;
-}
-
-int _open(char *path, int flags, ...)
-{
- /* Pretend like we always fail */
- return -1;
-}
-
-int _wait(int *status)
-{
- errno = ECHILD;
- return -1;
-}
-
-int _unlink(char *name)
-{
- errno = ENOENT;
- return -1;
-}
-
-int _times(struct tms *buf)
-{
- return -1;
-}
-
-int _stat(char *file, struct stat *st)
-{
- st->st_mode = S_IFCHR;
- return 0;
-}
-
-int _link(char *old, char *new)
-{
- errno = EMLINK;
- return -1;
-}
-
-int _fork(void)
-{
- errno = EAGAIN;
- return -1;
-}
-
-int _execve(char *name, char **argv, char **env)
-{
- errno = ENOMEM;
- return -1;
-}
+/**
+ ******************************************************************************
+ * @file syscalls.c
+ * @author Auto-generated by STM32CubeIDE
+ * @brief STM32CubeIDE Minimal System calls file
+ *
+ * For more information about which c-functions
+ * need which of these lowlevel functions
+ * please consult the Newlib libc-manual
+ ******************************************************************************
+ * @attention
+ *
+ * Copyright (c) 2021 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
+ *
+ ******************************************************************************
+ */
+
+/* Includes */
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+
+/* Variables */
+extern int __io_putchar(int ch) __attribute__((weak));
+extern int __io_getchar(void) __attribute__((weak));
+
+
+char *__env[1] = { 0 };
+char **environ = __env;
+
+
+/* Functions */
+void initialise_monitor_handles()
+{
+}
+
+int _getpid(void)
+{
+ return 1;
+}
+
+int _kill(int pid, int sig)
+{
+ errno = EINVAL;
+ return -1;
+}
+
+void _exit (int status)
+{
+ _kill(status, -1);
+ while (1) {} /* Make sure we hang here */
+}
+
+__attribute__((weak)) int _read(int file, char *ptr, int len)
+{
+ int DataIdx;
+
+ for (DataIdx = 0; DataIdx < len; DataIdx++)
+ {
+ *ptr++ = __io_getchar();
+ }
+
+return len;
+}
+
+__attribute__((weak)) int _write(int file, char *ptr, int len)
+{
+ int DataIdx;
+
+ for (DataIdx = 0; DataIdx < len; DataIdx++)
+ {
+ __io_putchar(*ptr++);
+ }
+ return len;
+}
+
+int _close(int file)
+{
+ return -1;
+}
+
+
+int _fstat(int file, struct stat *st)
+{
+ st->st_mode = S_IFCHR;
+ return 0;
+}
+
+int _isatty(int file)
+{
+ return 1;
+}
+
+int _lseek(int file, int ptr, int dir)
+{
+ return 0;
+}
+
+int _open(char *path, int flags, ...)
+{
+ /* Pretend like we always fail */
+ return -1;
+}
+
+int _wait(int *status)
+{
+ errno = ECHILD;
+ return -1;
+}
+
+int _unlink(char *name)
+{
+ errno = ENOENT;
+ return -1;
+}
+
+int _times(struct tms *buf)
+{
+ return -1;
+}
+
+int _stat(char *file, struct stat *st)
+{
+ st->st_mode = S_IFCHR;
+ return 0;
+}
+
+int _link(char *old, char *new)
+{
+ errno = EMLINK;
+ return -1;
+}
+
+int _fork(void)
+{
+ errno = EAGAIN;
+ return -1;
+}
+
+int _execve(char *name, char **argv, char **env)
+{
+ errno = ENOMEM;
+ return -1;
+}
diff --git a/Software/VNA_embedded/Src/sysmem.c b/Software/VNA_embedded/Src/sysmem.c
new file mode 100644
index 0000000..4353a47
--- /dev/null
+++ b/Software/VNA_embedded/Src/sysmem.c
@@ -0,0 +1,79 @@
+/**
+ ******************************************************************************
+ * @file sysmem.c
+ * @author Generated by STM32CubeIDE
+ * @brief STM32CubeIDE System Memory calls file
+ *
+ * For more information about which C functions
+ * need which of these lowlevel functions
+ * please consult the newlib libc manual
+ ******************************************************************************
+ * @attention
+ *
+ * Copyright (c) 2021 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
+ *
+ ******************************************************************************
+ */
+
+/* Includes */
+#include
+#include
+
+/**
+ * Pointer to the current high watermark of the heap usage
+ */
+static uint8_t *__sbrk_heap_end = NULL;
+
+/**
+ * @brief _sbrk() allocates memory to the newlib heap and is used by malloc
+ * and others from the C library
+ *
+ * @verbatim
+ * ############################################################################
+ * # .data # .bss # newlib heap # MSP stack #
+ * # # # # Reserved by _Min_Stack_Size #
+ * ############################################################################
+ * ^-- RAM start ^-- _end _estack, RAM end --^
+ * @endverbatim
+ *
+ * This implementation starts allocating at the '_end' linker symbol
+ * The '_Min_Stack_Size' linker symbol reserves a memory for the MSP stack
+ * The implementation considers '_estack' linker symbol to be RAM end
+ * NOTE: If the MSP stack, at any point during execution, grows larger than the
+ * reserved size, please increase the '_Min_Stack_Size'.
+ *
+ * @param incr Memory size
+ * @return Pointer to allocated memory
+ */
+void *_sbrk(ptrdiff_t incr)
+{
+ extern uint8_t _end; /* Symbol defined in the linker script */
+ extern uint8_t _estack; /* Symbol defined in the linker script */
+ extern uint32_t _Min_Stack_Size; /* Symbol defined in the linker script */
+ const uint32_t stack_limit = (uint32_t)&_estack - (uint32_t)&_Min_Stack_Size;
+ const uint8_t *max_heap = (uint8_t *)stack_limit;
+ uint8_t *prev_heap_end;
+
+ /* Initialize heap end at first call */
+ if (NULL == __sbrk_heap_end)
+ {
+ __sbrk_heap_end = &_end;
+ }
+
+ /* Protect heap from growing into the reserved MSP stack */
+ if (__sbrk_heap_end + incr > max_heap)
+ {
+ errno = ENOMEM;
+ return (void *)-1;
+ }
+
+ prev_heap_end = __sbrk_heap_end;
+ __sbrk_heap_end += incr;
+
+ return (void *)prev_heap_end;
+}
diff --git a/Software/VNA_embedded/Src/system_stm32g4xx.c b/Software/VNA_embedded/Src/system_stm32g4xx.c
index 723411b..d20700b 100644
--- a/Software/VNA_embedded/Src/system_stm32g4xx.c
+++ b/Software/VNA_embedded/Src/system_stm32g4xx.c
@@ -53,13 +53,12 @@
******************************************************************************
* @attention
*
- * © Copyright (c) 2017 STMicroelectronics.
- * All rights reserved.
+ * Copyright (c) 2019 STMicroelectronics.
+ * All rights reserved.
*
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
@@ -79,7 +78,7 @@
#include "stm32g4xx.h"
#if !defined (HSE_VALUE)
- #define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */
+ #define HSE_VALUE 24000000U /*!< Value of the External oscillator in Hz */
#endif /* HSE_VALUE */
#if !defined (HSI_VALUE)
@@ -103,11 +102,29 @@
*/
/************************* Miscellaneous Configuration ************************/
-/*!< Uncomment the following line if you need to relocate your vector Table in
- Internal SRAM. */
+/* Note: Following vector table addresses must be defined in line with linker
+ configuration. */
+/*!< Uncomment the following line if you need to relocate the vector table
+ anywhere in Flash or Sram, else the vector table is kept at the automatic
+ remap of boot address selected */
+/* #define USER_VECT_TAB_ADDRESS */
+
+#if defined(USER_VECT_TAB_ADDRESS)
+/*!< Uncomment the following line if you need to relocate your vector Table
+ in Sram else user remap will be done in Flash. */
/* #define VECT_TAB_SRAM */
-#define VECT_TAB_OFFSET 0x00UL /*!< Vector Table base offset field.
- This value must be a multiple of 0x200. */
+#if defined(VECT_TAB_SRAM)
+#define VECT_TAB_BASE_ADDRESS SRAM_BASE /*!< Vector Table base address field.
+ This value must be a multiple of 0x200. */
+#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
+ This value must be a multiple of 0x200. */
+#else
+#define VECT_TAB_BASE_ADDRESS FLASH_BASE /*!< Vector Table base address field.
+ This value must be a multiple of 0x200. */
+#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
+ This value must be a multiple of 0x200. */
+#endif /* VECT_TAB_SRAM */
+#endif /* USER_VECT_TAB_ADDRESS */
/******************************************************************************/
/**
* @}
@@ -167,11 +184,9 @@ void SystemInit(void)
#endif
/* Configure the Vector Table location add offset address ------------------*/
-#ifdef VECT_TAB_SRAM
- SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
-#else
- SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
-#endif
+#if defined(USER_VECT_TAB_ADDRESS)
+ SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
+#endif /* USER_VECT_TAB_ADDRESS */
}
/**
@@ -200,7 +215,7 @@ void SystemInit(void)
* in voltage and temperature.
*
* (***) HSE_VALUE is a constant defined in stm32g4xx_hal.h file (default value
- * 8 MHz), user has to ensure that HSE_VALUE is same as the real
+ * 24 MHz), user has to ensure that HSE_VALUE is same as the real
* frequency of the crystal used. Otherwise, this function may
* have wrong result.
*
@@ -267,5 +282,4 @@ void SystemCoreClockUpdate(void)
* @}
*/
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Software/VNA_embedded/Src/usbpd.c b/Software/VNA_embedded/Src/usbpd.c
deleted file mode 100644
index f577815..0000000
--- a/Software/VNA_embedded/Src/usbpd.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/* USER CODE BEGIN Header */
-/**
- ******************************************************************************
- * @file usbpd.c
- * @author MCD Application Team
- * @brief This file contains the device define.
- ******************************************************************************
- * @attention
- *
- * © Copyright (c) 2020 STMicroelectronics.
- * All rights reserved.
- *
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
- *
- ******************************************************************************
- */
-/* USER CODE END Header */
-
-/* Includes ------------------------------------------------------------------*/
-#include "usbpd.h"
-
-/* USER CODE BEGIN 0 */
-/* USER CODE END 0 */
-
-/* USER CODE BEGIN 1 */
-/* USER CODE END 1 */
-
-/* Global variables ---------------------------------------------------------*/
-
-/* USER CODE BEGIN 2 */
-/* USER CODE END 2 */
-
-/* USBPD init function */
-void MX_USBPD_Init(void)
-{
-
- /* Global Init of USBPD HW */
- USBPD_HW_IF_GlobalHwInit();
-
- /* Initialize the Device Policy Manager */
- if(USBPD_OK != USBPD_DPM_InitCore())
- {
- while(1);
- }
-
- /* Initialise the DPM application */
- if (USBPD_OK != USBPD_DPM_UserInit())
- {
- while(1);
- }
-
- /* USER CODE BEGIN 3 */
- /* USER CODE END 3 */
-
-}
-
-/* USER CODE BEGIN 4 */
-/* USER CODE END 4 */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Software/VNA_embedded/Src/usbpd_dpm_core.c b/Software/VNA_embedded/Src/usbpd_dpm_core.c
deleted file mode 100644
index 990ae22..0000000
--- a/Software/VNA_embedded/Src/usbpd_dpm_core.c
+++ /dev/null
@@ -1,350 +0,0 @@
-/* USER CODE BEGIN Header */
-/**
- ******************************************************************************
- * @file usbpd_dpm_core.c
- * @author MCD Application Team
- * @brief USBPD dpm core file
- ******************************************************************************
- * @attention
- *
- * © Copyright (c) 2020 STMicroelectronics.
- * All rights reserved.
- *
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
- *
- ******************************************************************************
- */
-/* USER CODE END Header */
-
-#define __USBPD_DPM_CORE_C
-
-/* Includes ------------------------------------------------------------------*/
-#include "usbpd_core.h"
-#include "usbpd_trace.h"
-#include "usbpd_dpm_core.h"
-#include "usbpd_dpm_user.h"
-#include "usbpd_dpm_conf.h"
-#include "cmsis_os.h"
-
-/* Private enum */
-enum
-{
- USBPD_THREAD_PORT_0 = USBPD_PORT_0,
-#if USBPD_PORT_COUNT == 2
- USBPD_THREAD_PORT_1 = USBPD_PORT_1,
-#endif
- USBPD_THREAD_CAD
-};
-
-/* Generic STM32 prototypes */
-extern uint32_t HAL_GetTick(void);
-
-/* Private function prototypes -----------------------------------------------*/
-void USBPD_DPM_CADCallback(uint8_t PortNum, USBPD_CAD_EVENT State, CCxPin_TypeDef Cc);
-void USBPD_PE_Task(void const *argument);
-void USBPD_CAD_Task(void const *argument);
-
-static void USBPD_PE_TaskWakeUp(uint8_t PortNum);
-static void USBPD_DPM_CADTaskWakeUp(void);
-
-/* Private typedef -----------------------------------------------------------*/
-osThreadDef(PE_0, USBPD_PE_Task, osPriorityHigh, 0, 200);
-osThreadDef(PE_1, USBPD_PE_Task, osPriorityHigh, 0, 200);
-
-/* Private define ------------------------------------------------------------*/
-#define MAX_TREAD_POWER (USBPD_PORT_COUNT + 1)
-
-#define OSTHREAD_PE(__VAL__) __VAL__==USBPD_PORT_0?osThread(PE_0):osThread(PE_1)
-
-/* Private macro -------------------------------------------------------------*/
-#define CHECK_PE_FUNCTION_CALL(_function_) if(USBPD_OK != _function_) {return USBPD_ERROR;}
-#define CHECK_CAD_FUNCTION_CALL(_function_) if(USBPD_CAD_OK != _function_) {return USBPD_ERROR;}
-
-#if defined(_DEBUG_TRACE)
-#define DPM_CORE_DEBUG_TRACE(_PORTNUM_, __MESSAGE__) USBPD_TRACE_Add(USBPD_TRACE_DEBUG, _PORTNUM_, 0u, (uint8_t *)(__MESSAGE__), sizeof(__MESSAGE__) - 1u);
-#else
-#define DPM_CORE_DEBUG_TRACE(_PORTNUM_, __MESSAGE__)
-#endif /* _DEBUG_TRACE */
-
-/* Private variables ---------------------------------------------------------*/
-static uint32_t DPM_Sleep_time[MAX_TREAD_POWER];
-static osThreadId DPM_Thread_Table[MAX_TREAD_POWER];
-osMessageQDef(queuePE, 2, uint16_t);
-osMessageQDef(queueCAD, 1, uint16_t);
-static osMessageQId PEQueueId[USBPD_PORT_COUNT], CADQueueId;
-
-USBPD_ParamsTypeDef DPM_Params[USBPD_PORT_COUNT];
-
-/* Private functions ---------------------------------------------------------*/
-static void DPM_ManageAttachedState(uint8_t PortNum, USBPD_CAD_EVENT State, CCxPin_TypeDef Cc);
-
-/**
- * @brief Initialize the core stack (port power role, PWR_IF, CAD and PE Init procedures)
- * @retval USBPD status
- */
-USBPD_StatusTypeDef USBPD_DPM_InitCore(void)
-{
-/* variable to get dynamique memory allocated by usbpd stack */
- uint32_t stack_dynamemsize;
-
-static const USBPD_PE_Callbacks dpmCallbacks =
-{
- NULL,
- NULL,
- USBPD_DPM_EvaluatePowerRoleSwap,
- USBPD_DPM_Notification,
- NULL,
- USBPD_DPM_GetDataInfo,
- USBPD_DPM_SetDataInfo,
- NULL,
- USBPD_DPM_SNK_EvaluateCapabilities,
- NULL,
- USBPD_PE_TaskWakeUp,
- NULL,
- NULL,
- NULL,
- USBPD_DPM_EvaluateDataRoleSwap,
- USBPD_DPM_IsPowerReady
-};
-
- static const USBPD_CAD_Callbacks CAD_cbs = { USBPD_DPM_CADCallback, USBPD_DPM_CADTaskWakeUp };
-
- /* Check the lib selected */
- if( USBPD_TRUE != USBPD_PE_CheckLIB(_LIB_ID))
- {
- return USBPD_ERROR;
- }
-
- /* to get how much memory are dynamically allocated by the stack
- the memory return is corresponding to 2 ports so if the application
- managed only one port divide the value return by 2 */
- stack_dynamemsize = USBPD_PE_GetMemoryConsumption();
-
- /* done to avoid warning */
- stack_dynamemsize--;
-
- /* Variable to be sure that DPM is correctly initialized */
- DPM_Params[USBPD_PORT_0].DPM_Initialized = USBPD_FALSE;
-#if USBPD_PORT_COUNT == 2
- DPM_Params[USBPD_PORT_1].DPM_Initialized = USBPD_FALSE;
-#endif /* USBPD_PORT_COUNT == 2 */
-
- /* check the stack settings */
- DPM_Params[USBPD_PORT_0].PE_SpecRevision = DPM_Settings[USBPD_PORT_0].PE_SpecRevision;
- DPM_Params[USBPD_PORT_0].PE_PowerRole = DPM_Settings[USBPD_PORT_0].PE_DefaultRole;
- DPM_Params[USBPD_PORT_0].PE_SwapOngoing = USBPD_FALSE;
- DPM_Params[USBPD_PORT_0].ActiveCCIs = CCNONE;
- DPM_Params[USBPD_PORT_0].VconnCCIs = CCNONE;
- DPM_Params[USBPD_PORT_0].VconnStatus = USBPD_FALSE;
-#if USBPD_PORT_COUNT == 2
- DPM_Params[USBPD_PORT_1].PE_SpecRevision = DPM_Settings[USBPD_PORT_1].PE_SpecRevision;
- DPM_Params[USBPD_PORT_1].PE_PowerRole = DPM_Settings[USBPD_PORT_1].PE_DefaultRole;
- DPM_Params[USBPD_PORT_1].PE_SwapOngoing = USBPD_FALSE;
- DPM_Params[USBPD_PORT_1].ActiveCCIs = CCNONE;
- DPM_Params[USBPD_PORT_1].VconnCCIs = CCNONE;
- DPM_Params[USBPD_PORT_1].VconnStatus = USBPD_FALSE;
-#endif /* USBPD_PORT_COUNT == 2 */
-
- /* CAD SET UP : Port 0 */
- CHECK_CAD_FUNCTION_CALL(USBPD_CAD_Init(USBPD_PORT_0, (USBPD_CAD_Callbacks *)&CAD_cbs, (USBPD_SettingsTypeDef *)&DPM_Settings[USBPD_PORT_0], &DPM_Params[USBPD_PORT_0]));
-#if USBPD_PORT_COUNT == 2
- CHECK_CAD_FUNCTION_CALL(USBPD_CAD_Init(USBPD_PORT_1, (USBPD_CAD_Callbacks *)&CAD_cbs, (USBPD_SettingsTypeDef *)&DPM_Settings[USBPD_PORT_1], &DPM_Params[USBPD_PORT_1]));
-#endif /* USBPD_PORT_COUNT == 2 */
-
- /* PE SET UP : Port 0 */
- CHECK_PE_FUNCTION_CALL(USBPD_PE_Init(USBPD_PORT_0, (USBPD_SettingsTypeDef *)&DPM_Settings[USBPD_PORT_0], &DPM_Params[USBPD_PORT_0], &dpmCallbacks));
-#if USBPD_PORT_COUNT == 2
- CHECK_PE_FUNCTION_CALL(USBPD_PE_Init(USBPD_PORT_1, (USBPD_SettingsTypeDef *)&DPM_Settings[USBPD_PORT_1], &DPM_Params[USBPD_PORT_1], &dpmCallbacks));
-#endif /* USBPD_PORT_COUNT == 2 */
-
- /* DPM is correctly initialized */
- DPM_Params[USBPD_PORT_0].DPM_Initialized = USBPD_TRUE;
-#if USBPD_PORT_COUNT == 2
- DPM_Params[USBPD_PORT_1].DPM_Initialized = USBPD_TRUE;
-#endif /* USBPD_PORT_COUNT == 2 */
-
- /* Enable CAD on Port 0 */
- USBPD_CAD_PortEnable(USBPD_PORT_0, USBPD_CAD_ENABLE);
-#if USBPD_PORT_COUNT == 2
- USBPD_CAD_PortEnable(USBPD_PORT_1, USBPD_CAD_ENABLE);
-#endif /* USBPD_PORT_COUNT == 2 */
-
- return USBPD_OK;
-}
-
-/**
- * @brief Initialize the OS parts (task, queue,... )
- * @retval USBPD status
- */
-USBPD_StatusTypeDef USBPD_DPM_InitOS(void)
-{
- osThreadDef(CAD, USBPD_CAD_Task, osPriorityRealtime, 0, 300);
- if((DPM_Thread_Table[USBPD_THREAD_CAD] = osThreadCreate(osThread(CAD), NULL)) == NULL)
- {
- return USBPD_ERROR;
- }
- CADQueueId = osMessageCreate(osMessageQ(queueCAD), NULL);
-
- /* Create the queue corresponding to PE task */
- PEQueueId[0] = osMessageCreate(osMessageQ(queuePE), NULL);
-#if USBPD_PORT_COUNT == 2
- PEQueueId[1] = osMessageCreate(osMessageQ(queuePE), NULL);
-#endif /* USBPD_PORT_COUNT == 2 */
-
- /* PE task to be created on attachment */
- DPM_Thread_Table[USBPD_THREAD_PORT_0] = NULL;
-#if USBPD_PORT_COUNT == 2
- DPM_Thread_Table[USBPD_THREAD_PORT_1] = NULL;
-#endif /* USBPD_PORT_COUNT == 2 */
-
- return USBPD_OK;
-}
-
-/**
- * @brief Initialize the OS parts (port power role, PWR_IF, CAD and PE Init procedures)
- * @retval None
- */
-void USBPD_DPM_Run(void)
-{
- osKernelStart();
-}
-
-/**
- * @brief Initialize DPM (port power role, PWR_IF, CAD and PE Init procedures)
- * @retval USBPD status
- */
-void USBPD_DPM_TimerCounter(void)
-{
- /* Call PE/PRL timers functions only if DPM is initialized */
- if (USBPD_TRUE == DPM_Params[USBPD_PORT_0].DPM_Initialized)
- {
- USBPD_DPM_UserTimerCounter(USBPD_PORT_0);
- USBPD_PE_TimerCounter(USBPD_PORT_0);
- USBPD_PRL_TimerCounter(USBPD_PORT_0);
- }
-#if USBPD_PORT_COUNT==2
- if (USBPD_TRUE == DPM_Params[USBPD_PORT_1].DPM_Initialized)
- {
- USBPD_DPM_UserTimerCounter(USBPD_PORT_1);
- USBPD_PE_TimerCounter(USBPD_PORT_1);
- USBPD_PRL_TimerCounter(USBPD_PORT_1);
- }
-#endif /* USBPD_PORT_COUNT == 2 */
-
-}
-
-/**
- * @brief WakeUp PE task
- * @param PortNum port number
- * @retval None
- */
-static void USBPD_PE_TaskWakeUp(uint8_t PortNum)
-{
- osMessagePut(PEQueueId[PortNum], 0xFFFF, 0);
-}
-
-/**
- * @brief WakeUp CAD task
- * @retval None
- */
-static void USBPD_DPM_CADTaskWakeUp(void)
-{
- osMessagePut(CADQueueId, 0xFFFF, 0);
-}
-
-/**
- * @brief Main task for PE layer
- * @param argument Not used
- * @retval None
- */
-void USBPD_PE_Task(void const *argument)
-{
- uint8_t _port = (uint32_t)argument;
-
- for(;;)
- {
- DPM_Sleep_time[_port] =
- USBPD_PE_StateMachine_SNK(_port);
- osMessageGet(PEQueueId[_port], DPM_Sleep_time[_port]);
-
- }
-}
-
-/**
- * @brief Main task for CAD layer
- * @param argument Not used
- * @retval None
- */
-void USBPD_CAD_Task(void const *argument)
-{
- for(;;)
- {
- DPM_Sleep_time[USBPD_THREAD_CAD] = USBPD_CAD_Process();
- osMessageGet(CADQueueId, DPM_Sleep_time[USBPD_THREAD_CAD]);
- }
-}
-
-/**
- * @brief CallBack reporting events on a specified port from CAD layer.
- * @param PortNum The handle of the port
- * @param State CAD state
- * @param Cc The Communication Channel for the USBPD communication
- * @retval None
- */
-void USBPD_DPM_CADCallback(uint8_t PortNum, USBPD_CAD_EVENT State, CCxPin_TypeDef Cc)
-{
-
- switch(State)
- {
- case USBPD_CAD_EVENT_ATTEMC :
- {
- DPM_ManageAttachedState(PortNum, State, Cc);
- break;
- }
- case USBPD_CAD_EVENT_ATTACHED :
- DPM_ManageAttachedState(PortNum, State, Cc);
- break;
- case USBPD_CAD_EVENT_DETACHED :
- case USBPD_CAD_EVENT_EMC :
- {
- /* The ufp is detached */
- (void)USBPD_PE_IsCableConnected(PortNum, 0);
- /* Terminate PE task */
- if (DPM_Thread_Table[PortNum] != NULL)
- {
- osThreadTerminate(DPM_Thread_Table[PortNum]);
- DPM_Thread_Table[PortNum] = NULL;
- }
- USBPD_DPM_UserCableDetection(PortNum, State);
- DPM_Params[PortNum].ActiveCCIs = CCNONE;
- DPM_Params[PortNum].PE_Power = USBPD_POWER_NO;
- break;
- }
- default :
- /* nothing to do */
- break;
- }
-}
-
-static void DPM_ManageAttachedState(uint8_t PortNum, USBPD_CAD_EVENT State, CCxPin_TypeDef Cc)
-{
- DPM_Params[PortNum].ActiveCCIs = Cc;
- (void)USBPD_PE_IsCableConnected(PortNum, 1);
-
- USBPD_DPM_UserCableDetection(PortNum, State);
-
- /* Create PE task */
- if (DPM_Thread_Table[PortNum] == NULL)
- {
- DPM_Thread_Table[PortNum] = osThreadCreate(OSTHREAD_PE(PortNum), (void *)((uint32_t)PortNum));
- if (DPM_Thread_Table[PortNum] == NULL)
- {
- /* should not occurr. May be an issue with FreeRTOS heap size too small */
- while(1);
- }
- }
-}
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Software/VNA_embedded/Src/usbpd_dpm_user.c b/Software/VNA_embedded/Src/usbpd_dpm_user.c
deleted file mode 100644
index 09f6cd9..0000000
--- a/Software/VNA_embedded/Src/usbpd_dpm_user.c
+++ /dev/null
@@ -1,405 +0,0 @@
-/* USER CODE BEGIN Header */
-/**
- ******************************************************************************
- * @file usbpd_dpm_user.c
- * @author MCD Application Team
- * @brief USBPD DPM user code
- ******************************************************************************
- * @attention
- *
- * © Copyright (c) 2020 STMicroelectronics.
- * All rights reserved.
- *
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
- *
- ******************************************************************************
- */
-/* USER CODE END Header */
-
-#define USBPD_DPM_USER_C
-/* Includes ------------------------------------------------------------------*/
-#include "usbpd_core.h"
-#include "usbpd_pdo_defs.h"
-#include "usbpd_dpm_core.h"
-#include "usbpd_dpm_conf.h"
-#include "usbpd_dpm_user.h"
-#include "usbpd_vdm_user.h"
-#include "usbpd_trace.h"
-#include "usbpd_pwr_if.h"
-#include "string.h"
-#include "cmsis_os.h"
-#include "usbpd_pwr_user.h"
-
-/** @addtogroup STM32_USBPD_APPLICATION
- * @{
- */
-
-/** @addtogroup STM32_USBPD_APPLICATION_DPM_USER
- * @{
- */
-
-/* Private typedef -----------------------------------------------------------*/
-/* USER CODE BEGIN Private_Typedef */
-
-/* USER CODE END Private_Typedef */
-
-/* Private define ------------------------------------------------------------*/
-/** @defgroup USBPD_USER_PRIVATE_DEFINES USBPD USER Private Defines
- * @{
- */
-/* USER CODE BEGIN Private_Define */
-
-/* USER CODE END Private_Define */
-/**
- * @}
- */
-
-/* Private macro -------------------------------------------------------------*/
-/** @defgroup USBPD_USER_PRIVATE_MACROS USBPD USER Private Macros
- * @{
- */
-/* USER CODE BEGIN Private_Macro */
-
-/* USER CODE END Private_Macro */
-/**
- * @}
- */
-
-/* Private variables ---------------------------------------------------------*/
-/** @defgroup USBPD_USER_PRIVATE_VARIABLES USBPD USER Private Variables
- * @{
- */
-/* USER CODE BEGIN Private_Variables */
-
-/* USER CODE END Private_Variables */
-/**
- * @}
- */
-
-/* Private function prototypes -----------------------------------------------*/
-/** @defgroup USBPD_USER_PRIVATE_FUNCTIONS USBPD USER Private Functions
- * @{
- */
-/* USER CODE BEGIN USBPD_USER_PRIVATE_FUNCTIONS_Prototypes */
-
-/* USER CODE END USBPD_USER_PRIVATE_FUNCTIONS_Prototypes */
-/**
- * @}
- */
-
-/* Exported functions ------- ------------------------------------------------*/
-/** @defgroup USBPD_USER_EXPORTED_FUNCTIONS USBPD USER Exported Functions
- * @{
- */
-/* USER CODE BEGIN USBPD_USER_EXPORTED_FUNCTIONS */
-
-/* USER CODE END USBPD_USER_EXPORTED_FUNCTIONS */
-
-/** @defgroup USBPD_USER_EXPORTED_FUNCTIONS_GROUP1 USBPD USER Exported Functions called by DPM CORE
- * @{
- */
-/* USER CODE BEGIN USBPD_USER_EXPORTED_FUNCTIONS_GROUP1 */
-
-/* USER CODE END USBPD_USER_EXPORTED_FUNCTIONS_GROUP1 */
-
-/**
- * @brief Initialize DPM (port power role, PWR_IF, CAD and PE Init procedures)
- * @retval USBPD Status
- */
-USBPD_StatusTypeDef USBPD_DPM_UserInit(void)
-{
-/* USER CODE BEGIN USBPD_DPM_UserInit */
- return USBPD_OK;
-/* USER CODE END USBPD_DPM_UserInit */
-}
-
-/**
- * @brief User delay implementation which is OS dependant
- * @param Time time in ms
- * @retval None
- */
-void USBPD_DPM_WaitForTime(uint32_t Time)
-{
-/* USER CODE BEGIN USBPD_DPM_WaitForTime */
-#ifdef _RTOS
- osDelay(Time);
-#else
- HAL_Delay(Time);
-#endif
-/* USER CODE END USBPD_DPM_WaitForTime */
-}
-
-/**
- * @brief User processing time, it is recommended to avoid blocking task for long time
- * @param argument DPM User event
- * @retval None
- */
-void USBPD_DPM_UserExecute(void const *argument)
-{
-/* USER CODE BEGIN USBPD_DPM_UserExecute */
-
-/* USER CODE END USBPD_DPM_UserExecute */
-}
-
-/**
- * @brief UserCableDetection reporting events on a specified port from CAD layer.
- * @param PortNum The handle of the port
- * @param State CAD state
- * @retval None
- */
-void USBPD_DPM_UserCableDetection(uint8_t PortNum, USBPD_CAD_EVENT State)
-{
-/* USER CODE BEGIN USBPD_DPM_UserCableDetection */
-
-/* USER CODE END USBPD_DPM_UserCableDetection */
-}
-
-/**
- * @brief function used to manage user timer.
- * @param PortNum Port number
- * @retval None
- */
-void USBPD_DPM_UserTimerCounter(uint8_t PortNum)
-{
-/* USER CODE BEGIN USBPD_DPM_UserTimerCounter */
-
-/* USER CODE END USBPD_DPM_UserTimerCounter */
-}
-
-/**
- * @}
- */
-
-/** @defgroup USBPD_USER_EXPORTED_FUNCTIONS_GROUP2 USBPD USER Exported Callbacks functions called by PE
- * @{
- */
-
-/**
- * @brief Callback function called by PE layer when HardReset message received from PRL
- * @param PortNum The current port number
- * @param CurrentRole the current role
- * @param Status status on hard reset event
- * @retval None
- */
-void USBPD_DPM_HardReset(uint8_t PortNum, USBPD_PortPowerRole_TypeDef CurrentRole, USBPD_HR_Status_TypeDef Status)
-{
-/* USER CODE BEGIN USBPD_DPM_HardReset */
-
-/* USER CODE END USBPD_DPM_HardReset */
-}
-
-/**
- * @brief Request the DPM to setup the new power level.
- * @param PortNum The current port number
- * @retval USBPD status
- */
-USBPD_StatusTypeDef USBPD_DPM_SetupNewPower(uint8_t PortNum)
-{
-/* USER CODE BEGIN USBPD_DPM_SetupNewPower */
- return USBPD_PWR_IF_SetProfile(PortNum);
-/* USER CODE END USBPD_DPM_SetupNewPower */
-}
-
-/**
- * @brief Evaluate the swap request from PE.
- * @param PortNum The current port number
- * @retval USBPD_ACCEPT, USBPD_WAIT, USBPD_REJECT
- */
-USBPD_StatusTypeDef USBPD_DPM_EvaluatePowerRoleSwap(uint8_t PortNum)
-{
-/* USER CODE BEGIN USBPD_DPM_EvaluatePowerRoleSwap */
- return USBPD_REJECT;
-/* USER CODE END USBPD_DPM_EvaluatePowerRoleSwap */
-}
-
-/**
- * @brief Callback function called by PE to inform DPM about PE event.
- * @param PortNum The current port number
- * @param EventVal @ref USBPD_NotifyEventValue_TypeDef
- * @retval None
- */
-void USBPD_DPM_Notification(uint8_t PortNum, USBPD_NotifyEventValue_TypeDef EventVal)
-{
-/* USER CODE BEGIN USBPD_DPM_Notification */
-
-/* USER CODE END USBPD_DPM_Notification */
-}
-
-/**
- * @brief DPM callback to allow PE to retrieve information from DPM/PWR_IF.
- * @param PortNum Port number
- * @param DataId Type of data to be updated in DPM based on @ref USBPD_CORE_DataInfoType_TypeDef
- * @param Ptr Pointer on address where DPM data should be written (u8 pointer)
- * @param Size Pointer on nb of u8 written by DPM
- * @retval None
- */
-void USBPD_DPM_GetDataInfo(uint8_t PortNum, USBPD_CORE_DataInfoType_TypeDef DataId, uint8_t *Ptr, uint32_t *Size)
-{
-/* USER CODE BEGIN USBPD_DPM_GetDataInfo */
-
-/* USER CODE END USBPD_DPM_GetDataInfo */
-}
-
-/**
- * @brief DPM callback to allow PE to update information in DPM/PWR_IF.
- * @param PortNum Port number
- * @param DataId Type of data to be updated in DPM based on @ref USBPD_CORE_DataInfoType_TypeDef
- * @param Ptr Pointer on the data
- * @param Size Nb of bytes to be updated in DPM
- * @retval None
- */
-void USBPD_DPM_SetDataInfo(uint8_t PortNum, USBPD_CORE_DataInfoType_TypeDef DataId, uint8_t *Ptr, uint32_t Size)
-{
-/* USER CODE BEGIN USBPD_DPM_SetDataInfo */
-
-/* USER CODE END USBPD_DPM_SetDataInfo */
-}
-
-/**
- * @brief Evaluate received Request Message from Sink port
- * @param PortNum Port number
- * @param PtrPowerObject Pointer on the power data object
- * @retval USBPD status : USBPD_ACCEPT, USBPD_REJECT, USBPD_WAIT, USBPD_GOTOMIN
- */
-USBPD_StatusTypeDef USBPD_DPM_EvaluateRequest(uint8_t PortNum, USBPD_CORE_PDO_Type_TypeDef *PtrPowerObject)
-{
-/* USER CODE BEGIN USBPD_DPM_EvaluateRequest */
- return USBPD_REJECT;
-/* USER CODE END USBPD_DPM_EvaluateRequest */
-}
-
-/**
- * @brief Evaluate received Capabilities Message from Source port and prepare the request message
- * @param PortNum Port number
- * @param PtrRequestData Pointer on selected request data object
- * @param PtrPowerObjectType Pointer on the power data object
- * @retval None
- */
-void USBPD_DPM_SNK_EvaluateCapabilities(uint8_t PortNum, uint32_t *PtrRequestData, USBPD_CORE_PDO_Type_TypeDef *PtrPowerObjectType)
-{
-/* USER CODE BEGIN USBPD_DPM_SNK_EvaluateCapabilities */
-
-/* USER CODE END USBPD_DPM_SNK_EvaluateCapabilities */
-}
-
-/**
- * @brief Power role swap status update
- * @param PortNum Port number
- * @param CurrentRole the current role
- * @param Status status on power role swap event
- */
-void USBPD_DPM_PowerRoleSwap(uint8_t PortNum, USBPD_PortPowerRole_TypeDef CurrentRole, USBPD_PRS_Status_TypeDef Status)
-{
-/* USER CODE BEGIN USBPD_DPM_PowerRoleSwap */
-
-/* USER CODE END USBPD_DPM_PowerRoleSwap */
-}
-
-/**
- * @brief Callback to be used by PE to evaluate a Vconn swap
- * @param PortNum Port number
- * @retval USBPD_ACCEPT, USBPD_REJECT, USBPD_WAIT
- */
-USBPD_StatusTypeDef USBPD_DPM_EvaluateVconnSwap(uint8_t PortNum)
-{
-/* USER CODE BEGIN USBPD_DPM_EvaluateVconnSwap */
- return USBPD_REJECT;
-/* USER CODE END USBPD_DPM_EvaluateVconnSwap */
-}
-
-/**
- * @brief Callback to be used by PE to manage VConn
- * @param PortNum Port number
- * @param State Enable or Disable VConn on CC lines
- * @retval USBPD_ACCEPT, USBPD_REJECT
- */
-USBPD_StatusTypeDef USBPD_DPM_PE_VconnPwr(uint8_t PortNum, USBPD_FunctionalState State)
-{
-/* USER CODE BEGIN USBPD_DPM_PE_VconnPwr */
- return USBPD_ERROR;
-/* USER CODE END USBPD_DPM_PE_VconnPwr */
-}
-
-/**
- * @brief DPM callback to allow PE to forward extended message information.
- * @param PortNum Port number
- * @param MsgType Type of message to be handled in DPM
- * This parameter can be one of the following values:
- * @arg @ref USBPD_EXT_SECURITY_REQUEST Security Request extended message
- * @arg @ref USBPD_EXT_SECURITY_RESPONSE Security Response extended message
- * @param ptrData Pointer on address Extended Message data could be read (u8 pointer)
- * @param DataSize Nb of u8 that compose Extended message
- * @retval None
- */
-void USBPD_DPM_ExtendedMessageReceived(uint8_t PortNum, USBPD_ExtendedMsg_TypeDef MsgType, uint8_t *ptrData, uint16_t DataSize)
-{
-/* USER CODE BEGIN USBPD_DPM_ExtendedMessageReceived */
-
-/* USER CODE END USBPD_DPM_ExtendedMessageReceived */
-}
-
-/**
- * @brief DPM callback used to know user choice about Data Role Swap.
- * @param PortNum Port number
- * @retval USBPD_REJECT, UBPD_ACCEPT
- */
-USBPD_StatusTypeDef USBPD_DPM_EvaluateDataRoleSwap(uint8_t PortNum)
-{
-/* USER CODE BEGIN USBPD_DPM_EvaluateDataRoleSwap */
- return USBPD_REJECT;
-/* USER CODE END USBPD_DPM_EvaluateDataRoleSwap */
-}
-
-/**
- * @brief Callback to be used by PE to check is VBUS is ready or present
- * @param PortNum Port number
- * @param Vsafe Vsafe status based on @ref USBPD_VSAFE_StatusTypeDef
- * @retval USBPD_DISABLE or USBPD_ENABLE
- */
-USBPD_FunctionalState USBPD_DPM_IsPowerReady(uint8_t PortNum, USBPD_VSAFE_StatusTypeDef Vsafe)
-{
-/* USER CODE BEGIN USBPD_DPM_IsPowerReady */
- return ((USBPD_OK == USBPD_PWR_IF_SupplyReady(PortNum, Vsafe)) ? USBPD_ENABLE : USBPD_DISABLE);
-/* USER CODE END USBPD_DPM_IsPowerReady */
-}
-
-/**
- * @}
- */
-
-/** @defgroup USBPD_USER_EXPORTED_FUNCTIONS_GROUP3 USBPD USER Functions PD messages requests
- * @{
- */
-
-/**
- * @}
- */
-
-/** @addtogroup USBPD_USER_PRIVATE_FUNCTIONS
- * @{
- */
-
-/* USER CODE BEGIN USBPD_USER_PRIVATE_FUNCTIONS */
-
-/* USER CODE END USBPD_USER_PRIVATE_FUNCTIONS */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Software/VNA_embedded/Src/usbpd_pwr_if.c b/Software/VNA_embedded/Src/usbpd_pwr_if.c
deleted file mode 100644
index 32f510a..0000000
--- a/Software/VNA_embedded/Src/usbpd_pwr_if.c
+++ /dev/null
@@ -1,341 +0,0 @@
-/* USER CODE BEGIN Header */
-/**
- ******************************************************************************
- * @file usbpd_pwr_if.c
- * @author MCD Application Team
- * @brief This file contains power interface control functions.
- ******************************************************************************
- * @attention
- *
- * © Copyright (c) 2020 STMicroelectronics.
- * All rights reserved.
- *
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
- *
- ******************************************************************************
- */
-/* USER CODE END Header */
-
-#define __USBPD_PWR_IF_C
-
-/* Includes ------------------------------------------------------------------*/
-#include "usbpd_pwr_if.h"
-#include "usbpd_hw_if.h"
-#include "usbpd_pwr_if.h"
-#include "usbpd_dpm_core.h"
-#include "usbpd_dpm_conf.h"
-#include "usbpd_pdo_defs.h"
-#include "usbpd_core.h"
-#include "usbpd_trace.h"
-
-/* USER CODE BEGIN Include */
-
-/* USER CODE END Include */
-
-/** @addtogroup STM32_USBPD_APPLICATION
- * @{
- */
-
-/** @addtogroup STM32_USBPD_APPLICATION_POWER_IF
- * @{
- */
-
-/* Private typedef -----------------------------------------------------------*/
-/* USER CODE BEGIN Private_Typedef */
-
-/* USER CODE END Private_Typedef */
-
-/* Private define ------------------------------------------------------------*/
-/** @addtogroup STM32_USBPD_APPLICATION_POWER_IF_Private_Defines
- * @{
- */
-/* USER CODE BEGIN Private_Define */
-
-/* USER CODE END Private_Define */
-/**
- * @}
- */
-
-/* Private macros ------------------------------------------------------------*/
-/** @addtogroup STM32_USBPD_APPLICATION_POWER_IF_Private_Macros
- * @{
- */
-/* USER CODE BEGIN Private_Macro */
-
-/* USER CODE END Private_Macro */
-/**
- * @}
- */
-
-/* Private variables ---------------------------------------------------------*/
-/** @addtogroup STM32_USBPD_APPLICATION_POWER_IF_Private_Variables
- * @{
- */
-/* USER CODE BEGIN Private_Variables */
-
-/* USER CODE END Private_Variables */
-
-/**
- * @}
- */
-
-/* Private function prototypes -----------------------------------------------*/
-/** @addtogroup STM32_USBPD_APPLICATION_POWER_IF_Private_Functions
- * @{
- */
-
-/* USER CODE BEGIN USBPD_USER_PRIVATE_FUNCTIONS_Prototypes */
-
-/* Functions to initialize Source PDOs */
-uint32_t _PWR_SRCFixedPDO(float _C_, float _V_,
- USBPD_CORE_PDO_PeakCurr_TypeDef _PK_,
- USBPD_CORE_PDO_DRDataSupport_TypeDef DRDSupport,
- USBPD_CORE_PDO_USBCommCapable_TypeDef UsbCommCapable,
- USBPD_CORE_PDO_ExtPowered_TypeDef ExtPower,
- USBPD_CORE_PDO_USBSuspendSupport_TypeDef UsbSuspendSupport,
- USBPD_CORE_PDO_DRPowerSupport_TypeDef DRPSupport);
-
-uint32_t _PWR_SRCVariablePDO(float _MAXV_, float _MINV_, float _C_);
-
-uint32_t _PWR_SRCBatteryPDO(float _MAXV_,float _MINV_,float _PWR_);
-/* Functions to initialize Sink PDOs */
-
-uint32_t _PWR_SNKFixedPDO(float _C_, float _V_,
- USBPD_CORE_PDO_DRDataSupport_TypeDef DRDSupport,
- USBPD_CORE_PDO_USBCommCapable_TypeDef UsbCommCapable,
- USBPD_CORE_PDO_ExtPowered_TypeDef ExtPower,
- USBPD_CORE_PDO_HigherCapability_TypeDef HigherCapab,
- USBPD_CORE_PDO_DRPowerSupport_TypeDef DRPSupport);
-
-uint32_t _PWR_SNKVariablePDO(float _MAXV_,float _MINV_,float _C_);
-
-uint32_t _PWR_SNKBatteryPDO(float _MAXV_,float _MINV_,float _PWR_);
-
-/* USER CODE END USBPD_USER_PRIVATE_FUNCTIONS_Prototypes */
-
-/**
- * @}
- */
-
-/** @addtogroup STM32_USBPD_APPLICATION_POWER_IF_Exported_Functions
- * @{
- */
-
-/**
- * @brief Initialize structures and variables related to power board profiles
- * used by Sink and Source, for all available ports.
- * @retval USBPD status
-*/
-USBPD_StatusTypeDef USBPD_PWR_IF_Init(void)
-{
-/* USER CODE BEGIN USBPD_PWR_IF_Init */
- return USBPD_ERROR;
-/* USER CODE END USBPD_PWR_IF_Init */
-}
-
-/**
- * @brief Sets the required power profile, now it works only with Fixed ones
- * @param PortNum Port number
- * @retval USBPD status
-*/
-USBPD_StatusTypeDef USBPD_PWR_IF_SetProfile(uint8_t PortNum)
-{
-/* USER CODE BEGIN USBPD_PWR_IF_SetProfile */
- return USBPD_ERROR;
-/* USER CODE END USBPD_PWR_IF_SetProfile */
-}
-
-/**
- * @brief Resets the Power Board
- * @retval USBPD status
-*/
-USBPD_StatusTypeDef USBPD_PWR_IF_PowerResetGlobal(void)
-{
-/* USER CODE BEGIN USBPD_PWR_IF_PowerResetGlobal */
- return USBPD_ERROR;
-/* USER CODE END USBPD_PWR_IF_PowerResetGlobal */
-}
-
-/**
- * @brief Resets the Power on a specified port
- * @param PortNum Port number
- * @retval USBPD status
-*/
-USBPD_StatusTypeDef USBPD_PWR_IF_PowerReset(uint8_t PortNum)
-{
-/* USER CODE BEGIN USBPD_PWR_IF_PowerReset */
- return USBPD_ERROR;
-/* USER CODE END USBPD_PWR_IF_PowerReset */
-}
-
-/**
- * @brief Checks if the power on a specified port is ready
- * @param PortNum Port number
- * @param Vsafe Vsafe status based on @ref USBPD_VSAFE_StatusTypeDef
- * @retval USBPD status
-*/
-USBPD_StatusTypeDef USBPD_PWR_IF_SupplyReady(uint8_t PortNum, USBPD_VSAFE_StatusTypeDef Vsafe)
-{
-/* USER CODE BEGIN USBPD_PWR_IF_SupplyReady */
- return USBPD_ERROR;
-/* USER CODE END USBPD_PWR_IF_SupplyReady */
-}
-
-/**
- * @brief Enables VBUS power on a specified port
- * @param PortNum Port number
- * @retval USBPD status
-*/
-USBPD_StatusTypeDef USBPD_PWR_IF_VBUSEnable(uint8_t PortNum)
-{
-/* USER CODE BEGIN USBPD_PWR_IF_VBUSEnable */
- return USBPD_ERROR;
-/* USER CODE END USBPD_PWR_IF_VBUSEnable */
-}
-
-/**
- * @brief Disbale VBUS/VCONN the power on a specified port
- * @param PortNum Port number
- * @retval USBPD status
-*/
-USBPD_StatusTypeDef USBPD_PWR_IF_VBUSDisable(uint8_t PortNum)
-{
-/* USER CODE BEGIN USBPD_PWR_IF_VBUSDisable */
- return USBPD_ERROR;
-/* USER CODE END USBPD_PWR_IF_VBUSDisable */
-}
-
-/**
- * @brief Disable the SNK to stop current consumption
- * @param PortNum Port number
- * @retval USBPD status
- */
-USBPD_StatusTypeDef USBPD_PWR_IF_SNKDisable(uint8_t PortNum)
-{
-/* USER CODE BEGIN USBPD_PWR_IF_SNKDisable */
- return USBPD_ERROR;
-/* USER CODE END USBPD_PWR_IF_SNKDisable */
-}
-
-/**
- * @brief Initialize power on a specified port
- * @param PortNum Port number
- * @retval USBPD status
- */
-USBPD_StatusTypeDef USBPD_PWR_IF_InitPower(uint8_t PortNum)
-{
- return USBPD_OK;
-}
-
-/**
- * @brief Checks if the power on a specified port is enabled
- * @param PortNum Port number
- * @retval USBPD_ENABLE or USBPD_DISABLE
-*/
-USBPD_FunctionalState USBPD_PWR_IF_VBUSIsEnabled(uint8_t PortNum)
-{
- /* Get the Status of the port */
- return USBPD_PORT_IsValid(PortNum) ? (USBPD_FunctionalState)HW_IF_PWR_VBUSIsEnabled(PortNum) : USBPD_DISABLE;
-}
-
-/**
- * @brief Reads the voltage and the current on a specified port
- * @param PortNum Port number
- * @param pVoltage: The Voltage in mV
- * @param pCurrent: The Current in mA
- * @retval USBPD_ERROR or USBPD_OK
-*/
-USBPD_StatusTypeDef USBPD_PWR_IF_ReadVA(uint8_t PortNum, uint16_t *pVoltage, uint16_t *pCurrent)
-{
-/* USER CODE BEGIN USBPD_PWR_IF_ReadVA */
- return USBPD_ERROR;
-/* USER CODE END USBPD_PWR_IF_ReadVA */
-}
-
-/**
- * @brief Enables the VConn on the port.
- * @param PortNum Port number
- * @param CC Specifies the CCx to be selected based on @ref CCxPin_TypeDef structure
- * @retval USBPD status
- */
-USBPD_StatusTypeDef USBPD_PWR_IF_Enable_VConn(uint8_t PortNum, CCxPin_TypeDef CC)
-{
-/* USER CODE BEGIN USBPD_PWR_IF_Enable_VConn */
- return USBPD_ERROR;
-/* USER CODE END USBPD_PWR_IF_Enable_VConn */
-}
-
-/**
- * @brief Disable the VConn on the port.
- * @param PortNum Port number
- * @param CC Specifies the CCx to be selected based on @ref CCxPin_TypeDef structure
- * @retval USBPD status
- */
-USBPD_StatusTypeDef USBPD_PWR_IF_Disable_VConn(uint8_t PortNum, CCxPin_TypeDef CC)
-{
-/* USER CODE BEGIN USBPD_PWR_IF_Disable_VConn */
- return USBPD_ERROR;
-/* USER CODE END USBPD_PWR_IF_Disable_VConn */
-}
-
-/**
- * @brief Allow PDO data reading from PWR_IF storage.
- * @param PortNum Port number
- * @param DataId Type of data to be read from PWR_IF
- * This parameter can be one of the following values:
- * @arg @ref USBPD_CORE_DATATYPE_SRC_PDO Source PDO reading requested
- * @arg @ref USBPD_CORE_DATATYPE_SNK_PDO Sink PDO reading requested
- * @param Ptr Pointer on address where PDO values should be written (u8 pointer)
- * @param Size Pointer on nb of u32 written by PWR_IF (nb of PDOs)
- * @retval None
- */
-void USBPD_PWR_IF_GetPortPDOs(uint8_t PortNum, USBPD_CORE_DataInfoType_TypeDef DataId, uint8_t *Ptr, uint32_t *Size)
-{
-/* USER CODE BEGIN USBPD_PWR_IF_GetPortPDOs */
-
-/* USER CODE END USBPD_PWR_IF_GetPortPDOs */
-}
-
-/**
- * @brief Find out SRC PDO pointed out by a position provided in a Request DO (from Sink).
- * @param PortNum Port number
- * @param RdoPosition RDO Position in list of provided PDO
- * @param Pdo Pointer on PDO value pointed out by RDO position (u32 pointer)
- * @retval Status of search
- * USBPD_OK : Src PDO found for requested DO position (output Pdo parameter is set)
- * USBPD_FAIL : Position is not compliant with current Src PDO for this port (no corresponding PDO value)
- */
-USBPD_StatusTypeDef USBPD_PWR_IF_SearchRequestedPDO(uint8_t PortNum, uint32_t RdoPosition, uint32_t *Pdo)
-{
-/* USER CODE BEGIN USBPD_PWR_IF_SearchRequestedPDO */
- return USBPD_FAIL;
-/* USER CODE END USBPD_PWR_IF_SearchRequestedPDO */
-}
-
-/**
- * @brief the function is called in case of critical issue is detected to switch in safety mode.
- * @retval None
- */
-void USBPD_PWR_IF_Alarm()
-{
-/* USER CODE BEGIN USBPD_PWR_IF_Alarm */
-
-/* USER CODE END USBPD_PWR_IF_Alarm */
-}
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Software/VNA_embedded/Src/usbpd_pwr_user.c b/Software/VNA_embedded/Src/usbpd_pwr_user.c
deleted file mode 100644
index 5052f2c..0000000
--- a/Software/VNA_embedded/Src/usbpd_pwr_user.c
+++ /dev/null
@@ -1,457 +0,0 @@
-/* USER CODE BEGIN Header */
-/**
- ******************************************************************************
- * @file usbpd_pwr_user.c
- * @author MCD Application Team
- * @brief USBPD PWR user code
- ******************************************************************************
- * @attention
- *
- * © Copyright (c) 2020 STMicroelectronics.
- * All rights reserved.
- *
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
- *
- ******************************************************************************
- */
-/* USER CODE END Header */
-
-/* Includes ------------------------------------------------------------------*/
-#include "usbpd_pwr_user.h"
-#include "stm32g4xx_hal.h"
-
-/* USER CODE BEGIN include */
-
-/* USER CODE END include */
-
-/** @addtogroup BSP
- * @{
- */
-
-/** @addtogroup POWER
- * @{
- */
-/** @defgroup POWER_Private_Typedef Private Typedef
- * @{
- */
-/* USER CODE BEGIN POWER_Private_Typedef */
-
-/* USER CODE END POWER_Private_Typedef */
-/**
- * @}
- */
-
-/** @defgroup POWER_Private_Constants Private Constants
-* @{
-*/
-/* USER CODE BEGIN POWER_Private_Constants */
-
-/* USER CODE END POWER_Private_Constants */
-/**
- * @}
- */
-
-/** @defgroup POWER_Private_Macros Private Macros
- * @{
- */
-/* USER CODE BEGIN POWER_Private_Macros */
-
-/* USER CODE END POWER_Private_Macros */
-/**
- * @}
- */
-
-/** @defgroup POWER_Private_Variables Private Variables
- * @{
- */
-/* USER CODE BEGIN POWER_Private_Variables */
-
-/* USER CODE END POWER_Private_Variables */
-/**
- * @}
- */
-
-/** @defgroup POWER_Private_Functions Private Functions
- * @{
- */
-/* USER CODE BEGIN POWER_Private_Prototypes */
-
-/* USER CODE END POWER_Private_Prototypes */
-/**
- * @}
- */
-
-/** @defgroup POWER_Exported_Variables Exported Variables
- * @{
- */
-/* USER CODE BEGIN POWER_Exported_Variables */
-
-/* USER CODE END POWER_Exported_Variables */
-/**
- * @}
- */
-
-/** @addtogroup POWER_Exported_Functions
- * @{
- */
-/**
- * @brief Initialize the hardware resources used by the Type-C power delivery (PD)
- * controller.
- * @param PortId Type-C port identifier
- * This parameter can be take one of the following values:
- * @arg TYPE_C_PORT_1
- * @arg TYPE_C_PORT_2
- * @retval PD controller status
- */
-PWR_StatusTypeDef BSP_PWR_VBUSInit(uint32_t PortId)
-{
-/* USER CODE BEGIN BSP_PWR_VBUSInit */
- return PWR_ERROR;
-/* USER CODE END BSP_PWR_VBUSInit */
-}
-
-/**
- * @brief Release the hardware resources used by the Type-C power delivery (PD)
- * controller.
- * @param PortId Type-C port identifier
- * This parameter can be take one of the following values:
- * @arg TYPE_C_PORT_1
- * @arg TYPE_C_PORT_2
- * @retval PD controller status
- */
-PWR_StatusTypeDef BSP_PWR_VBUSDeInit(uint32_t PortId)
-{
-/* USER CODE BEGIN BSP_PWR_VBUSDeInit */
- return PWR_ERROR;
-/* USER CODE END BSP_PWR_VBUSDeInit */
-}
-
-/**
- * @brief Enable power supply over VBUS.
- * @param PortId Type-C port identifier
- * This parameter can be take one of the following values:
- * @arg TYPE_C_PORT_1
- * @retval PD controller status
- */
-PWR_StatusTypeDef BSP_PWR_VBUSOn(uint32_t PortId)
-{
-/* USER CODE BEGIN BSP_PWR_VBUSOn */
- return PWR_ERROR;
-/* USER CODE END BSP_PWR_VBUSOn */
-}
-
-/**
- * @brief Disable power supply over VBUS.
- * @param PortId Type-C port identifier
- * This parameter can be take one of the following values:
- * @arg TYPE_C_PORT_1
- * @retval PD controller status
- */
-PWR_StatusTypeDef BSP_PWR_VBUSOff(uint32_t PortId)
-{
-/* USER CODE BEGIN BSP_PWR_VBUSOff */
- return PWR_ERROR;
-/* USER CODE END BSP_PWR_VBUSOff */
-}
-
-/**
- * @brief Set a fixed/variable PDO and manage the power control.
- * @param PortId Type-C port identifier
- * This parameter can be take one of the following values:
- * @arg TYPE_C_PORT_1
- * @param VbusTargetInmv the vbus Target (in mV)
- * @param OperatingCurrent the Operating Current (in mA)
- * @param MaxOperatingCurrent the Max Operating Current (in mA)
- * @retval PD controller status
- */
-PWR_StatusTypeDef BSP_PWR_VBUSSetVoltage_Fixed(uint32_t PortId,
- uint32_t VbusTargetInmv,
- uint32_t OperatingCurrent,
- uint32_t MaxOperatingCurrent)
-{
-/* USER CODE BEGIN BSP_PWR_VBUSSetVoltage_Fixed */
- return PWR_ERROR;
-/* USER CODE END BSP_PWR_VBUSSetVoltage_Fixed */
-}
-
-/**
- * @brief Set a fixed/variable PDO and manage the power control.
- * @param PortId Type-C port identifier
- * This parameter can be take one of the following values:
- * @arg TYPE_C_PORT_1
- * @param VbusTargetMinInmv the vbus Target min (in mV)
- * @param VbusTargetMaxInmv the vbus Target max (in mV)
- * @param OperatingCurrent the Operating Current (in mA)
- * @param MaxOperatingCurrent the Max Operating Current (in mA)
- * @retval PD controller status
- */
-PWR_StatusTypeDef BSP_PWR_VBUSSetVoltage_Variable(uint32_t PortId,
- uint32_t VbusTargetMinInmv,
- uint32_t VbusTargetMaxInmv,
- uint32_t OperatingCurrent,
- uint32_t MaxOperatingCurrent)
-{
-/* USER CODE BEGIN BSP_PWR_VBUSSetVoltage_Variable */
- return PWR_ERROR;
-/* USER CODE BEGIN BSP_PWR_VBUSSetVoltage_Variable */
-}
-
-/**
- * @brief Set a Battery PDO and manage the power control.
- * @param PortId Type-C port identifier
- * This parameter can be take one of the following values:
- * @arg TYPE_C_PORT_1
- * @param VbusTargetMin the vbus Target min (in mV)
- * @param VbusTargetMax the vbus Target max (in mV)
- * @param OperatingPower the Operating Power (in mW)
- * @param MaxOperatingPower the Max Operating Power (in mW)
- * @retval PD controller status
- */
-PWR_StatusTypeDef BSP_PWR_VBUSSetVoltage_Battery(uint32_t PortId,
- uint32_t VbusTargetMin,
- uint32_t VbusTargetMax,
- uint32_t OperatingPower,
- uint32_t MaxOperatingPower)
-{
-/* USER CODE BEGIN BSP_PWR_VBUSSetVoltage_Battery */
- return PWR_ERROR;
-/* USER CODE BEGIN BSP_PWR_VBUSSetVoltage_Battery */
-}
-
-/**
-* @brief Set a APDO and manage the power control.
-* @param PortId Type-C port identifier
-* This parameter can be take one of the following values:
-* @arg TYPE_C_PORT_1
-* @param VbusTargetInmv the vbus Target (in mV)
-* @param OperatingCurrent the Operating current (in mA)
-* @param Delta Delta between with previous APDO (in mV), 0 means APDO start
-* @retval PD controller status
-*/
-PWR_StatusTypeDef BSP_PWR_VBUSSetVoltage_APDO(uint32_t PortId,
- uint32_t VbusTargetInmv,
- uint32_t OperatingCurrent,
- int32_t Delta)
-{
-/* USER CODE BEGIN BSP_PWR_VBUSSetVoltage_APDO */
- return PWR_ERROR;
-/* USER CODE BEGIN BSP_PWR_VBUSSetVoltage_APDO */
-}
-
-/**
- * @brief Get actual voltage level measured on the VBUS line.
- * @param PortId Type-C port identifier
- * This parameter can be take one of the following values:
- * @arg TYPE_C_PORT_1
- * @arg TYPE_C_PORT_2
- * @retval Voltage measured voltage level (in mV)
- */
-uint32_t BSP_PWR_VBUSGetVoltage(uint32_t PortId)
-{
-/* USER CODE BEGIN BSP_PWR_VBUSGetVoltage */
- return 0;
-/* USER CODE END BSP_PWR_VBUSGetVoltage */
-}
-
-/**
- * @brief Get actual current level measured on the VBUS line.
- * @param PortId Type-C port identifier
- * This parameter can be take one of the following values:
- * @arg TYPE_C_PORT_1
- * @arg TYPE_C_PORT_2
- * @retval Current measured current level (in mA)
- */
-int32_t BSP_PWR_VBUSGetCurrent(uint32_t PortId)
-{
-/* USER CODE BEGIN BSP_PWR_VBUSGetCurrent */
- return 0;
-/* USER CODE END BSP_PWR_VBUSGetCurrent */
-}
-
-/**
- * @brief Initialize VCONN sourcing.
- * @param PortId Type-C port identifier
- * This parameter can be take one of the following values:
- * @arg TYPE_C_PORT_1
- * @arg TYPE_C_PORT_2
- * @param CCPinId Type-C CC pin identifier
- * This parameter can be take one of the following values:
- * @arg TYPE_C_CC1
- * @arg TYPE_C_CC2
- * @retval PD controller status
- */
-PWR_StatusTypeDef BSP_PWR_VCONNInit(uint32_t PortId,
- uint32_t CCPinId)
-{
-/* USER CODE BEGIN BSP_PWR_VCONNInit */
- return PWR_ERROR;
-/* USER CODE END BSP_PWR_VCONNInit */
-}
-
-/**
- * @brief Un-Initialize VCONN sourcing.
- * @param PortId Type-C port identifier
- * This parameter can be take one of the following values:
- * @arg TYPE_C_PORT_1
- * @arg TYPE_C_PORT_2
- * @param CCPinId Type-C CC pin identifier
- * This parameter can be take one of the following values:
- * @arg TYPE_C_CC1
- * @arg TYPE_C_CC2
- * @retval PD controller status
- */
-PWR_StatusTypeDef BSP_PWR_VCONNDeInit(uint32_t PortId,
- uint32_t CCPinId)
-{
-/* USER CODE BEGIN BSP_PWR_VCONNDeInit */
- return PWR_ERROR;
-/* USER CODE END BSP_PWR_VCONNDeInit */
-}
-
-/**
- * @brief Enable VCONN sourcing.
- * @param PortId Type-C port identifier
- * This parameter can be take one of the following values:
- * @arg TYPE_C_PORT_1
- * @arg TYPE_C_PORT_2
- * @param CCPinId Type-C CC pin identifier
- * This parameter can be take one of the following values:
- * @arg TYPE_C_CC1
- * @arg TYPE_C_CC2
- * @retval PD controller status
- */
-PWR_StatusTypeDef BSP_PWR_VCONNOn(uint32_t PortId,
- uint32_t CCPinId)
-{
-/* USER CODE BEGIN BSP_PWR_VCONNOn */
- return PWR_ERROR;
-/* USER CODE END BSP_PWR_VCONNOn */
-}
-
-/**
- * @brief Disable VCONN sourcing.
- * @param PortId Type-C port identifier
- * This parameter can be take one of the following values:
- * @arg TYPE_C_PORT_1
- * @arg TYPE_C_PORT_2
- * @param CCPinId CC pin identifier
- * This parameter can be take one of the following values:
- * @arg TYPE_C_CC1
- * @arg TYPE_C_CC2
- * @retval PD controller status
- */
-PWR_StatusTypeDef BSP_PWR_VCONNOff(uint32_t PortId,
- uint32_t CCPinId)
-{
-/* USER CODE BEGIN BSP_PWR_VCONNOff */
- return PWR_ERROR;
-/* USER CODE END BSP_PWR_VCONNOff */
-}
-
-/**
- * @brief Set the VBUS disconnection voltage threshold.
- * @note Callback funtion registered through BSP_PWR_RegisterVBUSDetectCallback
- * function call is invoked when VBUS falls below programmed threshold.
- * @note By default VBUS disconnection threshold is set to 3.3V
- * @param PortId Type-C port identifier
- * This parameter can be take one of the following values:
- * @arg TYPE_C_PORT_1
- * @arg TYPE_C_PORT_2
- * @param VoltageThreshold: VBUS disconnection voltage threshold (in mV)
- * @retval PD controller status
- */
-void BSP_PWR_SetVBUSDisconnectionThreshold(uint32_t PortId,
- uint32_t VoltageThreshold)
-{
-/* USER CODE BEGIN BSP_PWR_SetVBUSDisconnectionThreshold */
-
-/* USER CODE END BSP_PWR_SetVBUSDisconnectionThreshold */
-}
-
-/**
- * @brief Register USB Type-C Current callback function.
- * @note Callback function invoked when VBUS rises above 4V (VBUS present) or
- * when VBUS falls below programmed threshold (VBUS absent).
- * @note Callback funtion is un-registered when callback function pointer
- * argument is NULL.
- * @param PortId Type-C port identifier
- * This parameter can be take one of the following values:
- * @arg TYPE_C_PORT_1
- * @arg TYPE_C_PORT_2
- * @param pfnVBUSDetectCallback callback function pointer
-* @retval 0 success else fail
- */
-PWR_StatusTypeDef BSP_PWR_RegisterVBUSDetectCallback(uint32_t PortId,
- PWR_VBUSDetectCallbackFunc * pfnVBUSDetectCallback)
-{
-/* USER CODE BEGIN BSP_PWR_RegisterVBUSDetectCallback */
- return PWR_ERROR;
-/* USER CODE END BSP_PWR_RegisterVBUSDetectCallback */
-}
-
-/**
- * @brief Get actual VBUS status.
- * @param PortId Type-C port identifier
- * This parameter can be take one of the following values:
- * @arg TYPE_C_PORT_1
- * @retval VBUS status (1: On, 0: Off)
- */
-uint8_t BSP_PWR_VBUSIsOn(uint32_t PortId)
-{
-/* USER CODE BEGIN BSP_PWR_VBUSIsOn */
- return 0;
-/* USER CODE END BSP_PWR_VBUSIsOn */
-}
-
-/**
- * @brief Get actual VCONN status.
- * @param PortId Type-C port identifier
- * This parameter can be take one of the following values:
- * @arg TYPE_C_PORT_1
- * @param CCPinId Type-C CC pin identifier
- * This parameter can be take one of the following values:
- * @arg TYPE_C_CC1
- * @arg TYPE_C_CC2
- * @retval VCONN status (1: On, 0: Off)
- */
-uint8_t BSP_PWR_VCONNIsOn(uint32_t PortId,
- uint32_t CCPinId)
-{
-/* USER CODE BEGIN BSP_PWR_VCONNIsOn */
- return 0;
-/* USER CODE END BSP_PWR_VCONNIsOn */
-}
-
-/**
- * @}
- */
-
-/** @addtogroup POWER_Private_Functions
- * @{
- */
-
-/* USER CODE BEGIN POWER_Private_Functions */
-
-/* USER CODE END POWER_Private_Functions */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
-
diff --git a/Software/VNA_embedded/Src/usbpd_vdm_user.c b/Software/VNA_embedded/Src/usbpd_vdm_user.c
deleted file mode 100644
index add28e9..0000000
--- a/Software/VNA_embedded/Src/usbpd_vdm_user.c
+++ /dev/null
@@ -1,470 +0,0 @@
-/**
- ******************************************************************************
- * @file usbpd_vdm_user.c
- * @author MCD Application Team
- * @brief USBPD provider demo file
- ******************************************************************************
- * @attention
- *
- * © Copyright (c) 2020 STMicroelectronics.
- * All rights reserved.
- *
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
- *
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "usbpd_core.h"
-#include "usbpd_dpm_conf.h"
-#include "usbpd_vdm_user.h"
-#include "usbpd_dpm_user.h"
-/* USER CODE BEGIN Includes */
-
-/* USER CODE END Includes */
-
-/** @addtogroup STM32_USBPD_APPLICATION
- * @{
- */
-
-/** @addtogroup STM32_USBPD_APPLICATION_VDM_USER
- * @{
- */
-
-/* Private define ------------------------------------------------------------*/
-/* USER CODE BEGIN Private_define */
-
-/* USER CODE END Private_define */
-
-/* Private typedef -----------------------------------------------------------*/
-/* USER CODE BEGIN Private_typedef */
-
-/* USER CODE END Private_typedef */
-
-/* Private macro -------------------------------------------------------------*/
-/* USER CODE BEGIN Private_macro */
-
-/* USER CODE END Private_macro */
-
-/* Private function prototypes -----------------------------------------------*/
-static USBPD_StatusTypeDef USBPD_VDM_DiscoverIdentity(uint8_t PortNum, USBPD_DiscoveryIdentity_TypeDef *pIdentity);
-static USBPD_StatusTypeDef USBPD_VDM_DiscoverSVIDs(uint8_t PortNum, uint16_t **p_SVID_Info, uint8_t *nb);
-static USBPD_StatusTypeDef USBPD_VDM_DiscoverModes(uint8_t PortNum, uint16_t SVID, uint32_t **p_ModeInfo, uint8_t *nbMode);
-static USBPD_StatusTypeDef USBPD_VDM_ModeEnter(uint8_t PortNum, uint16_t SVID, uint32_t ModeIndex);
-static USBPD_StatusTypeDef USBPD_VDM_ModeExit(uint8_t PortNum, uint16_t SVID, uint32_t ModeIndex);
-static void USBPD_VDM_SendAttention(uint8_t PortNum, uint8_t *NbData, uint32_t *VDO);
-static void USBPD_VDM_ReceiveAttention(uint8_t PortNum, uint8_t NbData, uint32_t VDO);
-static USBPD_StatusTypeDef USBPD_VDM_ReceiveSpecific(uint8_t PortNum, USBPD_VDM_Command_Typedef VDMCommand, uint8_t *pNbData, uint32_t *pVDO);
-static void USBPD_VDM_InformIdentity(uint8_t PortNum, USBPD_SOPType_TypeDef SOPType, USBPD_VDM_CommandType_Typedef CommandStatus, USBPD_DiscoveryIdentity_TypeDef *pIdentity);
-static void USBPD_VDM_InformSVID(uint8_t PortNum, USBPD_SOPType_TypeDef SOPType, USBPD_VDM_CommandType_Typedef CommandStatus, USBPD_SVIDInfo_TypeDef *pListSVID);
-static void USBPD_VDM_InformMode(uint8_t PortNum, USBPD_SOPType_TypeDef SOPType, USBPD_VDM_CommandType_Typedef CommandStatus, USBPD_ModeInfo_TypeDef *pModesInfo);
-static void USBPD_VDM_InformModeEnter(uint8_t PortNum, USBPD_SOPType_TypeDef SOPType, USBPD_VDM_CommandType_Typedef CommandStatus, uint16_t SVID, uint32_t ModeIndex);
-static void USBPD_VDM_InformModeExit(uint8_t PortNum, USBPD_SOPType_TypeDef SOPType, USBPD_VDM_CommandType_Typedef CommandStatus, uint16_t SVID, uint32_t ModeIndex);
-static void USBPD_VDM_InformSpecific(uint8_t PortNum, USBPD_VDM_Command_Typedef VDMCommand, uint8_t *NbData, uint32_t *VDO);
-static void USBPD_VDM_SendSpecific(uint8_t PortNum, USBPD_VDM_Command_Typedef VDMCommand, uint8_t *NbData, uint32_t *VDO);
-static void USBPD_VDM_SendUVDM(uint8_t PortNum, USBPD_UVDMHeader_TypeDef *pUVDM_Header, uint8_t *pNbData, uint32_t *pVDO);
-static USBPD_StatusTypeDef USBPD_VDM_ReceiveUVDM(uint8_t PortNum, USBPD_UVDMHeader_TypeDef UVDM_Header, uint8_t *pNbData, uint32_t *pVDO);
-
-/* USER CODE BEGIN Private_prototypes */
-
-/* USER CODE END Private_prototypes */
-
-/* Private variables ---------------------------------------------------------*/
-/* USER CODE BEGIN Private_variables */
-const USBPD_VDM_Callbacks vdmCallbacks =
-{
- USBPD_VDM_DiscoverIdentity,
- USBPD_VDM_DiscoverSVIDs,
- USBPD_VDM_DiscoverModes,
- USBPD_VDM_ModeEnter,
- USBPD_VDM_ModeExit,
- USBPD_VDM_InformIdentity,
- USBPD_VDM_InformSVID,
- USBPD_VDM_InformMode,
- USBPD_VDM_InformModeEnter,
- USBPD_VDM_InformModeExit,
- USBPD_VDM_SendAttention,
- USBPD_VDM_ReceiveAttention,
- USBPD_VDM_SendSpecific,
- USBPD_VDM_ReceiveSpecific,
- USBPD_VDM_InformSpecific,
- USBPD_VDM_SendUVDM,
- USBPD_VDM_ReceiveUVDM,
-};
-/* USER CODE END Private_variables */
-
-/* Private functions ---------------------------------------------------------*/
-/**
- * @brief VDM Discovery identity callback
- * @note Function is called to get Discovery identity information linked to the device and answer
- * to SVDM Discovery identity init message sent by port partner
- * @param PortNum current port number
- * @param pIdentity Pointer on @ref USBPD_DiscoveryIdentity_TypeDef structure
- * @retval USBPD status: @ref USBPD_ACK or @ref USBPD_BUSY
- */
-static USBPD_StatusTypeDef USBPD_VDM_DiscoverIdentity(uint8_t PortNum, USBPD_DiscoveryIdentity_TypeDef *pIdentity)
-{
-/* USER CODE BEGIN USBPD_VDM_DiscoverIdentity */
- return USBPD_NAK;
-/* USER CODE END USBPD_VDM_DiscoverIdentity */
-}
-
-/**
- * @brief VDM Discover SVID callback
- * @note Function is called to retrieve SVID supported by device and answer
- * to SVDM Discovery SVID init message sent by port partner
- * @param PortNum current port number
- * @param p_SVID_Info Pointer on @ref USBPD_SVIDInfo_TypeDef structure
- * @param pNbSVID Pointer on number of SVID
- * @retval USBPD status @ref USBPD_BUSY or @ref USBPD_ACK or @ref USBPD_NAK
- */
-static USBPD_StatusTypeDef USBPD_VDM_DiscoverSVIDs(uint8_t PortNum, uint16_t **p_SVID_Info, uint8_t *pNbSVID)
-{
-/* USER CODE BEGIN USBPD_VDM_DiscoverSVIDs */
- return USBPD_NAK;
-/* USER CODE END USBPD_VDM_DiscoverSVIDs */
-}
-
-/**
- * @brief VDM Discover Mode callback (report all the modes supported by SVID)
- * @note Function is called to report all the modes supported by selected SVID and answer
- * to SVDM Discovery Mode init message sent by port partner
- * @param PortNum current port number
- * @param SVID SVID value
- * @param p_ModeTab Pointer on the mode value
- * @param NumberOfMode Number of mode available
- * @retval USBPD status
- */
-static USBPD_StatusTypeDef USBPD_VDM_DiscoverModes(uint8_t PortNum, uint16_t SVID, uint32_t **p_ModeTab, uint8_t *NumberOfMode)
-{
-/* USER CODE BEGIN USBPD_VDM_DiscoverModes */
- return USBPD_NAK;
-/* USER CODE END USBPD_VDM_DiscoverModes */
-}
-
-/**
- * @brief VDM Mode enter callback
- * @note Function is called to check if device can enter in the mode received for the selected SVID in the
- * SVDM enter mode init message sent by port partner
- * @param PortNum current port number
- * @param SVID SVID value
- * @param ModeIndex Index of the mode to be entered
- * @retval USBPD status @ref USBPD_ACK/@ref USBPD_NAK
- */
-static USBPD_StatusTypeDef USBPD_VDM_ModeEnter(uint8_t PortNum, uint16_t SVID, uint32_t ModeIndex)
-{
-/* USER CODE BEGIN USBPD_VDM_ModeEnter */
- return USBPD_NAK;
-/* USER CODE END USBPD_VDM_ModeEnter */
-}
-
-/**
- * @brief VDM Mode exit callback
- * @note Function is called to check if device can exit from the mode received for the selected SVID in the
- * SVDM exit mode init message sent by port partner
- * @param PortNum current port number
- * @param SVID SVID value
- * @param ModeIndex Index of the mode to be exited
- * @retval USBPD status @ref USBPD_ACK/@ref USBPD_NAK
- */
-static USBPD_StatusTypeDef USBPD_VDM_ModeExit(uint8_t PortNum, uint16_t SVID, uint32_t ModeIndex)
-{
-/* USER CODE BEGIN USBPD_VDM_ModeExit */
- return USBPD_NAK;
-/* USER CODE END USBPD_VDM_ModeExit */
-}
-
-/**
- * @brief Send VDM Attention message callback
- * @note Function is called when device wants to send a SVDM attention message to port partner
- * (for instance DP status can be filled through this function)
- * @param PortNum current port number
- * @param pNbData Pointer of number of VDO to send
- * @param pVDO Pointer of VDO to send
- * @retval None
- */
-static void USBPD_VDM_SendAttention(uint8_t PortNum, uint8_t *pNbData, uint32_t *pVDO)
-{
-/* USER CODE BEGIN USBPD_VDM_SendAttention */
-
-/* USER CODE END USBPD_VDM_SendAttention */
-}
-
-/**
- * @brief Receive VDM Attention callback
- * @note Function is called when a SVDM attention init message has been received from port partner
- * (for instance, save DP status data through this function)
- * @param PortNum current port number
- * @param NbData Number of received VDO
- * @param VDO Received VDO
- * @retval None
- */
-static void USBPD_VDM_ReceiveAttention(uint8_t PortNum, uint8_t NbData, uint32_t VDO)
-{
-/* USER CODE BEGIN USBPD_VDM_ReceiveAttention */
-
-/* USER CODE END USBPD_VDM_ReceiveAttention */
-}
-
-/**
- * @brief VDM Receive Specific message callback
- * @note Function is called to answer to a SVDM specific init message received by port partner.
- * (for instance, retrieve DP status or DP configure data through this function)
- * @param PortNum Current port number
- * @param VDMCommand VDM command based on @ref USBPD_VDM_Command_Typedef
- * @param pNbData Pointer of number of received VDO and used for the answer
- * @param pVDO Pointer of received VDO and use for the answer
- * @retval USBPD Status
- */
-static USBPD_StatusTypeDef USBPD_VDM_ReceiveSpecific(uint8_t PortNum, USBPD_VDM_Command_Typedef VDMCommand, uint8_t *pNbData, uint32_t *pVDO)
-{
-/* USER CODE BEGIN USBPD_VDM_ReceiveSpecific */
- return USBPD_NAK;
-/* USER CODE END USBPD_VDM_ReceiveSpecific */
-}
-
-/**
- * @brief Inform identity callback
- * @note Function is called to save Identity information received in Discovery identity from port partner
- (answer to SVDM discovery identity sent by device)
- * @param PortNum current port number
- * @param SOPType SOP type
- * @param CommandStatus Command status based on @ref USBPD_VDM_CommandType_Typedef
- * @param pIdentity Pointer on the discovery identity information based on @ref USBPD_DiscoveryIdentity_TypeDef
- * @retval None
-*/
-static void USBPD_VDM_InformIdentity(uint8_t PortNum, USBPD_SOPType_TypeDef SOPType, USBPD_VDM_CommandType_Typedef CommandStatus, USBPD_DiscoveryIdentity_TypeDef *pIdentity)
-{
-/* USER CODE BEGIN USBPD_VDM_InformIdentity */
- switch(CommandStatus)
- {
- case SVDM_RESPONDER_ACK :
- break;
- case SVDM_RESPONDER_NAK :
- break;
- case SVDM_RESPONDER_BUSY :
- break;
- default :
- break;
- }
-/* USER CODE END USBPD_VDM_InformIdentity */
-}
-
-/**
- * @brief Inform SVID callback
- * @note Function is called to save list of SVID received in Discovery SVID from port partner
- (answer to SVDM discovery SVID sent by device)
- * @param PortNum current port number
- * @param SOPType SOP type
- * @param CommandStatus Command status based on @ref USBPD_VDM_CommandType_Typedef
- * @param pListSVID Pointer of list of SVID based on @ref USBPD_SVIDInfo_TypeDef
- * @retval None
- */
-static void USBPD_VDM_InformSVID(uint8_t PortNum, USBPD_SOPType_TypeDef SOPType, USBPD_VDM_CommandType_Typedef CommandStatus, USBPD_SVIDInfo_TypeDef *pListSVID)
-{
-/* USER CODE BEGIN USBPD_VDM_InformSVID */
- switch(CommandStatus)
- {
- case SVDM_RESPONDER_ACK :
- break;
- case SVDM_RESPONDER_NAK :
- break;
- case SVDM_RESPONDER_BUSY :
- break;
- default :
- break;
- }
-/* USER CODE END USBPD_VDM_InformSVID */
-}
-
-/**
- * @brief Inform Mode callback ( received in Discovery Modes ACK)
- * @note Function is called to save list of modes linked to SVID received in Discovery mode from port partner
- (answer to SVDM discovery mode sent by device)
- * @param PortNum current port number
- * @param SOPType SOP type
- * @param CommandStatus Command status based on @ref USBPD_VDM_CommandType_Typedef
- * @param pModesInfo Pointer of Modes info based on @ref USBPD_ModeInfo_TypeDef
- * @retval None
- */
-static void USBPD_VDM_InformMode(uint8_t PortNum, USBPD_SOPType_TypeDef SOPType, USBPD_VDM_CommandType_Typedef CommandStatus, USBPD_ModeInfo_TypeDef *pModesInfo)
-{
-/* USER CODE BEGIN USBPD_VDM_InformMode */
- switch(CommandStatus)
- {
- case SVDM_RESPONDER_ACK :
- break;
- case SVDM_RESPONDER_NAK :
- break;
- case SVDM_RESPONDER_BUSY :
- break;
- default :
- break;
- }
-/* USER CODE END USBPD_VDM_InformMode */
-}
-
-/**
- * @brief Inform Mode enter callback
- * @note Function is called to inform if port partner accepted or not to enter in the mode
- * specified in the SVDM enter mode sent by the device
- * @param PortNum current port number
- * @param SOPType SOP type
- * @param CommandStatus Command status based on @ref USBPD_VDM_CommandType_Typedef
- * @param SVID SVID ID
- * @param ModeIndex Index of the mode to be entered
- * @retval None
- */
-static void USBPD_VDM_InformModeEnter(uint8_t PortNum, USBPD_SOPType_TypeDef SOPType, USBPD_VDM_CommandType_Typedef CommandStatus, uint16_t SVID, uint32_t ModeIndex)
-{
-/* USER CODE BEGIN USBPD_VDM_InformModeEnter */
- switch(CommandStatus)
- {
- case SVDM_RESPONDER_ACK :
- break;
- case SVDM_RESPONDER_NAK :
- break;
- case SVDM_RESPONDER_BUSY :
- /* retry in 50ms */
- break;
- default :
- break;
- }
-/* USER CODE END USBPD_VDM_InformModeEnter */
-}
-
-/**
- * @brief Inform Exit enter callback
- * @param PortNum current port number
- * @param SVID SVID ID
- * @param ModeIndex Index of the mode to be entered
- * @retval None
- */
-static void USBPD_VDM_InformModeExit(uint8_t PortNum, USBPD_SOPType_TypeDef SOPType, USBPD_VDM_CommandType_Typedef CommandStatus, uint16_t SVID, uint32_t ModeIndex)
-{
-/* USER CODE BEGIN USBPD_VDM_InformModeExit */
- switch(CommandStatus)
- {
- case SVDM_RESPONDER_ACK :
- break;
- case SVDM_RESPONDER_NAK :
- break;
- case SVDM_RESPONDER_BUSY :
- /* retry in 50ms */
- break;
- default :
- break;
- }
-/* USER CODE END USBPD_VDM_InformModeExit */
-}
-
-/**
- * @brief VDM Send Specific message callback
- * @note Function is called when device wants to send a SVDM specific init message to port partner
- * (for instance DP status or DP configure can be filled through this function)
- * @param PortNum current port number
- * @param VDMCommand VDM command based on @ref USBPD_VDM_Command_Typedef
- * @param pNbData Pointer of number of VDO to send
- * @param pVDO Pointer of VDO to send
- * @retval None
- */
-static void USBPD_VDM_SendSpecific(uint8_t PortNum, USBPD_VDM_Command_Typedef VDMCommand, uint8_t *pNbData, uint32_t *pVDO)
-{
-/* USER CODE BEGIN USBPD_VDM_SendSpecific */
-
-/* USER CODE END USBPD_VDM_SendSpecific */
-}
-
-/**
- * @brief VDM Specific message callback to inform user of reception of VDM specific message
- * @note Function is called when answer from SVDM specific init message has been received by the device
- * (for instance, save DP status and DP configure data through this function)
- * @param PortNum current port number
- * @param VDMCommand VDM command based on @ref USBPD_VDM_Command_Typedef
- * @param pNbData Pointer of number of received VDO
- * @param pVDO Pointer of received VDO
- * @retval None
- */
-static void USBPD_VDM_InformSpecific(uint8_t PortNum, USBPD_VDM_Command_Typedef VDMCommand, uint8_t *pNbData, uint32_t *pVDO)
-{
-/* USER CODE BEGIN USBPD_VDM_InformSpecific */
-
-/* USER CODE END USBPD_VDM_InformSpecific */
-}
-
-/**
- * @brief VDM Send Unstructured message callback
- * @param PortNum current port number
- * @param pUVDM_Header Pointer on UVDM header based on @ref USBPD_UVDMHeader_TypeDef
- * @param pNbData Pointer of number of VDO to send
- * @param pVDO Pointer of VDO to send
- * @retval None
- */
-static void USBPD_VDM_SendUVDM(uint8_t PortNum, USBPD_UVDMHeader_TypeDef *pUVDM_Header, uint8_t *pNbData, uint32_t *pVDO)
-{
-/* USER CODE BEGIN USBPD_VDM_SendUVDM */
-
-/* USER CODE END USBPD_VDM_SendUVDM */
-}
-
-/**
- * @brief Unstructured VDM message callback to inform user of reception of UVDM message
- * @param PortNum current port number
- * @param UVDM_Header UVDM header based on @ref USBPD_UVDMHeader_TypeDef
- * @param pNbData Pointer of number of received VDO
- * @param pVDO Pointer of received VDO
- * @retval USBPD Status
- */
-static USBPD_StatusTypeDef USBPD_VDM_ReceiveUVDM(uint8_t PortNum, USBPD_UVDMHeader_TypeDef UVDM_Header, uint8_t *pNbData, uint32_t *pVDO)
-{
-/* USER CODE BEGIN USBPD_VDM_ReceiveUVDM */
- return USBPD_ERROR;
-/* USER CODE END USBPD_VDM_ReceiveUVDM */
-}
-
-/* USER CODE BEGIN Private_functions */
-
-/* USER CODE END Private_functions */
-
-/* Exported functions ---------------------------------------------------------*/
-/**
- * @brief VDM Initialization function
- * @param PortNum Index of current used port
- * @retval status
- */
-USBPD_StatusTypeDef USBPD_VDM_UserInit(uint8_t PortNum)
-{
-/* USER CODE BEGIN USBPD_VDM_UserInit */
- return USBPD_OK;
-/* USER CODE END USBPD_VDM_UserInit */
-}
-
-/**
- * @brief VDM Reset function
- * @param PortNum Index of current used port
- * @retval status
- */
-void USBPD_VDM_UserReset(uint8_t PortNum)
-{
-/* USER CODE BEGIN USBPD_VDM_UserReset */
-
-/* USER CODE END USBPD_VDM_UserReset */
-}
-
-/* USER CODE BEGIN Exported_functions */
-
-/* USER CODE END Exported_functions */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
-
diff --git a/Software/VNA_embedded/startup/startup_stm32g431xx.s b/Software/VNA_embedded/Startup/startup_stm32g431cbux.s
similarity index 92%
rename from Software/VNA_embedded/startup/startup_stm32g431xx.s
rename to Software/VNA_embedded/Startup/startup_stm32g431cbux.s
index 1d6e034..9ea4773 100644
--- a/Software/VNA_embedded/startup/startup_stm32g431xx.s
+++ b/Software/VNA_embedded/Startup/startup_stm32g431cbux.s
@@ -15,13 +15,12 @@
******************************************************************************
* @attention
*
- * © Copyright (c) 2017 STMicroelectronics.
- * All rights reserved.
+ * Copyright (c) 2019 STMicroelectronics.
+ * All rights reserved.
*
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
@@ -496,4 +495,3 @@ g_pfnVectors:
.weak FMAC_IRQHandler
.thumb_set FMAC_IRQHandler,Default_Handler
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Software/VNA_embedded/VNA_embedded Debug.cfg b/Software/VNA_embedded/VNA_embedded Debug.cfg
deleted file mode 100644
index 9abf4c7..0000000
--- a/Software/VNA_embedded/VNA_embedded Debug.cfg
+++ /dev/null
@@ -1,36 +0,0 @@
-# This is an VNA_embedded board with a single STM32G431CBUx chip
-#
-# Generated by System Workbench for STM32
-# Take care that such file, as generated, may be overridden without any early notice. Please have a look to debug launch configuration setup(s)
-
-source [find interface/stlink.cfg]
-
-set WORKAREASIZE 0x5800
-
-transport select "hla_swd"
-
-set CHIPNAME STM32G431CBUx
-set BOARDNAME VNA_embedded
-
-# CHIPNAMES state
-set CHIPNAME_CPU0_ACTIVATED 1
-
-# Enable debug when in low power modes
-set ENABLE_LOW_POWER 1
-
-# Stop Watchdog counters when halt
-set STOP_WATCHDOG 1
-
-# STlink Debug clock frequency
-set CLOCK_FREQ 8000
-
-# use hardware reset, connect under reset
-# connect_assert_srst needed if low power mode application running (WFI...)
-reset_config srst_only srst_nogate connect_assert_srst
-set CONNECT_UNDER_RESET 1
-
-# BCTM CPU variables
-
-
-
-source [find target/stm32g4x.cfg]
diff --git a/Software/VNA_embedded/VNA_embedded Debug.launch b/Software/VNA_embedded/VNA_embedded Debug.launch
new file mode 100644
index 0000000..bcd0e30
--- /dev/null
+++ b/Software/VNA_embedded/VNA_embedded Debug.launch
@@ -0,0 +1,80 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Software/VNA_embedded/VNA_embedded.ioc b/Software/VNA_embedded/VNA_embedded.ioc
index 185e95d..b2ba0ff 100644
--- a/Software/VNA_embedded/VNA_embedded.ioc
+++ b/Software/VNA_embedded/VNA_embedded.ioc
@@ -103,7 +103,6 @@ Mcu.IP10=TIM2
Mcu.IP11=UCPD1
Mcu.IP12=USART3
Mcu.IP13=USB
-Mcu.IP14=USBPD
Mcu.IP2=FREERTOS
Mcu.IP3=I2C2
Mcu.IP4=NVIC
@@ -112,7 +111,7 @@ Mcu.IP6=SPI1
Mcu.IP7=SPI2
Mcu.IP8=SYS
Mcu.IP9=TIM1
-Mcu.IPNb=15
+Mcu.IPNb=14
Mcu.Name=STM32G431C(6-8-B)Ux
Mcu.Package=UFQFPN48
Mcu.Pin0=PF1-OSC_OUT
@@ -141,22 +140,21 @@ Mcu.Pin29=VP_ADC1_TempSens_Input
Mcu.Pin3=PA3
Mcu.Pin30=VP_FREERTOS_VS_CMSIS_V1
Mcu.Pin31=VP_SYS_VS_tim17
-Mcu.Pin32=VP_TIM1_VS_ClockSourceINT
-Mcu.Pin33=VP_TIM2_VS_ClockSourceINT
-Mcu.Pin34=VP_USBPD_VS_USBPD1
-Mcu.Pin35=VP_USBPD_VS_usbpd_tim3
+Mcu.Pin32=VP_SYS_VS_DBSignals
+Mcu.Pin33=VP_TIM1_VS_ClockSourceINT
+Mcu.Pin34=VP_TIM2_VS_ClockSourceINT
Mcu.Pin4=PA4
Mcu.Pin5=PA5
Mcu.Pin6=PA6
Mcu.Pin7=PA7
Mcu.Pin8=PC4
Mcu.Pin9=PB0
-Mcu.PinsNb=36
+Mcu.PinsNb=35
Mcu.ThirdPartyNb=0
Mcu.UserConstants=
Mcu.UserName=STM32G431CBUx
-MxCube.Version=5.2.1
-MxDb.Version=DB.5.0.21
+MxCube.Version=6.4.0
+MxDb.Version=DB.6.0.40
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.DMA1_Channel1_IRQn=true\:7\:0\:true\:false\:true\:true\:false\:true
NVIC.DMA1_Channel2_IRQn=true\:7\:0\:true\:false\:true\:true\:false\:true
@@ -173,7 +171,7 @@ NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false
NVIC.SavedPendsvIrqHandlerGenerated=true
NVIC.SavedSvcallIrqHandlerGenerated=true
NVIC.SavedSystickIrqHandlerGenerated=true
-NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:false\:true\:false\:false
+NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:false\:true\:false\:true
NVIC.TIM1_TRG_COM_TIM17_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true
NVIC.TimeBase=TIM1_TRG_COM_TIM17_IRQn
NVIC.TimeBaseIP=TIM17
@@ -232,6 +230,8 @@ PA7.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH
PA7.Locked=true
PA7.Mode=Full_Duplex_Master
PA7.Signal=SPI1_MOSI
+PA8.GPIOParameters=GPIO_Pu
+PA8.GPIO_Pu=GPIO_PULLUP
PA8.Locked=true
PA8.Mode=I2C
PA8.Signal=I2C2_SDA
@@ -285,6 +285,8 @@ PB9.Signal=GPIO_Input
PC10.Locked=true
PC10.Mode=Asynchronous
PC10.Signal=USART3_TX
+PC4.GPIOParameters=GPIO_Pu
+PC4.GPIO_Pu=GPIO_PULLUP
PC4.Locked=true
PC4.Mode=I2C
PC4.Signal=I2C2_SCL
@@ -302,7 +304,7 @@ ProjectManager.CustomerFirmwarePackage=
ProjectManager.DefaultFWLocation=true
ProjectManager.DeletePrevious=true
ProjectManager.DeviceId=STM32G431CBUx
-ProjectManager.FirmwarePackage=STM32Cube FW_G4 V1.0.1
+ProjectManager.FirmwarePackage=STM32Cube FW_G4 V1.5.0
ProjectManager.FreePins=false
ProjectManager.HalAssertFull=false
ProjectManager.HeapSize=0x200
@@ -317,7 +319,7 @@ ProjectManager.ProjectFileName=VNA_embedded.ioc
ProjectManager.ProjectName=VNA_embedded
ProjectManager.RegisterCallBack=
ProjectManager.StackSize=0x400
-ProjectManager.TargetToolchain=SW4STM32
+ProjectManager.TargetToolchain=STM32CubeIDE
ProjectManager.ToolChainLocation=
ProjectManager.UnderRoot=true
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-false,4-MX_I2C2_Init-I2C2-false-HAL-true,5-MX_SPI1_Init-SPI1-false-HAL-true,6-MX_SPI2_Init-SPI2-false-HAL-true,7-MX_UCPD1_Init-UCPD1-false-LL-true,8-MX_USART3_UART_Init-USART3-false-HAL-true,9-MX_USB_PCD_Init-USB-false-HAL-true,10-MX_USBPD_Init-USBPD-false-HAL-false,11-MX_TIM1_Init-TIM1-false-HAL-true,12-MX_TIM2_Init-TIM2-false-HAL-true,13-MX_ADC1_Init-ADC1-false-HAL-true
@@ -400,14 +402,13 @@ VP_ADC1_TempSens_Input.Mode=IN-TempSens
VP_ADC1_TempSens_Input.Signal=ADC1_TempSens_Input
VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1
VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1
+VP_SYS_VS_DBSignals.Mode=DisableDeadBatterySignals
+VP_SYS_VS_DBSignals.Signal=SYS_VS_DBSignals
VP_SYS_VS_tim17.Mode=TIM17
VP_SYS_VS_tim17.Signal=SYS_VS_tim17
VP_TIM1_VS_ClockSourceINT.Mode=Internal
VP_TIM1_VS_ClockSourceINT.Signal=TIM1_VS_ClockSourceINT
VP_TIM2_VS_ClockSourceINT.Mode=Internal
VP_TIM2_VS_ClockSourceINT.Signal=TIM2_VS_ClockSourceINT
-VP_USBPD_VS_USBPD1.Mode=USBPD_P0
-VP_USBPD_VS_USBPD1.Signal=USBPD_VS_USBPD1
-VP_USBPD_VS_usbpd_tim3.Mode=TIM3
-VP_USBPD_VS_usbpd_tim3.Signal=USBPD_VS_usbpd_tim3
board=custom
+isbadioc=false
diff --git a/Software/VNA_embedded/VNA_embedded.xml b/Software/VNA_embedded/VNA_embedded.xml
deleted file mode 100644
index 72f5d11..0000000
--- a/Software/VNA_embedded/VNA_embedded.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
-
-]>
-
-
- VNA_embedded
- SWD
- ST-Link
- stm32g431cbux
-
-