Konsolenbefehl um Lüfter anzusteuern
This commit is contained in:
parent
50ea6e4a74
commit
b13ee19743
@ -22,12 +22,14 @@
|
|||||||
using namespace ElektronischeLast;
|
using namespace ElektronischeLast;
|
||||||
|
|
||||||
uint16_t set_solltrom (CLI_OutFunction pfvOutFunction, char *acCommands[], uint16_t u16ArgCount);
|
uint16_t set_solltrom (CLI_OutFunction pfvOutFunction, char *acCommands[], uint16_t u16ArgCount);
|
||||||
|
uint16_t set_dutyCyle (CLI_OutFunction pfvOutFunction, char *acCommands[], uint16_t u16ArgCount);
|
||||||
uint16_t ist_werte(CLI_OutFunction pfvOutFunction, char *acCommands[], uint16_t u16ArgCount);
|
uint16_t ist_werte(CLI_OutFunction pfvOutFunction, char *acCommands[], uint16_t u16ArgCount);
|
||||||
|
|
||||||
static CLI_Command_t commands[] =
|
static CLI_Command_t commands[] =
|
||||||
{
|
{
|
||||||
{ "isoll", "Zielstrom für Last", set_solltrom },
|
{ "isoll", "Zielstrom für Last", set_solltrom },
|
||||||
{ "ist", "Zeige Istwerte an [-r für wiederholende Anzeige]", ist_werte }
|
{ "ist", "Zeige Istwerte an [-r für wiederholende Anzeige]", ist_werte },
|
||||||
|
{ "fan", "Setze Tastverhältnis für Lüfter", set_dutyCyle },
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::uint32_t i_soll = 0U;
|
static std::uint32_t i_soll = 0U;
|
||||||
@ -125,3 +127,20 @@ uint16_t ist_werte(CLI_OutFunction pfvOutFunction, char *acCommands[], uint16_t
|
|||||||
|
|
||||||
return recall;
|
return recall;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint16_t set_dutyCyle (CLI_OutFunction pfvOutFunction, char *acCommands[], uint16_t u16ArgCount)
|
||||||
|
{
|
||||||
|
char buf[40];
|
||||||
|
if(u16ArgCount == 1U)
|
||||||
|
{
|
||||||
|
uint32_t in = strtoul(acCommands[0], NULL, 10);
|
||||||
|
snprintf(buf, sizeof(buf), "\r\nNeu: %" PRIu32, in);
|
||||||
|
FanControl_SetDuty(in);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
snprintf(buf, sizeof(buf), "\r\nMissing Argument Dutycycle!");
|
||||||
|
}
|
||||||
|
pfvOutFunction(buf);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@ -10,8 +10,10 @@
|
|||||||
#include <stm32g0xx_ll_tim.h>
|
#include <stm32g0xx_ll_tim.h>
|
||||||
#include "FanControl.hpp"
|
#include "FanControl.hpp"
|
||||||
|
|
||||||
static std::uint32_t fan_speed;
|
#define TIMER_RELOAD_VALUE 2559UL
|
||||||
|
|
||||||
|
static std::uint32_t fan_speed;
|
||||||
|
static std::uint32_t duty;
|
||||||
extern "C" void TIM14_IRQHandler(void)
|
extern "C" void TIM14_IRQHandler(void)
|
||||||
{
|
{
|
||||||
LL_TIM_ClearFlag_UPDATE(TIM14);
|
LL_TIM_ClearFlag_UPDATE(TIM14);
|
||||||
@ -19,7 +21,10 @@ extern "C" void TIM14_IRQHandler(void)
|
|||||||
fan_speed = LL_TIM_GetCounter(TIM2) / 2UL;
|
fan_speed = LL_TIM_GetCounter(TIM2) / 2UL;
|
||||||
LL_TIM_SetCounter(TIM2, 0UL);
|
LL_TIM_SetCounter(TIM2, 0UL);
|
||||||
}
|
}
|
||||||
|
extern "C" void FanControl_SetDuty(uint32_t d)
|
||||||
|
{
|
||||||
|
duty = TIMER_RELOAD_VALUE / 100UL * d;
|
||||||
|
}
|
||||||
namespace ElektronischeLast
|
namespace ElektronischeLast
|
||||||
{
|
{
|
||||||
FanControl::FanControl(void)
|
FanControl::FanControl(void)
|
||||||
@ -30,7 +35,7 @@ namespace ElektronischeLast
|
|||||||
LL_TIM_InitTypeDef TIM_InitStruct = {
|
LL_TIM_InitTypeDef TIM_InitStruct = {
|
||||||
.Prescaler = 0UL,
|
.Prescaler = 0UL,
|
||||||
.CounterMode = LL_TIM_COUNTERMODE_UP,
|
.CounterMode = LL_TIM_COUNTERMODE_UP,
|
||||||
.Autoreload = 2559UL,
|
.Autoreload = TIMER_RELOAD_VALUE,
|
||||||
.ClockDivision = LL_TIM_CLOCKDIVISION_DIV1,
|
.ClockDivision = LL_TIM_CLOCKDIVISION_DIV1,
|
||||||
};
|
};
|
||||||
LL_TIM_Init(TIM3, &TIM_InitStruct);
|
LL_TIM_Init(TIM3, &TIM_InitStruct);
|
||||||
@ -72,6 +77,7 @@ namespace ElektronischeLast
|
|||||||
TIM_InitStruct.ClockDivision = LL_TIM_CLOCKDIVISION_DIV4;
|
TIM_InitStruct.ClockDivision = LL_TIM_CLOCKDIVISION_DIV4;
|
||||||
LL_TIM_Init(TIM14, &TIM_InitStruct);
|
LL_TIM_Init(TIM14, &TIM_InitStruct);
|
||||||
LL_TIM_DisableARRPreload(TIM14);
|
LL_TIM_DisableARRPreload(TIM14);
|
||||||
|
LL_TIM_EnableIT_UPDATE(TIM14);
|
||||||
|
|
||||||
/* TIM3 GPIO Configuration
|
/* TIM3 GPIO Configuration
|
||||||
* PC6 ------> TIM3_CH1
|
* PC6 ------> TIM3_CH1
|
||||||
@ -93,7 +99,9 @@ namespace ElektronischeLast
|
|||||||
GPIO_InitStruct.Alternate = LL_GPIO_AF_2;
|
GPIO_InitStruct.Alternate = LL_GPIO_AF_2;
|
||||||
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
LL_TIM_EnableCounter(TIM2);
|
||||||
LL_TIM_EnableCounter(TIM3);
|
LL_TIM_EnableCounter(TIM3);
|
||||||
|
LL_TIM_EnableCounter(TIM14);
|
||||||
|
|
||||||
this->compare_value = 0UL;
|
this->compare_value = 0UL;
|
||||||
|
|
||||||
@ -103,6 +111,7 @@ namespace ElektronischeLast
|
|||||||
|
|
||||||
void FanControl::run(std::uint32_t temp)
|
void FanControl::run(std::uint32_t temp)
|
||||||
{
|
{
|
||||||
|
this->compare_value = duty;
|
||||||
LL_TIM_OC_SetCompareCH1(TIM3, this->compare_value);
|
LL_TIM_OC_SetCompareCH1(TIM3, this->compare_value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
|
extern "C" void FanControl_SetDuty(uint32_t d);
|
||||||
|
|
||||||
namespace ElektronischeLast
|
namespace ElektronischeLast
|
||||||
{
|
{
|
||||||
class FanControl
|
class FanControl
|
||||||
|
Loading…
x
Reference in New Issue
Block a user