|
SmartSnippets DA1459x SDK
|
Timer. More...
Files | |
| file | hw_timer.h |
| Definition of API for the Timer, Timer2, Timer3 and Timer4 Low Level Driver. | |
Data Structures | |
| struct | timer_config_timer_capture |
| Timer configuration for timer/capture mode. More... | |
| struct | timer_config_oneshot |
| Timer configuration for oneshot mode. More... | |
| struct | timer_config_pwm |
| Timer PWM configuration. More... | |
| struct | timer_config |
| Timer configuration. More... | |
Macros | |
| #define | HW_TIMER_REG_GETF(id, reg, field) ((TBA(id)->reg & (TIMER_##reg##_##field##_Msk)) >> (TIMER_##reg##_##field##_Pos)) |
| Definition for the PWM synchronization bitfield. More... | |
| #define | HW_TIMER_REG_SETF(id, reg, field, val) |
| Set the value of a field of a TIMER register. More... | |
| #define | TIMER_MAX_PRESCALER_VAL |
| Maximum value for timer pre-scaler (5bits). More... | |
| #define | TIMER_MAX_RELOAD_VAL TIMER_TIMER_SETTINGS_REG_TIM_RELOAD_Msk |
| Maximum value for timer reload value (24bits). More... | |
| #define | TIMER_MAX_SHOTWIDTH_VAL TIMER_TIMER_SHOTWIDTH_REG_TIM_SHOTWIDTH_Msk |
| Maximum value for timer shot phase duration value in oneshot mode (24bits). More... | |
| #define | TIMER_MAX_PWM_FREQ_VAL TIMER_TIMER_PWM_CTRL_REG_TIM_PWM_FREQ_Msk |
| Maximum value for timer PWM Frequency (16bits). More... | |
| #define | TIMER_MAX_PWM_DC_VAL TIMER_TIMER_PWM_CTRL_REG_TIM_PWM_DC_Msk |
| Maximum value for timer PWM duty cycle (16bits). More... | |
| #define | HW_TIMER ((void *)TIMER_BASE) |
| Timer id. More... | |
Typedefs | |
| typedef void(* | hw_timer_handler_cb) (void) |
| Timer interrupt callback. More... | |
| typedef void(* | hw_timer_capture_handler_cb) (uint8_t gpio_event) |
| Timer capture interrupt callback. More... | |
Functions | |
| void | hw_timer_init (HW_TIMER_ID id, const timer_config *cfg) |
| Timer initialization. More... | |
| void | hw_timer_configure (HW_TIMER_ID id, const timer_config *cfg) |
| Timer configuration. More... | |
| void | hw_timer_configure_timer (HW_TIMER_ID id, const timer_config_timer_capture *cfg) |
| Timer configuration for timer/capture mode. More... | |
| void | hw_timer_configure_oneshot (HW_TIMER_ID id, const timer_config_oneshot *cfg) |
| Timer configuration for oneshot mode. More... | |
| __STATIC_INLINE void | hw_timer_freeze (const HW_TIMER_ID id) |
| Freeze timer. More... | |
| __STATIC_INLINE void | hw_timer_unfreeze (const HW_TIMER_ID id) |
| Unfreeze timer. More... | |
| __STATIC_INLINE bool | hw_timer_frozen (const HW_TIMER_ID id) |
| Check if timer is frozen. More... | |
| __STATIC_INLINE void | hw_timer_set_clk (HW_TIMER_ID id, HW_TIMER_CLK_SRC clk) |
| Set clock source of the timer. More... | |
| __STATIC_INLINE void | hw_timer_set_prescaler (HW_TIMER_ID id, uint8_t value) |
| Set timer clock prescaler. More... | |
| __STATIC_FORCEINLINE void | hw_timer_set_reload (HW_TIMER_ID id, uint32_t value) |
| Set timer reload value. More... | |
| __STATIC_INLINE void | hw_timer_set_oneshot_delay (HW_TIMER_ID id, uint32_t delay) |
| Set pulse delay in oneshot mode. More... | |
| __STATIC_INLINE void | hw_timer_set_shot_width (HW_TIMER_ID id, uint32_t duration) |
| Set shot width. More... | |
| __STATIC_INLINE void | hw_timer_set_freerun (HW_TIMER_ID id, bool enable) |
| Turn on free run mode of the timer. More... | |
| __STATIC_INLINE void | hw_timer_set_event1_trigger (HW_TIMER_ID id, HW_TIMER_TRIGGER edge) |
| Set a type of the edge which triggers event1. More... | |
| __STATIC_INLINE void | hw_timer_set_event2_trigger (HW_TIMER_ID id, HW_TIMER_TRIGGER edge) |
| Set a type of the edge which triggers event2. More... | |
| __STATIC_INLINE void | hw_timer_set_event3_trigger (HW_TIMER_TRIGGER edge) |
| Set a type of the edge which triggers event3. More... | |
| __STATIC_INLINE void | hw_timer_set_event4_trigger (HW_TIMER_TRIGGER edge) |
| Set a type of the edge which triggers event4. More... | |
| __STATIC_INLINE void | hw_timer_set_gpio_event_int (uint8_t mask) |
| Select which time capture event GPIOs will create a capture IRQ. More... | |
| __STATIC_INLINE void | hw_timer_set_event1_gpio (HW_TIMER_ID id, HW_TIMER_GPIO gpio) |
| Set a GPIO input which triggers event1. More... | |
| __STATIC_INLINE void | hw_timer_set_event2_gpio (HW_TIMER_ID id, HW_TIMER_GPIO gpio) |
| Set a GPIO input which triggers event2. More... | |
| __STATIC_INLINE void | hw_timer_set_event3_gpio (HW_TIMER_GPIO gpio) |
| Set a GPIO input which triggers event3. More... | |
| __STATIC_INLINE void | hw_timer_set_event4_gpio (HW_TIMER_GPIO gpio) |
| Set a GPIO input which triggers event4. More... | |
| __STATIC_INLINE HW_TIMER_CLK_SRC | hw_timer_get_clk (HW_TIMER_ID id) |
| Get clock source of the timer. More... | |
| __STATIC_INLINE uint32_t | hw_timer_get_prescaler (HW_TIMER_ID id) |
| Get timer clock prescaler. More... | |
| __STATIC_INLINE uint32_t | hw_timer_get_reload (HW_TIMER_ID id) |
| Get timer reload value. More... | |
| __STATIC_INLINE uint32_t | hw_timer_get_oneshot_delay (HW_TIMER_ID id) |
| Get pulse delay in oneshot mode. More... | |
| __STATIC_INLINE uint32_t | hw_timer_get_shot_width (HW_TIMER_ID id) |
| Get shot width. More... | |
| __STATIC_INLINE bool | hw_timer_get_freerun (HW_TIMER_ID id) |
| Get free-running mode state. More... | |
| __STATIC_INLINE HW_TIMER_TRIGGER | hw_timer_get_event1_trigger (HW_TIMER_ID id) |
| Get a type of the edge which triggers event1. More... | |
| __STATIC_INLINE HW_TIMER_TRIGGER | hw_timer_get_event2_trigger (HW_TIMER_ID id) |
| Get a type of the edge which triggers event2. More... | |
| __STATIC_INLINE HW_TIMER_TRIGGER | hw_timer_get_event3_trigger (void) |
| Get a type of the edge which triggers event3. Valid only for Timer. More... | |
| __STATIC_INLINE HW_TIMER_TRIGGER | hw_timer_get_event4_trigger (void) |
| Get a type of the edge which triggers event4. Valid only for Timer. More... | |
| __STATIC_INLINE HW_TIMER_GPIO | hw_timer_get_event1_gpio (HW_TIMER_ID id) |
| Get a GPIO input which triggers event1. More... | |
| __STATIC_INLINE HW_TIMER_GPIO | hw_timer_get_event2_gpio (HW_TIMER_ID id) |
| Get a GPIO input which triggers event2. More... | |
| __STATIC_INLINE HW_TIMER_GPIO | hw_timer_get_event3_gpio (void) |
| Get a GPIO input which triggers event3. Valid only for Timer. More... | |
| __STATIC_INLINE HW_TIMER_GPIO | hw_timer_get_event4_gpio (void) |
| Get a GPIO input which triggers event4. Valid only for Timer. More... | |
| __STATIC_INLINE uint32_t | hw_timer_get_capture1 (HW_TIMER_ID id) |
| Get the capture time for event on GPIO1. More... | |
| __STATIC_INLINE uint32_t | hw_timer_get_capture2 (HW_TIMER_ID id) |
| Get the capture time for event on GPIO2. More... | |
| __STATIC_INLINE uint32_t | hw_timer_get_capture3 (void) |
| Get the capture time for event on GPIO3. Valid only for Timer. More... | |
| __STATIC_INLINE uint32_t | hw_timer_get_capture4 (void) |
| Get the capture time for event on GPIO4. Valid only for Timer. More... | |
| __STATIC_INLINE void | hw_timer_set_direction (HW_TIMER_ID id, HW_TIMER_DIR dir) |
| Set the direction of timer counting. More... | |
| __STATIC_INLINE void | hw_timer_set_mode (HW_TIMER_ID id, HW_TIMER_MODE mode) |
| Set timer mode. More... | |
| __STATIC_INLINE HW_TIMER_MODE | hw_timer_get_mode (HW_TIMER_ID id) |
| Return timer mode. More... | |
| __STATIC_FORCEINLINE uint32_t | hw_timer_get_count (HW_TIMER_ID id) |
| Get the tick count of the timer. More... | |
| __STATIC_INLINE HW_TIMER_ONESHOT | hw_timer_get_oneshot_phase (HW_TIMER_ID id) |
| Get the current phase of the one shot mode. More... | |
| __STATIC_INLINE bool | hw_timer_get_gpio1_state (HW_TIMER_ID id) |
| Get the current state of Event input 1 (IN1) More... | |
| __STATIC_INLINE uint8_t | hw_timer_get_gpio_event_pending (void) |
| Get the time capture event GPIOs pending events. More... | |
| __STATIC_INLINE bool | hw_timer_get_gpio2_state (HW_TIMER_ID id) |
| Get the current state of Event input 2 (IN2) More... | |
| __STATIC_INLINE uint16_t | hw_timer_get_prescaler_val (HW_TIMER_ID id) |
| Get the current prescaler counter value. More... | |
| __RETAINED_CODE void | hw_timer_register_int (const HW_TIMER_ID id, hw_timer_handler_cb handler) |
| Register an interrupt handler. More... | |
| __RETAINED_HOT_CODE void | hw_timer_unregister_int (const HW_TIMER_ID id) |
| Unregister an interrupt handler. More... | |
| void | hw_timer_register_capture_int (hw_timer_capture_handler_cb handler, uint8_t gpio_mask) |
| Register an interrupt handler for GPIO triggered Timer Capture interrupt. More... | |
| void | hw_timer_unregister_capture_int (void) |
| Unregister an interrupt handler for GPIO triggered Timer Capture interrupt. More... | |
| __STATIC_INLINE void | hw_timer_enable (HW_TIMER_ID id) |
| Enable the timer. More... | |
| __STATIC_INLINE void | hw_timer_disable (HW_TIMER_ID id) |
| Disable the timer. More... | |
| __STATIC_INLINE void | hw_timer_enable_clk (HW_TIMER_ID id) |
| Enable the timer clock. More... | |
| __STATIC_INLINE void | hw_timer_disable_clk (HW_TIMER_ID id) |
| Disable the timer clock. More... | |
| void | hw_timer_configure_pwm (HW_TIMER_ID id, const timer_config_pwm *cfg) |
| Timer PWM configuration. More... | |
| __STATIC_INLINE void | hw_timer_set_pwm_freq (HW_TIMER_ID id, uint32_t value) |
| Set PWM frequency prescaler. More... | |
| __STATIC_INLINE void | hw_timer_set_pwm_duty_cycle (HW_TIMER_ID id, uint32_t value) |
| Set PWM duty cycle. More... | |
| __STATIC_INLINE uint32_t | hw_timer_get_pwm_freq (HW_TIMER_ID id) |
| Get PWM frequency. More... | |
| __STATIC_INLINE uint32_t | hw_timer_get_pwm_duty_cycle (HW_TIMER_ID id) |
| Get PWM duty cycle. More... | |
| __STATIC_INLINE void | hw_timer_clear_gpio_event (uint8_t mask) |
| Clear capture time GPIO event. More... | |
| __STATIC_INLINE void | hw_timer_clear_interrupt (const HW_TIMER_ID id) |
| Clear timer interrupt. More... | |
Timer.
| #define HW_TIMER ((void *)TIMER_BASE) |
Timer id.
| #define HW_TIMER_REG_GETF | ( | id, | |
| reg, | |||
| field | |||
| ) | ((TBA(id)->reg & (TIMER_##reg##_##field##_Msk)) >> (TIMER_##reg##_##field##_Pos)) |
Definition for the PWM synchronization bitfield.
Get the value of a field of a TIMER register.
| [in] | id | identifies TIMER, TIMER2, TIMER3 or TIMER4 |
| [in] | reg | is the register to access |
| [in] | field | is the register field to read |
| #define HW_TIMER_REG_SETF | ( | id, | |
| reg, | |||
| field, | |||
| val | |||
| ) |
Set the value of a field of a TIMER register.
| [in] | id | identifies TIMER, TIMER2, TIMER3 or TIMER4 |
| [in] | reg | is the register to access |
| [in] | field | is the register field to write |
| [in] | val | is the value to write |
| #define TIMER_MAX_PRESCALER_VAL |
Maximum value for timer pre-scaler (5bits).
| #define TIMER_MAX_PWM_DC_VAL TIMER_TIMER_PWM_CTRL_REG_TIM_PWM_DC_Msk |
Maximum value for timer PWM duty cycle (16bits).
| #define TIMER_MAX_PWM_FREQ_VAL TIMER_TIMER_PWM_CTRL_REG_TIM_PWM_FREQ_Msk |
Maximum value for timer PWM Frequency (16bits).
| #define TIMER_MAX_RELOAD_VAL TIMER_TIMER_SETTINGS_REG_TIM_RELOAD_Msk |
Maximum value for timer reload value (24bits).
| #define TIMER_MAX_SHOTWIDTH_VAL TIMER_TIMER_SHOTWIDTH_REG_TIM_SHOTWIDTH_Msk |
Maximum value for timer shot phase duration value in oneshot mode (24bits).
| typedef void(* hw_timer_capture_handler_cb) (uint8_t gpio_event) |
Timer capture interrupt callback.
| [in] | event | bitmask of capture time event GPIOs. "1" means capture event occurred on GPIO Bit: | 3 | 2 | 1 | 0 | +----—+----—+----—+----—+ | GPIO4 | GPIO3 | GPIO2 | GPIO1 | +----—+----—+----—+----—+ |
| typedef void(* hw_timer_handler_cb) (void) |
Timer interrupt callback.
| enum HW_TIMER_CLK_SRC |
| enum HW_TIMER_DIR |
| enum HW_TIMER_GPIO |
GPIOs for timer trigger.
In HW_TIMER_MODE_TIMER mode use to select which GPIO will trigger capture time. In HW_TIMER_MODE_ONESHOT mode use to select which GPIO will trigger the programmable pulse.
| enum HW_TIMER_MODE |
| enum HW_TIMER_ONESHOT |
| enum HW_TIMER_TRIGGER |
| __STATIC_INLINE void hw_timer_clear_gpio_event | ( | uint8_t | mask | ) |
Clear capture time GPIO event.
| [in] | mask | bitmask of capture time event GPIOs. Set "1" to clear event Bit: | 3 | 2 | 1 | 0 | +----—+----—+----—+----—+ event GPIO | GPIO4 | GPIO3 | GPIO2 | GPIO1 | +----—+----—+----—+----—+ |
| __STATIC_INLINE void hw_timer_clear_interrupt | ( | const HW_TIMER_ID | id | ) |
Clear timer interrupt.
Writing any value clears the interrupt
| [in] | id | timer id |
| void hw_timer_configure | ( | HW_TIMER_ID | id, |
| const timer_config * | cfg | ||
| ) |
Timer configuration.
Shortcut to call appropriate configuration function. If cfg is NULL, this function does nothing except switching timer to selected mode.
| [in] | id | timer id |
| [in] | cfg | configuration |
| void hw_timer_configure_oneshot | ( | HW_TIMER_ID | id, |
| const timer_config_oneshot * | cfg | ||
| ) |
Timer configuration for oneshot mode.
Shortcut to call appropriate configuration function. This does not switch timer to oneshot mode, it should be done separately using hw_timer_set_mode().
| [in] | id | timer id. Valid values for one shot mode are HW_TIMER and HW_TIMER2 |
| [in] | cfg | configuration |
| void hw_timer_configure_pwm | ( | HW_TIMER_ID | id, |
| const timer_config_pwm * | cfg | ||
| ) |
Timer PWM configuration.
Shortcut to call appropriate configuration function.
| [in] | id | timer id |
| [in] | cfg | configuration |
| void hw_timer_configure_timer | ( | HW_TIMER_ID | id, |
| const timer_config_timer_capture * | cfg | ||
| ) |
Timer configuration for timer/capture mode.
Shortcut to call appropriate configuration function. This does not switch timer to timer/capture mode, it should be done separately using hw_timer_set_mode().
| [in] | id | timer id |
| [in] | cfg | configuration |
| __STATIC_INLINE void hw_timer_disable | ( | HW_TIMER_ID | id | ) |
Disable the timer.
| [in] | id | timer id |
| __STATIC_INLINE void hw_timer_disable_clk | ( | HW_TIMER_ID | id | ) |
Disable the timer clock.
| [in] | id | timer id |
| __STATIC_INLINE void hw_timer_enable | ( | HW_TIMER_ID | id | ) |
Enable the timer.
| [in] | id | timer id |
| __STATIC_INLINE void hw_timer_enable_clk | ( | HW_TIMER_ID | id | ) |
Enable the timer clock.
| [in] | id | timer id |
| __STATIC_INLINE void hw_timer_freeze | ( | const HW_TIMER_ID | id | ) |
Freeze timer.
| [in] | id | timer id |
| __STATIC_INLINE bool hw_timer_frozen | ( | const HW_TIMER_ID | id | ) |
Check if timer is frozen.
| [in] | id | timer id |
| __STATIC_INLINE uint32_t hw_timer_get_capture1 | ( | HW_TIMER_ID | id | ) |
Get the capture time for event on GPIO1.
| [in] | id | timer id |
| __STATIC_INLINE uint32_t hw_timer_get_capture2 | ( | HW_TIMER_ID | id | ) |
Get the capture time for event on GPIO2.
| [in] | id | timer id |
| __STATIC_INLINE uint32_t hw_timer_get_capture3 | ( | void | ) |
Get the capture time for event on GPIO3. Valid only for Timer.
| __STATIC_INLINE uint32_t hw_timer_get_capture4 | ( | void | ) |
Get the capture time for event on GPIO4. Valid only for Timer.
| __STATIC_INLINE HW_TIMER_CLK_SRC hw_timer_get_clk | ( | HW_TIMER_ID | id | ) |
Get clock source of the timer.
| [in] | id | timer id |
| __STATIC_FORCEINLINE uint32_t hw_timer_get_count | ( | HW_TIMER_ID | id | ) |
Get the tick count of the timer.
| [in] | id | timer id |
| __STATIC_INLINE HW_TIMER_GPIO hw_timer_get_event1_gpio | ( | HW_TIMER_ID | id | ) |
Get a GPIO input which triggers event1.
| [in] | id | timer id |
| __STATIC_INLINE HW_TIMER_TRIGGER hw_timer_get_event1_trigger | ( | HW_TIMER_ID | id | ) |
Get a type of the edge which triggers event1.
| [in] | id | timer id |
| __STATIC_INLINE HW_TIMER_GPIO hw_timer_get_event2_gpio | ( | HW_TIMER_ID | id | ) |
Get a GPIO input which triggers event2.
| [in] | id | timer id |
| __STATIC_INLINE HW_TIMER_TRIGGER hw_timer_get_event2_trigger | ( | HW_TIMER_ID | id | ) |
Get a type of the edge which triggers event2.
| [in] | id | timer id |
| __STATIC_INLINE HW_TIMER_GPIO hw_timer_get_event3_gpio | ( | void | ) |
Get a GPIO input which triggers event3. Valid only for Timer.
| __STATIC_INLINE HW_TIMER_TRIGGER hw_timer_get_event3_trigger | ( | void | ) |
Get a type of the edge which triggers event3. Valid only for Timer.
| __STATIC_INLINE HW_TIMER_GPIO hw_timer_get_event4_gpio | ( | void | ) |
Get a GPIO input which triggers event4. Valid only for Timer.
| __STATIC_INLINE HW_TIMER_TRIGGER hw_timer_get_event4_trigger | ( | void | ) |
Get a type of the edge which triggers event4. Valid only for Timer.
| __STATIC_INLINE bool hw_timer_get_freerun | ( | HW_TIMER_ID | id | ) |
Get free-running mode state.
| [in] | id | timer id |
| __STATIC_INLINE bool hw_timer_get_gpio1_state | ( | HW_TIMER_ID | id | ) |
Get the current state of Event input 1 (IN1)
| [in] | id | timer id |
| __STATIC_INLINE bool hw_timer_get_gpio2_state | ( | HW_TIMER_ID | id | ) |
Get the current state of Event input 2 (IN2)
| [in] | id | timer id |
| __STATIC_INLINE uint8_t hw_timer_get_gpio_event_pending | ( | void | ) |
Get the time capture event GPIOs pending events.
This function can be used to read the pending status of the capture time event GPIOs (GPIO1 to GPIO4)
| __STATIC_INLINE HW_TIMER_MODE hw_timer_get_mode | ( | HW_TIMER_ID | id | ) |
Return timer mode.
| [in] | id | timer id |
| __STATIC_INLINE uint32_t hw_timer_get_oneshot_delay | ( | HW_TIMER_ID | id | ) |
Get pulse delay in oneshot mode.
| [in] | id | timer id |
| __STATIC_INLINE HW_TIMER_ONESHOT hw_timer_get_oneshot_phase | ( | HW_TIMER_ID | id | ) |
Get the current phase of the one shot mode.
| [in] | id | timer id |
| __STATIC_INLINE uint32_t hw_timer_get_prescaler | ( | HW_TIMER_ID | id | ) |
Get timer clock prescaler.
Actual timer frequency is timer_freq = freq_clock / (retval + 1)
| [in] | id | timer id |
| __STATIC_INLINE uint16_t hw_timer_get_prescaler_val | ( | HW_TIMER_ID | id | ) |
Get the current prescaler counter value.
This is value of internal counter used for prescaling. It can be used to have finer granularity when reading timer value.
For reading current setting of prescaler, see hw_timer_get_prescaler().
| [in] | id | timer id |
| __STATIC_INLINE uint32_t hw_timer_get_pwm_duty_cycle | ( | HW_TIMER_ID | id | ) |
Get PWM duty cycle.
Actualy PWM duty cycle is pwm_dc = retval / (pwm_freq + 1)
| [in] | id | timer id |
| __STATIC_INLINE uint32_t hw_timer_get_pwm_freq | ( | HW_TIMER_ID | id | ) |
Get PWM frequency.
Actual PWM frequency is pwm_freq = timer_freq / (retval + 1)
| [in] | id | timer id |
| __STATIC_INLINE uint32_t hw_timer_get_reload | ( | HW_TIMER_ID | id | ) |
| __STATIC_INLINE uint32_t hw_timer_get_shot_width | ( | HW_TIMER_ID | id | ) |
Get shot width.
This applies only to one-shot mode.
| [in] | id | timer id |
| void hw_timer_init | ( | HW_TIMER_ID | id, |
| const timer_config * | cfg | ||
| ) |
Timer initialization.
Turn on clock for timer and configure timer. After initialization both timer and its interrupt are disabled. cfg can be NULL - no configuration is performed in such case.
| [in] | id | timer id |
| [in] | cfg | configuration |
| void hw_timer_register_capture_int | ( | hw_timer_capture_handler_cb | handler, |
| uint8_t | gpio_mask | ||
| ) |
Register an interrupt handler for GPIO triggered Timer Capture interrupt.
| [in] | handler | function pointer to handler to call when an interrupt occurs |
| [in] | gpio_mask | bitmask of capture time event GPIOs. Set "1" to enable capture interrupt on GPIOx event Bit: | 3 | 2 | 1 | 0 | +----—+----—+----—+----—+ IRQ_EN | GPIO4 | GPIO3 | GPIO2 | GPIO1 | +----—+----—+----—+----—+ |
| __RETAINED_CODE void hw_timer_register_int | ( | const HW_TIMER_ID | id, |
| hw_timer_handler_cb | handler | ||
| ) |
Register an interrupt handler.
| [in] | id | timer id |
| [in] | handler | function pointer to handler to call when an interrupt occurs |
| __STATIC_INLINE void hw_timer_set_clk | ( | HW_TIMER_ID | id, |
| HW_TIMER_CLK_SRC | clk | ||
| ) |
Set clock source of the timer.
| [in] | id | timer id |
| [in] | clk | clock source of the timer, external or internal |
| __STATIC_INLINE void hw_timer_set_direction | ( | HW_TIMER_ID | id, |
| HW_TIMER_DIR | dir | ||
| ) |
Set the direction of timer counting.
| [in] | id | timer id |
| [in] | dir | counting direction of the timer, up or down |
| __STATIC_INLINE void hw_timer_set_event1_gpio | ( | HW_TIMER_ID | id, |
| HW_TIMER_GPIO | gpio | ||
| ) |
Set a GPIO input which triggers event1.
| [in] | id | timer id |
| [in] | gpio | GPIO input |
| __STATIC_INLINE void hw_timer_set_event1_trigger | ( | HW_TIMER_ID | id, |
| HW_TIMER_TRIGGER | edge | ||
| ) |
Set a type of the edge which triggers event1.
| [in] | id | timer id |
| [in] | edge | type of edge, rising or falling |
| __STATIC_INLINE void hw_timer_set_event2_gpio | ( | HW_TIMER_ID | id, |
| HW_TIMER_GPIO | gpio | ||
| ) |
Set a GPIO input which triggers event2.
| [in] | id | timer id |
| [in] | gpio | GPIO input |
| __STATIC_INLINE void hw_timer_set_event2_trigger | ( | HW_TIMER_ID | id, |
| HW_TIMER_TRIGGER | edge | ||
| ) |
Set a type of the edge which triggers event2.
| [in] | id | timer id |
| [in] | edge | type of edge, rising or falling |
| __STATIC_INLINE void hw_timer_set_event3_gpio | ( | HW_TIMER_GPIO | gpio | ) |
Set a GPIO input which triggers event3.
| [in] | gpio | GPIO input |
| __STATIC_INLINE void hw_timer_set_event3_trigger | ( | HW_TIMER_TRIGGER | edge | ) |
Set a type of the edge which triggers event3.
| [in] | edge | type of edge, rising or falling |
| __STATIC_INLINE void hw_timer_set_event4_gpio | ( | HW_TIMER_GPIO | gpio | ) |
Set a GPIO input which triggers event4.
| [in] | gpio | GPIO input |
| __STATIC_INLINE void hw_timer_set_event4_trigger | ( | HW_TIMER_TRIGGER | edge | ) |
Set a type of the edge which triggers event4.
| [in] | edge | type of edge, rising or falling |
| __STATIC_INLINE void hw_timer_set_freerun | ( | HW_TIMER_ID | id, |
| bool | enable | ||
| ) |
Turn on free run mode of the timer.
This mode is valid only when timer is counting up
| [in] | id | timer id |
| [in] | enable | if it is '1' timer does not zero when it reaches the reload value. |
| __STATIC_INLINE void hw_timer_set_gpio_event_int | ( | uint8_t | mask | ) |
Select which time capture event GPIOs will create a capture IRQ.
| [in] | mask | bitmask of capture time event GPIOs. Set "1" to enable capture interrupt on GPIOx event Bit: | 3 | 2 | 1 | 0 | +----—+----—+----—+----—+ IRQ_EN | GPIO4 | GPIO3 | GPIO2 | GPIO1 | +----—+----—+----—+----—+ |
| __STATIC_INLINE void hw_timer_set_mode | ( | HW_TIMER_ID | id, |
| HW_TIMER_MODE | mode | ||
| ) |
Set timer mode.
| [in] | id | timer id |
| [in] | mode | timer mode: '1' One shot, '0' counter |
| __STATIC_INLINE void hw_timer_set_oneshot_delay | ( | HW_TIMER_ID | id, |
| uint32_t | delay | ||
| ) |
Set pulse delay in oneshot mode.
| [in] | id | timer id |
| [in] | delay | delay (ticks). 24 bits long, shall not be greater than 0xffffff |
| __STATIC_INLINE void hw_timer_set_prescaler | ( | HW_TIMER_ID | id, |
| uint8_t | value | ||
| ) |
Set timer clock prescaler.
Actual timer frequency is timer_freq = freq_clock / (value + 1)
| [in] | id | timer id |
| [in] | value | prescaler. 5 bits long, shall not be greater than 0x1f |
| __STATIC_INLINE void hw_timer_set_pwm_duty_cycle | ( | HW_TIMER_ID | id, |
| uint32_t | value | ||
| ) |
Set PWM duty cycle.
Actualy PWM duty cycle is pwm_dc = value / (pwm_freq + 1)
| [in] | id | timer id |
| [in] | value | PWM duty cycle defined as above |
| __STATIC_INLINE void hw_timer_set_pwm_freq | ( | HW_TIMER_ID | id, |
| uint32_t | value | ||
| ) |
Set PWM frequency prescaler.
Actual PWM frequency is pwm_freq = timer_freq / (value + 1)
| [in] | id | timer id |
| [in] | value | PWM frequency defined as above |
| __STATIC_FORCEINLINE void hw_timer_set_reload | ( | HW_TIMER_ID | id, |
| uint32_t | value | ||
| ) |
Set timer reload value.
| [in] | id | timer id |
| [in] | value | reload value. 24 bits long, shall not be greater than 0xffffff |
| __STATIC_INLINE void hw_timer_set_shot_width | ( | HW_TIMER_ID | id, |
| uint32_t | duration | ||
| ) |
Set shot width.
This applies only to one-shot mode.
| [in] | id | timer id |
| [in] | duration | shot phase duration. 24 bits long, shall not be greater than 0xffffff |
| __STATIC_INLINE void hw_timer_unfreeze | ( | const HW_TIMER_ID | id | ) |
Unfreeze timer.
| [in] | id | timer id |
| void hw_timer_unregister_capture_int | ( | void | ) |
Unregister an interrupt handler for GPIO triggered Timer Capture interrupt.
| __RETAINED_HOT_CODE void hw_timer_unregister_int | ( | const HW_TIMER_ID | id | ) |
Unregister an interrupt handler.
| [in] | id | timer id |
1.8.16