Zephyr Project API 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches

Files

file  tmc6460.h
 Public API for the TMC6460 FOC gate driver.

Data Structures

struct  tmc6460_field
 Describes a bitfield within a TMC6460 register. More...

Functions

int tmc6460_write (const struct device *dev, uint16_t reg_addr, uint32_t reg_val)
 Write a value to a TMC6460 register.
int tmc6460_read (const struct device *dev, uint16_t reg_addr, uint32_t *reg_val)
 Read a value from a TMC6460 register.
int tmc6460_rtmi_stream_write (const struct device *dev, uint8_t rtmi_index, uint32_t value)
 Write a value to an RTMI streamed register slot (UART only).
int tmc6460_enable (const struct device *dev)
 Enable the TMC6460 gate driver.
int tmc6460_disable (const struct device *dev)
 Disable the TMC6460 gate driver.
int tmc6460_poll_flag (const struct device *dev, uint16_t reg_addr, uint32_t flag_mask, uint32_t poll_interval_ms, uint32_t timeout_ms)
 Poll a register until the given flag bits are set or a timeout.
static uint32_t tmc6460_field_update (uint32_t reg_val, struct tmc6460_field field, uint32_t field_val)
 Update a bitfield within a register value (in memory only).
static int tmc6460_field_write (const struct device *dev, struct tmc6460_field field, uint32_t field_val)
 Read-modify-write a bitfield on the device.

Detailed Description

Function Documentation

◆ tmc6460_disable()

int tmc6460_disable ( const struct device * dev)

#include <tmc6460.h>

Disable the TMC6460 gate driver.

Clears the DRV_EN bit in the MCC_CONFIG_GDRV register, disabling the gate driver output stage. This is a read-modify-write operation so other bits in the register are preserved.

Parameters
devPointer to the TMC6460 device.
Return values
0on success.
-EIOon bus failure.

◆ tmc6460_enable()

int tmc6460_enable ( const struct device * dev)

#include <tmc6460.h>

Enable the TMC6460 gate driver.

Sets the DRV_EN bit in the MCC_CONFIG_GDRV register, enabling the gate driver output stage. This is a read-modify-write operation so other bits in the register are preserved.

Parameters
devPointer to the TMC6460 device.
Return values
0on success.
-EIOon bus failure.

◆ tmc6460_field_update()

uint32_t tmc6460_field_update ( uint32_t reg_val,
struct tmc6460_field field,
uint32_t field_val )
inlinestatic

#include <tmc6460.h>

Update a bitfield within a register value (in memory only).

Parameters
reg_valThe current register value.
fieldThe field descriptor.
field_valThe new field value to insert.
Returns
The updated register value.

◆ tmc6460_field_write()

int tmc6460_field_write ( const struct device * dev,
struct tmc6460_field field,
uint32_t field_val )
inlinestatic

#include <tmc6460.h>

Read-modify-write a bitfield on the device.

Parameters
devPointer to the TMC6460 device.
fieldThe field descriptor.
field_valThe new field value to write.
Return values
0on success.
-errnoon failure.

◆ tmc6460_poll_flag()

int tmc6460_poll_flag ( const struct device * dev,
uint16_t reg_addr,
uint32_t flag_mask,
uint32_t poll_interval_ms,
uint32_t timeout_ms )

#include <tmc6460.h>

Poll a register until the given flag bits are set or a timeout.

Repeatedly reads reg_addr and checks whether all bits in flag_mask are set, sleeping poll_interval_ms between reads. This is a reusable helper for the common "wait for a ready/lock status bit" pattern (e.g. PLL lock, ADC ready).

Parameters
devPointer to the TMC6460 device.
reg_addr16-bit status register address to poll.
flag_maskBit mask that must be fully set for success.
poll_interval_msDelay between reads, in milliseconds (0 for a tight loop).
timeout_msMaximum time to wait, in milliseconds.
Return values
0if the flag bits became set.
-ETIMEDOUTif the timeout elapsed first.
-EIOon bus failure.

◆ tmc6460_read()

int tmc6460_read ( const struct device * dev,
uint16_t reg_addr,
uint32_t * reg_val )

#include <tmc6460.h>

Read a value from a TMC6460 register.

Parameters
devPointer to the TMC6460 device.
reg_addr16-bit register address.
reg_valPointer to store the 32-bit read value.
Return values
0on success.
-errnoon bus failure.

◆ tmc6460_rtmi_stream_write()

int tmc6460_rtmi_stream_write ( const struct device * dev,
uint8_t rtmi_index,
uint32_t value )

#include <tmc6460.h>

Write a value to an RTMI streamed register slot (UART only).

Uses the fire-and-forget stream write protocol (sync byte 0x41). This function is only available when CONFIG_TMC6460_UART is enabled.

Parameters
devPointer to the TMC6460 device.
rtmi_indexRTMI slot index (0..7).
value32-bit value to stream.
Return values
0on success.
-errnoon failure.

◆ tmc6460_write()

int tmc6460_write ( const struct device * dev,
uint16_t reg_addr,
uint32_t reg_val )

#include <tmc6460.h>

Write a value to a TMC6460 register.

Parameters
devPointer to the TMC6460 device.
reg_addr16-bit register address.
reg_val32-bit value to write.
Return values
0on success.
-errnoon bus failure.