Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
U
Using ws2812
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ebp1g21
Using ws2812
Commits
74582835
Commit
74582835
authored
2 years ago
by
ebp1g21
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
8e5b3413
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
ws2812.pio.h
+114
-0
114 additions, 0 deletions
ws2812.pio.h
with
114 additions
and
0 deletions
ws2812.pio.h
0 → 100644
+
114
−
0
View file @
74582835
// -------------------------------------------------- //
// This file is autogenerated by pioasm; do not edit! //
// -------------------------------------------------- //
#pragma once
#if !PICO_NO_HARDWARE
#include
"hardware/pio.h"
#endif
// ------ //
// ws2812 //
// ------ //
#define ws2812_wrap_target 0
#define ws2812_wrap 3
#define ws2812_T1 2
#define ws2812_T2 5
#define ws2812_T3 3
static
const
uint16_t
ws2812_program_instructions
[]
=
{
// .wrap_target
0x6221
,
// 0: out x, 1 side 0 [2]
0x1123
,
// 1: jmp !x, 3 side 1 [1]
0x1400
,
// 2: jmp 0 side 1 [4]
0xa442
,
// 3: nop side 0 [4]
// .wrap
};
#if !PICO_NO_HARDWARE
static
const
struct
pio_program
ws2812_program
=
{
.
instructions
=
ws2812_program_instructions
,
.
length
=
4
,
.
origin
=
-
1
,
};
static
inline
pio_sm_config
ws2812_program_get_default_config
(
uint
offset
)
{
pio_sm_config
c
=
pio_get_default_sm_config
();
sm_config_set_wrap
(
&
c
,
offset
+
ws2812_wrap_target
,
offset
+
ws2812_wrap
);
sm_config_set_sideset
(
&
c
,
1
,
false
,
false
);
return
c
;
}
#include
"hardware/clocks.h"
static
inline
void
ws2812_program_init
(
PIO
pio
,
uint
sm
,
uint
offset
,
uint
pin
,
float
freq
,
bool
rgbw
)
{
pio_gpio_init
(
pio
,
pin
);
pio_sm_set_consecutive_pindirs
(
pio
,
sm
,
pin
,
1
,
true
);
pio_sm_config
c
=
ws2812_program_get_default_config
(
offset
);
sm_config_set_sideset_pins
(
&
c
,
pin
);
sm_config_set_out_shift
(
&
c
,
false
,
true
,
rgbw
?
32
:
24
);
sm_config_set_fifo_join
(
&
c
,
PIO_FIFO_JOIN_TX
);
int
cycles_per_bit
=
ws2812_T1
+
ws2812_T2
+
ws2812_T3
;
float
div
=
clock_get_hz
(
clk_sys
)
/
(
freq
*
cycles_per_bit
);
sm_config_set_clkdiv
(
&
c
,
div
);
pio_sm_init
(
pio
,
sm
,
offset
,
&
c
);
pio_sm_set_enabled
(
pio
,
sm
,
true
);
}
#endif
// --------------- //
// ws2812_parallel //
// --------------- //
#define ws2812_parallel_wrap_target 0
#define ws2812_parallel_wrap 3
#define ws2812_parallel_T1 2
#define ws2812_parallel_T2 5
#define ws2812_parallel_T3 3
static
const
uint16_t
ws2812_parallel_program_instructions
[]
=
{
// .wrap_target
0x6020
,
// 0: out x, 32
0xa10b
,
// 1: mov pins, !null [1]
0xa401
,
// 2: mov pins, x [4]
0xa103
,
// 3: mov pins, null [1]
// .wrap
};
#if !PICO_NO_HARDWARE
static
const
struct
pio_program
ws2812_parallel_program
=
{
.
instructions
=
ws2812_parallel_program_instructions
,
.
length
=
4
,
.
origin
=
-
1
,
};
static
inline
pio_sm_config
ws2812_parallel_program_get_default_config
(
uint
offset
)
{
pio_sm_config
c
=
pio_get_default_sm_config
();
sm_config_set_wrap
(
&
c
,
offset
+
ws2812_parallel_wrap_target
,
offset
+
ws2812_parallel_wrap
);
return
c
;
}
#include
"hardware/clocks.h"
static
inline
void
ws2812_parallel_program_init
(
PIO
pio
,
uint
sm
,
uint
offset
,
uint
pin_base
,
uint
pin_count
,
float
freq
)
{
for
(
uint
i
=
pin_base
;
i
<
pin_base
+
pin_count
;
i
++
)
{
pio_gpio_init
(
pio
,
i
);
}
pio_sm_set_consecutive_pindirs
(
pio
,
sm
,
pin_base
,
pin_count
,
true
);
pio_sm_config
c
=
ws2812_parallel_program_get_default_config
(
offset
);
sm_config_set_out_shift
(
&
c
,
true
,
true
,
32
);
sm_config_set_out_pins
(
&
c
,
pin_base
,
pin_count
);
sm_config_set_set_pins
(
&
c
,
pin_base
,
pin_count
);
sm_config_set_fifo_join
(
&
c
,
PIO_FIFO_JOIN_TX
);
int
cycles_per_bit
=
ws2812_parallel_T1
+
ws2812_parallel_T2
+
ws2812_parallel_T3
;
float
div
=
clock_get_hz
(
clk_sys
)
/
(
freq
*
cycles_per_bit
);
sm_config_set_clkdiv
(
&
c
,
div
);
pio_sm_init
(
pio
,
sm
,
offset
,
&
c
);
pio_sm_set_enabled
(
pio
,
sm
,
true
);
}
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment