⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mfcf31f.tmp

📁 STM32,5110液晶显示超声波测距探鱼器200KHz,带电路图,精确到厘米
💻 TMP
📖 第 1 页 / 共 2 页
字号:
					((struct_HMI_Draw_Para_Pic *)HMI_Draw_Para)->width);
		}

	}
	else
	{	// In this way, every row need to manipulate
		memcpy(tempRow, NULL, HMI_WIDTH_PIX);
		// First Row
		temp_i = tempStartRowIndex;
		for (temp_n = ((struct_HMI_Draw_Para_Pic *)HMI_Draw_Para)->startX; 
					temp_n < ((struct_HMI_Draw_Para_Pic *)HMI_Draw_Para)->startX + ((struct_HMI_Draw_Para_Pic *)HMI_Draw_Para)->width;
					temp_n++)
		{
			tempRow[temp_n] = GRAM_ByteOr(&(sta_LCD_Graphic_BUF[temp_i][temp_n]), 0, 
																		(const_HMI_Pic_Entr[((struct_HMI_Draw_Para_Pic *)HMI_Draw_Para)->picID])[temp_i][temp_n], tempRowRemain_Start);	
		}
		// Middle rows, if it has
		if (tempRowNUM != 0)
		{
			for (temp_i = tempStartRowIndex + 1; temp_i <= tempLastRowIndex; temp_i++)
			{
				for (temp_n = ((struct_HMI_Draw_Para_Pic *)HMI_Draw_Para)->startX; 
							temp_n < ((struct_HMI_Draw_Para_Pic *)HMI_Draw_Para)->startX + ((struct_HMI_Draw_Para_Pic *)HMI_Draw_Para)->width;
							temp_n++)
				{
					tempRow[temp_n] = GRAM_ByteOr(&(sta_LCD_Graphic_BUF[temp_i][temp_n]), tempRow[temp_n], 
																				(const_HMI_Pic_Entr[((struct_HMI_Draw_Para_Pic *)HMI_Draw_Para)->picID])[temp_i][temp_n], tempRowRemain_Start);	
				}		
			}
		}
		// Last Row, if it has
		if (tempRowRemain_End != 0)
		{
			for (temp_n = ((struct_HMI_Draw_Para_Pic *)HMI_Draw_Para)->startX; 
						temp_n < ((struct_HMI_Draw_Para_Pic *)HMI_Draw_Para)->startX + ((struct_HMI_Draw_Para_Pic *)HMI_Draw_Para)->width;
						temp_n++)
			{
				tempRow[temp_n] = GRAM_ByteOr(&(sta_LCD_Graphic_BUF[temp_i][temp_n]), tempRow[temp_n], 
																			(const_HMI_Pic_Entr[((struct_HMI_Draw_Para_Pic *)HMI_Draw_Para)->picID])[temp_i][temp_n], tempRowRemain_Start);	
			}
		}
	}
	
	HMI_Data_TX(sta_LCD_Graphic_BUF[0], MAX_DISPLAY_BUF);
	return FINISHED;
}

WorkingStatus HMI_Draw_Pic(void *HMI_Draw_Para)
{
	if (FINISHED == HMI_Draw_Pic_CMD(HMI_Draw_Para))
	{
		if (FINISHED == HMI_Draw_Pic_Data(HMI_Draw_Para))
		{
			return FINISHED;
		}
	}
	return FINISHED;
}

ErrorStatus HMI_Display_Blank(void)
{
	struct_HMI_Queue *foundQueueSlot;
		// Fill in the HMI to do list queue with configuration task 
	foundQueueSlot = HMI_Find_Queue_Slot(HMI_TASK_TYPE_BUS);
//	sta_QueueIndex = foundQueueSlot - gHMI_Queue;	// sta_QueueIndex should start at gHMI_Queue (0), but ...
	foundQueueSlot->HMI_Func_Para = malloc(sizeof(struct_HMI_CMD_Para));
	if (NULL != foundQueueSlot->HMI_Func_Para)
	{
		foundQueueSlot->HMI_Function_Index = ENUM_HMI_CMD_STREAM;
		((struct_HMI_CMD_Para *)(foundQueueSlot->HMI_Func_Para))->DataList = (uint8_t *)const_HMI_Display_Blank;
		((struct_HMI_CMD_Para *)(foundQueueSlot->HMI_Func_Para))->DataLen = sizeof(const_HMI_Display_Blank);	//HMI_STARTUP_CONFIG_LEN;
	}
	else
	{
		FLAG_HEAP_FULL = SET;
		return ERROR;
	}
	return SUCCESS;
}

