This commit is contained in:
王绪洁 2025-03-19 11:06:37 +08:00
parent 8a52221917
commit 4f07311ac3
11 changed files with 4745 additions and 4713 deletions

View File

@ -6,6 +6,7 @@
"user_fmsc.h": "c", "user_fmsc.h": "c",
"fsmc.h": "c", "fsmc.h": "c",
"ch438q.h": "c", "ch438q.h": "c",
"ht1200m.h": "c" "ht1200m.h": "c",
"main.h": "c"
} }
} }

View File

@ -64,11 +64,15 @@ void Error_Handler(void);
#define HART_CLK_GPIO_Port GPIOA #define HART_CLK_GPIO_Port GPIOA
#define HART_ALL_RST_Pin GPIO_PIN_4 #define HART_ALL_RST_Pin GPIO_PIN_4
#define HART_ALL_RST_GPIO_Port GPIOA #define HART_ALL_RST_GPIO_Port GPIOA
#define CH438_1_AMOD_Pin GPIO_PIN_14
#define CH438_1_AMOD_GPIO_Port GPIOF
#define HART1_RTS_Pin GPIO_PIN_4 #define HART1_RTS_Pin GPIO_PIN_4
#define HART1_RTS_GPIO_Port GPIOG #define HART1_RTS_GPIO_Port GPIOG
#define CH438_INT_Pin GPIO_PIN_2 #define CH438_INT_Pin GPIO_PIN_2
#define CH438_INT_GPIO_Port GPIOD #define CH438_INT_GPIO_Port GPIOD
#define CH438_INT_EXTI_IRQn EXTI2_IRQn #define CH438_INT_EXTI_IRQn EXTI2_IRQn
#define CH438_1_RST_Pin GPIO_PIN_3
#define CH438_1_RST_GPIO_Port GPIOD
#define DAC1_CS_Pin GPIO_PIN_6 #define DAC1_CS_Pin GPIO_PIN_6
#define DAC1_CS_GPIO_Port GPIOB #define DAC1_CS_GPIO_Port GPIOB

View File

