incubator-nuttx/net/utils/net_dsec2tick.c

58 lines
2.1 KiB
C
Raw Normal View History

/****************************************************************************
* net/utils/net_dsec2tick.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/clock.h>
#include "utils/utils.h"
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: net_dsec2tick
*
* Description:
* Convert a decisecond value to a system clock ticks. Used by IGMP logic.
*
* Input Parameters:
* dsec The decisecond value to convert
*
* Returned Value:
* The decisecond value expressed as system clock ticks
*
****************************************************************************/
unsigned int net_dsec2tick(int dsec)
{
/* Convert the deci-second comparison value to clock ticks. The CLK_TCK
* value is the number of clock ticks per second; decisecs argument is the
* maximum delay in 100's of milliseconds. CLK_TCK/10 is then the number
* of clock ticks in 100 milliseconds.
*/
return CLK_TCK * dsec / 10;
}