mirror of
https://github.com/0xFEEDC0DE64/arduino-esp32.git
synced 2025-07-03 13:56:32 +02:00
Update IDF to 1c3dd23
* Update mDNS and LEDC * update toolchain * Update IDF to 1c3dd23 * Advertise the board variant for Arduino OTA * Add generic variant definition for mDNS
This commit is contained in:
@ -974,18 +974,73 @@ typedef struct xSTATIC_QUEUE
|
||||
uint8_t ucDummy9;
|
||||
#endif
|
||||
|
||||
struct {
|
||||
volatile uint32_t ucDummy10;
|
||||
uint32_t ucDummy11;
|
||||
#ifdef CONFIG_FREERTOS_PORTMUX_DEBUG
|
||||
void *pvDummy8;
|
||||
UBaseType_t uxDummy12;
|
||||
#endif
|
||||
} sDummy1;
|
||||
portMUX_TYPE muxDummy; //Mutex required due to SMP
|
||||
|
||||
} StaticQueue_t;
|
||||
typedef StaticQueue_t StaticSemaphore_t;
|
||||
|
||||
/*
|
||||
* In line with software engineering best practice, especially when supplying a
|
||||
* library that is likely to change in future versions, FreeRTOS implements a
|
||||
* strict data hiding policy. This means the event group structure used
|
||||
* internally by FreeRTOS is not accessible to application code. However, if
|
||||
* the application writer wants to statically allocate the memory required to
|
||||
* create an event group then the size of the event group object needs to be
|
||||
* know. The StaticEventGroup_t structure below is provided for this purpose.
|
||||
* Its sizes and alignment requirements are guaranteed to match those of the
|
||||
* genuine structure, no matter which architecture is being used, and no matter
|
||||
* how the values in FreeRTOSConfig.h are set. Its contents are somewhat
|
||||
* obfuscated in the hope users will recognise that it would be unwise to make
|
||||
* direct use of the structure members.
|
||||
*/
|
||||
typedef struct xSTATIC_EVENT_GROUP
|
||||
{
|
||||
TickType_t xDummy1;
|
||||
StaticList_t xDummy2;
|
||||
|
||||
#if( configUSE_TRACE_FACILITY == 1 )
|
||||
UBaseType_t uxDummy3;
|
||||
#endif
|
||||
|
||||
#if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
|
||||
uint8_t ucDummy4;
|
||||
#endif
|
||||
|
||||
portMUX_TYPE muxDummy; //Mutex required due to SMP
|
||||
|
||||
} StaticEventGroup_t;
|
||||
|
||||
/*
|
||||
* In line with software engineering best practice, especially when supplying a
|
||||
* library that is likely to change in future versions, FreeRTOS implements a
|
||||
* strict data hiding policy. This means the software timer structure used
|
||||
* internally by FreeRTOS is not accessible to application code. However, if
|
||||
* the application writer wants to statically allocate the memory required to
|
||||
* create a software timer then the size of the queue object needs to be know.
|
||||
* The StaticTimer_t structure below is provided for this purpose. Its sizes
|
||||
* and alignment requirements are guaranteed to match those of the genuine
|
||||
* structure, no matter which architecture is being used, and no matter how the
|
||||
* values in FreeRTOSConfig.h are set. Its contents are somewhat obfuscated in
|
||||
* the hope users will recognise that it would be unwise to make direct use of
|
||||
* the structure members.
|
||||
*/
|
||||
typedef struct xSTATIC_TIMER
|
||||
{
|
||||
void *pvDummy1;
|
||||
StaticListItem_t xDummy2;
|
||||
TickType_t xDummy3;
|
||||
UBaseType_t uxDummy4;
|
||||
void *pvDummy5[ 2 ];
|
||||
#if( configUSE_TRACE_FACILITY == 1 )
|
||||
UBaseType_t uxDummy6;
|
||||
#endif
|
||||
|
||||
#if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
|
||||
uint8_t ucDummy7;
|
||||
#endif
|
||||
|
||||
} StaticTimer_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -104,7 +104,6 @@ extern "C" {
|
||||
* used to create a synchronisation point between multiple tasks (a
|
||||
* 'rendezvous').
|
||||
*
|
||||
* \defgroup EventGroup
|
||||
*/
|
||||
|
||||
|
||||
@ -116,7 +115,6 @@ extern "C" {
|
||||
* xEventGroupCreate() returns an EventGroupHandle_t variable that can then
|
||||
* be used as a parameter to other event group functions.
|
||||
*
|
||||
* \defgroup EventGroupHandle_t EventGroupHandle_t
|
||||
* \ingroup EventGroup
|
||||
*/
|
||||
typedef void * EventGroupHandle_t;
|
||||
@ -126,18 +124,22 @@ typedef void * EventGroupHandle_t;
|
||||
* number of bits it holds is set by configUSE_16_BIT_TICKS (16 bits if set to 1,
|
||||
* 32 bits if set to 0.
|
||||
*
|
||||
* \defgroup EventBits_t EventBits_t
|
||||
* \ingroup EventGroup
|
||||
*/
|
||||
typedef TickType_t EventBits_t;
|
||||
|
||||
/**
|
||||
* event_groups.h
|
||||
*<pre>
|
||||
EventGroupHandle_t xEventGroupCreate( void );
|
||||
</pre>
|
||||
* Create a new event group.
|
||||
*
|
||||
* Create a new event group. This function cannot be called from an interrupt.
|
||||
* Internally, within the FreeRTOS implementation, event groups use a [small]
|
||||
* block of memory, in which the event group's structure is stored. If an event
|
||||
* groups is created using xEventGroupCreate() then the required memory is
|
||||
* automatically dynamically allocated inside the xEventGroupCreate() function.
|
||||
* (see http://www.freertos.org/a00111.html). If an event group is created
|
||||
* using xEventGropuCreateStatic() then the application writer must instead
|
||||
* provide the memory that will get used by the event group.
|
||||
* xEventGroupCreateStatic() therefore allows an event group to be created
|
||||
* without using any dynamic memory allocation.
|
||||
*
|
||||
* Although event groups are not related to ticks, for internal implementation
|
||||
* reasons the number of bits available for use in an event group is dependent
|
||||
@ -152,39 +154,79 @@ typedef TickType_t EventBits_t;
|
||||
* event group then NULL is returned. See http://www.freertos.org/a00111.html
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
// Declare a variable to hold the created event group.
|
||||
EventGroupHandle_t xCreatedEventGroup;
|
||||
|
||||
// Attempt to create the event group.
|
||||
xCreatedEventGroup = xEventGroupCreate();
|
||||
|
||||
// Was the event group created successfully?
|
||||
if( xCreatedEventGroup == NULL )
|
||||
{
|
||||
// The event group was not created because there was insufficient
|
||||
// FreeRTOS heap available.
|
||||
}
|
||||
else
|
||||
{
|
||||
// The event group was created.
|
||||
}
|
||||
</pre>
|
||||
* \defgroup xEventGroupCreate xEventGroupCreate
|
||||
* @code{c}
|
||||
* // Declare a variable to hold the created event group.
|
||||
* EventGroupHandle_t xCreatedEventGroup;
|
||||
*
|
||||
* // Attempt to create the event group.
|
||||
* xCreatedEventGroup = xEventGroupCreate();
|
||||
*
|
||||
* // Was the event group created successfully?
|
||||
* if( xCreatedEventGroup == NULL )
|
||||
* {
|
||||
* // The event group was not created because there was insufficient
|
||||
* // FreeRTOS heap available.
|
||||
* }
|
||||
* else
|
||||
* {
|
||||
* // The event group was created.
|
||||
* }
|
||||
* @endcode
|
||||
* \ingroup EventGroup
|
||||
*/
|
||||
EventGroupHandle_t xEventGroupCreate( void ) PRIVILEGED_FUNCTION;
|
||||
#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
|
||||
EventGroupHandle_t xEventGroupCreate( void ) PRIVILEGED_FUNCTION;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* event_groups.h
|
||||
*<pre>
|
||||
EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup,
|
||||
const EventBits_t uxBitsToWaitFor,
|
||||
const BaseType_t xClearOnExit,
|
||||
const BaseType_t xWaitForAllBits,
|
||||
const TickType_t xTicksToWait );
|
||||
</pre>
|
||||
* Create a new event group.
|
||||
*
|
||||
* Internally, within the FreeRTOS implementation, event groups use a [small]
|
||||
* block of memory, in which the event group's structure is stored. If an event
|
||||
* groups is created using xEventGropuCreate() then the required memory is
|
||||
* automatically dynamically allocated inside the xEventGroupCreate() function.
|
||||
* (see http://www.freertos.org/a00111.html). If an event group is created
|
||||
* using xEventGropuCreateStatic() then the application writer must instead
|
||||
* provide the memory that will get used by the event group.
|
||||
* xEventGroupCreateStatic() therefore allows an event group to be created
|
||||
* without using any dynamic memory allocation.
|
||||
*
|
||||
* Although event groups are not related to ticks, for internal implementation
|
||||
* reasons the number of bits available for use in an event group is dependent
|
||||
* on the configUSE_16_BIT_TICKS setting in FreeRTOSConfig.h. If
|
||||
* configUSE_16_BIT_TICKS is 1 then each event group contains 8 usable bits (bit
|
||||
* 0 to bit 7). If configUSE_16_BIT_TICKS is set to 0 then each event group has
|
||||
* 24 usable bits (bit 0 to bit 23). The EventBits_t type is used to store
|
||||
* event bits within an event group.
|
||||
*
|
||||
* @param pxEventGroupBuffer pxEventGroupBuffer must point to a variable of type
|
||||
* StaticEventGroup_t, which will be then be used to hold the event group's data
|
||||
* structures, removing the need for the memory to be allocated dynamically.
|
||||
*
|
||||
* @return If the event group was created then a handle to the event group is
|
||||
* returned. If pxEventGroupBuffer was NULL then NULL is returned.
|
||||
*
|
||||
* Example usage:
|
||||
* @code{c}
|
||||
* // StaticEventGroup_t is a publicly accessible structure that has the same
|
||||
* // size and alignment requirements as the real event group structure. It is
|
||||
* // provided as a mechanism for applications to know the size of the event
|
||||
* // group (which is dependent on the architecture and configuration file
|
||||
* // settings) without breaking the strict data hiding policy by exposing the
|
||||
* // real event group internals. This StaticEventGroup_t variable is passed
|
||||
* // into the xSemaphoreCreateEventGroupStatic() function and is used to store
|
||||
* // the event group's data structures
|
||||
* StaticEventGroup_t xEventGroupBuffer;
|
||||
*
|
||||
* // Create the event group without dynamically allocating any memory.
|
||||
* xEventGroup = xEventGroupCreateStatic( &xEventGroupBuffer );
|
||||
* @endcode
|
||||
*/
|
||||
#if( configSUPPORT_STATIC_ALLOCATION == 1 )
|
||||
EventGroupHandle_t xEventGroupCreateStatic( StaticEventGroup_t *pxEventGroupBuffer ) PRIVILEGED_FUNCTION;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* [Potentially] block to wait for one or more bits to be set within a
|
||||
* previously created event group.
|
||||
*
|
||||
@ -227,54 +269,48 @@ EventGroupHandle_t xEventGroupCreate( void ) PRIVILEGED_FUNCTION;
|
||||
* pdTRUE.
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
#define BIT_0 ( 1 << 0 )
|
||||
#define BIT_4 ( 1 << 4 )
|
||||
|
||||
void aFunction( EventGroupHandle_t xEventGroup )
|
||||
{
|
||||
EventBits_t uxBits;
|
||||
const TickType_t xTicksToWait = 100 / portTICK_PERIOD_MS;
|
||||
|
||||
// Wait a maximum of 100ms for either bit 0 or bit 4 to be set within
|
||||
// the event group. Clear the bits before exiting.
|
||||
uxBits = xEventGroupWaitBits(
|
||||
xEventGroup, // The event group being tested.
|
||||
BIT_0 | BIT_4, // The bits within the event group to wait for.
|
||||
pdTRUE, // BIT_0 and BIT_4 should be cleared before returning.
|
||||
pdFALSE, // Don't wait for both bits, either bit will do.
|
||||
xTicksToWait ); // Wait a maximum of 100ms for either bit to be set.
|
||||
|
||||
if( ( uxBits & ( BIT_0 | BIT_4 ) ) == ( BIT_0 | BIT_4 ) )
|
||||
{
|
||||
// xEventGroupWaitBits() returned because both bits were set.
|
||||
}
|
||||
else if( ( uxBits & BIT_0 ) != 0 )
|
||||
{
|
||||
// xEventGroupWaitBits() returned because just BIT_0 was set.
|
||||
}
|
||||
else if( ( uxBits & BIT_4 ) != 0 )
|
||||
{
|
||||
// xEventGroupWaitBits() returned because just BIT_4 was set.
|
||||
}
|
||||
else
|
||||
{
|
||||
// xEventGroupWaitBits() returned because xTicksToWait ticks passed
|
||||
// without either BIT_0 or BIT_4 becoming set.
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
* \defgroup xEventGroupWaitBits xEventGroupWaitBits
|
||||
* @code{c}
|
||||
* #define BIT_0 ( 1 << 0 )
|
||||
* #define BIT_4 ( 1 << 4 )
|
||||
*
|
||||
* void aFunction( EventGroupHandle_t xEventGroup )
|
||||
* {
|
||||
* EventBits_t uxBits;
|
||||
* const TickType_t xTicksToWait = 100 / portTICK_PERIOD_MS;
|
||||
*
|
||||
* // Wait a maximum of 100ms for either bit 0 or bit 4 to be set within
|
||||
* // the event group. Clear the bits before exiting.
|
||||
* uxBits = xEventGroupWaitBits(
|
||||
* xEventGroup, // The event group being tested.
|
||||
* BIT_0 | BIT_4, // The bits within the event group to wait for.
|
||||
* pdTRUE, // BIT_0 and BIT_4 should be cleared before returning.
|
||||
* pdFALSE, // Don't wait for both bits, either bit will do.
|
||||
* xTicksToWait ); // Wait a maximum of 100ms for either bit to be set.
|
||||
*
|
||||
* if( ( uxBits & ( BIT_0 | BIT_4 ) ) == ( BIT_0 | BIT_4 ) )
|
||||
* {
|
||||
* // xEventGroupWaitBits() returned because both bits were set.
|
||||
* }
|
||||
* else if( ( uxBits & BIT_0 ) != 0 )
|
||||
* {
|
||||
* // xEventGroupWaitBits() returned because just BIT_0 was set.
|
||||
* }
|
||||
* else if( ( uxBits & BIT_4 ) != 0 )
|
||||
* {
|
||||
* // xEventGroupWaitBits() returned because just BIT_4 was set.
|
||||
* }
|
||||
* else
|
||||
* {
|
||||
* // xEventGroupWaitBits() returned because xTicksToWait ticks passed
|
||||
* // without either BIT_0 or BIT_4 becoming set.
|
||||
* }
|
||||
* }
|
||||
* @endcode{c}
|
||||
* \ingroup EventGroup
|
||||
*/
|
||||
EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToWaitFor, const BaseType_t xClearOnExit, const BaseType_t xWaitForAllBits, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
|
||||
|
||||
/**
|
||||
* event_groups.h
|
||||
*<pre>
|
||||
EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear );
|
||||
</pre>
|
||||
*
|
||||
* Clear bits within an event group. This function cannot be called from an
|
||||
* interrupt.
|
||||
*
|
||||
@ -287,51 +323,45 @@ EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup, const EventBits
|
||||
* @return The value of the event group before the specified bits were cleared.
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
#define BIT_0 ( 1 << 0 )
|
||||
#define BIT_4 ( 1 << 4 )
|
||||
|
||||
void aFunction( EventGroupHandle_t xEventGroup )
|
||||
{
|
||||
EventBits_t uxBits;
|
||||
|
||||
// Clear bit 0 and bit 4 in xEventGroup.
|
||||
uxBits = xEventGroupClearBits(
|
||||
xEventGroup, // The event group being updated.
|
||||
BIT_0 | BIT_4 );// The bits being cleared.
|
||||
|
||||
if( ( uxBits & ( BIT_0 | BIT_4 ) ) == ( BIT_0 | BIT_4 ) )
|
||||
{
|
||||
// Both bit 0 and bit 4 were set before xEventGroupClearBits() was
|
||||
// called. Both will now be clear (not set).
|
||||
}
|
||||
else if( ( uxBits & BIT_0 ) != 0 )
|
||||
{
|
||||
// Bit 0 was set before xEventGroupClearBits() was called. It will
|
||||
// now be clear.
|
||||
}
|
||||
else if( ( uxBits & BIT_4 ) != 0 )
|
||||
{
|
||||
// Bit 4 was set before xEventGroupClearBits() was called. It will
|
||||
// now be clear.
|
||||
}
|
||||
else
|
||||
{
|
||||
// Neither bit 0 nor bit 4 were set in the first place.
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
* \defgroup xEventGroupClearBits xEventGroupClearBits
|
||||
* @code{c}
|
||||
* #define BIT_0 ( 1 << 0 )
|
||||
* #define BIT_4 ( 1 << 4 )
|
||||
*
|
||||
* void aFunction( EventGroupHandle_t xEventGroup )
|
||||
* {
|
||||
* EventBits_t uxBits;
|
||||
*
|
||||
* // Clear bit 0 and bit 4 in xEventGroup.
|
||||
* uxBits = xEventGroupClearBits(
|
||||
* xEventGroup, // The event group being updated.
|
||||
* BIT_0 | BIT_4 );// The bits being cleared.
|
||||
*
|
||||
* if( ( uxBits & ( BIT_0 | BIT_4 ) ) == ( BIT_0 | BIT_4 ) )
|
||||
* {
|
||||
* // Both bit 0 and bit 4 were set before xEventGroupClearBits() was
|
||||
* // called. Both will now be clear (not set).
|
||||
* }
|
||||
* else if( ( uxBits & BIT_0 ) != 0 )
|
||||
* {
|
||||
* // Bit 0 was set before xEventGroupClearBits() was called. It will
|
||||
* // now be clear.
|
||||
* }
|
||||
* else if( ( uxBits & BIT_4 ) != 0 )
|
||||
* {
|
||||
* // Bit 4 was set before xEventGroupClearBits() was called. It will
|
||||
* // now be clear.
|
||||
* }
|
||||
* else
|
||||
* {
|
||||
* // Neither bit 0 nor bit 4 were set in the first place.
|
||||
* }
|
||||
* }
|
||||
* @endcode
|
||||
* \ingroup EventGroup
|
||||
*/
|
||||
EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear ) PRIVILEGED_FUNCTION;
|
||||
|
||||
/**
|
||||
* event_groups.h
|
||||
*<pre>
|
||||
BaseType_t xEventGroupClearBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet );
|
||||
</pre>
|
||||
*
|
||||
* A version of xEventGroupClearBits() that can be called from an interrupt.
|
||||
*
|
||||
* Setting bits in an event group is not a deterministic operation because there
|
||||
@ -355,28 +385,27 @@ EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBit
|
||||
* if the timer service queue was full.
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
#define BIT_0 ( 1 << 0 )
|
||||
#define BIT_4 ( 1 << 4 )
|
||||
|
||||
// An event group which it is assumed has already been created by a call to
|
||||
// xEventGroupCreate().
|
||||
EventGroupHandle_t xEventGroup;
|
||||
|
||||
void anInterruptHandler( void )
|
||||
{
|
||||
// Clear bit 0 and bit 4 in xEventGroup.
|
||||
xResult = xEventGroupClearBitsFromISR(
|
||||
xEventGroup, // The event group being updated.
|
||||
BIT_0 | BIT_4 ); // The bits being set.
|
||||
|
||||
if( xResult == pdPASS )
|
||||
{
|
||||
// The message was posted successfully.
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
* \defgroup xEventGroupSetBitsFromISR xEventGroupSetBitsFromISR
|
||||
* @code{c}
|
||||
* #define BIT_0 ( 1 << 0 )
|
||||
* #define BIT_4 ( 1 << 4 )
|
||||
*
|
||||
* // An event group which it is assumed has already been created by a call to
|
||||
* // xEventGroupCreate().
|
||||
* EventGroupHandle_t xEventGroup;
|
||||
*
|
||||
* void anInterruptHandler( void )
|
||||
* {
|
||||
* // Clear bit 0 and bit 4 in xEventGroup.
|
||||
* xResult = xEventGroupClearBitsFromISR(
|
||||
* xEventGroup, // The event group being updated.
|
||||
* BIT_0 | BIT_4 ); // The bits being set.
|
||||
*
|
||||
* if( xResult == pdPASS )
|
||||
* {
|
||||
* // The message was posted successfully.
|
||||
* }
|
||||
* }
|
||||
* @endcode
|
||||
* \ingroup EventGroup
|
||||
*/
|
||||
#if( configUSE_TRACE_FACILITY == 1 )
|
||||
@ -386,11 +415,6 @@ EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBit
|
||||
#endif
|
||||
|
||||
/**
|
||||
* event_groups.h
|
||||
*<pre>
|
||||
EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet );
|
||||
</pre>
|
||||
*
|
||||
* Set bits within an event group.
|
||||
* This function cannot be called from an interrupt. xEventGroupSetBitsFromISR()
|
||||
* is a version that can be called from an interrupt.
|
||||
@ -415,56 +439,50 @@ EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBit
|
||||
* event group value before the call to xEventGroupSetBits() returns.
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
#define BIT_0 ( 1 << 0 )
|
||||
#define BIT_4 ( 1 << 4 )
|
||||
|
||||
void aFunction( EventGroupHandle_t xEventGroup )
|
||||
{
|
||||
EventBits_t uxBits;
|
||||
|
||||
// Set bit 0 and bit 4 in xEventGroup.
|
||||
uxBits = xEventGroupSetBits(
|
||||
xEventGroup, // The event group being updated.
|
||||
BIT_0 | BIT_4 );// The bits being set.
|
||||
|
||||
if( ( uxBits & ( BIT_0 | BIT_4 ) ) == ( BIT_0 | BIT_4 ) )
|
||||
{
|
||||
// Both bit 0 and bit 4 remained set when the function returned.
|
||||
}
|
||||
else if( ( uxBits & BIT_0 ) != 0 )
|
||||
{
|
||||
// Bit 0 remained set when the function returned, but bit 4 was
|
||||
// cleared. It might be that bit 4 was cleared automatically as a
|
||||
// task that was waiting for bit 4 was removed from the Blocked
|
||||
// state.
|
||||
}
|
||||
else if( ( uxBits & BIT_4 ) != 0 )
|
||||
{
|
||||
// Bit 4 remained set when the function returned, but bit 0 was
|
||||
// cleared. It might be that bit 0 was cleared automatically as a
|
||||
// task that was waiting for bit 0 was removed from the Blocked
|
||||
// state.
|
||||
}
|
||||
else
|
||||
{
|
||||
// Neither bit 0 nor bit 4 remained set. It might be that a task
|
||||
// was waiting for both of the bits to be set, and the bits were
|
||||
// cleared as the task left the Blocked state.
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
* \defgroup xEventGroupSetBits xEventGroupSetBits
|
||||
* @code{c}
|
||||
* #define BIT_0 ( 1 << 0 )
|
||||
* #define BIT_4 ( 1 << 4 )
|
||||
*
|
||||
* void aFunction( EventGroupHandle_t xEventGroup )
|
||||
* {
|
||||
* EventBits_t uxBits;
|
||||
*
|
||||
* // Set bit 0 and bit 4 in xEventGroup.
|
||||
* uxBits = xEventGroupSetBits(
|
||||
* xEventGroup, // The event group being updated.
|
||||
* BIT_0 | BIT_4 );// The bits being set.
|
||||
*
|
||||
* if( ( uxBits & ( BIT_0 | BIT_4 ) ) == ( BIT_0 | BIT_4 ) )
|
||||
* {
|
||||
* // Both bit 0 and bit 4 remained set when the function returned.
|
||||
* }
|
||||
* else if( ( uxBits & BIT_0 ) != 0 )
|
||||
* {
|
||||
* // Bit 0 remained set when the function returned, but bit 4 was
|
||||
* // cleared. It might be that bit 4 was cleared automatically as a
|
||||
* // task that was waiting for bit 4 was removed from the Blocked
|
||||
* // state.
|
||||
* }
|
||||
* else if( ( uxBits & BIT_4 ) != 0 )
|
||||
* {
|
||||
* // Bit 4 remained set when the function returned, but bit 0 was
|
||||
* // cleared. It might be that bit 0 was cleared automatically as a
|
||||
* // task that was waiting for bit 0 was removed from the Blocked
|
||||
* // state.
|
||||
* }
|
||||
* else
|
||||
* {
|
||||
* // Neither bit 0 nor bit 4 remained set. It might be that a task
|
||||
* // was waiting for both of the bits to be set, and the bits were
|
||||
* // cleared as the task left the Blocked state.
|
||||
* }
|
||||
* }
|
||||
* @endcode{c}
|
||||
* \ingroup EventGroup
|
||||
*/
|
||||
EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet ) PRIVILEGED_FUNCTION;
|
||||
|
||||
/**
|
||||
* event_groups.h
|
||||
*<pre>
|
||||
BaseType_t xEventGroupSetBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, BaseType_t *pxHigherPriorityTaskWoken );
|
||||
</pre>
|
||||
*
|
||||
* A version of xEventGroupSetBits() that can be called from an interrupt.
|
||||
*
|
||||
* Setting bits in an event group is not a deterministic operation because there
|
||||
@ -496,39 +514,38 @@ EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_
|
||||
* if the timer service queue was full.
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
#define BIT_0 ( 1 << 0 )
|
||||
#define BIT_4 ( 1 << 4 )
|
||||
|
||||
// An event group which it is assumed has already been created by a call to
|
||||
// xEventGroupCreate().
|
||||
EventGroupHandle_t xEventGroup;
|
||||
|
||||
void anInterruptHandler( void )
|
||||
{
|
||||
BaseType_t xHigherPriorityTaskWoken, xResult;
|
||||
|
||||
// xHigherPriorityTaskWoken must be initialised to pdFALSE.
|
||||
xHigherPriorityTaskWoken = pdFALSE;
|
||||
|
||||
// Set bit 0 and bit 4 in xEventGroup.
|
||||
xResult = xEventGroupSetBitsFromISR(
|
||||
xEventGroup, // The event group being updated.
|
||||
BIT_0 | BIT_4 // The bits being set.
|
||||
&xHigherPriorityTaskWoken );
|
||||
|
||||
// Was the message posted successfully?
|
||||
if( xResult == pdPASS )
|
||||
{
|
||||
// If xHigherPriorityTaskWoken is now set to pdTRUE then a context
|
||||
// switch should be requested. The macro used is port specific and
|
||||
// will be either portYIELD_FROM_ISR() or portEND_SWITCHING_ISR() -
|
||||
// refer to the documentation page for the port being used.
|
||||
portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
* \defgroup xEventGroupSetBitsFromISR xEventGroupSetBitsFromISR
|
||||
* @code{c}
|
||||
* #define BIT_0 ( 1 << 0 )
|
||||
* #define BIT_4 ( 1 << 4 )
|
||||
*
|
||||
* // An event group which it is assumed has already been created by a call to
|
||||
* // xEventGroupCreate().
|
||||
* EventGroupHandle_t xEventGroup;
|
||||
*
|
||||
* void anInterruptHandler( void )
|
||||
* {
|
||||
* BaseType_t xHigherPriorityTaskWoken, xResult;
|
||||
*
|
||||
* // xHigherPriorityTaskWoken must be initialised to pdFALSE.
|
||||
* xHigherPriorityTaskWoken = pdFALSE;
|
||||
*
|
||||
* // Set bit 0 and bit 4 in xEventGroup.
|
||||
* xResult = xEventGroupSetBitsFromISR(
|
||||
* xEventGroup, // The event group being updated.
|
||||
* BIT_0 | BIT_4 // The bits being set.
|
||||
* &xHigherPriorityTaskWoken );
|
||||
*
|
||||
* // Was the message posted successfully?
|
||||
* if( xResult == pdPASS )
|
||||
* {
|
||||
* // If xHigherPriorityTaskWoken is now set to pdTRUE then a context
|
||||
* // switch should be requested. The macro used is port specific and
|
||||
* // will be either portYIELD_FROM_ISR() or portEND_SWITCHING_ISR() -
|
||||
* // refer to the documentation page for the port being used.
|
||||
* portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
|
||||
* }
|
||||
* }
|
||||
* @endcode
|
||||
* \ingroup EventGroup
|
||||
*/
|
||||
#if( configUSE_TRACE_FACILITY == 1 )
|
||||
@ -538,14 +555,6 @@ EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_
|
||||
#endif
|
||||
|
||||
/**
|
||||
* event_groups.h
|
||||
*<pre>
|
||||
EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup,
|
||||
const EventBits_t uxBitsToSet,
|
||||
const EventBits_t uxBitsToWaitFor,
|
||||
TickType_t xTicksToWait );
|
||||
</pre>
|
||||
*
|
||||
* Atomically set bits within an event group, then wait for a combination of
|
||||
* bits to be set within the same event group. This functionality is typically
|
||||
* used to synchronise multiple tasks, where each task has to wait for the other
|
||||
@ -583,93 +592,87 @@ EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_
|
||||
* automatically cleared.
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
// Bits used by the three tasks.
|
||||
#define TASK_0_BIT ( 1 << 0 )
|
||||
#define TASK_1_BIT ( 1 << 1 )
|
||||
#define TASK_2_BIT ( 1 << 2 )
|
||||
|
||||
#define ALL_SYNC_BITS ( TASK_0_BIT | TASK_1_BIT | TASK_2_BIT )
|
||||
|
||||
// Use an event group to synchronise three tasks. It is assumed this event
|
||||
// group has already been created elsewhere.
|
||||
EventGroupHandle_t xEventBits;
|
||||
|
||||
void vTask0( void *pvParameters )
|
||||
{
|
||||
EventBits_t uxReturn;
|
||||
TickType_t xTicksToWait = 100 / portTICK_PERIOD_MS;
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
// Perform task functionality here.
|
||||
|
||||
// Set bit 0 in the event flag to note this task has reached the
|
||||
// sync point. The other two tasks will set the other two bits defined
|
||||
// by ALL_SYNC_BITS. All three tasks have reached the synchronisation
|
||||
// point when all the ALL_SYNC_BITS are set. Wait a maximum of 100ms
|
||||
// for this to happen.
|
||||
uxReturn = xEventGroupSync( xEventBits, TASK_0_BIT, ALL_SYNC_BITS, xTicksToWait );
|
||||
|
||||
if( ( uxReturn & ALL_SYNC_BITS ) == ALL_SYNC_BITS )
|
||||
{
|
||||
// All three tasks reached the synchronisation point before the call
|
||||
// to xEventGroupSync() timed out.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void vTask1( void *pvParameters )
|
||||
{
|
||||
for( ;; )
|
||||
{
|
||||
// Perform task functionality here.
|
||||
|
||||
// Set bit 1 in the event flag to note this task has reached the
|
||||
// synchronisation point. The other two tasks will set the other two
|
||||
// bits defined by ALL_SYNC_BITS. All three tasks have reached the
|
||||
// synchronisation point when all the ALL_SYNC_BITS are set. Wait
|
||||
// indefinitely for this to happen.
|
||||
xEventGroupSync( xEventBits, TASK_1_BIT, ALL_SYNC_BITS, portMAX_DELAY );
|
||||
|
||||
// xEventGroupSync() was called with an indefinite block time, so
|
||||
// this task will only reach here if the syncrhonisation was made by all
|
||||
// three tasks, so there is no need to test the return value.
|
||||
}
|
||||
}
|
||||
|
||||
void vTask2( void *pvParameters )
|
||||
{
|
||||
for( ;; )
|
||||
{
|
||||
// Perform task functionality here.
|
||||
|
||||
// Set bit 2 in the event flag to note this task has reached the
|
||||
// synchronisation point. The other two tasks will set the other two
|
||||
// bits defined by ALL_SYNC_BITS. All three tasks have reached the
|
||||
// synchronisation point when all the ALL_SYNC_BITS are set. Wait
|
||||
// indefinitely for this to happen.
|
||||
xEventGroupSync( xEventBits, TASK_2_BIT, ALL_SYNC_BITS, portMAX_DELAY );
|
||||
|
||||
// xEventGroupSync() was called with an indefinite block time, so
|
||||
// this task will only reach here if the syncrhonisation was made by all
|
||||
// three tasks, so there is no need to test the return value.
|
||||
}
|
||||
}
|
||||
|
||||
</pre>
|
||||
* \defgroup xEventGroupSync xEventGroupSync
|
||||
* @code{c}
|
||||
* // Bits used by the three tasks.
|
||||
* #define TASK_0_BIT ( 1 << 0 )
|
||||
* #define TASK_1_BIT ( 1 << 1 )
|
||||
* #define TASK_2_BIT ( 1 << 2 )
|
||||
*
|
||||
* #define ALL_SYNC_BITS ( TASK_0_BIT | TASK_1_BIT | TASK_2_BIT )
|
||||
*
|
||||
* // Use an event group to synchronise three tasks. It is assumed this event
|
||||
* // group has already been created elsewhere.
|
||||
* EventGroupHandle_t xEventBits;
|
||||
*
|
||||
* void vTask0( void *pvParameters )
|
||||
* {
|
||||
* EventBits_t uxReturn;
|
||||
* TickType_t xTicksToWait = 100 / portTICK_PERIOD_MS;
|
||||
*
|
||||
* for( ;; )
|
||||
* {
|
||||
* // Perform task functionality here.
|
||||
*
|
||||
* // Set bit 0 in the event flag to note this task has reached the
|
||||
* // sync point. The other two tasks will set the other two bits defined
|
||||
* // by ALL_SYNC_BITS. All three tasks have reached the synchronisation
|
||||
* // point when all the ALL_SYNC_BITS are set. Wait a maximum of 100ms
|
||||
* // for this to happen.
|
||||
* uxReturn = xEventGroupSync( xEventBits, TASK_0_BIT, ALL_SYNC_BITS, xTicksToWait );
|
||||
*
|
||||
* if( ( uxReturn & ALL_SYNC_BITS ) == ALL_SYNC_BITS )
|
||||
* {
|
||||
* // All three tasks reached the synchronisation point before the call
|
||||
* // to xEventGroupSync() timed out.
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* void vTask1( void *pvParameters )
|
||||
* {
|
||||
* for( ;; )
|
||||
* {
|
||||
* // Perform task functionality here.
|
||||
*
|
||||
* // Set bit 1 in the event flag to note this task has reached the
|
||||
* // synchronisation point. The other two tasks will set the other two
|
||||
* // bits defined by ALL_SYNC_BITS. All three tasks have reached the
|
||||
* // synchronisation point when all the ALL_SYNC_BITS are set. Wait
|
||||
* // indefinitely for this to happen.
|
||||
* xEventGroupSync( xEventBits, TASK_1_BIT, ALL_SYNC_BITS, portMAX_DELAY );
|
||||
*
|
||||
* // xEventGroupSync() was called with an indefinite block time, so
|
||||
* // this task will only reach here if the syncrhonisation was made by all
|
||||
* // three tasks, so there is no need to test the return value.
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* void vTask2( void *pvParameters )
|
||||
* {
|
||||
* for( ;; )
|
||||
* {
|
||||
* // Perform task functionality here.
|
||||
*
|
||||
* // Set bit 2 in the event flag to note this task has reached the
|
||||
* // synchronisation point. The other two tasks will set the other two
|
||||
* // bits defined by ALL_SYNC_BITS. All three tasks have reached the
|
||||
* // synchronisation point when all the ALL_SYNC_BITS are set. Wait
|
||||
* // indefinitely for this to happen.
|
||||
* xEventGroupSync( xEventBits, TASK_2_BIT, ALL_SYNC_BITS, portMAX_DELAY );
|
||||
*
|
||||
* // xEventGroupSync() was called with an indefinite block time, so
|
||||
* // this task will only reach here if the syncrhonisation was made by all
|
||||
* // three tasks, so there is no need to test the return value.
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* @endcode
|
||||
* \ingroup EventGroup
|
||||
*/
|
||||
EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, const EventBits_t uxBitsToWaitFor, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
|
||||
|
||||
|
||||
/**
|
||||
* event_groups.h
|
||||
*<pre>
|
||||
EventBits_t xEventGroupGetBits( EventGroupHandle_t xEventGroup );
|
||||
</pre>
|
||||
*
|
||||
* Returns the current value of the bits in an event group. This function
|
||||
* cannot be used from an interrupt.
|
||||
*
|
||||
@ -677,33 +680,22 @@ EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup, const EventBits_t u
|
||||
*
|
||||
* @return The event group bits at the time xEventGroupGetBits() was called.
|
||||
*
|
||||
* \defgroup xEventGroupGetBits xEventGroupGetBits
|
||||
* \ingroup EventGroup
|
||||
*/
|
||||
#define xEventGroupGetBits( xEventGroup ) xEventGroupClearBits( xEventGroup, 0 )
|
||||
|
||||
/**
|
||||
* event_groups.h
|
||||
*<pre>
|
||||
EventBits_t xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup );
|
||||
</pre>
|
||||
*
|
||||
* A version of xEventGroupGetBits() that can be called from an ISR.
|
||||
*
|
||||
* @param xEventGroup The event group being queried.
|
||||
*
|
||||
* @return The event group bits at the time xEventGroupGetBitsFromISR() was called.
|
||||
*
|
||||
* \defgroup xEventGroupGetBitsFromISR xEventGroupGetBitsFromISR
|
||||
* \ingroup EventGroup
|
||||
*/
|
||||
EventBits_t xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup );
|
||||
|
||||
/**
|
||||
* event_groups.h
|
||||
*<pre>
|
||||
void xEventGroupDelete( EventGroupHandle_t xEventGroup );
|
||||
</pre>
|
||||
*
|
||||
* Delete an event group that was previously created by a call to
|
||||
* xEventGroupCreate(). Tasks that are blocked on the event group will be
|
||||
@ -713,6 +705,8 @@ EventBits_t xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup );
|
||||
*/
|
||||
void vEventGroupDelete( EventGroupHandle_t xEventGroup );
|
||||
|
||||
/** @cond */
|
||||
|
||||
/* For internal use only. */
|
||||
void vEventGroupSetBitsCallback( void *pvEventGroup, const uint32_t ulBitsToSet );
|
||||
void vEventGroupClearBitsCallback( void *pvEventGroup, const uint32_t ulBitsToClear );
|
||||
@ -721,6 +715,8 @@ void vEventGroupClearBitsCallback( void *pvEventGroup, const uint32_t ulBitsToCl
|
||||
UBaseType_t uxEventGroupGetNumber( void* xEventGroup );
|
||||
#endif
|
||||
|
||||
/** @endcond */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -264,7 +264,7 @@ static inline unsigned portENTER_CRITICAL_NESTED() {
|
||||
|
||||
//xTaskCreateStatic uses these functions to check incoming memory.
|
||||
#define portVALID_TCB_MEM(ptr) (esp_ptr_internal(ptr) && esp_ptr_byte_accessible(ptr))
|
||||
#ifndef CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY
|
||||
#ifdef CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY
|
||||
#define portVALID_STACK_MEM(ptr) esp_ptr_byte_accessible(ptr)
|
||||
#else
|
||||
#define portVALID_STACK_MEM(ptr) (esp_ptr_internal(ptr) && esp_ptr_byte_accessible(ptr))
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -9,50 +9,58 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
Header definitions for a FreeRTOS ringbuffer object
|
||||
|
||||
A ringbuffer instantiated by these functions essentially acts like a FreeRTOS queue, with the
|
||||
difference that it's strictly FIFO and with the main advantage that you can put in randomly-sized
|
||||
items. The capacity, accordingly, isn't measured in the amount of items, but the amount of memory
|
||||
that is used for storing the items. Dependent on the size of the items, more or less of them will
|
||||
fit in the ring buffer.
|
||||
|
||||
This ringbuffer tries to be efficient with memory: when inserting an item, the item data will
|
||||
be copied to the ringbuffer memory. When retrieving an item, however, a reference to ringbuffer
|
||||
memory will be returned. The returned memory is guaranteed to be 32-bit aligned and contiguous.
|
||||
The application can use this memory, but as long as it does, ringbuffer writes that would write
|
||||
to this bit of memory will block.
|
||||
|
||||
The requirement for items to be contiguous is slightly problematic when the only way to place
|
||||
the next item would involve a wraparound from the end to the beginning of the ringbuffer. This can
|
||||
be solved (or not) in a few ways:
|
||||
- type = RINGBUF_TYPE_ALLOWSPLIT: The insertion code will split the item in two items; one which fits
|
||||
in the space left at the end of the ringbuffer, one that contains the remaining data which is placed
|
||||
in the beginning. Two xRingbufferReceive calls will be needed to retrieve the data.
|
||||
- type = RINGBUF_TYPE_NOSPLIT: The insertion code will leave the room at the end of the ringbuffer
|
||||
unused and instead will put the entire item at the start of the ringbuffer, as soon as there is
|
||||
enough free space.
|
||||
- type = RINGBUF_TYPE_BYTEBUF: This is your conventional byte-based ringbuffer. It does have no
|
||||
overhead, but it has no item contiguousness either: a read will just give you the entire written
|
||||
buffer space, or the space up to the end of the buffer, and writes can be broken up in any way
|
||||
possible. Note that this type cannot do a 2nd read before returning the memory of the 1st.
|
||||
|
||||
The maximum size of an item will be affected by this decision. When split items are allowed, it's
|
||||
acceptable to push items of (buffer_size)-16 bytes into the buffer. When it's not allowed, the
|
||||
maximum size is (buffer_size/2)-8 bytes. The bytebuf can fill the entire buffer with data, it has
|
||||
no overhead.
|
||||
*/
|
||||
|
||||
#include <freertos/queue.h>
|
||||
|
||||
//An opaque handle for a ringbuff object.
|
||||
typedef void * RingbufHandle_t;
|
||||
|
||||
//The various types of buffer
|
||||
/**
|
||||
* @brief The various types of buffer
|
||||
*
|
||||
* A ringbuffer instantiated by these functions essentially acts like a
|
||||
* FreeRTOS queue, with the difference that it's strictly FIFO and with
|
||||
* the main advantage that you can put in randomly-sized items. The capacity,
|
||||
* accordingly, isn't measured in the amount of items, but the amount of
|
||||
* memory that is used for storing the items. Dependent on the size of
|
||||
* the items, more or less of them will fit in the ring buffer.
|
||||
*
|
||||
* This ringbuffer tries to be efficient with memory: when inserting an item,
|
||||
* the item data will be copied to the ringbuffer memory. When retrieving
|
||||
* an item, however, a reference to ringbuffer memory will be returned.
|
||||
* The returned memory is guaranteed to be 32-bit aligned and contiguous.
|
||||
* The application can use this memory, but as long as it does, ringbuffer
|
||||
* writes that would write to this bit of memory will block.
|
||||
*
|
||||
* The requirement for items to be contiguous is slightly problematic when
|
||||
* the only way to place the next item would involve a wraparound from the end
|
||||
* to the beginning of the ringbuffer. This can be solved (or not) in a few ways,
|
||||
* see descriptions of possible ringbuf_type_t types below.
|
||||
*
|
||||
* The maximum size of an item will be affected by ringbuffer type.
|
||||
* When split items are allowed, it is acceptable to push items of
|
||||
* (buffer_size)-16 bytes into the buffer.
|
||||
* When it's not allowed, the maximum size is (buffer_size/2)-8 bytes.
|
||||
* The bytebuf can fill the entire buffer with data, it has no overhead.
|
||||
*/
|
||||
typedef enum {
|
||||
/** The insertion code will leave the room at the end of the ringbuffer
|
||||
* unused and instead will put the entire item at the start of the ringbuffer,
|
||||
* as soon as there is enough free space.
|
||||
*/
|
||||
RINGBUF_TYPE_NOSPLIT = 0,
|
||||
/** The insertion code will split the item in two items; one which fits
|
||||
* in the space left at the end of the ringbuffer, one that contains
|
||||
* the remaining data which is placed in the beginning.
|
||||
* Two xRingbufferReceive calls will be needed to retrieve the data.
|
||||
*/
|
||||
RINGBUF_TYPE_ALLOWSPLIT,
|
||||
/** This is your conventional byte-based ringbuffer. It does have no
|
||||
* overhead, but it has no item contiguousness either: a read will just
|
||||
* give you the entire written buffer space, or the space up to the end
|
||||
* of the buffer, and writes can be broken up in any way possible.
|
||||
* Note that this type cannot do a 2nd read before returning the memory
|
||||
* of the 1st.
|
||||
*/
|
||||
RINGBUF_TYPE_BYTEBUF
|
||||
} ringbuf_type_t;
|
||||
|
||||
@ -60,22 +68,32 @@ typedef enum {
|
||||
/**
|
||||
* @brief Create a ring buffer
|
||||
*
|
||||
* @param buf_length : Length of circular buffer, in bytes. Each entry will take up its own length, plus a header
|
||||
* that at the moment is equal to sizeof(size_t).
|
||||
* @param allow_split_items : pdTRUE if it is acceptable that item data is inserted as two
|
||||
* items instead of one.
|
||||
* @param buf_length Length of circular buffer, in bytes. Each entry will
|
||||
* take up its own length, plus a header that at the moment
|
||||
* is equal to sizeof(size_t).
|
||||
* @param type Type of ring buffer, see ringbuf_type_t.
|
||||
*
|
||||
* @return A RingbufHandle_t handle to the created ringbuffer, or NULL in case of error.
|
||||
*/
|
||||
RingbufHandle_t xRingbufferCreate(size_t buf_length, ringbuf_type_t type);
|
||||
|
||||
/**
|
||||
* @brief Create a ring buffer of type RINGBUF_TYPE_NOSPLIT for a fixed item_size
|
||||
*
|
||||
* This API is similar to xRingbufferCreate(), but it will internally allocate
|
||||
* additional space for the headers.
|
||||
*
|
||||
* @param item_size Size of each item to be put into the ring buffer
|
||||
* @param num_item Maximum number of items the buffer needs to hold simultaneously
|
||||
*
|
||||
* @return A RingbufHandle_t handle to the created ringbuffer, or NULL in case of error.
|
||||
*/
|
||||
RingbufHandle_t xRingbufferCreateNoSplit(size_t item_size, size_t num_item);
|
||||
|
||||
/**
|
||||
* @brief Delete a ring buffer
|
||||
*
|
||||
* @param ringbuf - Ring buffer to delete
|
||||
*
|
||||
* @return void
|
||||
* @param ringbuf Ring buffer to delete
|
||||
*/
|
||||
void vRingbufferDelete(RingbufHandle_t ringbuf);
|
||||
|
||||
@ -83,23 +101,57 @@ void vRingbufferDelete(RingbufHandle_t ringbuf);
|
||||
/**
|
||||
* @brief Get maximum size of an item that can be placed in the ring buffer
|
||||
*
|
||||
* @param ringbuf - Ring buffer to query
|
||||
* @param ringbuf Ring buffer to query
|
||||
*
|
||||
* @return Maximum size, in bytes, of an item that can be placed in a ring buffer.
|
||||
*/
|
||||
size_t xRingbufferGetMaxItemSize(RingbufHandle_t ringbuf);
|
||||
|
||||
/**
|
||||
* @brief Get current free size available in the buffer
|
||||
*
|
||||
* This gives the real time free space available in the ring buffer. So basically,
|
||||
* this will be the maximum size of the entry that can be sent into the buffer.
|
||||
*
|
||||
* @note This API is not thread safe. So, if multiple threads are accessing the same
|
||||
* ring buffer, it is the application's responsibility to ensure atomic access to this
|
||||
* API and the subsequent Send
|
||||
*
|
||||
* @param ringbuf - Ring buffer to query
|
||||
*
|
||||
* @return Current free size, in bytes, available for an entry
|
||||
*/
|
||||
size_t xRingbufferGetCurFreeSize(RingbufHandle_t ringbuf);
|
||||
|
||||
/**
|
||||
* @brief Check if the next item is wrapped
|
||||
*
|
||||
* This API tells if the next item that is available for a Receive is wrapped
|
||||
* or not. This is valid only if the ring buffer type is RINGBUF_TYPE_ALLOWSPLIT
|
||||
*
|
||||
* @note This API is not thread safe. So, if multiple threads are accessing the same
|
||||
* ring buffer, it is the application's responsibility to ensure atomic access to this
|
||||
* API and the subsequent Receive
|
||||
*
|
||||
* @param ringbuf - Ring buffer to query
|
||||
*
|
||||
* @return true if the next item is wrapped around
|
||||
* @return false if the next item is not wrapped
|
||||
*/
|
||||
bool xRingbufferIsNextItemWrapped(RingbufHandle_t ringbuf);
|
||||
|
||||
/**
|
||||
* @brief Insert an item into the ring buffer
|
||||
*
|
||||
* @param ringbuf - Ring buffer to insert the item into
|
||||
* @param data - Pointer to data to insert. NULL is allowed if data_size is 0.
|
||||
* @param data_size - Size of data to insert. A value of 0 is allowed.
|
||||
* @param xTicksToWait - Ticks to wait for room in the ringbuffer.
|
||||
* @param ringbuf Ring buffer to insert the item into
|
||||
* @param data Pointer to data to insert. NULL is allowed if data_size is 0.
|
||||
* @param data_size Size of data to insert. A value of 0 is allowed.
|
||||
* @param ticks_to_wait Ticks to wait for room in the ringbuffer.
|
||||
*
|
||||
* @return pdTRUE if succeeded, pdFALSE on time-out or when the buffer is larger
|
||||
* than indicated by xRingbufferGetMaxItemSize(ringbuf).
|
||||
* @return
|
||||
* - pdTRUE if succeeded
|
||||
* - pdFALSE on time-out or when the buffer is larger than indicated
|
||||
* by xRingbufferGetMaxItemSize(ringbuf).
|
||||
*/
|
||||
BaseType_t xRingbufferSend(RingbufHandle_t ringbuf, void *data, size_t data_size, TickType_t ticks_to_wait);
|
||||
|
||||
@ -107,11 +159,11 @@ BaseType_t xRingbufferSend(RingbufHandle_t ringbuf, void *data, size_t data_size
|
||||
/**
|
||||
* @brief Insert an item into the ring buffer from an ISR
|
||||
*
|
||||
* @param ringbuf - Ring buffer to insert the item into
|
||||
* @param data - Pointer to data to insert. NULL is allowed if data_size is 0.
|
||||
* @param data_size - Size of data to insert. A value of 0 is allowed.
|
||||
* @param higher_prio_task_awoken - Value pointed to will be set to pdTRUE if the push woke up a higher
|
||||
* priority task.
|
||||
* @param ringbuf Ring buffer to insert the item into
|
||||
* @param data Pointer to data to insert. NULL is allowed if data_size is 0.
|
||||
* @param data_size Size of data to insert. A value of 0 is allowed.
|
||||
* @param[out] higher_prio_task_awoken Value pointed to will be set to pdTRUE
|
||||
* if the push woke up a higher priority task.
|
||||
*
|
||||
* @return pdTRUE if succeeded, pdFALSE when the ring buffer does not have space.
|
||||
*/
|
||||
@ -120,14 +172,18 @@ BaseType_t xRingbufferSendFromISR(RingbufHandle_t ringbuf, void *data, size_t da
|
||||
/**
|
||||
* @brief Retrieve an item from the ring buffer
|
||||
*
|
||||
* @note A call to vRingbufferReturnItem() is required after this to free up the data received.
|
||||
* @note A call to vRingbufferReturnItem() is required after this to free up
|
||||
* the data received.
|
||||
*
|
||||
* @param ringbuf - Ring buffer to retrieve the item from
|
||||
* @param item_size - Pointer to a variable to which the size of the retrieved item will be written.
|
||||
* @param xTicksToWait - Ticks to wait for items in the ringbuffer.
|
||||
* @param ringbuf Ring buffer to retrieve the item from
|
||||
* @param[out] item_size Pointer to a variable to which the size of the
|
||||
* retrieved item will be written.
|
||||
* @param ticks_to_wait Ticks to wait for items in the ringbuffer.
|
||||
*
|
||||
* @return Pointer to the retrieved item on success; *item_size filled with the length of the
|
||||
* item. NULL on timeout, *item_size is untouched in that case.
|
||||
* @return
|
||||
* - pointer to the retrieved item on success; *item_size filled with
|
||||
* the length of the item.
|
||||
* - NULL on timeout, *item_size is untouched in that case.
|
||||
*/
|
||||
void *xRingbufferReceive(RingbufHandle_t ringbuf, size_t *item_size, TickType_t ticks_to_wait);
|
||||
|
||||
@ -135,44 +191,58 @@ void *xRingbufferReceive(RingbufHandle_t ringbuf, size_t *item_size, TickType_t
|
||||
/**
|
||||
* @brief Retrieve an item from the ring buffer from an ISR
|
||||
*
|
||||
* @note A call to vRingbufferReturnItemFromISR() is required after this to free up the data received
|
||||
* @note A call to vRingbufferReturnItemFromISR() is required after this to
|
||||
* free up the data received
|
||||
*
|
||||
* @param ringbuf - Ring buffer to retrieve the item from
|
||||
* @param item_size - Pointer to a variable to which the size of the retrieved item will be written.
|
||||
* @param ringbuf Ring buffer to retrieve the item from
|
||||
* @param[out] item_size Pointer to a variable to which the size of the
|
||||
* retrieved item will be written.
|
||||
*
|
||||
* @return Pointer to the retrieved item on success; *item_size filled with the length of the
|
||||
* item. NULL when the ringbuffer is empty, *item_size is untouched in that case.
|
||||
* @return
|
||||
* - Pointer to the retrieved item on success; *item_size filled with
|
||||
* the length of the item.
|
||||
* - NULL when the ringbuffer is empty, *item_size is untouched in that case.
|
||||
*/
|
||||
void *xRingbufferReceiveFromISR(RingbufHandle_t ringbuf, size_t *item_size);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Retrieve bytes from a ByteBuf type of ring buffer, specifying the maximum amount of bytes
|
||||
* to return
|
||||
|
||||
* @note A call to vRingbufferReturnItem() is required after this to free up the data received.
|
||||
* @brief Retrieve bytes from a ByteBuf type of ring buffer,
|
||||
* specifying the maximum amount of bytes to return
|
||||
*
|
||||
* @param ringbuf - Ring buffer to retrieve the item from
|
||||
* @param item_size - Pointer to a variable to which the size of the retrieved item will be written.
|
||||
* @param xTicksToWait - Ticks to wait for items in the ringbuffer.
|
||||
* @note A call to vRingbufferReturnItem() is required after this to free up
|
||||
* the data received.
|
||||
*
|
||||
* @return Pointer to the retrieved item on success; *item_size filled with the length of the
|
||||
* item. NULL on timeout, *item_size is untouched in that case.
|
||||
* @param ringbuf Ring buffer to retrieve the item from
|
||||
* @param[out] item_size Pointer to a variable to which the size
|
||||
* of the retrieved item will be written.
|
||||
* @param ticks_to_wait Ticks to wait for items in the ringbuffer.
|
||||
* @param wanted_size Maximum number of bytes to return.
|
||||
*
|
||||
* @return
|
||||
* - Pointer to the retrieved item on success; *item_size filled with
|
||||
* the length of the item.
|
||||
* - NULL on timeout, *item_size is untouched in that case.
|
||||
*/
|
||||
void *xRingbufferReceiveUpTo(RingbufHandle_t ringbuf, size_t *item_size, TickType_t ticks_to_wait, size_t wanted_size);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Retrieve bytes from a ByteBuf type of ring buffer, specifying the maximum amount of bytes
|
||||
* to return. Call this from an ISR.
|
||||
* @brief Retrieve bytes from a ByteBuf type of ring buffer,
|
||||
* specifying the maximum amount of bytes to return. Call this from an ISR.
|
||||
*
|
||||
* @note A call to vRingbufferReturnItemFromISR() is required after this to free up the data received
|
||||
* @note A call to vRingbufferReturnItemFromISR() is required after this
|
||||
* to free up the data received.
|
||||
*
|
||||
* @param ringbuf - Ring buffer to retrieve the item from
|
||||
* @param item_size - Pointer to a variable to which the size of the retrieved item will be written.
|
||||
* @param ringbuf Ring buffer to retrieve the item from
|
||||
* @param[out] item_size Pointer to a variable to which the size of the
|
||||
* retrieved item will be written.
|
||||
* @param wanted_size Maximum number of bytes to return.
|
||||
*
|
||||
* @return Pointer to the retrieved item on success; *item_size filled with the length of the
|
||||
* item. NULL when the ringbuffer is empty, *item_size is untouched in that case.
|
||||
* @return
|
||||
* - Pointer to the retrieved item on success; *item_size filled with
|
||||
* the length of the item.
|
||||
* - NULL when the ringbuffer is empty, *item_size is untouched in that case.
|
||||
*/
|
||||
void *xRingbufferReceiveUpToFromISR(RingbufHandle_t ringbuf, size_t *item_size, size_t wanted_size);
|
||||
|
||||
@ -181,10 +251,8 @@ void *xRingbufferReceiveUpToFromISR(RingbufHandle_t ringbuf, size_t *item_size,
|
||||
/**
|
||||
* @brief Return a previously-retrieved item to the ringbuffer
|
||||
*
|
||||
* @param ringbuf - Ring buffer the item was retrieved from
|
||||
* @param item - Item that was received earlier
|
||||
*
|
||||
* @return void
|
||||
* @param ringbuf Ring buffer the item was retrieved from
|
||||
* @param item Item that was received earlier
|
||||
*/
|
||||
void vRingbufferReturnItem(RingbufHandle_t ringbuf, void *item);
|
||||
|
||||
@ -193,34 +261,37 @@ void vRingbufferReturnItem(RingbufHandle_t ringbuf, void *item);
|
||||
/**
|
||||
* @brief Return a previously-retrieved item to the ringbuffer from an ISR
|
||||
*
|
||||
* @param ringbuf - Ring buffer the item was retrieved from
|
||||
* @param item - Item that was received earlier
|
||||
* @param higher_prio_task_awoken - Value pointed to will be set to pdTRUE if the push woke up a higher
|
||||
* priority task.
|
||||
*
|
||||
* @return void
|
||||
* @param ringbuf Ring buffer the item was retrieved from
|
||||
* @param item Item that was received earlier
|
||||
* @param[out] higher_prio_task_awoken Value pointed to will be set to pdTRUE
|
||||
* if the push woke up a higher priority task.
|
||||
*/
|
||||
void vRingbufferReturnItemFromISR(RingbufHandle_t ringbuf, void *item, BaseType_t *higher_prio_task_awoken);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Add the ringbuffer to a queue set. This specifically adds the semaphore that indicates
|
||||
* more space has become available in the ringbuffer.
|
||||
* @brief Add the ringbuffer to a queue set.
|
||||
*
|
||||
* @param ringbuf - Ring buffer to add to the queue set
|
||||
* @param xQueueSet - Queue set to add the ringbuffer to
|
||||
* This specifically adds the semaphore that indicates more space
|
||||
* has become available in the ringbuffer.
|
||||
*
|
||||
* @return pdTRUE on success, pdFALSE otherwise
|
||||
* @param ringbuf Ring buffer to add to the queue set
|
||||
* @param xQueueSet Queue set to add the ringbuffer to
|
||||
*
|
||||
* @return
|
||||
* - pdTRUE on success, pdFALSE otherwise
|
||||
*/
|
||||
BaseType_t xRingbufferAddToQueueSetRead(RingbufHandle_t ringbuf, QueueSetHandle_t xQueueSet);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Add the ringbuffer to a queue set. This specifically adds the semaphore that indicates
|
||||
* something has been written into the ringbuffer.
|
||||
* @brief Add the ringbuffer to a queue set.
|
||||
*
|
||||
* @param ringbuf - Ring buffer to add to the queue set
|
||||
* @param xQueueSet - Queue set to add the ringbuffer to
|
||||
* This specifically adds the semaphore that indicates something has been
|
||||
* written into the ringbuffer.
|
||||
*
|
||||
* @param ringbuf Ring buffer to add to the queue set
|
||||
* @param xQueueSet Queue set to add the ringbuffer to
|
||||
*
|
||||
* @return pdTRUE on success, pdFALSE otherwise
|
||||
*/
|
||||
@ -228,11 +299,13 @@ BaseType_t xRingbufferAddToQueueSetWrite(RingbufHandle_t ringbuf, QueueSetHandle
|
||||
|
||||
|
||||
/**
|
||||
* @brief Remove the ringbuffer from a queue set. This specifically removes the semaphore that indicates
|
||||
* more space has become available in the ringbuffer.
|
||||
* @brief Remove the ringbuffer from a queue set.
|
||||
*
|
||||
* @param ringbuf - Ring buffer to remove from the queue set
|
||||
* @param xQueueSet - Queue set to remove the ringbuffer from
|
||||
* This specifically removes the semaphore that indicates more space
|
||||
* has become available in the ringbuffer.
|
||||
*
|
||||
* @param ringbuf Ring buffer to remove from the queue set
|
||||
* @param xQueueSet Queue set to remove the ringbuffer from
|
||||
*
|
||||
* @return pdTRUE on success, pdFALSE otherwise
|
||||
*/
|
||||
@ -240,11 +313,13 @@ BaseType_t xRingbufferRemoveFromQueueSetRead(RingbufHandle_t ringbuf, QueueSetHa
|
||||
|
||||
|
||||
/**
|
||||
* @brief Remove the ringbuffer from a queue set. This specifically removes the semaphore that indicates
|
||||
* something has been written to the ringbuffer.
|
||||
* @brief Remove the ringbuffer from a queue set.
|
||||
*
|
||||
* @param ringbuf - Ring buffer to remove from the queue set
|
||||
* @param xQueueSet - Queue set to remove the ringbuffer from
|
||||
* This specifically removes the semaphore that indicates something
|
||||
* has been written to the ringbuffer.
|
||||
*
|
||||
* @param ringbuf Ring buffer to remove from the queue set
|
||||
* @param xQueueSet Queue set to remove the ringbuffer from
|
||||
*
|
||||
* @return pdTRUE on success, pdFALSE otherwise
|
||||
*/
|
||||
@ -254,9 +329,7 @@ BaseType_t xRingbufferRemoveFromQueueSetWrite(RingbufHandle_t ringbuf, QueueSetH
|
||||
/**
|
||||
* @brief Debugging function to print the internal pointers in the ring buffer
|
||||
*
|
||||
* @param ringbuf - Ring buffer to show
|
||||
*
|
||||
* @return void
|
||||
* @param ringbuf Ring buffer to show
|
||||
*/
|
||||
void xRingbufferPrintInfo(RingbufHandle_t ringbuf);
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -117,27 +117,29 @@ or interrupt version of the queue send function should be used. */
|
||||
*/
|
||||
typedef void * TimerHandle_t;
|
||||
|
||||
/*
|
||||
/**
|
||||
* Defines the prototype to which timer callback functions must conform.
|
||||
*/
|
||||
typedef void (*TimerCallbackFunction_t)( TimerHandle_t xTimer );
|
||||
|
||||
/*
|
||||
/**
|
||||
* Defines the prototype to which functions used with the
|
||||
* xTimerPendFunctionCallFromISR() function must conform.
|
||||
*/
|
||||
typedef void (*PendedFunction_t)( void *, uint32_t );
|
||||
|
||||
/**
|
||||
* TimerHandle_t xTimerCreate( const char * const pcTimerName,
|
||||
* TickType_t xTimerPeriodInTicks,
|
||||
* UBaseType_t uxAutoReload,
|
||||
* void * pvTimerID,
|
||||
* TimerCallbackFunction_t pxCallbackFunction );
|
||||
* Creates a new software timer instance, and returns a handle by which the
|
||||
* created software timer can be referenced.
|
||||
*
|
||||
* Creates a new software timer instance. This allocates the storage required
|
||||
* by the new timer, initialises the new timers internal state, and returns a
|
||||
* handle by which the new timer can be referenced.
|
||||
* Internally, within the FreeRTOS implementation, software timers use a block
|
||||
* of memory, in which the timer data structure is stored. If a software timer
|
||||
* is created using xTimerCreate() then the required memory is automatically
|
||||
* dynamically allocated inside the xTimerCreate() function. (see
|
||||
* http://www.freertos.org/a00111.html). If a software timer is created using
|
||||
* xTimerCreateStatic() then the application writer must provide the memory that
|
||||
* will get used by the software timer. xTimerCreateStatic() therefore allows a
|
||||
* software timer to be created without using any dynamic memory allocation.
|
||||
*
|
||||
* Timers are created in the dormant state. The xTimerStart(), xTimerReset(),
|
||||
* xTimerStartFromISR(), xTimerResetFromISR(), xTimerChangePeriod() and
|
||||
@ -176,7 +178,7 @@ typedef void (*PendedFunction_t)( void *, uint32_t );
|
||||
* structures, or the timer period was set to 0) then NULL is returned.
|
||||
*
|
||||
* Example usage:
|
||||
* @verbatim
|
||||
* @code{c}
|
||||
* #define NUM_TIMERS 5
|
||||
*
|
||||
* // An array to hold handles to the created timers.
|
||||
@ -250,18 +252,146 @@ typedef void (*PendedFunction_t)( void *, uint32_t );
|
||||
*
|
||||
* // Starting the scheduler will start the timers running as they have already
|
||||
* // been set into the active state.
|
||||
* xTaskStartScheduler();
|
||||
* vTaskStartScheduler();
|
||||
*
|
||||
* // Should not reach here.
|
||||
* for( ;; );
|
||||
* }
|
||||
* @endverbatim
|
||||
* @endcode
|
||||
*/
|
||||
TimerHandle_t xTimerCreate( const char * const pcTimerName, const TickType_t xTimerPeriodInTicks, const UBaseType_t uxAutoReload, void * const pvTimerID, TimerCallbackFunction_t pxCallbackFunction ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
|
||||
#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
|
||||
TimerHandle_t xTimerCreate( const char * const pcTimerName,
|
||||
const TickType_t xTimerPeriodInTicks,
|
||||
const UBaseType_t uxAutoReload,
|
||||
void * const pvTimerID,
|
||||
TimerCallbackFunction_t pxCallbackFunction ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Creates a new software timer instance, and returns a handle by which the
|
||||
* created software timer can be referenced.
|
||||
*
|
||||
* Internally, within the FreeRTOS implementation, software timers use a block
|
||||
* of memory, in which the timer data structure is stored. If a software timer
|
||||
* is created using xTimerCreate() then the required memory is automatically
|
||||
* dynamically allocated inside the xTimerCreate() function. (see
|
||||
* http://www.freertos.org/a00111.html). If a software timer is created using
|
||||
* xTimerCreateStatic() then the application writer must provide the memory that
|
||||
* will get used by the software timer. xTimerCreateStatic() therefore allows a
|
||||
* software timer to be created without using any dynamic memory allocation.
|
||||
*
|
||||
* Timers are created in the dormant state. The xTimerStart(), xTimerReset(),
|
||||
* xTimerStartFromISR(), xTimerResetFromISR(), xTimerChangePeriod() and
|
||||
* xTimerChangePeriodFromISR() API functions can all be used to transition a
|
||||
* timer into the active state.
|
||||
*
|
||||
* @param pcTimerName A text name that is assigned to the timer. This is done
|
||||
* purely to assist debugging. The kernel itself only ever references a timer
|
||||
* by its handle, and never by its name.
|
||||
*
|
||||
* @param xTimerPeriodInTicks The timer period. The time is defined in tick
|
||||
* periods so the constant portTICK_PERIOD_MS can be used to convert a time that
|
||||
* has been specified in milliseconds. For example, if the timer must expire
|
||||
* 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.
|
||||
*
|
||||
* @param uxAutoReload If uxAutoReload is set to pdTRUE then the timer will
|
||||
* expire repeatedly with a frequency set by the xTimerPeriodInTicks parameter.
|
||||
* If uxAutoReload is set to pdFALSE then the timer will be a one-shot timer and
|
||||
* enter the dormant state after it expires.
|
||||
*
|
||||
* @param pvTimerID An identifier that is assigned to the timer being created.
|
||||
* Typically this would be used in the timer callback function to identify which
|
||||
* timer expired when the same callback function is assigned to more than one
|
||||
* timer.
|
||||
*
|
||||
* @param pxCallbackFunction The function to call when the timer expires.
|
||||
* Callback functions must have the prototype defined by TimerCallbackFunction_t,
|
||||
* which is "void vCallbackFunction( TimerHandle_t xTimer );".
|
||||
*
|
||||
* @param pxTimerBuffer Must point to a variable of type StaticTimer_t, which
|
||||
* will be then be used to hold the software timer's data structures, removing
|
||||
* the need for the memory to be allocated dynamically.
|
||||
*
|
||||
* @return If the timer is created then a handle to the created timer is
|
||||
* returned. If pxTimerBuffer was NULL then NULL is returned.
|
||||
*
|
||||
* Example usage:
|
||||
* @code{c}
|
||||
*
|
||||
* // The buffer used to hold the software timer's data structure.
|
||||
* static StaticTimer_t xTimerBuffer;
|
||||
*
|
||||
* // A variable that will be incremented by the software timer's callback
|
||||
* // function.
|
||||
* UBaseType_t uxVariableToIncrement = 0;
|
||||
*
|
||||
* // A software timer callback function that increments a variable passed to
|
||||
* // it when the software timer was created. After the 5th increment the
|
||||
* // callback function stops the software timer.
|
||||
* static void prvTimerCallback( TimerHandle_t xExpiredTimer )
|
||||
* {
|
||||
* UBaseType_t *puxVariableToIncrement;
|
||||
* BaseType_t xReturned;
|
||||
*
|
||||
* // Obtain the address of the variable to increment from the timer ID.
|
||||
* puxVariableToIncrement = ( UBaseType_t * ) pvTimerGetTimerID( xExpiredTimer );
|
||||
*
|
||||
* // Increment the variable to show the timer callback has executed.
|
||||
* ( *puxVariableToIncrement )++;
|
||||
*
|
||||
* // If this callback has executed the required number of times, stop the
|
||||
* // timer.
|
||||
* if( *puxVariableToIncrement == 5 )
|
||||
* {
|
||||
* // This is called from a timer callback so must not block.
|
||||
* xTimerStop( xExpiredTimer, staticDONT_BLOCK );
|
||||
* }
|
||||
* }
|
||||
*
|
||||
*
|
||||
* void main( void )
|
||||
* {
|
||||
* // Create the software time. xTimerCreateStatic() has an extra parameter
|
||||
* // than the normal xTimerCreate() API function. The parameter is a pointer
|
||||
* // to the StaticTimer_t structure that will hold the software timer
|
||||
* // structure. If the parameter is passed as NULL then the structure will be
|
||||
* // allocated dynamically, just as if xTimerCreate() had been called.
|
||||
* xTimer = xTimerCreateStatic( "T1", // Text name for the task. Helps debugging only. Not used by FreeRTOS.
|
||||
* xTimerPeriod, // The period of the timer in ticks.
|
||||
* pdTRUE, // This is an auto-reload timer.
|
||||
* ( void * ) &uxVariableToIncrement, // A variable incremented by the software timer's callback function
|
||||
* prvTimerCallback, // The function to execute when the timer expires.
|
||||
* &xTimerBuffer ); // The buffer that will hold the software timer structure.
|
||||
*
|
||||
* // The scheduler has not started yet so a block time is not used.
|
||||
* xReturned = xTimerStart( xTimer, 0 );
|
||||
*
|
||||
* // ...
|
||||
* // Create tasks here.
|
||||
* // ...
|
||||
*
|
||||
* // Starting the scheduler will start the timers running as they have already
|
||||
* // been set into the active state.
|
||||
* vTaskStartScheduler();
|
||||
*
|
||||
* // Should not reach here.
|
||||
* for( ;; );
|
||||
* }
|
||||
* @endcode
|
||||
*/
|
||||
#if( configSUPPORT_STATIC_ALLOCATION == 1 )
|
||||
TimerHandle_t xTimerCreateStatic( const char * const pcTimerName,
|
||||
const TickType_t xTimerPeriodInTicks,
|
||||
const UBaseType_t uxAutoReload,
|
||||
void * const pvTimerID,
|
||||
TimerCallbackFunction_t pxCallbackFunction,
|
||||
StaticTimer_t *pxTimerBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
|
||||
#endif /* configSUPPORT_STATIC_ALLOCATION */
|
||||
|
||||
/**
|
||||
* void *pvTimerGetTimerID( TimerHandle_t xTimer );
|
||||
*
|
||||
* Returns the ID assigned to the timer.
|
||||
*
|
||||
* IDs are assigned to timers using the pvTimerID parameter of the call to
|
||||
@ -282,12 +412,31 @@ TimerHandle_t xTimerCreate( const char * const pcTimerName, const TickType_t xTi
|
||||
void *pvTimerGetTimerID( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
|
||||
|
||||
/**
|
||||
* BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer );
|
||||
* Sets the ID assigned to the timer.
|
||||
*
|
||||
* IDs are assigned to timers using the pvTimerID parameter of the call to
|
||||
* xTimerCreated() that was used to create the timer.
|
||||
*
|
||||
* If the same callback function is assigned to multiple timers then the timer
|
||||
* ID can be used as time specific (timer local) storage.
|
||||
*
|
||||
* @param xTimer The timer being updated.
|
||||
*
|
||||
* @param pvNewID The ID to assign to the timer.
|
||||
*
|
||||
* Example usage:
|
||||
*
|
||||
* See the xTimerCreate() API function example usage scenario.
|
||||
*/
|
||||
void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID ) PRIVILEGED_FUNCTION;
|
||||
|
||||
/**
|
||||
* Queries a timer to see if it is active or dormant.
|
||||
*
|
||||
* A timer will be dormant if:
|
||||
*
|
||||
* 1) It has been created but not started, or
|
||||
*
|
||||
* 2) It is an expired one-shot timer that has not been restarted.
|
||||
*
|
||||
* Timers are created in the dormant state. The xTimerStart(), xTimerReset(),
|
||||
@ -301,7 +450,7 @@ void *pvTimerGetTimerID( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
|
||||
* pdFALSE will be returned if the timer is active.
|
||||
*
|
||||
* Example usage:
|
||||
* @verbatim
|
||||
* @code{c}
|
||||
* // This function assumes xTimer has already been created.
|
||||
* void vAFunction( TimerHandle_t xTimer )
|
||||
* {
|
||||
@ -314,13 +463,11 @@ void *pvTimerGetTimerID( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
|
||||
* // xTimer is not active, do something else.
|
||||
* }
|
||||
* }
|
||||
* @endverbatim
|
||||
* @endcode
|
||||
*/
|
||||
BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
|
||||
|
||||
/**
|
||||
* TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );
|
||||
*
|
||||
* xTimerGetTimerDaemonTaskHandle() is only available if
|
||||
* INCLUDE_xTimerGetTimerDaemonTaskHandle is set to 1 in FreeRTOSConfig.h.
|
||||
*
|
||||
@ -330,8 +477,28 @@ BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
|
||||
TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );
|
||||
|
||||
/**
|
||||
* BaseType_t xTimerStart( TimerHandle_t xTimer, TickType_t xTicksToWait );
|
||||
* Returns the period of a timer.
|
||||
*
|
||||
* @param xTimer The handle of the timer being queried.
|
||||
*
|
||||
* @return The period of the timer in ticks.
|
||||
*/
|
||||
TickType_t xTimerGetPeriod( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
|
||||
|
||||
/**
|
||||
* Returns the time in ticks at which the timer will expire. If this is less
|
||||
* than the current tick count then the expiry time has overflowed from the
|
||||
* current time.
|
||||
*
|
||||
* @param xTimer The handle of the timer being queried.
|
||||
*
|
||||
* @return If the timer is running then the time in ticks at which the timer
|
||||
* will next expire is returned. If the timer is not running then the return
|
||||
* value is undefined.
|
||||
*/
|
||||
TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
|
||||
|
||||
/**
|
||||
* Timer functionality is provided by a timer service/daemon task. Many of the
|
||||
* public FreeRTOS timer API functions send commands to the timer service task
|
||||
* through a queue called the timer command queue. The timer command queue is
|
||||
@ -382,8 +549,6 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );
|
||||
#define xTimerStart( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START, ( xTaskGetTickCount() ), NULL, ( xTicksToWait ) )
|
||||
|
||||
/**
|
||||
* BaseType_t xTimerStop( TimerHandle_t xTimer, TickType_t xTicksToWait );
|
||||
*
|
||||
* Timer functionality is provided by a timer service/daemon task. Many of the
|
||||
* public FreeRTOS timer API functions send commands to the timer service task
|
||||
* through a queue called the timer command queue. The timer command queue is
|
||||
@ -424,10 +589,6 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );
|
||||
#define xTimerStop( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_STOP, 0U, NULL, ( xTicksToWait ) )
|
||||
|
||||
/**
|
||||
* BaseType_t xTimerChangePeriod( TimerHandle_t xTimer,
|
||||
* TickType_t xNewPeriod,
|
||||
* TickType_t xTicksToWait );
|
||||
*
|
||||
* Timer functionality is provided by a timer service/daemon task. Many of the
|
||||
* public FreeRTOS timer API functions send commands to the timer service task
|
||||
* through a queue called the timer command queue. The timer command queue is
|
||||
@ -469,7 +630,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );
|
||||
* configTIMER_TASK_PRIORITY configuration constant.
|
||||
*
|
||||
* Example usage:
|
||||
* @verbatim
|
||||
* @code{c}
|
||||
* // This function assumes xTimer has already been created. If the timer
|
||||
* // referenced by xTimer is already active when it is called, then the timer
|
||||
* // is deleted. If the timer referenced by xTimer is not active when it is
|
||||
@ -499,13 +660,11 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* @endverbatim
|
||||
* @endcode
|
||||
*/
|
||||
#define xTimerChangePeriod( xTimer, xNewPeriod, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_CHANGE_PERIOD, ( xNewPeriod ), NULL, ( xTicksToWait ) )
|
||||
|
||||
/**
|
||||
* BaseType_t xTimerDelete( TimerHandle_t xTimer, TickType_t xTicksToWait );
|
||||
*
|
||||
* Timer functionality is provided by a timer service/daemon task. Many of the
|
||||
* public FreeRTOS timer API functions send commands to the timer service task
|
||||
* through a queue called the timer command queue. The timer command queue is
|
||||
@ -542,8 +701,6 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );
|
||||
#define xTimerDelete( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_DELETE, 0U, NULL, ( xTicksToWait ) )
|
||||
|
||||
/**
|
||||
* BaseType_t xTimerReset( TimerHandle_t xTimer, TickType_t xTicksToWait );
|
||||
*
|
||||
* Timer functionality is provided by a timer service/daemon task. Many of the
|
||||
* public FreeRTOS timer API functions send commands to the timer service task
|
||||
* through a queue called the timer command queue. The timer command queue is
|
||||
@ -589,7 +746,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );
|
||||
* configuration constant.
|
||||
*
|
||||
* Example usage:
|
||||
* @verbatim
|
||||
* @code{c}
|
||||
* // When a key is pressed, an LCD back-light is switched on. If 5 seconds pass
|
||||
* // without a key being pressed, then the LCD back-light is switched off. In
|
||||
* // this case, the timer is a one-shot timer.
|
||||
@ -661,14 +818,11 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );
|
||||
* // Should not reach here.
|
||||
* for( ;; );
|
||||
* }
|
||||
* @endverbatim
|
||||
* @endcode
|
||||
*/
|
||||
#define xTimerReset( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_RESET, ( xTaskGetTickCount() ), NULL, ( xTicksToWait ) )
|
||||
|
||||
/**
|
||||
* BaseType_t xTimerStartFromISR( TimerHandle_t xTimer,
|
||||
* BaseType_t *pxHigherPriorityTaskWoken );
|
||||
*
|
||||
* A version of xTimerStart() that can be called from an interrupt service
|
||||
* routine.
|
||||
*
|
||||
@ -696,7 +850,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );
|
||||
* configuration constant.
|
||||
*
|
||||
* Example usage:
|
||||
* @verbatim
|
||||
* @code{c}
|
||||
* // This scenario assumes xBacklightTimer has already been created. When a
|
||||
* // key is pressed, an LCD back-light is switched on. If 5 seconds pass
|
||||
* // without a key being pressed, then the LCD back-light is switched off. In
|
||||
@ -747,14 +901,11 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );
|
||||
* // depends on the FreeRTOS port being used).
|
||||
* }
|
||||
* }
|
||||
* @endverbatim
|
||||
* @endcode
|
||||
*/
|
||||
#define xTimerStartFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START_FROM_ISR, ( xTaskGetTickCountFromISR() ), ( pxHigherPriorityTaskWoken ), 0U )
|
||||
|
||||
/**
|
||||
* BaseType_t xTimerStopFromISR( TimerHandle_t xTimer,
|
||||
* BaseType_t *pxHigherPriorityTaskWoken );
|
||||
*
|
||||
* A version of xTimerStop() that can be called from an interrupt service
|
||||
* routine.
|
||||
*
|
||||
@ -780,7 +931,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );
|
||||
* priority is set by the configTIMER_TASK_PRIORITY configuration constant.
|
||||
*
|
||||
* Example usage:
|
||||
* @verbatim
|
||||
* @code{c}
|
||||
* // This scenario assumes xTimer has already been created and started. When
|
||||
* // an interrupt occurs, the timer should be simply stopped.
|
||||
*
|
||||
@ -810,15 +961,11 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );
|
||||
* // depends on the FreeRTOS port being used).
|
||||
* }
|
||||
* }
|
||||
* @endverbatim
|
||||
* @endcode
|
||||
*/
|
||||
#define xTimerStopFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_STOP_FROM_ISR, 0, ( pxHigherPriorityTaskWoken ), 0U )
|
||||
|
||||
/**
|
||||
* BaseType_t xTimerChangePeriodFromISR( TimerHandle_t xTimer,
|
||||
* TickType_t xNewPeriod,
|
||||
* BaseType_t *pxHigherPriorityTaskWoken );
|
||||
*
|
||||
* A version of xTimerChangePeriod() that can be called from an interrupt
|
||||
* service routine.
|
||||
*
|
||||
@ -853,7 +1000,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );
|
||||
* priority is set by the configTIMER_TASK_PRIORITY configuration constant.
|
||||
*
|
||||
* Example usage:
|
||||
* @verbatim
|
||||
* @code{c}
|
||||
* // This scenario assumes xTimer has already been created and started. When
|
||||
* // an interrupt occurs, the period of xTimer should be changed to 500ms.
|
||||
*
|
||||
@ -883,14 +1030,11 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );
|
||||
* // depends on the FreeRTOS port being used).
|
||||
* }
|
||||
* }
|
||||
* @endverbatim
|
||||
* @endcode
|
||||
*/
|
||||
#define xTimerChangePeriodFromISR( xTimer, xNewPeriod, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_CHANGE_PERIOD_FROM_ISR, ( xNewPeriod ), ( pxHigherPriorityTaskWoken ), 0U )
|
||||
|
||||
/**
|
||||
* BaseType_t xTimerResetFromISR( TimerHandle_t xTimer,
|
||||
* BaseType_t *pxHigherPriorityTaskWoken );
|
||||
*
|
||||
* A version of xTimerReset() that can be called from an interrupt service
|
||||
* routine.
|
||||
*
|
||||
@ -918,7 +1062,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );
|
||||
* task priority is set by the configTIMER_TASK_PRIORITY configuration constant.
|
||||
*
|
||||
* Example usage:
|
||||
* @verbatim
|
||||
* @code{c}
|
||||
* // This scenario assumes xBacklightTimer has already been created. When a
|
||||
* // key is pressed, an LCD back-light is switched on. If 5 seconds pass
|
||||
* // without a key being pressed, then the LCD back-light is switched off. In
|
||||
@ -969,18 +1113,12 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );
|
||||
* // depends on the FreeRTOS port being used).
|
||||
* }
|
||||
* }
|
||||
* @endverbatim
|
||||
* @endcode
|
||||
*/
|
||||
#define xTimerResetFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_RESET_FROM_ISR, ( xTaskGetTickCountFromISR() ), ( pxHigherPriorityTaskWoken ), 0U )
|
||||
|
||||
|
||||
/**
|
||||
* BaseType_t xTimerPendFunctionCallFromISR( PendedFunction_t xFunctionToPend,
|
||||
* void *pvParameter1,
|
||||
* uint32_t ulParameter2,
|
||||
* BaseType_t *pxHigherPriorityTaskWoken );
|
||||
*
|
||||
*
|
||||
* Used from application interrupt service routines to defer the execution of a
|
||||
* function to the RTOS daemon task (the timer service task, hence this function
|
||||
* is implemented in timers.c and is prefixed with 'Timer').
|
||||
@ -1022,7 +1160,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );
|
||||
* timer daemon task, otherwise pdFALSE is returned.
|
||||
*
|
||||
* Example usage:
|
||||
* @verbatim
|
||||
* @code{c}
|
||||
*
|
||||
* // The callback function that will execute in the context of the daemon task.
|
||||
* // Note callback functions must all use this same prototype.
|
||||
@ -1060,17 +1198,11 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );
|
||||
* portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
|
||||
*
|
||||
* }
|
||||
* @endverbatim
|
||||
* @endcode
|
||||
*/
|
||||
BaseType_t xTimerPendFunctionCallFromISR( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, BaseType_t *pxHigherPriorityTaskWoken );
|
||||
|
||||
/**
|
||||
* BaseType_t xTimerPendFunctionCall( PendedFunction_t xFunctionToPend,
|
||||
* void *pvParameter1,
|
||||
* uint32_t ulParameter2,
|
||||
* TickType_t xTicksToWait );
|
||||
*
|
||||
*
|
||||
* Used to defer the execution of a function to the RTOS daemon task (the timer
|
||||
* service task, hence this function is implemented in timers.c and is prefixed
|
||||
* with 'Timer').
|
||||
@ -1099,8 +1231,6 @@ BaseType_t xTimerPendFunctionCallFromISR( PendedFunction_t xFunctionToPend, void
|
||||
BaseType_t xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, TickType_t xTicksToWait );
|
||||
|
||||
/**
|
||||
* const char * const pcTimerGetTimerName( TimerHandle_t xTimer );
|
||||
*
|
||||
* Returns the name that was assigned to a timer when the timer was created.
|
||||
*
|
||||
* @param xTimer The handle of the timer being queried.
|
||||
@ -1109,6 +1239,7 @@ BaseType_t xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, void *pvPar
|
||||
*/
|
||||
const char * pcTimerGetTimerName( TimerHandle_t xTimer ); /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
|
||||
|
||||
/** @cond */
|
||||
/*
|
||||
* Functions beyond this part are not part of the public API and are intended
|
||||
* for use by the kernel only.
|
||||
@ -1116,6 +1247,8 @@ const char * pcTimerGetTimerName( TimerHandle_t xTimer ); /*lint !e971 Unqualifi
|
||||
BaseType_t xTimerCreateTimerTask( void ) PRIVILEGED_FUNCTION;
|
||||
BaseType_t xTimerGenericCommand( TimerHandle_t xTimer, const BaseType_t xCommandID, const TickType_t xOptionalValue, BaseType_t * const pxHigherPriorityTaskWoken, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
|
||||
|
||||
/** @endcond */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user