好用的LED代码

代码原型基于Siliconlabs EFR32MG Zigbee协议栈的Siliconlabs Device UI  plugin进行优化。

每个LED都需要一个timer event,以下源码默认可以支持2个LED的独立控制实现。

LED功能支持开、关、切换、由开延时到关、由关延时到开、n次循环周期闪烁、n次循环非周期闪烁、扩展自定义回调。

LED功能描述:

1、LED开

void HalLed_TurnOn(uint8_t ledIndex)

ledIndex为LED索引,0为第一个LED,以此类推。

2、LED关

void HalLed_TurnOff(uint8_t ledIndex)

ledIndex为LED索引,0为第一个LED,以此类推。

3、LED切换

void HalLed_TurnToggle(uint8_t ledIndex)

ledIndex为LED索引,0为第一个LED,以此类推。

4、LED由开状态延时onTime后切换到关状态

void HalLed_OnToOff(uint8_t ledIndex, uint32_t onTime)

ledIndex为LED索引,0为第一个LED,以此类推;onTime为延时时间,单位ms。

5、LED由关状态延时onTime后切换到开状态
void HalLed_OffToOn(uint8_t ledIndex, uint32_t offTime)

ledIndex为LED索引,0为第一个LED,以此类推;offTime为延时时间,单位ms。

6、LED n次循环周期闪烁
void HalLed_PeriodicBlink(uint8_t ledIndex, uint32_t delayTime, uint32_t blinkTime, uint16_t periodicTime)

ledIndex为LED索引,0为第一个LED,以此类推;delayTime为延时执行的时间,单位ms;blinkTime为闪烁总时间,单位ms;periodicTime为开/关交替闪烁的时间,单位ms。

例:

HalLed_PeriodicBlink(0, 0, 10000, 500);

7、LED n次循环非周期闪烁
void HalLed_PatternBlink(uint8_t ledIndex, uint32_t delayTime, uint32_t blinkTime, uint8_t length, uint16_t *pattern);

ledIndex为LED索引,0为第一个LED,以此类推;delayTime为延时执行的时间,单位ms;blinkTime为闪烁总时间,单位ms;length为*pattern的长度;*pattern为开/关交替闪烁的时间组合,单位ms。

例:

static uint16_t u16szBlinkPatternTest[] =
{
	500,
	1000,
	500,
	1000,
    200,
	1000,
};


HalLed_PatternBlink(0, 0, 60000, COUNTOF(u16szBlinkPatternTest), u16szBlinkPatternTest);

8、LED是否忙碌(控制之前可以检查LED的定时事件还在执行)
bool HalLed_IsBusy(uint8_t ledIndex);

ledIndex为LED索引,0为第一个LED,以此类推,返回状态0表示空闲,1表示忙碌。

9、扩展自定义回调(可以组合一个或多个LED、蜂鸣器等开关量同时控制)

void HalLed_DiversifyBlinkRegister(uint8_t ledIndex, uint32_t delayTime, uint32_t blinkTime,
        uint8_t length, uint16_t *pattern, tpHalLedBlinkDiversifyCallback callback);

ledIndex为LED索引,0为第一个LED,以此类推;delayTime为延时执行的时间,单位ms;blinkTime为闪烁总时间,单位ms;length为*pattern的长度;*pattern为开/关交替闪烁的时间组合,单位ms;callback为回调函数。

例:

Use example:
1. Define the blink pattern time.
#define DHAL_LED_DIVERSIFY_BLINK_TIME_MS	{1000, 1000, 990, 10}

2. Declaration pattern time array.
static uint16_t u16szBlinkPatternDiversify[] = DHAL_LED_DIVERSIFY_BLINK_TIME_MS;

3. Define the callback function
void userApp_LedBlinkDiversifyCallback(uint8_t ledIndex, uint8_t ledControlIndex)
{
	HalLedPrintln("UMA--userApp_LedBlinkDiversifyCallback ledIndex=%d,ledControlIndex=%d", ledIndex, ledControlIndex);

	// LED control diversity sample code:
	// The hardware has red and green two-color LED. The control requirements are green bright 1000ms,
	// yellow bright 1000ms, red bright 990ms, and all led off 10ms.

	switch(ledControlIndex)
	{
	case 0:
		HalLed_TurnOff(0);	// green off
		HalLed_TurnOn(1);	// red on
        beep(1);
		break;
	case 1:
		HalLed_TurnOn(0);	// green on
		HalLed_TurnOff(1);	// red off
        beep(0);
		break;
	case 2:
		HalLed_TurnOn(0);	// green on -- yellow
		HalLed_TurnOn(1);	// red on
        beep(0);
		break;
	case 3:
		HalLed_TurnOff(0);	// green off
		HalLed_TurnOff(1);	// red off
        beep(0);
		break;
	default:
		break;
	}
}

4. Use the registration callback function.
void gasSensorPreheatingLedBlink(void)
{
	HalLed_DiversifyBlinkRegister(0, 0, 180000, COUNTOF(u16szBlinkPatternDiversify),
		u16szBlinkPatternDiversify, userApp_LedBlinkDiversifyCallback);
}

源码HalLED.c

/***********************************************************************************
* File        : HalLED.c
* Description : Hardware LED function.
* Author      : Chilli
* Date        : 2022.2.7
* Version     : 1.0.1
***********************************************************************************/

//==================================================================================
// Include head file
#include "app/framework/include/af.h"

#ifdef HAL_CONFIG
	#include "hal-config.h"
#endif
#ifdef HAL_BULBPWM_ENABLE
	#include CONFIGURATION_HEADER
	#include EMBER_AF_API_BULB_PWM_DRIVER
#endif

#include "HalGPIO.h"
#include "HalLED.h"

//==================================================================================
// Macro definition
#if (DHL_LED_NUMBER == 0)
void HalLed_Init(void)
{
	// None
}

void HalLed_TurnOn(uint8_t ledIndex)
{
	// None
}

void HalLed_TurnOff(uint8_t ledIndex)
{
	// None
}

void HalLed_TurnToggle(uint8_t ledIndex)
{
	// None
}

void HalLed_OnToOff(uint8_t ledIndex, uint32_t delayTime)
{
	// None
}

void HalLed_OffToOn(uint8_t ledIndex, uint32_t delayTime)
{
	// None
}

void HalLed_PeriodicBlink(uint8_t ledIndex, uint32_t delayTime, uint32_t blinkTime, uint16_t periodicTime)
{
	// None
}

