Upgrade to Pro — share decks privately, control downloads, hide ads and more …

TinyGo for Maker @Go to Songdo 2023 박제창

TinyGo for Maker @Go to Songdo 2023 박제창

TinyGo for Maker @Go to Songdo 2023 박제창

JaiChangPark

July 15, 2023
Tweet

More Decks by JaiChangPark

Other Decks in Programming

Transcript

  1. Go to Songdo 2023 TinyGo for Maker 박제창 (Dreamwalker) /

    GDG Golang Korea TinyGo를 위한 여정 Go to Songdo 2023
  2. Go to Songdo 2023 • 박제창 @Dreamwalker • Dreamus Company

    • GDG Golang Korea • Flutter Seoul • Github: JAICHANGPARK Speaker
  3. Go to Songdo 2023 Index • MicroController • Language &

    IDE • Build, Compile, Flash ⚡ • TinyGo • TinyGo Led Blink • TinyGo I2C
  4. Go to Songdo 2023 Are you maker Programming 회로설계 PCB

    (Artwork) 등등 Hardware Software MCU 인두기 장비들 3D 프린터 각종 공구 등등 다재다능해야함.
  5. Go to Songdo 2023 9.1093837015(28)×10−31 k Micro-controller (MCU) • 도체:

    전류가 잘 통하는 물질 ◦ 금, 은 ◦ 구리 • 부도체: 전류가 통하지 않는 물질 ◦ 고무 ◦ 기름 ◦ 유리 ◦ 플라스틱 • 반도체: 도체와 부도체 그 사이
  6. Go to Songdo 2023 9.1093837015(28)×10−31 k Micro-controller (MCU) • 옥텟

    규칙(octet rule)을 기억하시나요? https://www.shindengen.com/products/semi/coumn/basic/semi/semi_basic.html https://www.newtondesk.com/silicon-element/ https://en.wikipedia.org/wiki/Silicon
  7. Go to Songdo 2023 9.1093837015(28)×10−31 k Micro-controller (MCU) • 도핑

    (Doping) ◦ N형 ▪ 실리콘에 Donor를 Doping 하면 생성되는 반도체 ▪ 최외각 전자가 5개인 원소를 주입 ◦ P형 ▪ 실리콘(규소)에 acceptor를 Doping하면 생성되는 반도체 ▪ 최외각 전자가 3개인 원소를 주입
  8. Go to Songdo 2023 9.1093837015(28)×10−31 k Micro-controller (MCU) • Diode

    (Light-emitting diode) https://en.wikipedia.org/wiki/Shuji_Nakamura
  9. Go to Songdo 2023 9.1093837015(28)×10−31 k Micro-controller (MCU) • Transistor

    https://en.wikipedia.org/wiki/Transistor • 증폭기 • 스위치(칭)
  10. Go to Songdo 2023 9.1093837015(28)×10−31 k Micro-controller (MCU) • 논리회로

    • CMOS Based • Full Adder https://en.wikipedia.org/wiki/Adder_(electronics)
  11. Go to Songdo 2023 9.1093837015(28)×10−31 k Micro-controller (MCU) • 54

    시리즈 • 74 시리즈 • TTL • 74LS • 74HC • 등등 • 7408 (AND GATE) • 7404 • 7432 • 등등
  12. Go to Songdo 2023 9.1093837015(28)×10−31 k Micro-controller (MCU) Apple M2

    2022 : 20,000,000,000 (200억개) Z80 1970s 8,500개
  13. Go to Songdo 2023 9.1093837015(28)×10−31 k Micro-controller (MCU) • FPGA

    https://en.wikipedia.org/wiki/Field-pr ogrammable_gate_array • VHDL • Verilog
  14. Go to Songdo 2023 Micro-controller (MCU) Broadcom BCM2711, Quad core

    Cortex-A72 (ARM v8) 64-bit SoC @ 1.8GHz NXP i.MX 8M SoC (quad Cortex-A53, Cortex-M4F)
  15. Go to Songdo 2023 Micro-controller (MCU) Cortex-M0+ processor with 264kB

    internal RAM and support for up to 16MB of off-chip flash
  16. Go to Songdo 2023 Micro-controller (MCU) 개발하려는 시스템 필요한 포트

    수 (=핀 수) Peripherals 메모리 전원, 시스템 전류 소모 전력 동작 주파수 등등 Complex
  17. Go to Songdo 2023 Build, Compile 스케치는 프로그램 저장 공간

    235905 바이트(17%)를 사용. 최대 1310720 바이트. 전역 변수는 동적 메모리 22056바이트(6%)를 사용, 305624바이트의 지역변수가 남음. 최대는 327680 바이트.
  18. Go to Songdo 2023 TinyGo CLI Command build: compile packages

    and dependencies run: compile and run immediately test: test packages flash: compile and flash to the device gdb: run/flash and immediately enter GDB lldb: run/flash and immediately enter LLDB monitor: open communication port env: list environment variables used during build list: run go list using the TinyGo root clean: empty cache directory (C:\Users\HOME613\AppData\Local\tinygo) targets: list targets info: show info for specified target version: show version help: print this help text
  19. Go to Songdo 2023 TinyGo Driver • 보드에 다양한 센서를

    연결하여 사용 • 일반적으로 센서 제조자에서 드라이버를 제공하기도 함(C/C++코드만) • 그외 제공되는 라이브러리(드라이버)는 오픈소스 형태 • TinyGo도 대중적인 센서들을 드라이버가 존재해서 쉽게 사용이 가능
  20. Go to Songdo 2023 TinyGo LED Blink Arduino Nano RP2040

    Connect Raspberry Pi® RP2040 Nina W102 uBlox module
  21. Go to Songdo 2023 TinyGo LED Blink Arduino Nano RP2040

    Connect • Dual Cortex M0+ processor cores, up to 133MHz • 264kB of embedded SRAM in 6 banks • 30 multifunction GPIO • 6 dedicated IO for SPI Flash (supporting XIP) • Dedicated hardware for commonly used peripherals • Programmable IO for extended peripheral support • 4 channel ADC with internal temperature sensor, 500ksps, 12-bit conversion • USB 1.1 Host/Device
  22. Go to Songdo 2023 TinyGo LED Blink Arduino Nano RP2040

    Connect TinyGo Support? https://tinygo.org/docs/reference/mi crocontrollers/nano-rp2040/
  23. Go to Songdo 2023 #pragma once #include <macros.h> #include <stdint.h>

    #ifndef __PINS_ARDUINO__ #define __PINS_ARDUINO__ #ifdef __cplusplus extern "C" unsigned int PINCOUNT_fn(); #endif #define PIN_LED (13u) #define LED_BUILTIN PIN_LED TinyGo LED Blink https://github.com/arduino/ArduinoCore-mbed/blob/main/variants/NANO_RP2040_CONNECT/pins_arduino.h
  24. Go to Songdo 2023 class NinaPin { public: NinaPin(int _pin)

    : pin(_pin) {}; int get() { return pin; }; int analogReadResolution() { return getAnalogReadResolution(); }; bool operator== (NinaPin const & other) const { return pin == other.pin; } //operator int() = delete; __attribute__ ((error("Change me to a #define"))) operator int(); private: int pin; }; TinyGo LED Blink https://github.com/arduino/ArduinoCore-mbed/blob/main/variants/NANO_RP2040_CONNECT/nina_pins.h
  25. Go to Songdo 2023 // Arduino Example C/C++ based void

    setup() { pinMode(LED_BUILTIN, OUTPUT); } void loop() { digitalWrite(LED_BUILTIN, HIGH); delay(1000); digitalWrite(LED_BUILTIN, LOW); delay(1000); } TinyGo LED Blink
  26. Go to Songdo 2023 // TinyGo golang based led :=

    machine.LED led.Configure(machine.PinConfig{Mode: machine.PinOutput}) for { led.Low() time.Sleep(time.Millisecond * 500) led.High() time.Sleep(time.Millisecond * 500) } TinyGo LED Blink
  27. Go to Songdo 2023 TinyGo LED Blink led.Low() time.Sleep(time.Millisecond *

    500) led.High() time.Sleep(time.Millisecond * 500) power led LED BUILT IN
  28. Go to Songdo 2023 i2c := machine.I2C0 err := i2c.Configure(machine.I2CConfig{

    SCL: machine.I2C0_SCL_PIN, SDA: machine.I2C0_SDA_PIN, }) if err != nil { println("could not configure I2C:", err) return } TinyGo I2C
  29. Go to Songdo 2023 w := []byte{0x75} //117 r :=

    make([]byte, 1) err = i2c.Tx(0x68, w, r) if err != nil { println("could not interact with I2C device:", err) return } println("WHO_AM_I:", r[0]) TinyGo I2C