RX Flexible Software Package Documentation  Release v1.0.0

 
PCIF Interface

Detailed Description

Interface for PCIF functions.

Summary

Phase Counting Interface(PCIF) interface provides APIs and definitions for motor communication.

Data Structures

struct  pcif_callback_args_t
 
struct  pcif_phc_counter_info_t
 
struct  pcif_status_t
 
struct  pcif_cfg_t
 
struct  pcif_api_t
 
struct  pcif_instance_t
 

Typedefs

typedef void pcif_ctrl_t
 

Enumerations

enum  pcif_error_t
 
enum  pcif_state_t
 
enum  pcif_mode_t
 
enum  pcif_clock_source_t
 
enum  pcif_clock_div_t
 
enum  pcif_phase_polarity_t
 
enum  pcif_stop_mode_t
 
enum  pcif_rotation_direction_t
 

Data Structure Documentation

◆ pcif_callback_args_t

struct pcif_callback_args_t

Callback parameter data

Data Fields
void const * p_context

Placeholder for user data. Set in pcif_api_t::open function in pcif_cfg_t.

pcif_error_t error

◆ pcif_phc_counter_info_t

struct pcif_phc_counter_info_t

Phase Counting counter data configuration structure

Data Fields
uint16_t new_position New position of counter to be set.
int16_t edge_count Number of edge count.

◆ pcif_status_t

struct pcif_status_t

Current PCIF status.

Data Fields
pcif_state_t state Current PCIF state (stopped or running)
pcif_rotation_direction_t rotation_direction Rotation direction (clockwise or counter-clockwise)
uint16_t current_position_value Current output counter value (PHCPOSCNTM or INCOCNTM)
uint16_t position_write_value Latest PHCPCWDR write value (0 in incremental mode)
uint8_t input_counter_value Incremental input counter value (INCICNTM, 0 in phase-counting mode)

◆ pcif_cfg_t

struct pcif_cfg_t

User configuration structure, used in open function

Data Fields

pcif_mode_t mode
 Select enumerated value from pcif_mode_t.
 
uint8_t channel
 
pcif_clock_source_t clock_src
 Source clock selection.
 
pcif_clock_div_t clock_div
 Source clock divider.
 
pcif_phase_polarity_t a_phase_polarity
 A phase polarity output. More...
 
pcif_phase_polarity_t b_phase_polarity
 B phase polarity output.
 
pcif_phase_polarity_t z_phase_polarity
 Z phase polarity output.
 
uint16_t max_count_position
 Maximum position value.
 
timer_instance_t const * p_lower_lvl_timer
 Pointer to the timer instance structs.
 
void(* p_callback )(pcif_callback_args_t *p_args)
 
void * p_context
 
void const * p_extend
 Extension parameter for hardware specific settings.
 

Field Documentation

◆ channel

uint8_t pcif_cfg_t::channel

Select a channel corresponding to the channel number of the hardware.

◆ a_phase_polarity

pcif_phase_polarity_t pcif_cfg_t::a_phase_polarity

A phase polarity output.

Common setting

◆ p_callback

void(* pcif_cfg_t::p_callback) (pcif_callback_args_t *p_args)

Callback provided when an PCIF carrier period occurs. Set to NULL if not use.

◆ p_context

void* pcif_cfg_t::p_context

Placeholder for user data. Passed to the user callback in pcif_callback_args_t.

◆ pcif_api_t

struct pcif_api_t

PCIF_API functions implemented at the HAL layer will follow this API.

Data Fields

fsp_err_t(* open )(pcif_ctrl_t *const p_ctrl, pcif_cfg_t const *const p_cfg)
 
fsp_err_t(* start )(pcif_ctrl_t *const p_ctrl)
 
fsp_err_t(* stop )(pcif_ctrl_t *const p_ctrl, pcif_stop_mode_t stop_mode)
 
fsp_err_t(* setCounter )(pcif_ctrl_t *const p_ctrl, pcif_phc_counter_info_t const *const p_counter_info, bool pos_reset)
 
fsp_err_t(* statusGet )(pcif_ctrl_t *const p_ctrl, pcif_status_t *const p_status)
 
fsp_err_t(* softwareEventGenerate )(pcif_ctrl_t *const p_ctrl)
 