void HalLed_PatternBlink(uint8_t ledIndex, uint32_t delayTime, uint32_t blinkTime, uint8_t length, uint16_t *pattern)
{
	// None
}

bool HalLed_IsBusy(uint8_t ledIndex)
{
	// None
	return 0;
}

void HalLed_SetActivityNetworkLed(uint8_t ledIndex)
{
	// None
}

uint8_t HalLed_GetActivityNetworkLed(void)
{
	// None
	return 0;
}

void HalLed_NetworkBlinkOfStatusIndication(uint32_t waitTime)
{
	// None
}

void HalLed_NetworkBlinkOfSearch(uint32_t delayTime, uint32_t blinkTime)
{
	// None
}

void HalLed_NetworkBlinkOfPreoperation(uint32_t delayTime, uint32_t blinkTime)
{
	// None
}

void HalLed_NetworkBlinkOfJoinSuccess(uint32_t delayTime, uint32_t blinkTime)
{
	// None
}

void HalLed_NetworkBlinkOfJoinFailure(uint32_t delayTime, uint32_t blinkTime)
{
	// None
}

void HalLed_NetworkBlinkOfIdentify(uint32_t delayTime, uint32_t blinkTime)
{
	// None
}

WEAK(void w_HalLed_ControlCompleteCallback(uint8_t ledIndex, uint8_t ledState))
{
	// None
}

#if defined(DHL_LED_CONTROL_DIVERSIFY_ENABLE) && (DHL_LED_CONTROL_DIVERSIFY_ENABLE != FALSE)
void HalLed_DiversifyBlinkRegister(uint8_t ledIndex, uint32_t delayTime, uint32_t blinkTime,
	uint8_t length, uint16_t *pattern, tpHalLedBlinkDiversifyCallback callback)
{
	// None
}
#endif // DHL_LED_CONTROL_DIVERSIFY_ENABLE
#else
//==================================================================================
// Variable declaration
//-----------------------------------------------------------------------------
// Enumeration
typedef enum {
	E_LED_NONE = 0x00,
	E_LED_ON_TO_OFF,
	E_LED_OFF_TO_ON,
	E_LED_BLINK_PATTERN,
	E_LED_DIVERSIFY_PATTERN,
}teLedBlinkState;

//-----------------------------------------------------------------------------
// Structure
typedef struct {
	GPIO_Port_TypeDef	port;
	unsigned int		pin;
	bool				polarity;
}tsLedGpio;

typedef struct {
	uint8_t		u8State;
	uint8_t		u8PatternIndex;
	uint8_t		u8Patternlength;
	uint16_t	u16BlinkCount;
	uint16_t	u16szPatternTime[DHL_BLINK_PATTERN_MAX_LENGTH];

#if defined(DHL_LED_CONTROL_DIVERSIFY_ENABLE) && (DHL_LED_CONTROL_DIVERSIFY_ENABLE != FALSE)
	tpHalLedBlinkDiversifyCallback pHalLedBlinkDiversifyCallback;
#endif
}tsLedControl;

//-----------------------------------------------------------------------------
// Local variable
EmberEventControl HalLed0EventControl;
EmberEventControl HalLed1EventControl;

static uint8_t u8ActiveLed = 0;
static const tsLedGpio sLedGpio[DHL_LED_NUMBER] = DHAL_LED_INIT;
static tsLedControl sLedControl[DHL_LED_NUMBER];

static uint16_t u16szBlinkPatternPreoperation[] =
{
	DHL_LED_PREOPERATION_BLINK_ON_TIME_MS,
	DHL_LED_PREOPERATION_BLINK_OFF_TIME_MS,
};

static uint16_t u16szBlinkPatternSearch[] =
{
	DHL_LED_SEARCH_BLINK_ON_TIME_MS,
	DHL_LED_SEARCH_BLINK_OFF_TIME_MS,
};

static uint16_t u16szBlinkPatternJoinSuccess[] =
{
	DHL_LED_JOIN_OK_BLINK_ON_TIME_MS,
	DHL_LED_JOIN_OK_BLINK_OFF_TIME_MS,
};

static uint16_t u16szBlinkPatternJoinFailure[] =
{
	DHL_LED_JOIN_FAIL_BLINK_ON_TIME_MS,
	DHL_LED_JOIN_FAIL_BLINK_OFF_TIME_MS,
};

static uint16_t u16szBlinkPatternIdentify[] =
{
	DHL_LED_IDENTIFY_BLINK_ON_TIME_MS,
	DHL_LED_IDENTIFY_BLINK_OFF1_TIME_MS,
	DHL_LED_IDENTIFY_BLINK_ON_TIME_MS,
	DHL_LED_IDENTIFY_BLINK_OFF2_TIME_MS,
};


//==================================================================================
// Local function declaration
void halLed_ControlInit(void);
uint32_t halLed_ControlHandle(uint8_t ledIndex);
void halLed_ControlStart(uint8_t ledIndex, uint32_t delayTime);

//==================================================================================
// Event function declaration
void HalLed0EventFunction(void);
void HalLed1EventFunction(void);

//==================================================================================
// Local function
/******************************************************************************
 * Description : Leds control array parameter initialization.
 * Parameter   : void
 * Return      : void
 *****************************************************************************/
void halLed_ControlInit(void)
{
	for (uint8_t i = 0; i < DHL_LED_NUMBER; i++)
	{
		sLedControl[i].u8State = E_LED_NONE;
		sLedControl[i].u8PatternIndex = 0;
		sLedControl[i].u8Patternlength = 0;
		sLedControl[i].u16BlinkCount = 0;
		memset(sLedControl[i].u16szPatternTime, 0, sizeof(sLedControl[i].u16szPatternTime));
	}
}

/******************************************************************************
 * Description : Leds control handle function.
 * Parameter   : @ledIndex
 * Return      : @nRetTimeMs - The event next running time
 *****************************************************************************/
