⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vectors.c

📁 老外开发的机器人的底层单片机代码。比较有参考价值哦!
💻 C
字号:
//  Interrupt Vectors   vectors.c					// Rev 4/30/05

//Copyright (C) 2005 Alex Brown	rbirac@cox.net
//This program is free software; See license at the end of this file for details.

/*
 Set up to handle:
   	   RealTime interrupt
	   three encoder inputs
	   dual axis accelerometer
	   I2C
*/

#pragma nonpaged_function _start

extern void _start(void);			 // entry point in crt??.s 
extern void rti_handler(void); 	 	 //real time interrupt handler
extern void PORTP_handler(void);	 //encoder 0 handler
extern void PORTH_handler(void);	 //encoder 1 handler
extern void IRQ_handler(void);		 //encoder 2 handler
extern void PORTJ_handler(void);	 //dual axis accelerometer handler
extern void I2C_handler(void);		 //reads compass 
#define DUMMY_ENTRY	(void (*)(void))0xFFFF

#pragma abs_address:0xEF80 
		// EF80 is pseudo vector address
		// change the above address if your vector table starts elsewhere

void (*interrupt_vectors[])(void) = 
	{
	/* to cast a constant, say 0xb600, use
	   (void (*)())0xb600
	   to vector to a function, e.g. main(),
	     add above: extern void main(void);
		 replace DUMMY_ENTRY with   (void (*)()) main
	 */
	DUMMY_ENTRY, /*Reserved $FF80*/
	DUMMY_ENTRY, /*Reserved $FF82*/
	DUMMY_ENTRY, /*Reserved $FF84*/
	DUMMY_ENTRY, /*Reserved $FF86*/
	DUMMY_ENTRY, /*Reserved $FF88*/
	DUMMY_ENTRY, /*Reserved $FF8A*/
	DUMMY_ENTRY, /*PWM Emergency Shutdown*/
	(void (*)())PORTP_handler, /*Port P Interrupt   encoder 0 */
	DUMMY_ENTRY, /*MSCAN 4 Transmit*/
	DUMMY_ENTRY, /*MSCAN 4 Receive*/
	DUMMY_ENTRY, /*MSCAN 4 Error*/
	DUMMY_ENTRY, /*MSCAN 4 Wake-up*/
	DUMMY_ENTRY, /*MSCAN 3 Transmit*/
	DUMMY_ENTRY, /*MSCAN 3 Receive*/
	DUMMY_ENTRY, /*MSCAN 3 Error*/
	DUMMY_ENTRY, /*MSCAN 3 Wake-up*/
	DUMMY_ENTRY, /*MSCAN 2 Transmit*/
	DUMMY_ENTRY, /*MSCAN 2 Receive*/
	DUMMY_ENTRY, /*MSCAN 2 Error*/
	DUMMY_ENTRY, /*MSCAN 2 Wake-up*/
	DUMMY_ENTRY, /*MSCAN 1 Transmit*/
	DUMMY_ENTRY, /*MSCAN 1 Receive*/
	DUMMY_ENTRY, /*MSCAN 1 Error*/
	DUMMY_ENTRY, /*MSCAN 1 Wake-up*/
	DUMMY_ENTRY, /*MSCAN 0 Transmit*/
	DUMMY_ENTRY, /*MSCAN 0 Receive*/
	DUMMY_ENTRY, /*MSCAN 0 Error*/
	DUMMY_ENTRY, /*MSCAN 0 Wake-up*/
	DUMMY_ENTRY, /*Flash*/
	DUMMY_ENTRY, /*EEPROM*/
	DUMMY_ENTRY, /*SPI2*/
	DUMMY_ENTRY, /*SPI1*/
	(void (*)())I2C_handler, /*IIC Bus*/
	DUMMY_ENTRY, /*DLC*/
	DUMMY_ENTRY, /*SCME*/
	DUMMY_ENTRY, /*CRG Lock*/
	DUMMY_ENTRY, /*Pulse Accumulator B Overflow*/
	DUMMY_ENTRY, /*Modulus Down Counter Underflow*/
	(void (*)())PORTH_handler, /*Port H Interrupt   encoder 1 */
	(void (*)())PORTJ_handler, /*Port J Interrupt  accelerometer */
	DUMMY_ENTRY, /*ATD1*/
	DUMMY_ENTRY, /*ATD0*/
	DUMMY_ENTRY, /*SCI1*/
	DUMMY_ENTRY, /*SCI0*/
	DUMMY_ENTRY, /*SPI0*/
	DUMMY_ENTRY, /*Pulse Accumulator A Input Edge*/
	DUMMY_ENTRY, /*Pulse Accumulator A Overflow*/
	DUMMY_ENTRY, /*Timer Overflow*/
	DUMMY_ENTRY, /*Timer Channel 7*/
	DUMMY_ENTRY, /*Timer Channel 6*/
	DUMMY_ENTRY, /*Timer Channel 5*/
	DUMMY_ENTRY, /*Timer Channel 4*/
	DUMMY_ENTRY, /*Timer Channel 3*/
	DUMMY_ENTRY, /*Timer Channel 2*/
	DUMMY_ENTRY, /*Timer Channel 1*/
	DUMMY_ENTRY, /*Timer Channel 0*/
	(void (*)()) rti_handler, 		/*Real Time Interrupt*/
	(void (*)()) IRQ_handler, /*IRQ   Encoder 2*/
	DUMMY_ENTRY, /*XIRQ*/
	DUMMY_ENTRY, /*SWI*/
	DUMMY_ENTRY, /*Unimplement Intruction Trap*/
	DUMMY_ENTRY, /*COP failure reset*/
	DUMMY_ENTRY, /*Clock monitor fail reset*/
	_start, /*Reset*/
	};

//  OPEN SOURCE SOFTWARE LICENSE
/* Permission is hereby granted, free of charge, to any person obtaining a copy 
of this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to use, 
copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the 
Software, and to permit persons to whom the Software is furnished to do so, 
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all 
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ 	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -