NEORV32 Software Framework Documentation
The NEORV32 RISC-V Processor
Loading...
Searching...
No Matches
neorv32_neoled.h File Reference

Smart LED Interface (NEOLED) HW driver header file. More...

#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  neorv32_neoled_t
 

Functions

void neorv32_neoled_write_nonblocking (uint32_t data)
 
Prototypes
int neorv32_neoled_available (void)
 
void neorv32_neoled_setup (uint32_t prsc, uint32_t t_total, uint32_t t_high_zero, uint32_t t_high_one, int irq_mode)
 
void neorv32_neoled_setup_ws2812 (int irq_mode)
 
void neorv32_neoled_set_mode (uint32_t mode)
 
void neorv32_neoled_strobe_blocking (void)
 
void neorv32_neoled_strobe_nonblocking (void)
 
void neorv32_neoled_enable (void)
 
void neorv32_neoled_disable (void)
 
void neorv32_neoled_write_blocking (uint32_t data)
 
uint32_t neorv32_neoled_get_buffer_size (void)
 

IO Device: Smart LED Hardware Interface (NEOLED)

#define NEORV32_NEOLED   ((neorv32_neoled_t*) (NEORV32_NEOLED_BASE))
 
enum  NEORV32_NEOLED_CTRL_enum {
  NEOLED_CTRL_EN = 0 , NEOLED_CTRL_MODE = 1 , NEOLED_CTRL_STROBE = 2 , NEOLED_CTRL_PRSC0 = 3 ,
  NEOLED_CTRL_PRSC1 = 4 , NEOLED_CTRL_PRSC2 = 5 , NEOLED_CTRL_BUFS_0 = 6 , NEOLED_CTRL_BUFS_1 = 7 ,
  NEOLED_CTRL_BUFS_2 = 8 , NEOLED_CTRL_BUFS_3 = 9 , NEOLED_CTRL_T_TOT_0 = 10 , NEOLED_CTRL_T_TOT_1 = 11 ,
  NEOLED_CTRL_T_TOT_2 = 12 , NEOLED_CTRL_T_TOT_3 = 13 , NEOLED_CTRL_T_TOT_4 = 14 , NEOLED_CTRL_T_ZERO_H_0 = 15 ,
  NEOLED_CTRL_T_ZERO_H_1 = 16 , NEOLED_CTRL_T_ZERO_H_2 = 17 , NEOLED_CTRL_T_ZERO_H_3 = 18 , NEOLED_CTRL_T_ZERO_H_4 = 19 ,
  NEOLED_CTRL_T_ONE_H_0 = 20 , NEOLED_CTRL_T_ONE_H_1 = 21 , NEOLED_CTRL_T_ONE_H_2 = 22 , NEOLED_CTRL_T_ONE_H_3 = 23 ,
  NEOLED_CTRL_T_ONE_H_4 = 24 , NEOLED_CTRL_IRQ_CONF = 27 , NEOLED_CTRL_TX_EMPTY = 28 , NEOLED_CTRL_TX_HALF = 29 ,
  NEOLED_CTRL_TX_FULL = 30 , NEOLED_CTRL_TX_BUSY = 31
}
 

Detailed Description

Smart LED Interface (NEOLED) HW driver header file.

Note
These functions should only be used if the NEOLED unit was synthesized (IO_NEOLED_EN = true).
See also
https://stnolting.github.io/neorv32/sw/files.html

Macro Definition Documentation

◆ NEORV32_NEOLED

#define NEORV32_NEOLED   ((neorv32_neoled_t*) (NEORV32_NEOLED_BASE))

NEOLED module hardware access (neorv32_neoled_t)

Enumeration Type Documentation

◆ NEORV32_NEOLED_CTRL_enum

NEOLED control register bits

Enumerator
NEOLED_CTRL_EN 

NEOLED control register(0) (r/w): NEOLED global enable

NEOLED_CTRL_MODE 

NEOLED control register(1) (r/w): TX mode (0=24-bit, 1=32-bit)

NEOLED_CTRL_STROBE 

NEOLED control register(2) (r/w): Strobe (0=send normal data, 1=send RESET command on data write)

NEOLED_CTRL_PRSC0 

NEOLED control register(3) (r/w): Clock prescaler select bit 0 (pulse-clock speed select)

NEOLED_CTRL_PRSC1 

NEOLED control register(4) (r/w): Clock prescaler select bit 1 (pulse-clock speed select)

NEOLED_CTRL_PRSC2 

NEOLED control register(5) (r/w): Clock prescaler select bit 2 (pulse-clock speed select)

NEOLED_CTRL_BUFS_0 

NEOLED control register(6) (r/-): log2(tx buffer size) bit 0

NEOLED_CTRL_BUFS_1 

NEOLED control register(7) (r/-): log2(tx buffer size) bit 1

NEOLED_CTRL_BUFS_2 

NEOLED control register(8) (r/-): log2(tx buffer size) bit 2

NEOLED_CTRL_BUFS_3 

NEOLED control register(9) (r/-): log2(tx buffer size) bit 3

NEOLED_CTRL_T_TOT_0 

NEOLED control register(10) (r/w): pulse-clock ticks per total period bit 0

NEOLED_CTRL_T_TOT_1 

NEOLED control register(11) (r/w): pulse-clock ticks per total period bit 1

NEOLED_CTRL_T_TOT_2 

NEOLED control register(12) (r/w): pulse-clock ticks per total period bit 2

NEOLED_CTRL_T_TOT_3 

NEOLED control register(13) (r/w): pulse-clock ticks per total period bit 3

NEOLED_CTRL_T_TOT_4 

NEOLED control register(14) (r/w): pulse-clock ticks per total period bit 4