uint32_t halLed_ControlHandle(uint8_t ledIndex)
{
	uint8_t i = 0;
	uint32_t nRetTimeMs = 0;
	if (ledIndex < DHL_LED_NUMBER)
	{
		switch (sLedControl[ledIndex].u8State)
		{
		case E_LED_ON_TO_OFF:
			// was on. this must be time to turn it off.
			HalLed_TurnOff(ledIndex);
			break;

		case E_LED_OFF_TO_ON:
			// was on. this must be time to turn it off.
			HalLed_TurnOn(ledIndex);
			break;

		case E_LED_BLINK_PATTERN:
			if (sLedControl[ledIndex].u16BlinkCount > 0)
			{
				if ((sLedControl[ledIndex].u8PatternIndex % 2) == 0)
				{
					HalLed_TurnOn(ledIndex);
				}
				else
				{
					HalLed_TurnOff(ledIndex);
				}
				nRetTimeMs = sLedControl[ledIndex].u16szPatternTime[sLedControl[ledIndex].u8PatternIndex];

				sLedControl[ledIndex].u8PatternIndex++;
				if (sLedControl[ledIndex].u8PatternIndex >= sLedControl[ledIndex].u8Patternlength)
				{
					sLedControl[ledIndex].u8PatternIndex = 0;
					if (sLedControl[ledIndex].u16BlinkCount != 65535) // blink forever if count is 65535
					{
						sLedControl[ledIndex].u16BlinkCount--;
					}
				}

				if(nRetTimeMs == 0) // u16szPatternTime[] The array element has a value of 0
				{
					HalLed_TurnOff(ledIndex);
					sLedControl[ledIndex].u8PatternIndex = 0;
					sLedControl[ledIndex].u16BlinkCount = 0;
				}
			}
			else
			{
				HalLed_TurnOff(ledIndex);
			}
			break;

		case E_LED_DIVERSIFY_PATTERN:
			#if defined(DHL_LED_CONTROL_DIVERSIFY_ENABLE) && (DHL_LED_CONTROL_DIVERSIFY_ENABLE != FALSE)
				if (sLedControl[ledIndex].u16BlinkCount > 0)
				{
					if(sLedControl[ledIndex].pHalLedBlinkDiversifyCallback != NULL)
					{
						sLedControl[ledIndex].pHalLedBlinkDiversifyCallback(ledIndex, sLedControl[ledIndex].u8PatternIndex);
					}
					nRetTimeMs = sLedControl[ledIndex].u16szPatternTime[sLedControl[ledIndex].u8PatternIndex];

					sLedControl[ledIndex].u8PatternIndex++;
					if (sLedControl[ledIndex].u8PatternIndex >= sLedControl[ledIndex].u8Patternlength)
					{
						sLedControl[ledIndex].u8PatternIndex = 0;
						if (sLedControl[ledIndex].u16BlinkCount != 65535) // blink forever if count is 65535
						{
							sLedControl[ledIndex].u16BlinkCount--;
						}
					}

					if(nRetTimeMs == 0) // u16szPatternTime[] The array element has a value of 0
					{
						/*for (i = 0; i < DHL_LED_NUMBER; i++)
						{
							HalLed_TurnOff(i);
						} // */
						sLedControl[ledIndex].u8PatternIndex = 0;
						sLedControl[ledIndex].u16BlinkCount = 0;
					}
				}
				else
				{
					/*for (i = 0; i < DHL_LED_NUMBER; i++)
					{
						HalLed_TurnOff(i);
					} // */
				}
			#endif // DHL_LED_CONTROL_DIVERSIFY_ENABLE
			break;

		default:
			break;
		}
	}

	if(nRetTimeMs == 0)
	{
		w_HalLed_ControlCompleteCallback(ledIndex, sLedControl[ledIndex].u8State);
		sLedControl[ledIndex].u8State = E_LED_NONE;
	}
	return nRetTimeMs;
}

/******************************************************************************
 * Description : Leds control start.
 * Parameter   : @ledIndex
 * 				@delayTime
 * Return      : void
 *****************************************************************************/
void halLed_ControlStart(uint8_t ledIndex, uint32_t delayTime)
{
	if(ledIndex == 0)
	{
		emberEventControlSetDelayMS(HalLed0EventControl, delayTime);
	}
	else if(ledIndex == 1)
	{
		emberEventControlSetDelayMS(HalLed1EventControl, delayTime);
	}
}



//==================================================================================
// Event function
/******************************************************************************
 * Description : Led0 event function.
 * Parameter   : void
 * Return      : void
 *****************************************************************************/
void HalLed0EventFunction(void)
{
	emberEventControlSetInactive(HalLed0EventControl);

	uint32_t nNextTimeMs = halLed_ControlHandle(0);
	if (nNextTimeMs > 0)
	{
		emberEventControlSetDelayMS(HalLed0EventControl, nNextTimeMs);
	}
}

/******************************************************************************
 * Description : Led1 event function.
 * Parameter   : void
 * Return      : void
 *****************************************************************************/
void HalLed1EventFunction(void)
{
	emberEventControlSetInactive(HalLed1EventControl);

	uint32_t nNextTimeMs = halLed_ControlHandle(1);
	if (nNextTimeMs > 0)
	{
		emberEventControlSetDelayMS(HalLed1EventControl, nNextTimeMs);
	}
}


//==================================================================================
// Extend function
/******************************************************************************
 * Description : LED Initialization.
 * Parameter   : void
 * Return      : void
 *****************************************************************************/
void HalLed_Init(void)
{
#if !defined(_SILICON_LABS_32B_SERIES_2)
	CMU_ClockEnable(cmuClock_HFPER, true);
#endif //!defined(_SILICON_LABS_32B_SERIES_2)
	CMU_ClockEnable(cmuClock_GPIO, true);
	for (uint8_t i = 0; i < DHL_LED_NUMBER; i++)
	{
	#if defined(CORTEXM3_EM3585) // architecture is EM35x
		if(sLedGpio[i].polarity == DHL_LED_LOW_POLARITY)
		{
			HalGpio_ConfigOutLow((sLedGpio[i].port << 3) | sLedGpio[i].pin);
		}
		else // DHL_LED_HIGH_POLARITY
		{
			HalGpio_ConfigOutHigh((sLedGpio[i].port << 3) | sLedGpio[i].pin);
		}
	#elif defined(CORTEXM3_EFR32)
		GPIO_PinModeSet(sLedGpio[i].port, sLedGpio[i].pin, gpioModePushPull, (unsigned int)sLedGpio[i].polarity);
	#endif
	}
	// PWM control can be added later.

	HalLedPrintln("HalLed_Init ledNum=%d", DHL_LED_NUMBER);
	halLed_ControlInit();
}

/******************************************************************************
 * Description : Control the LED light on.
 * Parameter   : @ledIndex
 * Return      : void
 *****************************************************************************/
