]> rtime.felk.cvut.cz Git - arc.git/blobdiff - system/kernel/include/counter_i.h
Again, loads of refactoring and removing and adding files.
[arc.git] / system / kernel / include / counter_i.h
index 6b7e20ce4c175496e5a9c40a03da211068156f22..cc210d7a2a763117f0b9c7f2574de1a3c6dcf103 100644 (file)
  * 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
@@ -49,14 +50,36 @@ typedef struct counter_obj_s {
        //  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