fsp_err_t(* close )(pcif_ctrl_t *const p_ctrl)
 

Field Documentation

◆ open

fsp_err_t(* pcif_api_t::open) (pcif_ctrl_t *const p_ctrl, pcif_cfg_t const *const p_cfg)

Initial configuration.

Implemented as
Precondition
Peripheral clocks and any required output pins should be configured prior to calling this function.
Note
To reconfigure after calling this function, call pcif_api_t::close first.
Parameters
[in]p_ctrlPointer to control structure. Must be declared by user. Elements set here.
[in]p_cfgPointer to pin configuration structure. All elements of this structure must be set by user.

◆ start

fsp_err_t(* pcif_api_t::start) (pcif_ctrl_t *const p_ctrl)

Start the output waveform.

Implemented as
Parameters
[in]p_ctrlControl block set in pcif_api_t::open call for this module.

◆ stop

fsp_err_t(* pcif_api_t::stop) (pcif_ctrl_t *const p_ctrl, pcif_stop_mode_t stop_mode)

Stop the output waveform.

Implemented as
Parameters
[in]p_ctrlControl block set in pcif_api_t::open call for this module.
[in]stop_modeStop mode

◆ setCounter

fsp_err_t(* pcif_api_t::setCounter) (pcif_ctrl_t *const p_ctrl, pcif_phc_counter_info_t const *const p_counter_info, bool pos_reset)

Set the counter and the initial value.

Implemented as
Note
This function is only available in phase counting mode.
Parameters
[in]p_ctrlControl block set in pcif_api_t::open call for this module.
[in]p_counter_infoPointer to counter info structure. All elements of this structure must be set by user.
[in]pos_resetReset counter position.

◆ statusGet

fsp_err_t(* pcif_api_t::statusGet) (pcif_ctrl_t *const p_ctrl, pcif_status_t *const p_status)

Stores current status in p_status.

Implemented as
Parameters
[in]p_ctrlControl block set in pcif_api_t::open call for this module.
[out]p_statusCurrent status for this module.

◆ softwareEventGenerate

fsp_err_t(* pcif_api_t::softwareEventGenerate) (pcif_ctrl_t *const p_ctrl)

Generates a software event to trigger the PCIF.

Implemented as
Note
This function is only available in incremental mode.
This function is used to generate a Z phase signal.
Parameters
[in]p_ctrlControl block set in pcif_api_t::open call for this module.

◆ close

fsp_err_t(* pcif_api_t::close) (pcif_ctrl_t *const p_ctrl)

Closes the driver and allows reconfiguration. May reduce power consumption.

Implemented as
Parameters
[in]p_ctrlControl block set in pcif_api_t::open call for this module.

◆ pcif_instance_t

struct pcif_instance_t

This structure encompasses everything that is needed to use an instance of this interface.

Data Fields
pcif_ctrl_t * p_ctrl Pointer to the control structure for this instance.
pcif_cfg_t const * p_cfg Pointer to the configuration structure for this instance.
pcif_api_t const * p_api Pointer to the API structure for this instance.

Typedef Documentation

◆ pcif_ctrl_t

typedef void pcif_ctrl_t

PCIF_API control block. Allocate an instance specific control block to pass into the PCIF_API API calls.

Enumeration Type Documentation

◆ pcif_error_t

PCIF Error Event

Enumerator
PCIF_ERROR_NONE 

No error.

PCIF_ERROR_CARRIER_PERIOD 

Carrier Period Event error.

PCIF_ERROR_INTERNAL_EDGE_COUNTING 

Internal Edge Count error.

PCIF_ERROR_EDGE_COUNTING_OVERFLOW 

Internal Edge Count Overflow error.

PCIF_ERROR_OLD_EDGE_COUNTING 

Old Edge Count Usage error.

◆ pcif_state_t

PCIF Status

Enumerator
PCIF_STATE_STOPPED 

PCIF is idle.

PCIF_STATE_RUNNING 

PCIF is busy.

◆ pcif_mode_t

PCIF Mode

Enumerator
PCIF_MODE_PHASE_COUNTING 

Phase counting mode.

PCIF_MODE_INCREMENTAL 

Incremental mode.

◆ pcif_clock_source_t

Selection of source clock

Enumerator
PCIF_CLOCK_SOURCE_ASYN_CLK 

Select asynchronous clock source (GPTCLK)

PCIF_CLOCK_SOURCE_SYN_CLK 

Select synchronous clock source (PCLK)

◆ pcif_clock_div_t

Division clock ratio for source clock

Enumerator
PCIF_CLOCK_DIV_1 

Clock source divided by 1.

PCIF_CLOCK_DIV_2 

Clock source divided by 2 with duty ratio 1:1.

PCIF_CLOCK_DIV_3 

Clock source divided by 3 with duty ratio 2:1.

PCIF_CLOCK_DIV_4 

Clock source divided by 4 with duty ratio 2:2.

PCIF_CLOCK_DIV_5 

Clock source divided by 5 with duty ratio 3:2.

PCIF_CLOCK_DIV_6 

Clock source divided by 6 with duty ratio 3:3.

PCIF_CLOCK_DIV_7 

Clock source divided by 7 with duty ratio 4:3.

PCIF_CLOCK_DIV_8 

Clock source divided by 8 with duty ratio 4:4.

PCIF_CLOCK_DIV_9 

Clock source divided by 9 with duty ratio 5:4.

PCIF_CLOCK_DIV_10 

Clock source divided by 10 with duty ratio 5:5.

PCIF_CLOCK_DIV_11 

Clock source divided by 11 with duty ratio 6:5.

PCIF_CLOCK_DIV_12 

Clock source divided by 12 with duty ratio 6:6.

PCIF_CLOCK_DIV_13 

Clock source divided by 13 with duty ratio 7:6.

PCIF_CLOCK_DIV_14 

Clock source divided by 14 with duty ratio 7:7.

PCIF_CLOCK_DIV_15 

Clock source divided by 15 with duty ratio 8:7.

PCIF_CLOCK_DIV_16 

Clock source divided by 16 with duty ratio 8:8.

PCIF_CLOCK_DIV_17 

Clock source divided by 17 with duty ratio 9:8.

PCIF_CLOCK_DIV_18 

Clock source divided by 18 with duty ratio 9:9.

PCIF_CLOCK_DIV_19 

Clock source divided by 19 with duty ratio 10:9.

PCIF_CLOCK_DIV_20 

Clock source divided by 20 with duty ratio 10:10.

PCIF_CLOCK_DIV_21 

Clock source divided by 21 with duty ratio 11:10.

PCIF_CLOCK_DIV_22 

Clock source divided by 22 with duty ratio 11:11.

PCIF_CLOCK_DIV_23 

Clock source divided by 23 with duty ratio 12:11.

PCIF_CLOCK_DIV_24 

Clock source divided by 24 with duty ratio 12:12.

PCIF_CLOCK_DIV_25 

Clock source divided by 25 with duty ratio 13:12.

PCIF_CLOCK_DIV_26 

Clock source divided by 26 with duty ratio 13:13.

PCIF_CLOCK_DIV_27 

Clock source divided by 27 with duty ratio 14:13.

PCIF_CLOCK_DIV_28 

Clock source divided by 28 with duty ratio 14:14.

PCIF_CLOCK_DIV_29 

Clock source divided by 29 with duty ratio 15:14.

PCIF_CLOCK_DIV_30 

Clock source divided by 30 with duty ratio 15:15.

PCIF_CLOCK_DIV_31 

Clock source divided by 31 with duty ratio 16:15.

PCIF_CLOCK_DIV_32 

Clock source divided by 32 with duty ratio 16:16.

◆ pcif_phase_polarity_t

Output phase polarity selection

Enumerator
PCIF_PHASE_POSITIVE 

Positive phase.

PCIF_PHASE_NEGATIVE 

Negative phase.

◆ pcif_stop_mode_t

Stop mode

Enumerator
PCIF_STOP_MODE_IMMEDIATE 

PCIF stops immediately.

PCIF_STOP_MODE_SYNC 

PCIF stops after generating the ABZ phase and synchronizing with the carrier cycle.

◆ pcif_rotation_direction_t

Rotation direction

Enumerator
PCIF_ROTATION_DIRECTION_CW 

Clockwise rotation.

PCIF_ROTATION_DIRECTION_CCW 

Counter-clockwise rotation.