void HalLed_TurnOn(uint8_t ledIndex)
{
	if (ledIndex >= DHL_LED_NUMBER)
	{
		return;
	}

#if defined(CORTEXM3_EM3585) // architecture is EM35x
	if(sLedGpio[ledIndex].polarity == DHL_LED_LOW_POLARITY)
	{
		HalGpio_SetOutLow((sLedGpio[ledIndex].port << 3) | sLedGpio[ledIndex].pin); // Output low level, Led on.
	}
	else // DHL_LED_HIGH_POLARITY
	{
		HalGpio_SetOutHigh((sLedGpio[ledIndex].port << 3) | sLedGpio[ledIndex].pin); // Output high level, Led on.
	}
#elif defined(CORTEXM3_EFR32)
	if(sLedGpio[ledIndex].polarity == DHL_LED_LOW_POLARITY)
	{
		GPIO_PinOutClear(sLedGpio[ledIndex].port, sLedGpio[ledIndex].pin); // Output low level, Led on.
	}
	else // DHL_LED_HIGH_POLARITY
	{
		GPIO_PinOutSet(sLedGpio[ledIndex].port, sLedGpio[ledIndex].pin); // Output high level, Led on.
	}
#endif
	// PWM control can be added later

	//HalLedPrintln("HalLed_TurnOn ledIndex=%d", ledIndex);
}

/******************************************************************************
 * Description : Control the LED light off.
 * Parameter   : @ledIndex
 * Return      : void
 *****************************************************************************/
void HalLed_TurnOff(uint8_t ledIndex)
{
	if (ledIndex >= DHL_LED_NUMBER)
	{
		return;
	}

#if defined(CORTEXM3_EM3585) // architecture is EM35x
	if(sLedGpio[ledIndex].polarity == DHL_LED_LOW_POLARITY)
	{
		HalGpio_SetOutHigh((sLedGpio[ledIndex].port << 3) | sLedGpio[ledIndex].pin); // Output High level, light off.
	}
	else // DHL_LED_HIGH_POLARITY
	{
		HalGpio_SetOutLow((sLedGpio[ledIndex].port << 3) | sLedGpio[ledIndex].pin); // Output Low level, light off.
	}
#elif defined(CORTEXM3_EFR32)
	if(sLedGpio[ledIndex].polarity == DHL_LED_LOW_POLARITY)
	{
		GPIO_PinOutSet(sLedGpio[ledIndex].port, sLedGpio[ledIndex].pin); // Output High level, light off.
	}
	else // DHL_LED_HIGH_POLARITY
	{
		GPIO_PinOutClear(sLedGpio[ledIndex].port, sLedGpio[ledIndex].pin); // Output Low level, light off.
	}
#endif
	// PWM control can be added later

	//HalLedPrintln("HalLed_TurnOff ledIndex=%d", ledIndex);
}

/******************************************************************************
 * Description : Control the LED light Toggle on/off.
 * Parameter   : @ledIndex
 * Return      : void
 *****************************************************************************/
void HalLed_TurnToggle(uint8_t ledIndex)
{
	if (ledIndex >= DHL_LED_NUMBER)
	{
		return;
	}

#if defined(CORTEXM3_EM3585) // architecture is EM35x
	// Not supported for now
#elif defined(CORTEXM3_EFR32)
	GPIO_PinOutToggle(sLedGpio[ledIndex].port, sLedGpio[ledIndex].pin); // Output Low level, light off.
#endif
	// PWM control can be added later

	//HalLedPrintln("HalLed_TurnToggle ledIndex=%d", ledIndex);
}

/******************************************************************************
 * Description : Control LED to turn on, then delay to turn it off.
 * Parameter   : @ledIndex
 * 				@onTime unit ms
 * Return      : void
 *****************************************************************************/
void HalLed_OnToOff(uint8_t ledIndex, uint32_t onTime)
{
	if((ledIndex >= DHL_LED_NUMBER) || (onTime == 0))
	{
		if(onTime == 0)
		{
			HalLed_TurnOff(ledIndex);
		}
		return;
	}

	HalLed_TurnOn(ledIndex);
	sLedControl[ledIndex].u8State = E_LED_ON_TO_OFF;

	halLed_ControlStart(ledIndex, onTime);
	HalLedPrintln("HalLed_OnToOff ledIndex=%d,onTime=%d", ledIndex, onTime);
}

/******************************************************************************
 * Description : Control LED to turn off, then delay to turn it on.
 * Parameter   : @ledIndex
 * 				@offTime unit ms
 * Return      : void
 *****************************************************************************/
void HalLed_OffToOn(uint8_t ledIndex, uint32_t offTime)
{
	if((ledIndex >= DHL_LED_NUMBER) || (offTime == 0))
	{
		if(offTime == 0)
		{
			HalLed_TurnOn(ledIndex);
		}
		return;
	}

	HalLed_TurnOff(ledIndex);
	sLedControl[ledIndex].u8State = E_LED_OFF_TO_ON;

	halLed_ControlStart(ledIndex, offTime);
	HalLedPrintln("HalLed_OffToOn ledIndex=%d,offTime=%d", ledIndex, offTime);
}

/******************************************************************************
 * Description : Control LED periodic Blink.
 * Parameter   : @ledIndex
 *				@delayTime unit ms
 *				@blinkTime unit ms
 *				@periodicTime unit ms
 * Return      : void
 *****************************************************************************/
void HalLed_PeriodicBlink(uint8_t ledIndex, uint32_t delayTime, uint32_t blinkTime, uint16_t periodicTime)
{
	uint16_t nCount = 0;

	if(periodicTime == 0)
	{
		sLedControl[ledIndex].u16BlinkCount = 0;
		return;
	}
	nCount = blinkTime / (periodicTime * 2);
	if((ledIndex >= DHL_LED_NUMBER) || (blinkTime == 0) || (nCount == 0))
	{
		if(nCount == 0)
		{
			sLedControl[ledIndex].u16BlinkCount = 0;
		}
		return;
	}

	HalLed_TurnOff(ledIndex);
	sLedControl[ledIndex].u8State = E_LED_BLINK_PATTERN;
	sLedControl[ledIndex].u8PatternIndex = 0;
	sLedControl[ledIndex].u8Patternlength = 2;
	sLedControl[ledIndex].u16BlinkCount = nCount;
	sLedControl[ledIndex].u16szPatternTime[0] = periodicTime;
	sLedControl[ledIndex].u16szPatternTime[1] = periodicTime;
#if defined(DHL_LED_CONTROL_DIVERSIFY_ENABLE) && (DHL_LED_CONTROL_DIVERSIFY_ENABLE != FALSE)
	sLedControl[ledIndex].pHalLedBlinkDiversifyCallback = NULL;
#endif

	halLed_ControlStart(ledIndex, delayTime);
	HalLedPrintln("HalLed_PeriodicBlink ledIndex=%d,delayTime=%d,blinkTime=%d,periodicTime=%d",
			ledIndex, delayTime, blinkTime, periodicTime);
}

/******************************************************************************
 * Description : Control LED Pattern Blink.
 * Parameter   : @ledIndex
 * 				@delayTime unit ms
 * 				@blinkTime unit ms
 * 				@length of *pattern length
 * 				@*pattern unit ms
 * Return      : void
 *****************************************************************************/
void HalLed_PatternBlink(uint8_t ledIndex, uint32_t delayTime, uint32_t blinkTime, uint8_t length, uint16_t *pattern)
{
	uint8_t i = 0;
	uint16_t nCount = 0;
	uint32_t nTime = 0;
	for (i = 0; i < length; i++)
	{
		sLedControl[ledIndex].u16szPatternTime[i] = pattern[i];
		nTime += pattern[i];
	}
	if(nTime == 0)
	{
		sLedControl[ledIndex].u16BlinkCount = 0;
		return;
	}
	nCount = blinkTime / nTime;

	if((ledIndex >= DHL_LED_NUMBER) || (blinkTime == 0) || (length == 0) || (nCount == 0))
	{
		if(nCount == 0)
		{
			sLedControl[ledIndex].u16BlinkCount = 0;
		}
		return;
	}

	HalLed_TurnOff(ledIndex);
	sLedControl[ledIndex].u8State = E_LED_BLINK_PATTERN;
	sLedControl[ledIndex].u8PatternIndex = 0;
	sLedControl[ledIndex].u8Patternlength = length;
	sLedControl[ledIndex].u16BlinkCount = nCount;
#if defined(DHL_LED_CONTROL_DIVERSIFY_ENABLE) && (DHL_LED_CONTROL_DIVERSIFY_ENABLE != FALSE)
	sLedControl[ledIndex].pHalLedBlinkDiversifyCallback = NULL;
#endif

	halLed_ControlStart(ledIndex, delayTime);
	HalLedPrintln("HalLed_PatternBlink ledIndex=%d,delayTime=%d,blinkTime=%d,length=%d,nCount=%d",
				ledIndex, delayTime, blinkTime, length, nCount);
}

/******************************************************************************
 * Description : Control LED Complete Callback.
 * Parameter   : @ledIndex
 * Return      : void
 *****************************************************************************/
bool HalLed_IsBusy(uint8_t ledIndex)
{
	bool nBusy = 0;
	if(ledIndex >= DHL_LED_NUMBER)
	{
		return nBusy;
	}

	if(ledIndex == 0)
	{
		if(emberEventControlGetActive(HalLed0EventControl))
			nBusy = 1;
	}
	else if(ledIndex == 1)
	{
		if(emberEventControlGetActive(HalLed1EventControl))
			nBusy = 1;
	}
	HalLedPrintln("HalLed_IsBusy ledIndex=%d,nBusy=%d", ledIndex, nBusy);
	return nBusy;
}

/******************************************************************************
 * Description : Set Activity Network Led Index.
 * Parameter   : @ledIndex
 * Return      : void
 *****************************************************************************/
void HalLed_SetActivityNetworkLed(uint8_t ledIndex)
{
	if(ledIndex >= DHL_LED_NUMBER)
	{
		return;
	}

	u8ActiveLed = ledIndex;
	HalLedPrintln("HalLed_SetActivityNetworkLed ledIndex=%d", ledIndex);
}

/******************************************************************************
 * Description : Get Activity Network Led Index.
 * Parameter   : void
 * Return      : u8ActiveLed
 *****************************************************************************/
uint8_t HalLed_GetActivityNetworkLed(void)
{
	return u8ActiveLed;
}

/******************************************************************************
 * Description : Control LED blink when Status indication.
 * Parameter   : @blinkTime unit ms
 * Return      : void
 *****************************************************************************/
void HalLed_NetworkBlinkOfStatusIndication(uint32_t blinkTime)
{
	//HalLedPrintln("HalLed_NetworkBlinkOfStatusIndication blinkTime=%d", blinkTime);
	HalLed_OnToOff(u8ActiveLed, blinkTime);
}

/******************************************************************************
 * Description : Control LED blink when preoperation.
 * Parameter   : @delayTime unit ms
 * 				@blinkTime unit ms
 * Return      : void
 *****************************************************************************/
void HalLed_NetworkBlinkOfPreoperation(uint32_t delayTime, uint32_t blinkTime)
{
	HalLedPrintln("HalLed_NetworkBlinkOfPreoperation delayTime=%d,blinkTime=%d", delayTime, blinkTime);
	HalLed_PatternBlink(u8ActiveLed, delayTime, blinkTime, COUNTOF(u16szBlinkPatternPreoperation), u16szBlinkPatternPreoperation);
}

/******************************************************************************
 * Description : Control LED blink when searching the network.
 * Parameter   : @delayTime unit ms
 * 				@blinkTime unit ms
 * Return      : void
 *****************************************************************************/
void HalLed_NetworkBlinkOfSearch(uint32_t delayTime, uint32_t blinkTime)
{
	HalLedPrintln("HalLed_NetworkBlinkOfSearch delayTime=%d,blinkTime=%d", delayTime, blinkTime);
	HalLed_PatternBlink(u8ActiveLed, delayTime, blinkTime, COUNTOF(u16szBlinkPatternSearch), u16szBlinkPatternSearch);
}

/******************************************************************************
 * Description : Control LED blink when join/rejoin network success.
 * Parameter   : @delayTime unit ms
 * 				@blinkTime unit ms
 * Return      : void
 *****************************************************************************/
void HalLed_NetworkBlinkOfJoinSuccess(uint32_t delayTime, uint32_t blinkTime)
{
	HalLedPrintln("HalLed_NetworkBlinkOfJoinSuccess delayTime=%d,blinkTime=%d", delayTime, blinkTime);
	HalLed_PatternBlink(u8ActiveLed, delayTime, blinkTime, COUNTOF(u16szBlinkPatternJoinSuccess), u16szBlinkPatternJoinSuccess);
}

/******************************************************************************
 * Description : Control LED blink when join network failure or leave network.
 * Parameter   : @delayTime unit ms
 * 				@blinkTime unit ms
 * Return      : void
 *****************************************************************************/
