Flash_synchronizer.c 2.83 KB
Newer Older
hu's avatar
hu committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
/************************************************ ******************************
文 件 名:Flash_synchronizer.h
功能描述:闪烁同步信号发生器库文件
作    者:张暄
版    本:V1.0
日    期:2017.04.02
******************************************************************************/

#include "Flash_synchronizer.h"

volatile uint8_t FlashSync1Hz;
volatile uint8_t FlashSync2Hz;
volatile uint8_t FlashSync5Hz;
volatile uint8_t FlashSync05Hz;
volatile uint8_t FlashSync_2_5_Hz;

const uint8_t FlashSync1HzTable[] = {0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
                                     1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
                                    };
const uint8_t FlashSync2HzTable[] = {0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 1u, 1u,
                                     0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 1u, 1u,
                                    };
const uint8_t FlashSync5HzTable[] = {0u, 0u, 1u, 1u, 0u, 0u, 1u, 1u, 0u, 0u,
                                     1u, 1u, 0u, 0u, 1u, 1u, 0u, 0u, 1u, 1u,
                                    };
const uint8_t FlashSync05HzTable[] = {0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
                                      1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
                                      1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
                                      0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
                                     };
const uint8_t FlashSync_2_5_HzTable[] = {0u, 0u, 0u, 0u, 1u, 1u, 1u, 1u, 0u, 0u,
                                         0u, 0u, 1u, 1u, 1u, 1u, 0u, 0u, 0u, 0u,
                                         1u, 1u, 1u, 1u, 0u, 0u, 0u, 0u, 1u, 1u,
                                         1u, 1u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 1u,
                                        }; /* 2.5Hz */

hu's avatar
hu committed
37 38
uint8_t FlashTimer = 0u;
uint8_t FlashTimer40 = 0u;
hu's avatar
hu committed
39 40 41 42 43 44 45

/******************************************************************************
函数名:Flash_Sync_Signal_Generation_Service
功  能:闪烁同步信号发生服务
参  数:无
返回值:无
*******************************************************************************
hu's avatar
hu committed
46
注  意:该服务函数必须每50ms被调用一次
hu's avatar
hu committed
47 48 49
******************************************************************************/
void Flash_Sync_Signal_Generation_Service ( void )
{
hu's avatar
hu committed
50 51
    FlashTimer++;       /*50ms一次 加  1*/
    if ( FlashTimer >= 20u )
hu's avatar
hu committed
52
    {
hu's avatar
hu committed
53
        FlashTimer = 0u;
hu's avatar
hu committed
54 55
    }

hu's avatar
hu committed
56 57
    FlashTimer40++;       /*50ms一次 加  1*/
    if ( FlashTimer40 >= 40u )
hu's avatar
hu committed
58
    {
hu's avatar
hu committed
59
        FlashTimer40 = 0u;
hu's avatar
hu committed
60 61 62 63 64 65 66
    }

    FLASH_SYNC_1Hz = FlashSync1HzTable[FlashTimer]; /*500ms*/
    FLASH_SYNC_2Hz = FlashSync2HzTable[FlashTimer]; /*250ms*/
    FLASH_SYNC_5Hz = FlashSync5HzTable[FlashTimer]; /*100ms*/
    FLASH_SYNC_2_5_Hz = FlashSync_2_5_HzTable[FlashTimer40]; /*200ms*/
}