备份,解决通讯导致的程序卡死问题,将TCP数据发送移出中断
This commit is contained in:
parent
38adf29ce9
commit
3cfaa27de4
|
@ -78,6 +78,7 @@ void Error_Handler(void);
|
|||
#define HART9_RTS_GPIO_Port GPIOB
|
||||
#define CH438_2_INT_Pin GPIO_PIN_13
|
||||
#define CH438_2_INT_GPIO_Port GPIOF
|
||||
#define CH438_2_INT_EXTI_IRQn EXTI15_10_IRQn
|
||||
#define CH438_AMOD_Pin GPIO_PIN_14
|
||||
#define CH438_AMOD_GPIO_Port GPIOF
|
||||
#define HART8_RTS_Pin GPIO_PIN_0
|
||||
|
|
|
@ -54,6 +54,7 @@ void UsageFault_Handler(void);
|
|||
void DebugMon_Handler(void);
|
||||
void EXTI2_IRQHandler(void);
|
||||
void TIM4_IRQHandler(void);
|
||||
void EXTI15_10_IRQHandler(void);
|
||||
void ETH_IRQHandler(void);
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
|
|
|
@ -58,15 +58,15 @@ osThreadId ch438_taskHandle;
|
|||
|
||||
/* USER CODE END FunctionPrototypes */
|
||||
|
||||
void start_lwip_task(void const * argument);
|
||||
void start_dac_task(void const * argument);
|
||||
void start_ch438_task(void const * argument);
|
||||
void start_lwip_task(void const *argument);
|
||||
void start_dac_task(void const *argument);
|
||||
void start_ch438_task(void const *argument);
|
||||
|
||||
extern void MX_LWIP_Init(void);
|
||||
void MX_FREERTOS_Init(void); /* (MISRA C 2004 rule 8.1) */
|
||||
|
||||
/* 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 */
|
||||
static StaticTask_t xIdleTaskTCBBuffer;
|
||||
|
@ -82,11 +82,12 @@ void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer, StackTyp
|
|||
/* USER CODE END GET_IDLE_TASK_MEMORY */
|
||||
|
||||
/**
|
||||
* @brief FreeRTOS initialization
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void MX_FREERTOS_Init(void) {
|
||||
* @brief FreeRTOS initialization
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void MX_FREERTOS_Init(void)
|
||||
{
|
||||
/* USER CODE BEGIN Init */
|
||||
|
||||
/* USER CODE END Init */
|
||||
|
@ -109,7 +110,7 @@ void MX_FREERTOS_Init(void) {
|
|||
|
||||
/* Create the thread(s) */
|
||||
/* definition and creation of lwip_task */
|
||||
osThreadDef(lwip_task, start_lwip_task, osPriorityNormal, 0, 10000);
|
||||
osThreadDef(lwip_task, start_lwip_task, osPriorityNormal, 0, 12040);
|
||||
lwip_taskHandle = osThreadCreate(osThread(lwip_task), NULL);
|
||||
|
||||
/* definition and creation of dac_task */
|
||||
|
@ -123,7 +124,6 @@ void MX_FREERTOS_Init(void) {
|
|||
/* USER CODE BEGIN RTOS_THREADS */
|
||||
/* add threads, ... */
|
||||
/* USER CODE END RTOS_THREADS */
|
||||
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN Header_start_lwip_task */
|
||||
|
@ -133,7 +133,7 @@ void MX_FREERTOS_Init(void) {
|
|||
* @retval None
|
||||
*/
|
||||
/* 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 */
|
||||
MX_LWIP_Init();
|
||||
|
@ -143,7 +143,10 @@ void start_lwip_task(void const * argument)
|
|||
for (;;)
|
||||
{
|
||||
// osThreadTerminate(NULL);
|
||||
vTaskDelay(100);
|
||||
ch438_interrupt_handler_data_ch438_chip_1();
|
||||
ch438_interrupt_handler_data_ch438_chip_2();
|
||||
|
||||
vTaskDelay(10);
|
||||
}
|
||||
/* USER CODE END start_lwip_task */
|
||||
}
|
||||
|
@ -155,7 +158,7 @@ void start_lwip_task(void const * argument)
|
|||
* @retval None
|
||||
*/
|
||||
/* 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 */
|
||||
/* Infinite loop */
|
||||
|
@ -179,16 +182,15 @@ void start_dac_task(void const * argument)
|
|||
* @retval None
|
||||
*/
|
||||
/* 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 */
|
||||
/* Infinite loop */
|
||||
ch438_init();
|
||||
for (;;)
|
||||
{
|
||||
// uint8_t data[10] = {0xFF, 0xff, 0xff, 0xff, 0xff, 0x02, 0x00, 0x00, 0x00, 0x02};
|
||||
// ch438_send_data(9, data, 10);
|
||||
vTaskDelay(500);
|
||||
osThreadTerminate(NULL);
|
||||
// vTaskDelay(500);
|
||||
}
|
||||
/* USER CODE END start_ch438_task */
|
||||
}
|
||||
|
|
|
@ -162,9 +162,12 @@ void MX_GPIO_Init(void)
|
|||
HAL_GPIO_Init(CH438_1_INT_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/* EXTI interrupt init*/
|
||||
HAL_NVIC_SetPriority(EXTI2_IRQn, 5, 0);
|
||||
HAL_NVIC_SetPriority(EXTI2_IRQn, 6, 0);
|
||||
HAL_NVIC_EnableIRQ(EXTI2_IRQn);
|
||||
|
||||
HAL_NVIC_SetPriority(EXTI15_10_IRQn, 6, 0);
|
||||
HAL_NVIC_EnableIRQ(EXTI15_10_IRQn);
|
||||
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 2 */
|
||||
|
|
|
@ -65,9 +65,9 @@ void MX_FREERTOS_Init(void);
|
|||
/* USER CODE END 0 */
|
||||
|
||||
/**
|
||||
* @brief The application entry point.
|
||||
* @retval int
|
||||
*/
|
||||
* @brief The application entry point.
|
||||
* @retval int
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
@ -119,22 +119,22 @@ int main(void)
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief System Clock Configuration
|
||||
* @retval None
|
||||
*/
|
||||
* @brief System Clock Configuration
|
||||
* @retval None
|
||||
*/
|
||||
void SystemClock_Config(void)
|
||||
{
|
||||
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
|
||||
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
|
||||
|
||||
/** Configure the main internal regulator output voltage
|
||||
*/
|
||||
*/
|
||||
__HAL_RCC_PWR_CLK_ENABLE();
|
||||
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
|
||||
|
||||
/** 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.HSEState = RCC_HSE_ON;
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||
|
@ -149,9 +149,8 @@ void SystemClock_Config(void)
|
|||
}
|
||||
|
||||
/** 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.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
|
||||
|
@ -168,29 +167,32 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
|||
{
|
||||
if (CH438_1_INT_Pin == GPIO_Pin)
|
||||
{
|
||||
// ch438_1_int_flag = 1; // 设置CH438_1的中断标志,用于中断处理函数中判断是否为CH438_1的中断请求
|
||||
ch438_interrupt_handler_ch438_chip_1();
|
||||
}
|
||||
if (CH438_2_INT_Pin == GPIO_Pin)
|
||||
{
|
||||
// ch438_2_int_flag = 1; // 设置CH438_1的中断标志,用于中断处理函数中判断是否为CH438_1的中断请求
|
||||
ch438_interrupt_handler_ch438_chip_2();
|
||||
}
|
||||
}
|
||||
/* USER CODE END 4 */
|
||||
|
||||
/**
|
||||
* @brief Period elapsed callback in non blocking mode
|
||||
* @note This function is called when TIM4 interrupt took place, inside
|
||||
* HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment
|
||||
* a global variable "uwTick" used as application time base.
|
||||
* @param htim : TIM handle
|
||||
* @retval None
|
||||
*/
|
||||
* @brief Period elapsed callback in non blocking mode
|
||||
* @note This function is called when TIM4 interrupt took place, inside
|
||||
* HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment
|
||||
* a global variable "uwTick" used as application time base.
|
||||
* @param htim : TIM handle
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
|
||||
{
|
||||
/* USER CODE BEGIN Callback 0 */
|
||||
|
||||
/* USER CODE END Callback 0 */
|
||||
if (htim->Instance == TIM4) {
|
||||
if (htim->Instance == TIM4)
|
||||
{
|
||||
HAL_IncTick();
|
||||
}
|
||||
/* USER CODE BEGIN Callback 1 */
|
||||
|
@ -199,9 +201,9 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief This function is executed in case of error occurrence.
|
||||
* @retval None
|
||||
*/
|
||||
* @brief This function is executed in case of error occurrence.
|
||||
* @retval None
|
||||
*/
|
||||
void Error_Handler(void)
|
||||
{
|
||||
/* USER CODE BEGIN Error_Handler_Debug */
|
||||
|
@ -213,14 +215,14 @@ void Error_Handler(void)
|
|||
/* 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
|
||||
* where the assert_param error has occurred.
|
||||
* @param file: pointer to the source file name
|
||||
* @param line: assert_param error line source number
|
||||
* @retval None
|
||||
*/
|
||||
* @brief Reports the name of the source file and the source line number
|
||||
* where the assert_param error has occurred.
|
||||
* @param file: pointer to the source file name
|
||||
* @param line: assert_param error line source number
|
||||
* @retval None
|
||||
*/
|
||||
void assert_failed(uint8_t *file, uint32_t line)
|
||||
{
|
||||
/* USER CODE BEGIN 6 */
|
||||
|
|
|
@ -189,6 +189,20 @@ void TIM4_IRQHandler(void)
|
|||
/* USER CODE END TIM4_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles EXTI line[15:10] interrupts.
|
||||
*/
|
||||
void EXTI15_10_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN EXTI15_10_IRQn 0 */
|
||||
|
||||
/* USER CODE END EXTI15_10_IRQn 0 */
|
||||
HAL_GPIO_EXTI_IRQHandler(CH438_2_INT_Pin);
|
||||
/* USER CODE BEGIN EXTI15_10_IRQn 1 */
|
||||
|
||||
/* USER CODE END EXTI15_10_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Ethernet global interrupt.
|
||||
*/
|
||||
|
|
|
@ -611,7 +611,7 @@ void HAL_ETH_MspInit(ETH_HandleTypeDef* ethHandle)
|
|||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
|
||||
/* Peripheral interrupt init */
|
||||
HAL_NVIC_SetPriority(ETH_IRQn, 5, 0);
|
||||
HAL_NVIC_SetPriority(ETH_IRQn, 6, 0);
|
||||
HAL_NVIC_EnableIRQ(ETH_IRQn);
|
||||
/* USER CODE BEGIN ETH_MspInit 1 */
|
||||
|
||||
|
|
|
@ -51,8 +51,10 @@
|
|||
#define MEMP_NUM_TCP_PCB 20
|
||||
/*----- Value in opt.h for MEM_ALIGNMENT: 1 -----*/
|
||||
#define MEM_ALIGNMENT 4
|
||||
/*----- Default Value for MEM_SIZE: 1600 ---*/
|
||||
#define MEM_SIZE 1024
|
||||
/*----- Default Value for MEMP_NUM_PBUF: 16 ---*/
|
||||
#define MEMP_NUM_PBUF 32
|
||||
#define MEMP_NUM_PBUF 20
|
||||
/*----- Default Value for MEMP_NUM_RAW_PCB: 4 ---*/
|
||||
#define MEMP_NUM_RAW_PCB 20
|
||||
/*----- Default Value for MEMP_NUM_TCP_PCB_LISTEN: 8 ---*/
|
||||
|
@ -63,18 +65,18 @@
|
|||
#define MEMP_NUM_NETCONN 20
|
||||
/*----- Default Value for MEMP_NUM_SELECT_CB: 4 ---*/
|
||||
#define MEMP_NUM_SELECT_CB 20
|
||||
/*----- Default Value for PBUF_POOL_SIZE: 16 ---*/
|
||||
#define PBUF_POOL_SIZE 24
|
||||
/*----- Default Value for PBUF_POOL_BUFSIZE: 592 ---*/
|
||||
#define PBUF_POOL_BUFSIZE 1024
|
||||
#define PBUF_POOL_BUFSIZE 512
|
||||
/*----- Value in opt.h for LWIP_ETHERNET: LWIP_ARP || PPPOE_SUPPORT -*/
|
||||
#define LWIP_ETHERNET 1
|
||||
/*----- Value in opt.h for LWIP_DNS_SECURE: (LWIP_DNS_SECURE_RAND_XID | LWIP_DNS_SECURE_NO_MULTIPLE_OUTSTANDING | LWIP_DNS_SECURE_RAND_SRC_PORT) -*/
|
||||
#define LWIP_DNS_SECURE 7
|
||||
/*----- Value in opt.h for TCP_SND_QUEUELEN: (4*TCP_SND_BUF + (TCP_MSS - 1))/TCP_MSS -----*/
|
||||
#define TCP_SND_QUEUELEN 9
|
||||
/*----- Default Value for TCP_SND_QUEUELEN: 9 ---*/
|
||||
#define TCP_SND_QUEUELEN 24
|
||||
/*----- Value in opt.h for TCP_SNDLOWAT: LWIP_MIN(LWIP_MAX(((TCP_SND_BUF)/2), (2 * TCP_MSS) + 1), (TCP_SND_BUF) - 1) -*/
|
||||
#define TCP_SNDLOWAT 1071
|
||||
/*----- Value in opt.h for TCP_SNDQUEUELOWAT: LWIP_MAX(TCP_SND_QUEUELEN)/2, 5) -*/
|
||||
#define TCP_SNDQUEUELOWAT 5
|
||||
/*----- Value in opt.h for TCP_WND_UPDATE_THRESHOLD: LWIP_MIN(TCP_WND/4, TCP_MSS*4) -----*/
|
||||
#define TCP_WND_UPDATE_THRESHOLD 536
|
||||
/*----- Value in opt.h for LWIP_NETIF_LINK_CALLBACK: 0 -----*/
|
||||
|
|
|
@ -145,10 +145,59 @@
|
|||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>ST-LINKIII-KEIL_SWO</Key>
|
||||
<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 -FO15 -FD20000000 -FC800 -FN1 -FF0STM32F4xx_1024.FLM -FS08000000 -FL0100000 -FP0($$Device:STM32F407ZGTx$CMSIS\Flash\STM32F4xx_1024.FLM)</Name>
|
||||
</SetRegEntry>
|
||||
</TargetDriverDllRegistry>
|
||||
<Breakpoint/>
|
||||
<Breakpoint>
|
||||
<Bp>
|
||||
<Number>0</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>295</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>134236232</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>1</BreakIfRCount>
|
||||
<Filename>../Middlewares/Third_Party/LwIP/src/core/memp.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression>\\valve_debugging\../Middlewares/Third_Party/LwIP/src/core/memp.c\295</Expression>
|
||||
</Bp>
|
||||
<Bp>
|
||||
<Number>1</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>36</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>134290996</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>1</BreakIfRCount>
|
||||
<Filename>..\User\application\src\tcpserverc.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression>\\valve_debugging\../User/application/src/tcpserverc.c\36</Expression>
|
||||
</Bp>
|
||||
<Bp>
|
||||
<Number>2</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>142</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>0</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>0</BreakIfRCount>
|
||||
<Filename>../Core/Src/freertos.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression></Expression>
|
||||
</Bp>
|
||||
</Breakpoint>
|
||||
<WatchWindow1>
|
||||
<Ww>
|
||||
<count>0</count>
|
||||
|
@ -220,6 +269,36 @@
|
|||
<WinNumber>1</WinNumber>
|
||||
<ItemText>uart_times,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>14</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>lwip_taskHandle</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>15</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>PBUF_TRANSPORT</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>16</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>MEMP_DEBUG</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>17</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>pxQueue</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>18</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>pxQueue->uxQueueType</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>19</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>ch438_1_int_flag</ItemText>
|
||||
</Ww>
|
||||
</WatchWindow1>
|
||||
<MemoryWindow1>
|
||||
<Mm>
|
||||
|
@ -245,7 +324,7 @@
|
|||
<periodic>1</periodic>
|
||||
<aLwin>1</aLwin>
|
||||
<aCover>0</aCover>
|
||||
<aSer1>0</aSer1>
|
||||
<aSer1>1</aSer1>
|
||||
<aSer2>0</aSer2>
|
||||
<aPa>0</aPa>
|
||||
<viewmode>1</viewmode>
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -28,6 +28,8 @@ const uint8_t Interruptnum[] = {
|
|||
ch438_uart_data_t ch438_uart_data[16] = {0};
|
||||
uint8_t receive_data_len;
|
||||
uint32_t uart_times[TCP_MAX] = {0};
|
||||
uint8_t ch438_1_int_flag = 0;
|
||||
uint8_t ch438_2_int_flag = 0;
|
||||
static void ch438_tranconfig(uint8_t uart_num);
|
||||
static void ch438_set_baudrate(uint8_t uart_num, uint32_t baudrate);
|
||||
|
||||
|
@ -341,23 +343,23 @@ void ch438_interrupt_handler_ch438_chip_1(void)
|
|||
case INT_THR_EMPTY: /* THR空中断 */
|
||||
hart_ht1200m_rts_io_receive(i);
|
||||
break;
|
||||
case INT_RCV_OVERTIME: /* 接收超时中断 */
|
||||
ch438_uart_data[i].receive_data_length = ch438_recv_data(i, ch438_uart_data[i].receive_data_buff);
|
||||
// ch438_send_data(i, ch438_uart_data[i].receive_data_buff, ch438_uart_data[i].receive_data_length);
|
||||
if (tcp_echo_flags[i] == 1)
|
||||
{
|
||||
user_send_data_hart(i, ch438_uart_data[i].receive_data_buff, ch438_uart_data[i].receive_data_length);
|
||||
uart_times[i]++;
|
||||
}
|
||||
break;
|
||||
case INT_RCV_SUCCESS: /* 接收数据可用中断 */
|
||||
ch438_uart_data[i].receive_data_length = ch438_recv_data(i, ch438_uart_data[i].receive_data_buff);
|
||||
if (tcp_echo_flags[i] == 1)
|
||||
{
|
||||
user_send_data_hart(i, ch438_uart_data[i].receive_data_buff, ch438_uart_data[i].receive_data_length);
|
||||
uart_times[i]++;
|
||||
}
|
||||
break;
|
||||
// case INT_RCV_OVERTIME: /* 接收超时中断 */
|
||||
// ch438_uart_data[i].receive_data_length = ch438_recv_data(i, ch438_uart_data[i].receive_data_buff);
|
||||
// // ch438_send_data(i, ch438_uart_data[i].receive_data_buff, ch438_uart_data[i].receive_data_length);
|
||||
// if (tcp_echo_flags[i] == 1)
|
||||
// {
|
||||
// user_send_data_hart(i, ch438_uart_data[i].receive_data_buff, ch438_uart_data[i].receive_data_length);
|
||||
// uart_times[i]++;
|
||||
// }
|
||||
// break;
|
||||
// case INT_RCV_SUCCESS: /* 接收数据可用中断 */
|
||||
// ch438_uart_data[i].receive_data_length = ch438_recv_data(i, ch438_uart_data[i].receive_data_buff);
|
||||
// if (tcp_echo_flags[i] == 1)
|
||||
// {
|
||||
// user_send_data_hart(i, ch438_uart_data[i].receive_data_buff, ch438_uart_data[i].receive_data_length);
|
||||
// uart_times[i]++;
|
||||
// }
|
||||
// break;
|
||||
case INT_RCV_LINES: /* 接收线路状态中断 */
|
||||
ch438_read_reg(ch438_num, offsetadd[i] | REG_LSR_ADDR, 1);
|
||||
break;
|
||||
|
@ -397,6 +399,56 @@ void ch438_interrupt_handler_ch438_chip_2(void)
|
|||
case INT_THR_EMPTY: /* THR空中断 */
|
||||
hart_ht1200m_rts_io_receive(i);
|
||||
break;
|
||||
// case INT_RCV_OVERTIME: /* 接收超时中断 */
|
||||
// ch438_uart_data[i].receive_data_length = ch438_recv_data(i, ch438_uart_data[i].receive_data_buff);
|
||||
// if (tcp_echo_flags[i] == 1)
|
||||
// {
|
||||
// user_send_data_hart(i, ch438_uart_data[i].receive_data_buff, ch438_uart_data[i].receive_data_length);
|
||||
// uart_times[i]++;
|
||||
// }
|
||||
// break;
|
||||
// case INT_RCV_SUCCESS: /* 接收数据可用中断 */
|
||||
// ch438_uart_data[i].receive_data_length = ch438_recv_data(i, ch438_uart_data[i].receive_data_buff);
|
||||
// if (tcp_echo_flags[i] == 1)
|
||||
// {
|
||||
// user_send_data_hart(i, ch438_uart_data[i].receive_data_buff, ch438_uart_data[i].receive_data_length);
|
||||
// uart_times[i]++;
|
||||
// }
|
||||
// break;
|
||||
case INT_RCV_LINES: /* 接收线路状态中断 */
|
||||
ch438_read_reg(ch438_num, offsetadd[i - 8] | REG_LSR_ADDR, 1);
|
||||
break;
|
||||
case INT_MODEM_CHANGE: /* MODEM输入变化中断 */
|
||||
ch438_read_reg(ch438_num, offsetadd[i - 8] | REG_MSR_ADDR, 1);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void ch438_interrupt_handler_data_ch438_chip_1(void)
|
||||
{
|
||||
uint8_t gInterruptStatus; /* 全局中断状态 */
|
||||
uint8_t InterruptStatus; /* 独立串口中断状态 */
|
||||
uint8_t i;
|
||||
uint8_t ch438_num = CH438_CHIP0;
|
||||
gInterruptStatus = ch438_read_reg(ch438_num, REG_SSR_ADDR, 1);
|
||||
|
||||
if (!gInterruptStatus)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
if (gInterruptStatus & Interruptnum[i]) /* 检测哪个串口发生中断 */
|
||||
{
|
||||
InterruptStatus = ch438_read_reg(ch438_num, offsetadd[i] | REG_IIR_ADDR, 1) & 0x0f; /* 读串口的中断状态 */
|
||||
|
||||
switch (InterruptStatus)
|
||||
{
|
||||
|
||||
case INT_RCV_OVERTIME: /* 接收超时中断 */
|
||||
ch438_uart_data[i].receive_data_length = ch438_recv_data(i, ch438_uart_data[i].receive_data_buff);
|
||||
if (tcp_echo_flags[i] == 1)
|
||||
|
@ -413,12 +465,7 @@ void ch438_interrupt_handler_ch438_chip_2(void)
|
|||
uart_times[i]++;
|
||||
}
|
||||
break;
|
||||
case INT_RCV_LINES: /* 接收线路状态中断 */
|
||||
ch438_read_reg(ch438_num, offsetadd[i - 8] | REG_LSR_ADDR, 1);
|
||||
break;
|
||||
case INT_MODEM_CHANGE: /* MODEM输入变化中断 */
|
||||
ch438_read_reg(ch438_num, offsetadd[i - 8] | REG_MSR_ADDR, 1);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -426,6 +473,50 @@ void ch438_interrupt_handler_ch438_chip_2(void)
|
|||
}
|
||||
}
|
||||
|
||||
void ch438_interrupt_handler_data_ch438_chip_2(void)
|
||||
{
|
||||
uint8_t gInterruptStatus; /* 全局中断状态 */
|
||||
uint8_t InterruptStatus; /* 独立串口中断状态 */
|
||||
uint8_t i;
|
||||
uint8_t ch438_num = CH438_CHIP1;
|
||||
gInterruptStatus = ch438_read_reg(ch438_num, REG_SSR_ADDR, 1);
|
||||
|
||||
if (!gInterruptStatus)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 8; i < 16; i++)
|
||||
{
|
||||
if (gInterruptStatus & Interruptnum[i - 8]) /* 检测哪个串口发生中断 */
|
||||
{
|
||||
InterruptStatus = ch438_read_reg(ch438_num, offsetadd[i - 8] | REG_IIR_ADDR, 1) & 0x0f; /* 读串口的中断状态 */
|
||||
|
||||
switch (InterruptStatus)
|
||||
{
|
||||
case INT_RCV_OVERTIME: /* 接收超时中断 */
|
||||
ch438_uart_data[i].receive_data_length = ch438_recv_data(i, ch438_uart_data[i].receive_data_buff);
|
||||
if (tcp_echo_flags[i] == 1)
|
||||
{
|
||||
user_send_data_hart(i, ch438_uart_data[i].receive_data_buff, ch438_uart_data[i].receive_data_length);
|
||||
uart_times[i]++;
|
||||
}
|
||||
break;
|
||||
case INT_RCV_SUCCESS: /* 接收数据可用中断 */
|
||||
ch438_uart_data[i].receive_data_length = ch438_recv_data(i, ch438_uart_data[i].receive_data_buff);
|
||||
if (tcp_echo_flags[i] == 1)
|
||||
{
|
||||
user_send_data_hart(i, ch438_uart_data[i].receive_data_buff, ch438_uart_data[i].receive_data_length);
|
||||
uart_times[i]++;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void ch438_init(void)
|
||||
{
|
||||
uint8_t i;
|
||||
|
|
|
@ -133,6 +133,8 @@ typedef struct
|
|||
} ch438_uart_data_t;
|
||||
|
||||
extern ch438_uart_data_t ch438_uart_data[16];
|
||||
extern uint8_t ch438_1_int_flag;
|
||||
extern uint8_t ch438_2_int_flag;
|
||||
|
||||
void ch438_write_reg(uint8_t ch438_num, uint8_t addr, uint8_t data, uint8_t size);
|
||||
uint8_t ch438_read_reg(uint8_t ch438_num, uint8_t addr, uint8_t size);
|
||||
|
@ -146,6 +148,8 @@ 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);
|
||||
void ch438_interrupt_handler_ch438_chip_1(void);
|
||||
void ch438_interrupt_handler_ch438_chip_2(void);
|
||||
void ch438_interrupt_handler_data_ch438_chip_1(void);
|
||||
void ch438_interrupt_handler_data_ch438_chip_2(void);
|
||||
void ch438_init(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -9,7 +9,7 @@ ETH.RxBuffLen=1536
|
|||
ETH.RxMode=ETH_RXINTERRUPT_MODE
|
||||
FREERTOS.FootprintOK=true
|
||||
FREERTOS.IPParameters=Tasks01,configENABLE_FPU,configMAX_PRIORITIES,configMAX_TASK_NAME_LEN,FootprintOK,configTOTAL_HEAP_SIZE,configMINIMAL_STACK_SIZE
|
||||
FREERTOS.Tasks01=lwip_task,0,10000,start_lwip_task,Default,NULL,Dynamic,NULL,NULL;dac_task,0,512,start_dac_task,Default,NULL,Dynamic,NULL,NULL;ch438_task,0,512,start_ch438_task,Default,NULL,Dynamic,NULL,NULL
|
||||
FREERTOS.Tasks01=lwip_task,0,12040,start_lwip_task,Default,NULL,Dynamic,NULL,NULL;dac_task,0,512,start_dac_task,Default,NULL,Dynamic,NULL,NULL;ch438_task,0,512,start_ch438_task,Default,NULL,Dynamic,NULL,NULL
|
||||
FREERTOS.configENABLE_FPU=1
|
||||
FREERTOS.configMAX_PRIORITIES=32
|
||||
FREERTOS.configMAX_TASK_NAME_LEN=24
|
||||
|
@ -27,19 +27,22 @@ GPIO.groupedBy=Group By Peripherals
|
|||
KeepUserPlacement=false
|
||||
LWIP.BSP.number=1
|
||||
LWIP.GATEWAY_ADDRESS=192.168.001.222
|
||||
LWIP.IPParameters=LWIP_DHCP,IP_ADDRESS,NETMASK_ADDRESS,GATEWAY_ADDRESS,MEMP_NUM_TCP_PCB_LISTEN,MEMP_NUM_NETCONN,MEMP_NUM_RAW_PCB,MEMP_NUM_SELECT_CB,MEMP_NUM_REASSDATA,MEMP_NUM_TCP_PCB,MEMP_NUM_PBUF,MEMP_NUM_TCP_SEG,PBUF_POOL_BUFSIZE
|
||||
LWIP.IPParameters=LWIP_DHCP,IP_ADDRESS,NETMASK_ADDRESS,GATEWAY_ADDRESS,MEMP_NUM_TCP_PCB_LISTEN,MEMP_NUM_NETCONN,MEMP_NUM_RAW_PCB,MEMP_NUM_SELECT_CB,MEMP_NUM_REASSDATA,MEMP_NUM_TCP_PCB,MEMP_NUM_PBUF,MEMP_NUM_TCP_SEG,PBUF_POOL_BUFSIZE,PBUF_POOL_SIZE,MEM_SIZE,TCP_SND_QUEUELEN
|
||||
LWIP.IP_ADDRESS=192.168.001.029
|
||||
LWIP.LWIP_DHCP=0
|
||||
LWIP.MEMP_NUM_NETCONN=20
|
||||
LWIP.MEMP_NUM_PBUF=32
|
||||
LWIP.MEMP_NUM_PBUF=20
|
||||
LWIP.MEMP_NUM_RAW_PCB=20
|
||||
LWIP.MEMP_NUM_REASSDATA=5
|
||||
LWIP.MEMP_NUM_SELECT_CB=20
|
||||
LWIP.MEMP_NUM_TCP_PCB=20
|
||||
LWIP.MEMP_NUM_TCP_PCB_LISTEN=20
|
||||
LWIP.MEMP_NUM_TCP_SEG=32
|
||||
LWIP.MEM_SIZE=1024
|
||||
LWIP.NETMASK_ADDRESS=255.255.255.000
|
||||
LWIP.PBUF_POOL_BUFSIZE=1024
|
||||
LWIP.PBUF_POOL_BUFSIZE=512
|
||||
LWIP.PBUF_POOL_SIZE=24
|
||||
LWIP.TCP_SND_QUEUELEN=24
|
||||
LWIP.Version=v2.1.2_Cube
|
||||
LWIP0.BSP.STBoard=false
|
||||
LWIP0.BSP.api=BSP_COMPONENT_DRIVER
|
||||
|
@ -150,8 +153,9 @@ MxCube.Version=6.9.2
|
|||
MxDb.Version=DB.6.0.92
|
||||
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
|
||||
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
|
||||
NVIC.ETH_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true
|
||||
NVIC.EXTI2_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
|
||||
NVIC.ETH_IRQn=true\:6\:0\:true\:false\:true\:true\:false\:true\:true
|
||||
NVIC.EXTI15_10_IRQn=true\:6\:0\:true\:false\:true\:true\:true\:true\:true
|
||||
NVIC.EXTI2_IRQn=true\:6\:0\:true\:false\:true\:true\:true\:true\:true
|
||||
NVIC.ForceEnableDMAVector=true
|
||||
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
|
||||
NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
|
||||
|
|
Loading…
Reference in New Issue