Konsolenbefehl um Lüfter anzusteuern
This commit is contained in:
parent
50ea6e4a74
commit
b13ee19743
@ -22,12 +22,14 @@
|
||||
using namespace ElektronischeLast;
|
||||
|
||||
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);
|
||||
|
||||
static CLI_Command_t commands[] =
|
||||
{
|
||||
{ "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;
|
||||
@ -125,3 +127,20 @@ uint16_t ist_werte(CLI_OutFunction pfvOutFunction, char *acCommands[], uint16_t
|
||||
|
||||
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 "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)
|
||||
{
|
||||
LL_TIM_ClearFlag_UPDATE(TIM14);
|
||||
@ -19,7 +21,10 @@ extern "C" void TIM14_IRQHandler(void)
|
||||
fan_speed = LL_TIM_GetCounter(TIM2) / 2UL;
|
||||
LL_TIM_SetCounter(TIM2, 0UL);
|
||||
}
|
||||
|
||||
extern "C" void FanControl_SetDuty(uint32_t d)
|
||||
{
|
||||
duty = TIMER_RELOAD_VALUE / 100UL * d;
|
||||
}
|
||||
namespace ElektronischeLast
|
||||
{
|
||||
FanControl::FanControl(void)
|
||||
@ -30,7 +35,7 @@ namespace ElektronischeLast
|
||||
LL_TIM_InitTypeDef TIM_InitStruct = {
|
||||
.Prescaler = 0UL,
|
||||
.CounterMode = LL_TIM_COUNTERMODE_UP,
|
||||
.Autoreload = 2559UL,
|
||||
.Autoreload = TIMER_RELOAD_VALUE,
|
||||
.ClockDivision = LL_TIM_CLOCKDIVISION_DIV1,
|
||||
};
|
||||
LL_TIM_Init(TIM3, &TIM_InitStruct);
|
||||
@ -72,6 +77,7 @@ namespace ElektronischeLast
|
||||
TIM_InitStruct.ClockDivision = LL_TIM_CLOCKDIVISION_DIV4;
|
||||
LL_TIM_Init(TIM14, &TIM_InitStruct);
|
||||
LL_TIM_DisableARRPreload(TIM14);
|
||||
LL_TIM_EnableIT_UPDATE(TIM14);
|
||||
|
||||
/* TIM3 GPIO Configuration
|
||||
* PC6 ------> TIM3_CH1
|
||||
@ -93,7 +99,9 @@ namespace ElektronischeLast
|
||||
GPIO_InitStruct.Alternate = LL_GPIO_AF_2;
|
||||
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
LL_TIM_EnableCounter(TIM2);
|
||||
LL_TIM_EnableCounter(TIM3);
|
||||
LL_TIM_EnableCounter(TIM14);
|
||||
|
||||
this->compare_value = 0UL;
|
||||
|
||||
@ -103,6 +111,7 @@ namespace ElektronischeLast
|
||||
|
||||
void FanControl::run(std::uint32_t temp)
|
||||
{
|
||||
this->compare_value = duty;
|
||||
LL_TIM_OC_SetCompareCH1(TIM3, this->compare_value);
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
extern "C" void FanControl_SetDuty(uint32_t d);
|
||||
|
||||
namespace ElektronischeLast
|
||||
{
|
||||
class FanControl
|
||||
|
Loading…
x
Reference in New Issue
Block a user