NEOLED_CTRL_T_ZERO_H_0 

NEOLED control register(15) (r/w): pulse-clock ticks per ZERO high-time bit 0

NEOLED_CTRL_T_ZERO_H_1 

NEOLED control register(16) (r/w): pulse-clock ticks per ZERO high-time bit 1

NEOLED_CTRL_T_ZERO_H_2 

NEOLED control register(17) (r/w): pulse-clock ticks per ZERO high-time bit 2

NEOLED_CTRL_T_ZERO_H_3 

NEOLED control register(18) (r/w): pulse-clock ticks per ZERO high-time bit 3

NEOLED_CTRL_T_ZERO_H_4 

NEOLED control register(19) (r/w): pulse-clock ticks per ZERO high-time bit 4

NEOLED_CTRL_T_ONE_H_0 

NEOLED control register(20) (r/w): pulse-clock ticks per ONE high-time bit 0

NEOLED_CTRL_T_ONE_H_1 

NEOLED control register(21) (r/w): pulse-clock ticks per ONE high-time bit 1

NEOLED_CTRL_T_ONE_H_2 

NEOLED control register(22) (r/w): pulse-clock ticks per ONE high-time bit 2

NEOLED_CTRL_T_ONE_H_3 

NEOLED control register(23) (r/w): pulse-clock ticks per ONE high-time bit 3

NEOLED_CTRL_T_ONE_H_4 

NEOLED control register(24) (r/w): pulse-clock ticks per ONE high-time bit 4

NEOLED_CTRL_IRQ_CONF 

NEOLED control register(27) (r/w): TX FIFO interrupt: 1=IRQ if FIFO is empty, 1=IRQ if FIFO is less than half-full

NEOLED_CTRL_TX_EMPTY 

NEOLED control register(28) (r/-): TX FIFO is empty

NEOLED_CTRL_TX_HALF 

NEOLED control register(29) (r/-): TX FIFO is at least half-full

NEOLED_CTRL_TX_FULL 

NEOLED control register(30) (r/-): TX FIFO is full

NEOLED_CTRL_TX_BUSY 

NEOLED control register(31) (r/-): busy flag

Function Documentation

◆ neorv32_neoled_available()

int neorv32_neoled_available ( void )

Check if NEOLED unit was synthesized.

Returns
0 if NEOLED was not synthesized, 1 if NEOLED is available.

◆ neorv32_neoled_disable()

void neorv32_neoled_disable ( void )

Disable NEOLED controller.

◆ neorv32_neoled_enable()

void neorv32_neoled_enable ( void )

Enable NEOLED controller.

◆ neorv32_neoled_get_buffer_size()

uint32_t neorv32_neoled_get_buffer_size ( void )

Get NEOLED hardware buffer size.

Returns
Number of entries in NEOLED TX buffer.

◆ neorv32_neoled_set_mode()

void neorv32_neoled_set_mode ( uint32_t mode)

Set NEOLED mode (24-bit RGB / 32-bit RGBW).

Parameters
[in]mode0 = 24-bit mode (RGB), 1 = 32-bit mode (RGBW)

◆ neorv32_neoled_setup()

void neorv32_neoled_setup ( uint32_t prsc,
uint32_t t_total,
uint32_t t_high_zero,
uint32_t t_high_one,
int irq_mode )

Enable and configure NEOLED controller. The NEOLED control register bits are listed in NEORV32_NEOLED_CTRL_enum. This function performs a "raw" configuration (just configuring the according control register bit).

Parameters
[in]prscClock prescaler select (0..7). See NEORV32_CLOCK_PRSC_enum.
[in]t_totalNumber of pre-scaled clock ticks for total bit period (0..31).
[in]t_high_zeroNumber of pre-scaled clock ticks to generate high-time for sending a '0' (0..31).
[in]t_high_oneNumber of pre-scaled clock ticks to generate high-time for sending a '1' (0..31).
[in]irq_modeInterrupt condition (1=IRQ if FIFO is empty, 1=IRQ if FIFO is less than half-full).

◆ neorv32_neoled_setup_ws2812()

void neorv32_neoled_setup_ws2812 ( int irq_mode)

Configure NEOLED controller for using WS2812 LEDs (NeoPixel-compatible). This function computes all the required timings and finally calls neorv32_neoled_setup.

Note
WS2812 timing: T_period = 1.2us, T_high_zero = 0.4us, T_high_one = 0.8us. Change the constants if required.
This function uses the SYSINFO_CLK value (from the SYSINFO HW module) to do the timing computations.
Parameters
[in]irq_modeInterrupt condition (1=IRQ if FIFO is empty, 1=IRQ if FIFO is less than half-full).

◆ neorv32_neoled_strobe_blocking()

void neorv32_neoled_strobe_blocking ( void )

Send strobe command ("RESET") - blocking.

◆ neorv32_neoled_strobe_nonblocking()

void neorv32_neoled_strobe_nonblocking ( void )

Send strobe command ("RESET") - non-blocking.

◆ neorv32_neoled_write_blocking()

void neorv32_neoled_write_blocking ( uint32_t data)

Send single RGB(W) data word to NEOLED module (blocking).

Warning
This function is blocking as it polls the NEOLED FIFO full flag.
Parameters
[in]dataLSB-aligned 24-bit RGB or 32-bit RGBW data

◆ neorv32_neoled_write_nonblocking()

void neorv32_neoled_write_nonblocking ( uint32_t data)
inline

Send single RGB(W) data word to NEOLED module (non-blocking).

Warning
This function uses NO busy/flag checks at all!
Parameters
[in]dataLSB-aligned 24-bit RGB or 32-bit RGBW data