Skip to content

Commit

Permalink
make all the APIs async, drop all the startup stuff
Browse files Browse the repository at this point in the history
to use this crate you must now use the cortex-m-quickstart template. See the
crate level documentation for instructions.
  • Loading branch information
japaric committed Apr 29, 2017
1 parent 3add1be commit e2fecfb
Show file tree
Hide file tree
Showing 96 changed files with 2,400 additions and 3,798 deletions.
7 changes: 0 additions & 7 deletions .cargo/config

This file was deleted.

6 changes: 0 additions & 6 deletions .gdbinit

This file was deleted.

6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
*.org
*.rs.bk
*.svd
**/*.rs.bk
Cargo.lock
target
target/
39 changes: 17 additions & 22 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,35 @@
cache: cargo
dist: trusty
language: rust
rust: nightly
services: docker
sudo: required

matrix:
include:
- env: TARGET=x86_64-unknown-linux-gnu
rust: nightly
- env: TARGET=thumbv7em-none-eabihf
env: TARGET=x86_64-unknown-linux-gnu
rust: nightly

before_install: set -e

install:
# NOTE(TRAVIS_BRANCH) Travis is configured to only build *pushes* (not PRs).
- if [ $TRAVIS_BRANCH != master ] || [ $TRAVIS_EVENT_TYPE = cron ]; then
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=$TRAVIS_RUST_VERSION -y;
source ~/.cargo/env;
rustup component add rust-src;
fi
- sh ci/install.sh
- source ~/.cargo/env || true

script:
# NOTE(TRAVIS_BRANCH) See the NOTE in the `install` section
# if: check if `src/examples` has not been re-generated
# chmod: Travis can't cache files that are not readable by "others"
- if [ $TRAVIS_BRANCH != master ] || [ $TRAVIS_EVENT_TYPE = cron ]; then
cargo generate-lockfile;
sh ci/run-docker.sh $TARGET;
if [ $TARGET = x86_64-unknown-linux-gnu ]; then
./gen-examples.sh;
stdout=$(git status --porcelain);
test "$stdout" = "" || ( echo "Outdated examples:" && echo "$stdout" && false );
fi;
chmod -R a+r $HOME/.cargo;
fi
- bash ci/script.sh

after_script: set +e

cache: cargo
before_cache:
# Travis can't cache files that are not readable by "others"
- chmod -R a+r $HOME/.cargo

branches:
only:
# release tags
- /^v\d+\.\d+\.\d+.*$/
- auto
- master
- try
Expand Down
20 changes: 13 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Added

- A heap allocator which is enabled by default but can be disabled via the
"alloc" Cargo feature.
## [v0.4.0] - 2017-04-28

### Changed

- Fixed the override-panic-fmt example to use the panic_fmt lang item rather
than the more unstable symbol name (`rust_begin_unwind`)
- [breaking-change] The startup routine has been removed from this crate. This
crate is now meant to be used with the [cortex-m-quickstart] template, check
the crate level documentation for details.

[cortex-m-quickstart]: https://docs.rs/cortex-m-quickstart/0.1.1/cortex_m_quickstart/

- [breaking-change] The whole API is now async only (check the `examples`
module). Note that for this release we are not on parity with the v0.3.0 API
in terms of functionality.

## [v0.3.0] - 2016-11-14

Expand Down Expand Up @@ -75,6 +79,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

- Low level access to some peripherals: DBGMCU, GPIO, RCC and TIM

[Unreleased]: https://github.com/japaric/f3/compare/v0.3.0...HEAD
[Unreleased]: https://github.com/japaric/f3/compare/v0.4.0...HEAD
[v0.4.0]: https://github.com/japaric/f3/compare/v0.3.0...v0.4.0
[v0.3.1]: https://github.com/japaric/f3/compare/v0.3.0...v0.3.1
[v0.3.0]: https://github.com/japaric/f3/compare/v0.2.0...v0.3.0
[v0.2.0]: https://github.com/japaric/f3/compare/v0.1.0...v0.2.0
44 changes: 9 additions & 35 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,43 +1,17 @@
[package]
authors = ["Jorge Aparicio <[email protected]>"]
build = "build.rs"
description = "A crate to play with the STM32F3DISCOVERY"
authors = ["Jorge Aparicio <[email protected]>"]
categories = ["asynchronous", "embedded", "hardware-support", "no-std"]
description = "Board Support Crate for the STM32F3DISCOVERY"
documentation = "https://docs.rs/f3"
keywords = ["arm", "cortex-m", "stm32f3discovery", "stm32"]
keywords = ["arm", "cortex-m", "stm32"]
license = "MIT OR Apache-2.0"
name = "f3"
repository = "https://github.com/japaric/f3"
version = "0.3.0"
version = "0.4.0"

[dependencies]
cortex-m = "0.1.5"
ref_slice = "1.1.1"
stm32f30x-memory-map = "0.1.0"
stm32f30x = "0.4.0"

[target.'cfg(target_arch = "arm")'.dependencies.alloc-cortex-m]
optional = true
version = "0.2.0"

[dependencies.compiler-builtins-snapshot]
features = ["memcpy"]
version = "0.0.20161008"

[dependencies.r0]
optional = true
version = "0.1.0"

[dev-dependencies]
m = "0.1.0"

[features]
alloc = ["alloc-cortex-m", "default-init", "static-ram"]
default = ["alloc", "default-exception-handler", "default-init", "default-panic-fmt", "examples", "interrupts", "static-ram"]
default-exception-handler = []
default-init = []
default-panic-fmt = []
examples = []
interrupts = []
static-ram = ["r0"]

[profile.release]
lto = true
[dependencies.cast]
default-features = false
version = "0.2.0"
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# `f3`

> A crate to play with the [STM32F3DISCOVERY]
> Board Support Crate for the STM32F3DISCOVERY
[STM32F3DISCOVERY]: http://www.st.com/en/evaluation-tools/stm32f3discovery.html

Expand All @@ -24,6 +24,6 @@ at your option.

### Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the
work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any
additional terms or conditions.
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.
200 changes: 8 additions & 192 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,199 +3,15 @@ use std::fs::File;
use std::io::Write;
use std::path::PathBuf;

fn main() {
// Pass our linker script to the top crate
let mut ld = String::new();

let interrupts = env::var_os("CARGO_FEATURE_INTERRUPTS").is_some();
let static_ram = env::var_os("CARGO_FEATURE_STATIC_RAM").is_some();

ld.push_str("
MEMORY
{
CCRAM : ORIGIN = 0x10000000, LENGTH = 8K
FLASH : ORIGIN = 0x08000000, LENGTH = 256K
RAM : ORIGIN = 0x20000000, LENGTH = 40K
}
ENTRY(_reset)
SECTIONS
{
.text ORIGIN(FLASH) :
{
/* Vector table */
_VECTOR_TABLE = .;
LONG(ORIGIN(CCRAM) + LENGTH(CCRAM));
LONG(_reset + 1);
KEEP(*(.rodata._EXCEPTIONS));
_eexceptions = .;");

