MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
SEMA42: Hardware Semaphores Driver

Macros

#define SEMA42_GATE_NUM_RESET_ALL   (64U)
 The number to reset all SEMA42 gates. More...
 
#define SEMA42_GATEn(base, n)   (((volatile uint8_t *)(&((base)->GATE3)))[(n) ^ 3U])
 SEMA42 gate n register address. More...
 

Enumerations

enum  {
  kStatus_SEMA42_Busy = MAKE_STATUS(kStatusGroup_SEMA42, 0),
  kStatus_SEMA42_Reseting = MAKE_STATUS(kStatusGroup_SEMA42, 1)
}
 SEMA42 status return codes. More...
 
enum  sema42_gate_status_t {
  kSEMA42_Unlocked = 0U,
  kSEMA42_LockedByProc0 = 1U,
  kSEMA42_LockedByProc1 = 2U,
  kSEMA42_LockedByProc2 = 3U,
  kSEMA42_LockedByProc3 = 4U,
  kSEMA42_LockedByProc4 = 5U,
  kSEMA42_LockedByProc5 = 6U,
  kSEMA42_LockedByProc6 = 7U,
  kSEMA42_LockedByProc7 = 8U,
  kSEMA42_LockedByProc8 = 9U,
  kSEMA42_LockedByProc9 = 10U,
  kSEMA42_LockedByProc10 = 11U,
  kSEMA42_LockedByProc11 = 12U,
  kSEMA42_LockedByProc12 = 13U,
  kSEMA42_LockedByProc13 = 14U,
  kSEMA42_LockedByProc14 = 15U
}
 SEMA42 gate lock status. More...
 

Functions

void SEMA42_Init (SEMA42_Type *base)
 Initializes the SEMA42 module. More...
 
void SEMA42_Deinit (SEMA42_Type *base)
 De-initializes the SEMA42 module. More...
 
status_t SEMA42_TryLock (SEMA42_Type *base, uint8_t gateNum, uint8_t procNum)
 Tries to lock the SEMA42 gate. More...
 
void SEMA42_Lock (SEMA42_Type *base, uint8_t gateNum, uint8_t procNum)
 Locks the SEMA42 gate. More...
 
static void SEMA42_Unlock (SEMA42_Type *base, uint8_t gateNum)
 Unlocks the SEMA42 gate. More...
 
static sema42_gate_status_t SEMA42_GetGateStatus (SEMA42_Type *base, uint8_t gateNum)
 Gets the status of the SEMA42 gate. More...
 
status_t SEMA42_ResetGate (SEMA42_Type *base, uint8_t gateNum)
 Resets the SEMA42 gate to an unlocked status. More...
 
static status_t SEMA42_ResetAllGates (SEMA42_Type *base)
 Resets all SEMA42 gates to an unlocked status. More...
 

Driver version

#define FSL_SEMA42_DRIVER_VERSION   (MAKE_VERSION(2, 0, 1))
 SEMA42 driver version.
 

Detailed Description

The MCUXpresso SDK provides a driver for the SEMA42 module of MCUXpresso SDK devices.

The SEMA42 driver is used for multicore platforms. Before using the SEMA42, call the SEMA42_Init() function to initialize the module. Note that this function only enables the clock but does not reset the gates because the module might be used by other processors at the same time. To reset the gates, call either the SEMA42_ResetGate() or SEMA42_ResetAllGates() functions. The function SEMA42_Deinit() deinitializes the SEMA42.
The SEMA42 provides two functions to lock the SEMA42 gate. The function SEMA42_TryLock() tries to lock the gate. If the gate has been locked by another processor, this function returns an error immediately. The function SEMA42_Lock() is a blocking method, which waits until the gate is free and locks it.
The SEMA42_Unlock() unlocks the SEMA42 gate. The gate can only be unlocked by the processor which locked it. If the gate is not locked by the current processor, this function takes no effect. The function SEMA42_GetGateStatus() returns a status whether the gate is unlocked and which processor locks the gate.
The SEMA42 gate can be reset to unlock forcefully. The function SEMA42_ResetGate() resets a specific gate. The function SEMA42_ResetAllGates() resets all gates.

Typical use case

Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/sema42

Macro Definition Documentation

#define SEMA42_GATE_NUM_RESET_ALL   (64U)
#define SEMA42_GATEn (   base,
 
)    (((volatile uint8_t *)(&((base)->GATE3)))[(n) ^ 3U])

The SEMA42 gates are sorted in the order 3, 2, 1, 0, 7, 6, 5, 4, ... not in the order 0, 1, 2, 3, 4, 5, 6, 7, ... The macro SEMA42_GATEn gets the SEMA42 gate based on the gate index.

