Ejemplo n.º 1
0
/**
 * \brief Main function.
 *
 * Initializes the board, and runs the application in an infinite loop.
 */
int main(void)
{
    /* hardware initialization */
    sysclk_init();
    board_init();
    pmic_init();
    timer_init();
    rs485_init();
    led_init();
	adc_init();
#ifdef CONF_BOARD_ENABLE_RS485_XPLAINED
    // Enable display backlight
    gpio_set_pin_high(NHD_C12832A1Z_BACKLIGHT);
#endif
    // Workaround for known issue: Enable RTC32 sysclk
    sysclk_enable_module(SYSCLK_PORT_GEN, SYSCLK_RTC);
    while (RTC32.SYNCCTRL & RTC32_SYNCBUSY_bm) {
        // Wait for RTC32 sysclk to become stable
    }
    cpu_irq_enable();
    /* application initialization */
    rs485_baud_rate_set(38400);
    bacnet_init();
    /*  run forever - timed tasks */
    timer_callback(bacnet_task_timed, 5);
    for (;;) {
        bacnet_task();
        led_task();
    }
}
Ejemplo n.º 2
0
int main(
    void)
{
    struct itimer Blink_Timer;

    /*At this stage the microcontroller clock setting is already configured,
       this is done through SystemInit() function which is called from startup
       file (startup_stm32f10x_xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f10x.c file */
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
    led_init();
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |
        RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE,
        ENABLE);
    timer_init();
    lse_init();
    led_init();
    rs485_init();
    bacnet_init();
    timer_interval_start(&Blink_Timer, 125);
    for (;;) {
        if (timer_interval_expired(&Blink_Timer)) {
            timer_interval_reset(&Blink_Timer);
            led_ld3_toggle();
        }
        led_task();
        bacnet_task();
    }
}
Ejemplo n.º 3
0
int main(
    void)
{
    uint16_t pdu_len = 0;
    BACNET_ADDRESS src; /* source address */
    uint8_t pdu[MAX_MPDU];      /* PDU data */

    Timer_Init();
    bacnet_init();
    /* broadcast an I-Am on startup */
    Send_I_Am(&Handler_Transmit_Buffer[0]);
    for (;;) {
        millisecond_timer();
        if (!DCC_Timer) {
            dcc_timer_seconds(1);
            DCC_Timer = 1000;
        }
        /* BACnet handling */
        pdu_len = datalink_receive(&src, &pdu[0], MAX_MPDU, 0);
        if (pdu_len) {
#ifndef DLMSTP_TEST
            npdu_handler(&src, &pdu[0], pdu_len);
#endif
        }
    }
}