Updated the PIC18F6720 port, and added PIC18F97J60 port. Both compile and build but were untested on actual hardware.
This commit is contained in:
@@ -630,11 +630,11 @@ endif
|
||||
ifeq ($(TYPE_IMAGE), DEBUG_RUN)
|
||||
dist/${CND_CONF}/${IMAGE_TYPE}/BACnet-Server.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}: ${OBJECTFILES} nbproject/Makefile-${CND_CONF}.mk
|
||||
@${MKDIR} dist/${CND_CONF}/${IMAGE_TYPE}
|
||||
${MP_LD} $(MP_EXTRA_LD_PRE) "..\18F6720.lkr" -p$(MP_PROCESSOR_OPTION_LD) -w -x -u_DEBUG -z__MPLAB_BUILD=1 -u_CRUNTIME -z__MPLAB_DEBUG=1 -z__MPLAB_DEBUGGER_ICD3=1 $(MP_LINKER_DEBUG_OPTION) -l ${MP_CC_DIR}\\..\\lib -o dist/${CND_CONF}/${IMAGE_TYPE}/BACnet-Server.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX} ${OBJECTFILES_QUOTED_IF_SPACED}
|
||||
${MP_LD} $(MP_EXTRA_LD_PRE) -p$(MP_PROCESSOR_OPTION_LD) -w -x -u_DEBUG -z__MPLAB_BUILD=1 -u_CRUNTIME -z__MPLAB_DEBUG=1 -z__MPLAB_DEBUGGER_ICD3=1 $(MP_LINKER_DEBUG_OPTION) -l ${MP_CC_DIR}\\..\\lib -o dist/${CND_CONF}/${IMAGE_TYPE}/BACnet-Server.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX} ${OBJECTFILES_QUOTED_IF_SPACED}
|
||||
else
|
||||
dist/${CND_CONF}/${IMAGE_TYPE}/BACnet-Server.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}: ${OBJECTFILES} nbproject/Makefile-${CND_CONF}.mk
|
||||
@${MKDIR} dist/${CND_CONF}/${IMAGE_TYPE}
|
||||
${MP_LD} $(MP_EXTRA_LD_PRE) "..\18F6720.lkr" -p$(MP_PROCESSOR_OPTION_LD) -w -z__MPLAB_BUILD=1 -u_CRUNTIME -l ${MP_CC_DIR}\\..\\lib -o dist/${CND_CONF}/${IMAGE_TYPE}/BACnet-Server.X.${IMAGE_TYPE}.${DEBUGGABLE_SUFFIX} ${OBJECTFILES_QUOTED_IF_SPACED}
|
||||
${MP_LD} $(MP_EXTRA_LD_PRE) -p$(MP_PROCESSOR_OPTION_LD) -w -z__MPLAB_BUILD=1 -u_CRUNTIME -l ${MP_CC_DIR}\\..\\lib -o dist/${CND_CONF}/${IMAGE_TYPE}/BACnet-Server.X.${IMAGE_TYPE}.${DEBUGGABLE_SUFFIX} ${OBJECTFILES_QUOTED_IF_SPACED}
|
||||
endif
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
#Thu May 26 09:55:31 CDT 2016
|
||||
#Mon May 30 09:47:38 CDT 2016
|
||||
default.com-microchip-mplab-nbide-toolchainC18-C18LanguageToolchain.md5=21ae92f54c0f89bc027339aedc19b7f9
|
||||
default.languagetoolchain.dir=C\:\\Program Files (x86)\\Microchip\\mplabc18\\v3.40\\bin
|
||||
com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=ef199adcc8f049579a105cca20571dcb
|
||||
|
||||
@@ -23,11 +23,11 @@
|
||||
<itemPath>../../../include/bacstr.h</itemPath>
|
||||
<itemPath>../../../include/bigend.h</itemPath>
|
||||
<itemPath>../../../include/config.h</itemPath>
|
||||
<itemPath>../hardware.h</itemPath>
|
||||
</logicalFolder>
|
||||
<logicalFolder name="LinkerScript"
|
||||
displayName="Linker Files"
|
||||
projectFiles="true">
|
||||
<itemPath>../18F6720.lkr</itemPath>
|
||||
</logicalFolder>
|
||||
<logicalFolder name="SourceFiles"
|
||||
displayName="Source Files"
|
||||
|
||||
@@ -29,175 +29,11 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/* PORTA.0 Photocell Input PORTA.1 LED Row6 PORTA.2 LED Row5 PORTA.3 LED
|
||||
* Row4 PORTA.4 Square Wave input from RTC PORTA.5 LCD RW PORTB.0 Zero
|
||||
* Cross PORTB.1 USB RXF# PORTB.2 USB TXE# PORTB.3 Keypad Row Enable
|
||||
* (74HC373 Output Control) PORTB.4 Keypad Row Gate (74HC373 Gate)
|
||||
* PORTB.5 Switch Input Latch & Keypad Column Gate (74HC373 Gate) PORTB.6
|
||||
* ICD connection PORTB.7 ICD connection PORTC.0 Pilot Latch PORTC.1
|
||||
* Pilot Output Enable (low) PORTC.2 Piezo PORTC.3 I2C clock PORTC.4 I2C
|
||||
* data PORTC.5 RS232 enable (low) PORTC.6 RS232 Tx PORTC.7 RS232 Rx
|
||||
* PORTD.0 Data bus PORTD.1 Data bus PORTD.2 Data bus PORTD.3 Data bus
|
||||
* PORTD.4 Data bus PORTD.5 Data bus PORTD.6 Data bus PORTD.7 Data bus
|
||||
* PORTE.0 USB RD PORTE.1 USB WR PORTE.2 LCD RS PORTE.3 485 transmit
|
||||
* enable PORTE.4 Relay data latch PORTE.5 Switch Input Clock PORTE.6
|
||||
* Switch Input High/Low PORTE.7 Switch Input Data PORTF.0 LED Row2
|
||||
* PORTF.1 LED Row1 PORTF.2 LED Col5 PORTF.3 LED Col4 PORTF.4 LED Col3
|
||||
* PORTF.5 LED Col2 PORTF.6 LED Col1 PORTF.7 LED Col0 PORTG.0 485 receive
|
||||
* enable PORTG.1 485 Tx PORTG.2 485 Rx PORTG.3 LCD E PORTG.4 LED Row0 */
|
||||
#define LCD_BUSY PORTDbits.RD7
|
||||
#define LCD_E PORTGbits.RG3
|
||||
#define LCD_RW PORTAbits.RA5
|
||||
#define LCD_RS PORTEbits.RE2
|
||||
#define LCD_DATA PORTD
|
||||
#define LCD_TRIS TRISD
|
||||
|
||||
#define PILOT_LATCH PORTCbits.RC0
|
||||
#define PILOT_ENABLE PORTCbits.RC1
|
||||
#define PILOT_PORT PORTD
|
||||
#define PILOT_PORT_TRIS TRISD
|
||||
|
||||
#define PIEZO PORTCbits.RC2
|
||||
#define PIEZO_ON() TRISCbits.TRISC2 = 0
|
||||
#define PIEZO_OFF() TRISCbits.TRISC2 = 1
|
||||
|
||||
#define RS232_ENABLE PORTCbits.RC5
|
||||
|
||||
#define RS485_TX_ENABLE PORTEbits.RE3
|
||||
#define RS485_RX_DISABLE PORTGbits.RG0
|
||||
|
||||
#define SWITCH_LOAD PORTBbits.RB5
|
||||
#define SWITCH_CLK PORTEbits.RE5
|
||||
#define SWITCH_COM PORTEbits.RE6
|
||||
#define SWITCH_DATA PORTEbits.RE7
|
||||
|
||||
#define LEDPORT PORTF
|
||||
#define LEDTRIS TRISF
|
||||
#define LED_ROW1 PORTGbits.RG4
|
||||
#define LED_ROW2 PORTFbits.RF1
|
||||
#define LED_ROW3 PORTFbits.RF0
|
||||
#define LED_ROW4 PORTAbits.RA3
|
||||
#define LED_ROW5 PORTAbits.RA2
|
||||
#define LED_ROW6 PORTAbits.RA1
|
||||
|
||||
#define RELAY_PORT PORTD
|
||||
#define RELAY_PORT_TRIS TRISD
|
||||
#define RELAY_LATCH PORTEbits.RE4
|
||||
|
||||
#define KEYPAD_DATA PORTD
|
||||
#define KEYPAD_TRIS TRISD
|
||||
#define KEYPAD_COL_LATCH PORTBbits.RB5
|
||||
#define KEYPAD_ROW_ENABLE PORTBbits.RB3
|
||||
#define KEYPAD_ROW_LATCH PORTBbits.RB4
|
||||
#define KEYPAD_ROW1 0 b00000001
|
||||
#define KEYPAD_ROW2 0 b00000010
|
||||
#define KEYPAD_ROW3 0 b00000100
|
||||
#define KEYPAD_ROW4 0 b00001000
|
||||
#define KEYPAD_ROW5 0 b00010000
|
||||
#define KEYPAD_ROW6 0 b00100000
|
||||
|
||||
#define USB_RD_EMPTY PORTBbits.RB1
|
||||
#define USB_WR_FULL PORTBbits.RB2
|
||||
#define USB_RD PORTEbits.RE0
|
||||
#define USB_WR PORTEbits.RE1
|
||||
#define USB_PORT PORTD
|
||||
#define USB_PORT_TRIS TRISD
|
||||
|
||||
#define ZERO_CROSS PORTBbits.RB0
|
||||
|
||||
#define PORT_A_TRIS_MASK 0x11 /* 0b00010001 */
|
||||
#define PORT_B_TRIS_MASK 0xC7 /* 0b11000111 */
|
||||
#define PORT_C_TRIS_MASK 0x9C /* 0b10011100 */
|
||||
#define PORT_D_TRIS_MASK 0xFF /* 0b11111111 */
|
||||
#define PORT_E_TRIS_MASK 0x88 /* 0b10001000 */
|
||||
#define PORT_F_TRIS_MASK 0x00 /* 0b00000000 */
|
||||
#define PORT_G_TRIS_MASK 0x04 /* 0b00000100 */
|
||||
|
||||
#define TURN_OFF_COMPARATORS() CMCON = 0x07
|
||||
|
||||
#define SHORT_BEEP 50
|
||||
#define LONG_BEEP 250
|
||||
|
||||
#define CLICK() Hardware_Sound_Piezo(SHORT_BEEP);
|
||||
#define BEEP() Hardware_Sound_Piezo(LONG_BEEP);
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
uint8_t:1;
|
||||
uint8_t:1;
|
||||
uint8_t Thursday:1;
|
||||
uint8_t Wednesday:1;
|
||||
uint8_t Tuesday:1;
|
||||
uint8_t Monday:1;
|
||||
uint8_t Program:1;
|
||||
uint8_t Run:1;
|
||||
|
||||
uint8_t:1;
|
||||
uint8_t:1;
|
||||
uint8_t Input1:1;
|
||||
uint8_t Input2:1;
|
||||
uint8_t Input3:1;
|
||||
uint8_t Input4:1;
|
||||
uint8_t Input5:1;
|
||||
uint8_t Input6:1;
|
||||
|
||||
uint8_t:1;
|
||||
uint8_t:1;
|
||||
uint8_t:1;
|
||||
uint8_t Input7:1;
|
||||
uint8_t:1;
|
||||
uint8_t:1;
|
||||
uint8_t Input8:1;
|
||||
uint8_t Photocell:1;
|
||||
|
||||
uint8_t:1;
|
||||
uint8_t:1;
|
||||
uint8_t:1;
|
||||
uint8_t:1;
|
||||
uint8_t:1;
|
||||
uint8_t:1;
|
||||
uint8_t Remote:1;
|
||||
uint8_t Relay8:1;
|
||||
|
||||
uint8_t:1;
|
||||
uint8_t:1;
|
||||
uint8_t:1;
|
||||
uint8_t Relay7:1;
|
||||
uint8_t Relay6:1;
|
||||
uint8_t Relay5:1;
|
||||
uint8_t Relay4:1;
|
||||
uint8_t Relay3:1;
|
||||
|
||||
uint8_t:1;
|
||||
uint8_t:1;
|
||||
uint8_t Relay2:1;
|
||||
uint8_t Relay1:1;
|
||||
uint8_t Holiday:1;
|
||||
uint8_t Sunday:1;
|
||||
uint8_t Saturday:1;
|
||||
uint8_t Friday:1;
|
||||
};
|
||||
struct {
|
||||
uint8_t row1;
|
||||
uint8_t row2;
|
||||
uint8_t row3;
|
||||
uint8_t row4;
|
||||
uint8_t row5;
|
||||
uint8_t row6;
|
||||
};
|
||||
} LED_REGS;
|
||||
|
||||
union SWITCH_REGS {
|
||||
struct {
|
||||
uint8_t All_On:1;
|
||||
uint8_t All_Off:1;
|
||||
uint8_t Addr:4;
|
||||
uint8_t Pilot_Fault:1;
|
||||
uint8_t Master:1;
|
||||
};
|
||||
uint8_t Sw_Byte;
|
||||
};
|
||||
|
||||
enum INT_STATE { INT_DISABLED, INT_ENABLED, INT_RESTORE };
|
||||
|
||||
#define RESTART_WDT() { _asm CLRWDT _endasm }
|
||||
@@ -261,11 +97,4 @@ enum INT_STATE { INT_DISABLED, INT_ENABLED, INT_RESTORE };
|
||||
T2CON = (mode | (postscale - 1) << 3); \
|
||||
PR2 = period
|
||||
|
||||
|
||||
/* Global Vars */
|
||||
extern volatile LED_REGS LEDS;
|
||||
extern volatile LED_REGS Blink;
|
||||
extern uint8_t Piezo_Timer;
|
||||
extern volatile bool DataPortLocked;
|
||||
|
||||
#endif /* HARDWARE_H */
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*********************************************************************/
|
||||
#include <p18f6720.h>
|
||||
#include "stdint.h"
|
||||
#include "hardware.h"
|
||||
#include "rs485.h"
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h> /* for memmove */
|
||||
#include <p18f6720.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "stdint.h"
|
||||
@@ -129,98 +128,27 @@ void Global_Int(
|
||||
void Hardware_Initialize(
|
||||
void)
|
||||
{
|
||||
/* PORTA.0 Input - Photocell PORTA.1 Output - LED Row6 PORTA.2 Output
|
||||
* - LED Row5 PORTA.3 Output - LED Row4 PORTA.4 Input - Square Wave
|
||||
* input from RTC PORTA.5 Output - LCD RW */
|
||||
TRISA = 0xD1;
|
||||
|
||||
/* PORTB.0 Input - Zero Cross PORTB.1 Input - USB RXF# PORTB.2 Input
|
||||
* USB TXE# PORTB.3 Output - Keypad Row Enable (74HC373 Output Control)
|
||||
* PORTB.4 Output Keypad Row Gate (74HC373 Gate) PORTB.5 Output Switch
|
||||
* Input Latch & Keypad Column Gate (74HC373 Gate) PORTB.6 Input - ICD
|
||||
* connection PORTB.7 Input - ICD connection */
|
||||
TRISB = 0xC7;
|
||||
|
||||
/* PORTC.0 Output - Pilot Latch PORTC.1 Output - Pilot Output Enable
|
||||
* (low) PORTC.2 I/O - Piezo PORTC.3 Input - I2C clock PORTC.4 Input
|
||||
* I2C data PORTC.5 Output RS232 enable (low) PORTC.6 Output - RS232 Tx
|
||||
* PORTC.7 Input - RS232 Rx */
|
||||
TRISC = 0x9C;
|
||||
|
||||
/* PORTD.0 I/O - Data bus PORTD.1 I/O - Data bus PORTD.2 I/O - Data
|
||||
* bus PORTD.3 I/O - Data bus PORTD.4 I/O - Data bus PORTD.5 I/O - Data
|
||||
* bus PORTD.6 I/O - Data bus PORTD.7 I/O - Data bus */
|
||||
TRISD = 0xFF;
|
||||
|
||||
/* PORTE.0 Input - USB RD PORTE.1 Input - USB WR PORTE.2 Output - LCD
|
||||
* RS PORTE.3 Output - 485 transmit enable PORTE.4 Output - Relay data
|
||||
* latch PORTE.5 Output Switch Input Clock PORTE.6 Output - Switch
|
||||
* Input High/Low PORTE.7 Input Switch Input Data */
|
||||
TRISE = 0x83;
|
||||
|
||||
/* PORTF.0 Output - LED Row2 PORTF.1 Output - LED Row1 PORTF.2 Output
|
||||
* - LED Col5 PORTF.3 Output - LED Col4 PORTF.4 Output - LED Col3
|
||||
* PORTF.5 Output - LED Col2 PORTF.6 Output - LED Col1 PORTF.7 Output
|
||||
* LED Col0 */
|
||||
TRISA = 0x00;
|
||||
TRISB = 0x00;
|
||||
TRISC = 0x00;
|
||||
TRISD = 0x00;
|
||||
TRISE = 0x00;
|
||||
TRISF = 0x00;
|
||||
|
||||
/* PORTG.0 Output - 485 receive enable PORTG.1 Output - 485 Tx PORTG.2
|
||||
* Input 485 Rx PORTG.3 Output - LCD E PORTG.4 Output - LED Row0 */
|
||||
TRISG = 0xE6;
|
||||
|
||||
/* The initial state of the keypad enables and latches */
|
||||
KEYPAD_ROW_ENABLE = 1;
|
||||
KEYPAD_ROW_LATCH = 0;
|
||||
KEYPAD_COL_LATCH = 1;
|
||||
|
||||
RELAY_LATCH = 0;
|
||||
|
||||
/* Setup to read the switch inputs */
|
||||
SWITCH_COM = 1;
|
||||
|
||||
/* Enable the RS232 transmitter */
|
||||
RS232_ENABLE = 0;
|
||||
|
||||
/* Turn all leds off. These are the hardware pins */
|
||||
LED_ROW1 = 1;
|
||||
LED_ROW2 = 1;
|
||||
LED_ROW3 = 1;
|
||||
LED_ROW4 = 1;
|
||||
LED_ROW5 = 1;
|
||||
LED_ROW6 = 1;
|
||||
LEDPORT = 0x03;
|
||||
|
||||
/* The initial values for the signals to the LCD */
|
||||
LCD_E = 1;
|
||||
LCD_RW = 1;
|
||||
LCD_RS = 1;
|
||||
|
||||
/* The following gives us a PWM frequency of 1.990KHz with a 50% duty
|
||||
* cycle It also serves to multiplex the LEDs. */
|
||||
PIEZO_OFF();
|
||||
CCPR1L = 0x4E;
|
||||
CCP1CON = 0x2F;
|
||||
setup_timer2(6, 156, 2);
|
||||
PIE1bits.TMR2IE = 1;
|
||||
|
||||
TRISG = 0x00;
|
||||
/* We will use Timer4 as our system tick timer. Our system tick is set
|
||||
* to 1ms. Hold off on enabling the int. */
|
||||
setup_timer4(5, 250, 5);
|
||||
|
||||
/* Setup our interrupt priorities */
|
||||
RCONbits.IPEN = 1;
|
||||
IPR1 = 0;
|
||||
IPR2 = 0;
|
||||
IPR3 = 0;
|
||||
|
||||
/* Setup TMR0 to be high priority */
|
||||
INTCON2 = 0xFC;
|
||||
INTCON3 = 0;
|
||||
|
||||
/* USART 1 high priority */
|
||||
IPR1bits.RC1IP = 1;
|
||||
IPR1bits.TX1IP = 1;
|
||||
|
||||
/* Finally enable our ints */
|
||||
Global_Int(INT_ENABLED);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user