void HalLed_NetworkBlinkOfJoinFailure(uint32_t delayTime, uint32_t blinkTime)
{
	HalLedPrintln("HalLed_NetworkBlinkOfJoinFailure delayTime=%d,blinkTime=%d", delayTime, blinkTime);
	HalLed_PatternBlink(u8ActiveLed, delayTime, blinkTime, COUNTOF(u16szBlinkPatternJoinFailure), u16szBlinkPatternJoinFailure);
}

/******************************************************************************
 * Description : Control network LED blink when identify device.
 * Parameter   : @delayTime unit ms
 * 				@blinkTime unit ms
 * Return      : void
 *****************************************************************************/
void HalLed_NetworkBlinkOfIdentify(uint32_t delayTime, uint32_t blinkTime)
{
	HalLedPrintln("HalLed_NetworkBlinkOfIdentify delayTime=%d,blinkTime=%d", delayTime, blinkTime);
	HalLed_PatternBlink(u8ActiveLed, delayTime, blinkTime, COUNTOF(u16szBlinkPatternIdentify), u16szBlinkPatternIdentify);
}

/******************************************************************************
 * Description : Control LED Complete Callback.
 * Parameter   : @ledIndex
 * 				@ledState
 * Return      : void
 *****************************************************************************/
WEAK(void w_HalLed_ControlCompleteCallback(uint8_t ledIndex, uint8_t ledState))
{
	HalLedPrintln("HL--w_HalLed_ControlCompleteCallback ledIndex=%d,ledState=%d", ledIndex, ledState);
}

#if defined(DHL_LED_CONTROL_DIVERSIFY_ENABLE) && (DHL_LED_CONTROL_DIVERSIFY_ENABLE != FALSE)
/******************************************************************************
 * Description : Control LED Pattern Diversify Blink and register callback function.
 * Parameter   : @ledIndex
 * 				@delayTime unit ms
 * 				@blinkTime unit ms
 * 				@length of *pattern length
 * 				@*pattern unit ms
 * 				@callback callback function
 * Return      : void
 *****************************************************************************/
void HalLed_DiversifyBlinkRegister(uint8_t ledIndex, uint32_t delayTime, uint32_t blinkTime,
	uint8_t length, uint16_t *pattern, tpHalLedBlinkDiversifyCallback callback)
{
	uint8_t i = 0;
	uint16_t nCount = 0;
	uint32_t nTime = 0;

	for (i = 0; i < length; i++)
	{
		sLedControl[ledIndex].u16szPatternTime[i] = pattern[i];
		nTime += pattern[i];
	}
	nCount = blinkTime / nTime;

	if((ledIndex >= DHL_LED_NUMBER) || (blinkTime == 0) || (length == 0) || (nCount == 0))
	{
		return;
	}

	HalLed_TurnOff(ledIndex);
	sLedControl[ledIndex].u8State = E_LED_DIVERSIFY_PATTERN;
	sLedControl[ledIndex].u8PatternIndex = 0;
	sLedControl[ledIndex].u8Patternlength = length;
	sLedControl[ledIndex].u16BlinkCount = nCount;
	sLedControl[ledIndex].pHalLedBlinkDiversifyCallback = callback;

	halLed_ControlStart(ledIndex, delayTime);
	HalLedPrintln("HalLed_DiversifyBlinkRegister ledIndex=%d,delayTime=%d,blinkTime=%d,length=%d,nCount=%d",
				ledIndex, delayTime, blinkTime, length, nCount);
}
#endif // DHL_LED_CONTROL_DIVERSIFY_ENABLE


#endif // DHL_LED_NUMBER

源码HalLED.h

/***********************************************************************************
* File        : HalLED.h
* Description : Hardware LED function.
* Author      : Chilli
* Date        : 2022.2.7
* Version     : 1.0.1
***********************************************************************************/
#ifndef HAL_LED_H_
#define HAL_LED_H_

//==================================================================================
// Include head file


//==================================================================================
// Macro definition
// DHL(Define Hal LED)
#ifndef DHL_LED_CONFIG_METHODS
	#define DHL_LED_CONFIG_METHODS							1			// LED Config Methods: 0 is SDK, 1 is User
#endif

#if defined(DHL_LED_CONFIG_METHODS)
	#if (DHL_LED_CONFIG_METHODS == 0)
		#ifndef DHL_LED_BLINK_PROBLEM_RESOLVE_ENABLE
			#define DHL_LED_BLINK_PROBLEM_RESOLVE_ENABLE	1			// 0 is Disable, 1 is enable
		#endif

		#ifndef DHL_UI_LED_ENABLE
			#define DHL_UI_LED_ENABLE						1			// 0 is Disable, 1 is enable
		#endif

		#ifndef DHL_LED_NWK_DRIVE_METHODS
			#define DHL_LED_NWK_DRIVE_METHODS				0			// Network LED Drive Methods: 0 is GPIO, 1 is PWM
		#endif
	#elif (DHL_LED_CONFIG_METHODS == 1)
		#define DHL_LED_HIGH_POLARITY						1			// High polarity
		#define DHL_LED_LOW_POLARITY						0			// Low polarity

		#ifndef DHL_LED_NUMBER
			#define DHL_LED_NUMBER							0
		#endif

		#ifndef DHL_LED_CONTROL_DIVERSIFY_ENABLE
			#define DHL_LED_CONTROL_DIVERSIFY_ENABLE		0			// LED Control Diversify: 0 is Disable, 1 is enable
		#endif

		#ifndef DHL_LED_NWK_DRIVE_METHODS
			#define DHL_LED_NWK_DRIVE_METHODS				0			// Network LED Drive Methods: 0 is GPIO, 1 is PWM
		#endif

		#ifndef DHL_BLINK_PATTERN_MAX_LENGTH
			#define DHL_BLINK_PATTERN_MAX_LENGTH			20
		#endif

//		#ifndef DHL_LED_PREOPERATION_BLINK_TIME_MS
//			#define DHL_LED_PREOPERATION_BLINK_TIME_MS		300			// time of the LED blink for preoperation.
//		#endif

		#ifndef DHL_LED_PREOPERATION_BLINK_ON_TIME_MS
			#define DHL_LED_PREOPERATION_BLINK_ON_TIME_MS	150			//
		#endif

		#ifndef DHL_LED_PREOPERATION_BLINK_OFF_TIME_MS
			#define DHL_LED_PREOPERATION_BLINK_OFF_TIME_MS	150			//
		#endif

//		#ifndef DHL_LED_SEARCH_BLINK_TIME_MS
//			#define DHL_LED_SEARCH_BLINK_TIME_MS			60000		// time of the LED blink for search network.
//		#endif

		#ifndef DHL_LED_SEARCH_BLINK_ON_TIME_MS
			#define DHL_LED_SEARCH_BLINK_ON_TIME_MS			100			//
		#endif

		#ifndef DHL_LED_SEARCH_BLINK_OFF_TIME_MS
			#define DHL_LED_SEARCH_BLINK_OFF_TIME_MS		100			//
		#endif

//		#ifndef DHL_LED_JOIN_OK_BLINK_TIME_MS
//			#define DHL_LED_JOIN_OK_BLINK_TIME_MS			3100		// time of the LED blink for join/rejoin network successful.
//		#endif

		#ifndef DHL_LED_JOIN_OK_BLINK_ON_TIME_MS
			#define DHL_LED_JOIN_OK_BLINK_ON_TIME_MS		3000		//
		#endif

		#ifndef DHL_LED_JOIN_OK_BLINK_OFF_TIME_MS
			#define DHL_LED_JOIN_OK_BLINK_OFF_TIME_MS		100			//
		#endif

//		#ifndef DHL_LED_JOIN_FAIL_BLINK_TIME_MS
//			#define DHL_LED_JOIN_FAIL_BLINK_TIME_MS			3000		// time of the LED blink for join network failure or leave network.
//		#endif

		#ifndef DHL_LED_JOIN_FAIL_BLINK_ON_TIME_MS
			#define DHL_LED_JOIN_FAIL_BLINK_ON_TIME_MS		250			//
		#endif

		#ifndef DHL_LED_JOIN_FAIL_BLINK_OFF_TIME_MS
			#define DHL_LED_JOIN_FAIL_BLINK_OFF_TIME_MS		250			//
		#endif

//		#ifndef DHL_LED_IDENTIFY_BLINK_TIME_MS
//			#define DHL_LED_IDENTIFY_BLINK_TIME_MS			10000		// time of times the LED blink for identify device.
//		#endif

		#ifndef DHL_LED_IDENTIFY_BLINK_ON_TIME_MS
			#define DHL_LED_IDENTIFY_BLINK_ON_TIME_MS		100			//
		#endif

		#ifndef DHL_LED_IDENTIFY_BLINK_OFF1_TIME_MS
			#define DHL_LED_IDENTIFY_BLINK_OFF1_TIME_MS		200			//
		#endif

		#ifndef DHL_LED_IDENTIFY_BLINK_OFF2_TIME_MS
			#define DHL_LED_IDENTIFY_BLINK_OFF2_TIME_MS		600			//
		#endif

		#if defined(DHL_LED_CONTROL_DIVERSIFY_ENABLE) && (DHL_LED_CONTROL_DIVERSIFY_ENABLE != FALSE)
			typedef void (*tpHalLedBlinkDiversifyCallback)(uint8_t ledIndex, uint8_t ledControlIndex);
		#endif
	#endif
#endif // DHL_LED_CONFIG_METHODS




//==================================================================================
// Variable declaration
//-----------------------------------------------------------------------------
// Enumeration

//-----------------------------------------------------------------------------
// Structure

//-----------------------------------------------------------------------------
// Extend variable


//==================================================================================
// Extend function declaration
void HalLed_Init(void);
void HalLed_TurnOn(uint8_t ledIndex);
void HalLed_TurnOff(uint8_t ledIndex);
void HalLed_TurnToggle(uint8_t ledIndex);

void HalLed_OnToOff(uint8_t ledIndex, uint32_t onTime);
void HalLed_OffToOn(uint8_t ledIndex, uint32_t offTime);
void HalLed_PeriodicBlink(uint8_t ledIndex, uint32_t delayTime, uint32_t blinkTime, uint16_t periodicTime);
void HalLed_PatternBlink(uint8_t ledIndex, uint32_t delayTime, uint32_t blinkTime, uint8_t length, uint16_t *pattern);
bool HalLed_IsBusy(uint8_t ledIndex);

void HalLed_SetActivityNetworkLed(uint8_t ledIndex);
uint8_t HalLed_GetActivityNetworkLed(void);

void HalLed_NetworkBlinkOfStatusIndication(uint32_t blinkTime);
void HalLed_NetworkBlinkOfPreoperation(uint32_t delayTime, uint32_t blinkTime);
void HalLed_NetworkBlinkOfSearch(uint32_t delayTime, uint32_t blinkTime);
void HalLed_NetworkBlinkOfJoinSuccess(uint32_t delayTime, uint32_t blinkTime);
void HalLed_NetworkBlinkOfJoinFailure(uint32_t delayTime, uint32_t blinkTime);
void HalLed_NetworkBlinkOfIdentify(uint32_t delayTime, uint32_t blinkTime);

void w_HalLed_ControlCompleteCallback(uint8_t ledIndex, uint8_t ledState);

#if defined(DHL_LED_CONTROL_DIVERSIFY_ENABLE) && (DHL_LED_CONTROL_DIVERSIFY_ENABLE != FALSE)
	void HalLed_DiversifyBlinkRegister(uint8_t ledIndex, uint32_t delayTime, uint32_t blinkTime,
		uint8_t length, uint16_t *pattern, tpHalLedBlinkDiversifyCallback callback);

/* Use example:
1. Define the blink pattern time.
#define DHAL_LED_DIVERSIFY_BLINK_TIME_MS	{1000, 1000, 990, 10}

2. Declaration pattern time array.
static uint16_t u16szBlinkPatternDiversify[] = DHAL_LED_DIVERSIFY_BLINK_TIME_MS;

3. Define the callback function
void userApp_LedBlinkDiversifyCallback(uint8_t ledIndex, uint8_t ledControlIndex)
{
	HalLedPrintln("UMA--userApp_LedBlinkDiversifyCallback ledIndex=%d,ledControlIndex=%d", ledIndex, ledControlIndex);

	// LED control diversity sample code:
	// The hardware has red and green two-color LED. The control requirements are green bright 1000ms,
	// yellow bright 1000ms, red bright 990ms, and all led off 10ms.

	switch(ledControlIndex)
	{
	case 0:
		HalLed_TurnOff(0);	// green off
		HalLed_TurnOn(1);	// red on
		break;
	case 1:
		HalLed_TurnOn(0);	// green on
		HalLed_TurnOff(1);	// red off
		break;
	case 2:
		HalLed_TurnOn(0);	// green on -- yellow
		HalLed_TurnOn(1);	// red on
		break;
	case 3:
		HalLed_TurnOff(0);	// green off
		HalLed_TurnOff(1);	// red off
		break;
	default:
		break;
	}
}

4. Use the registration callback function.
void gasSensorPreheatingLedBlink(void)
{
	HalLed_DiversifyBlinkRegister(0, 0, 180000, COUNTOF(u16szBlinkPatternDiversify),
		u16szBlinkPatternDiversify, userApp_LedBlinkDiversifyCallback);
}
*/
#endif

