Intel® Quark™ Microcontroller Software Interface  1.4.0
Intel® Quark™ Microcontroller BSP
PWM / Timer

Pulse width modulation and Timer driver. More...

Data Structures

struct  qm_pwm_config_t
 QM PWM / Timer configuration type. More...
 

Enumerations

enum  qm_pwm_mode_t { QM_PWM_MODE_TIMER_FREE_RUNNING = QM_PWM_MODE_TIMER_FREE_RUNNING_VALUE, QM_PWM_MODE_TIMER_COUNT = QM_PWM_MODE_TIMER_COUNT_VALUE }
 QM PWM mode type. More...
 

Functions

int qm_pwm_set_config (const qm_pwm_t pwm, const qm_pwm_id_t id, const qm_pwm_config_t *const cfg)
 Change the configuration of a PWM channel. More...
 
int qm_pwm_set (const qm_pwm_t pwm, const qm_pwm_id_t id, const uint32_t lo_count, const uint32_t hi_count)
 Set the next period values of a PWM channel. More...
 
int qm_pwm_get (const qm_pwm_t pwm, const qm_pwm_id_t id, uint32_t *const lo_count, uint32_t *const hi_count)
 Get the current period values of a PWM channel. More...
 
int qm_pwm_start (const qm_pwm_t pwm, const qm_pwm_id_t id)
 Start a PWM/timer channel. More...
 
int qm_pwm_stop (const qm_pwm_t pwm, const qm_pwm_id_t id)
 Stop a PWM/timer channel. More...
 
int qm_pwm_save_context (const qm_pwm_t pwm, qm_pwm_context_t *const ctx)
 Save PWM peripheral's context. More...
 
int qm_pwm_restore_context (const qm_pwm_t pwm, const qm_pwm_context_t *const ctx)
 Restore PWM peripheral's context. More...
 

Detailed Description

Pulse width modulation and Timer driver.

Enumeration Type Documentation

QM PWM mode type.

Enumerator
QM_PWM_MODE_TIMER_FREE_RUNNING 

Timer: Free running mode.

Timer: Counter mode.

QM_PWM_MODE_TIMER_COUNT 

PWM mode.

Definition at line 21 of file qm_pwm.h.

Function Documentation

int qm_pwm_get ( const qm_pwm_t  pwm,
const qm_pwm_id_t  id,
uint32_t *const  lo_count,
uint32_t *const  hi_count 
)

Get the current period values of a PWM channel.

Parameters
[in]pwmWhich PWM module to get the count of.
[in]idPWM channel id to read the values of.
[out]lo_countNum of cycles the output is driven low. This must not be NULL.
[out]hi_countNum of cycles the output is driven high. This must not be NULL.
Returns
Standard errno return type for QMSI.
Return values
0on success.
Negativeerrno for possible error codes.

Definition at line 151 of file qm_pwm.c.

References qm_pwm_channel_t::loadcount, qm_pwm_reg_t::timer, and qm_pwm_reg_t::timer_loadcount2.

int qm_pwm_restore_context ( const qm_pwm_t  pwm,
const qm_pwm_context_t *const  ctx 
)

Restore PWM peripheral's context.

Restore the configuration of the specified PWM peripheral after exiting sleep.

Parameters
[in]pwmPWM device.
[in]ctxPWM context structure. This must not be NULL.
Returns
Standard errno return type for QMSI.
Return values
0on success.
Negativeerrno for possible error codes.

Definition at line 210 of file qm_pwm.c.

References qm_pwm_channel_t::controlreg, qm_pwm_context_t::controlreg, qm_pwm_channel_t::loadcount, qm_pwm_context_t::loadcount, qm_pwm_context_t::loadcount2, qm_pwm_reg_t::timer, and qm_pwm_reg_t::timer_loadcount2.

int qm_pwm_save_context ( const qm_pwm_t  pwm,
qm_pwm_context_t *const  ctx 
)

