TimerMSP432E4.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2019, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 /*!*****************************************************************************
33  * @file TimerMSP432E4.h
34  * @brief Timer driver interface for MSP432E4 devices
35  *
36  * # Operation #
37  * This driver implements half and full width general purpose timers for the
38  * MSP432E4 device. For MSP432E4 devices, the system clock is 120 MHz and a 16-bit
39  * timer has an 8-bit prescaler. The desired period may not always be
40  * achieved due to hardware limitations, such as the aforementioned. The timer
41  * resolution is limited to 8.33ns due to the 120 MHz clock. A timer period no
42  * greater than 546,133us can be achieved when operating in 16-bit mode.
43  * Similarly, a period no greater than 35,791,394us can be achieved when
44  * operating in 32-bit mode. The same time constraints apply to the 16-bit
45  * timer when attempting to use a frequency less than 5 Hertz. For additional
46  * details, refer to the device's technical reference manual.
47  *
48  * The timer always operates in count down mode. When using a half width timer,
49  * an 8-bit prescaler will be implemented by the driver if necessary. If the
50  * timer is operating in Timer_FREE_RUNNING, the timer will count down from the
51  * specified period to 0 before restarting.
52  *
53  * When using a half width timer, Timer_getCount() will return the
54  * value of the counter in bits 15:0 and bits 23:16 will contain the
55  * current free-running value of the prescaler. Bits 31:24 are always 0.
56  * When using a full width timer, Timer_getCount() will return the
57  * the value of the 32-bit timer.
58  *
59  * #Timer_ONESHOT_CALLBACK is non-blocking. After Timer_start() is called,
60  * the calling thread will continue execution. When the timer interrupt
61  * is triggered, the specified callback function will be called. The timer
62  * will not generate another interrupt unless Timer_start() is called again.
63  * Calling Timer_stop() or Timer_close() after Timer_start() but, before the
64  * timer interrupt, will prevent the specified callback from ever being
65  * invoked.
66  *
67  * #Timer_ONESHOT_BLOCKING is a blocking call. A semaphore is used to block
68  * the calling thead's execution until the timer generates an interrupt. If
69  * Timer_stop() is called, the calling thread will become unblocked
70  * immediately. The behavior of the timer in this mode is similar to a sleep
71  * function.
72  *
73  * #Timer_CONTINUOUS_CALLBACK is non-blocking. After Timer_start() is called,
74  * the calling thread will continue execution. When the timer interrupt is
75  * treiggered, the specified callback function will be called. The timer is
76  * automatically restarted and will continue to periodically generate
77  * interrupts until Timer_stop() is called.
78  *
79  * #Timer_FREE_RUNNING is non-blocking. After Timer_start() is called,
80  * the calling thread will continue execution. The timer will not
81  * generate an interrupt in this mode. The timer will count down from the
82  * specified period until it reaches 0. The timer will automatically reload
83  * the period and start over. The timer will continue running until
84  * Timer_stop() is called.
85  *
86  * # Resource Allocation #
87  * Each general purpose timer block contains two timers, Timer A and Timer B,
88  * that can be configured to operate independently; or concatenated to operate
89  * as one 32-bit timer. This behavior is managed through a set of resource
90  * allocation APIs. For example, the TimerMSP432E4_allocateTimerResource API
91  * will allocate a timer for exclusive use. Any attempt to allocate this
92  * resource in the future will result in a false value being returned from the
93  * allocation API. To free a timer resource, the TimerMSP432E4_freeTimerResource
94  * is used. The application is not responsible for calling these allocation
95  * APIs directly.
96  *
97  * ============================================================================
98  */
99 
100 #ifndef ti_drivers_timer_TimerMSP432E4__include
101 #define ti_drivers_timer_TimerMSP432E4__include
102 
103 #include <stdbool.h>
104 #include <stdint.h>
105 
106 #include <ti/drivers/Timer.h>
107 #include <ti/drivers/Power.h>
108 #include <ti/drivers/dpl/HwiP.h>
109 #include <ti/drivers/dpl/SemaphoreP.h>
110 
111 #ifdef __cplusplus
112 extern "C"
113 {
114 #endif
115 
127 typedef enum {
132 
134 
166 typedef struct {
168  uint32_t baseAddress;
169 
172 
174  uint32_t intNum;
175 
177  uint32_t intPriority;
179 
185 typedef struct {
186  HwiP_Handle hwiHandle;
188  SemaphoreP_Handle timerSem;
191  uint32_t timer;
192  uint32_t period;
193  uint32_t prescaler;
194  bool isRunning;
196 
214 extern bool TimerMSP432E4_allocateTimerResource(uint32_t baseAddress,
215  TimerMSP432E4_SubTimer subTimer);
216 
235 extern void TimerMSP432E4_freeTimerResource(uint32_t baseAddress,
236  TimerMSP432E4_SubTimer subTimer);
237 
238 #ifdef __cplusplus
239 }
240 #endif
241 
242 #endif /* ti_drivers_timer_TimerMSP432E4__include */
TimerMSP432E4 Hardware Attributes.
Definition: TimerMSP432E4.h:166
TimerMSP432E4_Object.
Definition: TimerMSP432E4.h:185
uint32_t intPriority
Definition: TimerMSP432E4.h:177
Definition: TimerMSP432E4.h:130
SemaphoreP_Handle timerSem
Definition: TimerMSP432E4.h:188
Power Manager.
uint32_t period
Definition: TimerMSP432E4.h:192
Timer_Mode mode
Definition: TimerMSP432E4.h:190
Power_NotifyObj notifyObj
Definition: TimerMSP432E4.h:187
TimerMSP432E4_SubTimer subTimer
Definition: TimerMSP432E4.h:171
bool isRunning
Definition: TimerMSP432E4.h:194
Timer_CallBackFxn callBack
Definition: TimerMSP432E4.h:189
Timer driver.
uint32_t prescaler
Definition: TimerMSP432E4.h:193
Power notify object structure.
Definition: Power.h:443
uint32_t timer
Definition: TimerMSP432E4.h:191
void TimerMSP432E4_freeTimerResource(uint32_t baseAddress, TimerMSP432E4_SubTimer subTimer)
Function to de-allocate a timer peripheral.
bool TimerMSP432E4_allocateTimerResource(uint32_t baseAddress, TimerMSP432E4_SubTimer subTimer)
Function to allocate a timer peripheral.
HwiP_Handle hwiHandle
Definition: TimerMSP432E4.h:186
Timer_Mode
Timer mode settings.
Definition: Timer.h:239
uint32_t baseAddress
Definition: TimerMSP432E4.h:168
The definition of a timer function table that contains the required set of functions to control a spe...
Definition: Timer.h:379
void(* Timer_CallBackFxn)(Timer_Handle handle)
Timer callback function.
Definition: Timer.h:299
TimerMSP432E4_SubTimer
Definition: TimerMSP432E4.h:127
uint32_t intNum
Definition: TimerMSP432E4.h:174
Definition: TimerMSP432E4.h:129
Definition: TimerMSP432E4.h:128
const Timer_FxnTable TimerMSP432E4_fxnTable
© Copyright 1995-2019, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale