📄 main.h
字号:
//****************************************************************************************
//****************************************************************************************
// Project Name: MMC / SD CARD FAT16 & FAT 32 DRIVER
// GENERIC GLOBAL HEADER FILE
// Copyright: EMBEDDED-CODE.COM
//
// Licenced To: NONE
// Licence Number: NONE
//
// IMPORTANT: These files are copyright of embedded-code.com and are subject to a licence
// agreement. All rights reserved. Unauthorised use, reproduction or distribution of
// these files may lead to prosecution.
// Any use in violation of the licence restrictions may subject the user to criminal
// sanctions under applicable laws, as well as to civil liability for the breach of the
// terms and conditions of the license.
// This software is provided in an "as is" condition. No warranties, whether express,
// implied or statutory, including, but not limited to, implied warranties of
// merchantability and fitness for a particular purpose apply to this software.
// Embedded-code.com shall not be liable in any circumstances for special, incidental
// or consequential damages, for any reason whatsoever.
// Please see 'www.embedded-code.com\licence' or email 'licence@embedded-code.com' for
// full details.
// This file contains hidden markers to identify it uniquely to the licence number it was
// purchased under.
// DO NOT REMOVE THIS NOTICE - IT IS A REQUIREMENT OF THE LICENCE AGREEMENT.
//****************************************************************************************
//****************************************************************************************
//**********************************************
//**********************************************
//********** SAMPLE PROJECT REVISIONS **********
//**********************************************
//**********************************************
//
//V1.02
//- First released version.
//
//V1.03
//- Corrected RB3 pin TRIS definition from an input to an output (LED2 pin).
//
//V1.04
//- No changes to sample project
//
//V1.05
//- No changes to sample project
//
//V1.06
//- No changes to sample project
//******************************************
//******************************************
//********** PROJECT GLOBAL FLAGS **********
//******************************************
//******************************************
//#define IN_DEVELOPMENT_MODE //Include if we are debugging, comment out if we are building code for release (this define used in the source code if desired)
#define USING_3V3_POWER //Include if the target circuit is 3.3V rather than 5V (used by the configuration defines to select the relevant brown out reset voltage)
//*************************************
//*************************************
//********** GENERAL DEFINES **********
//*************************************
//*************************************
//INCLUDE THE DEVICE HEADER FILE
#include <p18f452.h>
//----------------------
//----- OSCILLATOR ----- //<<<<< CHECK FOR A NEW APPLICATION <<<<<
//----------------------
//10MHz Osc
//= 10MHz instruction clock with 4xPLL
//= 100nS per instruction
#define INSTRUCTION_CLOCK_FREQUENCY 6000000
//----------------------
//----- INTERRUPTS -----
//----------------------
#define ENABLE_INT INTCONbits.GIE = 1 //Enable all unmasket interupts
#define DISABLE_INT INTCONbits.GIE = 0 //Disable all unmasket interupts
//****************************************
//****************************************
//***** GLOBAL DATA TYPE DEFINITIONS *****
//****************************************
//****************************************
#ifndef GLOBAL_DATA_TYPE_INIT //(Include this section only once for each source file)
#define GLOBAL_DATA_TYPE_INIT
#undef BOOL
#undef TRUE
#undef FALSE
#undef BYTE
#undef SIGNED_BYTE
#undef WORD
#undef SIGNED_WORD
#undef DWORD
#undef SIGNED_DWORD
//BOOLEAN - 1 bit:
typedef enum _BOOL { FALSE = 0, TRUE } BOOL;
//BYTE - 8 bit unsigned:
typedef unsigned char BYTE;
//SIGNED_BYTE - 8 bit signed:
typedef signed char SIGNED_BYTE;
//WORD - 16 bit unsigned:
typedef unsigned int WORD;
//SIGNED_WORD - 16 bit signed:
typedef signed int SIGNED_WORD;
//DWORD - 32 bit unsigned:
typedef unsigned long DWORD;
//SIGNED_DWORD - 32 bit signed:
typedef signed long SIGNED_DWORD;
//BYTE BIT ACCESS:
typedef union _BYTE_VAL
{
struct
{
unsigned int b0:1;
unsigned int b1:1;
unsigned int b2:1;
unsigned int b3:1;
unsigned int b4:1;
unsigned int b5:1;
unsigned int b6:1;
unsigned int b7:1;
} bits;
BYTE Val;
} BYTE_VAL;
//WORD ACCESS
typedef union _WORD_VAL
{
WORD val;
struct
{
BYTE LSB;
BYTE MSB;
} byte;
BYTE v[2];
} WORD_VAL;
#define LSB(a) ((a).v[0])
#define MSB(a) ((a).v[1])
//DWORD ACCESS:
typedef union _DWORD_VAL
{
DWORD val;
struct
{
BYTE LOLSB;
BYTE LOMSB;
BYTE HILSB;
BYTE HIMSB;
} byte;
struct
{
WORD LSW;
WORD MSW;
} word;
BYTE v[4];
} DWORD_VAL;
#define LOWER_LSB(a) ((a).v[0])
#define LOWER_MSB(a) ((a).v[1])
#define UPPER_LSB(a) ((a).v[2])
#define UPPER_MSB(a) ((a).v[3])
//EXAMPLE OF HOW TO USE THE DATA TYPES:-
// WORD_VAL variable_name; //Define the variable
// variable_name = 0xffffffff; //Writing 32 bit value
// variable_name.LSW = 0xffff; //Writing 16 bit value to the lower word
// variable_name.LOLSB = 0xff; //Writing 8 bit value to the low word least significant byte
// variable_name.v[0] = 0xff; //Writing 8 bit value to byte 0 (least significant byte)
#endif //GLOBAL_DATA_TYPE_INIT
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -