Ignore:
Timestamp:
Apr 5, 2019, 9:26:53 PM (5 years ago)
Author:
coas-nagasima
Message:

mbed関連を更新
シリアルドライバをmbedのHALを使うよう変更
ファイルディスクリプタの処理を更新

File:
1 edited

Legend:

Unmodified
Added
Removed
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/mbed/hal/lp_ticker_api.h

    r352 r374  
    2222#include "device.h"
    2323
    24 #if DEVICE_LOWPOWERTIMER
     24#if DEVICE_LPTICKER
    2525
    2626#include "hal/ticker_api.h"
     
    3131
    3232/**
    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 *
    3451 * @{
    3552 */
    3653
     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
     64typedef 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 */
     76ticker_irq_handler_type set_lp_ticker_irq_handler(ticker_irq_handler_type ticker_irq_handler);
     77
    3778/** Get low power ticker's data
    3879 *
    3980 * @return The low power ticker data
    4081 */
    41 const ticker_data_t* get_lp_ticker_data(void);
     82const ticker_data_t *get_lp_ticker_data(void);
    4283
    4384/** The wrapper for ticker_irq_handler, to pass lp ticker's data
     
    5091/** Initialize the low power ticker
    5192 *
     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
    52116 */
    53117void lp_ticker_init(void);
    54118
    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 */
     129void 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
    58157 */
    59158uint32_t lp_ticker_read(void);
     
    61160/** Set interrupt for specified timestamp
    62161 *
    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
    64180 */
    65181void lp_ticker_set_interrupt(timestamp_t timestamp);
     
    67183/** Disable low power ticker interrupt
    68184 *
     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
    69193 */
    70194void lp_ticker_disable_interrupt(void);
     
    72196/** Clear the low power ticker interrupt
    73197 *
     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
    74206 */
    75207void 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 */
     219void 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 */
     235const ticker_info_t *lp_ticker_get_info(void);
    76236
    77237/**@}*/
Note: See TracChangeset for help on using the changeset viewer.