os counter 的理论我们已经讲过,具体可参考《OS10 -OS11》,下面我们分析一下代码。本文的代码定义在counter.h中。其定义了OsCounterType的类型。并提供了几个内联函数的接口,如获取AlarmBaseType,获取counter的当前值,counter之间的差值等。
/* -------------------------------- Arctic Core ------------------------------
#ifndef COUNTER_I_H_
#define COUNTER_I_H_
#include "Os.h"
#include "internal.h"
#include "os_config_macros.h"
#include <sys/queue.h>
#define COUNTER_TYPE_HARD 0
#define COUNTER_TYPE_SOFT 1
#define COUNTER_UNIT_TICKS 0
#define COUNTER_UNIT_NANO 1
/* STD container : OsCounter
* OsCounterMaxAllowedValue: 1 Integer
* OsCounterMinCycle: 1 Integer
* OsCounterTicksPerBase: 1 Integer
* OsCounterType: