|
1 |
| -# LED roulette |
| 1 | +<!-- # LED roulette --> |
2 | 2 |
|
3 |
| -Alright, let's start by building the following application: |
| 3 | +# Roleta LED |
| 4 | + |
| 5 | +<!-- Alright, let's start by building the following application: --> |
| 6 | + |
| 7 | +Certo, vamos começar construindo a seguinte aplicação: |
4 | 8 |
|
5 | 9 | <p align="center">
|
6 | 10 | <video src="../assets/roulette_fast.mp4" loop autoplay>
|
7 | 11 | </p>
|
8 | 12 |
|
9 |
| -I'm going to give you a high level API to implement this app but don't worry we'll do low level |
10 |
| -stuff later on. The main goal of this chapter is to get familiar with the *flashing* and debugging |
11 |
| -process. |
| 13 | +<!-- I'm going to give you a high level API to implement this app but don't worry |
| 14 | +we'll do low level stuff later on. The main goal of this chapter is to get |
| 15 | +familiar with the _flashing_ and debugging process. --> |
| 16 | + |
| 17 | +Vou fornecer a você uma API de alto nível para implementar este aplicativo, mas |
| 18 | +não se preocupe, faremos coisas de baixo nível posteriormente. O objetivo |
| 19 | +principal deste capítulo é familiarizar-se com o processo de _flashing_ e |
| 20 | +depuração. |
| 21 | + |
| 22 | +<!-- The starter code is in the `src` directory of the book repository. Inside that |
| 23 | +directory there are more directories named after each chapter of this book. Most |
| 24 | +of those directories are starter Cargo projects. --> |
12 | 25 |
|
13 |
| -The starter code is in the `src` directory of the book repository. Inside that directory there are more |
14 |
| -directories named after each chapter of this book. Most of those directories are starter Cargo |
15 |
| -projects. |
| 26 | +O código inicial está no diretório `src` do repositório do livro. Dentro desse |
| 27 | +diretório, existem mais diretórios com nomes de cada capítulo deste livro. A |
| 28 | +maioria desses diretórios são projetos iniciais de Cargo. |
16 | 29 |
|
17 |
| -Now, jump into the `src/05-led-roulette` directory. Check the `src/main.rs` file: |
| 30 | +<!-- Now, jump into the `src/05-led-roulette` directory. Check the `src/main.rs` |
| 31 | +file: --> |
18 | 32 |
|
19 |
| -``` rust |
| 33 | +Agora, vá para o diretório `src/05-led-roulette`. Verifique o arquivo |
| 34 | +`src/main.rs`: |
| 35 | + |
| 36 | +```rust |
20 | 37 | {{#include src/main.rs}}
|
21 | 38 | ```
|
22 | 39 |
|
23 |
| -Microcontroller programs are different from standard programs in two aspects: `#![no_std]` and |
24 |
| -`#![no_main]`. |
| 40 | +<!-- Microcontroller programs are different from standard programs in two aspects: |
| 41 | +`#![no_std]` and `#![no_main]`. --> |
| 42 | + |
| 43 | +Programas para microcontroladores são diferentes de programas convencionais em |
| 44 | +dois aspectos: `#![no_std]` e `#![no_main]`. |
| 45 | + |
| 46 | +<!-- The `no_std` attribute says that this program won't use the `std` crate, which |
| 47 | +assumes an underlying OS; the program will instead use the `core` crate, a |
| 48 | +subset of `std` that can run on bare metal systems (i.e., systems without OS |
| 49 | +abstractions like files and sockets). --> |
| 50 | + |
| 51 | +O atributo `no_std` indica que este programa não usará o crate `std`, que |
| 52 | +pressupõe a existência de um sistema operacional subjacente. Em vez disso, o |
| 53 | +programa usará o crate `core`, que é um subconjunto do `std` que pode ser |
| 54 | +executado em sistemas bare metal (ou seja, sistemas sem abstrações de sistema |
| 55 | +operacional, como arquivos e sockets). |
| 56 | + |
| 57 | +<!-- The `no_main` attribute says that this program won't use the standard `main` |
| 58 | +interface, which is tailored for command line applications that receive |
| 59 | +arguments. Instead of the standard `main` we'll use the `entry` attribute from |
| 60 | +the [`cortex-m-rt`] crate to define a custom entry point. In this program we |
| 61 | +have named the entry point "main", but any other name could have been used. The |
| 62 | +entry point function must have signature `fn() -> !`; this type indicates that |
| 63 | +the function can't return -- this means that the program never terminates. --> |
| 64 | + |
| 65 | +O atributo `no_main` indica que este programa não usará a interface `main` |
| 66 | +padrão, que é adequada para aplicativos de linha de comando que recebem |
| 67 | +argumentos. Em vez do `main` padrão, utilizaremos o atributo `entry` do crate |
| 68 | +[cortex-m-rt] para definir um ponto de entrada customizado. Neste programa, |
| 69 | +nomeamos o ponto de entrada como "main", mas poderíamos ter usado qualquer outro |
| 70 | +nome. A função de ponto de entrada deve ter a assinatura `fn() -> !`, indicando |
| 71 | +que a função não pode retornar -- isso significa que o programa nunca termina. |
25 | 72 |
|
26 |
| -The `no_std` attribute says that this program won't use the `std` crate, which assumes an underlying |
27 |
| -OS; the program will instead use the `core` crate, a subset of `std` that can run on bare metal |
28 |
| -systems (i.e., systems without OS abstractions like files and sockets). |
| 73 | +[`cortex-m-rt`]: https://crates.io/crates/cortex-m-rt |
29 | 74 |
|
30 |
| -The `no_main` attribute says that this program won't use the standard `main` interface, which is |
31 |
| -tailored for command line applications that receive arguments. Instead of the standard `main` we'll |
32 |
| -use the `entry` attribute from the [`cortex-m-rt`] crate to define a custom entry point. In this |
33 |
| -program we have named the entry point "main", but any other name could have been used. The entry |
34 |
| -point function must have signature `fn() -> !`; this type indicates that the function can't return |
35 |
| --- this means that the program never terminates. |
| 75 | +<!-- If you are a careful observer, you'll also notice there is a `.cargo` directory |
| 76 | +in the Cargo project as well. This directory contains a Cargo configuration file |
| 77 | +(`.cargo/config`) that tweaks the linking process to tailor the memory layout of |
| 78 | +the program to the requirements of the target device. This modified linking |
| 79 | +process is a requirement of the `cortex-m-rt` crate. --> |
36 | 80 |
|
37 |
| -[`cortex-m-rt`]: https://crates.io/crates/cortex-m-rt |
| 81 | +Se você for um observador cuidadoso, também notará que existe um diretório |
| 82 | +`.cargo` no projeto Cargo. Esse diretório contém um arquivo de configuração do |
| 83 | +Cargo (`.cargo/config`) que ajusta o processo de linking para adaptar o layout |
| 84 | +de memória do programa aos requisitos do dispositivo alvo. Esse processo de |
| 85 | +linking modificado é um requisito do crate `cortex-m-rt`. |
38 | 86 |
|
39 |
| -If you are a careful observer, you'll also notice there is a `.cargo` directory in the Cargo project |
40 |
| -as well. This directory contains a Cargo configuration file (`.cargo/config`) that tweaks the |
41 |
| -linking process to tailor the memory layout of the program to the requirements of the target device. |
42 |
| -This modified linking process is a requirement of the `cortex-m-rt` crate. |
| 87 | +<!-- Furthermore, there is also an `Embed.toml` file --> |
43 | 88 |
|
44 |
| -Furthermore, there is also an `Embed.toml` file |
| 89 | +Além disso, há também um arquivo `Embed.toml`. |
45 | 90 |
|
46 | 91 | ```toml
|
47 | 92 | {{#include Embed.toml}}
|
48 | 93 | ```
|
49 | 94 |
|
50 |
| -This file tells `cargo-embed` that: |
| 95 | +<!-- This file tells `cargo-embed` that: --> |
| 96 | + |
| 97 | +Este arquivo informa ao `cargo-embed` que: |
| 98 | + |
| 99 | +<!-- - we are working with either a nrf52833 or nrf51822, you will again have to |
| 100 | + remove the comments from the chip you are using, just like you did in |
| 101 | + chapter 3. --> |
| 102 | + |
| 103 | +- Estamos trabalhando com um nrf52833 ou nrf51822. Você terá que remover |
| 104 | + novamente os comentários do chip que estiver usando, assim como fez no |
| 105 | + capítulo 3. |
| 106 | + |
| 107 | +<!-- - we want to halt the chip after we flashed it so our program does not instantly |
| 108 | + jump to the loop --> |
| 109 | + |
| 110 | +- Desejamos interromper o chip depois de gravá-lo para que nosso programa não |
| 111 | + salte instantaneamente para o loop. |
| 112 | + |
| 113 | +<!-- - we want to disable RTT, RTT being a protocol that allows the chip to send text |
| 114 | + to a debugger. You have in fact already seen RTT in action, it was the |
| 115 | + protocol that sent "Hello World" in chapter 3. --> |
| 116 | + |
| 117 | +- Queremos desabilitar o RTT, que é um protocolo que permite ao chip enviar |
| 118 | + texto para um depurador. Na verdade, você já viu o RTT em ação: ele foi o |
| 119 | + protocolo que enviou "Hello World" no capítulo 3. |
| 120 | + |
| 121 | +<!-- - we want to enable GDB, this will be required for the debugging procedure --> |
| 122 | + |
| 123 | +- Desejamos habilitar o GDB, pois isso será necessário para o procedimento de |
| 124 | + depuração. |
51 | 125 |
|
52 |
| -* we are working with either a nrf52833 or nrf51822, you will again have to remove the comments from the |
53 |
| - chip you are using, just like you did in chapter 3. |
54 |
| -* we want to halt the chip after we flashed it so our program does not instantly jump to the loop |
55 |
| -* we want to disable RTT, RTT being a protocol that allows the chip to send text to a debugger. |
56 |
| - You have in fact already seen RTT in action, it was the protocol that sent "Hello World" in chapter 3. |
57 |
| -* we want to enable GDB, this will be required for the debugging procedure |
| 126 | +<!-- Alright, let's start by building this program. --> |
58 | 127 |
|
59 |
| -Alright, let's start by building this program. |
| 128 | +Certo, vamos começar construindo este programa. |
0 commit comments