Ignore:
Timestamp:
Jan 22, 2025, 11:40:26 AM (5 days ago)
Author:
Zed
Message:

FAN PWM control and TACHO signal measuring are working.

Location:
ctrl/firmware/Main/CubeMX/Core
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • ctrl/firmware/Main/CubeMX/Core/Inc/main.h

    r62 r66  
    8282#define GSM_STATUS_Pin GPIO_PIN_13
    8383#define GSM_STATUS_GPIO_Port GPIOD
     84#define FAN_TACHO_Pin GPIO_PIN_6
     85#define FAN_TACHO_GPIO_Port GPIOC
     86#define FAN_PWM_Pin GPIO_PIN_7
     87#define FAN_PWM_GPIO_Port GPIOC
    8488#define SD_DETECT_Pin GPIO_PIN_8
    8589#define SD_DETECT_GPIO_Port GPIOA
  • ctrl/firmware/Main/CubeMX/Core/Inc/stm32h7xx_it.h

    r64 r66  
    5656void DMA1_Stream1_IRQHandler(void);
    5757void DMA1_Stream2_IRQHandler(void);
     58void TIM3_IRQHandler(void);
    5859void USART3_IRQHandler(void);
     60void TIM8_CC_IRQHandler(void);
    5961void SDMMC1_IRQHandler(void);
    6062void TIM7_IRQHandler(void);
  • ctrl/firmware/Main/CubeMX/Core/Src/app_threadx.c

    r65 r66  
    3333#include "gsm_thread.h"
    3434#include "gsm_rx_thread.h"
     35#include "fan_thread.h"
    3536
    3637/* USER CODE END Includes */
     
    4748#define GSM_THREAD_STACK_SIZE_BYTES                     (1024U)
    4849#define GSM_RX_THREAD_STACK_SIZE_BYTES          (1024U)
     50#define FAN_THREAD_STACK_SIZE_BYTES                     (512U)
    4951
    5052/* USER CODE END PD */
     
    6163TX_THREAD gsm_thread_ptr;
    6264TX_THREAD gsm_rx_thread_ptr;
     65TX_THREAD fan_thread_ptr;
    6366
    6467/* USER CODE END PV */
     
    8386  VOID *gsm_thread_pointer;
    8487  VOID *gsm_rx_thread_pointer;
     88  VOID *fan_thread_pointer;
    8589
    8690  /* USER CODE END App_ThreadX_MEM_POOL */
     
    97101
    98102
    99   // Allocate the stack for gsm thread
     103  // Allocate the stack for gsm send thread
    100104  ret = tx_byte_allocate(byte_pool, &gsm_thread_pointer, GSM_THREAD_STACK_SIZE_BYTES, TX_NO_WAIT);
    101105  if (ret != TX_SUCCESS) { printf("Cannot allocate bytes of memory!\n"); return ret; }
     
    105109  if (ret != TX_SUCCESS) { printf("Cannot create %s!\n", gsm_thread_name); return ret; }
    106110
    107   // Allocate the stack for gsm send thread
     111  // Allocate the stack for gsm rx thread
    108112  ret = tx_byte_allocate(byte_pool, &gsm_rx_thread_pointer, GSM_RX_THREAD_STACK_SIZE_BYTES, TX_NO_WAIT);
    109113  if (ret != TX_SUCCESS) { printf("Cannot allocate bytes of memory!\n"); return ret; }
    110114
    111115  char* gsm_rx_thread_name = "GSM RX Thread";
    112   ret = tx_thread_create(&gsm_rx_thread_ptr, gsm_rx_thread_name, gsmRxThread, 0x0001,   gsm_rx_thread_pointer, GSM_RX_THREAD_STACK_SIZE_BYTES, TX_MAX_PRIORITIES-1, TX_MAX_PRIORITIES-1, TX_NO_TIME_SLICE, TX_AUTO_START);
     116  ret = tx_thread_create(&gsm_rx_thread_ptr, gsm_rx_thread_name, gsmRxThread, 0x0001, gsm_rx_thread_pointer, GSM_RX_THREAD_STACK_SIZE_BYTES, TX_MAX_PRIORITIES-1, TX_MAX_PRIORITIES-1, TX_NO_TIME_SLICE, TX_AUTO_START);
    113117  if (ret != TX_SUCCESS) { printf("Cannot create %s!\n", gsm_rx_thread_name); return ret; }
    114118
     119  // Allocate the stack for fan control thread
     120  ret = tx_byte_allocate(byte_pool, &fan_thread_pointer, FAN_THREAD_STACK_SIZE_BYTES, TX_NO_WAIT);
     121  if (ret != TX_SUCCESS) { printf("Cannot allocate bytes of memory!\n"); return ret; }
     122
     123  char* fan_thread_name = "FAN Thread";
     124  ret = tx_thread_create(&fan_thread_ptr, fan_thread_name, fanThread, 0x0001, fan_thread_pointer, FAN_THREAD_STACK_SIZE_BYTES, TX_MAX_PRIORITIES-1, TX_MAX_PRIORITIES-1, TX_NO_TIME_SLICE, TX_AUTO_START);
     125  if (ret != TX_SUCCESS) { printf("Cannot create %s!\n", fan_thread_name); return ret; }
    115126
    116127
  • ctrl/firmware/Main/CubeMX/Core/Src/gpio.c

    r63 r66  
    8888
    8989  /*Configure GPIO pins : PC13 PC0 PC1 PC2
    90                            PC3 PC4 PC5 PC6
    91                            PC7 */
     90                           PC3 PC4 PC5 */
    9291  GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2
    93                           |GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6
    94                           |GPIO_PIN_7;
     92                          |GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5;
    9593  GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
    9694  GPIO_InitStruct.Pull = GPIO_NOPULL;
  • ctrl/firmware/Main/CubeMX/Core/Src/main.c

    r61 r66  
    2525#include "sdmmc.h"
    2626#include "spi.h"
     27#include "tim.h"
    2728#include "usart.h"
    2829#include "gpio.h"
     
    120121  MX_SDMMC1_SD_Init();
    121122  MX_USART3_UART_Init();
     123  MX_TIM3_Init();
     124  MX_TIM8_Init();
    122125  /* USER CODE BEGIN 2 */
    123126#undef MX_SDMMC1_SD_Init
  • ctrl/firmware/Main/CubeMX/Core/Src/stm32h7xx_it.c

    r65 r66  
    2525
    2626#include "gsm_rx_thread.h"
     27#include "fan_thread.h"
    2728
    2829/* USER CODE END Includes */
     
    6263extern DMA_HandleTypeDef hdma_spi4_tx;
    6364extern SPI_HandleTypeDef hspi4;
     65extern TIM_HandleTypeDef htim3;
     66extern TIM_HandleTypeDef htim8;
    6467extern DMA_HandleTypeDef hdma_usart3_rx;
    6568extern DMA_HandleTypeDef hdma_usart3_tx;
     
    212215
    213216/**
     217  * @brief This function handles TIM3 global interrupt.
     218  */
     219void TIM3_IRQHandler(void)
     220{
     221  /* USER CODE BEGIN TIM3_IRQn 0 */
     222
     223  /* USER CODE END TIM3_IRQn 0 */
     224  HAL_TIM_IRQHandler(&htim3);
     225  /* USER CODE BEGIN TIM3_IRQn 1 */
     226
     227  /* USER CODE END TIM3_IRQn 1 */
     228}
     229
     230/**
    214231  * @brief This function handles USART3 global interrupt.
    215232  */
     
    226243
    227244/**
     245  * @brief This function handles TIM8 capture compare interrupt.
     246  */
     247void TIM8_CC_IRQHandler(void)
     248{
     249  /* USER CODE BEGIN TIM8_CC_IRQn 0 */
     250
     251  /* USER CODE END TIM8_CC_IRQn 0 */
     252  HAL_TIM_IRQHandler(&htim8);
     253  /* USER CODE BEGIN TIM8_CC_IRQn 1 */
     254
     255  /* USER CODE END TIM8_CC_IRQn 1 */
     256}
     257
     258/**
    228259  * @brief This function handles SDMMC1 global interrupt.
    229260  */
     
    278309//------------------------------------------------------------------------------
    279310
    280 /*void HAL_UART_RxCpltCallback(UART_HandleTypeDef * huart)
    281 {
    282         //if (huart->Instance == USART3) gsmUnitSentData();
    283 }*/
     311void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim)
     312{
     313        if (htim->Instance == TIM8) pulseMeasured();
     314}
    284315
    285316//------------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.