* for more details.
* -------------------------------- Arctic Core ------------------------------*/
-
-
-
-
-
-
-
#ifndef COUNTER_I_H_\r
#define COUNTER_I_H_\r
\r
\r
#define COUNTER_UNIT_TICKS 0\r
#define COUNTER_UNIT_NANO 1\r
+
+/* STD container : OsCounter
+ * OsCounterMaxAllowedValue: 1 Integer
+ * OsCounterMinCycle: 1 Integer
+ * OsCounterTicksPerBase: 1 Integer
+ * OsCounterType: 1 Enum HARDWARE/SOFTWARE
+ * OsSecondsPerTick: 0..1 Float
+ * OsCounterAccessingApplication: 0..* Ref
+ * OsDriver[C]: 0..1
+ * OsTimeConstant[C]: 0..*
+ */
\r
-/*-----------------------------------------------------------------*/\r
-typedef struct counter_obj_s {\r
- // counter id( TODO: remove ?? I use index here )\r
-// uint32_t cid;\r
+typedef struct OsCounter {\r
char name[16];\r
// hardware or software counter, SWS OS255\r
_Bool type;\r
// hmm, strange to call it alarm base.... but see spec.\r
AlarmBaseType alarm_base;\r
/* Used only if we configure a GPT timer as os timer */\r
- OsDriver driver;\r
+ OsDriver *driver;\r
/* List of alarms this counter is connected to\r
* Overkill ??? Could have list of id's here, but easier to debug this way*/\r
- SLIST_HEAD(slist,alarm_obj_s) alarm_head;\r
+ SLIST_HEAD(slist,OsAlarm) alarm_head;\r
/* List of scheduletable connected to this counter */\r
- SLIST_HEAD(sclist,sched_table_s) sched_head;\r
-} counter_obj_t;\r
+ SLIST_HEAD(sclist,OsSchTbl) sched_head;\r
+} OsCounterType;\r
+
+
+static inline TickType Os_CounterGetMaxValue(OsCounterType *cPtr ) {
+ return cPtr->alarm_base.maxallowedvalue;
+}
\r
-TickType GetCounterValue_( counter_obj_t *c_p );\r
+static inline TickType Os_CounterGetValue( OsCounterType *cPtr ) {
+ return cPtr->val;
+}\r
+
+
+/**
+ *
+ * @param curr
+ * @param max
+ * @param add
+ * @return
+ */
+static inline TickType Os_CounterCalcModulo( TickType curr, TickType max, TickType add ) {
+ TickType diff = max - curr;
+ return (diff >= add ) ? (curr + add) : (add - curr);
+}
+
+
\r
#endif /*COUNTER_I_H_*/\r