Arduino STM32 リファレンス 日本語版 (copy)
原文
本ドキュメントは、 「Maple LeafLabs, LLC. Last updated on Jan 15, 2014」をたま吉が翻訳・加筆修正した非公式ドキュメントです。誤訳・記載ミスが多々ありますが、ご了承下さい。
※NAVER、ヤフオク等の営利目的の記事転用、リンク貼りは禁止です。
構造
setup()
loop()
制御文
if
for
switch
while
do
break
continue
return
goto
基本的な文法
; (セミコロン)
{ } (中括弧)
コメント // (シングルラインコメント)、 /* */ (マルチラインコメント)
#define (定数の定義)
#include (ヘッダーファイルの読み込み)
演算子
代入演算子 =
算術演算子 + (加算)、 - (減算)、 * (掛け算)、 / (割り算)
剰余演算子 %(剰余)
比較演算子 == (等しい)、!= (等しくない)、 < (小さい)、 > (大きい)、 <= (以下)、  >= (以上)
ブール演算子 && (理AND演算子)  || (論理OR演算子)  ! (論理NOT演算子)
ポインター演算子  * (間接演算子)、 & (アドレス演算子)
ビット演算子 & (ビット単位のAND)、  | (ビット単位のOR)、 ^ (ビット単位のXOR)、 ~ (ビット単位のNOT)
ビットシフト演算子  << (左シフト)、  >> (右シフト)
インクリメントおよびデクリメント演算子  ++ (インクリメント)、  -- (ディクリメント)
複合演算子
+= (複合足し算)、 -= (複合引き算)、  *= (複合掛け算)、  /= (複合割り算)
%= (複合剰余)、  &= (複合ビット単位AND)、  |= (複合ビット単位OR)
^= (複合ビット単位XOR)、  <<= (複合左シフト)、  >>= (複合右シフト)
キーワード
C++キーワード
定数
true | false、 HIGH | LOW、 INPUT | OUTPUT、 LSBFIRST | MSBFIRST (wirish_constants.h)
数値定数, 浮動小数点定数
ボード固有の定数
その他便利な定数 (PI、HALF_PI、TWO_PI…)
データ型
void
ブール型 bool (1 バイト)
char (1 バイト)、unsigned char (1 バイト)、byte (1 バイト)
int (4 バイト)、unsigned int (4 バイト)、long (4 バイト intと同じ)、unsigned long (4 バイト unsigned intと同じ)
long long (8 バイト)、unsigned long long (8 バイト)、int64(long longと同じ)、uint64(unsigned long longと同じ)
float (4 バイト)
double (8 バイト)
文字列
配列
enum
組み込み型
文字列型 (Stringクラス)
変数の応用
変数, スコープ
static
volatile
const
__io、__FLASH__、__attr_flash、
API・コアライブラリ
型変換
char()、byte()、int()、long()、float()、double()
makeWord() (ヘッダーファイル wirish_math.h)
word() (ヘッダーファイル wirish_math.h)
ユーティリティ
sizeof()
ASSERT()
デジタル入出力関数 (ヘッダーファイル io.h)
pinMode()
digitalWrite()
digitalRead()
アナログ入出力関数 (ヘッダーファイル io.h)
analogRead()
analogWrite()
pwmWrite()
その他の入出力関数
shiftOut() (ヘッダーファイル io.h)
shiftIn() (ヘッダーファイル io.h)
pulseIn() (ヘッダーファイル wiring_pulse.h)
tone()
noTone()
時間に関する関数 (ヘッダーファイル wirish_time.h)
millis()
micros()
delay()
delayMicroseconds()
数学的な関数 (ヘッダーファイル wirish_math.h)
min()、 max()
abs()
constrain()
map()
pow()
sqrt()
sq()
round()
radians()、degrees()
三角関数 (ヘッダーファイル wirish_math.h)
sin()
cos()
tan()
乱数に関する関数 (ヘッダーファイル wirish_math.h)
randomSeed()
random()
数値文字列変換 (ヘッダーファイル itoa.h)
itoa()、 ltoa()
utoa()、ultoa()
ビットとバイトの操作 (ヘッダーファイル wirish.h)
lowByte()、 highByte()
bitRead()、 bitWrite()
bitSet()、 bitClear()、 bit()
_BV()
文字ユーティリティ関数 (ヘッダーファイル WCharacter.h)
isControl()、 isPrintable()、 isGraph()、 isPunct()
isWhitespace()、 isSpace()
isDigit()、 isHexadecimalDigit()
isAlphaNumeric()、 isAlpha()、 isAscii()
isLowerCase()、 isUpperCase()
int toAscii()、 int toLowerCase()、 int toUpperCase()
システムクロック・時間変換 (ヘッダーファイル wirish.h)
clockCyclesPerMicrosecond()
clockCyclesToMicroseconds()
microsecondsToClockCycles()
デバッグ用ポートの利用設定
disableDebugPorts() (ヘッダファイル wirish_debug.h)
enableDebugPorts() (ヘッダファイル wirish_debug.h)
afio_cfg_debug_ports() (ヘッダファイル series/gpio.h)
外部割り込み (レファンスマニュアル => 外部割込み)
attachInterrupt()
detachInterrupt()
タイマー・タイマー割り込み・高度なPWM制御
HardwareTimer タイマライブラリ
割り込みの有効・無効設定
interrupts()
noInterrupts()
GPIOポート利用支援
digitalPinToPort()
digitalPinToBitMask()
portOutputRegister()
portInputRegister()
portSetRegister()
portClearRegister()
portConfigRegister()
文字出力ユーティリティ
Print print()とprintln()を提供する基本クラス
Stream 文字ベースのストリームの基本クラス
Printable
シリアル通信
Arduino STM32では、USBポートを利用した仮想シリアルポート、シリアル端子を利用したシリアルポートが用意されています。利用するボードにより異なりますが、シリアル端子を利用したシリアルポートは3ポート以上用意されています。
USBSerial クラス(usb_serial.h) 実装済オブジェクト:Serail(*1)
HardwareSerial クラス(HardwareSerial.h) 実装済オブジェクト:Serial1,Serial2,Serial3, ... SerialN
(注意) Serialオブジェクトはスケッチ書き込み手段がシリアル端子を利用した場合、Serialクラスのインスタンスとなります。USBポートを利用したシリアル通信を行いたい場合は、明示的にUSBSerial クラスからインスタンスを作成して利用する必要があります。
(補足)ボート定義情報 ./Arduino_STM32/STM32F1/boards.txt で-DSERIAL_USBの指定がある書き込み方法ではSerialオブジェクトがUSBSerial クラスのインスタンス、それ以外はHardwareSerial クラスのインスタンスとなります。
標準Cライブラリ
Arduino STM32では、組み込みアプリケーションで使用するための C標準ライブラリnewlibが利用できます。
newlibから呼ばれる スタブ関数(低レベル入出力関数)はボード別にsyscalls.cに定義されています。メモリ獲得関数の除き、その大半は実装の無い空関数であり、標準入出力の利用はサポートされていません。
またnewlibは、ArduinoのAVR-GCCのC標準ライブラリとは実装が異なるため、動作及び仕様が異なる可能性があります。
Arduino STM32 標準ライブラリ
Arduino STM32に含まれる標準ライブラリ(コア以外のライブラリ)です。
EEPROM 仮想EEPROMクラスライブラリ
flash_stm32 内蔵フラッシメモリ利用ライブラリ
RTClock 内蔵RTC利用ライブラリ
Wire I2C通信ライブラリ
SPI SPI通信ライブラリ
SDIO
STM32ADC
Adafruit_GFX_AS
Adafruit_ILI9341、 Adafruit_ILI9341_STM
Adafruit_SSD1306
Ethernet_STM
FreeRTOS、 FreeRTOS821、 FreeRTOS900
MapleCoOS、 MapleCoOS116
Lcd7920_STM
LiquidCrystal
OLED_I2C
Serasidis_EtherCard_STM
Serasidis_VS1003B_STM
Serasidis_XPT2046_touch
Touch-Screen-Library_STM
WS2812B
動作確認済Arduino標準ライブラリ
SD
libmaple下位レイアライブラリ
libmaple下位レイアライブラリは、STM32のデバイスを利用するたのAPI、レジスタマップで構成されています。
APIの利用のほか、直接レジスタを操作することも可能です。
Backup register (BKP) suport (bkp.h) libmaple/bkp.h バックアップメモリの利用
Bit-banding support(bitband.h) libmaple/bitband.h ビットバンディングサポートライブラリ
System timer (SysTick) support (systick.h) libmaple/systick.h システムタイマ
GPIO port and AFIO support(gpio.h) libmaple/gpio.h GPIO・AFIOサポートライブラリ
Nested Vector Interrupt Controller (NVIC) support(nvic.h) ネスト型ベクタ割り込みコントローラ(NVIC)のサポート
External interrupt support(exti.h) libmaple/exti.h 外部割り込みサポート
Flash support(flash.h)
Power control (PWR) support(pwr.h)
Reset and Clock Control (RCC) support(rcc.h)
Independent Watchdog (IWDG) support(iwdg,h)
Timer support(timer.h)
USART support(usart.h)
Inter-Integrated Circuit (I2C) peripheral support(i2c.h)
Serial Peripheral Interface (SPI) support(spi.h)
Direct Memory Access (DMA) support(dma.h)
Analog to Digital Conversion (ADC) support(adc.h)
Flexible Static Memory Controller (FSMC) support(fsmc.h)
System Control Block (SCB) support(scb.h)
Simple busy-loop delaying(delay.h)
Miscellaneous utility macros and procedures(util.h)
Digital to Analog Conversion (DAC) support(dac.h)
Simple circular byte buffer(ring_buffer.h)
公開ライブラリ・スケッチ
Arduino STM32 TVoutライブラリ
Arduino STM32用 NTSCビデオ出力ラブラリ
rduino STM32用 PS/2 キーボードライブラリ
PS2Keyboard 2.4 Arduino STM32対応バージョン
Arduino STM32用 内部フラッシュメモリ書き込みライブラリ
SDライブラリ修正版(STM32対応、MMC対応、半角カタカナ対応)
Arduino STM32 Xbox Chatpad ライブラリ (KeiTakagi/XboxChatpad)
Helper library for using Stop & Standby modes with STM32duino (chacal/stm32sleep)
Minimalistic terminal based on STM32 and ILI9341 2.2" LCD (cbm80amiga/STM32_TFT22_terminal_RRE)
STM32F103 based minimalist oscilloscope (pingumacpenguin/STM32-O-Scope)
TOYOSHIKI Tiny BASIC for Arduino STM32 (V0.5 V0.85β)
/icons/hr.icon
License and Attribution: Portions of this page were adapted from the Arduino Reference Documentation, which is released under a Creative Commons Attribution-ShareAlike 3.0 License.
Copyright 2010, 2011, LeafLabs, LLC. Last updated on Jan 15, 2014
このドキュメントはleafLabs, LLC.が執筆し、たま吉が翻訳・一部加筆修正したものです。
NAVER、ヤフオク等の営利目的の記事転用、リンク貼りは禁止です。
本ドキュメントに関する問い合わせ先: たま吉 mail:tamacat2014@gmail.com