一、
int rt_tick_from_millisecond(rt_int32_t ms)
{
int tick;
if (ms < 0)
tick = RT_WAITING_FOREVER;
else
tick = (RT_TICK_PER_SECOND * ms + 999) / 1000;
/* return the calculated tick */
return tick;
}
for(start_index=0; start_index<Total_Item_Number; ++start_index){
AT24CXX_Read(DATA_BASE_ADDR+((start_index+Total_Item_Number-1)%Total_Item_Number)*sizeof(Storage_Item_t), last_index_time_buf, sizeof(last_index_time_buf));
AT24CXX_Read(DATA_BASE_ADDR+start_index*sizeof(Storage_Item_t), cur_index_time_buf, sizeof(cur_index_time_buf));
last_index_time = *(uint32_t *)(last_index_time_buf+2);
cur_index_time = *(uint32_t *)(cur_index_time_buf+2);
if(start_time>last_index_time && start_time<cur_index_time)
break;
}
(+(量程-1))%或/量程,优化代码
二、
do..while(0) 在宏定义中的使用