1 /**************************************************************************/
2 /*                                                                        */
3 /*       Copyright (c) Microsoft Corporation. All rights reserved.        */
4 /*                                                                        */
5 /*       This software is licensed under the Microsoft Software License   */
6 /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */
7 /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */
8 /*       and in the root directory of this software.                      */
9 /*                                                                        */
10 /**************************************************************************/
11 
12 
13 /**************************************************************************/
14 /**************************************************************************/
15 /**                                                                       */
16 /** ThreadX Component                                                     */
17 /**                                                                       */
18 /**   Timer                                                               */
19 /**                                                                       */
20 /**************************************************************************/
21 /**************************************************************************/
22 
23 #define TX_SOURCE_CODE
24 
25 
26 /* Include necessary system files.  */
27 
28 #include "tx_api.h"
29 #include "tx_timer.h"
30 
31 
32 /**************************************************************************/
33 /*                                                                        */
34 /*  FUNCTION                                               RELEASE        */
35 /*                                                                        */
36 /*    _txe_timer_info_get                                 PORTABLE C      */
37 /*                                                           6.1          */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    William E. Lamie, Microsoft Corporation                             */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This function checks for errors in the timer information get        */
45 /*    service.                                                            */
46 /*                                                                        */
47 /*  INPUT                                                                 */
48 /*                                                                        */
49 /*    timer_ptr                         Pointer to timer control block    */
50 /*    name                              Destination for the timer name    */
51 /*    active                            Destination for active flag       */
52 /*    remaining_ticks                   Destination for remaining ticks   */
53 /*                                        before expiration               */
54 /*    reschedule_ticks                  Destination for reschedule ticks  */
55 /*    next_timer                        Destination for next timer on the */
56 /*                                        created list                    */
57 /*                                                                        */
58 /*  OUTPUT                                                                */
59 /*                                                                        */
60 /*    TX_TIMER_ERROR                    Invalid timer pointer             */
61 /*    status                            Completion status                 */
62 /*                                                                        */
63 /*  CALLS                                                                 */
64 /*                                                                        */
65 /*    _tx_timer_info_get                Actual info get call              */
66 /*                                                                        */
67 /*  CALLED BY                                                             */
68 /*                                                                        */
69 /*    Application Code                                                    */
70 /*                                                                        */
71 /*  RELEASE HISTORY                                                       */
72 /*                                                                        */
73 /*    DATE              NAME                      DESCRIPTION             */
74 /*                                                                        */
75 /*  05-19-2020     William E. Lamie         Initial Version 6.0           */
76 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
77 /*                                            resulting in version 6.1    */
78 /*                                                                        */
79 /**************************************************************************/
_txe_timer_info_get(TX_TIMER * timer_ptr,CHAR ** name,UINT * active,ULONG * remaining_ticks,ULONG * reschedule_ticks,TX_TIMER ** next_timer)80 UINT  _txe_timer_info_get(TX_TIMER *timer_ptr, CHAR **name, UINT *active, ULONG *remaining_ticks,
81                 ULONG *reschedule_ticks, TX_TIMER **next_timer)
82 {
83 
84 UINT    status;
85 
86 
87     /* Check for an invalid timer pointer.  */
88     if (timer_ptr == TX_NULL)
89     {
90 
91         /* Timer pointer is invalid, return appropriate error code.  */
92         status =  TX_TIMER_ERROR;
93     }
94 
95     /* Now check for invalid timer ID.  */
96     else if (timer_ptr -> tx_timer_id != TX_TIMER_ID)
97     {
98 
99         /* Timer pointer is invalid, return appropriate error code.  */
100         status =  TX_TIMER_ERROR;
101     }
102     else
103     {
104 
105         /* Otherwise, call the actual timer information get service.  */
106         status =  _tx_timer_info_get(timer_ptr, name, active, remaining_ticks, reschedule_ticks, next_timer);
107     }
108 
109     /* Return completion status.  */
110     return(status);
111 }
112 
113