Save PWM peripheral's context.

Saves the configuration of the specified PWM peripheral before entering sleep.

Parameters
[in]pwmPWM device.
[out]ctxPWM context structure. This must not be NULL.
Returns
Standard errno return type for QMSI.
Return values
0on success.
Negativeerrno for possible error codes.

Definition at line 202 of file qm_pwm.c.

References qm_pwm_channel_t::controlreg, qm_pwm_context_t::controlreg, qm_pwm_channel_t::loadcount, qm_pwm_context_t::loadcount, qm_pwm_context_t::loadcount2, qm_pwm_reg_t::timer, and qm_pwm_reg_t::timer_loadcount2.

int qm_pwm_set ( const qm_pwm_t  pwm,
const qm_pwm_id_t  id,
const uint32_t  lo_count,
const uint32_t  hi_count 
)

Set the next period values of a PWM channel.

This includes low period count and high period count. When operating in PWM mode, 0% and 100% duty cycle is not available on Quark SE or Quark D2000. When operating in PWM mode, hi_count must be > 0. In timer mode, the value of high count is ignored.

Set PWM period counts.

Parameters
[in]pwmWhich PWM module to set the counts of.
[in]idPWM channel id to set.
[in]lo_countNum of cycles the output is driven low.
[in]hi_countNum of cycles the output is driven high.
Returns
Standard errno return type for QMSI.
Return values
0on success.
Negativeerrno for possible error codes.

Definition at line 131 of file qm_pwm.c.

References qm_pwm_channel_t::loadcount, qm_pwm_reg_t::timer, and qm_pwm_reg_t::timer_loadcount2.

int qm_pwm_set_config ( const qm_pwm_t  pwm,
const qm_pwm_id_t  id,
const qm_pwm_config_t *const  cfg 
)

Change the configuration of a PWM channel.

This includes low period load value, high period load value, interrupt enable/disable. If interrupts are enabled, registers an ISR with the given user callback function. When operating in PWM mode, 0% and 100% duty cycle is not available on Quark SE or Quark D2000. When setting the mode to PWM mode, hi_count must be > 0. In timer mode, the value of high count is ignored.

Set PWM channel configuration.

Parameters
[in]pwmWhich PWM module to configure.
[in]idPWM channel id to configure.
[in]cfgNew configuration for PWM. This must not be NULL.
Returns
Standard errno return type for QMSI.
Return values
0on success.
Negativeerrno for possible error codes.

Definition at line 106 of file qm_pwm.c.

References qm_pwm_config_t::callback, qm_pwm_config_t::callback_data, qm_pwm_channel_t::controlreg, qm_pwm_config_t::hi_count, qm_pwm_config_t::lo_count, qm_pwm_channel_t::loadcount, qm_pwm_config_t::mask_interrupt, qm_pwm_config_t::mode, qm_pwm_reg_t::timer, and qm_pwm_reg_t::timer_loadcount2.

int qm_pwm_start ( const qm_pwm_t  pwm,
const qm_pwm_id_t  id 
)

Start a PWM/timer channel.

Parameters
[in]pwmWhich PWM block the PWM is in.
[in]idPWM channel id to start.
Returns
Standard errno return type for QMSI.
Return values
0on success.
Negativeerrno for possible error codes.

Definition at line 83 of file qm_pwm.c.

References qm_pwm_channel_t::controlreg, and qm_pwm_reg_t::timer.

int qm_pwm_stop ( const qm_pwm_t  pwm,
const qm_pwm_id_t  id 
)

Stop a PWM/timer channel.

Parameters
[in]pwmWhich PWM block the PWM is in.
[in]idPWM channel id to stop.
Returns
Standard errno return type for QMSI.
Return values
0on success.
Negativeerrno for possible error codes.

Definition at line 94 of file qm_pwm.c.

References qm_pwm_channel_t::controlreg, and qm_pwm_reg_t::timer.