PRSEMLIB
Detailed Description
Peripheral Reflex System (PRS) Peripheral API.
This module contains functions to control the PRS peripheral of Silicon Labs 32-bit MCUs and SoCs. The PRS allows configurable, fast, and autonomous communication between peripherals on the MCU or SoC.
Macros |
|
#define | PRS_ASYNC_CHAN_COUNT PRS_ASYNC_CH_NUM |
#define | PRS_ASYNC_SUPPORTED 1 |
#define | PRS_BURTC_OF PRS_BURTC_OVERFLOW |
#define | PRS_SYNC_CHAN_COUNT PRS_SYNC_CH_NUM |
Enumerations |
|
enum |
PRS_ChType_t
{
prsTypeAsync , prsTypeSync } |
enum |
PRS_Consumer_t
{
prsConsumerNone = 0x000, prsConsumerCMU_CALDN = offsetof(PRS_TypeDef, CONSUMER_CMU_CALDN), prsConsumerCMU_CALUP = offsetof(PRS_TypeDef, CONSUMER_CMU_CALUP), prsConsumerIADC0_SCANTRIGGER = offsetof(PRS_TypeDef, CONSUMER_IADC0_SCANTRIGGER), prsConsumerIADC0_SINGLETRIGGER = offsetof(PRS_TypeDef, CONSUMER_IADC0_SINGLETRIGGER), prsConsumerLDMA_REQUEST0 = offsetof(PRS_TypeDef, CONSUMER_LDMAXBAR_DMAREQ0), prsConsumerLDMA_REQUEST1 = offsetof(PRS_TypeDef, CONSUMER_LDMAXBAR_DMAREQ1), prsConsumerLETIMER0_CLEAR = offsetof(PRS_TypeDef, CONSUMER_LETIMER_CLEAR), prsConsumerLETIMER0_START = offsetof(PRS_TypeDef, CONSUMER_LETIMER_START), prsConsumerLETIMER0_STOP = offsetof(PRS_TypeDef, CONSUMER_LETIMER_STOP), prsConsumerTIMER0_CC0 = offsetof(PRS_TypeDef, CONSUMER_TIMER0_CC0), prsConsumerTIMER0_CC1 = offsetof(PRS_TypeDef, CONSUMER_TIMER0_CC1), prsConsumerTIMER0_CC2 = offsetof(PRS_TypeDef, CONSUMER_TIMER0_CC2), prsConsumerTIMER1_CC0 = offsetof(PRS_TypeDef, CONSUMER_TIMER1_CC0), prsConsumerTIMER1_CC1 = offsetof(PRS_TypeDef, CONSUMER_TIMER1_CC1), prsConsumerTIMER1_CC2 = offsetof(PRS_TypeDef, CONSUMER_TIMER1_CC2), prsConsumerTIMER2_CC0 = offsetof(PRS_TypeDef, CONSUMER_TIMER2_CC0), prsConsumerTIMER2_CC1 = offsetof(PRS_TypeDef, CONSUMER_TIMER2_CC1), prsConsumerTIMER2_CC2 = offsetof(PRS_TypeDef, CONSUMER_TIMER2_CC2), prsConsumerTIMER3_CC0 = offsetof(PRS_TypeDef, CONSUMER_TIMER3_CC0), prsConsumerTIMER3_CC1 = offsetof(PRS_TypeDef, CONSUMER_TIMER3_CC1), prsConsumerTIMER3_CC2 = offsetof(PRS_TypeDef, CONSUMER_TIMER3_CC2), prsConsumerUSART0_CLK = offsetof(PRS_TypeDef, CONSUMER_USART0_CLK), prsConsumerUSART0_IR = offsetof(PRS_TypeDef, CONSUMER_USART0_IR), prsConsumerUSART0_RX = offsetof(PRS_TypeDef, CONSUMER_USART0_RX), prsConsumerUSART0_TRIGGER = offsetof(PRS_TypeDef, CONSUMER_USART0_TRIGGER), prsConsumerUSART1_CLK = offsetof(PRS_TypeDef, CONSUMER_USART1_CLK), prsConsumerUSART1_IR = offsetof(PRS_TypeDef, CONSUMER_USART1_IR), prsConsumerUSART1_RX = offsetof(PRS_TypeDef, CONSUMER_USART1_RX), prsConsumerUSART1_TRIGGER = offsetof(PRS_TypeDef, CONSUMER_USART1_TRIGGER), prsConsumerUSART2_CLK = offsetof(PRS_TypeDef, CONSUMER_USART2_CLK), prsConsumerUSART2_IR = offsetof(PRS_TypeDef, CONSUMER_USART2_IR), prsConsumerUSART2_RX = offsetof(PRS_TypeDef, CONSUMER_USART2_RX), prsConsumerUSART2_TRIGGER = offsetof(PRS_TypeDef, CONSUMER_USART2_TRIGGER), prsConsumerWDOG0_SRC0 = offsetof(PRS_TypeDef, CONSUMER_WDOG0_SRC0), prsConsumerWDOG0_SRC1 = offsetof(PRS_TypeDef, CONSUMER_WDOG0_SRC1), prsConsumerWDOG1_SRC0 = offsetof(PRS_TypeDef, CONSUMER_WDOG1_SRC0), prsConsumerWDOG1_SRC1 = offsetof(PRS_TypeDef, CONSUMER_WDOG1_SRC1) } |
enum |
PRS_Edge_TypeDef
{
prsEdgeOff , prsEdgePos , prsEdgeNeg , prsEdgeBoth } |
enum |
PRS_Logic_t
{
prsLogic_Zero = _PRS_ASYNC_CH_CTRL_FNSEL_LOGICAL_ZERO, prsLogic_A_NOR_B = _PRS_ASYNC_CH_CTRL_FNSEL_A_NOR_B, prsLogic_NOT_A_AND_B = _PRS_ASYNC_CH_CTRL_FNSEL_NOT_A_AND_B, prsLogic_NOT_A = _PRS_ASYNC_CH_CTRL_FNSEL_NOT_A, prsLogic_A_AND_NOT_B = _PRS_ASYNC_CH_CTRL_FNSEL_A_AND_NOT_B, prsLogic_NOT_B = _PRS_ASYNC_CH_CTRL_FNSEL_NOT_B, prsLogic_A_XOR_B = _PRS_ASYNC_CH_CTRL_FNSEL_A_XOR_B, prsLogic_A_NAND_B = _PRS_ASYNC_CH_CTRL_FNSEL_A_NAND_B, prsLogic_A_AND_B = _PRS_ASYNC_CH_CTRL_FNSEL_A_AND_B, prsLogic_A_XNOR_B = _PRS_ASYNC_CH_CTRL_FNSEL_A_XNOR_B, prsLogic_B = _PRS_ASYNC_CH_CTRL_FNSEL_B, prsLogic_A_OR_NOT_B = _PRS_ASYNC_CH_CTRL_FNSEL_A_OR_NOT_B, prsLogic_A = _PRS_ASYNC_CH_CTRL_FNSEL_A, prsLogic_NOT_A_OR_B = _PRS_ASYNC_CH_CTRL_FNSEL_NOT_A_OR_B, prsLogic_A_OR_B = _PRS_ASYNC_CH_CTRL_FNSEL_A_OR_B, prsLogic_One = _PRS_ASYNC_CH_CTRL_FNSEL_LOGICAL_ONE } |
enum |
PRS_Signal_t
{
prsSignalNone = 0x0, prsSignalTIMER0_UF = PRS_TIMER0_UF, prsSignalTIMER0_OF = PRS_TIMER0_OF, prsSignalTIMER0_CC0 = PRS_TIMER0_CC0, prsSignalTIMER0_CC1 = PRS_TIMER0_CC1, prsSignalTIMER0_CC2 = PRS_TIMER0_CC2, prsSignalTIMER1_UF = PRS_TIMER1_UF, prsSignalTIMER1_OF = PRS_TIMER1_OF, prsSignalTIMER1_CC0 = PRS_TIMER1_CC0, prsSignalTIMER1_CC1 = PRS_TIMER1_CC1, prsSignalTIMER1_CC2 = PRS_TIMER1_CC2, prsSignalTIMER2_UF = PRS_TIMER2_UF, prsSignalTIMER2_OF = PRS_TIMER2_OF, prsSignalTIMER2_CC0 = PRS_TIMER2_CC0, prsSignalTIMER2_CC1 = PRS_TIMER2_CC1, prsSignalTIMER2_CC2 = PRS_TIMER2_CC2, prsSignalTIMER3_UF = PRS_TIMER3_UF, prsSignalTIMER3_OF = PRS_TIMER3_OF, prsSignalTIMER3_CC0 = PRS_TIMER3_CC0, prsSignalTIMER3_CC1 = PRS_TIMER3_CC1, prsSignalTIMER3_CC2 = PRS_TIMER3_CC2, prsSignalLETIMER0_CH0 = PRS_LETIMER0_CH0, prsSignalLETIMER0_CH1 = PRS_LETIMER0_CH1, prsSignalRTCC_CCV0 = PRS_RTCC_CCV0, prsSignalRTCC_CCV1 = PRS_RTCC_CCV1, prsSignalRTCC_CCV2 = PRS_RTCC_CCV2, prsSignalBURTC_COMP = PRS_BURTC_COMP, prsSignalBURTC_OF = PRS_BURTC_OF, prsSignalACMP0_OUT = PRS_ACMP0_OUT, prsSignalACMP1_OUT = PRS_ACMP1_OUT, prsSignalUSART0_IRTX = PRS_USART0_IRTX, prsSignalUSART0_TXC = PRS_USART0_TXC, prsSignalUSART0_RXDATA = PRS_USART0_RXDATA, prsSignalUSART0_RTS = PRS_USART0_RTS, prsSignalUSART0_TX = PRS_USART0_TX, prsSignalUSART0_CS = PRS_USART0_CS, prsSignalUSART1_TXC = PRS_USART1_TXC, prsSignalUSART1_RXDATA = PRS_USART1_RXDATA, prsSignalUSART1_IRTX = PRS_USART1_IRTX, prsSignalUSART1_RTS = PRS_USART1_RTS, prsSignalUSART1_TX = PRS_USART1_TX, prsSignalUSART1_CS = PRS_USART1_CS, prsSignalUSART2_TXC = PRS_USART2_TXC, prsSignalUSART2_RXDATA = PRS_USART2_RXDATA, prsSignalUSART2_IRTX = PRS_USART2_IRTX, prsSignalUSART2_RTS = PRS_USART2_RTS, prsSignalUSART2_TX = PRS_USART2_TX, prsSignalUSART2_CS = PRS_USART2_CS, prsSignalIADC0_SCANENTRY = PRS_IADC0_SCANENTRYDONE, prsSignalIADC0_SCANTABLE = PRS_IADC0_SCANTABLEDONE, prsSignalIADC0_SINGLE = PRS_IADC0_SINGLEDONE, prsSignalGPIO_PIN0 = PRS_GPIO_PIN0, prsSignalGPIO_PIN1 = PRS_GPIO_PIN1, prsSignalGPIO_PIN2 = PRS_GPIO_PIN2, prsSignalGPIO_PIN3 = PRS_GPIO_PIN3, prsSignalGPIO_PIN4 = PRS_GPIO_PIN4, prsSignalGPIO_PIN5 = PRS_GPIO_PIN5, prsSignalGPIO_PIN6 = PRS_GPIO_PIN6, prsSignalGPIO_PIN7 = PRS_GPIO_PIN7 } |
Functions |
|
__STATIC_INLINE void | PRS_ChannelLevelSet (unsigned int ch, bool level) |
Set the PRS channel level for one asynchronous PRS channel.
|
|
__STATIC_INLINE void | PRS_ChannelPulse (unsigned int ch) |
Trigger a pulse on one PRS channel.
|
|
__STATIC_INLINE bool | PRS_ChannelValue (unsigned int ch, PRS_ChType_t type) |
Get the PRS channel value for a single channel.
|
|
void | PRS_Combine (unsigned int chA, unsigned int chB, PRS_Logic_t logic) |
Combine two PRS channels using a logic function.
|
|
void | PRS_ConnectConsumer (unsigned int ch, PRS_ChType_t type, PRS_Consumer_t consumer) |
Connect a peripheral consumer to a PRS channel.
|
|
void | PRS_ConnectSignal (unsigned int ch, PRS_ChType_t type, PRS_Signal_t signal) |
Connect a PRS signal to a channel.
|
|
int | PRS_GetFreeChannel ( PRS_ChType_t type) |
Search for the first free PRS channel.
|
|
__STATIC_INLINE uint32_t | PRS_LevelGet (void) |
Get level control bit for all channels.
|
|
__STATIC_INLINE void | PRS_LevelSet (uint32_t level, uint32_t mask) |
Set level control bit for one or more channels.
|
|
void | PRS_PinOutput (unsigned int ch, PRS_ChType_t type, GPIO_Port_TypeDef port, uint8_t pin) |
Send the output of a PRS channel to a GPIO pin.
|
|
__STATIC_INLINE void | PRS_PulseTrigger (uint32_t channels) |
Trigger a high pulse (one HFPERCLK) for one or more channels.
|
|
void | PRS_Reset (void) |
Reset all PRS channels.
|
|
void | PRS_SourceAsyncSignalSet (unsigned int ch, uint32_t source, uint32_t signal) |
Set the source and asynchronous signal for a channel.
|
|
void | PRS_SourceSignalSet (unsigned int ch, uint32_t source, uint32_t signal, PRS_Edge_TypeDef edge) |
Set a source and signal for a channel.
|
|
__STATIC_INLINE uint32_t | PRS_Values ( PRS_ChType_t type) |
Get the PRS channel values for all channels.
|
|
Enumeration Type Documentation
enum PRS_ChType_t |
enum PRS_Consumer_t |
PRS Consumers.
Definition at line
256
of file
em_prs.h
.
enum PRS_Edge_TypeDef |
enum PRS_Logic_t |
Logic functions that can be used when combining two PRS channels.
Definition at line
114
of file
em_prs.h
.
enum PRS_Signal_t |
PRS Signal.
Definition at line
135
of file
em_prs.h
.
Function Documentation
__STATIC_INLINE void PRS_ChannelLevelSet | ( | unsigned int |
ch,
|
bool |
level
|
||
) |
Set the PRS channel level for one asynchronous PRS channel.
- Parameters
-
[in] ch
PRS channel number. [in] level
true to set the level high (1) and false to set the level low (0).
Definition at line
428
of file
em_prs.h
.
References PRS_LevelSet() .
__STATIC_INLINE void PRS_ChannelPulse | ( | unsigned int |
ch
|
) |
Trigger a pulse on one PRS channel.
- Parameters
-
[in] ch
PRS channel number.
Definition at line
440
of file
em_prs.h
.
References PRS_PulseTrigger() .
__STATIC_INLINE bool PRS_ChannelValue | ( | unsigned int |
ch,
|
PRS_ChType_t |
type
|
||
) |
Get the PRS channel value for a single channel.
- Parameters
-
[in] ch
PRS channel number. [in] type
PRS channel type. This can be either prsTypeAsync or prsTypeSync .
- Returns
- The current PRS channel output value. This is either 0 or 1.
Definition at line
389
of file
em_prs.h
.
References PRS_Values() .
void PRS_Combine | ( | unsigned int |
chA,
|
unsigned int |
chB,
|
||
PRS_Logic_t |
logic
|
||
) |
Combine two PRS channels using a logic function.
This function allows you to combine the output of one PRS channel with the the signal of another PRS channel using various logic functions. Note that the hardware only allows one PRS channel to be combined with the previous channel. So for instance channel 5 can be combined only with channel 4.
The logic function operates on two PRS channels called A and B. The output of PRS channel B is combined with the PRS source configured for channel A to produce an output. This output is used as the output of channel A.
- Parameters
-
[in] chA
PRS Channel for the A input. [in] chB
PRS Channel for the B input. [in] logic
The logic function to use when combining the Channel A and Channel B. The output of the logic function is the output of Channel A. Function like AND, OR, XOR, NOT and more are available.
Definition at line
527
of file
em_prs.c
.
References _PRS_ASYNC_CH_CTRL_FNSEL_MASK , _PRS_ASYNC_CH_CTRL_FNSEL_SHIFT , and PRS .
void PRS_ConnectConsumer | ( | unsigned int |
ch,
|
PRS_ChType_t |
type,
|
||
PRS_Consumer_t |
consumer
|
||
) |
Connect a peripheral consumer to a PRS channel.
Different peripherals can use PRS channels as their input. This function can be used to connect a peripheral consumer to a PRS channel. Multiple consumers can be connected to a single PRS channel.
- Parameters
-
[in] ch
PRS channel number. [in] type
PRS channel type. This can be either prsTypeAsync or prsTypeSync . [in] consumer
This is the PRS consumer.
Definition at line
442
of file
em_prs.c
.
References _PRS_CONSUMER_TIMER0_CC0_PRSSEL_SHIFT , _PRS_CONSUMER_TIMER0_CC0_SPRSSEL_SHIFT , PRS , prsConsumerNone , and prsTypeAsync .
void PRS_ConnectSignal | ( | unsigned int |
ch,
|
PRS_ChType_t |
type,
|
||
PRS_Signal_t |
signal
|
||
) |
Connect a PRS signal to a channel.
This function will make the PRS signal available on the specific channel. Only a single PRS signal can be connected to any given channel.
- Parameters
-
[in] ch
PRS channel number. [in] type
PRS channel type. This can be either prsTypeAsync or prsTypeSync . [in] signal
This is the PRS signal that should be placed on the channel.
Definition at line
383
of file
em_prs.c
.
References _PRS_ASYNC_CH_CTRL_SIGSEL_MASK , _PRS_ASYNC_CH_CTRL_SIGSEL_SHIFT , _PRS_ASYNC_CH_CTRL_SOURCESEL_MASK , _PRS_ASYNC_CH_CTRL_SOURCESEL_SHIFT , _PRS_SYNC_CH_CTRL_SIGSEL_SHIFT , _PRS_SYNC_CH_CTRL_SOURCESEL_SHIFT , PRS , PRS_ASYNC_CH_CTRL_FNSEL_A , and prsTypeAsync .
Referenced by PRS_SourceAsyncSignalSet() .
int PRS_GetFreeChannel | ( | PRS_ChType_t |
type
|
) |
Search for the first free PRS channel.
- Parameters
-
[in] type
PRS channel type. This can be either prsTypeAsync or prsTypeSync .
- Returns
- Channel number >= 0 if an unused PRS channel was found. If no free PRS channel was found then -1 is returned.
Definition at line
316
of file
em_prs.c
.
References prsTypeAsync .
__STATIC_INLINE uint32_t PRS_LevelGet | ( | void |
|
) |
Get level control bit for all channels.
- Returns
- The current software level configuration.
Definition at line
340
of file
em_prs.h
.
References PRS .
__STATIC_INLINE void PRS_LevelSet | ( | uint32_t |
level,
|
uint32_t |
mask
|
||
) |
Set level control bit for one or more channels.
The level value for a channel is XORed with both the pulse possibly issued by PRS_PulseTrigger() and the PRS input signal selected for the channel(s).
- Note
- Note that software level control is only available for asynchronous channels on Series 2 devices.
- Parameters
-
[in] level
Level to use for channels indicated by mask
. Use logical OR combination of PRS_SWLEVEL_CHnLEVEL defines for channels to set high level, otherwise 0.[in] mask
Mask indicating which channels to set level for. Use logical OR combination of PRS_SWLEVEL_CHnLEVEL defines.
Definition at line
324
of file
em_prs.h
.
References PRS .
Referenced by PRS_ChannelLevelSet() .
void PRS_PinOutput | ( | unsigned int |
ch,
|
PRS_ChType_t |
type,
|
||
GPIO_Port_TypeDef |
port,
|
||
uint8_t |
pin
|
||
) |
Send the output of a PRS channel to a GPIO pin.
This function is used to send the output of a PRS channel to a GPIO pin. Note that there are certain restrictions to where a PRS channel can be routed. Consult the datasheet of the device to see if a channel can be routed to the requested GPIO pin. Some devices for instance can only route the async channels 0-5 on GPIO pins PAx and PBx while async channels 6-11 can only be routed to GPIO pins PCx and PDx
- Parameters
-
[in] ch
PRS channel number. [in] type
PRS channel type. This can be either prsTypeAsync or prsTypeSync . [in] port
GPIO port [in] pin
GPIO pin
Definition at line
483
of file
em_prs.c
.
References _GPIO_PRS_ASYNCH0ROUTE_PIN_SHIFT , _GPIO_PRS_ASYNCH0ROUTE_PORT_SHIFT , _GPIO_PRS_ROUTEEN_ASYNCH0PEN_SHIFT , _GPIO_PRS_ROUTEEN_SYNCH0PEN_SHIFT , GPIO , and prsTypeAsync .
__STATIC_INLINE void PRS_PulseTrigger | ( | uint32_t |
channels
|
) |
Trigger a high pulse (one HFPERCLK) for one or more channels.
Setting a bit for a channel causes the bit in the register to remain high for one HFPERCLK cycle. Pulse is XORed with both the corresponding bit in PRS SWLEVEL register and the PRS input signal selected for the channel(s).
- Parameters
-
[in] channels
Logical ORed combination of channels to trigger a pulse for. Use PRS_SWPULSE_CHnPULSE defines.
Definition at line
409
of file
em_prs.h
.
References _PRS_ASYNC_SWPULSE_MASK , and PRS .
Referenced by PRS_ChannelPulse() .
void PRS_Reset | ( | void |
|
) |
Reset all PRS channels.
This function will reset all the PRS channel configuration.
Definition at line
345
of file
em_prs.c
.
References _PRS_ASYNC_CH_CTRL_RESETVALUE , _PRS_SYNC_CH_CTRL_RESETVALUE , and PRS .
void PRS_SourceAsyncSignalSet | ( | unsigned int |
ch,
|
uint32_t |
source,
|
||
uint32_t |
signal
|
||
) |
Set the source and asynchronous signal for a channel.
Asynchronous reflexes are not clocked on HFPERCLK and can be used even in EM2/EM3. There is a limitation to reflexes operating in asynchronous mode in that they can only be used by a subset of the reflex consumers. See the PRS chapter in the reference manual for the complete list of supported asynchronous signals and consumers.
- Note
- This function is not supported on EFM32GxxxFyyy parts. In asynchronous mode, the edge detector only works in EM0 and should not be used. The EDSEL parameter in PRS_CHx_CTRL register is set to 0 (OFF) by default.
- Parameters
-
[in] ch
A channel to define the source and asynchronous signal for. [in] source
A source to select for the channel. Use one of PRS_CH_CTRL_SOURCESEL_x defines. [in] signal
An asynchronous signal (for selected source
) to use. Use one of the PRS_CH_CTRL_SIGSEL_x defines that support asynchronous operation.
Definition at line
258
of file
em_prs.c
.
References PRS_ConnectSignal() , and prsTypeAsync .
Referenced by adcDeInit() , ezradio_hal_GpioInit() , MIC_deInit() , and MIC_init() .
void PRS_SourceSignalSet | ( | unsigned int |
ch,
|
uint32_t |
source,
|
||
uint32_t |
signal,
|
||
PRS_Edge_TypeDef |
edge
|
||
) |
Set a source and signal for a channel.
- Parameters
-
[in] ch
A channel to define the signal and source for. [in] source
A source to select for the channel. Use one of PRS_CH_CTRL_SOURCESEL_x defines. [in] signal
A signal (for selected source
) to use. Use one of PRS_CH_CTRL_SIGSEL_x defines.[in] edge
An edge (for selected source/signal) to generate the pulse for.
Definition at line
211
of file
em_prs.c
.
References _PRS_SYNC_CH_CTRL_SIGSEL_MASK , _PRS_SYNC_CH_CTRL_SOURCESEL_MASK , and PRS .
__STATIC_INLINE uint32_t PRS_Values | ( | PRS_ChType_t |
type
|
) |
Get the PRS channel values for all channels.
- Parameters
-
[in] type
PRS channel type. This can be either prsTypeAsync or prsTypeSync .
- Returns
- The current PRS channel output values for all channels as a bitset.
Definition at line
361
of file
em_prs.h
.
References PRS , and prsTypeAsync .
Referenced by PRS_ChannelValue() .