Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
lwc
/
compare
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Pipelines
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
26b36a28
authored
5 years ago
by
Sebastian Renner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First steps for stm middleware
parent
b5532c06
master
…
128B
f7_masked
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
0 deletions
+72
-0
templates/blackpill/flash.jlink
+7
-0
templates/blackpill/middleware.py
+65
-0
No files found.
templates/blackpill/flash.jlink
0 → 100644
View file @
26b36a28
if SWD
speed 4000
device STM32F103C8
loadbin build/blackpill.bin 0x8000000
r
g
exit
This diff is collapsed.
Click to expand it.
templates/blackpill/middleware.py
0 → 100755
View file @
26b36a28
#!/usr/bin/env python3
import
os
import
sys
import
struct
import
serial
from
subprocess
import
Popen
,
PIPE
,
run
def
flash
():
run
(
"JLinkExe flash.jlink"
,
shell
=
True
,
check
=
True
)
def
read
(
channel
,
l
):
if
channel
==
'ser'
:
data
=
ser
.
read
(
l
)
elif
channel
==
'std'
:
data
=
sys
.
stdin
.
read
(
l
)
else
:
raise
Exception
(
"read() complains: no sai channelino"
)
if
len
(
data
)
!=
l
:
raise
Exception
(
"could not read
%
d bytes of data (got
%
d)"
%
(
l
,
len
(
data
)))
return
data
def
write
(
channel
,
data
,
direction
):
if
channel
==
'ser'
:
l
=
ser
.
write
(
data
)
elif
channel
==
'std'
:
l
=
sys
.
stdout
.
write
(
data
)
else
:
raise
Exception
(
"write() complains: no sai channelino"
)
if
len
(
data
)
!=
l
:
raise
Exception
(
"could not write
%
d bytes of data (put
%
d)"
%
(
len
(
data
),
l
))
def
obtain
(
channel
):
l
=
read
(
channel
,
4
)
print
(
l
)
(
l
,
)
=
struct
.
unpack
(
"<I"
,
l
)
return
read
(
channel
,
l
)
def
submit
(
channel
,
action
,
data
):
h
=
struct
.
pack
(
"<BI"
,
ord
(
action
),
len
(
data
))
write
(
channel
,
h
)
write
(
channel
,
data
)
def
main
():
#flash()
ser
=
serial
.
Serial
(
'/dev/ttyUSB0'
,
115200
)
while
(
1
):
action
=
read
(
'std'
,
1
)
if
(
action
):
if
action
==
'c'
or
action
==
'm'
or
action
==
'a'
or
action
==
'k'
or
action
==
's'
or
action
==
'p'
:
data
=
obtain
(
'std'
)
submit
(
'ser'
,
action
,
data
)
elif
action
==
'e'
or
action
==
'd'
:
write
(
'ser'
,
action
)
elif
action
==
'C'
or
action
==
'M'
or
action
==
'A'
or
action
==
'K'
or
action
==
'S'
or
action
==
'P'
:
write
(
'ser'
,
action
)
data
=
obtain
(
'ser'
)
submit
(
'std'
,
action
,
data
)
else
:
raise
Exception
(
"no capiche aczione
%
s"
%
(
action
))
if
__name__
==
"__main__"
:
sys
.
exit
(
main
())
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment