亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? encoder.c

?? ATMEL的AVR單片機庫文件
?? C
字號:
/*! \file encoder.c \brief Quadrature Encoder reader/driver. */
//*****************************************************************************
//
// File Name	: 'encoder.c'
// Title		: Quadrature Encoder reader/driver
// Author		: Pascal Stang - Copyright (C) 2003-2004
// Created		: 2003.01.26
// Revised		: 2004.06.25
// Version		: 0.3
// Target MCU	: Atmel AVR Series
// Editor Tabs	: 4
//
// NOTE: This code is currently below version 1.0, and therefore is considered
// to be lacking in some functionality or documentation, or may not be fully
// tested.  Nonetheless, you can expect most functions to work.
//
// This code is distributed under the GNU Public License
//		which can be found at http://www.gnu.org/licenses/gpl.txt
//
//*****************************************************************************

#ifndef WIN32
	#include <avr/io.h>
	#include <avr/signal.h>
	#include <avr/interrupt.h>
#endif

#include "global.h"
#include "encoder.h"

// Program ROM constants

// Global variables
volatile EncoderStateType EncoderState[NUM_ENCODERS];

// Functions

// encoderInit() initializes hardware and encoder position readings
//		Run this init routine once before using any other encoder functions.
void encoderInit(void)
{
	u08 i;

	// initialize/clear encoder data
	for(i=0; i<NUM_ENCODERS; i++)
	{
		EncoderState[i].position = 0;
		//EncoderState[i].velocity = 0;		// NOT CURRENTLY USED
	}

	// configure direction and interrupt I/O pins:
	// - for input
	// - apply pullup resistors
	// - any-edge interrupt triggering
	// - enable interrupt

	#ifdef ENC0_SIGNAL
		// set interrupt pins to input and apply pullup resistor
		cbi(ENC0_PHASEA_DDR, ENC0_PHASEA_PIN);
		sbi(ENC0_PHASEA_PORT, ENC0_PHASEA_PIN);
		// set encoder direction pin for input and apply pullup resistor
		cbi(ENC0_PHASEB_DDR, ENC0_PHASEB_PIN);
		sbi(ENC0_PHASEB_PORT, ENC0_PHASEB_PIN);
		// configure interrupts for any-edge triggering
		sbi(ENC0_ICR, ENC0_ISCX0);
		cbi(ENC0_ICR, ENC0_ISCX1);
		// enable interrupts
		sbi(IMSK, ENC0_INT);	// ISMK is auto-defined in encoder.h
	#endif
	#ifdef ENC1_SIGNAL
		// set interrupt pins to input and apply pullup resistor
		cbi(ENC1_PHASEA_DDR, ENC1_PHASEA_PIN);
		sbi(ENC1_PHASEA_PORT, ENC1_PHASEA_PIN);
		// set encoder direction pin for input and apply pullup resistor
		cbi(ENC1_PHASEB_DDR, ENC1_PHASEB_PIN);
		sbi(ENC1_PHASEB_PORT, ENC1_PHASEB_PIN);
		// configure interrupts for any-edge triggering
		sbi(ENC1_ICR, ENC1_ISCX0);
		cbi(ENC1_ICR, ENC1_ISCX1);
		// enable interrupts
		sbi(IMSK, ENC1_INT);	// ISMK is auto-defined in encoder.h
	#endif
	#ifdef ENC2_SIGNAL
		// set interrupt pins to input and apply pullup resistor
		cbi(ENC2_PHASEA_DDR, ENC2_PHASEA_PIN);
		sbi(ENC2_PHASEA_PORT, ENC2_PHASEA_PIN);
		// set encoder direction pin for input and apply pullup resistor
		cbi(ENC2_PHASEB_DDR, ENC2_PHASEB_PIN);
		sbi(ENC2_PHASEB_PORT, ENC2_PHASEB_PIN);
		// configure interrupts for any-edge triggering
		sbi(ENC2_ICR, ENC2_ISCX0);
		cbi(ENC2_ICR, ENC2_ISCX1);
		// enable interrupts
		sbi(IMSK, ENC2_INT);	// ISMK is auto-defined in encoder.h
	#endif
	#ifdef ENC3_SIGNAL
		// set interrupt pins to input and apply pullup resistor
		cbi(ENC3_PHASEA_DDR, ENC3_PHASEA_PIN);
		sbi(ENC3_PHASEA_PORT, ENC3_PHASEA_PIN);
		// set encoder direction pin for input and apply pullup resistor
		cbi(ENC3_PHASEB_DDR, ENC3_PHASEB_PIN);
		sbi(ENC3_PHASEB_PORT, ENC3_PHASEB_PIN);
		// configure interrupts for any-edge triggering
		sbi(ENC3_ICR, ENC3_ISCX0);
		cbi(ENC3_ICR, ENC3_ISCX1);
		// enable interrupts
		sbi(IMSK, ENC3_INT);	// ISMK is auto-defined in encoder.h
	#endif
	
	// enable global interrupts
	sei();
}

