Flags

Functions

void flags_init (flags_t *flags, flags_value_t value)
 
void flags_deinit (flags_t *flags)
 
void flags_clr (flags_t *flags, flags_mask_t mask)
 
flags_t * flags_create (flags_value_t value)
 
void flags_destroy (flags_t *flags)
 
flags_value_t flags_get (flags_t *flags)
 
void flags_set (flags_t *flags, flags_mask_t mask)
 
void flags_wait_all (flags_t *flags, flags_mask_t mask, flags_value_t *value)
 
int flags_wait_all_tmo (flags_t *flags, flags_mask_t mask, tick_t time, flags_mask_t *value)
 
void flags_wait_any (flags_t *flags, flags_mask_t mask, flags_value_t *value)
 
int flags_wait_any_tmo (flags_t *flags, flags_mask_t mask, tick_t time, flags_value_t *value)
 
void flags_set_name (flags_t *flags, const char *name)
 
void flags_show (void)
 
void flags_show_with_fmt_fn (fmt_fn_t fn)
 

Detailed Description

Function Documentation

◆ flags_clr()

void flags_clr ( flags_t *  flags,
flags_mask_t  mask 
)

Clears the flag. Bits that are set to one in the mask are cleared in the flag register. Bits that are set to zero in the mask are left unmodified.

Parameters
flagsFlags handle
maskMask value

◆ flags_create()

flags_t* flags_create ( flags_value_t  value)

Allocates and initialises a flags handle. See flags_init() for further details.

Parameters
valueInitial value of flags
Returns
The flags handle to be used in all subsequent operations on the flag.

◆ flags_deinit()

void flags_deinit ( flags_t *  flags)

Deinitialises the flags handle. The flags must not be in use when this function is called (no task can be waiting on the flag, nor can they do so at any time after calling this function).

This function must not be called with a handle that was returned by flags_create(). See flags_destroy().

Parameters
flagsFlags handle

◆ flags_destroy()

void flags_destroy ( flags_t *  flags)

Frees the resources allocated by the flags. The flags must not be in use when this function is called (no task can be waiting on the flag, nor can they do so at any time after calling this function).

This function must only be called with a handle that was returned by flags_create().

Parameters
flagsFlags handle

◆ flags_get()

flags_value_t flags_get ( flags_t *  flags)

Gets the value in the flag register.

Parameters
flagsFlags handle
Returns
The value in the flag register.

◆ flags_init()

void flags_init ( flags_t *  flags,
flags_value_t  value 
)

Initialises a flags handle. The flag register is initialised to value.

This function must not be called with a handle that was returned by flags_create().

Parameters
flagsFlags handle
valueInitial value of flags

◆ flags_set()

void flags_set ( flags_t *  flags,
flags_mask_t  mask 
)

Sets the flag. Bits that are set to one in the mask are set in the flag register. Bits that are set to zero in the mask are left unmodified.

If any tasks were waiting on any of the bits that were modified, they will be put in the READY state.

Parameters
flagsFlags handle
maskMask value

◆ flags_set_name()

void flags_set_name ( flags_t *  flags,
const char *  name 
)

Sets the name of the flag.

This function is only used for debugging purposes, where a kernel-aware debugger may present this name to the user.

The name will be stored in a separate table for kernel objects. If the name could not be set, the error is silently ignored.

Parameters
flagsFlags handle
nameString describing flag

◆ flags_show()

void flags_show ( void  )

Prints all registered flags to stdout using rprintp(). This may prove useful for debugging purposes. This function should not be called from application code, but may be called from e.g. uerror() or an exception handler.

◆ flags_show_with_fmt_fn()

void flags_show_with_fmt_fn ( fmt_fn_t  fn)

Same as flags_show(), but using supplied function for formatted output.

Parameters
fnFunction for formatted output

◆ flags_wait_all()

void flags_wait_all ( flags_t *  flags,
flags_mask_t  mask,
flags_value_t *  value 
)

Waits for all of the requested bits in the flag register to be set.

If all of the bits that are set to one in the mask are also set to one in the flag, then the function will return immediately. If any of the bits that are set to one in the mask are not set in the flag, then the calling task is put in the WAITING state.

Parameters
flagsFlags handle
maskMask value
valueUpdated with value of flags after waiting

◆ flags_wait_all_tmo()

int flags_wait_all_tmo ( flags_t *  flags,
flags_mask_t  mask,
tick_t  time,
flags_mask_t *  value 
)

Analogous to flags_wait_all(), but a maximum time to wait can be specified. If any of the requested bits are not set, the calling task will wait until all of the requested bits become set, or the number of ticks given by time expires.

Parameters
flagsFlags handle
maskMask value
timeNumber of ticks to wait
valueUpdated with value of flags after waiting
Returns
0 if all of the requested bits are set, 1 if the service timed out.

◆ flags_wait_any()

void flags_wait_any ( flags_t *  flags,
flags_mask_t  mask,
flags_value_t *  value 
)

Waits for any of the requested bits in the flag register to be set.

If any of the bits that are set to one in the mask are also set to one in the flag, then the function will return immediately. If none of the bits that are set to one in the mask are set in the flag, then the calling task is put in the WAITING state.

Parameters
flagsFlags handle
maskMask value
valueUpdated with value of flag register after waiting

◆ flags_wait_any_tmo()

int flags_wait_any_tmo ( flags_t *  flags,
flags_mask_t  mask,
tick_t  time,
flags_value_t *  value 
)

Analogous to flags_wait_any(), but a maximum time to wait can be specified. If none of the requested bits are set, the calling task will wait until any of the requested bits become set, or the number of ticks given by time expires.

Parameters
flagsFlags handle
maskMask value
timeNumber of ticks to wait
valueUpdated with value of flag register after waiting
Returns
0 if any of the requested bits are set, 1 if the service timed out.