ErrorStatus HMI_StartUp_Logo(void)
{
	struct_HMI_Queue *foundQueueSlot;
	// And finally a logo task
	foundQueueSlot = HMI_Find_Queue_Slot(HMI_TASK_TYPE_BUS);
	foundQueueSlot->HMI_Func_Para = malloc(sizeof(struct_HMI_Draw_Para_Pic));
	if (NULL != foundQueueSlot->HMI_Func_Para)
	{
		foundQueueSlot->HMI_Function_Index = ENUM_HMI_DRAW_PIC_DATA;
		((struct_HMI_Draw_Para_Pic *)(foundQueueSlot->HMI_Func_Para))->picID = HMI_STARTUP_LOGO_ID;
		((struct_HMI_Draw_Para_Pic *)(foundQueueSlot->HMI_Func_Para))->startX = 0;
		((struct_HMI_Draw_Para_Pic *)(foundQueueSlot->HMI_Func_Para))->startY = 0;
		((struct_HMI_Draw_Para_Pic *)(foundQueueSlot->HMI_Func_Para))->width = HMI_WIDTH_PIX;
		((struct_HMI_Draw_Para_Pic *)(foundQueueSlot->HMI_Func_Para))->height = HMI_HEIGHT_PIX;
	}
	else
	{
		FLAG_HEAP_FULL = SET;
		return ERROR;
	}
	return SUCCESS;
}

ErrorStatus HMI_StartUp_BL_Test(void)
{
	struct_HMI_Queue *foundQueueSlot;
	// Add back light blink test task
	foundQueueSlot = HMI_Find_Queue_Slot(HMI_TASK_TYPE_NO_BUS);
	foundQueueSlot->HMI_Func_Para = malloc(sizeof(struct_HMI_BL_Test));
	if (NULL != foundQueueSlot->HMI_Func_Para)
	{
		foundQueueSlot->HMI_Function_Index = ENUM_BL_TEST;
		((struct_HMI_BL_Test *)(foundQueueSlot->HMI_Func_Para))->Interval = MAX_BL_TEST_BLINK_INTER;
		HMI_BL_Test_Stage = 0;
	}
	else
	{
		FLAG_HEAP_FULL = SET;
		return ERROR;
	}
	return SUCCESS;
}


WorkingStatus HMI_BL_Test(void *HMI_Draw_Para)
{
	static uint32_t sta_LastTime;
	
	if (0 == HMI_BL_Test_Stage)
	{
		sta_LastTime = gSystem_1ms_CNT;
		GPIO_ResetBits(LCD_BACKLIGHT_PORT, LCD_BACKLIGHT_PIN);
		HMI_BL_Test_Stage++;
	}
	else
	{
		if (((uint32_t)(gSystem_1ms_CNT - sta_LastTime)) > MAX_BL_TEST_BLINK_INTER)
		{
			sta_LastTime = gSystem_1ms_CNT;
			if (LSB_MASK & HMI_BL_Test_Stage)
			{
				GPIO_SetBits(LCD_BACKLIGHT_PORT, LCD_BACKLIGHT_PIN);
			}
			else
			{
				GPIO_ResetBits(LCD_BACKLIGHT_PORT, LCD_BACKLIGHT_PIN);
			}
			HMI_BL_Test_Stage++;
		}
	}
	
	if (HMI_BL_Test_Stage > MAX_BL_TEST_BLINK_NUM)
	{
		GPIO_ResetBits(LCD_BACKLIGHT_PORT, LCD_BACKLIGHT_PIN);
		return FINISHED;
	}
	else
	{
		return WORKING;
	}
}

// The one end with ex will NOT clear GRAM in STM32
// One task
void ClearScreen(uint8_t style)
{
	memcpy(sta_LCD_Graphic_BUF[0], NULL, MAX_DISPLAY_BUF);
	HMI_Display_Blank();
}

void HMI_Initial(void)
{
	GPIO_InitTypeDef GPIO_InitStructure;
	uint8_t temp_QueueIndex;
	// Pull up RST Pin
	GPIO_SetBits(LCD_RST_PORT, LCD_RST_PIN);	
	// Empty the HMI to do list queue
	sta_QueueIndex = 0;
	sta_QueueIndex_NoBus = 0;
	Flag_HMI_General_G01 = 0;
	FLAG_HMI_QUEUE_FULL = RESET;
	for (temp_QueueIndex = 0; temp_QueueIndex < HMI_QUEUE_LEN; temp_QueueIndex++)
	{
		HMI_Queue_Slot_Free(gHMI_Queue + temp_QueueIndex);
	}
	
	for (temp_QueueIndex = 0; temp_QueueIndex < HMI_NO_BUS_QUEUE_LEN; temp_QueueIndex++)
	{
		HMI_Queue_Slot_Free(gHMI_Queue_NoBus + temp_QueueIndex);
	}

	HMI_StartUp_Config();
	HMI_StartUp_Logo();
	HMI_StartUp_BL_Test();
	
	// Return control to SPI
	GPIO_InitStructure.GPIO_Pin = LCD_MASTER_NSS_PIN;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
	GPIO_Init(LCD_MASTER_PORT, &GPIO_InitStructure);
	
		// Enter normal routine of executing the queue
	sta_HMI_StateMachine = HMI_STATE_EXE_QUEUE;

}

void HMI_Bus_Task_Executer(void)
{
	if (NULL != (*(gHMI_Queue + sta_QueueIndex)).HMI_Function_Index)
	{	// There is some task waiting for execution				
		// Execute them
		if (FINISHED == (*HMI_Function_Array[(*(gHMI_Queue + sta_QueueIndex)).HMI_Function_Index])((*(gHMI_Queue + sta_QueueIndex)).HMI_Func_Para))
		{
			// Release the data buffer pointed by Queue Pointer
			HMI_Queue_Slot_Free(gHMI_Queue + sta_QueueIndex);
	
			if (sta_QueueIndex < HMI_QUEUE_LEN)
			{
				sta_QueueIndex++;
			}
			else
			{
				sta_QueueIndex = 0;
			}
		}// Otherwise this function still need to be execute (eg. Not all data have been transfered)
	}
}

void HMI_NoBus_Task_Executer(void)
{
	if (NULL != (*(gHMI_Queue_NoBus + sta_QueueIndex_NoBus)).HMI_Function_Index)
	{	// There is some task waiting for execution				
		// Execute them
		if (FINISHED == (*HMI_Function_Array[(*(gHMI_Queue_NoBus + sta_QueueIndex_NoBus)).HMI_Function_Index])((*(gHMI_Queue_NoBus + sta_QueueIndex_NoBus)).HMI_Func_Para))
		{
			// Release the data buffer pointed by Queue Pointer
			HMI_Queue_Slot_Free(gHMI_Queue_NoBus + sta_QueueIndex_NoBus);
	
			if (sta_QueueIndex_NoBus < HMI_NO_BUS_QUEUE_LEN)
			{
				sta_QueueIndex_NoBus++;
			}
			else
			{
				sta_QueueIndex_NoBus = 0;
			}
		}// Otherwise this function still need to be execute (eg. Not all data have been transfered)
	}
}

void HMI_Error_Task_Handler(void)
{

}

void HMI_Manager()
{
	static uint32_t StartResetTime;
//	static uint8_t sta_HMI_Config_Stage = 0;
	static char *sta_SecretBuf4Error_Heap = "HEAP FULL";
	
	switch (sta_HMI_StateMachine)
	{
		case HMI_STATE_IDLE:
			if (SET == FLAG_HMI_START_RESET)
			{
				StartResetTime = gSystem_1ms_CNT;
				sta_HMI_StateMachine = HMI_STATE_RESETING;
			}
		break;

		case HMI_STATE_RESETING:
			if ((uint32_t)(gSystem_1ms_CNT - StartResetTime) > HMI_RESET_TIME)
			{
				//sta_HMI_Config_Stage = 0;
				sta_HMI_StateMachine = HMI_STATE_INITIAL;
			}

		break;

		case HMI_STATE_INITIAL:
			HMI_Initial();
		break;

	  case HMI_STATE_EXE_QUEUE:
			// Do NOT need DMA SPI to complete TX
			HMI_NoBus_Task_Executer();

			if ((SET == SPI_I2S_GetFlagStatus(LCD_MASTER_SPI, SPI_I2S_FLAG_TXE)) && 
			(RESET == SPI_I2S_GetFlagStatus(LCD_MASTER_SPI, SPI_I2S_FLAG_BSY)))
			{	// DMA and SPI is free
				if (0 != Flag_Global_Error)
				{	// There is some error
					if (FLAG_HMI_QUEUE_STATUS != FLAG_HMI_QUEUE_FULL )
					{	// Error hasn't been handled
						FLAG_HMI_QUEUE_STATUS = FLAG_HMI_QUEUE_FULL;
						if (SET == FLAG_HMI_QUEUE_FULL)
						{
							// Heap full, normally this means program problem
							HMI_Error_Task_Handler();

						}
						else
						{
							// Thanks god heap come back again

						}
					}
					else
					{	// Error has been handled, although it still there, but your have job to do
						HMI_Bus_Task_Executer();
					}
				}
				else
				{	// No error found
					HMI_Bus_Task_Executer();
				}
			}
		break;

		default :
		break;
	}

}


//void UARTSIM900_DMA_Init(void)
//{
//	DMA_InitTypeDef DMA_InitStructure;
//
//	RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
//
//	/* USART3_TX_DMA_Channel (triggered by USART3 TX event) Config */
//	DMA_DeInit(DMA1_Channel2);
//	DMA_InitStructure.DMA_PeripheralBaseAddr = SIMUART_DR;
//	DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)0x20012000;   // 96KB RAM => 0x20018000 top address
//	DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST;
//	DMA_InitStructure.DMA_BufferSize = 0x10;
//	DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
//	DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
//	DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
//	DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
//	DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;
//	DMA_InitStructure.DMA_Priority = DMA_Priority_VeryHigh;
//	DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
//	DMA_Init(DMA1_Channel2, &DMA_InitStructure);
//
//	DMA_ITConfig(DMA1_Channel2, DMA_IT_TC, ENABLE);
//}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -