Functions
IO operation functions
Peripheral Driver » HAL Driver » PWM » Functions

IO operation functions. More...

## Functions
hal_status_t | hal_pwm_start (pwm_handle_t *p_pwm)
| Starts the PWM signal generation on the output. More...
hal_status_t | hal_pwm_stop (pwm_handle_t *p_pwm)
| Stops the PWM signal generation on the output. More...
hal_status_t | hal_pwm_resume (pwm_handle_t *p_pwm)
| Resume the PWM signal generation on the output. More...
hal_status_t | hal_pwm_pause (pwm_handle_t *p_pwm)
| Pause the PWM signal generation on the output. More...
hal_status_t | hal_pwm_update_freq (pwm_handle_t *p_pwm, uint32_t freq)
| Update the PWM frequency on the output. More...
void | hal_pwm_suspend_reg (pwm_handle_t *p_pwm)
| Suspend some registers related to PWM configuration before sleep. More...
void | hal_pwm_resume_reg (const pwm_handle_t *p_pwm)
| Restore some registers related to PWM configuration after sleep. This function must be used in conjunction with the hal_pwm_suspend_reg(). More...
hal_pm_status_t | hal_pm_pwm_suspend (pwm_handle_t *p_pwm)
| Suspend the specified PWM. More...
void | hal_pm_pwm_resume (const pwm_handle_t *p_pwm)
| Resume the specified PWM. More...
hal_status_t | hal_pwm_config_channel (pwm_handle_t *p_pwm, const pwm_none_coding_channel_init_t *p_config, hal_pwm_active_channel_t channel)
| Initialize the PWM channels according to the specified parameters in the pwm_init_t. More...
hal_status_t | hal_pwm_inactive_channel (const pwm_handle_t *p_pwm, hal_pwm_active_channel_t channel)
| Set the specified PWM channel inactive. More...
hal_status_t | hal_pwm_set_coding_data_in_one_channel (const pwm_handle_t *p_pwm, uint32_t coding_data)
| Set pwm coding data. More...
hal_status_t | hal_pwm_set_coding_data_in_three_channels (const pwm_handle_t *p_pwm, uint32_t coding_data0, uint32_t coding_data1, uint32_t coding_data2)
| Set pwm coding data. More...
hal_status_t | hal_pwm_start_coding_with_dma (pwm_handle_t *p_pwm, uint32_t *p_data, uint16_t size)
| Start generate wave form in DMA mode. More...
hal_status_t | hal_pwm_start_coding_in_one_channel (pwm_handle_t *p_pwm, uint32_t coding_data)
| Start generate one channel wave form in Interrupt mode. More...
hal_status_t | hal_pwm_start_coding_in_three_channels (pwm_handle_t *p_pwm, uint32_t coding_data0, uint32_t coding_data1, uint32_t coding_data2)
| Start generate three channels wave form in Interrupt mode. More...
void | hal_pwm_irq_handler (pwm_handle_t *p_pwm)
| PWM irq handler. More...
hal_pwm_state_t | hal_pwm_get_state (const pwm_handle_t *p_pwm)
| Return the PWM handle state. More...

## Detailed Description

IO operation functions.

      ==============================================================================
                          ##### IO operation functions #####
      ==============================================================================
      [..]
        This section provides functions allowing to:
        (+) Start the PWM.
        (+) Stop the PWM.
        (+) Configure the specified PWM channel.

## Function Documentation

## ◆ hal_pm_pwm_resume()

void hal_pm_pwm_resume | ( | const pwm_handle_t * | p_pwm | ) |

Resume the specified PWM.

Parameters

  [in] | p_pwm | Pointer to a PWM handle

Return values

  ::None |

## ◆ hal_pm_pwm_suspend()

hal_pm_status_t hal_pm_pwm_suspend | ( | pwm_handle_t * | p_pwm | ) |

Suspend the specified PWM.

Parameters

  [in] | p_pwm | Pointer to a PWM handle

Return values

  HAL_PM_ACTIVE | Device is active, not allow sleep.
  HAL_PM_SLEEP | Allow sleep.

## ◆ hal_pwm_config_channel()

hal_status_t hal_pwm_config_channel | ( | pwm_handle_t * | p_pwm,
|  | const pwm_none_coding_channel_init_t * | p_config,
|  | hal_pwm_active_channel_t | channel
| ) |  |

Initialize the PWM channels according to the specified parameters in the pwm_init_t.

Parameters

  [in] | p_pwm | Pointer to a PWM handle that contains the configuration information for the specified PWM module.
  [in] | p_config | PWM Channels configuration structure.
  [in] | channel | PWM Channels to be configured. This parameter can be one of the following values: HAL_PWM_ACTIVE_CHANNEL_A :PWM Channel A is active HAL_PWM_ACTIVE_CHANNEL_B :PWM Channel B is active HAL_PWM_ACTIVE_CHANNEL_C :PWM Channel C is active HAL_PWM_ACTIVE_CHANNEL_ALL :All Channels are active

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.

## ◆ hal_pwm_get_state()

hal_pwm_state_t hal_pwm_get_state | ( | const pwm_handle_t * | p_pwm | ) |

Return the PWM handle state.

Parameters

  [in] | p_pwm | Pointer to a PWM handle that contains the configuration information for the specified PWM module.

Return values

  HAL_PWM_STATE_RESET | Peripheral is not initialized or disabled.
  HAL_PWM_STATE_READY | Peripheral is initialized and ready for use.
  HAL_PWM_STATE_BUSY | An internal process is ongoing.
  HAL_PWM_STATE_ERROR | Reception process is ongoing.

## ◆ hal_pwm_inactive_channel()

hal_status_t hal_pwm_inactive_channel | ( | const pwm_handle_t * | p_pwm,
|  | hal_pwm_active_channel_t | channel
| ) |  |

