701 lines
32 KiB
HTML
701 lines
32 KiB
HTML
|
<!DOCTYPE html>
|
||
|
<html lang="en">
|
||
|
<head>
|
||
|
<meta charset="utf-8" />
|
||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
||
|
|
||
|
<title></title>
|
||
|
<link rel="stylesheet" href="dist/reveal.css" />
|
||
|
<link rel="stylesheet" href="dist/theme/night.css" id="theme" />
|
||
|
<link rel="stylesheet" href="plugin/highlight/zenburn.css" />
|
||
|
<link rel="stylesheet" href="css/layout.css" />
|
||
|
<link rel="stylesheet" href="plugin/customcontrols/style.css">
|
||
|
|
||
|
<link rel="stylesheet" href="plugin/reveal-pointer/pointer.css" />
|
||
|
|
||
|
|
||
|
<script defer src="dist/fontawesome/all.min.js"></script>
|
||
|
|
||
|
<script type="text/javascript">
|
||
|
var forgetPop = true;
|
||
|
function onPopState(event) {
|
||
|
if(forgetPop){
|
||
|
forgetPop = false;
|
||
|
} else {
|
||
|
parent.postMessage(event.target.location.href, "app://obsidian.md");
|
||
|
}
|
||
|
}
|
||
|
window.onpopstate = onPopState;
|
||
|
window.onmessage = event => {
|
||
|
if(event.data == "reload"){
|
||
|
window.document.location.reload();
|
||
|
}
|
||
|
forgetPop = true;
|
||
|
}
|
||
|
|
||
|
function fitElements(){
|
||
|
const itemsToFit = document.getElementsByClassName('fitText');
|
||
|
for (const item in itemsToFit) {
|
||
|
if (Object.hasOwnProperty.call(itemsToFit, item)) {
|
||
|
var element = itemsToFit[item];
|
||
|
fitElement(element,1, 1000);
|
||
|
element.classList.remove('fitText');
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function fitElement(element, start, end){
|
||
|
|
||
|
let size = (end + start) / 2;
|
||
|
element.style.fontSize = `${size}px`;
|
||
|
|
||
|
if(Math.abs(start - end) < 1){
|
||
|
while(element.scrollHeight > element.offsetHeight){
|
||
|
size--;
|
||
|
element.style.fontSize = `${size}px`;
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if(element.scrollHeight > element.offsetHeight){
|
||
|
fitElement(element, start, size);
|
||
|
} else {
|
||
|
fitElement(element, size, end);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
document.onreadystatechange = () => {
|
||
|
fitElements();
|
||
|
if (document.readyState === 'complete') {
|
||
|
if (window.location.href.indexOf("?export") != -1){
|
||
|
parent.postMessage(event.target.location.href, "app://obsidian.md");
|
||
|
}
|
||
|
if (window.location.href.indexOf("print-pdf") != -1){
|
||
|
let stateCheck = setInterval(() => {
|
||
|
clearInterval(stateCheck);
|
||
|
window.print();
|
||
|
}, 250);
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
|
||
|
|
||
|
</script>
|
||
|
</head>
|
||
|
<body>
|
||
|
<div class="reveal">
|
||
|
<div class="slides"><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
# Rust en Arduino: La manera díficil
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
<img src="Pasted image 20221208231749.png" alt="" style="width: 300px; object-fit: fill">
|
||
|
|
||
|
## Kirbylife (Gabriel)
|
||
|
|
||
|
Ingeniero de software en Intel
|
||
|
Programo en Python 🐍 por comida y en Rust 🦀 por dopamina.
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
## Preparación del ambiente
|
||
|
1. avr-gcc
|
||
|
2. avr-bintuils
|
||
|
3. avr-dude
|
||
|
4. avr-atmel328p.json
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
Notación numérica
|
||
|
|
||
|
| Prefijo | Sistema | Ejemplo |
|
||
|
| ------- | ----------- | -------------- |
|
||
|
| 0x | Hexadecimal | **0x**25 = 37 |
|
||
|
| | | **0x**FF = 255 |
|
||
|
| 0b | Binario | **0b**101 = 5 |
|
||
|
| | | **0b**1010101 = 85 |
|
||
|
| \<Nada> | Decimal | 10, 5, 240 |
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
## Registros
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
<img src="arduino_secciones2.jpg" alt="" style="object-fit: scale-down">
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
Cada sección de pines tiene asignados 3 registros:
|
||
|
- Registro de control
|
||
|
- Registro de OUTPUTs
|
||
|
- Registro de INPUTs
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
### Ejemplo:
|
||
|
- Se hará con la 3ra sección de pines
|
||
|
- El registro de control será el AA
|
||
|
- El registro de OUTPUTs será el AB
|
||
|
- El registro de INPUTs será el AC
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
```
|
||
|
OUTPUT = 1
|
||
|
INPUT = 0
|
||
|
```
|
||
|
<img src="Pasted image 20221124222324.png" alt="" style="object-fit: scale-down">
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
```
|
||
|
Registro Binario Decimal Hexadecimal
|
||
|
AA 0b00001111 15 0x0f
|
||
|
```
|
||
|
|
||
|
<img src="Pasted image 20221124223245.png" alt="" style="object-fit: scale-down">
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
```
|
||
|
Registro Binario Decimal Hexadecimal
|
||
|
AB 0b00000001 1 0x01
|
||
|
```
|
||
|
<img src="Pasted image 20221124225301.png" alt="" style="object-fit: scale-down">
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
| Operación | Registro | Valor |
|
||
|
| --------- | -------- | ---------- |
|
||
|
| Escribir | AA | 0b00001111 |
|
||
|
| Escribir | AB | 0b00000001 |
|
||
|
| Leer | AC | 0b00100000 |
|
||
|
|
||
|
<img src="Pasted image 20221124235204.png" alt="" style="width: 400px; object-fit: fill">
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
## main.rs
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
```Rust
|
||
|
#![no_std]
|
||
|
#![no_main]
|
||
|
|
||
|
#[no_mangle]
|
||
|
pub extern "C" fn main() {}
|
||
|
|
||
|
#[panic_handler]
|
||
|
fn panic(_info: &::core::panic::PanicInfo) -> ! {
|
||
|
loop {}
|
||
|
}
|
||
|
```
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
```Rust
|
||
|
#![no_std]
|
||
|
#![no_main]
|
||
|
```
|
||
|
\---
|
||
|
- `#![no_std]`: Evita que se incluya la biblioteca estándar
|
||
|
- `#![no_main]`: Delega a la persona que programa el punto de entrada
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
```Rust
|
||
|
#[no_mangle]
|
||
|
pub fn extern "C" main() {
|
||
|
}
|
||
|
```
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
```Rust
|
||
|
#[no_mangle]
|
||
|
```
|
||
|
Sin `no_mangle`:
|
||
|
<img src="Pasted image 20221120225932.png" alt="" style="object-fit: scale-down">
|
||
|
|
||
|
Con `no_mangle`:
|
||
|
<img src="Pasted image 20221120230036.png" alt="" style="object-fit: scale-down">
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
```Rust
|
||
|
pub fn extern "C" main() {}
|
||
|
```
|
||
|
- `pub`: Indica que esa función puede ser accedida fuera del `main.rs`
|
||
|
- `extern "C"`: Indica que esa función utilizará el ABI de C
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
```Rust
|
||
|
#[panic_handler]
|
||
|
fn panic(_info: &::core::panic::PanicInfo) -> ! {
|
||
|
loop {}
|
||
|
}
|
||
|
```
|
||
|
- `#[panic_handler]`: Le indica al compilador que esa función sea la que se ejecuta cuando suceda un `panic!`
|
||
|
- `core::panic::PanicInfo`: Contiene la información del `panic!` en cuestión
|
||
|
- `!`: Le indica al compilador que esa función será infinita
|
||
|
- `loop`: Ciclo infinito del que no se puede salir hasta reiniciar
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
## Cargo.toml
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
```toml
|
||
|
[profile.release]
|
||
|
lto = true
|
||
|
panic = "abort"
|
||
|
```
|
||
|
- `lto = true`: Optimización del linker (workarround por un bug en LLVM)
|
||
|
- `panic = "abourt"`: Coloca un `eh_personality` genérico que no tiene ningún efecto
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
## Compilación
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
`cargo build -Z build-std=core --target avr-atmega328p.json --release`
|
||
|
\---
|
||
|
- `-Z build-std=core`: Indica al compilador que agregue el crate `core`
|
||
|
- `--target avr-atmega328p.json`: Indica que se hara compilación cruzada
|
||
|
- `--release`: Se compilará con el perfil release
|
||
|
|
||
|
\---
|
||
|
###### \*Debe hacerse con la versión nocturna
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
<img src="2022-11-22--1669097803_1358x141_scrot.png" alt="" style="object-fit: scale-down">
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
## Especificaciones del ATmega328p
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
<img src="Pasted image 20221122232816.png" alt="" style="object-fit: scale-down">
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
### 3 tipos de regitros
|
||
|
1. DDR (Data Direction Register): Indican en que modo está cada pin
|
||
|
2. PORT: Contiene la propia información de salida (el de escritura)
|
||
|
3. PIN: Contiene la propia información de entrada (el de lectura)
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
### Contruir el nombre de un pin:
|
||
|
`{Registro}{Letra indicativa}{N° de pin}`
|
||
|
#### Exemplos:
|
||
|
| Con Registros | En processing |
|
||
|
| ------------- | ------------------ |
|
||
|
| PORTC5 | A5 |
|
||
|
| DDRB2 | 10 |
|
||
|
| PIND6 | 6 |
|
||
|
| PORTD | Del 0 al 7 |
|
||
|
| PORTB5 | Led incrustrado 💡 |
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
<img src="Pasted image 20221213120624.png" alt="" style="object-fit: scale-down">
|
||
|
|
||
|
`PORTB = 0x25`
|
||
|
`DDRB = 0x24`
|
||
|
`PINB = 0x23`
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
```Rust
|
||
|
use core::ptr::{read_volatile, write_volatile};
|
||
|
|
||
|
const DDRB: *mut u8 = 0x24 as *mut u8;
|
||
|
const PORTB: *mut u8 = 0x25 as *mut u8;
|
||
|
|
||
|
#[no_mangle]
|
||
|
pub extern "C" fn main() {
|
||
|
unsafe { write_volatile(DDRB, 0b11111111) };
|
||
|
unsafe { write_volatile(PORTB, 0b00100000) };
|
||
|
}
|
||
|
```
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
Coloca todos los pines de la sección B en modo OUTPUT:
|
||
|
```Rust
|
||
|
76543210
|
||
|
unsafe { write_volatile(DDRB, 0b11111111) };
|
||
|
```
|
||
|
|
||
|
Pone voltaje alto en el pin 5 de la sección B:
|
||
|
```Rust
|
||
|
76543210
|
||
|
unsafe { write_volatile(PORTB, 0b00100000) };
|
||
|
```
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
### Compilando
|
||
|
<img src="2022-11-22--1669182946_1084x249_scrot.png" alt="" style="object-fit: scale-down">
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
## ¿Cómo subir el resultado al Arduino?
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
<img src="2022-11-23--1669183468_622x338_scrot.png" alt="" style="object-fit: scale-down">
|
||
|
|
||
|
Arduino IDE > Herramientas > Puerto > "Arduino UNO".
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
### Convertir el .elf a un .hex
|
||
|
```Bash
|
||
|
avr-objcopy -O ihex -R .eeprom path/al/archivo.elf <output>.hex
|
||
|
```
|
||
|
<img src="2022-11-23--1669183799_769x60_scrot.png" alt="" style="object-fit: scale-down">
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
### Subir el archivo .hex
|
||
|
```Bash
|
||
|
avrdude -p atmega328p -c arduino -P <puerto> -U flash:w:<archivo.hex>:i
|
||
|
```
|
||
|
<img src="2022-11-23--1669184095_683x461_scrot.png" alt="" style="object-fit: scale-down">
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
<img src="Pasted image 20221123195630.png" alt="" style="object-fit: scale-down">
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
```Rust
|
||
|
pub extern "C" fn main() {
|
||
|
unsafe { write_volatile(DDRB, 0b11111111) };
|
||
|
unsafe { write_volatile(PORTB, 0b00000000) };
|
||
|
}
|
||
|
```
|
||
|
<img src="Pasted image 20221123195956.png" alt="" style="object-fit: scale-down">
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
## std::thread\::sleep??
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
<img src="Pasted image 20221123224248.png" alt="" style="object-fit: scale-down">
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
```Rust
|
||
|
#![feature(asm_experimental_arch)]
|
||
|
|
||
|
use core::arch::asm;
|
||
|
|
||
|
const CPU_SPEED: u32 = 16_000_000;
|
||
|
|
||
|
fn sleep(time: u32) {
|
||
|
for _ in 0..(CPU_SPEED / 10 * time) {
|
||
|
unsafe { asm!("nop") }
|
||
|
}
|
||
|
}
|
||
|
```
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
<img src="2022-11-23--1669265981_1028x627_scrot.png" alt="" style="object-fit: scale-down">
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
```Rust
|
||
|
#[no_mangle]
|
||
|
pub extern "C" fn main() -> ! {
|
||
|
unsafe { write_volatile(DDRB, 0b11111111) };
|
||
|
|
||
|
loop {
|
||
|
unsafe { write_volatile(PORTB, 0b00000000) };
|
||
|
sleep(1);
|
||
|
unsafe { write_volatile(PORTB, 0b00100000) };
|
||
|
sleep(1);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
fn sleep(time: u32) { ... }
|
||
|
```
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
```Rust
|
||
|
#[no_mangle]
|
||
|
loop {
|
||
|
let mut portb_value = unsafe { read_volatile(PORTB) };
|
||
|
portb_value = portb_value ^ ( 1 << 5 );
|
||
|
unsafe { write_volatile(PORTB, portb_value) };
|
||
|
sleep(1);
|
||
|
}
|
||
|
```
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
### Operador XOR (^)
|
||
|
| Entrada A | Entrada B | Salida |
|
||
|
| --------- | --------- | ------ |
|
||
|
| 0 | 0 | 0 |
|
||
|
| 0 | 1 | 1 |
|
||
|
| 1 | 0 | 1 |
|
||
|
| 1 | 1 | 0 |
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
### Operador shift left ( << )
|
||
|
| Entrada A | Entrada B | Salida |
|
||
|
| --------- | --------- | ---------- |
|
||
|
| 0b1 | 2 | 0b100 |
|
||
|
| 0b101 | 5 | 0b10100000 |
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
Compilamos, convertimos, subimos y...
|
||
|
✨`\._.\ \._./ /._./`✨
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
## PEEEEERO
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
## ✨ HAL ✨
|
||
|
#### (Capa de abstracción de hardware)
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
### embedded-hal 🤖
|
||
|
```Rust
|
||
|
trait OutputPin {
|
||
|
fn set_high();
|
||
|
fn set_low();
|
||
|
fn toggle();
|
||
|
...
|
||
|
}
|
||
|
|
||
|
trait InputPin {
|
||
|
fn is_low() -> bool;
|
||
|
fn is_high() -> bool;
|
||
|
}
|
||
|
|
||
|
SpiDevice, I2c, Serial, UART, Delay, etc...
|
||
|
```
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
### Biblioteca 📜
|
||
|
```Rust
|
||
|
fn blink(pin: &mut OutputPin, delay: &mut DelayUs) -> ! {
|
||
|
pin.set_high();
|
||
|
loop {
|
||
|
pin.toggle();
|
||
|
delay.delay_ms(1000);
|
||
|
}
|
||
|
}
|
||
|
```
|
||
|
###### solo para fines ilustrativos, no sirve este código
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
### arduino-hal ⚡
|
||
|
```Rust
|
||
|
struct Pin {
|
||
|
ddr: *mut u8;
|
||
|
port: *mut u8;
|
||
|
number: u8;
|
||
|
}
|
||
|
|
||
|
impl embedded_hal::OutputPin for Pin {
|
||
|
fn set_high(&self) {
|
||
|
let mut pin_value = unsafe { read_volatile(self.port) };
|
||
|
pin_value = pin_value | (1 << self.number);
|
||
|
unsafe { write_volatile(self.port, pin_value) };
|
||
|
}
|
||
|
fn set_low(&self) { ... }
|
||
|
fn set_toggle(&self) { ... }
|
||
|
}
|
||
|
```
|
||
|
###### solo para fines ilustrativos, no sirve este código
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
### Firmware 💻
|
||
|
```Rust
|
||
|
#[arduino_hal::entry]
|
||
|
fn main() -> ! {
|
||
|
let mut led_pin = arduino_hal::pins::B5;
|
||
|
led_pin.set_output();
|
||
|
|
||
|
blink::blink(led_pin);
|
||
|
}
|
||
|
```
|
||
|
###### solo para fines ilustrativos, no sirve este código
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
<img src="diagrama-hal.png" alt="" style="width: 600px; object-fit: fill">
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
```Rust
|
||
|
use panic_halt as _;
|
||
|
|
||
|
#[arduino_hal::entry]
|
||
|
fn main() -> ! {
|
||
|
let peripherals = arduino_hal::Peripherals::take().unwrap();
|
||
|
let pins = arduino_hal::pins!(peripherals);
|
||
|
|
||
|
let mut led = pins.d13.into_output();
|
||
|
led.set_high();
|
||
|
|
||
|
loop {
|
||
|
led.toggle();
|
||
|
delay_ms(1000);
|
||
|
}
|
||
|
}
|
||
|
```
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
Compilamos, convertimos, subimos y...
|
||
|
✨`\._.\ \._./ /._./`✨
|
||
|
(De nuevo)
|
||
|
</div></script></section><section data-markdown><script type="text/template"><!-- .slide: class="drop" -->
|
||
|
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true">
|
||
|
|
||
|
## Mis redes :)
|
||
|
|
||
|
**Telegram:** @kirbylife
|
||
|
**Mastodon:** @kirbylife\@mstdn.mx
|
||
|
**Twitter:** @kirbylife
|
||
|
**e-mail:** hola\@kirbylife.dev
|
||
|
|
||
|
**Repositorio:** https:\//gitlab.com/kirbylife/arduino_blinkrs
|
||
|
</div></script></section></div>
|
||
|
</div>
|
||
|
|
||
|
<script src="dist/reveal.js"></script>
|
||
|
|
||
|
<script src="plugin/markdown/markdown.js"></script>
|
||
|
<script src="plugin/highlight/highlight.js"></script>
|
||
|
<script src="plugin/zoom/zoom.js"></script>
|
||
|
<script src="plugin/notes/notes.js"></script>
|
||
|
<script src="plugin/math/math.js"></script>
|
||
|
<script src="plugin/mermaid/mermaid.js"></script>
|
||
|
<script src="plugin/chart/chart.min.js"></script>
|
||
|
<script src="plugin/chart/plugin.js"></script>
|
||
|
<script src="plugin/customcontrols/plugin.js"></script>
|
||
|
<script src="plugin/reveal-pointer/pointer.js"></script>
|
||
|
|
||
|
<script>
|
||
|
function extend() {
|
||
|
var target = {};
|
||
|
for (var i = 0; i < arguments.length; i++) {
|
||
|
var source = arguments[i];
|
||
|
for (var key in source) {
|
||
|
if (source.hasOwnProperty(key)) {
|
||
|
target[key] = source[key];
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return target;
|
||
|
}
|
||
|
|
||
|
function isLight(color) {
|
||
|
let hex = color.replace('#', '');
|
||
|
|
||
|
// convert #fff => #ffffff
|
||
|
if(hex.length == 3){
|
||
|
hex = `${hex[0]}${hex[0]}${hex[1]}${hex[1]}${hex[2]}${hex[2]}`;
|
||
|
}
|
||
|
|
||
|
const c_r = parseInt(hex.substr(0, 2), 16);
|
||
|
const c_g = parseInt(hex.substr(2, 2), 16);
|
||
|
const c_b = parseInt(hex.substr(4, 2), 16);
|
||
|
const brightness = ((c_r * 299) + (c_g * 587) + (c_b * 114)) / 1000;
|
||
|
return brightness > 155;
|
||
|
}
|
||
|
|
||
|
var bgColor = getComputedStyle(document.documentElement).getPropertyValue('--r-background-color').trim();
|
||
|
var isLight = isLight(bgColor);
|
||
|
|
||
|
if(isLight){
|
||
|
document.body.classList.add('has-light-background');
|
||
|
} else {
|
||
|
document.body.classList.add('has-dark-background');
|
||
|
}
|
||
|
|
||
|
// default options to init reveal.js
|
||
|
var defaultOptions = {
|
||
|
controls: true,
|
||
|
progress: true,
|
||
|
history: true,
|
||
|
center: true,
|
||
|
transition: 'default', // none/fade/slide/convex/concave/zoom
|
||
|
plugins: [
|
||
|
RevealMarkdown,
|
||
|
RevealHighlight,
|
||
|
RevealZoom,
|
||
|
RevealNotes,
|
||
|
RevealMath.MathJax3,
|
||
|
RevealMermaid,
|
||
|
RevealChart,
|
||
|
RevealCustomControls,
|
||
|
RevealPointer,
|
||
|
],
|
||
|
|
||
|
|
||
|
allottedTime: 120 * 1000,
|
||
|
|
||
|
mathjax3: {
|
||
|
mathjax: 'plugin/math/mathjax/tex-mml-chtml.js',
|
||
|
},
|
||
|
markdown: {
|
||
|
gfm: true,
|
||
|
mangle: true,
|
||
|
pedantic: false,
|
||
|
smartLists: false,
|
||
|
smartypants: false,
|
||
|
},
|
||
|
|
||
|
mermaid: {
|
||
|
theme: isLight ? 'default' : 'dark',
|
||
|
},
|
||
|
|
||
|
customcontrols: {
|
||
|
controls: [
|
||
|
]
|
||
|
},
|
||
|
};
|
||
|
|
||
|
// options from URL query string
|
||
|
var queryOptions = Reveal().getQueryHash() || {};
|
||
|
|
||
|
var options = extend(defaultOptions, {"width":960,"height":700,"margin":0.04,"controls":true,"progress":true,"slideNumber":false,"transition":"slide","transitionSpeed":"default"}, queryOptions);
|
||
|
</script>
|
||
|
|
||
|
<script>
|
||
|
Reveal.initialize(options);
|
||
|
</script>
|
||
|
</body>
|
||
|
|
||
|
<!-- created with Advanced Slides -->
|
||
|
</html>
|