Skip to content
98 changes: 98 additions & 0 deletions App/Inc/l298n_stepper_system.h
Comment thread
dzhang39 marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#ifndef L298N_STEPPER_SYSTEM_H
#define L298N_STEPPER_SYSTEM_H

#ifdef __cplusplus
extern "C" {
#endif

#include <stdbool.h>
#include <stdint.h>
#include "stm32l4xx.h"




typedef volatile uint32_t* TIMER_CHANNEL;
typedef uint16_t GPIO_PIN;

typedef struct{
Comment thread
dzhang39 marked this conversation as resolved.

GPIO_TypeDef* ena_port;
GPIO_PIN ena_pin;

GPIO_TypeDef* enb_port;
GPIO_PIN enb_pin;

GPIO_TypeDef* in1_port;
GPIO_PIN in1_pin;

GPIO_TypeDef* in2_port;
GPIO_PIN in2_pin;

GPIO_TypeDef* in3_port;
GPIO_PIN in3_pin;

GPIO_TypeDef* in4_port;
GPIO_PIN in4_pin;



uint16_t steps_per_rev;

uint32_t tick_accumulator;
uint32_t ticks_per_step;
uint16_t current_speed;
uint16_t max_speed;

uint8_t current_step;
uint8_t dir;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is dir?


uint32_t max_time_ms; //max time (currently not implemented)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ignore this then

uint32_t current_time_running_ms;//how long its been running (not implemented)

uint8_t status;

}l298n_stepper_driver_t;



/*
*
*
* PUT CONFIG HERE
*
*
*/

#define NUM_STEPPERS 0//replace w number of steppers

//EXAMPLE

extern l298n_stepper_driver_t drivers[NUM_STEPPERS]; // needs to be defined in the .c
Comment thread
dzhang39 marked this conversation as resolved.
extern TIM_TypeDef* global_interrupt_clock;
extern uint32_t l298n_stepper_timer_period_us; //assumes clock speed is 8mhz

#define STEPPER_0_VEL_PARAM_NAME ""

extern char* vel_param_names[NUM_STEPPERS];



#define STEPPER_0_STATUS_PARAM_NAME_C ""

extern char* status_param_names_C[NUM_STEPPERS];



#define STEPPER_0_STATUS_PARAM_NAME_R ""

extern char* status_param_names_R[NUM_STEPPERS];


void l298n_stepper_system_controller(void);

#ifdef __cplusplus
}
#endif

#endif /* COPY_RENAME_ME_SYSTEM_H */
4 changes: 4 additions & 0 deletions App/Inc/project_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ extern "C" {
#define PROJECT_CAN_ID_SCIENCE_DC_MOTOR_R 0x071U
#define PROJECT_CAN_ID_SCIENCE_SERVO_PCB_C 0x080U
#define PROJECT_CAN_ID_SCIENCE_SERVO_PCB_R 0x081U
#define PROJECT_CAN_ID_SCIENCE_STEPPER_PCB_C 0x090U
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Internal_Thoughts: From an outside perspective, this is where you would type the 3 bit ID into Cangaroo?

#define PROJECT_CAN_ID_SCIENCE_STEPPER_PCB_R 0x091U



/* =========================
* Servo application sizing
Expand Down
2 changes: 2 additions & 0 deletions App/Src/can_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ const uint32_t g_can_rx_id_filter[] =
PROJECT_CAN_ID_SCIENCE_DC_MOTOR_R,
PROJECT_CAN_ID_SCIENCE_SERVO_PCB_C,
PROJECT_CAN_ID_SCIENCE_SERVO_PCB_R,
PROJECT_CAN_ID_SCIENCE_STEPPER_PCB_C,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Including Science Stepper Now

PROJECT_CAN_ID_SCIENCE_STEPPER_PCB_R,
};
#else
const uint32_t g_can_rx_id_filter[] =
Expand Down
Loading
Loading