// encoderOff() disables hardware and stops encoder position updates
void encoderOff(void)
{
	// disable encoder interrupts
	#ifdef ENC0_SIGNAL
		// disable interrupts
		sbi(IMSK, INT0);	// ISMK is auto-defined in encoder.h
	#endif
	#ifdef ENC1_SIGNAL
		// disable interrupts
		sbi(IMSK, INT1);	// ISMK is auto-defined in encoder.h
	#endif
	#ifdef ENC2_SIGNAL
		// disable interrupts
		sbi(IMSK, INT2);	// ISMK is auto-defined in encoder.h
	#endif
	#ifdef ENC3_SIGNAL
		// disable interrupts
		sbi(IMSK, INT3);	// ISMK is auto-defined in encoder.h
	#endif
}

// encoderGetPosition() reads the current position of the encoder 
s32 encoderGetPosition(u08 encoderNum)
{
	// sanity check
	if(encoderNum < NUM_ENCODERS)
		return EncoderState[encoderNum].position;
	else
		return 0;
}

// encoderSetPosition() sets the current position of the encoder
void encoderSetPosition(u08 encoderNum, s32 position)
{
	// sanity check
	if(encoderNum < NUM_ENCODERS)
		EncoderState[encoderNum].position = position;
	// else do nothing
}

#ifdef ENC0_SIGNAL
//! Encoder 0 interrupt handler
SIGNAL(ENC0_SIGNAL)
{
	// encoder has generated a pulse
	// check the relative phase of the input channels
	// and update position accordingly
	if( ((inb(ENC0_PHASEA_PORTIN) & (1<<ENC0_PHASEA_PIN)) == 0) ^
		((inb(ENC0_PHASEB_PORTIN) & (1<<ENC0_PHASEB_PIN)) == 0) )
	{
		EncoderState[0].position++;
	}
	else
	{
		EncoderState[0].position--;
	}
}
#endif

#ifdef ENC1_SIGNAL
//! Encoder 1 interrupt handler
SIGNAL(ENC1_SIGNAL)
{
	// encoder has generated a pulse
	// check the relative phase of the input channels
	// and update position accordingly
	if( ((inb(ENC1_PHASEA_PORTIN) & (1<<ENC1_PHASEA_PIN)) == 0) ^
		((inb(ENC1_PHASEB_PORTIN) & (1<<ENC1_PHASEB_PIN)) == 0) )
	{
		EncoderState[1].position++;
	}
	else
	{
		EncoderState[1].position--;
	}
}
#endif

