![]() |
Synergy Software Package User's Manual
|
Driver for the General PWM Timer (GPT). More...
Data Structures | |
| struct | gpt_output_pin_t |
| struct | gpt_instance_ctrl_t |
| struct | timer_on_gpt_cfg_t |
Enumerations | |
| enum | gpt_pin_level_t { GPT_PIN_LEVEL_LOW = 0, GPT_PIN_LEVEL_HIGH = 1, GPT_PIN_LEVEL_RETAINED = 2 } |
| enum | gpt_shortest_level_t { GPT_SHORTEST_LEVEL_OFF = 0, GPT_SHORTEST_LEVEL_ON = 1 } |
| enum | gpt_trigger_t { GPT_TRIGGER_NONE = 0, GPT_TRIGGER_GTIOCA_RISING_WHILE_GTIOCB_LOW = (1UL << 8), GPT_TRIGGER_GTIOCA_RISING_WHILE_GTIOCB_HIGH = (1UL << 9), GPT_TRIGGER_GTIOCA_FALLING_WHILE_GTIOCB_LOW = (1UL << 10), GPT_TRIGGER_GTIOCA_FALLING_WHILE_GTIOCB_HIGH = (1UL << 11), GPT_TRIGGER_GTIOCB_RISING_WHILE_GTIOCA_LOW = (1UL << 12), GPT_TRIGGER_GTIOCB_RISING_WHILE_GTIOCA_HIGH = (1UL << 13), GPT_TRIGGER_GTIOCB_FALLING_WHILE_GTIOCA_LOW = (1UL << 14), GPT_TRIGGER_GTIOCB_FALLING_WHILE_GTIOCA_HIGH = (1UL << 15), GPT_TRIGGER_SOURCE_REGISTER_ENABLE = (1UL << 31) } |
| enum | gpt_output_t { GPT_OUTPUT_RETAINED = 0, GPT_OUTPUT_LOW = 1, GPT_OUTPUT_HIGH = 2, GPT_OUTPUT_TOGGLED = 3 } |
Functions | |
| ssp_err_t | R_GPT_TimerOpen (timer_ctrl_t *const p_api_ctrl, timer_cfg_t const *const p_cfg) |
| Powers on GPT, handles required initialization described in hardware manual. Implements timer_api_t::open. More... | |
| ssp_err_t | R_GPT_Stop (timer_ctrl_t *const p_api_ctrl) |
| Stops timer. Implements timer_api_t::stop. More... | |
| ssp_err_t | R_GPT_Start (timer_ctrl_t *const p_api_ctrl) |
| Starts timer. Implements timer_api_t::start. More... | |
| ssp_err_t | R_GPT_CounterGet (timer_ctrl_t *const p_api_ctrl, timer_size_t *const p_value) |
| Sets counter value in provided p_value pointer. Implements timer_api_t::counterGet. More... | |
| ssp_err_t | R_GPT_Reset (timer_ctrl_t *const p_api_ctrl) |
| Resets the counter value to 0. Implements timer_api_t::reset. More... | |
| ssp_err_t | R_GPT_PeriodSet (timer_ctrl_t *const p_api_ctrl, timer_size_t const period, timer_unit_t const unit) |
| Sets period value provided. Implements timer_api_t::periodSet. More... | |
| ssp_err_t | R_GPT_DutyCycleSet (timer_ctrl_t *const p_api_ctrl, timer_size_t const duty_cycle, timer_pwm_unit_t const unit, uint8_t const pin) |
| Sets status in provided p_status pointer. Implements pwm_api_t::dutyCycleSet. More... | |
| ssp_err_t | R_GPT_InfoGet (timer_ctrl_t *const p_api_ctrl, timer_info_t *const p_info) |
| Get timer information and store it in provided pointer p_info. Implements timer_api_t::infoGet. More... | |
| ssp_err_t | R_GPT_Close (timer_ctrl_t *const p_api_ctrl) |
| Stops counter, disables output pins, and clears internal driver data. More... | |
| ssp_err_t | R_GPT_VersionGet (ssp_version_t *const p_version) |
| Sets driver version based on compile time macros. More... | |
Driver for the General PWM Timer (GPT).
Extends Timer Interface.
This module implements the Timer Interface using the General PWM Timer (GPT) peripherals GPT32EH, GPT32E, GPT32. It also provides an output compare extension to output the timer signal to the GTIOC pin.
| enum gpt_output_t |
| enum gpt_pin_level_t |
| enum gpt_shortest_level_t |
| enum gpt_trigger_t |
Sources can be used to start the timer, stop the timer, count up, or count down.
| ssp_err_t R_GPT_Close | ( | timer_ctrl_t *const | p_api_ctrl | ) |
Stops counter, disables output pins, and clears internal driver data.
| SSP_SUCCESS | Successful close. |
| SSP_ERR_ASSERTION | The parameter p_ctrl is NULL. |
| SSP_ERR_NOT_OPEN | The channel is not opened. |
Cleanup. Stop counter and disable output.
Unlock channel
Clear stored internal driver data
| ssp_err_t R_GPT_CounterGet | ( | timer_ctrl_t *const | p_api_ctrl, |
| timer_size_t *const | p_value | ||
| ) |
Sets counter value in provided p_value pointer. Implements timer_api_t::counterGet.
| SSP_SUCCESS | Counter value read, p_value is valid. |
| SSP_ERR_ASSERTION | The p_ctrl or p_value parameter was null. |
| SSP_ERR_NOT_OPEN | The channel is not opened. |
Read counter value
| ssp_err_t R_GPT_DutyCycleSet | ( | timer_ctrl_t *const | p_api_ctrl, |
| timer_size_t const | duty_cycle, | ||
| timer_pwm_unit_t const | unit, | ||
| uint8_t const | pin | ||
| ) |
Sets status in provided p_status pointer. Implements pwm_api_t::dutyCycleSet.
| SSP_SUCCESS | Counter value written successfully. |
| SSP_ERR_ASSERTION | The p_ctrl parameter was null. |
| SSP_ERR_NOT_OPEN | The channel is not opened. |
| SSP_ERR_INVALID_ARGUMENT | The pin value is out of range; Should be either 0 (for GTIOCA) or 1 (for GTIOCB). |
Converted duty cycle to PCLK counts before it can be set in registers
Set duty cycle.
| ssp_err_t R_GPT_InfoGet | ( | timer_ctrl_t *const | p_api_ctrl, |
| timer_info_t *const | p_info | ||
| ) |
Get timer information and store it in provided pointer p_info. Implements timer_api_t::infoGet.
| SSP_SUCCESS | Period, count direction, frequency, and status value written to caller's structure successfully. |
| SSP_ERR_ASSERTION | The p_ctrl or p_info parameter was null. |
| SSP_ERR_NOT_OPEN | The channel is not opened. |
Get and store period
Get and store clock frequency
Get and store clock counting direction
| ssp_err_t R_GPT_PeriodSet | ( | timer_ctrl_t *const | p_api_ctrl, |
| timer_size_t const | period, | ||
| timer_unit_t const | unit | ||
| ) |
Sets period value provided. Implements timer_api_t::periodSet.
| SSP_SUCCESS | Period value written successfully. |
| SSP_ERR_ASSERTION | The p_ctrl parameter was null. |
| SSP_ERR_INVALID_ARGUMENT | One of the following is invalid:
|
| SSP_ERR_NOT_OPEN | The channel is not opened. |
Delay must be converted to PCLK counts before it can be set in registers
Make sure period is valid.
Store current status, then stop timer before setting divisor register
Reset counter in case new cycle is less than current count value, then restore state (counting or stopped).
| ssp_err_t R_GPT_Reset | ( | timer_ctrl_t *const | p_api_ctrl | ) |
Resets the counter value to 0. Implements timer_api_t::reset.
| SSP_SUCCESS | Counter value written successfully. |
| SSP_ERR_ASSERTION | The p_ctrl parameter was null. |
| SSP_ERR_NOT_OPEN | The channel is not opened. |
Write the counter value
| ssp_err_t R_GPT_Start | ( | timer_ctrl_t *const | p_api_ctrl | ) |
Starts timer. Implements timer_api_t::start.
| SSP_SUCCESS | Timer successfully started. |
| SSP_ERR_ASSERTION | The p_ctrl parameter was null. |
| SSP_ERR_NOT_OPEN | The channel is not opened. |
Start timer
| ssp_err_t R_GPT_Stop | ( | timer_ctrl_t *const | p_api_ctrl | ) |
Stops timer. Implements timer_api_t::stop.
| SSP_SUCCESS | Timer successfully stopped. |
| SSP_ERR_ASSERTION | The p_ctrl parameter was null. |
| SSP_ERR_NOT_OPEN | The channel is not opened. |
Stop timer
| ssp_err_t R_GPT_TimerOpen | ( | timer_ctrl_t *const | p_api_ctrl, |
| timer_cfg_t const *const | p_cfg | ||
| ) |
Powers on GPT, handles required initialization described in hardware manual. Implements timer_api_t::open.
The Open function configures a single GPT channel, starts the channel, and provides a handle for use with the GPT API Control and Close functions. This function must be called once prior to calling any other GPT API functions. After a channel is opened, the Open function should not be called again for the same channel without first calling the associated Close function.
GPT hardware does not support one-shot functionality natively. When using one-shot mode, the timer will be stopped in an ISR after the requested period has elapsed.
The GPT implementation of the general timer can accept a timer_on_gpt_cfg_t extension parameter.
| SSP_SUCCESS | Initialization was successful and timer has started. |
| SSP_ERR_ASSERTION | One of the following parameters is incorrect. Either
|
| SSP_ERR_INVALID_ARGUMENT | One of the following parameters is invalid:
|
| SSP_ERR_IN_USE | The channel specified has already been opened. No configurations were changed. Call the associated Close function or use associated Control commands to reconfigure the channel. |
| SSP_ERR_IRQ_BSP_DISABLED | - p_cfg->mode is TIMER_MODE_ONE_SHOT, but ISR is not enabled. ISR must be enabled to use one-shot mode. |
| SSP_ERR_IP_CHANNEL_NOT_PRESENT | - The channel requested in the p_cfg parameter is not available on this device. |
Calculate period and store internal variables
Save the configuration
Calculate duty cycle
Verify channel is not already used
Power on GPT before setting any hardware registers. Make sure the counter is stopped before setting mode register, PCLK divisor register, and counter register.
| ssp_err_t R_GPT_VersionGet | ( | ssp_version_t *const | p_version | ) |
Sets driver version based on compile time macros.
| SSP_SUCCESS | Successful close. |
| SSP_ERR_ASSERTION | The parameter p_version is NULL. |