change layout of books

This commit is contained in:
Jorge Aparicio 2019-02-11 21:40:53 +01:00
parent 68a937a72a
commit 0007a35a27
36 changed files with 95 additions and 92 deletions

3
.gitignore vendored
View file

@ -1,7 +1,6 @@
**/*.rs.bk
.#*
.gdb_history
/book/book
/ru/book
/book/*/book
/target
Cargo.lock

View file

@ -3,7 +3,7 @@
This is the smallest possible RTFM application:
``` rust
{{#include ../../../examples/smallest.rs}}
{{#include ../../../../examples/smallest.rs}}
```
All RTFM applications use the [`app`] attribute (`#[app(..)]`). This attribute
@ -47,7 +47,7 @@ The example below shows the types of the `core` and `device` variables and
showcases safe access to a `static mut` variable.
``` rust
{{#include ../../../examples/init.rs}}
{{#include ../../../../examples/init.rs}}
```
Running the example will print `init` to the console and then exit the QEMU
@ -55,7 +55,7 @@ process.
``` console
$ cargo run --example init
{{#include ../../../ci/expected/init.run}}```
{{#include ../../../../ci/expected/init.run}}```
## `idle`
@ -78,12 +78,12 @@ references that are safe to access.
The example below shows that `idle` runs after `init`.
``` rust
{{#include ../../../examples/idle.rs}}
{{#include ../../../../examples/idle.rs}}
```
``` console
$ cargo run --example idle
{{#include ../../../ci/expected/idle.run}}```
{{#include ../../../../ci/expected/idle.run}}```
## `interrupt` / `exception`
@ -93,12 +93,12 @@ and exception handlers. In RTFM, we refer to interrupt and exception handlers as
*hardware* tasks.
``` rust
{{#include ../../../examples/interrupt.rs}}
{{#include ../../../../examples/interrupt.rs}}
```
``` console
$ cargo run --example interrupt
{{#include ../../../ci/expected/interrupt.run}}```
{{#include ../../../../ci/expected/interrupt.run}}```
So far all the RTFM applications we have seen look no different that the
applications one can write using only the `cortex-m-rt` crate. In the next

View file

@ -64,4 +64,4 @@ $ cargo add panic-semihosting
``` console
$ # NOTE: I have uncommented the `runner` option in `.cargo/config`
$ cargo run
{{#include ../../../ci/expected/init.run}}```
{{#include ../../../../ci/expected/init.run}}```

View file

@ -19,12 +19,12 @@ no preemption is possible. The `SHARED` resource can only be accessed by these
two handlers.
``` rust
{{#include ../../../examples/resource.rs}}
{{#include ../../../../examples/resource.rs}}
```
``` console
$ cargo run --example resource
{{#include ../../../ci/expected/resource.run}}```
{{#include ../../../../ci/expected/resource.run}}```
## Priorities
@ -62,12 +62,12 @@ the critical section created by the lowest priority handler.
[`lock`]: ../../api/rtfm/trait.Mutex.html#method.lock
``` rust
{{#include ../../../examples/lock.rs}}
{{#include ../../../../examples/lock.rs}}
```
``` console
$ cargo run --example lock
{{#include ../../../ci/expected/lock.run}}```
{{#include ../../../../ci/expected/lock.run}}```
## Late resources
@ -91,12 +91,12 @@ the consumer resource.
[`Queue`]: ../../api/heapless/spsc/struct.Queue.html
``` rust
{{#include ../../../examples/late.rs}}
{{#include ../../../../examples/late.rs}}
```
``` console
$ cargo run --example late
{{#include ../../../ci/expected/late.run}}```
{{#include ../../../../ci/expected/late.run}}```
## `static` resources
@ -111,9 +111,9 @@ In the example below a key is loaded (or created) at runtime and then used from
two tasks that run at different priorities.
``` rust
{{#include ../../../examples/static.rs}}
{{#include ../../../../examples/static.rs}}
```
``` console
$ cargo run --example static
{{#include ../../../ci/expected/static.run}}```
{{#include ../../../../ci/expected/static.run}}```

View file

@ -18,9 +18,9 @@ the [`alloc-singleton`] abstractions.
[`alloc-singleton`]: https://crates.io/crates/alloc-singleton
``` rust
{{#include ../../../examples/singleton.rs}}
{{#include ../../../../examples/singleton.rs}}
```
``` console
$ cargo run --example singleton
{{#include ../../../ci/expected/singleton.run}}```
{{#include ../../../../ci/expected/singleton.run}}```

View file

@ -19,12 +19,12 @@ The example below showcases three software tasks that run at 2 different
priorities. The three tasks map to 2 interrupts handlers.
``` rust
{{#include ../../../examples/task.rs}}
{{#include ../../../../examples/task.rs}}
```
``` console
$ cargo run --example task
{{#include ../../../ci/expected/task.run}}```
{{#include ../../../../ci/expected/task.run}}```
## Message passing
@ -35,12 +35,12 @@ the signature of the task handler.
The example below showcases three tasks, two of them expect a message.
``` rust
{{#include ../../../examples/message.rs}}
{{#include ../../../../examples/message.rs}}
```
``` console
$ cargo run --example message
{{#include ../../../ci/expected/message.run}}```
{{#include ../../../../ci/expected/message.run}}```
## Capacity
@ -55,9 +55,9 @@ capacity is not specified then the second `spawn.foo` call in `UART0` would
fail.
``` rust
{{#include ../../../examples/capacity.rs}}
{{#include ../../../../examples/capacity.rs}}
```
``` console
$ cargo run --example capacity
{{#include ../../../ci/expected/capacity.run}}```
{{#include ../../../../ci/expected/capacity.run}}```

View file

@ -38,13 +38,13 @@ was scheduled to run first.
> counter functionality has not been implemented in `qemu-system-arm`.
``` rust
{{#include ../../../examples/schedule.rs}}
{{#include ../../../../examples/schedule.rs}}
```
Running the program on real hardware produces the following output in the console:
``` text
{{#include ../../../ci/expected/schedule.run}}
{{#include ../../../../ci/expected/schedule.run}}
```
## Periodic tasks
@ -54,7 +54,7 @@ through the `scheduled` variable. This information and the `schedule` API can be
used to implement periodic tasks as shown in the example below.
``` rust
{{#include ../../../examples/periodic.rs}}
{{#include ../../../../examples/periodic.rs}}
```
This is the output produced by the example. Note that there is zero drift /
@ -62,7 +62,7 @@ jitter even though `schedule.foo` was invoked at the *end* of `foo`. Using
`Instant::now` instead of `scheduled` would have resulted in drift / jitter.
``` text
{{#include ../../../ci/expected/periodic.run}}
{{#include ../../../../ci/expected/periodic.run}}
```
## Baseline
@ -87,11 +87,11 @@ spawned from it will use `Instant::now()` as their baseline time.
The example below showcases the different meanings of the *baseline*.
``` rust
{{#include ../../../examples/baseline.rs}}
{{#include ../../../../examples/baseline.rs}}
```
Running the program on real hardware produces the following output in the console:
``` text
{{#include ../../../ci/expected/baseline.run}}
{{#include ../../../../ci/expected/baseline.run}}
```

View file

@ -8,12 +8,12 @@ data. This lets you easily write generic code that operates on resources and can
be called from different tasks. Here's one such example:
``` rust
{{#include ../../../examples/generics.rs}}
{{#include ../../../../examples/generics.rs}}
```
``` console
$ cargo run --example generics
{{#include ../../../ci/expected/generics.run}}```
{{#include ../../../../ci/expected/generics.run}}```
This also lets you change the static priorities of tasks without having to
rewrite code. If you consistently use `lock`s to access the data behind shared
@ -31,7 +31,7 @@ The example below logs a message whenever the `foo` task is spawned, but only if
the program has been compiled using the `dev` profile.
``` rust
{{#include ../../../examples/cfg.rs}}
{{#include ../../../../examples/cfg.rs}}
```
## Running tasks from RAM
@ -56,22 +56,22 @@ improve performance in some cases.
The example below shows how to place the higher priority task, `bar`, in RAM.
``` rust
{{#include ../../../examples/ramfunc.rs}}
{{#include ../../../../examples/ramfunc.rs}}
```
Running this program produces the expected output.
``` console
$ cargo run --example ramfunc
{{#include ../../../ci/expected/ramfunc.run}}```
{{#include ../../../../ci/expected/ramfunc.run}}```
One can look at the output of `cargo-nm` to confirm that `bar` ended in RAM
(`0x2000_0000`), whereas `foo` ended in Flash (`0x0000_0000`).
``` console
$ cargo nm --example ramfunc --release | grep ' foo::'
{{#include ../../../ci/expected/ramfunc.grep.foo}}```
{{#include ../../../../ci/expected/ramfunc.grep.foo}}```
``` console
$ cargo nm --example ramfunc --release | grep ' bar::'
{{#include ../../../ci/expected/ramfunc.grep.bar}}```
{{#include ../../../../ci/expected/ramfunc.grep.bar}}```

View file

@ -13,7 +13,7 @@ function.
The example below shows the different types generates by the `app` attribute.
``` rust
{{#include ../../../examples/types.rs}}
{{#include ../../../../examples/types.rs}}
```
## `Send`
@ -36,7 +36,7 @@ shared `static mut` resources.
The example below shows where a type that doesn't implement `Send` can be used.
``` rust
{{#include ../../../examples/not-send.rs}}
{{#include ../../../../examples/not-send.rs}}
```
## `Sync`
@ -56,5 +56,5 @@ resources shared between tasks that run at the *same* priority.
The example below shows where a type that doesn't implement `Sync` can be used.
``` rust
{{#include ../../../examples/not-sync.rs}}
{{#include ../../../../examples/not-sync.rs}}
```

View file

@ -9,8 +9,8 @@ This book contains user level documentation for the Real Time For the Masses
There is a translation of this book in [Russian].
[Russian]: ru/index.html
[Russian]: ../ru/index.html
{{#include ../../README.md:5:46}}
{{#include ../../../README.md:5:46}}
{{#include ../../README.md:52:}}
{{#include ../../../README.md:52:}}

View file

@ -3,7 +3,7 @@
Это наименьшая возможная программа на RTFM:
``` rust
{{#include ../../../examples/smallest.rs}}
{{#include ../../../../examples/smallest.rs}}
```
Все программы на RTFM используют атрибут [`app`] (`#[app(..)]`). Этот атрибут
@ -44,14 +44,14 @@
демонстрирует безопасный доступ к переменной `static mut`.
``` rust
{{#include ../../../examples/init.rs}}
{{#include ../../../../examples/init.rs}}
```
Запуск примера напечатает `init` в консоли и завершит процесс QEMU.
``` console
$ cargo run --example init
{{#include ../../../ci/expected/init.run}}```
{{#include ../../../../ci/expected/init.run}}```
## `idle`
@ -74,12 +74,12 @@ $ cargo run --example init
В примере ниже показан запуск `idle` после `init`.
``` rust
{{#include ../../../examples/idle.rs}}
{{#include ../../../../examples/idle.rs}}
```
``` console
$ cargo run --example idle
{{#include ../../../ci/expected/idle.run}}```
{{#include ../../../../ci/expected/idle.run}}```
## `interrupt` / `exception`
@ -89,12 +89,12 @@ $ cargo run --example idle
*аппаратными* задачами.
``` rust
{{#include ../../../examples/interrupt.rs}}
{{#include ../../../../examples/interrupt.rs}}
```
``` console
$ cargo run --example interrupt
{{#include ../../../ci/expected/interrupt.run}}```
{{#include ../../../../ci/expected/interrupt.run}}```
До сих пор программы RTFM, которые мы видели не отличались от программ, которые
можно написать, используя только библиотеку `cortex-m-rt`. В следующем разделе

View file

@ -64,4 +64,4 @@ $ cargo add panic-semihosting
``` console
$ # ПРИМЕЧАНИЕ: Я раскомментировал опцию `runner` в `.cargo/config`
$ cargo run
{{#include ../../../ci/expected/init.run}}```
{{#include ../../../../ci/expected/init.run}}```

View file

@ -19,12 +19,12 @@
К ресурсу `SHARED` можно получить доступ только из этих двух прерываний.
``` rust
{{#include ../../../examples/resource.rs}}
{{#include ../../../../examples/resource.rs}}
```
``` console
$ cargo run --example resource
{{#include ../../../ci/expected/resource.run}}
{{#include ../../../../ci/expected/resource.run}}
```
## Приоритеты
@ -64,12 +64,12 @@ API критической секции, предоставляемое фрей
[`lock`]: ../../api/rtfm/trait.Mutex.html#method.lock
``` rust
{{#include ../../../examples/lock.rs}}
{{#include ../../../../examples/lock.rs}}
```
``` console
$ cargo run --example lock
{{#include ../../../ci/expected/lock.run}}```
{{#include ../../../../ci/expected/lock.run}}```
## Поздние ресурсы
@ -93,12 +93,12 @@ $ cargo run --example lock
[`Queue`]: ../../api/heapless/spsc/struct.Queue.html
``` rust
{{#include ../../../examples/late.rs}}
{{#include ../../../../examples/late.rs}}
```
``` console
$ cargo run --example late
{{#include ../../../ci/expected/late.run}}```
{{#include ../../../../ci/expected/late.run}}```
## `static`-ресурсы
@ -114,9 +114,9 @@ $ cargo run --example late
задачах, запущенных на разных приоритетах.
``` rust
{{#include ../../../examples/static.rs}}
{{#include ../../../../examples/static.rs}}
```
``` console
$ cargo run --example static
{{#include ../../../ci/expected/static.run}}```
{{#include ../../../../ci/expected/static.run}}```

View file

@ -18,9 +18,9 @@
[`alloc-singleton`]: https://crates.io/crates/alloc-singleton
``` rust
{{#include ../../../examples/singleton.rs}}
{{#include ../../../../examples/singleton.rs}}
```
``` console
$ cargo run --example singleton
{{#include ../../../ci/expected/singleton.run}}```
{{#include ../../../../ci/expected/singleton.run}}```

View file

@ -19,12 +19,12 @@ RTFM также поддерживает *программные* задачи,
разных приоритетах. Трем задачам назначены 2 обработчика прерываний.
``` rust
{{#include ../../../examples/task.rs}}
{{#include ../../../../examples/task.rs}}
```
``` console
$ cargo run --example task
{{#include ../../../ci/expected/task.run}}```
{{#include ../../../../ci/expected/task.run}}```
## Передача сообщений
@ -35,12 +35,12 @@ $ cargo run --example task
Пример ниже демонстрирует три задачи, две из которых ожидают сообщения.
``` rust
{{#include ../../../examples/message.rs}}
{{#include ../../../../examples/message.rs}}
```
``` console
$ cargo run --example message
{{#include ../../../ci/expected/message.run}}```
{{#include ../../../../ci/expected/message.run}}```
## Ёмкость
@ -55,9 +55,9 @@ $ cargo run --example message
не определена, тогда второй вызов `spawn.foo` в `UART0` вызовет ошибку.
``` rust
{{#include ../../../examples/capacity.rs}}
{{#include ../../../../examples/capacity.rs}}
```
``` console
$ cargo run --example capacity
{{#include ../../../ci/expected/capacity.run}}```
{{#include ../../../../ci/expected/capacity.run}}```

View file

@ -30,13 +30,13 @@
> тактов Cortex-M не реализована в `qemu-system-arm`.
``` rust
{{#include ../../../examples/schedule.rs}}
{{#include ../../../../examples/schedule.rs}}
```
Запуск программы на реальном оборудовании производит следующий вывод в консоли:
``` text
{{#include ../../../ci/expected/schedule.run}}
{{#include ../../../../ci/expected/schedule.run}}
```
## Периодические задачи
@ -46,7 +46,7 @@
быть использованы для реализации периодических задач, как показано в примере ниже.
``` rust
{{#include ../../../examples/periodic.rs}}
{{#include ../../../../examples/periodic.rs}}
```
Это вывод, произведенный примером. Заметьте, что есть смещение / колебание нуля
@ -54,7 +54,7 @@
`Instant::now` вместо `scheduled` имело бы влияние на смещение / колебание.
``` text
{{#include ../../../ci/expected/periodic.run}}
{{#include ../../../../ci/expected/periodic.run}}
```
## Базовое время
@ -80,11 +80,11 @@
Пример ниже демонстрирует разное значение *базового времени*.
``` rust
{{#include ../../../examples/baseline.rs}}
{{#include ../../../../examples/baseline.rs}}
```
Запуск программы на реальном оборудовании произведет следующий вывод в консоли:
``` text
{{#include ../../../ci/expected/baseline.run}}
{{#include ../../../../ci/expected/baseline.run}}
```

View file

@ -8,12 +8,12 @@
ресурсами, который можно вызывать из различных задач. Вот такой пример:
``` rust
{{#include ../../../examples/generics.rs}}
{{#include ../../../../examples/generics.rs}}
```
``` console
$ cargo run --example generics
{{#include ../../../ci/expected/generics.run}}```
{{#include ../../../../ci/expected/generics.run}}```
Это также позволяет Вам изменять статические приоритеты задач без
переписывания кода. Если Вы единообразно используете `lock`-и для доступа
@ -42,22 +42,22 @@ RTFM v0.4.x была возможность взаимодействия с др
В примере ниже показано как разместить высокоприоритетную задачу `bar` в ОЗУ.
``` rust
{{#include ../../../examples/ramfunc.rs}}
{{#include ../../../../examples/ramfunc.rs}}
```
Запуск этой программы произведет ожидаемый вывод.
``` console
$ cargo run --example ramfunc
{{#include ../../../ci/expected/ramfunc.run}}```
{{#include ../../../../ci/expected/ramfunc.run}}```
Можно посмотреть на вывод `cargo-nm`, чтобы убедиться, что `bar` расположен в ОЗУ
(`0x2000_0000`), тогда как `foo` расположен во Flash (`0x0000_0000`).
``` console
$ cargo nm --example ramfunc --release | grep ' foo::'
{{#include ../../../ci/expected/ramfunc.grep.foo}}```
{{#include ../../../../ci/expected/ramfunc.grep.foo}}```
``` console
$ cargo nm --example ramfunc --release | grep ' bar::'
{{#include ../../../ci/expected/ramfunc.grep.bar}}```
{{#include ../../../../ci/expected/ramfunc.grep.bar}}```

View file

@ -13,7 +13,7 @@
В примере ниже сгенерированы разные типы с помощью атрибута `app`.
``` rust
{{#include ../../../examples/types.rs}}
{{#include ../../../../examples/types.rs}}
```
## `Send`
@ -35,7 +35,7 @@
В примере ниже показано, где можно использовать типы, не реализующие `Send`.
``` rust
{{#include ../../../examples/not-send.rs}}
{{#include ../../../../examples/not-send.rs}}
```
## `Sync`
@ -55,5 +55,5 @@
В примере ниже показано, где можно использовать типы, не реализующие `Sync`.
``` rust
{{#include ../../../examples/not-sync.rs}}
{{#include ../../../../examples/not-sync.rs}}
```

View file

@ -7,6 +7,6 @@
Эта книга содержит документацию уровня пользователя фреймворком Real Time For the Masses
(RTFM). Описание API можно найти [здесь](../api/rtfm/index.html).
{{#include README_RU.md:5:54}}
{{#include ../..ADME_RU.md:5:54}}
{{#include README_RU.md:60:}}
{{#include ../..ADME_RU.md:60:}}

View file

@ -23,15 +23,19 @@ main() {
else
cargo doc
fi
( cd book && mdbook build )
( cd ru && mdbook build )
( cd book/en && mdbook build )
( cd book/ru && mdbook build )
local td=$(mktemp -d)
cp -r target/doc $td/api
cp -r book/book $td/
cp LICENSE-* $td/book/
mkdir $td/book
cp -r book/en/book $td/book/en
cp -r book/ru/book $td/book/ru
cp LICENSE-* $td/book/en
cp LICENSE-* $td/book/ru
linkchecker $td/book/
linkchecker $td/book/en/
linkchecker $td/book/ru/
linkchecker $td/api/rtfm/
linkchecker $td/api/cortex_m_rtfm_macros/
fi

View file

@ -7,7 +7,7 @@
//!
//! The user level documentation can be found [here].
//!
//! [here]: https://japaric.github.io/cortex-m-rtfm/book/
//! [here]: https://japaric.github.io/cortex-m-rtfm/book/en/
//!
//! Don't forget to check the documentation of the [`#[app]`] attribute, which is the main component
//! of the framework.