Updated the PIC port for MS/TP. Tested on my hardware.
This commit is contained in:
Binary file not shown.
@@ -77,31 +77,6 @@ void dlmstp_init(
|
|||||||
RS485_Initialize();
|
RS485_Initialize();
|
||||||
MSTP_Port.InputBuffer = &Receive_Buffer.pdu[0];
|
MSTP_Port.InputBuffer = &Receive_Buffer.pdu[0];
|
||||||
MSTP_Init(&MSTP_Port);
|
MSTP_Init(&MSTP_Port);
|
||||||
/* FIXME: implement your data storage */
|
|
||||||
data = 64; /* I2C_Read_Byte(
|
|
||||||
EEPROM_DEVICE_ADDRESS,
|
|
||||||
EEPROM_MSTP_MAC_ADDR); */
|
|
||||||
if (data <= 127)
|
|
||||||
MSTP_Port.This_Station = data;
|
|
||||||
else
|
|
||||||
dlmstp_set_my_address(DEFAULT_MAC_ADDRESS);
|
|
||||||
/* FIXME: implement your data storage */
|
|
||||||
data = 127; /* I2C_Read_Byte(
|
|
||||||
EEPROM_DEVICE_ADDRESS,
|
|
||||||
EEPROM_MSTP_MAX_MASTER_ADDR); */
|
|
||||||
if ((data <= 127) && (data >= MSTP_Port.This_Station))
|
|
||||||
MSTP_Port.Nmax_master = data;
|
|
||||||
else
|
|
||||||
dlmstp_set_max_master(DEFAULT_MAX_MASTER);
|
|
||||||
/* FIXME: implement your data storage */
|
|
||||||
data = 1;
|
|
||||||
/* I2C_Read_Byte(
|
|
||||||
EEPROM_DEVICE_ADDRESS,
|
|
||||||
EEPROM_MSTP_MAX_INFO_FRAMES_ADDR); */
|
|
||||||
if (data >= 1)
|
|
||||||
MSTP_Port.Nmax_info_frames = data;
|
|
||||||
else
|
|
||||||
dlmstp_set_max_info_frames(DEFAULT_MAX_INFO_FRAMES);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void dlmstp_cleanup(
|
void dlmstp_cleanup(
|
||||||
|
|||||||
@@ -231,7 +231,6 @@ void Initialize_Variables(
|
|||||||
ENABLE_TIMER4_INT();
|
ENABLE_TIMER4_INT();
|
||||||
/* interrupts must be enabled before we read our inputs */
|
/* interrupts must be enabled before we read our inputs */
|
||||||
Global_Int(INT_ENABLED);
|
Global_Int(INT_ENABLED);
|
||||||
dlmstp_init();
|
|
||||||
/* Start our time from now */
|
/* Start our time from now */
|
||||||
Milliseconds = 0;
|
Milliseconds = 0;
|
||||||
}
|
}
|
||||||
@@ -259,6 +258,12 @@ void main(
|
|||||||
RCONbits.NOT_RI = 1;
|
RCONbits.NOT_RI = 1;
|
||||||
Hardware_Initialize();
|
Hardware_Initialize();
|
||||||
Initialize_Variables();
|
Initialize_Variables();
|
||||||
|
/* initialize BACnet Data Link Layer */
|
||||||
|
dlmstp_set_my_address(42);
|
||||||
|
dlmstp_set_max_info_frames(1);
|
||||||
|
dlmstp_set_max_master(127);
|
||||||
|
RS485_Set_Baud_Rate(38400);
|
||||||
|
dlmstp_init();
|
||||||
/* Handle anything that needs to be done on powerup */
|
/* Handle anything that needs to be done on powerup */
|
||||||
/* Greet the BACnet world! */
|
/* Greet the BACnet world! */
|
||||||
Send_I_Am(&Handler_Transmit_Buffer[0]);
|
Send_I_Am(&Handler_Transmit_Buffer[0]);
|
||||||
|
|||||||
@@ -697,11 +697,7 @@ bool MSTP_Master_Node_FSM(
|
|||||||
mstp_port->FrameCount = mstp_port->Nmax_info_frames;
|
mstp_port->FrameCount = mstp_port->Nmax_info_frames;
|
||||||
mstp_port->master_state = MSTP_MASTER_STATE_DONE_WITH_TOKEN;
|
mstp_port->master_state = MSTP_MASTER_STATE_DONE_WITH_TOKEN;
|
||||||
transition_now = true;
|
transition_now = true;
|
||||||
} else if (mstp_port->SilenceTimer > Tusage_delay) {
|
|
||||||
/* if we missed our timing deadline, another token will be sent */
|
|
||||||
mstp_port->master_state = MSTP_MASTER_STATE_IDLE;
|
|
||||||
} else {
|
} else {
|
||||||
/* don't send it if we are too late in getting out */
|
|
||||||
uint8_t destination = mstp_port->TxBuffer[3];
|
uint8_t destination = mstp_port->TxBuffer[3];
|
||||||
RS485_Send_Frame(mstp_port,
|
RS485_Send_Frame(mstp_port,
|
||||||
(uint8_t *) & mstp_port->TxBuffer[0], mstp_port->TxLength);
|
(uint8_t *) & mstp_port->TxBuffer[0], mstp_port->TxLength);
|
||||||
|
|||||||
Reference in New Issue
Block a user