diff --git a/bacnet-stack/ports/pic18/18f252.lkr b/bacnet-stack/ports/pic18/18f252.lkr new file mode 100644 index 00000000..3e0717a3 --- /dev/null +++ b/bacnet-stack/ports/pic18/18f252.lkr @@ -0,0 +1,29 @@ +// $Id$ +// File: 18f252.lkr +// Sample linker script for the PIC18F252 processor + +LIBPATH . + +FILES c018i.o +FILES clib.lib +FILES p18f252.lib + +CODEPAGE NAME=vectors START=0x0 END=0x29 PROTECTED +CODEPAGE NAME=page START=0x2A END=0x7FFF +CODEPAGE NAME=idlocs START=0x200000 END=0x200007 PROTECTED +CODEPAGE NAME=config START=0x300000 END=0x30000D PROTECTED +CODEPAGE NAME=devid START=0x3FFFFE END=0x3FFFFF PROTECTED +CODEPAGE NAME=eedata START=0xF00000 END=0xF000FF PROTECTED + +ACCESSBANK NAME=accessram START=0x0 END=0x7F +DATABANK NAME=gpr0 START=0x80 END=0xFF +DATABANK NAME=gpr1 START=0x100 END=0x1FF +DATABANK NAME=gpr2 START=0x200 END=0x2FF +DATABANK NAME=gpr3 START=0x300 END=0x3FF +DATABANK NAME=gpr4 START=0x400 END=0x4FF +DATABANK NAME=gpr5 START=0x500 END=0x5FF +ACCESSBANK NAME=accesssfr START=0xF80 END=0xFFF PROTECTED + +SECTION NAME=CONFIG ROM=config + +STACK SIZE=0x100 RAM=gpr5 diff --git a/bacnet-stack/ports/pic18/bacnet.mcp b/bacnet-stack/ports/pic18/bacnet.mcp new file mode 100644 index 00000000..6c6e1d4a --- /dev/null +++ b/bacnet-stack/ports/pic18/bacnet.mcp @@ -0,0 +1,112 @@ +[HEADER] +magic_cookie={66E99B07-E706-4689-9E80-9B2582898A13} +file_version=1.0 +[PATH_INFO] +dir_src= +dir_bin= +dir_tmp= +dir_sin= +dir_inc=D:\mcc18\h;\bacnet-stack;\bacnet-stack\ports\pic18 +dir_lib=D:\mcc18\lib +dir_lkr= +[CAT_FILTERS] +filter_src=*.asm;*.c +filter_inc=*.h;*.inc +filter_obj=*.o +filter_lib=*.lib +filter_lkr=*.lkr +[OTHER_FILES] +file_000=no +file_001=no +file_002=no +file_003=no +file_004=no +file_005=no +file_006=no +file_007=no +file_008=no +file_009=no +file_010=no +file_011=no +file_012=no +file_013=no +file_014=no +file_015=no +file_016=no +file_017=no +file_018=no +file_019=no +file_020=no +file_021=no +file_022=no +file_023=no +file_024=no +file_025=no +file_026=no +file_027=no +file_028=no +file_029=no +file_030=no +file_031=no +file_032=no +file_033=no +file_034=no +file_035=no +file_036=no +file_037=no +file_038=no +file_039=no +file_040=no +[FILE_INFO] +file_000=rs485.c +file_001=D:\bacnet-stack\whois.c +file_002=D:\bacnet-stack\apdu.c +file_003=D:\bacnet-stack\bacdcode.c +file_004=D:\bacnet-stack\bacerror.c +file_005=D:\bacnet-stack\bigend.c +file_006=D:\bacnet-stack\crc.c +file_007=D:\bacnet-stack\device.c +file_008=D:\bacnet-stack\iam.c +file_009=D:\bacnet-stack\mstp.c +file_010=D:\bacnet-stack\npdu.c +file_011=D:\bacnet-stack\reject.c +file_012=D:\bacnet-stack\ringbuf.c +file_013=D:\bacnet-stack\rp.c +file_014=D:\bacnet-stack\abort.c +file_015=D:\bacnet-stack\wp.c +file_016=main.c +file_017=stdbool.h +file_018=stdint.h +file_019=D:\bacnet-stack\wp.h +file_020=D:\bacnet-stack\apdu.h +file_021=D:\bacnet-stack\bacdcode.h +file_022=D:\bacnet-stack\bacdef.h +file_023=D:\bacnet-stack\bacenum.h +file_024=D:\bacnet-stack\bacerror.h +file_025=D:\bacnet-stack\bigend.h +file_026=D:\bacnet-stack\bits.h +file_027=D:\bacnet-stack\bytes.h +file_028=D:\bacnet-stack\config.h +file_029=D:\bacnet-stack\crc.h +file_030=D:\bacnet-stack\device.h +file_031=D:\bacnet-stack\iam.h +file_032=D:\bacnet-stack\mstp.h +file_033=D:\bacnet-stack\npdu.h +file_034=D:\bacnet-stack\reject.h +file_035=D:\bacnet-stack\ringbuf.h +file_036=D:\bacnet-stack\rp.h +file_037=D:\bacnet-stack\rs485.h +file_038=D:\bacnet-stack\whois.h +file_039=D:\bacnet-stack\abort.h +file_040=18f252.lkr +[SUITE_INFO] +suite_guid={5B7D72DD-9861-47BD-9F60-2BE967BF8416} +suite_state= +[TOOL_SETTINGS] +TS{DD2213A8-6310-47B1-8376-9430CDFC013F}= +TS{BFD27FBA-4A02-4C0E-A5E5-B812F3E7707C}=/m"$(BINDIR_)$(TARGETBASE).map" /o"$(TARGETBASE).cof" +TS{C2AF05E7-1416-4625-923D-E114DB6E2B96}= +TS{ADE93A55-C7C7-4D4D-A4BA-59305F7D0391}= +[TOOL_LOC_STAMPS] +tool_loc{96C98149-AA1B-4CF9-B967-FAE79CAB663C}=D:\mcc18\bin\mplink.exe +tool_loc{E56A1C86-9D32-4DF6-8C34-FE0388B1B644}=D:\mcc18\bin\mcc18.exe diff --git a/bacnet-stack/ports/pic18/bacnet.mcw b/bacnet-stack/ports/pic18/bacnet.mcw new file mode 100644 index 00000000..16cee15e Binary files /dev/null and b/bacnet-stack/ports/pic18/bacnet.mcw differ diff --git a/bacnet-stack/ports/pic18/main.c b/bacnet-stack/ports/pic18/main.c new file mode 100644 index 00000000..1b5a78d9 --- /dev/null +++ b/bacnet-stack/ports/pic18/main.c @@ -0,0 +1,66 @@ +/*####COPYRIGHTBEGIN#### + ------------------------------------------- + Copyright (C) 2004 Steve Karg + + 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; either version 2 + of the License, or (at your option) any later version. + + 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. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to: + The Free Software Foundation, Inc. + 59 Temple Place - Suite 330 + Boston, MA 02111-1307 + USA. + + As a special exception, if other files instantiate templates or + use macros or inline functions from this file, or you compile + this file and link it with other works to produce a work based + on this file, this file does not by itself cause the resulting + work to be covered by the GNU General Public License. However + the source code for this file must still be made available in + accordance with section (3) of the GNU General Public License. + + This exception does not invalidate any other reasons why a work + based on this file might be covered by the GNU General Public + License. + ------------------------------------------- +####COPYRIGHTEND####*/ + +#include +#include +#include "mstp.h" +#include "bytes.h" +#include "crc.h" +#include "rs485.h" +#include "ringbuf.h" + +static struct mstp_port_struct_t MSTP_Port; // port data +static uint8_t MSTP_MAC_Address = 0x05; // local MAC address + +int main(void) +{ + + MSTP_Init(&MSTP_Port,MSTP_MAC_Address); + + // loop forever + for (;;) + { + // input + RS485_Check_UART_Data(&MSTP_Port); + MSTP_Receive_Frame_FSM(&MSTP_Port); + // process + + // output + MSTP_Master_Node_FSM(&MSTP_Port); + + } + + return 0; +} diff --git a/bacnet-stack/ports/pic18/rs485.c b/bacnet-stack/ports/pic18/rs485.c index 03e45387..19e3e107 100644 --- a/bacnet-stack/ports/pic18/rs485.c +++ b/bacnet-stack/ports/pic18/rs485.c @@ -54,10 +54,10 @@ void RS485_Send_Frame( (void)nbytes; // FIXME: temp until we implement this code // in order to avoid line contention - while (mstp_port->SilenceTimer < Tturnaround) - { + //while (mstp_port->SilenceTimer < Tturnaround) + //{ // wait, yield, or whatever - } + //} // Disable the receiver, and enable the transmit line driver.