Go to the documentation of this file.
40 #define TMC7300_BRIDGE_NUM 2
41 #define TMC7300_DUTY_MAX_VALUE 511
42 #define TMC7300_SENDDELAY_MAX_VALUE 15
44 #define TMC7300_GCONF_REG 0x00
45 #define TMC7300_IFCNT_REG 0x02
46 #define TMC7300_SLAVECONF_REG 0x03
47 #define TMC7300_IOIN_REG 0x03
48 #define TMC7300_CURRENT_LIMIT_REG 0x10
49 #define TMC7300_PWM_AB_REG 0x22
50 #define TMC7300_CHOPCONF_REG 0x6C
51 #define TMC7300_DRV_STATUS_REG 0x6F
52 #define TMC7300_PWMCONF_REG 0x70
54 #define TMC7300_PAR_MODE_MASK NO_OS_BIT(2)
55 #define TMC7300_PWM_DIRECT_MASK NO_OS_BIT(0)
56 #define TMC7300_DRV_ENABLE_MASK NO_OS_BIT(0)
57 #define TMC7300_SLAVECONF_MASK NO_OS_GENMASK(11, 8)
58 #define TMC7300_IRUN_MASK NO_OS_GENMASK(12, 8)
59 #define TMC7300_PWM_B_MASK NO_OS_GENMASK(24, 16)
60 #define TMC7300_PWM_FREQ_MASK NO_OS_GENMASK(17, 16)
61 #define TMC7300_FREEWHEEL_MASK NO_OS_GENMASK(21, 20)
62 #define TMC7300_BLANK_TIME_MASK NO_OS_GENMASK(16, 15)
64 #define TMC7300_LI_MASK(bridge) (bridge == 0) ? NO_OS_BIT(6) : \
67 #define TMC7300_PWM_MASK(bridge) (bridge == 0) ? NO_OS_GENMASK(8, 0) : \
struct tmc7300_bridge_priv bridge_priv[TMC7300_BRIDGE_NUM]
Definition: tmc7300.h:168
uint32_t addr
Definition: tmc7300.h:177
int tmc7300_get_blank_time(struct tmc7300_desc *, enum tmc7300_blank_time *)
Get the comparator blank time register.
Definition: tmc7300.c:443
int tmc7300_remove(struct tmc7300_desc *desc)
Free the resources allocated by tmc7300_init().
Definition: tmc7300.c:551
int tmc7300_reg_write(struct tmc7300_desc *desc, uint32_t addr, uint32_t val)
Write a register.
Definition: tmc7300.c:77
uint8_t ad1
Definition: tmc7300.h:123
int tmc7300_reg_read(struct tmc7300_desc *, uint32_t, uint32_t *)
Read a register.
Definition: tmc7300.c:113
#define TMC7300_SLAVECONF_REG
Definition: tmc7300.h:46
uint8_t irun
Definition: tmc7300.h:166
#define TMC7300_BRIDGE_NUM
Definition: tmc7300.h:40
int32_t no_os_uart_write(struct no_os_uart_desc *desc, const uint8_t *data, uint32_t bytes_number)
Write to UART.
Definition: no_os_uart.c:144
int tmc7300_get_load_indicator(struct tmc7300_desc *desc, enum tmc7300_bridge bridge, uint32_t *val)
Get the load indicator.
Definition: tmc7300.c:189
@ TMC7300_BRIDGE_B
Definition: tmc7300.h:72
#define TMC7300_PAR_MODE_MASK
Definition: tmc7300.h:54
int tmc7300_set_pwm_duty(struct tmc7300_desc *desc, enum tmc7300_bridge bridge, int32_t duty)
Set the PWM duty cycle.
Definition: tmc7300.c:232
uint8_t comp_b1b2
Definition: tmc7300.h:131
int tmc7300_get_blank_time(struct tmc7300_desc *desc, enum tmc7300_blank_time *time)
Get the comparator blank time register.
Definition: tmc7300.c:443
int tmc7300_set_send_delay(struct tmc7300_desc *desc, uint8_t delay)
Set the UART response delay.
Definition: tmc7300.c:288
uint8_t s2gb
Definition: tmc7300.h:104
#define TMC7300_IFCNT_REG
Definition: tmc7300.h:45
bool motor_drive
Definition: tmc7300.h:164
Definition: tmc7300.h:119
@ TMC7300_BLANK_TIME_24
Definition: tmc7300.h:90
int32_t no_os_uart_read(struct no_os_uart_desc *desc, uint8_t *data, uint32_t bytes_number)
Read data from UART.
Definition: no_os_uart.c:118
@ TMC7300_BRIDGE_A
Definition: tmc7300.h:71
#define TMC7300_PWM_DIRECT_MASK
Definition: tmc7300.h:55
Header file for the TMC7300 driver.
#define TMC7300_SLAVECONF_MASK
Definition: tmc7300.h:57
uint16_t reserved
Definition: tmc7300.h:132
#define TMC7300_DRV_ENABLE_MASK
Definition: tmc7300.h:56
int tmc7300_get_ifcnt(struct tmc7300_desc *, uint8_t *)
Get the number of UART valid write accesses. Wraps around at 255.
Definition: tmc7300.c:303
struct no_os_gpio_desc * en_gpio
Definition: tmc7300.h:181
uint8_t mode_input
Definition: tmc7300.h:127
void * no_os_calloc(size_t nitems, size_t size)
Allocate memory and return a pointer to it, set memory to 0.
Definition: chibios_alloc.c:54
int tmc7300_reg_update(struct tmc7300_desc *desc, uint32_t addr, uint32_t mask, uint32_t val)
Update a register.
Definition: tmc7300.c:162
#define TMC7300_DUTY_MAX_VALUE
Definition: tmc7300.h:41
uint32_t reserved
Definition: tmc7300.h:111
uint32_t addr
Definition: tmc7300.h:152
struct no_os_gpio_desc * vio_gpio
Definition: tmc7300.h:158
int tmc7300_get_drv_status(struct tmc7300_desc *desc, union tmc7300_drv_status *status)
Read the driver status register.
Definition: tmc7300.c:323
@ TMC7300_DIR_CW
Definition: tmc7300.h:96
@ TMC7300_BLANK_TIME_32
Definition: tmc7300.h:91
uint8_t otpw
Definition: tmc7300.h:101
@ TMC7300_DIR_CCW
Definition: tmc7300.h:97
uint32_t no_os_field_prep(uint32_t mask, uint32_t val)
uint8_t ot
Definition: tmc7300.h:102
uint8_t uart_input
Definition: tmc7300.h:126
uint32_t val
Definition: tmc7300.h:116
int tmc7300_reg_read(struct tmc7300_desc *desc, uint32_t addr, uint32_t *val)
Read a register.
Definition: tmc7300.c:113
Stucture holding the UART descriptor.
Definition: no_os_uart.h:134
uint32_t val
Definition: tmc7300.h:138
int tmc7300_set_pwm_duty(struct tmc7300_desc *, enum tmc7300_bridge, int32_t)
Set the PWM duty cycle.
Definition: tmc7300.c:232
Definition: tmc7300.h:150
uint8_t lia
Definition: tmc7300.h:107
struct no_os_gpio_desc * en_gpio
Definition: tmc7300.h:156
#define TMC7300_PWMCONF_REG
Definition: tmc7300.h:52
void no_os_put_unaligned_be32(uint32_t val, uint8_t *buf)
int tmc7300_reg_update(struct tmc7300_desc *, uint32_t, uint32_t, uint32_t)
Update a register.
Definition: tmc7300.c:162
int tmc7300_set_blank_time(struct tmc7300_desc *, enum tmc7300_blank_time)
Set the comparator blank time register.
Definition: tmc7300.c:426
int tmc7300_set_send_delay(struct tmc7300_desc *, uint8_t)
Set the UART response delay.
Definition: tmc7300.c:288
#define TMC7300_GCONF_REG
Definition: tmc7300.h:44
@ TMC7300_BLANK_TIME_40
Definition: tmc7300.h:92
@ TMC7300_BREAK_LS
Definition: tmc7300.h:77
int tmc7300_get_ifcnt(struct tmc7300_desc *desc, uint8_t *ifcnt)
Get the number of UART valid write accesses. Wraps around at 255.
Definition: tmc7300.c:303
uint8_t s2vsb
Definition: tmc7300.h:106
uint8_t pwm_duty
Definition: tmc7300.h:142
uint8_t a2
Definition: tmc7300.h:128
@ TMC7300_BREAK_HS
Definition: tmc7300.h:78
int tmc7300_drv_enable(struct tmc7300_desc *desc, bool enable)
Enable the bridge driver.
Definition: tmc7300.c:210
tmc7300_blank_time
Definition: tmc7300.h:88
int tmc7300_set_current_limit(struct tmc7300_desc *, uint32_t)
Set the current limit.
Definition: tmc7300.c:261
#define TMC7300_CHOPCONF_REG
Definition: tmc7300.h:50
int32_t no_os_gpio_remove(struct no_os_gpio_desc *desc)
Free the resources allocated by no_os_gpio_get().
Definition: no_os_gpio.c:104
#define TMC7300_SENDDELAY_MAX_VALUE
Definition: tmc7300.h:42
uint8_t nstdby
Definition: tmc7300.h:121
int tmc7300_set_pwm_duty_dir(struct tmc7300_desc *desc, enum tmc7300_bridge bridge, uint8_t duty, enum tmc7300_motor_dir dir)
Set the PWM duty cycle and direction.
Definition: tmc7300.c:466
int tmc7300_set_pwm_freq(struct tmc7300_desc *desc, enum tmc7300_pwm_freq freq)
Set the frequency of the PWM signal.
Definition: tmc7300.c:390
enum tmc7300_motor_dir motor_dir
Definition: tmc7300.h:143
uint8_t comp_a1a2
Definition: tmc7300.h:130
tmc7300_standstill_mode
Definition: tmc7300.h:75
Structure holding the GPIO descriptor.
Definition: no_os_gpio.h:96
int tmc7300_get_ioin(struct tmc7300_desc *desc, union tmc7300_ioin *ioin)
Read the IOIN register.
Definition: tmc7300.c:344
tmc7300_pwm_freq
Definition: tmc7300.h:81
#define TMC7300_IOIN_REG
Definition: tmc7300.h:47
#define TMC7300_PWM_MASK(bridge)
Definition: tmc7300.h:67
Definition: tmc7300.h:141
struct _tmc7300_drv_status bits
Definition: tmc7300.h:115
#define TMC7300_CURRENT_LIMIT_REG
Definition: tmc7300.h:48
Definition: tmc7300.h:114
uint8_t t120
Definition: tmc7300.h:109
int tmc7300_set_current_limit(struct tmc7300_desc *desc, uint32_t val)
Set the current limit.
Definition: tmc7300.c:261
int tmc7300_init(struct tmc7300_desc **desc, struct tmc7300_init_param *param)
Initialize the TMC7300 driver.
Definition: tmc7300.c:495
int tmc7300_drv_enable(struct tmc7300_desc *, bool)
Enable the bridge driver.
Definition: tmc7300.c:210
@ TMC7300_PWM_FREQ_2_410
Definition: tmc7300.h:85
uint8_t a1
Definition: tmc7300.h:129
@ TMC7300_FREEWHEELING
Definition: tmc7300.h:76
#define TMC7300_PWM_FREQ_MASK
Definition: tmc7300.h:60
uint32_t no_os_field_get(uint32_t mask, uint32_t word)
int tmc7300_get_load_indicator(struct tmc7300_desc *, enum tmc7300_bridge, uint32_t *)
Get the load indicator.
Definition: tmc7300.c:189
@ TMC7300_PWM_FREQ_2_512
Definition: tmc7300.h:84
uint8_t en
Definition: tmc7300.h:120
#define NO_OS_BIT(x)
Definition: no_os_util.h:45
#define TMC7300_LI_MASK(bridge)
Definition: tmc7300.h:64
int tmc7300_init(struct tmc7300_desc **, struct tmc7300_init_param *)
Initialize the TMC7300 driver.
Definition: tmc7300.c:495
void no_os_free(void *ptr)
Deallocate memory previously allocated by a call to no_os_calloc or no_os_malloc.
Definition: chibios_alloc.c:69
int tmc7300_get_drv_status(struct tmc7300_desc *, union tmc7300_drv_status *)
Read the driver status register.
Definition: tmc7300.c:323
uint8_t lib
Definition: tmc7300.h:108
Definition: tmc7300.h:100
int32_t no_os_gpio_set_value(struct no_os_gpio_desc *desc, uint8_t value)
Set the value of the specified GPIO.
Definition: no_os_gpio.c:197
uint32_t no_os_get_unaligned_be32(uint8_t *buf)
#define TMC7300_BLANK_TIME_MASK
Definition: tmc7300.h:62
int tmc7300_set_pwm_freq(struct tmc7300_desc *, enum tmc7300_pwm_freq)
Set the frequency of the PWM signal.
Definition: tmc7300.c:390
struct no_os_uart_desc * comm_desc
Definition: tmc7300.h:154
struct no_os_uart_desc * comm_desc
Definition: tmc7300.h:179
#define TMC7300_PWM_AB_REG
Definition: tmc7300.h:49
Header file of GPIO Interface.
@ TMC7300_PWM_FREQ_2_683
Definition: tmc7300.h:83
int tmc7300_set_standstill_mode(struct tmc7300_desc *desc, enum tmc7300_standstill_mode mode)
Set the standstill mode. The motorrun bit will be set to 0.
Definition: tmc7300.c:364
int tmc7300_get_ioin(struct tmc7300_desc *, union tmc7300_ioin *)
Read the IOIN register.
Definition: tmc7300.c:344
TMC7300 initialization structure.
Definition: tmc7300.h:175
tmc7300_motor_dir
Definition: tmc7300.h:95
Header file of UART interface.
@ TMC7300_BLANK_TIME_16
Definition: tmc7300.h:89
uint8_t t150
Definition: tmc7300.h:110
Definition: tmc7300.h:136
Header file of utility functions.
int tmc7300_set_standstill_mode(struct tmc7300_desc *, enum tmc7300_standstill_mode)
Set the standstill mode. The motorrun bit will be set to 0.
Definition: tmc7300.c:364
uint8_t ad0
Definition: tmc7300.h:122
#define TMC7300_FREEWHEEL_MASK
Definition: tmc7300.h:61
uint8_t diag
Definition: tmc7300.h:124
uint8_t s2vsa
Definition: tmc7300.h:105
bool parallel_mode
Definition: tmc7300.h:185
enum no_os_spi_mode mode
Definition: no_os_spi.h:202
#define TMC7300_DRV_STATUS_REG
Definition: tmc7300.h:51
int tmc7300_get_pwm_freq(struct tmc7300_desc *desc, enum tmc7300_pwm_freq *freq)
Get the frequency of the PWM signal.
Definition: tmc7300.c:406
uint8_t version
Definition: tmc7300.h:133
uint8_t s2ga
Definition: tmc7300.h:103
int tmc7300_set_pwm_duty_dir(struct tmc7300_desc *, enum tmc7300_bridge, uint8_t, enum tmc7300_motor_dir)
Set the PWM duty cycle and direction.
Definition: tmc7300.c:466
int tmc7300_remove(struct tmc7300_desc *)
Free the resources allocated by tmc7300_init().
Definition: tmc7300.c:551
struct no_os_gpio_desc * vio_gpio
Definition: tmc7300.h:183
int tmc7300_reg_write(struct tmc7300_desc *, uint32_t, uint32_t)
Write a register.
Definition: tmc7300.c:77
tmc7300_bridge
Definition: tmc7300.h:70
#define TMC7300_IRUN_MASK
Definition: tmc7300.h:58
@ TMC7300_PWM_FREQ_2_1024
Definition: tmc7300.h:82
int tmc7300_set_blank_time(struct tmc7300_desc *desc, enum tmc7300_blank_time time)
Set the comparator blank time register.
Definition: tmc7300.c:426
uint8_t uart_on
Definition: tmc7300.h:125
struct _tmc7300_ioin bits
Definition: tmc7300.h:137
int tmc7300_get_pwm_freq(struct tmc7300_desc *, enum tmc7300_pwm_freq *)
Get the frequency of the PWM signal.
Definition: tmc7300.c:406