mirror of
https://github.com/raspberrypi/pico-sdk.git
synced 2025-12-10 07:14:36 +01:00
Compare commits
2 commits
b52528a6a4
...
a7708c7a5f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a7708c7a5f | ||
|
|
a76f2416ba |
6 changed files with 53 additions and 10 deletions
25
MODULE.bazel
25
MODULE.bazel
|
|
@ -16,7 +16,10 @@ http_archive(
|
||||||
build_file = "//bazel/toolchain:gcc_arm_none_eabi.BUILD",
|
build_file = "//bazel/toolchain:gcc_arm_none_eabi.BUILD",
|
||||||
sha256 = "8fd8b4a0a8d44ab2e195ccfbeef42223dfb3ede29d80f14dcf2183c34b8d199a",
|
sha256 = "8fd8b4a0a8d44ab2e195ccfbeef42223dfb3ede29d80f14dcf2183c34b8d199a",
|
||||||
strip_prefix = "arm-gnu-toolchain-13.2.Rel1-aarch64-arm-none-eabi",
|
strip_prefix = "arm-gnu-toolchain-13.2.Rel1-aarch64-arm-none-eabi",
|
||||||
url = "https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-aarch64-arm-none-eabi.tar.xz",
|
urls = [
|
||||||
|
"https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-aarch64-arm-none-eabi.tar.xz",
|
||||||
|
"https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-aarch64-arm-none-eabi.tar.xz",
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
http_archive(
|
http_archive(
|
||||||
|
|
@ -24,7 +27,10 @@ http_archive(
|
||||||
build_file = "//bazel/toolchain:gcc_arm_none_eabi.BUILD",
|
build_file = "//bazel/toolchain:gcc_arm_none_eabi.BUILD",
|
||||||
sha256 = "6cd1bbc1d9ae57312bcd169ae283153a9572bd6a8e4eeae2fedfbc33b115fdbb",
|
sha256 = "6cd1bbc1d9ae57312bcd169ae283153a9572bd6a8e4eeae2fedfbc33b115fdbb",
|
||||||
strip_prefix = "arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi",
|
strip_prefix = "arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi",
|
||||||
url = "https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-x86_64-arm-none-eabi.tar.xz",
|
urls = [
|
||||||
|
"https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-x86_64-arm-none-eabi.tar.xz",
|
||||||
|
"https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-x86_64-arm-none-eabi.tar.xz",
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
http_archive(
|
http_archive(
|
||||||
|
|
@ -32,7 +38,10 @@ http_archive(
|
||||||
build_file = "//bazel/toolchain:gcc_arm_none_eabi.BUILD",
|
build_file = "//bazel/toolchain:gcc_arm_none_eabi.BUILD",
|
||||||
sha256 = "51d933f00578aa28016c5e3c84f94403274ea7915539f8e56c13e2196437d18f",
|
sha256 = "51d933f00578aa28016c5e3c84f94403274ea7915539f8e56c13e2196437d18f",
|
||||||
strip_prefix = "arm-gnu-toolchain-13.2.Rel1-mingw-w64-i686-arm-none-eabi",
|
strip_prefix = "arm-gnu-toolchain-13.2.Rel1-mingw-w64-i686-arm-none-eabi",
|
||||||
url = "https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-mingw-w64-i686-arm-none-eabi.zip",
|
urls = [
|
||||||
|
"https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-mingw-w64-i686-arm-none-eabi.zip",
|
||||||
|
"https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-mingw-w64-i686-arm-none-eabi.zip",
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
http_archive(
|
http_archive(
|
||||||
|
|
@ -40,7 +49,10 @@ http_archive(
|
||||||
build_file = "//bazel/toolchain:gcc_arm_none_eabi.BUILD",
|
build_file = "//bazel/toolchain:gcc_arm_none_eabi.BUILD",
|
||||||
sha256 = "075faa4f3e8eb45e59144858202351a28706f54a6ec17eedd88c9fb9412372cc",
|
sha256 = "075faa4f3e8eb45e59144858202351a28706f54a6ec17eedd88c9fb9412372cc",
|
||||||
strip_prefix = "arm-gnu-toolchain-13.2.Rel1-darwin-x86_64-arm-none-eabi",
|
strip_prefix = "arm-gnu-toolchain-13.2.Rel1-darwin-x86_64-arm-none-eabi",
|
||||||
url = "https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-darwin-x86_64-arm-none-eabi.tar.xz",
|
urls = [
|
||||||
|
"https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-darwin-x86_64-arm-none-eabi.tar.xz",
|
||||||
|
"https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-darwin-x86_64-arm-none-eabi.tar.xz",
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
http_archive(
|
http_archive(
|
||||||
|
|
@ -48,7 +60,10 @@ http_archive(
|
||||||
build_file = "//bazel/toolchain:gcc_arm_none_eabi.BUILD",
|
build_file = "//bazel/toolchain:gcc_arm_none_eabi.BUILD",
|
||||||
sha256 = "39c44f8af42695b7b871df42e346c09fee670ea8dfc11f17083e296ea2b0d279",
|
sha256 = "39c44f8af42695b7b871df42e346c09fee670ea8dfc11f17083e296ea2b0d279",
|
||||||
strip_prefix = "arm-gnu-toolchain-13.2.Rel1-darwin-arm64-arm-none-eabi",
|
strip_prefix = "arm-gnu-toolchain-13.2.Rel1-darwin-arm64-arm-none-eabi",
|
||||||
url = "https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-darwin-arm64-arm-none-eabi.tar.xz",
|
urls = [
|
||||||
|
"https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-darwin-arm64-arm-none-eabi.tar.xz",
|
||||||
|
"https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-darwin-arm64-arm-none-eabi.tar.xz",
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
http_archive(
|
http_archive(
|
||||||
|
|
|
||||||
|
|
@ -220,6 +220,8 @@ output_fmt [^%\n]+
|
||||||
|
|
||||||
{comment} { }
|
{comment} { }
|
||||||
|
|
||||||
|
"." return yy::parser::make_DOT(loc);
|
||||||
|
|
||||||
. { throw yy::parser::syntax_error(loc, "invalid character: " + std::string(yytext)); }
|
. { throw yy::parser::syntax_error(loc, "invalid character: " + std::string(yytext)); }
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,7 @@
|
||||||
DOT_SET ".set"
|
DOT_SET ".set"
|
||||||
DOT_OUT ".out"
|
DOT_OUT ".out"
|
||||||
DOT_IN ".in"
|
DOT_IN ".in"
|
||||||
|
DOT "."
|
||||||
|
|
||||||
JMP "jmp"
|
JMP "jmp"
|
||||||
WAIT "wait"
|
WAIT "wait"
|
||||||
|
|
@ -203,8 +204,8 @@ directive:
|
||||||
| DOT_OUT value direction autop threshold { pioasm.get_current_program(@1, ".out", true).set_out(@$, $2, $3, $4, $5); }
|
| DOT_OUT value direction autop threshold { pioasm.get_current_program(@1, ".out", true).set_out(@$, $2, $3, $4, $5); }
|
||||||
| DOT_SET value { pioasm.get_current_program(@1, ".set", true).set_set_count(@$, $2); }
|
| DOT_SET value { pioasm.get_current_program(@1, ".set", true).set_set_count(@$, $2); }
|
||||||
| WRAP_TARGET { pioasm.get_current_program(@1, ".wrap_target").set_wrap_target(@$); }
|
| WRAP_TARGET { pioasm.get_current_program(@1, ".wrap_target").set_wrap_target(@$); }
|
||||||
|
| WRAP expression { pioasm.get_current_program(@1, ".wrap").set_wrap(@$, $2); }
|
||||||
| WRAP { pioasm.get_current_program(@1, ".wrap").set_wrap(@$); }
|
| WRAP { pioasm.get_current_program(@1, ".wrap").set_wrap(@$); }
|
||||||
| WORD value { pioasm.get_current_program(@1, "instruction").add_instruction(std::shared_ptr<instruction>(new instr_word(@$, $2))); }
|
|
||||||
| LANG_OPT NON_WS NON_WS ASSIGN INT { pioasm.get_current_program(@1, ".lang_opt").add_lang_opt($2, $3, std::to_string($5)); }
|
| LANG_OPT NON_WS NON_WS ASSIGN INT { pioasm.get_current_program(@1, ".lang_opt").add_lang_opt($2, $3, std::to_string($5)); }
|
||||||
| LANG_OPT NON_WS NON_WS ASSIGN STRING { pioasm.get_current_program(@1, ".lang_opt").add_lang_opt($2, $3, $5); }
|
| LANG_OPT NON_WS NON_WS ASSIGN STRING { pioasm.get_current_program(@1, ".lang_opt").add_lang_opt($2, $3, $5); }
|
||||||
| LANG_OPT NON_WS NON_WS ASSIGN NON_WS { pioasm.get_current_program(@1, ".lang_opt").add_lang_opt($2, $3, $5); }
|
| LANG_OPT NON_WS NON_WS ASSIGN NON_WS { pioasm.get_current_program(@1, ".lang_opt").add_lang_opt($2, $3, $5); }
|
||||||
|
|
@ -224,6 +225,7 @@ directive:
|
||||||
/* value is a more limited top level expression... requiring parenthesis */
|
/* value is a more limited top level expression... requiring parenthesis */
|
||||||
%type <std::shared_ptr<resolvable>> value;
|
%type <std::shared_ptr<resolvable>> value;
|
||||||
value: INT { $$ = resolvable_int(@$, $1); }
|
value: INT { $$ = resolvable_int(@$, $1); }
|
||||||
|
| DOT { $$ = resolvable_int(@$, pioasm.get_current_program(@1, ".").instructions.size()); }
|
||||||
| ID { $$ = std::shared_ptr<resolvable>(new name_ref(@$, $1)); }
|
| ID { $$ = std::shared_ptr<resolvable>(new name_ref(@$, $1)); }
|
||||||
| LPAREN expression RPAREN { $$ = $2; }
|
| LPAREN expression RPAREN { $$ = $2; }
|
||||||
|
|
||||||
|
|
@ -257,7 +259,8 @@ instruction:
|
||||||
|
|
||||||
%type <std::shared_ptr<instruction>> base_instruction;
|
%type <std::shared_ptr<instruction>> base_instruction;
|
||||||
base_instruction:
|
base_instruction:
|
||||||
NOP { $$ = std::shared_ptr<instruction>(new instr_nop(@$)); }
|
WORD value { $$ = std::shared_ptr<instruction>(new instr_word(@$, $2)); }
|
||||||
|
| NOP { $$ = std::shared_ptr<instruction>(new instr_nop(@$)); }
|
||||||
| JMP condition comma expression { $$ = std::shared_ptr<instruction>(new instr_jmp(@$, $2, $4)); }
|
| JMP condition comma expression { $$ = std::shared_ptr<instruction>(new instr_jmp(@$, $2, $4)); }
|
||||||
| WAIT value wait_source { $$ = std::shared_ptr<instruction>(new instr_wait(@$, $2, $3)); }
|
| WAIT value wait_source { $$ = std::shared_ptr<instruction>(new instr_wait(@$, $2, $3)); }
|
||||||
| WAIT wait_source { $$ = std::shared_ptr<instruction>(new instr_wait(@$, resolvable_int(@$, 1), $2)); }
|
| WAIT wait_source { $$ = std::shared_ptr<instruction>(new instr_wait(@$, resolvable_int(@$, 1), $2)); }
|
||||||
|
|
|
||||||
|
|
@ -161,6 +161,17 @@ void program::set_wrap(const yy::location &l) {
|
||||||
wrap = resolvable_int(l, instructions.size() - 1);
|
wrap = resolvable_int(l, instructions.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void program::set_wrap(const yy::location &l, rvalue target) {
|
||||||
|
set_wrap(l);
|
||||||
|
|
||||||
|
if (wrap_target) {
|
||||||
|
std::stringstream msg;
|
||||||
|
msg << ".wrap_target was already specified at " << wrap_target->location;
|
||||||
|
throw syntax_error(l, msg.str());
|
||||||
|
}
|
||||||
|
wrap_target = std::move(target);
|
||||||
|
}
|
||||||
|
|
||||||
void program::set_wrap_target(const yy::location &l) {
|
void program::set_wrap_target(const yy::location &l) {
|
||||||
if (wrap_target) {
|
if (wrap_target) {
|
||||||
std::stringstream msg;
|
std::stringstream msg;
|
||||||
|
|
@ -299,12 +310,12 @@ raw_encoding instruction::raw_encode(program& program) {
|
||||||
throw syntax_error(location, "internal error");
|
throw syntax_error(location, "internal error");
|
||||||
}
|
}
|
||||||
|
|
||||||
uint instr_word::encode(program &program) {
|
raw_encoding instr_word::raw_encode(program& program) {
|
||||||
uint value = encoding->resolve(program);
|
uint value = encoding->resolve(program);
|
||||||
if (value > 0xffffu) {
|
if (value > 0xffffu) {
|
||||||
throw syntax_error(location, ".word value must be a positive 16 bit value");
|
throw syntax_error(location, ".word value must be a positive 16 bit value");
|
||||||
}
|
}
|
||||||
return value;
|
return {inst_type(0), value >> 5, value & 0x1fu};
|
||||||
}
|
}
|
||||||
|
|
||||||
uint instr_mov::get_push_get_index(const program &program, extended_mov index) {
|
uint instr_mov::get_push_get_index(const program &program, extended_mov index) {
|
||||||
|
|
|
||||||
|
|
@ -321,6 +321,8 @@ struct program : public src_item {
|
||||||
|
|
||||||
void set_wrap(const yy::location &l);
|
void set_wrap(const yy::location &l);
|
||||||
|
|
||||||
|
void set_wrap(const yy::location &l, rvalue target);
|
||||||
|
|
||||||
void set_sideset(const yy::location &l, rvalue _sideset, bool optional, bool pindirs) {
|
void set_sideset(const yy::location &l, rvalue _sideset, bool optional, bool pindirs) {
|
||||||
sideset = rvalue_loc(_sideset, l);
|
sideset = rvalue_loc(_sideset, l);
|
||||||
sideset_opt = optional;
|
sideset_opt = optional;
|
||||||
|
|
@ -486,7 +488,7 @@ struct instr_word : public instruction {
|
||||||
|
|
||||||
instr_word(const yy::location &l, rvalue encoding) : instruction(l), encoding(std::move(encoding)) {}
|
instr_word(const yy::location &l, rvalue encoding) : instruction(l), encoding(std::move(encoding)) {}
|
||||||
|
|
||||||
uint encode(program &program) override;
|
raw_encoding raw_encode(program &program) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,16 @@ wait gpio 40
|
||||||
.mov_status txfifo < 12
|
.mov_status txfifo < 12
|
||||||
.mov_status irq next set 3
|
.mov_status irq next set 3
|
||||||
|
|
||||||
|
.program wrap
|
||||||
|
decrement:
|
||||||
|
jmp x--, .+1
|
||||||
|
skip:
|
||||||
|
.wrap .+1
|
||||||
|
delay:
|
||||||
|
jmp x--, .
|
||||||
|
jump:
|
||||||
|
.word (.-1) [2]
|
||||||
|
|
||||||
.program python
|
.program python
|
||||||
.pio_version 1
|
.pio_version 1
|
||||||
wait 0 jmppin
|
wait 0 jmppin
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue