Exemple #1
0
/**************************************************************************
* Description: initializes the BACnet library
* Returns: none
* Notes: none
**************************************************************************/
void bacnet_init(void)
{
    unsigned i;

    Ringbuf_Init(&Receive_Queue, (uint8_t *) & Receive_Buffer,
        sizeof(struct mstp_rx_packet), MSTP_RECEIVE_PACKET_COUNT);
    dlmstp_init(NULL);
    /* initialize objects */
    Device_Init(NULL);
    /* set up our confirmed service unrecognized service handler - required! */
    apdu_set_unrecognized_service_handler_handler
        (handler_unrecognized_service);
    /* we need to handle who-is to support dynamic device binding */
    apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is);
    apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_HAS, handler_who_has);
    /* Set the handlers for any confirmed services that we support. */
    /* We must implement read property - it's required! */
    apdu_set_confirmed_handler(SERVICE_CONFIRMED_READ_PROPERTY,
        handler_read_property);
    apdu_set_confirmed_handler(SERVICE_CONFIRMED_READ_PROP_MULTIPLE,
        handler_read_property_multiple);
    apdu_set_confirmed_handler(SERVICE_CONFIRMED_REINITIALIZE_DEVICE,
        handler_reinitialize_device);
    apdu_set_confirmed_handler(SERVICE_CONFIRMED_WRITE_PROPERTY,
        handler_write_property);
    /* handle communication so we can shut up when asked */
    apdu_set_confirmed_handler(SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL,
        handler_device_communication_control);
    /* start the cyclic 1 second timer for DCC */
    timer_interval_start_seconds(&DCC_Timer, DCC_CYCLE_SECONDS);
    /* start the cyclic 1 second timer for COV */
    timer_interval_start_seconds(&COV_Timer, COV_CYCLE_SECONDS);
    /* start the cyclic 1 second timer for TSM */
    timer_interval_start_seconds(&TSM_Timer, TSM_CYCLE_SECONDS);
	for (i = 0; i < MAX_ANALOG_INPUTS; i++) {
        Analog_Input_Units_Set(
            Analog_Input_Index_To_Instance(i),
            UNITS_PERCENT);
    }
}
Exemple #2
0
void test_init(
    void)
{
#ifdef MSTP_MONITOR
    serial_baud_rate_set(115200);
#else
    serial_baud_rate_set(9600);
#endif
    timer_interval_start_seconds(&Test_Timer, 1);
    /* configure a port pin as output */
#if (BDK_VERSION==4)
    BIT_SET(DDRD, DDB5);
#else
    BIT_SET(DDRB, DDB0);
#endif
}
Exemple #3
0
/**************************************************************************
* Description: handles reinitializing the device after a few seconds
* Returns: none
* Notes: gives the device enough time to acknowledge the RD request
**************************************************************************/
static void reinit_task(void)
{
    BACNET_REINITIALIZED_STATE state = BACNET_REINIT_IDLE;

    state = Device_Reinitialized_State();
    if (state == BACNET_REINIT_IDLE) {
        /* set timer to never expire */
        timer_interval_infinity(&Reinit_Timer);
    } else if (timer_interval_active(&Reinit_Timer)) {
        if (timer_interval_expired(&Reinit_Timer)) {
            /* reset MCU via watchdog timeout */
            wdt_reset_mcu();
        }
    } else {
        timer_interval_start_seconds(&Reinit_Timer, 3);
    }
}