events and exti
This commit is contained in:
@@ -81,6 +81,8 @@ void Error_Handler(void);
|
||||
#define LED_GPIO_Port GPIOC
|
||||
#define ADC_SENSR_Pin LL_GPIO_PIN_1
|
||||
#define ADC_SENSR_GPIO_Port GPIOA
|
||||
#define PWM_HEATER_Pin LL_GPIO_PIN_6
|
||||
#define PWM_HEATER_GPIO_Port GPIOA
|
||||
#define OLED_CS_Pin LL_GPIO_PIN_0
|
||||
#define OLED_CS_GPIO_Port GPIOB
|
||||
#define OLED_DC_Pin LL_GPIO_PIN_1
|
||||
@@ -95,6 +97,7 @@ void Error_Handler(void);
|
||||
#define KNOB_B_GPIO_Port GPIOB
|
||||
#define KNOB_PUSH_Pin LL_GPIO_PIN_8
|
||||
#define KNOB_PUSH_GPIO_Port GPIOB
|
||||
#define KNOB_PUSH_EXTI_IRQn EXTI9_5_IRQn
|
||||
#ifndef NVIC_PRIORITYGROUP_0
|
||||
#define NVIC_PRIORITYGROUP_0 ((uint32_t)0x00000007) /*!< 0 bit for pre-emption priority,
|
||||
4 bits for subpriority */
|
||||
|
||||
@@ -54,6 +54,7 @@ void UsageFault_Handler(void);
|
||||
void DebugMon_Handler(void);
|
||||
void SysTick_Handler(void);
|
||||
void DMA1_Channel1_IRQHandler(void);
|
||||
void EXTI9_5_IRQHandler(void);
|
||||
void TIM4_IRQHandler(void);
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
|
||||
+10
-2
@@ -2,13 +2,21 @@
|
||||
* TODO file description
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "app_gui.h"
|
||||
#include "cmsis_os2.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "queue.h"
|
||||
|
||||
void app_task_gui(void *argument) {
|
||||
PRINTF("app_task_gui\r\n");
|
||||
while (1) {
|
||||
vTaskDelay(pdMS_TO_TICKS(1000));
|
||||
uint8_t message = 0;
|
||||
bool suc = osMessageQueueGet(guiEventQueHandle, &message, NULL, pdMS_TO_TICKS(1000));
|
||||
|
||||
if (suc == osOK && (message != GUI_NOTIFY_TEMP_CHANGE)) {
|
||||
// input events
|
||||
PRINTF("Event %d\r\n", message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,21 @@
|
||||
#ifndef BLUEPILLTROUBA_APP_GUI_H
|
||||
#define BLUEPILLTROUBA_APP_GUI_H
|
||||
|
||||
#include "cmsis_os2.h"
|
||||
|
||||
extern osThreadId_t guiTskHandle;
|
||||
extern osMessageQueueId_t guiEventQueHandle;
|
||||
|
||||
void app_task_gui(void *argument);
|
||||
|
||||
// sent through the notify queue
|
||||
enum GuiNotify {
|
||||
GUI_EVENT_NONE = 0,
|
||||
GUI_NOTIFY_KNOB_PLUS,
|
||||
GUI_NOTIFY_KNOB_MINUS,
|
||||
GUI_NOTIFY_KNOB_PRESS,
|
||||
GUI_NOTIFY_KNOB_RELEASE,
|
||||
GUI_NOTIFY_TEMP_CHANGE,
|
||||
};
|
||||
|
||||
#endif //BLUEPILLTROUBA_APP_GUI_H
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include "app_heater.h"
|
||||
#include "cmsis_os2.h"
|
||||
#include "tim.h"
|
||||
#include "queue.h"
|
||||
#include "app_gui.h"
|
||||
|
||||
extern osMutexId_t heaterMutexHandle;
|
||||
|
||||
@@ -79,6 +81,14 @@ void app_heater_set_target(float target) {
|
||||
heaterExitCritical();
|
||||
}
|
||||
|
||||
void app_heater_emergency_shutdown() {
|
||||
PID_SetCtlMode(&state.pid, PID_MANUAL);
|
||||
|
||||
// TODO check if this really turns the channel off!
|
||||
LL_TIM_OC_SetCompareCH1(TIM_HEATER, 0);
|
||||
LL_TIM_CC_DisableChannel(TIM_HEATER, LL_TIM_CHANNEL_CH1);
|
||||
}
|
||||
|
||||
void app_task_heater(void *argument)
|
||||
{
|
||||
heater_pwm_init();
|
||||
@@ -96,6 +106,9 @@ void app_task_heater(void *argument)
|
||||
state.oven_temp = app_temp_read_oven();
|
||||
state.soc_temp = app_temp_read_soc();
|
||||
|
||||
enum GuiNotify ev = GUI_NOTIFY_TEMP_CHANGE;
|
||||
xQueueSend(guiEventQueHandle, &ev, pdMS_TO_TICKS(100));
|
||||
|
||||
heaterEnterCritical();
|
||||
PID_Compute(&state.pid, state.oven_temp);
|
||||
if (state.pid.ctlMode == PID_AUTOMATIC) {
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
#define BLUEPILLTROUBA_APP_HEATER_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "cmsis_os2.h"
|
||||
|
||||
extern osThreadId_t heaterTskHandle;
|
||||
|
||||
void app_task_heater(void *argument);
|
||||
|
||||
@@ -21,4 +24,7 @@ void app_heater_enable(bool enable);
|
||||
/// Mutex is locked internally.
|
||||
void app_heater_set_target(float target);
|
||||
|
||||
/// Shutdown the heater; This function does not use mutex and just disables the PWM via register access.
|
||||
void app_heater_emergency_shutdown();
|
||||
|
||||
#endif //BLUEPILLTROUBA_APP_HEATER_H
|
||||
|
||||
+62
-1
@@ -6,6 +6,13 @@
|
||||
#include "main.h"
|
||||
#include "app_knob.h"
|
||||
#include "tim.h"
|
||||
#include "app_gui.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include "queue.h"
|
||||
#include "timers.h"
|
||||
|
||||
extern osTimerId_t buttonPushTimerHandle;
|
||||
extern osTimerId_t buttonReleaseTimerHandle;
|
||||
|
||||
static struct {
|
||||
uint16_t wheel;
|
||||
@@ -18,14 +25,68 @@ void app_knob_init()
|
||||
LL_TIM_CC_EnableChannel(TIM_KNOB, LL_TIM_CHANNEL_CH1 | LL_TIM_CHANNEL_CH2);
|
||||
LL_TIM_EnableCounter(TIM_KNOB);
|
||||
|
||||
// HAL_TIM_Encoder_Start(&htim4, TIM_CHANNEL_ALL);
|
||||
// for the change interrupt
|
||||
LL_TIM_EnableIT_CC1(TIM_KNOB);
|
||||
LL_TIM_EnableIT_CC2(TIM_KNOB);
|
||||
}
|
||||
|
||||
uint16_t app_knob_get_raw() {
|
||||
return LL_TIM_GetCounter(TIM_KNOB);
|
||||
}
|
||||
|
||||
static char buf[100];
|
||||
|
||||
void app_knob_turn_isr()
|
||||
{
|
||||
// TODO
|
||||
uint16_t old_wheel = s_knob.wheel;
|
||||
s_knob.wheel = LL_TIM_GetCounter(TIM_KNOB);
|
||||
|
||||
int16_t wheel_change = (int16_t)(s_knob.wheel - old_wheel);
|
||||
|
||||
BaseType_t yield = pdFALSE;
|
||||
|
||||
while (wheel_change > 0) {
|
||||
wheel_change--;
|
||||
enum GuiNotify ev = GUI_NOTIFY_KNOB_PLUS;
|
||||
xQueueSendFromISR(guiEventQueHandle, &ev, &yield);
|
||||
}
|
||||
|
||||
while (wheel_change < 0) {
|
||||
wheel_change++;
|
||||
enum GuiNotify ev = GUI_NOTIFY_KNOB_MINUS;
|
||||
xQueueSendFromISR(guiEventQueHandle, &ev, &yield);
|
||||
}
|
||||
|
||||
portYIELD_FROM_ISR(yield);
|
||||
}
|
||||
|
||||
|
||||
// TODO use EXTI for push
|
||||
|
||||
bool app_knob_pushed() {
|
||||
return 0 == LL_GPIO_IsInputPinSet(KNOB_PUSH_GPIO_Port, KNOB_PUSH_Pin);
|
||||
}
|
||||
|
||||
void app_knob_push_isr(bool push)
|
||||
{
|
||||
PUTCHAR(push ? '#' : '.');
|
||||
|
||||
BaseType_t yield = pdFALSE;
|
||||
if (push) {
|
||||
xTimerStopFromISR(buttonReleaseTimerHandle, &yield);
|
||||
xTimerStopFromISR(buttonPushTimerHandle, &yield);
|
||||
xTimerChangePeriodFromISR(buttonPushTimerHandle, pdMS_TO_TICKS(10), &yield);
|
||||
} else {
|
||||
xTimerStopFromISR(buttonPushTimerHandle, &yield);
|
||||
xTimerStopFromISR(buttonReleaseTimerHandle, &yield);
|
||||
xTimerChangePeriodFromISR(buttonReleaseTimerHandle, pdMS_TO_TICKS(10), &yield);
|
||||
}
|
||||
portYIELD_FROM_ISR(yield);
|
||||
}
|
||||
|
||||
void app_push_debounce(void *argument) {
|
||||
bool push = (bool) argument;
|
||||
enum GuiNotify ev = push ? GUI_NOTIFY_KNOB_PRESS : GUI_NOTIFY_KNOB_RELEASE;
|
||||
xQueueSend(guiEventQueHandle, &ev, pdMS_TO_TICKS(100));
|
||||
}
|
||||
|
||||
@@ -5,9 +5,14 @@
|
||||
#ifndef BLUEPILLTROUBA_APP_KNOB_H
|
||||
#define BLUEPILLTROUBA_APP_KNOB_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
void app_knob_init();
|
||||
|
||||
uint16_t app_knob_get_raw();
|
||||
bool app_knob_pushed();
|
||||
|
||||
void app_knob_turn_isr();
|
||||
void app_knob_push_isr(bool push);
|
||||
|
||||
#endif //BLUEPILLTROUBA_APP_KNOB_H
|
||||
|
||||
+2
-3
@@ -158,11 +158,10 @@ void app_analog_init()
|
||||
LL_ADC_REG_StartConversionExtTrig(ADC_TEMP, LL_ADC_REG_TRIG_EXT_RISING);
|
||||
// LL_ADC_REG_StartConversionSWStart(ADC_TEMP);
|
||||
|
||||
// this timer runs with 1 kHz clock
|
||||
LL_TIM_SetTriggerOutput(TIM1, LL_TIM_TRGO_CC1IF);
|
||||
LL_TIM_CC_EnableChannel(TIM1, LL_TIM_CHANNEL_CH1);
|
||||
LL_TIM_OC_SetCompareCH1(TIM1, 10);
|
||||
LL_TIM_SetAutoReload(TIM1, 20);
|
||||
LL_TIM_EnableAllOutputs(TIM1);
|
||||
LL_TIM_EnableAllOutputs(TIM1); // TIM1 needs outputs specially enabled - it's "advanced timer"
|
||||
LL_TIM_EnableCounter(TIM1);
|
||||
}
|
||||
|
||||
|
||||
+25
-2
@@ -90,7 +90,7 @@ const osThreadAttr_t guiTsk_attributes = {
|
||||
};
|
||||
/* Definitions for guiEventQue */
|
||||
osMessageQueueId_t guiEventQueHandle;
|
||||
uint8_t guiEventQueBuffer[ 16 * 8 ];
|
||||
uint8_t guiEventQueBuffer[ 32 * 1 ];
|
||||
osStaticMessageQDef_t guiEventQueControlBlock;
|
||||
const osMessageQueueAttr_t guiEventQue_attributes = {
|
||||
.name = "guiEventQue",
|
||||
@@ -107,6 +107,22 @@ const osTimerAttr_t beepTimer_attributes = {
|
||||
.cb_mem = &beepTimerControlBlock,
|
||||
.cb_size = sizeof(beepTimerControlBlock),
|
||||
};
|
||||
/* Definitions for buttonPushTimer */
|
||||
osTimerId_t buttonPushTimerHandle;
|
||||
osStaticTimerDef_t buttonPushTimerControlBlock;
|
||||
const osTimerAttr_t buttonPushTimer_attributes = {
|
||||
.name = "buttonPushTimer",
|
||||
.cb_mem = &buttonPushTimerControlBlock,
|
||||
.cb_size = sizeof(buttonPushTimerControlBlock),
|
||||
};
|
||||
/* Definitions for buttonReleaseTimer */
|
||||
osTimerId_t buttonReleaseTimerHandle;
|
||||
osStaticTimerDef_t buttonReleaseTimerControlBlock;
|
||||
const osTimerAttr_t buttonReleaseTimer_attributes = {
|
||||
.name = "buttonReleaseTimer",
|
||||
.cb_mem = &buttonReleaseTimerControlBlock,
|
||||
.cb_size = sizeof(buttonReleaseTimerControlBlock),
|
||||
};
|
||||
/* Definitions for heaterMutex */
|
||||
osMutexId_t heaterMutexHandle;
|
||||
osStaticMutexDef_t heaterMutexControlBlock;
|
||||
@@ -125,6 +141,7 @@ void app_task_main(void *argument);
|
||||
extern void app_task_heater(void *argument);
|
||||
extern void app_task_gui(void *argument);
|
||||
extern void app_beep_end(void *argument);
|
||||
extern void app_push_debounce(void *argument);
|
||||
|
||||
void MX_FREERTOS_Init(void); /* (MISRA C 2004 rule 8.1) */
|
||||
|
||||
@@ -184,13 +201,19 @@ void MX_FREERTOS_Init(void) {
|
||||
/* creation of beepTimer */
|
||||
beepTimerHandle = osTimerNew(app_beep_end, osTimerOnce, NULL, &beepTimer_attributes);
|
||||
|
||||
/* creation of buttonPushTimer */
|
||||
buttonPushTimerHandle = osTimerNew(app_push_debounce, osTimerOnce, (void*) 1, &buttonPushTimer_attributes);
|
||||
|
||||
/* creation of buttonReleaseTimer */
|
||||
buttonReleaseTimerHandle = osTimerNew(app_push_debounce, osTimerOnce, (void*) 0, &buttonReleaseTimer_attributes);
|
||||
|
||||
/* USER CODE BEGIN RTOS_TIMERS */
|
||||
/* start timers, add new ones, ... */
|
||||
/* USER CODE END RTOS_TIMERS */
|
||||
|
||||
/* Create the queue(s) */
|
||||
/* creation of guiEventQue */
|
||||
guiEventQueHandle = osMessageQueueNew (16, 8, &guiEventQue_attributes);
|
||||
guiEventQueHandle = osMessageQueueNew (32, 1, &guiEventQue_attributes);
|
||||
|
||||
/* USER CODE BEGIN RTOS_QUEUES */
|
||||
/* add queues, ... */
|
||||
|
||||
+20
-4
@@ -44,6 +44,7 @@
|
||||
void MX_GPIO_Init(void)
|
||||
{
|
||||
|
||||
LL_EXTI_InitTypeDef EXTI_InitStruct = {0};
|
||||
LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
|
||||
/* GPIO Ports Clock Enable */
|
||||
@@ -98,12 +99,27 @@ void MX_GPIO_Init(void)
|
||||
LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
|
||||
/**/
|
||||
GPIO_InitStruct.Pin = KNOB_PUSH_Pin;
|
||||
GPIO_InitStruct.Mode = LL_GPIO_MODE_FLOATING;
|
||||
LL_GPIO_Init(KNOB_PUSH_GPIO_Port, &GPIO_InitStruct);
|
||||
LL_GPIO_AF_EnableRemap_PD01();
|
||||
|
||||
/**/
|
||||
LL_GPIO_AF_EnableRemap_PD01();
|
||||
LL_GPIO_AF_SetEXTISource(LL_GPIO_AF_EXTI_PORTB, LL_GPIO_AF_EXTI_LINE8);
|
||||
|
||||
/**/
|
||||
EXTI_InitStruct.Line_0_31 = LL_EXTI_LINE_8;
|
||||
EXTI_InitStruct.LineCommand = ENABLE;
|
||||
EXTI_InitStruct.Mode = LL_EXTI_MODE_IT;
|
||||
EXTI_InitStruct.Trigger = LL_EXTI_TRIGGER_RISING_FALLING;
|
||||
LL_EXTI_Init(&EXTI_InitStruct);
|
||||
|
||||
/**/
|
||||
LL_GPIO_SetPinPull(KNOB_PUSH_GPIO_Port, KNOB_PUSH_Pin, LL_GPIO_PULL_UP);
|
||||
|
||||
/**/
|
||||
LL_GPIO_SetPinMode(KNOB_PUSH_GPIO_Port, KNOB_PUSH_Pin, LL_GPIO_MODE_INPUT);
|
||||
|
||||
/* EXTI interrupt init*/
|
||||
NVIC_SetPriority(EXTI9_5_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),5, 0));
|
||||
NVIC_EnableIRQ(EXTI9_5_IRQn);
|
||||
|
||||
}
|
||||
|
||||
|
||||
+31
-1
@@ -24,8 +24,8 @@
|
||||
#include "task.h"
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
#include <stdio.h>
|
||||
#include "app_temp.h"
|
||||
#include "app_knob.h"
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
@@ -206,6 +206,29 @@ void DMA1_Channel1_IRQHandler(void)
|
||||
/* USER CODE END DMA1_Channel1_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles EXTI line[9:5] interrupts.
|
||||
*/
|
||||
void EXTI9_5_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN EXTI9_5_IRQn 0 */
|
||||
bool state = LL_GPIO_IsInputPinSet(KNOB_PUSH_GPIO_Port, KNOB_PUSH_Pin);
|
||||
|
||||
/* USER CODE END EXTI9_5_IRQn 0 */
|
||||
if (LL_EXTI_IsActiveFlag_0_31(LL_EXTI_LINE_8) != RESET)
|
||||
{
|
||||
LL_EXTI_ClearFlag_0_31(LL_EXTI_LINE_8);
|
||||
/* USER CODE BEGIN LL_EXTI_LINE_8 */
|
||||
|
||||
app_knob_push_isr(0 == state);
|
||||
|
||||
/* USER CODE END LL_EXTI_LINE_8 */
|
||||
}
|
||||
/* USER CODE BEGIN EXTI9_5_IRQn 1 */
|
||||
|
||||
/* USER CODE END EXTI9_5_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles TIM4 global interrupt.
|
||||
*/
|
||||
@@ -213,6 +236,13 @@ void TIM4_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN TIM4_IRQn 0 */
|
||||
|
||||
if (LL_TIM_IsActiveFlag_CC1(TIM4) || LL_TIM_IsActiveFlag_CC2(TIM4)) {
|
||||
LL_TIM_ClearFlag_CC1(TIM4);
|
||||
LL_TIM_ClearFlag_CC2(TIM4);
|
||||
app_knob_turn_isr();
|
||||
}
|
||||
|
||||
|
||||
/* USER CODE END TIM4_IRQn 0 */
|
||||
/* USER CODE BEGIN TIM4_IRQn 1 */
|
||||
|
||||
|
||||
+14
-6
@@ -30,6 +30,8 @@ void MX_TIM1_Init(void)
|
||||
|
||||
/* USER CODE BEGIN TIM1_Init 0 */
|
||||
|
||||
// --- this timer is used to time ADC sampling. ---
|
||||
|
||||
/* USER CODE END TIM1_Init 0 */
|
||||
|
||||
LL_TIM_InitTypeDef TIM_InitStruct = {0};
|
||||
@@ -44,7 +46,7 @@ void MX_TIM1_Init(void)
|
||||
/* USER CODE END TIM1_Init 1 */
|
||||
TIM_InitStruct.Prescaler = 64000;
|
||||
TIM_InitStruct.CounterMode = LL_TIM_COUNTERMODE_UP;
|
||||
TIM_InitStruct.Autoreload = 100;
|
||||
TIM_InitStruct.Autoreload = 10;
|
||||
TIM_InitStruct.ClockDivision = LL_TIM_CLOCKDIVISION_DIV1;
|
||||
TIM_InitStruct.RepetitionCounter = 0;
|
||||
LL_TIM_Init(TIM1, &TIM_InitStruct);
|
||||
@@ -54,7 +56,7 @@ void MX_TIM1_Init(void)
|
||||
TIM_OC_InitStruct.OCMode = LL_TIM_OCMODE_PWM1;
|
||||
TIM_OC_InitStruct.OCState = LL_TIM_OCSTATE_DISABLE;
|
||||
TIM_OC_InitStruct.OCNState = LL_TIM_OCSTATE_DISABLE;
|
||||
TIM_OC_InitStruct.CompareValue = 0;
|
||||
TIM_OC_InitStruct.CompareValue = 1;
|
||||
TIM_OC_InitStruct.OCPolarity = LL_TIM_OCPOLARITY_HIGH;
|
||||
TIM_OC_InitStruct.OCNPolarity = LL_TIM_OCPOLARITY_HIGH;
|
||||
TIM_OC_InitStruct.OCIdleState = LL_TIM_OCIDLESTATE_LOW;
|
||||
@@ -82,6 +84,8 @@ void MX_TIM2_Init(void)
|
||||
|
||||
/* USER CODE BEGIN TIM2_Init 0 */
|
||||
|
||||
// --- this timer generates the buzzer PWM. The PWM parameters are adjusted on the fly ---
|
||||
|
||||
/* USER CODE END TIM2_Init 0 */
|
||||
|
||||
LL_TIM_InitTypeDef TIM_InitStruct = {0};
|
||||
@@ -133,6 +137,8 @@ void MX_TIM3_Init(void)
|
||||
|
||||
/* USER CODE BEGIN TIM3_Init 0 */
|
||||
|
||||
// --- this timer generates the heater PWM. The duty is set as 640 * percent ---
|
||||
|
||||
/* USER CODE END TIM3_Init 0 */
|
||||
|
||||
LL_TIM_InitTypeDef TIM_InitStruct = {0};
|
||||
@@ -145,7 +151,7 @@ void MX_TIM3_Init(void)
|
||||
/* USER CODE BEGIN TIM3_Init 1 */
|
||||
|
||||
/* USER CODE END TIM3_Init 1 */
|
||||
TIM_InitStruct.Prescaler = 2000;
|
||||
TIM_InitStruct.Prescaler = 1000;
|
||||
TIM_InitStruct.CounterMode = LL_TIM_COUNTERMODE_UP;
|
||||
TIM_InitStruct.Autoreload = 64000;
|
||||
TIM_InitStruct.ClockDivision = LL_TIM_CLOCKDIVISION_DIV1;
|
||||
@@ -169,11 +175,11 @@ void MX_TIM3_Init(void)
|
||||
/**TIM3 GPIO Configuration
|
||||
PA6 ------> TIM3_CH1
|
||||
*/
|
||||
GPIO_InitStruct.Pin = LL_GPIO_PIN_6;
|
||||
GPIO_InitStruct.Pin = PWM_HEATER_Pin;
|
||||
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
|
||||
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
|
||||
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
||||
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
LL_GPIO_Init(PWM_HEATER_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
}
|
||||
/* TIM4 init function */
|
||||
@@ -182,6 +188,8 @@ void MX_TIM4_Init(void)
|
||||
|
||||
/* USER CODE BEGIN TIM4_Init 0 */
|
||||
|
||||
// --- This timer captures the rotary encoder. The count must be divided by 4, but it can't be done by the hardware, doesn't work well. ---
|
||||
|
||||
/* USER CODE END TIM4_Init 0 */
|
||||
|
||||
LL_TIM_InitTypeDef TIM_InitStruct = {0};
|
||||
@@ -211,7 +219,7 @@ void MX_TIM4_Init(void)
|
||||
LL_TIM_SetEncoderMode(TIM4, LL_TIM_ENCODERMODE_X2_TI1);
|
||||
LL_TIM_IC_SetActiveInput(TIM4, LL_TIM_CHANNEL_CH1, LL_TIM_ACTIVEINPUT_DIRECTTI);
|
||||
LL_TIM_IC_SetPrescaler(TIM4, LL_TIM_CHANNEL_CH1, LL_TIM_ICPSC_DIV1);
|
||||
LL_TIM_IC_SetFilter(TIM4, LL_TIM_CHANNEL_CH1, LL_TIM_IC_FILTER_FDIV1);
|
||||
LL_TIM_IC_SetFilter(TIM4, LL_TIM_CHANNEL_CH1, LL_TIM_IC_FILTER_FDIV32_N8);
|
||||
LL_TIM_IC_SetPolarity(TIM4, LL_TIM_CHANNEL_CH1, LL_TIM_IC_POLARITY_RISING);
|
||||
LL_TIM_IC_SetActiveInput(TIM4, LL_TIM_CHANNEL_CH2, LL_TIM_ACTIVEINPUT_DIRECTTI);
|
||||
LL_TIM_IC_SetPrescaler(TIM4, LL_TIM_CHANNEL_CH2, LL_TIM_ICPSC_DIV1);
|
||||
|
||||
+2
-1
@@ -51,7 +51,8 @@ void MX_USART1_UART_Init(void)
|
||||
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
GPIO_InitStruct.Pin = LL_GPIO_PIN_10;
|
||||
GPIO_InitStruct.Mode = LL_GPIO_MODE_FLOATING;
|
||||
GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT;
|
||||
GPIO_InitStruct.Pull = LL_GPIO_PULL_UP;
|
||||
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
/* USER CODE BEGIN USART1_Init 1 */
|
||||
|
||||
Reference in New Issue
Block a user