1 /***************************************************************************
2 * Copyright (c) 2024 Microsoft Corporation
3 *
4 * This program and the accompanying materials are made available under the
5 * terms of the MIT License which is available at
6 * https://opensource.org/licenses/MIT.
7 *
8 * SPDX-License-Identifier: MIT
9 **************************************************************************/
10
11
12 /**************************************************************************/
13 /**************************************************************************/
14 /** */
15 /** ThreadX Component */
16 /** */
17 /** Timer */
18 /** */
19 /**************************************************************************/
20 /**************************************************************************/
21
22 #define TX_SOURCE_CODE
23
24
25 /* Include necessary system files. */
26
27 #include "tx_api.h"
28 #include "tx_timer.h"
29
30
31 /**************************************************************************/
32 /* */
33 /* FUNCTION RELEASE */
34 /* */
35 /* _txe_timer_activate PORTABLE C */
36 /* 6.1 */
37 /* AUTHOR */
38 /* */
39 /* William E. Lamie, Microsoft Corporation */
40 /* */
41 /* DESCRIPTION */
42 /* */
43 /* This function checks for errors in the activate application timer */
44 /* function call. */
45 /* */
46 /* INPUT */
47 /* */
48 /* timer_ptr Pointer to timer control block */
49 /* */
50 /* OUTPUT */
51 /* */
52 /* TX_TIMER_ERROR Invalid application timer */
53 /* TX_ACTIVATE_ERROR Application timer already active */
54 /* status Actual completion status */
55 /* */
56 /* CALLS */
57 /* */
58 /* _tx_timer_activate Actual application timer activate */
59 /* */
60 /* CALLED BY */
61 /* */
62 /* Application Code */
63 /* */
64 /* RELEASE HISTORY */
65 /* */
66 /* DATE NAME DESCRIPTION */
67 /* */
68 /* 05-19-2020 William E. Lamie Initial Version 6.0 */
69 /* 09-30-2020 Yuxin Zhou Modified comment(s), */
70 /* resulting in version 6.1 */
71 /* */
72 /**************************************************************************/
_txe_timer_activate(TX_TIMER * timer_ptr)73 UINT _txe_timer_activate(TX_TIMER *timer_ptr)
74 {
75
76 UINT status;
77
78
79 /* Check for an invalid timer pointer. */
80 if (timer_ptr == TX_NULL)
81 {
82 /* Timer pointer is invalid, return appropriate error code. */
83 status = TX_TIMER_ERROR;
84 }
85
86 /* Now check for invalid timer ID. */
87 else if (timer_ptr -> tx_timer_id != TX_TIMER_ID)
88 {
89 /* Timer pointer is invalid, return appropriate error code. */
90 status = TX_TIMER_ERROR;
91 }
92 else
93 {
94
95 /* Call actual application timer activate function. */
96 status = _tx_timer_activate(timer_ptr);
97 }
98
99 /* Return completion status. */
100 return(status);
101 }
102
103