函数内检查参数实现
the assert_param macro(宏)
#define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) /* Exported functions ------------------------------------------------------- */ void assert_failed(uint8_t* file, uint32_t line);
void assert_failed(u8* file, u32 line)
{
rt_kprintf("\n\r Wrong parameter value detected on\r\n");
rt_kprintf(" file %s\r\n", file);
rt_kprintf(" line %d\r\n", line);
while (1) ;
}
----------------------------------------------------------------------------
void ADC_DeInit(ADC_TypeDef* ADCx)
{
/* Check the parameters */
assert_param(IS_ADC_ALL_PERIPH(ADCx));
// 后面省略
}
#define IS_ADC_ALL_PERIPH(PERIPH) (((PERIPH) == ADC1) || ((PERIPH) == ADC2) || ((PERIPH) == ADC3))
如果,感到此时的自己很辛苦,那告诉自己:容易走的都是下坡路。坚持住,因为你正在走上坡路,走过去,你就一定会有进步。如果,你正在埋怨命运不眷顾,开导自己:命,是失败者的借口;运,是成功者的谦词。命运从来都是掌握在自己的手中,埋怨,只是一种懦弱的表现;努力,才是人生的态度。

浙公网安备 33010602011771号