PIXELRZ - Serial Pixel Interface#
Introduction#
PIXELRZ relays on external addressable LED to be configured correctly. In this example we will use WS2812B LEDS. Check datasheet of WS2812B for timing. To configure the timing, user must call @sl_hal_pixelrz_get_symbol_configuration().
Example#
{
#define PIXELRZ_GPIO PB0
#define PIXELRZ_PIXEL_COUNT 60 // 60 pixels
#define PIXELRZ_PIXEL_WIDTH 24 // 24 bits per pixel
#define PIXELRZ_PIXEL_TRAIL 0 // no trail data
// WS2812B timing values in microseconds. Check datasheet.
#define WS2812B_T0_HIGH 0.4f
#define WS2812B_T0_LOW 0.85f
#define WS2812B_T1_HIGH 0.8f
#define WS2812B_T1_LOW 0.45f
#define WS2812B_TRST_HIGH 0.0f
#define WS2812B_TRST_LOW 60.0f
sl_hal_pixelrz_init_t init_serial = SL_HAL_PIXELRZ_CONFIG_SEQUENTIAL_DEFAULT;
uint32_t freq;
sl_clock_manager_enable_bus_clock(SL_BUS_CLOCK_PIXELRZ0);
sl_clock_manager_get_clock_branch_frequency(SL_CLOCK_BRANCH_PIXELRZCLK, &freq);
init_serial.pixel_number = PIXELRZ_PIXEL_COUNT;
init_serial.pixel_width = PIXELRZ_PIXEL_WIDTH;
init_serial.trail_data_width = PIXELRZ_PIXEL_TRAIL;
init_serial.zero_symbol = sl_hal_pixelrz_get_symbol_configuration(WS2812B_T0_HIGH, WS2812B_T0_LOW, freq);
init_serial.one_symbol = sl_hal_pixelrz_get_symbol_configuration(WS2812B_T1_HIGH, WS2812B_T1_LOW, freq);
init_serial.reset_symbol = sl_hal_pixelrz_get_symbol_configuration(WS2812B_TRST_HIGH, WS2812B_TRST_LOW, freq);
// Configure the GPIO.
sl_gpio_set_pin_mode(PIXELRZ_GPIO, SL_GPIO_MODE_PUSH_PULL, 0);
GPIO->PIXELRZROUTE[PIXELRZ_NUM(PIXELRZ0)].RZTXOUTROUTE = (PIXELRZ_GPIO->port << _GPIO_PIXELRZ_RZTXOUTROUTE_PORT_SHIFT)
| (PIXELRZ_GPIO->pin << _GPIO_PIXELRZ_RZTXOUTROUTE_PIN_SHIFT);
GPIO->PIXELRZROUTE[PIXELRZ_NUM(PIXELRZ0)].ROUTEEN = GPIO_PIXELRZ_ROUTEEN_RZTXOUTPEN;
sl_hal_pixelrz_init(PIXELRZ0, &init_serial);
sl_hal_pixelrz_enable(PIXELRZ0);
sl_hal_pixelrz_enable_tx(PIXELRZ0);
sl_hal_pixelrz_wait_sync(PIXELRZ0);
// User can start transmitting data directly or using LDMA.
}
Modules#
Enumerations#
PIXELRZ mode. Serial or parallel.
The frame trigger source.
Functions#
Initialize PIXELRZ.
Get symbol from time settings.
Wait for ongoing sync of register(s) to the low-frequency domain to complete.
Wait for disabling to finish.
Enable PIXELRZ.
Disable PIXELRZ.
Transmits one data word.
Enable PIXELRZ transmitter.
Disable PIXELRZ transmitter.
Clear TX FIFO.
Reset the PIXELRZ.
Gets PIXELRZ STATUS register value.
Clear one or more pending PIXELRZ interrupts.
Set one or more pending PIXELRZ interrupts from Software.
Disable one or more PIXELRZ interrupts.
Enable one or more PIXELRZ interrupts.
Get pending PIXELRZ interrupt flags.
Get enabled PIXELRZ interrupt flags.
Get enabled and pending PIXELRZ interrupt flags.
Macros#
Check if PIXELRZ instance is valid.
Default sequential configuration.
Default parallel configuration.
Enumeration Documentation#
sl_hal_pixelrz_mode_t#
sl_hal_pixelrz_mode_t
PIXELRZ mode. Serial or parallel.
Enumerator | |
---|---|
SL_HAL_PIXELRZ_MODE_SEQUENTIAL | Sequential mode. |
SL_HAL_PIXELRZ_MODE_PARALLEL | Parallel mode. |
sl_hal_pixelrz_trigger_t#
sl_hal_pixelrz_trigger_t
The frame trigger source.
Enumerator | |
---|---|
SL_HAL_PIXELRZ_TRIG_SW | Software trigger mode. |
SL_HAL_PIXELRZ_TRIG_AUTO | Auto trigger mode. |
SL_HAL_PIXELRZ_TRIG_PRS | Software trigger mode. |
Function Documentation#
sl_hal_pixelrz_init#
void sl_hal_pixelrz_init (PIXELRZ_TypeDef * pixelrz, const sl_hal_pixelrz_init_t * init)
Initialize PIXELRZ.
Type | Direction | Argument Name | Description |
---|---|---|---|
PIXELRZ_TypeDef * | [in] | pixelrz | A pointer to the PIXELRZ peripheral register block. |
const sl_hal_pixelrz_init_t * | [in] | init | A pointer to the PIXELRZ initialization structure. |
sl_hal_pixelrz_get_symbol_configuration#
sl_hal_pixelrz_symbol_t sl_hal_pixelrz_get_symbol_configuration (float time_high_us, float time_low_us, uint32_t freq)
Get symbol from time settings.
Type | Direction | Argument Name | Description |
---|---|---|---|
float | [in] | time_high_us | High time in microseconds. |
float | [in] | time_low_us | Low time in microseconds. |
uint32_t | [in] | freq | PIXELRZ source clock frequency. |
Check the datasheet for timing configuration.
Returns
Symbol high/low time values in clock cycles.
sl_hal_pixelrz_wait_sync#
void sl_hal_pixelrz_wait_sync (PIXELRZ_TypeDef * pixelrz)
Wait for ongoing sync of register(s) to the low-frequency domain to complete.
Type | Direction | Argument Name | Description |
---|---|---|---|
PIXELRZ_TypeDef * | [in] | pixelrz | Pointer to the PIXELRZ peripheral register block. |
sl_hal_pixelrz_wait_ready#
void sl_hal_pixelrz_wait_ready (PIXELRZ_TypeDef * pixelrz)
Wait for disabling to finish.
Type | Direction | Argument Name | Description |
---|---|---|---|
PIXELRZ_TypeDef * | [in] | pixelrz | Pointer to the PIXELRZ peripheral register block. |
sl_hal_pixelrz_enable#
void sl_hal_pixelrz_enable (PIXELRZ_TypeDef * pixelrz)
Enable PIXELRZ.
Type | Direction | Argument Name | Description |
---|---|---|---|
PIXELRZ_TypeDef * | [in] | pixelrz | Pointer to the PIXELRZ peripheral register block. |
sl_hal_pixelrz_disable#
void sl_hal_pixelrz_disable (PIXELRZ_TypeDef * pixelrz)
Disable PIXELRZ.
Type | Direction | Argument Name | Description |
---|---|---|---|
PIXELRZ_TypeDef * | [in] | pixelrz | Pointer to the PIXELRZ peripheral register block. |
sl_hal_pixelrz_tx#
void sl_hal_pixelrz_tx (PIXELRZ_TypeDef * pixelrz, uint32_t data)
Transmits one data word.
Type | Direction | Argument Name | Description |
---|---|---|---|
PIXELRZ_TypeDef * | [in] | pixelrz | Pointer to the PIXELRZ peripheral register block. |
uint32_t | [in] | data | Data to transmit. |
Data will be written into FIFO.
sl_hal_pixelrz_enable_tx#
void sl_hal_pixelrz_enable_tx (PIXELRZ_TypeDef * pixelrz)
Enable PIXELRZ transmitter.
Type | Direction | Argument Name | Description |
---|---|---|---|
PIXELRZ_TypeDef * | [in] | pixelrz | Pointer to the PIXELRZ peripheral register block. |
The behaviour of this command will depend on the trigger configuration. If trigger is set to Software mode, this command will trigger transmission of one frame and stop, user must run this command for every frame. If trigger is set to Auto mode, the data will be transmitted whenever there's data in the FIFO and it will trigger transmission of all frames.
sl_hal_pixelrz_disable_tx#
void sl_hal_pixelrz_disable_tx (PIXELRZ_TypeDef * pixelrz)
Disable PIXELRZ transmitter.
Type | Direction | Argument Name | Description |
---|---|---|---|
PIXELRZ_TypeDef * | [in] | pixelrz | Pointer to the PIXELRZ peripheral register block. |
sl_hal_pixelrz_clear_tx#
void sl_hal_pixelrz_clear_tx (PIXELRZ_TypeDef * pixelrz)
Clear TX FIFO.
Type | Direction | Argument Name | Description |
---|---|---|---|
PIXELRZ_TypeDef * | [in] | pixelrz | Pointer to the PIXELRZ peripheral register block. |
sl_hal_pixelrz_reset#
void sl_hal_pixelrz_reset (PIXELRZ_TypeDef * pixelrz)
Reset the PIXELRZ.
Type | Direction | Argument Name | Description |
---|---|---|---|
PIXELRZ_TypeDef * | [in] | pixelrz | A pixelrz peripheral module. |
sl_hal_pixelrz_get_status#
uint32_t sl_hal_pixelrz_get_status (PIXELRZ_TypeDef * pixelrz)
Gets PIXELRZ STATUS register value.
Type | Direction | Argument Name | Description |
---|---|---|---|
PIXELRZ_TypeDef * | [in] | pixelrz | A PIXELRZ peripheral module. |
Returns
Current STATUS register value.
sl_hal_pixelrz_clear_interrupts#
void sl_hal_pixelrz_clear_interrupts (PIXELRZ_TypeDef * pixelrz, uint32_t flags)
Clear one or more pending PIXELRZ interrupts.
Type | Direction | Argument Name | Description |
---|---|---|---|
PIXELRZ_TypeDef * | [in] | pixelrz | Pointer to the PIXELRZ peripheral register block. |
uint32_t | [in] | flags | Pending PIXELRZ interrupt source(s) to clear. Use one or more valid interrupt flags for the PIXELRZ module (PIXELRZ_IF_nnn) OR'ed together. |
sl_hal_pixelrz_set_interrupts#
void sl_hal_pixelrz_set_interrupts (PIXELRZ_TypeDef * pixelrz, uint32_t flags)
Set one or more pending PIXELRZ interrupts from Software.
Type | Direction | Argument Name | Description |
---|---|---|---|
PIXELRZ_TypeDef * | [in] | pixelrz | Pointer to the PIXELRZ peripheral register block. |
uint32_t | [in] | flags | PIXELRZ interrupt source(s) to set to pending. Use one or more valid interrupt flags for the PIXELRZ module (PIXELRZ_IF_nnn) OR'ed together. |
sl_hal_pixelrz_disable_interrupts#
void sl_hal_pixelrz_disable_interrupts (PIXELRZ_TypeDef * pixelrz, uint32_t flags)
Disable one or more PIXELRZ interrupts.
Type | Direction | Argument Name | Description |
---|---|---|---|
PIXELRZ_TypeDef * | [in] | pixelrz | Pointer to the PIXELRZ peripheral register block. |
uint32_t | [in] | flags | PIXELRZ interrupt source(s) to disable. Use one or more valid interrupt flags for the PIXELRZ module (PIXELRZ_IEN_nnn) OR'ed together. |
sl_hal_pixelrz_enable_interrupts#
void sl_hal_pixelrz_enable_interrupts (PIXELRZ_TypeDef * pixelrz, uint32_t flags)
Enable one or more PIXELRZ interrupts.
Type | Direction | Argument Name | Description |
---|---|---|---|
PIXELRZ_TypeDef * | [in] | pixelrz | Pointer to the PIXELRZ peripheral register block. |
uint32_t | [in] | flags | PIXELRZ interrupt source(s) to enable. Use one or more valid interrupt flags for the PIXELRZ module (PIXELRZ_IEN_nnn) OR'ed together. |
Note
Depending on the use, a pending interrupt may already be set prior to enabling the interrupt. To ignore a pending interrupt, consider using sl_hal_pixelrz_clear_interrupts() prior to enabling the interrupt.
sl_hal_pixelrz_get_pending_interrupts#
uint32_t sl_hal_pixelrz_get_pending_interrupts (PIXELRZ_TypeDef * pixelrz)
Get pending PIXELRZ interrupt flags.
Type | Direction | Argument Name | Description |
---|---|---|---|
PIXELRZ_TypeDef * | [in] | pixelrz | Pointer to the PIXELRZ peripheral register block. |
Note
Event bits are not cleared by this function.
Returns
PIXELRZ interrupt source(s) pending. Returns one or more valid interrupt flags for the PIXELRZ module (PIXELRZ_IF_nnn) OR'ed together.
sl_hal_pixelrz_get_enabled_interrupts#
uint32_t sl_hal_pixelrz_get_enabled_interrupts (PIXELRZ_TypeDef * pixelrz)
Get enabled PIXELRZ interrupt flags.
Type | Direction | Argument Name | Description |
---|---|---|---|
PIXELRZ_TypeDef * | [in] | pixelrz | Pointer to the PIXELRZ peripheral register block. |
Note
Event bits are not cleared by this function.
Returns
PIXELRZ interrupt source(s) enabled. Returns one or more valid enabled interrupt sources in PIXELRZx_IEN_nnn.
sl_hal_pixelrz_get_enabled_pending_interrupts#
uint32_t sl_hal_pixelrz_get_enabled_pending_interrupts (PIXELRZ_TypeDef * pixelrz)
Get enabled and pending PIXELRZ interrupt flags.
Type | Direction | Argument Name | Description |
---|---|---|---|
PIXELRZ_TypeDef * | [in] | pixelrz | Pointer to the PIXELRZ peripheral register block. |
Useful for handling more interrupt sources in the same interrupt handler.
Note
Interrupt flags are not cleared by this function.
Returns
Pending and enabled PIXELRZ interrupt sources. The return value is the bitwise AND combination of
the OR combination of enabled interrupt sources in PIXELRZx_IEN_nnn register (PIXELRZx_IEN_nnn) and
the OR combination of valid interrupt flags of the PIXELRZ module (PIXELRZx_IF_nnn).