generated from sirlilpanda/kicad-project-template-actionless
Created wacky_bully project + a bit of work towards implementing motor drivers
This commit is contained in:
3
software/wacky_bully/main/CMakeLists.txt
Normal file
3
software/wacky_bully/main/CMakeLists.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
idf_component_register(SRCS "wacky_bully.c"
|
||||
REQUIRES "drv8701" freertos
|
||||
INCLUDE_DIRS ".")
|
||||
16
software/wacky_bully/main/idf_component.yml
Normal file
16
software/wacky_bully/main/idf_component.yml
Normal file
@@ -0,0 +1,16 @@
|
||||
## IDF Component Manager Manifest File
|
||||
dependencies:
|
||||
## Required IDF version
|
||||
idf:
|
||||
version: ">=4.1.0"
|
||||
# # Put list of dependencies here
|
||||
# # For components maintained by Espressif:
|
||||
# component: "~1.0.0"
|
||||
# # For 3rd party components:
|
||||
# username/component: ">=1.0.0,<2.0.0"
|
||||
# username2/component2:
|
||||
# version: "~1.0.0"
|
||||
# # For transient dependencies `public` flag can be set.
|
||||
# # `public` flag doesn't have an effect dependencies of the `main` component.
|
||||
# # All dependencies of `main` are public by default.
|
||||
# public: true
|
||||
51
software/wacky_bully/main/wacky_bully.c
Normal file
51
software/wacky_bully/main/wacky_bully.c
Normal file
@@ -0,0 +1,51 @@
|
||||
#include <stdio.h>
|
||||
#include "drv8701.h"
|
||||
#include "freertos/idf_additions.h"
|
||||
#include "portmacro.h"
|
||||
#include "soc/gpio_num.h"
|
||||
|
||||
|
||||
drv8701_task_config_t motor1 = {
|
||||
.ph_pin = GPIO_NUM_13,
|
||||
.en_pin = GPIO_NUM_14,
|
||||
.pwm_group_num = 0,
|
||||
};
|
||||
drv8701_task_config_t motor2 = {
|
||||
.ph_pin = GPIO_NUM_21,
|
||||
.en_pin = GPIO_NUM_45,
|
||||
.pwm_group_num = 0,
|
||||
};
|
||||
drv8701_task_config_t motor3 = {
|
||||
.ph_pin = GPIO_NUM_9,
|
||||
.en_pin = GPIO_NUM_10,
|
||||
.pwm_group_num = 1,
|
||||
};
|
||||
drv8701_task_config_t motor4 = {
|
||||
.ph_pin = GPIO_NUM_11,
|
||||
.en_pin = GPIO_NUM_12,
|
||||
.pwm_group_num = 1,
|
||||
};
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
printf("Starting\n");
|
||||
|
||||
xTaskCreate(drv8701_task, "Motor1 Task", 2048, (void *)&motor1, 4, NULL);
|
||||
xTaskCreate(drv8701_task, "Motor2 Task", 2048, (void *)&motor2, 4, NULL);
|
||||
xTaskCreate(drv8701_task, "Motor3 Task", 2048, (void *)&motor3, 4, NULL);
|
||||
xTaskCreate(drv8701_task, "Motor4 Task", 2048, (void *)&motor4, 4, NULL);
|
||||
|
||||
vTaskDelay(500 / portTICK_PERIOD_MS);
|
||||
float motor1_vel = 0.0;
|
||||
while(true) {
|
||||
motor1_vel = motor1_vel + 0.1;
|
||||
if (motor1_vel > 1.0)
|
||||
motor1_vel = -1.0;
|
||||
printf("Motor1 velocity: %0.2f\n", motor1_vel);
|
||||
set_motor_vel(&motor1, motor1_vel);
|
||||
set_motor_vel(&motor2, motor1_vel);
|
||||
set_motor_vel(&motor3, motor1_vel);
|
||||
set_motor_vel(&motor4, motor1_vel);
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user