0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

megaTinyCore の組み込みマクロ

Last updated at Posted at 2021-11-27

概要

新しいAVRマイコンシリーズで、tinyAVR0シリーズ(tinyAVR® 0-Series)とtinyAVR1シリーズ(tinyAVR® 1-Series)、tinyAVR2シリーズ(tinyAVR® 2-Series)があります。
よくヘッダファイルで使用される、CPU毎に定義を変える場合に使用する #ifdefined(AVR_ATmega168)という式をmegaTinyCore時に使用する組み込みマクロ名をまとめてみました。

tinyAVR0シリーズ

型名 マクロ名
ATtiny202 AVR_ATtiny202
ATtiny402 AVR_ATtiny402
ATtiny204 AVR_ATtiny204
ATtiny404 AVR_ATtiny404
ATtiny804 AVR_ATtiny804
ATtiny1604 AVR_ATtiny1604_
ATtiny406 AVR_ATtiny406
ATtiny806 AVR_ATtiny806
ATtiny1606 AVR_ATtiny1606
ATtiny807 AVR_ATtiny807
ATtiny1607 AVR_ATtiny1607

tinyAVR1シリーズ

型名 マクロ名
ATtiny212 AVR_ATtiny212
ATtiny412 AVR_ATtiny412
ATtiny214 AVR_ATtiny214
ATtiny414 AVR_ATtiny414
ATtiny814 AVR_ATtiny814
ATtiny1614 AVR_ATtiny1614
ATtiny416 AVR_ATtiny416
ATtiny816 AVR_ATtiny816
ATtiny1616 AVR_ATtiny1616
ATtiny3216 AVR_ATtiny3216
ATtiny417 AVR_ATtiny417
ATtiny817 AVR_ATtiny817
ATtiny1617 AVR_ATtiny1617
ATtiny3217 AVR_ATtiny3217

tinyAVR2シリーズ

型名 マクロ名
ATtiny424 AVR_ATtiny424
ATtiny824 AVR_ATtiny824
ATtiny1624 AVR_ATtiny1624
ATtiny3224 AVR_ATtiny3224
ATtiny426 AVR_ATtiny426
ATtiny826 AVR_ATtiny826
ATtiny1626 AVR_ATtiny1626
ATtiny3226 AVR_ATtiny3226
ATtiny427 AVR_ATtiny427
ATtiny827 AVR_ATtiny827
ATtiny1627 AVR_ATtiny1627
ATtiny3227 AVR_ATtiny3227

プログラム例

foo.h
# if defined(__AVR_ATtiny202__)
# error This chip is ATtiny202

# elif defined(__AVR_ATtiny412__)
# error This chip is ATtiny412

# elif defined(__AVR_ATtiny424__)
# error This chip is ATtiny424

# endif

■例)ChipにATtiny202 に指定してコンパイル

スクリーンショット 2021-11-27 20.51.25.png

foo.h:2:2: error: #error This chip s Attiny202
 #error This chip is ATtiny202
  ^~~~~
exit status 1
# error This chip is ATtiny202

組み込みマクロ(build-in macros)として____AVR_ATtiny202____ が定義されますので、
 #if defind(ATtiny202)で真となり、#error This chip is ATtiny202 を表示します。

振り返り

Arduinoの組み込みマクロがフォルダ内のどのファイルに定義されているのかが調査が未調査です。
判明次第、このページを改版したい。

参考リンク

3.19.6 AVRオプション
https://runebook.dev/ja/docs/gcc/avr-options

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?