SRA Board Components
ESP-IDF component for SRA Board
Macros | Functions
motor_driver.h File Reference
#include "esp_err.h"
#include "esp_log.h"
#include "mcpwm_interface.h"
Include dependency graph for motor_driver.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MOTOR_A_0   100
 
#define MOTOR_A_1   101
 
#define MOTOR_FORWARD   200
 
#define MOTOR_BACKWARD   201
 
#define MOTOR_STOP   202
 
#define MCPWM_FREQ   20000
 
#define MCPWM_RESOLUTION   10000000
 

Functions

esp_err_t enable_motor_driver (motor_handle_t *motor, int motor_id)
 Enable motor driver. More...
 
esp_err_t set_motor_speed (motor_handle_t motor, int direction, float duty_cycle)
 
int get_motor_driver_status ()
 Checks if the motor driver is engaged. More...
 

Macro Definition Documentation

◆ MCPWM_FREQ

#define MCPWM_FREQ   20000

◆ MCPWM_RESOLUTION

#define MCPWM_RESOLUTION   10000000

◆ MOTOR_A_0

#define MOTOR_A_0   100

◆ MOTOR_A_1

#define MOTOR_A_1   101

◆ MOTOR_BACKWARD

#define MOTOR_BACKWARD   201

◆ MOTOR_FORWARD

#define MOTOR_FORWARD   200

◆ MOTOR_STOP

#define MOTOR_STOP   202

Function Documentation

◆ enable_motor_driver()

esp_err_t enable_motor_driver ( motor_handle_t motor,
int  motor_id 
)

Enable motor driver.

Parameters
motor_handle_tMotor object handle
motor_idset it as MOTOR_A_0, MOTOR_A_1 to select the appropriate motor to bind to the handle.
Returns
  • ESP_OK: Success
  • ESP_ERR_INVALID_ARG: Invalid argument
  • ESP_FAIL: Failed

◆ get_motor_driver_status()

int get_motor_driver_status ( )

Checks if the motor driver is engaged.

Returns
true if the motor driver is engaged, false otherwise.

◆ set_motor_speed()

esp_err_t set_motor_speed ( motor_handle_t  motor,
int  direction,
float  duty_cycle 
)