Debug/Fix V2, V3 - Versuch2 + Versuch3 work

This commit is contained in:
jonny 2025-11-18 11:11:21 +01:00
parent 33672839e9
commit fcc401cb99
9 changed files with 71 additions and 74 deletions

12
.gitignore vendored
View File

@ -3,12 +3,12 @@
#-----------------------------------------------------------
# Build output folders
/Debug/
/Release/
/build/
/out/
/bin/
/obj/
Debug/
Release/
build/
out/
bin/
obj/
# STM32Cube auto-generated configuration backups
*.launch

View File

@ -197,8 +197,6 @@ void Error_Handler(void);
#define PMOD_UART7_CTS_GPIO_Port GPIOF
#define PMOD_UART7_RTS_Pin GPIO_PIN_8
#define PMOD_UART7_RTS_GPIO_Port GPIOF
#define LCD_BL_Pin GPIO_PIN_11
#define LCD_BL_GPIO_Port GPIOH
#define USB_OTGHS_OVCR_INT_Pin GPIO_PIN_10
#define USB_OTGHS_OVCR_INT_GPIO_Port GPIOH
#define LCD_PSRAM_D1_Pin GPIO_PIN_15

View File

@ -48,9 +48,9 @@
#define TOUCH_EVENT_JUST_PRESSED 0
// calibrate touch display
#define CAL_TOUCH_TOP_LEFT_X 0
#define CAL_TOUCH_TOP_LEFT_Y 0
#define CAL_TOUCH_BOT_RIGHT_X 200
#define CAL_TOUCH_TOP_LEFT_X 235
#define CAL_TOUCH_TOP_LEFT_Y 76
#define CAL_TOUCH_BOT_RIGHT_X 0
#define CAL_TOUCH_BOT_RIGHT_Y 200
/* USER CODE END PD */
@ -110,11 +110,11 @@ static inline int32_t clamp_i16(int32_t value, int32_t min, int32_t max)
void drawButton(bool isPressed){
if (isPressed){
Display_FillRect( 75, 130, 100, 100, LCD_COLOR_RED );
Display_DrawRect( 74, 129, 102, 102, LCD_COLOR_RED );
//Display_DrawRect( 74, 129, 102, 102, LCD_COLOR_RED );
}
else {
Display_FillRect( 75, 130, 100, 100, LCD_COLOR_BLACK );
Display_DrawRect( 74, 129, 102, 102, LCD_COLOR_RED );
Display_DrawRect( 75, 130, 100, 100, LCD_COLOR_RED );
}
}
@ -183,7 +183,7 @@ int main(void)
Display_Printf( 0, 10,
LCD_COLOR_WHITE, LCD_COLOR_BLACK,
&FontBig,
"Zahl %d", i
"Zahl %03d", i
);
if (i == 0) i = 100;
else i--;
@ -195,7 +195,8 @@ int main(void)
if (time_msPassedSince(timestamp_lastTouchRead) >= 20) { // run this block every 20ms
timestamp_lastTouchRead = HAL_GetTick();
// read touch register
HAL_I2C_Mem_Read(I2C3, 112, 3, I2C_MEMADD_SIZE_8BIT, DataRx, 4, 1000);
HAL_I2C_Mem_Read(&hi2c3, 112, 3, I2C_MEMADD_SIZE_8BIT, DataRx, 4, 1000);
//printf("read touch mem byte1=%d, byte2=%d\n\r", DataRx[0], DataRx[1]);
// interpret received data
EventflagLast = Eventflag;
@ -208,8 +209,9 @@ int main(void)
Display_Printf( 0, 30,
LCD_COLOR_WHITE, LCD_COLOR_BLACK,
&FontBig,
"x=%d y=%d", xRaw, yRaw
"x=%04d y=%04d", xRaw, yRaw
);
printf("touch: x=%d y=%d\n\r", xRaw, yRaw);
//scale to display size
xTouch = 239 * ((int32_t)xRaw - CAL_TOUCH_TOP_LEFT_X) / ((int32_t)CAL_TOUCH_BOT_RIGHT_X - CAL_TOUCH_TOP_LEFT_X);
@ -484,7 +486,8 @@ static void MX_GPIO_Init(void)
HAL_GPIO_WritePin(GPIOA, USB_OTG_FS_ID_Pin|GPIO_PIN_5|SYS_LD_USER1_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOH, PMOD_GPIO_1_Pin|ARD_D4_GPIO_Pin|USB_OTGHS_PPWR_EN_Pin|LCD_RST_Pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOH, PMOD_GPIO_1_Pin|ARD_D4_GPIO_Pin|USB_OTGHS_PPWR_EN_Pin|GPIO_PIN_11
|LCD_RST_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOB, USB_OTG_HS_ID_Pin|SYS_LD_USER2_Pin, GPIO_PIN_RESET);
@ -633,9 +636,9 @@ static void MX_GPIO_Init(void)
HAL_GPIO_Init(UART_RXD_WIFI_TX_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pins : PMOD_SEL_0_Pin PMOD_GPIO_1_Pin ARD_D4_GPIO_Pin USB_OTGHS_PPWR_EN_Pin
CTP_RST_Pin LCD_RST_Pin */
PH11 CTP_RST_Pin LCD_RST_Pin */
GPIO_InitStruct.Pin = PMOD_SEL_0_Pin|PMOD_GPIO_1_Pin|ARD_D4_GPIO_Pin|USB_OTGHS_PPWR_EN_Pin
|CTP_RST_Pin|LCD_RST_Pin;
|GPIO_PIN_11|CTP_RST_Pin|LCD_RST_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
@ -698,14 +701,6 @@ static void MX_GPIO_Init(void)
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(ARD_A3_ADC3_IN8_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pin : LCD_BL_Pin */
GPIO_InitStruct.Pin = LCD_BL_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF2_TIM5;
HAL_GPIO_Init(LCD_BL_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pin : USB_OTGHS_OVCR_INT_Pin */
GPIO_InitStruct.Pin = USB_OTGHS_OVCR_INT_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;

View File

@ -606,10 +606,8 @@ PH10.GPIOParameters=GPIO_Label
PH10.GPIO_Label=USB_OTGHS_OVCR_INT
PH10.Locked=true
PH10.Signal=GPIO_Input
PH11.GPIOParameters=GPIO_Label
PH11.GPIO_Label=LCD_BL [STLD40DPUR_EN]
PH11.Locked=true
PH11.Signal=S_TIM5_CH2
PH11.Signal=GPIO_Output
PH12.GPIOParameters=GPIO_Label
PH12.GPIO_Label=USB_OTGHS_PPWR_EN
PH12.Locked=true
@ -732,7 +730,7 @@ ProjectManager.ToolChainLocation=
ProjectManager.UAScriptAfterPath=
ProjectManager.UAScriptBeforePath=
ProjectManager.UnderRoot=true
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_USART6_UART_Init-USART6-false-HAL-true,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_USART6_UART_Init-USART6-false-HAL-true,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_I2C3_Init-I2C3-false-HAL-true,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true
RCC.AHBFreq_Value=216000000
RCC.APB1CLKDivider=RCC_HCLK_DIV4
RCC.APB1Freq_Value=54000000
@ -895,8 +893,6 @@ SH.S_TIM2_CH2.0=TIM2_CH2
SH.S_TIM2_CH2.ConfNb=1
SH.S_TIM3_CH3.0=TIM3_CH3
SH.S_TIM3_CH3.ConfNb=1
SH.S_TIM5_CH2.0=TIM5_CH2
SH.S_TIM5_CH2.ConfNb=1
SH.S_TIM9_CH1.0=TIM9_CH1
SH.S_TIM9_CH1.ConfNb=1
SH.S_TIM9_CH2.0=TIM9_CH2

File diff suppressed because one or more lines are too long

View File

@ -197,8 +197,6 @@ void Error_Handler(void);
#define PMOD_UART7_CTS_GPIO_Port GPIOF
#define PMOD_UART7_RTS_Pin GPIO_PIN_8
#define PMOD_UART7_RTS_GPIO_Port GPIOF
#define LCD_BL_Pin GPIO_PIN_11
#define LCD_BL_GPIO_Port GPIOH
#define USB_OTGHS_OVCR_INT_Pin GPIO_PIN_10
#define USB_OTGHS_OVCR_INT_GPIO_Port GPIOH
#define LCD_PSRAM_D1_Pin GPIO_PIN_15

View File

@ -25,6 +25,7 @@
#include "display.h"
#include "fonts.h"
#include <stdbool.h>
#include <stdio.h>
/* USER CODE END Includes */
@ -133,6 +134,17 @@ void drawButton(bool isPressed){
//==========================
//==== Task definitions ====
//==========================
void Task0_PrintStats(void *){
while (1)
{
// print processor statistics
Usage_PrintStats();
vTaskDelay(pdMS_TO_TICKS(6000));
} //end while(1)
}
void Task1_blinkGreenLed(void *){
while(1){
HAL_GPIO_TogglePin(LED_GREEN_GPIO_PORT, LED_GREEN_GPIO_PIN);
@ -150,21 +162,40 @@ void Task2_blinkBlueLed(void *){
}
//#define TEST_WITH_HAL_DELAY_NO_SMPHR
SemaphoreHandle_t Mutex_redLed = NULL;
void Task3_4_blinkRedLed(void * param_uint32_blinkDelay){
uint32_t blinkDelayMs = (uint32_t)param_uint32_blinkDelay;
uint32_t *paramPtr = (uint32_t*)param_uint32_blinkDelay;
uint32_t blinkDelayMs = *paramPtr;
printf("starting task to blink red led with delay %d...\n\r", blinkDelayMs);
while(1){
#ifndef TEST_WITH_HAL_DELAY_NO_SMPHR
xSemaphoreTake(Mutex_redLed, portMAX_DELAY);
#endif
//printf("take semaphore task with delay %d\n\r", blinkDelayMs);
for (int i=0; i<2; i++){
HAL_GPIO_WritePin(LED_RED_GPIO_PORT, LED_RED_GPIO_PIN, GPIO_PIN_SET);
//printf("led turned on, delaying %d\n\r", blinkDelayMs);
#ifdef TEST_WITH_HAL_DELAY_NO_SMPHR
HAL_Delay(blinkDelayMs);
#else
vTaskDelay(pdMS_TO_TICKS(blinkDelayMs));
#endif
HAL_GPIO_WritePin(LED_RED_GPIO_PORT, LED_RED_GPIO_PIN, GPIO_PIN_RESET);
//printf("led turned off, delaying %d\n\r", blinkDelayMs);
#ifdef TEST_WITH_HAL_DELAY_NO_SMPHR
HAL_Delay(blinkDelayMs);
#else
vTaskDelay(pdMS_TO_TICKS(blinkDelayMs));
#endif
}
xSemaphoreGive(Mutex_redLed);
#ifndef TEST_WITH_HAL_DELAY_NO_SMPHR
vTaskDelay(pdMS_TO_TICKS(75));
#endif
}
}
@ -199,10 +230,11 @@ void Task6_countButtonPresses(void *){
while(1){
if (xSemaphoreTake(Semphr_buttonPressEvent, pdMS_TO_TICKS(1000))){
y++;
printf("Task6: received Semaphore, current count = %d", y);
printf("Task6: pre print asdasdasd\n\r");
printf("Task6: received Semaphore, current count = %d\n\r", y);
vTaskDelay(pdMS_TO_TICKS(5));
}
printf("### Task 6 Loop ###");
printf("### Task 6 Loop ###\n\r");
}
}
@ -211,7 +243,7 @@ void Task7_receiveQueueEvents(void *){
bool receivedEvent;
while(1){
if (xQueueReceive(Queue_buttonEvents, &receivedEvent, portMAX_DELAY)){
printf("Task 7: %s", receivedEvent ? "pressed" : "released");
printf("Task 7: %s\n\r", receivedEvent ? "pressed" : "released");
}
vTaskDelay(pdMS_TO_TICKS(10));
}
@ -295,21 +327,6 @@ int main(void)
osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 256);
defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL);
xTaskCreate(Task1_blinkGreenLed, "Task1_green-led", 256, NULL, 0, NULL);
xTaskCreate(Task2_blinkBlueLed, "Task2_blue-led", 256, NULL, 0, NULL);
uint32_t delay1 = 150;
xTaskCreate(Task3_4_blinkRedLed, "Task3_red-led-150", 256, (void *)&delay1, 0, NULL);
uint32_t delay2 = 600;
xTaskCreate(Task3_4_blinkRedLed, "Task4_red-led-600", 256, (void *)&delay2, 0, NULL);
xTaskCreate(Task5_readButton, "Task5_read-button", 256, NULL, 0, NULL);
xTaskCreate(Task6_countButtonPresses, "Task6_countButtonPresses", 256, NULL, 0, NULL);
xTaskCreate(Task7_receiveQueueEvents, "Task7_receiveQueueEvents", 256, NULL, 0, NULL);
/* USER CODE BEGIN RTOS_THREADS */
/* add threads, ... */
/* USER CODE END RTOS_THREADS */
@ -321,10 +338,14 @@ int main(void)
/* Infinite loop */
/* USER CODE BEGIN WHILE */
// apparently this is not run!
printf("entering main while(1)...\n\r");
while (1)
{
// print processor statistics
Usage_PrintStats();
printf("main loop...\n\r");
//Usage_PrintStats();
vTaskDelay(pdMS_TO_TICKS(1000));
/* USER CODE END WHILE */
@ -571,7 +592,8 @@ static void MX_GPIO_Init(void)
HAL_GPIO_WritePin(GPIOA, USB_OTG_FS_ID_Pin|GPIO_PIN_5|SYS_LD_USER1_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOH, PMOD_GPIO_1_Pin|ARD_D4_GPIO_Pin|USB_OTGHS_PPWR_EN_Pin|LCD_RST_Pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOH, PMOD_GPIO_1_Pin|ARD_D4_GPIO_Pin|USB_OTGHS_PPWR_EN_Pin|GPIO_PIN_11
|LCD_RST_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOB, USB_OTG_HS_ID_Pin|SYS_LD_USER2_Pin, GPIO_PIN_RESET);
@ -720,9 +742,9 @@ static void MX_GPIO_Init(void)
HAL_GPIO_Init(UART_RXD_WIFI_TX_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pins : PMOD_SEL_0_Pin PMOD_GPIO_1_Pin ARD_D4_GPIO_Pin USB_OTGHS_PPWR_EN_Pin
CTP_RST_Pin LCD_RST_Pin */
PH11 CTP_RST_Pin LCD_RST_Pin */
GPIO_InitStruct.Pin = PMOD_SEL_0_Pin|PMOD_GPIO_1_Pin|ARD_D4_GPIO_Pin|USB_OTGHS_PPWR_EN_Pin
|CTP_RST_Pin|LCD_RST_Pin;
|GPIO_PIN_11|CTP_RST_Pin|LCD_RST_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
@ -785,14 +807,6 @@ static void MX_GPIO_Init(void)
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(ARD_A3_ADC3_IN8_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pin : LCD_BL_Pin */
GPIO_InitStruct.Pin = LCD_BL_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF2_TIM5;
HAL_GPIO_Init(LCD_BL_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pin : USB_OTGHS_OVCR_INT_Pin */
GPIO_InitStruct.Pin = USB_OTGHS_OVCR_INT_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;

View File

@ -129,7 +129,7 @@ void Usage_PrintStats( void )
TotalTimeDiff /= 100UL; // For percentage calculations.
if( TaskStatusTime > 0 && Usage_TaskStatusTimePrev != 0 && !Ignore ) {
printf("CPU usage without idle: %d%%, free RTOS heap: %d, SOL: %d\n", (int) (NonIdleCounter/TotalTimeDiff), xPortGetFreeHeapSize(), (int) Usage_SOL );
printf("CPU usage without idle: %d%%, free RTOS heap: %d, SOL: %d\n\r", (int) (NonIdleCounter/TotalTimeDiff), xPortGetFreeHeapSize(), (int) Usage_SOL );
Usage_SOL++;
for( x = 0; x < TaskCnt; x++ ) {
TS = Usage_TaskStatusArraySort[ x ];
@ -147,7 +147,7 @@ void Usage_PrintStats( void )
}
}
printf(" %2d: %-16s: CPU: %3u%%, free stack: %3u\n",
printf(" %2d: %-16s: CPU: %3u%%, free stack: %3u\n\r",
(int) TS->xTaskNumber, TS->pcTaskName, (int) Usage,
TS->usStackHighWaterMark );
}

View File

@ -617,10 +617,8 @@ PH10.GPIOParameters=GPIO_Label
PH10.GPIO_Label=USB_OTGHS_OVCR_INT
PH10.Locked=true
PH10.Signal=GPIO_Input
PH11.GPIOParameters=GPIO_Label
PH11.GPIO_Label=LCD_BL [STLD40DPUR_EN]
PH11.Locked=true
PH11.Signal=S_TIM5_CH2
PH11.Signal=GPIO_Output
PH12.GPIOParameters=GPIO_Label
PH12.GPIO_Label=USB_OTGHS_PPWR_EN
PH12.Locked=true
@ -906,8 +904,6 @@ SH.S_TIM2_CH2.0=TIM2_CH2
SH.S_TIM2_CH2.ConfNb=1
SH.S_TIM3_CH3.0=TIM3_CH3
SH.S_TIM3_CH3.ConfNb=1
SH.S_TIM5_CH2.0=TIM5_CH2
SH.S_TIM5_CH2.ConfNb=1
SH.S_TIM9_CH1.0=TIM9_CH1
SH.S_TIM9_CH1.ConfNb=1
SH.S_TIM9_CH2.0=TIM9_CH2