|
/********************* (C) COPYRIGHT Wind Snow Team ****************************
* File Name : clock.h
* Author : Wind snow Li.
* Version : V1.0
* Date : 2011-1-13
* Description : The header file contains some clock macroinstruction.
********************************************************************************
*
*
*
*
*
*******************************************************************************/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __CLOCK__H__
#define __CLOCK__H__
/* Includes ------------------------------------------------------------------*/
#include "data_typedef.h"
/* The following header files related to specific hardware MCU -------------- */
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* 定义时钟的频率, 确定此项目中, MCLK的频率. */
#define SYSTEM_CLOCK 8000000
/* Flash模块操作频率 */
#define FLASH_FREQ ( (u8)((( f32 )SYSTEM_CLOCK ) /350000 + 0.5 ) & 0x3F )
/* 利用本征函数来定义软件延时, 会降低移植性, 但是时间很准确, 且非常简单 */
/*延时uS*/
#define DELAY_uS(x) __delay_cycles((u32)((f32)SYSTEM_CLOCK / 1000000 * (x)))
/*延时mS*/
#define DELAY_mS(x) __delay_cycles((u32)((f32)SYSTEM_CLOCK / 1000 * (x)))
/*延时S*/
#define DELAY_S(x) __delay_cycles((u32)((f32)SYSTEM_CLOCK * (x)))
/* Exported functions ------------------------------------------------------- */
/* ------------------ High layer function ----------------------------------- */
/* ------------------ Low layer function ----------------------------------- */
#endif /* __CLOCK__H__ */
/******************* (C) COPYRIGHT Wind Snow Team ************* END OF FILE ***/
/********************* (C) COPYRIGHT Wind Snow Team ****************************
* File Name : data_typedef.h
* Author : Wind snow Li.
* Version : V1.0
* Date : 2011-1-12 09:28
* Description : This file contains all the common data types.
********************************************************************************
*
* This file contains all the common data types.
* Try to use these to redefine the type, in order to make all the files style
* tends the unification.
*
*******************************************************************************/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __DATA__TYPE__DEF__H__
#define __DATA__TYPE__DEF__H__
/* Includes ------------------------------------------------------------------*/
/* Exported types ------------------------------------------------------------*/
typedef signed long s32;
typedef signed int s16;
typedef signed char s8;
typedef volatile signed long vs32;
typedef volatile signed int vs16;
typedef volatile signed char vs8;
typedef unsigned long u32;
typedef unsigned int u16;
typedef unsigned char u8;
typedef unsigned long const uc32; /* Read Only */
typedef unsigned int const uc16; /* Read Only */
typedef unsigned char const uc8; /* Read Only */
typedef volatile unsigned long vu32;
typedef volatile unsigned int vu16;
typedef volatile unsigned char vu8;
typedef volatile unsigned long const vuc32; /* Read Only */
typedef volatile unsigned int const vuc16; /* Read Only */
typedef volatile unsigned char const vuc8; /* Read Only */
#ifndef BOOL
typedef enum {FALSE = 0, TRUE = !FALSE} BOOL;
#endif
typedef enum {RESET = 0, SET = !RESET} FlagStatus, ITStatus;
typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState;
typedef enum {ERROR = 0, SUCCESS = !ERROR} ErrorStatus;
typedef float f32;
typedef double d64;
typedef volatile BOOL vb;
#define U8_MAX ( ( u8 ) 255 )
#define S8_MAX ( ( s8 ) 127 )
#define S8_MIN ( ( s8 ) -128 )
#define U16_MAX ( ( u16 ) 65535u )
#define S16_MAX ( ( s16 ) 32767 )
#define S16_MIN ( ( s16 ) -32768 )
#define U32_MAX ( ( u32 ) 4294967295uL )
#define S32_MAX ( ( s32 ) 2147483647 )
#define S32_MIN ( ( s32 ) 2147483648uL )
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
/* ------------------ High layer function ----------------------------------- */
/* ------------------ Low layer function ----------------------------------- */
#endif /* __DATA__TYPE__DEF__H__ */
/******************* (C) COPYRIGHT Wind Snow Team ************* END OF FILE ***/
/********************* (C) COPYRIGHT Wind Snow Team ****************************
* File Name : header_file.h
* Author : Wind snow Li.
* Version : V1.0
* Date : 2011-1-18
* Description : The file automatic contains specific MCU header file.
********************************************************************************
*
*
*
*
*
*******************************************************************************/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __HEADER__FILE__H__
#define __HEADER__FILE__H__
/* Includes ------------------------------------------------------------------*/
/* msp430x1xx family */
#if defined (__MSP430C111__) || defined (__MSP430C112__) \
|| defined (__MSP430E112__) || defined (__MSP430F110__) \
|| defined (__MSP430F112__)
#include "MSP430x11x.h"
#elif defined (__MSP430C1111__) || defined (__MSP430C1121__) \
|| defined (__MSP430F1101__) || defined (__MSP430F1101A__) \
|| defined (__MSP430F1111__) || defined (__MSP430F1111A__) \
|| defined (__MSP430F1121__) || defined (__MSP430F1121A__)
#include "MSP430x11x1.h"
#elif defined (__MSP430F1122__) || defined (__MSP430F1132__)
#include "MSP430x11x2.h"
#elif defined (__MSP430F1222__) || defined (__MSP430F1232__)
#include "MSP430x12x2.h"
#elif defined (__MSP430C1331__) || defined (__MSP430C1351__)
#include "MSP430x13x1.h"
#elif defined (__MSP430F133__) || defined (__MSP430F135__)
#include "MSP430x13x.h"
#elif defined (__MSP430F133__) || defined (__MSP430F135__)
#include "MSP430x13x.h"
#elif defined (__MSP430F1471__) || defined (__MSP430F1481__) \
|| defined (__MSP430F1491__)
#include "MSP430x14x1.h"
#elif defined (__MSP430F147__) || defined (__MSP430F148__) \
|| defined(__MSP430F149__)
#include "MSP430x14x.h"
#elif defined (__MSP430F155__) || defined (__MSP430F156__) \
|| defined(__MSP430F157__)
#include "MSP430x15x.h"
#elif defined (__MSP430F167__) || defined (__MSP430F168__) \
|| defined(__MSP430F169__)
#include "MSP430x16x.h"
/* msp430x2xx family */
#elif defined (__MSP430F2001__) || defined (__MSP430F2011__)
#include "MSP430x20x1.h"
#elif defined (__MSP430F2002__) || defined (__MSP430F2012__)
#include "MSP430x20x2.h"
#elif defined (__MSP430F2003__) || defined (__MSP430F2013__)
#include "MSP430x20x3.h"
#elif defined (__MSP430F2101__) || defined (__MSP430F2111__) \
|| defined (__MSP430F2121__) || defined (__MSP430F2131__)
#include "MSP430x21x1.h"
#elif defined (__MSP430F2102__) || defined (__MSP430F2112__) \
|| defined (__MSP430F2122__) || defined (__MSP430F2132__)
#include "msp430x21x2.h"
#elif defined (__MSP430F2232__) || defined (__MSP430F2252__) \
|| defined (__MSP430F2272__)
#include "MSP430x22x2.h"
#elif defined (__MSP430F2234__) || defined (__MSP430F2354__) \
|| defined (__MSP430F2274__)
#include "MSP430x22x4.h"
#elif defined (__MSP430F2330__) || defined (__MSP430F2350__) \
|| defined (__MSP430F2370__)
#include "MSP430x23x0.h"
/* msp430x4xx family */
#elif defined (__MSP430C412__) || defined (__MSP430C413__)
#include "MSP430x41x.h"
#elif defined(__MSP430F412__) || defined(__MSP430F413__)
#include "MSP430x41x.h"
#elif defined (__MSP430F415__)
#include "MSP430x415.h"
#elif defined (__MSP430F417__)
#include "MSP430x417.h"
#elif defined (__MSP430F4250__) || defined (__MSP430F4260__) \
|| defined(__MSP430F4270__)
#include "MSP430x42x0.h"
#elif defined (__MSP430F423__) || defined (__MSP430F425__) \
|| defined(__MSP430F427__) || defined (__MSP430W423__) \
|| defined (__MSP430W425__) || defined(__MSP430W427__)
#include "MSP430x42x.h"
#elif defined (__MSP430FE423__) || defined (__MSP430FE425__) \
|| defined(__MSP430FE427__)
#include "MSP430xE42x.h"
#elif defined (__MSP430W423__) || defined (__MSP430W425__) \
|| defined(__MSP430W427__)
#include "MSP430xW42x.h"
#elif defined (__MSP430F435__) || defined (__MSP430F436__) \
|| defined(__MSP430F437__) || defined (__MSP430G437__) \
|| defined (__MSP430G438__) || defined(__MSP430G439__)
#include "MSP430x43x.h"
#elif defined (__MSP430G437__) || defined (__MSP430G438__) \
|| defined(__MSP430G439__)
#include "MSP430xG43x.h"
#elif defined (__MSP430F447__) || defined (__MSP430F448__) \
|| defined(__MSP430F449__)
#include "MSP430x44x.h"
#elif defined (__MSP430FG4616__) || defined (__MSP430FG4617__) \
|| defined(__MSP430FG4618__) || defined(__MSP430FG4619__)
#include "MSP430xG46x.h"
#else
#error "无法找到确切的头文件,重新核实"
#endif
/* The following header files related to specific hardware MCU -------------- */
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
/* ------------------ High layer function ----------------------------------- */
/* ------------------ Low layer function ----------------------------------- */
#endif /* __H__ */
/******************* (C) COPYRIGHT Wind Snow Team ************* END OF FILE ***/
/********************* (C) COPYRIGHT Wind Snow Team ****************************
* File Name : IOport.h
* Author : Wind snow Li.
* Version : V1.0
* Date : 2011-1-18
* Description : The header file contains some IO port macroinstruction.
********************************************************************************
*
*
*
*
*
*******************************************************************************/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __IO__PORT__H__
#define __IO__PORT__H__
/* Includes ------------------------------------------------------------------*/
/* The following header files related to specific hardware MCU -------------- */
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
#define _ADD_STR(a, b) a##b
#define ADD_STR(a, b) _ADD_STR(a, b)
/* PxIN */
#define _IO_PORT_IN(PORT) (PORT##IN)
#define GPIO_READ_BITS(PORT, BIT) ( (_IO_PORT_IN(PORT) & BIT) ? (SET):(RESET))
#define GOIO_READ_PORTS(PORT) ( _IO_PORT_IN(PORT) )
/* PxOUT */
#define _IO_PORT_OUT(PORT) (PORT##OUT)
#define GPIO_SET_BITS(PORT, BIT) ( ( _IO_PORT_OUT(PORT) ) |= (BIT) )
#define GPIO_RESET_BITS(PORT, BIT) ( ( _IO_PORT_OUT(PORT) ) &= ~(BIT) )
/* PxDIR */
#define _IO_PORT_DIR(PORT) (PORT##DIR)
#define GPIO_OUTPUT_DIR(PORT, BIT) ( ( _IO_PORT_DIR(PORT) ) |= (BIT) )
#define GPIO_INPUT_DIR(PORT, BIT) ( ( _IO_PORT_DIR(PORT) ) &= ~(BIT) )
/* PxIE */
#define _IO_PORT_IE(PORT) (PORT##IE)
#define GPIO_ENABLE_IRQ(PORT, BIT) ( ( _IO_PORT_IE(PORT) ) |= (BIT) )
#define GPIO_DISABLE_IRQ(PORT, BIT) ( ( _IO_PORT_IE(PORT) ) &= ~(BIT) )
/* PxSEL */
#define _IO_PORT_SEL(PORT) (PORT##SEL)
#define GPIO_PORT_FUNC(PORT, BIT) ( ( _IO_PORT_SEL(PORT) ) |= (BIT) )
#define GPIO_MULTI_FUNC(PORT, BIT) ( ( _IO_PORT_SEL(PORT) ) &= ~(BIT) )
/* Exported functions ------------------------------------------------------- */
/* ------------------ High layer function ----------------------------------- */
#define TEST_BIT(x) ( GPIO_READ_BITS( ADD_STR(x, _PORT), ADD_STR(x, _BIT) ) )
#define SET_BIT(x) ( GPIO_SET_BITS( ADD_STR(x, _PORT), ADD_STR(x, _BIT) ) )
#define CLR_BIT(x) ( GPIO_RESET_BITS( ADD_STR(x, _PORT), ADD_STR(x, _BIT) ) )
#define BIT_OUT(x) ( GPIO_OUTPUT_DIR( ADD_STR(x, _PORT), ADD_STR(x, _BIT) ) )
#define BIT_IN(x) ( GPIO_INPUT_DIR( ADD_STR(x, _PORT), ADD_STR(x, _BIT) ) )
#define EINT_BIT(x) ( GPIO_ENABLE_IRQ( ADD_STR(x, _PORT), ADD_STR(x, _BIT) ) )
#define DINT_BIT(x) ( GPIO_DISABLE_IRQ( ADD_STR(x, _PORT), ADD_STR(x, _BIT) ) )
/* eg. */
/* #define HC165_SCLK_PORT P1 // 使用的是P1口 */
/* #define HC165_SCLK_BIT BIT5 // BIT5位 */
/* BIT_OUT( HC165_SCLK ); // 简单,形象 */
/* ------------------ Low layer function ----------------------------------- */
#endif /* __IO__PORT__H__ */
/******************* (C) COPYRIGHT Wind Snow Team ************* END OF FILE ***/
/********************* (C) COPYRIGHT Wind Snow Team ****************************
* File Name : macro_math.h
* Author : Wind snow Li.
* Version : V1.0
* Date : 2011-1-18
* Description : The header file contains some math macroinstruction.
********************************************************************************
*
*
*
*
*
*******************************************************************************/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MACRO__MATH__H__
#define __MACRO__MATH__H__
/* Includes ------------------------------------------------------------------*/
#include "data_typedef.h"
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/*得到指定地址上的一个字节*/
#define READ_U8( x ) ( *( (u8 *) (x) ) )
/*得到指定地址上的一个字*/
#define READ_U16( x ) (* ( (u16 *) (x) ) )
/*两个数的大者*/
#define MAX( x, y ) ( ((x) > (y)) ? (x) : (y) )
/*两个数的小者*/
#define MIN( x, y ) ( ((x) < (y)) ? (x) : (y) )
/* 求数组的个数 */
#define SIZE_OF_ARRAY(x) (sizeof( (x) ) / sizeof( (x[0]) ) )
/* 求一个数的绝对值 */
#define ABS(x) ( ((x) > 0) ? (x) : ( -(x) ) )
/* Exported functions ------------------------------------------------------- */
/* ------------------ High layer function ----------------------------------- */
/* ------------------ Low layer function ----------------------------------- */
#endif /* __MACRO__MATH__H__ */
/******************* (C) COPYRIGHT Wind Snow Team ************* END OF FILE ***/
点击此处下载 ourdev_617806GYFNB3.rar(文件大小:798字节) (原文件名:clock.rar)
点击此处下载 ourdev_617807TRQCPE.rar(文件大小:940字节) (原文件名:data_typedef.rar)
点击此处下载 ourdev_617808INGYST.rar(文件大小:1K) (原文件名:header_file.rar)
点击此处下载 ourdev_617809HXWWHS.rar(文件大小:925字节) (原文件名:IOport.rar)
点击此处下载 ourdev_617810KFK5I5.rar(文件大小:699字节) (原文件名:macro_math.rar) |
阿莫论坛20周年了!感谢大家的支持与爱护!!
你熬了10碗粥,别人一桶水倒进去,淘走90碗,剩下10碗给你,你看似没亏,其实你那10碗已经没有之前的裹腹了,人家的一桶水换90碗,继续卖。说白了,通货膨胀就是,你的钱是挣来的,他的钱是印来的,掺和在一起,你的钱就贬值了。
|