Set the specified PWM channel inactive.

Parameters

  [in] | p_pwm | Pointer to a PWM handle that contains the configuration information for the specified PWM module.
  [in] | channel | PWM Channels to be configured.

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.

## ◆ hal_pwm_irq_handler()

void hal_pwm_irq_handler | ( | pwm_handle_t * | p_pwm | ) |

PWM irq handler.

Parameters

  [in] | p_pwm | Pointer to a PWM handle that contains the configuration information for the specified PWM module.

Return values

  ::None |

## ◆ hal_pwm_pause()

hal_status_t hal_pwm_pause | ( | pwm_handle_t * | p_pwm | ) |

Pause the PWM signal generation on the output.

Parameters

  [in] | p_pwm | Pointer to a PWM handle that contains the configuration information for the specified PWM module.

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.

## ◆ hal_pwm_resume()

hal_status_t hal_pwm_resume | ( | pwm_handle_t * | p_pwm | ) |

Resume the PWM signal generation on the output.

Parameters

  [in] | p_pwm | Pointer to a PWM handle that contains the configuration information for the specified PWM module.

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.

## ◆ hal_pwm_resume_reg()

void hal_pwm_resume_reg | ( | const pwm_handle_t * | p_pwm | ) |

Restore some registers related to PWM configuration after sleep. This function must be used in conjunction with the hal_pwm_suspend_reg().

Parameters

  [in] | p_pwm | Pointer to a PWM handle which contains the configuration information for the specified PWM module.

Return values

  None |

## ◆ hal_pwm_set_coding_data_in_one_channel()

hal_status_t hal_pwm_set_coding_data_in_one_channel | ( | const pwm_handle_t * | p_pwm,
|  | uint32_t | coding_data
| ) |  |

Set pwm coding data.

Parameters

  [in] | p_pwm | Pointer to a PWM handle that contains the configuration information for the specified PWM module.
  [in] | coding_data | every bit represent compa0 or compa1 in coding data.

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.

## ◆ hal_pwm_set_coding_data_in_three_channels()

hal_status_t hal_pwm_set_coding_data_in_three_channels | ( | const pwm_handle_t * | p_pwm,
|  | uint32_t | coding_data0,
|  | uint32_t | coding_data1,
|  | uint32_t | coding_data2
| ) |  |

Set pwm coding data.

Parameters

  [in] | p_pwm | Pointer to a PWM handle that contains the configuration information for the specified PWM module.
  [in] | coding_data0 | every bit represent compa0 or compa1 in coding data0.
  [in] | coding_data1 | every bit represent compb0 or compb1 in coding data1.
  [in] | coding_data2 | every bit represent compc0 or compc1 in coding data2.

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.

## ◆ hal_pwm_start()

hal_status_t hal_pwm_start | ( | pwm_handle_t * | p_pwm | ) |

Starts the PWM signal generation on the output.

Parameters

  [in] | p_pwm | Pointer to a PWM handle that contains the configuration information for the specified PWM module.

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.

## ◆ hal_pwm_start_coding_in_one_channel()

hal_status_t hal_pwm_start_coding_in_one_channel | ( | pwm_handle_t * | p_pwm,
|  | uint32_t | coding_data
| ) |  |

Start generate one channel wave form in Interrupt mode.

Parameters

  [in] | p_pwm | Pointer to a PWM handle that contains the configuration information for the specified PWM module.
  [in] | coding_data | every bit represent compa0 or compa1 in coding data0.

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.

## ◆ hal_pwm_start_coding_in_three_channels()

hal_status_t hal_pwm_start_coding_in_three_channels | ( | pwm_handle_t * | p_pwm,
|  | uint32_t | coding_data0,
|  | uint32_t | coding_data1,
|  | uint32_t | coding_data2
| ) |  |

Start generate three channels wave form in Interrupt mode.

Parameters

  [in] | p_pwm | Pointer to a PWM handle that contains the configuration information for the specified PWM module.
  [in] | coding_data0 | every bit represent compa0 or compa1 in coding data0.
  [in] | coding_data1 | every bit represent compb0 or compb1 in coding data1.
  [in] | coding_data2 | every bit represent compc0 or compc1 in coding data2.

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.

## ◆ hal_pwm_start_coding_with_dma()

hal_status_t hal_pwm_start_coding_with_dma | ( | pwm_handle_t * | p_pwm,
|  | uint32_t * | p_data,
|  | uint16_t | size
| ) |  |

Start generate wave form in DMA mode.

Parameters

  [in] | p_pwm | Pointer to a PWM handle that contains the configuration information for the specified PWM module.
  [in] | p_data | the coding data address.
  [in] | size | coding data size.

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.

## ◆ hal_pwm_stop()

hal_status_t hal_pwm_stop | ( | pwm_handle_t * | p_pwm | ) |

Stops the PWM signal generation on the output.

Parameters

  [in] | p_pwm | Pointer to a PWM handle that contains the configuration information for the specified PWM module.

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.

## ◆ hal_pwm_suspend_reg()

void hal_pwm_suspend_reg | ( | pwm_handle_t * | p_pwm | ) |

Suspend some registers related to PWM configuration before sleep.

Parameters

  [in] | p_pwm | Pointer to a PWM handle which contains the configuration information for the specified PWM module.

Return values

  None |

## ◆ hal_pwm_update_freq()

hal_status_t hal_pwm_update_freq | ( | pwm_handle_t * | p_pwm,
|  | uint32_t | freq
| ) |  |

Update the PWM frequency on the output.

Parameters

  [in] | p_pwm | Pointer to a PWM handle that contains the configuration information for the specified PWM module.
  [in] | freq | This parameter ranges between min = 0 and max = SystemFreq / 2.

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.