LED_Driver_Interface.c 2.52 KB
Newer Older
时昊's avatar
时昊 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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109


#include "LED_Driver.h"
#include "LED_Driver_Interface.h"
#include "Simulated_IIC_2_Master.h"
#include "RTE_GPIO.h"
#include "dr7f701401.dvf.h"
#include <string.h>
#include "Watchdog.h"
#include <string.h>
#include "rh850_macros.h"
/*如果条件允许将u8LEDDriverRamData定义在休眠唤醒后不会被清空的RAM区域*/
#pragma alignvar(8)
LED_Driver_uint8_t u8LEDDriverRamData [ LED_DRIVER_RAM_LEN ];
#pragma alignvar(8)
const LED_Driver_uint8_t u8AW21036ChipAddress [ LED_DRIVER_CHIP_NUM ] = {

#if ( LED_DRIVER_CHIP_NUM >= 1U )
    AW21036_CHIP1_ADDRESS,
#endif

#if ( LED_DRIVER_CHIP_NUM >= 2U )
    AW21036_CHIP2_ADDRESS,
#endif

#if ( LED_DRIVER_CHIP_NUM >= 3U )
    AW21036_CHIP3_ADDRESS,
#endif

#if ( LED_DRIVER_CHIP_NUM >= 4U )
    AW21036_CHIP4_ADDRESS,
#endif

};

const LED_Driver_uint8_t u8IS31ChipAddress [ LED_DRIVER_CHIP_NUM ] = {

#if ( LED_DRIVER_CHIP_NUM >= 1U )
    IS31_CHIP1_ADDRESS,
#endif

#if ( LED_DRIVER_CHIP_NUM >= 2U )
    IS31_CHIP2_ADDRESS,
#endif

#if ( LED_DRIVER_CHIP_NUM >= 3U )
    IS31_CHIP3_ADDRESS,
#endif

#if ( LED_DRIVER_CHIP_NUM >= 4U )
    IS31_CHIP4_ADDRESS,
#endif

};

/*设置shutdown引脚*/
void LED_Driver_Shutdown_Pin_Set(LED_Driver_uint8_t u8Level)
{
    SDB_LED_DRIVER = u8Level;
}

/****************初始化函数调用示例*************/
void delay(void)
{
    uint16_t i;
    for ( i = 0; i < 0xffff; ++i )
    {
        nop( );
        WDT_Clear( );
    }
}

void LED_Driver_Init_Example(void)
{
    LED_Driver_Par_st_t stLEDDriverParInit;

    /*芯片数量*/
    stLEDDriverParInit.u8LEDDriverChipNum = LED_DRIVER_CHIP_NUM;
    /*shutdown 引脚控制函数*/
    stLEDDriverParInit.pfnLEDDriverShutdownPinSetCallBack = LED_Driver_Shutdown_Pin_Set;
    /*喂狗函数*/
    stLEDDriverParInit.pfnLEDDriverFeedDogCallBack = WDT_Clear; /*根据项目需调整*/
    /*10us 延时函数*/
    stLEDDriverParInit.pfnLEDDriverDelay10usCallBack = delay; /*根据项目需调整*/
    /*3236芯片地址数组*/
    stLEDDriverParInit.pu8IS31ChipAddress = u8IS31ChipAddress;
    /*21036芯片地址数组*/
    stLEDDriverParInit.pu8AW21036ChipAddress = u8AW21036ChipAddress;
    memset(u8LEDDriverRamData, 0, sizeof(u8LEDDriverRamData));
    Simulated_IIC_2_Init( );

    LED_Driver_Init_KL30(u8LEDDriverRamData, &stLEDDriverParInit);

    /*唤醒初始化同样*/
}

uint8_t u8LEDDriverCheckCount = 0U;
void LED_Driver_Refresh_Example(void)
{
	if (u8LEDDriverCheckCount >= 10U)
    {
        u8LEDDriverCheckCount = 0U;
        LED_Driver_Work_Check();
    }
    else
    {
        u8LEDDriverCheckCount++;
    }
}