Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Astro
rust-card10
Commits
afa6cbdc
Commit
afa6cbdc
authored
Aug 22, 2019
by
Astro
⚙
Browse files
updates
parent
fc74de1b
Pipeline
#2807
failed with stage
in 9 minutes and 4 seconds
Changes
5
Pipelines
1
Show whitespace changes
Inline
Side-by-side
c
@
4d77b5c4
Compare
9a0d1584
...
4d77b5c4
Subproject commit
9a0d1584f84042fe29c4bff12cbdb577e96a23fe
Subproject commit
4d77b5c4cbb1f017014b1178482ec2be019a3711
default.nix
View file @
afa6cbdc
...
...
@@ -10,26 +10,39 @@ let
rustc
=
rust
;
cargo
=
rust
;
};
py-crc16
=
callPackage
./python-crc16.nix
{};
epic-stubs
=
stdenv
.
mkDerivation
{
name
=
"epic-stubs"
;
src
=
./c
;
buildInputs
=
[
gcc
python3
];
buildPhase
=
''
${
python3
}
/bin/python epicardium/api/genapi.py -H epicardium/epicardium.h -c client.c -s server.c
''
;
installPhase
=
''
mkdir $out
cp client.c server.c $out/
''
;
};
firmware
=
rustPlatform
.
buildRustPackage
rec
{
name
=
"rust-card10"
;
version
=
"0.0.0"
;
src
=
./.
;
cargoSha256
=
"04blshy2c4xms9v8ik921qs3ym4vq8rsx8pw78brw7r88x6lx01a"
;
buildInputs
=
[
py-crc16
]
++
(
with
pkgsCross
.
armhf-embedded
.
stdenv
;
[
cc
binutils
]);
preBuild
=
"export CARGO_HOME=$(mktemp -d cargo-home.XXX)"
;
cargoSha256
=
"10qv30p3kr570glnyn37b6r8pgx48zj0mr9qf84m4wk4sjp3wxsd"
;
buildInputs
=
[
pkgsCross
.
armhf-embedded
.
stdenv
.
cc
];
prePatch
=
''
cp
${
epic-stubs
}
/client.c l0dable/src/
''
;
preBuild
=
''
export LIBCLANG_PATH=
${
llvmPackages
.
libclang
}
/lib
export CPATH=
${
glibc_multi
.
dev
}
/include
export CARGO_HOME=$(mktemp -d cargo-home.XXX)
cd example
''
;
doCheck
=
false
;
installPhase
=
''
mkdir -p $out/lib
cp target/thumbv7em-none-eabihf/release/watchapp $out/lib/
arm-none-eabihf-objcopy -O binary $out/lib/watchapp $out/lib/card10.bin
${
python3
}
/bin/python c/bootloader/crc_patch.py $out/lib/card10.bin
cp target/thumbv7em-none-eabihf/release/example $out/lib/example.elf
''
;
};
in
{
inherit
openocd
rust
rustPlatform
py-crc16
firmware
;
inherit
rust
rustPlatform
firmware
epic-stubs
;
}
l0dable/src/client.c
View file @
afa6cbdc
...
...
@@ -73,6 +73,20 @@ void epic_system_reset(void)
_api_call_transact
(
epc__apistub_buffer
);
}
/* Autogenerated stub for API_BATTERY_VOLTAGE */
int
epic_read_battery_voltage
(
float
*
result
)
{
const
int
epc__apistub_size
=
sizeof
(
float
*
);
void
*
epc__apistub_buffer
;
epc__apistub_buffer
=
_api_call_start
(
API_BATTERY_VOLTAGE
,
epc__apistub_size
);
/* TODO: Check if epc__apistub_buffer is not NULL */
*
(
float
**
)(
epc__apistub_buffer
+
0
)
=
result
;
return
*
(
int
*
)
_api_call_transact
(
epc__apistub_buffer
);
}
/* Autogenerated stub for API_UART_WRITE_STR */
void
epic_uart_write_str
(
const
char
*
str
,
intptr_t
length
)
{
...
...
@@ -385,6 +399,63 @@ void epic_leds_set_gamma_table( uint8_t rgb_channel, uint8_t *gamma_table )
_api_call_transact
(
epc__apistub_buffer
);
}
/* Autogenerated stub for API_LEDS_CLEAR_ALL */
void
epic_leds_clear_all
(
uint8_t
r
,
uint8_t
g
,
uint8_t
b
)
{
const
int
epc__apistub_size
=
sizeof
(
uint8_t
)
+
sizeof
(
uint8_t
)
+
sizeof
(
uint8_t
);
void
*
epc__apistub_buffer
;
epc__apistub_buffer
=
_api_call_start
(
API_LEDS_CLEAR_ALL
,
epc__apistub_size
);
/* TODO: Check if epc__apistub_buffer is not NULL */
*
(
uint8_t
*
)(
epc__apistub_buffer
+
0
)
=
r
;
*
(
uint8_t
*
)(
epc__apistub_buffer
+
sizeof
(
uint8_t
))
=
g
;
*
(
uint8_t
*
)(
epc__apistub_buffer
+
sizeof
(
uint8_t
)
+
sizeof
(
uint8_t
))
=
b
;
_api_call_transact
(
epc__apistub_buffer
);
}
/* Autogenerated stub for API_PERSONAL_STATE_SET */
int
epic_personal_state_set
(
uint8_t
state
,
_Bool
persistent
)
{
const
int
epc__apistub_size
=
sizeof
(
uint8_t
)
+
sizeof
(
_Bool
);
void
*
epc__apistub_buffer
;
epc__apistub_buffer
=
_api_call_start
(
API_PERSONAL_STATE_SET
,
epc__apistub_size
);
/* TODO: Check if epc__apistub_buffer is not NULL */
*
(
uint8_t
*
)(
epc__apistub_buffer
+
0
)
=
state
;
*
(
_Bool
*
)(
epc__apistub_buffer
+
sizeof
(
uint8_t
))
=
persistent
;
return
*
(
int
*
)
_api_call_transact
(
epc__apistub_buffer
);
}
/* Autogenerated stub for API_PERSONAL_STATE_GET */
int
epic_personal_state_get
()
{
const
int
epc__apistub_size
=
0
;
void
*
epc__apistub_buffer
;
epc__apistub_buffer
=
_api_call_start
(
API_PERSONAL_STATE_GET
,
epc__apistub_size
);
/* TODO: Check if epc__apistub_buffer is not NULL */
return
*
(
int
*
)
_api_call_transact
(
epc__apistub_buffer
);
}
/* Autogenerated stub for API_PERSONAL_STATE_IS_PERSISTENT */
int
epic_personal_state_is_persistent
()
{
const
int
epc__apistub_size
=
0
;
void
*
epc__apistub_buffer
;
epc__apistub_buffer
=
_api_call_start
(
API_PERSONAL_STATE_IS_PERSISTENT
,
epc__apistub_size
);
/* TODO: Check if epc__apistub_buffer is not NULL */
return
*
(
int
*
)
_api_call_transact
(
epc__apistub_buffer
);
}
/* Autogenerated stub for API_STREAM_READ */
int
epic_stream_read
(
int
sd
,
void
*
buf
,
size_t
count
)
{
...
...
@@ -862,6 +933,21 @@ int epic_rtc_schedule_alarm(uint32_t timestamp)
return
*
(
int
*
)
_api_call_transact
(
epc__apistub_buffer
);
}
/* Autogenerated stub for API_TRNG_READ */
int
epic_trng_read
(
uint8_t
*
dest
,
size_t
size
)
{
const
int
epc__apistub_size
=
sizeof
(
uint8_t
*
)
+
sizeof
(
size_t
);
void
*
epc__apistub_buffer
;
epc__apistub_buffer
=
_api_call_start
(
API_TRNG_READ
,
epc__apistub_size
);
/* TODO: Check if epc__apistub_buffer is not NULL */
*
(
uint8_t
**
)(
epc__apistub_buffer
+
0
)
=
dest
;
*
(
size_t
*
)(
epc__apistub_buffer
+
sizeof
(
uint8_t
*
))
=
size
;
return
*
(
int
*
)
_api_call_transact
(
epc__apistub_buffer
);
}
/* Weakly linked stubs for ISRs */
void
__epic_isr_reset
(
api_int_id_t
id
)
...
...
l0dable/src/display.rs
View file @
afa6cbdc
...
...
@@ -3,20 +3,34 @@ use super::bindings::*;
pub
struct
Display
;
impl
Display
{
pub
const
W
:
u16
=
160
;
pub
const
H
:
u16
=
80
;
pub
fn
open
()
->
Self
{
unsafe
{
epic_disp_open
();
}
Display
}
pub
fn
print
(
&
self
,
x
:
u16
,
y
:
u16
,
s
:
&
str
,
fg
:
u16
,
bg
:
u16
)
{
pub
fn
update
(
&
self
)
{
unsafe
{
epic_disp_update
();
}
}
/// s must be 0-terminated
pub
fn
print
(
&
self
,
x
:
u16
,
y
:
u16
,
s
:
&
[
u8
],
fg
:
u16
,
bg
:
u16
)
{
unsafe
{
epic_disp_print
(
x
,
y
,
s
.as_ptr
(),
fg
,
bg
);
}
}
pub
fn
update
(
&
self
)
{
pub
fn
pixel
(
&
self
,
x
:
u16
,
y
:
u16
,
color
:
u16
)
{
unsafe
{
epic_disp_update
();
epic_disp_pixel
(
x
,
y
,
color
);
}
}
}
impl
Drop
for
Display
{
fn
drop
(
&
mut
self
)
{
unsafe
{
epic_disp_close
();
}
}
}
shell.nix
View file @
afa6cbdc
...
...
@@ -9,7 +9,7 @@ stdenv.mkDerivation {
gdb
rust
pkgsCross
.
armhf-embedded
.
stdenv
.
cc
py-crc16
openocd
];
# Set Environment Variables
...
...
@@ -17,14 +17,6 @@ stdenv.mkDerivation {
shellHook
=
''
export LIBCLANG_PATH=
${
llvmPackages
.
libclang
}
/lib
echo "Starting openocd…"
${
openocd
}
/bin/openocd-card10 &
# Let openocd output scroll by
sleep 1
export PATH=`pwd`/.bin:$PATH
echo "Run 'cargo card10 watchapp'"
echo "Run 'cd example && cargo build --release'"
''
;
}
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