Last active
June 7, 2023 18:26
-
-
Save M0nteCarl0/4d521c817be9acf396e28a21147cc67b to your computer and use it in GitHub Desktop.
STM L6258 PWM controlled high current DMOS universal motor driver HAL module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Control_ST_L6258.h" | |
/****************************************************************************** | |
* @file Control_ST_L625.c | |
* @author Molotaliev A.O([email protected]) | |
* @version V 0.5.1 | |
* @date 10-May-2016 | |
* @brief This Driver for H-Bridge ST L6258(LGPL) | |
* | |
* | |
****************************************************************************/ | |
Control_ST_L6258:: Control_ST_L6258(void) | |
{ | |
} | |
/****************************************************************************/ | |
Control_ST_L6258:: ~Control_ST_L6258(void) | |
{ | |
} | |
/****************************************************************************/ | |
void Control_ST_L6258::InitHBridgeFirst(H_Bridge_Assigment HBridge) | |
{ | |
_H_BridgeFirst = HBridge; | |
ST_L6258_InitHBridge(_H_BridgeFirst); | |
} | |
/****************************************************************************/ | |
void Control_ST_L6258::InitHBridgeSecond(H_Bridge_Assigment HBridge) | |
{ | |
_H_BridgeSecond = HBridge; | |
ST_L6258_InitHBridge(_H_BridgeSecond); | |
} | |
/****************************************************************************/ | |
void Control_ST_L6258 :: SetCurrentFirstBridge(Current_Percentage CurrentPerc) | |
{ | |
SetCurrentBridge(_H_BridgeFirst,CurrentPerc); | |
} | |
/****************************************************************************/ | |
void Control_ST_L6258:: SetCurrentSecondBridge(Current_Percentage CurrentPerc) | |
{ | |
SetCurrentBridge(_H_BridgeSecond,CurrentPerc); | |
} | |
/****************************************************************************/ | |
void Control_ST_L6258:: SetDirectionFirstBridge(Current_Direction Dir) | |
{ | |
SetDirectionBridge(_H_BridgeFirst,Dir); | |
} | |
/****************************************************************************/ | |
void Control_ST_L6258:: SetDirectionSecondBridge(Current_Direction Dir) | |
{ | |
SetDirectionBridge(_H_BridgeSecond,Dir); | |
} | |
/****************************************************************************/ | |
void Control_ST_L6258:: SetParametrsFirstBridge(Current_Direction Dir,Current_Percentage CurrentPerc) | |
{ | |
ST_L6258_DC_EngineConrtol(_H_BridgeFirst,CurrentPerc,Dir); | |
} | |
/****************************************************************************/ | |
void Control_ST_L6258:: SetParametrsSecondBridge(Current_Direction Dir,Current_Percentage CurrentPerc) | |
{ | |
ST_L6258_DC_EngineConrtol(_H_BridgeSecond,CurrentPerc,Dir); | |
} | |
/****************************************************************************/ | |
void Control_ST_L6258::SetCurrentBridge( H_Bridge_Assigment HBridge,Current_Percentage CurrentPerc) | |
{ | |
ST_L6258_SetCurrent(HBridge,CurrentPerc); | |
} | |
/****************************************************************************/ | |
void Control_ST_L6258:: SetDirectionBridge(H_Bridge_Assigment HBridge,Current_Direction Dir) | |
{ | |
ST_L6258_SetDirection(HBridge,Dir); | |
} | |
/****************************************************************************/ | |
void Control_ST_L6258::Disable(void) | |
{ | |
ST_L6258_Enable(_H_BridgeSecond,false); | |
} | |
/****************************************************************************/ | |
void Control_ST_L6258::Enable(void) | |
{ | |
ST_L6258_Enable(_H_BridgeSecond,true); | |
} | |
/****************************************************************************/ | |
Control_ST_L6258 Control_ST_L6258::operator =(Control_ST_L6258 Source) | |
{ | |
this->SetFirstHBridge(Source.GetFirstHBridge()); | |
this->SetSecondtHBridge(Source.GetSecondHBridge()); | |
return *this; | |
} | |
/****************************************************************************/ | |
H_Bridge_Assigment Control_ST_L6258:: GetFirstHBridge(void) | |
{ | |
return _H_BridgeFirst; | |
} | |
/****************************************************************************/ | |
H_Bridge_Assigment Control_ST_L6258::GetSecondHBridge(void) | |
{ | |
return _H_BridgeSecond; | |
} | |
/****************************************************************************/ | |
void Control_ST_L6258::SetFirstHBridge(H_Bridge_Assigment Source) | |
{ | |
_H_BridgeFirst = Source; | |
} | |
/****************************************************************************/ | |
void Control_ST_L6258:: SetSecondtHBridge(H_Bridge_Assigment Source) | |
{ | |
_H_BridgeSecond = Source; | |
} | |
/****************************************************************************/ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include "ST_L6258.h" | |
/****************************************************************************** | |
* @file Control_ST_L625.c | |
* @author Molotaliev A.O([email protected]) | |
* @version V 0.5.1 | |
* @date 10-May-2016 | |
* @brief This Driver for H-Bridge ST L6258(LGPL) | |
* | |
* | |
****************************************************************************/ | |
class Control_ST_L6258 | |
{ | |
public: | |
Control_ST_L6258(void); | |
~Control_ST_L6258(void); | |
void InitHBridgeFirst(H_Bridge_Assigment HBridge); | |
void InitHBridgeSecond(H_Bridge_Assigment HBridge); | |
void SetCurrentFirstBridge(Current_Percentage CurrentPerc); | |
void SetCurrentSecondBridge(Current_Percentage CurrentPerc); | |
void SetDirectionFirstBridge(Current_Direction Dir); | |
void SetDirectionSecondBridge(Current_Direction Dir); | |
void SetParametrsFirstBridge(Current_Direction Dir,Current_Percentage CurrentPerc); | |
void SetParametrsSecondBridge(Current_Direction Dir,Current_Percentage CurrentPerc); | |
void Disable(void); | |
void Enable(void); | |
Control_ST_L6258 operator =(Control_ST_L6258 Source); | |
H_Bridge_Assigment GetFirstHBridge(void); | |
H_Bridge_Assigment GetSecondHBridge(void); | |
void SetFirstHBridge(H_Bridge_Assigment Source); | |
void SetSecondtHBridge(H_Bridge_Assigment Source); | |
private: | |
void SetCurrentBridge(H_Bridge_Assigment _H_Bridge,Current_Percentage CurrentPerc); | |
void SetDirectionBridge(H_Bridge_Assigment _H_Bridge,Current_Direction Dir); | |
H_Bridge_Assigment _H_BridgeFirst; | |
H_Bridge_Assigment _H_BridgeSecond; | |
Current_Percentage _CurrentFirstBridge; | |
Current_Percentage _CurrenSecondBridge; | |
Current_Direction _DirectionCurrentFirstBridge; | |
Current_Direction _DirectionCurrenttSecondBridge; | |
}; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stm32f4xx.h" | |
/****************************************************************************** | |
* @file ST_L6258_definitions.h | |
* @author Molotaliev A.O([email protected]) | |
* @version V 0.0.1 | |
* @date 16-february-2016/17-february-2016/9-March-2016 | |
* @brief Init Struct Definitions ST L6258 | |
* | |
*/ | |
/****************************************************************************/ | |
typedef struct H_Bridge_Assigment | |
{ | |
uint32_t RCC_Phase; | |
uint32_t RCC_HB; | |
GPIO_TypeDef* GPIOHB; | |
GPIO_TypeDef* GPIOPhase; | |
uint32_t L0; | |
uint32_t L1; | |
uint32_t L2; | |
uint32_t L3; | |
uint32_t Phase; | |
uint32_t Disable; | |
}H_Bridge_Assigment; | |
/****************************************************************************/ | |
enum Current_Direction | |
{ | |
Current_Direction_CW, | |
Current_Direction_CWW, | |
}; | |
/****************************************************************************/ | |
enum Current_Percentage | |
{ | |
Current_Percentage_0, | |
Current_Percentage_9_5, | |
Current_Percentage_19_1, | |
Current_Percentage_28_6, | |
Current_Percentage_38_1, | |
Current_Percentage_47_6, | |
Current_Percentage_55_6, | |
Current_Percentage_63_5, | |
Current_Percentage_71_4, | |
Current_Percentage_77_8, | |
Current_Percentage_82_5, | |
Current_Percentage_88_9, | |
Current_Percentage_92_1, | |
Current_Percentage_95_2, | |
Current_Percentage_98_4, | |
Current_Percentage_100, | |
}; | |
/****************************************************************************/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment