Functions for the SPWM driver. More...
Functions | |
| spwm_status_en | spwm_init (spwm_instance_en id) |
| spwm_status_en | spwm_deinit (spwm_instance_en id) |
| spwm_status_en | spwm_enable (spwm_instance_en id, uint8_t group_id) |
| spwm_status_en | spwm_disable (spwm_instance_en id, uint8_t group_id) |
| spwm_status_en | spwm_clkdiv_config (spwm_instance_en id, uint8_t clkdiv_id, uint32_t int_div, uint32_t fra_div) |
| spwm_status_en | spwm_clkdiv_enable (spwm_instance_en id, uint8_t clkdiv_id, bool enable, uint8_t phase_align_sel) |
| spwm_status_en | spwm_otrigclk_config (spwm_instance_en id, uint8_t clkdiv_id) |
| spwm_status_en | spwm_configure (spwm_instance_en id, uint8_t group_id, const spwm_config_t *config) |
| spwm_status_en | spwm_trigger (spwm_instance_en id, uint8_t group_id, spwm_trigger_en trig) |
| spwm_status_en | spwm_group_trigger (spwm_instance_en id, uint8_t group_trigger_id) |
| spwm_status_en | spwm_get_counter (spwm_instance_en id, uint8_t group_id, uint32_t *val) |
| spwm_status_en | spwm_get_cc0 (spwm_instance_en id, uint8_t group_id, uint32_t *val) |
| spwm_status_en | spwm_get_cc1 (spwm_instance_en id, uint8_t group_id, uint32_t *val) |
| spwm_status_en | spwm_get_period (spwm_instance_en id, uint8_t group_id, uint32_t *val) |
| spwm_status_en | spwm_get_line_sel (spwm_instance_en id, uint8_t group_id, uint32_t *val) |
| spwm_status_en | spwm_get_cc0_buff (spwm_instance_en id, uint8_t group_id, uint32_t *val) |
| spwm_status_en | spwm_get_cc1_buff (spwm_instance_en id, uint8_t group_id, uint32_t *val) |
| spwm_status_en | spwm_get_period_buff (spwm_instance_en id, uint8_t group_id, uint32_t *val) |
| spwm_status_en | spwm_get_line_sel_buff (spwm_instance_en id, uint8_t group_id, uint32_t *val) |
| spwm_status_en | spwm_set_clkdiv (spwm_instance_en id, uint8_t group_id, uint8_t clkdiv_id) |
| spwm_status_en | spwm_set_mode (spwm_instance_en id, uint8_t group_id, spwm_mode_en mode) |
| spwm_status_en | spwm_set_count_mode (spwm_instance_en id, uint8_t group_id, spwm_count_mode_en count_mode) |
| spwm_status_en | spwm_set_counter (spwm_instance_en id, uint8_t group_id, uint32_t val) |
| spwm_status_en | spwm_set_one_shot (spwm_instance_en id, uint8_t group_id, bool one_shot) |
| spwm_status_en | spwm_set_prescale (spwm_instance_en id, uint8_t group_id, spwm_prescale_en prescale) |
| spwm_status_en | spwm_set_deadtime (spwm_instance_en id, uint8_t group_id, uint32_t deadtime, uint32_t compl_deadtime) |
| spwm_status_en | spwm_set_cc0 (spwm_instance_en id, uint8_t group_id, uint32_t val) |
| spwm_status_en | spwm_set_cc1 (spwm_instance_en id, uint8_t group_id, uint32_t val) |
| spwm_status_en | spwm_set_period (spwm_instance_en id, uint8_t group_id, uint32_t val) |
| spwm_status_en | spwm_set_line_sel (spwm_instance_en id, uint8_t group_id, uint32_t val) |
| spwm_status_en | spwm_set_cc0_buff (spwm_instance_en id, uint8_t group_id, uint32_t val) |
| spwm_status_en | spwm_set_cc1_buff (spwm_instance_en id, uint8_t group_id, uint32_t val) |
| spwm_status_en | spwm_set_period_buff (spwm_instance_en id, uint8_t group_id, uint32_t val) |
| spwm_status_en | spwm_set_line_sel_buff (spwm_instance_en id, uint8_t group_id, uint32_t val) |
| spwm_status_en | spwm_set_trig_in_all (spwm_instance_en id, uint8_t group_id, const spwm_trigger_in_cfg_t *cfg) |
| spwm_status_en | spwm_set_trig_in (spwm_instance_en id, uint8_t group_id, spwm_trigger_en trigger, const spwm_trigger_in_cfg_t *config) |
| spwm_status_en | spwm_set_trig_out (spwm_instance_en id, uint8_t group_id, int out_id, spwm_trigger_out_en out) |
| spwm_status_en | spwm_set_sema (spwm_instance_en id, uint8_t group_id, uint8_t sema_id, uint8_t val) |
| spwm_status_en | spwm_set_sema_sel (spwm_instance_en id, uint8_t group_id, int sema_id, spwm_trigger_out_en out) |
| uint32_t | spwm_make_line_sel (spwm_line_src_en out, spwm_line_src_en compl) |
| spwm_status_en | spwm_get_interrupt_status (spwm_instance_en id, uint8_t group_id, uint32_t *irq_status) |
| spwm_status_en | spwm_enable_interrupt (spwm_instance_en id, uint8_t group_id, spwm_intr_en intr) |
| spwm_status_en | spwm_disable_interrupt (spwm_instance_en id, uint8_t group_id, spwm_intr_en intr) |
| spwm_status_en | spwm_disable_all_interrupts (spwm_instance_en id, uint8_t group_id) |
| spwm_status_en | spwm_clear_all_interrupts (spwm_instance_en id, uint8_t group_id) |
| spwm_status_en | spwm_output_select (spwm_instance_en id, uint8_t group_id, spwm_io_pin_en pin, bool compl) |
| spwm_status_en | spwm_clear_interrupt (spwm_instance_en id, uint8_t group_id, uint32_t mask) |
| spwm_status_en | spwm_clear_desc_interrupt (spwm_instance_en id, uint8_t desc_id) |
| spwm_status_en | spwm_enable_desc_interrupt (spwm_instance_en id, uint8_t desc_id) |
| spwm_status_en | spwm_disable_desc_interrupt (spwm_instance_en id, uint8_t desc_id) |
| spwm_status_en | spwm_register_callback (spwm_instance_en id, spwm_isr_cb_t cb, void *user_ctx) |
| spwm_status_en | spwm_register_desc_callback (spwm_instance_en id, spwm_desc_isr_cb_t cb, void *param) |
| spwm_dsc_status_en | spwm_dsc_mem_alloc (size_t size_bytes, uint16_t *handle) |
| void | spwm_dsc_mem_free (uint16_t handle) |
| spwm_dsc_chain_t * | spwm_dsc_chain_create (void) |
| void | spwm_dsc_chain_destroy (spwm_dsc_chain_t *chain) |
| spwm_dsc_status_en | spwm_dsc_chain_init_for_handle (spwm_instance_en id, spwm_dsc_chain_t *chain, uint16_t handle) |
| spwm_dsc_status_en | spwm_dsc_chain_init (spwm_instance_en id, spwm_dsc_chain_t *chain, uint32_t start_offset_bytes, uint32_t block_size_bytes) |
| spwm_dsc_status_en | spwm_dsc_chain_add_cfg (spwm_dsc_chain_t *chain, uint8_t group_id, spwm_dsc_reg_id_en reg_id, const uint32_t *values, uint32_t num_values, bool last) |
| spwm_dsc_status_en | spwm_dsc_chain_add_syn (spwm_dsc_chain_t *chain, spwm_dsc_syn_op_en opcode, uint8_t group, uint32_t counter_mask, bool last) |
| spwm_dsc_status_en | spwm_dsc_chain_add_nxt (spwm_dsc_chain_t *chain, uint32_t target_offset_bytes) |
| spwm_dsc_status_en | spwm_dsc_chain_start (spwm_instance_en id, const spwm_dsc_chain_t *chain, uint8_t desc_id, bool enable_interrupt) |
| spwm_dsc_status_en | spwm_dsc_chain_get_status (spwm_instance_en id, const spwm_dsc_chain_t *chain, uint8_t instance, spwm_dsc_chain_status_t *status) |
Functions for the SPWM driver.
group_spwm_data_structures
| spwm_status_en spwm_init | ( | spwm_instance_en | id | ) |
Initializes the SPWM instance and low-level resources.
This function configures the hardware base address, resets registers to a known safe state, and prepares the instance for subsequent configuration.
| id | SPWM instance identifier. |
| spwm_status_en spwm_deinit | ( | spwm_instance_en | id | ) |
Deinitializes the SPWM instance and releases resources.
Stops the counter, disables interrupts, and returns the block to reset state.
| id | SPWM instance identifier. |
| spwm_status_en spwm_enable | ( | spwm_instance_en | id, |
| uint8_t | group_id ) |
Enables the SPWM group.
This function enables the specified SPWM group within a given SPWM instance by setting the ENABLED bit in the group control register.
| id | SPWM instance identifier. |
| group_id | Group index to enable. |
| spwm_status_en spwm_disable | ( | spwm_instance_en | id, |
| uint8_t | group_id ) |
Disables the SPWM group.
This function disables the specified SPWM group by clearing the ENABLED bit in the group control register. Typically used when stopping output from a SPWM group.
| id | SPWM instance identifier. |
| group_id | Group index to disable. |
| spwm_status_en spwm_clkdiv_config | ( | spwm_instance_en | id, |
| uint8_t | clkdiv_id, | ||
| uint32_t | int_div, | ||
| uint32_t | fra_div ) |
Configures the integer and fractional dividers for an SPWM clock divider.
This function programs the INT_DIV and FRA_DIV fields of the selected SPWM clock divider. The divider must be disabled prior to calling this function.
| id | SPWM instance identifier. |
| clkdiv_id | Clock divider index. |
| int_div | Integer divider value (must be >= 1). |
| fra_div | Fractional divider value. |
| spwm_status_en spwm_clkdiv_enable | ( | spwm_instance_en | id, |
| uint8_t | clkdiv_id, | ||
| bool | enable, | ||
| uint8_t | phase_align_sel ) |
Enables or disables a specific SPWM clock divider.
This function issues the DIV_CMD sequence to enable or disable the selected clock divider. When enabling, both divider selection and phase-alignment selection are written before asserting ENABLE.
| id | SPWM instance identifier. |
| clkdiv_id | Clock divider index. |
| enable | true to enable, false to disable. |
| phase_align_sel | Divider ID to phase-align with when enabling. |
| spwm_status_en spwm_otrigclk_config | ( | spwm_instance_en | id, |
| uint8_t | clkdiv_id ) |
Selects the output-trigger clock divider for the SPWM block.
This function configures the OTRIGCLK clock source by selecting which clock divider output is routed to the SPWM trigger-clock domain.
| id | SPWM instance identifier. |
| clkdiv_id | Clock divider index to route as the trigger clock. |
| spwm_status_en spwm_configure | ( | spwm_instance_en | id, |
| uint8_t | group_id, | ||
| const spwm_config_t * | config ) |
Applies unified configuration to the SPWM instance for a specific group.
This function programs all configuration parameters for the selected SPWM group, including mode, clock divider, compare values, period, trigger routing, and mode-specific settings.
| id | SPWM instance identifier. |
| group_id | Group index to configure. |
| config | Pointer to populated spwm_config_t structure. |
| spwm_status_en spwm_trigger | ( | spwm_instance_en | id, |
| uint8_t | group_id, | ||
| spwm_trigger_en | trig ) |
Issues a single trigger pulse to a specific SPWM group.
This function generates a one-shot pulse on the selected trigger signal (START, STOP, RELOAD, CAPTURE0, or CAPTURE1).
| id | SPWM instance identifier. |
| group_id | Group index to send the trigger to. |
| trig | Trigger type to issue (see spwm_trigger_en). |
| spwm_status_en spwm_group_trigger | ( | spwm_instance_en | id, |
| uint8_t | group_trigger_id ) |
Generates a trigger pulse on the global SPWM group-trigger bus.
This function asserts a single trigger line in the global TR_CMD register to activate the selected group trigger.
| id | SPWM instance identifier. |
| group_trigger_id | Index of the group trigger to assert. |
| spwm_status_en spwm_get_counter | ( | spwm_instance_en | id, |
| uint8_t | group_id, | ||
| uint32_t * | val ) |
Reads the current counter register value of a group.
This function retrieves the current register value of the counter register for the specified SPWM group.
| id | SPWM instance identifier. |
| group_id | Group index to read. |
| val | [out] Pointer to store the counter value. |
| spwm_status_en spwm_get_cc0 | ( | spwm_instance_en | id, |
| uint8_t | group_id, | ||
| uint32_t * | val ) |
Reads the CC0 compare value of a group.
This function retrieves the active CC0 register value from the specified SPWM group.
| id | SPWM instance identifier. |
| group_id | Group index to read. |
| val | [out] Pointer to store the CC0 value. |
| spwm_status_en spwm_get_cc1 | ( | spwm_instance_en | id, |
| uint8_t | group_id, | ||
| uint32_t * | val ) |
Reads the CC1 compare value of a group.
This function retrieves the active CC1 register value from the specified SPWM group.
| id | SPWM instance identifier. |
| group_id | Group index to read. |
| val | [out] Pointer to store the CC1 value. |
| spwm_status_en spwm_get_period | ( | spwm_instance_en | id, |
| uint8_t | group_id, | ||
| uint32_t * | val ) |
Reads the base period of a group.
This function retrieves the active period register value from the specified SPWM group.
| id | SPWM instance identifier. |
| group_id | Group index to read. |
| val | [out] Pointer to store the period value. |
| spwm_status_en spwm_get_line_sel | ( | spwm_instance_en | id, |
| uint8_t | group_id, | ||
| uint32_t * | val ) |
Reads the line selection register of a group.
This function retrieves the current line selection configuration for the specified SPWM group.
| id | SPWM instance identifier. |
| group_id | Group index to read. |
| val | [out] Pointer to store the line selection value. |
| spwm_status_en spwm_get_cc0_buff | ( | spwm_instance_en | id, |
| uint8_t | group_id, | ||
| uint32_t * | val ) |
Reads the CC0 buffered compare value of a group.
This function retrieves the buffered CC0 value from the specified SPWM group.
| id | SPWM instance identifier. |
| group_id | Group index to read. |
| val | [out] Pointer to store the buffered CC0 value. |
| spwm_status_en spwm_get_cc1_buff | ( | spwm_instance_en | id, |
| uint8_t | group_id, | ||
| uint32_t * | val ) |
Reads the CC1 buffered compare value of a group.
This function retrieves the buffered CC1 value from the specified SPWM group.
| id | SPWM instance identifier. |
| group_id | Group index to read. |
| val | [out] Pointer to store the buffered CC1 value. |
| spwm_status_en spwm_get_period_buff | ( | spwm_instance_en | id, |
| uint8_t | group_id, | ||
| uint32_t * | val ) |
Reads the buffered period of a group.
This function retrieves the period buffer value from the specified SPWM group.
| id | SPWM instance identifier. |
| group_id | Group index to read. |
| val | [out] Pointer to store the buffered period value. |
| spwm_status_en spwm_get_line_sel_buff | ( | spwm_instance_en | id, |
| uint8_t | group_id, | ||
| uint32_t * | val ) |
Reads the buffered line selection of a group.
This function retrieves the line selection buffer value from the specified SPWM group.
| id | SPWM instance identifier. |
| group_id | Group index to read. |
| val | [out] Pointer to store the buffered line selection value. |
| spwm_status_en spwm_set_clkdiv | ( | spwm_instance_en | id, |
| uint8_t | group_id, | ||
| uint8_t | clkdiv_id ) |
Selects the clock divider used by an SPWM group.
This function updates the CLKDIV_SEL field in the group clock control register to specify which clock divider output drives the selected SPWM group.
| id | SPWM instance identifier. |
| group_id | Group index whose clock divider is being selected. |
| clkdiv_id | Clock divider index to assign to the group. |
| spwm_status_en spwm_set_mode | ( | spwm_instance_en | id, |
| uint8_t | group_id, | ||
| spwm_mode_en | mode ) |
Sets the operating mode of an SPWM group.
This function programs the MODE field in the group control register to select the functional mode of operation, such as timer, capture, PWM, PWM with dead-time, or pseudo-random PWM mode.
| id | SPWM instance identifier. |
| group_id | Group index to configure. |
| mode | SPWM operating mode to be applied. |
| spwm_status_en spwm_set_count_mode | ( | spwm_instance_en | id, |
| uint8_t | group_id, | ||
| spwm_count_mode_en | count_mode ) |
Sets the counter direction or counting mode of an SPWM group.
This function programs the UP_DOWN_MODE field in the group control register to control how the counter operates, such as counting up, down, or up-down.
| id | SPWM instance identifier. |
| group_id | Group index to configure. |
| count_mode | Counter mode selection. |
| spwm_status_en spwm_set_counter | ( | spwm_instance_en | id, |
| uint8_t | group_id, | ||
| uint32_t | val ) |
Sets the counter value of a group.
This function writes a new value to the active counter of the specified SPWM group.
| id | SPWM instance identifier. |
| group_id | Group index to write. |
| val | Counter value to set. |
| spwm_status_en spwm_set_one_shot | ( | spwm_instance_en | id, |
| uint8_t | group_id, | ||
| bool | one_shot ) |
Configures the one-shot mode of a SPWM group.
This function enables or disables one-shot operation for the specified SPWM group. In one-shot mode, the counter stops automatically after reaching the terminal count.
| id | SPWM instance identifier. |
| group_id | Group index to configure. |
| one_shot | true to enable one-shot mode, false to disable. |
| spwm_status_en spwm_set_prescale | ( | spwm_instance_en | id, |
| uint8_t | group_id, | ||
| spwm_prescale_en | prescale ) |
Sets the prescaler for a SPWM group.
This function configures the clock prescaler that divides the input clock to the specified SPWM group.
| id | SPWM instance identifier. |
| group_id | Group index to configure. |
| prescale | Prescaler value (see spwm_prescale_en). |
| spwm_status_en spwm_set_deadtime | ( | spwm_instance_en | id, |
| uint8_t | group_id, | ||
| uint32_t | deadtime, | ||
| uint32_t | compl_deadtime ) |
Configures dead-time for PWM outputs of a SPWM group.
This function sets the line and complementary line dead-time values, which are inserted between high-side and low-side switches to prevent shoot-through.
| id | SPWM instance identifier. |
| group_id | Group index to configure. |
| deadtime | Dead-time for the main output line (in clock cycles). |
| compl_deadtime | Dead-time for the complementary output line (in clock cycles). |
| spwm_status_en spwm_set_cc0 | ( | spwm_instance_en | id, |
| uint8_t | group_id, | ||
| uint32_t | val ) |
Sets the CC0 compare value of a SPWM group.
This function writes a new value to the CC0 register of the specified SPWM group.
| id | SPWM instance identifier. |
| group_id | Group index to write. |
| val | CC0 compare value to set. |
| spwm_status_en spwm_set_cc1 | ( | spwm_instance_en | id, |
| uint8_t | group_id, | ||
| uint32_t | val ) |
Sets the CC1 compare value of a SPWM group.
This function writes a new value to the CC1 register of the specified SPWM group.
| id | SPWM instance identifier. |
| group_id | Group index to write. |
| val | CC1 compare value to set. |
| spwm_status_en spwm_set_period | ( | spwm_instance_en | id, |
| uint8_t | group_id, | ||
| uint32_t | val ) |
Sets the base period of a SPWM group.
This function updates the active period register of the specified SPWM group.
| id | SPWM instance identifier. |
| group_id | Group index to write. |
| val | Period value to set. |
| spwm_status_en spwm_set_line_sel | ( | spwm_instance_en | id, |
| uint8_t | group_id, | ||
| uint32_t | val ) |
Sets the line selection of a SPWM group.
This function configures the output line mapping for the SPWM group.
| id | SPWM instance identifier. |
| group_id | Group index to configure. |
| val | Line selection value to set. |
| spwm_status_en spwm_set_cc0_buff | ( | spwm_instance_en | id, |
| uint8_t | group_id, | ||
| uint32_t | val ) |
Sets the CC0 buffer compare value of a SPWM group.
This function writes a value to the CC0 buffer register of the specified SPWM group.
| id | SPWM instance identifier. |
| group_id | Group index to write. |
| val | CC0 buffer value to set. |
| spwm_status_en spwm_set_cc1_buff | ( | spwm_instance_en | id, |
| uint8_t | group_id, | ||
| uint32_t | val ) |
Sets the CC1 buffer compare value of a SPWM group.
This function writes a value to the CC1 buffer register of the specified SPWM group.
| id | SPWM instance identifier. |
| group_id | Group index to write. |
| val | CC1 buffer value to set. |
| spwm_status_en spwm_set_period_buff | ( | spwm_instance_en | id, |
| uint8_t | group_id, | ||
| uint32_t | val ) |
Sets the buffered period value of a SPWM group.
This function writes a value to the period buffer register of the specified SPWM group. When auto-reload is enabled, the buffered value will be loaded into the active period register on the configured trigger event.
| id | SPWM instance identifier. |
| group_id | Group index to write. |
| val | Period buffer value to set. |
| spwm_status_en spwm_set_line_sel_buff | ( | spwm_instance_en | id, |
| uint8_t | group_id, | ||
| uint32_t | val ) |
Sets the buffered line selection of a SPWM group.
This function writes a value to the line selection buffer register of the specified SPWM group. When auto-reload is enabled, the buffered value will be loaded into the active line selection register on the configured trigger event.
| id | SPWM instance identifier. |
| group_id | Group index to configure. |
| val | Line selection buffer value to set. |
| spwm_status_en spwm_set_trig_in_all | ( | spwm_instance_en | id, |
| uint8_t | group_id, | ||
| const spwm_trigger_in_cfg_t * | cfg ) |
Configures all input trigger lines for the SPWM group in a batch operation.
This function configures all SPWM_TRIG_IN_COUNT trigger inputs (CAP0, COUNT, RELOAD, STOP, START, CAP1) for the specified group in a single call, providing a more efficient alternative to multiple individual spwm_set_trig_in calls.
| id | SPWM instance identifier. |
| group_id | Group index to configure. |
| cfg | Pointer to array of SPWM_TRIG_IN_COUNT trigger configuration structures. The array must contain configurations for all trigger inputs in order: [0]=CAP0, [1]=COUNT, [2]=RELOAD, [3]=STOP, [4]=START, [5]=CAP1. |
| spwm_status_en spwm_set_trig_in | ( | spwm_instance_en | id, |
| uint8_t | group_id, | ||
| spwm_trigger_en | trigger, | ||
| const spwm_trigger_in_cfg_t * | config ) |
Configures a single input trigger line for the SPWM group.
This function programs the source, edge detection mode, and inversion setting for a specified trigger input (CAP0, COUNT, RELOAD, STOP, START, or CAP1).
| id | SPWM instance identifier. |
| group_id | Group index to configure. |
| trigger | Input trigger selection (see spwm_trigger_en). |
| config | Pointer to input trigger configuration structure containing source, edge detection, and inversion settings. |
| spwm_status_en spwm_set_trig_out | ( | spwm_instance_en | id, |
| uint8_t | group_id, | ||
| int | out_id, | ||
| spwm_trigger_out_en | out ) |
Configures an output trigger event source for the SPWM group.
This function selects which internal counter event (overflow, underflow, terminal count, CC0/CC1 match, or line output) generates a pulse on the specified trigger output (TR_OUT0 or TR_OUT1).
| id | SPWM instance identifier. |
| group_id | Group index to configure. |
| out_id | Output trigger index (0 for TR_OUT0, 1 for TR_OUT1). |
| out | Output event selection (see spwm_trigger_out_en). |
| spwm_status_en spwm_set_sema | ( | spwm_instance_en | id, |
| uint8_t | group_id, | ||
| uint8_t | sema_id, | ||
| uint8_t | val ) |
Sets a semaphore value for a specified channel in the SPWM group.
This function writes to a semaphore register, which can be used for synchronization between SPWM groups or with descriptor chains. Semaphores are typically set by hardware events and polled or cleared by software or descriptor operations.
| id | SPWM instance identifier. |
| group_id | Group index to configure. |
| sema_id | Semaphore channel index (0 for SEMA0, 1 for SEMA1). |
| val | Value to write to the semaphore register. |
| spwm_status_en spwm_set_sema_sel | ( | spwm_instance_en | id, |
| uint8_t | group_id, | ||
| int | sema_id, | ||
| spwm_trigger_out_en | out ) |
Selects the trigger-out source for a semaphore channel.
This function configures which internal counter event automatically sets the specified semaphore. This allows hardware events to signal descriptor chains or other SPWM groups without software intervention.
| id | SPWM instance identifier. |
| group_id | Group index to configure. |
| sema_id | Semaphore channel index (0 for SEMA0, 1 for SEMA1). |
| out | Output event selection that will set the semaphore (see spwm_trigger_out_en). |
| uint32_t spwm_make_line_sel | ( | spwm_line_src_en | out, |
| spwm_line_src_en | compl ) |
Creates a line selection value for SPWM output routing.
This utility function encodes the source selections for both normal and complementary PWM outputs into a single 32-bit value that can be written to the line selection register. Each output can be configured independently to drive low, high, PWM signal, inverted PWM, or high-impedance.
| out | Source selection for the normal output (see spwm_line_src_en). |
| compl | Source selection for the complementary output (see spwm_line_src_en). |
| spwm_status_en spwm_get_interrupt_status | ( | spwm_instance_en | id, |
| uint8_t | group_id, | ||
| uint32_t * | irq_status ) |
Reads the interrupt status for the specified SPWM group.
This function retrieves the current state of all interrupt sources for the group, including terminal count, CC0 match, and CC1 match interrupts. The status reflects which interrupts have been latched regardless of whether they are enabled.
| id | SPWM instance identifier. |
| group_id | Group index to read. |
| irq_status | [out] Pointer to store the interrupt status bitmask. |
| spwm_status_en spwm_enable_interrupt | ( | spwm_instance_en | id, |
| uint8_t | group_id, | ||
| spwm_intr_en | intr ) |
Enables a specific interrupt source for the SPWM group.
This function unmasks the specified interrupt type (terminal count, CC0 match, or CC1 match) for the given group, allowing it to trigger the group's interrupt handler when the corresponding event occurs.
| id | SPWM instance identifier. |
| group_id | Group index to configure. |
| intr | Interrupt type to enable (see spwm_intr_en). |
| spwm_status_en spwm_disable_interrupt | ( | spwm_instance_en | id, |
| uint8_t | group_id, | ||
| spwm_intr_en | intr ) |
Disables a specific interrupt source for the SPWM group.
This function masks the specified interrupt type (terminal count, CC0 match, or CC1 match) for the given group, preventing it from triggering the group's interrupt handler even if the corresponding event occurs.
| id | SPWM instance identifier. |
| group_id | Group index to configure. |
| intr | Interrupt type to disable (see spwm_intr_en). |
| spwm_status_en spwm_disable_all_interrupts | ( | spwm_instance_en | id, |
| uint8_t | group_id ) |
Disables all interrupt sources for the specified SPWM group.
This function masks all interrupt types (terminal count, CC0 match, and CC1 match) for the given group, ensuring no interrupts from this group will be triggered.
| id | SPWM instance identifier. |
| group_id | Group index to configure. |
| spwm_status_en spwm_clear_all_interrupts | ( | spwm_instance_en | id, |
| uint8_t | group_id ) |
Clears all pending interrupts for the specified SPWM group.
This function clears the latched state of all interrupt sources (terminal count, CC0 match, and CC1 match) for the given group. This is typically called from the interrupt service routine to acknowledge handled interrupts.
| id | SPWM instance identifier. |
| group_id | Group index to clear. |
| spwm_status_en spwm_output_select | ( | spwm_instance_en | id, |
| uint8_t | group_id, | ||
| spwm_io_pin_en | pin, | ||
| bool | compl ) |
Selects the output pin and polarity for the specified SPWM group.
This function configures which physical SPWM output pin is driven by the specified group and whether the normal or complementary output is used. This allows flexible routing of SPWM signals to different output pins.
| id | SPWM instance identifier. |
| group_id | Group index to configure. |
| pin | Output pin to select (see spwm_io_pin_en). |
| compl | true to route the complementary output to the pin, false for normal output. |
| spwm_status_en spwm_clear_interrupt | ( | spwm_instance_en | id, |
| uint8_t | group_id, | ||
| uint32_t | mask ) |
Clears selected interrupt sources for a given SPWM group.
This function clears specific interrupt flags for the group based on the provided bitmask, allowing selective acknowledgment of interrupt sources.
| id | SPWM instance identifier. |
| group_id | SPWM group index. |
| mask | Bitmask specifying which interrupt sources to clear. |
| spwm_status_en spwm_clear_desc_interrupt | ( | spwm_instance_en | id, |
| uint8_t | desc_id ) |
Clears the descriptor interrupt for an SPWM instance.
This function clears the descriptor-related interrupt status for the specified descriptor instance, acknowledging completion or error conditions generated by the descriptor engine.
| id | SPWM instance identifier. |
| desc_id | Descriptor instance index. |
| spwm_status_en spwm_enable_desc_interrupt | ( | spwm_instance_en | id, |
| uint8_t | desc_id ) |
Enables interrupt for a specific descriptor instance.
This function unmasks the interrupt for the specified descriptor instance. Descriptor interrupt callbacks must be registered separately using spwm_register_desc_callback.
| id | SPWM instance identifier. |
| desc_id | Descriptor instance index to enable. |
| spwm_status_en spwm_disable_desc_interrupt | ( | spwm_instance_en | id, |
| uint8_t | desc_id ) |
Disables interrupt for a specific descriptor instance.
This function masks the interrupt for the specified descriptor instance, preventing it from triggering interrupt handlers even if descriptor events occur.
| id | SPWM instance identifier. |
| desc_id | Descriptor instance index to disable. |
| spwm_status_en spwm_register_callback | ( | spwm_instance_en | id, |
| spwm_isr_cb_t | cb, | ||
| void * | user_ctx ) |
Registers an ISR callback for the SPWM instance.
This function registers a callback function that will be invoked from the SPWM ISR context when enabled interrupt sources are latched. The callback receives a bitmask indicating which interrupt sources fired.
| id | SPWM instance identifier. |
| cb | Callback function pointer (see spwm_isr_cb_t). |
| user_ctx | Opaque pointer passed back to the callback function. |
| spwm_status_en spwm_register_desc_callback | ( | spwm_instance_en | id, |
| spwm_desc_isr_cb_t | cb, | ||
| void * | param ) |
Registers a descriptor ISR callback for the SPWM instance.
This function registers a callback function that will be invoked when any descriptor instance on the SPWM instance completes or encounters an error. The callback receives the descriptor instance ID that triggered the event.
| id | SPWM instance identifier. |
| cb | Callback function pointer (see spwm_desc_isr_cb_t). |
| param | User-defined context pointer passed to the callback function. |
| spwm_dsc_status_en spwm_dsc_mem_alloc | ( | size_t | size_bytes, |
| uint16_t * | handle ) |
Allocates memory from the SPWM descriptor memory pool.
This function allocates a contiguous block of descriptor SRAM and returns a handle that can be used to reference the allocated memory. The handle can be converted to an offset for use with descriptor chain initialization.
| size_bytes | Number of bytes to allocate from the descriptor memory pool. |
| handle | [out] Pointer to a variable where the allocated descriptor handle will be stored. |
| void spwm_dsc_mem_free | ( | uint16_t | handle | ) |
Frees previously allocated SPWM descriptor memory.
This function releases descriptor SRAM identified by the provided handle, making it available for future allocations. The handle becomes invalid after this call.
| handle | Handle of the allocated descriptor memory to be freed. |
| spwm_dsc_chain_t * spwm_dsc_chain_create | ( | void | ) |
Allocates and initializes a new SPWM descriptor chain object.
This function dynamically allocates a descriptor chain structure and initializes it to an empty state. The chain can then be populated with descriptors and executed on a descriptor instance.
| void spwm_dsc_chain_destroy | ( | spwm_dsc_chain_t * | chain | ) |
Frees resources associated with a SPWM descriptor chain.
This function deallocates the descriptor chain structure and releases any associated resources. The chain pointer becomes invalid after this call.
| chain | Pointer to the descriptor chain to destroy. |
| spwm_dsc_status_en spwm_dsc_chain_init_for_handle | ( | spwm_instance_en | id, |
| spwm_dsc_chain_t * | chain, | ||
| uint16_t | handle ) |
Initializes a descriptor chain using a memory handle.
This function associates a descriptor chain with descriptor SRAM previously allocated via spwm_dsc_mem_alloc. The handle is automatically converted to the appropriate offset within the descriptor memory space.
| id | SPWM instance identifier. |
| chain | [out] Pointer to a descriptor chain structure to initialize. |
| handle | Descriptor memory handle obtained from spwm_dsc_mem_alloc. |
| spwm_dsc_status_en spwm_dsc_chain_init | ( | spwm_instance_en | id, |
| spwm_dsc_chain_t * | chain, | ||
| uint32_t | start_offset_bytes, | ||
| uint32_t | block_size_bytes ) |
Initializes a descriptor chain at a specified offset in descriptor SRAM.
This function associates a descriptor chain with a given SPWM instance and initializes it to start at the specified byte offset within the descriptor SRAM. This allows manual control over descriptor memory placement.
| id | SPWM instance identifier. |
| chain | [out] Pointer to a descriptor chain structure to initialize. |
| start_offset_bytes | Byte offset from the descriptor SRAM base address where this chain begins. Must be within the descriptor SRAM window and aligned to a 4-byte boundary. |
| block_size_bytes | Size of the descriptor memory block allocated for this chain, in bytes. |
| spwm_dsc_status_en spwm_dsc_chain_add_cfg | ( | spwm_dsc_chain_t * | chain, |
| uint8_t | group_id, | ||
| spwm_dsc_reg_id_en | reg_id, | ||
| const uint32_t * | values, | ||
| uint32_t | num_values, | ||
| bool | last ) |
Appends a CFG descriptor to a descriptor chain.
A CFG descriptor performs a burst write of multiple 32-bit values to consecutive SPWM group registers starting at the specified register address. This enables efficient batch configuration of SPWM parameters.
| chain | [in,out] Pointer to an initialized descriptor chain. |
| group_id | SPWM group index whose registers will be written. |
| reg_id | Starting register identifier for the burst write (see spwm_dsc_reg_id_en). |
| values | Pointer to an array of 32-bit values to be written. The first value is written to the starting register, and subsequent values to consecutive registers. |
| num_values | Number of 32-bit values in the array. Must be greater than zero and within the maximum supported by a single CFG descriptor. |
| last | If true, marks this as the last descriptor in the chain (LC bit set), stopping execution. If false, execution continues with the next descriptor. |
| spwm_dsc_status_en spwm_dsc_chain_add_syn | ( | spwm_dsc_chain_t * | chain, |
| spwm_dsc_syn_op_en | opcode, | ||
| uint8_t | group, | ||
| uint32_t | counter_mask, | ||
| bool | last ) |
Appends a SYN descriptor to a descriptor chain.
A SYN descriptor synchronizes descriptor execution with SPWM counter semaphores. It can wait for semaphores to be set, set semaphores, or clear semaphores, enabling coordination between descriptor chains and hardware events.
| chain | [in,out] Pointer to an initialized descriptor chain. |
| opcode | Synchronization operation to perform (see spwm_dsc_syn_op_en):
|
| group | Semaphore group index (typically 0 or 1) selecting which semaphore per counter is targeted. |
| counter_mask | Bitmask selecting which counters participate in the operation. Bit n corresponds to counter index n within the chosen group. Must be non-zero. |
| last | If true, marks this as the last descriptor in the chain (LC bit set), stopping execution. If false, execution continues with the next descriptor. |
| spwm_dsc_status_en spwm_dsc_chain_add_nxt | ( | spwm_dsc_chain_t * | chain, |
| uint32_t | target_offset_bytes ) |
Appends a NXT descriptor to a descriptor chain.
A NXT descriptor performs an unconditional jump to another descriptor offset in descriptor SRAM, enabling loops and multi-stage execution flows within a chain.
| chain | Pointer to an initialized descriptor chain. |
| target_offset_bytes | Target descriptor offset in bytes from the descriptor SRAM base address. Must be 4-byte aligned and within the descriptor SRAM range. |
| spwm_dsc_status_en spwm_dsc_chain_start | ( | spwm_instance_en | id, |
| const spwm_dsc_chain_t * | chain, | ||
| uint8_t | desc_id, | ||
| bool | enable_interrupt ) |
Starts execution of a descriptor chain on a descriptor instance.
Programs the descriptor instance with the chain start offset and issues a start command. Optionally enables instance-level interrupts.
| id | SPWM instance identifier. |
| chain | Pointer to the descriptor chain to execute. |
| desc_id | Descriptor instance index on which to run the chain. |
| enable_interrupt | Enables or disables descriptor instance interrupts. |
| spwm_dsc_status_en spwm_dsc_chain_get_status | ( | spwm_instance_en | id, |
| const spwm_dsc_chain_t * | chain, | ||
| uint8_t | instance, | ||
| spwm_dsc_chain_status_t * | status ) |
Retrieves the execution status of a descriptor instance.
Reads hardware execution and interrupt state and reports decoded status information for the specified descriptor instance.
| id | SPWM instance identifier. |
| chain | Pointer to the descriptor chain associated with the instance. |
| instance | Descriptor instance index to query. |
| status | Pointer to a structure receiving the execution status. |