Browse Source

Reference the hard reset thread by the new struct

Clara Hobbs 6 years ago
parent
commit
e7a7d30691
4 changed files with 7 additions and 11 deletions
  1. 1
    3
      lib/src/hard_reset.c
  2. 0
    3
      lib/src/hard_reset.h
  3. 4
    3
      lib/src/int_n.c
  4. 2
    2
      lib/src/policy_engine.c

+ 1
- 3
lib/src/hard_reset.c View File

26
 #include "pd.h"
26
 #include "pd.h"
27
 
27
 
28
 
28
 
29
-thread_t *pdb_hardrst_thread;
30
-
31
 /*
29
 /*
32
  * Hard Reset machine states
30
  * Hard Reset machine states
33
  */
31
  */
160
 
158
 
161
 void pdb_hardrst_run(struct pdb_config *cfg)
159
 void pdb_hardrst_run(struct pdb_config *cfg)
162
 {
160
 {
163
-    pdb_hardrst_thread = chThdCreateStatic(cfg->prl._hardrst_wa,
161
+    cfg->prl.hardrst_thread = chThdCreateStatic(cfg->prl._hardrst_wa,
164
             sizeof(cfg->prl._hardrst_wa), PDB_PRIO_PRL, HardReset, cfg);
162
             sizeof(cfg->prl._hardrst_wa), PDB_PRIO_PRL, HardReset, cfg);
165
 }
163
 }

+ 0
- 3
lib/src/hard_reset.h View File

30
 #define PDB_EVT_HARDRST_I_HARDSENT EVENT_MASK(2)
30
 #define PDB_EVT_HARDRST_I_HARDSENT EVENT_MASK(2)
31
 #define PDB_EVT_HARDRST_DONE EVENT_MASK(3)
31
 #define PDB_EVT_HARDRST_DONE EVENT_MASK(3)
32
 
32
 
33
-/* The Hard Reset thread object */
34
-extern thread_t *pdb_hardrst_thread;
35
-
36
 /*
33
 /*
37
  * Start the Hard Reset thread
34
  * Start the Hard Reset thread
38
  */
35
  */

+ 4
- 3
lib/src/int_n.c View File

21
 #include <ch.h>
21
 #include <ch.h>
22
 #include <hal.h>
22
 #include <hal.h>
23
 
23
 
24
+#include <pdb.h>
24
 #include "priorities.h"
25
 #include "priorities.h"
25
 #include "fusb302b.h"
26
 #include "fusb302b.h"
26
 #include "protocol_rx.h"
27
 #include "protocol_rx.h"
32
 /*
33
 /*
33
  * INT_N polling thread
34
  * INT_N polling thread
34
  */
35
  */
35
-static THD_FUNCTION(IntNPoll, cfg) {
36
-    (void) cfg;
36
+static THD_FUNCTION(IntNPoll, vcfg) {
37
+    struct pdb_config *cfg = vcfg;
37
 
38
 
38
     union fusb_status status;
39
     union fusb_status status;
39
     eventmask_t events;
40
     eventmask_t events;
69
             if (status.interrupta & FUSB_INTERRUPTA_I_HARDSENT) {
70
             if (status.interrupta & FUSB_INTERRUPTA_I_HARDSENT) {
70
                 events |= PDB_EVT_HARDRST_I_HARDSENT;
71
                 events |= PDB_EVT_HARDRST_I_HARDSENT;
71
             }
72
             }
72
-            chEvtSignal(pdb_hardrst_thread, events);
73
+            chEvtSignal(cfg->prl.hardrst_thread, events);
73
 
74
 
74
             /* If the I_OCP_TEMP and OVRTEMP flags are set, tell the Policy
75
             /* If the I_OCP_TEMP and OVRTEMP flags are set, tell the Policy
75
              * Engine thread */
76
              * Engine thread */

+ 2
- 2
lib/src/policy_engine.c View File

484
     }
484
     }
485
 
485
 
486
     /* Generate a hard reset signal */
486
     /* Generate a hard reset signal */
487
-    chEvtSignal(pdb_hardrst_thread, PDB_EVT_HARDRST_RESET);
487
+    chEvtSignal(cfg->prl.hardrst_thread, PDB_EVT_HARDRST_RESET);
488
     chEvtWaitAny(PDB_EVT_PE_HARD_SENT);
488
     chEvtWaitAny(PDB_EVT_PE_HARD_SENT);
489
 
489
 
490
     /* Increment HardResetCounter */
490
     /* Increment HardResetCounter */
505
      * it here. */
505
      * it here. */
506
 
506
 
507
     /* Tell the protocol layer we're done with the reset */
507
     /* Tell the protocol layer we're done with the reset */
508
-    chEvtSignal(pdb_hardrst_thread, PDB_EVT_HARDRST_DONE);
508
+    chEvtSignal(cfg->prl.hardrst_thread, PDB_EVT_HARDRST_DONE);
509
 
509
 
510
     return PESinkStartup;
510
     return PESinkStartup;
511
 }
511
 }

Loading…
Cancel
Save