* @brief This function will calculate the tick from millisecond. * * @param ms is the specified millisecond. * - Negative Number wait forever * - Zero not wait * - Max 0x7fffffff * * @return Return the calculated tick. */
| 212 | * @return Return the calculated tick. |
| 213 | */ |
| 214 | rt_tick_t rt_tick_from_millisecond(rt_int32_t ms) |
| 215 | { |
| 216 | rt_tick_t tick; |
| 217 | |
| 218 | if (ms < 0) |
| 219 | { |
| 220 | tick = (rt_tick_t)RT_WAITING_FOREVER; |
| 221 | } |
| 222 | else |
| 223 | { |
| 224 | #if RT_TICK_PER_SECOND == 1000u |
| 225 | tick = ms; |
| 226 | #else |
| 227 | tick = RT_TICK_PER_SECOND * (ms / 1000); |
| 228 | tick += (RT_TICK_PER_SECOND * (ms % 1000) + 999) / 1000; |
| 229 | #endif /* RT_TICK_PER_SECOND == 1000u */ |
| 230 | } |
| 231 | |
| 232 | /* return the calculated tick */ |
| 233 | return tick; |
| 234 | } |
| 235 | RTM_EXPORT(rt_tick_from_millisecond); |
| 236 | |
| 237 | /** |
no outgoing calls