-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasico.h
102 lines (80 loc) · 3.89 KB
/
basico.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// -----------------------------------------------------------------------
// Copyright (C) Rodrigo Almeida 2014
// -----------------------------------------------------------------------
// Arquivo: basico.h
// Header com defines para bit-functions e registros dos
// microcontroladores PIC18F4550 e PIC18F4520
// Autor: Rodrigo Maximiano Antunes de Almeida
// rodrigomax at unifei.edu.br
// Licensa: GNU GPL 2
// -----------------------------------------------------------------------
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 2 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// -----------------------------------------------------------------------
//#ifndef PIC18F4550
// #define PIC18F4550
//#endif
#ifndef PIC18F4520
#define PIC18F4520
#endif
//funções de bit
#define BitSet(arg,bit) ((arg) |= (1<<bit))
#define BitClr(arg,bit) ((arg) &= ~(1<<bit))
#define BitFlp(arg,bit) ((arg) ^= (1<<bit))
#define BitTst(arg,bit) ((arg) & (1<<bit))
//defines para registros especiais
#define PORTA (*(volatile __near unsigned char*)0xF80)
#define PORTB (*(volatile __near unsigned char*)0xF81)
#define PORTC (*(volatile __near unsigned char*)0xF82)
#define PORTD (*(volatile __near unsigned char*)0xF83)
#define PORTE (*(volatile __near unsigned char*)0xF84)
#define TRISA (*(volatile __near unsigned char*)0xF92)
#define TRISB (*(volatile __near unsigned char*)0xF93)
#define TRISC (*(volatile __near unsigned char*)0xF94)
#define TRISD (*(volatile __near unsigned char*)0xF95)
#define TRISE (*(volatile __near unsigned char*)0xF96)
#define INTCON (*(volatile __near unsigned char*)0xFF2)
#define INTCON2 (*(volatile __near unsigned char*)0xFF1)
#define PIE1 (*(volatile __near unsigned char*)0xF9D)
#define PIR1 (*(volatile __near unsigned char*)0xF9E)
#define PIR2 (*(volatile __near unsigned char*)0xFA1)
#define TMR0L (*(volatile __near unsigned char*)0xFD6)
#define TMR0H (*(volatile __near unsigned char*)0xFD7)
#define T0CON (*(volatile __near unsigned char*)0xFD5)
#ifdef PIC18F4550
#define SPPCON (*(volatile __near unsigned char*)0xF65)
#define SPPCFG (*(volatile __near unsigned char*)0xF63)
#endif
#define ADCON2 (*(volatile __near unsigned char*)0xFC0)
#define ADCON1 (*(volatile __near unsigned char*)0xFC1)
#define ADCON0 (*(volatile __near unsigned char*)0xFC2)
#define ADRESL (*(volatile __near unsigned char*)0xFC3)
#define ADRESH (*(volatile __near unsigned char*)0xFC4)
#define RCSTA (*(volatile __near unsigned char*)0xFAB)
#define TXSTA (*(volatile __near unsigned char*)0xFAC)
#define TXREG (*(volatile __near unsigned char*)0xFAD)
#define RCREG (*(volatile __near unsigned char*)0xFAE)
#define SPBRG (*(volatile __near unsigned char*)0xFAF)
#define SPBRGH (*(volatile __near unsigned char*)0xFB0)
#define BAUDCON (*(volatile __near unsigned char*)0xFB8)
#define RCON (*(volatile __near unsigned char*)0xFD0)
#define WDTCON (*(volatile __near unsigned char*)0xFD1)
#define T2CON (*(volatile __near unsigned char*)0xFCA)
#define PR2 (*(volatile __near unsigned char*)0xFCB)
#define CCP2CON (*(volatile __near unsigned char*)0xFBA)
#define CCPR2L (*(volatile __near unsigned char*)0xFBB)
#define CCP1CON (*(volatile __near unsigned char*)0xFBD)
#define CCPR1L (*(volatile __near unsigned char*)0xFBE)
#ifdef PIC18F4520
#define SSPCON2 (*(volatile __near unsigned char*)0xFC5)
#define SSPCON1 (*(volatile __near unsigned char*)0xFC6)
#define SSPSTAT (*(volatile __near unsigned char*)0xFC7)
#define SSPAD (*(volatile __near unsigned char*)0xFC8)
#define SSPBUF (*(volatile __near unsigned char*) 0xFC9)
#endif