#ifdef ENC2_SIGNAL
//! Encoder 2 interrupt handler
SIGNAL(ENC2_SIGNAL)
{
	// encoder has generated a pulse
	// check the relative phase of the input channels
	// and update position accordingly
	if( ((inb(ENC2_PHASEA_PORTIN) & (1<<ENC2_PHASEA_PIN)) == 0) ^
		((inb(ENC2_PHASEB_PORTIN) & (1<<ENC2_PHASEB_PIN)) == 0) )
	{
		EncoderState[2].position++;
	}
	else
	{
		EncoderState[2].position--;
	}
}
#endif

#ifdef ENC3_SIGNAL
//! Encoder 3 interrupt handler
SIGNAL(ENC3_SIGNAL)
{
	// encoder has generated a pulse
	// check the relative phase of the input channels
	// and update position accordingly
	if( ((inb(ENC3_PHASEA_PORTIN) & (1<<ENC3_PHASEA_PIN)) == 0) ^
		((inb(ENC3_PHASEB_PORTIN) & (1<<ENC3_PHASEB_PIN)) == 0) )
	{
		EncoderState[3].position++;
	}
	else
	{
		EncoderState[3].position--;
	}
}
#endif

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲国产成人av网| 一区二区三区四区激情| 欧美成人综合网站| 欧美一级夜夜爽| 91.com视频| 久久久噜噜噜久久中文字幕色伊伊| 91精品国产高清一区二区三区蜜臀| 欧美人妇做爰xxxⅹ性高电影| 欧美在线一区二区| 欧美一区二区三区视频免费| 欧美一区二区福利在线| 精品国产免费一区二区三区四区| 精品捆绑美女sm三区| 久久久精品国产免大香伊| 亚洲人成伊人成综合网小说| 一区二区三区**美女毛片| 亚洲狼人国产精品| 性欧美大战久久久久久久久| 狠狠狠色丁香婷婷综合激情| 成人一级片网址| 91老师片黄在线观看| 精品久久一区二区三区| 亚洲色图欧美偷拍| 日韩av在线播放中文字幕| 国产美女一区二区| 在线观看一区二区视频| 精品福利视频一区二区三区| 一区二区三区在线看| 狠狠色2019综合网| 欧美片网站yy| 亚洲美女屁股眼交| 成人av资源网站| 精品处破学生在线二十三| 午夜亚洲福利老司机| 成人一区二区三区视频| 精品嫩草影院久久| 日韩1区2区3区| 欧美日韩国产成人在线免费| 亚洲男人的天堂av| 成人福利在线看| 国产偷v国产偷v亚洲高清| 久久精品国产成人一区二区三区| 欧美一级精品在线| 国产欧美精品在线观看| 国产在线精品一区在线观看麻豆| 欧美精选一区二区| 偷拍与自拍一区| 欧美一级欧美三级| 日本va欧美va精品| 久久免费美女视频| 国产成人在线视频网站| 欧美国产激情二区三区| 91丨porny丨在线| 一级中文字幕一区二区| 555夜色666亚洲国产免| 久草精品在线观看| 中文字幕国产一区二区| 日本丶国产丶欧美色综合| 青青草97国产精品免费观看 | 91麻豆精品国产91久久久资源速度 | 精品国产亚洲在线| 成a人片国产精品| 一级特黄大欧美久久久| 欧美成人精品3d动漫h| 9人人澡人人爽人人精品| 偷偷要91色婷婷| 亚洲少妇最新在线视频| 精品久久久久99| 99v久久综合狠狠综合久久| 久久麻豆一区二区| 欧美在线观看视频一区二区| 一区二区三区蜜桃网| 久久伊人中文字幕| 欧美日韩国产小视频在线观看| 丰满亚洲少妇av| 久久电影国产免费久久电影 | 免费看欧美女人艹b| 一区二区三区不卡视频 | 极品少妇一区二区三区精品视频| 亚洲天天做日日做天天谢日日欢| 精品奇米国产一区二区三区| 欧美性生交片4| 欧美天堂亚洲电影院在线播放| 丁香六月综合激情| 国产69精品久久久久毛片| 麻豆精品一区二区三区| 午夜精品久久久久久久久久| 国产亚洲精品超碰| 久久免费视频一区| 欧美精品一区二区三区很污很色的| 欧美日韩在线播| 在线观看91精品国产入口| 99久久久无码国产精品| 成人一级片在线观看| 大尺度一区二区| 在线精品视频一区二区三四| 欧美视频在线一区| 日韩欧美国产综合一区| 久久久综合激的五月天| 国产精品蜜臀av| 亚洲美女屁股眼交| 日本美女视频一区二区| 国产乱国产乱300精品| 国产精品538一区二区在线| 高清久久久久久| 欧美视频中文字幕| 久久亚洲私人国产精品va媚药| 国产精品成人网| 日韩激情视频在线观看| 国内精品国产成人| 色婷婷亚洲精品| 久久亚洲欧美国产精品乐播| 亚洲精品老司机| 韩国一区二区三区| 欧美日韩久久久| 国产精品美女一区二区| 日本欧美肥老太交大片| 91丨九色丨蝌蚪富婆spa| 日韩免费看的电影| 亚洲一区二区偷拍精品| 国产成人精品影院| 这里只有精品99re| 亚洲第一成年网| a亚洲天堂av| 日本一区免费视频| 国产专区综合网| 欧美xxxxx牲另类人与| 亚洲h精品动漫在线观看| 91麻豆免费观看| 久久精品综合网| 九九**精品视频免费播放| 欧美一区二区三区男人的天堂| 一区二区三区国产豹纹内裤在线| 国产91丝袜在线18| 国产午夜一区二区三区| 风间由美中文字幕在线看视频国产欧美| 日韩视频在线你懂得| 精品在线观看视频| 久久日韩精品一区二区五区| 国产一区二区三区在线观看免费| 欧美大肚乱孕交hd孕妇| 久久99国产精品久久99果冻传媒| 日韩欧美在线影院| 国产最新精品免费| 中文字幕永久在线不卡| 欧美日韩一本到| 久久99精品国产| 亚洲日本va午夜在线电影| 欧美午夜在线一二页| 九色综合狠狠综合久久| 中文字幕一区二区三区在线观看| 9久草视频在线视频精品| 亚洲成人动漫在线免费观看| 欧美高清视频在线高清观看mv色露露十八| 日韩精品成人一区二区在线| 久久在线观看免费| 欧美体内she精视频| 国产一区二区0| 亚洲成人自拍网| 中文字幕不卡在线| 91精品国产91久久久久久最新毛片| 国产一区二区三区免费观看| 亚洲图片另类小说| 久久综合久久综合久久综合| 欧美自拍丝袜亚洲| av电影在线观看一区| 韩国三级电影一区二区| 亚洲一区二区三区在线播放| 久久蜜臀中文字幕| 2020国产精品自拍| 日韩一级大片在线观看| 91精品国产91久久综合桃花| 欧美日韩一级黄| 欧美视频在线一区| 国产一区美女在线| 日韩一区二区三区在线视频| 国产一区二区三区蝌蚪| 亚洲在线中文字幕| 亚洲女性喷水在线观看一区| 国产精品成人在线观看| 成人欧美一区二区三区白人| 国产精品毛片a∨一区二区三区| 久久婷婷一区二区三区| 国产亚洲欧美一区在线观看| 久久综合久久综合久久综合| 久久嫩草精品久久久精品| 国产视频一区在线播放| 亚洲国产电影在线观看| 亚洲欧美综合在线精品| 亚洲一区二区三区在线| 亚洲成av人片www| 精品在线播放免费| 成人永久aaa| 3d动漫精品啪啪一区二区竹菊| 日韩一区二区三区在线观看| 国产欧美一区二区精品秋霞影院 | 亚洲综合av网| 老汉av免费一区二区三区| 国产aⅴ精品一区二区三区色成熟| 成人18精品视频|