@ -57,15 +57,15 @@ osThreadId ch438_taskHandle;
/* USER CODE END FunctionPrototypes */ /* USER CODE END FunctionPrototypes */
void start_lwip_task(void const *argument); void start_lwip_task(void const * argument);
void start_dac_task(void const *argument); void start_dac_task(void const * argument);
void start_ch438_task(void const *argument); void start_ch438_task(void const * argument);
extern void MX_LWIP_Init(void); extern void MX_LWIP_Init(void);
void MX_FREERTOS_Init(void); /* (MISRA C 2004 rule 8.1) */ void MX_FREERTOS_Init(void); /* (MISRA C 2004 rule 8.1) */
/* GetIdleTaskMemory prototype (linked to static allocation support) */ /* GetIdleTaskMemory prototype (linked to static allocation support) */
void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize); void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize );
/* USER CODE BEGIN GET_IDLE_TASK_MEMORY */ /* USER CODE BEGIN GET_IDLE_TASK_MEMORY */
static StaticTask_t xIdleTaskTCBBuffer; static StaticTask_t xIdleTaskTCBBuffer;
@ -81,12 +81,11 @@ void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer, StackTyp
/* USER CODE END GET_IDLE_TASK_MEMORY */ /* USER CODE END GET_IDLE_TASK_MEMORY */
/** /**
* @brief FreeRTOS initialization * @brief FreeRTOS initialization
* @param None * @param None
* @retval None * @retval None
*/ */
void MX_FREERTOS_Init(void) void MX_FREERTOS_Init(void) {
{
/* USER CODE BEGIN Init */ /* USER CODE BEGIN Init */
/* USER CODE END Init */ /* USER CODE END Init */
@ -123,6 +122,7 @@ void MX_FREERTOS_Init(void)
/* USER CODE BEGIN RTOS_THREADS */ /* USER CODE BEGIN RTOS_THREADS */
/* add threads, ... */ /* add threads, ... */
/* USER CODE END RTOS_THREADS */ /* USER CODE END RTOS_THREADS */
} }
/* USER CODE BEGIN Header_start_lwip_task */ /* USER CODE BEGIN Header_start_lwip_task */
@ -132,7 +132,7 @@ void MX_FREERTOS_Init(void)
* @retval None * @retval None
*/ */
/* USER CODE END Header_start_lwip_task */ /* USER CODE END Header_start_lwip_task */
void start_lwip_task(void const *argument) void start_lwip_task(void const * argument)
{ {
/* init code for LWIP */ /* init code for LWIP */
MX_LWIP_Init(); MX_LWIP_Init();
@ -152,7 +152,7 @@ void start_lwip_task(void const *argument)
* @retval None * @retval None
*/ */
/* USER CODE END Header_start_dac_task */ /* USER CODE END Header_start_dac_task */
void start_dac_task(void const *argument) void start_dac_task(void const * argument)
{ {
/* USER CODE BEGIN start_dac_task */ /* USER CODE BEGIN start_dac_task */
/* Infinite loop */ /* Infinite loop */
@ -172,16 +172,16 @@ void start_dac_task(void const *argument)
* @retval None * @retval None
*/ */
/* USER CODE END Header_start_ch438_task */ /* USER CODE END Header_start_ch438_task */
void start_ch438_task(void const *argument) void start_ch438_task(void const * argument)
{ {
/* USER CODE BEGIN start_ch438_task */ /* USER CODE BEGIN start_ch438_task */
/* Infinite loop */ /* Infinite loop */
ch438_init(); ch438_init();
for (;;) for (;;)
{ {
uint8_t data[5] = {0xFF, 0x34, 0x56, 0x78, 0x9a}; uint8_t data[9] = {0xFF, 0xff, 0xff, 0xff, 0xff, 0x34, 0x56, 0x78, 0x9a};
ch438_test(); ch438_test();
ch438_send_data(CH438_UART0, data, 5); ch438_send_data(CH438_UART0, data, 9);
osDelay(1000); osDelay(1000);
} }
/* USER CODE END start_ch438_task */ /* USER CODE END start_ch438_task */

View File

@ -42,7 +42,7 @@ void MX_FSMC_Init(void)
/* USER CODE END FSMC_Init 1 */ /* USER CODE END FSMC_Init 1 */
/** Perform the SRAM1 memory initialization sequence /** Perform the SRAM1 memory initialization sequence
*/ */
hsram1.Instance = FSMC_NORSRAM_DEVICE; hsram1.Instance = FSMC_NORSRAM_DEVICE;
hsram1.Extended = FSMC_NORSRAM_EXTENDED_DEVICE; hsram1.Extended = FSMC_NORSRAM_EXTENDED_DEVICE;
/* hsram1.Init */ /* hsram1.Init */
@ -61,7 +61,7 @@ void MX_FSMC_Init(void)
hsram1.Init.WriteBurst = FSMC_WRITE_BURST_DISABLE; hsram1.Init.WriteBurst = FSMC_WRITE_BURST_DISABLE;
hsram1.Init.PageSize = FSMC_PAGE_SIZE_NONE; hsram1.Init.PageSize = FSMC_PAGE_SIZE_NONE;
/* Timing */ /* Timing */
Timing.AddressSetupTime = 15; Timing.AddressSetupTime = 10;
Timing.AddressHoldTime = 15; Timing.AddressHoldTime = 15;
Timing.DataSetupTime = 10; Timing.DataSetupTime = 10;
Timing.BusTurnAroundDuration = 15; Timing.BusTurnAroundDuration = 15;
@ -72,11 +72,11 @@ void MX_FSMC_Init(void)
if (HAL_SRAM_Init(&hsram1, &Timing, NULL) != HAL_OK) if (HAL_SRAM_Init(&hsram1, &Timing, NULL) != HAL_OK)
{ {
Error_Handler(); Error_Handler( );
} }
/** Perform the SRAM2 memory initialization sequence /** Perform the SRAM2 memory initialization sequence
*/ */
hsram2.Instance = FSMC_NORSRAM_DEVICE; hsram2.Instance = FSMC_NORSRAM_DEVICE;
hsram2.Extended = FSMC_NORSRAM_EXTENDED_DEVICE; hsram2.Extended = FSMC_NORSRAM_EXTENDED_DEVICE;
/* hsram2.Init */ /* hsram2.Init */
@ -106,7 +106,7 @@ void MX_FSMC_Init(void)
if (HAL_SRAM_Init(&hsram2, &Timing, NULL) != HAL_OK) if (HAL_SRAM_Init(&hsram2, &Timing, NULL) != HAL_OK)
{ {
Error_Handler(); Error_Handler( );
} }
/* USER CODE BEGIN FSMC_Init 2 */ /* USER CODE BEGIN FSMC_Init 2 */
@ -116,14 +116,12 @@ void MX_FSMC_Init(void)
static uint32_t FSMC_Initialized = 0; static uint32_t FSMC_Initialized = 0;
static void HAL_FSMC_MspInit(void) static void HAL_FSMC_MspInit(void){
{
/* USER CODE BEGIN FSMC_MspInit 0 */ /* USER CODE BEGIN FSMC_MspInit 0 */
/* USER CODE END FSMC_MspInit 0 */ /* USER CODE END FSMC_MspInit 0 */
GPIO_InitTypeDef GPIO_InitStruct = {0}; GPIO_InitTypeDef GPIO_InitStruct = {0};
if (FSMC_Initialized) if (FSMC_Initialized) {
{
return; return;
} }
FSMC_Initialized = 1; FSMC_Initialized = 1;
@ -153,7 +151,8 @@ static void HAL_FSMC_MspInit(void)
PG9 ------> FSMC_NE2 PG9 ------> FSMC_NE2
*/ */
/* GPIO_InitStruct */ /* GPIO_InitStruct */
GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_12; GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3
|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_12;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
@ -162,7 +161,7 @@ static void HAL_FSMC_MspInit(void)
HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
/* GPIO_InitStruct */ /* GPIO_InitStruct */
GPIO_InitStruct.Pin = GPIO_PIN_7 | GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10; GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
@ -171,7 +170,8 @@ static void HAL_FSMC_MspInit(void)
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
/* GPIO_InitStruct */ /* GPIO_InitStruct */
GPIO_InitStruct.Pin = GPIO_PIN_14 | GPIO_PIN_15 | GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_7; GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1
|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_7;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
@ -193,8 +193,7 @@ static void HAL_FSMC_MspInit(void)
/* USER CODE END FSMC_MspInit 1 */ /* USER CODE END FSMC_MspInit 1 */
} }
void HAL_SRAM_MspInit(SRAM_HandleTypeDef *sramHandle) void HAL_SRAM_MspInit(SRAM_HandleTypeDef* sramHandle){
{
/* USER CODE BEGIN SRAM_MspInit 0 */ /* USER CODE BEGIN SRAM_MspInit 0 */
/* USER CODE END SRAM_MspInit 0 */ /* USER CODE END SRAM_MspInit 0 */
@ -206,13 +205,11 @@ void HAL_SRAM_MspInit(SRAM_HandleTypeDef *sramHandle)
static uint32_t FSMC_DeInitialized = 0; static uint32_t FSMC_DeInitialized = 0;
static void HAL_FSMC_MspDeInit(void) static void HAL_FSMC_MspDeInit(void){
{
/* USER CODE BEGIN FSMC_MspDeInit 0 */ /* USER CODE BEGIN FSMC_MspDeInit 0 */
/* USER CODE END FSMC_MspDeInit 0 */ /* USER CODE END FSMC_MspDeInit 0 */
if (FSMC_DeInitialized) if (FSMC_DeInitialized) {
{
return; return;
} }
FSMC_DeInitialized = 1; FSMC_DeInitialized = 1;
@ -241,11 +238,13 @@ static void HAL_FSMC_MspDeInit(void)
PG9 ------> FSMC_NE2 PG9 ------> FSMC_NE2
*/ */
HAL_GPIO_DeInit(GPIOF, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_12); HAL_GPIO_DeInit(GPIOF, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3
|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_12);
HAL_GPIO_DeInit(GPIOE, GPIO_PIN_7 | GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10); HAL_GPIO_DeInit(GPIOE, GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10);
HAL_GPIO_DeInit(GPIOD, GPIO_PIN_14 | GPIO_PIN_15 | GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_7); HAL_GPIO_DeInit(GPIOD, GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1
|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_7);
HAL_GPIO_DeInit(GPIOG, GPIO_PIN_9); HAL_GPIO_DeInit(GPIOG, GPIO_PIN_9);
@ -254,8 +253,7 @@ static void HAL_FSMC_MspDeInit(void)
/* USER CODE END FSMC_MspDeInit 1 */ /* USER CODE END FSMC_MspDeInit 1 */
} }
void HAL_SRAM_MspDeInit(SRAM_HandleTypeDef *sramHandle) void HAL_SRAM_MspDeInit(SRAM_HandleTypeDef* sramHandle){
{
/* USER CODE BEGIN SRAM_MspDeInit 0 */ /* USER CODE BEGIN SRAM_MspDeInit 0 */
/* USER CODE END SRAM_MspDeInit 0 */ /* USER CODE END SRAM_MspDeInit 0 */
@ -265,9 +263,9 @@ void HAL_SRAM_MspDeInit(SRAM_HandleTypeDef *sramHandle)
/* USER CODE END SRAM_MspDeInit 1 */ /* USER CODE END SRAM_MspDeInit 1 */
} }
/** /**
* @} * @}
*/ */
/** /**
* @} * @}
*/ */

View File

@ -60,9 +60,15 @@ void MX_GPIO_Init(void)
/*Configure GPIO pin Output Level */ /*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(HART_ALL_RST_GPIO_Port, HART_ALL_RST_Pin, GPIO_PIN_SET); HAL_GPIO_WritePin(HART_ALL_RST_GPIO_Port, HART_ALL_RST_Pin, GPIO_PIN_SET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(CH438_1_AMOD_GPIO_Port, CH438_1_AMOD_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */ /*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(HART1_RTS_GPIO_Port, HART1_RTS_Pin, GPIO_PIN_SET); HAL_GPIO_WritePin(HART1_RTS_GPIO_Port, HART1_RTS_Pin, GPIO_PIN_SET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(CH438_1_RST_GPIO_Port, CH438_1_RST_Pin, GPIO_PIN_SET);
/*Configure GPIO pin Output Level */ /*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(DAC1_CS_GPIO_Port, DAC1_CS_Pin, GPIO_PIN_SET); HAL_GPIO_WritePin(DAC1_CS_GPIO_Port, DAC1_CS_Pin, GPIO_PIN_SET);
@ -80,6 +86,13 @@ void MX_GPIO_Init(void)
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
HAL_GPIO_Init(HART_ALL_RST_GPIO_Port, &GPIO_InitStruct); HAL_GPIO_Init(HART_ALL_RST_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pin : PtPin */
GPIO_InitStruct.Pin = CH438_1_AMOD_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
HAL_GPIO_Init(CH438_1_AMOD_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pin : PtPin */ /*Configure GPIO pin : PtPin */
GPIO_InitStruct.Pin = HART1_RTS_Pin; GPIO_InitStruct.Pin = HART1_RTS_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
@ -93,6 +106,13 @@ void MX_GPIO_Init(void)
GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Pull = GPIO_PULLUP;
HAL_GPIO_Init(CH438_INT_GPIO_Port, &GPIO_InitStruct); HAL_GPIO_Init(CH438_INT_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pin : PtPin */
GPIO_InitStruct.Pin = CH438_1_RST_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
HAL_GPIO_Init(CH438_1_RST_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pin : PtPin */ /*Configure GPIO pin : PtPin */
GPIO_InitStruct.Pin = DAC1_CS_Pin; GPIO_InitStruct.Pin = DAC1_CS_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;

View File

@ -1,7 +1,7 @@
/* USER CODE BEGIN Header */ /* USER CODE BEGIN Header */
/** /**
****************************************************************************** ******************************************************************************
* @file : main.c * @file main.c
* @brief : Main program body * @brief : Main program body
****************************************************************************** ******************************************************************************
* @attention * @attention
@ -28,6 +28,7 @@
/* Private includes ----------------------------------------------------------*/ /* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */ /* USER CODE BEGIN Includes */
#include "ht1200m.h" #include "ht1200m.h"
#include "ch438q.h"
/* USER CODE END Includes */ /* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/ /* Private typedef -----------------------------------------------------------*/
@ -64,9 +65,9 @@ void MX_FREERTOS_Init(void);
/* USER CODE END 0 */ /* USER CODE END 0 */
/** /**
* @brief The application entry point. * @brief The application entry point.
* @retval int * @retval int
*/ */
int main(void) int main(void)
{ {
/* USER CODE BEGIN 1 */ /* USER CODE BEGIN 1 */
@ -86,7 +87,7 @@ int main(void)
SystemClock_Config(); SystemClock_Config();
/* USER CODE BEGIN SysInit */ /* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */ /* USER CODE END SysInit */
/* Initialize all configured peripherals */ /* Initialize all configured peripherals */
@ -117,22 +118,22 @@ int main(void)
} }
/** /**
* @brief System Clock Configuration * @brief System Clock Configuration
* @retval None * @retval None
*/ */
void SystemClock_Config(void) void SystemClock_Config(void)
{ {
RCC_OscInitTypeDef RCC_OscInitStruct = {0}; RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
/** Configure the main internal regulator output voltage /** Configure the main internal regulator output voltage
*/ */
__HAL_RCC_PWR_CLK_ENABLE(); __HAL_RCC_PWR_CLK_ENABLE();
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
/** Initializes the RCC Oscillators according to the specified parameters /** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure. * in the RCC_OscInitTypeDef structure.
*/ */
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON; RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
@ -147,8 +148,9 @@ void SystemClock_Config(void)
} }
/** Initializes the CPU, AHB and APB buses clocks /** Initializes the CPU, AHB and APB buses clocks
*/ */
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2; RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
@ -161,24 +163,29 @@ void SystemClock_Config(void)
} }
/* USER CODE BEGIN 4 */ /* USER CODE BEGIN 4 */
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
if (CH438_INT_Pin == GPIO_Pin)
{
ch438_interrupt_handler();
}
}
/* USER CODE END 4 */ /* USER CODE END 4 */
/** /**
* @brief Period elapsed callback in non blocking mode * @brief Period elapsed callback in non blocking mode
* @note This function is called when TIM4 interrupt took place, inside * @note This function is called when TIM4 interrupt took place, inside
* HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment * HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment
* a global variable "uwTick" used as application time base. * a global variable "uwTick" used as application time base.
* @param htim : TIM handle * @param htim : TIM handle
* @retval None * @retval None
*/ */
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{ {
/* USER CODE BEGIN Callback 0 */ /* USER CODE BEGIN Callback 0 */
/* USER CODE END Callback 0 */ /* USER CODE END Callback 0 */
if (htim->Instance == TIM4) if (htim->Instance == TIM4) {
{
HAL_IncTick(); HAL_IncTick();
} }
/* USER CODE BEGIN Callback 1 */ /* USER CODE BEGIN Callback 1 */
@ -187,9 +194,9 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
} }
/** /**
* @brief This function is executed in case of error occurrence. * @brief This function is executed in case of error occurrence.
* @retval None * @retval None
*/ */
void Error_Handler(void) void Error_Handler(void)
{ {
/* USER CODE BEGIN Error_Handler_Debug */ /* USER CODE BEGIN Error_Handler_Debug */
@ -201,14 +208,14 @@ void Error_Handler(void)
/* USER CODE END Error_Handler_Debug */ /* USER CODE END Error_Handler_Debug */
} }
#ifdef USE_FULL_ASSERT #ifdef USE_FULL_ASSERT
/** /**
* @brief Reports the name of the source file and the source line number * @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred. * where the assert_param error has occurred.
* @param file: pointer to the source file name * @param file: pointer to the source file name
* @param line: assert_param error line source number * @param line: assert_param error line source number
* @retval None * @retval None
*/ */
void assert_failed(uint8_t *file, uint32_t line) void assert_failed(uint8_t *file, uint32_t line)
{ {
/* USER CODE BEGIN 6 */ /* USER CODE BEGIN 6 */

View File

@ -1,7 +1,7 @@
/* USER CODE BEGIN Header */ /* USER CODE BEGIN Header */
/** /**
****************************************************************************** ******************************************************************************
* @file stm32f4xx_it.c * @file stm32f4xx_it.c
* @brief Interrupt Service Routines. * @brief Interrupt Service Routines.
****************************************************************************** ******************************************************************************
* @attention * @attention
@ -67,8 +67,8 @@ extern TIM_HandleTypeDef htim4;
/* Cortex-M4 Processor Interruption and Exception Handlers */ /* Cortex-M4 Processor Interruption and Exception Handlers */
/******************************************************************************/ /******************************************************************************/
/** /**
* @brief This function handles Non maskable interrupt. * @brief This function handles Non maskable interrupt.
*/ */
void NMI_Handler(void) void NMI_Handler(void)
{ {
/* USER CODE BEGIN NonMaskableInt_IRQn 0 */ /* USER CODE BEGIN NonMaskableInt_IRQn 0 */
@ -82,8 +82,8 @@ void NMI_Handler(void)
} }
/** /**
* @brief This function handles Hard fault interrupt. * @brief This function handles Hard fault interrupt.
*/ */
void HardFault_Handler(void) void HardFault_Handler(void)
{ {
/* USER CODE BEGIN HardFault_IRQn 0 */ /* USER CODE BEGIN HardFault_IRQn 0 */
@ -97,8 +97,8 @@ void HardFault_Handler(void)
} }
/** /**
* @brief This function handles Memory management fault. * @brief This function handles Memory management fault.
*/ */
void MemManage_Handler(void) void MemManage_Handler(void)
{ {
/* USER CODE BEGIN MemoryManagement_IRQn 0 */ /* USER CODE BEGIN MemoryManagement_IRQn 0 */
@ -112,8 +112,8 @@ void MemManage_Handler(void)
} }
/** /**
* @brief This function handles Pre-fetch fault, memory access fault. * @brief This function handles Pre-fetch fault, memory access fault.
*/ */
void BusFault_Handler(void) void BusFault_Handler(void)
{ {
/* USER CODE BEGIN BusFault_IRQn 0 */ /* USER CODE BEGIN BusFault_IRQn 0 */
@ -127,8 +127,8 @@ void BusFault_Handler(void)
} }
/** /**
* @brief This function handles Undefined instruction or illegal state. * @brief This function handles Undefined instruction or illegal state.
*/ */
void UsageFault_Handler(void) void UsageFault_Handler(void)
{ {
/* USER CODE BEGIN UsageFault_IRQn 0 */ /* USER CODE BEGIN UsageFault_IRQn 0 */
@ -142,8 +142,8 @@ void UsageFault_Handler(void)
} }
/** /**
* @brief This function handles Debug monitor. * @brief This function handles Debug monitor.
*/ */
void DebugMon_Handler(void) void DebugMon_Handler(void)
{ {
/* USER CODE BEGIN DebugMonitor_IRQn 0 */ /* USER CODE BEGIN DebugMonitor_IRQn 0 */
@ -162,8 +162,8 @@ void DebugMon_Handler(void)
/******************************************************************************/ /******************************************************************************/
/** /**
* @brief This function handles EXTI line2 interrupt. * @brief This function handles EXTI line2 interrupt.
*/ */
void EXTI2_IRQHandler(void) void EXTI2_IRQHandler(void)
{ {
/* USER CODE BEGIN EXTI2_IRQn 0 */ /* USER CODE BEGIN EXTI2_IRQn 0 */
@ -171,13 +171,13 @@ void EXTI2_IRQHandler(void)
/* USER CODE END EXTI2_IRQn 0 */ /* USER CODE END EXTI2_IRQn 0 */
HAL_GPIO_EXTI_IRQHandler(CH438_INT_Pin); HAL_GPIO_EXTI_IRQHandler(CH438_INT_Pin);
/* USER CODE BEGIN EXTI2_IRQn 1 */ /* USER CODE BEGIN EXTI2_IRQn 1 */
ch438_interrupt_handler(); // ch438_interrupt_handler();
/* USER CODE END EXTI2_IRQn 1 */ /* USER CODE END EXTI2_IRQn 1 */
} }
/** /**
* @brief This function handles TIM4 global interrupt. * @brief This function handles TIM4 global interrupt.
*/ */
void TIM4_IRQHandler(void) void TIM4_IRQHandler(void)
{ {
/* USER CODE BEGIN TIM4_IRQn 0 */ /* USER CODE BEGIN TIM4_IRQn 0 */
@ -190,8 +190,8 @@ void TIM4_IRQHandler(void)
} }
/** /**
* @brief This function handles Ethernet global interrupt. * @brief This function handles Ethernet global interrupt.
*/ */
void ETH_IRQHandler(void) void ETH_IRQHandler(void)
{ {
/* USER CODE BEGIN ETH_IRQn 0 */ /* USER CODE BEGIN ETH_IRQn 0 */

View File

@ -148,24 +148,7 @@
<Name>-U090F00028316303030303032 -O2254 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(2BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC800 -FN1 -FF0STM32F4xx_1024.FLM -FS08000000 -FL0100000 -FP0($$Device:STM32F407ZGTx$CMSIS\Flash\STM32F4xx_1024.FLM)</Name> <Name>-U090F00028316303030303032 -O2254 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(2BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC800 -FN1 -FF0STM32F4xx_1024.FLM -FS08000000 -FL0100000 -FP0($$Device:STM32F407ZGTx$CMSIS\Flash\STM32F4xx_1024.FLM)</Name>
</SetRegEntry> </SetRegEntry>
</TargetDriverDllRegistry> </TargetDriverDllRegistry>
<Breakpoint> <Breakpoint/>
<Bp>
<Number>0</Number>
<Type>0</Type>
<LineNumber>184</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134258924</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>../Core/Src/freertos.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\valve_debugging\../Core/Src/freertos.c\184</Expression>
</Bp>
</Breakpoint>
<WatchWindow1> <WatchWindow1>
<Ww> <Ww>
<count>0</count> <count>0</count>
@ -276,7 +259,7 @@
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>2</FileNumber> <FileNumber>2</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>../Core/Src/main.c</PathWithFileName> <PathWithFileName>../Core/Src/main.c</PathWithFileName>

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,8 @@
#ifndef __CH438Q_H__ #ifndef __CH438Q_H__
#define __CH438Q_H__ #define __CH438Q_H__
#include "fsmc.h"
#include "main.h"
/* CH438串口寄存器地址 */ /* CH438串口寄存器地址 */
#define REG_RBR_ADDR 0x00 /* 串口0接收缓冲寄存器地址 */ #define REG_RBR_ADDR 0x00 /* 串口0接收缓冲寄存器地址 */
#define REG_THR_ADDR 0x00 /* 串口0发送保持寄存器地址 */ #define REG_THR_ADDR 0x00 /* 串口0发送保持寄存器地址 */
@ -134,4 +134,6 @@ void ch438_send_data(uint8_t uart_num, uint8_t *data, uint16_t len);
uint8_t ch438_recv_data(uint8_t uart_num, uint8_t *data); uint8_t ch438_recv_data(uint8_t uart_num, uint8_t *data);
void ch438_interrupt_handler(void); void ch438_interrupt_handler(void);
void ch438_init(void); void ch438_init(void);
#endif #endif

View File

@ -64,41 +64,43 @@ Mcu.Pin14=PA7
Mcu.Pin15=PC4 Mcu.Pin15=PC4
Mcu.Pin16=PC5 Mcu.Pin16=PC5
Mcu.Pin17=PF12 Mcu.Pin17=PF12
Mcu.Pin18=PE7 Mcu.Pin18=PF14
Mcu.Pin19=PE8 Mcu.Pin19=PE7
Mcu.Pin2=PF1 Mcu.Pin2=PF1
Mcu.Pin20=PE9 Mcu.Pin20=PE8
Mcu.Pin21=PE10 Mcu.Pin21=PE9
Mcu.Pin22=PB11 Mcu.Pin22=PE10
Mcu.Pin23=PB12 Mcu.Pin23=PB11
Mcu.Pin24=PB13 Mcu.Pin24=PB12
Mcu.Pin25=PD14 Mcu.Pin25=PB13
Mcu.Pin26=PD15 Mcu.Pin26=PD14
Mcu.Pin27=PG4 Mcu.Pin27=PD15
Mcu.Pin28=PA13 Mcu.Pin28=PG4
Mcu.Pin29=PA14 Mcu.Pin29=PA13
Mcu.Pin3=PF2 Mcu.Pin3=PF2
Mcu.Pin30=PD0 Mcu.Pin30=PA14
Mcu.Pin31=PD1 Mcu.Pin31=PD0
Mcu.Pin32=PD2 Mcu.Pin32=PD1
Mcu.Pin33=PD4 Mcu.Pin33=PD2
Mcu.Pin34=PD5 Mcu.Pin34=PD3
Mcu.Pin35=PD7 Mcu.Pin35=PD4
Mcu.Pin36=PG9 Mcu.Pin36=PD5
Mcu.Pin37=PB3 Mcu.Pin37=PD7
Mcu.Pin38=PB4 Mcu.Pin38=PG9
Mcu.Pin39=PB5 Mcu.Pin39=PB3
Mcu.Pin4=PF3 Mcu.Pin4=PF3
Mcu.Pin40=PB6 Mcu.Pin40=PB4
Mcu.Pin41=VP_FREERTOS_VS_CMSIS_V1 Mcu.Pin41=PB5
Mcu.Pin42=VP_LWIP_VS_Enabled Mcu.Pin42=PB6
Mcu.Pin43=VP_SYS_VS_tim4 Mcu.Pin43=VP_FREERTOS_VS_CMSIS_V1
Mcu.Pin44=VP_LWIP_VS_Enabled
Mcu.Pin45=VP_SYS_VS_tim4
Mcu.Pin5=PF4 Mcu.Pin5=PF4
Mcu.Pin6=PF5 Mcu.Pin6=PF5
Mcu.Pin7=PH0-OSC_IN Mcu.Pin7=PH0-OSC_IN
Mcu.Pin8=PH1-OSC_OUT Mcu.Pin8=PH1-OSC_OUT
Mcu.Pin9=PC1 Mcu.Pin9=PC1
Mcu.PinsNb=44 Mcu.PinsNb=46
Mcu.ThirdPartyNb=0 Mcu.ThirdPartyNb=0
Mcu.UserConstants= Mcu.UserConstants=
Mcu.UserName=STM32F407ZGTx Mcu.UserName=STM32F407ZGTx
@ -183,6 +185,13 @@ PD2.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_FALLING
PD2.GPIO_PuPd=GPIO_PULLUP PD2.GPIO_PuPd=GPIO_PULLUP
PD2.Locked=true PD2.Locked=true
PD2.Signal=GPXTI2 PD2.Signal=GPXTI2
PD3.GPIOParameters=GPIO_Speed,PinState,GPIO_PuPd,GPIO_Label
PD3.GPIO_Label=CH438_1_RST
PD3.GPIO_PuPd=GPIO_PULLUP
PD3.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH
PD3.Locked=true
PD3.PinState=GPIO_PIN_SET
PD3.Signal=GPIO_Output
PD4.Signal=FSMC_NOE PD4.Signal=FSMC_NOE
PD5.Signal=FSMC_NWE PD5.Signal=FSMC_NWE
PD7.Mode=NorPsramChipSelect1_1 PD7.Mode=NorPsramChipSelect1_1
@ -201,6 +210,13 @@ PE9.Signal=FSMC_D6_DA6
PF0.Signal=FSMC_A0 PF0.Signal=FSMC_A0
PF1.Signal=FSMC_A1 PF1.Signal=FSMC_A1
PF12.Signal=FSMC_A6 PF12.Signal=FSMC_A6
PF14.GPIOParameters=GPIO_Speed,PinState,GPIO_PuPd,GPIO_Label
PF14.GPIO_Label=CH438_1_AMOD
PF14.GPIO_PuPd=GPIO_PULLDOWN
PF14.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH
PF14.Locked=true
PF14.PinState=GPIO_PIN_RESET
PF14.Signal=GPIO_Output
PF2.Signal=FSMC_A2 PF2.Signal=FSMC_A2
PF3.Signal=FSMC_A3 PF3.Signal=FSMC_A3
PF4.Signal=FSMC_A4 PF4.Signal=FSMC_A4