#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
//おまじない
#define ON(pin) pin(PORT,|=)
#define OFF(pin) pin(PORT,&=~)
#define GET(pin) pin(PIN,&)
#define FLIP(pin) pin(PIN,|=)
#define IN(pin) pin(DDR,&=~)
#define OUT(pin) pin(DDR,|=)
#define PinA0(n,op) ((n ## A) op _BV(0))
#define PinA1(n,op) ((n ## A) op _BV(1))
#define PinA2(n,op) ((n ## A) op _BV(2))
#define PinB0(n,op) ((n ## B) op _BV(0))
#define PinB1(n,op) ((n ## B) op _BV(1))
#define PinB2(n,op) ((n ## B) op _BV(2))
#define PinB3(n,op) ((n ## B) op _BV(3))
#define PinB4(n,op) ((n ## B) op _BV(4))
#define PinB5(n,op) ((n ## B) op _BV(5))
#define PinB6(n,op) ((n ## B) op _BV(6))
#define PinB7(n,op) ((n ## B) op _BV(7))
#define PinD0(n,op) ((n ## D) op _BV(0))
#define PinD1(n,op) ((n ## D) op _BV(1))
#define PinD2(n,op) ((n ## D) op _BV(2))
#define PinD3(n,op) ((n ## D) op _BV(3))
#define PinD4(n,op) ((n ## D) op _BV(4))
#define PinD5(n,op) ((n ## D) op _BV(5))
#define PinD6(n,op) ((n ## D) op _BV(6))
//タイマークロック選択用マクロ==============
#define timer0_stop (0<<CS02) | (0<<CS01) | (0<<CS00)
#define timer0_ck_1 (0<<CS02) | (0<<CS01) | (1<<CS00)
#define timer0_ck_8 (0<<CS02) | (1<<CS01) | (0<<CS00)
#define timer0_ck_64 (0<<CS02) | (1<<CS01) | (1<<CS00)
#define timer0_ck_256 (1<<CS02) | (0<<CS01) | (0<<CS00)
#define timer0_ck_1024 (1<<CS02) | (0<<CS01) | (1<<CS00)
#define timer1_stop (0<<CS12) | (0<<CS11) | (0<<CS10)
#define timer1_ck_1 (0<<CS12) | (0<<CS11) | (1<<CS10)
#define timer1_ck_8 (0<<CS12) | (1<<CS11) | (0<<CS10)
#define timer1_ck_64 (0<<CS12) | (1<<CS11) | (1<<CS10)
#define timer1_ck_256 (1<<CS12) | (0<<CS11) | (0<<CS10)
#define timer1_ck_1024 (1<<CS12) | (0<<CS11) | (1<<CS10)
/* ピン番号とポートの名前の対応 (ATTiny2313)
___|___|___|___|___|___|___|___|___|___|_
| 20 19 18 17 16 15 14 13 12 11 |
|Vcc PB7 PB6 PB5 PB4 PB3 PB2 PB1 PB0 PD6 |
|⊃ |
|PA2 PD0 PD1 PA1 PA0 PD2 PD3 PD4 PD5 GND |
|__1___2___3___4___5___6___7___8___9__10_|
| | | | | | | | | |
分周器設定
001 前置分周なし
010 1/8
011 1/64
100 1/256
101 1/1024
*/
//ピン配置=================================
// 1番(C6)はリセット (好きな名前)に好きな名前入れて
#define (好きな名前) PinD0
#define (好きな名前) PinD1
#define (好きな名前) PinA1
#define (好きな名前) PinA0
#define (好きな名前) PinD2
#define (好きな名前) PinD3
#define (好きな名前) PinD4
#define (好きな名前) PinD5
// 10番はGND
#define (好きな名前) PinD6
#define (好きな名前) PinB0
#define (好きな名前) PinB1
#define (好きな名前) PinB2
#define (好きな名前) PinB3
#define (好きな名前) PinB4
#define (好きな名前) PinB5 //MOSI
#define (好きな名前) PinB6 //MISO
#define (好きな名前) PinB7 //USCK
// 20番はVcc
int main()
{
//メイン文
}
コメントをかく