#endif // HAL_LED_H_


芯片引脚宏定义

// LED >>>
#define DHAL_LED_NUMBER								2			// Number of LED
#define DHL_LED_NUMBER								DHAL_LED_NUMBER
//#define DHL_LED_CONTROL_DIVERSIFY_ENABLE			1			// LED Control Diversify: 0 is Disable, 1 is enable
#if (DHAL_LED_NUMBER >= 1)
	#if defined(CORTEXM3_EM3585)
		#define DHAL_LED0_PIN_INDEX					0
		#define DHAL_LED0_PORT						(gpioPortA)
		#define DHAL_LED0_PIN						(2U)
		#define DHAL_LED0_PINS						PORTA_PIN(2)
		#define DHAL_LED0_POLARITY					0
	#elif defined(CORTEXM3_EFR32)
		#define DHAL_LED0_PIN_INDEX					0
		#define DHAL_LED0_PORT						(gpioPortF)
		#define DHAL_LED0_PIN						(6U)
		#define DHAL_LED0_PINS						PORTF_PIN(6)
		#define DHAL_LED0_POLARITY					0
	#endif
#endif // DHAL_LED_NUMBER >= 1

#if (DHAL_LED_NUMBER >= 2)
	#if defined(CORTEXM3_EM3585)
		#define DHAL_LED1_PIN_INDEX					1
		#define DHAL_LED1_PORT						(gpioPortA)
		#define DHAL_LED1_PIN						(4U)
		#define DHAL_LED1_PINS						PORTA_PIN(4)
		#define DHAL_LED1_POLARITY					0
	#elif defined(CORTEXM3_EFR32)
		#define DHAL_LED1_PIN_INDEX					1
		#define DHAL_LED1_PORT						(gpioPortF)
		#define DHAL_LED1_PIN						(2U)
		#define DHAL_LED1_PINS						PORTF_PIN(2)
		#define DHAL_LED1_POLARITY					1
	#endif
#endif // DHAL_LED_NUMBER >= 2

#if (DHAL_LED_NUMBER == 1)
	#define DHAL_LED_INIT							{{DHAL_LED0_PORT, DHAL_LED0_PIN, DHAL_LED0_POLARITY}}
#elif (DHAL_LED_NUMBER == 2)
	#define DHAL_LED_INIT							{{DHAL_LED0_PORT, DHAL_LED0_PIN, DHAL_LED0_POLARITY},\
												 	 {DHAL_LED1_PORT, DHAL_LED1_PIN, DHAL_LED1_POLARITY}}
#endif // DHAL_LED_NUMBER

#if defined(DHL_LED_CONTROL_DIVERSIFY_ENABLE) && (DHL_LED_CONTROL_DIVERSIFY_ENABLE != FALSE)
	#define DHAL_LED_DIVERSIFY_BLINK_TIME_MS		{1000, 1000, 1000, 1000, 990, 10}		//
#endif //DHL_LED_CONTROL_DIVERSIFY_ENABLE
// LED <<<

Debug打印宏设置

// DUMA(Define User Main Application)
#define DUMA_PRINT_ENABLE
#ifdef DUMA_PRINT_ENABLE
    #define DebugPrintln(ENABLE, ...)                            \
        if(ENABLE)                                                \
        {                                                        \
            emberAfPrintln(EMBER_AF_PRINT_APP,  __VA_ARGS__);    \
        }    
 
    #define DebugBufferPrintln(ENABLE, buffer, len, withSpace)                        \
        if(ENABLE)                                                                    \
        {                                                                            \
            emberAfPrint(EMBER_AF_PRINT_APP,  "[");                                    \
            emberAfPrintBuffer(EMBER_AF_PRINT_APP, (buffer), (len), (withSpace));    \
            emberAfPrint(EMBER_AF_PRINT_APP,  "]\r\n");                                \
        }
 
    #define DebugBufferPrint(ENABLE, buffer, len, withSpace)                        \
        if(ENABLE)                                                                    \
        {                                                                            \
            emberAfPrintBuffer(EMBER_AF_PRINT_APP, (buffer), (len), (withSpace));    \
        }
#else
    #define DebugPrintln(ENABLE, ...)
    #define DebugBufferPrintln(ENABLE, buffer, len, withSpace)
    #define DebugBufferPrint(ENABLE, buffer, len, withSpace)
#endif // DUMA_PRINT_ENABLE
 
//-------------------------------------------------------------------
// Debug print enable. 0 is disable, 1 is enable.
#define DUMA_PRINT_HAL_ADC_ENABLE                            0
#define DUMA_PRINT_HAL_GPIO_ENABLE                            0
#define DUMA_PRINT_HAL_BUTTON_ENABLE                        1
#define DUMA_PRINT_HAL_LED_ENABLE                            0
#define DUMA_PRINT_BUFFER_ENABLE                            1
 
#define HalAdcPrintln(...)                                    DebugPrintln(DUMA_PRINT_HAL_ADC_ENABLE, __VA_ARGS__)
#define HalGpioPrintln(...)                                    DebugPrintln(DUMA_PRINT_HAL_GPIO_ENABLE, __VA_ARGS__)
#define HalButtonPrintln(...)                                DebugPrintln(DUMA_PRINT_HAL_BUTTON_ENABLE, __VA_ARGS__)
#define HalLedPrintln(...)                                    DebugPrintln(DUMA_PRINT_HAL_LED_ENABLE, __VA_ARGS__)
#define UserBufferPrint(buffer, len, withSpace)                DebugBufferPrint(DUMA_PRINT_BUFFER_ENABLE, (buffer), (len), (withSpace))

注:

宏定义中支持的设置:

1、LED的数量设置,默认0,但Timer Event仍然需要配置;

2、LED引脚端口及极性

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值