- Timestamp:
- Apr 5, 2019, 9:26:53 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
asp3_tinet_ecnl_arm/trunk/asp3_dcre/mbed/hal/lp_ticker_api.h
r352 r374 22 22 #include "device.h" 23 23 24 #if DEVICE_L OWPOWERTIMER24 #if DEVICE_LPTICKER 25 25 26 26 #include "hal/ticker_api.h" … … 31 31 32 32 /** 33 * \defgroup hal_LpTicker Low Power Ticker Functions 33 * \defgroup hal_lp_ticker Low Power Ticker 34 * Low level interface to the low power ticker of a target 35 * 36 * # Defined behavior 37 * * Has a reported frequency between 4KHz and 64KHz - verified by ::lp_ticker_info_test 38 * * Has a counter that is at least 12 bits wide - verified by ::lp_ticker_info_test 39 * * Continues operating in deep sleep mode - verified by ::lp_ticker_deepsleep_test 40 * * All behavior defined by the @ref hal_ticker_shared "ticker specification" 41 * 42 * # Undefined behavior 43 * * See the @ref hal_ticker_shared "ticker specification" 44 * * Calling any function other than lp_ticker_init after calling lp_ticker_free 45 * 46 * # Potential bugs 47 * * Glitches due to ripple counter - Verified by ::lp_ticker_glitch_test 48 * 49 * @see hal_lp_ticker_tests 50 * 34 51 * @{ 35 52 */ 36 53 54 /** 55 * \defgroup hal_lp_ticker_tests Low Power Ticker tests 56 * Tests to validate the proper implementation of the low power ticker 57 * 58 * To run the low power ticker hal tests use the command: 59 * 60 * mbed test -t <toolchain> -m <target> -n tests-mbed_hal-common_ticker*,tests-mbed_hal-lp_ticker* 61 * 62 */ 63 64 typedef void (*ticker_irq_handler_type)(const ticker_data_t *const); 65 66 /** Set low power ticker IRQ handler 67 * 68 * @param ticker_irq_handler IRQ handler to be connected 69 * 70 * @return previous ticker IRQ handler 71 * 72 * @note by default IRQ handler is set to ::ticker_irq_handler 73 * @note this function is primarily for testing purposes and it's not required part of HAL implementation 74 * 75 */ 76 ticker_irq_handler_type set_lp_ticker_irq_handler(ticker_irq_handler_type ticker_irq_handler); 77 37 78 /** Get low power ticker's data 38 79 * 39 80 * @return The low power ticker data 40 81 */ 41 const ticker_data_t *get_lp_ticker_data(void);82 const ticker_data_t *get_lp_ticker_data(void); 42 83 43 84 /** The wrapper for ticker_irq_handler, to pass lp ticker's data … … 50 91 /** Initialize the low power ticker 51 92 * 93 * Initialize or re-initialize the ticker. This resets all the 94 * clocking and prescaler registers, along with disabling 95 * the compare interrupt. 96 * 97 * Pseudo Code: 98 * @code 99 * void lp_ticker_init() 100 * { 101 * // Enable clock gate so processor can read LPTMR registers 102 * POWER_CTRL |= POWER_CTRL_LPTMR_Msk; 103 * 104 * // Disable the timer and ensure it is powered down 105 * LPTMR_CTRL &= ~(LPTMR_CTRL_ENABLE_Msk | LPTMR_CTRL_COMPARE_ENABLE_Msk); 106 * 107 * // Configure divisors - no division necessary 108 * LPTMR_PRESCALE = 0; 109 * LPTMR_CTRL |= LPTMR_CTRL_ENABLE_Msk; 110 * 111 * // Install the interrupt handler 112 * NVIC_SetVector(LPTMR_IRQn, (uint32_t)lp_ticker_irq_handler); 113 * NVIC_EnableIRQ(LPTMR_IRQn); 114 * } 115 * @endcode 52 116 */ 53 117 void lp_ticker_init(void); 54 118 55 /** Read the current counter 56 * 57 * @return The current timer's counter value in microseconds 119 /** Deinitialize the lower power ticker 120 * 121 * Powerdown the lp ticker in preparation for sleep, powerdown, or reset. 122 * 123 * After calling this function no other ticker functions should be called except 124 * lp_ticker_init(). Calling any function other than init after freeing is 125 * undefined. 126 * 127 * @note This function stops the ticker from counting. 128 */ 129 void lp_ticker_free(void); 130 131 /** Read the current tick 132 * 133 * If no rollover has occurred, the seconds passed since lp_ticker_init() 134 * was called can be found by dividing the ticks returned by this function 135 * by the frequency returned by ::lp_ticker_get_info. 136 * 137 * @return The current timer's counter value in ticks 138 * 139 * Pseudo Code: 140 * @code 141 * uint32_t lp_ticker_read() 142 * { 143 * uint16_t count; 144 * uint16_t last_count; 145 * 146 * // Loop until the same tick is read twice since this 147 * // is ripple counter on a different clock domain. 148 * count = LPTMR_COUNT; 149 * do { 150 * last_count = count; 151 * count = LPTMR_COUNT; 152 * } while (last_count != count); 153 * 154 * return count; 155 * } 156 * @endcode 58 157 */ 59 158 uint32_t lp_ticker_read(void); … … 61 160 /** Set interrupt for specified timestamp 62 161 * 63 * @param timestamp The time in microseconds to be set 162 * @param timestamp The time in ticks to be set 163 * 164 * @note no special handling needs to be done for times in the past 165 * as the common timer code will detect this and call 166 * lp_ticker_fire_interrupt() if this is the case 167 * 168 * @note calling this function with timestamp of more than the supported 169 * number of bits returned by ::lp_ticker_get_info results in undefined 170 * behavior. 171 * 172 * Pseudo Code: 173 * @code 174 * void lp_ticker_set_interrupt(timestamp_t timestamp) 175 * { 176 * LPTMR_COMPARE = timestamp; 177 * LPTMR_CTRL |= LPTMR_CTRL_COMPARE_ENABLE_Msk; 178 * } 179 * @endcode 64 180 */ 65 181 void lp_ticker_set_interrupt(timestamp_t timestamp); … … 67 183 /** Disable low power ticker interrupt 68 184 * 185 * Pseudo Code: 186 * @code 187 * void lp_ticker_disable_interrupt(void) 188 * { 189 * // Disable the compare interrupt 190 * LPTMR_CTRL &= ~LPTMR_CTRL_COMPARE_ENABLE_Msk; 191 * } 192 * @endcode 69 193 */ 70 194 void lp_ticker_disable_interrupt(void); … … 72 196 /** Clear the low power ticker interrupt 73 197 * 198 * Pseudo Code: 199 * @code 200 * void lp_ticker_clear_interrupt(void) 201 * { 202 * // Write to the ICR (interrupt clear register) of the LPTMR 203 * LPTMR_ICR = LPTMR_ICR_COMPARE_Msk; 204 * } 205 * @endcode 74 206 */ 75 207 void lp_ticker_clear_interrupt(void); 208 209 /** Set pending interrupt that should be fired right away. 210 * 211 * Pseudo Code: 212 * @code 213 * void lp_ticker_fire_interrupt(void) 214 * { 215 * NVIC_SetPendingIRQ(LPTMR_IRQn); 216 * } 217 * @endcode 218 */ 219 void lp_ticker_fire_interrupt(void); 220 221 /** Get frequency and counter bits of this ticker. 222 * 223 * Pseudo Code: 224 * @code 225 * const ticker_info_t* lp_ticker_get_info() 226 * { 227 * static const ticker_info_t info = { 228 * 32768, // 32KHz 229 * 16 // 16 bit counter 230 * }; 231 * return &info; 232 * } 233 * @endcode 234 */ 235 const ticker_info_t *lp_ticker_get_info(void); 76 236 77 237 /**@}*/
Note:
See TracChangeset
for help on using the changeset viewer.