Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CCS
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marko Mecina
CCS
Commits
65ea49bf
Commit
65ea49bf
authored
1 month ago
by
Marko Mecina
Browse files
Options
Downloads
Patches
Plain Diff
add command sequencer library
parent
9c74288b
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
Ccs/cmd_sequencer.py
+109
-0
109 additions, 0 deletions
Ccs/cmd_sequencer.py
with
109 additions
and
0 deletions
Ccs/cmd_sequencer.py
0 → 100644
+
109
−
0
View file @
65ea49bf
"""
Tools to create and interpret general purpose command sequences
"""
import
ctypes
NOP
=
0b000
UPDT
=
0b001
MOD
=
0b010
CMT
=
0b011
CBLK
=
0b100
VER
=
0b101
DATUM_BYTES_N
=
4
class
InstructionWord
(
ctypes
.
BigEndianStructure
):
_pack_
=
1
_fields_
=
[(
"
CMD
"
,
ctypes
.
c_uint32
,
3
),
(
"
IM
"
,
ctypes
.
c_uint32
,
1
),
(
"
DELAY
"
,
ctypes
.
c_uint32
,
12
),
(
"
REG
"
,
ctypes
.
c_uint32
,
6
),
(
"
SHIFT
"
,
ctypes
.
c_uint32
,
5
),
(
"
WIDTH
"
,
ctypes
.
c_uint32
,
5
)]
def
__str__
(
self
):
return
'
\n
'
.
join
([
'
{}: {}
'
.
format
(
i
[
0
],
getattr
(
self
,
i
[
0
]))
for
i
in
self
.
_fields_
])
class
Command
(
ctypes
.
BigEndianStructure
):
_pack_
=
1
_fields_
=
[(
"
INSTRUCTION
"
,
InstructionWord
),
(
"
DATUM
"
,
ctypes
.
c_uint32
)]
def
__str__
(
self
):
return
self
.
INSTRUCTION
.
__str__
()
+
'
\n
DATUM: 0x{:08X}
'
.
format
(
self
.
DATUM
)
class
BlockCommit
(
ctypes
.
BigEndianStructure
):
_pack_
=
1
_fields_
=
[(
"
INSTRUCTION
"
,
InstructionWord
),
(
"
N
"
,
ctypes
.
c_uint32
,
6
),
(
"
RESERVED
"
,
ctypes
.
c_uint32
,
26
)]
def
__str__
(
self
):
return
self
.
INSTRUCTION
.
__str__
()
+
'
\n
N: {}
'
.
format
(
self
.
N
)
def
nop
():
cmd
=
Command
()
cmd
.
INSTRUCTION
.
CMD
=
NOP
return
cmd
def
updt
(
reg
,
im
,
delay
):
cmd
=
Command
()
cmd
.
INSTRUCTION
.
CMD
=
UPDT
cmd
.
INSTRUCTION
.
REG
=
reg
cmd
.
INSTRUCTION
.
IM
=
im
cmd
.
INSTRUCTION
.
DELAY
=
delay
return
cmd
def
mod
(
reg
,
shift
,
width
,
datum
):
cmd
=
Command
()
cmd
.
INSTRUCTION
.
CMD
=
MOD
cmd
.
INSTRUCTION
.
REG
=
reg
cmd
.
INSTRUCTION
.
SHIFT
=
shift
cmd
.
INSTRUCTION
.
WIDTH
=
width
cmd
.
DATUM
=
datum
return
cmd
def
cmt
(
reg
,
im
,
delay
):
cmd
=
Command
()
cmd
.
INSTRUCTION
.
CMD
=
CMT
cmd
.
INSTRUCTION
.
REG
=
reg
cmd
.
INSTRUCTION
.
IM
=
im
cmd
.
INSTRUCTION
.
DELAY
=
delay
return
cmd
def
cblk
(
reg
,
n
,
delay
,
im
):
cmd
=
BlockCommit
()
cmd
.
INSTRUCTION
.
CMD
=
CBLK
cmd
.
INSTRUCTION
.
REG
=
reg
cmd
.
INSTRUCTION
.
IM
=
im
cmd
.
INSTRUCTION
.
DELAY
=
delay
cmd
.
N
=
n
return
cmd
def
ver
(
reg
,
im
,
delay
,
shift
,
width
,
datum
):
cmd
=
Command
()
cmd
.
INSTRUCTION
.
CMD
=
VER
cmd
.
INSTRUCTION
.
IM
=
im
cmd
.
INSTRUCTION
.
DELAY
=
delay
cmd
.
INSTRUCTION
.
REG
=
reg
cmd
.
INSTRUCTION
.
SHIFT
=
shift
cmd
.
INSTRUCTION
.
WIDTH
=
width
cmd
.
DATUM
=
datum
return
cmd
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