Esempio n. 1
0
/*************************************************************************
* Description: Task for blinking LED
* Returns: none
* Notes: none
*************************************************************************/
void led_task(
    void)
{
    if (Off_Delay_Milliseconds_1) {
        if (timer_elapsed_milliseconds(TIMER_LED_1, Off_Delay_Milliseconds_1)) {
            Off_Delay_Milliseconds_1 = 0;
            led_off(LED_1);
        }
    }
    if (Off_Delay_Milliseconds_2) {
        if (timer_elapsed_milliseconds(TIMER_LED_2, Off_Delay_Milliseconds_2)) {
            Off_Delay_Milliseconds_2 = 0;
            led_off(LED_2);
        }
    }
    if (Off_Delay_Milliseconds_3) {
        if (timer_elapsed_milliseconds(TIMER_LED_3, Off_Delay_Milliseconds_3)) {
            Off_Delay_Milliseconds_3 = 0;
            led_off(LED_3);
        }
    }
    if (Off_Delay_Milliseconds_4) {
        if (timer_elapsed_milliseconds(TIMER_LED_4, Off_Delay_Milliseconds_4)) {
            Off_Delay_Milliseconds_4 = 0;
            led_off(LED_4);
        }
    }
}
Esempio n. 2
0
void rs485_turnaround_delay(
    void)
{
    uint16_t turnaround_time;

    /* delay after reception before trasmitting - per MS/TP spec */
    /* wait a minimum  40 bit times since reception */
    /* at least 1 ms for errors: rounding, clock tick */
    turnaround_time = 1 + ((Tturnaround * 1000UL) / Baud_Rate);
    while (!timer_elapsed_milliseconds(TIMER_SILENCE, turnaround_time)) {
        /* do nothing - wait for timer to increment */
    };
}
Esempio n. 3
0
void lse_init(
    void)
{
    uint32_t LSE_Delay = 0;
    struct etimer Delay_Timer;

    /* Enable access to the backup register => LSE can be enabled */
    PWR_BackupAccessCmd(ENABLE);
    /* Enable LSE (Low Speed External Oscillation) */
    RCC_LSEConfig(RCC_LSE_ON);

    /* Check the LSE Status */
    while (1) {
        if (LSE_Delay < LSE_FAIL_FLAG) {
            timer_elapsed_start(&Delay_Timer);
            while (!timer_elapsed_milliseconds(&Delay_Timer, 500)) {
                /* do nothing */
            }
            /* check whether LSE is ready, with 4 seconds timeout */
            LSE_Delay += 0x10;
            if (RCC_GetFlagStatus(RCC_FLAG_LSERDY) != RESET) {
                /* Set flag: LSE PASS */
                LSE_Delay |= LSE_PASS_FLAG;
                led_ld4_off();
                /* Disable LSE */
                RCC_LSEConfig(RCC_LSE_OFF);
                break;
            }
        }

        /* LSE_FAIL_FLAG = 0x80 */
        else if (LSE_Delay >= LSE_FAIL_FLAG) {
            if (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET) {
                /* Set flag: LSE FAIL */
                LSE_Delay |= LSE_FAIL_FLAG;
                led_ld4_on();
            }
            /* Disable LSE */
            RCC_LSEConfig(RCC_LSE_OFF);
            break;
        }
    }
}
Esempio n. 4
0
/*************************************************************************
* Description: Use the silence timer to determine turnaround time.
* Returns: true if turnaround time has expired.
* Notes: none
**************************************************************************/
bool rs485_turnaround_elapsed(
    void)
{
    return timer_elapsed_milliseconds(&Silence_Timer, rs485_turnaround_time());
}
Esempio n. 5
0
/*************************************************************************
* Description: Determine the amount of silence on the wire from the timer.
* Returns: true if the amount of time has elapsed
* Notes: none
**************************************************************************/
bool rs485_silence_elapsed(
    uint32_t interval)
{
    return timer_elapsed_milliseconds(&Silence_Timer, interval);
}