if interrupts {
ld.push_str("
KEEP(*(.rodata._INTERRUPTS));
_einterrupts = .;");
}

ld.push_str("
/* Entry point: reset handler */
_reset = .;
KEEP(*(.text._reset));
*(.text.*);
*(.rodata.*);
} > FLASH");

if static_ram {
ld.push_str("
.bss : ALIGN(4)
{
_sbss = .;
*(.bss.*);
_ebss = ALIGN(4);
} > RAM
.data : ALIGN(4)
{
_sdata = .;
*(.data.*);
_edata = ALIGN(4);
} > RAM AT > FLASH
_sidata = LOADADDR(.data);
_heap_start = .;
_heap_end = ORIGIN(RAM) + LENGTH(RAM);
");
}

ld.push_str("
/DISCARD/ :
{
*(.ARM.exidx.*)
*(.note.gnu.build-id.*)");

if !static_ram {
ld.push_str("
*(.bss.*)
*(.data.*)");
}

ld.push_str("
}
}
/* HACK to make these symbols overrideable by _dependencies_ (they were
already overridable by the top crate), we declare them as undefined
(EXTERN) here. */
EXTERN(__aeabi_memclr4);
EXTERN(_default_exception_handler);
EXTERN(_init);
/* Exceptions */
PROVIDE(_nmi = _default_exception_handler);
PROVIDE(_hard_fault = _default_exception_handler);
PROVIDE(_memmanage_fault = _default_exception_handler);
PROVIDE(_bus_fault = _default_exception_handler);
PROVIDE(_usage_fault = _default_exception_handler);
PROVIDE(_svcall = _default_exception_handler);
PROVIDE(_pendsv = _default_exception_handler);
PROVIDE(_systick = _default_exception_handler);");

if interrupts {

ld.push_str("
/* Interrupts */
PROVIDE(_wwdg = _default_exception_handler);
PROVIDE(_pvd = _default_exception_handler);
PROVIDE(_tamper_stamp = _default_exception_handler);
PROVIDE(_rtc_wkup = _default_exception_handler);
PROVIDE(_flash = _default_exception_handler);
PROVIDE(_rcc = _default_exception_handler);
PROVIDE(_exti0 = _default_exception_handler);
PROVIDE(_exti1 = _default_exception_handler);
PROVIDE(_exti2_ts = _default_exception_handler);
PROVIDE(_exti3 = _default_exception_handler);
PROVIDE(_exti4 = _default_exception_handler);
PROVIDE(_dma1_channel1 = _default_exception_handler);
PROVIDE(_dma1_channel2 = _default_exception_handler);
PROVIDE(_dma1_channel3 = _default_exception_handler);
PROVIDE(_dma1_channel4 = _default_exception_handler);
PROVIDE(_dma1_channel5 = _default_exception_handler);
PROVIDE(_dma1_channel6 = _default_exception_handler);
PROVIDE(_dma1_channel7 = _default_exception_handler);
PROVIDE(_adc1_2 = _default_exception_handler);
PROVIDE(_usb_hp_can_tx = _default_exception_handler);
PROVIDE(_usb_lp_can_rx0 = _default_exception_handler);
PROVIDE(_can_rx1 = _default_exception_handler);
PROVIDE(_can_sce = _default_exception_handler);
PROVIDE(_exti9_5 = _default_exception_handler);
PROVIDE(_tim1_brk_tim15 = _default_exception_handler);
PROVIDE(_tim1_up_tim16 = _default_exception_handler);
PROVIDE(_tim1_trg_com_tim17 = _default_exception_handler);
PROVIDE(_tim1_cc = _default_exception_handler);
PROVIDE(_tim2 = _default_exception_handler);
PROVIDE(_tim3 = _default_exception_handler);
PROVIDE(_tim4 = _default_exception_handler);
PROVIDE(_i2c1_ev = _default_exception_handler);
PROVIDE(_i2c1_er = _default_exception_handler);
PROVIDE(_i2c2_ev = _default_exception_handler);
PROVIDE(_i2c2_er = _default_exception_handler);
PROVIDE(_spi1 = _default_exception_handler);
PROVIDE(_spi2 = _default_exception_handler);
PROVIDE(_usart1 = _default_exception_handler);
PROVIDE(_usart2 = _default_exception_handler);
PROVIDE(_usart3 = _default_exception_handler);
PROVIDE(_exti15_10 = _default_exception_handler);
PROVIDE(_rtc_alarm = _default_exception_handler);
PROVIDE(_usb_wake_up = _default_exception_handler);
PROVIDE(_tim8_brk = _default_exception_handler);
PROVIDE(_tim8_up = _default_exception_handler);
PROVIDE(_tim8_trg_com = _default_exception_handler);
PROVIDE(_tim8_cc = _default_exception_handler);
PROVIDE(_adc3 = _default_exception_handler);
PROVIDE(_fmc = _default_exception_handler);
PROVIDE(_spi3 = _default_exception_handler);
PROVIDE(_uart4 = _default_exception_handler);
PROVIDE(_uart5 = _default_exception_handler);
PROVIDE(_tim6_dac = _default_exception_handler);
PROVIDE(_tim7 = _default_exception_handler);
PROVIDE(_dma2_channel1 = _default_exception_handler);
PROVIDE(_dma2_channel2 = _default_exception_handler);
PROVIDE(_dma2_channel3 = _default_exception_handler);
PROVIDE(_dma2_channel4 = _default_exception_handler);
PROVIDE(_dma2_channel5 = _default_exception_handler);
PROVIDE(_adc4 = _default_exception_handler);
PROVIDE(_comp1_2_3 = _default_exception_handler);
PROVIDE(_comp4_5_6 = _default_exception_handler);
PROVIDE(_comp7 = _default_exception_handler);
PROVIDE(_i2c3_ev = _default_exception_handler);
PROVIDE(_i2c3_er = _default_exception_handler);
PROVIDE(_usb_hp = _default_exception_handler);
PROVIDE(_usb_lp = _default_exception_handler);
PROVIDE(_usb_wake_up_rmp = _default_exception_handler);
PROVIDE(_tim20_brk = _default_exception_handler);
PROVIDE(_tim20_up = _default_exception_handler);
PROVIDE(_tim20_trg_com = _default_exception_handler);
PROVIDE(_tim20_cc = _default_exception_handler);
PROVIDE(_fpu = _default_exception_handler);
PROVIDE(_spi4 = _default_exception_handler);");
}

ld.push_str("
ASSERT(_eexceptions - ORIGIN(FLASH) == 0x40, \"exceptions \
not linked where expected\");");

if interrupts {
ld.push_str("
ASSERT(_einterrupts - ORIGIN(FLASH) == 0x194, \
\"interrupts not linked where expected\");");
}

let out = PathBuf::from(env::var_os("OUT_DIR").unwrap());
File::create(out.join("stm32f3discovery.ld"))
pub fn main() {
// Put the linker script somewhere the linker can find it
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
File::create(out.join("memory.x"))
.unwrap()
.write_all(ld.as_bytes())
.write_all(include_bytes!("memory.x"))
.unwrap();

println!("cargo:rustc-link-search={}", out.display());

println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=memory.x");
}
Loading

0 comments on commit e2fecfb

Please sign in to comment.