R1 code for micro:bit based train controller code, requires second micro:bit running rx code to operate - see https://meanderingpi.wordpress.com/ for more information

Fork of nrf51-sdk by Lancaster University

Embed: (wiki syntax)

« Back to documentation index

Mutex

An internal module of Peer_manager. More...

Functions

void pm_mutex_init (uint8_t *p_mutex, uint16_t mutex_size)
 Initializes a mutex group.
bool pm_mutex_lock (uint8_t *p_mutex, uint16_t mutex_bit_id)
 Locks the mutex specified by the bit id.
uint16_t pm_mutex_lock_first_available (uint8_t *p_mutex, uint16_t mutex_size)
 Locks the first unlocked mutex within the mutex group.
void pm_mutex_unlock (uint8_t *p_mutex, uint16_t mutex_bit_id)
 Unlocks the mutex specified by the bit id.
bool pm_mutex_lock_status_get (uint8_t *p_mutex, uint16_t mutex_bit_id)
 Gets the locking status of the specified mutex.

Detailed Description

An internal module of Peer_manager.

This module provides thread-safe mutexes.


Function Documentation

void pm_mutex_init ( uint8_t *  p_mutex,
uint16_t  mutex_size 
)

Initializes a mutex group.

Parameters:
[in]p_mutexPointer to the mutex group. See MUTEX_STORAGE_SIZE().
[in]mutex_sizeThe size of the mutex group in number of mutexes.

Definition at line 71 of file pm_mutex.c.

bool pm_mutex_lock ( uint8_t *  p_mutex,
uint16_t  mutex_bit_id 
)

Locks the mutex specified by the bit id.

Parameters:
inout]p_mutex Pointer to the mutex group.
[in]mutex_bit_idThe bit id of the mutex.
Return values:
trueif it was possible to lock the mutex.
falseotherwise.

Definition at line 80 of file pm_mutex.c.

uint16_t pm_mutex_lock_first_available ( uint8_t *  p_mutex,
uint16_t  mutex_size 
)

Locks the first unlocked mutex within the mutex group.

Parameters:
[in,out]p_mutexPointer to the mutex group.
[in]mutex_sizeThe size of the mutex group.
Returns:
The first unlocked mutex id in the group.
Return values:
group-sizeif there was no unlocked mutex available.

Definition at line 108 of file pm_mutex.c.

bool pm_mutex_lock_status_get ( uint8_t *  p_mutex,
uint16_t  mutex_bit_id 
)

Gets the locking status of the specified mutex.

Parameters:
[in,out]p_mutexPointer to the mutex group.
[in]mutex_bit_idThe bit id of the mutex.
Return values:
trueif the mutex was locked.
falseotherwise.

Definition at line 125 of file pm_mutex.c.

void pm_mutex_unlock ( uint8_t *  p_mutex,
uint16_t  mutex_bit_id 
)

Unlocks the mutex specified by the bit id.

Parameters:
[in,out]p_mutexPointer to the mutex group.
[in]mutex_bit_idThe bit id of the mutex.

Definition at line 93 of file pm_mutex.c.