Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@
.DS_Store
*.swp
/Output

# Ignore local overrides of platform.txt and boards.txt,
/boards.local.txt
/platform.local.txt
2 changes: 1 addition & 1 deletion cores/nRF5/Uart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ size_t Uart::write(const uint8_t *buffer, size_t size)
do
{
size_t remaining = size - sent;
size_t txSize = min(remaining, SERIAL_BUFFER_SIZE);
size_t txSize = min(remaining, (size_t)SERIAL_BUFFER_SIZE);

xSemaphoreTake(_mutex, portMAX_DELAY);

Expand Down
32 changes: 32 additions & 0 deletions cores/nRF5/freertos/Source/include/FreeRTOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ extern "C" {
#define INCLUDE_uxTaskGetStackHighWaterMark 0
#endif

#ifndef INCLUDE_pxTaskGetStackStart
#define INCLUDE_pxTaskGetStackStart 0
#endif

#ifndef INCLUDE_eTaskGetState
#define INCLUDE_eTaskGetState 0
#endif
Expand Down Expand Up @@ -392,6 +396,22 @@ extern "C" {
#define tracePOST_MOVED_TASK_TO_READY_STATE( pxTCB )
#endif

#ifndef traceREADDED_TASK_TO_READY_STATE
#define traceREADDED_TASK_TO_READY_STATE( pxTCB ) traceMOVED_TASK_TO_READY_STATE( pxTCB )
#endif

#ifndef traceMOVED_TASK_TO_DELAYED_LIST
#define traceMOVED_TASK_TO_DELAYED_LIST()
#endif

#ifndef traceMOVED_TASK_TO_OVERFLOW_DELAYED_LIST
#define traceMOVED_TASK_TO_OVERFLOW_DELAYED_LIST()
#endif

#ifndef traceMOVED_TASK_TO_SUSPENDED_LIST
#define traceMOVED_TASK_TO_SUSPENDED_LIST( pxTCB )
#endif

#ifndef traceQUEUE_CREATE
#define traceQUEUE_CREATE( pxNewQueue )
#endif
Expand Down Expand Up @@ -636,6 +656,18 @@ extern "C" {
#define traceTASK_NOTIFY_GIVE_FROM_ISR()
#endif

#ifndef traceISR_EXIT_TO_SCHEDULER
#define traceISR_EXIT_TO_SCHEDULER()
#endif

#ifndef traceISR_EXIT
#define traceISR_EXIT()
#endif

#ifndef traceISR_ENTER
#define traceISR_ENTER()
#endif

#ifndef traceSTREAM_BUFFER_CREATE_FAILED
#define traceSTREAM_BUFFER_CREATE_FAILED( xIsMessageBuffer )
#endif
Expand Down
19 changes: 19 additions & 0 deletions cores/nRF5/freertos/Source/include/task.h
Original file line number Diff line number Diff line change
Expand Up @@ -1421,6 +1421,25 @@ TaskHandle_t xTaskGetHandle( const char *pcNameToQuery ) PRIVILEGED_FUNCTION; /*
*/
UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;

/**
* task.h
* <PRE>uint8_t* pxTaskGetStackStart( TaskHandle_t xTask);</PRE>
*
* INCLUDE_pxTaskGetStackStart must be set to 1 in FreeRTOSConfig.h for
* this function to be available.
*
* Returns the start of the stack associated with xTask. That is,
* the highest stack memory address on architectures where the stack grows down
* from high memory, and the lowest memory address on architectures where the
* stack grows up from low memory.
*
* @param xTask Handle of the task associated with the stack returned.
* Set xTask to NULL to return the stack of the calling task.
*
* @return A pointer to the start of the stack.
*/
uint8_t* pxTaskGetStackStart( 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
Expand Down
39 changes: 36 additions & 3 deletions cores/nRF5/freertos/Source/tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,19 @@ count overflows. */
tracePOST_MOVED_TASK_TO_READY_STATE( pxTCB )
/*-----------------------------------------------------------*/

/*
* Place the task represented by pxTCB which has been in a ready list before
* into the appropriate ready list for the task.
* It is inserted at the end of the list.
*/
#define prvReaddTaskToReadyList( pxTCB ) \
traceREADDED_TASK_TO_READY_STATE( pxTCB ); \
taskRECORD_READY_PRIORITY( ( pxTCB )->uxPriority ); \
vListInsertEnd( &( pxReadyTasksLists[ ( pxTCB )->uxPriority ] ), &( ( pxTCB )->xStateListItem ) ); \
tracePOST_MOVED_TASK_TO_READY_STATE( pxTCB )
/*-----------------------------------------------------------*/


/*
* Several functions take an TaskHandle_t parameter that can optionally be NULL,
* where NULL is used to indicate that the handle of the currently executing
Expand Down Expand Up @@ -1598,7 +1611,7 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB )
{
mtCOVERAGE_TEST_MARKER();
}
prvAddTaskToReadyList( pxTCB );
prvReaddTaskToReadyList( pxTCB );
}
else
{
Expand Down Expand Up @@ -1660,6 +1673,7 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB )
mtCOVERAGE_TEST_MARKER();
}

traceMOVED_TASK_TO_SUSPENDED_LIST(pxTCB);
vListInsertEnd( &xSuspendedTaskList, &( pxTCB->xStateListItem ) );

#if( configUSE_TASK_NOTIFICATIONS == 1 )
Expand Down Expand Up @@ -3671,6 +3685,20 @@ static void prvCheckTasksWaitingTermination( void )
#endif /* INCLUDE_uxTaskGetStackHighWaterMark */
/*-----------------------------------------------------------*/

#if (INCLUDE_pxTaskGetStackStart == 1)
uint8_t* pxTaskGetStackStart( TaskHandle_t xTask)
{
TCB_t *pxTCB;
UBaseType_t uxReturn;
(void)uxReturn;

pxTCB = prvGetTCBFromHandle( xTask );
return ( uint8_t * ) pxTCB->pxStack;
}
#endif /* INCLUDE_pxTaskGetStackStart */
/*-----------------------------------------------------------*/


#if ( INCLUDE_vTaskDelete == 1 )

static void prvDeleteTCB( TCB_t *pxTCB )
Expand Down Expand Up @@ -3840,7 +3868,7 @@ TCB_t *pxTCB;

/* Inherit the priority before being moved into the new list. */
pxMutexHolderTCB->uxPriority = pxCurrentTCB->uxPriority;
prvAddTaskToReadyList( pxMutexHolderTCB );
prvReaddTaskToReadyList( pxMutexHolderTCB );
}
else
{
Expand Down Expand Up @@ -3930,7 +3958,7 @@ TCB_t *pxTCB;
any other purpose if this task is running, and it must be
running to give back the mutex. */
listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) pxTCB->uxPriority ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */
prvAddTaskToReadyList( pxTCB );
prvReaddTaskToReadyList( pxTCB );

/* Return true to indicate that a context switch is required.
This is only actually required in the corner case whereby
Expand Down Expand Up @@ -4943,6 +4971,7 @@ const TickType_t xConstTickCount = xTickCount;
/* Add the task to the suspended task list instead of a delayed task
list to ensure it is not woken by a timing event. It will block
indefinitely. */
traceMOVED_TASK_TO_SUSPENDED_LIST(pxCurrentTCB);
vListInsertEnd( &xSuspendedTaskList, &( pxCurrentTCB->xStateListItem ) );
}
else
Expand All @@ -4959,12 +4988,14 @@ const TickType_t xConstTickCount = xTickCount;
{
/* Wake time has overflowed. Place this item in the overflow
list. */
traceMOVED_TASK_TO_OVERFLOW_DELAYED_LIST();
vListInsert( pxOverflowDelayedTaskList, &( pxCurrentTCB->xStateListItem ) );
}
else
{
/* The wake time has not overflowed, so the current block list
is used. */
traceMOVED_TASK_TO_DELAYED_LIST();
vListInsert( pxDelayedTaskList, &( pxCurrentTCB->xStateListItem ) );

/* If the task entering the blocked state was placed at the
Expand Down Expand Up @@ -4994,11 +5025,13 @@ const TickType_t xConstTickCount = xTickCount;
if( xTimeToWake < xConstTickCount )
{
/* Wake time has overflowed. Place this item in the overflow list. */
traceMOVED_TASK_TO_OVERFLOW_DELAYED_LIST();
vListInsert( pxOverflowDelayedTaskList, &( pxCurrentTCB->xStateListItem ) );
}
else
{
/* The wake time has not overflowed, so the current block list is used. */
traceMOVED_TASK_TO_DELAYED_LIST();
vListInsert( pxDelayedTaskList, &( pxCurrentTCB->xStateListItem ) );

/* If the task entering the blocked state was placed at the head of the
Expand Down
6 changes: 6 additions & 0 deletions cores/nRF5/freertos/portable/CMSIS/nrf52/port_cmsis_systick.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@

void xPortSysTickHandler( void )
{
traceISR_ENTER();
#if configUSE_TICKLESS_IDLE == 1
nrf_rtc_event_clear(portNRF_RTC_REG, NRF_RTC_EVENT_COMPARE_0);
#endif
Expand Down Expand Up @@ -89,11 +90,16 @@ void xPortSysTickHandler( void )
/* Increment the RTOS tick as usual which checks if there is a need for rescheduling */
if ( switch_req != pdFALSE )
{
traceISR_EXIT_TO_SCHEDULER();
/* A context switch is required. Context switching is performed in
the PendSV interrupt. Pend the PendSV interrupt. */
SCB->ICSR = SCB_ICSR_PENDSVSET_Msk;
__SEV();
}
else
{
traceISR_EXIT();
}

portCLEAR_INTERRUPT_MASK_FROM_ISR( isrstate );
}
Expand Down
9 changes: 8 additions & 1 deletion cores/nRF5/freertos/portable/CMSIS/nrf52/portmacro_cmsis.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,14 @@ typedef unsigned long UBaseType_t;
__ISB(); \
}while (0)

#define portEND_SWITCHING_ISR( xSwitchRequired ) if ( (xSwitchRequired) != pdFALSE ) portYIELD()
#define portEND_SWITCHING_ISR( xSwitchRequired ) do { \
if( xSwitchRequired != pdFALSE ) { \
traceISR_EXIT_TO_SCHEDULER(); \
portYIELD(); \
} else { \
traceISR_EXIT(); \
} \
} while (0)
#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
/*-----------------------------------------------------------*/

Expand Down
31 changes: 7 additions & 24 deletions cores/nRF5/sysview/Config/Global.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*********************************************************************
* SEGGER Microcontroller GmbH & Co. KG *
* SEGGER Microcontroller GmbH *
* The Embedded Experts *
**********************************************************************
* *
* (c) 2015 - 2017 SEGGER Microcontroller GmbH & Co. KG *
* (c) 1995 - 2019 SEGGER Microcontroller GmbH *
* *
* www.segger.com Support: [email protected] *
* *
Expand All @@ -17,24 +17,14 @@
* *
* SEGGER strongly recommends to not make any changes *
* to or modify the source code of this software in order to stay *
* compatible with the RTT protocol and J-Link. *
* compatible with the SystemView and RTT protocol, and J-Link. *
* *
* Redistribution and use in source and binary forms, with or *
* without modification, are permitted provided that the following *
* conditions are met: *
* condition is met: *
* *
* o Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* *
* o 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. *
* *
* o Neither the name of SEGGER Microcontroller GmbH & Co. KG *
* nor the names of its contributors may be used to endorse or *
* promote products derived from this software without specific *
* prior written permission. *
* notice, this condition and the following disclaimer. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
Expand All @@ -52,17 +42,10 @@
* *
**********************************************************************
* *
* SystemView version: V2.52d *
* SystemView version: 3.10 *
* *
**********************************************************************
----------------------------------------------------------------------
File : Global.h
Purpose : Global types
In case your application already has a Global.h, you should
merge the files. In order to use Segger code, the types
U8, U16, U32, I8, I16, I32 need to be defined in Global.h;
additional definitions do not hurt.
---------------------------END-OF-HEADER------------------------------
-------------------------- END-OF-HEADER -----------------------------
*/

#ifndef GLOBAL_H // Guard against multiple inclusion
Expand Down
Loading