The input gate index is XOR'ed with 3U: 0 ^ 3 = 3 1 ^ 3 = 2 2 ^ 3 = 1 3 ^ 3 = 0 4 ^ 3 = 7 5 ^ 3 = 6 6 ^ 3 = 5 7 ^ 3 = 4 ...

Enumeration Type Documentation

anonymous enum
Enumerator
kStatus_SEMA42_Busy 

SEMA42 gate has been locked by other processor.

kStatus_SEMA42_Reseting 

SEMA42 gate reseting is ongoing.

Enumerator
kSEMA42_Unlocked 

The gate is unlocked.

kSEMA42_LockedByProc0 

The gate is locked by processor 0.

kSEMA42_LockedByProc1 

The gate is locked by processor 1.

kSEMA42_LockedByProc2 

The gate is locked by processor 2.

kSEMA42_LockedByProc3 

The gate is locked by processor 3.

kSEMA42_LockedByProc4 

The gate is locked by processor 4.

kSEMA42_LockedByProc5 

The gate is locked by processor 5.

kSEMA42_LockedByProc6 

The gate is locked by processor 6.

kSEMA42_LockedByProc7 

The gate is locked by processor 7.

kSEMA42_LockedByProc8 

The gate is locked by processor 8.

kSEMA42_LockedByProc9 

The gate is locked by processor 9.

kSEMA42_LockedByProc10 

The gate is locked by processor 10.

kSEMA42_LockedByProc11 

The gate is locked by processor 11.

kSEMA42_LockedByProc12 

The gate is locked by processor 12.

kSEMA42_LockedByProc13 

The gate is locked by processor 13.

kSEMA42_LockedByProc14 

The gate is locked by processor 14.

Function Documentation

void SEMA42_Init ( SEMA42_Type *  base)

This function initializes the SEMA42 module. It only enables the clock but does not reset the gates because the module might be used by other processors at the same time. To reset the gates, call either SEMA42_ResetGate or SEMA42_ResetAllGates function.

Parameters
baseSEMA42 peripheral base address.
void SEMA42_Deinit ( SEMA42_Type *  base)

This function de-initializes the SEMA42 module. It only disables the clock.

Parameters
baseSEMA42 peripheral base address.
status_t SEMA42_TryLock ( SEMA42_Type *  base,
uint8_t  gateNum,
uint8_t  procNum 
)

This function tries to lock the specific SEMA42 gate. If the gate has been locked by another processor, this function returns an error code.

Parameters
baseSEMA42 peripheral base address.
gateNumGate number to lock.
procNumCurrent processor number.
Return values
kStatus_SuccessLock the sema42 gate successfully.
kStatus_SEMA42_BusySema42 gate has been locked by another processor.
void SEMA42_Lock ( SEMA42_Type *  base,
uint8_t  gateNum,
uint8_t  procNum 
)

This function locks the specific SEMA42 gate. If the gate has been locked by other processors, this function waits until it is unlocked and then lock it.

Parameters
baseSEMA42 peripheral base address.
gateNumGate number to lock.
procNumCurrent processor number.
static void SEMA42_Unlock ( SEMA42_Type *  base,
uint8_t  gateNum 
)
inlinestatic

This function unlocks the specific SEMA42 gate. It only writes unlock value to the SEMA42 gate register. However, it does not check whether the SEMA42 gate is locked by the current processor or not. As a result, if the SEMA42 gate is not locked by the current processor, this function has no effect.

Parameters
baseSEMA42 peripheral base address.
gateNumGate number to unlock.
static sema42_gate_status_t SEMA42_GetGateStatus ( SEMA42_Type *  base,
uint8_t  gateNum 
)
inlinestatic

This function checks the lock status of a specific SEMA42 gate.

Parameters
baseSEMA42 peripheral base address.
gateNumGate number.
Returns
status Current status.
status_t SEMA42_ResetGate ( SEMA42_Type *  base,
uint8_t  gateNum 
)

This function resets a SEMA42 gate to an unlocked status.

Parameters
baseSEMA42 peripheral base address.
gateNumGate number.
Return values
kStatus_SuccessSEMA42 gate is reset successfully.
kStatus_SEMA42_ResetingSome other reset process is ongoing.
static status_t SEMA42_ResetAllGates ( SEMA42_Type *  base)
inlinestatic

This function resets all SEMA42 gate to an unlocked status.

Parameters
baseSEMA42 peripheral base address.
Return values
kStatus_SuccessSEMA42 is reset successfully.
kStatus_SEMA42_ResetingSome other reset process is ongoing.