81 lines
1.3 KiB
C
81 lines
1.3 KiB
C
#include "M451Series.h"
|
|
#include "global.h"
|
|
|
|
|
|
void PWM0P0_IRQHandler(void)
|
|
{
|
|
static uint32_t lastStep = 0;
|
|
|
|
if(Axis1 != 0){
|
|
PWM_EnableOutput(PWM0, PWM_CH_0_MASK);
|
|
if(Axis1 > 0){
|
|
PB4 = 1;
|
|
}else{
|
|
PB4 = 0;
|
|
}
|
|
}
|
|
else{
|
|
PWM_DisableOutput(PWM0, PWM_CH_0_MASK);
|
|
}
|
|
if(Axis2 != 0){
|
|
PWM_EnableOutput(PWM0, PWM_CH_1_MASK);
|
|
if(Axis2 > 0){
|
|
PB8 = 1;
|
|
}else{
|
|
PB8 = 0;
|
|
}
|
|
}
|
|
else{
|
|
PWM_DisableOutput(PWM0, PWM_CH_1_MASK);
|
|
}
|
|
if(Axis3 != 0){
|
|
if(Axis3 > 0){
|
|
PB9 = 1;
|
|
}else{
|
|
PB9 = 0;
|
|
}
|
|
PWM_EnableOutput(PWM0, PWM_CH_3_MASK);
|
|
}
|
|
else{
|
|
PWM_DisableOutput(PWM0, PWM_CH_3_MASK);
|
|
}
|
|
if(Axis4 != 0){
|
|
PWM_EnableOutput(PWM0, PWM_CH_4_MASK);
|
|
if(Axis4 > 0){
|
|
PB11 = 1;
|
|
}else{
|
|
PB11 = 0;
|
|
}
|
|
}else{
|
|
PWM_DisableOutput(PWM0, PWM_CH_4_MASK);
|
|
}
|
|
|
|
// Clear channel 0 period interrupt flag
|
|
PWM_ClearPeriodIntFlag(PWM0, 0);
|
|
}
|
|
|
|
void PWM1P0_IRQHandler(void){
|
|
if(Axis5 != 0){
|
|
PWM_EnableOutput(PWM1, PWM_CH_0_MASK);
|
|
if(Axis5 > 0){
|
|
PE5 = 1;
|
|
}else{
|
|
PE5 = 0;
|
|
}
|
|
}else{
|
|
PWM_DisableOutput(PWM1, PWM_CH_0_MASK);
|
|
}
|
|
if(Axis6 != 0){
|
|
PWM_EnableOutput(PWM1, PWM_CH_1_MASK);
|
|
if(Axis6 > 0){
|
|
PA9 = 1;
|
|
}else{
|
|
PA9 = 0;
|
|
}
|
|
}else{
|
|
PWM_DisableOutput(PWM1, PWM_CH_1_MASK);
|
|
}
|
|
PWM_ClearPeriodIntFlag(PWM1, 0);
|
|
|
|
}
|