Updated atmega168 project files.

This commit is contained in:
skarg
2007-08-16 22:13:57 +00:00
parent 62d557a58d
commit 07816a3fd5
8 changed files with 43 additions and 19 deletions
+11 -11
View File
@@ -107,6 +107,17 @@ typedef enum {
/* larger values for this timeout, not to exceed 100 milliseconds.) */
#define Tusage_timeout 25
/* The minimum time after the end of the stop bit of the final octet of a */
/* received frame before a node may enable its EIA-485 driver: 40 bit times. */
/* At 9600 baud, 40 bit times would be about 4.166 milliseconds */
/* At 19200 baud, 40 bit times would be about 2.083 milliseconds */
/* At 38400 baud, 40 bit times would be about 1.041 milliseconds */
/* At 57600 baud, 40 bit times would be about 0.694 milliseconds */
/* At 76800 baud, 40 bit times would be about 0.520 milliseconds */
/* At 115200 baud, 40 bit times would be about 0.347 milliseconds */
/* 40 bits is 4 octets including a start and stop bit with each octet */
#define Tturnaround (40UL)
/* turnaround_time_milliseconds = (Tturnaround*1000UL)/RS485_Baud; */
struct mstp_port_struct_t {
MSTP_RECEIVE_STATE receive_state;
@@ -240,17 +251,6 @@ struct mstp_port_struct_t {
#define DEFAULT_MAX_MASTER 127
#define DEFAULT_MAC_ADDRESS 127
/* The minimum time after the end of the stop bit of the final octet of a */
/* received frame before a node may enable its EIA-485 driver: 40 bit times. */
/* At 9600 baud, 40 bit times would be about 4.166 milliseconds */
/* At 19200 baud, 40 bit times would be about 2.083 milliseconds */
/* At 38400 baud, 40 bit times would be about 1.041 milliseconds */
/* At 57600 baud, 40 bit times would be about 0.694 milliseconds */
/* At 76800 baud, 40 bit times would be about 0.520 milliseconds */
/* At 115200 baud, 40 bit times would be about 0.347 milliseconds */
/* 40 bits is 4 octets including a start and stop bit with each octet */
#define Tturnaround 40
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
+4 -2
View File
@@ -75,7 +75,8 @@ ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2
## Linker flags
LDFLAGS = $(COMMON)
LDFLAGS += -Wl,-Map=$(TARGET).map,-L=.,-l$(TARGET)
#LDFLAGS += -Wl,-Map=$(TARGET).map,-L=.,-l$(TARGET)
LDFLAGS += -Wl,-Map=$(TARGET).map
## Intel Hex file production flags
HEX_FLASH_FLAGS = -R .eeprom
@@ -84,7 +85,8 @@ HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"
HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings
## Objects that must be built in order to link
OBJECTS = $(COBJ) $(DEMOOBJ)
#OBJECTS = $(COBJ) $(DEMOOBJ)
OBJECTS = $(COBJ)
## Build
TARGET_ELF=$(TARGET).elf
File diff suppressed because one or more lines are too long
+3 -3
View File
@@ -40,12 +40,12 @@ uint16_t MSTP_Packets = 0;
/* local MS/TP port data - shared with RS-485 */
static volatile struct mstp_port_struct_t MSTP_Port;
/* receive buffer */
static DLMSTP_PACKET Receive_Packet;
static DLMSTP_PACKET Transmit_Packet;
/* buffers needed by mstp port struct */
static uint8_t TxBuffer[MAX_MPDU];
static uint8_t RxBuffer[MAX_MPDU];
/* buffers used by the datalink layer */
static DLMSTP_PACKET Receive_Packet;
static DLMSTP_PACKET Transmit_Packet;
#define INCREMENT_AND_LIMIT_UINT16(x) {if (x < 0xFFFF) x++;}
Binary file not shown.
+23 -1
View File
@@ -36,6 +36,26 @@
void init(void)
{
/* Initialize the Clock Prescaler for ATmega48/88/168 */
/* The device is shipped with the CKDIV8 Fuse programmed */
/* The default CLKPSx bits are factory set to 0011 */
/* Enbable the Clock Prescaler */
CLKPR = _BV(CLKPCE);
/* CLKPS3 CLKPS2 CLKPS1 CLKPS0 Clock Division Factor
------ ------ ------ ------ ---------------------
0 0 0 0 1
0 0 0 1 2
0 0 1 0 4
0 0 1 1 8
0 1 0 0 16
0 1 0 1 32
0 1 1 0 64
0 1 1 1 128
1 0 0 0 256
1 x x x Reserved
*/
/* Set the CLKPS3..0 bits to Prescaler of 1 */
CLKPR = 0;
/* Initialize I/O ports */
/* For Port DDRx (Data Direction) Input=1, Output=1 */
/* For Port PORTx (Bit Value) TriState=0, High=1 */
@@ -66,7 +86,9 @@ void task_milliseconds(void)
while (Timer_Milliseconds) {
Timer_Milliseconds--;
/* add other millisecond timer tasks here */
#if defined(BACDL_MSTP)
dlmstp_millisecond_timer();
#endif
}
}
@@ -90,7 +112,7 @@ int main(void)
/* BACnet handling */
pdu_len = datalink_receive(&src, &PDUBuffer[0], MAX_MPDU, 0);
if (pdu_len) {
npdu_handler(&src, &PDUBuffer[0], pdu_len);
//npdu_handler(&src, &PDUBuffer[0], pdu_len);
}
}
+1 -1
View File
@@ -124,7 +124,7 @@ void RS485_Send_Frame(
/* delay after reception - per MS/TP spec */
if (mstp_port) {
/* wait about 40 bit times since reception */
turnaround_time = (40UL*1000UL)/RS485_Baud;
turnaround_time = (Tturnaround*1000UL)/RS485_Baud;
if (!turnaround_time) {
turnaround_time = 1;
}
Binary file not shown.